Curation round 16: Mom's Knife and the bone club, sin minibosses and death rewards, slots and beggars, NPC rendering and twelve bosses, alt path visuals, the Forgotten's flight and tainted HUDs, Sheol and the Cathedral to the credits, familiars and transformations
This commit is contained in:
1 parent
76c594f9a0
commit
e9de039d0f
151 files changed
+14996
-5208
No files matched your search
@@ -1,21 +1,226 @@
|
||||
#include "classes.h"
|
||||
#include "boss_ai.h"
|
||||
#include "entity_bomb.h"
|
||||
#include "entity_effect_combat.h"
|
||||
#include "entity_npc.h"
|
||||
#include "entity_pickup.h"
|
||||
#include "entity_player.h"
|
||||
#include "game.h"
|
||||
#include "game_end.h"
|
||||
#include "grid_entity_trap_door.h"
|
||||
#include "hud.h"
|
||||
#include "item_pool.h"
|
||||
#include "lua_api.h"
|
||||
#include "manager.h"
|
||||
#include "music_manager.h"
|
||||
#include "npc_basement.h"
|
||||
#include "room.h"
|
||||
#include "room_special.h"
|
||||
#include "room_transition.h"
|
||||
#include "seeds.h"
|
||||
#include "sfx_manager.h"
|
||||
#include "stage_transition.h"
|
||||
#include <algorithm>
|
||||
|
||||
// The reach of a Fart a script leaves out.
|
||||
constexpr float FART_RADIUS = 85;
|
||||
// The last stage the run's stage counters keep.
|
||||
constexpr int STAGE_COUNTER_MAX = 13;
|
||||
// Making this many devil deals in one run unlocks Azazel.
|
||||
constexpr int AZAZEL_DEALS = 3;
|
||||
constexpr int ACHIEVEMENT_AZAZEL = 79;
|
||||
// A Greed run's waves, bosses and the devil's included (one more in Greedier).
|
||||
constexpr int GREED_WAVE_TOTAL = 11;
|
||||
// The argument past the last line HUD:ShowFortuneText reads.
|
||||
constexpr int FORTUNE_ARGUMENT_END = 34;
|
||||
|
||||
// 006fe2f0 Moves the players into a room of the floor at once: each leaves the room, the level changes room, the new
|
||||
// room updates once and the item pool takes the room's pool. A Random() is drawn and dropped on the way.
|
||||
void Game::ChangeRoom(int roomIndex, int dimension)
|
||||
{
|
||||
for (Entity_Player* player : playerManager.playerList) player->room_exit(false);
|
||||
Level::ChangeRoom(roomIndex, dimension);
|
||||
room->Update();
|
||||
|
||||
Random();
|
||||
int pool = itemPool.get_pool_from_room_entities(room->roomType, *room->descriptor, room->bossId);
|
||||
itemPool.lastPool = pool == POOL_NONE ? POOL_TREASURE : pool;
|
||||
}
|
||||
|
||||
// 00703850 A random player within a radius of a position, else the last of the shuffled players.
|
||||
// The original reads before an empty player list. Here there is no player then.
|
||||
static Entity_Player* game_random_player(Game& game, Vector position, float radius)
|
||||
{
|
||||
std::vector<Entity_Player*> players = game.playerManager.playerList;
|
||||
if (players.empty()) return nullptr;
|
||||
|
||||
for (size_t index = players.size() - 1; index > 0; index--)
|
||||
std::swap(players[index], players[Random() % (index + 1)]);
|
||||
for (Entity_Player* player : players)
|
||||
if (vector_length_squared(vector_sub(position, player->pos)) < radius * radius) return player;
|
||||
return players.back();
|
||||
}
|
||||
|
||||
// 00704b70 Rerolls the collectibles the floor's other rooms keep: each saved pedestal of an item that may be rerolled
|
||||
// becomes a fresh, untouched one.
|
||||
static void game_level_collectibles_reroll(Game& game)
|
||||
{
|
||||
for (int index = 0; index < game.nbRooms; index++)
|
||||
for (EntitySaveState& saved : game.roomList[index].savedEntities)
|
||||
{
|
||||
bool isRerollable = Entity_Pickup::CanRerollVariant(PICKUP_COLLECTIBLE, saved.subtype);
|
||||
if (saved.type != ENTITY_PICKUP || saved.variant != PICKUP_COLLECTIBLE || saved.subtype == 0 ||
|
||||
!isRerollable)
|
||||
continue;
|
||||
saved.subtype = 0;
|
||||
saved.boolStorage1 = false;
|
||||
}
|
||||
}
|
||||
|
||||
// (00704b10, 00704b30, 00704b40, 0065d000, 007e92c0, 00738310, 00738320, 007e9330, 007e9370, 0085e3c0, 0085e3d0,
|
||||
// 0085e3f0, 0085e400, 00753c50, 007e92d0, 00753c80, 00753cb0, 0085e370, 00703560) Registers Game's run counters: the
|
||||
// devil deals and donations, and the stages cleared without damage, hearts or half health.
|
||||
// The original pushes the last levels with damage or without half health as an unregistered class.
|
||||
static void game_counters_register(lua_State* state)
|
||||
{
|
||||
lua_method(state, "AddDevilRoomDeal", [](Game& game) {
|
||||
if (++game.devilRoomDeals >= AZAZEL_DEALS) g_manager->persistentGameData.TryUnlock(ACHIEVEMENT_AZAZEL);
|
||||
});
|
||||
lua_method(state, "DonateGreed", [](Game& game, int amount) { game.donationModGreed += amount; });
|
||||
lua_method(state, "DonateAngel", [](Game& game, int amount) { game.donationModAngel += amount; });
|
||||
lua_method(state, "GetDonationModGreed", [](Game& game) { return game.donationModGreed; });
|
||||
lua_method(state, "GetDonationModAngel", [](Game& game) { return game.donationModAngel; });
|
||||
lua_method(state, "ClearDonationModGreed", [](Game& game) { game.donationModGreed = 0; });
|
||||
lua_method(state, "ClearDonationModAngel", [](Game& game) { game.donationModAngel = 0; });
|
||||
lua_method(state, "SetLastDevilRoomStage",
|
||||
[](Game& game, int stage) { game.lastDevilRoomStage = std::clamp(stage, 0, STAGE_COUNTER_MAX); });
|
||||
lua_method(state, "AddTreasureRoomsVisited", [](Game& game) { game.treasureRoomsVisited++; });
|
||||
lua_method(state, "AddStageWithoutHeartsPicked", [](Game& game) { game.stagesWithoutHeartsPicked++; });
|
||||
lua_method(state, "ClearStagesWithoutHeartsPicked", [](Game& game) { game.stagesWithoutHeartsPicked = 0; });
|
||||
lua_method(state, "AddStageWithoutDamage", [](Game& game) { game.stagesWithoutDamage++; });
|
||||
lua_method(state, "ClearStagesWithoutDamage", [](Game& game) { game.stagesWithoutDamage = 0; });
|
||||
lua_method(state, "SetLastLevelWithDamage",
|
||||
[](Game& game, int stage) { game.lastLevelWithDamage = std::clamp(stage, 0, STAGE_COUNTER_MAX); });
|
||||
lua_method(state, "GetLastLevelWithDamage", [](Game&) { return LuaOpaque{}; });
|
||||
lua_method(state, "SetLastLevelWithoutHalfHp",
|
||||
[](Game& game, int stage) { game.lastLevelWithoutHalfHp = std::clamp(stage, 0, STAGE_COUNTER_MAX); });
|
||||
lua_method(state, "GetLastLevelWithoutHalfHp", [](Game&) { return LuaOpaque{}; });
|
||||
lua_method(state, "AddEncounteredBoss",
|
||||
[](Game&, int type, int variant) { game_encountered_boss_add(type, variant); });
|
||||
lua_method(state, "GetNumEncounteredBosses", [](Game& game) { return (int)game.encounteredBosses.size(); });
|
||||
lua_method(state, "GetGreedWavesNum",
|
||||
[](Game& game) { return GREED_WAVE_TOTAL + (game.difficulty == DIFFICULTY_GREEDIER); });
|
||||
}
|
||||
|
||||
// (00440ee0, 00440620, 00753cc0, 004a5d00, 00703460, 005b1860, 00456860, 0085e390) Registers Game's screen and world
|
||||
// effects: explosions, particles, shockwaves, darkness, pixelation, hallucinations, fades and the HUD font.
|
||||
// The original pushes the ambush and the item overlay as unregistered classes.
|
||||
static void game_effects_register(lua_State* state)
|
||||
{
|
||||
lua_method(state, "BombDamage",
|
||||
[](Game&, Vector position, float damage, float radius, bool isLineCheck, Entity* source, TearFlags flags,
|
||||
int64_t damageFlags, bool isDamageSource) {
|
||||
explosion_damage({.tearFlags = flags,
|
||||
.position = position,
|
||||
.source = source,
|
||||
.damageFlags = (uint64_t)damageFlags,
|
||||
.damage = damage,
|
||||
.radius = radius,
|
||||
.isDamageSource = isDamageSource,
|
||||
.isLineCheck = isLineCheck});
|
||||
});
|
||||
lua_method(state, "BombExplosionEffects",
|
||||
[](Game&, Vector position, float damage, TearFlags flags, const ColorMod& color, Entity* source,
|
||||
float radiusMultiplier, bool isLineCheck, int64_t damageFlags, bool isDamageSource) {
|
||||
explosion_effects({.tearFlags = flags,
|
||||
.color = color,
|
||||
.position = position,
|
||||
.source = source,
|
||||
.damageFlags = (uint64_t)damageFlags,
|
||||
.damage = damage,
|
||||
.radiusMultiplier = radiusMultiplier,
|
||||
.isDamageSource = isDamageSource,
|
||||
.isLineCheck = isLineCheck});
|
||||
});
|
||||
lua_method(state, "BombTearflagEffects",
|
||||
[](Game&, Vector position, float radius, TearFlags flags, Entity* source, float radiusMultiplier) {
|
||||
explosion_tear_flag_effects({.tearFlags = flags,
|
||||
.position = position,
|
||||
.source = source,
|
||||
.radius = radius,
|
||||
.radiusMultiplier = radiusMultiplier});
|
||||
});
|
||||
lua_method(state, "SpawnParticles",
|
||||
[](Game&, Vector position, int variant, int count, float speed, const ColorMod& color, float height,
|
||||
int subType) {
|
||||
game_particles_spawn({.color = color,
|
||||
.position = position,
|
||||
.height = height,
|
||||
.speed = speed,
|
||||
.count = count,
|
||||
.subType = subType,
|
||||
.variant = variant});
|
||||
});
|
||||
lua_method(state, "MakeShockwave", [](Game&, Vector position, float amplitude, float speed, int duration) {
|
||||
shockwave_make(position, amplitude, speed, duration);
|
||||
});
|
||||
lua_method(state, "UpdateStrangeAttractor",
|
||||
[](Game&, Vector, float, float) { reconstruction_missing("Game::AttractEntities 00705b90"); });
|
||||
lua_method(state, "CharmFart",
|
||||
[](Game&, Vector, float, Entity*) { reconstruction_missing("Game::CharmFart 00703f90"); });
|
||||
lua_method(state, "Darken", [](Game& game, float strength, int timeout) {
|
||||
game.darknessStrength = strength;
|
||||
game.darknessTimeout = timeout;
|
||||
});
|
||||
lua_method(state, "GetTargetDarkness", [](Game& game) { return game.darknessStrength; });
|
||||
lua_method(state, "AddPixelation", [](Game& game, int duration) {
|
||||
game.pixelationTimer = std::max(duration, game.pixelationTimer);
|
||||
game.pixelationDuration = game.pixelationTimer;
|
||||
});
|
||||
lua_method(state, "ShowHallucination",
|
||||
[](Game& game, int frames, int backdrop) { game.ShowHallucination(frames, backdrop); });
|
||||
lua_method(state, "HasHallucination", [](Game& game) { return game.hallucinationTimer > 0; });
|
||||
lua_method(state, "Fadein", [](Game& game, float speed, bool isShowIcon, KColor color) {
|
||||
game.Fadein(speed, isShowIcon ? FADE_ICON_SHOW : FADE_ICON_HIDE, color);
|
||||
});
|
||||
lua_method(state, "Fadeout",
|
||||
[](Game& game, float speed, FadeOutTarget target, KColor color) { game.Fadeout(speed, target, color); });
|
||||
lua_method(state, "GetFont", [](Game&) { return &g_manager->font2_TeamMeatEx12; });
|
||||
lua_method(state, "GetAmbush", [](Game&) { return LuaOpaque{}; });
|
||||
lua_method(state, "GetItemOverlay", [](Game&) { return LuaOpaque{}; });
|
||||
lua_method(state, "ShowFortune", [](Game&) { reconstruction_missing("Game::ShowFortuneText 009807a0"); });
|
||||
lua_method(state, "ShowRule", [](Game&) { reconstruction_missing("Game::ShowFortuneText 009807a0"); });
|
||||
}
|
||||
|
||||
// (00704f20, 006f9770) Registers how Game moves the run on: its frame and draw, room and floor changes, rerolls,
|
||||
// the ending and the next victory lap.
|
||||
// The original hands StartStageTransition a player from its stack. Here it has none.
|
||||
static void game_flow_register(lua_State* state)
|
||||
{
|
||||
lua_method(state, "Update", [](Game& game) { game.Update(); });
|
||||
lua_method(state, "Render", [](Game& game) { game.Render(); });
|
||||
lua_method(state, "ChangeRoom",
|
||||
[](Game& game, int roomIndex, int dimension) { game.ChangeRoom(roomIndex, dimension); });
|
||||
lua_method(state, "MoveToRandomRoom", [](Game& game, bool isErrorRoom, uint32_t seed, Entity_Player* player) {
|
||||
game_random_room_move(game, isErrorRoom, seed, player);
|
||||
});
|
||||
lua_method(state, "StartStageTransition", [](Game& game, bool isSameStage, StageTransitionType type) {
|
||||
game.stageTransition.start({.type = type, .isSameStage = isSameStage});
|
||||
});
|
||||
lua_method(state, "GetRandomPlayer", game_random_player);
|
||||
lua_method(state, "RerollLevelCollectibles", game_level_collectibles_reroll);
|
||||
lua_method(state, "RerollLevelPickups",
|
||||
[](Game&, uint32_t) { reconstruction_missing("Game::RerollLevelPickups 00704c50"); });
|
||||
lua_method(state, "RerollEnemy", [](Game&, Entity*, bool) {
|
||||
reconstruction_missing("Game::RerollEnemy 007050c0");
|
||||
return false;
|
||||
});
|
||||
lua_method(state, "SpawnEntityDesc",
|
||||
[](Game&, LuaIgnored, Vector, Entity*) { reconstruction_missing("Game::SpawnEntityDesc 006fece0"); });
|
||||
lua_method(state, "End", [](Game&, GameEnding ending) { game_end(ending); });
|
||||
lua_method(state, "FinishChallenge", [](Game&) { challenge_finish(); });
|
||||
lua_method(state, "NextVictoryLap", [](Game&) { reconstruction_missing("Game::NextVictoryLap 006f7ac0"); });
|
||||
}
|
||||
|
||||
// (00703510, 00703570) Registers Lua's Game: the run's level, room, players, pools, seeds and HUD, spawning, room
|
||||
// transitions and farts, and its state flags and counters. Game is also the Level it derives from.
|
||||
@@ -79,9 +284,23 @@ static void game_register(lua_State* state)
|
||||
lua_field<&Game::blueWombParTime>(state, "BlueWombParTime");
|
||||
lua_field<&Game::bossRushParTime>(state, "BossRushParTime");
|
||||
lua_field<&Game::screenShakeOffset>(state, "ScreenShakeOffset");
|
||||
game_counters_register(state);
|
||||
game_effects_register(state);
|
||||
game_flow_register(state);
|
||||
lua_class_end(state);
|
||||
}
|
||||
|
||||
// HUD:ShowFortuneText: the string arguments after the HUD, up to the first that is not one, as a fortune's lines.
|
||||
static int hud_fortune_text_show(lua_State* state)
|
||||
{
|
||||
HUD& hud = *static_cast<HUD*>(lua_object_check(state, 1, LUA_CLASS_HUD));
|
||||
std::vector<std::string> lines;
|
||||
for (int index = 2; index < FORTUNE_ARGUMENT_END && lua_type(state, index) == LUA_TSTRING; index++)
|
||||
lines.emplace_back(lua_tostring(state, index));
|
||||
hud.ShowFortuneText(lines);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Registers Lua's HUD, ItemPool and Seeds, the parts of a run Game hands out.
|
||||
static void game_parts_register(lua_State* state)
|
||||
{
|
||||
@@ -101,6 +320,8 @@ static void game_parts_register(lua_State* state)
|
||||
lua_method(state, "Update", [](HUD& hud) { hud.Update(); });
|
||||
lua_method(state, "PostUpdate", [](HUD& hud) { hud.PostUpdate(); });
|
||||
lua_method(state, "Render", [](HUD& hud) { hud.Render(); });
|
||||
lua_pushcfunction(state, hud_fortune_text_show);
|
||||
lua_table_set(state, -2, "ShowFortuneText");
|
||||
lua_class_end(state);
|
||||
|
||||
lua_class_begin(state, "ItemPool", LUA_CLASS_ITEM_POOL);
|
||||
@@ -136,6 +357,7 @@ static void game_parts_register(lua_State* state)
|
||||
lua_class_begin(state, "Seeds", LUA_CLASS_SEEDS);
|
||||
lua_method(state, "GetStartSeed", [](Seeds& seeds) { return seeds.GetStartSeed(); });
|
||||
lua_method(state, "IsCustomRun", [](Seeds& seeds) { return seeds.isCustomRun; });
|
||||
lua_method(state, "IsInitialized", [](Seeds& seeds) { return seeds.gameStartSeed != 0; });
|
||||
lua_method(state, "GetStartSeedString", [](Seeds& seeds) { return seeds.GetStartSeedString(); });
|
||||
lua_method(state, "GetNextSeed", [](Seeds& seeds) { return seeds.GetNextSeed(); });
|
||||
lua_method(state, "GetStageSeed", [](Seeds& seeds, int stage) { return seeds.GetStageSeed(stage); });
|
||||
|
||||
Reference in new issue
Block a user