import copy, json, 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): 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))] def fan(n, width): return [[round(math.cos(math.radians(a)), 4), round(math.sin(math.radians(a)), 4)] for a in (width * (i / (n - 1) - 0.5) for i in range(n))] YELLOW, BLUE, GREEN = [1, 1, 0.3, 0.3, 0.3, 0], [0.4, 0.6, 1, 0, 0.1, 0.4], [0.4, 1, 0.4, 0, 0.3, 0] BEAM = {"art": {"anm2": "gfx/effects/light_beam/light_beam.anm2", "animation": "Beam", "scale": 1, "offset_y": 0}, "strike": ["StrikeStart", "StrikeEnd"], "period": 3, "radius": 30, "enemy_damage": 0, "player_damage": 1, "friendly": False, "wave": {"spacing": 40, "period": 4, "steps": 12}} # Phase 2-1's barrage patterns (combined one to three a barrage), each a 13-tick Scream loop's shots. BASIC = [ [{"shot": "ring", "on": "Start", "count": 12, "speed": 6, "curve": 0.03, "curve_alternate": True, "tint": YELLOW}], [{"shot": "aimed", "on": "Start", "speed": 8, "fan": fan(7, 70), "tint": BLUE}], [{"shot": "aimed", "on": "Start", "until": "Back", "every": 3, "speed": 6, "speed_scale": 1.03, "speed_limit": 12, "tint": YELLOW}, {"shot": "aimed", "on": "Start", "until": "Back", "every": 3, "speed": 10, "speed_scale": 0.97, "speed_limit": 4, "tint": BLUE}], [{"shot": "spiral", "on": "Start", "until": "Back", "every": 4, "speed": 7, "spread": 0.3, "fan": ways(4), "tint": GREEN}], ] # Phase 2-2 adds a dense ring and slowing spirals; 2-3 a wide closing spread. DENSE = [[{"shot": "ring", "on": "Start", "count": 28, "speed": 5, "tint": GREEN}], [{"shot": "spiral", "on": "Start", "until": "Back", "every": 3, "speed": 9, "spread": 0.25, "fan": ways(4, True), "speed_scale": 0.95, "speed_limit": 3, "tint": BLUE}]] CLOSING = [[{"shot": "aimed", "on": "Start", "speed": 7, "fan": fan(15, 160), "curve": 0.01, "curve_alternate": True, "tint": YELLOW}]] def barrage(patterns): """Tell1, then the face's screams (a pattern each), the barrage.""" return [{"animation": "Scream", "rolled": False, "loop": {"at": "Back", "to": "Start", "count": 2}, "shots": shots, "sounds": [snd(0x1a5, "Start")], "cooldown": 40} for shots in patterns] def attacks(stage): out = barrage(BASIC + (DENSE if 1 <= stage < 3 else []) + (CLOSING if stage == 2 else [])) if 1 <= stage <= 3: # Hush Flies, launched or circling. out.append({"animation": "SpawnFlies", "rolled": False, "release": "Start", "spawn": ["hush_fly"], "count": 6, "spawn_offset": 60, "spawn_cap": {"type": "hush_fly", "below": 12}, "sounds": [snd(0x1a6, "Start")], "cooldown": 40}) if stage >= 2: # A horde of Blue Gapers; three rows of shots down one way, 2-5 times. out.append({"animation": "OpenMouth", "rolled": False, "release": "SkinPull", "spawn": ["blue_gaper"], "count": 5, "spawn_offset": 80, "spawn_cap": {"type": "blue_gaper", "below": 10}, "sounds": [snd(0x1a7, "SkinPull")], "next": len(out) + 1}) out.append({"animation": "CloseMouth", "rolled": False, "cooldown": 30}) out.append({"animation": "AttackLoopDown", "rolled": False, "directional_poses": ["AttackLoopLeft", "AttackLoopDown", "AttackLoopUp", "AttackLoopRight"], "loop": {"at": "Back", "to": "Start", "count": 8}, "shots": [{"shot": "aimed", "on": "Start", "speed": 4, "speed_scale": 1.02, "speed_limit": 9, "fan": [[1, -0.35], [1, 0], [1, 0.35]], "tint": BLUE}], "cooldown": 30}) if stage >= 3: # Three large red shots splitting in threes. out.append({"animation": "Puffed", "rolled": False, "release": "Start", "shots": [{"shot": "aimed", "speed": 9, "fan": fan(3, 120), "scale": 2.5, "speed_scale": 0.96, "speed_limit": 1, "fall_velocity": -4, "fall_acceleration": 0.06, "landing": [{"effect": "enemy_shots", "count": 3, "speed": 9}]}], "sounds": [snd(0x1a6, "Start")], "cooldown": 40}) if stage >= 4: # Eye lasers up, ground beams marching at Isaac, five slow lines out. out.append({"animation": "LaserStart", "rolled": False, "sounds": [snd(0x1a9, "Start")], "next": len(out) + 1}) out.append({"animation": "LaserLoop", "rolled": False, "release": "Start", "loop": {"at": "Back", "to": "Start", "count": 6}, "effects": [{"effect": "bolts", "directions": "player", "offset": 60, "bolt": BEAM}], "creep": {"from": "Start", "to": "Start", "spread": 0, "growth": 0, "scale": 1.5, "color": BLUE, "slippery": True}, "shots": [{"shot": "spiral", "on": "Start", "speed": 3, "spread": 0.2, "fan": ways(5), "tint": BLUE}], "next": len(out) + 2}) out.append({"animation": "LaserEnd", "rolled": False, "cooldown": 40}) return out # Each 20% of health lost: it sinks, out of reach, and comes up again (in Phase 2-2 at the room's centre). SINK = [{"animation": "TurnConcave", "rolled": False, "untouchable": {"from": "Start", "to": "End"}, "sounds": [snd(0x1a6, "Start")], "next": 1}, {"animation": "Concave", "rolled": False, "untouchable": {"from": "Start", "to": "Back"}, "loop": {"at": "Back", "to": "Start", "count": 45}, "next": 2}, {"animation": "BecomeConvex", "rolled": False, "untouchable": {"from": "Start", "to": "PopOut"}, "cooldown": 30}] def stage_rules(stage): body = attacks(stage) options = list(range(len(body))) return {"idle_pose": "Wiggle", "attacks": body + SINK, "choice": {"one_in": 25, "options": options}} first = stage_rules(0) upsert({"key": "hush", "name": "Hush", "flash_id": 40700000, "hp": 6666, "mass": 1000, "radius": 100, "contact_damage": 0.5, "gibs": {"count": 0}, "behavior": dict(first, kind="scripted", move="anchor", spawn_clip={"animation": "Appear"}, phases=[{"when": [{"hp_share_below": share, "idle": True}], "attack": len(stage_rules(n)["attacks"]) - 3, "patch": stage_rules(n)} for n, share in ((1, 0.8), (2, 0.6), (3, 0.4), (4, 0.2))]), "death": {"animation": "Death"}, "death_burst": {"boss_sounds": ["rocket_blast_death_1.mp3"], "frames": "ash"}, "art": "gfx/bosses/hush/hush.anm2"}) # Hush's opening: ??? as Flash's (the isaac controller, altboss 2), at half ???'s health, Hush rising where it falls. base = next(e for e in json.load(open('resources/data/entities.json'))['entities'] if e['key'] == 'isaac') behavior = copy.deepcopy(base['behavior']) behavior.pop('eternal', None) upsert({"key": "blue_baby_alt", "name": "??? (Hush)", "flash_id": 10200200, "hp": 500, "mass": 100, "radius": 25, "hp_multiplier": 2, "contact_damage": 0.5, "grid_collision": False, "explosion_response": {"impulse_scale": 0.015}, "variants": {"boss_variant": True}, "symbol_type": 102, "behavior": behavior, "death": {"animation": "Death"}, "gibs": {"count": 0}, "death_spawn": {"overkill_limit": 1000000, "count": 1, "crowd_scale": 0, "count_step": 1, "radius": 0, "pool": [{"create_type": "hush", "weight": 1}]}, "art": {"anm2": "gfx/bosses/isaac/isaac.anm2", "forms": {"1": "gfx/bosses/blue_baby/blue_baby.anm2"}}})