#include "entity_player_characters.h" #include "boss_ai.h" #include "entity_effect.h" #include "entity_familiar.h" #include "entity_knife.h" #include "entity_player_tainted.h" #include "game.h" #include "hud.h" #include "item_overlay.h" #include "item_pool.h" #include "manager.h" #include "menu_manager.h" #include "npc_ai.h" #include "player_manager.h" #include "room.h" #include "room_config.h" #include "room_descriptor.h" #include "room_grid.h" #include #include #include constexpr uint32_t CACHE_TWIN_SPEED = 0x80000000; constexpr int CHARGE_STORE_MAX = 99; constexpr int SOUL_CHARGE_CONSUMABLE = 0x20; constexpr int BLOOD_CHARGE_CONSUMABLE = 0x100; constexpr int BLOOD_CLOT_SUBTYPE_SPENT = 7; constexpr int WHORE_OF_BABYLON_RED_HEARTS = 1; constexpr int EVE_WHORE_OF_BABYLON_RED_HEARTS = 2; constexpr int DEATHMATCH_WHORE_RED_HEARTS = 16; constexpr int NULLITEM_SLOW_A = 62; constexpr int NULLITEM_SLOW_B = 65; constexpr float AZAZELS_STUMP_DAMAGE_SCALE = 1.5f; constexpr int MAGGY_HEART_LIMIT = 4; constexpr int MAGGY_BIRTHRIGHT_HEART_LIMIT = 6; constexpr int MAGGY_DRAIN_FRAMES = 300; constexpr int MAGGY_DRIP_ODDS = 5; constexpr float MAGGY_DRIP_SCALE_SPREAD = 0.5f; constexpr float MAGGY_DRIP_SCALE_BASE = 0.2f; constexpr int MAGGY_HUG_READY = 3; constexpr int MAGGY_HUG_FRAMES = 9; constexpr int MAGGY_HUG_SUBTYPE = 4; constexpr float MAGGY_HUG_REACH = 6; constexpr float MAGGY_HUG_RISE = -14; constexpr int COLOR_PRIORITY_HUG = 255; constexpr int BERSERK_CHARGE_MAX = 99999; constexpr float BERSERK_CHARGE_PER_DAMAGE = 50000; constexpr float DEATHMATCH_DAMAGE_CHARGE_SCALE = 0.1f; constexpr float DAMAGE_CHARGE_PER_STAGE = 20; constexpr float DAMAGE_CHARGE_BASE = 40; constexpr float TWIN_SPEED_MAX = 2; constexpr float TWIN_SPEED_MIN = 0.1f; constexpr float TWIN_SPAWN_OFFSET = 20; constexpr float SAFE_SPAWN_LOOKAHEAD = 45; constexpr float SAFE_SPAWN_FAR_ENOUGH = 14400; constexpr float SAFE_SPAWN_NEAREST_START = 1e8f; constexpr int SAFE_SPAWN_RADIUS_MIN = 30; constexpr int SAFE_SPAWN_RADIUS_STEP = 3; constexpr int SAFE_SPAWN_TRIES = 150; constexpr int NPC_TYPE_FIRST = 10; constexpr int NPC_TYPE_LAST = 999; constexpr int ROOM_IDX_DEBUG = -16; constexpr float FORGOTTEN_CHAIN_SCALE = 120; constexpr int MAGDALENE_PILL_TRIES = 10; constexpr int REVIVE_DAMAGE_COOLDOWN = 90; constexpr int COOP_REVIVE_DAMAGE_COOLDOWN = 150; constexpr int LAZARUS_RISEN_MAX_HEARTS = 2; constexpr int LAZARUS_BIRTHRIGHT_STEW_FRAMES = 1800; constexpr int POOF_LARGE_SUBTYPE = 3; constexpr int COLLECTIBLE_GUPPYS_COLLAR_RNG = 212; constexpr int TRINKET_BROKEN_ANKH_RNG = 28; constexpr int SOUL_CHARGE_HEART_CONTAINERS = 2; constexpr int KEEPER_START_COIN_HEARTS = 4; constexpr float INDICATOR_SCREEN_WIDTH = 338; constexpr float INDICATOR_SCREEN_HEIGHT = 182; constexpr float INDICATOR_ORIGIN_X = 60; constexpr float INDICATOR_ORIGIN_Y = 140; constexpr float INDICATOR_SCALE = 0.65f; constexpr float INDICATOR_BOTTOM_MARGIN = 10; constexpr float INDICATOR_FADE_START = 10; constexpr float INDICATOR_FADE_LENGTH = 140; constexpr std::string_view FORGOTTEN_BOMB_SHEET = "gfx/characters/costumes/character_016b_theforgotten_bomb.png"; // The damage each character type adds as a share of its damage (the exe's table at 00b6bce8). constexpr std::array CHARACTER_DAMAGE_SHARES = { 0, 0, 0.2f, 0.35f, 0.05f, -0.25f, 0, 0.5f, 0, 0, 0, 0.4f, 1, 0, 0.2f, 0, 0.5f, 0, 0, 0, 0, 0, -0.25f, 0.2f, 0, 0, 0.2f, 0, 0.5f, 0, 0, 0.3f, 0, 0, 0, 0.5f, 0, 0, 0.5f, 0, 0}; // The speed each character type adds (the exe's table at 00c5c3b0, whose Eden entries the evaluation overwrites with // Eden's rolled speed). constexpr std::array CHARACTER_SPEEDS = { 0, -0.15f, 0.3f, 0, 0.1f, 0.23f, 0.1f, 0.25f, 0, 0, 0, 0.25f, 0.1f, 0, -0.1f, 0, 0, 0.3f, 0, 0, 0, 0, 0, 0.3f, 0.23f, -0.1f, 0, 0, 0, 0, 0, 0, -0.15f, 0, 0, 0, 0, 0, -0.1f, 0, 0}; // Whether the player is Eden or Tainted Eden, whose stats carry their rolled offsets. bool is_eden(const Entity_Player& player) { return player.playerType == PLAYER_EDEN || player.playerType == PLAYER_EDEN_B; } // Whether the player is Azazel, its tainted form, or holds Azazel's Stump's effect. bool is_azazel(Entity_Player& player) { return player.playerType == PLAYER_AZAZEL || player.playerType == PLAYER_AZAZEL_B || player.temporaryEffects.HasTrinketEffect(TRINKET_AZAZELS_STUMP); } // Whether the frame and the stat evaluation are reconstructed for the player's character: the normal ones and the // tainted ones the frame (00782af0, 00794e50) has no branch for. Tainted Judas's and Tainted Keeper's Birthright have // one, and so has Tainted Lazarus's, which keeps both forms in the room. bool is_character_reconstructed(Entity_Player& player) { switch (player.playerType) { case PLAYER_JUDAS_B: case PLAYER_KEEPER_B: case PLAYER_LAZARUS_B: case PLAYER_LAZARUS2_B: return !player.HasCollectible(COLLECTIBLE_BIRTHRIGHT); case PLAYER_JACOB_B: case PLAYER_JACOB2_B: case PLAYER_ISAAC_B: case PLAYER_MAGDALENE_B: case PLAYER_BLUEBABY_B: case PLAYER_THEFORGOTTEN_B: case PLAYER_THESOUL_B: case PLAYER_LILITH_B: case PLAYER_CAIN_B: case PLAYER_SAMSON_B: case PLAYER_EVE_B: case PLAYER_AZAZEL_B: case PLAYER_EDEN_B: case PLAYER_THELOST_B: case PLAYER_APOLLYON_B: case PLAYER_BETHANY_B: return true; default: return player.playerType >= PLAYER_ISAAC && player.playerType <= PLAYER_ESAU; } } // The tears up or down a character adds to the items' before Binge Eater's: Samson's, the tainted ones', Azazel's (or // its stump's) and the twins'. float character_tears_get(Entity_Player& player) { switch (player.playerType) { case PLAYER_SAMSON: case PLAYER_SAMSON_B: return -0.1f; case PLAYER_BLUEBABY_B: return -0.35f; case PLAYER_APOLLYON_B: case PLAYER_EVE_B: return -0.5f; case PLAYER_AZAZEL: return 0.5f; default: break; } if (player.temporaryEffects.HasTrinketEffect(TRINKET_AZAZELS_STUMP)) return 0.5f; if (player.playerType == PLAYER_JACOB || player.playerType == PLAYER_JACOB_B || player.playerType == PLAYER_JACOB2_B) return 0.27777f; if (player.playerType == PLAYER_ESAU || player.playerType == PLAYER_LAZARUS2_B) return -0.099649f; return 0; } // The tears the Keepers lose after Binge Eater's, unless 20/20 holds them up. float character_tears_penalty_get(Entity_Player& player) { if (player.HasCollectible(COLLECTIBLE_20_20)) return 0; if (player.playerType == PLAYER_KEEPER) return 1.9f; return player.playerType == PLAYER_KEEPER_B ? 2.2f : 0; } // What a character multiplies its damage by: its share plus one, Azazel's Stump's 1.5, and nothing for Eve and Tainted // Eve while their Whore of Babylon is on. float character_damage_scale_get(Entity_Player& player) { TemporaryEffects& effects = player.temporaryEffects; if (effects.HasTrinketEffect(TRINKET_AZAZELS_STUMP)) return AZAZELS_STUMP_DAMAGE_SCALE; if (player.playerType == PLAYER_EVE && effects.HasCollectibleEffect(COLLECTIBLE_WHORE_OF_BABYLON)) return 1; if (player.playerType == PLAYER_EVE_B && effects.HasNullEffect(NULLITEM_BLOODY_BABYLON)) return 1; if (player.playerType < 0 || player.playerType >= PLAYER_TYPE_COUNT) return 1; return CHARACTER_DAMAGE_SHARES[player.playerType] + 1; } // The damage a character adds after its multiplier: Eden's roll, Jacob's loss and Esau's gain. float character_damage_get(Entity_Player& player) { if (is_eden(player)) return player.edenDamage; if (player.playerType == PLAYER_JACOB) return -0.75f; return player.playerType == PLAYER_ESAU ? 0.25f : 0; } // The shot speed a character adds: Samson's, Eden's roll and the twins'. float character_shot_speed_get(Entity_Player& player) { if (player.playerType == PLAYER_SAMSON) return 0.31f; if (is_eden(player)) return player.edenShotSpeed; if (player.playerType == PLAYER_JACOB) return 0.15f; return player.playerType == PLAYER_ESAU ? -0.15f : 0; } // The range a character adds to the base 260: the short ranged ones (and Azazel's Stump) lose 80, Samson and Jacob 60, // Esau gains 60 and Eden its roll. float character_range_get(Entity_Player& player) { switch (player.playerType) { case PLAYER_CAIN: case PLAYER_LAZARUS: case PLAYER_AZAZEL: case PLAYER_CAIN_B: case PLAYER_JUDAS_B: case PLAYER_LAZARUS_B: return -80; default: break; } if (player.temporaryEffects.HasTrinketEffect(TRINKET_AZAZELS_STUMP)) return -80; if (player.playerType == PLAYER_SAMSON || player.playerType == PLAYER_SAMSON_B || player.playerType == PLAYER_JACOB) return -60; if (is_eden(player)) return player.edenTearRange; return player.playerType == PLAYER_ESAU ? 60 : 0; } // The speed table's entry for the player's type, Eden's roll for the Edens. static float speed_table_get(Entity_Player& player) { if (is_eden(player)) return player.edenSpeed; if (player.playerType < 0 || player.playerType >= PLAYER_TYPE_COUNT) return 0; return CHARACTER_SPEEDS[player.playerType]; } // The speed a character adds, Azazel's for its stump. float character_speed_get(Entity_Player& player) { if (player.temporaryEffects.HasTrinketEffect(TRINKET_AZAZELS_STUMP)) return CHARACTER_SPEEDS[PLAYER_AZAZEL]; return speed_table_get(player); } // The luck a character adds: Cain's Birthright, Lazarus' and Esau's loss, the Keepers' and Tainted Lazarus' dead // form's, and Jacob's gain. float character_luck_get(Entity_Player& player) { float luck = player.playerType == PLAYER_CAIN && player.HasCollectible(COLLECTIBLE_BIRTHRIGHT) ? 1.0f : 0.0f; switch (player.playerType) { case PLAYER_LAZARUS: case PLAYER_ESAU: return luck - 1; case PLAYER_KEEPER: case PLAYER_KEEPER_B: case PLAYER_LAZARUS2_B: return luck - 2; case PLAYER_JACOB: return luck + 1; default: return luck; } } // The speed part of 00763570's end: a twin's speed is evaluated too, then Jacob and Esau share their average and other // pairs the leading twin's, clamped to 0.1 to 2. The twin evaluated here skips its own share. void twins_speed_share(Entity_Player& player) { Entity_Player* twin = player.twin_get(); if ((player.cacheFlags & (CACHE_TWIN_SPEED | CACHE_SPEED)) != CACHE_SPEED || !twin) return; twin->cacheFlags |= CACHE_TWIN_SPEED | CACHE_SPEED; twin->EvaluateItems(); bool isJacobAndEsau = player.playerType == PLAYER_JACOB || player.playerType == PLAYER_ESAU; float speed = player.moveSpeed; if (isJacobAndEsau) speed = (player.moveSpeed + twin->moveSpeed) * 0.5f; else if (player.GetMainTwin() != &player) speed = twin->moveSpeed; speed = std::max(std::min(speed, TWIN_SPEED_MAX), TWIN_SPEED_MIN); player.moveSpeed = speed; twin->moveSpeed = speed; } // The speed the slowing null effects take, only from characters not already slower than Isaac. bool is_character_slowed(Entity_Player& player) { TemporaryEffects& effects = player.temporaryEffects; bool isFaster = player.playerType >= PLAYER_TYPE_COUNT || speed_table_get(player) >= 0; return isFaster && (effects.HasNullEffect(NULLITEM_SLOW_A) || effects.HasNullEffect(NULLITEM_SLOW_B)); } // The UpdateCostumes part (0075bf00) that redraws the player's head and body in the skin colors its costumes left it: // the character's skin sheet in each changed color on every layer but the ghost, or Tainted Forgotten's bomb sheet in // Hot Potato. void Entity_Player::skin_recolor(const SkinColors& colors) { EntityConfig_Player* config = g_manager->entityConfig.GetPlayer(playerType); if (g_game->challenge == CHALLENGE_HOT_POTATO && playerType == PLAYER_THEFORGOTTEN_B) for (int layer = 0; layer < COSTUME_LAYER_COUNT; layer++) sprite.ReplaceSpritesheet(layer, FORGOTTEN_BOMB_SHEET); else if (config && !config->skinPath.empty()) { auto sheet_get = [&](int applied, int color) { if (applied == color) return std::string(); return costume_path_apply_skin_color(config->skinPath, color, -1, nullptr, nullptr); }; std::string headSheet = sheet_get(headColor, colors.head); std::string bodySheet = sheet_get(bodyColor, colors.body); for (int layer = 0; layer < COSTUME_LAYER_COUNT; layer++) { const std::string& sheet = is_body_layer(layer) ? bodySheet : headSheet; if (layer != PLAYER_LAYER_GHOST && !sheet.empty()) sprite.ReplaceSpritesheet(layer, sheet); } } sprite.LoadGraphics(); headColor = colors.head; bodyColor = colors.body; } // Whether Whore of Babylon wakes for the player's red hearts: at one or less (16 in the deathmatch), Eve's at two, or // always with her Birthright, hers only once the room has run a frame. bool is_whore_of_babylon_awake(Entity_Player& player) { Game& game = *g_game; bool isDeathmatch = game.deathmatchManager.is_active(); if (player.redHearts <= (isDeathmatch ? DEATHMATCH_WHORE_RED_HEARTS : WHORE_OF_BABYLON_RED_HEARTS)) return true; if (player.playerType != PLAYER_EVE) return false; int eveRedHearts = isDeathmatch ? DEATHMATCH_WHORE_RED_HEARTS : EVE_WHORE_OF_BABYLON_RED_HEARTS; if (player.redHearts > eveRedHearts && !player.HasCollectible(COLLECTIBLE_BIRTHRIGHT)) return false; return game.room->isInitialized && game.frameCount - game.room->enterFrame > 1; } // Tainted Eve down to her last heart with no clots left: her own Whore of Babylon wakes, once the room has run a frame. void tainted_eve_babylon_try(Entity_Player& player) { Game& game = *g_game; Room& room = *game.room; if (!room.isInitialized || game.frameCount - room.enterFrame <= 1) return; if (player.temporaryEffects.HasNullEffect(NULLITEM_BLOODY_BABYLON)) return; for (Entity* entity : room.entityList.persistentEL) if (entity && entity->type == ENTITY_FAMILIAR && static_cast(entity)->player == &player && entity->variant == Entity_Familiar::BLOOD_BABY && entity->subtype != BLOOD_CLOT_SUBTYPE_SPENT && !entity->isDead) return; game.itemOverlay.Show(GIANTBOOK_WHORE_OF_BABYLON, 3, nullptr); player.temporaryEffects.AddNullEffect(NULLITEM_BLOODY_BABYLON, true, 1); } // 007d2ad0 Adds soul charges, kept within 0 to 99: the actives they charge flash, the twin shares them and the HUD // redraws. void Entity_Player::AddSoulCharge(int count) { int oldSoulCharge = effectiveSoulCharge; effectiveSoulCharge = std::clamp(count + oldSoulCharge, 0, CHARGE_STORE_MAX); apply_soul_charge_to_actives(oldSoulCharge); ConsumableCountChanged(SOUL_CHARGE_CONSUMABLE); g_game->hud.refresh_request(HUD_REFRESH_PLAYER); } // 007d2b50 The soul charges Bethany can spend, none for other characters. int Entity_Player::GetEffectiveSoulCharge() { return playerType == PLAYER_BETHANY ? effectiveSoulCharge : 0; } // 006f0020 Sets the soul charges as they are. void Entity_Player::SetSoulCharge(int amount) { effectiveSoulCharge = amount; } // 007d2d40 Adds blood charges, kept within 0 to 99, as AddSoulCharge does for Tainted Bethany. void Entity_Player::AddBloodCharge(int amount) { int oldBloodCharge = effectiveBloodCharge; effectiveBloodCharge = std::clamp(amount + oldBloodCharge, 0, CHARGE_STORE_MAX); blood_charge_changed(oldBloodCharge); ConsumableCountChanged(BLOOD_CHARGE_CONSUMABLE); g_game->hud.refresh_request(HUD_REFRESH_PLAYER); } // 007d2dd0 The blood charges Tainted Bethany can spend, none for other characters. int Entity_Player::GetEffectiveBloodCharge() { return playerType == PLAYER_BETHANY_B ? effectiveBloodCharge : 0; } // 006f0030 Sets the blood charges as they are. void Entity_Player::SetBloodCharge(int amount) { effectiveBloodCharge = amount; } // 009bc280 A spot for a player to appear near a position, away from the room's enemies and shots and where they head // (and the other players in the deathmatch): up to 50 random spots on circles growing from 30, each moved to a free // tile, until one is 120 away from all of them, else the farthest found. Vector PlayerManager::find_safe_spawn_position(Vector position) { Game& game = *g_game; Room& room = *game.room; std::vector dangers; Vector best{}; float bestDistance = 0; for (Entity* entity : room.entityList.updateEL) { bool isPlayer = game.deathmatchManager.is_active() && entity->type == ENTITY_PLAYER; bool isEnemy = entity->type >= NPC_TYPE_FIRST && entity->type <= NPC_TYPE_LAST; if (!isPlayer && !isEnemy && entity->type != ENTITY_PROJECTILE) continue; dangers.push_back(entity->pos); dangers.push_back(vector_make(entity->velocity.x * SAFE_SPAWN_LOOKAHEAD + entity->pos.x, entity->velocity.y * SAFE_SPAWN_LOOKAHEAD + entity->pos.y)); } for (int radius = 0; radius < SAFE_SPAWN_TRIES && bestDistance <= SAFE_SPAWN_FAR_ENOUGH; radius += SAFE_SPAWN_RADIUS_STEP) { float angle = random_unit() * 3.14f; angle = angle + angle; float distance = (float)radius + SAFE_SPAWN_RADIUS_MIN; Vector spot = vector_make(std::cos(angle) * distance + position.x, std::sin(angle) * distance + position.y); spot = room_free_pickup_position_find({.position = room.GetClampedPositionImpl(spot, 0, 0, 0, 0), .isAvoidActiveEntities = true}); float nearest = SAFE_SPAWN_NEAREST_START; for (const Vector& danger : dangers) { float dx = spot.x - danger.x; float dy = spot.y - danger.y; nearest = std::min(nearest, dy * dy + dx * dx); } if (bestDistance >= nearest) continue; best = spot; bestDistance = nearest; } return best; } // 007d2000 Spawns a twin of a character type as a co-player that shares this player's controller and stands 20 to its // right, this player moving 20 to the left, and gives both their HUDs. Entity_Player* Entity_Player::InitTwin(int twinType) { Game& game = *g_game; Entity_Player* twin = game.playerManager.SpawnCoPlayer2(twinType); twin->twinPlayer = this; twinPlayer = twin; twin->SetControllerIndex(controllerIndex, false); twin->pos = PlayerManager::find_safe_spawn_position(pos); twin->pos = vector_make(pos.x + TWIN_SPAWN_OFFSET, pos.y + 0); pos = vector_make(pos.x - TWIN_SPAWN_OFFSET, pos.y + 0); game.hud.AssignPlayerHUDs(); return twin; } // Lets go of the sub player: unlinks and deletes it. static void sub_player_free(Entity_Player& player) { player.subPlayer->ClearReferences(); delete player.subPlayer; player.subPlayer = nullptr; } // Takes a companion out of the room with a poof where it stood. static void companion_poof(Entity* companion) { g_game->Spawn({.position = companion->pos, .spawner = companion, .type = ENTITY_EFFECT, .variant = EFFECT_POOF01, .seed = Random()}); companion->Remove(); } // 007cbcd0 Gives The Forgotten and The Soul their other half as a sub player (unless the soul has left the body), and // takes it away from other characters, with the Forgotten's body and Dark Esau, which leave with a poof. Only players // of the run have halves. void Entity_Player::init_forgotten_twin() { if (playerIndex < 0) return; if (playerType == PLAYER_THEFORGOTTEN || playerType == PLAYER_THESOUL) { if (temporaryEffects.HasNullEffect(NULLITEM_SOUL_FORGOTTEN)) { if (subPlayer) sub_player_free(*this); } else if (!subPlayer) { subPlayer = new Entity_Player(); subPlayer->Init(type, variant, playerType == PLAYER_THEFORGOTTEN ? PLAYER_THESOUL : PLAYER_THEFORGOTTEN, initSeed); } return; } if (subPlayer && !subPlayer->isValid) sub_player_free(*this); if (forgottenBody) { companion_poof(forgottenBody); forgottenBody = nullptr; } if (darkEsau && playerType != PLAYER_JACOB_B && playerType != PLAYER_JACOB2_B) companion_poof(darkEsau); } // 007cbef0 Lays the Forgotten's body where the Soul leaves it (where it was last left, with the Soul's Birthright, // unless that is another room of this dimension), sized, scaled and tinted as the player, with the chain binding it to // the Soul. A body left by a replaced player stays. The room it lies in is remembered. Entity* Entity_Player::spawn_forgotten_body() { Game& game = *g_game; if (forgottenBody) { if (replacedPlayer) return forgottenBody; forgottenBody->Remove(); forgottenBody = nullptr; } bool isBirthrightBody = HasCollectible(COLLECTIBLE_BIRTHRIGHT) && playerType == PLAYER_THESOUL; bool isBodyLeft = isBirthrightBody && forgottenBodyRoomIdx != FORGOTTEN_BODY_ROOM_NONE; int roomIdx = forgottenBodyRoomIdx >= 0 ? forgottenBodyRoomIdx % DIMENSION_ROOM_COUNT : forgottenBodyRoomIdx; int dimension = forgottenBodyRoomIdx >= 0 ? forgottenBodyRoomIdx / DIMENSION_ROOM_COUNT : 0; if (isBirthrightBody && roomIdx != FORGOTTEN_BODY_ROOM_NONE) { RoomConfig_Room* data = game.room->descriptor->data; bool isHome = data && data->type == ROOM_DUNGEON && data->stageId == STAGE_ID_HOME; if (!isHome && dimension == game.currentDimensionIdx && game.GetRoomByIdx(roomIdx, dimension) != game.room->descriptor) return nullptr; } Vector spawnPos = isBodyLeft ? forgottenBodyPos : pos; auto* body = static_cast(game.Spawn( {.position = spawnPos, .type = ENTITY_FAMILIAR, .variant = Entity_Familiar::FORGOTTEN_BODY, .seed = Random()})); body->pos = spawnPos; body->SetSize(size, sizeMulti, -1); body->sprite.scale = playerSpriteScale; body->sprite.color = colorOverride; body->ClearEntityFlags(FLAG_APPEAR); forgottenBody = body; if (game.currentRoomIdx != ROOM_IDX_DEBUG) { forgottenBodyRoomIdx = game.currentRoomIdx >= 0 ? game.currentDimensionIdx * DIMENSION_ROOM_COUNT + game.currentRoomIdx : game.currentRoomIdx; forgottenBodyPos = spawnPos; } if (isBirthrightBody) return body; Entity* chain = game.Spawn({.position = pos, .type = ENTITY_EFFECT, .variant = EFFECT_FORGOTTEN_CHAIN, .seed = Random()}); chain->child = body; chain->target = this; static_cast(chain)->scale = FORGOTTEN_CHAIN_SCALE; chain->Update(); return body; } // The part of 007bc740 that hands Magdalene her starting pill: Full Health, told apart from Health Up's color (up to // ten tries), already identified. void Entity_Player::magdalene_pill_add() { ItemPool& pool = g_game->itemPool; int pill = pool.ForceAddPillEffect(PILLEFFECT_FULL_HEALTH); for (int i = 0; i < MAGDALENE_PILL_TRIES; i++) { int healthUp = pool.ForceAddPillEffect(PILLEFFECT_HEALTH_UP); if (pill != healthUp) break; pill = pool.ForceAddPillEffect(PILLEFFECT_FULL_HEALTH); if (pill != healthUp) break; } AddPocketItem(pill, POCKET_PILL); pool.IdentifyPill((uint32_t)pill); } // Whether the player is Jacob or Esau, who share their item and pocket buttons. static bool is_jacob_or_esau(Entity_Player& player) { return player.playerType == PLAYER_JACOB || player.playerType == PLAYER_ESAU; } // Whether Jacob and Esau play with the classic controls, where Jacob's item button is Esau's pocket button and drop // switches the pocket button between them. static bool is_twin_classic_controls() { return g_manager->optionsConfig.jacobEsauControls == 0; } // The button a twin reads for its item (Esau's is the pocket button) or its pocket (Jacob's is the item button) with // the classic controls. Any other player reads its own. ButtonAction twin_button_action(Entity_Player& player, TwinButton button) { if (is_jacob_or_esau(player) && is_twin_classic_controls()) return player.GetMainTwin() == &player ? ACTION_ITEM : ACTION_PILL_CARD; return button == TWIN_BUTTON_ITEM ? ACTION_ITEM : ACTION_PILL_CARD; } // Whether the drop button keeps a twin from its item or pocket button this frame. With the classic controls drop held // takes the item button away and drop released the pocket button, while the pair stands together. Otherwise drop // held hands both buttons from Jacob to Esau. bool is_twin_button_blocked(Entity_Player& player, TwinButton button) { if (!is_jacob_or_esau(player)) return false; bool isDropHeld = input_is_action_pressed(ACTION_DROP, player.controllerIndex, &player); if (is_twin_classic_controls()) return player.twin_get() && (button == TWIN_BUTTON_ITEM ? isDropHeld : !isDropHeld); if (player.GetMainTwin() == &player) return isDropHeld; return !isDropHeld; } // The Render part (0078ca00) that points at a co-op player outside the screen: its character's icon at the screen's // edge, faded in over 140 past the edge. The icon is HUD::render_player_type_icon, which stops the game when shown. void Entity_Player::coop_indicator_render() { Room& room = *g_game->room; if (g_game->playerManager.GetPlayerSlotFromController(controllerIndex) < 0) return; float scale = g_displayPixelRatio * g_screenPointScale; float x = ((g_screenWidth - INDICATOR_SCREEN_WIDTH) * 0.5f + (pos.x - INDICATOR_ORIGIN_X) * INDICATOR_SCALE) * scale; float y = ((pos.y - INDICATOR_ORIGIN_Y) * INDICATOR_SCALE + (g_screenHeight - INDICATOR_SCREEN_HEIGHT) * 0.5f) * scale; x = (float)std::floor(x + 0.5f) / scale + room.renderScrollOffset.x; y = (float)std::floor(y + 0.5f) / scale + room.renderScrollOffset.y; float edgeX = std::min(std::max(x, 0.0f), g_screenWidth); float edgeY = std::min(std::max(y, 0.0f), g_screenHeight + INDICATOR_BOTTOM_MARGIN); float distance = std::sqrt((y - edgeY) * (y - edgeY) + (x - edgeX) * (x - edgeX)); if (std::clamp((distance - INDICATOR_FADE_START) / INDICATOR_FADE_LENGTH, 0.0f, 1.0f) > 0) reconstruction_missing("HUD::render_player_type_icon 009a6660 (the co-op player indicator)"); } // 007c3620 Takes off the costume the character's config dresses it in. void Entity_Player::RemoveSkinCostume() { EntityConfig_Player* config = g_manager->entityConfig.GetPlayer(playerType); if (config && config->costumeID != -1) RemoveCostume(g_manager->itemConfig.GetNullItem(config->costumeID)); } // 007a2220 Brings a dead player back with half a red heart (half a soul heart without containers or bone hearts), // one broken heart fewer when they fill every container. A co-op ghost or baby appears again somewhere safe, and // Tainted Forgotten is dropped by its soul and gets its weapons back. The extra layer shows again. void Entity_Player::Revive() { if (!isDead) return; isDead = false; damageCooldown = 1; if (GetHeartLimit(false) < 1) brokenHearts = std::max(brokenHearts - 1, 0); if (maxHearts >= 1) { redHearts = 1; soulHearts = 0; } else if (boneHearts < 1) { redHearts = 0; soulHearts = 1; } if (variant == PLAYER_VARIANT_COOP_BABY || isCoopGhost) { PlayExtraAnimation("Appear", false); pos = PlayerManager::find_safe_spawn_position(pos); damageCooldown = COOP_REVIVE_DAMAGE_COOLDOWN; } if (playerType == PLAYER_THEFORGOTTEN_B) { Entity_Player* soul = twin_get(); if (soul && soul->heldEntity == this) { soul->heldEntity = nullptr; ClearEntityFlags(FLAG_HELD | FLAG_THROWN); } cacheFlags = CACHE_ALL; weaponTypes.fill(false); EvaluateItems(); } if (LayerState* extra = sprite.GetLayer(PLAYER_LAYER_EXTRA)) extra->isVisible = true; } // 007a23a0 Revives the player by a collectible's rule, the owner of the collectible playing its part. Only Lazarus' // Rags (Lazarus' own rising) is reconstructed: the player is dressed as Lazarus Risen (unless already Lazarus), // keeps a container fewer (two at least) filled with a red heart, rises as Lazarus Risen (the tainted Lazaruses stay // themselves) with Lazarus' boost, Red Stew's effect with his Birthright, and a poof. It stays vulnerable for 90 frames // at least. void Entity_Player::collectible_revive(int collectible, bool isOwner) { Game& game = *g_game; ItemConfig& items = g_manager->itemConfig; if (playerIndex >= 0) Revive(); if (collectible != COLLECTIBLE_LAZARUS_RAGS) reconstruction_missing(("Entity_Player::collectible_revive 007a23a0 (collectible " + std::to_string(collectible) + (isOwner ? ", owner)" : ")")) .c_str()); if (playerType != PLAYER_LAZARUS) { if (playerType != PLAYER_THEFORGOTTEN_B) RemoveSkinCostume(); AddCostume(items.GetCollectible(COLLECTIBLE_LAZARUS_RAGS), false); } soulHearts = 0; blackHearts = 0; eternalHearts = 0; maxHearts = std::max(maxHearts - 2, LAZARUS_RISEN_MAX_HEARTS); boneHeartsMask = 0; boneHearts = 0; redHearts = std::min(maxHearts, LAZARUS_RISEN_MAX_HEARTS); rottenHearts = 0; if (HasCollectible(COLLECTIBLE_BIRTHRIGHT) && playerType == PLAYER_LAZARUS) redStewBonusDuration = LAZARUS_BIRTHRIGHT_STEW_FRAMES; if (playerType != PLAYER_LAZARUS_B && playerType != PLAYER_LAZARUS2_B) playerType = PLAYER_LAZARUS2; cacheFlags |= CACHE_ALL; temporaryEffects.AddNullEffect(NULLITEM_LAZARUS_BOOST, true, 1); update_player_skin(); EvaluateItems(); if (forgottenBody) pos = forgottenBody->pos; Entity* poof = game.Spawn({.position = pos, .spawner = this, .subType = POOF_LARGE_SUBTYPE, .type = ENTITY_EFFECT, .variant = EFFECT_POOF01, .seed = Random()}); poof->renderDepthOffset = posOffset.y + 1; isVisible = true; damageCooldown = std::max(damageCooldown, REVIVE_DAMAGE_COOLDOWN); UpdateHeartDependentEffects(); if (game.deathmatchManager.is_active() || isDead || goldenHearts <= 0) return; int holders = (std::min(redHearts, maxHearts) + 1) / 2 + (soulHearts + 1) / 2 + boneHearts; if (holders >= goldenHearts) return; BreakGoldenHearts(goldenHearts - holders); goldenHearts = holders; } // The end of 007a1090 once the first of the pair lives again: Judas' Birthright makes a Judas saved by Plan C Black // Judas, the first player's old character lets go of what it brought, and each player rolls Guppy's Collar's and Broken // Ankh's generators, gets its Forgotten half back and settles whether it can shoot and its color. void revived_players_settle(std::vector& players, int oldType) { Entity_Player& first = *players[0]; if (oldType == PLAYER_JUDAS && first.playerType != PLAYER_BLACKJUDAS && first.HasCollectible(COLLECTIBLE_BIRTHRIGHT) && first.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_PLAN_C)) { if (ItemConfig_Item* planC = g_manager->itemConfig.GetCollectible(COLLECTIBLE_PLAN_C)) first.temporaryEffects.RemoveEffect(planC, -1); first.maxHearts = 0; first.redHearts = 0; first.playerType = PLAYER_BLACKJUDAS; first.cacheFlags |= CACHE_ALL; first.update_player_skin(); first.EvaluateItems(); first.TryPreventDeath(); } first.player_type_change_prepare(oldType); for (Entity_Player* player : players) { player->GetCollectibleRNG(COLLECTIBLE_GUPPYS_COLLAR_RNG).Next(); player->GetTrinketRNG(TRINKET_BROKEN_ANKH_RNG).Next(); player->init_forgotten_twin(); player->UpdateCanShoot(); player->ResetColor(); } } // 007cf610 Lets go of what the old character brought once the player became another: a twin it had (Jacob's Esau, // Tainted Forgotten's soul, Tainted Lazarus' other form) unless the twin is that character, Tainted Isaac's inventory // and Tainted Jacob's curse (not reconstructed yet), Tainted Forgotten's flight, and its pocket active for the new // one's. void Entity_Player::player_type_change_prepare(int oldType) { if (oldType == playerType) return; bool isJacobPair = (playerType == PLAYER_JACOB_B && oldType == PLAYER_JACOB2_B) || (playerType == PLAYER_JACOB2_B && oldType == PLAYER_JACOB_B); if (isJacobPair) return; Entity_Player* twin = twin_get(); if (twin) { if (twin->playerType == oldType) return; if (oldType == PLAYER_JACOB || oldType == PLAYER_THEFORGOTTEN_B) remove_twin(); } if (oldType == PLAYER_LAZARUS_B || oldType == PLAYER_LAZARUS2_B) remove_twin(); if (playerType == PLAYER_ISAAC_B) tainted_isaac_inventory_trim(*this); if ((playerType == PLAYER_JACOB_B || playerType == PLAYER_JACOB2_B) && !temporaryEffects.HasNullEffect(NULLITEM_JACOBS_CURSE)) reconstruction_missing("Entity_Player::player_type_change_prepare 007cf610 (Tainted Jacob's curse)"); if (oldType == PLAYER_THEFORGOTTEN_B) { cacheFlags |= CACHE_FLYING; canFly = true; EvaluateItems(); } EntityConfig_Player* config = g_manager->entityConfig.GetPlayer(playerType); SetPocketActiveItem(config ? config->pocketActiveID : 0, ACTIVE_SLOT_POCKET, false); g_game->hud.mark_all_slots_dirty(HISTORY_REBUILD_ICONS, HISTORY_CLEAR_ITEMS); } // The ChangePlayerType part that hands Bethany's soul charges back as soul hearts, shared among the Bethanies (one at // least), when she becomes another character. static int bethany_soul_share_get(Entity_Player& player) { PlayerManager& players = g_game->playerManager; if (player.playerType != PLAYER_BETHANY || player.effectiveSoulCharge <= 0) return 0; int bethanies = (int)std::ranges::count_if(players.playerList, [](Entity_Player* each) { return each->playerType == PLAYER_BETHANY; }); return std::max(player.effectiveSoulCharge / bethanies, 1); } // The ChangePlayerType part that takes the hearts of the player's other half (The Forgotten's or The Soul's) back, // then splits them again for the new halves: soul hearts go to a soul half, bone and red hearts to a bone half, and // an eternal heart beyond the first. void Entity_Player::forgotten_halves_hearts_move() { if (Entity_Player* half = subPlayer) { int shift = (soulHearts + 1) / 2; int oldBoneHearts = boneHearts; maxHearts += half->maxHearts; redHearts += half->redHearts; soulHearts = half->soulHearts + soulHearts; boneHearts = half->boneHearts + oldBoneHearts; blackHearts |= half->blackHearts << (shift & 31); boneHeartsMask |= half->boneHeartsMask << ((oldBoneHearts + shift) & 31); eternalHearts += half->eternalHearts; rottenHearts += half->rottenHearts; goldenHearts += half->goldenHearts; } init_forgotten_twin(); Entity_Player* half = subPlayer; if (!half) return; HealthType health = half->GetHealthType(); if (health == HEALTH_SOUL) { half->soulHearts = soulHearts; half->blackHearts = blackHearts; soulHearts = 0; blackHearts = 0; } else if (health == HEALTH_BONE) { half->AddBoneHearts(boneHearts); half->redHearts = redHearts; redHearts = 0; boneHearts = 0; boneHeartsMask = 0; } if (eternalHearts > 1) { eternalHearts--; half->eternalHearts++; } half->update_bone_hearts(); } // The ChangePlayerType part that reshapes the hearts for how the new character counts health: none keeps half a soul // heart, coins become two coin hearts and one broken heart at most, soul hearts lose the red ones, and bone hearts // turn the containers into bone hearts. static void health_type_apply(Entity_Player& player, HealthType health) { switch (health) { case HEALTH_NO_HEALTH: player.rottenHearts = 0; player.boneHeartsMask = 0; player.boneHearts = 0; player.eternalHearts = 0; player.maxHearts = 0; player.redHearts = 0; player.soulHearts = 1; player.blackHearts = 0; break; case HEALTH_COIN: player.brokenHearts = std::min(player.brokenHearts, 1); player.AddMaxHearts(KEEPER_START_COIN_HEARTS, false); player.rottenHearts = 0; player.boneHeartsMask = 0; player.boneHearts = 0; player.soulHearts = 0; player.blackHearts = 0; break; case HEALTH_SOUL: player.rottenHearts = 0; player.maxHearts = 0; player.redHearts = 0; break; case HEALTH_BONE: { int bones = player.maxHearts / 2; player.maxHearts = 0; if (bones > 0) player.AddBoneHearts(bones); player.redHearts = std::min(player.redHearts, player.GetEffectiveMaxHearts()); player.soulHearts = 0; player.blackHearts = 0; break; } default: break; } } // The ChangePlayerType part that takes a twin's hearts into the player that no longer needs it: the most broken hearts, // then its containers, bone, eternal, red, soul and golden hearts, its black ones after the player's soul hearts, and // its rotten ones as far as the red hearts hold them. static void twin_hearts_take(Entity_Player& player, Entity_Player& twin) { int oldSoulHearts = player.soulHearts; player.brokenHearts = std::max(player.brokenHearts, twin.brokenHearts); player.AddMaxHearts(twin.maxHearts, false); player.AddBoneHearts(twin.boneHearts); player.AddEternalHearts(twin.eternalHearts); player.AddHearts(twin.redHearts, true, false); player.AddSoulHearts(twin.soulHearts, false); player.AddGoldenHearts(twin.goldenHearts, false); player.blackHearts |= twin.blackHearts << ((oldSoulHearts / 2) & 31); player.rottenHearts = std::min(player.rottenHearts + twin.rottenHearts, (player.redHearts + 1) / 2); player.UpdateBlackHeartMask(); } // The ChangePlayerType part that keeps the sprite's animation, frame and playing state through a reload. static void animation_restore(ANM2& sprite, const std::string& animation, bool isPlaying, float frame) { if (animation.empty()) return; if (!isPlaying) { sprite.SetFrame(animation, (int)frame); return; } const AnimationState& state = sprite.animState; bool isStopped = state.animData && state.animData->isLooping && !state.isPlaying; if (!state.animData || sprite.GetAnimation() != animation || isStopped) sprite.Play(animation, PLAY_FORCED); if (sprite.animState.animData) sprite.animState.SetFrameFloat(frame); } // 007ce6e0 Turns the player into another character: The Forgotten and The Soul only swap forms when isKeepState, Bethany // hands her soul charges back, the costume, hearts, halves and twin follow the new character, the sprite reloads with // the animation kept, and the stats, innate items and costumes are redone. Tainted Forgotten gets its soul and Tainted // Lazarus its other form unless isKeepState. Becoming Jacob, who splits his hearts with a new Esau, is not // reconstructed yet. void Entity_Player::ChangePlayerType(int newType, bool isKeepState) { EntityConfig& configs = g_manager->entityConfig; if (newType < 0) return; bool isForgottenSwap = (newType == PLAYER_THEFORGOTTEN && playerType == PLAYER_THESOUL) || (newType == PLAYER_THESOUL && playerType == PLAYER_THEFORGOTTEN); if (isKeepState && isForgottenSwap) { SwapForgottenForm(true, true); return; } int soulShare = isKeepState ? 0 : bethany_soul_share_get(*this); RemoveSkinCostume(); int oldType = playerType; if (oldType == PLAYER_LAZARUS2) { EntityConfig_Player* lazarus = configs.GetPlayer(PLAYER_LAZARUS); if (lazarus && lazarus->costumeID != -1) RemoveCostume(g_manager->itemConfig.GetNullItem(lazarus->costumeID)); } playerType = newType; if (soulShare > 0) { AddSoulCharge(-soulShare); AddSoulHearts(soulShare, false); } if (oldType == PLAYER_THEFORGOTTEN_B) { if (Entity_Player* soul = twin_get()) Teleport(soul->pos, false, false); ClearEntityFlags(FLAG_THROWN); posOffset.y = 0; heightVelocity = 0; } HealthType health = GetHealthType(); forgotten_halves_hearts_move(); health_type_apply(*this, health); if (!isCoopGhost) TryPreventDeath(); update_bone_hearts(); UpdateHeartDependentEffects(); UpdateCanShoot(); AddEternalHearts(0); if (playerType == PLAYER_JACOB) { if (!isKeepState) reconstruction_missing("Entity_Player::ChangePlayerType 007ce6e0 (Jacob splitting his hearts with Esau)"); } else if (Entity_Player* twin = twin_get(); twin && !isKeepState) twin_hearts_take(*this, *twin); if (playerType == PLAYER_BETHANY && soulHearts > 0) { AddSoulCharge(soulHearts); soulHearts = 0; if (!g_game->deathmatchManager.is_active()) blackHearts = 0; HealthType bethanyHealth = GetHealthType(); bool isBoneless = bethanyHealth == HEALTH_SOUL || bethanyHealth == HEALTH_NO_HEALTH; if ((isBoneless ? maxHearts : maxHearts + boneHearts * 2) < 1) { maxHearts = SOUL_CHARGE_HEART_CONTAINERS; redHearts = SOUL_CHARGE_HEART_CONTAINERS; } } if (playerType == PLAYER_BLUEBABY_B) poop_spell_roll(); if (!config) KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"Player Config invalid!\n"); std::string animation = sprite.animState.animData ? sprite.GetAnimation() : std::string(); bool isPlaying = sprite.animState.isPlaying; float frame = sprite.animState.animFrame; if (config) sprite.Load(config->anm2Path, GRAPHICS_DEFER); update_player_skin(); ResetColor(); player_type_change_prepare(oldType); animation_restore(sprite, animation, isPlaying, frame); if (!isKeepState && playerType == PLAYER_THEFORGOTTEN_B) InitTwin(PLAYER_THESOUL_B)->InitPostLevelInitStats(); else if (!isKeepState && playerType == PLAYER_LAZARUS_B && !backupPlayer) { backupPlayer = new Entity_Player(); backupPlayer->Init(type, variant, PLAYER_LAZARUS2_B, initSeed); backupPlayer->backupPlayer = this; } cacheFlags = CACHE_ALL; EvaluateItems(); apply_innate_collectibles(); UpdateCostumes(); } // The TakeDamage part (007729d0) for the items Eve and Samson start with: Dead Bird's effect wakes (and its costume // goes), and Bloody Lust, Bloody Gust and Blood Rights count the hit, Bloody Lust's and Bloody Gust's effects waking // (Samson's Bloody Lust without its costume). The deathmatch's timed Dead Bird is not reconstructed yet. void character_items_hit(Entity_Player& player) { TemporaryEffects& effects = player.temporaryEffects; if (player.HasCollectible(COLLECTIBLE_DEAD_BIRD)) { if (g_game->deathmatchManager.is_active()) reconstruction_missing("Entity_Player::TakeDamage 007729d0 (Dead Bird's deathmatch cooldown)"); ItemConfig_Item* deadBird = g_manager->itemConfig.GetCollectible(COLLECTIBLE_DEAD_BIRD); effects.AddEffect(TemporaryEffect(deadBird), true, 1); player.RemoveCostume(deadBird); } bool isLust = player.HasCollectible(COLLECTIBLE_BLOODY_LUST); bool isGust = player.HasCollectible(COLLECTIBLE_BLOODY_GUST); if (!isLust && !isGust && !player.HasCollectible(COLLECTIBLE_BLOOD_RIGHTS)) return; if (isLust) effects.AddCollectibleEffect(COLLECTIBLE_BLOODY_LUST, player.playerType != PLAYER_SAMSON, 1); if (isGust) effects.AddCollectibleEffect(COLLECTIBLE_BLOODY_GUST, true, 1); player.bloodLustCounter++; } // 007d4320 The red hearts Tainted Magdalene keeps for good: two hearts, three with Birthright. int maggy_heart_limit(Entity_Player& player) { return player.HasCollectible(COLLECTIBLE_BIRTHRIGHT) ? MAGGY_BIRTHRIGHT_HEART_LIMIT : MAGGY_HEART_LIMIT; } // Whether Tainted Magdalene holds health that drains: red hearts above her lasting ones, or soul hearts beyond the // last half heart. bool is_maggy_draining(Entity_Player& player) { return player.redHearts > maggy_heart_limit(player) || player.soulHearts > 1 || (player.soulHearts == 1 && player.redHearts + player.boneHearts > 0); } // Tainted Magdalene's drain, part of 00782af0: health above her lasting hearts loses half a heart every 300 frames, // red before soul. Anyone else's drain timer stays at 0. static void maggy_health_drain(Entity_Player& player) { if (player.playerType != PLAYER_MAGDALENE_B || !is_maggy_draining(player)) { player.maggyHealthDrainCooldown = 0; return; } if (player.maggyHealthDrainCooldown == 0) { player.maggyHealthDrainCooldown = MAGGY_DRAIN_FRAMES; return; } if (--player.maggyHealthDrainCooldown >= 1) return; if (player.redHearts > maggy_heart_limit(player)) player.AddHearts(-1, false, false); else if (is_maggy_draining(player)) player.AddSoulHearts(-1, false); player.maggyHealthDrainCooldown = MAGGY_DRAIN_FRAMES; } // The bleeding part of 00794e50: with Anemic's effect, bleeding out from her own wound, or while Tainted Magdalene's // health drains, one frame in five drops a small spot of red creep. static void blood_drip_update(Entity_Player& player) { bool isBleeding = player.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_ANEMIC) || (player.HasEntityFlags(FLAG_BLEED_OUT) && player.bleedSource.entity == &player) || (player.playerType == PLAYER_MAGDALENE_B && player.maggyHealthDrainCooldown > 0); if (!isBleeding || random_below(MAGGY_DRIP_ODDS) != 0) return; uint32_t seed = Random(); Entity* drip = g_game->Spawn({.position = player.pos, .spawner = &player, .type = ENTITY_EFFECT, .variant = EFFECT_PLAYER_CREEP_RED, .seed = seed}); float scale = random_unit() * MAGGY_DRIP_SCALE_SPREAD + MAGGY_DRIP_SCALE_BASE; drip->sprite.scale = vector_make(scale, scale); drip->Update(); } // 007d9200 Adds to Tainted Samson's berserk charge (held below full during a suplex). A full charge empties into // Berserk!, roaring, which reopens the backwards path's stages. The color is reevaluated. void Entity_Player::add_samson_berserk_charge(int amount) { samsonBerserkCharge += amount; if (suplexState != 0) samsonBerserkCharge = std::min(samsonBerserkCharge, BERSERK_CHARGE_MAX); if (samsonBerserkCharge > BERSERK_CHARGE_MAX) { samsonBerserkCharge = 0; if (ItemConfig_Item* berserk = g_manager->itemConfig.GetCollectible(COLLECTIBLE_BERSERK)) temporaryEffects.AddEffect(TemporaryEffect(berserk), true, 1); for (int sound : {SOUND_BERSERK_START, SOUND_ISAAC_ROAR}) { seed_fart_sound_override(&sound); g_manager->sfxManager.Play(sound); } g_game->UpdateBackwardsPathStages(); } cacheFlags |= CACHE_COLOR; temporaryEffects.isEvaluateCachePending = true; } // 007d3560 How much charge a point of damage dealt is worth: a tenth in a versus match, else less the deeper the // floor (the alternate floors count one deeper). float damage_charge_scale() { Game& game = *g_game; if (game.deathmatchManager.is_active()) return DEATHMATCH_DAMAGE_CHARGE_SCALE; bool isDeeper = game.stageType == STAGETYPE_REPENTANCE || game.stageType == STAGETYPE_REPENTANCE_B; return 1 / ((float)(game.stage + (isDeeper ? 1 : 0)) * DAMAGE_CHARGE_PER_STAGE + DAMAGE_CHARGE_BASE); } // The Berserk! charge part of 00794e50: out of Berserk!, the damage enemies took this frame charges Tainted Samson's // berserk bar and any Berserk! held in an active slot. static void berserk_charge_update(Entity_Player& player) { bool isCharging = player.HasCollectible(COLLECTIBLE_BERSERK) || player.playerType == PLAYER_SAMSON_B; if (!isCharging || player.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_BERSERK)) return; if (g_game->deathmatchManager.is_active()) reconstruction_missing("Entity_Player::update_effects 00794e50 (the versus damage dealt)"); float dealt = g_game->room->entityList.enemyDamageInflicted; if (dealt <= 0) return; int charge = (int)(damage_charge_scale() * dealt * BERSERK_CHARGE_PER_DAMAGE); if (player.playerType == PLAYER_SAMSON_B) player.add_samson_berserk_charge(charge); for (int slot = 0; slot < ACTIVE_SLOT_COUNT && charge > 0; slot++) if (player.activeItems[slot].item == COLLECTIBLE_BERSERK) charge -= player.AddActiveCharge(charge, slot, false, false, true); } // The characters' pieces of a whole frame the plain frame runs, with the items' frame (00794e50): Tainted Magdalene's // drain and its drip, and the Berserk! charge. void character_frame_update(Entity_Player& player) { maggy_health_drain(player); blood_drip_update(player); berserk_charge_update(player); blue_baby_poop_update(player); } // Tainted Magdalene's hug, part of 0078e1f0: touching a vulnerable enemy that is not a friend, with the last swing // nearly over, swings a bone club at it (along its main axis) with her melee damage doubled against her damage, the // tear look of a bone swing, and a 9 frame cooldown. void tainted_magdalene_hug(Entity_Player& player, Entity& collider) { if (player.playerType != PLAYER_MAGDALENE_B || !collider.IsVulnerableEnemy(nullptr) || player.maggySwingCooldown >= MAGGY_HUG_READY || collider.HasEntityFlags(FLAG_FRIENDLY)) return; float damageScale = player.meleeDamage + player.meleeDamage; int displacement = (int)(Random() & 1) * 2 - 1; TearParams params = player.GetTearHitParams(WEAPON_BONE, damageScale / player.damage, displacement, nullptr); uint32_t seed = Random(); auto* club = static_cast(g_game->Spawn({.position = player.pos, .spawner = &player, .subType = MAGGY_HUG_SUBTYPE, .type = ENTITY_KNIFE, .variant = KNIFE_BONE_CLUB, .seed = seed})); club->parent = &player; club->targetPosition = vector_make(MAGGY_HUG_REACH, 0); club->rotation = vector_angle(vector_cardinal(vector_sub(collider.pos, player.pos))); club->posOffset = vector_make(0, MAGGY_HUG_RISE); club->SetColor(params.tearColor, -1, COLOR_PRIORITY_HUG, false, true); club->sprite.scale = player.sprite.scale; club->tearFlags = params.tearFlags; club->SetCollisionDamage(params.tearDamage); // The club carries the entity flag the player's code reads as bleeding out (bit 34). club->AddEntityFlags(FLAG_BLEED_OUT); club->SetAttackAnimation(); club->Update(); player.maggySwingCooldown = MAGGY_HUG_FRAMES; }