614 lines
24 KiB
C++
614 lines
24 KiB
C++
#include "boss_repentance.h"
|
|
#include "boss_ai.h"
|
|
#include "entity_bomb.h"
|
|
#include "entity_config.h"
|
|
#include "entity_effect.h"
|
|
#include "entity_player.h"
|
|
#include "entity_tear.h"
|
|
#include "loot_list.h"
|
|
#include <algorithm>
|
|
#include <array>
|
|
|
|
// The Horny Boys' states: idle, teleporting up and down, their poof out and back, the juggle, the Loki dance and the
|
|
// fly summon.
|
|
constexpr int HORNY_IDLE = NPC_STATE_IDLE;
|
|
constexpr int HORNY_TELEPORT_UP = NPC_STATE_JUMP;
|
|
constexpr int HORNY_POOF_BACK = NPC_STATE_STOMP;
|
|
constexpr int HORNY_TELEPORT_DOWN = NPC_STATE_ATTACK;
|
|
constexpr int HORNY_POOF = NPC_STATE_ATTACK2;
|
|
constexpr int HORNY_JUGGLE = NPC_STATE_ATTACK3;
|
|
constexpr int HORNY_DANCE = NPC_STATE_ATTACK4;
|
|
constexpr int HORNY_SUMMON = NPC_STATE_SUMMON;
|
|
|
|
// They keep three bombs (entityDeque) behind hidden layers 3 to 5, and take no damage from explosions but their
|
|
// players', their own kind's lasers or fire jets.
|
|
constexpr size_t HORNY_BOMBS = 3;
|
|
constexpr std::array<int, 3> HORNY_HIDDEN_LAYERS = {3, 4, 5};
|
|
constexpr int HORNY_IDLE_FRAMES = 60;
|
|
constexpr int HORNY_MOVES = 4;
|
|
constexpr float HORNY_LOW_HEALTH = 0.33f;
|
|
constexpr float HORNY_FRICTION = 0.8f;
|
|
constexpr float HORNY_SLOW_FRICTION = 0.7f;
|
|
|
|
// Their moves, in turn: the fly summon, the juggle, the dance, and a teleport or poof chain.
|
|
enum HornyMove
|
|
{
|
|
HORNY_MOVE_SUMMON,
|
|
HORNY_MOVE_JUGGLE,
|
|
HORNY_MOVE_DANCE,
|
|
HORNY_MOVE_VANISH
|
|
};
|
|
constexpr int HORNY_POOFS = 5;
|
|
constexpr int HORNY_TELEPORTS = 3;
|
|
constexpr int HORNY_LOW_EXTRA = 2;
|
|
|
|
// Their bombs: a plain one most often, a hot one or a sad blood one, all lit for 35, thrown at 10 to 28 by the
|
|
// distance (100 to 300). A teleport leaves a brimstone bomb lit for 25, a poof a sad blood bomb about to go off.
|
|
constexpr int HORNY_PLAIN_WEIGHT = 6;
|
|
constexpr int HORNY_HOT_WEIGHT = 3;
|
|
constexpr int HORNY_SAD_WEIGHT = 1;
|
|
constexpr RNG HORNY_PICK_RNG = {0, 5, 9, 7};
|
|
constexpr int HORNY_BOMB_FUSE = 35;
|
|
constexpr int HORNY_TELEPORT_FUSE = 25;
|
|
constexpr int HORNY_POOF_FUSE = 2;
|
|
constexpr float HORNY_THROW_NEAR = 100;
|
|
constexpr float HORNY_THROW_SPAN = 200;
|
|
constexpr float HORNY_THROW_SPEED = 10;
|
|
constexpr float HORNY_THROW_SPEED_RANGE = 18;
|
|
constexpr float HORNY_THROW_FALL = -4;
|
|
constexpr float HORNY_THROW_HEIGHT = -24;
|
|
constexpr float HORNY_POOF_DROP = 5;
|
|
constexpr float HORNY_DEATH_SPREAD = 10;
|
|
constexpr float HORNY_TELEPORT_FRAME = 20;
|
|
|
|
// A teleport spot: of six random cells the farthest from them, 200 from the nearest player and not straight in line
|
|
// with it closer than 400, on a free path.
|
|
constexpr int HORNY_SPOT_TRIES = 6;
|
|
constexpr float HORNY_SPOT_MARGIN = 20;
|
|
constexpr float HORNY_SPOT_LINE = 20;
|
|
constexpr float HORNY_SPOT_FAR_SQUARED = 160000;
|
|
constexpr float HORNY_SPOT_NEAR_SQUARED = 40000;
|
|
constexpr int HORNY_SPOT_PATH = 500;
|
|
|
|
// The juggle: bombs taken up on its second and third throws, and three thrown 60 and 30 degrees off the target and
|
|
// at it, in the order 1, 2, 0.
|
|
constexpr float HORNY_JUGGLE_DRIFT = 0.55f;
|
|
constexpr int HORNY_JUGGLE_THROWS = 3;
|
|
constexpr int HORNY_THROW_FIRST = 4;
|
|
constexpr float HORNY_THROW_TURN = 30;
|
|
constexpr std::array<int, 3> HORNY_THROW_ORDER = {1, 2, 0};
|
|
constexpr std::array<std::string_view, 3> HORNY_JUGGLES = {"Juggle0", "Juggle1", "Juggle2"};
|
|
|
|
// The dance: kept 80 inside the walls, a pattern of shots on each beat and three fire wave lobs on each cough.
|
|
constexpr float HORNY_DANCE_MARGIN = 80;
|
|
constexpr float HORNY_DANCE_PULL = 0.01f;
|
|
constexpr float HORNY_DANCE_SPEED = 3;
|
|
constexpr std::array<std::string_view, 4> HORNY_DANCES = {"LokiDance2", "LokiDance3", "LokiDance4", "LokiDance5"};
|
|
constexpr float HORNY_DANCE_FALL = -0.05f;
|
|
constexpr float HORNY_DIAGONAL = 7.071068f;
|
|
constexpr ColorMod HORNY_LOB_COLOR = {{1, 1, 1, 1}, {0, 0, 0, 0}, {1, 0.3f, 0}};
|
|
constexpr float HORNY_LOB_SCALE = 2;
|
|
constexpr float HORNY_LOB_SPEED = 10;
|
|
constexpr int HORNY_LOBS = 3;
|
|
constexpr float HORNY_LOB_SLOWING = 0.2f;
|
|
constexpr float HORNY_LOB_FALL = -0.6f;
|
|
constexpr float HORNY_LOB_FALL_STEP = -0.12f;
|
|
constexpr float HORNY_LOB_RISE_SHARE = 0.7f;
|
|
constexpr float HORNY_LOB_RISE = -3;
|
|
constexpr float HORNY_LOB_RISE_STEP = -5;
|
|
constexpr float HORNY_AIM_LEAD = 0.1f;
|
|
|
|
// The summon: a Boom Fly 50 below with three fly bombs about it, 120 degrees apart.
|
|
constexpr float HORNY_FLY_DROP = 50;
|
|
constexpr int HORNY_FLY_BOMBS = 3;
|
|
constexpr float HORNY_FLY_BOMB_STEP = 120;
|
|
constexpr float HORNY_FLY_BOMB_REACH = 10;
|
|
constexpr int HORNY_FLY_BOMB_VARIANT = 1;
|
|
|
|
// The bomb in a slot (entityDeque), if any.
|
|
static EntityPtr& horny_bomb_slot(Entity_NPC& npc, size_t slot)
|
|
{
|
|
return npc.entityDeque[slot];
|
|
}
|
|
|
|
// Explosions from other than a player, their own kind's lasers and fire jets do them no harm.
|
|
static bool horny_hit_is_ignored(Entity_NPC& npc, const DamageEvent& hit)
|
|
{
|
|
const EntityRef& source = hit.source;
|
|
if (source.flags & (ENTITY_REF_CHARMED | ENTITY_REF_FRIENDLY)) return false;
|
|
bool isForeignBlast =
|
|
(hit.damageFlags & DAMAGE_EXPLOSION) && source.spawnerType != ENTITY_PLAYER && source.type != ENTITY_PLAYER;
|
|
bool isOwnLaser = (hit.damageFlags & DAMAGE_LASER) && source.type == npc.type;
|
|
bool isFireJet =
|
|
source.type == ENTITY_EFFECT && source.variant == EFFECT_FIRE_JET && source.spawnerType != ENTITY_PLAYER;
|
|
return isForeignBlast || isOwnLaser || isFireJet;
|
|
}
|
|
|
|
// 004bcb30 A hidden bomb of a variant held in its first slot, replacing the one there.
|
|
static Entity_Bomb* horny_bomb_hold(Entity_NPC& npc, int variant)
|
|
{
|
|
if (horny_bomb_slot(npc, 0)) horny_bomb_slot(npc, 0)->Remove();
|
|
auto* bomb = static_cast<Entity_Bomb*>(g_game->Spawn(
|
|
{.position = npc.pos, .spawner = &npc, .type = ENTITY_BOMB, .variant = variant, .seed = Random()}));
|
|
bomb->isVisible = false;
|
|
bomb->entityCollisionClass = ENTCOLL_NONE;
|
|
bomb->entityGridCollisionClass = GRIDCOLL_NONE;
|
|
bomb->parent = &npc;
|
|
bomb->AddEntityFlags(FLAG_FREEZE);
|
|
horny_bomb_slot(npc, 0) = bomb;
|
|
return bomb;
|
|
}
|
|
|
|
// 004bcc70 A hidden lit bomb in a slot, plain, hot or sad blood, replacing the one there.
|
|
static void horny_bomb_spawn(Entity_NPC& npc, size_t slot)
|
|
{
|
|
if (horny_bomb_slot(npc, slot)) horny_bomb_slot(npc, slot)->Remove();
|
|
WeightedOutcomePicker picker;
|
|
picker.AddOutcomeWeight(BOMB_NORMAL, HORNY_PLAIN_WEIGHT);
|
|
picker.AddOutcomeWeight(BOMB_HOT, HORNY_HOT_WEIGHT);
|
|
picker.AddOutcomeWeight(BOMB_SAD_BLOOD, HORNY_SAD_WEIGHT);
|
|
RNG rng = HORNY_PICK_RNG;
|
|
rng._seed = Random() | 1;
|
|
int variant = picker.PickOutcome(rng);
|
|
TearFlags flags;
|
|
if (variant == BOMB_HOT) flags.set(TEAR_BURN);
|
|
else if (variant == BOMB_SAD_BLOOD) flags.set(TEAR_SAD_BOMB);
|
|
|
|
auto* bomb = static_cast<Entity_Bomb*>(g_game->Spawn(
|
|
{.position = npc.pos, .spawner = &npc, .type = ENTITY_BOMB, .variant = variant, .seed = Random()}));
|
|
bomb->isVisible = false;
|
|
bomb->entityCollisionClass = ENTCOLL_NONE;
|
|
bomb->entityGridCollisionClass = GRIDCOLL_NONE;
|
|
bomb->parent = &npc;
|
|
bomb->AddEntityFlags(FLAG_FREEZE);
|
|
bomb->SetExplosionCountdown(HORNY_BOMB_FUSE);
|
|
bomb->tearFlags = flags;
|
|
bomb->isLoadCostumes = true;
|
|
bomb->Update();
|
|
horny_bomb_slot(npc, slot) = bomb;
|
|
}
|
|
|
|
// 004bc8c0 Throws the bomb in a slot at a spot, faster the farther it is, and empties the slot. The bomb thrown, if
|
|
// the slot held one.
|
|
static Entity_Bomb* horny_bomb_throw(Entity_NPC& npc, size_t slot, Vector spot)
|
|
{
|
|
Entity* held = horny_bomb_slot(npc, slot).get();
|
|
if (!held) return nullptr;
|
|
auto* bomb = held->type == ENTITY_BOMB ? static_cast<Entity_Bomb*>(held) : nullptr;
|
|
if (bomb)
|
|
{
|
|
float reach =
|
|
std::clamp((vector_length(vector_sub(npc.pos, spot)) - HORNY_THROW_NEAR) / HORNY_THROW_SPAN, 0.0f, 1.0f);
|
|
Vector velocity = vector_scale(vector_normalized(vector_sub(spot, npc.pos)),
|
|
reach * HORNY_THROW_SPEED_RANGE + HORNY_THROW_SPEED);
|
|
bomb->parent = &npc;
|
|
bomb->entityCollisionClass = ENTCOLL_ALL;
|
|
bomb->isVisible = true;
|
|
bomb->fallSpeed = HORNY_THROW_FALL;
|
|
bomb->posOffset = vector_make(0, HORNY_THROW_HEIGHT);
|
|
bomb->pos = npc.pos;
|
|
bomb->ClearEntityFlags(FLAG_FREEZE);
|
|
bomb->velocity = velocity;
|
|
bomb->Update();
|
|
}
|
|
horny_bomb_slot(npc, slot) = nullptr;
|
|
return bomb;
|
|
}
|
|
|
|
// 004bc680 Picks a teleport spot (targetPosition). Whether one was found.
|
|
static bool horny_spot_pick(Entity_NPC& npc)
|
|
{
|
|
Room& room = *g_game->room;
|
|
float best = 0;
|
|
npc.targetPosition = {};
|
|
for (int i = 0; i < HORNY_SPOT_TRIES; i++)
|
|
{
|
|
int cell = room.GetGridIndex(room.GetRandomPosition(HORNY_SPOT_MARGIN));
|
|
Vector spot = room.GetGridPosition(cell);
|
|
Vector fromPlayer = vector_sub(spot, game_nearest_player(spot)->pos);
|
|
float playerSquared = vector_length_squared(fromPlayer);
|
|
bool isOffLine = std::abs(fromPlayer.x) >= HORNY_SPOT_LINE && std::abs(fromPlayer.y) >= HORNY_SPOT_LINE;
|
|
if (!isOffLine && playerSquared < HORNY_SPOT_FAR_SQUARED) continue;
|
|
if (playerSquared < HORNY_SPOT_NEAR_SQUARED) continue;
|
|
if ((uint32_t)cell < ROOM_GRID_CELLS && room.gridPaths[cell] >= HORNY_SPOT_PATH) continue;
|
|
float fromSelf = vector_length_squared(vector_sub(npc.pos, spot));
|
|
if (fromSelf <= best) continue;
|
|
npc.targetPosition = spot;
|
|
best = fromSelf;
|
|
}
|
|
return !vector_is_zero(npc.targetPosition);
|
|
}
|
|
|
|
// Back to idle after a chain of moves.
|
|
static void horny_idle_return(Entity_NPC& npc)
|
|
{
|
|
npc.sprite.Play("Idle");
|
|
npc.state = HORNY_IDLE;
|
|
npc.stateFrame = 0;
|
|
npc.i1 = 0;
|
|
}
|
|
|
|
// A poof where they vanish or appear.
|
|
static void horny_poof(Entity_NPC& npc)
|
|
{
|
|
g_game->Spawn({.position = npc.pos, .type = ENTITY_EFFECT, .variant = EFFECT_POOF01, .seed = Random()})->Update();
|
|
}
|
|
|
|
// Idle: wandering a second, then the next move in turn.
|
|
static void horny_idle_update(Entity_NPC& npc)
|
|
{
|
|
npc.friction *= HORNY_FRICTION;
|
|
npc.pathfinder.MoveRandomlyBoss(STATUS_OBEYED);
|
|
if (!npc.sprite.IsPlaying()) npc.sprite.Play("Idle");
|
|
npc.stateFrame += npc_ticks_get(npc);
|
|
if (npc.stateFrame < HORNY_IDLE_FRAMES) return;
|
|
|
|
bool isLow = npc.health < npc.maxHitPoints * HORNY_LOW_HEALTH;
|
|
switch (npc.i2)
|
|
{
|
|
case HORNY_MOVE_SUMMON:
|
|
npc.state = HORNY_SUMMON;
|
|
npc.sprite.Play("SpawnFly");
|
|
npc.stateFrame = 0;
|
|
break;
|
|
case HORNY_MOVE_JUGGLE:
|
|
npc.state = HORNY_JUGGLE;
|
|
npc.sprite.Play("JuggleStart");
|
|
npc.stateFrame = 0;
|
|
horny_bomb_spawn(npc, 0);
|
|
npc.i1 = 0;
|
|
break;
|
|
case HORNY_MOVE_DANCE:
|
|
npc.state = HORNY_DANCE;
|
|
npc.sprite.Play("LokiDance");
|
|
npc.i1 = 0;
|
|
npc.stateFrame = 0;
|
|
break;
|
|
case HORNY_MOVE_VANISH:
|
|
if ((Random() & 1) == 0)
|
|
{
|
|
npc.state = HORNY_POOF;
|
|
npc.sprite.Play("BombPoof");
|
|
npc.i1 = HORNY_POOFS + (isLow ? HORNY_LOW_EXTRA : 0);
|
|
}
|
|
else
|
|
{
|
|
npc.state = HORNY_TELEPORT_UP;
|
|
npc.sprite.Play("TeleportUp");
|
|
npc.i1 = HORNY_TELEPORTS + (isLow ? HORNY_LOW_EXTRA : 0);
|
|
}
|
|
npc.stateFrame = 0;
|
|
break;
|
|
}
|
|
npc.i2 = (npc.i2 + 1) % HORNY_MOVES;
|
|
}
|
|
|
|
// The teleport: up and gone, down at a far spot with a brimstone bomb thrown at the target, as many times as set.
|
|
static void horny_teleport_update(Entity_NPC& npc)
|
|
{
|
|
npc.friction *= HORNY_SLOW_FRICTION;
|
|
if (npc.state == HORNY_TELEPORT_UP)
|
|
{
|
|
if (npc.sprite.IsEventTriggered("Sound"))
|
|
{
|
|
npc.shadowSize = 0;
|
|
npc.entityCollisionClass = ENTCOLL_NONE;
|
|
}
|
|
if (npc.sprite.IsPlaying() || !horny_spot_pick(npc)) return;
|
|
npc.pos = npc.targetPosition;
|
|
npc.sprite.Play("TeleportDown");
|
|
horny_bomb_hold(npc, BOMB_BRIMSTONE)->SetExplosionCountdown(HORNY_TELEPORT_FUSE);
|
|
npc.state = HORNY_TELEPORT_DOWN;
|
|
return;
|
|
}
|
|
|
|
if (npc.sprite.IsEventTriggered("Sound"))
|
|
{
|
|
npc.shadowSize = npc.config->shadowSize;
|
|
npc.entityCollisionClass = ENTCOLL_ALL;
|
|
}
|
|
if (npc.sprite.IsEventTriggered("Shoot")) horny_bomb_throw(npc, 0, npc.GetPlayerTarget()->pos);
|
|
if (npc.sprite.IsPlaying()) return;
|
|
if (--npc.i1 <= 0) return horny_idle_return(npc);
|
|
npc.sprite.Play("TeleportUp");
|
|
npc.sprite.SetFrame(HORNY_TELEPORT_FRAME);
|
|
npc.state = HORNY_TELEPORT_UP;
|
|
npc.stateFrame = 0;
|
|
}
|
|
|
|
// The poof: a sad blood bomb dropped where they vanish, and back elsewhere, as many times as set.
|
|
static void horny_poof_update(Entity_NPC& npc)
|
|
{
|
|
npc.friction *= HORNY_SLOW_FRICTION;
|
|
if (npc.state == HORNY_POOF_BACK)
|
|
{
|
|
if (npc.sprite.IsEventTriggered("Shoot"))
|
|
{
|
|
npc.shadowSize = npc.config->shadowSize;
|
|
npc.entityCollisionClass = ENTCOLL_ALL;
|
|
}
|
|
if (npc.sprite.IsPlaying()) return;
|
|
if (--npc.i1 <= 0) return horny_idle_return(npc);
|
|
npc.sprite.Play("BombPoof");
|
|
npc.state = HORNY_POOF;
|
|
npc.stateFrame = 0;
|
|
return;
|
|
}
|
|
|
|
if (npc.sprite.IsEventTriggered("Sound"))
|
|
{
|
|
Entity_Bomb* bomb = horny_bomb_hold(npc, BOMB_SAD_BLOOD);
|
|
bomb->SetExplosionCountdown(HORNY_POOF_FUSE);
|
|
bomb->isLoadCostumes = true;
|
|
bomb->tearFlags.reset();
|
|
bomb->tearFlags.set(TEAR_SAD_BOMB);
|
|
}
|
|
// The original writes the dropped bomb's fall without checking it threw one.
|
|
if (npc.sprite.IsEventTriggered("Shoot"))
|
|
if (Entity_Bomb* bomb = horny_bomb_throw(npc, 0, npc.pos)) bomb->fallSpeed = HORNY_POOF_DROP;
|
|
if (npc.entityCollisionClass != ENTCOLL_NONE && !npc.sprite.animState.GetNullFrame("OverlayFrame"))
|
|
{
|
|
npc.shadowSize = 0;
|
|
npc.entityCollisionClass = ENTCOLL_NONE;
|
|
horny_poof(npc);
|
|
}
|
|
if (npc.sprite.IsPlaying() || !horny_spot_pick(npc)) return;
|
|
npc.pos = npc.targetPosition;
|
|
npc.sprite.Play("BombPoofBack");
|
|
npc.state = HORNY_POOF_BACK;
|
|
horny_poof(npc);
|
|
}
|
|
|
|
// The juggle: drifting diagonally, taking up bombs on the second and third juggles and throwing all three about the
|
|
// target.
|
|
static void horny_juggle_update(Entity_NPC& npc)
|
|
{
|
|
npc.friction *= HORNY_FRICTION;
|
|
Vector drift = vector_make(npc.velocity.x < 0 ? -HORNY_JUGGLE_DRIFT : HORNY_JUGGLE_DRIFT,
|
|
npc.velocity.y < 0 ? -HORNY_JUGGLE_DRIFT : HORNY_JUGGLE_DRIFT);
|
|
npc_push(npc, drift);
|
|
|
|
if (npc.sprite.IsEventTriggered("Shoot"))
|
|
{
|
|
bool isPickup = npc.i1 == 1 || npc.i1 == 2;
|
|
if (isPickup && !horny_bomb_slot(npc, (size_t)npc.i1)) horny_bomb_spawn(npc, (size_t)npc.i1);
|
|
else if (npc.i1 >= HORNY_THROW_FIRST)
|
|
{
|
|
Vector toward = vector_sub(npc.GetPlayerTarget()->pos, npc.pos);
|
|
float turn = (float)(npc.i1 - HORNY_THROW_FIRST - 1) * HORNY_THROW_TURN - HORNY_THROW_TURN;
|
|
Vector spot = vector_add(vector_rotated(toward, turn), npc.pos);
|
|
Entity_Bomb* bomb = horny_bomb_throw(npc, (size_t)HORNY_THROW_ORDER[npc.i1 - HORNY_THROW_FIRST], spot);
|
|
if (bomb) bomb->pos = vector_make(npc.GetNullOffset("BombGuide").x + npc.pos.x, npc.pos.y);
|
|
npc.PlaySound(SOUND_CUTE_GRUNT, 1, 2, false, 1);
|
|
npc.i1++;
|
|
}
|
|
}
|
|
if (npc.sprite.IsPlaying()) return;
|
|
if (npc.i1 < HORNY_JUGGLE_THROWS)
|
|
{
|
|
npc.sprite.Play(HORNY_JUGGLES[npc.i1++]);
|
|
npc.PlaySound(SOUND_SCAMPER, 1, 2, false, 1);
|
|
}
|
|
else if (npc.i1 == HORNY_JUGGLE_THROWS)
|
|
{
|
|
npc.sprite.Play("JuggleThrow");
|
|
npc.i1++;
|
|
}
|
|
else horny_idle_return(npc);
|
|
}
|
|
|
|
// One beat of the dance: the shot pattern its count calls for, and a splash.
|
|
static void horny_dance_beat(Entity_NPC& npc)
|
|
{
|
|
npc.PlaySound(SOUND_CUTE_GRUNT, 1, 2, false, 1);
|
|
ProjectileParams params;
|
|
params.fallingAccelModifier = HORNY_DANCE_FALL;
|
|
auto fire = [&](float x, float y, ProjectilesMode mode) {
|
|
npc.FireProjectiles(npc.pos, vector_make(x, y), mode, params);
|
|
};
|
|
switch (npc.stateFrame)
|
|
{
|
|
case 0:
|
|
case 2:
|
|
case 17:
|
|
case 19:
|
|
fire(10, 0, PROJECTILES_PLUS);
|
|
break;
|
|
case 1:
|
|
case 8:
|
|
case 18:
|
|
fire(10, 0, PROJECTILES_CROSS);
|
|
break;
|
|
case 3:
|
|
case 11:
|
|
fire(10, 0, PROJECTILES_EIGHT);
|
|
break;
|
|
case 4:
|
|
case 15:
|
|
params.circleAngle = PI_F / 12;
|
|
fire(10, 12, PROJECTILES_RING);
|
|
break;
|
|
case 5:
|
|
params.circleAngle = 0;
|
|
fire(8, 8, PROJECTILES_RING);
|
|
params.circleAngle = PI_F / 20;
|
|
fire(10, 8, PROJECTILES_RING);
|
|
params.circleAngle = -PI_F / 20;
|
|
fire(10, 8, PROJECTILES_RING);
|
|
break;
|
|
case 6:
|
|
case 7:
|
|
params.bulletFlags = npc.stateFrame == 6 ? PROJECTILE_CURVE_LEFT : PROJECTILE_CURVE_RIGHT;
|
|
params.circleAngle = 0;
|
|
fire(8, 10, PROJECTILES_RING);
|
|
break;
|
|
case 9:
|
|
fire(10, 0, PROJECTILES_THREE_WIDE);
|
|
fire(-10, 0, PROJECTILES_THREE_WIDE);
|
|
fire(0, 10, PROJECTILES_THREE_WIDE);
|
|
fire(0, -10, PROJECTILES_THREE_WIDE);
|
|
break;
|
|
case 10:
|
|
case 12:
|
|
{
|
|
ProjectilesMode mode = npc.stateFrame == 10 ? PROJECTILES_THREE_WIDE : PROJECTILES_FIVE;
|
|
fire(HORNY_DIAGONAL, HORNY_DIAGONAL, mode);
|
|
fire(-HORNY_DIAGONAL, HORNY_DIAGONAL, mode);
|
|
fire(HORNY_DIAGONAL, -HORNY_DIAGONAL, mode);
|
|
fire(-HORNY_DIAGONAL, -HORNY_DIAGONAL, mode);
|
|
break;
|
|
}
|
|
case 13:
|
|
params.circleAngle = 0;
|
|
fire(6, 10, PROJECTILES_RING);
|
|
break;
|
|
case 14:
|
|
fire(8, 0, PROJECTILES_EIGHT);
|
|
break;
|
|
case 16:
|
|
params.circleAngle = 0;
|
|
fire(8, 12, PROJECTILES_RING);
|
|
break;
|
|
}
|
|
blood_explosion_spawn(BLOOD_EXPLOSION_BURST, npc.pos, {}, COLOR_DEFAULT, {})->sprite.rotation =
|
|
random_unit() * FULL_TURN_DEGREES;
|
|
npc.stateFrame++;
|
|
}
|
|
|
|
// The dance's cough: three fire wave lobs at the target's lead, each shorter and higher.
|
|
static void horny_dance_cough(Entity_NPC& npc)
|
|
{
|
|
npc.PlaySound(SOUND_WHEEZY_COUGH, 1, 2, false, 1);
|
|
ProjectileParams params;
|
|
params.bulletFlags |= PROJECTILE_FIRE_WAVE;
|
|
params.scale = HORNY_LOB_SCALE;
|
|
params.color = HORNY_LOB_COLOR;
|
|
Entity* target = npc.GetPlayerTarget();
|
|
float distance = vector_length(vector_sub(npc.pos, target->pos));
|
|
Vector lead = vector_make(target->velocity.x * HORNY_AIM_LEAD * distance + target->pos.x,
|
|
target->velocity.y * HORNY_AIM_LEAD * distance + target->pos.y);
|
|
for (int i = 0; i < HORNY_LOBS; i++)
|
|
{
|
|
Entity_Projectile* lob = npc.FireBossProjectiles(1, lead, HORNY_LOB_SPEED, params);
|
|
lob->scale = HORNY_LOB_SCALE;
|
|
lob->velocity = vector_scale(lob->velocity, 1 - (float)i * HORNY_LOB_SLOWING);
|
|
lob->fallingAccel = lob->fallingAccel + HORNY_LOB_FALL + (float)i * HORNY_LOB_FALL_STEP;
|
|
lob->fallingSpeed = lob->fallingSpeed * HORNY_LOB_RISE_SHARE + HORNY_LOB_RISE + (float)i * HORNY_LOB_RISE_STEP;
|
|
}
|
|
}
|
|
|
|
// The Loki dance: drawn off the walls, four dances of beats and coughs.
|
|
static void horny_dance_update(Entity_NPC& npc)
|
|
{
|
|
npc.friction *= HORNY_SLOW_FRICTION;
|
|
Vector inside = g_game->room->GetClampedPositionImpl(npc.pos, HORNY_DANCE_MARGIN, HORNY_DANCE_MARGIN,
|
|
HORNY_DANCE_MARGIN, HORNY_DANCE_MARGIN);
|
|
Vector pull = vector_scale(vector_sub(inside, npc.pos), HORNY_DANCE_PULL);
|
|
if (vector_length_squared(pull) > HORNY_DANCE_SPEED * HORNY_DANCE_SPEED)
|
|
pull = vector_resized(pull, HORNY_DANCE_SPEED);
|
|
npc.velocity = vector_add(vector_scale(pull, npc.speedMultiplier), npc.velocity);
|
|
if (!npc.sprite.IsPlaying())
|
|
{
|
|
if (npc.i1 < (int)HORNY_DANCES.size()) npc.sprite.Play(HORNY_DANCES[npc.i1++]);
|
|
else horny_idle_return(npc);
|
|
}
|
|
if (npc.sprite.IsEventTriggered("Shoot")) horny_dance_beat(npc);
|
|
if (npc.sprite.IsEventTriggered("Sound")) horny_dance_cough(npc);
|
|
}
|
|
|
|
// The summon: a Boom Fly with three fly bombs circling it.
|
|
static void horny_summon_update(Entity_NPC& npc)
|
|
{
|
|
npc.friction *= HORNY_SLOW_FRICTION;
|
|
if (npc.sprite.IsEventTriggered("Shoot"))
|
|
{
|
|
npc.PlaySound(SOUND_SUMMONSOUND, 1, 2, false, 1);
|
|
Vector spot = vector_make(npc.pos.x, npc.pos.y + HORNY_FLY_DROP);
|
|
Entity* fly = g_game->Spawn({.position = spot, .spawner = &npc, .type = ENTITY_BOOMFLY, .seed = Random()});
|
|
fly->entityCollisionClass = ENTCOLL_PLAYEROBJECTS;
|
|
fly->Update();
|
|
for (int i = 0; i < HORNY_FLY_BOMBS; i++)
|
|
{
|
|
float angle = (float)i * HORNY_FLY_BOMB_STEP;
|
|
uint32_t seed = Random();
|
|
Vector position = vector_add(vector_scale(vector_from_angle(angle), HORNY_FLY_BOMB_REACH), spot);
|
|
auto* bomb = static_cast<Entity_NPC*>(g_game->Spawn({.position = position,
|
|
.spawner = &npc,
|
|
.type = ENTITY_FLY_BOMB,
|
|
.variant = HORNY_FLY_BOMB_VARIANT,
|
|
.seed = seed}));
|
|
bomb->parent = fly;
|
|
bomb->ClearEntityFlags(FLAG_APPEAR);
|
|
bomb->v1.x = angle;
|
|
bomb->entityCollisionClass = ENTCOLL_PLAYEROBJECTS;
|
|
bomb->Update();
|
|
}
|
|
}
|
|
if (npc.sprite.IsPlaying()) return;
|
|
npc.stateFrame = 0;
|
|
npc.state = HORNY_IDLE;
|
|
npc.sprite.Play("Idle");
|
|
}
|
|
|
|
// Before its update, the hits it ignores are taken back.
|
|
static void horny_damage_filter(Entity_NPC& npc)
|
|
{
|
|
for (DamageEvent& hit : npc.damageEvents)
|
|
{
|
|
if (!horny_hit_is_ignored(npc, hit)) continue;
|
|
npc.pendingDamage -= hit.damage;
|
|
hit.damage = 0;
|
|
}
|
|
npc.pendingDamage = std::max(npc.pendingDamage, 0.0f);
|
|
}
|
|
|
|
// 004bd2a0 The Horny Boys: teleports and poofs leaving bombs, a juggle of three bombs, the Loki dance and a Boom Fly
|
|
// with fly bombs, in turn. Killed, they throw what bombs they hold.
|
|
void boss_horny_boys_update(Entity_NPC& npc)
|
|
{
|
|
if (npc.aiCallPhase == AI_PHASE_PRE_UPDATE) return horny_damage_filter(npc);
|
|
|
|
switch (npc.state)
|
|
{
|
|
case NPC_STATE_INIT:
|
|
npc.state = HORNY_IDLE;
|
|
npc.ClearDequeRefs();
|
|
npc.entityDeque.resize(HORNY_BOMBS);
|
|
npc.entityGridCollisionClass = GRIDCOLL_WALLS;
|
|
npc.stateFrame = 0;
|
|
npc.aiCallFlags = AI_CALL_PRE_UPDATE;
|
|
for (int layer : HORNY_HIDDEN_LAYERS) npc.sprite.GetLayer(layer)->isVisible = false;
|
|
break;
|
|
case HORNY_IDLE:
|
|
horny_idle_update(npc);
|
|
break;
|
|
case HORNY_TELEPORT_UP:
|
|
case HORNY_TELEPORT_DOWN:
|
|
horny_teleport_update(npc);
|
|
break;
|
|
case HORNY_POOF:
|
|
case HORNY_POOF_BACK:
|
|
horny_poof_update(npc);
|
|
break;
|
|
case HORNY_JUGGLE:
|
|
horny_juggle_update(npc);
|
|
break;
|
|
case HORNY_DANCE:
|
|
horny_dance_update(npc);
|
|
break;
|
|
case HORNY_SUMMON:
|
|
horny_summon_update(npc);
|
|
break;
|
|
}
|
|
if (!npc.isDead) return;
|
|
|
|
for (size_t slot = 0; slot < HORNY_BOMBS; slot++)
|
|
{
|
|
float angle = random_unit() * PI_ROUGH;
|
|
angle += angle;
|
|
Vector spot = vector_make(std::cos(angle) * HORNY_DEATH_SPREAD + npc.pos.x,
|
|
std::sin(angle) * HORNY_DEATH_SPREAD + npc.pos.y);
|
|
horny_bomb_throw(npc, slot, spot);
|
|
}
|
|
}
|