Curation round 10: combat, pathfinding, death and game over, items and stats, room state, Continue, Lua callbacks

Seven agents took over tear and contact collision, NPC death with blood and gibs, champions, PathFinder, the Gaper's
kin, the player's death with the game over screen, item pedestals with collectible pickup, AddCollectible and
EvaluateItems, room state save and restore, GameState::read, pressure plates, fireplaces, entity lights, ambient
sounds, and one Lua callback enum with gated runners. Integration reconstructed Room::Update's loot preview and
Entity_NPC::UpdatePickupGhosts and replaced a leftover Sacred Orb stub that stopped every pedestal roll.
Under gdb: Gapers die with blood and gibs, a cleared room opens its doors, the treasure room's item is taken (banner,
costume, stats: a Magic Mushroom gives damage 3.5 -> 6.12 and a heart), death leads to the game over diary, and a saved
run is read back on the next boot with Continue offered. 3028 functions taken over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-20 09:55:14 -05:00
1 parent 48933cd312
commit d8385e6c64
64 files changed
+8665 -3059

No files matched your search

+358 -35
View File
@@ -193,6 +193,7 @@ constexpr int COLLECTIBLE_CONTAGION_ID = 466;
constexpr int COLLECTIBLE_BROKEN_MODEM_ID = 514;
constexpr int COLLECTIBLE_SANGUINE_BOND_ID = 640;
constexpr int COLLECTIBLE_VASCULITIS_ID = 657;
constexpr int COLLECTIBLE_GUPPYS_EYE_ID = 665;
constexpr int COLLECTIBLE_BONE_SPURS_ID = 683;
constexpr int COLLECTIBLE_LIL_ABADDON_ID = 684;
constexpr int COLLECTIBLE_SALVATION_ID = 696;
@@ -612,7 +613,7 @@ void Entity_NPC::Init(int entityType, int entityVariant, int entitySubType, uint
pathfinder.Reset();
if (isBoss) reconstruction_missing("Entity_NPC::Init 006b8b20: the room's boss count (Room+0x7224)");
totalDamageTaken = 0;
lua_callback_check(CALLBACK_POST_NPC_INIT, "Entity_NPC::Init 006b8b20: MC_POST_NPC_INIT");
lua_engine_get().PostNPCInit(this);
}
// The odds a boss spawns in one of its alternate colors.
@@ -837,17 +838,247 @@ void Entity_NPC::SetBossColorIdx(int bossColorIdx, int)
ResetColor();
}
// 006d03e0
void Entity_NPC::MakeChampion(uint32_t, int, bool)
// A champion color's look, the exe's table at 00c354c0: the color its _champion sheets draw in (none without alpha)
// and the color its sprite otherwise shows.
struct ChampionLook
{
reconstruction_missing("Entity_NPC::MakeChampion 006d03e0");
ColorMod sheetColor;
ColorMod spriteColor;
};
// A look from its sheet color's channels and its sprite's tint and offset.
constexpr ChampionLook champion_look(float red, float green, float blue, float alpha, ColorMod spriteColor = COLOR_DEFAULT)
{
return {{{red, green, blue, alpha}, {0, 0, 0, 0}, {0, 0, 0}}, spriteColor};
}
// 00c354c0 (data) The table of champion looks.
constexpr float CHAMPION_GLOW = 30 / 255.0f;
constexpr std::array<ChampionLook, CHAMPION_COUNT> CHAMPION_LOOKS = {{
champion_look(1, 0.1f, 0.1f, 1),
champion_look(0.6f, 0.6f, 0, 1),
champion_look(0.1f, 0.8f, 0.2f, 1),
champion_look(1, 0.6f, 0.2f, 1),
champion_look(0.2f, 0.2f, 1, 1),
champion_look(0.03f, 0.24f, 0.24f, 1),
champion_look(1, 1, 1, 1, {{1, 1, 1, 1}, {0, 0, 0, 0}, {90 / 255.0f, 90 / 255.0f, 90 / 255.0f}}),
champion_look(0.5f, 0.5f, 0.5f, 1),
champion_look(1, 1, 1, 1, {{1, 1, 1, 0.6f}, {0, 0, 0, 0}, {120 / 255.0f, 120 / 255.0f, 120 / 255.0f}}),
champion_look(0, 0, 0, 0, {{0, 0, 0, 1}, {0, 0, 0, 0}, {0, 0, 0}}),
champion_look(1, 0, 1, 1),
champion_look(0.75f, 0, 1, 1),
champion_look(0.5f, 0, 0, 1),
champion_look(0.5f, 0.5f, 1, 1),
champion_look(0, 0, 0, 0),
champion_look(0.1f, 0.8f, 0.2f, 1, {{0.9f, 1, 0.9f, 1}, {0, 0, 0, 0}, {0, CHAMPION_GLOW, 0}}),
champion_look(0.5f, 0.5f, 0.5f, 1, {{0.9f, 0.9f, 0.9f, 1}, {0, 0, 0, 0}, {CHAMPION_GLOW, CHAMPION_GLOW, CHAMPION_GLOW}}),
champion_look(0.8f, 0.8f, 0.8f, 1, {{1, 1, 1, 1}, {0, 0, 0, 0}, {50 / 255.0f, 50 / 255.0f, 50 / 255.0f}}),
champion_look(0, 0, 0, 0),
champion_look(0, 0, 0, 0),
champion_look(1, 0.2f, 0.2f, 1, {{1, 0.9f, 0.9f, 1}, {0, 0, 0, 0}, {CHAMPION_GLOW, 0, 0}}),
champion_look(0, 0, 0, 0),
champion_look(0, 0, 0, 0),
champion_look(0.3f, 0.3f, 0.3f, 1, {{0.8f, 0.8f, 0.8f, 1}, {0, 0, 0, 0}, {0, 0, 0}}),
champion_look(0.28f, 0.14f, 0.134f, 1),
champion_look(1, 1, 1, 1),
}};
// The colors a seed's champion roll picks among: the common ones (the late stages' with yellow), the rare, the
// pulsing and sized, the late stages' special ones, and the late stages' uncommon ones.
constexpr std::array<int, 6> CHAMPIONS_EARLY = {CHAMPION_RED, CHAMPION_GREEN, CHAMPION_DARK_GREEN,
CHAMPION_GREY, CHAMPION_PINK, CHAMPION_LIGHT_BLUE};
constexpr std::array<int, 7> CHAMPIONS_LATE = {CHAMPION_RED, CHAMPION_YELLOW, CHAMPION_GREEN, CHAMPION_DARK_GREEN,
CHAMPION_GREY, CHAMPION_PINK, CHAMPION_LIGHT_BLUE};
constexpr std::array<int, 3> CHAMPIONS_RARE = {CHAMPION_ORANGE, CHAMPION_DARK_BLUE, CHAMPION_DARK_RED};
constexpr std::array<int, 6> CHAMPIONS_PULSING = {CHAMPION_CAMO, CHAMPION_PULSE_GREEN, CHAMPION_PULSE_GREY,
CHAMPION_FLY_PROTECTED, CHAMPION_TINY, CHAMPION_GIANT};
constexpr std::array<int, 4> CHAMPIONS_SPECIAL = {CHAMPION_PULSE_RED, CHAMPION_SIZE_PULSE, CHAMPION_KING,
CHAMPION_DEATH};
constexpr std::array<int, 4> CHAMPIONS_UNCOMMON = {CHAMPION_TRANSPARENT, CHAMPION_FLICKER, CHAMPION_PURPLE,
CHAMPION_BROWN};
constexpr uint32_t CHAMPION_RNG_SHIFT_INDEX = 33;
constexpr uint32_t CHAMPION_LATE_STAGE = 5;
constexpr uint32_t CHAMPION_YELLOW_STAGE = 3;
constexpr uint32_t CHAMPION_PULSING_EARLY_COUNT = 4;
constexpr float CHAMPION_ROLL_WHITE = 0.005f;
constexpr float CHAMPION_ROLL_RAINBOW = 0.01f;
constexpr float CHAMPION_ROLL_UNCOMMON = 0.05f;
constexpr float CHAMPION_ROLL_RARE = 0.15f;
constexpr float CHAMPION_ROLL_PULSING = 0.3f;
constexpr float CHAMPION_ROLL_SPECIAL = 0.35f;
constexpr std::array<int, 4> CHAMPION_NO_DARK_RED_TYPES = {240, 241, 242, 304};
constexpr int ENTITY_NO_WHITE_CHAMPION = 889;
// The champions' health, speed, size and contact damage, and the effect variant some keep around them.
constexpr float CHAMPION_SCALE = 1.15f;
constexpr float CHAMPION_TINY_SCALE = 0.5f;
constexpr float CHAMPION_GIANT_SCALE = 1.5f;
constexpr float CHAMPION_CONTACT_DAMAGE = 2;
constexpr float CHAMPION_DEATH_CONTACT_DAMAGE = 4;
constexpr float CHAMPION_HP_RED = 1.333f;
constexpr float CHAMPION_HP_YELLOW = 0.75f;
constexpr float CHAMPION_HP_GREY = 0.333f;
constexpr float CHAMPION_HP_BIG = 1.5f;
constexpr float CHAMPION_HP_KING = 3;
constexpr float CHAMPION_SPEED_FAST = 1.333f;
constexpr float CHAMPION_SPEED_SLOW = 0.8f;
constexpr float CHAMPION_SPEED_GIANT = 0.9f;
constexpr int CHAMPION_FLICKER_MIN = 60;
constexpr int CHAMPION_FLICKER_RANGE = 30;
constexpr int CHAMPION_SHOT_MIN = 40;
constexpr int CHAMPION_SHOT_RANGE = 20;
constexpr int EFFECT_PULLING = 57;
constexpr int EFFECT_CREEP_GREEN = 23;
constexpr int CHAMPION_CREEP_FRAMES = 7;
constexpr int CHAMPION_CREEP_TIMEOUT = 30;
constexpr float CHAMPION_SHOT_SPEED = 5;
constexpr float CHAMPION_SHOT_FALL_ACCEL = 0.3f;
constexpr float CHAMPION_SHOT_FALL_SPEED = -5;
constexpr int SOUND_BLOODSHOOT = 178;
constexpr float FLICKER_FADE = 0.05f;
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}};
// Where a flickering champion is in its fade.
enum FlickerState : int
{
FLICKER_SHOWN,
FLICKER_FADING_OUT,
FLICKER_FADING_IN,
FLICKER_HIDDEN
};
constexpr int PULLING_PURPLE = 0;
constexpr int PULLING_GREY = 1;
constexpr int PULLING_RED = 2;
constexpr ColorMod PULLING_RED_COLOR = {{1, 0.2f, 0.2f, 1}, {0, 0, 0, 0}, {0, 0, 0}};
// 00505b80 The color a champion shows over a sprite without its sheets: its sheet color laid over its sprite color
// (Color::__mul), or the sprite color for a look drawn on no sheet.
static ColorMod champion_sprite_color_get(int championColor)
{
const ChampionLook& look = CHAMPION_LOOKS[championColor];
if (look.sheetColor._tint[3] <= 0) return look.spriteColor;
ColorMod color = look.sheetColor;
const ColorMod& other = look.spriteColor;
for (int i = 0; i < 4; i++) color._tint[i] *= other._tint[i];
if (other._colorize[0] + other._colorize[1] + other._colorize[2] != 0)
for (int i = 0; i < 4; i++) color._colorize[i] = other._colorize[i];
for (int i = 0; i < 3; i++) color._offset[i] += other._offset[i];
return color;
}
// The sheet color of a champion color's look, or none for a look drawn on no _champion sheet.
const ColorMod* champion_color_get(int championColor)
{
if (championColor < 0 || championColor >= CHAMPION_COUNT) return nullptr;
reconstruction_missing("Entity_NPC champion colors: the table at 00c354c0");
const ColorMod& sheetColor = CHAMPION_LOOKS[championColor].sheetColor;
return sheetColor._tint[3] > 0 ? &sheetColor : nullptr;
}
// Part of 006d03e0: a seed's champion color by the stage: rarely white or rainbow and uncommonly a strange one late,
// else a rare, pulsing or sized, special late, or common one.
static int champion_color_roll(uint32_t seed)
{
RNG rng;
rng.SetSeed(seed, CHAMPION_RNG_SHIFT_INDEX);
float roll = rng.RandomFloat();
uint32_t stage = g_game->stage;
bool isLate = stage >= CHAMPION_LATE_STAGE;
if (roll < CHAMPION_ROLL_RAINBOW && isLate) return roll < CHAMPION_ROLL_WHITE ? CHAMPION_WHITE : CHAMPION_RAINBOW;
if (roll < CHAMPION_ROLL_UNCOMMON && isLate) return CHAMPIONS_UNCOMMON[rng.RandomInt(CHAMPIONS_UNCOMMON.size())];
if (roll < CHAMPION_ROLL_RARE) return CHAMPIONS_RARE[rng.RandomInt(CHAMPIONS_RARE.size())];
if (roll < CHAMPION_ROLL_PULSING)
{
uint32_t count = stage >= CHAMPION_YELLOW_STAGE ? CHAMPIONS_PULSING.size() : CHAMPION_PULSING_EARLY_COUNT;
return CHAMPIONS_PULSING[rng.RandomInt(count)];
}
if (roll < CHAMPION_ROLL_SPECIAL && isLate) return CHAMPIONS_SPECIAL[rng.RandomInt(CHAMPIONS_SPECIAL.size())];
if (stage < CHAMPION_YELLOW_STAGE) return CHAMPIONS_EARLY[rng.RandomInt(CHAMPIONS_EARLY.size())];
return CHAMPIONS_LATE[rng.RandomInt(CHAMPIONS_LATE.size())];
}
// Part of 006d03e0: what a champion color changes beside the look: health, speed, grid collision, timers, and the
// pulling effect or eternal fly some keep with them.
void Entity_NPC::champion_traits_apply(bool isInit)
{
switch (championColorIdx)
{
case CHAMPION_RED: maxHitPoints *= CHAMPION_HP_RED; break;
case CHAMPION_YELLOW:
championSpeed = CHAMPION_SPEED_FAST;
maxHitPoints *= CHAMPION_HP_YELLOW;
break;
case CHAMPION_GREY: maxHitPoints *= CHAMPION_HP_GREY; [[fallthrough]];
case CHAMPION_DARK_BLUE: championSpeed = CHAMPION_SPEED_SLOW; break;
case CHAMPION_TRANSPARENT: entityGridCollisionClass = GRIDCOLL_WALLS; break;
case CHAMPION_FLICKER: flickerTimer = random_below(CHAMPION_FLICKER_RANGE) + CHAMPION_FLICKER_MIN; break;
case CHAMPION_PINK: championTimer = random_below(CHAMPION_SHOT_RANGE) + CHAMPION_SHOT_MIN; break;
case CHAMPION_PURPLE: spawn_at(ENTITY_EFFECT, EFFECT_PULLING, PULLING_PURPLE, pos, this)->parent = this; break;
case CHAMPION_PULSE_GREY: spawn_at(ENTITY_EFFECT, EFFECT_PULLING, PULLING_GREY, pos, this)->parent = this; break;
case CHAMPION_FLY_PROTECTED:
if (!isInit) reconstruction_missing("Entity_NPC::MakeChampion 006d03e0: the fly protected champion's fly");
break;
case CHAMPION_TINY:
maxHitPoints *= CHAMPION_HP_GREY;
championSpeed *= CHAMPION_SPEED_FAST;
break;
case CHAMPION_GIANT:
maxHitPoints *= CHAMPION_HP_BIG;
championSpeed *= CHAMPION_SPEED_GIANT;
[[fallthrough]];
case CHAMPION_DEATH:
if (collisionDamage > 0) collisionDamage = CHAMPION_DEATH_CONTACT_DAMAGE;
break;
case CHAMPION_PULSE_RED:
{
Entity* pulling = spawn_at(ENTITY_EFFECT, EFFECT_PULLING, PULLING_RED, pos, this);
pulling->parent = this;
pulling->SetColor(PULLING_RED_COLOR, -1, COLOR_PRIORITY_DEFAULT, false, true);
break;
}
case CHAMPION_KING: maxHitPoints *= CHAMPION_HP_KING; break;
case CHAMPION_RAINBOW: reconstruction_missing("Entity_NPC::MakeChampion 006d03e0: the rainbow champion");
default: break;
}
}
// 006d03e0 Makes it a champion of a color, or of one its seed draws for the stage at -1: twice the health and 2
// contact damage, its size (half for the tiny, 1.5 for the giant, 1.15 else), its champion sprite and its color's
// traits. Dark red never befalls the slides and white not the fly protected kind. Only Init makes a champion twice.
void Entity_NPC::MakeChampion(uint32_t seed, int championColor, bool isInit)
{
if (isChampion && !isInit) return;
float baseMaxHitPoints = maxHitPoints;
maxHitPoints = baseMaxHitPoints + baseMaxHitPoints;
ResetColor();
if (collisionDamage > 0) collisionDamage = CHAMPION_CONTACT_DAMAGE;
isChampion = true;
championColorIdx = championColor;
if (championColor < 0) championColor = champion_color_roll(seed);
bool isNoDarkRed = std::ranges::find(CHAMPION_NO_DARK_RED_TYPES, type) != CHAMPION_NO_DARK_RED_TYPES.end();
if (championColor == CHAMPION_DARK_RED && isNoDarkRed) championColor = CHAMPION_RED;
else if (championColor == CHAMPION_WHITE && type == ENTITY_NO_WHITE_CHAMPION) championColor = CHAMPION_FLY_PROTECTED;
championColorIdx = std::clamp(championColor, (int)CHAMPION_RED, (int)CHAMPION_RAINBOW);
float championScale = CHAMPION_SCALE;
if (championColorIdx == CHAMPION_TINY)
{
SetSize(size * CHAMPION_TINY_SCALE, sizeMulti, config->gridCollisionPoints);
championScale = CHAMPION_TINY_SCALE;
}
else if (championColorIdx == CHAMPION_GIANT) championScale = CHAMPION_GIANT_SCALE;
scale = championScale;
sprite.scale = vector_make(championScale * shrinkStatus1, championScale * shrinkStatus1);
load_graphics(false);
champion_traits_apply(isInit);
if (type == ENTITY_MULLIGAN && variant == MULLIGAN_VARIANT_FLEEING)
maxHitPoints = std::min(maxHitPoints, baseMaxHitPoints);
if (!isInit) health = maxHitPoints;
ResetColor();
}
// The enemy a "random enemy" spawn (type 306) turns into on each stage, on Normal and on Hard.
@@ -1212,7 +1443,7 @@ void Entity_NPC::appear_update()
poof->posOffset = posOffset;
poof->renderDepthOffset = posOffset.y + 1;
if (isChampion && championColorIdx < CHAMPION_COUNT)
reconstruction_missing("Entity_NPC::Update 006c4b30: a champion's appear poof color (GetColorWithFlash)");
poof->SetColor(champion_sprite_color_get(championColorIdx), -1, COLOR_PRIORITY_DEFAULT, false, true);
int sound = isDeathSoundAlt ? SOUND_SUMMON_POOF : SOUND_SUMMONSOUND;
g_manager->sfxManager.Stop(sound);
@@ -1343,12 +1574,105 @@ void Entity_NPC::decoy_update()
// creep and shot champions), and Wrath's twin flicker.
void Entity_NPC::champion_update()
{
if (isChampion || type == ENTITY_FLICKER_TYPE)
reconstruction_missing("Entity_NPC::Update 006c4b30: the champion colors' effects");
if (HasEntityFlags(FLAG_SHRINK) && shrinkCountdown >= 1 && shrinkCountdown < SHRINK_PULSE_FRAMES)
const NullFrame* overlay = sprite.animState.animData ? sprite.animState.GetNullFrame("OverlayEffect") : nullptr;
bool isEffectShown = !overlay || overlay->isVisible;
bool isShrunk = HasEntityFlags(FLAG_SHRINK);
int champion = championColorIdx;
bool isGreen = champion == CHAMPION_GREEN || champion == CHAMPION_RAINBOW;
if (isGreen && isEffectShown && IsFrame(CHAMPION_CREEP_FRAMES, 0) && !isShrunk)
{
Entity_Effect* creep = static_cast<Entity_Effect*>(spawn_at(ENTITY_EFFECT, EFFECT_CREEP_GREEN, 0, pos, this));
creep->SetTimeout(CHAMPION_CREEP_TIMEOUT);
creep->Update();
}
if (champion == CHAMPION_BROWN) reconstruction_missing("Entity_NPC::Update 006c4b30: the brown champion's poop");
if (champion == CHAMPION_WHITE) white_champion_update();
if (champion == CHAMPION_FLICKER || type == ENTITY_FLICKER_TYPE) flicker_update();
if (champion == CHAMPION_TRANSPARENT) entityGridCollisionClass = GRIDCOLL_WALLS;
else if ((champion == CHAMPION_PINK || champion == CHAMPION_RAINBOW) && --championTimer < 1 && isEffectShown &&
!isShrunk)
champion_shot_fire();
if ((champion == CHAMPION_PURPLE || champion == CHAMPION_RAINBOW) && isEffectShown)
reconstruction_missing("Entity_NPC::Update 006c4b30: the purple champion's pull");
if (champion == CHAMPION_DARK_RED && (isDead || championRegenTimer != 0))
reconstruction_missing("Entity_NPC::Update 006c4b30: the dark red champion's regeneration");
bool isPulsing = champion == CHAMPION_CAMO || champion == CHAMPION_PULSE_GREEN || champion == CHAMPION_PULSE_GREY ||
champion == CHAMPION_PULSE_RED || champion == CHAMPION_KING || champion == CHAMPION_RAINBOW;
if (isPulsing) reconstruction_missing("Entity_NPC::Update 006c4b30: the camouflaged, pulsing and king champions");
if (champion == CHAMPION_SIZE_PULSE && championTimer > 0) championTimer--;
if (isShrunk && shrinkCountdown >= 1 && shrinkCountdown < SHRINK_PULSE_FRAMES)
reconstruction_missing("Entity_NPC::Update 006c4b30: the shrinking pulse");
}
// Part of 006c4b30: a white champion cannot be hurt while another enemy holding the doors lives, unless that one is
// white too.
void Entity_NPC::white_champion_update()
{
isInvincible = false;
ClearEntityFlags(FLAG_NO_STATUS_EFFECTS);
for (Entity* entity : g_game->room->GetEntities()->updateEL)
{
Entity_NPC* npc = entity->IsEnemy() ? dynamic_cast<Entity_NPC*>(entity) : nullptr;
if (!npc || !npc->CanShutDoors() || (npc->isChampion && npc->championColorIdx == CHAMPION_WHITE)) continue;
isInvincible = true;
AddEntityFlags(FLAG_NO_STATUS_EFFECTS);
}
}
// Part of 006c4b30: the flickering champion (and the Flicker kind) waits visible, fades out, hides, then fades back
// in, its sprite's alpha following.
void Entity_NPC::flicker_update()
{
switch (flickerState)
{
case FLICKER_SHOWN:
if (flickerTimer-- < 0) flickerState = FLICKER_FADING_OUT;
break;
case FLICKER_FADING_OUT:
if (flickerAlpha > 0) flickerAlpha -= FLICKER_FADE;
else
{
flickerState = FLICKER_HIDDEN;
flickerTimer = random_below(CHAMPION_FLICKER_RANGE) + CHAMPION_FLICKER_MIN;
}
break;
case FLICKER_FADING_IN:
if (flickerAlpha < 1) flickerAlpha += FLICKER_FADE;
else
{
flickerState = FLICKER_SHOWN;
flickerTimer = random_below(CHAMPION_FLICKER_RANGE) + CHAMPION_FLICKER_MIN;
}
break;
case FLICKER_HIDDEN:
isVisible = false;
if (flickerTimer-- < 0)
{
isVisible = true;
flickerState = FLICKER_FADING_IN;
}
break;
default: break;
}
sprite.color._tint[3] = flickerAlpha;
}
// Part of 006c4b30: the pink champion shoots along its walk every 40 to 59 frames while it moves.
void Entity_NPC::champion_shot_fire()
{
float speed = vector_length(velocity);
if (speed <= 0) return;
Vector direction = vector_scale(velocity, 1 / speed);
championTimer = random_below(CHAMPION_SHOT_RANGE) + CHAMPION_SHOT_MIN;
ProjectileParams params;
params.fallingAccelModifier = CHAMPION_SHOT_FALL_ACCEL;
params.fallingSpeedModifier = CHAMPION_SHOT_FALL_SPEED;
FireProjectiles(pos, vector_scale(direction, CHAMPION_SHOT_SPEED), PROJECTILES_SINGLE, params);
PlaySound(SOUND_BLOODSHOOT, 1, 2, false, 1);
}
// Part of 006c4b30: in a room that checks it, an enemy no grounded player has a path to stops holding the doors
// after its second miss, checked every 60 frames once 900 frames passed.
void Entity_NPC::unreachable_update()
@@ -1868,12 +2192,24 @@ void Entity_NPC::ClearDequeRefs()
entityDeque.clear();
}
// 006c1100 Shows its own color again: a boss's alternate color, or for a champion its champion color.
// 006c1100 Shows its own color again: a champion its sprite color (on its _champion sheets) or its color laid over
// it, a boss its alternate color, else its own. A friendly enemy is washed out and a frozen one iced.
void Entity_NPC::ResetColor()
{
if (isChampion) reconstruction_missing("Entity_NPC::ResetColor 006c1100: a champion's color");
if (bosscoloridx < 0) sprite.color = color;
if (isChampion)
{
bool isChampionSheet = std::ranges::any_of(sprite.layerStates, [](const LayerState& layer)
{ return layer.bitflags & LAYER_CHAMPION_SHEET; });
if (championColorIdx >= 0 && championColorIdx < CHAMPION_COUNT)
sprite.color = isChampionSheet ? CHAMPION_LOOKS[championColorIdx].spriteColor
: champion_sprite_color_get(championColorIdx);
}
else if (bosscoloridx < 0) sprite.color = color;
else if (bosscoloridx < (int)config->bossColors.size()) sprite.color = config->bossColors[bosscoloridx].color;
bool isShadowCharger = type == ENTITY_SHADOW_CHARGER && variant == 0 && subtype == SHADOW_CHARGER_SUBTYPE;
if (IsFriendly() && !isShadowCharger) sprite.color = FRIENDLY_COLOR;
if (type == ENTITY_FROZEN_ENEMY) sprite.color = FROZEN_COLOR;
}
// 006d4e00 Bursts it: a blood explosion its size (or a fly's, a spider's, a poop's), in its splat color, from its
@@ -2270,7 +2606,7 @@ void Entity_NPC::Render(const Vector& offset)
Entity::Render(offset);
if (!isVisible)
renderPosition = vector_add(render_position_get(vector_add(pos, posOffset), RENDER_SNAPPED), offset);
lua_callback_check(CALLBACK_POST_NPC_RENDER, "Entity_NPC::Render 006d2e50: MC_POST_NPC_RENDER");
lua_engine_get().PostNPCRender(this, offset);
RenderMode renderMode = g_game->room->entityList.renderMode;
if (renderMode != RENDER_NORMAL && renderMode != RENDER_WATER_ABOVE) return;
@@ -2415,7 +2751,7 @@ void Entity_NPC::trigger_kill_item_effects()
aimTargetEffect = nullptr;
if (HasEntityFlags(FLAG_BRIMSTONE_MARKED) && HasEntityFlags(FLAG_EXTRA_GORE))
reconstruction_missing("Entity_NPC::trigger_kill_item_effects 006d5400: the marked enemy's spreading status");
lua_callback_check(CALLBACK_POST_NPC_DEATH, "Entity_NPC::trigger_kill_item_effects 006d5400: MC_POST_NPC_DEATH");
lua_engine_get().PostNPCDeath(this);
}
// 006bbdc0 The rewards a dead enemy gives its killers: the damage flags' and Gimpy's drops, the familiars' and
@@ -2697,30 +3033,12 @@ void* Entity_NPC::fireplace_get_loot(void*, bool)
reconstruction_missing("Entity_NPC::fireplace_get_loot 006d1580");
}
// 006d4a00
bool Entity_NPC::CanBeDamagedFromVelocity(Vector)
{
reconstruction_missing("Entity_NPC::CanBeDamagedFromVelocity 006d4a00");
}
// 006d4db0
bool Entity_NPC::CanReroll()
{
reconstruction_missing("Entity_NPC::CanReroll 006d4db0");
}
// 006d6d20
uint32_t Entity_NPC::on_player_damaged()
{
reconstruction_missing("Entity_NPC::on_player_damaged 006d6d20");
}
// 006d6d80
void Entity_NPC::room_enter()
{
reconstruction_missing("Entity_NPC::room_enter 006d6d80");
}
// 006d7520
void Entity_NPC::update_blood_guide_gibs(float*)
{
@@ -2763,10 +3081,15 @@ uint8_t Entity_NPC::split(float, const EntityRef&, bool)
reconstruction_missing("Entity_NPC::split 006d97e0");
}
// 006da530
// 006da530 While a player holds Guppy's Eye, a lit fireplace or a living shopkeeper shows the loot it would drop as
// ghosts. Otherwise the ghosts shown before go.
void Entity_NPC::UpdatePickupGhosts()
{
reconstruction_missing("Entity_NPC::UpdatePickupGhosts 006da530");
bool isLootHolder = (type == ENTITY_FIREPLACE && health > 1) || (type == ENTITY_SHOPKEEPER && !isDead);
if (isLootHolder && g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_GUPPYS_EYE_ID, LAZARUS_SHARE_CHECK))
reconstruction_missing("Entity_NPC::UpdatePickupGhosts 006da530 (the loot ghosts)");
if (pickupGhostsEntity) pickupGhostsEntity->Remove();
}
// 0096ce90