Curation round 10: combat, pathfinding, death and game over, items and stats, room state, Continue, Lua callbacks
Seven agents took over tear and contact collision, NPC death with blood and gibs, champions, PathFinder, the Gaper's kin, the player's death with the game over screen, item pedestals with collectible pickup, AddCollectible and EvaluateItems, room state save and restore, GameState::read, pressure plates, fireplaces, entity lights, ambient sounds, and one Lua callback enum with gated runners. Integration reconstructed Room::Update's loot preview and Entity_NPC::UpdatePickupGhosts and replaced a leftover Sacred Orb stub that stopped every pedestal roll. Under gdb: Gapers die with blood and gibs, a cleared room opens its doors, the treasure room's item is taken (banner, costume, stats: a Magic Mushroom gives damage 3.5 -> 6.12 and a heart), death leads to the game over diary, and a saved run is read back on the next boot with Continue offered. 3028 functions taken over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
48933cd312
commit
d8385e6c64
64 files changed
+8665
-3059
No files matched your search
@@ -0,0 +1,545 @@
|
||||
#include "game_over.h"
|
||||
#include "entity_familiar.h"
|
||||
#include "entity_list.h"
|
||||
#include "entity_player.h"
|
||||
#include "game.h"
|
||||
#include "item_config.h"
|
||||
#include "log.h"
|
||||
#include "manager.h"
|
||||
#include "platform.h"
|
||||
#include "player_manager.h"
|
||||
#include "room.h"
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
constexpr int COLLECTIBLE_1UP = 11;
|
||||
constexpr int COLLECTIBLE_POOP = 36;
|
||||
constexpr int COLLECTIBLE_YUM_HEART = 45;
|
||||
constexpr int COLLECTIBLE_SHOOP_DA_WHOOP = 49;
|
||||
constexpr int COLLECTIBLE_CHARM_VAMPIRE = 62;
|
||||
constexpr int COLLECTIBLE_BATTERY = 63;
|
||||
constexpr int COLLECTIBLE_DEAD_CAT = 81;
|
||||
constexpr int COLLECTIBLE_THE_NAIL = 83;
|
||||
constexpr int COLLECTIBLE_PEEPER = 155;
|
||||
constexpr int COLLECTIBLE_ANKH = 161;
|
||||
constexpr int COLLECTIBLE_GUPPYS_COLLAR = 212;
|
||||
constexpr int COLLECTIBLE_STARTER_DECK = 251;
|
||||
constexpr int COLLECTIBLE_LITTLE_BAGGY = 252;
|
||||
constexpr int COLLECTIBLE_JUDAS_SHADOW = 311;
|
||||
constexpr int COLLECTIBLE_LAZARUS_RAGS = 332;
|
||||
constexpr int COLLECTIBLE_POLYDACTYLY = 454;
|
||||
constexpr int COLLECTIBLE_WAVY_CAP = 582;
|
||||
constexpr int COLLECTIBLE_MOMS_BRACELET = 604;
|
||||
constexpr int COLLECTIBLE_VADE_RETRO = 653;
|
||||
constexpr int COLLECTIBLE_INNER_CHILD = 688;
|
||||
constexpr int TRINKET_AAA_BATTERY = 3;
|
||||
constexpr int TRINKET_BROKEN_ANKH = 28;
|
||||
constexpr int TRINKET_FISH_TAIL = 94;
|
||||
constexpr int TRINKET_LOCUST_OF_WRATH = 113;
|
||||
constexpr int TRINKET_LOCUST_OF_CONQUEST = 117;
|
||||
constexpr int TRINKET_BAT_WING = 118;
|
||||
constexpr int TRINKET_AZAZELS_STUMP = 162;
|
||||
constexpr int NULLITEM_BATWING_WINGS = 40;
|
||||
constexpr int NULLITEM_WAVY_CAP_1 = 71;
|
||||
constexpr int NULLITEM_BLOODY_BABYLON = 110;
|
||||
constexpr int NULLITEM_LAZARUS_SOUL_REVIVE = 113;
|
||||
constexpr int CARD_SOUL_LAZARUS = 89;
|
||||
constexpr int ACHIEVEMENT_THE_LOST = 82;
|
||||
constexpr int BABY_FOUND_SOUL = 59;
|
||||
constexpr int FAMILIAR_BLUE_FLY = 43;
|
||||
constexpr int FAMILIAR_BLOOD_BABY = 238;
|
||||
constexpr int CLOT_SUBTYPE_UNCOUNTED = 7;
|
||||
constexpr int SPECIAL_DAILY_SHUFFLED_ITEMS = 7;
|
||||
constexpr uint32_t QUEUED_TOUCHED = 0x1;
|
||||
|
||||
constexpr int SOUND_BLOOD_LASER = 5;
|
||||
constexpr int SOUND_BLOOD_LASER_LARGE = 7;
|
||||
constexpr int SOUND_FART = 37;
|
||||
constexpr int SOUND_ISAAC_HURT_GRUNT = 55;
|
||||
constexpr int SOUND_MONSTER_YELL_A = 119;
|
||||
constexpr int SOUND_POWERUP_SPEWER = 132;
|
||||
constexpr int SOUND_REDLIGHTNING_ZAP = 133;
|
||||
constexpr int SOUND_TEARIMPACTS = 150;
|
||||
constexpr int SOUND_VAMP_GULP = 157;
|
||||
constexpr int SOUND_BATTERYCHARGE = 170;
|
||||
constexpr int SOUND_BEEP = 171;
|
||||
constexpr int SOUND_ISAACDIES = 217;
|
||||
constexpr int SOUND_ITEMRECHARGE = 218;
|
||||
constexpr int SOUND_PLOP = 237;
|
||||
constexpr int SOUND_SPLATTER = 258;
|
||||
constexpr int SOUND_THUMBS_DOWN = 267;
|
||||
constexpr int SOUND_THUMBSUP = 268;
|
||||
|
||||
constexpr float DEATH_FRICTION = 0.6f;
|
||||
constexpr int DEATH_FRAME_TWIN_FALLS = 7;
|
||||
constexpr int DEATH_FRAME_BONES_BREAK = 19;
|
||||
constexpr int PAPER_FRAME_PERIOD = 4;
|
||||
constexpr int PAPER_FRAME_SINGLE = 3;
|
||||
constexpr int PAPER_FRAME_DOUBLE = 2;
|
||||
constexpr int BROKEN_ANKH_CHANCES[] = {22, 33};
|
||||
constexpr int BROKEN_ANKH_CHANCE_MAX = 50;
|
||||
constexpr int BROKEN_ANKH_ROLL = 100;
|
||||
constexpr int FISH_TAIL_EXTRA_ROLL = 5;
|
||||
constexpr int FISH_TAIL_LUCKY_MAX = 3;
|
||||
constexpr int POCKET_ACTIVE_FIRST_SLOT = 2;
|
||||
constexpr int CONQUEST_EXTRA_ROLL = 4;
|
||||
constexpr int CONQUEST_EXTRA_ROLL_DOUBLE = 5;
|
||||
|
||||
// The player and its twin, the one with the lower player index first, as a death handles them together.
|
||||
static std::vector<Entity_Player*> death_players_get(Entity_Player& player)
|
||||
{
|
||||
Entity_Player* twin = player.twin_get();
|
||||
|
||||
if (!twin) return {&player};
|
||||
if (twin->playerIndex != -1 && twin->playerIndex < player.playerIndex && twin != &player) return {twin, &player};
|
||||
return {&player, twin};
|
||||
}
|
||||
|
||||
// The first of the players with a collectible, or null.
|
||||
static Entity_Player* collectible_holder_find(std::vector<Entity_Player*>& players, int collectible)
|
||||
{
|
||||
auto isHolder = [&](Entity_Player* player) { return player->HasCollectible(collectible); };
|
||||
auto found = std::ranges::find_if(players, isHolder);
|
||||
return found == players.end() ? nullptr : *found;
|
||||
}
|
||||
|
||||
// The first of the players with a trinket, or null.
|
||||
static Entity_Player* trinket_holder_find(std::vector<Entity_Player*>& players, uint32_t trinket)
|
||||
{
|
||||
auto isHolder = [&](Entity_Player* player) { return player->HasTrinket(trinket); };
|
||||
auto found = std::ranges::find_if(players, isHolder);
|
||||
return found == players.end() ? nullptr : *found;
|
||||
}
|
||||
|
||||
// Whether Missing Poster revives: once the Lost is unlocked, and always in a daily or debug run.
|
||||
static bool is_missing_poster_unlocked()
|
||||
{
|
||||
Manager& manager = *g_manager;
|
||||
bool isExemptRun =
|
||||
manager.state == MANAGER_STATE_GAME && g_game && (g_game->dailyChallenge._id != 0 || g_game->isDebug);
|
||||
|
||||
return manager.persistentGameData.achievements[ACHIEVEMENT_THE_LOST] || isExemptRun;
|
||||
}
|
||||
|
||||
// What revives a dying player and its twin, in the order the game tries them, or null. Broken Ankh's roll draws from
|
||||
// its RNG even when the death is only checked. A Missing Poster still locked ends the search.
|
||||
static const char* revival_find(Entity_Player& player, std::vector<Entity_Player*>& players)
|
||||
{
|
||||
for (Entity_Player* each : players)
|
||||
if (each->temporaryEffects.HasNullEffect(NULLITEM_LAZARUS_SOUL_REVIVE)) return "Soul of Lazarus's revival";
|
||||
for (Entity_Player* each : players)
|
||||
for (uint32_t slot = 0; slot < each->GetMaxPocketItems(); slot++)
|
||||
{
|
||||
PocketItem& pocket = each->pocketItems[std::min<uint32_t>(slot, POCKET_SLOT_COUNT - 1)];
|
||||
if (pocket.type == POCKET_CARD && pocket.id == CARD_SOUL_LAZARUS) return "Soul of Lazarus's revival";
|
||||
}
|
||||
|
||||
if (collectible_holder_find(players, COLLECTIBLE_1UP)) return "1up!'s revival";
|
||||
if (player.playerType == PLAYER_LAZARUS) return "Lazarus rising";
|
||||
if (collectible_holder_find(players, COLLECTIBLE_DEAD_CAT)) return "Dead Cat's revival";
|
||||
if (collectible_holder_find(players, COLLECTIBLE_INNER_CHILD)) return "Inner Child's revival";
|
||||
Entity_Player* collar = collectible_holder_find(players, COLLECTIBLE_GUPPYS_COLLAR);
|
||||
if (collar && collar->GetCollectibleRNG(COLLECTIBLE_GUPPYS_COLLAR)._seed & 1) return "Guppy's Collar's revival";
|
||||
if (collectible_holder_find(players, COLLECTIBLE_LAZARUS_RAGS)) return "Lazarus' Rags's revival";
|
||||
if (collectible_holder_find(players, COLLECTIBLE_ANKH)) return "Ankh's revival";
|
||||
|
||||
if (Entity_Player* ankh = trinket_holder_find(players, TRINKET_BROKEN_ANKH))
|
||||
{
|
||||
int multiplier = ankh->GetTrinketMultiplier(TRINKET_BROKEN_ANKH);
|
||||
int chance = multiplier >= 1 && multiplier <= 2 ? BROKEN_ANKH_CHANCES[multiplier - 1] : BROKEN_ANKH_CHANCE_MAX;
|
||||
if ((int)ankh->GetTrinketRNG(TRINKET_BROKEN_ANKH).RandomInt(BROKEN_ANKH_ROLL) < chance)
|
||||
return "Broken Ankh's revival";
|
||||
}
|
||||
if (collectible_holder_find(players, COLLECTIBLE_JUDAS_SHADOW)) return "Judas' Shadow's revival";
|
||||
if (trinket_holder_find(players, TRINKET_MISSING_POSTER))
|
||||
return is_missing_poster_unlocked() ? "Missing Poster's revival" : nullptr;
|
||||
if (player.playerType == PLAYER_THELOST_B && player.HasCollectible(COLLECTIBLE_BIRTHRIGHT))
|
||||
return "Tainted Lost's Birthright revival";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 007a1090 The death of a player out of health, with its twin, once its death animation ended: the first revival
|
||||
// its items give, else a co-op ghost while others live, else the end of the run. A co-op baby leaves the run.
|
||||
// With isCheckOnly, only whether it would revive. A locked Missing Poster says so in a Sacrifice Room, where dying
|
||||
// with it unlocks the Lost.
|
||||
// Only the death that ends the run is reconstructed: revivals and helpers stop the game when reached.
|
||||
bool Entity_Player::TriggerDeath(bool isCheckOnly)
|
||||
{
|
||||
Game& game = *g_game;
|
||||
|
||||
if (variant == PLAYER_VARIANT_COOP_BABY)
|
||||
{
|
||||
if (isCheckOnly) return false;
|
||||
coop_baby_death_effect();
|
||||
game.playerManager.trigger_coop_baby_death(this);
|
||||
isVisible = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Entity_Player*> players = death_players_get(*this);
|
||||
bool isSacrificeRoom = game.room->roomType == ROOM_SACRIFICE;
|
||||
if (!isCheckOnly && HasTrinket(TRINKET_MISSING_POSTER) && isSacrificeRoom)
|
||||
g_manager->persistentGameData.TryUnlock(ACHIEVEMENT_THE_LOST);
|
||||
|
||||
const char* revival = revival_find(*this, players);
|
||||
if (isCheckOnly) return revival || (trinket_holder_find(players, TRINKET_MISSING_POSTER) && isSacrificeRoom);
|
||||
if (revival) reconstruction_missing(revival);
|
||||
|
||||
for (Entity_Player* player : players)
|
||||
{
|
||||
player->pitfallState = 0;
|
||||
player->isControlsEnabled = true;
|
||||
player->entityCollisionClass = ENTCOLL_ALL;
|
||||
}
|
||||
|
||||
Entity_Player& first = *players[0];
|
||||
PlayerManager& playerManager = game.playerManager;
|
||||
if (first.isDead && !first.parent && playerManager.IsCoopPlay() && playerManager.GetNumAlivePlayers() > 1 &&
|
||||
!first.isCoopGhost)
|
||||
for (Entity_Player* player : players) player->MorphToCoopGhost();
|
||||
if (!first.isDead) reconstruction_missing("Entity_Player::TriggerDeath 007a1090 (a co-op ghost's return)");
|
||||
if (first.parent && first.variant == PLAYER_VARIANT_PLAYER && first.parent->is_player())
|
||||
reconstruction_missing("Entity_Player::TriggerDeath 007a1090 (a helper player's death)");
|
||||
|
||||
playerManager.trigger_coop_baby_death(this);
|
||||
isVisible = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 007cbb60 Whether the player would revive from its death.
|
||||
bool Entity_Player::WillPlayerRevive()
|
||||
{
|
||||
return TriggerDeath(true);
|
||||
}
|
||||
|
||||
// Whether a death loses the run: no other main player (its twin aside) lives on or revives.
|
||||
static bool is_run_lost(Entity_Player& dying)
|
||||
{
|
||||
Game& game = *g_game;
|
||||
|
||||
for (size_t i = 0; i < game.playerManager.playerList.size(); i++)
|
||||
{
|
||||
Entity_Player* player = game.GetPlayer((int)i);
|
||||
bool isOther = player != &dying && player != dying.twin_get();
|
||||
if (!isOther || player->parent || player->variant != PLAYER_VARIANT_PLAYER) continue;
|
||||
if (!player->isDead || player->WillPlayerRevive()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Plays a sound in the player's voice, as the fart seed may replace it.
|
||||
static void voice_play(int sound, float pitch)
|
||||
{
|
||||
seed_fart_sound_override(&sound);
|
||||
g_manager->sfxManager.Play(sound, {.pitch = pitch});
|
||||
}
|
||||
|
||||
// The death part of the player's frame, Update 00782af0: outside transitions the death animation starts once (with
|
||||
// Mysterious Paper's chance of Missing Poster), the held entity is thrown, the ghost shows, and a run lost forgets its
|
||||
// save. The player slows to a halt, cries out on the animation's DeathSound, takes its twin down with it once the
|
||||
// animation shows, and vanishes when it ends.
|
||||
// Update returns into this before its base entity update, which the original runs for the dead too, so it runs here.
|
||||
void Entity_Player::death_update()
|
||||
{
|
||||
Entity::Update();
|
||||
if (!HasEntityFlags(FLAG_INTERPOLATION_UPDATE)) bodySprite.Update();
|
||||
|
||||
Game& game = *g_game;
|
||||
std::string_view animation = GetDeathAnimName();
|
||||
bool isTransitioning = game.roomTransition.mode != TRANSITION_NONE || game.stageTransition._state != 0;
|
||||
|
||||
if (!isTransitioning && sprite.GetAnimation() != animation)
|
||||
{
|
||||
isVisible = true;
|
||||
PlayExtraAnimation(animation);
|
||||
int paper = GetTrinketMultiplier(TRINKET_MYSTERIOUS_PAPER);
|
||||
int paperFrame = game.frameCount % PAPER_FRAME_PERIOD;
|
||||
if ((paper >= 1 && paperFrame == PAPER_FRAME_SINGLE) || (paper >= 2 && paperFrame == PAPER_FRAME_DOUBLE))
|
||||
temporaryEffects.AddTrinketEffect(TRINKET_MISSING_POSTER, true, 1);
|
||||
if (heldEntity) ThrowHeldEntity(Vector{});
|
||||
if (LayerState* ghost = sprite.GetLayer("ghost")) ghost->isVisible = true;
|
||||
|
||||
bool isMainPlayer = !parent && variant == PLAYER_VARIANT_PLAYER && !isCoopGhost;
|
||||
if (isMainPlayer && !WillPlayerRevive() && is_run_lost(*this) && !game.deathmatchManager.is_active())
|
||||
{
|
||||
game_save_delete();
|
||||
persistent_game_data_set_writable();
|
||||
}
|
||||
if (variant == PLAYER_VARIANT_COOP_BABY && babySkin == BABY_FOUND_SOUL && parent && parent->is_player())
|
||||
parent->ToPlayer()->temporaryEffects.AddTrinketEffect(TRINKET_FOUND_SOUL, true, 1);
|
||||
velocity = Vector{};
|
||||
}
|
||||
friction *= DEATH_FRICTION;
|
||||
|
||||
if (activeItems[0].item == COLLECTIBLE_VADE_RETRO && sprite.IsPlaying())
|
||||
reconstruction_missing("Entity_Player::Update 00782af0 (Vade Retro used by a dead player's ghost)");
|
||||
if (playerType == PLAYER_THEFORGOTTEN_B)
|
||||
{
|
||||
if (sprite.IsPlaying(animation) && sprite.GetFrame() == DEATH_FRAME_BONES_BREAK)
|
||||
reconstruction_missing("Entity_Player::Update 00782af0 (Tainted Forgotten's bones break)");
|
||||
}
|
||||
else if (sprite.IsPlaying(animation) && sprite.IsEventTriggered("DeathSound"))
|
||||
{
|
||||
if (!IsHologram()) voice_play(SOUND_ISAACDIES, get_voice_pitch());
|
||||
if (playerType == PLAYER_BLUEBABY_B)
|
||||
reconstruction_missing("Entity_Player::Update 00782af0 (Tainted Blue Baby's last poops)");
|
||||
}
|
||||
|
||||
bool isDeathShown = (sprite.IsPlaying(animation) &&
|
||||
(sprite.GetFrame() > DEATH_FRAME_TWIN_FALLS || playerType == PLAYER_THEFORGOTTEN_B)) ||
|
||||
sprite.IsFinished();
|
||||
Entity_Player* twin = twin_get();
|
||||
if (!isTransitioning && isDeathShown && twin && !twin->isDead && !twin->sprite.IsPlaying(twin->GetDeathAnimName()))
|
||||
{
|
||||
if (game.playerManager.IsCoopPlay())
|
||||
{
|
||||
if (!twin->isCoopGhost) twin->Kill(EntityRef());
|
||||
}
|
||||
else
|
||||
{
|
||||
twin->lastDamageFlags = lastDamageFlags;
|
||||
twin->lastDamageSource = lastDamageSource;
|
||||
twin->Kill(EntityRef());
|
||||
twin->isVisible = true;
|
||||
twin->PlayExtraAnimation(twin->GetDeathAnimName());
|
||||
}
|
||||
}
|
||||
if (sprite.IsFinished(animation)) isVisible = false;
|
||||
}
|
||||
|
||||
// 007a6680 Leaves the room: the queued item is added, room-long states end (Holy Mantle's unless kept), the compass,
|
||||
// Metronome's item, Bat Wing's wings and Wavy Cap's trip wear off, the temporary effects clear, the costumes of actives
|
||||
// no longer worn come off, a held item is put away, and a soul player of the Forgotten or Jacob leaves.
|
||||
// The after-images and the deathmatch's damage are not modeled.
|
||||
void Entity_Player::room_exit(bool isKeepHolyMantle)
|
||||
{
|
||||
ItemConfig& items = g_manager->itemConfig;
|
||||
Game& game = *g_game;
|
||||
|
||||
FlushQueueItem();
|
||||
if (!isKeepHolyMantle) holyMantleState = 0;
|
||||
isBrokenRemotePending = false;
|
||||
cursedPennyPending = 0;
|
||||
roomDamageTaken = 0;
|
||||
|
||||
if (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_COMPASS) && !HasCollectible(COLLECTIBLE_COMPASS))
|
||||
game.RemoveCompassEffect();
|
||||
if (int metronomeItem = metronomeCollectibleId)
|
||||
{
|
||||
temporaryEffects.RemoveCollectibleEffect(COLLECTIBLE_METRONOME, 1);
|
||||
ItemConfig_Item* item = items.GetCollectible(metronomeItem);
|
||||
metronomeCollectibleId = 0;
|
||||
if (activeItems[0].item != metronomeItem && !HasCollectible(metronomeItem)) RemoveCostume(item);
|
||||
}
|
||||
if (temporaryEffects.HasTrinketEffect(TRINKET_BAT_WING)) RemoveCostume(items.GetNullItem(NULLITEM_BATWING_WINGS));
|
||||
if (TemporaryEffect* wavyCap = temporaryEffects.GetCollectibleEffect(COLLECTIBLE_WAVY_CAP))
|
||||
for (int count = wavyCap->count; count > 0; count--)
|
||||
{
|
||||
temporaryEffects.AddNullEffect(NULLITEM_WAVY_CAP_1, false, 1);
|
||||
temporaryEffects.RemoveCollectibleEffect(COLLECTIBLE_WAVY_CAP, 1);
|
||||
}
|
||||
if (temporaryEffects.HasNullEffect(NULLITEM_BLOODY_BABYLON))
|
||||
{
|
||||
int hearts = boneHearts + goldenHearts + soulHearts + eternalHearts + redHearts;
|
||||
auto isClot = [this](Entity* entity)
|
||||
{
|
||||
bool isOwned = entity && entity->IsFamiliar() && static_cast<Entity_Familiar*>(entity)->player == this;
|
||||
return isOwned && entity->variant == FAMILIAR_BLOOD_BABY && entity->subtype != CLOT_SUBTYPE_UNCOUNTED &&
|
||||
!entity->isDead;
|
||||
};
|
||||
EntityList_EL& persistent = game.room->entityList.persistentEL;
|
||||
if (playerType != PLAYER_EVE_B || hearts != 1 || std::ranges::any_of(persistent, isClot))
|
||||
temporaryEffects.RemoveNullEffect(NULLITEM_BLOODY_BABYLON, -1);
|
||||
}
|
||||
ClearTemporaryEffects();
|
||||
|
||||
for (ActiveItemDesc& active : activeItems)
|
||||
{
|
||||
int id = active.item;
|
||||
if (id == 0 || (id != COLLECTIBLE_SHOOP_DA_WHOOP && temporaryEffects.HasCollectibleEffect(id))) continue;
|
||||
ItemConfig_Item* item = items.GetCollectible(id);
|
||||
if (item && (!item->isAddCostumeOnPickup || !HasCollectible(id))) RemoveCostume(item);
|
||||
}
|
||||
if (itemState != COLLECTIBLE_MOMS_BRACELET || game.stageTransition._state != 0)
|
||||
{
|
||||
bodySprite.Reset();
|
||||
isPlayingItemAnimation = false;
|
||||
ResetItemState();
|
||||
itemStateCooldown = 0;
|
||||
}
|
||||
|
||||
bool isSoulPlayer = temporaryEffects.HasNullEffect(NULLITEM_SOUL_FORGOTTEN) ||
|
||||
temporaryEffects.HasNullEffect(NULLITEM_SOUL_JACOB);
|
||||
if (parent && isSoulPlayer) game.playerManager.RemoveCoPlayer(this);
|
||||
}
|
||||
|
||||
// 0075e1d0 Adds the item held over the head, golden or not, as picked up for the first time unless it was touched
|
||||
// before, then lets Astral Projection trigger. False when nothing was queued.
|
||||
bool Entity_Player::FlushQueueItem()
|
||||
{
|
||||
if (!queuedItem.item)
|
||||
{
|
||||
try_trigger_astral_projection();
|
||||
return false;
|
||||
}
|
||||
|
||||
log_printf(LOG_INFO, "item queue flush\n");
|
||||
QueueItemData queued = queuedItem;
|
||||
queuedItem.item = nullptr;
|
||||
queuedItem.charge = 0;
|
||||
queuedItem.varData = 0;
|
||||
bool isFirstTime = !(queued.flags & QUEUED_TOUCHED);
|
||||
bool isShuffledDaily = g_game->dailyChallenge._specialDailyId == SPECIAL_DAILY_SHUFFLED_ITEMS;
|
||||
|
||||
if (queued.item->type == ITEM_TRINKET)
|
||||
{
|
||||
if (isShuffledDaily)
|
||||
reconstruction_missing("Entity_Player::FlushQueueItem 0075e1d0 (a shuffled daily's trinket)");
|
||||
uint32_t id = (uint32_t)queued.item->id;
|
||||
AddTrinket((int)(queued.flags & QUEUED_GOLDEN ? id | TRINKET_GOLDEN_FLAG : id), isFirstTime);
|
||||
}
|
||||
else if (queued.item->type != ITEM_NULL)
|
||||
{
|
||||
if (isShuffledDaily) reconstruction_missing("Entity_Player::FlushQueueItem 0075e1d0 (a shuffled daily's item)");
|
||||
AddCollectible(queued.item->id, queued.charge, isFirstTime, 0, queued.varData);
|
||||
}
|
||||
try_trigger_astral_projection();
|
||||
return true;
|
||||
}
|
||||
|
||||
// 007907a0 Ends the room's temporary effects: the effects clear, Strength's heart containers go, the color override
|
||||
// resets, the Lost curse lifts outside the mirror world, Azazel's Stump's form ends, the room's lent collectibles are
|
||||
// taken back and the pocket active slot empties.
|
||||
void Entity_Player::ClearTemporaryEffects()
|
||||
{
|
||||
Game& game = *g_game;
|
||||
|
||||
if (!temporaryEffects.effects.empty()) temporaryEffects.ClearEffects(false);
|
||||
for (int i = 0; i < strengthMaxHearts; i++)
|
||||
if (soulHearts + boneHearts * 2 + maxHearts > 2) AddMaxHearts(-2, false);
|
||||
strengthMaxHearts = 0;
|
||||
colorOverride = COLOR_DEFAULT;
|
||||
|
||||
TemporaryEffect* lostCurse = temporaryEffects.GetNullEffect(NULLITEM_LOST_CURSE);
|
||||
int dimension = game.roomTransition.mode != TRANSITION_NONE ? game.roomTransition.roomDimension
|
||||
: game.currentDimensionIdx;
|
||||
if (lostCurse && lostCurse->count == 2 && (!game.HasMirrorDimension() || dimension == 0))
|
||||
{
|
||||
temporaryEffects.RemoveNullEffect(NULLITEM_LOST_CURSE, -1);
|
||||
if (backupPlayer && backupPlayer->temporaryEffects.HasNullEffect(NULLITEM_LOST_CURSE))
|
||||
backupPlayer->temporaryEffects.RemoveNullEffect(NULLITEM_LOST_CURSE, -1);
|
||||
}
|
||||
if (TemporaryEffect* stump = temporaryEffects.GetTrinketEffect(TRINKET_AZAZELS_STUMP); stump && stump->count == 1)
|
||||
temporaryEffects.RemoveTrinketEffect(TRINKET_AZAZELS_STUMP, 1);
|
||||
|
||||
for (auto& [id, count] : roomTemporaryCollectibles)
|
||||
{
|
||||
ItemConfig_Item* item = g_manager->itemConfig.GetCollectible(id);
|
||||
if (item && item->type != ITEM_ACTIVE)
|
||||
for (int i = 0; i < count; i++) RemoveCollectible(item->id, true, 0, true);
|
||||
count = 0;
|
||||
}
|
||||
roomTemporaryCollectibles.clear();
|
||||
SetPocketActiveItem(0, ACTIVE_SLOT_COUNT - 1, false);
|
||||
}
|
||||
|
||||
// 007d41d0 Puts an active item in a pocket slot (2 or 3), the one there before removed with its pocket.
|
||||
// Only emptying the slot is reconstructed: a new item stops the game.
|
||||
void Entity_Player::SetPocketActiveItem(int collectible, int slot, bool)
|
||||
{
|
||||
if (slot < POCKET_ACTIVE_FIRST_SLOT || slot >= ACTIVE_SLOT_COUNT) return;
|
||||
|
||||
for (int i = 0; i < POCKET_SLOT_COUNT; i++)
|
||||
{
|
||||
if (pocketItems[i].type != POCKET_ACTIVE || pocketItems[i].id != slot + 1) continue;
|
||||
if (int item = activeItems[pocketItems[i].id - 1].item) RemoveCollectible(item, true, slot, true);
|
||||
std::shift_left(pocketItems.begin() + i, pocketItems.end(), 1);
|
||||
pocketItems.back() = {0, POCKET_CARD};
|
||||
}
|
||||
if (collectible != 0 && g_manager->itemConfig.GetCollectible(collectible))
|
||||
reconstruction_missing("Entity_Player::SetPocketActiveItem 007d41d0 (a new pocket active)");
|
||||
}
|
||||
|
||||
// 007ad440 How many pocket slots the player has: one, two with Starter Deck, Little Baggy or Polydactyly, and one
|
||||
// more per pocket active.
|
||||
uint32_t Entity_Player::GetMaxPocketItems()
|
||||
{
|
||||
bool isExtraSlot = HasCollectible(COLLECTIBLE_STARTER_DECK) || HasCollectible(COLLECTIBLE_LITTLE_BAGGY) ||
|
||||
HasCollectible(COLLECTIBLE_POLYDACTYLY);
|
||||
auto isActive = [](PocketItem& pocket) { return pocket.type == POCKET_ACTIVE && pocket.id > 0; };
|
||||
|
||||
return (isExtraSlot ? 2 : 1) + (uint32_t)std::ranges::count_if(pocketItems, isActive);
|
||||
}
|
||||
|
||||
// 007c3a60 Loads the sounds the player's weapons and items will play before the room needs them.
|
||||
void Entity_Player::preload_item_sounds()
|
||||
{
|
||||
SFXManager& sfx = g_manager->sfxManager;
|
||||
|
||||
if (weaponTypes[WEAPON_TEARS])
|
||||
for (int sound : {SOUND_SPLATTER, SOUND_TEARIMPACTS}) sfx.Preload(sound);
|
||||
if (weaponTypes[WEAPON_LASER]) sfx.Preload(SOUND_REDLIGHTNING_ZAP);
|
||||
if (weaponTypes[WEAPON_BRIMSTONE]) sfx.Preload(SOUND_BLOOD_LASER_LARGE);
|
||||
if (HasCollectible(COLLECTIBLE_PEEPER)) sfx.Preload(SOUND_PLOP);
|
||||
sfx.Preload(SOUND_ISAAC_HURT_GRUNT);
|
||||
if (HasCollectible(COLLECTIBLE_SHOOP_DA_WHOOP)) sfx.Preload(SOUND_BLOOD_LASER);
|
||||
if (activeItems[0].item != 0)
|
||||
{
|
||||
for (int sound : {SOUND_BEEP, SOUND_ITEMRECHARGE}) sfx.Preload(sound);
|
||||
if (HasCollectible(COLLECTIBLE_BATTERY) || HasTrinket(TRINKET_AAA_BATTERY)) sfx.Preload(SOUND_BATTERYCHARGE);
|
||||
}
|
||||
if (HasCollectible(COLLECTIBLE_POOP)) sfx.Preload(SOUND_FART);
|
||||
if (HasCollectible(COLLECTIBLE_YUM_HEART) || HasCollectible(COLLECTIBLE_CHARM_VAMPIRE))
|
||||
sfx.Preload(SOUND_VAMP_GULP);
|
||||
if (HasCollectible(COLLECTIBLE_THE_NAIL)) sfx.Preload(SOUND_MONSTER_YELL_A);
|
||||
if (pocketItems[0].type == POCKET_PILL && pocketItems[0].id != 0)
|
||||
for (int sound : {SOUND_POWERUP_SPEWER, SOUND_THUMBSUP, SOUND_THUMBS_DOWN}) sfx.Preload(sound);
|
||||
}
|
||||
|
||||
// How many locusts Fish Tail makes of each: two, sometimes three or four with a golden or doubled tail, else one.
|
||||
static int fish_tail_factor_get(Entity_Player& player)
|
||||
{
|
||||
if (!player.HasTrinket(TRINKET_FISH_TAIL)) return 1;
|
||||
|
||||
int multiplier = player.GetTrinketMultiplier(TRINKET_FISH_TAIL);
|
||||
bool isLucky = multiplier >= 2 && multiplier <= FISH_TAIL_LUCKY_MAX && Random() % FISH_TAIL_EXTRA_ROLL == 0;
|
||||
return isLucky ? multiplier + 1 : 2;
|
||||
}
|
||||
|
||||
// 007c8830 Sends out the player's locusts as the room starts: one per copy of each Locust trinket (Fish Tail
|
||||
// multiplying them), Conquest's with a few extra from its RNG.
|
||||
void Entity_Player::spawn_locusts()
|
||||
{
|
||||
for (int trinket = TRINKET_LOCUST_OF_WRATH; trinket <= TRINKET_LOCUST_OF_CONQUEST; trinket++)
|
||||
{
|
||||
if (!HasTrinket(trinket)) continue;
|
||||
|
||||
int count = GetTrinketMultiplier(trinket);
|
||||
if (trinket == TRINKET_LOCUST_OF_CONQUEST)
|
||||
{
|
||||
int roll = count == 2 ? CONQUEST_EXTRA_ROLL_DOUBLE : CONQUEST_EXTRA_ROLL;
|
||||
count += (int)(GetTrinketRNG(trinket).Next() % roll) * fish_tail_factor_get(*this);
|
||||
}
|
||||
else count *= fish_tail_factor_get(*this);
|
||||
|
||||
int subType = trinket - TRINKET_LOCUST_OF_WRATH + 1;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
EntitySpawn spawn = {.position = pos, .spawner = this, .subType = subType, .type = ENTITY_FAMILIAR,
|
||||
.variant = FAMILIAR_BLUE_FLY, .seed = Random()};
|
||||
Entity* locust = g_game->Spawn(spawn);
|
||||
locust->ClearEntityFlags(FLAG_APPEAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 007bf3d0 Whether the player can pick an item up now: alive, not dying, not firing Mega Blast, and not in an
|
||||
// animation other than its hurt one unless it holds an item up.
|
||||
bool Entity_Player::CanPickupItem()
|
||||
{
|
||||
const std::string& animation = sprite.GetAnimation();
|
||||
|
||||
if ((isPlayingExtraAnimation || isPlayingItemAnimation) && animation != "Hit" && !IsHoldingItem()) return false;
|
||||
return !isDead && animation != "Death" && megaBlastDuration < 1;
|
||||
}
|
||||
Reference in new issue
Block a user