Curation round 22: every NpcAI below type 400, Repentance bosses and Rotgut, the player's last branches, clots and familiars, bomb tear effects and chain lightning, Mother and Home to Dogma, Greed and Greedier, the new Anm2Ed JSON loader, shared IDs folded (135 duplicates)

This commit is contained in:
shweet committed 2026-11-22 21:57:51 -05:00
1 parent 6a11163842
commit b9405bfb31
198 files changed
+21859 -2999

No files matched your search

+155 -35
View File
@@ -1,4 +1,5 @@
#include "entity_npc.h"
#include "boss_repentance.h"
#include "active_items.h"
#include "boss_ai.h"
#include "boss_death.h"
@@ -11,6 +12,7 @@
#include "entity_pickup.h"
#include "entity_player.h"
#include "entity_projectile.h"
#include "entity_text.h"
#include "data.h"
#include "game.h"
#include "grid_entity.h"
@@ -43,6 +45,11 @@ constexpr int ENTITY_NO_DECOY_TYPE = 213;
constexpr uint32_t DOPLE_PICK_SHIFT = 11;
constexpr int ENTITY_UNREACHABLE_EXEMPT = 886;
constexpr int ENTITY_DAMAGE_NUMBERS_TYPE = 964;
constexpr float DAMAGE_NUMBER_MAX = 9999;
constexpr float DAMAGE_NUMBER_MIN = 0.1f;
constexpr float DAMAGE_NUMBER_PRECISION = 10;
constexpr float DAMAGE_NUMBER_RISE = 20;
constexpr float DAMAGE_NUMBER_SPEED = -3;
// G-Fuel's explosions: past 1.5 the big one, which shakes the screen for 40 frames, else one of two small ones for
// 20, their sound pitched 0.9 to 1.1.
@@ -94,7 +101,6 @@ constexpr int ENTITY_FORWARD_DOWN_A = 262;
constexpr int ENTITY_FORWARD_DOWN_B = 263;
constexpr int DEATH_NO_BURST_FIRST = 74;
constexpr int DEATH_NO_BURST_LAST = 76;
constexpr int CHALLENGE_KILL_CHARGE = 33;
constexpr std::string_view BIG_HORN_SPLASH_EVENT = "Poof";
constexpr std::string_view DIRT_LAYER = "dirt";
constexpr std::string_view HOLE_LAYER = "Hole";
@@ -204,8 +210,6 @@ constexpr int TRINKET_ICE_CUBE_ID = 188;
constexpr int ROOM_TRINKET_STATUS_FRAMES = -90;
constexpr int NULLITEM_DAMOCLES_WEAKNESS = 64;
constexpr int CHALLENGE_BEANS = 30;
constexpr int CHALLENGE_SLOW = 22;
constexpr int ACHIEVEMENT_BOSS_COLORS = 3;
constexpr int ACHIEVEMENT_MORE_BOSS_COLORS = 33;
constexpr int ACHIEVEMENT_REDIRECTS = 348;
@@ -213,7 +217,6 @@ constexpr uint32_t ROOM_CONFIG_FLAG_NO_CHAMPIONS = 1 << 2;
constexpr int GRID_CELL = 40;
constexpr float GRID_TOP = 120;
constexpr int SHIELD_FRAMES_DEFAULT = 120;
constexpr uint32_t DEBUG_QUICK_KILL = 1 << 9;
constexpr int BOSS_ID_NONE_EXCLUDED_FIRST = 46;
constexpr int BOSS_ID_NONE_EXCLUDED_LAST = 52;
constexpr int BOSS_ID_EXCLUDED = 38;
@@ -732,14 +735,14 @@ void Entity_NPC::boss_color_roll()
RoomDescriptor* descriptor = game.room->descriptor;
RNG rng = {descriptor ? descriptor->spawnSeed : 0, 1, 11, 16};
if (rng.RandomFloat() < boss_color_chance_get()) subtype = (int)rng.RandomInt(colors) + 1;
if (config->id == ENTITY_MOM && subtype == 2 && game.challenge == CHALLENGE_BEANS) subtype = 0;
if (config->id == ENTITY_MOM && subtype == 2 && game.challenge == CHALLENGE_GUARDIAN) subtype = 0;
}
if (game.stageType == STAGETYPE_REPENTANCE || game.stageType == STAGETYPE_REPENTANCE_B)
{
if (config->id == ENTITY_MOM) subtype = 3;
else if (config->id == ENTITY_MOMS_HEART) subtype = 1;
}
if (subtype == 0 || subtype > colors) return;
if (subtype == 0 || (uint32_t)subtype > (uint32_t)colors) return;
EntityConfig_BossColor color = config->bossColors[subtype - 1];
bosscoloridx = subtype - 1;
@@ -928,6 +931,24 @@ void Entity_NPC::SetBossColorIdx(int bossColorIdx, int)
constexpr ColorMod FRIENDLY_COLOR = {{0.8f, 0.8f, 0.8f, 1}, {1, 1, 1, -0.5f}, {0.1f, 0.1f, 0.1f}};
constexpr ColorMod FROZEN_COLOR = {{0.8f, 0.8f, 0.8f, 1}, {1, 1, 1, 0.5f}, {0.3f, 0.5f, 0.8f}};
// An iced enemy's frozen statue: its weight, health and grid collision points, the cold flash it appears with, the
// mist it trails when shoved (and the creep it leaves now and then), the wall margin it breaks at, and its ten shards.
constexpr float STATUE_HEALTH = 10;
constexpr int STATUE_GRID_POINTS = 8;
constexpr ColorMod STATUE_FLASH = {{0.8f, 0.8f, 0.8f, 1}, {1, 1, 1, 0.5f}, {0.8f, 1, 1.2f}};
constexpr int STATUE_FLASH_FRAMES = 6;
constexpr float STATUE_TRAIL_SCALE_MIN = 0.2f;
constexpr float STATUE_MIST_DRAG = 0.14f;
constexpr float STATUE_MIST_SPIN_MIN = 2;
constexpr float STATUE_MIST_SPIN_RANGE = 10;
constexpr uint32_t STATUE_MIST_FRAMES = 15;
constexpr ColorMod STATUE_MIST_COLOR = {{1, 1, 1, 0.4f}, {0, 0, 0, 0}, {0.8f, 0.9f, 1}};
constexpr float STATUE_WALL_MARGIN = 4;
constexpr int STATUE_SHARDS = 10;
constexpr float STATUE_SHARD_SPEED = 16;
constexpr float STATUE_SHARD_DAMAGE = 7;
constexpr float STATUE_SHARD_FALL = 0.2f;
// The enemy a "random enemy" spawn (type 306) turns into on each stage, on Normal and on Hard.
struct StageEnemy
{
@@ -1203,7 +1224,7 @@ void Entity_NPC::status_overlay_update()
TemporaryEffects& roomEffects = g_game->room->temporaryEffects;
bool isTimeSlowed = roomEffects.HasCollectibleEffect(COLLECTIBLE_STOP_WATCH_ID) ||
roomEffects.HasCollectibleEffect(COLLECTIBLE_HOURGLASS_ID) ||
(g_game->challenge != CHALLENGE_SLOW && g_game->room->brokenWatchState == BROKEN_WATCH_SLOW);
(g_game->challenge != CHALLENGE_SPEED && g_game->room->brokenWatchState == BROKEN_WATCH_SLOW);
bool isTimeImmune = (flags & (FLAG_FRIENDLY | FLAG_NO_STATUS_EFFECTS)) && type != ENTITY_DEATHS_HEAD;
std::string_view animation;
@@ -1808,8 +1829,7 @@ void Entity_NPC::Update()
hitList.clear();
type_update();
if (isDead && !isDeadBefore && !IsBoss() && !config->isBoss && HasEntityFlags(FLAG_ICE))
reconstruction_missing("Entity_NPC::Update 006c4b30: an iced enemy turning into a statue");
if (isDead && !isDeadBefore && !IsBoss() && !config->isBoss && HasEntityFlags(FLAG_ICE)) ice_statue_make();
if (!isDead && state != NPC_STATE_DEATH)
{
ClearEntityFlags(FLAG_EXTRA_GORE);
@@ -1877,7 +1897,7 @@ float Entity_NPC::compute_speed_multiplier()
if (!IsFriendly())
{
if (room.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_STOP_WATCH_ID) ||
(g_game->challenge != CHALLENGE_SLOW && room.brokenWatchState == BROKEN_WATCH_SLOW))
(g_game->challenge != CHALLENGE_SPEED && room.brokenWatchState == BROKEN_WATCH_SLOW))
speed *= SPEED_HALF;
else if (TemporaryEffect* hourglass = room.temporaryEffects.GetCollectibleEffect(COLLECTIBLE_HOURGLASS_ID))
speed *= 1 - std::clamp((float)hourglass->cooldown / SLOW_TIMESCALE_EFFECT_FRAMES, 0.0f, 1.0f) * SPEED_HALF;
@@ -1925,7 +1945,7 @@ bool Entity_NPC::TakeDamage(float damage, uint64_t damageFlags, const EntityRef&
if (attacker && attacker->type != ENTITY_PLAYER) attacker = attacker->spawnerEntity;
Entity_Player* player =
attacker && attacker->type == ENTITY_PLAYER ? static_cast<Entity_Player*>(attacker) : game_nearest_player(pos);
if (damageFlags & DAMAGE_SPAWN_FLY) reconstruction_missing("Entity_NPC::TakeDamage 006d60a0: the hit's blue fly");
if (damageFlags & DAMAGE_SPAWN_FLY) player->AddBlueFlies(1, player->pos, this);
if (!player->proceduralItems.empty())
reconstruction_missing("Entity_NPC::TakeDamage 006d60a0: the attacker's on-hit procedural items");
return isHurt;
@@ -2459,11 +2479,24 @@ void Entity_NPC::spawn_damage_numbers()
if (!isShown || !isVisible || sprite.color._tint[3] <= 0 || health <= 0) return;
if (GetStatusEffectTarget() != this || isInvincible) return;
auto isDealt = [](const DamageEvent& event) {
return event.damage > 0;
};
if (std::ranges::any_of(damageEvents, isDealt))
reconstruction_missing("Entity_NPC::spawn_damage_numbers 006d7010: the damage text");
for (DamageEvent& event : damageEvents)
{
if (event.damage <= 0) continue;
EntitySpawn spawn;
spawn.seed = Random();
spawn.velocity = vector_make(0, DAMAGE_NUMBER_SPEED - random_unit() * 2);
spawn.position = vector_make(pos.x, pos.y - DAMAGE_NUMBER_RISE);
spawn.type = ENTITY_TEXT;
spawn.variant = TEXT_DAMAGE;
Entity* number = g_game->Spawn(spawn);
float shown = std::min(std::floor(event.damage * DAMAGE_NUMBER_PRECISION + HALF) / DAMAGE_NUMBER_PRECISION,
DAMAGE_NUMBER_MAX);
number->targetPosition = vector_make(shown > 0 ? shown : DAMAGE_NUMBER_MIN, maxHitPoints);
number->parent = this;
number->Update();
}
}
// 006d7230 A shielded boss's shield: the damage of its last frames (shieldFrames) averaged per second, and past
@@ -2567,7 +2600,7 @@ void Entity_NPC::kill_items_trigger()
}
}
bool isFriendlyKill = IsFriendly() && g_game->challenge == CHALLENGE_KILL_CHARGE &&
bool isFriendlyKill = IsFriendly() && g_game->challenge == CHALLENGE_POKEY_MANS &&
players.FirstCollectibleOwner(COLLECTIBLE_FRIEND_BALL, LAZARUS_SHARE_CHECK) &&
(spawnerType == ENTITY_PLAYER || spawnerType == ENTITY_FAMILIAR) && spawnerEntity &&
spawnerEntity->type == ENTITY_PLAYER;
@@ -2637,8 +2670,7 @@ void Entity_NPC::trigger_kill_item_effects()
{
if (isBoss) g_game->room->TriggerBossDeath(*this);
else if (isChampion) champion_drop();
if (type == ENTITY_ROTGUT && variant == 1)
reconstruction_missing("rotgut_death_spawn_effects 00581200: Rotgut's death");
if (type == ENTITY_ROTGUT && variant == ROTGUT_MAGGOT) rotgut_death_spawn_effects(*this);
if (HasEntityFlags(FLAG_SPAWN_STICKY_SPIDERS)) sticky_spiders_spawn();
if (!HasEntityFlags(FLAG_NO_REWARD)) kill_rewards_spawn();
@@ -2832,22 +2864,12 @@ void Entity_NPC::Hornfel_UpdateFrame()
reconstruction_missing("Entity_NPC::Hornfel_UpdateFrame 004bb0e0");
}
// 0059e390
void Entity_NPC::CreateBling()
{
reconstruction_missing("Entity_NPC::CreateBling 0059e390");
}
// 0059e4c0
void Entity_NPC::CreateGoldParticles(uint32_t)
{
reconstruction_missing("Entity_NPC::CreateGoldParticles 0059e4c0");
}
// 006be760
// 006be760 Kills it with no source into its own death animation (Flush! and Lua's KillUnique).
void Entity_NPC::KillUnique()
{
reconstruction_missing("Entity_NPC::KillUnique 006be760");
Kill(EntityRef());
state = NPC_STATE_UNIQUE_DEATH;
stateFrame = 0;
}
// A thrown spider: a free landing spot within 100 when none is given, a Strider instead over Downpour's and Dross's
@@ -2890,10 +2912,108 @@ Entity_NPC* Entity_NPC::ThrowSpider(const Vector& position, Entity* spawner, Vec
return spider;
}
// 006ca930
// Part of 006c4b30: an enemy killed while iced does not die. Its killers are rewarded as for a death, then it stands
// as a frozen statue (ENTITY_FROZEN_ENEMY, keeping its type in its state frame): inside the room, heavy, harmless,
// untargetable and alone (every pointer to it dropped), flashing cold. A Blood Puppy's familiar holds on to it.
void Entity_NPC::ice_statue_make()
{
trigger_death_rewards();
for (Entity_Player* player : g_game->playerManager.playerList) player->trigger_npc_death(this);
toxic_shock_creep_spawn();
for (EntityPtr* referrer : referrers) referrer->forget();
referrers.clear();
sprite.Stop();
sprite.StopOverlay();
RemoveStatusEffects();
statusEffectSprite.Reset();
SetCollisionDamage(0);
entityCollisionClass = ENTCOLL_ALL;
if (entityGridCollisionClass < GRIDCOLL_WALLS || entityGridCollisionClass == GRIDCOLL_PITSONLY)
entityGridCollisionClass = GRIDCOLL_WALLS;
pos = g_game->room->GetClampedPosition(pos, 0);
if (config->gridCollisionPoints < 1) SetSize(size, sizeMulti, STATUE_GRID_POINTS);
mass = STATUE_MASS;
isDead = false;
isCanShutDoors = false;
isBoss = false;
isInvincible = true;
AddEntityFlags(FLAG_NO_STATUS_EFFECTS | FLAG_NO_TARGET | FLAG_NO_BLOOD_SPLASH | FLAG_ICE_FROZEN);
health = STATUE_HEALTH;
maxHitPoints = STATUE_HEALTH;
if (type == ENTITY_BLOOD_PUPPY && parent && parent->IsFamiliar()) static_cast<Entity_Familiar*>(parent.get())->linkedEntity = this;
spawnerType = 0;
spawnerVariant = 0;
spawnerEntity = nullptr;
parent = nullptr;
child = nullptr;
target = nullptr;
stateFrame = type;
type = ENTITY_FROZEN_ENEMY;
ResetColor();
SetColor(STATUE_FLASH, STATUE_FLASH_FRAMES, 1, true, true);
}
// 006ca930 A frozen statue's frame: it slows, and each hit it took chips one of its ten points (an explosion or a
// crush breaks it at once). Shoved, it slides with a trail of cold mist and breaks on the first wall. Broken, it gives
// its kill's item effects and bursts into ten ice shards that slow, stronger the deeper the floor.
void Entity_NPC::update_frozen()
{
reconstruction_missing("Entity_NPC::update_frozen 006ca930");
friction *= HALF;
for (const DamageEvent& hit : damageEvents)
{
if (isDead) break;
if (hit.damageFlags & (DAMAGE_EXPLOSION | DAMAGE_CRUSH) || --health <= 0) Kill(EntityRef());
}
damageEvents.clear();
pendingDamage = 0;
pendingDamageFlags = 0;
Entity::Update();
if (HasEntityFlags(FLAG_KNOCKED_BACK))
{
if ((Random() & 1) == 0)
{
Entity* creep = g_game->Spawn({.position = pos, .type = ENTITY_EFFECT, .variant = EFFECT_PLAYER_CREEP_HOLYWATER_TRAIL,
.seed = Random()});
float scale = random_unit() * HALF + STATUE_TRAIL_SCALE_MIN;
creep->sprite.scale = vector_make(scale, scale);
creep->Update();
}
auto* mist = static_cast<Entity_Effect*>(g_game->Spawn({.position = pos, .velocity = vector_scale(velocity, STATUE_MIST_DRAG),
.type = ENTITY_EFFECT, .variant = EFFECT_DUST_CLOUD, .seed = Random()}));
mist->rotation = random_unit() * STATUE_MIST_SPIN_RANGE + STATUE_MIST_SPIN_MIN;
mist->SetTimeout((int)(Random() % STATUE_MIST_FRAMES) + STATUE_MIST_FRAMES);
mist->posOffset = posOffset;
mist->sprite.GetLayer(0)->color = STATUE_MIST_COLOR;
if (isCollidesWithGrid)
{
pos = g_game->room->GetClampedPositionImpl(vector_sub(pos, gridCollisionVelocity), STATUE_WALL_MARGIN, STATUE_WALL_MARGIN,
STATUE_WALL_MARGIN, STATUE_WALL_MARGIN);
Kill(EntityRef());
}
}
if (!isDead) return;
trigger_kill_item_effects();
float damage = (float)g_game->stage + STATUE_SHARD_DAMAGE;
float turn = random_unit() * FULL_TURN_DEGREES;
TearFlags flags;
flags.set(TEAR_ICE_FLAG);
flags.set(TEAR_SLOW);
for (int i = 0; i < STATUE_SHARDS; i++)
{
Vector velocity = vector_scale(vector_from_angle(i * FULL_TURN_DEGREES / STATUE_SHARDS + turn), STATUE_SHARD_SPEED);
auto* shard = static_cast<Entity_Tear*>(g_game->Spawn({.position = pos, .velocity = velocity, .type = ENTITY_TEAR,
.variant = TEAR_ICE, .seed = Random()}));
shard->SetCollisionDamage(damage);
shard->SetTearFlags(flags);
shard->fallingAccel = STATUE_SHARD_FALL;
shard->spawnerType = ENTITY_PLAYER;
shard->Update();
}
}
// 006d0c60