Curation round 17: Theora and Vorbis cutscene videos, Ludovico, Epic and Dr. Fetus, Tractor Beam and Eye of the Occult, familiars and blue spiders, fortune teller and restock, the Bag of Crafting and four tainted characters, ten enemies, water and the ultra secret door, Isaac, ???, the Lamb and Hush
This commit is contained in:
1 parent
e9de039d0f
commit
024cb12016
133 files changed
+13325
-2520
No files matched your search
+364
-1
@@ -1,7 +1,10 @@
|
||||
#include "boss_ai.h"
|
||||
#include "entity_effect_combat.h"
|
||||
#include "loot_list.h"
|
||||
#include "npc_caves.h"
|
||||
#include "room_grid.h"
|
||||
#include "sfx_manager.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
// Polycephalus's subtypes (the red one, and the pair) and the Stain's grey one. Variant 1 is the Pile.
|
||||
@@ -350,11 +353,371 @@ static void polycephalus_surface(Entity_NPC& npc, bool isGrey)
|
||||
if (npc_anim_is_done(npc)) npc.state = NPC_STATE_IDLE;
|
||||
}
|
||||
|
||||
// The Pile's moves (the outcomes it draws among), and its burrow phases (i1's second byte).
|
||||
enum PileMove
|
||||
{
|
||||
PILE_CHARGE,
|
||||
PILE_SPIKES,
|
||||
PILE_SUMMON,
|
||||
PILE_BURROW
|
||||
};
|
||||
|
||||
// The Pile's rests, burrow and surfacing spot (away from players, near its target), shots, charge and spikes.
|
||||
constexpr uint32_t PILE_REST_SPREAD = 30;
|
||||
constexpr int PILE_REST_MIN = 30;
|
||||
constexpr float PILE_WANDER_SPEED = 0.3f;
|
||||
constexpr float PILE_FRICTION = 0.8f;
|
||||
constexpr int PILE_ENEMY_LIMIT = 3;
|
||||
constexpr int PILE_BURROWS = 3;
|
||||
constexpr int PILE_SINK_FRAMES = 10;
|
||||
constexpr int PILE_DIG_STEP = 3;
|
||||
constexpr float PILE_PLAYER_REACH = 5000;
|
||||
constexpr float PILE_CLEARANCE_SQUARED = 6400;
|
||||
constexpr float PILE_SPOT_BEST = 10000;
|
||||
constexpr int PILE_SPOT_TRIES = 10;
|
||||
constexpr float PILE_SPOT_REACH = 120;
|
||||
constexpr float PILE_SPOT_REACH_SPREAD = 0.2f;
|
||||
constexpr float PILE_SPOT_REACH_MIN = 0.8f;
|
||||
constexpr float PILE_SPOT_FREE_STEP = 40;
|
||||
constexpr float PILE_SPOT_NEAR_CAP = 22500;
|
||||
constexpr float PILE_DIG_SPAN = 100;
|
||||
constexpr int PILE_DIG_FRAMES = 6;
|
||||
constexpr float PILE_DIG_SPEED = 2;
|
||||
constexpr float PILE_SHOT_SPEED = 10;
|
||||
constexpr int PILE_LAST_BURROW = 2;
|
||||
constexpr int PILE_DIG_DELAY = 10;
|
||||
constexpr float PILE_CHARGE_SPEED = 4;
|
||||
constexpr int PILE_ROAR_DELAY = 20;
|
||||
constexpr int PILE_CRASH_SHAKE = 15;
|
||||
constexpr float PILE_CRASH_VOLUME = 2;
|
||||
constexpr int PILE_CRASH_SHOTS = 20;
|
||||
constexpr int PILE_CRACKS = 4;
|
||||
constexpr float PILE_CRACK_STEP = 90;
|
||||
constexpr float PILE_CRACK_START = 45;
|
||||
constexpr int PILE_CRACK_SUBTYPE = 2;
|
||||
constexpr int PILE_DUST_COUNT = 2;
|
||||
constexpr float PILE_DUST_SPEED = 6;
|
||||
constexpr float PILE_DUST_HEIGHT = 100000;
|
||||
constexpr int PILE_DUST_SUBTYPE = 0x20000;
|
||||
constexpr float PILE_BONY_REACH = 60;
|
||||
constexpr int PILE_SPIKE_COOLDOWN = 6;
|
||||
constexpr float PILE_CELL = 40;
|
||||
constexpr float PILE_CELL_ROUND = 0.5f;
|
||||
constexpr ColorMod PILE_SPIKE_COLOR = {{1, 1, 1, 1}, {1, 1, 1, 1}, {0, 0, 0}};
|
||||
|
||||
// The Pile's first move never charges or raises spikes. It only summons with few enemies about.
|
||||
static void pile_move_pick(Entity_NPC& npc)
|
||||
{
|
||||
WeightedOutcomePicker picker;
|
||||
bool isFirst = npc.i1 & 0xff;
|
||||
if (!isFirst)
|
||||
{
|
||||
picker.AddOutcomeWeight(PILE_CHARGE, 1);
|
||||
picker.AddOutcomeWeight(PILE_SPIKES, 1);
|
||||
}
|
||||
if (g_game->room->GetAliveEnemiesCount() < PILE_ENEMY_LIMIT) picker.AddOutcomeWeight(PILE_SUMMON, 1);
|
||||
picker.AddOutcomeWeight(PILE_BURROW, 1);
|
||||
|
||||
switch (picker.PickOutcome({Random() | 1, 5, 9, 7}))
|
||||
{
|
||||
case PILE_CHARGE:
|
||||
npc.state = NPC_STATE_ATTACK2;
|
||||
npc.projectileCooldown = 0;
|
||||
break;
|
||||
case PILE_SPIKES:
|
||||
{
|
||||
Room& room = *g_game->room;
|
||||
int column = (int)((npc.pos.x - PILE_CELL) / PILE_CELL + PILE_CELL_ROUND);
|
||||
int row = (int)((npc.pos.y - PILE_CELL * 3) / PILE_CELL + PILE_CELL_ROUND);
|
||||
int reach = std::max({row, column, room.gridWidth - column - 1, room.gridHeight - row - 1});
|
||||
npc.state = NPC_STATE_SUMMON2;
|
||||
npc.projectileDelay = reach * 2;
|
||||
npc.projectileCooldown = PILE_SPIKE_COOLDOWN;
|
||||
npc.PlaySound(SOUND_GRROOWL, 1, 2, false, 1);
|
||||
break;
|
||||
}
|
||||
case PILE_SUMMON:
|
||||
npc.state = NPC_STATE_SUMMON;
|
||||
break;
|
||||
default:
|
||||
npc.state = NPC_STATE_JUMP;
|
||||
npc.projectileDelay = PILE_BURROWS;
|
||||
npc.i1 &= ~0xff00;
|
||||
npc_sound_play(SOUND_MAGGOT_ENTER_GROUND, 1, PILE_DIG_DELAY, 1);
|
||||
}
|
||||
npc.i1 &= ~0xff;
|
||||
}
|
||||
|
||||
// A random spot about a center, a fraction of the Pile's reach away.
|
||||
static Vector pile_spot_roll(Vector center)
|
||||
{
|
||||
float angle = random_unit() * RANDOM_HALF_TURN;
|
||||
angle += angle;
|
||||
float reach = (random_unit() * PILE_SPOT_REACH_SPREAD + PILE_SPOT_REACH_MIN) * PILE_SPOT_REACH;
|
||||
return vector_make(std::cos(angle) * reach + center.x, std::sin(angle) * reach + center.y);
|
||||
}
|
||||
|
||||
// Where to surface: the best of ten free spots near its target, kept away from the players and from itself.
|
||||
static void pile_surface_pick(Entity_NPC& npc)
|
||||
{
|
||||
Room& room = *g_game->room;
|
||||
Vector center = npc.CalcTargetPosition(0);
|
||||
Vector best{};
|
||||
float bestScore = 0;
|
||||
for (int i = 0; i < PILE_SPOT_TRIES; i++)
|
||||
{
|
||||
Vector spot = room_free_pickup_position_find(
|
||||
{.position = pile_spot_roll(center), .isAvoidActiveEntities = true});
|
||||
if (!room.IsPositionInRoom(spot, 0) || room_grid_collision_at(spot) != 0) continue;
|
||||
Entity* player = game_nearest_target_player(spot, &npc, false, false, PILE_PLAYER_REACH);
|
||||
if (!player) continue;
|
||||
float playerDistance = vector_length_squared(vector_sub(player->pos, spot));
|
||||
if (playerDistance <= PILE_CLEARANCE_SQUARED) continue;
|
||||
float score = std::min(vector_length_squared(vector_sub(npc.pos, spot)), PILE_SPOT_NEAR_CAP) +
|
||||
playerDistance + playerDistance;
|
||||
if (bestScore >= score) continue;
|
||||
best = spot;
|
||||
bestScore = score;
|
||||
}
|
||||
npc.targetPosition = best;
|
||||
float span = std::max(vector_length(vector_sub(npc.pos, best)) / PILE_DIG_SPAN, 1.0f);
|
||||
npc.projectileCooldown = (int)(span * PILE_DIG_FRAMES);
|
||||
}
|
||||
|
||||
// Digging toward its spot: one a player nears is swapped for the nearest of ten clear ones about that player.
|
||||
static void pile_dig(Entity_NPC& npc, int ticks)
|
||||
{
|
||||
npc.projectileCooldown = std::max(npc.projectileCooldown - ticks, 0);
|
||||
if (npc.projectileCooldown == 0 || (ticks > 0 && npc.projectileCooldown % PILE_DIG_STEP == 0))
|
||||
{
|
||||
Room& room = *g_game->room;
|
||||
Vector old = npc.targetPosition;
|
||||
Entity* player = game_nearest_target_player(old, &npc, false, false, PILE_PLAYER_REACH);
|
||||
if (vector_length_squared(vector_sub(player->pos, old)) <= PILE_CLEARANCE_SQUARED)
|
||||
{
|
||||
float bestDistance = PILE_SPOT_BEST;
|
||||
for (int i = 0; i < PILE_SPOT_TRIES; i++)
|
||||
{
|
||||
Vector spot = room_free_pickup_position_find(
|
||||
{.position = pile_spot_roll(player->pos), .step = PILE_SPOT_FREE_STEP, .isAvoidActiveEntities = true});
|
||||
if (!room.IsPositionInRoom(spot, 0) || room_grid_collision_at(spot) != 0 ||
|
||||
vector_length_squared(vector_sub(player->pos, spot)) <= PILE_CLEARANCE_SQUARED)
|
||||
continue;
|
||||
float distance = vector_length_squared(vector_sub(old, spot));
|
||||
if (distance >= bestDistance) continue;
|
||||
npc.targetPosition = spot;
|
||||
bestDistance = distance;
|
||||
}
|
||||
npc.projectileCooldown = std::max(npc.projectileCooldown, 1);
|
||||
}
|
||||
}
|
||||
npc.pathfinder.FindGridPath(npc.targetPosition, PILE_DIG_SPEED, 0, DIRECT_PATH_FAR);
|
||||
}
|
||||
|
||||
// Its burrow: under it goes, digs to a spot away from the players, and comes up there to shoot.
|
||||
static void pile_burrow(Entity_NPC& npc, int ticks)
|
||||
{
|
||||
npc.UpdateDirtColor(false);
|
||||
if (!(npc.i1 & 0xff00))
|
||||
{
|
||||
npc.sprite.Play("GoUnder");
|
||||
if (!npc.sprite.IsFinished("GoUnder")) return;
|
||||
npc.targetPosition = {};
|
||||
npc.v1 = npc.pos;
|
||||
npc.i1 |= 0x100;
|
||||
npc.projectileCooldown = PILE_SINK_FRAMES;
|
||||
return;
|
||||
}
|
||||
if (npc.projectileCooldown >= 1)
|
||||
{
|
||||
npc.sprite.Play("DirtShrink");
|
||||
npc.entityCollisionClass = ENTCOLL_NONE;
|
||||
if (vector_is_zero(npc.targetPosition)) pile_surface_pick(npc);
|
||||
else pile_dig(npc, ticks);
|
||||
return;
|
||||
}
|
||||
if (npc.projectileCooldown == 0)
|
||||
{
|
||||
npc.pos = npc.targetPosition;
|
||||
npc.sprite.Play("ComeUp");
|
||||
npc.projectileCooldown = -1;
|
||||
npc.UpdateDirtColor(true);
|
||||
return;
|
||||
}
|
||||
if (npc.sprite.GetFrame() == 1) npc.entityCollisionClass = ENTCOLL_ALL;
|
||||
if (!npc.sprite.IsFinished("ComeUp")) return;
|
||||
npc.targetPosition = npc.GetPlayerTarget()->pos;
|
||||
npc.state = NPC_STATE_ATTACK;
|
||||
}
|
||||
|
||||
// Surfaced, it spits five bones at its target, then burrows again (three times in all, the last with Attack3).
|
||||
static void pile_shoot(Entity_NPC& npc)
|
||||
{
|
||||
const char* anim = npc.projectileDelay < PILE_LAST_BURROW ? "Attack3" : "Attack1";
|
||||
npc.sprite.Play(anim);
|
||||
if (npc.sprite.IsEventTriggered("Shoot"))
|
||||
{
|
||||
npc.PlaySound(SOUND_GHOST_SHOOT, 1, 2, false, 1);
|
||||
ProjectileParams params;
|
||||
params.variant = PROJECTILE_BONE;
|
||||
Vector aim = vector_scale(vector_normalized(vector_sub(npc.targetPosition, npc.pos)), PILE_SHOT_SPEED);
|
||||
npc.FireProjectiles(npc.pos, aim, PROJECTILES_FIVE, params);
|
||||
}
|
||||
if (!npc.sprite.IsFinished(anim)) return;
|
||||
npc.i1 &= ~0xff00;
|
||||
if (--npc.projectileDelay < 1)
|
||||
{
|
||||
npc.stateFrame = (int)(Random() % PILE_REST_SPREAD) + PILE_REST_MIN;
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
npc.state = NPC_STATE_JUMP;
|
||||
npc_sound_play(SOUND_MAGGOT_ENTER_GROUND, 1, PILE_DIG_DELAY, 1);
|
||||
}
|
||||
|
||||
// Its charge: it rolls at its target, kicking up dirt, until it hits a wall, which cracks the floor four ways and
|
||||
// rains bones on its target.
|
||||
static void pile_charge(Entity_NPC& npc, int ticks)
|
||||
{
|
||||
npc.UpdateDirtColor(false);
|
||||
if (npc.projectileCooldown == 0)
|
||||
{
|
||||
npc.sprite.Play("ChargeBegin");
|
||||
if (!npc.sprite.IsEventTriggered("StartCharge")) return;
|
||||
npc.v1 = vector_scale(vector_normalized(vector_sub(npc.GetPlayerTarget()->pos, npc.pos)), PILE_CHARGE_SPEED);
|
||||
npc.PlaySound(SOUND_MONSTER_ROAR_0, 1, PILE_ROAR_DELAY, false, 1);
|
||||
npc_sound_play(SOUND_MAGGOT_BURST_OUT, 1, PILE_ROAR_DELAY, 1);
|
||||
npc.projectileCooldown = 1;
|
||||
return;
|
||||
}
|
||||
if (npc.projectileCooldown == 1)
|
||||
{
|
||||
if (npc_anim_is_done(npc)) npc.sprite.Play("ChargeLoop");
|
||||
if (ticks > 0)
|
||||
{
|
||||
g_game->Spawn({.position = npc.pos, .type = ENTITY_EFFECT, .variant = EFFECT_DIRT_PILE, .seed = Random()});
|
||||
game_particles_spawn({.position = vector_add(vector_add(npc.velocity, npc.velocity), npc.pos),
|
||||
.height = PILE_DUST_HEIGHT,
|
||||
.speed = PILE_DUST_SPEED,
|
||||
.count = PILE_DUST_COUNT,
|
||||
.subType = PILE_DUST_SUBTYPE,
|
||||
.variant = EFFECT_ROCK_PARTICLE});
|
||||
}
|
||||
npc.AddVelocity_divided(npc.v1, false);
|
||||
if (!npc.isCollidesWithGrid) return;
|
||||
|
||||
npc_sound_play(SOUND_HELLBOSS_GROUNDPOUND, PILE_CRASH_VOLUME, 2, 1);
|
||||
game_shake_screen(PILE_CRASH_SHAKE);
|
||||
npc.projectileDelay = PILE_CRASH_SHOTS;
|
||||
for (int i = 0; i < PILE_CRACKS; i++)
|
||||
{
|
||||
auto* crack = static_cast<Entity_Effect*>(g_game->Spawn({.position = npc.pos, .spawner = &npc,
|
||||
.subType = PILE_CRACK_SUBTYPE,
|
||||
.type = ENTITY_EFFECT,
|
||||
.variant = EFFECT_CRACKWAVE, .seed = Random()}));
|
||||
crack->parent = &npc;
|
||||
crack->rotation = (float)i * PILE_CRACK_STEP + PILE_CRACK_START;
|
||||
}
|
||||
npc.velocity = {};
|
||||
npc.sprite.Play("ChargeEnd");
|
||||
npc.projectileCooldown = 2;
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < ticks && npc.projectileDelay != 0; i++)
|
||||
{
|
||||
if (--npc.projectileDelay & 1) continue;
|
||||
Entity* target = npc.GetPlayerTarget();
|
||||
ProjectileParams params;
|
||||
params.variant = PROJECTILE_BONE;
|
||||
for (int shots = (int)(Random() & 1) + 1; shots != 0; shots--)
|
||||
npc.FireBossProjectiles(1, target->pos, 1, params);
|
||||
}
|
||||
}
|
||||
|
||||
// Its spikes: rings of spikes ripple out from it a cell at a time, along the four axes.
|
||||
static void pile_spikes(Entity_NPC& npc, int ticks)
|
||||
{
|
||||
if (npc.projectileCooldown != 0) npc.projectileCooldown = std::max(npc.projectileCooldown - ticks, 0);
|
||||
else
|
||||
{
|
||||
Room& room = *g_game->room;
|
||||
for (int i = 0; i < ticks && npc.projectileDelay >= 1; i++, npc.projectileDelay--)
|
||||
{
|
||||
if (npc.projectileDelay & 1) continue;
|
||||
Vector cell = room.GetGridPosition(room.GetGridIndex(npc.pos));
|
||||
for (int direction = 0; direction < 4; direction++)
|
||||
{
|
||||
float reach = (float)(npc.projectileDelay / 2) * PILE_CELL;
|
||||
Vector spot = vector_add(cell, vector_scale(vector_from_direction(direction), reach));
|
||||
if (!room.IsPositionInRoom(spot, 0) || room_grid_collision_at(spot) != 0) continue;
|
||||
Entity* spike = g_game->Spawn({.position = spot, .spawner = &npc, .type = ENTITY_EFFECT,
|
||||
.variant = EFFECT_SPIKE, .seed = Random()});
|
||||
spike->sprite.color = PILE_SPIKE_COLOR;
|
||||
spike->Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
npc.sprite.Play("Summon");
|
||||
if (!npc_anim_is_done(npc)) return;
|
||||
if (npc.projectileDelay != 0) return npc.sprite.Play("Idle");
|
||||
npc.stateFrame = (int)(Random() % PILE_REST_SPREAD) + PILE_REST_MIN;
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
}
|
||||
|
||||
// 005983f0 NpcAI::ENTITY_POLYCEPHALUS_the_pile: the Pile wanders, then burrows to surface and spit bones, charges a
|
||||
// wall, raises rings of spikes, or digs up a Bony.
|
||||
static void pile_update(Entity_NPC& npc)
|
||||
{
|
||||
int ticks = npc_ticks_get(npc);
|
||||
npc.friction *= PILE_FRICTION;
|
||||
switch (npc.state)
|
||||
{
|
||||
case NPC_STATE_INIT:
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
npc.stateFrame = (int)(Random() % PILE_REST_SPREAD) + PILE_REST_MIN;
|
||||
npc.i1 = (npc.i1 & ~0xff) | 1;
|
||||
npc.AddEntityFlags(FLAG_NO_BLOOD_SPLASH);
|
||||
return;
|
||||
case NPC_STATE_IDLE:
|
||||
npc.UpdateDirtColor(false);
|
||||
npc.sprite.Play("Idle");
|
||||
npc.pathfinder.MoveRandomlyAxisAligned(PILE_WANDER_SPEED, STATUS_OBEYED);
|
||||
if (npc.stateFrame < 1) pile_move_pick(npc);
|
||||
else npc.stateFrame -= ticks;
|
||||
return;
|
||||
case NPC_STATE_JUMP:
|
||||
return pile_burrow(npc, ticks);
|
||||
case NPC_STATE_ATTACK:
|
||||
return pile_shoot(npc);
|
||||
case NPC_STATE_ATTACK2:
|
||||
if (npc.projectileCooldown < 2) return pile_charge(npc, ticks);
|
||||
pile_charge(npc, ticks);
|
||||
break;
|
||||
case NPC_STATE_SUMMON:
|
||||
npc.sprite.Play("Attack3");
|
||||
if (npc.sprite.IsEventTriggered("Shoot"))
|
||||
{
|
||||
npc_sound_play(SOUND_SUMMONSOUND, 1, 2, 1);
|
||||
uint32_t seed = Random();
|
||||
Vector spot = vector_add(vector_scale(random_direction(), PILE_BONY_REACH), npc.pos);
|
||||
g_game->Spawn({.position = spot, .spawner = &npc, .type = ENTITY_BONY, .seed = seed})->Update();
|
||||
}
|
||||
break;
|
||||
case NPC_STATE_SUMMON2:
|
||||
return pile_spikes(npc, ticks);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (!npc_anim_is_done(npc)) return;
|
||||
npc.stateFrame = (int)(Random() % PILE_REST_SPREAD) + PILE_REST_MIN;
|
||||
npc.state = NPC_STATE_IDLE;
|
||||
}
|
||||
|
||||
// 00489ca0 NpcAI::ENTITY_POLYCEPHALUS: Polycephalus and the Stain burrow about and surface near their target to
|
||||
// shoot, spray creep, spin rings of shots or summon. The Pile (variant 1) has its own AI.
|
||||
void boss_polycephalus_update(Entity_NPC& npc)
|
||||
{
|
||||
if (npc.variant == POLYCEPHALUS_PILE) return (void)NpcAI::ENTITY_POLYCEPHALUS_the_pile(&npc);
|
||||
if (npc.variant == POLYCEPHALUS_PILE) return pile_update(npc);
|
||||
bool isGrey = npc.type == ENTITY_STAIN && npc.subtype == STAIN_GREY;
|
||||
npc.i2++;
|
||||
|
||||
|
||||
Reference in new issue
Block a user