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:
1 parent
69a354f843
commit
48933cd312
59 files changed
+13387
-6056
No files matched your search
+180
-47
@@ -4,6 +4,9 @@
|
||||
#include "game.h"
|
||||
#include "grid_entity_door.h"
|
||||
#include "hud.h"
|
||||
#include "lua_engine.h"
|
||||
#include "menu_special_seeds.h"
|
||||
#include "music_manager.h"
|
||||
#include "manager.h"
|
||||
#include "platform.h"
|
||||
#include "room.h"
|
||||
@@ -62,6 +65,38 @@ constexpr int STAGE_ID_DROSS = 28;
|
||||
constexpr int STAGE_ID_VOID = 26;
|
||||
|
||||
constexpr uint32_t CHALLENGE_XXXXXXXXL = 21;
|
||||
|
||||
// The Ascent's music: the alternate path's stages take the layers past the chapters'.
|
||||
constexpr int ALT_PATH_LAYER_FIRST = 3;
|
||||
constexpr int STAGE_ID_HOME = 35;
|
||||
constexpr int DIMENSION_MINESHAFT = 2;
|
||||
constexpr int ENEMY_TYPE_FIRST = 10;
|
||||
constexpr int ENEMY_TYPE_LAST = 999;
|
||||
constexpr int COLLECTIBLE_BERSERK = 704;
|
||||
|
||||
// The enemies' health that makes a room's music intense, growing with the floor (a Greed floor counting as two).
|
||||
constexpr float INTENSE_HEALTH_BASE = 40;
|
||||
constexpr float INTENSE_HEALTH_PER_STAGE = 14;
|
||||
constexpr float INTENSE_HEALTH_ALWAYS = 10000;
|
||||
constexpr float MINESHAFT_HEALTH_PER_PIT = 3;
|
||||
constexpr int GREED_STAGE_LAST_PAIRED = 4;
|
||||
constexpr int GREED_STAGE_SHOP = 5;
|
||||
constexpr int GREED_DEPTH_SHOP = 10;
|
||||
|
||||
// The endless basement's floor number as roman numerals, and the counts its jokes start at.
|
||||
struct RomanNumeral
|
||||
{
|
||||
int value;
|
||||
const char* text;
|
||||
};
|
||||
constexpr RomanNumeral ROMAN_NUMERALS[] = {{1000, "M"}, {900, "CM"}, {500, "D"}, {400, "CD"}, {100, "C"}, {90, "XC"},
|
||||
{50, "L"}, {40, "XL"}, {10, "X"}, {9, "IX"}, {5, "V"}, {4, "IV"},
|
||||
{1, "I"}};
|
||||
constexpr uint32_t NUMERAL_QUESTION = 3;
|
||||
constexpr uint32_t NUMERAL_EXCLAIM = 4;
|
||||
constexpr uint32_t NUMERAL_ELLIPSIS = 5;
|
||||
constexpr uint32_t NUMERAL_SPIKES = 1001;
|
||||
constexpr std::string_view DEATHMATCH_NAME_KEY = "Online/DEATHMATCH_NAME";
|
||||
constexpr uint32_t SPECIAL_DAILY_NO_CURSES = 18;
|
||||
constexpr uint32_t SPECIAL_DAILY_DEALS = 17;
|
||||
constexpr uint32_t SPECIAL_DAILY_CURSED = 37;
|
||||
@@ -532,7 +567,7 @@ void Level::Init(bool isResetLilPortalRoom)
|
||||
room->camera->position_center();
|
||||
room->camera->DoUpdate(false);
|
||||
TextureCache::Purge();
|
||||
FUN_00865260();
|
||||
static_cast<LuaEngine*>(g_luaEngine)->PostNewLevel();
|
||||
isLevelGenerating = false;
|
||||
}
|
||||
|
||||
@@ -2464,7 +2499,7 @@ void Level::load_room()
|
||||
|
||||
if (isUpdated && game.frameCount == entity.spawnFrame) entity.Update();
|
||||
}
|
||||
FUN_00865180();
|
||||
static_cast<LuaEngine*>(g_luaEngine)->PostNewRoom();
|
||||
if (!game.deathmatchManager.is_active()) return;
|
||||
game.deathmatchManager.type->Init();
|
||||
game.dizzyTargetIntensity = 0;
|
||||
@@ -2620,12 +2655,6 @@ bool Level::boss_count_adjust(int&, int&)
|
||||
reconstruction_missing("Level::boss_count_adjust 007523e0");
|
||||
}
|
||||
|
||||
// 0073fc80 Moves to another room.
|
||||
void Level::ChangeRoom(int, int)
|
||||
{
|
||||
reconstruction_missing("Level::ChangeRoom 0073fc80");
|
||||
}
|
||||
|
||||
// 0073fa20 Enters a room config directly, for debugging.
|
||||
void Level::DEBUG_goto_room(RoomConfig_Room*)
|
||||
{
|
||||
@@ -2727,18 +2756,6 @@ Vector Level::GetEnterPosition()
|
||||
return g_vectorZero;
|
||||
}
|
||||
|
||||
// 0073d9b0 A door slot as another shape sees it.
|
||||
int Level::get_door_slot(int, int, bool, int)
|
||||
{
|
||||
reconstruction_missing("Level::get_door_slot 0073d9b0");
|
||||
}
|
||||
|
||||
// 0073da40 The slot a door leads into.
|
||||
int Level::GetTargetSlot(int, int)
|
||||
{
|
||||
reconstruction_missing("Level::GetTargetSlot 0073da40");
|
||||
}
|
||||
|
||||
// 0074c160 The cell a door leads to.
|
||||
XY Level::get_door_neighbor_pos(XY, RoomShape, int)
|
||||
{
|
||||
@@ -2787,12 +2804,6 @@ void Level::UncoverHiddenDoor(int, int)
|
||||
reconstruction_missing("Level::UncoverHiddenDoor 0074a1b0");
|
||||
}
|
||||
|
||||
// 0074d4a0 Prepares a Blue Key room.
|
||||
bool Level::prepare_blue_room(int, int, int)
|
||||
{
|
||||
reconstruction_missing("Level::prepare_blue_room 0074d4a0");
|
||||
}
|
||||
|
||||
// 0074d780 Adds a second boss room.
|
||||
bool Level::TryInitializeExtraBossRoom(uint32_t)
|
||||
{
|
||||
@@ -2884,10 +2895,80 @@ void Level::RemoveCurses(uint32_t)
|
||||
reconstruction_missing("Level::RemoveCurses 00748bc0");
|
||||
}
|
||||
|
||||
// 007eb870 Updates the Ascent's stages.
|
||||
// The music layer the Ascent turns on for a stage it climbs through: one per chapter, the alternate paths' past them.
|
||||
static int backwards_layer_get(int ascentStage)
|
||||
{
|
||||
uint32_t stageType = g_game->backwardsStages[ascentStage - 1].stageType;
|
||||
bool isAltPath = stageType == STAGETYPE_REPENTANCE || stageType == STAGETYPE_REPENTANCE_B;
|
||||
return isAltPath ? (ascentStage - 2) / 2 + ALT_PATH_LAYER_FIRST : (ascentStage - 1) / 2;
|
||||
}
|
||||
|
||||
// 007eb870 Sets the current track's layers for the room the players are in (the original's this is the room). On the
|
||||
// Ascent each layer is a stage climbed through outside its boss room. Elsewhere the intense layer plays while the
|
||||
// room's enemies have health enough for the floor (always from the Blue Womb on, and with Berserk), the Mines' chase
|
||||
// counting its pits. Nothing changes in the Home's dungeon or in Home's alternate. True when a layer plays.
|
||||
bool Level::UpdateBackwardsPathStages()
|
||||
{
|
||||
reconstruction_missing("Level::UpdateBackwardsPathStages 007eb870");
|
||||
Game& game = *g_game;
|
||||
MusicManager& music = g_manager->musicManager;
|
||||
RoomDescriptor* descriptor = room->descriptor;
|
||||
RoomConfig_Room* data = descriptor->data;
|
||||
|
||||
if (data && data->type == ROOM_DUNGEON && data->stageId == STAGE_ID_HOME) return false;
|
||||
int floor = (int)game.stage;
|
||||
bool isAscentFloor = floor >= (int)LEVEL_STAGE_BASEMENT_I && floor <= (int)ASCENT_LAST_STAGE;
|
||||
if (isAscentFloor && (game.gameStateFlags >> LEVEL_GAME_STATE_BACKWARDS_PATH & 1))
|
||||
{
|
||||
bool isAltPath = game.stageType == STAGETYPE_REPENTANCE || game.stageType == STAGETYPE_REPENTANCE_B;
|
||||
int first = floor + (isAltPath ? 1 : 0);
|
||||
uint32_t layers = 0;
|
||||
for (int ascentStage = first; ascentStage <= BACKWARDS_STAGE_COUNT; ascentStage++)
|
||||
if (ascentStage != first || game.room->descriptor->listIndex != game.lastBossRoomListIdx)
|
||||
layers |= 1u << backwards_layer_get(ascentStage);
|
||||
for (int layer = 0; layer < MUSIC_LAYER_COUNT; layer++)
|
||||
layers >> layer & 1 ? music.EnableLayer(layer, LAYER_FADE) : music.DisableLayer(layer);
|
||||
return layers != 0;
|
||||
}
|
||||
if (!isAscentFloor && floor == (int)LEVEL_STAGE_HOME && game.stageType == STAGETYPE_WOTL) return true;
|
||||
|
||||
int depth = floor;
|
||||
if (game.IsGreedMode()) depth = floor <= GREED_STAGE_LAST_PAIRED ? floor * 2 - 1 : floor == GREED_STAGE_SHOP ? GREED_DEPTH_SHOP : 0;
|
||||
float threshold = (float)depth * INTENSE_HEALTH_PER_STAGE + INTENSE_HEALTH_BASE;
|
||||
float health = 0;
|
||||
for (size_t i = 0; i < game.playerManager.playerList.size(); i++)
|
||||
if (game.GetPlayer((int)i)->temporaryEffects.HasCollectibleEffect(COLLECTIBLE_BERSERK))
|
||||
{
|
||||
health = INTENSE_HEALTH_ALWAYS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (floor < (int)LEVEL_STAGE_BLUE_WOMB)
|
||||
{
|
||||
for (Entity* entity : room->entityList.updateEL)
|
||||
{
|
||||
bool isCounted = (game.deathmatchManager.is_active() && entity->type == ENTITY_PLAYER) ||
|
||||
(entity->type >= ENEMY_TYPE_FIRST && entity->type <= ENEMY_TYPE_LAST);
|
||||
if (isCounted && entity->CanShutDoors() && !entity->isDead && !entity->HasEntityFlags(FLAG_NO_TARGET))
|
||||
health += entity->health;
|
||||
}
|
||||
if (health > 0)
|
||||
{
|
||||
bool isMineshaft = false;
|
||||
if (game.challenge == CHALLENGE_RED_REDEMPTION)
|
||||
isMineshaft = RoomConfig::GetStageID(floor, GetRoomStageType(currentRoomIdx), ROOM_MODE_CURRENT) == STAGE_ID_MINES;
|
||||
else if (game.currentDimensionIdx != DIMENSION_MINESHAFT)
|
||||
isMineshaft = RoomConfig::GetStageID(floor, (int)game.stageType, ROOM_MODE_CURRENT) == STAGE_ID_MINES;
|
||||
uint32_t flags = descriptor->flags;
|
||||
bool isChase = isMineshaft && !(flags & ROOM_DESCRIPTOR_FLAG_CLEAR) && (flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER) &&
|
||||
!(flags & ROOM_DESCRIPTOR_FLAG_FLOODED);
|
||||
if (isChase) health += (float)descriptor->pitsCount * MINESHAFT_HEALTH_PER_PIT;
|
||||
}
|
||||
}
|
||||
else if (!(descriptor->flags & ROOM_DESCRIPTOR_FLAG_CLEAR)) health += INTENSE_HEALTH_ALWAYS;
|
||||
|
||||
bool isIntense = health >= threshold;
|
||||
isIntense ? music.EnableLayer(0, LAYER_FADE) : music.DisableLayer(0);
|
||||
return isIntense;
|
||||
}
|
||||
|
||||
// 0074b960 The stage counted as in normal runs.
|
||||
@@ -2926,22 +3007,86 @@ RoomDescriptor* Level::get_secret_exit_room(int)
|
||||
reconstruction_missing("Level::get_secret_exit_room 0074bba0");
|
||||
}
|
||||
|
||||
// 007460b0 The floor's name.
|
||||
// 00745ca0 A stage's display name in the current language: stages.xml's, then the endless basement's roman numeral and
|
||||
// its jokes, then " I" or " II" for a chapter's floor or " XL" for a labyrinth, scrambled for dyslexia. Greed and Red
|
||||
// Redemption add no floor number. Empty for no stage.
|
||||
std::string Level::get_stage_display_name(const StageNameQuery& query)
|
||||
{
|
||||
if (query.stage == 0) return "";
|
||||
|
||||
Game& game = *g_game;
|
||||
RoomMode mode = query.mode;
|
||||
if (mode == ROOM_MODE_CURRENT) mode = g_game && g_game->IsGreedMode() ? ROOM_MODE_GREED : ROOM_MODE_NORMAL;
|
||||
int stageId = RoomConfig::GetStageID(query.stage, query.stageType, mode);
|
||||
std::string name = game.roomConfig.stages[stageId].GetDisplayName(LANGUAGE_CURRENT);
|
||||
|
||||
if (query.numeral > 0)
|
||||
{
|
||||
name += ' ';
|
||||
int remaining = query.numeral;
|
||||
for (const RomanNumeral& numeral : ROMAN_NUMERALS)
|
||||
for (; remaining >= numeral.value; remaining -= numeral.value) name += numeral.text;
|
||||
|
||||
uint32_t count = (uint32_t)game.stageNameNumeral;
|
||||
if (count == NUMERAL_QUESTION) name += "?";
|
||||
if (count == NUMERAL_EXCLAIM) name += "?!";
|
||||
if (count == NUMERAL_ELLIPSIS) name += "...";
|
||||
if (count == NUMERAL_SPIKES) name += " Spikes";
|
||||
if (count % 1000 == 0) name += "... Please stop.";
|
||||
else if (count % 500 == 0) name += "!V";
|
||||
else if (count % 100 == 0) name += "!!!";
|
||||
else if (count % 50 == 0) name += "!!";
|
||||
else if (count % 10 == 0) name += "!";
|
||||
}
|
||||
|
||||
bool isNumbered = mode != ROOM_MODE_GREED && game.challenge != CHALLENGE_RED_REDEMPTION;
|
||||
if (isNumbered && (query.curses & CURSE_OF_LABYRINTH)) name += " XL";
|
||||
else if (isNumbered && query.numeral == 0 && query.stage >= 1 && query.stage <= (int)LEVEL_STAGE_WOMB_II)
|
||||
name += query.stage & 1 ? " I" : " II";
|
||||
return query.isScrambled ? string_scramble_seeded(name) : name;
|
||||
}
|
||||
|
||||
// 007460b0 The floor's name, with Red Redemption's room stage type, the endless basement's numeral and dyslexia.
|
||||
std::string Level::GetName()
|
||||
{
|
||||
reconstruction_missing("Level::GetName 007460b0");
|
||||
Game& game = *g_game;
|
||||
bool isRedRedemption = game.challenge == CHALLENGE_RED_REDEMPTION;
|
||||
|
||||
return get_stage_display_name({.stage = (int)stage,
|
||||
.stageType = isRedRedemption ? GetRoomStageType(currentRoomIdx) : (int)stageType,
|
||||
.curses = GetCurses(),
|
||||
.numeral = game.seedEffects.HasSeedEffect(SEED_INFINITE_BASEMENT) ? game.stageNameNumeral : 0,
|
||||
.isScrambled = game.seedEffects.HasSeedEffect(SEED_DYSLEXIA),
|
||||
.mode = ROOM_MODE_CURRENT});
|
||||
}
|
||||
|
||||
// 00746260 The floor's curse's name.
|
||||
// 00746260 The name of the floor's first curse, scrambled for dyslexia. Empty for none.
|
||||
std::string Level::GetCurseName()
|
||||
{
|
||||
reconstruction_missing("Level::GetCurseName 00746260");
|
||||
Game& game = *g_game;
|
||||
std::string name;
|
||||
|
||||
for (uint32_t curse = 0; curse < game.roomConfig.curses.size(); curse++)
|
||||
if (GetCurses() & 1u << curse)
|
||||
{
|
||||
name = game.roomConfig.GetCurseName(curse + 1);
|
||||
break;
|
||||
}
|
||||
return game.seedEffects.HasSeedEffect(SEED_DYSLEXIA) ? string_scramble_seeded(name) : name;
|
||||
}
|
||||
|
||||
// 00746560 Shows the floor's name.
|
||||
void Level::ShowName(bool)
|
||||
// 00746560 Shows the floor's name and curse in the HUD's banner, hiding by itself unless sticky. Versus shows its own.
|
||||
void Level::ShowName(bool isSticky)
|
||||
{
|
||||
reconstruction_missing("Level::ShowName 00746560");
|
||||
std::string name = GetName();
|
||||
std::string curse = GetCurseName();
|
||||
|
||||
if (g_game->deathmatchManager.is_active())
|
||||
{
|
||||
name = g_manager->stringTable.translate(DEATHMATCH_NAME_KEY);
|
||||
curse.clear();
|
||||
}
|
||||
g_game->hud.messageMain.Show(name.c_str(), curse.c_str(), !isSticky, !curse.empty());
|
||||
}
|
||||
|
||||
// 007475b0 Restores the floor from a save.
|
||||
@@ -2950,18 +3095,6 @@ void Level::RestoreGameState(GameState&)
|
||||
reconstruction_missing("Level::RestoreGameState 007475b0");
|
||||
}
|
||||
|
||||
// 00747e10 Saves the floor.
|
||||
void Level::store_game_state(GameState&)
|
||||
{
|
||||
reconstruction_missing("Level::store_game_state 00747e10");
|
||||
}
|
||||
|
||||
// 00747360 Saves a room config's id.
|
||||
void Level::write_room_config(RoomConfig_Room*, void*, void*)
|
||||
{
|
||||
reconstruction_missing("Level::write_room_config 00747360");
|
||||
}
|
||||
|
||||
// 007474a0 The room config a saved id names.
|
||||
RoomConfig_Room* Level::get_room_config_from_saved_id(uint32_t*, void*)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user