Curation round 25 (code only): the ultra horsemen and the Beast's background, the Scourge and Polty, the player's last gaps with the frame gate removed, game core, debug and daily, local co-op and player-controlled enemies, TMTRAINER, local versus, the vanilla Lua API, the special-daily fix, shared constants folded (60 duplicates, 10 offline gaps)

This commit is contained in:
shweet committed 2026-11-23 07:35:21 -05:00
1 parent 534339a496
commit 5c89798773
280 files changed
+14904 -5309

No files matched your search

+170 -24
View File
@@ -20,8 +20,10 @@
#include "room.h"
#include "room_config.h"
#include "room_grid.h"
#include "room_transition.h"
#include "sfx_manager.h"
#include <algorithm>
#include <set>
#include <cmath>
// The trinkets' constants: Rosary Bead's Bible chance, the battery trinkets' achievement, Wooden Cross's mantles
@@ -48,9 +50,12 @@ constexpr int BOOSTER_SPECIAL = 25;
constexpr int BOOSTER_SUIT_FIRST = 1;
constexpr int BOOSTER_SUIT = 5;
// Whether a trinket stays in its slot when a new one is picked up: the Tick, and Rainbow Worm in Pride Day.
// Whether a trinket stays in its slot when a new one is picked up: the Tick, and Rainbow Worm in Pride Day (in a
// versus match every trinket, when its rules keep them).
static bool is_trinket_stuck(uint32_t trinket)
{
DeathmatchManager& versus = g_game->deathmatchManager;
if (versus.is_active()) return !versus.type->is_trinket_swap_allowed();
return trinket == TRINKET_TICK || (trinket == TRINKET_RAINBOW_WORM && g_game->challenge == CHALLENGE_PRIDE_DAY);
}
@@ -111,9 +116,6 @@ bool Entity_Player::HasGoldenTrinket(uint32_t trinketId)
// Tick (and Rainbow Worm in Pride Day) stay unless the new trinket burns the Tick.
bool Entity_Player::TryHoldTrinket(int trinketId)
{
if (g_game->deathmatchManager.is_active())
reconstruction_missing("Entity_Player::TryHoldTrinket 007716f0 (the versus mode)");
for (int i = 0; i < GetMaxTrinkets(); i++)
{
uint32_t held = trinkets[i];
@@ -150,9 +152,6 @@ static void moms_toenail_stomp(Vector position, int stomps)
Entity_Pickup* Entity_Player::DropTrinket(Vector position, bool isReplaceTick)
{
FlushQueueItem();
if (g_game->deathmatchManager.is_active())
reconstruction_missing("Entity_Player::DropTrinket 00771800 (the versus mode)");
int slot = -1;
for (int i = 0; i < TRINKET_SLOT_COUNT && trinkets[i] != 0; i++)
{
@@ -325,8 +324,18 @@ void Entity_Player::TriggerTrinketRemoved(uint32_t trinketId)
break;
case TRINKET_BROKEN_SYRINGE:
case TRINKET_MOMS_LOCK:
{
int& lent = id == TRINKET_BROKEN_SYRINGE ? versus.drugEffect : versus.momEffect;
if (!isVersusLost || lent == 0) break;
temporaryEffects.RemoveCollectibleEffect(lent, 1);
lent = 0;
break;
}
case TRINKET_THE_TWINS:
if (isVersusLost) reconstruction_missing("Entity_Player::TriggerTrinketRemoved 007adb30 (the versus trinkets)");
if (!isVersusLost) break;
for (int lent : versus.twinsEffects)
if (g_manager->itemConfig.GetCollectible(lent)) temporaryEffects.RemoveCollectibleEffect(lent, 1);
versus.twinsEffects.clear();
break;
case TRINKET_DEVILS_CROWN: Level::update_treasure_room_doors_for_trinket(); break;
case TRINKET_MOTHERS_KISS: update_greeds_gullet(); break;
@@ -418,8 +427,10 @@ bool Entity_Player::TryRemoveTrinket(uint32_t trinketId)
return true;
}
if (isMain) return TryRemoveSmeltedTrinket(trinketId);
if (!proceduralItems.empty()) reconstruction_missing("Entity_Player::TryRemoveTrinket 00771f60 (a glitched item)");
return false;
int glitched = glitched_item_copying(*this, ITEM_TRINKET, (int)trinketId);
if (glitched == 0) return false;
RemoveCollectible(glitched, false, 0, true);
return true;
}
// 007d83f0 Lil Clot's clots: one per copy of the trinket, less those already following, each launched in a random
@@ -437,7 +448,7 @@ void Entity_Player::spawn_lil_clot_familiars()
for (int i = clots; i < multiplier; i++)
{
uint32_t seed = Random();
float angle = random_unit() * RANDOM_HALF_TURN;
float angle = random_unit() * PI_ROUGH;
angle += angle;
Vector velocity = vector_make(std::cos(angle) * CLOT_LAUNCH_SPEED, std::sin(angle) * CLOT_LAUNCH_SPEED);
Entity* clot = g_game->Spawn({.position = pos, .velocity = velocity, .spawner = this, .subType = CLOT_SUBTYPE,
@@ -503,8 +514,140 @@ void equality_update(Entity_Player& player)
player.EvaluateItems();
}
// Where a Cursed Penny teleport may lead: the room types it draws from, the special rooms it adds, and whether cleared
// (visited) and uncleared (unvisited) rooms count.
struct PennyTeleport
{
std::vector<int> roomTypes;
std::vector<int> rooms;
bool isClearedAllowed = false;
bool isUnclearedAllowed = false;
};
// The ordinary rooms most coins send to, with the Isaac's rooms and the extra ones some add after them.
constexpr int PENNY_ROOMS[] = {ROOM_DEFAULT, ROOM_SHOP, ROOM_TREASURE, ROOM_BOSS, ROOM_MINIBOSS, ROOM_SECRET,
ROOM_SUPERSECRET, ROOM_ARCADE, ROOM_CHALLENGE, ROOM_LIBRARY, ROOM_SACRIFICE};
// The rooms a coin's Cursed Penny teleport may lead to, rolled by the coin (a penny, a nickel, a dime, a double, a
// lucky, a sticky or a golden one): better rooms the more Cursed Pennies (25 or 50 more in 100). A dime may open the
// devil or the angel room, others the error room or the black market.
static PennyTeleport penny_teleport_roll(int coin, int bonus, RNG& rng)
{
auto rooms = [](std::initializer_list<int> extra) {
std::vector<int> types(std::begin(PENNY_ROOMS), std::end(PENNY_ROOMS));
types.insert(types.end(), extra);
return types;
};
PennyTeleport teleport;
teleport.isClearedAllowed = coin >= 2 && coin <= 7;
teleport.isUnclearedAllowed = coin >= 1 && coin <= 7;
uint32_t roll = coin >= 1 && coin <= 7 ? rng.RandomInt(100) : 0;
switch (coin)
{
case 1:
if (roll < (uint32_t)bonus + 50) teleport.roomTypes = {ROOM_DEFAULT};
else
{
teleport.isClearedAllowed = true;
teleport.roomTypes = rooms({ROOM_CHEST, ROOM_DICE, ROOM_BLACK_MARKET, ROOM_PLANETARIUM, ROOM_ISAACS});
}
break;
case 2:
teleport.roomTypes = roll < (uint32_t)bonus + 50
? std::vector<int>{ROOM_SHOP, ROOM_TREASURE, ROOM_ARCADE, ROOM_CHALLENGE,
ROOM_LIBRARY, ROOM_PLANETARIUM}
: std::vector<int>{ROOM_DEFAULT, ROOM_BOSS, ROOM_MINIBOSS, ROOM_SECRET,
ROOM_SUPERSECRET, ROOM_SACRIFICE, ROOM_CHEST, ROOM_DICE,
ROOM_BLACK_MARKET, ROOM_ISAACS};
break;
case 3:
if (roll < (uint32_t)bonus + 25)
{
bool isAngel = rng.RandomInt(100) < 50;
g_game->InitializeDevilAngelRoom(isAngel, !isAngel);
teleport.rooms = {ROOM_DEVIL_IDX};
break;
}
teleport.roomTypes = rooms({ROOM_CURSE, ROOM_CHEST, ROOM_DICE, ROOM_PLANETARIUM, ROOM_ISAACS});
teleport.rooms = {ROOM_ERROR_IDX, ROOM_BLACK_MARKET_IDX};
break;
case 4:
if (roll < (uint32_t)bonus + 50) teleport.roomTypes = {ROOM_CHEST, ROOM_DICE, ROOM_ISAACS};
else
{
teleport.roomTypes = rooms({ROOM_PLANETARIUM, ROOM_SECRET, ROOM_SUPERSECRET});
teleport.rooms = {ROOM_BLACK_MARKET_IDX};
}
break;
case 5:
if (roll < (uint32_t)bonus + 50) teleport.roomTypes = {ROOM_SECRET, ROOM_SUPERSECRET};
else
{
teleport.roomTypes = rooms({ROOM_CHEST, ROOM_DICE, ROOM_PLANETARIUM, ROOM_ISAACS});
teleport.rooms = {ROOM_BLACK_MARKET_IDX};
}
break;
case 6:
teleport.roomTypes = {roll < 50 ? ROOM_CURSE : ROOM_BOSS};
break;
case 7:
if (roll < (uint32_t)bonus + 10) teleport.rooms = {ROOM_ERROR_IDX};
else
{
teleport.roomTypes = rooms({ROOM_PLANETARIUM, ROOM_SECRET, ROOM_SUPERSECRET, ROOM_CHEST, ROOM_DICE,
ROOM_ISAACS});
teleport.rooms = {ROOM_BLACK_MARKET_IDX};
}
break;
}
return teleport;
}
// The floor's rooms in the current dimension of the rolled types, each cell once: a cleared one when cleared rooms
// count, an uncleared one when those do, and only when a visited room's (or an unvisited room's) kind counts too.
static void penny_rooms_add(PennyTeleport& teleport)
{
Game& game = *g_game;
std::set<int> seen;
for (int index = 0; index < game.nbRooms; index++)
{
RoomDescriptor& room = game.roomList[index];
if (!room.data || room.dimension != game.currentDimensionIdx) continue;
if (std::ranges::find(teleport.roomTypes, room.data->type) == teleport.roomTypes.end()) continue;
if (!seen.insert(room.gridIndex).second) continue;
bool isClear = room.flags & ROOM_DESCRIPTOR_FLAG_CLEAR;
bool isAllowed = isClear ? teleport.isClearedAllowed : teleport.isUnclearedAllowed;
bool isVisitAllowed = room.visitedCount != 0 ? teleport.isClearedAllowed : teleport.isUnclearedAllowed;
if (isAllowed && isVisitAllowed) teleport.rooms.push_back(room.gridIndex);
}
}
// Cursed Penny's teleport after a coin: to a random room of the coin's roll (a sticky coin's curse room falling back
// on the boss room), else as Teleport! does.
static void cursed_penny_teleport(Entity_Player& player)
{
RNG& rng = player.GetTrinketRNG(TRINKET_CURSED_PENNY);
int copies = player.GetTrinketMultiplier(TRINKET_CURSED_PENNY);
int bonus = copies == 2 ? 25 : copies == 3 ? 50 : 0;
PennyTeleport teleport = penny_teleport_roll(player.cursedPennyPending, bonus, rng);
penny_rooms_add(teleport);
int target = teleport.rooms.empty() ? 0 : teleport.rooms[rng.RandomInt((uint32_t)teleport.rooms.size())];
if (player.cursedPennyPending == 6 && teleport.roomTypes.front() == ROOM_CURSE && target == 0)
target = g_game->QueryRoomTypeIndex(ROOM_BOSS, false, rng, false);
if (target == 0)
{
int item = player.GetTrinketMultiplier(TRINKET_BROKEN_REMOTE) <= 1 ? COLLECTIBLE_TELEPORT : COLLECTIBLE_TELEPORT_2;
player.UseActiveItem({.item = item, .flags = USE_NOANIM});
return;
}
g_game->leaveDoor = -1;
g_game->StartRoomTransition({.player = &player, .animation = TRANSITION_TELEPORT, .roomIndex = target});
}
// Broken Remote's part of 00782af0: after an active used from the main slot the player teleports (Teleport 2.0's pick
// with more than one copy). Cursed Penny's teleports stop the game.
// with more than one copy). After a coin Cursed Penny teleports it.
void trinket_teleports_update(Entity_Player& player)
{
Game& game = *g_game;
@@ -517,8 +660,7 @@ void trinket_teleports_update(Entity_Player& player)
int item = player.GetTrinketMultiplier(TRINKET_BROKEN_REMOTE) <= 1 ? COLLECTIBLE_TELEPORT : COLLECTIBLE_TELEPORT_2;
player.UseActiveItem({.item = item, .flags = USE_NOANIM});
}
else if (player.cursedPennyPending != 0)
reconstruction_missing("Entity_Player::Update 00782af0 (Cursed Penny's teleport)");
else if (player.cursedPennyPending != 0) cursed_penny_teleport(player);
player.isBrokenRemotePending = false;
player.cursedPennyPending = 0;
}
@@ -537,8 +679,7 @@ void Entity_Player::add_random_drug_item_effect()
int id = DRUG_ITEMS[GetTrinketRNG(TRINKET_BROKEN_SYRINGE).Next() & 7];
temporaryEffects.AddEffect(TemporaryEffect(g_manager->itemConfig.GetCollectible(id)), true, 1);
if (g_game->deathmatchManager.is_active())
reconstruction_missing("Entity_Player::add_random_drug_item_effect 007dbba0 (the versus mode)");
if (g_game->deathmatchManager.is_active()) versus.drugEffect = id;
}
// 007dbc80 Mom's Lock lends one of Mom's thirteen collectibles' effects for the room. The versus mode remembers which.
@@ -548,8 +689,7 @@ void Entity_Player::AddRandomMomItemEffect()
int id = MOM_ITEMS[GetTrinketRNG(TRINKET_MOMS_LOCK).Next() % std::size(MOM_ITEMS)];
temporaryEffects.AddEffect(TemporaryEffect(g_manager->itemConfig.GetCollectible(id)), true, 1);
if (g_game->deathmatchManager.is_active())
reconstruction_missing("Entity_Player::AddRandomMomItemEffect 007dbc80 (the versus mode)");
if (g_game->deathmatchManager.is_active()) versus.momEffect = id;
}
// 007dbe70 Modeling Clay copies only summonable collectibles.
@@ -759,8 +899,8 @@ static bool is_pre_ascent_mom_room()
return room.roomType == ROOM_BOSS && room.descriptor->data->subtype == BOSS_SUBTYPE_MOM && g_game->IsPreAscent();
}
// The pickup effects of 0075f0e0 for the collectibles 367 on that do more than drop pickups: Mom's Box's Wooden
// Cross and Duct Tape, Tarot Cloth's card, Divorce Papers, Brittle Bones, the Broken Shovel, Luna's secret room,
// The pickup effects of 0075f0e0 for Clear Rune's rune and the collectibles 367 on that do more than drop pickups:
// Mom's Box's Wooden Cross and Duct Tape, Tarot Cloth's card, Divorce Papers, Brittle Bones, the Broken Shovel, Luna's secret room,
// Saturnus' tears, the Booster Pack, False PHD, Dad's Note's ascent and TMTRAINER. Camo Undies only acts in versus.
void late_collectible_gain(Entity_Player& player, int type, bool isFirstTime)
{
@@ -772,6 +912,15 @@ void late_collectible_gain(Entity_Player& player, int type, bool isFirstTime)
wooden_cross_mantle_add(player);
if (player.GetTrinketMultiplier(TRINKET_DUCT_TAPE) > 1 && player.ductTapeMode == 0) player.ductTapeMode = 1;
return;
case COLLECTIBLE_CLEAR_RUNE:
if (!isFirstTime) return;
{
int rune = ItemPool::GetCardEx((int)rng.Next(), 0, -1, 0, true);
Vector position = room_free_pickup_position_find({.position = player.pos, .step = GAIN_PICKUP_STEP});
g_game->Spawn({.position = position, .subType = rune, .type = ENTITY_PICKUP, .variant = PICKUP_TAROTCARD,
.seed = rng.Next()});
}
return;
case COLLECTIBLE_TAROT_CLOTH:
if (!isFirstTime) return;
{
@@ -782,8 +931,7 @@ void late_collectible_gain(Entity_Player& player, int type, bool isFirstTime)
}
return;
case COLLECTIBLE_CAMO_UNDIES:
if (g_game->deathmatchManager.is_active())
reconstruction_missing("Entity_Player::AddCollectible 0075f0e0 (Camo Undies in versus)");
if (g_game->deathmatchManager.is_active()) camo_undies_confuse(player);
return;
case COLLECTIBLE_DIVORCE_PAPERS:
if (isFirstTime) divorce_papers_gain(player, rng);
@@ -813,8 +961,6 @@ void late_collectible_gain(Entity_Player& player, int type, bool isFirstTime)
if (isFirstTime) tmtrainer_gain(player);
return;
}
reconstruction_missing((std::string("Entity_Player::AddCollectible 0075f0e0 (the pickup effect of ") +
std::to_string(type) + ")").c_str());
}
// Purity's pickup in 0075f0e0: a colour is rolled, its aura and glow come on.