Curation round 14: console and Lua API, effects, lasers, enemies, eleven bosses, the Depths and Mom, status effects, the playable characters

This commit is contained in:
shweet committed 2026-11-20 19:04:41 -05:00
1 parent 8ae02a8422
commit 6e3da161fc
138 files changed
+16754 -6825

No files matched your search

+97 -8
View File
@@ -58,6 +58,21 @@ constexpr uint32_t ERROR_ROOM_SHIFT = 7;
constexpr uint32_t MAGIC_SKIN_SHIFT = 55;
constexpr uint32_t GOLDEN_SHIFT = 19;
constexpr uint32_t PILL_SHIFT = 12;
// GetCard's odds of a special card, a rune and a playing card, and the shifts of GetCardEx's and Tainted Lost's draws.
constexpr int CARD_SPECIAL_ODDS = 25;
constexpr int CARD_RUNE_ODDS = 10;
constexpr int CARD_SUIT_ODDS = 10;
constexpr uint32_t CARD_DRAW_SHIFT = 21;
constexpr uint32_t HOLY_CARD_RNG_SHIFT = 47;
// The rune pool's least size, the odds of a blank giving a Rune Shard, and the cards GetCardEx tells apart.
constexpr size_t RUNE_POOL_MIN = 6;
constexpr uint32_t RUNE_SHARD_ODDS = 5;
constexpr int CARD_RUNE_SHARD = 55;
constexpr int HOLY_CARD = 51;
constexpr uint32_t HOLY_CARD_ODDS = 10;
constexpr int CARD_TAROT_LAST = 22;
constexpr int REVERSED_TAROT_OFFSET = 55;
constexpr uint32_t REVERSED_TAROT_ODDS = 7;
constexpr float CHAOS_WEIGHT_SCALE = 100;
constexpr float MAGIC_SKIN_CHANCE_PER_USE = 0.01f;
constexpr int MAGIC_SKIN_ROLL_BASE = 4;
@@ -113,9 +128,7 @@ constexpr int PILL_HORSE_ODDS = 70;
constexpr int PILL_EFFECT_NONE = -1;
constexpr int PILLEFFECT_BAD_TRIP = 1;
constexpr int PILLEFFECT_EXPLOSIVE_DIARRHEA = 4;
constexpr int PILLEFFECT_FULL_HEALTH = 5;
constexpr int PILLEFFECT_HEALTH_DOWN = 6;
constexpr int PILLEFFECT_HEALTH_UP = 7;
constexpr int PILLEFFECT_I_FOUND_PILLS = 8;
// The effect class each shuffled color slot must have, or -1 for any.
constexpr int PILL_SLOT_CLASSES[PILL_COLOR_SLOTS - 1] = {3, 3, 3, 3, 2, 1, 0, -1, -1, 3, 2, 1, -1, -1};
@@ -961,14 +974,90 @@ void ItemPool::remove_deathmatch_pill_effects()
reconstruction_missing("ItemPool::remove_deathmatch_pill_effects 00734cc0");
}
// (00734870) A card from a seed.
int ItemPool::GetCard(uint32_t, bool, bool, bool)
// 00734870 A card from a seed as MC_GET_CARD leaves it: special cards one in 25 unless only runes, runes one in ten
// (always when only runes), and playing cards one in ten.
int ItemPool::GetCard(uint32_t drawSeed, bool isPlaying, bool isRunes, bool isOnlyRunes)
{
reconstruction_missing("ItemPool::GetCard 00734870");
int suitChance = isPlaying ? CARD_SUIT_ODDS : 0;
int runeChance = isOnlyRunes ? 1 : isRunes ? CARD_RUNE_ODDS : 0;
int card = GetCardEx((int)drawSeed, isOnlyRunes ? 0 : CARD_SPECIAL_ODDS, runeChance, suitChance, true);
RNG rng = rng_make(drawSeed, POOL_SHIFT);
return lua_engine_get().GetCard(
{.rng = &rng, .card = card, .isOnlyRunes = isOnlyRunes, .isPlaying = isPlaying, .isRunes = isRunes});
}
// (00734180) A card, rune or special card from a seed, by the chances given.
int ItemPool::GetCardEx(int, int, int, int, bool)
// Whether a card id is an unlocked card.
static bool is_card_available(int id)
{
reconstruction_missing("ItemPool::GetCardEx 00734180");
ItemConfig_Card* card = g_manager->itemConfig.GetCard(id);
return card && card->IsAvailable();
}
// One of a pool's cards when the generator rolls one in odds, or 0.
static int card_pool_draw(RNG& rng, int odds, const std::vector<int>& pool)
{
if (rng.Next() % (uint32_t)odds != 0 || pool.empty()) return 0;
return pool[rng.RandomInt((uint32_t)pool.size())];
}
// 00734180 A card from a seed, one in each chance from its pool: a special card (with objects when allowed), a rune
// (the pool padded with blanks to six, a blank giving a Rune Shard when runes are certain or one in five times), a
// playing card, else a tarot card, reversed one in seven times when unlocked. Tainted Lost turns a tenth of the draws
// with special cards into Holy Cards. A chance of 0 leaves its pool out, a rune chance of -1 always draws a rune.
int ItemPool::GetCardEx(int drawSeed, int specialChance, int runeChance, int suitChance, bool isNonCardsAllowed)
{
std::vector<int> special;
std::vector<int> runes;
std::vector<int> suits;
std::vector<int> tarots;
for (int id = 1; id < (int)g_manager->itemConfig.cards.size(); id++)
{
if (!is_card_available(id) || id == CARD_RUNE_SHARD) continue;
switch (g_manager->itemConfig.GetCard(id)->cardType)
{
case CARD_TAROT: tarots.push_back(id); break;
case CARD_SUIT:
if (suitChance) suits.push_back(id);
break;
case CARD_RUNE:
if (runeChance) runes.push_back(id);
break;
case CARD_OBJECT:
if (isNonCardsAllowed && specialChance) special.push_back(id);
break;
case CARD_SPECIAL:
if (specialChance) special.push_back(id);
break;
default: break;
}
}
if (!runes.empty() || runeChance == -1) runes.resize(std::max(runes.size(), RUNE_POOL_MIN), 0);
RNG rng = rng_make((uint32_t)drawSeed, CARD_DRAW_SHIFT);
int runeOdds = runeChance == -1 ? 1 : runeChance;
int card = specialChance ? card_pool_draw(rng, specialChance, special) : 0;
bool isRuneShard = false;
if (!card && runeOdds && rng.Next() % (uint32_t)runeOdds == 0 && !runes.empty())
{
card = runes[rng.RandomInt((uint32_t)runes.size())];
isRuneShard = !card && (runeOdds == 1 || rng.RandomInt(RUNE_SHARD_ODDS) == 0);
}
if (isRuneShard) card = CARD_RUNE_SHARD;
else
{
if (!card && suitChance) card = card_pool_draw(rng, suitChance, suits);
if (!card && !tarots.empty()) card = tarots[rng.RandomInt((uint32_t)tarots.size())];
bool isReversible = card > 0 && card <= CARD_TAROT_LAST;
if (isReversible && rng.Next() % REVERSED_TAROT_ODDS == 0 && is_card_available(card + REVERSED_TAROT_OFFSET))
card += REVERSED_TAROT_OFFSET;
if (card == 0) log_printf(LOG_ASSERT, "No unlocked cards/runes to pick from!\n");
}
if (!specialChance) return card;
for (Entity_Player* player : g_game->playerManager.playerList)
{
if (player->variant != 0 || player->isCoopGhost || player->playerType != PLAYER_THELOST_B) continue;
return rng_make(rng._seed, HOLY_CARD_RNG_SHIFT).Next() % HOLY_CARD_ODDS == 0 ? HOLY_CARD : card;
}
return card;
}