#include "boss_ai.h" #include "entity_bomb.h" #include "entity_config.h" #include "entity_laser.h" #include "grid_entity_trap_door.h" #include "manager.h" #include "music_manager.h" #include "npc_caves.h" #include "room_grid.h" #include "sfx_manager.h" #include #include #include // Satan's phases (his i1): the statue, waiting while the Fallen fights, the fight, his death, and the feet he leaves. enum SatanPhase { SATAN_STATUE, SATAN_AWAKENING, SATAN_FIGHT, SATAN_DYING, SATAN_FEET }; // His attacks (states): a spread of shots, a brimstone beam straight down, two sweeping beams, and two shot fans. enum SatanAttack { SATAN_SPREAD = NPC_STATE_ATTACK, SATAN_BEAM = NPC_STATE_ATTACK2, SATAN_SWEEP = NPC_STATE_ATTACK3, SATAN_FANS = NPC_STATE_ATTACK4 }; constexpr int SATAN_FEET_VARIANT = 10; constexpr float SATAN_FRICTION = 0.8f; constexpr int KAMIKAZE_LEECH = 1; // The statue sinks 80 into the floor, blocks its cell's path and wakes 130 frames in, calling the Fallen and two // kamikaze leeches 30 below it (50 to each side). Satan rises 25 frames after he is the last enemy left. constexpr float SATAN_STATUE_SINK = 80; constexpr int STATUE_PATH_BLOCKED = 2000; constexpr int STATUE_PATH_AWAKE = 1000; constexpr int STATUE_SOUND_FRAME = 2; constexpr int STATUE_WAKE_FRAMES = 130; constexpr float SUMMON_DROP = 30; constexpr float LEECH_SPREAD = 50; constexpr int RISE_FRAME = 25; constexpr float BOSS_MUSIC_FADE = 0.08f; // The fight: Satan keeps below y 245 and 120 from the side walls, walks toward a spot 60 above his target (93% of its // height, at least 305), leading it by 25 frames of its speed, and steps at most 15 across and 7 down a frame. constexpr float FIGHT_TOP = 245; constexpr float WALK_TARGET_SCALE = 0.93f; constexpr float WALK_TARGET_MIN = 305; constexpr float WALK_TARGET_RISE = 60; constexpr float WALK_LEAD_FRAMES = 25; constexpr float WALK_STEP_X = 15; constexpr float WALK_STEP_Y = 7; constexpr float WALK_ACCEL = 0.1f; constexpr float SIDE_MARGIN = 120; // The attack choices: a beam when the target crosses beneath him (above 70 over his aim), one roll in 15 for a spread // (3 in 10) or the fans, and the sweep for a target 40 to 200 to the side. constexpr float BEAM_REACH_UP = -70; constexpr int BEAM_REPEAT_ODDS = 10; constexpr float SWEEP_REPEAT_REACH = 40; constexpr int SWEEP_REPEAT_ODDS = 3; constexpr int SHOT_ODDS = 15; constexpr int SPREAD_ODDS = 10; constexpr int SPREAD_IN_TEN = 3; constexpr int ATTACK_ODDS = 3; constexpr float WALK_ONLY_REACH = 100; constexpr float SWEEP_REACH_MIN = 40; constexpr float SWEEP_LEAD_MAX = 200; // The spread: big shots aimed 5 frames ahead, five (four on Shoot2) at 8.2 (10 past 300) times 0.85, again from frame // 10 unless the target is 300 away or one roll in 3. constexpr float SPREAD_LEAD_FRAMES = 5; constexpr float SPREAD_SCALE = 1.4f; constexpr float SPREAD_SPREAD = 1.15f; constexpr float SPREAD_FALL_ACCEL = -0.07f; constexpr float SPREAD_HEIGHT = -40; constexpr float SPREAD_FALL_SPEED = 5.5f; constexpr float SPREAD_FAR = 300; constexpr float SPREAD_SPEED = 8.2f; constexpr float SPREAD_SPEED_FAR = 10; constexpr float SPREAD_SPEED_SCALE = 0.85f; constexpr float SPREAD_REPEAT_FRAME = 10; // The beams: a straight one 60 above him for 16 frames, 1.2 wide, and two that sweep 1.5 a frame from 40 to each side // of straight down, 100 out, for 14 frames. He shakes 10 (5 for the sweeps and fans) while they fire. constexpr float SATAN_BEAM_RISE = 60; constexpr float BEAM_ANGLE = 90; constexpr int SATAN_BEAM_TIMEOUT = 16; constexpr float BEAM_SCALE = 1.2f; constexpr float SATAN_BEAM_DEPTH = 3000; constexpr float BEAM_RECOIL = 5; constexpr float BEAM_SHAKE = 10; constexpr float SWEEP_SHAKE = 5; constexpr int SATAN_SWEEP_TIMEOUT = 14; constexpr float SWEEP_REACH = 100; constexpr float SWEEP_ROTATION = 40; constexpr float SATAN_SWEEP_SPEED = 1.5f; constexpr float SWEEP_ANGLE_LEFT = 120; constexpr float SWEEP_ANGLE_RIGHT = 60; constexpr float SWEEP_RECOIL = 2.5f; // The fans: a ring each side, 100 out, of shots kept within their side's half turn. constexpr float FAN_REACH = 100; constexpr float FAN_HEIGHT = -40; constexpr float FAN_FALL_SPEED = 2.5f; constexpr float FAN_DOT_LIMIT = -0.38f; static const Vector FAN_VELOCITY = vector_make(7.5f, 14); // His death: grey dust and a shake at Shoot, three red bursts about him at Shoot2, then the feet take over. constexpr ColorMod DEATH_DUST_COLOR = {{0.52f, 0.52f, 0.52f, 0.8f}, {0, 0, 0, 0}, {0, 0, 0}}; constexpr ColorMod DEATH_BURST_COLOR = {{1, 0.05f, 0.05f, 0.8f}, {0, 0, 0, 0}, {0, 0, 0}}; constexpr int DEATH_SHAKE = 12; constexpr int DEATH_BURST_SIZE = 2; constexpr float DEATH_BURST_REACH = 10; static const std::array DEATH_BURSTS = {vector_make(-40, -10), vector_make(40, -10), vector_make(0, 10)}; // The feet: hidden, each rolls one in 9 to stomp on its target, unless the other lifted less than 21 frames ago, kept // 111 from it. A stomp crushes 300 within 70 and ripples the room, and with fewer than 4 enemies one roll in 2 calls a // leech 200 out. A foot's death kills the other and hurts every enemy left by 100. constexpr int SATAN_STOMP_ODDS = 9; constexpr int STOMP_SETTLE_FRAMES = 21; constexpr float FEET_SPACING = 111; constexpr int STOMP_LEECH_CROWD = 4; constexpr float STOMP_LEECH_REACH = 200; constexpr float SATAN_STOMP_DAMAGE = 300; constexpr float SATAN_STOMP_RADIUS = 70; constexpr float SATAN_STOMP_RIPPLE_AMPLITUDE = 0.04f; constexpr float SATAN_STOMP_RIPPLE_SPEED = 0.025f; constexpr int SATAN_STOMP_RIPPLE_FRAMES = 13; constexpr ColorMod SATAN_STOMP_DUST_COLOR = {{0.62f, 0.62f, 0.62f, 0.8f}, {0, 0, 0, 0}, {0, 0, 0}}; constexpr float FEET_DEATH_DAMAGE = 100; constexpr int FEET_DEATH_COUNTDOWN = 30; // 007ebc40 Crossfades to the room's boss track as a boss fight starts. void boss_music_crossfade() { g_manager->musicManager.Crossfade(g_game->room->boss_music_get(), BOSS_MUSIC_FADE); } // Explosions and crushes neither a player nor a familiar set off pass Satan by, his feet's stomps among them. static void stray_blasts_ignore(Entity_NPC& npc) { if (npc.pendingDamage <= 0) return; for (DamageEvent& event : npc.damageEvents) { bool isBlast = event.damageFlags & (DAMAGE_EXPLOSION | DAMAGE_CRUSH); bool isPlayers = event.source.type == ENTITY_PLAYER || event.source.spawnerType == ENTITY_PLAYER || event.source.spawnerType == ENTITY_FAMILIAR; if (!isBlast || isPlayers) continue; npc.pendingDamage -= event.damage; event.damage = 0; } } // A blow that would kill him mid fight starts his death instead, at no health. static void death_start(Entity_NPC& npc) { npc.damageEvents.clear(); npc.pendingDamage = 0; npc.pendingDamageFlags = 0; npc.stateFrame = 0; npc.health = 0; npc.state = NPC_STATE_MOVE; npc.isDead = false; npc.i1 = SATAN_DYING; npc_sound_play(SOUND_SATAN_HURT, 1, 2, champion_pitch_get(npc)); npc_anim_restart(npc.sprite, "Death"); npc.RemoveStatusEffects(); } // The first update: Satan sinks into his statue with no health to hurt, a foot hides with a stomp's sound. static void satan_init(Entity_NPC& npc) { npc.state = NPC_STATE_IDLE; npc.entityCollisionClass = ENTCOLL_NONE; if (npc.variant != SATAN_FEET_VARIANT) { npc.ClearEntityFlags(FLAG_APPEAR); npc.maxHitPoints = 0; npc.health = 0; npc.damageEvents.clear(); npc.pendingDamage = 0; npc.pendingDamageFlags = 0; npc.shadowSize = 0; npc.pos.y += SATAN_STATUE_SINK; npc.targetPosition = npc.pos; return; } npc_sound_play(SOUND_SATAN_STOMP, 1, 4, champion_pitch_get(npc)); npc.i1 = SATAN_FEET; npc.stateFrame = 0; npc.isVisible = false; npc.shadowSize = 0; } // Spawns an entity from Satan and runs its first update at once. static void summon(Entity_NPC& npc, int type, int variant, Vector offset) { Entity* entity = g_game->Spawn({.position = vector_add(npc.pos, offset), .spawner = &npc, .type = type, .variant = variant, .seed = Random()}); entity->Update(); } // The statue: it blocks its cell, then wakes with a blast, calls the Fallen and two leeches and starts the boss music. static void statue_update(Entity_NPC& npc, int ticks, int gridIndex) { npc.entityGridCollisionClass = GRIDCOLL_NONE; Room& room = *g_game->room; if (gridIndex >= 0) room.gridPaths[gridIndex] = STATUE_PATH_BLOCKED; for (; ticks > 0; ticks--) if (++npc.stateFrame == STATUE_SOUND_FRAME) npc_sound_play(SOUND_SATAN_APPEAR, 1, 2, champion_pitch_get(npc)); if (npc.stateFrame > STATUE_WAKE_FRAMES) { npc_sound_play(SOUND_SATAN_BLAST, 1, 2, champion_pitch_get(npc)); npc_sound_play(SOUND_SUMMONSOUND, 2, 2, champion_pitch_get(npc)); npc.stateFrame = 0; npc.i1++; summon(npc, ENTITY_FALLEN, 0, vector_make(0, SUMMON_DROP)); summon(npc, ENTITY_LEECH, KAMIKAZE_LEECH, vector_make(LEECH_SPREAD, SUMMON_DROP)); summon(npc, ENTITY_LEECH, KAMIKAZE_LEECH, vector_make(-LEECH_SPREAD, SUMMON_DROP)); boss_music_crossfade(); } const AnimationData* anim = npc.sprite.animState.animData; bool isIdleDone = anim && !npc.sprite.animState.isPlaying && anim->name == "SmallIdle" && !anim->isLooping; if (!anim || (!npc.sprite.animState.isPlaying && !isIdleDone)) npc_anim_restart(npc.sprite, "SmallIdle"); npc.pos = npc.targetPosition; npc.AddEntityFlags(FLAG_NO_PHYSICS_KNOCKBACK); } // Waiting: once Satan is the last enemy he takes his full health, rises with his own music and joins the fight. static void awakening_update(Entity_NPC& npc, int ticks, int gridIndex) { Room& room = *g_game->room; if (gridIndex >= 0) room.gridPaths[gridIndex] = STATUE_PATH_AWAKE; if (room.GetAliveEnemiesCount() == 1) { for (; ticks > 0; ticks--) { if (++npc.stateFrame != RISE_FRAME) continue; room.entityList.bossMaxHealth = 0; npc.maxHitPoints = npc.config->baseHP; npc.health = npc.maxHitPoints; npc_sound_play(SOUND_SATAN_RISE_UP, 1, 2, champion_pitch_get(npc)); npc_anim_restart(npc.sprite, "Change"); npc.shadowSize = npc.config->shadowSize; g_manager->musicManager.Crossfade(MUSIC_SATAN_BOSS, BOSS_MUSIC_FADE); } if (npc.sprite.IsEventTriggered("Shoot")) npc.PlaySound(SOUND_SATAN_BLAST, 1, 2, false, 1); if (npc.stateFrame > RISE_FRAME && npc_anim_is_done(npc)) { npc.i1++; npc.state = NPC_STATE_MOVE; npc.stateFrame = 0; if (gridIndex >= 0) room.gridPaths[gridIndex] = 0; npc.ClearEntityFlags(FLAG_NO_PHYSICS_KNOCKBACK); } } npc.pos = npc.targetPosition; } // Picks a shot attack: a spread three times in ten, else the fans. static const char* shot_attack_pick(Entity_NPC& npc) { npc.stateFrame = 0; bool isSpread = Random() % SPREAD_ODDS < SPREAD_IN_TEN; npc.state = isSpread ? SATAN_SPREAD : SATAN_FANS; npc.i2 = npc.state; return isSpread ? "Attack01" : "Attack03"; } // Walking after the target, and choosing the next attack: the beam when it crosses beneath, now and then a shot attack // (never twice running), else the sweep when it is near enough to the side, else closing in. static void walk_update(Entity_NPC& npc, Entity& target) { npc.sprite.Play("Walk"); float aimY = std::max(target.pos.y * WALK_TARGET_SCALE, WALK_TARGET_MIN); float leadX = target.velocity.x * 2 * WALK_LEAD_FRAMES + target.pos.x - npc.pos.x; float dx = target.pos.x - npc.pos.x; float dy = aimY - npc.pos.y - WALK_TARGET_RISE; const char* anim = nullptr; bool isBeam = (leadX * dx < 0 && dy > BEAM_REACH_UP && (npc.i2 != SATAN_BEAM || Random() % BEAM_REPEAT_ODDS == 0)) || (npc.i2 == SATAN_SWEEP && std::abs(dx) < SWEEP_REPEAT_REACH && Random() % SWEEP_REPEAT_ODDS == 0); if (isBeam) { npc.PlaySound(SOUND_SATAN_CHARGE_UP, 1, 2, false, 1); npc.stateFrame = 0; npc.state = SATAN_BEAM; npc.i2 = SATAN_BEAM; anim = "Attack02"; } else if (Random() % SHOT_ODDS == 0) anim = shot_attack_pick(npc); else if (Random() % ATTACK_ODDS == 0 && npc.i2 != SATAN_SPREAD && npc.i2 != SATAN_FANS) anim = shot_attack_pick(npc); else if (std::abs(dx) > WALK_ONLY_REACH || dy < 0) npc_push(npc, vector_make(std::clamp(dx, -WALK_STEP_X, WALK_STEP_X) * WALK_ACCEL, std::clamp(dy, -WALK_STEP_Y, WALK_STEP_Y) * WALK_ACCEL)); else if (std::abs(dx) > SWEEP_REACH_MIN && std::abs(leadX) < SWEEP_LEAD_MAX) { npc.PlaySound(SOUND_SATAN_CHARGE_UP, 1, 2, false, 1); npc.stateFrame = 0; npc.state = SATAN_SWEEP; npc.i2 = SATAN_SWEEP; anim = "Attack03"; } if (anim) npc_anim_restart(npc.sprite, anim); Vector next = g_game->room->GetClampedPositionImpl(vector_add(npc.pos, npc.velocity), 0, SIDE_MARGIN, 0, SIDE_MARGIN); npc.velocity = vector_sub(next, npc.pos); } // The spread: shots at the target's lead on Shoot and Shoot2, repeated from frame 10 while it stays near. static void spread_update(Entity_NPC& npc, Entity& target) { Vector lead = vector_make(target.velocity.x * 2 * SPREAD_LEAD_FRAMES + target.pos.x - npc.pos.x, target.velocity.y * 2 * SPREAD_LEAD_FRAMES + target.pos.y - npc.pos.y); if (npc_anim_is_done(npc)) { if (vector_length(lead) >= SPREAD_FAR || Random() % ATTACK_ODDS == 0) npc.state = NPC_STATE_MOVE; else { npc_anim_restart(npc.sprite, "Attack01"); if (npc.sprite.animState.animData) npc.sprite.animState.SetFrameFloat(SPREAD_REPEAT_FRAME); } } bool isShoot2 = npc.sprite.IsEventTriggered("Shoot2"); if (!npc.sprite.IsEventTriggered("Shoot") && !isShoot2) return; ProjectileParams params; params.scale = SPREAD_SCALE; params.spread = SPREAD_SPREAD; params.fallingAccelModifier = SPREAD_FALL_ACCEL; npc.PlaySound(SOUND_SATAN_SPIT, 1, 2, false, 1); if (!isShoot2) { params.heightModifier = SPREAD_HEIGHT; params.fallingSpeedModifier = SPREAD_FALL_SPEED; } float speed = (vector_length(lead) <= SPREAD_FAR ? SPREAD_SPEED : SPREAD_SPEED_FAR) * SPREAD_SPEED_SCALE; npc.FireProjectiles(npc.pos, vector_scale(vector_normalized(lead), speed), isShoot2 ? PROJECTILES_FOUR : PROJECTILES_FIVE, params); } // Satan shakes from side to side between an attack's Shoot and Shoot2, on frames he updates. static void attack_shake(Entity_NPC& npc, int ticks, float shake) { if (!npc.sprite.WasEventTriggered("Shoot") || npc.sprite.WasEventTriggered("Shoot2") || ticks <= 0) return; npc.pos.x += (int)npc.updateTime % 2 == 1 ? shake : -shake; } // A brimstone beam of Satan's from a spot, at an angle, drawn over the room. static Entity_Laser* beam_fire(Entity_NPC& npc, Vector from, float angle, int timeout) { Entity_Laser* laser = Entity_Laser::ShootAngle( {.position = from, .source = &npc, .angleDegrees = angle, .timeout = timeout, .variant = LASER_THICK_RED}); laser->renderDepthOffset = SATAN_BEAM_DEPTH; return laser; } // The beam straight down from his mouth. static void beam_update(Entity_NPC& npc, int ticks) { if (npc.sprite.IsEventTriggered("Shoot")) { Entity_Laser* laser = beam_fire(npc, vector_make(npc.pos.x, npc.pos.y - SATAN_BEAM_RISE), BEAM_ANGLE, SATAN_BEAM_TIMEOUT); laser->scale = BEAM_SCALE; laser->ResetSpriteScale(); laser->Update(); npc.pos.x -= BEAM_RECOIL; } attack_shake(npc, ticks, BEAM_SHAKE); } // The two sweeping beams, 100 to each side, turning toward each other. static void sweep_update(Entity_NPC& npc, int ticks) { if (!npc.sprite.IsEventTriggered("Shoot")) return attack_shake(npc, ticks, SWEEP_SHAKE); for (int side = -1; side <= 1; side += 2) { float angle = side < 0 ? SWEEP_ANGLE_LEFT : SWEEP_ANGLE_RIGHT; Vector from = vector_make(npc.pos.x + side * SWEEP_REACH, npc.pos.y - SATAN_BEAM_RISE); Entity_Laser* laser = beam_fire(npc, from, angle, SATAN_SWEEP_TIMEOUT); laser->rotationDegrees = side * SWEEP_ROTATION; laser->isActiveRotating = true; laser->rotationDelay = 0; laser->rotationSpd = side * SATAN_SWEEP_SPEED; laser->Update(); npc.pos.x -= SWEEP_RECOIL; } } // The two fans of shots, 100 to each side, each kept to its own side. static void fans_update(Entity_NPC& npc, int ticks) { if (!npc.sprite.IsEventTriggered("Shoot")) return attack_shake(npc, ticks, SWEEP_SHAKE); npc.PlaySound(SOUND_SATAN_SPIT, 1, 2, false, 1); for (int side = -1; side <= 1; side += 2) { ProjectileParams params; params.fireDirectionLimit = vector_make((float)side, 0); params.scale = SPREAD_SCALE; params.heightModifier = FAN_HEIGHT; params.fallingSpeedModifier = FAN_FALL_SPEED; params.dotProductLimit = FAN_DOT_LIMIT; npc.FireProjectiles(vector_make(npc.pos.x + side * FAN_REACH, npc.pos.y), FAN_VELOCITY, PROJECTILES_RING, params); npc.pos.x -= SWEEP_RECOIL; } } // The fight: solid and kept low in the room, he walks and attacks, walking again when an attack's animation ends. static void fight_update(Entity_NPC& npc, int ticks) { npc.renderZOffset = 0; npc.entityCollisionClass = ENTCOLL_ALL; npc.entityGridCollisionClass = GRIDCOLL_WALLS_X; npc.pos.y = std::max(npc.pos.y, FIGHT_TOP); Entity& target = *npc.GetPlayerTarget(); switch (npc.state) { case NPC_STATE_MOVE: return walk_update(npc, target); case SATAN_SPREAD: return spread_update(npc, target); case SATAN_BEAM: beam_update(npc, ticks); break; case SATAN_SWEEP: sweep_update(npc, ticks); break; case SATAN_FANS: fans_update(npc, ticks); break; default: return; } if (npc_anim_is_done(npc)) npc.state = NPC_STATE_MOVE; } // His death: he bleeds and bursts as it plays, then leaves two feet tied to each other and is gone. static void dying_update(Entity_NPC& npc) { npc.stateFrame++; npc.entityCollisionClass = ENTCOLL_NONE; npc.isInvincible = true; ANM2& sprite = npc.sprite; if (sprite.animState.animData) if (const NullFrame* guide = sprite.animState.GetNullFrame("BloodGuide")) npc.update_blood_guide_gibs(*guide); if (sprite.animState.animData) { if (sprite.IsEventTriggered("Sound")) npc.PlaySound(SOUND_SATAN_GROW, 1, 2, false, 1); if (sprite.IsEventTriggered("Shoot")) { npc.MakeGroundPoof(npc.pos, DEATH_DUST_COLOR, 1); game_shake_screen(DEATH_SHAKE); } if (sprite.IsEventTriggered("Shoot2")) for (const Vector& spot : DEATH_BURSTS) { float angle = random_unit() * PI_ROUGH * 2; uint32_t seed = Random(); Vector position = vector_make(std::cos(angle) * DEATH_BURST_REACH + spot.x + npc.pos.x, std::sin(angle) * DEATH_BURST_REACH + spot.y + npc.pos.y); Entity* burst = g_game->Spawn({.position = position, .spawner = &npc, .subType = DEATH_BURST_SIZE, .type = ENTITY_EFFECT, .variant = EFFECT_POOF02, .seed = seed}); burst->SetColor(DEATH_BURST_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true); burst->sprite.isFlipX = (Random() & 1) == 0; burst->Update(); } if (!npc_anim_is_done(npc)) return; } auto spawnFoot = [&] { return static_cast(g_game->Spawn({.spawner = &npc, .type = npc.type, .variant = npc.variant + SATAN_FEET_VARIANT, .seed = Random()})); }; Entity_NPC* first = spawnFoot(); Entity_NPC* second = spawnFoot(); second->parent = first; first->child = second; second->state = NPC_STATE_INIT; first->state = NPC_STATE_INIT; first->Update(); second->Update(); npc.Remove(); } // Moves a foot to 111 from another that stands nearer. static void foot_space(Entity_NPC& foot, Entity_NPC& other) { Vector away = vector_sub(other.pos, foot.pos); float distance = vector_length(away); if (distance >= FEET_SPACING || distance <= 0) return; foot.pos = vector_sub(foot.pos, vector_scale(away, (FEET_SPACING - distance) / distance)); } // A hidden foot comes down on its target now and then, calling a leech when few enemies are left. static void foot_rest(Entity_NPC& npc) { npc.isVisible = false; npc.entityCollisionClass = ENTCOLL_NONE; npc.entityGridCollisionClass = GRIDCOLL_GROUND; if (Random() % SATAN_STOMP_ODDS != 0) return; if (npc.parent && npc.stateFrame != 0 && npc.ParentNPC()->stateFrame < STOMP_SETTLE_FRAMES) return; if (npc.child && npc.ChildNPC()->stateFrame < STOMP_SETTLE_FRAMES) return; npc.state = NPC_STATE_STOMP; npc.stateFrame = 0; npc_anim_restart(npc.sprite, "Stomp"); npc.isVisible = true; Entity& target = *npc.GetPlayerTarget(); npc.pos = target.pos; if (npc.parent) foot_space(npc, *npc.ParentNPC()); if (npc.child) foot_space(npc, *npc.ChildNPC()); if (g_game->room->GetAliveEnemiesCount() >= STOMP_LEECH_CROWD || (Random() & 1) != 0) return; Vector spot = room_free_pickup_position_find( {.position = target.pos, .step = STOMP_LEECH_REACH, .isAvoidActiveEntities = true}); g_game->Spawn({.position = spot, .spawner = &npc, .type = ENTITY_LEECH, .variant = KAMIKAZE_LEECH, .seed = Random()}); } // A stomp: solid from the landing until it lifts, crushing and rippling where it lands. The feet share the lower // health, and one's death ends the other and hurts every enemy left. static void foot_update(Entity_NPC& npc) { if (npc.state == NPC_STATE_IDLE) return foot_rest(npc); if (npc.state == NPC_STATE_STOMP) { npc.stateFrame++; bool isDown = npc.sprite.WasEventTriggered("Stomp") && !npc.sprite.WasEventTriggered("Lift"); npc.entityCollisionClass = isDown ? ENTCOLL_ALL : ENTCOLL_NONE; if (npc.sprite.IsEventTriggered("Stomp")) { npc.PlaySound(SOUND_HELLBOSS_GROUNDPOUND, 1, 2, false, 1); explosion_damage({.position = npc.pos, .source = &npc, .damageFlags = DAMAGE_CRUSH, .damage = SATAN_STOMP_DAMAGE, .radius = SATAN_STOMP_RADIUS, .isLineCheck = false}); shockwave_make(npc.pos, SATAN_STOMP_RIPPLE_AMPLITUDE, SATAN_STOMP_RIPPLE_SPEED, SATAN_STOMP_RIPPLE_FRAMES); npc.MakeGroundPoofAtSelf(SATAN_STOMP_DUST_COLOR, 1); } if (npc_anim_is_done(npc)) { npc.isVisible = false; npc.state = NPC_STATE_IDLE; } } if (npc.parent) { Entity_NPC& other = *npc.ParentNPC(); float health = std::min(npc.health, other.health); other.health = health; npc.health = health; } if (!npc.isDead) return; if (npc.child) npc.child->Kill(EntityRef()); if (npc.parent) npc.parent->Kill(EntityRef()); for (Entity* entity : std::vector(g_game->room->entityList.updateEL)) if (entity->CanShutDoors()) entity->TakeDamage(FEET_DEATH_DAMAGE, 0, EntityRef(), FEET_DEATH_COUNTDOWN); } // 0047f640 Satan (84) and his feet (84.10): the statue that wakes to call the Fallen, the fight once it falls, his // death, and the feet stomping until they die. void boss_satan_update(Entity_NPC& npc) { stray_blasts_ignore(npc); if (npc.i1 == SATAN_FIGHT && npc.health - npc.pendingDamage < 0) death_start(npc); if (npc.state == NPC_STATE_INIT) return satan_init(npc); npc.friction *= SATAN_FRICTION; int ticks = npc_ticks_get(npc); int gridIndex = g_game->room->GetGridIndex(vector_add(npc.pos, npc.posOffset)); switch (npc.i1) { case SATAN_STATUE: return statue_update(npc, ticks, gridIndex); case SATAN_AWAKENING: return awakening_update(npc, ticks, gridIndex); case SATAN_FIGHT: return fight_update(npc, ticks); case SATAN_DYING: return dying_update(npc); case SATAN_FEET: return foot_update(npc); } }