import math, sys; sys.path.insert(0, '../../b5tools'); from rec import upsert; from snd import snd def rot(deg): r = deg * math.pi / 180; c, s = round(math.cos(r), 4), round(math.sin(r), 4) return [c, -s, s, c] def ways(n, isMirrored=False): """n turns evenly round; mirrored, they spiral the other way.""" return [[-m[0], m[1], -m[2], m[3]] if isMirrored else m for m in (rot(360 * i / n) for i in range(n))] TURN = 3 * 0.125 / 30 * 2 * math.pi # FUN_004830e0's turn of its ring a launch (every third tick). # FUN_004830e0's ten Swarm2 patterns (120 ticks each, i2 = random(10)), its loop being 20 frames. PATTERNS = [ [{"shot": "spiral", "on": "Start", "until": "Back", "every": 3, "speed": 12, "spread": round(TURN, 4), "fan": ways(5)}], [{"shot": "spiral", "on": "Start", "until": "Back", "every": 3, "speed": 12, "spread": round(TURN, 4), "fan": ways(5, True)}], # A 3-ring flying flat that bursts where it breaks (BURST). [{"shot": "ring", "on": "Start", "count": 3, "speed": 8, "fall_velocity": 0, "fall_acceleration": 0, "landing": [{"effect": "enemy_shots", "count": 4, "speed": 6}]}], [{"shot": "ring", "on": "Start", "count": 10, "speed": 9}], # Homing (SMART, 0.3) fans of 7 at 9 every eighth tick: at Isaac, swaying or jittered round him. [{"shot": "aimed", "on": "Start", "until": "Back", "every": 8, "count": 7, "spread": 0.4, "speed": 9, "homing": {}}], [{"shot": "aimed", "on": "Start", "until": "Back", "every": 8, "count": 7, "spread": 0.4, "speed": 9, "homing": {}, "direction_jitter": [0.1, 0.1]}], [{"shot": "aimed", "on": "Start", "until": "Back", "every": 8, "count": 7, "spread": 0.4, "speed": 9, "homing": {}, "direction_jitter": [0.16, 0.16]}], [{"shot": "aimed", "on": "Start", "until": "Back", "every": 8, "count": 7, "spread": 0.4, "speed": 9, "homing": {}, "fan": [[1, 0.2], [1, 0], [1, -0.2]]}], [{"shot": "aimed", "on": "Start", "until": "Back", "every": 13, "count": 8, "spread": 0, "speed": 9, "homing": {}}], [{"shot": "spiral", "on": "Start", "until": "Back", "every": 10, "speed": 9, "spread": round(10 * 0.125 / 30 * 2 * math.pi, 4), "fan": ways(3, True), "homing": {}}], ] FLY = {"spawn": ["attack_fly"], "spawn_on": "Start", "spawn_speed": 10, "spawn_cap": {"type": "attack_fly", "below": 4}} def loops(clip, isFlies): return [dict({"animation": clip, "rolled": False, "loop": {"at": "Back", "to": "Start", "count": 5}, "shots": pattern, "seek": 0.33, "retention": 0.5}, **(FLY if isFlies else {})) for pattern in PATTERNS] first = [ # 0-1 State 8: the explosive scatter (twelve boss shots, EXPLODE), flies in Phase 1. {"animation": "Charge", "rolled": False, "sounds": [snd(0x6c, "Start")], "next": 1}, {"animation": "Swarm", "rolled": False, "release": "Shoot", "shots": [{"shot": "boss_volley", "count": 12, "speed": 8, "scale": 0.8, "fall_velocity": -8, "fall_acceleration": 0.5, "landing": [{"effect": "explosion", "manned": True}]}], "sounds": [snd(0xb, "Shoot")], "cooldown": 60, "cooldown_random": [30, 1]}, # 2-3 State 10: Swarm2, then one of its ten patterns (4-13), at a third of its pace, then 14 Swarm2End. {"animation": "Charge", "rolled": False, "sounds": [snd(0x6a, "Start")], "next": 3}, {"animation": "Swarm2Start", "rolled": False, "next": list(range(4, 14))}, ] + loops("Swarm2Loop", True) for loop in first[4:]: loop["next"] = 14 first.append({"animation": "Swarm2End", "rolled": False, "cooldown": 60, "cooldown_random": [30, 1]}) DASH = ["HeadDashSide", "HeadDashDown", "HeadDashUp"] head = [ # 0-1 State 8: a large burst of 15 homing shots at Isaac. {"animation": "HeadCharge", "rolled": False, "sounds": [snd(0x6c, "Start")], "next": 1}, {"animation": "HeadShoot", "rolled": False, "release": "Shoot", "shots": [{"shot": "boss_volley", "count": 15, "speed": 9, "scale": 1.5, "homing": {}, "volley": {"aim_speed": 9, "aimed_spread": 3}}], "sounds": [snd(0xb, "Shoot")], "cooldown": 60, "cooldown_random": [30, 1]}, # 2-3 State 10: HeadShoot2, one of the patterns (4-13), then 14. {"animation": "HeadCharge", "rolled": False, "sounds": [snd(0x6a, "Start")], "next": 3}, {"animation": "HeadShoot2Start", "rolled": False, "next": list(range(4, 14))}, ] + loops("HeadShoot2Loop", False) for loop in head[4:]: loop["next"] = 14 head += [ {"animation": "HeadShoot2End", "rolled": False, "cooldown": 60, "cooldown_random": [30, 1]}, # 15-16 State 11: four brimstone beams, a quarter turn apart, held 60-89 ticks, turning a quarter either way. {"animation": "HeadCharge", "rolled": False, "sounds": [snd(0x6c, "Start")], "next": 16}, {"animation": "HeadShoot2Loop", "rolled": False, "loop": {"at": "Back", "to": "Start", "count": 2}, "laser": {"beams": [{"direction": d, "offset": [0, -30]} for d in ([1, 0], [0, 1], [-1, 0], [0, -1])], "player_damage": 1, "sweep": {"rate": 2, "random_sign": True, "delay": 15, "delay_random": 29, "bounce": 90}, "sounds": ["blood_laser_large.mp3"], "sound_period": 30}, "next": 14}, # 17 State 9: lined up with Isaac within 20, a dash to the room's edge (7.5, 10 or 12 fast). {"animation": "HeadDashSide", "period": 1, "one_in": 1, "line": {"axis": "row", "within": 20}, "directional_poses": DASH, "charge_speed": 10, "on_wall": "end", "repeat": {"limit": 20}, "retention": 1, "sounds": [snd(0x77, "Start")], "cooldown": 20}, {"animation": "HeadDashSide", "period": 1, "one_in": 1, "line": {"axis": "column", "within": 20}, "directional_poses": DASH, "charge_speed": 10, "on_wall": "end", "repeat": {"limit": 20}, "retention": 1, "sounds": [snd(0x77, "Start")], "cooldown": 20}, ] SPLIT = {"animation": "Death", "rolled": False, "release": "Explosion", "spawn": ["lamb_body"], "spawn_offset": 0, "count": 1, "untouchable": {"from": "Start", "to": "Explosion"}, "sounds": [snd(0x7a, "Start")], "cooldown": 30} upsert({"key": "the_lamb", "name": "The Lamb", "flash_id": 27300000, "hp": 2000, "mass": 45, "radius": 13, "contact_damage": 1, "explosion_response": {"manned_damage": 0}, "gibs": {"large": True}, "grid_collision": False, "floor_hazards": {"flight": "flying"}, "behavior": {"kind": "scripted", "move": "hover", "flying": True, "speed": 1, "retention": 0.5, "idle_pose": "Idle", "spawn_clip": {"animation": "Appear"}, "attacks": first, "first_cooldown": [60, 30], # Every 60-89 idle ticks: state 8 or 10, alike. "choice": {"one_in": 1, "options": [0, 2]}, # At half health the body drops away (lamb_body) and the head goes on alone: HeadShoot, HeadShoot2 # and the beams a quarter each, else a dash when lined up. "phases": [{"when": [{"hp_share_below": 0.5}], "attack": 19, "patch": {"idle_pose": "HeadIdle", "attacks": head + [SPLIT], "choice": {"one_in": 1, "options": [0, 2, 15, 17, 18]}}}]}, "death": {"animation": "Death"}, "death_burst": {"boss_sounds": ["rocket_blast_death_1.mp3"], "frames": "Explosion"}, "art": "gfx/bosses/the_lamb/the_lamb.anm2"})