Curation round 9: floors and walls, room transitions, collision, the first enemies, saving, damage, pickups

Seven agents took over the backdrop's floor and wall rendering, room transitions (StartRoomTransition, on_leave,
room_enter), grid collision with tear hits and decal baking, Entity_NPC's core with the AI dispatch and the first
enemies (flies, Gaper, Pooter, Clotty, Horf, Dip, Spider), the run's save, player damage, PlayerManager::Update,
ShowName, pickups, slots and the common effects. Integration added LuaEngine::PostNewLevel/PostNewRoom, one shared
lua_callback_check (4 copies merged) and the enemy type range the original checks.
Under gdb a run draws its rooms with floors and walls, walks between rooms, fights Gapers with contact damage and the
damage flash, and collects pickups. Next: tears hitting enemies, pathfinding, item pedestals, death.
2891 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 08:24:38 -05:00
1 parent 69a354f843
commit 48933cd312
59 files changed
+13387 -6056

No files matched your search

+263 -79
View File
@@ -2,71 +2,202 @@
#include "entity.h"
#include "anm2.h"
#include "path_finder.h"
#include <deque>
#include <vector>
// Construction and destruction (006b88e0, 006b8590) are the defaults, but for the pathfinder's owner the constructor
// sets. PathFinder::Init's reset waits for PathFinder's takeover.
// Field accessors (004567a0, 006a8230, 006b8480, 007e92b0) are the public fields.
// Lua's NpcState: where an NPC's AI is in its routine. State 1 holds the AI while the NPC appears.
enum NpcState : int
{
NPC_STATE_INIT = 0,
NPC_STATE_APPEAR = 1,
NPC_STATE_APPEAR_CUSTOM = 2,
NPC_STATE_IDLE = 3,
NPC_STATE_MOVE = 4,
NPC_STATE_SUICIDE = 5,
NPC_STATE_JUMP = 6,
NPC_STATE_STOMP = 7,
NPC_STATE_ATTACK = 8,
NPC_STATE_ATTACK2 = 9,
NPC_STATE_ATTACK3 = 10,
NPC_STATE_ATTACK4 = 11,
NPC_STATE_ATTACK5 = 12,
NPC_STATE_SUMMON = 13,
NPC_STATE_SUMMON2 = 14,
NPC_STATE_SUMMON3 = 15,
NPC_STATE_SPECIAL = 16,
NPC_STATE_UNIQUE_DEATH = 17,
NPC_STATE_DEATH = 18
};
// Which extra AI calls an NPC asks for (_aiCallFlags), and the phase (_aiCallPhase) the AI sees in each.
enum AiCall : uint32_t
{
AI_CALL_PRE_UPDATE = 1 << 0,
AI_CALL_INTERPOLATE = 1 << 1,
AI_CALL_COLLISION = 1 << 2,
AI_CALL_POST_UPDATE = 1 << 3
};
enum AiPhase : int
{
AI_PHASE_UPDATE = 0,
AI_PHASE_PRE_UPDATE = 1,
AI_PHASE_INTERPOLATE = 2,
AI_PHASE_COLLISION = 3,
AI_PHASE_POST_UPDATE = 4
};
// The spreads FireProjectiles shoots (Lua's ProjectilesMode): fans of one to five shots along the velocity, plus and
// cross shapes and their union at the velocity's x, and a ring of round(velocity.y) shots at the velocity's x.
enum ProjectilesMode : int
{
PROJECTILES_SINGLE,
PROJECTILES_TWO,
PROJECTILES_THREE,
PROJECTILES_THREE_WIDE,
PROJECTILES_FOUR,
PROJECTILES_FIVE,
PROJECTILES_PLUS,
PROJECTILES_CROSS,
PROJECTILES_EIGHT,
PROJECTILES_RING
};
// Lua's ChampionColor values the NPC code tests.
enum ChampionColor : int
{
CHAMPION_NONE = -1,
CHAMPION_RED = 0,
CHAMPION_YELLOW = 1,
CHAMPION_GREEN = 2,
CHAMPION_ORANGE = 3,
CHAMPION_DARK_BLUE = 4,
CHAMPION_DARK_GREEN = 5,
CHAMPION_WHITE = 6,
CHAMPION_GREY = 7,
CHAMPION_TRANSPARENT = 8,
CHAMPION_FLICKER = 9,
CHAMPION_PINK = 10,
CHAMPION_PURPLE = 11,
CHAMPION_DARK_RED = 12,
CHAMPION_LIGHT_BLUE = 13,
CHAMPION_CAMO = 14,
CHAMPION_PULSE_GREEN = 15,
CHAMPION_PULSE_GREY = 16,
CHAMPION_FLY_PROTECTED = 17,
CHAMPION_TINY = 18,
CHAMPION_GIANT = 19,
CHAMPION_PULSE_RED = 20,
CHAMPION_SIZE_PULSE = 21,
CHAMPION_KING = 22,
CHAMPION_DEATH = 23,
CHAMPION_BROWN = 24,
CHAMPION_RAINBOW = 25,
CHAMPION_COUNT = 26
};
// Construction (0043ef30) is the default, but for the circle angle it draws at random.
// How FireProjectiles shoots (Lua's ProjectileParams): the shots' variant, look, fall, homing and change, and the
// spread they leave in.
struct ProjectileParams
{
ColorMod color = COLOR_DEFAULT;
Vector fireDirectionLimit{};
Vector positionOffset{};
Vector targetPosition{};
uint64_t bulletFlags = 0;
uint64_t changeFlags = 0;
float acceleration = 1.01f;
float changeVelocity = 0;
float circleAngle;
float curvingStrength = 0.005f;
float damage = -1;
float depthOffset = 0;
float dotProductLimit = -1000;
float fallingAccelModifier = 0;
float fallingSpeedModifier = 0;
float heightModifier = 0;
float homingStrength = 1;
float scale = 1;
float spread = 1;
float unknownA0 = 0;
float velocityMulti = 1;
int changeTimeout = 30;
int variant = 0;
int wiggleFrameOffset = 0;
bool isGridCollision = true;
bool isFallingKept = false;
bool isRenderedAtGround = false;
ProjectileParams();
};
// Construction and destruction (006b88e0, 006b8590, 006b8910) are the defaults.
// Field accessors (004567a0, 006a8230, 006b8480, 007e92b0, 004e4850) are the public fields.
// An enemy or other non-player character (Lua's EntityNPC): its AI state and counters, pathfinder, champion and boss
// colors, shields, Delirium's forms, and the player controlling it with Siren or a friendly ball.
struct Entity_NPC : Entity
{
ANM2 chargeBarSprite;
ANM2 statusEffectSprite;
NPCAI_Pathfinder pathfinder{};
PathFinder pathfinder{this};
std::deque<EntityPtr> entityDeque;
std::deque<Vector> vectorDeque1;
std::deque<Vector> vectorDeque2;
std::deque<float> damageHistory;
std::vector<DamageEvent> killDamageEvents;
std::vector<uint32_t> hitList;
std::vector<uint32_t> secondaryHitList;
ColorMod dirtColor = COLOR_DEFAULT;
ColorMod floorColor = COLOR_DEFAULT;
EntityPtr aimTargetEffect;
EntityPtr entityRef;
EntityPtr forcedTarget;
EntityPtr pickupGhostsEntity;
EntityPtr salvationTarget;
EntityPtr unknownF54;
Entity* collisionEntity = nullptr;
Entity* deliriumEntity = nullptr;
Entity_Effect* pickupGhostsEntity = nullptr;
Entity_Player* sirenPlayerEntity = nullptr;
void* aimTargetEffect = nullptr;
uint64_t killDamageFlags = 0;
Vector confusionTargetPos{};
Vector controllerMovement{};
Vector forwardVector{};
Vector v1{};
Vector v2{};
float aiFloat = 0;
float championSpeed = 0;
float flickerAlpha = 0;
float hitPointsMulti = 0;
float aiFloat = 1;
float championSpeed = 1;
float flickerAlpha = 1;
float hitPointsMulti = 1;
float killDamage = 0;
float scale = 0;
float scaleMulti = 0;
float scale = 1;
float scaleMulti = 1;
float shieldStrength = 0;
float totalDamageTaken = 0;
int aiCallPhase = 0;
int aiCallPhase = AI_PHASE_UPDATE;
int aiCounter = 0;
int appearFrames = 0;
int bosscoloridx = 0;
int championColorIdx = 0;
int bosscoloridx = -1;
int championColorIdx = CHAMPION_NONE;
int championTimer = 0;
int collisionResult = 0;
int controllerID = 0;
int controllerID = -1;
int decoyTargetTimer = 0;
int flickerState = 0;
int flickerTimer = 0;
int forcedTargetTimer = 0;
int groupIdx = 0;
int groupIdx = -1;
int i1 = 0;
int i2 = 0;
int lastGridIndex = 0;
int lastGridIndex = -1;
int projectileCooldown = 0;
int projectileDelay = 0;
int projectileDelay = -1;
int savedState = 0;
int shieldFrames = 0;
int state = 0;
int state = NPC_STATE_INIT;
int stateFrame = 0;
int unknownF2c = 0;
uint32_t aiCallFlags = 0;
uint32_t deliriumAttackID = 0;
uint32_t deliriumBossType = 0;
@@ -84,10 +215,11 @@ struct Entity_NPC : Entity
bool isCanShutDoors = false;
bool isChampion = false;
bool isCollisionIsLow = false;
bool isDeathSoundAlt = false;
bool isUnknownC61 = false;
bool isUnknownC62 = false;
bool isUnreachableOnce = false;
Entity_NPC() { pathfinder._entity = this; }
void Init(int type, int variant, int subType, uint32_t initSeed) override;
void PreUpdate() override;
void Update() override;
@@ -106,75 +238,127 @@ struct Entity_NPC : Entity
void ResetColor() override;
void LoadEntityConfig() override;
Entity_NPC* ParentNPC();
Entity_NPC* ChildNPC();
void Hornfel_UpdateAI();
void Hornfel_UpdateFrame();
void update_physics();
void apply_velocity(char);
void update_move_direction_anim();
void SetMinecartPosVel(const Vector& pos, const Vector& vel);
void MinecartUpdateChild(Entity* child);
void UpdateCordChain(bool isHalfScale);
void render_overlay(const Vector& offset, bool isShadow);
static int FindTargetPit(const Vector& pos1, const Vector& pos2, uint32_t pitIndex);
static Entity_NPC* ThrowStrider(const Vector& pos, Entity* spawner, const Vector& targetPos);
void render_v1_layer_frames();
void RenderSegmentLink(const Vector& offset, bool isShadow);
void CreateBling();
void CreateGoldParticles(uint32_t count);
void set_entity_ptr_f54(Entity* entity);
void ResetPathFinderTarget();
void hold_set(int countdown, const Vector& position);
Entity_Effect* MakeSplat(float size);
Entity_Effect* MakeBloodCloud(const Vector& pos, const ColorMod& color);
bool TryForceTarget(Entity* target, int duration);
float compute_speed_multiplier();
void load_graphics(uint8_t);
void KillUnique();
Entity* GetPlayerTarget();
Vector CalcTargetPosition(float distanceLimit);
void UpdateDirtColor(uint8_t immediate);
static uint8_t Redirect(int* entityType, int* variant);
void Morph(int entityType, int variant, int subType, int championid);
void* shopkeeper_get_loot(void* outLoot, bool isShouldAdvance);
static Entity_NPC* ThrowSpider(const Vector& position, Entity* spawner, Vector targetPos, bool isBig,
float yOffset);
void update_frozen();
void fire_projectile_from_params(Entity_Projectile* projectile);
void SetBossColorIdx(int bossColorIdx, int unused);
void load_graphics(bool isReloadAnm2);
void boss_color_roll();
static bool Redirect(int* entityType, int* variant);
void Morph(int entityType, int variant, int subType, int championId);
void MakeChampion(uint32_t seed, int championColor, bool isInit);
void SetRef_bec(Entity* entity);
static void* QueryNPCsType(void* outList, int type, int variant);
static EntityList* QueryNPCsGroup(EntityList* outList, int groupIdx);
void* fireplace_get_loot(void* outLoot, bool isShouldAdvance);
bool CanBeDamagedFromVelocity(Vector velocity);
bool CanReroll();
void PlayDeathEffects();
void trigger_kill_item_effects();
void SetBossColorIdx(int bossColorIdx, int unused);
void SetScale(float newScale);
void PlaySound(int id, float volume, int framedelay, uint8_t loop, float pitch);
int GetAliveEnemyCount();
uint32_t on_player_damaged();
void UpdateDirtColor(bool isImmediate);
void room_enter();
float compute_speed_multiplier();
void ai_call(AiPhase phase);
void status_overlay_update();
bool paused_update();
void appear_update();
void appear_init();
void death_animation_update();
void death_animation_start();
void decoy_update();
void champion_update();
void unreachable_update();
void dead_update();
void midas_coins_spawn();
void toxic_shock_creep_spawn();
void player_aura_update();
void item_effects_update();
void poof02_spawn();
void ripple_spawn();
void seed_effects_update();
void type_update();
void forced_target_update();
void update_frozen();
void update_physics();
void apply_velocity(char isInterpolated);
void update_move_direction_anim();
void update_blood_guide_gibs(float* nullFrame);
void spawn_damage_numbers();
void update_damage_history();
void update_blood_guide_gibs(float* nullFrame);
void status_overlay_render(const Vector& offset);
void Hornfel_UpdateAI();
void Hornfel_UpdateFrame();
Entity* GetPlayerTarget();
Vector CalcTargetPosition(float distanceLimit);
bool TryForceTarget(Entity* target, int duration);
void ResetPathFinderTarget();
bool IsTargetInAttackRange(float range, int frameInterval, bool isPredictVelocity);
int GetAliveEnemyCount();
void AnimWalkFrame(std::string_view horizontalAnim, std::string_view verticalAnim, float speedThreshold);
void PlaySound(int id, float volume, int frameDelay, bool isLoop, float pitch);
void FireProjectiles(const Vector& position, const Vector& velocity, ProjectilesMode mode,
const ProjectileParams& params);
void FireBossProjectiles(int count, const Vector& targetPos, float trajectoryModifier,
const ProjectileParams& params);
void projectile_params_apply(Entity_Projectile& projectile, const ProjectileParams& params);
void fire_projectile_from_params(Entity_Projectile* projectile);
Entity_Effect* MakeSplat(float size);
Entity_Effect* MakeBloodCloud(const Vector& pos, const ColorMod& color);
static Entity_NPC* ThrowSpider(const Vector& position, Entity* spawner, Vector targetPos, bool isBig,
float yOffset);
void player_contact(Entity_Player& player);
void enemy_contact(Entity& other);
void PlayDeathEffects();
int death_burst_get();
void trigger_kill_item_effects();
void trigger_death_rewards();
void KillUnique();
bool CanBeDamagedFromVelocity(Vector velocity);
bool CanReroll();
uint8_t split(float damage, const EntityRef& source, bool isPlaySound);
Entity_NPC* ParentNPC();
Entity_NPC* ChildNPC();
void ClearChild();
void ClearDequeRefs();
void set_entity_ptr_f54(Entity* entity);
void SetRef_bec(Entity* entity);
void hold_set(int countdown, const Vector& position);
bool IsControllerActionPressed(int action);
bool IsControllerActionTriggered(int buttonAction);
Vector GetControllerInput(float deadzone);
Vector GetControllerMovementInput(float deadzone);
void TransferControl(Entity_NPC* target);
void SpawnControlTarget(int inputMode, float rotation);
void ClearChild();
Vector GetAimTargetPosition();
bool is_controller_input_idle();
void UpdateChargeBar(float start, float end, float value, bool isHideWhenFull);
void UpdateControllerMovement(bool isForceUpdate);
void UpdateChildEffectPosition(bool isPredictMovement);
uint8_t split(float damage, const EntityRef& source, bool isPlaySound);
void UpdatePickupGhosts();
void TransferControl(Entity_NPC* target);
void SpawnControlTarget(int inputMode, float rotation);
Vector GetAimTargetPosition();
void SetAimAngle(float angle);
static void render_debug(float*, int);
void UpdateChargeBar(float start, float end, float value, bool isHideWhenFull);
void UpdatePickupGhosts();
void SetMinecartPosVel(const Vector& pos, const Vector& vel);
void MinecartUpdateChild(Entity* child);
void UpdateCordChain(bool isHalfScale);
void render_overlay(const Vector& offset, bool isShadow);
void render_v1_layer_frames();
void RenderSegmentLink(const Vector& offset, bool isShadow);
void CreateBling();
void CreateGoldParticles(uint32_t count);
void* shopkeeper_get_loot(void* outLoot, bool isShouldAdvance);
void* fireplace_get_loot(void* outLoot, bool isShouldAdvance);
uint32_t on_player_damaged();
static int FindTargetPit(const Vector& pos1, const Vector& pos2, uint32_t pitIndex);
static Entity_NPC* ThrowStrider(const Vector& pos, Entity* spawner, const Vector& targetPos);
static void* QueryNPCsType(void* outList, int type, int variant);
static EntityList* QueryNPCsGroup(EntityList* outList, int groupIdx);
static void render_debug(float* position, int unused);
};
extern bool g_isChampionRollSkipped;
// Game's, Room's and PlayerManager's queries the enemies need, until those classes carry them.
Entity_Player* game_nearest_player(const Vector& position);
bool game_is_enemy_erased(Entity& entity);
bool any_player_flying();
Entity* game_nearest_target_player(const Vector& position, Entity* source, bool isPlayersOnly, bool isTargetDecoys,
float maxDistance);
void game_shake_screen(int timeout);
bool game_is_hard_mode();
uint32_t room_grid_collision_at(const Vector& position);
bool room_check_line(const Vector& start, const Vector& end, int mode, int gridPathThreshold);