Curation round 18: tears and four weapons, passive item and trinket sweeps, pills and most cards, alt path and main path enemies, Hush and the Blue Womb, Mega Satan, the Void, Tainted ???, Forgotten, Lilith and Eden, wisps
This commit is contained in:
1 parent
024cb12016
commit
9dfc09518c
157 files changed
+24212
-6106
No files matched your search
@@ -0,0 +1,717 @@
|
||||
#include "boss_ai.h"
|
||||
#include "entity_effect.h"
|
||||
#include "entity_laser.h"
|
||||
#include "entity_player.h"
|
||||
#include "npc_caves.h"
|
||||
#include <cmath>
|
||||
|
||||
// The Sisters Vis' states: idle, the leap across the room and its landing, the twin beam, the roll, and their three
|
||||
// solo attacks (a sweeping beam, a beam, a spray of shots) and summons.
|
||||
constexpr int SISTERS_LEAP = NPC_STATE_JUMP;
|
||||
constexpr int SISTERS_LAND = NPC_STATE_STOMP;
|
||||
constexpr int SISTERS_ROLL = NPC_STATE_ATTACK;
|
||||
constexpr int SISTERS_TWIN_BEAM = NPC_STATE_ATTACK2;
|
||||
constexpr int SISTERS_BEAM = NPC_STATE_ATTACK3;
|
||||
constexpr int SISTERS_SWEEP = NPC_STATE_ATTACK4;
|
||||
constexpr int SISTERS_SPRAY = NPC_STATE_ATTACK5;
|
||||
constexpr int SISTERS_SUMMON_BEGOTTEN = NPC_STATE_SUMMON;
|
||||
constexpr int SISTERS_SUMMON_VIS = NPC_STATE_SUMMON2;
|
||||
|
||||
// A step's progress through an attack (i1): its start, its loop, waiting on the beam, and its end.
|
||||
constexpr int STEP_START = 0;
|
||||
constexpr int STEP_LOOP = 1;
|
||||
constexpr int STEP_WAIT = 2;
|
||||
constexpr int STEP_END = 3;
|
||||
constexpr int SPRAY_END = 2;
|
||||
|
||||
constexpr ColorMod SISTERS_SPLAT_COLOR = {
|
||||
{0.039215688f, 0.3137255f, 0.039215688f, 1}, {0, 0, 0, 0}, {0.3921569f, 0.3921569f, 0.3137255f}};
|
||||
constexpr ColorMod SISTERS_RAGE_COLOR = {{1, 0.3f, 0.3f, 1}, {0, 0, 0, 0}, {0, 0, 0}};
|
||||
constexpr ColorMod SISTERS_SUMMON_SPLAT_COLOR = {{0, 0, 0, 1}, {0, 0, 0, 0}, {0.42f, 0.43f, 0.35f}};
|
||||
constexpr ColorMod SISTERS_TRACER_COLOR = {{0.6f, 0.05f, 0, 0.8f}, {0, 0, 0, 0}, {0, 0, 0}};
|
||||
constexpr float SISTERS_WIDTH = 1.2f;
|
||||
constexpr float SISTERS_HEIGHT = 0.5f;
|
||||
|
||||
constexpr float SISTERS_SPAWN_REACH = 40;
|
||||
constexpr float SISTERS_RAGE_GAP = 300;
|
||||
constexpr int SISTERS_RAGE_FRAMES = 120;
|
||||
constexpr float SISTERS_RAGE_DAMAGE = 1.5f;
|
||||
constexpr float SISTERS_BEAM_HURT = 1.5f;
|
||||
constexpr float SISTERS_FRICTION = 0.5f;
|
||||
constexpr int SISTERS_IDLE_FRAMES = 20;
|
||||
constexpr uint32_t SISTERS_MOVE_ODDS = 5;
|
||||
constexpr uint32_t SISTERS_PERCENT = 100;
|
||||
constexpr uint32_t SISTERS_LEAP_PERCENT = 35;
|
||||
constexpr uint32_t SISTERS_SUMMON_PERCENT = 84;
|
||||
constexpr int SISTERS_SUMMON_LIMIT = 2;
|
||||
constexpr uint32_t SISTERS_BEGOTTEN_ODDS = 3;
|
||||
constexpr float SISTERS_LEAD_FRAMES = 10;
|
||||
constexpr float SISTERS_LEAP_STEP = 0.02f;
|
||||
constexpr float SISTERS_LEAP_ARRIVE_SQUARED = 2;
|
||||
|
||||
constexpr float SISTERS_SUMMON_DROP = 20;
|
||||
constexpr float SISTERS_SUMMON_SPEED = 5;
|
||||
constexpr int SISTERS_SPLATS_MIN = 2;
|
||||
constexpr uint32_t SISTERS_SPLATS_RANGE = 3;
|
||||
|
||||
constexpr float SISTERS_ROLL_SPEED = 16;
|
||||
constexpr float SISTERS_RAGE_ROLL_SPEED = 24;
|
||||
constexpr int SISTERS_CREEP_FRAMES = 3;
|
||||
constexpr float SISTERS_CREEP_SCALE = 2;
|
||||
constexpr int SISTERS_CREEP_TIMEOUT = 5;
|
||||
constexpr int SISTERS_ROLL_MIN = 65;
|
||||
constexpr uint32_t SISTERS_ROLL_STOP_ODDS = 35;
|
||||
constexpr uint32_t SISTERS_BEAM_PERCENT = 60;
|
||||
constexpr uint32_t SISTERS_SWEEP_PERCENT = 70;
|
||||
|
||||
constexpr float SISTERS_BEAM_HEIGHT = -30;
|
||||
constexpr float SISTERS_BEAM_SIDE = 35;
|
||||
constexpr float SISTERS_TRACER_HEIGHT = -40;
|
||||
constexpr float SISTERS_TRACER_SCALE = 8;
|
||||
constexpr int SISTERS_TRACER_TIMEOUT = 40;
|
||||
constexpr int SISTERS_TWIN_TRACER_TIMEOUT = 42;
|
||||
constexpr int SISTERS_BEAM_TIMEOUT = 30;
|
||||
constexpr int SISTERS_TWIN_BEAM_TIMEOUT = 15;
|
||||
constexpr int SISTERS_SWEEP_TIMEOUT = 60;
|
||||
constexpr int SISTERS_BEAM_VARIANT = 6;
|
||||
constexpr float SISTERS_BEAM_BACK_DEPTH = -10;
|
||||
constexpr float SISTERS_BEAM_FRONT_DEPTH = 3000;
|
||||
constexpr float SISTERS_TWIN_BEAM_REACH = 57;
|
||||
constexpr float SISTERS_TWIN_GAP_ACROSS = 157;
|
||||
constexpr float SISTERS_TWIN_GAP_DOWN = 87;
|
||||
constexpr float SISTERS_SWEEP_TURN = 2;
|
||||
constexpr float SISTERS_FAR = 9999999;
|
||||
|
||||
constexpr float SISTERS_SPRAY_SPEED = 6;
|
||||
constexpr float SISTERS_RAGE_SPRAY_SPEED = 8;
|
||||
constexpr float SISTERS_SPRAY_SIDE = 30;
|
||||
constexpr float SISTERS_SPRAY_HEIGHT = -15;
|
||||
constexpr int SISTERS_SPRAY_FRAMES = 30;
|
||||
constexpr float SISTERS_SPRAY_THIRD = 33;
|
||||
constexpr float SISTERS_SPRAY_TWO_THIRDS = 66;
|
||||
constexpr int SISTERS_SPRAY_PERIOD = 5;
|
||||
|
||||
constexpr std::string_view LASER_START[] = {"LaserStartSide", "LaserStartUp", "LaserStartSide", "LaserStartDown"};
|
||||
constexpr std::string_view LASER_LOOP[] = {"LaserLoopSide", "LaserLoopUp", "LaserLoopSide", "LaserLoopDown"};
|
||||
constexpr std::string_view LASER_END[] = {"LaserEndSide", "LaserEndUp", "LaserEndSide", "LaserEndDown"};
|
||||
|
||||
// What a sister knows of the other each frame: her, whether this one spawned first, and whether either is hindered.
|
||||
struct SistersView
|
||||
{
|
||||
Entity_NPC* sister = nullptr;
|
||||
bool isFirst = false;
|
||||
bool isSecond = false;
|
||||
bool isImpaired = false;
|
||||
bool isSisterInactive = false;
|
||||
};
|
||||
|
||||
// 00682740 An angle in degrees brought into -180 to 180.
|
||||
float normalize_angle_degrees(float angle)
|
||||
{
|
||||
if (std::abs(angle) > FULL_TURN_DEGREES) angle = std::fmod(angle, FULL_TURN_DEGREES);
|
||||
if (angle > HALF_TURN_DEGREES) return angle - FULL_TURN_DEGREES;
|
||||
if (angle < -HALF_TURN_DEGREES) angle += FULL_TURN_DEGREES;
|
||||
return angle;
|
||||
}
|
||||
|
||||
// The angle a sister faces along a direction (left, up, right, down).
|
||||
static float sisters_direction_angle(int direction)
|
||||
{
|
||||
return normalize_angle_degrees((float)direction * RIGHT_ANGLE_DEGREES + HALF_TURN_DEGREES);
|
||||
}
|
||||
|
||||
// Both sisters back to idle.
|
||||
static void sisters_reset(Entity_NPC& npc, Entity_NPC* sister)
|
||||
{
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
npc.i1 = 0;
|
||||
npc.stateFrame = 0;
|
||||
if (!sister) return;
|
||||
|
||||
sister->state = NPC_STATE_IDLE;
|
||||
sister->i1 = 0;
|
||||
sister->stateFrame = 0;
|
||||
}
|
||||
|
||||
// Its beam hurts it half again as much while it fires.
|
||||
static void sisters_beam_hurt(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.pendingDamage <= 0) return;
|
||||
|
||||
for (DamageEvent& event : npc.damageEvents) event.damage *= SISTERS_BEAM_HURT;
|
||||
}
|
||||
|
||||
// A tracer showing where the beam will fire, once per attack (in the first slot of its entity queue).
|
||||
static Entity_Effect* sisters_tracer_spawn(Entity_NPC& npc, int direction, int timeout)
|
||||
{
|
||||
return following_effect_spawn(npc, {.offset = vector_make(0, SISTERS_TRACER_HEIGHT),
|
||||
.targetPosition = vector_from_angle(sisters_direction_angle(direction)),
|
||||
.color = SISTERS_TRACER_COLOR,
|
||||
.scale = SISTERS_TRACER_SCALE,
|
||||
.timeout = timeout});
|
||||
}
|
||||
|
||||
// The queued tracer, once it is gone.
|
||||
static void sisters_tracer_keep(Entity_NPC& npc, int direction)
|
||||
{
|
||||
if (npc.entityDeque.front().get()) return;
|
||||
|
||||
npc.entityDeque.front() = sisters_tracer_spawn(npc, direction, SISTERS_TWIN_TRACER_TIMEOUT);
|
||||
}
|
||||
|
||||
// A beam from its mouth along a direction, in front of it unless it fires up.
|
||||
static Entity_Laser* sisters_beam_fire(Entity_NPC& npc, int direction, int timeout)
|
||||
{
|
||||
Vector offset = vector_make(0, SISTERS_BEAM_HEIGHT);
|
||||
if (direction == 0) offset.x = -SISTERS_BEAM_SIDE;
|
||||
else if (direction == 2) offset.x = SISTERS_BEAM_SIDE;
|
||||
|
||||
Entity_Laser* laser = Entity_Laser::ShootAngle({.position = npc.pos,
|
||||
.posOffset = offset,
|
||||
.source = &npc,
|
||||
.angleDegrees = sisters_direction_angle(direction),
|
||||
.timeout = timeout,
|
||||
.variant = SISTERS_BEAM_VARIANT});
|
||||
laser->renderDepthOffset = direction == 1 ? SISTERS_BEAM_BACK_DEPTH : SISTERS_BEAM_FRONT_DEPTH;
|
||||
return laser;
|
||||
}
|
||||
|
||||
// The second sister, spawned beside the first and tied to her (as tough as a Delirium form).
|
||||
static void sisters_init(Entity_NPC& npc)
|
||||
{
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
npc.stateFrame = 0;
|
||||
npc.sizeMulti = vector_make(SISTERS_WIDTH, SISTERS_HEIGHT);
|
||||
npc.splatColor = SISTERS_SPLAT_COLOR;
|
||||
npc.i2 = 0;
|
||||
npc.entityDeque.resize(1);
|
||||
if (npc.spawnerType == npc.type) return;
|
||||
|
||||
uint32_t seed = Random();
|
||||
float angle = random_unit() * RANDOM_HALF_TURN;
|
||||
angle += angle;
|
||||
Entity* sister = g_game->Spawn({.position = vector_make(std::cos(angle) * SISTERS_SPAWN_REACH + npc.pos.x,
|
||||
std::sin(angle) * SISTERS_SPAWN_REACH + npc.pos.y),
|
||||
.velocity = npc.velocity,
|
||||
.spawner = &npc,
|
||||
.subType = npc.subtype,
|
||||
.type = npc.type,
|
||||
.variant = npc.variant,
|
||||
.seed = seed});
|
||||
if (npc.type != ENTITY_SISTERS_VIS) return;
|
||||
|
||||
npc.child = sister;
|
||||
sister->child = &npc;
|
||||
if (!npc.HasEntityFlags(FLAG_DELIRIUM_FORM)) return;
|
||||
|
||||
sister->health = npc.health;
|
||||
sister->maxHitPoints = npc.maxHitPoints;
|
||||
}
|
||||
|
||||
// The leap: the sisters jump to opposite walls, the first to the top or left one past where her target heads.
|
||||
static void sisters_leap_start(Entity_NPC& npc, Entity_NPC& sister)
|
||||
{
|
||||
Room& room = *g_game->room;
|
||||
npc.state = SISTERS_LEAP;
|
||||
Vector lead = vector_scale(npc.GetPlayerTarget()->velocity, SISTERS_LEAD_FRAMES);
|
||||
npc.targetPosition = vector_add(npc.CalcTargetPosition(0), lead);
|
||||
bool isAcross = Random() & 1;
|
||||
if (isAcross) npc.targetPosition.x = room.topLeftPos.x;
|
||||
else npc.targetPosition.y = room.topLeftPos.y;
|
||||
npc.targetPosition = room.GetClampedPositionImpl(npc.targetPosition, npc.size, npc.size, npc.size, npc.size);
|
||||
npc.v1.x = 0;
|
||||
npc.i1 = 0;
|
||||
|
||||
sister.state = SISTERS_LEAP;
|
||||
sister.i1 = 0;
|
||||
sister.v1.x = 0;
|
||||
sister.targetPosition = npc.targetPosition;
|
||||
if (isAcross) sister.targetPosition.x = room.bottomRightPos.x;
|
||||
else sister.targetPosition.y = room.bottomRightPos.y;
|
||||
sister.targetPosition = room.GetClampedPositionImpl(sister.targetPosition, npc.size, npc.size, npc.size, npc.size);
|
||||
}
|
||||
|
||||
// Whether the room has room for a summon: under two other enemies, or under two of its own minions for a Delirium
|
||||
// form.
|
||||
static bool sisters_is_summon_allowed(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.HasEntityFlags(FLAG_DELIRIUM_FORM))
|
||||
return (uint32_t)(npc.CountRelatedEntities(ENTITY_BEGOTTEN, 0, nullptr) + npc.CountRelatedEntities(ENTITY_VIS, 0, nullptr)) <
|
||||
SISTERS_SUMMON_LIMIT;
|
||||
Room& room = *g_game->room;
|
||||
return room.GetAliveEnemiesCount() - room.GetAliveBossesCount() < SISTERS_SUMMON_LIMIT;
|
||||
}
|
||||
|
||||
// Idle: after 20 frames, one roll in five (the first sister leading, neither hindered) picks a leap, a summon or a
|
||||
// roll for both.
|
||||
static void sisters_idle(Entity_NPC& npc, const SistersView& view)
|
||||
{
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
npc.entityGridCollisionClass = GRIDCOLL_GROUND;
|
||||
npc_anim_loop(npc.sprite, "Idle");
|
||||
if (npc.HasEntityFlags(FLAG_DELIRIUM_FORM) && room_is_clear()) return;
|
||||
if (npc.stateFrame++ <= SISTERS_IDLE_FRAMES) return;
|
||||
if (Random() % SISTERS_MOVE_ODDS != 0 || (!view.isFirst && view.sister) || view.isImpaired) return;
|
||||
|
||||
uint32_t roll = Random() % SISTERS_PERCENT;
|
||||
if (roll < SISTERS_LEAP_PERCENT && !view.isSisterInactive) return sisters_leap_start(npc, *view.sister);
|
||||
if (roll > SISTERS_SUMMON_PERCENT)
|
||||
{
|
||||
if (!sisters_is_summon_allowed(npc)) return;
|
||||
|
||||
npc.state = Random() % SISTERS_BEGOTTEN_ODDS != 0 ? SISTERS_SUMMON_VIS : SISTERS_SUMMON_BEGOTTEN;
|
||||
if (npc.child.get() && !view.isSisterInactive) view.sister->state = npc.state;
|
||||
return;
|
||||
}
|
||||
|
||||
npc.state = SISTERS_ROLL;
|
||||
npc.i1 = 0;
|
||||
npc.PlaySound(SOUND_FAT_WIGGLE, 1, 2, false, 1);
|
||||
if (view.isSisterInactive) return;
|
||||
|
||||
view.sister->state = SISTERS_ROLL;
|
||||
view.sister->i1 = 0;
|
||||
}
|
||||
|
||||
// The summon: a Begotten or a Vis dropped on Shoot, with a few gray splats under it.
|
||||
static void sisters_summon(Entity_NPC& npc)
|
||||
{
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
npc.entityGridCollisionClass = GRIDCOLL_GROUND;
|
||||
npc_anim_loop(npc.sprite, "Attack1");
|
||||
if (npc.sprite.animState.animData)
|
||||
{
|
||||
if (npc.sprite.IsEventTriggered("Shoot"))
|
||||
{
|
||||
int type = npc.state == SISTERS_SUMMON_BEGOTTEN ? ENTITY_BEGOTTEN : ENTITY_VIS;
|
||||
Vector drop = vector_make(npc.pos.x, npc.pos.y + SISTERS_SUMMON_DROP);
|
||||
g_game->Spawn({.position = drop, .velocity = vector_make(0, SISTERS_SUMMON_SPEED), .spawner = &npc, .type = type, .seed = Random()})
|
||||
->Update();
|
||||
npc.PlaySound(SOUND_SKIN_PULL, 1, 2, false, 1);
|
||||
|
||||
int splats = (int)(Random() % SISTERS_SPLATS_RANGE) + SISTERS_SPLATS_MIN;
|
||||
for (int i = 0; i < splats; i++)
|
||||
{
|
||||
Entity_Effect* splat = npc.MakeSplat(random_unit() * 0.5f + 0.5f);
|
||||
splat->pos = i == 0 ? drop : vector_make(npc.pos.x, random_unit() * SISTERS_SUMMON_DROP + npc.pos.y);
|
||||
splat->SetColor(SISTERS_SUMMON_SPLAT_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
|
||||
splat->Update();
|
||||
}
|
||||
}
|
||||
if (npc.sprite.animState.animData && npc.sprite.animState.isPlaying) return;
|
||||
}
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
npc.stateFrame = 0;
|
||||
}
|
||||
|
||||
// The roll's start: once curled up, a shove at the target (away from it for the second sister).
|
||||
static void sisters_roll_start(Entity_NPC& npc, const SistersView& view, float speed)
|
||||
{
|
||||
npc_anim_loop(npc.sprite, "RollStart");
|
||||
if (!npc_anim_is_done(npc)) return;
|
||||
|
||||
npc.i1++;
|
||||
npc.velocity = vector_add(npc.velocity, vector_scale(vector_normalized(vector_sub(npc.GetPlayerTarget()->pos, npc.pos)), speed));
|
||||
npc.stateFrame = 0;
|
||||
if (view.isSecond) npc.velocity = vector_scale(npc.velocity, -1);
|
||||
}
|
||||
|
||||
// Rolling at full speed, leaving creep (green for the first, brown for the second), until both roll and, past 65
|
||||
// frames, one roll in 35 on screen picks the next attack: a beam, a sweep or a spray.
|
||||
static void sisters_roll_loop(Entity_NPC& npc, const SistersView& view, float speed)
|
||||
{
|
||||
if (npc.sprite.GetFrame() % SISTERS_CREEP_FRAMES == 0)
|
||||
{
|
||||
auto* creep = static_cast<Entity_Effect*>(g_game->Spawn({.position = npc.pos,
|
||||
.spawner = &npc,
|
||||
.type = ENTITY_EFFECT,
|
||||
.variant = view.isSecond ? EFFECT_CREEP_SLIPPERY_BROWN : EFFECT_CREEP_GREEN,
|
||||
.seed = Random()}));
|
||||
creep->sprite.scale = vector_make(SISTERS_CREEP_SCALE, SISTERS_CREEP_SCALE);
|
||||
creep->timeout = SISTERS_CREEP_TIMEOUT;
|
||||
creep->lifespan = SISTERS_CREEP_TIMEOUT;
|
||||
creep->Update();
|
||||
}
|
||||
npc.sprite.Play("RollLoop");
|
||||
if (!vector_is_zero(npc.velocity)) npc.velocity = vector_scale(vector_normalized(npc.velocity), speed);
|
||||
|
||||
Entity_NPC* sister = view.sister;
|
||||
if (sister && (sister->state != SISTERS_ROLL || sister->i1 != STEP_LOOP)) return;
|
||||
if (npc.stateFrame++ <= SISTERS_ROLL_MIN && !view.isImpaired) return;
|
||||
if (Random() % SISTERS_ROLL_STOP_ODDS != 0 || !g_game->room->camera->IsPosVisible(npc.pos)) return;
|
||||
|
||||
uint32_t roll = Random() % SISTERS_PERCENT;
|
||||
if (roll < SISTERS_BEAM_PERCENT) npc.i1 = 2;
|
||||
else npc.i1 = roll < SISTERS_SWEEP_PERCENT ? 3 : 4;
|
||||
}
|
||||
|
||||
// The roll's end: a taunt, then the attack the roll picked.
|
||||
static void sisters_roll_end(Entity_NPC& npc, const SistersView& view)
|
||||
{
|
||||
npc.sprite.Play("Taunt");
|
||||
if (!npc_anim_is_done(npc)) return;
|
||||
if (view.isImpaired) return sisters_reset(npc, view.sister);
|
||||
|
||||
int next = npc.i1;
|
||||
if (next < 2 || next > 4) return;
|
||||
|
||||
npc.targetPosition = vector_sub(npc.GetPlayerTarget()->pos, npc.pos);
|
||||
npc.i1 = 0;
|
||||
npc.stateFrame = 0;
|
||||
if (next == 3) npc.state = SISTERS_SWEEP;
|
||||
else if (next == 4) npc.state = SISTERS_SPRAY;
|
||||
else
|
||||
{
|
||||
npc.state = SISTERS_BEAM;
|
||||
sisters_tracer_spawn(npc, vector_to_direction(npc.targetPosition), SISTERS_TRACER_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
// The roll: curling up, rolling about the room and ending in an attack.
|
||||
static void sisters_roll(Entity_NPC& npc, const SistersView& view)
|
||||
{
|
||||
float speed = npc.i2 != 0 ? SISTERS_RAGE_ROLL_SPEED : SISTERS_ROLL_SPEED;
|
||||
if (npc.i1 == 0) return sisters_roll_start(npc, view, speed);
|
||||
if (npc.i1 == 1) return sisters_roll_loop(npc, view, speed);
|
||||
sisters_roll_end(npc, view);
|
||||
}
|
||||
|
||||
// The beam: from its mouth toward where its target stood, then both back to idle.
|
||||
static void sisters_beam(Entity_NPC& npc, const SistersView& view)
|
||||
{
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
npc.entityGridCollisionClass = GRIDCOLL_GROUND;
|
||||
int direction = vector_to_direction(npc.targetPosition);
|
||||
npc.sprite.isFlipX = direction == 0;
|
||||
switch (npc.i1)
|
||||
{
|
||||
case STEP_START:
|
||||
npc.sprite.Play(LASER_START[direction]);
|
||||
if (npc_anim_is_done(npc)) npc.i1++;
|
||||
return;
|
||||
case STEP_LOOP:
|
||||
{
|
||||
sisters_beam_hurt(npc);
|
||||
npc.sprite.Play(LASER_LOOP[direction]);
|
||||
Entity_Laser* laser = sisters_beam_fire(npc, direction, SISTERS_BEAM_TIMEOUT);
|
||||
npc.entityRef = laser;
|
||||
laser->Update();
|
||||
npc.i1++;
|
||||
return;
|
||||
}
|
||||
case STEP_WAIT:
|
||||
if (!npc.entityRef.get()) npc.i1 = STEP_END;
|
||||
return;
|
||||
case STEP_END:
|
||||
npc.sprite.Play(LASER_END[direction]);
|
||||
if (npc_anim_is_done(npc)) sisters_reset(npc, view.sister);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The twin beam: after landing, each fires at the other (or a player when alone), the beam reaching halfway.
|
||||
static void sisters_twin_beam(Entity_NPC& npc, const SistersView& view)
|
||||
{
|
||||
npc.entityGridCollisionClass = GRIDCOLL_GROUND;
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
Vector aim = game_random_player(*g_game, npc.pos, SISTERS_FAR)->pos;
|
||||
if (view.sister) aim = view.sister->pos;
|
||||
float across = std::abs(npc.pos.x - aim.x);
|
||||
float down = std::abs(npc.pos.y - aim.y);
|
||||
bool isAcross = down < across;
|
||||
int direction = 0;
|
||||
if (across <= down) direction = (npc.pos.y < aim.y) * 2 + 1;
|
||||
else if (npc.pos.x < aim.x) direction = 2;
|
||||
npc.sprite.isFlipX = direction == 0;
|
||||
|
||||
switch (npc.i1)
|
||||
{
|
||||
case STEP_START:
|
||||
npc.sprite.Play(LASER_START[direction]);
|
||||
sisters_tracer_keep(npc, direction);
|
||||
if (npc_anim_is_done(npc)) npc.i1++;
|
||||
return;
|
||||
case STEP_LOOP:
|
||||
{
|
||||
sisters_beam_hurt(npc);
|
||||
npc.sprite.Play(LASER_LOOP[direction]);
|
||||
Entity_Laser* laser = sisters_beam_fire(npc, direction, SISTERS_TWIN_BEAM_TIMEOUT);
|
||||
laser->maxDistance = SISTERS_TWIN_BEAM_REACH;
|
||||
if (view.sister)
|
||||
{
|
||||
float gap = isAcross ? std::abs(npc.pos.x - view.sister->pos.x) - SISTERS_TWIN_GAP_ACROSS
|
||||
: std::abs(npc.pos.y - view.sister->pos.y) - SISTERS_TWIN_GAP_DOWN;
|
||||
laser->maxDistance = gap * 0.5f;
|
||||
}
|
||||
laser->Update();
|
||||
npc.entityRef = laser;
|
||||
npc.i1++;
|
||||
return;
|
||||
}
|
||||
case STEP_WAIT:
|
||||
if (!npc.entityRef.get()) npc.i1 = STEP_END;
|
||||
return;
|
||||
case STEP_END:
|
||||
npc.sprite.Play(LASER_END[direction]);
|
||||
if (!npc_anim_is_done(npc)) return;
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
npc.i1 = 0;
|
||||
npc.stateFrame = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The spray: shots along its facing in pairs, threes or fours (one of three, faster when enraged), for 30 frames.
|
||||
static void sisters_spray(Entity_NPC& npc, const SistersView& view)
|
||||
{
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
npc.entityGridCollisionClass = GRIDCOLL_GROUND;
|
||||
int direction = vector_to_direction(npc.targetPosition);
|
||||
if (npc.i1 == STEP_START)
|
||||
{
|
||||
npc.sprite.isFlipX = direction == 0;
|
||||
npc.sprite.Play(LASER_START[direction]);
|
||||
if (!npc_anim_is_done(npc)) return;
|
||||
npc.PlaySound(SOUND_BOSS_SPIT_BLOB_BARF, 1, 2, false, 1);
|
||||
npc.i1++;
|
||||
npc.v1.x = (float)(Random() % SISTERS_PERCENT);
|
||||
return;
|
||||
}
|
||||
if (npc.i1 == SPRAY_END)
|
||||
{
|
||||
npc.sprite.Play(LASER_END[direction]);
|
||||
if (npc_anim_is_done(npc)) sisters_reset(npc, view.sister);
|
||||
return;
|
||||
}
|
||||
if (npc.i1 != STEP_LOOP) return;
|
||||
|
||||
npc.stateFrame++;
|
||||
float pick = npc.v1.x;
|
||||
int period = SISTERS_SPRAY_PERIOD + (npc.i2 == 0) * 2;
|
||||
ProjectilesMode mode = PROJECTILES_FOUR;
|
||||
if (pick < SISTERS_SPRAY_THIRD)
|
||||
{
|
||||
period += 2;
|
||||
mode = PROJECTILES_TWO;
|
||||
}
|
||||
else if (pick < SISTERS_SPRAY_TWO_THIRDS)
|
||||
{
|
||||
period += 1;
|
||||
mode = PROJECTILES_THREE_WIDE;
|
||||
}
|
||||
if (npc.stateFrame % period == 0)
|
||||
{
|
||||
float speed = npc.i2 != 0 ? SISTERS_RAGE_SPRAY_SPEED : SISTERS_SPRAY_SPEED;
|
||||
Vector velocity = vector_scale(vector_from_direction(direction), speed);
|
||||
float side = direction == 0 ? -SISTERS_SPRAY_SIDE : direction == 2 ? SISTERS_SPRAY_SIDE : 0;
|
||||
ProjectileParams params;
|
||||
params.depthOffset = direction == 1 ? SISTERS_BEAM_BACK_DEPTH : SISTERS_BEAM_FRONT_DEPTH;
|
||||
npc.PlaySound(SOUND_BLOODSHOOT, 1, 2, false, 1);
|
||||
npc.FireProjectiles(vector_make(npc.pos.x + side, npc.pos.y + SISTERS_SPRAY_HEIGHT), velocity, mode, params);
|
||||
}
|
||||
if (npc.stateFrame > SISTERS_SPRAY_FRAMES) npc.i1++;
|
||||
}
|
||||
|
||||
// Whether a sweeping beam turned past the edge of its quarter (and turns back), or ended its sweep. The edges are
|
||||
// 150 to 210 facing left, 240 to 300 up, 330 to 30 right and 60 to 120 down.
|
||||
static void sisters_sweep_turn(Entity_NPC& npc, Entity_Laser& laser, int direction)
|
||||
{
|
||||
float angle = laser.angleDegrees;
|
||||
if (angle < 0) angle += FULL_TURN_DEGREES;
|
||||
angle += npc.i1 == 3 ? SISTERS_SWEEP_TURN : -SISTERS_SWEEP_TURN;
|
||||
|
||||
bool isWrapped = true;
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
if (angle >= 210) npc.i1 = 2;
|
||||
else if (angle <= 150) npc.i1 = 3;
|
||||
break;
|
||||
case 1:
|
||||
if (angle >= 300) npc.i1 = 2;
|
||||
else if (angle <= 240) npc.i1 = 3;
|
||||
break;
|
||||
case 2:
|
||||
if (angle >= 30 && angle < 180) npc.i1 = 2;
|
||||
else if (angle > 180 && angle <= 330) npc.i1 = 3;
|
||||
else if (angle <= 180) isWrapped = false;
|
||||
break;
|
||||
case 3:
|
||||
if (angle >= 120) npc.i1 = 2;
|
||||
else if (angle <= 60) npc.i1 = 3;
|
||||
break;
|
||||
}
|
||||
if (isWrapped && angle > HALF_TURN_DEGREES) angle -= FULL_TURN_DEGREES;
|
||||
laser.set_aim_angle(normalize_angle_degrees(angle));
|
||||
}
|
||||
|
||||
// The sweep: a long beam swinging back and forth across its quarter until it fades.
|
||||
static void sisters_sweep(Entity_NPC& npc, const SistersView& view)
|
||||
{
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
npc.entityGridCollisionClass = GRIDCOLL_GROUND;
|
||||
int direction = vector_to_direction(npc.targetPosition);
|
||||
if (npc.i1 == STEP_START)
|
||||
{
|
||||
npc.sprite.isFlipX = direction == 0;
|
||||
npc.sprite.Play(LASER_START[direction]);
|
||||
sisters_tracer_keep(npc, direction);
|
||||
if (npc_anim_is_done(npc)) npc.i1++;
|
||||
return;
|
||||
}
|
||||
if (npc.i1 == STEP_LOOP)
|
||||
{
|
||||
sisters_beam_hurt(npc);
|
||||
npc.sprite.Play(LASER_LOOP[direction]);
|
||||
Entity_Laser* laser = sisters_beam_fire(npc, direction, SISTERS_SWEEP_TIMEOUT);
|
||||
laser->Update();
|
||||
npc.entityRef = laser;
|
||||
npc.i1 = (int)(Random() & 1) + 2;
|
||||
return;
|
||||
}
|
||||
if (npc.i1 == 4)
|
||||
{
|
||||
npc.sprite.Play(LASER_END[direction]);
|
||||
if (npc_anim_is_done(npc)) sisters_reset(npc, view.sister);
|
||||
return;
|
||||
}
|
||||
if (npc.i1 > 4) return;
|
||||
if (!npc.entityRef.get())
|
||||
{
|
||||
npc.i1 = 4;
|
||||
return;
|
||||
}
|
||||
sisters_sweep_turn(npc, *static_cast<Entity_Laser*>(npc.entityRef.get()), direction);
|
||||
}
|
||||
|
||||
// The leap: Jumping, then the loop, gliding to its spot from the jump on until it lands there.
|
||||
static void sisters_leap(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.i1 == 0)
|
||||
{
|
||||
npc.sprite.Play("Jumping");
|
||||
npc.i1++;
|
||||
}
|
||||
else if (npc.i1 == 1 && npc_anim_is_done(npc))
|
||||
{
|
||||
npc.sprite.Play("JumpLoop");
|
||||
npc.i1++;
|
||||
}
|
||||
else if (npc.i1 == 2 && vector_length_squared(vector_sub(npc.targetPosition, npc.pos)) < SISTERS_LEAP_ARRIVE_SQUARED)
|
||||
{
|
||||
npc.i1 = 0;
|
||||
npc.state = SISTERS_LAND;
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
}
|
||||
|
||||
if (npc.sprite.WasEventTriggered("Jump")) npc.PlaySound(SOUND_MEAT_JUMPS, 1, 2, false, 1);
|
||||
if (npc.i1 < 2 && !npc.sprite.WasEventTriggered("Jump")) return;
|
||||
|
||||
npc.v1.x = std::min(npc.v1.x + SISTERS_LEAP_STEP, 1.0f);
|
||||
npc.pos = vector_add(vector_scale(npc.pos, 1 - npc.v1.x), vector_scale(npc.targetPosition, npc.v1.x));
|
||||
npc.entityCollisionClass = ENTCOLL_NONE;
|
||||
npc.entityGridCollisionClass = GRIDCOLL_WALLS;
|
||||
}
|
||||
|
||||
// The landing, then the twin beam once both stand (or idle alone).
|
||||
static void sisters_land(Entity_NPC& npc, Entity_NPC* sister)
|
||||
{
|
||||
npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
npc.entityGridCollisionClass = GRIDCOLL_GROUND;
|
||||
if (npc.i1 == 0)
|
||||
{
|
||||
npc.sprite.Play("Landing");
|
||||
npc.i1++;
|
||||
return;
|
||||
}
|
||||
if (npc.i1 == 1)
|
||||
{
|
||||
if (npc.sprite.IsEventTriggered("Landed")) npc.PlaySound(SOUND_MEAT_IMPACTS, 1, 2, false, 1);
|
||||
if (npc_anim_is_done(npc)) npc.i1++;
|
||||
return;
|
||||
}
|
||||
if (!npc_anim_is_done(npc)) return;
|
||||
|
||||
if (!sister)
|
||||
{
|
||||
npc.i1 = 0;
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
}
|
||||
else if (sister->i1 == 2)
|
||||
{
|
||||
npc.i1 = 0;
|
||||
sister->i1 = 0;
|
||||
npc.state = SISTERS_TWIN_BEAM;
|
||||
sister->state = SISTERS_TWIN_BEAM;
|
||||
}
|
||||
}
|
||||
|
||||
// Each sister ignores her Vis' hits, and rages red (hitting harder, rolling and shooting faster) when alone or far
|
||||
// healthier than the other.
|
||||
static SistersView sisters_view(Entity_NPC& npc)
|
||||
{
|
||||
SistersView view;
|
||||
view.sister = static_cast<Entity_NPC*>(npc.child.get());
|
||||
bool isSpawnedTwin = npc.spawnerType == npc.type;
|
||||
view.isFirst = !isSpawnedTwin && view.sister;
|
||||
view.isSecond = isSpawnedTwin && view.sister;
|
||||
view.isImpaired = npc.HasEntityFlags(FLAG_DISTRACTED);
|
||||
view.isSisterInactive = !view.sister || view.sister->HasEntityFlags(FLAG_DISTRACTED);
|
||||
if (!view.sister) npc.i2++;
|
||||
else if (npc.health - view.sister->health > SISTERS_RAGE_GAP) npc.i2 = SISTERS_RAGE_FRAMES;
|
||||
|
||||
if (npc.pendingDamage > 0)
|
||||
for (DamageEvent& event : npc.damageEvents)
|
||||
if (event.source.type == ENTITY_VIS) event.damage = 0;
|
||||
return view;
|
||||
}
|
||||
|
||||
// 00496fb0 The Sisters Vis (410): two sisters leaping to opposite walls and beaming at each other, rolling about in
|
||||
// creep, summoning Vis and Begotten, and beaming, sweeping and spraying alone.
|
||||
void boss_sisters_vis_update(Entity_NPC& npc)
|
||||
{
|
||||
SistersView view = sisters_view(npc);
|
||||
if (npc.state == NPC_STATE_INIT) return sisters_init(npc);
|
||||
|
||||
npc.sprite.color = npc.i2 == 0 ? npc.color : SISTERS_RAGE_COLOR;
|
||||
npc.collisionDamage = npc.i2 == 0 ? 1 : SISTERS_RAGE_DAMAGE;
|
||||
switch (npc.state)
|
||||
{
|
||||
case NPC_STATE_IDLE:
|
||||
sisters_idle(npc, view);
|
||||
break;
|
||||
case SISTERS_SUMMON_BEGOTTEN:
|
||||
case SISTERS_SUMMON_VIS:
|
||||
sisters_summon(npc);
|
||||
break;
|
||||
case SISTERS_ROLL:
|
||||
sisters_roll(npc, view);
|
||||
break;
|
||||
case SISTERS_BEAM:
|
||||
sisters_beam(npc, view);
|
||||
break;
|
||||
case SISTERS_LEAP:
|
||||
sisters_leap(npc);
|
||||
break;
|
||||
case SISTERS_LAND:
|
||||
sisters_land(npc, view.sister);
|
||||
break;
|
||||
case SISTERS_TWIN_BEAM:
|
||||
sisters_twin_beam(npc, view);
|
||||
break;
|
||||
case SISTERS_SPRAY:
|
||||
sisters_spray(npc, view);
|
||||
break;
|
||||
case SISTERS_SWEEP:
|
||||
sisters_sweep(npc, view);
|
||||
break;
|
||||
}
|
||||
|
||||
bool isBeaming = npc.state == SISTERS_BEAM || npc.state == SISTERS_TWIN_BEAM || npc.state == SISTERS_SWEEP ||
|
||||
npc.state == SISTERS_SPRAY;
|
||||
if (!isBeaming) npc.sprite.isFlipX = npc.GetPlayerTarget()->pos.x - npc.pos.x < 0;
|
||||
if (npc.sprite.animState.animData && npc.sprite.IsEventTriggered("ScareSFX"))
|
||||
npc_sound_play(SOUND_SISTERS_VIS_SCARE, 1, 2, 1);
|
||||
npc.friction *= SISTERS_FRICTION;
|
||||
if (npc.i2 > 0) npc.i2--;
|
||||
}
|
||||
Reference in new issue
Block a user