Curation round 24 (code only): pickups and slots, level generation with the Ascent and the Death Certificate return, rooms and grid entities, Game and Entity core with Polty, Clutch, Matriarch, Chimera, Bumbino and other bosses, the player's remaining branches, familiars and weapons, HUD and engine stubs, 004b6a90 renamed push_back, shared constants folded (66 duplicates, 38 main gaps)

This commit is contained in:
shweet committed 2026-11-23 03:27:24 -05:00
1 parent 11c71fe041
commit 534339a496
232 files changed
+14610 -3185

No files matched your search

+49 -42
View File
@@ -59,8 +59,6 @@ constexpr float GFUEL_BIG_SCALE = 1.5f;
constexpr std::string_view GFUEL_BIG_EXPLOSION_ANM2 = "gfx/promo/gfuel/effects/explosion_big.anm2";
constexpr std::array<std::string_view, 2> GFUEL_EXPLOSION_ANM2S = {"gfx/promo/gfuel/effects/explosion.anm2",
"gfx/promo/gfuel/effects/explosion2.anm2"};
constexpr float GFUEL_BLAST_PITCH = 0.9f;
constexpr float GFUEL_BLAST_PITCH_RANGE = 0.2f;
constexpr int GFUEL_BIG_BLAST_SHAKE = 40;
constexpr int GFUEL_BLAST_SHAKE = 20;
@@ -132,7 +130,6 @@ constexpr float CONFUSION_WANDER = 240;
constexpr float FEAR_WANDER = 100;
constexpr int FEAR_RETARGET_RANGE = 15;
constexpr int FEAR_RETARGET_MIN = 5;
constexpr float MOVEMENT_DEADZONE = 0.1f;
constexpr float ATTACK_PREDICT_FRAMES = 5;
constexpr int LINE_BLOCKED_MAX = 8;
// The corners of the band a line check samples around each step.
@@ -174,7 +171,6 @@ constexpr int MARK_SPREAD_COUNTDOWN = 30;
constexpr ColorMod SPREAD_SLOW_COLOR = {{1, 1, 1.3f, 1}, {0, 0, 0, 0}, {40 / 255.0f, 40 / 255.0f, 40 / 255.0f}};
constexpr int SOUND_POOP_DEATH = 237;
constexpr float POOP_DEATH_VOLUME = 0.9f;
constexpr uint64_t FLAG_FRIENDLY_BALL_DYING = 1ull << 60;
// The burst effects a dead NPC leaves besides blood (Lua's EffectVariant).
enum DeathBurst : int
@@ -203,7 +199,6 @@ constexpr int COLLECTIBLE_SPIDER_MOD_ID = 403;
constexpr int COLLECTIBLE_BROKEN_MODEM_ID = 514;
constexpr int COLLECTIBLE_GUPPYS_EYE_ID = 665;
constexpr int COLLECTIBLE_SALVATION_ID = 696;
constexpr int COLLECTIBLE_VANISHING_TWIN_ID = 697;
constexpr int TRINKET_PURPLE_HEART_ID = 5;
constexpr int TRINKET_TICK_ID = 53;
constexpr int TRINKET_SUPER_MAGNET_ID = 68;
@@ -216,8 +211,6 @@ constexpr int ACHIEVEMENT_BOSS_COLORS = 3;
constexpr int ACHIEVEMENT_MORE_BOSS_COLORS = 33;
constexpr int ACHIEVEMENT_REDIRECTS = 348;
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 int BOSS_ID_NONE_EXCLUDED_FIRST = 46;
constexpr int BOSS_ID_NONE_EXCLUDED_LAST = 52;
@@ -318,7 +311,6 @@ Entity* spawn_at(int type, int variant, int subType, const Vector& position, Ent
// spawn. In a versus match the other players count too.
static bool is_nearest_enemy_candidate(Entity& entity, bool isVersusPlayer)
{
constexpr int CULTIST_BLOOD_SPAWN = 10;
int type = entity.type;
if (g_game->frameCount - entity.spawnFrame <= 1) return false;
@@ -331,10 +323,17 @@ static bool is_nearest_enemy_candidate(Entity& entity, bool isVersusPlayer)
type != ENTITY_GENERIC_PROP && type != ENTITY_MINECART;
}
// 00707370 Game::GetNearestEnemy: the enemy nearest a position within a radius that a source may target, a charmed
// one counted 400 farther. A friendly source passes over the players it may not hurt, and in a versus match over its
// own ancestors. The original's optional distance function is left out, as no caller here passes one.
Entity* game_nearest_enemy(const Vector& position, Entity* source, float radius)
// A candidate's measure in a nearest search: the search's own, or its squared distance from the position.
static float target_distance_get(TargetDistance distance, const Vector& position, Entity* source, Entity& candidate)
{
if (distance) return distance(position, source, candidate);
return vector_length_squared(vector_sub(candidate.pos, position));
}
// 00707370 Game::GetNearestEnemy: the enemy nearest a position (by the search's measure) within a radius that a
// source may target, a charmed one counted 400 farther. A friendly source passes over the players it may not hurt,
// and in a versus match over its own ancestors.
Entity* game_nearest_enemy(const Vector& position, Entity* source, float radius, TargetDistance measure)
{
constexpr float CHARMED_DISTANCE_SQUARED = 160000;
bool isVersus = g_game->deathmatchManager.is_active();
@@ -350,7 +349,7 @@ Entity* game_nearest_enemy(const Vector& position, Entity* source, float radius)
if (source && ((isVersus && source->IsDescendantOf(entity)) || !source->IsValidTarget(entity))) continue;
if (!is_nearest_enemy_candidate(*entity, isVersus && isPlayer)) continue;
float distance = vector_length_squared(vector_sub(position, entity->pos));
float distance = target_distance_get(measure, position, source, *entity);
if (entity->HasEntityFlags(FLAG_CHARM)) distance += CHARMED_DISTANCE_SQUARED;
if (distance >= best) continue;
best = distance;
@@ -412,9 +411,9 @@ static int active_charges_get(Entity_Player& player)
// What a target counts as from a position: its squared distance, pushed back while its player is invincible or (for
// the Blood Puppy) without control, pulled to a twin walking into the other, and for Bulb led by the active charge it holds.
static float target_score_get(const Vector& position, Entity* source, Entity& target, Entity_Player* player,
bool isBulb)
bool isBulb, TargetDistance measure)
{
float distance = vector_length_squared(vector_sub(target.pos, position));
float distance = target_distance_get(measure, position, source, target);
if (!player) return distance;
Entity_Player* twin = player->twin_get();
@@ -426,7 +425,7 @@ static float target_score_get(const Vector& position, Entity* source, Entity& ta
Vector between = vector_sub(twin->pos, player->pos);
bool isMeeting = vector_dot(vector_add(player->velocity, twin->velocity), between) < 0 &&
vector_length_squared(between) < TWIN_NEAR_SQUARED;
if (isMeeting) distance = vector_length_squared(vector_sub(twin->pos, position)) + 1;
if (isMeeting) distance = target_distance_get(measure, position, source, *twin) + 1;
}
if (!isBulb) return distance;
@@ -458,7 +457,7 @@ bool entity_is_prey(Entity& prey)
// it. Isaac's Heart stands in for its player.
// The stand-in target a player keeps at Entity_Player 0x144c waits for Entity_Player to name it.
Entity* game_nearest_target_player(const Vector& position, Entity* source, bool isPlayersOnly, bool isTargetDecoys,
float maxDistance)
float maxDistance, TargetDistance measure)
{
if (!isPlayersOnly && isTargetDecoys && source && source->IsEnemy())
{
@@ -493,7 +492,7 @@ Entity* game_nearest_target_player(const Vector& position, Entity* source, bool
player = static_cast<Entity_Familiar*>(target)->player;
if (player && player->IsInvisible()) continue;
float score = target_score_get(position, source, *target, player, isBulb);
float score = target_score_get(position, source, *target, player, isBulb, measure);
if (score >= best) continue;
best = score;
nearest = target;
@@ -503,7 +502,7 @@ Entity* game_nearest_target_player(const Vector& position, Entity* source, bool
for (Entity* decoy : g_game->room->entityList.mainEL)
{
if (decoy->type != ENTITY_FAMILIAR || decoy->variant != Entity_Familiar::PUNCHING_BAG) continue;
float distance = vector_length_squared(vector_sub(decoy->pos, position));
float distance = target_distance_get(measure, position, source, *decoy);
if (distance >= best) continue;
best = distance;
nearest = decoy;
@@ -515,7 +514,7 @@ Entity* game_nearest_target_player(const Vector& position, Entity* source, bool
{
if (prey_is_friendly(baited, source) || baited->isDead || !baited->HasEntityFlags(FLAG_BAITED)) continue;
if (!source || !source->IsValidTarget(baited)) continue;
float distance = vector_length_squared(vector_sub(baited->pos, position)) * BAITED_DISTANCE_SCALE;
float distance = target_distance_get(measure, position, source, *baited) * BAITED_DISTANCE_SCALE;
if (distance >= best) continue;
best = distance;
nearest = baited;
@@ -532,7 +531,7 @@ Entity* game_nearest_target_player(const Vector& position, Entity* source, bool
continue;
if (prey->HasEntityFlags(FLAG_NO_TARGET)) continue;
float distance = vector_length_squared(vector_sub(prey->pos, position));
float distance = target_distance_get(measure, position, source, *prey);
bool isFriendly = prey->HasEntityFlags(FLAG_FRIENDLY);
if (prey->type == ENTITY_BISHOP && !isFriendly) distance *= PUPPY_BISHOP_SCALE;
if (prey->type == ENTITY_BLOOD_PUPPY) distance += PUPPY_KIN_PENALTY;
@@ -575,8 +574,8 @@ void game_encountered_boss_add(int bossType, int bossVariant)
uint32_t room_grid_collision_at(const Vector& position)
{
Room& room = *g_game->room;
int column = (int)((position.x - GRID_CELL) / GRID_CELL + HALF);
int row = (int)((position.y - GRID_TOP) / GRID_CELL + HALF);
int column = (int)((position.x - GRID_ORIGIN_X) / GRID_CELL_SIZE + HALF);
int row = (int)((position.y - GRID_ORIGIN_Y) / GRID_CELL_SIZE + HALF);
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
return room.GetGridCollision(isInside ? room.gridWidth * row + column : -1);
}
@@ -623,10 +622,10 @@ bool room_check_line(const Vector& start, const Vector& end, int mode, int gridP
step = vector_scale(step, LINE_STEP / length);
auto cellOf = [](float value, float origin) {
return (int)((value - origin) / GRID_CELL + HALF);
return (int)((value - origin) / GRID_CELL_SIZE + HALF);
};
int startColumn = cellOf(start.x, GRID_CELL);
int startRow = cellOf(start.y, GRID_TOP);
int startColumn = cellOf(start.x, GRID_ORIGIN_X);
int startRow = cellOf(start.y, GRID_ORIGIN_Y);
bool isStartInside =
startColumn >= 0 && startColumn < room.gridWidth && startRow >= 0 && startRow < room.gridHeight;
int startIndex = isStartInside ? room.gridWidth * startRow + startColumn : -1;
@@ -638,8 +637,8 @@ bool room_check_line(const Vector& start, const Vector& end, int mode, int gridP
at = vector_sub(at, step);
if (mode == LINE_MODE_EXPLOSION)
{
int column = cellOf(at.x, GRID_CELL);
int row = cellOf(at.y, GRID_TOP);
int column = cellOf(at.x, GRID_ORIGIN_X);
int row = cellOf(at.y, GRID_ORIGIN_Y);
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
int cellIndex = isInside ? row * room.gridWidth + column : -1;
if (line_cell_is_blast_wall(room, cellIndex)) return false;
@@ -647,8 +646,8 @@ bool room_check_line(const Vector& start, const Vector& end, int mode, int gridP
}
if (mode == LINE_MODE_CELL)
{
int column = cellOf(at.x, GRID_CELL);
int row = cellOf(at.y, GRID_TOP);
int column = cellOf(at.x, GRID_ORIGIN_X);
int row = cellOf(at.y, GRID_ORIGIN_Y);
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
int cellIndex = isInside ? row * room.gridWidth + column : -1;
if (room.GetGridCollision(cellIndex) != COLLISION_NONE) return false;
@@ -657,8 +656,8 @@ bool room_check_line(const Vector& start, const Vector& end, int mode, int gridP
}
for (const LineCorner& corner : LINE_CORNERS)
{
int column = cellOf(at.x + corner.x, GRID_CELL);
int row = cellOf(at.y + corner.y, GRID_TOP);
int column = cellOf(at.x + corner.x, GRID_ORIGIN_X);
int row = cellOf(at.y + corner.y, GRID_ORIGIN_Y);
int collision = line_cell_collision(room, column, row);
if (mode == LINE_MODE_PROJECTILE && collision == COLLISION_PIT) continue;
if (collision != COLLISION_NONE) return false;
@@ -1905,7 +1904,7 @@ void Entity_NPC::Update()
spawn_damage_numbers();
update_damage_history();
if (aiCallFlags & AI_CALL_PRE_UPDATE) ai_call(AI_PHASE_PRE_UPDATE);
if (HasEntityFlags(FLAG_PERSISTENT | FLAG_FRIENDLY_BALL_DYING)) captured_update();
if (HasEntityFlags(FLAG_PERSISTENT | FLAG_DELIRIUM_FORM)) captured_update();
float healthBefore = health;
if (type == ENTITY_MINECART) update_physics();
@@ -1937,8 +1936,8 @@ void Entity_NPC::Update()
forced_target_update();
}
// Part of 006c4b30: an enemy captured in a Friendly Ball (or dying out of one) wastes a quarter of health every 15
// frames down to 1, greying and shrinking with it. A hit this frame that is not fire, spikes or poop passes on as 1
// Part of 006c4b30: a persistent enemy or a Delirium form (Delirious's friendly boss) wastes a quarter of health every
// 15 frames down to 1, greying and shrinking with it. A hit this frame that is not fire, spikes or poop passes on as 1
// damage from its biggest hit, or as 5 from an explosion.
// The shrink is lost at once, as the frame's scale reset (FUN_006d6650) overwrites it.
void Entity_NPC::captured_update()
@@ -1982,35 +1981,43 @@ void Entity_NPC::captured_update()
// The camouflage seeds: an enemy takes on the floor under it, sampled on its first frames and every 30 after, and
// blends a tenth of the way toward it each frame, nearly black underneath.
void Entity_NPC::camouflage_update()
{
constexpr float CAMO_DARKNESS = 0.02f;
camouflage_blend(*this, floorColor, CAMO_DARKNESS);
}
// The camouflage of an entity on the camo seeds: a color sampled from the floor under it on its first frames and
// every 30 after, which its sprite blends a tenth of the way toward each frame, tinted to a darkness underneath.
void camouflage_blend(Entity& entity, ColorMod& floorColor, float darkness)
{
constexpr float CAMO_ALPHA = 0.7f;
constexpr float CAMO_FLOOR_TONE = 0.9f;
constexpr float CAMO_ALPHA_BLEND = 0.3f;
constexpr float CAMO_FLOOR_BLEND = 0.5f;
constexpr float CAMO_SPRITE_BLEND = 0.1f;
constexpr float CAMO_DARKNESS = 0.02f;
constexpr int CAMO_RESAMPLE_FRAMES = 30;
constexpr int CAMO_SAMPLE_WINDOW = 2;
Room& room = *g_game->room;
if (FrameCount() < CAMO_SAMPLE_WINDOW)
ANM2& sprite = entity.sprite;
if (entity.FrameCount() < CAMO_SAMPLE_WINDOW)
{
KColor floor = room_floor_texel_get(room, pos);
KColor floor = room_floor_texel_get(room, entity.pos);
const float shares[] = {floor._red, floor._green, floor._blue};
std::fill_n(floorColor._tint, 3, 0.0f);
floorColor._tint[3] = CAMO_ALPHA;
for (int i = 0; i < 3; i++) floorColor._offset[i] = shares[i] * CAMO_FLOOR_TONE;
sprite.color = floorColor;
}
if ((uint32_t)(g_game->frameCount + index) % CAMO_RESAMPLE_FRAMES < CAMO_SAMPLE_WINDOW)
if ((uint32_t)(g_game->frameCount + entity.index) % CAMO_RESAMPLE_FRAMES < CAMO_SAMPLE_WINDOW)
{
KColor floor = room_floor_texel_get(room, pos);
KColor floor = room_floor_texel_get(room, entity.pos);
floorColor._tint[3] = std::lerp(floorColor._tint[3], CAMO_ALPHA, CAMO_ALPHA_BLEND);
const float shares[] = {floor._red, floor._green, floor._blue};
for (int i = 0; i < 3; i++)
floorColor._offset[i] = std::lerp(floorColor._offset[i], shares[i] * CAMO_FLOOR_TONE, CAMO_FLOOR_BLEND);
}
ColorMod blended = color_lerp(sprite.color, floorColor, CAMO_SPRITE_BLEND);
std::fill_n(blended._tint, 3, CAMO_DARKNESS);
std::fill_n(blended._tint, 3, darkness);
blended._tint[3] = 1;
sprite.color = blended;
}
@@ -2150,7 +2157,7 @@ float Entity_NPC::compute_speed_multiplier()
if (HasEntityFlags(FLAG_SLOW) && state != NPC_STATE_DEATH) speed *= SPEED_HALF;
if (HasEntityFlags(FLAG_WEAKNESS)) speed *= SPEED_WEAKENED;
if (IsBoss() && !IsFriendly() && room.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_VANISHING_TWIN_ID))
if (IsBoss() && !IsFriendly() && room.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_VANISHING_TWIN))
speed *= SPEED_VANISHING_TWIN;
return speed;
}