From 69a354f843e843b85efe88bf13e84ff0fb663bbd Mon Sep 17 00:00:00 2001 From: shweet Date: Fri, 20 Nov 2026 06:43:01 -0500 Subject: [PATCH] Curation round 8: the first room plays: Isaac walks and shoots tears Eight agents took over Room::Init's pieces, RailManager, Room::Render/render_lighting/Update, the GridEntity hierarchy (walls, doors, rocks, pits, poop ...), Game::Update and interpolate_update, the run's save, update_ingame_input, Game::Spawn with the entity factory and grid collision, the player's movement and tears through Weapon/Weapon_Tears, PlayerManager's positions, the camera focus, MinimapConfig, PlayerHUD, mod shader rendering, Entity_Tear and Entity_Effect. Integration wrote Level::get_secret_exit_kind, shared the secret-exit enum (four copies merged) and fixed the generator's vtable-stub check (word boundary and namespace, not a substring). Under gdb a run reaches the first room: doors, HUD with hearts and minimap, WASD movement with acceleration, arrow-key tears that fly and splash. Floor and walls (Backdrop::RenderFloor/RenderWalls) and room transitions are next. The official build/isaac reaches the start room and stops at Entity_NPC::Redirect. 2770 functions taken over. Co-Authored-By: Claude Opus 5.5 --- generated-src/ambush.cpp | 2 +- generated-src/beast_arena.cpp | 323 -- generated-src/classes.h | 986 ++--- generated-src/color.cpp | 35 - generated-src/deathmatch_type_base.cpp | 4 +- generated-src/entity_factory.cpp | 597 --- generated-src/grid_entity.cpp | 320 -- generated-src/grid_entity_decoration.cpp | 544 --- generated-src/grid_entity_door.cpp | 3224 ----------------- generated-src/grid_entity_fire.cpp | 563 --- generated-src/grid_entity_gravity.cpp | 230 -- generated-src/grid_entity_lock.cpp | 338 -- generated-src/grid_entity_pit.cpp | 1310 ------- generated-src/grid_entity_poop.cpp | 1494 -------- generated-src/grid_entity_pressure_plate.cpp | 1795 --------- generated-src/grid_entity_rock.cpp | 1429 -------- generated-src/grid_entity_spikes.cpp | 788 ---- generated-src/grid_entity_stairs.cpp | 388 -- generated-src/grid_entity_statue.cpp | 69 - generated-src/grid_entity_teleporter.cpp | 256 -- generated-src/grid_entity_tnt.cpp | 176 - generated-src/grid_entity_trap_door.cpp | 1169 ------ generated-src/grid_entity_wall.cpp | 195 - generated-src/grid_entity_web.cpp | 225 -- .../isaac_repentance_plus/weapon.cpp | 37 - generated-src/l_room_tile_desc.cpp | 102 - generated-src/npc_helper.cpp | 12 +- generated-src/rail_manager.cpp | 74 - generated-src/sprite.cpp | 38 - generated-src/stage_transition.cpp | 4 +- generated-src/stubs.cpp | 511 ++- generated-src/tear_params.cpp | 123 - generated-src/weapon.cpp | 2479 ------------- generated-src/weapon_bombs.cpp | 224 +- generated-src/weapon_bone.cpp | 2428 ++++++++++++- generated-src/weapon_brimstone.cpp | 1106 +++++- generated-src/weapon_deathmatch.cpp | 166 +- generated-src/weapon_fetus.cpp | 402 +- generated-src/weapon_knife.cpp | 802 +++- generated-src/weapon_laser.cpp | 621 +++- generated-src/weapon_ludovico.cpp | 635 ++++ generated-src/weapon_monstros_lung.cpp | 4 +- generated-src/weapon_rockets.cpp | 505 ++- generated-src/weapon_spirit_sword.cpp | 576 +++ generated-src/weapon_tears.cpp | 57 - generated-src/weapon_tech_x.cpp | 292 +- generated-src/weapon_umbilical_whip.cpp | 144 + generated-src/weapon_urn_of_souls.cpp | 483 ++- scripts/source_tree.py | 8 +- src/backdrop.cpp | 144 +- src/beast_arena.cpp | 88 + src/beast_arena.h | 19 + src/camera.cpp | 21 +- src/entity.cpp | 6 - src/entity_collision.cpp | 293 ++ src/entity_effect.cpp | 277 +- src/entity_effect.h | 5 + src/entity_factory.cpp | 1223 +++++++ src/entity_factory.h | 93 + src/entity_familiar.h | 3 +- src/entity_player.cpp | 15 +- src/entity_player.h | 36 +- src/entity_player_frame.cpp | 288 +- src/entity_player_health.cpp | 45 + src/entity_player_items.cpp | 72 + src/entity_player_missing.cpp | 40 - src/entity_player_weapons.cpp | 483 +++ src/entity_projectile.cpp | 6 - src/entity_projectile.h | 1 - src/entity_tear.cpp | 961 ++++- src/entity_tear.h | 96 +- src/fx_layers.cpp | 11 +- src/game.cpp | 42 +- src/game.h | 24 + src/game_state.cpp | 54 +- src/game_state.h | 1 + src/game_update.cpp | 527 +++ src/generic_prompt.h | 2 - src/grid_entity.cpp | 302 ++ src/grid_entity.h | 135 + src/grid_entity_decoration.cpp | 122 + src/grid_entity_decoration.h | 19 + src/grid_entity_door.cpp | 1217 +++++++ src/grid_entity_door.h | 94 + src/grid_entity_fire.cpp | 26 + src/grid_entity_fire.h | 29 + src/grid_entity_gravity.cpp | 20 + src/grid_entity_gravity.h | 11 + src/grid_entity_lock.cpp | 38 + src/grid_entity_lock.h | 18 + src/grid_entity_pit.cpp | 93 + src/grid_entity_pit.h | 33 + src/grid_entity_poop.cpp | 85 + src/grid_entity_poop.h | 50 + src/grid_entity_pressure_plate.cpp | 56 + src/grid_entity_pressure_plate.h | 23 + src/grid_entity_rock.cpp | 563 +++ src/grid_entity_rock.h | 48 + src/grid_entity_spikes.cpp | 43 + src/grid_entity_spikes.h | 16 + src/grid_entity_stairs.cpp | 20 + src/grid_entity_stairs.h | 11 + src/grid_entity_statue.cpp | 24 + src/grid_entity_statue.h | 20 + src/grid_entity_teleporter.cpp | 26 + src/grid_entity_teleporter.h | 16 + src/grid_entity_tnt.cpp | 33 + src/grid_entity_tnt.h | 19 + src/grid_entity_trap_door.cpp | 20 + src/grid_entity_trap_door.h | 14 + src/grid_entity_wall.cpp | 261 ++ src/grid_entity_wall.h | 14 + src/grid_entity_web.cpp | 35 + src/grid_entity_web.h | 16 + src/hud.cpp | 117 +- src/hud.h | 108 +- src/item_pool.cpp | 31 +- src/item_pool.h | 22 +- src/level.cpp | 141 +- src/level.h | 11 + src/manager.cpp | 3 +- src/manager_input.cpp | 127 + src/minimap.cpp | 434 ++- src/minimap.h | 6 +- src/mod_manager.cpp | 123 + src/mod_manager.h | 2 + src/player_hud.cpp | 843 +++++ src/player_hud.h | 136 + src/player_manager.cpp | 139 +- src/player_manager.h | 10 + src/rail_manager.cpp | 115 + src/rail_manager.h | 39 + src/room.cpp | 1750 +++++++-- src/room.h | 51 +- src/room_render.cpp | 1158 ++++++ src/room_render.h | 53 + src/room_transition.cpp | 1 + src/room_update.cpp | 846 +++++ src/weapon.cpp | 553 +++ src/weapon.h | 209 ++ 140 files changed, 23561 insertions(+), 20206 deletions(-) delete mode 100644 generated-src/beast_arena.cpp delete mode 100644 generated-src/entity_factory.cpp delete mode 100644 generated-src/grid_entity.cpp delete mode 100644 generated-src/grid_entity_decoration.cpp delete mode 100644 generated-src/grid_entity_door.cpp delete mode 100644 generated-src/grid_entity_fire.cpp delete mode 100644 generated-src/grid_entity_gravity.cpp delete mode 100644 generated-src/grid_entity_lock.cpp delete mode 100644 generated-src/grid_entity_pit.cpp delete mode 100644 generated-src/grid_entity_poop.cpp delete mode 100644 generated-src/grid_entity_pressure_plate.cpp delete mode 100644 generated-src/grid_entity_rock.cpp delete mode 100644 generated-src/grid_entity_spikes.cpp delete mode 100644 generated-src/grid_entity_stairs.cpp delete mode 100644 generated-src/grid_entity_statue.cpp delete mode 100644 generated-src/grid_entity_teleporter.cpp delete mode 100644 generated-src/grid_entity_tnt.cpp delete mode 100644 generated-src/grid_entity_trap_door.cpp delete mode 100644 generated-src/grid_entity_wall.cpp delete mode 100644 generated-src/grid_entity_web.cpp delete mode 100644 generated-src/isaac_repentance_plus/weapon.cpp delete mode 100644 generated-src/l_room_tile_desc.cpp delete mode 100644 generated-src/rail_manager.cpp delete mode 100644 generated-src/tear_params.cpp delete mode 100644 generated-src/weapon.cpp create mode 100644 generated-src/weapon_ludovico.cpp delete mode 100644 generated-src/weapon_tears.cpp create mode 100644 generated-src/weapon_umbilical_whip.cpp create mode 100644 src/beast_arena.cpp create mode 100644 src/beast_arena.h create mode 100644 src/entity_collision.cpp create mode 100644 src/entity_factory.cpp create mode 100644 src/entity_factory.h create mode 100644 src/entity_player_weapons.cpp create mode 100644 src/game_update.cpp create mode 100644 src/grid_entity.cpp create mode 100644 src/grid_entity.h create mode 100644 src/grid_entity_decoration.cpp create mode 100644 src/grid_entity_decoration.h create mode 100644 src/grid_entity_door.cpp create mode 100644 src/grid_entity_door.h create mode 100644 src/grid_entity_fire.cpp create mode 100644 src/grid_entity_fire.h create mode 100644 src/grid_entity_gravity.cpp create mode 100644 src/grid_entity_gravity.h create mode 100644 src/grid_entity_lock.cpp create mode 100644 src/grid_entity_lock.h create mode 100644 src/grid_entity_pit.cpp create mode 100644 src/grid_entity_pit.h create mode 100644 src/grid_entity_poop.cpp create mode 100644 src/grid_entity_poop.h create mode 100644 src/grid_entity_pressure_plate.cpp create mode 100644 src/grid_entity_pressure_plate.h create mode 100644 src/grid_entity_rock.cpp create mode 100644 src/grid_entity_rock.h create mode 100644 src/grid_entity_spikes.cpp create mode 100644 src/grid_entity_spikes.h create mode 100644 src/grid_entity_stairs.cpp create mode 100644 src/grid_entity_stairs.h create mode 100644 src/grid_entity_statue.cpp create mode 100644 src/grid_entity_statue.h create mode 100644 src/grid_entity_teleporter.cpp create mode 100644 src/grid_entity_teleporter.h create mode 100644 src/grid_entity_tnt.cpp create mode 100644 src/grid_entity_tnt.h create mode 100644 src/grid_entity_trap_door.cpp create mode 100644 src/grid_entity_trap_door.h create mode 100644 src/grid_entity_wall.cpp create mode 100644 src/grid_entity_wall.h create mode 100644 src/grid_entity_web.cpp create mode 100644 src/grid_entity_web.h create mode 100644 src/manager_input.cpp create mode 100644 src/player_hud.cpp create mode 100644 src/player_hud.h create mode 100644 src/rail_manager.cpp create mode 100644 src/rail_manager.h create mode 100644 src/room_render.cpp create mode 100644 src/room_render.h create mode 100644 src/room_update.cpp create mode 100644 src/weapon.cpp create mode 100644 src/weapon.h diff --git a/generated-src/ambush.cpp b/generated-src/ambush.cpp index 397e035..c7b2b14 100644 --- a/generated-src/ambush.cpp +++ b/generated-src/ambush.cpp @@ -103,7 +103,7 @@ void Ambush::StartChallenge() ((targetRoomType < 3 || (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 8)) != 0xb)))))))) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((door)) + 0xc)))) != 1)) { *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((door)) + 0xc)))) = 1; - (GHIDRA_CAST((door)))->GridEntity_Door::UpdateAnimation(); + GridEntity_Door::UpdateAnimation(door); currentRoomType = door->_currentRoomType; if (((((currentRoomType == 7) || (targetRoomType = door->_targetRoomType, targetRoomType == 7)) || diff --git a/generated-src/beast_arena.cpp b/generated-src/beast_arena.cpp deleted file mode 100644 index ae7627c..0000000 --- a/generated-src/beast_arena.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include "classes.h" - -// 00592260 -void BeastArena::get_scroll_speed() -{ - return; -} - -// 00839b80 -void BeastArena::init() -{ - uint8_t bVar1; - LayerState *layer; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - char *ptr; - int iVar2; - uint32_t uVar3; - uint8_t *pbVar4; - ANM2 *pAVar5; - int layer13SrcBlend; - int *unaff_FS_OFFSET; - std_string anm2Path; - uint32_t uStack_24; - int iStack_20; - int iStack_1c; - uint8_t *puStack_18; - uint32_t uStack_14; - int *roomConfig; - - iStack_20 = GHIDRA_INT(register0x00000010) + -4; - uStack_14 = 0xffffffff; - puStack_18 = &LAB_00af18ad; - iStack_1c = *unaff_FS_OFFSET; - uStack_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U; - *unaff_FS_OFFSET = GHIDRA_INT(&iStack_1c); - roomConfig = *GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST(this) + 4)) + 0x10)); - if (((roomConfig == GHIDRA_CAST(0x0)) || (roomConfig[2] != 0x10)) || (*roomConfig != 0x23)) { - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x118)) = 0; - } - else { - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x118)) = 1; - iVar2 = GHIDRA_INT(register0x00000010) + -4; - if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x10d)) == '\0') { - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x30); - anm2Path._size = 0x21; - anm2Path._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/backdrop/hell/background.anm2",0x22); - uStack_14 = 0; - ANM2::Load(GHIDRA_CAST((GHIDRA_INT(this) + 4)),&anm2Path,0); - uStack_14 = 0xffffffff; - bVar1 = extraout_CL; - if (0xf < anm2Path._capacity) { - uVar3 = anm2Path._capacity + 1; - ptr = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - ptr = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar3 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(ptr,uVar3); - bVar1 = extraout_CL_00; - } - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x114)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x114)) | 0x200; - ANM2::LoadGraphics(GHIDRA_CAST((GHIDRA_INT(this) + 4)),bVar1); - pbVar4 = GHIDRA_CAST((GHIDRA_INT(this) + 0x1c)); - if (0xf < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x30))) { - pbVar4 = *GHIDRA_CAST(pbVar4); - } - bVar1 = ANM2::SetAnimation(GHIDRA_CAST((GHIDRA_INT(this) + 4)),pbVar4,1); - iVar2 = iStack_20; - if (bVar1 != 0) { - AnimationState::Rewind(GHIDRA_CAST((GHIDRA_INT(this) + 0x34))); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)) = 1; - iVar2 = iStack_20; - } - } - iStack_20 = iVar2; - pbVar4 = GHIDRA_CAST(0x0); - if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x84)) != 0) { - do { - layer = ANM2::GetLayer(GHIDRA_CAST((GHIDRA_INT(this) + 4)),pbVar4); - pbVar4 = pbVar4 + 1; - layer->_wrapSMode = 0; - layer->_wrapTMode = 1; - } while (pbVar4 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x84))); - } - pAVar5 = GHIDRA_CAST((GHIDRA_INT(this) + 4)); - layer = ANM2::GetLayer(pAVar5,GHIDRA_CAST(0x0)); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,GHIDRA_CAST(0x1)); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,GHIDRA_CAST(0x2)); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,GHIDRA_CAST(0x3)); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,&DAT_00000004); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,&DAT_00000005); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,&DAT_00000006); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,&DAT_00000007); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - uVar3 = g_graphicsManager_flags; - layer = ANM2::GetLayer(pAVar5,&DAT_00000008); - layer13SrcBlend = 1; - iVar2 = 1; - if ((uVar3 & 4) == 0) { - iVar2 = 6; - } - layer->_blendMode[0] = 0; - layer->_blendMode[1] = iVar2; - layer->_blendMode[2] = 7; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 7; - pAVar5 = GHIDRA_CAST((GHIDRA_INT(this) + 4)); - layer = ANM2::GetLayer(pAVar5,&DAT_00000009); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,GHIDRA_CAST(0xa)); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,&DAT_0000000b); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - layer = ANM2::GetLayer(pAVar5,GHIDRA_CAST(0xc)); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 1; - layer->_blendMode[2] = 0; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 0; - uVar3 = g_graphicsManager_flags; - layer = ANM2::GetLayer(GHIDRA_CAST((GHIDRA_INT(this) + 4)),&DAT_0000000d); - if ((uVar3 & 4) == 0) { - layer13SrcBlend = 6; - } - layer->_blendMode[0] = 0; - layer->_blendMode[1] = layer13SrcBlend; - layer->_blendMode[2] = 1; - layer->_blendMode[3] = 1; - layer->_blendMode[4] = 1; - layer = ANM2::GetLayer(GHIDRA_CAST((GHIDRA_INT(this) + 4)),&DAT_0000000e); - layer->_blendMode[0] = 0; - layer->_blendMode[1] = 0; - layer->_blendMode[2] = 2; - layer->_blendMode[3] = 0; - layer->_blendMode[4] = 2; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x11c)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x120)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x124)) = 0; - } - *unaff_FS_OFFSET = iStack_1c; - return; -} - -// 0083a080 -void BeastArena::update() -{ - Entity *this_00; - uint32_t i; - float shiftX; - int entityType; - int room; - - if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x118)) != '\0') { - if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x10d)) != '\0') { - AnimationState::Update(GHIDRA_CAST((GHIDRA_INT(this) + 0x34))); - AnimationState::Update(GHIDRA_CAST((GHIDRA_INT(this) + 0x54))); - } - i = 0; - shiftX = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x120)) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x124)); - room = *GHIDRA_CAST(this); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x11c)) = shiftX; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x124)) = shiftX; - if (*GHIDRA_CAST((room + 0x1264)) != 0) { - do { - this_00 = *GHIDRA_CAST((*GHIDRA_CAST((room + 0x125c)) + i * 4)); - entityType = this_00->_type; - if (entityType == 1) { -LAB_0083a185: - Entity::PlayerCollideWithGrid(this_00,0); - } - else { - if (entityType != 3) { - shiftX = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x120)); - if (this_00->_sortingLayer == 0) { - shiftX = shiftX * 0.1; - } - (this_00->_pos).x = shiftX + (this_00->_pos).x; - (this_00->_pos).y = (this_00->_pos).y + 0.0; - if ((entityType == 0x3b7) && (this_00->_variant == 1)) { - (this_00->_targetPosition).x = - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x120)) + (this_00->_targetPosition).x; - (this_00->_targetPosition).y = (this_00->_targetPosition).y + 0.0; - } - } - if (entityType == 1) goto LAB_0083a185; - } - i = i + 1; - } while (i < *GHIDRA_CAST((room + 0x1264))); - } - } - return; -} - -// 0083a1b0 -void BeastArena::render_light() -{ - char cVar1; - uint32_t uVar2; - LayerState *this; - int *in_ECX; - KColor *color; - int unused; - uint8_t colorQuad [112]; - uint8_t sourceQuad [36]; - KColor white; - float lightOffsetX; - int *texture; - int *textureRefCount; - Vector sourcePos; - Vector screenSize; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - int room; - - local_8 = 0xffffffff; - puStack_c = &LAB_00b0266d; - local_10 = ExceptionList; - uVar2 = __security_cookie ^ GHIDRA_UINT((sourceQuad + 0x60)); - ExceptionList = &local_10; - g_graphicsManager_blendMode[0] = 0; - g_graphicsManager_blendMode[1] = 1; - g_graphicsManager_blendMode[2] = 7; - if (((uint8_t)g_graphicsManager_flags & 4) == 0) { - g_graphicsManager_blendMode[1] = 6; - } - g_graphicsManager_blendMode[3] = 1; - g_graphicsManager_blendMode[4] = 7; - room = *in_ECX; - lightOffsetX = (((*GHIDRA_CAST((room + 0x6ae8)) - *GHIDRA_CAST((room + 0x6ae0))) + 52.0) - 480.0) * 0.5 + - *GHIDRA_CAST((room + 0x11fc)) + *GHIDRA_CAST((room + 0x1204)) + - (g_game->_screenShakeOffset).x + 26.0; - sourcePos.y = (((*GHIDRA_CAST((room + 0x6aec)) - *GHIDRA_CAST((room + 0x6ae4))) + 52.0) - 270.0) * 0.5 + - *GHIDRA_CAST((room + 0x1200)) + *GHIDRA_CAST((room + 0x1208)) + - (g_game->_screenShakeOffset).y + 26.0; - this = ANM2::GetLayer(GHIDRA_CAST((in_ECX + 1)),GHIDRA_CAST(0x10)); - LayerState::GetTexture(this,&texture); - local_8 = 0; - if (texture != GHIDRA_CAST(0x0)) { - (GHIDRA_CAST((&white)))->KColor::SetFromARGB(0xffffffff); - screenSize.x = g_screenWidth; - screenSize.y = g_screenHeight; - render_quad_set_rect(colorQuad,&g_vectorZero,&screenSize,color); - sourcePos.x = DAT_00c5d170 - lightOffsetX; - screenSize.x = g_screenWidth; - screenSize.y = g_screenHeight; - sourcePos.y = DAT_00c5d174 - sourcePos.y; - quad_set_rect(sourceQuad,&sourcePos,&screenSize,unused); - (**(code **)(*texture + 0x14))(sourceQuad,colorQuad,g_drawRectUnset); - } - local_8 = 1; - if (textureRefCount != GHIDRA_CAST(0x0)) { - cVar1 = (**(code **)(*textureRefCount + 0xc))(uVar2); - if ((cVar1 != '\0') && (g_imageReleaseFn != (void *)0x0)) { - (*g_imageReleaseFn)(&texture); - } - } - ExceptionList = local_10; - return; -} diff --git a/generated-src/classes.h b/generated-src/classes.h index eb505df..2cd587c 100644 --- a/generated-src/classes.h +++ b/generated-src/classes.h @@ -216,6 +216,7 @@ struct EntityList; struct EntityList_EL; struct EntityList_Query; struct EntityPartition; +struct EntityPool; struct EntityPtr; struct EntityRef; struct EntitySaveState; @@ -247,6 +248,7 @@ struct FamiliarData; struct File; struct FileSymbolInfo; struct FileSystem; +struct FireEmber; struct Font; struct FontCharBlock; struct FontGlyph; @@ -294,6 +296,7 @@ struct GridEntity_Teleporter; struct GridEntity_TrapDoor; struct GridEntity_Wall; struct GridEntity_Web; +struct GridHurt; struct GroupIconResource; struct HBITMAP__; struct HBRUSH__; @@ -465,6 +468,7 @@ struct PngWriter; struct PocketItem; struct PocketItemConfig; struct Point; +struct PoolDesc; struct PoolItem; struct Popup; struct PopupButton; @@ -485,6 +489,7 @@ struct Quad; struct QueueItemData; struct RNG; struct RailManager; +struct RainSpawner; struct RebirthSaveData; struct RedirectedPath; struct ReferenceCountBase; @@ -508,12 +513,14 @@ struct RoomConfig_Stage; struct RoomConfig_VariantSet; struct RoomDescriptor; struct RoomEntry; +struct RoomEntrySpawn; struct RoomGridPath; struct RoomPoints; struct RoomQuery; struct RoomScore; struct RoomSet; struct RoomSpawn; +struct RoomSurfaces; struct RoomTransition; struct RoomTransitionRequest; struct SFXManager; @@ -525,7 +532,9 @@ struct Shader; struct Shape; struct SharedPtr; struct SharedPtrPair; +struct Shockwave; struct ShockwaveParams; +struct ShootInput; struct SimpleString; struct Size; struct SmeltedTrinket; @@ -569,7 +578,9 @@ struct Vector; struct VectorRing; struct VentricleRazorPortal; struct VideoPlayer; +struct WaterClipInfo; struct Weapon; +struct WeaponDelete; struct Weapon_Bombs; struct Weapon_Bone; struct Weapon_Brimstone; @@ -944,14 +955,6 @@ LAYOUT32(offsetof(BeamRenderer, _useOverlayData) == 0x11c); LAYOUT32(offsetof(BeamRenderer, _unkBool) == 0x11d); LAYOUT32(sizeof(BeamRenderer) == 0x11e); -struct BeastArena { - static void get_scroll_speed(); // 00592260 - void init(); // 00839b80 - void update(); // 0083a080 - static void render_light(); // 0083a1b0 -}; - - struct BitSet128 { static BitSet128 * operator_and(BitSet128 *outResult, BitSet128 *a, BitSet128 *b); // 00417170 uint8_t IsNonZero(); // 004171b0 @@ -1331,12 +1334,6 @@ LAYOUT32(offsetof(DestinationQuad, _bottomLeft) == 0x10); LAYOUT32(offsetof(DestinationQuad, _bottomRight) == 0x18); LAYOUT32(sizeof(DestinationQuad) == 0x20); -struct EntityFactory { - Entity * Create(uint32_t type, uint8_t force); // 006f0090 - void constructor(); // 006f2a10 -}; - - struct EntityList_Query { ~EntityList_Query(); // 004175b0 }; @@ -1468,48 +1465,6 @@ struct GameOver { LAYOUT32(offsetof(GameOver, _state) == 0x0); LAYOUT32(offsetof(GameOver, _isStopSoundsPending) == 0x11c); -struct std_vector_bool { - void * _begin; - void * _end; - void * _capacity; - uint32_t _size; -}; -LAYOUT32(offsetof(std_vector_bool, _begin) == 0x0); -LAYOUT32(offsetof(std_vector_bool, _end) == 0x4); -LAYOUT32(offsetof(std_vector_bool, _capacity) == 0x8); -LAYOUT32(offsetof(std_vector_bool, _size) == 0xc); -LAYOUT32(sizeof(std_vector_bool) == 0x10); - -struct GameStateItemPool { - std_vector _poolsItemWeights[31]; - uint32_t _bibleUpgrades[31]; - uint32_t _seed; - int _lastPool; - uint32_t _itemPoolRNGseed; - uint32_t _trinketPoolRNGseed; - float _unkFloat674; - float _unkFloat678; - std_vector_bool _removedCollectibles; - std_vector_bool _trinketPoolItems; - int _pillEffects[15]; - bool _identifiedPillEffects[15]; - uint8_t _pad_0x273[0x1]; - uint8_t _remainingGenesisItems[0x4]; // uint16_t[31] -}; -LAYOUT32(offsetof(GameStateItemPool, _poolsItemWeights) == 0x0); -LAYOUT32(offsetof(GameStateItemPool, _bibleUpgrades) == 0x174); -LAYOUT32(offsetof(GameStateItemPool, _seed) == 0x1f0); -LAYOUT32(offsetof(GameStateItemPool, _lastPool) == 0x1f4); -LAYOUT32(offsetof(GameStateItemPool, _itemPoolRNGseed) == 0x1f8); -LAYOUT32(offsetof(GameStateItemPool, _trinketPoolRNGseed) == 0x1fc); -LAYOUT32(offsetof(GameStateItemPool, _unkFloat674) == 0x200); -LAYOUT32(offsetof(GameStateItemPool, _unkFloat678) == 0x204); -LAYOUT32(offsetof(GameStateItemPool, _removedCollectibles) == 0x208); -LAYOUT32(offsetof(GameStateItemPool, _trinketPoolItems) == 0x218); -LAYOUT32(offsetof(GameStateItemPool, _pillEffects) == 0x228); -LAYOUT32(offsetof(GameStateItemPool, _identifiedPillEffects) == 0x264); -LAYOUT32(offsetof(GameStateItemPool, _remainingGenesisItems) == 0x274); - struct GameStatePlayer { ~GameStatePlayer(); // 00754d90 void read_player_key(void *stream); // 009c86e0 @@ -1577,359 +1532,6 @@ LAYOUT32(offsetof(GridEntityDesc, _varData) == 0x14); LAYOUT32(offsetof(GridEntityDesc, _initialized) == 0x18); LAYOUT32(offsetof(GridEntityDesc, _variableSeed) == 0x1c); -struct RNG { - static void Shuffle(RNG *rng, int *begin, int *end); // 005cc070 - void game_constructor(uint32_t seed, uint32_t shiftidx); // 007e8f90 - void SetSeed(uint32_t Seed, uint32_t ShiftIdx); // 007e8fe0 - uint32_t RandomInt(uint32_t max); // 007e9020 - float RandomFloat(); // 007e9080 - uint32_t Next(); // 007e90f0 - - uint32_t _seed; - uint32_t _shift1; - uint32_t _shift2; - uint32_t _shift3; -}; -LAYOUT32(offsetof(RNG, _seed) == 0x0); -LAYOUT32(offsetof(RNG, _shift1) == 0x4); -LAYOUT32(offsetof(RNG, _shift2) == 0x8); -LAYOUT32(offsetof(RNG, _shift3) == 0xc); - -struct GridEntity { - virtual ~GridEntity(); // 00709cb0 slot 0 - virtual void guard_check_icall(); // 0040c200 slot 1 ::guard_check_icall - virtual void Update(); // 00af05d3 slot 2 - virtual void Render(); // 00af05d3 slot 3 - virtual uint8_t Hurt(); // 006a80c0 slot 4 - virtual uint8_t Destroy(uint8_t isImmediate); // 00709c10 slot 5 - virtual void * GetWaterClipInfo(void *outInfo); // 00709f90 slot 6 GridEntity_Wall::GetWaterClipInfo - virtual uint8_t CanTakeDamageFromTearEffects(); // 00709c30 slot 7 - virtual void BeginBatches(); // 00af05d3 slot 8 - int GetType(); // 004073c0 - ANM2 * GetSprite(); // 00428930 - int GetVariant(); // 0043eec0 - int GetGridIndex(); // 004e4830 - int VarData(); // 0067efc0 - static void SetType(uint32_t param_1); // 00709c00 - GridEntity(); // 00709c40 - void Init(uint32_t Seed); // 00709db0 - Vector * Position(Vector *outPosition); // 00709df0 - Vector * get_render_position(Vector *outPosition); // 00709e50 - uint8_t IsBreakableRock(); // 0070b2a0 - GridEntity * InitSubclass(uint32_t flags); // 0070ba00 - uint8_t IsEasyCrushableOrWalkable(); // 0070bec0 - uint8_t IsDangerousCrushableOrWalkable(); // 0070bf10 - void SetVariant(int variant); // 00738140 - static void trigger_output(GridEntity *gridEntity); // 00823150 - RNG * GetRNG(); // 0085dda0 - static void HurtWithSource(); // 008c5cd9 - static void PostInit(); // 008c5ce8 - - uint8_t _desc[0x14]; // GridEntityDesc - int _varData; - uint8_t _pad_0x1c[0x8]; - unsigned int _gridIndex; - unsigned int _spawnFrame; - RNG _rng; - int _collisionClass; - uint8_t _sprite[0x114]; // ANM2 -}; -LAYOUT32(offsetof(GridEntity, _desc) == 0x4); -LAYOUT32(offsetof(GridEntity, _varData) == 0x18); -LAYOUT32(offsetof(GridEntity, _gridIndex) == 0x24); -LAYOUT32(offsetof(GridEntity, _spawnFrame) == 0x28); -LAYOUT32(offsetof(GridEntity, _rng) == 0x2c); -LAYOUT32(offsetof(GridEntity, _collisionClass) == 0x3c); -LAYOUT32(offsetof(GridEntity, _sprite) == 0x40); -LAYOUT32(sizeof(GridEntity) == 0x154); - -struct GridEntity_Decoration : GridEntity { - void Update() override; // 0099a8e0 slot 2 - void Render() override; // 0099ac00 slot 3 - void * GetWaterClipInfo(void *outInfo) override; // 00714750 slot 6 GridEntity_Web::GetWaterClipInfo - void BeginBatches() override; // 0099acc0 slot 8 -}; -LAYOUT32(sizeof(GridEntity_Decoration) == 0x154); - -struct GridEntity_Door : GridEntity { - virtual ~GridEntity_Door(); // 0070bb20 slot 0 - void Update() override; // 0070c5c0 slot 2 - void Render() override; // 0070d1e0 slot 3 - uint8_t Destroy(uint8_t isImmediate) override; // 0070f5e0 slot 5 - void * GetWaterClipInfo(void *outInfo) override; // 00711720 slot 6 - uint8_t CanTakeDamageFromTearEffects() override; // 0070f670 slot 7 - void BeginBatches() override; // 00711590 slot 8 - uint8_t IsOpen(); // 00435fc0 - uint8_t IsLocked(); // 00435fd0 - int Direction(); // 005cd5e0 - uint8_t IsRoomType(int roomType); // 005cd5f0 - int TargetRoomIndex(); // 0060cfe0 - static bool IsKeyFamiliarTarget(); // 0060cff0 - int get_secret_exit_kind(); // 0070d360 - void LoadSprite(); // 0070d3f0 - void UpdateAnimation(); // 0070ee40 - uint32_t CanBlowOpen(); // 0070f680 - void SpawnDust(); // 0070f810 - uint8_t TryBlowOpen(uint8_t isFromExplosion, Entity *source); // 0070fb60 - uint8_t TryUnlock(Entity_Player *player, uint8_t isForce); // 00710480 - void Close(uint8_t isForce); // 00710d30 - void Bar(); // 00710d90 - void Open(); // 00710dd0 - void SetRoomTypes(int CurrentRoomType, int TargetRoomType); // 00710fa0 - void SetLocked(uint8_t isLocked); // 00711630 - uint32_t IsTargetRoomArcade(); // 00711690 - uint8_t IsBusted(); // 00738170 - int Slot(); // 00833290 - Vector * GetSpriteOffset(); // 0085e0b0 - - int _updateCount; - int _slot; - int _currentRoomType; - int _targetRoomType; - int _direction; - uint8_t _sparkleSprite[0x114]; // ANM2 - uint8_t _extraSprite[0x114]; // ANM2 - bool _isExtraVisible; - bool _isBusted; - bool _isUnlockedByPlayer; - uint8_t _pad_0x393[0x1]; - int _targetRoomIdx; - uint32_t _previousState; - uint32_t _previousVariant; - uint32_t _doorFlags; - std_string _openAnimation; - std_string _closeAnimation; - std_string _lockedAnimation; - std_string _openLockedAnimation; -}; -LAYOUT32(offsetof(GridEntity_Door, _updateCount) == 0x154); -LAYOUT32(offsetof(GridEntity_Door, _slot) == 0x158); -LAYOUT32(offsetof(GridEntity_Door, _currentRoomType) == 0x15c); -LAYOUT32(offsetof(GridEntity_Door, _targetRoomType) == 0x160); -LAYOUT32(offsetof(GridEntity_Door, _direction) == 0x164); -LAYOUT32(offsetof(GridEntity_Door, _sparkleSprite) == 0x168); -LAYOUT32(offsetof(GridEntity_Door, _extraSprite) == 0x27c); -LAYOUT32(offsetof(GridEntity_Door, _isExtraVisible) == 0x390); -LAYOUT32(offsetof(GridEntity_Door, _isBusted) == 0x391); -LAYOUT32(offsetof(GridEntity_Door, _isUnlockedByPlayer) == 0x392); -LAYOUT32(offsetof(GridEntity_Door, _targetRoomIdx) == 0x394); -LAYOUT32(offsetof(GridEntity_Door, _previousState) == 0x398); -LAYOUT32(offsetof(GridEntity_Door, _previousVariant) == 0x39c); -LAYOUT32(offsetof(GridEntity_Door, _doorFlags) == 0x3a0); -LAYOUT32(offsetof(GridEntity_Door, _openAnimation) == 0x3a4); -LAYOUT32(offsetof(GridEntity_Door, _closeAnimation) == 0x3bc); -LAYOUT32(offsetof(GridEntity_Door, _lockedAnimation) == 0x3d4); -LAYOUT32(offsetof(GridEntity_Door, _openLockedAnimation) == 0x3ec); -LAYOUT32(sizeof(GridEntity_Door) == 0x404); - -struct GridEntity_Fire : GridEntity { - virtual ~GridEntity_Fire(); // 0070ba00 slot 0 GridEntity::InitSubclass - void Update() override; // 0067e0f0 slot 2 - void Render() override; // 0067e880 slot 3 - uint8_t Hurt() override; // 0067ea60 slot 4 - void BeginBatches() override; // 0067db00 slot 8 - - uint8_t _pad_0x154[0x23c]; -}; -LAYOUT32(sizeof(GridEntity_Fire) == 0x390); - -struct GridEntity_Gravity : GridEntity { - void guard_check_icall() override; // 0099b520 slot 1 - void Update() override; // 0099b980 slot 2 - void Render() override; // 0071edb0 slot 3 GridEntity::Render - void BeginBatches() override; // 0099b510 slot 8 -}; -LAYOUT32(sizeof(GridEntity_Gravity) == 0x154); - -struct GridEntity_Lock : GridEntity { - virtual ~GridEntity_Lock(); // 0070bdd0 slot 0 - void Update() override; // 00711950 slot 2 - void Render() override; // 00711f30 slot 3 GridEntity_Teleporter::Render - void * GetWaterClipInfo(void *outInfo) override; // 00712090 slot 6 - void BeginBatches() override; // 00711780 slot 8 - void try_unlock(Entity_Player *player, uint8_t isForce); // 00711af0 - void break_open(Entity_Player *player); // 00711bb0 - - uint8_t _pad_0x154[0x4]; -}; -LAYOUT32(sizeof(GridEntity_Lock) == 0x158); - -struct GridEntity_Pit : GridEntity { - virtual ~GridEntity_Pit(); // 007120d0 slot 0 - void guard_check_icall() override; // 00714320 slot 1 - void Update() override; // 00712180 slot 2 - void Render() override; // 00713440 slot 3 - void * GetWaterClipInfo(void *outInfo) override; // 00714750 slot 6 GridEntity_Web::GetWaterClipInfo - void BeginBatches() override; // 00713760 slot 8 - void update_sprite_edges(); // 00713ee0 - void UpdateCollision(); // 00714610 - void SetLadder(uint8_t isLadder); // 007146e0 - static void MakeBridge(int param_1, int param_2); // 00714700 - - bool _hasLadder; - uint8_t _pad_0x155[0x3]; -}; -LAYOUT32(offsetof(GridEntity_Pit, _hasLadder) == 0x154); -LAYOUT32(sizeof(GridEntity_Pit) == 0x158); - -struct GridEntity_Poop : GridEntity { - virtual ~GridEntity_Poop(); // 0070bc60 slot 0 - void guard_check_icall() override; // 00718dd0 slot 1 - void Update() override; // 00714770 slot 2 - void Render() override; // 007151e0 slot 3 - uint8_t Hurt() override; // 00715330 slot 4 - void * GetWaterClipInfo(void *outInfo) override; // 007166b0 slot 6 - void BeginBatches() override; // 00715940 slot 8 - void ReduceSpawnRate(); // 00456870 - void RespawnRedPoop(); // 007166f0 - static void spawn_hit_gibs(Vector *position, int poopVariant, int maxGibs); // 00716760 - static void destroy_effects(); // 00716b10 - GridEntity_Poop * get_giga_part(int variant, uint8_t isCreate); // 00718ac0 - - int _reviveTimer; - std_string _stateAnimation; - bool _isUnderPlayer; - uint8_t _pad_0x171[0x2b]; -}; -LAYOUT32(offsetof(GridEntity_Poop, _reviveTimer) == 0x154); -LAYOUT32(offsetof(GridEntity_Poop, _stateAnimation) == 0x158); -LAYOUT32(offsetof(GridEntity_Poop, _isUnderPlayer) == 0x170); -LAYOUT32(sizeof(GridEntity_Poop) == 0x19c); - -struct GridEntity_PressurePlate : GridEntity { - virtual ~GridEntity_PressurePlate(); // 0070bd00 slot 0 - void Update() override; // 00983330 slot 2 - void Render() override; // 00985c10 slot 3 - void * GetWaterClipInfo(void *outInfo) override; // 00986430 slot 6 - void BeginBatches() override; // 00985f00 slot 8 - void update_press(); // 009833c0 - void update_greed_button_anim(uint8_t isRed); // 009837b0 - void play_pending_animation(); // 009838c0 - void update_greed_button(); // 009839f0 - void Reward(); // 00984550 - - uint8_t _timerPlate[0x114]; // ANM2 - char* _nextGreedAnimation; - RNG _greedModeRNG; -}; -LAYOUT32(offsetof(GridEntity_PressurePlate, _timerPlate) == 0x154); -LAYOUT32(offsetof(GridEntity_PressurePlate, _nextGreedAnimation) == 0x268); -LAYOUT32(offsetof(GridEntity_PressurePlate, _greedModeRNG) == 0x26c); -LAYOUT32(sizeof(GridEntity_PressurePlate) == 0x27c); - -struct GridEntity_Rock : GridEntity { - virtual ~GridEntity_Rock(); // 0070b950 slot 0 GridEntity_Fire::InitSubclass - void guard_check_icall() override; // 0071a760 slot 1 - void Update() override; // 00718fe0 slot 2 - void Render() override; // 00719ad0 slot 3 - uint8_t Destroy(uint8_t isImmediate) override; // 007197d0 slot 5 - void * GetWaterClipInfo(void *outInfo) override; // 0071deb0 slot 6 - void BeginBatches() override; // 00719f80 slot 8 - uint8_t * GetRubbleAnim(); // 005cd820 - void update_collision(); // 00718f80 - void RenderTop(Vector *pos); // 00719dd0 - void SetBigRockFrame(uint32_t param_2); // 0071a940 - int GetBigRockFrame(); // 0071aa70 - void UpdateAnimFrame(); // 0071aa90 - void UpdateNeighbors(); // 0071aaf0 - static void RegisterRockDestroyed(int GridEntityType); // 0071af10 - void TrySpawnWorms(); // 0071af60 - static void PlayBreakSound(int GridEntityType, int BackdropType); // 0071b100 - uint8_t TrySpawnLadder(); // 0071b1c0 - - std_string _anim; - std_string _rubbleAnim; - std_vector _rubbleOffsets; - int _frameCnt; - uint8_t _pad_0x194[0x4]; -}; -LAYOUT32(offsetof(GridEntity_Rock, _anim) == 0x154); -LAYOUT32(offsetof(GridEntity_Rock, _rubbleAnim) == 0x16c); -LAYOUT32(offsetof(GridEntity_Rock, _rubbleOffsets) == 0x184); -LAYOUT32(offsetof(GridEntity_Rock, _frameCnt) == 0x190); -LAYOUT32(sizeof(GridEntity_Rock) == 0x198); - -struct GridEntity_Spikes : GridEntity { - virtual ~GridEntity_Spikes(); // 0070bdd0 slot 0 GridEntity_Lock::Free - void Update() override; // 0071e9b0 slot 2 - void Render() override; // 0071edb0 slot 3 GridEntity::Render - void BeginBatches() override; // 0071dfc0 slot 8 - uint8_t is_disabled(); // 0071e920 - void unsummon(uint8_t isInstant); // 0071eb30 - - int _timeout; -}; -LAYOUT32(offsetof(GridEntity_Spikes, _timeout) == 0x154); -LAYOUT32(sizeof(GridEntity_Spikes) == 0x158); - -struct GridEntity_Stairs : GridEntity { - void Update() override; // 0099bd50 slot 2 - void Render() override; // 0071edb0 slot 3 GridEntity::Render - void * GetWaterClipInfo(void *outInfo) override; // 00714750 slot 6 GridEntity_Web::GetWaterClipInfo - void BeginBatches() override; // 0099bad0 slot 8 -}; -LAYOUT32(sizeof(GridEntity_Stairs) == 0x154); - -struct GridEntity_Statue : GridEntity { - virtual ~GridEntity_Statue(); // 0070bdd0 slot 0 GridEntity_Lock::Free - void Update() override; // 00838520 slot 2 - void Render() override; // 0042cdf0 slot 3 - uint8_t Destroy(uint8_t isImmediate) override; // 00838560 slot 5 - void BeginBatches() override; // 00838ae0 slot 8 - - uint8_t _pad_0x154[0x4]; -}; -LAYOUT32(sizeof(GridEntity_Statue) == 0x158); - -struct GridEntity_TNT : GridEntity { - virtual ~GridEntity_TNT(); // 0070bdd0 slot 0 GridEntity_Lock::Free - void Update() override; // 0071f090 slot 2 - void Render() override; // 0071edb0 slot 3 GridEntity::Render - uint8_t Hurt() override; // 0071f250 slot 4 - uint8_t Destroy(uint8_t isImmediate) override; // 0071f2b0 slot 5 - void BeginBatches() override; // 0071ee90 slot 8 - - int _frameCnt; -}; -LAYOUT32(offsetof(GridEntity_TNT, _frameCnt) == 0x154); -LAYOUT32(sizeof(GridEntity_TNT) == 0x158); - -struct GridEntity_Teleporter : GridEntity { - void Update() override; // 00838c30 slot 2 - void Render() override; // 00711f30 slot 3 - void * GetWaterClipInfo(void *outInfo) override; // 00714750 slot 6 GridEntity_Web::GetWaterClipInfo - void BeginBatches() override; // 00838eb0 slot 8 -}; -LAYOUT32(sizeof(GridEntity_Teleporter) == 0x154); - -struct GridEntity_TrapDoor : GridEntity { - virtual ~GridEntity_TrapDoor(); // 0070bdd0 slot 0 GridEntity_Lock::Free - void Update() override; // 0071fef0 slot 2 - void Render() override; // 0071edb0 slot 3 GridEntity::Render - void * GetWaterClipInfo(void *outInfo) override; // 00714750 slot 6 GridEntity_Web::GetWaterClipInfo - void BeginBatches() override; // 0071f630 slot 8 - - uint8_t _pad_0x154[0x4]; -}; -LAYOUT32(sizeof(GridEntity_TrapDoor) == 0x158); - -struct GridEntity_Wall : GridEntity { - void guard_check_icall() override; // 00721310 slot 1 - void Update() override; // 0040c200 slot 2 ::guard_check_icall - void Render() override; // 00720fe0 slot 3 - void BeginBatches() override; // 007210d0 slot 8 -}; -LAYOUT32(sizeof(GridEntity_Wall) == 0x154); - -struct GridEntity_Web : GridEntity { - void Update() override; // 00721780 slot 2 - void Render() override; // 0071edb0 slot 3 GridEntity::Render - uint8_t Destroy(uint8_t isImmediate) override; // 00721a10 slot 5 - void * GetWaterClipInfo(void *outInfo) override; // 00714750 slot 6 - void BeginBatches() override; // 00721540 slot 8 -}; -LAYOUT32(sizeof(GridEntity_Web) == 0x154); - struct HBITMAP__ { int unused; }; @@ -3630,11 +3232,6 @@ LAYOUT32(offsetof(KerningPair, _first) == 0x4); LAYOUT32(offsetof(KerningPair, _amount) == 0x8); LAYOUT32(sizeof(KerningPair) == 0x10); -struct LRoomTileDesc { - void * GetRandomTile(void *ret, uint32_t seed); // 0081fb70 -}; - - struct LayerAnimation { LayerAnimation(); // 0040c1e0 }; @@ -4211,13 +3808,6 @@ struct PopupWindow { }; -struct PosVel { - Vector _position; - uint8_t _velocity[0x4]; // Vector -}; -LAYOUT32(offsetof(PosVel, _position) == 0x0); -LAYOUT32(offsetof(PosVel, _velocity) == 0x8); - struct ProceduralEffect { static uint8_t roll_trigger_target(uint32_t *outTarget, float *outChance, RNG *rng); // 009e0700 static uint8_t roll_spawn_target(uint32_t *outTarget, float *outChance, RNG *rng); // 009e0ad0 @@ -4289,16 +3879,23 @@ struct Quad { }; -struct RailManager { - void Render(Vector *offset); // 009e2f20 +struct RNG { + static void Shuffle(RNG *rng, int *begin, int *end); // 005cc070 + void game_constructor(uint32_t seed, uint32_t shiftidx); // 007e8f90 + void SetSeed(uint32_t Seed, uint32_t ShiftIdx); // 007e8fe0 + uint32_t RandomInt(uint32_t max); // 007e9020 + float RandomFloat(); // 007e9080 + uint32_t Next(); // 007e90f0 - void * _room; - uint8_t _pad_0x4[0x1c0]; - uint8_t _sprite[0x114]; // ANM2 + uint32_t _seed; + uint32_t _shift1; + uint32_t _shift2; + uint32_t _shift3; }; -LAYOUT32(offsetof(RailManager, _room) == 0x0); -LAYOUT32(offsetof(RailManager, _sprite) == 0x1c4); -LAYOUT32(sizeof(RailManager) == 0x2d8); +LAYOUT32(offsetof(RNG, _seed) == 0x0); +LAYOUT32(offsetof(RNG, _shift1) == 0x4); +LAYOUT32(offsetof(RNG, _shift2) == 0x8); +LAYOUT32(offsetof(RNG, _shift3) == 0xc); struct RebirthSaveData { static void Clear(); // 009e3dc0 @@ -4579,29 +4176,6 @@ struct SteamCloudFile : KAGE::Filesys::FileStream { }; LAYOUT32(sizeof(SteamCloudFile) == 0x24); -struct TearParams { - void constructor(); // 005cd690 - TearParams * operator_(TearParams *other); // 006075a0 - void copy(void *other); // 0065b490 - - int _tearVariant; - int _bombVariant; - ColorMod _tearColor; - uint8_t _pad_0x34[0x4]; - BitSet128 _flags; - uint8_t _pad_0x44[0x4]; - float _tearDamage; - float _tearScale; - float _tearHeight; -}; -LAYOUT32(offsetof(TearParams, _tearVariant) == 0x0); -LAYOUT32(offsetof(TearParams, _bombVariant) == 0x4); -LAYOUT32(offsetof(TearParams, _tearColor) == 0x8); -LAYOUT32(offsetof(TearParams, _flags) == 0x38); -LAYOUT32(offsetof(TearParams, _tearDamage) == 0x48); -LAYOUT32(offsetof(TearParams, _tearScale) == 0x4c); -LAYOUT32(offsetof(TearParams, _tearHeight) == 0x50); - struct TexturePtr { static void release(); // 0040c440 @@ -4645,275 +4219,334 @@ struct VideoPlayer { }; -struct Weapon { - virtual ~Weapon(); // 009f3260 slot 0 - virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 - virtual void Update(char param_2); // 009f34f0 slot 2 - virtual void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated); // 009f3540 slot 3 - virtual void Reset(); // 009f3480 slot 4 - virtual void ClearReferences(); // 009f3320 slot 5 - virtual long double GetMaxCharge(); // 009f3130 slot 6 - virtual long double GetChargeBarAmount(); // 009f4150 slot 7 - virtual void vfunc_8(); // 009f3130 slot 8 - virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 - virtual uint32_t GetMainEntity(); // 009f3140 slot 10 +struct Weapon_Bombs { + virtual ~Weapon_Bombs(); // 009f9880 slot 0 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *param_1, uint8_t param_2, uint8_t param_3); // 009f9b60 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 009f3320 slot 5 Weapon::ClearReferences + virtual long double GetMaxCharge(); // 009f3130 slot 6 Weapon::GetMaxCharge + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual Entity * GetFocusEntity(); // 009fa190 slot 9 + virtual Entity * GetMainEntity(); // 009f3150 slot 10 Weapon::GetMainEntity virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall - virtual uint32_t GetMarkedTargetVariant(); // 009f3140 slot 12 + virtual int GetMarkedTargetVariant(); // 009fa1b0 slot 12 + virtual uint8_t CanTakeDamageFromTearEffects(); // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects + virtual uint8_t CanShutDoors(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors + + uint8_t _pad_0x4[0x44]; +}; +LAYOUT32(sizeof(Weapon_Bombs) == 0x48); + +struct Weapon_Bone { + virtual ~Weapon_Bone(); // 009f9aa0 slot 0 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(uint8_t isInterpolated); // 009fa220 slot 2 + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 009fa450 slot 3 + virtual void Reset(); // 009fed90 slot 4 + virtual void ClearReferences(); // 009fedf0 slot 5 + virtual long double GetMaxCharge(); // 009feeb0 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual int CountSeedEffects(); // 0085e1b0 slot 9 Seeds::CountSeedEffects + virtual Entity * GetMainEntity(); // 009f3150 slot 10 Weapon::GetMainEntity + virtual void TriggerNewRoom(); // 009fef20 slot 11 + virtual uint32_t GetFocusEntity(); // 009f3140 slot 12 Weapon::GetFocusEntity + virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors + virtual uint8_t CanTriggerCursedEyeTeleport(); // 009ff1a0 slot 14 + virtual uint8_t CanTriggerKidneyStone(); // 009ff210 slot 15 + virtual uint8_t CanOverrideForgottenThrow(); // 009ff230 slot 16 + static void init_club(int *param_1); // 009ff0c0 + + uint8_t _pad_0x4[0x5c]; +}; +LAYOUT32(sizeof(Weapon_Bone) == 0x60); + +struct Weapon_Brimstone { + virtual ~Weapon_Brimstone(); // 009f9a20 slot 0 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 009ff360 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 00a02790 slot 5 + virtual long double GetMaxCharge(); // 00a00f30 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 00a02870 slot 9 + virtual uint32_t GetMainEntity(); // 009f3160 slot 10 + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual int GetMarkedTargetVariant(); // 00a02800 slot 12 virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors virtual uint8_t CanTriggerCursedEyeTeleport(); // 005ccc00 slot 14 Entity::CanShutDoors virtual uint8_t CanTriggerKidneyStone(); // 005ccc00 slot 15 Entity::CanShutDoors virtual uint8_t CanOverrideForgottenThrow(); // 005ccc00 slot 16 Entity::CanShutDoors - static uint8_t is_held_item(ANM2 *sprite, std_string *animName, void *itemDesc); // 0075a2b0 - uint8_t IsAxisAligned(); // 009f3360 - Vector * get_aim_direction(Vector *outDir, Vector *defaultDir); // 009f33e0 - Vector * get_owner_position(Vector *outPos); // 009f3bd0 - float get_damage(); // 009f3c80 - BitSet128 * get_owner_tear_flags(BitSet128 *outFlags); // 009f3d00 - ColorMod * get_tear_color(ColorMod *outColor); // 009f3db0 - ColorMod * get_laser_color(ColorMod *outColor); // 009f3f60 - void * GetMultiShotParams(void *outParams, int unusedArg); // 009f41c0 - void stop_costume_item_anim(int collectibleId); // 009f4ff0 - uint8_t IsItemAnimFinished(uint32_t collectibleID); // 009f50f0 - uint8_t is_c_section_anim_finished(int unused); // 009f5510 - void SetBlinkTime(int delay, int unused); // 009f56c0 - void SetHeadLockTime(int Time); // 009f5720 - void set_head_direction(int direction); // 009f5780 - Vector * get_tear_movement_inheritance(Vector *outResult, Vector *direction); // 009f5890 - Vector * GetOwnerLaserOffset(Vector *outOffset, int laserOffsetId, Vector *direction); // 009f5a30 - Entity_Tear * fire_tear(Vector *position, Vector *velocity, uint32_t flags, int unused, float damageMultiplier, float positionStep); // 009f5ad0 - static Entity_Bomb * fire_bomb(Weapon *weapon, Vector *position, Vector *velocity); // 009f5d60 - Entity_Laser * fire_brimstone_with_color(Vector *direction, float damageMult, uint32_t unk2); // 009f6570 - Entity_Laser * fire_laser(Vector *position, uint32_t offsetId, Vector *direction, uint8_t isLeftEye, uint8_t isOneHit, float damageScale); // 009f6610 - Entity_Knife * fire_knife(Entity *parent, uint32_t variant, uint8_t isCantOverwrite, int unused1, int unused2, float rotationOffset); // 009f6a60 - Entity_Knife * FireSword(Entity *param_2, uint32_t param_3, float param_4, uint8_t param_5, uint8_t param_6, uint32_t param_7, Entity *param_8); // 009f6c50 - void TriggerTearEffects(Vector *direction, int count); // 009f7930 - - Entity* _owner; - uint8_t _technology2Laser[0x2c]; // EntityPtr - uint32_t _modifiers; - uint8_t _pad_0x38[0xc]; -}; -LAYOUT32(offsetof(Weapon, _owner) == 0x4); -LAYOUT32(offsetof(Weapon, _technology2Laser) == 0x8); -LAYOUT32(offsetof(Weapon, _modifiers) == 0x34); -LAYOUT32(sizeof(Weapon) == 0x44); - -struct Weapon_Bombs : Weapon { - virtual ~Weapon_Bombs(); // 009f9880 slot 0 - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 009f9b60 slot 3 - uint32_t GetFocusEntity() override; // 009fa190 slot 9 - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity - uint32_t GetMarkedTargetVariant() override; // 009fa1b0 slot 12 - uint8_t CanShutDoors() override; // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects - - uint8_t _pad_0x44[0x4]; -}; -LAYOUT32(sizeof(Weapon_Bombs) == 0x48); - -struct Weapon_Bone : Weapon { - virtual ~Weapon_Bone(); // 009f9aa0 slot 0 - void Update(char param_2) override; // 009fa220 slot 2 - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 009fa450 slot 3 - void Reset() override; // 009fed90 slot 4 - void ClearReferences() override; // 009fedf0 slot 5 - long double GetMaxCharge() override; // 009feeb0 slot 6 - uint32_t GetFocusEntity() override; // 0085e1b0 slot 9 Seeds::CountSeedEffects - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity - void guard_check_icall() override; // 009fef20 slot 11 - uint8_t CanTriggerCursedEyeTeleport() override; // 009ff1a0 slot 14 - uint8_t CanTriggerKidneyStone() override; // 009ff210 slot 15 - uint8_t CanOverrideForgottenThrow() override; // 009ff230 slot 16 - static void init_club(int *param_1); // 009ff0c0 - - uint8_t _pad_0x44[0x1c]; -}; -LAYOUT32(sizeof(Weapon_Bone) == 0x60); - -struct Weapon_Brimstone : Weapon { - virtual ~Weapon_Brimstone(); // 009f9a20 slot 0 - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 009ff360 slot 3 - void ClearReferences() override; // 00a02790 slot 5 - long double GetMaxCharge() override; // 00a00f30 slot 6 - uint32_t GetFocusEntity() override; // 00a02870 slot 9 - uint32_t GetMainEntity() override; // 009f3160 slot 10 - uint32_t GetMarkedTargetVariant() override; // 00a02800 slot 12 void fire_c_section_fetuses(); // 00a00d10 void init_laser(Entity_Laser *laser); // 00a00f90 void fire(float Speed, uint8_t IgnoreStatusEffects); // 00a02890 - uint8_t _pad_0x44[0x4]; + uint8_t _pad_0x4[0x44]; uint8_t _mainLaser[0x4]; // EntityPtr }; LAYOUT32(offsetof(Weapon_Brimstone, _mainLaser) == 0x48); LAYOUT32(sizeof(Weapon_Brimstone) == 0x4c); -struct Weapon_Deathmatch : Weapon { - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a031b0 slot 3 - long double GetMaxCharge() override; // 00a036b0 slot 6 +struct Weapon_Deathmatch { + virtual ~Weapon_Deathmatch(); // 009f3260 slot 0 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a031b0 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 009f3320 slot 5 Weapon::ClearReferences + virtual float GetMaxCharge(); // 00a036b0 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 Weapon::GetFocusEntity + virtual void vfunc_10(); // 009f3140 slot 10 Weapon::GetFocusEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual void vfunc_12(); // 009f3140 slot 12 Weapon::GetFocusEntity + virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors + virtual void vfunc_14(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors + + uint8_t _pad_0x4[0x40]; }; LAYOUT32(sizeof(Weapon_Deathmatch) == 0x44); -struct Weapon_Fetus : Weapon { - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a036e0 slot 3 - long double GetMaxCharge() override; // 00a03f60 slot 6 - uint32_t GetMarkedTargetVariant() override; // 009fa1b0 slot 12 Weapon_Bombs::GetMarkedTargetVariant - uint8_t CanTriggerKidneyStone() override; // 00709c30 slot 15 GridEntity::CanTakeDamageFromTearEffects +struct Weapon_Fetus { + virtual ~Weapon_Fetus(); // 009f3260 slot 0 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a036e0 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 009f3320 slot 5 Weapon::ClearReferences + virtual float GetMaxCharge(); // 00a03f60 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 Weapon::GetFocusEntity + virtual void vfunc_10(); // 009f3140 slot 10 Weapon::GetFocusEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual int GetMarkedTargetVariant(); // 009fa1b0 slot 12 Weapon_Bombs::GetMarkedTargetVariant + virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors + virtual void vfunc_14(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual uint8_t CanTakeDamageFromTearEffects(); // 00709c30 slot 15 GridEntity::CanTakeDamageFromTearEffects + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors + + uint8_t _pad_0x4[0x40]; }; LAYOUT32(sizeof(Weapon_Fetus) == 0x44); -struct Weapon_Knife : Weapon { +struct Weapon_Knife { virtual ~Weapon_Knife(); // 009f99b0 slot 0 - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a03f90 slot 3 - void ClearReferences() override; // 00a04f90 slot 5 - long double GetMaxCharge() override; // 00a05010 slot 6 - uint32_t GetFocusEntity() override; // 009fa190 slot 9 Weapon_Bombs::GetFocusEntity - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity - void guard_check_icall() override; // 009fef20 slot 11 Weapon_Bone::TriggerNewRoom - uint32_t GetMarkedTargetVariant() override; // 009fa1b0 slot 12 Weapon_Bombs::GetMarkedTargetVariant - uint8_t CanShutDoors() override; // 00a05060 slot 13 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a03f90 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 00a04f90 slot 5 + virtual float GetMaxCharge(); // 00a05010 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual Entity * GetFocusEntity(); // 009fa190 slot 9 Weapon_Bombs::GetFocusEntity + virtual Entity * GetMainEntity(); // 009f3150 slot 10 Weapon::GetMainEntity + virtual void TriggerNewRoom(); // 009fef20 slot 11 Weapon_Bone::TriggerNewRoom + virtual int GetMarkedTargetVariant(); // 009fa1b0 slot 12 Weapon_Bombs::GetMarkedTargetVariant + virtual uint8_t SupportsTractorBeam(); // 00a05060 slot 13 + virtual uint8_t CanShutDoors(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors void init_knife(Entity_Knife *knife); // 00a05070 - uint8_t _pad_0x44[0x10]; + uint8_t _pad_0x4[0x50]; }; LAYOUT32(sizeof(Weapon_Knife) == 0x54); -struct Weapon_Laser : Weapon { +struct Weapon_Laser { virtual ~Weapon_Laser(); // 009f9930 slot 0 - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a052b0 slot 3 - void Reset() override; // 00a052a0 slot 4 - void ClearReferences() override; // 00a063b0 slot 5 - long double GetMaxCharge() override; // 00a06870 slot 6 - uint32_t GetFocusEntity() override; // 009fa190 slot 9 Weapon_Bombs::GetFocusEntity - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity - uint32_t GetMarkedTargetVariant() override; // 00a02800 slot 12 Weapon_Brimstone::GetMarkedTargetVariant - uint8_t CanTriggerCursedEyeTeleport() override; // 00a068e0 slot 14 - uint8_t CanTriggerKidneyStone() override; // 00a05060 slot 15 Weapon_Knife::SupportsTractorBeam + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *param_1, uint8_t param_2, uint8_t param_3); // 00a052b0 slot 3 + virtual void Reset(); // 00a052a0 slot 4 + virtual void ClearReferences(); // 00a063b0 slot 5 + virtual long double GetMaxCharge(); // 00a06870 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual Entity * GetFocusEntity(); // 009fa190 slot 9 Weapon_Bombs::GetFocusEntity + virtual Entity * GetMainEntity(); // 009f3150 slot 10 Weapon::GetMainEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual int GetMarkedTargetVariant(); // 00a02800 slot 12 Weapon_Brimstone::GetMarkedTargetVariant + virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors + virtual uint8_t CanTriggerCursedEyeTeleport(); // 00a068e0 slot 14 + virtual uint8_t SupportsTractorBeam(); // 00a05060 slot 15 Weapon_Knife::SupportsTractorBeam + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors static void init_laser(Weapon *weapon, Entity_Laser *laser); // 00a06330 - uint8_t _pad_0x44[0xc]; + uint8_t _pad_0x4[0x4c]; }; LAYOUT32(sizeof(Weapon_Laser) == 0x50); -struct Weapon_Ludovico : Weapon { +struct Weapon_Ludovico { virtual ~Weapon_Ludovico(); // 009f9880 slot 0 Weapon_Bombs::Free - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a06a30 slot 3 - void ClearReferences() override; // 00a063b0 slot 5 Weapon_Laser::ClearReferences - uint32_t GetFocusEntity() override; // 009f3150 slot 9 Weapon::GetMainEntity - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a06a30 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 00a063b0 slot 5 Weapon_Laser::ClearReferences + virtual long double GetMaxCharge(); // 009f3130 slot 6 Weapon::GetMaxCharge + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual Entity * GetMainEntity(); // 009f3150 slot 9 Weapon::GetMainEntity + virtual void vfunc_10(); // 009f3150 slot 10 Weapon::GetMainEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual uint32_t GetFocusEntity(); // 009f3140 slot 12 Weapon::GetFocusEntity + virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors + virtual void vfunc_14(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors - uint8_t _pad_0x44[0x4]; + uint8_t _pad_0x4[0x44]; }; LAYOUT32(sizeof(Weapon_Ludovico) == 0x48); -struct Weapon_MonstrosLung : Weapon { - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a07d50 slot 3 - long double GetMaxCharge() override; // 00a08c80 slot 6 - uint32_t GetMarkedTargetVariant() override; // 00a08cd0 slot 12 - uint8_t CanShutDoors() override; // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects +struct Weapon_MonstrosLung { + virtual ~Weapon_MonstrosLung(); // 009f3260 slot 0 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(); // 00a07d50 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 009f3320 slot 5 Weapon::ClearReferences + virtual float GetMaxCharge(); // 00a08c80 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 Weapon::GetFocusEntity + virtual uint32_t GetMainEntity(); // 009f3140 slot 10 Weapon::GetFocusEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual uint32_t GetMarkedTargetVariant(); // 00a08cd0 slot 12 + virtual uint8_t CanTakeDamageFromTearEffects(); // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects + virtual uint8_t CanShutDoors(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual uint8_t CanTriggerKidneyStone(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual uint8_t CanOverrideForgottenThrow(); // 005ccc00 slot 16 Entity::CanShutDoors static void FireBurst(uint32_t param_1, int param_2); // 00a08700 + + uint8_t _pad_0x4[0x40]; }; LAYOUT32(sizeof(Weapon_MonstrosLung) == 0x44); -struct Weapon_MultiShotParams { - short numTears; - short numLanesPerEye; - float spreadAngleTears; - float spreadAngleLaser; - float speadAngleTechX; - float spreadAngleKnife; - int numEyesActive; - float multiEyeAngle; - uint8_t isCrossEyed; - uint8_t isShootingBackwards; - uint8_t isShootingSideways; - uint8_t _pad_0x1f[0x1]; - short numRandomDirTears; -}; -LAYOUT32(offsetof(Weapon_MultiShotParams, numTears) == 0x0); -LAYOUT32(offsetof(Weapon_MultiShotParams, numLanesPerEye) == 0x2); -LAYOUT32(offsetof(Weapon_MultiShotParams, spreadAngleTears) == 0x4); -LAYOUT32(offsetof(Weapon_MultiShotParams, spreadAngleLaser) == 0x8); -LAYOUT32(offsetof(Weapon_MultiShotParams, speadAngleTechX) == 0xc); -LAYOUT32(offsetof(Weapon_MultiShotParams, spreadAngleKnife) == 0x10); -LAYOUT32(offsetof(Weapon_MultiShotParams, numEyesActive) == 0x14); -LAYOUT32(offsetof(Weapon_MultiShotParams, multiEyeAngle) == 0x18); -LAYOUT32(offsetof(Weapon_MultiShotParams, isCrossEyed) == 0x1c); -LAYOUT32(offsetof(Weapon_MultiShotParams, isShootingBackwards) == 0x1d); -LAYOUT32(offsetof(Weapon_MultiShotParams, isShootingSideways) == 0x1e); -LAYOUT32(offsetof(Weapon_MultiShotParams, numRandomDirTears) == 0x20); -LAYOUT32(sizeof(Weapon_MultiShotParams) == 0x22); - -struct Weapon_Rockets : Weapon { +struct Weapon_Rockets { virtual ~Weapon_Rockets(); // 009f9880 slot 0 Weapon_Bombs::Free - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a08d40 slot 3 - void ClearReferences() override; // 00a063b0 slot 5 Weapon_Laser::ClearReferences - uint32_t GetFocusEntity() override; // 009f3150 slot 9 Weapon::GetMainEntity - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity - uint32_t GetMarkedTargetVariant() override; // 00a099a0 slot 12 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *aimDirection, uint8_t isShooting, uint8_t isInterpolated); // 00a08d40 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 00a063b0 slot 5 Weapon_Laser::ClearReferences + virtual long double GetMaxCharge(); // 009f3130 slot 6 Weapon::GetMaxCharge + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual Entity * GetMainEntity(); // 009f3150 slot 9 Weapon::GetMainEntity + virtual void vfunc_10(); // 009f3150 slot 10 Weapon::GetMainEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual int GetMarkedTargetVariant(); // 00a099a0 slot 12 + virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors + virtual void vfunc_14(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors - uint8_t _pad_0x44[0x4]; + uint8_t _pad_0x4[0x44]; }; LAYOUT32(sizeof(Weapon_Rockets) == 0x48); -struct Weapon_SpiritSword : Weapon { +struct Weapon_SpiritSword { virtual ~Weapon_SpiritSword(); // 009f9930 slot 0 Weapon_Laser::Free - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a099e0 slot 3 - void Reset() override; // 00a0a6f0 slot 4 - void ClearReferences() override; // 00a063b0 slot 5 Weapon_Laser::ClearReferences - long double GetMaxCharge() override; // 00a0a700 slot 6 - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a099e0 slot 3 + virtual void Reset(); // 00a0a6f0 slot 4 + virtual void ClearReferences(); // 00a063b0 slot 5 Weapon_Laser::ClearReferences + virtual long double GetMaxCharge(); // 00a0a700 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 Weapon::GetFocusEntity + virtual Entity * GetMainEntity(); // 009f3150 slot 10 Weapon::GetMainEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual void vfunc_12(); // 009f3140 slot 12 Weapon::GetFocusEntity + virtual uint8_t CanShutDoors(); // 005ccc00 slot 13 Entity::CanShutDoors + virtual void vfunc_14(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors - uint8_t _pad_0x44[0xc]; + uint8_t _pad_0x4[0x4c]; }; LAYOUT32(sizeof(Weapon_SpiritSword) == 0x50); -struct Weapon_Tears : Weapon { - virtual ~Weapon_Tears(); // 009f9900 slot 0 - void Update(char param_2) override; // 00a0d870 slot 2 - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a0a720 slot 3 - void Reset() override; // 00a0d850 slot 4 - long double GetMaxCharge() override; // 00a0d8e0 slot 6 - uint32_t GetMarkedTargetVariant() override; // 009fa1b0 slot 12 Weapon_Bombs::GetMarkedTargetVariant - uint8_t CanShutDoors() override; // 00a05060 slot 13 Weapon_Knife::SupportsTractorBeam - uint8_t CanTriggerCursedEyeTeleport() override; // 00a0d950 slot 14 - uint8_t CanTriggerKidneyStone() override; // 00a05060 slot 15 Weapon_Knife::SupportsTractorBeam +struct Weapon_TechX { + virtual ~Weapon_TechX(); // 009f3260 slot 0 + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a0d9c0 slot 3 + virtual void Reset(); // 009f3480 slot 4 Weapon::Reset + virtual void ClearReferences(); // 009f3320 slot 5 Weapon::ClearReferences + virtual float GetMaxCharge(); // 00a0e260 slot 6 + virtual long double GetChargeBarAmount(); // 009f4150 slot 7 Weapon::GetChargeBarAmount + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 Weapon::GetFocusEntity + virtual void vfunc_10(); // 009f3140 slot 10 Weapon::GetFocusEntity + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual uint32_t GetMarkedTargetVariant(); // 00a08cd0 slot 12 Weapon_MonstrosLung::GetMarkedTargetVariant + virtual uint8_t CanTakeDamageFromTearEffects(); // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects + virtual uint8_t CanShutDoors(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 00709c30 slot 15 GridEntity::CanTakeDamageFromTearEffects + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors - uint8_t _pad_0x44[0xc]; -}; -LAYOUT32(sizeof(Weapon_Tears) == 0x50); - -struct Weapon_TechX : Weapon { - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a0d9c0 slot 3 - long double GetMaxCharge() override; // 00a0e260 slot 6 - uint32_t GetMarkedTargetVariant() override; // 00a08cd0 slot 12 Weapon_MonstrosLung::GetMarkedTargetVariant - uint8_t CanShutDoors() override; // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects - uint8_t CanTriggerKidneyStone() override; // 00709c30 slot 15 GridEntity::CanTakeDamageFromTearEffects + uint8_t _pad_0x4[0x40]; }; LAYOUT32(sizeof(Weapon_TechX) == 0x44); -struct Weapon_UmbilicalWhip : Weapon { +struct Weapon_UmbilicalWhip { virtual ~Weapon_UmbilicalWhip(); // 009f9880 slot 0 Weapon_Bombs::Free - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a0e270 slot 3 - void Reset() override; // 0040c200 slot 4 ::guard_check_icall - void ClearReferences() override; // 00a063b0 slot 5 Weapon_Laser::ClearReferences - long double GetChargeBarAmount() override; // 009f3130 slot 7 Weapon::GetMaxCharge - uint32_t GetMainEntity() override; // 009f3150 slot 10 Weapon::GetMainEntity - uint8_t CanShutDoors() override; // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a0e270 slot 3 + virtual void guard_check_icall(); // 0040c200 slot 4 ::guard_check_icall + virtual void ClearReferences(); // 00a063b0 slot 5 Weapon_Laser::ClearReferences + virtual long double GetMaxCharge(); // 009f3130 slot 6 Weapon::GetMaxCharge + virtual void vfunc_7(); // 009f3130 slot 7 Weapon::GetMaxCharge + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 Weapon::GetFocusEntity + virtual Entity * GetMainEntity(); // 009f3150 slot 10 Weapon::GetMainEntity + virtual void vfunc_11(); // 0040c200 slot 11 ::guard_check_icall + virtual void vfunc_12(); // 009f3140 slot 12 Weapon::GetFocusEntity + virtual uint8_t CanTakeDamageFromTearEffects(); // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects + virtual uint8_t CanShutDoors(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors - uint8_t _pad_0x44[0x4]; + uint8_t _pad_0x4[0x44]; }; LAYOUT32(sizeof(Weapon_UmbilicalWhip) == 0x48); -struct Weapon_UrnOfSouls : Weapon { +struct Weapon_UrnOfSouls { virtual ~Weapon_UrnOfSouls(); // 009f97e0 slot 0 - void Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) override; // 00a0e630 slot 3 - void Reset() override; // 00a0f410 slot 4 - void ClearReferences() override; // 00a0f420 slot 5 - long double GetChargeBarAmount() override; // 009f3130 slot 7 Weapon::GetMaxCharge - uint32_t GetMainEntity() override; // 009f3170 slot 10 - uint8_t CanShutDoors() override; // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects + virtual void Init(uint32_t param_2, uint32_t param_3); // 009f34d0 slot 1 Weapon::Init + virtual void Update(char param_2); // 009f34f0 slot 2 Weapon::Update + virtual void Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated); // 00a0e630 slot 3 + virtual void Reset(); // 00a0f410 slot 4 + virtual void ClearReferences(); // 00a0f420 slot 5 + virtual long double GetMaxCharge(); // 009f3130 slot 6 Weapon::GetMaxCharge + virtual void vfunc_7(); // 009f3130 slot 7 Weapon::GetMaxCharge + virtual void vfunc_8(); // 009f3130 slot 8 Weapon::GetMaxCharge + virtual uint32_t GetFocusEntity(); // 009f3140 slot 9 Weapon::GetFocusEntity + virtual Entity * GetMainEntity(); // 009f3170 slot 10 + virtual void guard_check_icall(); // 0040c200 slot 11 ::guard_check_icall + virtual void vfunc_12(); // 009f3140 slot 12 Weapon::GetFocusEntity + virtual uint8_t CanTakeDamageFromTearEffects(); // 00709c30 slot 13 GridEntity::CanTakeDamageFromTearEffects + virtual uint8_t CanShutDoors(); // 005ccc00 slot 14 Entity::CanShutDoors + virtual void vfunc_15(); // 005ccc00 slot 15 Entity::CanShutDoors + virtual void vfunc_16(); // 005ccc00 slot 16 Entity::CanShutDoors - uint8_t _pad_0x44[0x10]; + uint8_t _pad_0x4[0x50]; }; LAYOUT32(sizeof(Weapon_UrnOfSouls) == 0x54); @@ -5871,6 +5504,18 @@ LAYOUT32(offsetof(std_multiset, _head) == 0x0); LAYOUT32(offsetof(std_multiset, _size) == 0x4); LAYOUT32(sizeof(std_multiset) == 0x8); +struct std_vector_bool { + void * _begin; + void * _end; + void * _capacity; + uint32_t _size; +}; +LAYOUT32(offsetof(std_vector_bool, _begin) == 0x0); +LAYOUT32(offsetof(std_vector_bool, _end) == 0x4); +LAYOUT32(offsetof(std_vector_bool, _capacity) == 0x8); +LAYOUT32(offsetof(std_vector_bool, _size) == 0xc); +LAYOUT32(sizeof(std_vector_bool) == 0x10); + struct tagBITMAPINFO { uint8_t bmiHeader[0x28]; // BITMAPINFOHEADER uint8_t bmiColors[0x4]; // RGBQUAD @@ -6348,7 +5993,6 @@ void FUN_00407470(); // 00407470 int FUN_004074a0(); // 004074a0 void _empty_check_0x34(); // 0040a7c0 void FUN_0040bcb0(uint8_t *param_1); // 0040bcb0 -void guard_check_icall(); // 0040c200 void FUN_0040c230(); // 0040c230 bool FUN_0040c2d0(); // 0040c2d0 void FUN_0040c2f0(); // 0040c2f0 @@ -6448,7 +6092,6 @@ int FUN_00417920(); // 00417920 void FUN_00417dd0(); // 00417dd0 void FUN_00417df0(); // 00417df0 void FUN_00417e50(); // 00417e50 -void render_entity_light_masks(float *param_1); // 00419b50 int FUN_0041b770(int param_1); // 0041b770 void FUN_0041c670(); // 0041c670 int FUN_0041c6f0(uint32_t param_1); // 0041c6f0 @@ -6535,7 +6178,6 @@ StageTransition * FUN_00428b50(); // 00428b50 void FUN_00428b60(void *param_1, uint32_t param_2); // 00428b60 void FUN_00428ce0(); // 00428ce0 uint32_t FUN_00428d30(uint32_t param_1); // 00428d30 -void update_cutscene_state_machine(); // 004291c0 void FUN_00429810(uint32_t param_1); // 00429810 void FUN_00429f20(); // 00429f20 int FUN_00429f30(uint32_t param_1); // 00429f30 @@ -7158,7 +6800,6 @@ uint8_t FUN_0067efd0(); // 0067efd0 float random_float(); // 0067efe0 uint32_t FUN_0067f030(); // 0067f030 Vector * RandomVector(Vector *out, uint32_t seed); // 0067f0d0 -int vector_to_direction(Vector *vec); // 0067f260 void FUN_0067f2e0(); // 0067f2e0 void * string_split(void *outTokens, std_string *text, uint8_t delimiter); // 0067f420 uint8_t string_to_bool(void *self); // 0067f600 @@ -7328,7 +6969,6 @@ void FUN_006b5f40(); // 006b5f40 void play_sound_with_fart_seed(int soundId, float volume, int frameDelay, uint8_t isLoop, float pitch); // 006b6470 void * spawn_rock_particles(float *param_1, float *param_2); // 006b68c0 void FUN_006b6e40(float *param_1, int param_2); // 006b6e40 -void FUN_006b7cc0(float *param_1); // 006b7cc0 void vector_0x3c_tidy(); // 006b7d40 void FUN_006b7db0(uint32_t *param_1); // 006b7db0 uint32_t * FUN_006b7fd0(int param_1, uint32_t *param_2); // 006b7fd0 @@ -7577,7 +7217,6 @@ void FUN_007538b0(); // 007538b0 void FUN_007538c0(); // 007538c0 uint8_t FUN_007538d0(); // 007538d0 uint32_t FUN_007538e0(); // 007538e0 -int FUN_00753940(); // 00753940 void FUN_007539a0(); // 007539a0 int FUN_00753bf0(); // 00753bf0 void FUN_00753c40(uint32_t param_1); // 00753c40 @@ -7741,7 +7380,6 @@ void FUN_007e92e0(uint32_t param_1, uint32_t param_2); // 007e92e0 void FUN_007e93d0(int param_1); // 007e93d0 void FUN_007ea0c0(); // 007ea0c0 void FUN_007ea5d0(); // 007ea5d0 -void init_room_render_surfaces(); // 007ea630 void FUN_007ebc40(); // 007ebc40 uint32_t FUN_007ed240(); // 007ed240 uint8_t entity_type_is_saved(int type, int variant, uint32_t subType, int spawnerType, uint8_t isRoomFlag); // 007eed10 @@ -7756,7 +7394,6 @@ uint32_t FUN_0081e220(); // 0081e220 void FUN_0081fae0(uint32_t *param_1); // 0081fae0 uint32_t FUN_008207a0(); // 008207a0 void FUN_00821940(); // 00821940 -void FUN_00823540(); // 00823540 int FUN_00823ec0(); // 00823ec0 uint32_t FUN_00827180(float *param_1); // 00827180 void FUN_00827f30(); // 00827f30 @@ -7837,7 +7474,6 @@ void FUN_008452f0(SourceQuad *param_1, void *param_2, ColorMod *param_3); // 00 void collectible_icon_render(void *param_1, ColorMod *param_2, int *param_3, int *param_4); // 00848c20 void FUN_0084a870(float *param_1); // 0084a870 void FUN_0084abc0(uint32_t *param_1, float *param_2, uint32_t *param_3, uint32_t *param_4); // 0084abc0 -void FUN_0084bab0(Vector *param_1, ColorMod *param_2, int param_3); // 0084bab0 void FUN_0084bba0(); // 0084bba0 void FUN_0084bbc0(uint32_t *param_1); // 0084bbc0 void FUN_0084bc00(uint32_t *param_1); // 0084bc00 @@ -8017,7 +7653,6 @@ void FUN_00865260(); // 00865260 uint32_t Catch_008652e9(); // 008652e9 int lua_callback_run_get_card(RNG *rng, int card, uint8_t isPlaying, uint8_t isRunes, uint8_t isOnlyRunes); // 00865340 uint8_t * Catch_00865424(); // 00865424 -uint32_t * lua_callback_run_get_shader_params(uint32_t *param_1, void *param_2); // 00865490 uint8_t * Catch_008655b7(); // 008655b7 char * FUN_00865660(char *param_1, uint32_t *param_2); // 00865660 uint32_t FUN_008658c0(uint32_t param_1, uint32_t *param_2); // 008658c0 @@ -10230,7 +9865,6 @@ void FUN_009baa10(char param_1); // 009baa10 int FUN_009bac00(int param_1); // 009bac00 uint32_t FUN_009be9c0(); // 009be9c0 void entity_vector_set_flag_410(void *self, uint8_t value); // 009bea10 -Vector * players_center_position(void *self, Vector *outPosition, uint8_t isUseCache); // 009beba0 void FUN_009bfc00(); // 009bfc00 void FUN_009bfc20(); // 009bfc20 void FUN_009bfc40(); // 009bfc40 @@ -10305,7 +9939,6 @@ void FUN_009e24f0(uint32_t *param_1, uint32_t param_2); // 009e24f0 void FUN_009e2520(void *param_1); // 009e2520 void FUN_009e2580(int *param_1, uint32_t *param_2); // 009e2580 int * FUN_009e2760(int *param_1, uint32_t *param_2); // 009e2760 -void anm2_member_at_1c4_destroy(void *self); // 009e27c0 uint8_t room_grid_flood_fill(void *self, uint32_t startIndex, uint32_t targetIndex); // 009e3560 int FUN_009e3d30(); // 009e3d30 void FUN_009e3d60(); // 009e3d60 @@ -10382,24 +10015,16 @@ void Catch_All_009f229d(); // 009f229d uint32_t * FUN_009f2410(uint32_t *param_1); // 009f2410 void FUN_009f2480(); // 009f2480 void * map_int_ImagePtr_subscript(void *self, int *key); // 009f2e20 -void FUN_009f3180(); // 009f3180 void FUN_009f3c10(); // 009f3c10 void FUN_009f3c40(); // 009f3c40 void FUN_009f4130(); // 009f4130 -void * FUN_009f4230(void *param_1, int param_2, int param_3, float param_4, float param_5, float param_6, short param_7, float param_8, float param_9, float param_10, float param_11, int param_12, float param_13, uint8_t param_14, short param_15); // 009f4230 Entity_Player * FUN_009f4fc0(); // 009f4fc0 -int FUN_009f57f0(); // 009f57f0 void FUN_009f5810(uint8_t param_1); // 009f5810 -uint32_t FUN_009f5830(); // 009f5830 -uint32_t FUN_009f5850(); // 009f5850 -uint32_t FUN_009f5870(); // 009f5870 -int FUN_009f5aa0(); // 009f5aa0 Entity_Tear * fire_fetus_tear(void *self, Vector *position, Vector *velocity, int fireFlags, Entity *source, float damageMultiplier, int unused); // 009f6e60 uint32_t * FUN_009f9080(); // 009f9080 uint32_t * FUN_009f90f0(); // 009f90f0 uint32_t * FUN_009f9170(); // 009f9170 uint32_t * FUN_009f91f0(); // 009f91f0 -uint32_t * FUN_009f9260(); // 009f9260 uint32_t * FUN_009f92d0(); // 009f92d0 uint32_t * FUN_009f9350(); // 009f9350 uint32_t * FUN_009f93d0(); // 009f93d0 @@ -22132,7 +21757,6 @@ int Random(int Max); // 0067f010 Vector * GetAxisAlignedUnitVectorFromDir(Vector *outVector, int direction); // 0067f1d0 Vector * GetRandomPickupVelocity(Vector *outVelocity, Vector *position, uint32_t pickupVelType, RNG *rng); // 006ee440 Vector * GetCollectibleSpawnPosition(Vector *outPosition, Vector *target); // 006eeaa0 -GridEntity * CreateGridEntity(int type, uint32_t gridIndex); // 0070b2e0 void DebugString(); // 0086ef30 int GetPlayer(void *L); // 0086ef50 int GetFrameCount(); // 0086f090 @@ -22181,8 +21805,6 @@ uint32_t * LoadModData(uint32_t *param_1, void *param_2, int param_3); // 00871 bool HasModData(void *param_1, int param_2); // 00871980 void RemoveModData(void *param_1, int param_2); // 00871c10 void Shutdown(); // 009ab700 -Weapon * CreateWeapon(int weaponType, Entity *owner); // 009f9020 -void DestoryWeapon(Weapon **weapon); // 009f9050 } namespace ItemInfo { uint8_t is_collectible_seen(int param_1); // 0083d760 diff --git a/generated-src/color.cpp b/generated-src/color.cpp index 2deb590..0276b0b 100644 --- a/generated-src/color.cpp +++ b/generated-src/color.cpp @@ -220,41 +220,6 @@ void Color::assign(uint32_t *param_1) return; } -// 004e46d0 -void Color::apply_to_kcolor(KColor *outColor, ColorMod *color, KColor *input) -{ - float fVar1; - float tintAlpha; - float blue; - float green; - float red; - float inputAlpha; - float offsetRed; - float tintAlpha; - - fVar1 = color->_colorize[3]; - tintAlpha = color->_tint[3]; - red = color->_tint[0] * input->_red; - green = color->_tint[1] * input->_green; - blue = color->_tint[2] * input->_blue; - inputAlpha = input->_alpha; - if (fVar1 != 0.0) { - tintAlpha = green * 0.71516 + red * 0.212671 + blue * 0.072169; - red = red + (tintAlpha * color->_colorize[0] - red) * fVar1; - green = green + (tintAlpha * color->_colorize[1] - green) * fVar1; - blue = blue + (tintAlpha * color->_colorize[2] - blue) * fVar1; - } - fVar1 = color->_offset[2]; - tintAlpha = color->_offset[1]; - offsetRed = color->_offset[0]; - outColor->_unk = 0; - outColor->_alpha = tintAlpha * inputAlpha; - outColor->_blue = blue + fVar1; - outColor->_green = green + tintAlpha; - outColor->_red = red + offsetRed; - return; -} - // 00682ed0 void Color::Reset() { diff --git a/generated-src/deathmatch_type_base.cpp b/generated-src/deathmatch_type_base.cpp index a946aca..a30facb 100644 --- a/generated-src/deathmatch_type_base.cpp +++ b/generated-src/deathmatch_type_base.cpp @@ -241,7 +241,7 @@ LAB_0042ab07: spikes = GHIDRA_CAST(0x0); } else { - (GHIDRA_CAST((spikes)))->GridEntity::GridEntity(); + GridEntity::GridEntity(spikes); *GHIDRA_CAST(spikes) = IsaacRepentancePlus::GridEntity_Spikes::vftable; } local_8 = 0xffffffff; @@ -258,7 +258,7 @@ LAB_0042ab07: *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((spikes)) + 0x8)))) = 0; spikes->_varData = 0; spikes->_collisionClass = 0; - spikes->BeginBatches(); + (**(code **)(*GHIDRA_CAST(spikes) + 0x20))(); game = g_game; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((spikes)) + 0x10)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((spikes)) + 0x10)))) + 1; (*GHIDRA_CAST((GHIDRA_CAST((spikes)) + 0x1c))) = 1; diff --git a/generated-src/entity_factory.cpp b/generated-src/entity_factory.cpp deleted file mode 100644 index e9340fb..0000000 --- a/generated-src/entity_factory.cpp +++ /dev/null @@ -1,597 +0,0 @@ -#include "classes.h" - -// 006f0090 -Entity * EntityFactory::Create(uint32_t type, uint8_t force) -{ - char cVar1; - uint32_t slot; - uint32_t tries; - uint8_t *npcPool; - bool isRetrying; - - if (GHIDRA_INT(type) < 0x3e9) { - if (type == 1000) { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) + 1U & 0x3ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) = slot; - cVar1 = *GHIDRA_CAST((slot * 0x4c0 + 0x170 + GHIDRA_INT(this))); - if (cVar1 == '\0') goto LAB_006f0d18; - isRetrying = tries < 0x401; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((slot * 0x4c0 + GHIDRA_INT(this))) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) + 1U & 0x3ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((slot * 0x4c0 + GHIDRA_INT(this))) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x400; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) * 0x4c0 + GHIDRA_INT(this))) + 0x38)) - (); - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5db84,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) * 0x4c0 + 0x177 + GHIDRA_INT(this))) = 1; - (**(code **)(*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) * 0x4c0 + GHIDRA_INT(this))) + 0x28))(); - (**(code **)(*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) * 0x4c0 + GHIDRA_INT(this))) + 0x44))(); - *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) * 0x4c0 + 0x177 + GHIDRA_INT(this))) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)); - } -LAB_006f0d18: - return GHIDRA_CAST((slot * 0x4c0 + GHIDRA_INT(this))); - } - switch(type) { - case 1: - KAGE_LogMessage(0x10,GHIDRA_CAST("EntityFactory cannot spawn Entity_Player.\n")); - return GHIDRA_CAST(0x0); - case 2: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x848 + 0x223990)); - if (cVar1 == '\0') goto LAB_006f0638; - isRetrying = tries < 0x201; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x848 + 0x223820)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x848 + 0x223820)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x200; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) * 0x848 + 0x223820)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5db4c,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) * 0x848 + 0x223997)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) * 0x848 + 0x223820)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) * 0x848 + 0x223820)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) * 0x848 + 0x223997)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)); - } -LAB_006f0638: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x848 + 0x223820)); - case 3: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) + 1U & 0x3f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0xf48 + 0x130178)); - if (cVar1 == '\0') goto LAB_006f021a; - isRetrying = tries < 0x41; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0xf48 + 0x130008)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) + 1U & 0x3f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0xf48 + 0x130008)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x40; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) * 0xf48 + 0x130008)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5daa4,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) * 0xf48 + 0x13017f)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) * 0xf48 + 0x130008)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) * 0xf48 + 0x130008)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) * 0xf48 + 0x13017f)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)); - } -LAB_006f021a: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0xf48 + 0x130008)); - case 4: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) + 1U & 0x3f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x9d8 + 0x16d380)); - if (cVar1 == '\0') goto LAB_006f0374; - isRetrying = tries < 0x41; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x9d8 + 0x16d210)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) + 1U & 0x3f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x9d8 + 0x16d210)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x40; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) * 0x9d8 + 0x16d210)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5dadc,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) * 0x9d8 + 0x16d387)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) * 0x9d8 + 0x16d210)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) * 0x9d8 + 0x16d210)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) * 0x9d8 + 0x16d387)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)); - } -LAB_006f0374: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x9d8 + 0x16d210)); - case 5: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x6f0 + 0x357da0)); - if (cVar1 == '\0') goto LAB_006f08f8; - isRetrying = tries < 0x201; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x6f0 + 0x357c30)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x6f0 + 0x357c30)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x200; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) * 0x6f0 + 0x357c30)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5dc90,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) * 0x6f0 + 0x357da7)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) * 0x6f0 + 0x357c30)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) * 0x6f0 + 0x357c30)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) * 0x6f0 + 0x357da7)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)); - } -LAB_006f08f8: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x6f0 + 0x357c30)); - case 6: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) + 1U & 0x7f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) = slot; - if (*GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT((&UNK_00435da8 + slot * 0x550)))) == '\0') goto LAB_006f0a56; - isRetrying = tries < 0x81; - tries = tries + 1; - } while (isRetrying); - if (*GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT((&UNK_00435da8 + slot * 0x550)))) != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x550 + 0x435c38)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) + 1U & 0x7f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x550 + 0x435c38)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x80; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) * 0x550 + 0x435c38)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5dbbc,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT((&UNK_00435daf + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) * 0x550)))) = - 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) * 0x550 + 0x435c38)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) * 0x550 + 0x435c38)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT((&UNK_00435daf + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) * 0x550)))) = - 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)); - } -LAB_006f0a56: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x550 + 0x435c38)); - case 7: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) + 1U & 0x7f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x568 + 0x32c998)); - if (cVar1 == '\0') goto LAB_006f0796; - isRetrying = tries < 0x81; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x568 + 0x32c828)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) + 1U & 0x7f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x568 + 0x32c828)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x80; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) * 0x568 + 0x32c828)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5dc58,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) * 0x568 + 0x32c99f)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) * 0x568 + 0x32c828)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) * 0x568 + 0x32c828)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) * 0x568 + 0x32c99f)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)); - } -LAB_006f0796: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x568 + 0x32c828)); - case 8: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) + 1U & 0x3f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x520 + 0x6965c8)); - if (cVar1 == '\0') goto LAB_006f0bb4; - isRetrying = tries < 0x41; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x520 + 0x696458)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) + 1U & 0x3f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x520 + 0x696458)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x40; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) * 0x520 + 0x696458)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5dcc8,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) * 0x520 + 0x6965cf)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) * 0x520 + 0x696458)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) * 0x520 + 0x696458)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) * 0x520 + 0x6965cf)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)); - } -LAB_006f0bb4: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x520 + 0x696458)); - case 9: - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x478 + 0x194988)); - if (cVar1 == '\0') goto LAB_006f04d8; - isRetrying = tries < 0x201; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x478 + 0x194818)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x478 + 0x194818)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x200; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_INT(this) + - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) * 0x478 + 0x194818)) + 0x38))() - ; - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5db10,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) * 0x478 + 0x19498f)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) * 0x478 + 0x194818)) + 0x28) - )(); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) * 0x478 + 0x194818)) + 0x44) - )(); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) * 0x478 + 0x19498f)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)); - } -LAB_006f04d8: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x478 + 0x194818)); - } - } - else if (type == 0x2329) { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) + 1U & 0x7f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) = slot; - cVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x530 + 0x64c5b8)); - if (cVar1 == '\0') goto LAB_006f0fe6; - isRetrying = tries < 0x81; - tries = tries + 1; - } while (isRetrying); - if (cVar1 != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x530 + 0x64c448)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) + 1U & 0x7f; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + slot * 0x530 + 0x64c448)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x80; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) * 0x530 + 0x64c448)) - + 0x38))(); - if (cVar1 == '\0') { - KAGE_LogMessage(4,(uint8_t *) - "Overwritten an entity with don\'t overwrite flag at index %d!\n"); - } - } - __std_type_info_name(0xc5dc24,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n" - ); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) * 0x530 + 0x64c5bf)) = 1; - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) * 0x530 + 0x64c448)) + 0x28)) - (); - (**(code **)(*GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) * 0x530 + 0x64c448)) + 0x44)) - (); - *GHIDRA_CAST((GHIDRA_CAST(this) + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) * 0x530 + 0x64c5bf)) = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)); - } -LAB_006f0fe6: - return GHIDRA_CAST((GHIDRA_INT(this) + slot * 0x530 + 0x64c448)); - } - npcPool = &DAT_00460440 + GHIDRA_INT(this); - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) = slot; - if (npcPool[slot * 0xf60 + 0x170] == '\0') goto LAB_006f0e88; - isRetrying = tries < 0x201; - tries = tries + 1; - } while (isRetrying); - if (npcPool[slot * 0xf60 + 0x170] != '\0') { - if (force != 0) { - return GHIDRA_CAST(0x0); - } - cVar1 = (**(code **)(*GHIDRA_CAST((npcPool + slot * 0xf60)) + 0x38))(); - if (cVar1 == '\0') { - tries = 0; - do { - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) + 1U & 0x1ff; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) = slot; - cVar1 = (**(code **)(*GHIDRA_CAST((npcPool + slot * 0xf60)) + 0x38))(); - if (cVar1 != '\0') break; - isRetrying = tries < 0x200; - tries = tries + 1; - } while (isRetrying); - cVar1 = (**(code **)(*GHIDRA_CAST((npcPool + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) * 0xf60)) + 0x38))(); - if (cVar1 == '\0') { - KAGE_LogMessage(4,GHIDRA_CAST("Overwritten an entity with don\'t overwrite flag at index %d!\n")) - ; - } - } - __std_type_info_name(0xc5dbf0,&DAT_00c71620); - KAGE_LogMessage(4,(uint8_t *) - "Entity pool array %s is full, overwriting at index %d! (frame count: %d)\n"); - npcPool[*GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) * 0xf60 + 0x177] = 1; - (**(code **)(*GHIDRA_CAST((npcPool + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) * 0xf60)) + 0x28))(); - (**(code **)(*GHIDRA_CAST((npcPool + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) * 0xf60)) + 0x44))(); - npcPool[*GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) * 0xf60 + 0x177] = 0; - slot = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)); - } -LAB_006f0e88: - return GHIDRA_CAST((npcPool + slot * 0xf60)); -} - -// 006f2a10 -void EntityFactory::constructor() -{ - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afbb39; - local_10 = ExceptionList; - ExceptionList = &local_10; - _eh_vector_constructor_iterator_(this,0x4c0,0x400,Entity_Effect::constructor,FUN_005cda90); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x130000)) = 0; - local_8 = 0; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x130008),0xf48,0x40,Entity_Familiar::Constructor,FUN_0060d400); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x16d208)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 1; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x16d210),0x9d8,0x40,FUN_006a1e80,FUN_006a1fc0); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x194810)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 2; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x194818),0x478,0x200,Entity_Projectile::Constructor, - GHIDRA_CAST<_func_void_void_ptr *>(&LAB_00652b80)); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x223818)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 3; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x223820),0x848,0x200,Entity_Tear::Constructor, - Entity_Tear::~Entity_Tear); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x32c820)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 4; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x32c828),0x568,0x80,Entity_Laser::Constructor, - Entity_Laser::destructor); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x357c28)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 5; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x357c30),0x6f0,0x200,Entity_Pickup::Constructor, - Entity_Pickup::~Entity_Pickup); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x435c30)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 6; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x435c38),0x550,0x80,FUN_0065d0c0,FUN_0065d160); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x460438)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 7; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x460440),0xf60,0x200,Entity_NPC::Constructor, - Entity_NPC::~Entity_NPC); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x64c440)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 8; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x64c448),0x530,0x80,FUN_005ccc30, - GHIDRA_CAST<_func_void_void_ptr *>(&LAB_005ccc90)); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x675c48)) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 9; - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x675c50),0x410,0x80,FUN_006a7ec0, - GHIDRA_CAST<_func_void_void_ptr *>(&LAB_006a7f10)); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x696450)) = 0; - local_8 = CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),10); - _eh_vector_constructor_iterator_ - ((void *)(GHIDRA_INT(this) + 0x696458),0x520,0x40,Entity_Knife::Constructor,FUN_00960bc0); - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x6aac58)) = 0; - ExceptionList = local_10; - return; -} diff --git a/generated-src/grid_entity.cpp b/generated-src/grid_entity.cpp deleted file mode 100644 index ae583f4..0000000 --- a/generated-src/grid_entity.cpp +++ /dev/null @@ -1,320 +0,0 @@ -#include "classes.h" - -// 004073c0 -int GridEntity::GetType() -{ - return *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); -} - -// 00428930 -ANM2 * GridEntity::GetSprite() -{ - return &this->_sprite; -} - -// 0043eec0 -int GridEntity::GetVariant() -{ - return *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); -} - -// 004e4830 -int GridEntity::GetGridIndex() -{ - return this->_gridIndex; -} - -// 0067efc0 -int GridEntity::VarData() -{ - return this->_varData; -} - -// 006a80c0 -uint8_t GridEntity::Hurt() -{ - return 0; -} - -// 00709c00 -void GridEntity::SetType(uint32_t param_1) -{ - int in_ECX; - - *GHIDRA_CAST((in_ECX + 4)) = param_1; - return; -} - -// 00709c10 -uint8_t GridEntity::Destroy(uint8_t isImmediate) -{ - uint8_t bVar1; - - /* WARNING: Could not recover jumptable at 0x00709c20. Too many branches */ - /* WARNING: Treating indirect jump as call */ - bVar1 = this->Hurt(); - return bVar1; -} - -// 00709c30 -uint8_t GridEntity::CanTakeDamageFromTearEffects() -{ - return 1; -} - -// 00709c40 -GridEntity::GridEntity() -{ - *GHIDRA_CAST(this) = IsaacRepentancePlus::GridEntity::vftable; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) = 0x16a9de81; - this->_varData = 0; - (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x1c))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x20)))) = 0x16a9de81; - (this->_rng)._shift1 = 5; - (this->_rng)._shift2 = 9; - (this->_rng)._seed = -0x55e8beb1; - (this->_rng)._shift3 = 7; - ANM2::constructor(&this->_sprite); - return; -} - -// 00709db0 -void GridEntity::Init(uint32_t Seed) -{ - Game *game; - - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) = Seed; - this->_collisionClass = 0; - this->BeginBatches(); - game = g_game; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) + 1; - (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x1c))) = 1; - this->_spawnFrame = game->_frameCount; - return; -} - -// 00709df0 -Vector * GridEntity::Position(Vector *outPosition) -{ - int gridIndex; - int gridWidth; - - gridIndex = this->_gridIndex; - gridWidth = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - outPosition->x = (float)(gridIndex % gridWidth) * 40.0 + 40.0; - outPosition->y = (float)(gridIndex / gridWidth) * 40.0 + 120.0; - return outPosition; -} - -// 00709e50 -Vector * GridEntity::get_render_position(Vector *outPosition) -{ - float pixelScale; - double dVar1; - int gridIndex; - int roomWidth; - - gridIndex = this->_gridIndex; - pixelScale = g_displayPixelRatio * g_screenPointScale; - roomWidth = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - dVar1 = floor((double)(((((float)(gridIndex % roomWidth) * 40.0 + 40.0) - 60.0) * 0.65 + - (g_screenWidth - 338.0) * 0.5) * pixelScale + 0.5)); - outPosition->x = (float)dVar1 / pixelScale; - dVar1 = floor((double)(((((float)(gridIndex / roomWidth) * 40.0 + 120.0) - 140.0) * 0.65 + - (g_screenHeight - 182.0) * 0.5) * pixelScale + 0.5)); - outPosition->y = (float)dVar1 / pixelScale; - return outPosition; -} - -// 0070b2a0 -uint8_t GridEntity::IsBreakableRock() -{ - int gridType; - - gridType = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((gridType == 2) || - ((gridType != 3 && - (((((gridType == 4 || (gridType == 5)) || (gridType == 6)) || (gridType == 0x16)) || - ((gridType != 0x18 && (((gridType == 0x19 || (gridType == 0x1a)) || (gridType == 0x1b)))))))) - )) { - return 1; - } - return 0; -} - -// 0070ba00 -GridEntity * GridEntity::InitSubclass(uint32_t flags) -{ - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - - puStack_c = &LAB_00afb440; - local_10 = ExceptionList; - ExceptionList = &local_10; - local_8 = 0; - ANM2::Reset(GHIDRA_CAST((this[1]._sprite._championColor._colorize + 1))); - AnimationState::~AnimationState(GHIDRA_CAST(&this[2]._gridIndex)); - AnimationState::~AnimationState(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[2])) + 0x4))))); - (GHIDRA_CAST((GHIDRA_CAST(&this[1]._sprite._flipX))))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST((GHIDRA_CAST((this[1]._sprite._championColor._colorize + 1)))))->msvc::string::_Tidy_deallocate(); - FID_conflict__Tidy(this[1]._sprite._championColor._tint + 2); - local_8 = 1; - ANM2::Reset(GHIDRA_CAST((this + 1))); - AnimationState::~AnimationState(GHIDRA_CAST(&this[1]._sprite._filename._size)); - AnimationState::~AnimationState(GHIDRA_CAST(&this[1]._rng._shift1)); - (GHIDRA_CAST((GHIDRA_CAST(&this[1]._varData))))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST((GHIDRA_CAST((this + 1)))))->msvc::string::_Tidy_deallocate(); - *GHIDRA_CAST(this) = IsaacRepentancePlus::GridEntity::vftable; - local_8 = 2; - ANM2::Reset(&this->_sprite); - AnimationState::~AnimationState(&(this->_sprite)._overlayAnimState); - AnimationState::~AnimationState(&(this->_sprite)._animState); - (GHIDRA_CAST(((this->_sprite)._animDefaultName._buf)))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->msvc::string::_Tidy_deallocate(); - if ((flags & 1) != 0) { - operator_delete(this,0x390); - } - ExceptionList = local_10; - return this; -} - -// 0070bec0 -uint8_t GridEntity::IsEasyCrushableOrWalkable() -{ - int gridType; - - if ((((((GHIDRA_UINT(this->_gridIndex) < 0x1c0) && - (0 < *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)))) && - (gridType = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))), gridType != 2)) && - ((gridType != 6 && (gridType != 4)))) && ((gridType != 0x16 && (gridType != 0x1a)))) && - ((gridType != 0xe || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1)))) { - return 0; - } - return 1; -} - -// 0070bf10 -uint8_t GridEntity::IsDangerousCrushableOrWalkable() -{ - int gridType; - - if (((((GHIDRA_UINT(this->_gridIndex) < 0x1c0) && - (999 < *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)))) && - (gridType = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))), gridType != 0xc)) && - ((gridType != 5 && (gridType != 8)))) && - ((gridType != 9 && ((gridType != 0xe || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 1)))))) { - return 0; - } - return 1; -} - -// 00738140 -void GridEntity::SetVariant(int variant) -{ - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = variant; - return; -} - -// 00823150 -void GridEntity::trigger_output(GridEntity *gridEntity) -{ - int iVar1; - EntityRef *source; - uint32_t seed; - int soundId; - Vector spawnPos; - EntityRef destroySource; - Manager *manager; - - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0x4)))); - if (iVar1 == 0xc) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) < 4) { - destroySource._position.y = g_vectorZero.y; - destroySource._velocity.y = g_vectorZero.y; - destroySource._type = 0; - destroySource._variant = 0; - destroySource._spawnerType = 0; - destroySource._spawnerVariant = 0; - destroySource._position.x = g_vectorZero.x; - destroySource._velocity.x = g_vectorZero.x; - destroySource._flags = 0; - destroySource._entity = (void *)0x0; - gridEntity->Destroy(1,&destroySource); - return; - } - } - else if (iVar1 == 0x14) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) == 0) { - ANM2::Play(&gridEntity->_sprite,GHIDRA_CAST("Switched"),0); - return; - } - } - else if (iVar1 == 2) { - if ((gridEntity->_varData != 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) == 1)) { - source = EntityRef::EntityRef(&destroySource); - gridEntity->Destroy(1,source); - return; - } - } - else if (iVar1 == 7) { - if ((gridEntity->_varData != 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) == 0)) { - seed = Random(); - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - spawnPos.x = (float)(gridEntity->_gridIndex % iVar1) * 40.0 + 40.0; - spawnPos.y = (float)(gridEntity->_gridIndex / iVar1) * 40.0 + 120.0; - Game::SpawnEx(g_game,1000,0xf,&spawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,seed,0); - manager = g_manager; - soundId = 0x89; - seed_fart_sound_override(&soundId); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,1.0,0.0); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) == 0) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) = 2; - (GHIDRA_CAST((GHIDRA_CAST(gridEntity))))->GridEntity_Pit::UpdateCollision(); - return; - } - } - } - else if (iVar1 == 0x17) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) == 2) { - ANM2::Play(&gridEntity->_sprite,GHIDRA_CAST("TurnOn"),0); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) = 1; - return; - } - ANM2::Play(&gridEntity->_sprite,GHIDRA_CAST("TurnOff"),0); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gridEntity)) + 0xc)))) = 2; - } - return; -} - -// 0085dda0 -RNG * GridEntity::GetRNG() -{ - return &this->_rng; -} - -// 008c5cd9 -void GridEntity::HurtWithSource() -{ - int *in_ECX; - - /* WARNING: Could not recover jumptable at 0x008c5cdb. Too many branches */ - /* WARNING: Treating indirect jump as call */ - (**(code **)(*in_ECX + 0x10))(); - return; -} - -// 008c5ce8 -void GridEntity::PostInit() -{ - int *in_ECX; - - /* WARNING: Could not recover jumptable at 0x008c5cea. Too many branches */ - /* WARNING: Treating indirect jump as call */ - (**(code **)(*in_ECX + 4))(); - return; -} diff --git a/generated-src/grid_entity_decoration.cpp b/generated-src/grid_entity_decoration.cpp deleted file mode 100644 index 97a39e7..0000000 --- a/generated-src/grid_entity_decoration.cpp +++ /dev/null @@ -1,544 +0,0 @@ -#include "classes.h" - -// 0099a8e0 -void GridEntity_Decoration::Update() -{ - uint8_t isSecondFoot; - uint32_t uVar1; - Entity_Player *player; - Vector *renderPos; - std_string *psVar2; - std_string *animNameData; - double dVar3; - Vector renderPosBuf; - float texelR; - float texelG; - float texelB; - float texelA; - float local_60; - float sampleY; - float decoRenderX; - float decoRenderY; - Sprite *sprite; - float sampleX; - GridEntity_Decoration *decoration; - float pixelScale; - float scaledCoord; - std_string *animName [4]; - uint32_t animNameSize; - uint32_t animNameCapacity; - uint32_t securityCookie; - uint8_t *puStack_20; - void *local_1c; - uint8_t *puStack_18; - std_string *local_14; - - puStack_20 = GHIDRA_CAST((animName + 0xe)); - local_14 = GHIDRA_CAST(0xffffffff); - puStack_18 = &LAB_00af462d; - local_1c = ExceptionList; - securityCookie = __security_cookie ^ GHIDRA_UINT((animName + 0xb)); - ExceptionList = &local_1c; - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 1000) && ((this->_sprite)._loaded != 0)) { - decoration = this; - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - ANM2::GetAnimation(GHIDRA_CAST(&(this->_sprite)._animState),GHIDRA_CAST(animName)); - animNameData = animName[0]; - local_14 = GHIDRA_CAST(0x0); - psVar2 = GHIDRA_CAST(animName); - if (0xf < animNameCapacity) { - psVar2 = animName[0]; - } - uVar1 = msvc::string::find(GHIDRA_CAST(psVar2),animNameSize,0,GHIDRA_CAST("Puddle"),6); - if (uVar1 != 0xffffffff) { - sprite = GHIDRA_CAST(&this->_sprite); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - uVar1 = 0; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) { - do { - player = Game::GetPlayer(g_game,uVar1); - if (player->_entityGridCollisionClass == 5) { - renderPos = (GHIDRA_CAST((GHIDRA_CAST(decoration))))->GridEntity::get_render_position(&renderPosBuf); - decoRenderX = renderPos->x; - pixelScale = g_displayPixelRatio * g_screenPointScale; - decoRenderY = renderPos->y; - scaledCoord = ((g_screenWidth - 338.0) * 0.5 + ((player->_pos).x - 60.0) * 0.65) * - pixelScale + 0.5; - dVar3 = floor((double)scaledCoord); - sampleX = (float)dVar3 / pixelScale; - scaledCoord = ((g_screenHeight - 182.0) * 0.5 + ((player->_pos).y - 140.0) * 0.65) * - pixelScale + 0.5; - dVar3 = floor((double)scaledCoord); - scaledCoord = (float)dVar3; - sampleY = scaledCoord / pixelScale; - local_60 = sampleX; - (GHIDRA_CAST((sprite)))->Sprite::GetTexel(&texelR,sampleX,sampleY,decoRenderX,decoRenderY,0x3c23d70a, - 0xffffffff); - if (0.0 < texelA) { - Entity_Player::is_footstep_triggered(player,-1); - if (player->_canFly == 0) { - isSecondFoot = Entity_Player::is_footstep_triggered(player,0); - if (isSecondFoot == 0) { - (player->_footprintColor1)._offset[0] = texelR; - (player->_footprintColor1)._offset[1] = texelG; - (player->_footprintColor1)._offset[2] = texelB; - } - else { - (player->_footprintColor2)._offset[0] = texelR; - (player->_footprintColor2)._offset[1] = texelG; - (player->_footprintColor2)._offset[2] = texelB; - } - } - } - } - uVar1 = uVar1 + 1; - } while (uVar1 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2))); - animNameData = animName[0]; - } - } - if (0xf < animNameCapacity) { - uVar1 = animNameCapacity + 1; - psVar2 = animNameData; - if (0xfff < uVar1) { - psVar2 = GHIDRA_CAST(animNameData[-1]._capacity); - uVar1 = animNameCapacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST((GHIDRA_INT(animNameData) + (-4 - GHIDRA_INT(psVar2))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(psVar2,uVar1); - } - } - ExceptionList = local_1c; - return; -} - -// 0099acc0 -void GridEntity_Decoration::BeginBatches() -{ - code *pcVar1; - uint8_t bVar2; - uint32_t uVar3; - uint8_t *puddleMatch; - std_string *psVar4; - int iVar5; - std_string *psVar6; - uint8_t *pbVar7; - void *pvVar8; - char *pcVar9; - GridEntity_Decoration *decoration; - uint32_t uVar10; - bool bVar11; - RNG decorRng; - int attemptsLeft; - uint32_t animSeed; - std_string *local_78; - uint32_t rngShift3; - GridEntity_Decoration *savedThis; - int backdropType; - std_string *animNameHeap; - std_string *local_64; - char isAnimAccepted; - void *curAnimName [4]; - uint32_t curAnimNameSize; - uint32_t curAnimNameCapacity; - std_string anm2Path; - std_string local_2c; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - uint32_t *animNameSize; - int *puddleCount; - - local_8 = 0xffffffff; - puStack_c = &LAB_00b0d8bd; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&local_2c)[1]._size); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1000) { - return; - } - if ((g_game->_difficulty == 2) || (g_game->_difficulty == 3)) { - bVar11 = true; - } - else { - bVar11 = false; - } - pvVar8 = g_game->_room; - backdropType = *GHIDRA_CAST((GHIDRA_CAST(pvVar8) + 0x1d18)); - iVar5 = 0; - if (*GHIDRA_CAST((GHIDRA_CAST(pvVar8) + 4)) != 0) { - iVar5 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar8) + 4)) + 0x58)); - } - uVar10 = this->_gridIndex + iVar5; - decorRng._shift1 = 5; - decorRng._shift2 = 9; - rngShift3 = 7; - decorRng._shift3 = 7; - ExceptionList = &local_10; - decorRng._seed = uVar10; - savedThis = this; - if (*GHIDRA_CAST((GHIDRA_CAST(pvVar8) + 8)) == 0x10) { - local_2c._size = 0; - local_2c._capacity = 0xf; - local_2c._buf[0] = '\0'; - local_2c._buf[1] = '\0'; - local_2c._buf[2] = '\0'; - local_2c._buf[3] = '\0'; - if (backdropType == 0x38) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = msvc::_Allocate(0x20); - local_2c._size = 0x1a; - local_2c._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))),"gfx/grid/Tiles_Rotgut.anm2",0x1b); - local_8 = 0; - ANM2::Load(&this->_sprite,&local_2c,1); - local_8 = 0xffffffff; - if (0xf < local_2c._capacity) { - uVar10 = local_2c._capacity + 1; - pcVar9 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - if (0xfff < uVar10) { - pcVar9 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + -4)); - uVar10 = local_2c._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar9))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar9,uVar10); - } - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (iVar5 == 10) { - ANM2::SetFrame(&this->_sprite,GHIDRA_CAST("Ladder"),0); - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - if (iVar5 == 0x14) { - ANM2::SetFrame(&this->_sprite,GHIDRA_CAST("Ladder"),1); - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - if (iVar5 == 0x1e) { - ANM2::SetFrame(&this->_sprite,GHIDRA_CAST("Ladder"),2); - ExceptionList = local_10; - return; - } - ExceptionList = local_10; - return; - } - if (backdropType == 0x37) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = msvc::_Allocate(0x30); - local_2c._size = 0x26; - local_2c._capacity = 0x2f; - builtin_strncpy(((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_buf,"gfx/grid/Tiles_I",0x10); - ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_size = 0x646d6574; - ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_capacity = 0x65676e75; - builtin_strncpy((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + 0x18)))->_buf,"on_Gideon.anm2",0xf); - local_8 = 1; - } - else { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = msvc::_Allocate(0x20); - local_2c._size = 0x1f; - local_2c._capacity = 0x1f; - builtin_strncpy(((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_buf,"gfx/grid/Tiles_I",0x10); - ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_size = 0x646d6574; - ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_capacity = 0x65676e75; - builtin_strncpy((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + 0x18)))->_buf,"on.anm2",8); - local_8 = 2; - } - ANM2::Load(&this->_sprite,&local_2c,1); - local_8 = 0xffffffff; - if (0xf < local_2c._capacity) { - uVar10 = local_2c._capacity + 1; - psVar4 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - if (0xfff < uVar10) { - psVar4 = GHIDRA_CAST((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + -0x18)))->_capacity); - uVar10 = local_2c._capacity + 0x24; - if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + (-4 - GHIDRA_INT(psVar4))))) goto LAB_0099af04; - } - operator_delete(psVar4,uVar10); - } - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (iVar5 == 10) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("Ladder1"),0); - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - if (iVar5 == 0x14) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("Ladder2"),0); - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - if (iVar5 == 0x1e) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("Ladder3"),0); - ExceptionList = local_10; - return; - } - ExceptionList = local_10; - return; - } - if ((bVar11) && ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 10 || (backdropType == 0x14)))) { - local_2c._size = 0; - local_2c._capacity = 0xf; - local_2c._buf[0] = '\0'; - local_2c._buf[1] = '\0'; - local_2c._buf[2] = '\0'; - local_2c._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = msvc::_Allocate(0x20); - local_2c._size = 0x1c; - local_2c._capacity = 0x1f; - builtin_strncpy(((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_buf,"gfx/grid/Props_1",0x10); - ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_size = 0x72475f32; - ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))))->_capacity = 0x2e646565; - builtin_strncpy((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + 0x18)))->_buf,"anm2",5); - local_8 = 3; - ANM2::Load(&this->_sprite,&local_2c,1); - local_8 = 0xffffffff; - if (0xf < local_2c._capacity) { - uVar10 = local_2c._capacity + 1; - psVar4 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - if (0xfff < uVar10) { - psVar4 = GHIDRA_CAST((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + -0x18)))->_capacity); - uVar10 = local_2c._capacity + 0x24; - if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + (-4 - GHIDRA_INT(psVar4))))) goto LAB_0099af04; - } - operator_delete(psVar4,uVar10); - } - uVar10 = (GHIDRA_CAST((&decorRng)))->RNG::Next(); - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::PlayRandom(uVar10); - ExceptionList = local_10; - return; - } - (GHIDRA_CAST((anm2Path._buf)))->msvc::string::string((void *)(GHIDRA_INT(pvVar8) + *GHIDRA_CAST((GHIDRA_CAST(pvVar8) + 0x1d18)) * 0x13c + 0x1d94)); - local_8 = 4; - iVar5 = g_game->_stage; - bVar2 = Seeds::HasSeedEffect(&g_game->_seedEffects,0x4f); - if ((bVar2 != 0) && - ((((iVar5 == 3 || (iVar5 == 4)) || (iVar5 == 0xb)) || - ((1 < iVar5 && (uVar10 == (uVar10 / 5) * 5)))))) { - (GHIDRA_CAST((anm2Path._buf)))->msvc::string::assign(GHIDRA_CAST("gfx/promo/gfuel/grid/props_gfuel.anm2"),0x25); - } - decoration = savedThis; - if (anm2Path._size != 0) { - ANM2::Load(&savedThis->_sprite,&anm2Path,1); - attemptsLeft = 0x14; -LAB_0099b160: - iVar5 = attemptsLeft + -1; - bVar11 = 0 < attemptsLeft; - attemptsLeft = iVar5; - if (bVar11) { - if (uVar10 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar10 = uVar10 >> ((uint8_t)decorRng._shift1 & 0x1f) ^ uVar10; - uVar10 = uVar10 << ((uint8_t)decorRng._shift2 & 0x1f) ^ uVar10; - animSeed = uVar10 >> ((uint8_t)rngShift3 & 0x1f) ^ uVar10; - (GHIDRA_CAST((GHIDRA_CAST(&decoration->_sprite))))->Sprite::PlayRandom(animSeed); - pvVar8 = (decoration->_sprite)._animState._animData; - if (pvVar8 == (void *)0x0) { - local_2c._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = GHIDRA_CAST(0x0); - local_2c._size = 0; - } - else { - (GHIDRA_CAST((local_2c._buf)))->msvc::string::string(pvVar8); - } - local_64 = &local_2c; - if (0xf < local_2c._capacity) { - local_64 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - } - animNameHeap = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - if (4 < local_2c._size) { - iVar5 = -1; - if (local_2c._size - 5 != -1) { - iVar5 = local_2c._size - 5; - } - psVar4 = GHIDRA_CAST((local_64->_buf + iVar5)); - do { - if (psVar4->_buf[0] == 'C') { - pcVar9 = "Caves"; - iVar5 = 1; - psVar6 = psVar4; - if (*GHIDRA_CAST(psVar4->_buf) == 0x65766143) { - psVar6 = GHIDRA_CAST((psVar4->_buf + 4)); - iVar5 = -3; - pcVar9 = "s"; - } - bVar11 = (uint8_t)psVar6->_buf[0] < (uint8_t)*pcVar9; - if ((psVar6->_buf[0] == *pcVar9) && - ((iVar5 == -3 || - (((bVar11 = (uint8_t)psVar6->_buf[1] < (uint8_t)pcVar9[1], psVar6->_buf[1] == pcVar9[1] && - (bVar11 = (uint8_t)psVar6->_buf[2] < (uint8_t)pcVar9[2], psVar6->_buf[2] == pcVar9[2])) - && (bVar11 = (uint8_t)psVar6->_buf[3] < (uint8_t)pcVar9[3], psVar6->_buf[3] == pcVar9[3]) - ))))) { - uVar10 = 0; - } - else { - uVar10 = -GHIDRA_UINT(bVar11) | 1; - } - if (uVar10 == 0) { - if ((GHIDRA_INT(psVar4) - GHIDRA_INT(local_64) != -1) && (backdropType != 4)) goto LAB_0099b501; - break; - } - } - if (psVar4 == local_64) break; - psVar4 = GHIDRA_CAST((GHIDRA_INT(&psVar4[-1]._capacity) + 3)); - } while( true ); - } - local_64 = &local_2c; - if (0xf < local_2c._capacity) { - local_64 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - } - if (8 < local_2c._size) { - iVar5 = -1; - if (local_2c._size - 9 != -1) { - iVar5 = local_2c._size - 9; - } - psVar4 = GHIDRA_CAST((local_64->_buf + iVar5)); - do { - if (psVar4->_buf[0] == 'C') { - pcVar9 = "Catacombs"; - uVar10 = 5; - psVar6 = psVar4; - do { - if (*GHIDRA_CAST(psVar6->_buf) != *GHIDRA_CAST(pcVar9)) break; - psVar6 = GHIDRA_CAST((psVar6->_buf + 4)); - pcVar9 = pcVar9 + 4; - bVar11 = 3 < uVar10; - uVar10 = uVar10 - 4; - } while (bVar11); - bVar11 = (uint8_t)psVar6->_buf[0] < (uint8_t)*pcVar9; - if ((psVar6->_buf[0] == *pcVar9) && - ((uVar10 == 0xfffffffd || - (((bVar11 = (uint8_t)psVar6->_buf[1] < (uint8_t)pcVar9[1], psVar6->_buf[1] == pcVar9[1] && - (bVar11 = (uint8_t)psVar6->_buf[2] < (uint8_t)pcVar9[2], psVar6->_buf[2] == pcVar9[2])) - && (bVar11 = (uint8_t)psVar6->_buf[3] < (uint8_t)pcVar9[3], psVar6->_buf[3] == pcVar9[3]) - ))))) { - uVar10 = 0; - } - else { - uVar10 = -GHIDRA_UINT(bVar11) | 1; - } - if (uVar10 == 0) { - if ((GHIDRA_INT(psVar4) - GHIDRA_INT(local_64) != -1) && (backdropType != 5)) goto LAB_0099b501; - break; - } - } - if (psVar4 == local_64) break; - psVar4 = GHIDRA_CAST((GHIDRA_INT(&psVar4[-1]._capacity) + 3)); - } while( true ); - } - local_78 = &local_2c; - if (0xf < local_2c._capacity) { - local_78 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - } - if (5 < local_2c._size) { - local_64 = GHIDRA_CAST((local_78->_buf + (local_2c._size - 5))); - for (puddleMatch = memchr(local_78,0x50,GHIDRA_INT(local_64) - GHIDRA_INT(local_78)); - puddleMatch != GHIDRA_CAST(0x0); - puddleMatch = memchr(puddleMatch + 1,0x50,GHIDRA_INT(local_64) - GHIDRA_INT((puddleMatch + 1)))) { - pcVar9 = "Puddle"; - iVar5 = 2; - pbVar7 = puddleMatch; - if (*GHIDRA_CAST(puddleMatch) == 0x64647550) { - pbVar7 = puddleMatch + 4; - iVar5 = -2; - pcVar9 = "le"; - } - bVar11 = *pbVar7 < (uint8_t)*pcVar9; - if (((*pbVar7 == *pcVar9) && - (bVar11 = pbVar7[1] < (uint8_t)pcVar9[1], pbVar7[1] == pcVar9[1])) && - ((iVar5 == -2 || - ((bVar11 = pbVar7[2] < (uint8_t)pcVar9[2], pbVar7[2] == pcVar9[2] && - (bVar11 = pbVar7[3] < (uint8_t)pcVar9[3], pbVar7[3] == pcVar9[3])))))) { - uVar10 = 0; - } - else { - uVar10 = -GHIDRA_UINT(bVar11) | 1; - } - if (uVar10 == 0) { - if ((GHIDRA_INT(puddleMatch) - GHIDRA_INT(local_78) != -1) && - (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x721c)) != 0)) goto LAB_0099b501; - break; - } - } - } - isAnimAccepted = '\x01'; - goto LAB_0099b3bd; - } - goto LAB_0099b406; - } - if (anm2Path._capacity < 0x10) { - ExceptionList = local_10; - return; - } - uVar10 = anm2Path._capacity + 1; - if (uVar10 < 0x1000) goto LAB_0099b4b8; - uVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(*(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4))); - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4); -joined_r0x0099b4b2: - uVar10 = anm2Path._capacity + 0x24; - if (0x1f < uVar3) { -LAB_0099af04: - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } -LAB_0099b4b8: - operator_delete((*GHIDRA_CAST((GHIDRA_CAST(&((void *)anm2Path._buf)) + 0x0))),uVar10); - ExceptionList = local_10; - return; -LAB_0099b501: - isAnimAccepted = '\0'; -LAB_0099b3bd: - if (0xf < local_2c._capacity) { - uVar10 = local_2c._capacity + 1; - psVar4 = animNameHeap; - if (0xfff < uVar10) { - psVar4 = GHIDRA_CAST(animNameHeap[-1]._capacity); - uVar10 = local_2c._capacity + 0x24; - if (0x1f < GHIDRA_UINT((GHIDRA_INT(animNameHeap) + (-4 - GHIDRA_INT(psVar4))))) goto LAB_0099af04; - } - operator_delete(psVar4,uVar10); - } - decoration = savedThis; - uVar10 = animSeed; - if (isAnimAccepted != '\0') goto LAB_0099b406; - goto LAB_0099b160; -LAB_0099b406: - psVar4 = ANM2::GetAnimation(GHIDRA_CAST(&(decoration->_sprite)._animState),GHIDRA_CAST(curAnimName)); - animNameSize = &psVar4->_size; - if (0xf < psVar4->_capacity) { - psVar4 = *GHIDRA_CAST(psVar4->_buf); - } - uVar10 = msvc::string::find(GHIDRA_CAST(psVar4),*animNameSize,0,GHIDRA_CAST("Puddle"),6); - if (0xf < curAnimNameCapacity) { - uVar3 = curAnimNameCapacity + 1; - pvVar8 = curAnimName[0]; - if (0xfff < uVar3) { - pvVar8 = *(void **)(GHIDRA_INT(curAnimName[0]) + -4); - uVar3 = curAnimNameCapacity + 0x24; - if (0x1f < GHIDRA_UINT((GHIDRA_INT(curAnimName[0]) + (-4 - GHIDRA_INT(pvVar8))))) goto LAB_0099af04; - } - operator_delete(pvVar8,uVar3); - } - curAnimNameSize = 0; - curAnimNameCapacity = 0xf; - curAnimName[0] = (void *)(GHIDRA_UINT(curAnimName[0]) & 0xffffff00); - if (uVar10 != 0xffffffff) { - puddleCount = GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x721c)); - *puddleCount = *puddleCount + 1; - } - if (anm2Path._capacity < 0x10) { - ExceptionList = local_10; - return; - } - uVar10 = anm2Path._capacity + 1; - if (uVar10 < 0x1000) goto LAB_0099b4b8; - uVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(*(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4))); - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4); - goto joined_r0x0099b4b2; -} diff --git a/generated-src/grid_entity_door.cpp b/generated-src/grid_entity_door.cpp deleted file mode 100644 index 18e4b44..0000000 --- a/generated-src/grid_entity_door.cpp +++ /dev/null @@ -1,3224 +0,0 @@ -#include "classes.h" - -// 00435fc0 -uint8_t GridEntity_Door::IsOpen() -{ - return *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2; -} - -// 00435fd0 -uint8_t GridEntity_Door::IsLocked() -{ - int temp_5fc7b31e12; - - temp_5fc7b31e12 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if ((((temp_5fc7b31e12 == 1) || (temp_5fc7b31e12 == 4)) || (temp_5fc7b31e12 == 3)) || - ((temp_5fc7b31e12 == 2 || (temp_5fc7b31e12 == 5)))) { - return 1; - } - return 0; -} - -// 005cd5e0 -int GridEntity_Door::Direction() -{ - return this->_direction; -} - -// 005cd5f0 -uint8_t GridEntity_Door::IsRoomType(int roomType) -{ - if ((this->_currentRoomType == roomType) || (this->_targetRoomType == roomType)) { - return 1; - } - return 0; -} - -// 0060cfe0 -int GridEntity_Door::TargetRoomIndex() -{ - return this->_targetRoomIdx; -} - -// 0060cff0 -bool GridEntity_Door::IsKeyFamiliarTarget() -{ - int in_ECX; - - return *GHIDRA_CAST((in_ECX + 8)) == 5; -} - -// 0070c5c0 -void GridEntity_Door::Update() -{ - void *pvVar1; - uint64_t qVar2; - uint8_t isChallengeOpen; - int iVar3; - uint32_t uVar4; - std_string *animName; - uint8_t *animNameCursor; - uint32_t forcedCurses; - uint32_t preventedCurses; - Entity_Player *player; - RoomDescriptor *targetRoomDesc; - LayerState *layer; - char *expectedName; - int iVar5; - uint32_t uVar6; - bool isLess; - double dVar7; - uint32_t uVar8; - ColorMod *pCVar9; - uint8_t auStack_f4 [47]; - uint8_t local_c5; - float local_c4; - float boxTop; - float local_bc; - float local_b8; - uint32_t auStack_b4 [8]; - uint32_t uStack_94; - uint32_t uStack_90; - uint32_t uStack_8c; - ColorMod local_88; - uint32_t uStack_5c; - uint32_t local_58; - uint32_t uStack_54; - uint32_t uStack_50; - uint32_t uStack_4c; - uint32_t local_44; - uint8_t *animData; - AnimationState *animState; - uint32_t *flagsHigh; - Game *game; - Manager *manager; - float playerX; - float playerY; - int *roomConfig; - - local_44 = __security_cookie ^ GHIDRA_UINT(auStack_f4); - this->_updateCount = this->_updateCount + 1; - game = g_game; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 5) { - uVar6 = *GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - if ((uVar6 & 0x20000) != 0) { - *GHIDRA_CAST(&g_game->_gameStateFlags) = GHIDRA_INT(g_game->_gameStateFlags); - *GHIDRA_CAST((GHIDRA_INT(&game->_gameStateFlags) + 4)) = uVar6 | 0x20000; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - UpdateAnimation(this); - Open(this); - } - } - iVar3 = get_secret_exit_kind(this); - game = g_game; - if ((iVar3 == 4) && ((g_game->_gameStateFlags & 0x10000000000000) != 0)) { - iVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if ((iVar3 == 1) || - ((((iVar3 == 4 || (iVar3 == 3)) || (iVar3 == 2)) || - ((iVar3 == 5 || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 2)))))) { - if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) & 1) != 0) { - if (iVar3 != 4) { - if (iVar3 == 5) { - qVar2 = g_game->_gameStateFlags; - flagsHigh = GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - *flagsHigh = *flagsHigh | 0x20000; - *GHIDRA_CAST(&game->_gameStateFlags) = GHIDRA_INT(qVar2); - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - UpdateAnimation(this); - } - Open(this); - } - goto LAB_0070c6c5; - } -LAB_0070c6cb: - if ((this->_doorFlags & 0x10) != 0) goto LAB_0070c737; - if ((this->_targetRoomIdx == -7) || (g_game->_currentRoomIdx == -7)) { -LAB_0070c718: - if (((this->_sprite)._animState._animData == (void *)0x0) || - ((this->_sprite)._animState._isPlaying == 0)) { -LAB_0070c72b: - this->_collisionClass = 5; - } - } - else { - if (this->_targetRoomType != 5) { - if (this->_targetRoomType == 0x1b) { - isChallengeOpen = Level::HasPhotoDoor(GHIDRA_CAST(g_game)); - if (isChallengeOpen != 0) goto LAB_0070c718; - } - goto LAB_0070c72b; - } - if (g_game->_stage == 9) goto LAB_0070c718; - this->_collisionClass = 5; - } - } - else { -LAB_0070c6c5: - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) goto LAB_0070c6cb; -LAB_0070c737: - animName = &this->_closeAnimation; - this->_collisionClass = 4; - if (0xf < (this->_closeAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - isChallengeOpen = ANM2::IsPlaying(&this->_sprite,GHIDRA_CAST(animName)); - if (((isChallengeOpen != 0) && - (pvVar1 = (this->_sprite)._animState._animData, pvVar1 != (void *)0x0)) && - (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x34)) == '\0')) { - dVar7 = floor((double)(this->_sprite)._animState._animFrame); - manager = g_manager; - local_c4 = (float)dVar7; - if (GHIDRA_INT(dVar7) == 2) { - local_c4 = 6.44597e-44; - if ((this->_doorFlags & 8) == 0) { - local_c4 = 4.90454e-44; - } - seed_fart_sound_override(GHIDRA_CAST(&local_c4)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c4),1.0,10,0,1.0,0.0); - } - } - } - uVar6 = this->_doorFlags; - uVar4 = uVar6 & 0xff; - if (((uVar6 & 8) != 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2)) { - animName = &this->_openAnimation; - if (0xf < (this->_openAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - uVar8 = 0x70c823; - local_c5 = (uint8_t)uVar6; - isChallengeOpen = ANM2::IsPlaying(&this->_sprite,GHIDRA_CAST(animName)); - if (isChallengeOpen == 0) { -LAB_0070c871: - uVar4 = GHIDRA_UINT(local_c5); - } - else { - pvVar1 = (this->_sprite)._animState._animData; - if ((pvVar1 == (void *)0x0) || - (uVar4 = this->_doorFlags & 0xff, *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x34)) == '\0')) { - local_c5 = (uint8_t)this->_doorFlags; - iVar3 = ANM2::GetFrame(&this->_sprite); - if (iVar3 != 2) goto LAB_0070c871; - FUN_0070bfa0(0x2f,10,uVar8,0x3f800000); - uVar4 = GHIDRA_UINT((uint8_t)this->_doorFlags); - } - } - } - if (((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 8) && - ((((uVar4 & 1) != 0 || (this->_targetRoomType == 0x17)) && (this->_currentRoomType == 1)))) && - (((this->_sprite)._animState._animData == (void *)0x0 || - ((this->_sprite)._animState._isPlaying == 0)))) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("Opened"),0); - } - else if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("Closed"),0); - } - } - else { - iVar3 = this->_currentRoomType; - if ((iVar3 == 7) || - (((iVar5 = this->_targetRoomType, iVar5 == 7 || (iVar3 == 8)) || - ((iVar5 == 8 || ((iVar3 == 0x1d || (iVar5 == 0x1d)))))))) { -LAB_0070c926: - animName = &this->_openAnimation; - if (0xf < (this->_openAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - isChallengeOpen = ANM2::IsFinishedImpl(&this->_sprite,GHIDRA_CAST(animName)); - if (isChallengeOpen != 0) { - animData = (this->_sprite)._animState._animData; - if (animData != GHIDRA_CAST(0x0)) { - animNameCursor = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameCursor = *GHIDRA_CAST(animData); - } - expectedName = "Opened"; - do { - isChallengeOpen = *animNameCursor; - isLess = isChallengeOpen < (uint8_t)*expectedName; - if (isChallengeOpen != *expectedName) { -LAB_0070c980: - uVar6 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0070c985; - } - if (isChallengeOpen == 0) break; - isChallengeOpen = animNameCursor[1]; - isLess = isChallengeOpen < (uint8_t)expectedName[1]; - if (isChallengeOpen != expectedName[1]) goto LAB_0070c980; - animNameCursor = animNameCursor + 2; - expectedName = expectedName + 2; - } while (isChallengeOpen != 0); - uVar6 = 0; -LAB_0070c985: - if ((uVar6 == 0) && - ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_0070c9b8; - } - isChallengeOpen = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Opened"),1); - if (isChallengeOpen != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - } - else if (iVar5 == 5) { - targetRoomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - if ((targetRoomDesc->Flags & 1) == 0) goto LAB_0070c926; - } - } -LAB_0070c9b8: - uVar6 = g_game->_debugCurses; - uVar4 = g_game->_curses; - forcedCurses = Seeds::GetForcedCurses(); - preventedCurses = Seeds::GetPreventedCurses(); - if ((((~preventedCurses & (forcedCurses | uVar6 | uVar4) & 0x10) == 0) || - (this->_targetRoomType != 1)) || (local_c5 = '\x01', this->_currentRoomType != 1)) { - local_c5 = '\0'; - } - if ((((this->_doorFlags & 4) != 0) && (uVar6 = this->_direction, uVar6 < 4)) && - (this->_varData == 0)) { - local_88._tint[0] = -43.0; - local_88._tint[1] = -20.0; - local_88._tint[2] = 15.0; - local_88._tint[3] = 20.0; - iVar3 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_88._colorize[0] = -20.0; - local_88._colorize[1] = -43.0; - local_88._colorize[2] = 20.0; - local_88._colorize[3] = 15.0; - local_88._offset[0] = -15.0; - local_88._offset[1] = -20.0; - local_88._offset[2] = 43.0; - uStack_5c = 0x41a00000; - local_58 = 0xc1a00000; - uStack_54 = 0xc1700000; - uStack_50 = 0x41a00000; - uStack_4c = 0x422c0000; - local_bc = (float)(this->_gridIndex % iVar3) * 40.0 + 40.0; - local_b8 = (float)(this->_gridIndex / iVar3) * 40.0 + 120.0; - local_c4 = local_bc + local_88._tint[uVar6 * 4]; - local_bc = local_bc + local_88._tint[uVar6 * 4 + 2]; - boxTop = local_b8 + local_88._tint[uVar6 * 4 + 1]; - local_b8 = local_b8 + local_88._tint[uVar6 * 4 + 3]; - uVar6 = 0; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) { - do { - player = Game::GetPlayer(g_game,uVar6); - if (((player->_entityGridCollisionClass == 5) || (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)) == 10)) - || (local_c5 != '\0')) { - playerX = (player->_pos).x; - playerY = (player->_pos).y; - if ((local_c4 <= playerX) && (boxTop <= playerY)) { - if (playerX <= local_bc) { - if (playerY <= local_b8) { - Game::save_rewind_state(this->_slot); - local_88._tint[0] = 0.0; - local_88._tint[1] = 0.0; - local_88._tint[2] = 0.0; - local_88._tint[3] = 0.0; - local_88._colorize[0] = g_vectorZero.x; - local_88._colorize[1] = g_vectorZero.y; - local_88._colorize[2] = g_vectorZero.x; - local_88._colorize[3] = g_vectorZero.y; - local_88._offset[0] = 0.0; - local_88._offset[1] = 0.0; - (**(code **)(*GHIDRA_CAST(player) + 0x20))(0x3f800000,0x10010000,0,&local_88); - } - } - } - } - uVar6 = uVar6 + 1; - } while (uVar6 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2))); - } - } - if ((((((this->_targetRoomType == 0xb) && ((this->_doorFlags & 8) != 0)) && (this->_isBusted == 0) - ) && ((this->_currentRoomType != 0x1d && - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) >> 10 & 1) == 0)))) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 1)) && (this->_isUnlockedByPlayer == 0)) { - isChallengeOpen = Level::CanOpenChallengeRoom(GHIDRA_CAST(g_game),this->_targetRoomIdx); - if (isChallengeOpen == 0) { - Close(this,0); - } - } - animState = &(this->_sprite)._animState; - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - if ((this->_extraSprite)._loaded != 0) { - AnimationState::Update(&(this->_extraSprite)._animState); - AnimationState::Update(&(this->_extraSprite)._overlayAnimState); - } - if ((this->_sprite)._animState._animData != (void *)0x0) { - isChallengeOpen = - AnimationState::WasEventTriggered(&(this->_sprite)._animState,GHIDRA_CAST("ScreenshakeStop")); - if (isChallengeOpen == 0) { - if ((this->_sprite)._animState._animData != (void *)0x0) { - isChallengeOpen = AnimationState::WasEventTriggered(animState,GHIDRA_CAST("ScreenshakeStart")); - if (isChallengeOpen != 0) { - Game::ShakeScreen(g_game,4); - if ((this->_sprite)._animState._animData != (void *)0x0) { - isChallengeOpen = AnimationState::IsEventTriggered(animState,GHIDRA_CAST("ScreenshakeStart")) - ; - manager = g_manager; - if (isChallengeOpen != 0) { - local_c4 = 7.28675e-44; - seed_fart_sound_override(GHIDRA_CAST(&local_c4)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c4),1.0,2,0,0.33,0.0); - } - } - } - } - } - else { - Game::ShakeScreen(g_game,0); - } - } - if (this->_targetRoomType == 0x1b) { - iVar3 = get_secret_exit_kind(this); - if ((iVar3 == 3) && ((this->_sprite)._animState._animData != (void *)0x0)) { - isChallengeOpen = AnimationState::IsEventTriggered(animState,GHIDRA_CAST("Sound")); - if (isChallengeOpen != 0) { - isChallengeOpen = Level::HasPhotoDoor(GHIDRA_CAST(g_game)); - manager = g_manager; - if (isChallengeOpen == 0) { - local_c4 = 9.52883e-44; - seed_fart_sound_override(GHIDRA_CAST(&local_c4)); - uVar8 = 0x3f800000; - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c4),1.0,2,0,1.0,0.0); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 8) { - FUN_0070bfa0(0x9c,2,uVar8,0x3f800000); - } - } - else { - local_c4 = 7.28675e-44; - seed_fart_sound_override(GHIDRA_CAST(&local_c4)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c4),1.0,2,0,0.33,0.0); - } - } - if ((this->_sprite)._animState._animData != (void *)0x0) { - isChallengeOpen = AnimationState::IsEventTriggered(animState,&DAT_00b64ba4); - if (isChallengeOpen != 0) { - Game::ShakeScreen(g_game,8); - SpawnDust(this); - } - } - } - } - targetRoomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - if ((targetRoomDesc->Flags & 0x40000U) != 0) { - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST("Background")); - if (layer != GHIDRA_CAST(0x0)) { - uStack_94 = 0; - uStack_90 = 0; - uStack_8c = 0; - if (&layer->_color != GHIDRA_CAST(auStack_b4)) { - (layer->_color)._tint[0] = 1.0; - (layer->_color)._tint[1] = 1.0; - (layer->_color)._tint[2] = 1.0; - (layer->_color)._tint[3] = 1.0; - (layer->_color)._offset[0] = 0.0; - (layer->_color)._offset[1] = 0.0; - (layer->_color)._colorize[0] = 0.8; - (layer->_color)._colorize[1] = 1.1; - (layer->_color)._colorize[2] = 1.8; - (layer->_color)._colorize[3] = 0.8; - (layer->_color)._offset[2] = 0.0; - } - } - } - roomConfig = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x10)); - if ((((roomConfig != GHIDRA_CAST(0x0)) && (*roomConfig == 0x23)) && - (pvVar1 = targetRoomDesc->Data, pvVar1 != (void *)0x0)) && - (((*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 8)) == 1 && (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x10)) == 3)) && - (g_game->_stageType == 1)))) { - uVar6 = Random(); - local_c4 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * - 2.3283064e-10 * 0.2 + 0.5; - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x3)); - local_88._offset[0] = 0.0; - local_88._colorize[0] = 0.0; - local_88._colorize[1] = 0.0; - local_88._colorize[2] = 0.0; - local_88._colorize[3] = 0.0; - local_88._offset[1] = 0.0; - layer->_visible = 1; - pCVar9 = &local_88; - local_88._offset[2] = 0.0; - local_88._tint[0] = 0.9; - local_88._tint[1] = 0.93; - local_88._tint[2] = 1.0; - local_88._tint[3] = local_c4; - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x3)); - (GHIDRA_CAST((GHIDRA_CAST(&layer->_color))))->Color::operator_assign(pCVar9); - pCVar9 = &local_88; - local_88._tint[0] = 1.0; - local_88._tint[1] = 1.0; - local_88._tint[2] = 1.0; - local_88._tint[3] = 1.0; - local_88._colorize[0] = 3.0; - local_88._colorize[1] = 3.0; - local_88._colorize[2] = 3.2; - local_88._colorize[3] = local_c4; - local_88._offset[0] = 0.0; - local_88._offset[1] = 0.0; - local_88._offset[2] = 0.0; - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x0)); - (GHIDRA_CAST((GHIDRA_CAST(&layer->_color))))->Color::operator_assign(pCVar9); - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 2) { - iVar3 = PlayerManager::GetTrinketMultiplier(&g_game->_playerManager,0x3e); - if (1 < iVar3) { - if ((this->_currentRoomType != 7) && (this->_targetRoomType != 7)) { - iVar3 = PlayerManager::GetTrinketMultiplier(&g_game->_playerManager,0x3e); - if ((iVar3 < 3) || ((this->_currentRoomType != 8 && (this->_targetRoomType != 8)))) - goto LAB_0070d1ab; - } - iVar5 = 300; - iVar3 = PlayerManager::GetTrinketMultiplier(&g_game->_playerManager,0x3e); - manager = g_manager; - if (2 < iVar3) { - iVar5 = 0x96; - } - if (*GHIDRA_CAST(g_game->_room) == '\0') { - iVar3 = -1; - } - else { - iVar3 = g_game->_frameCount - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x11f0)); - } - if ((iVar3 % iVar5 < 0xb) && (iVar3 % iVar5 == 0)) { - local_c4 = 1.42092e-42; - seed_fart_sound_override(GHIDRA_CAST(&local_c4)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c4),1.0,2,0,1.0,0.0); - isChallengeOpen = ANM2::SetAnimation(&this->_sparkleSprite,GHIDRA_CAST("Sparkle"),1); - if (isChallengeOpen != 0) { - AnimationState::Rewind(&(this->_sparkleSprite)._animState); - (this->_sparkleSprite)._animState._isPlaying = 1; - } - } - } - } -LAB_0070d1ab: - if ((this->_sparkleSprite)._loaded != 0) { - AnimationState::Update(&(this->_sparkleSprite)._animState); - AnimationState::Update(&(this->_sparkleSprite)._overlayAnimState); - } - return; -} - -// 0070d360 -int GridEntity_Door::get_secret_exit_kind() -{ - RoomDescriptor *roomDesc; - int roomData; - - if (this->_targetRoomType == 0x1b) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - if (roomDesc->Data != (void *)0x0) { - return *GHIDRA_CAST((GHIDRA_CAST(roomDesc->Data) + 0x10)); - } - } - else if (this->_currentRoomType == 0x1b) { - roomData = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x10)); - if (roomData != 0) { - return *GHIDRA_CAST((roomData + 0x10)); - } - } - else { - if (this->_targetRoomType == 5) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - } - else { - if (this->_currentRoomType != 5) { - return 0; - } - roomDesc = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)); - } - if ((roomDesc->Data != (void *)0x0) && (*GHIDRA_CAST((GHIDRA_CAST(roomDesc->Data) + 0x10)) == 0x5a)) { - return 4; - } - } - return 0; -} - -// 0070d3f0 -void GridEntity_Door::LoadSprite() -{ - bool bVar1; - uint8_t *puVar2; - uint8_t bVar3; - int iVar4; - LayerState *layer; - RoomDescriptor *roomDesc; - RoomDescriptor *targetRoomDesc; - int iVar5; - ColorMod *extraout_EAX; - ColorMod *extraout_EAX_00; - Entity_Player *payToPlayOwner; - void *pvVar6; - uint8_t unk; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - uint8_t extraout_CL_01; - uint8_t extraout_CL_02; - uint8_t extraout_CL_03; - uint8_t extraout_CL_04; - uint8_t extraout_CL_05; - uint8_t extraout_CL_06; - uint8_t extraout_CL_07; - uint8_t extraout_CL_08; - uint8_t extraout_CL_09; - uint8_t extraout_CL_10; - uint8_t extraout_CL_11; - uint8_t extraout_CL_12; - uint8_t unk_00; - std_string *pathString; - char *pcVar7; - Game *extraout_ECX; - uint8_t *pathEnd; - uint32_t uVar8; - uint32_t uVar9; - ANM2 *sprite; - float colorizeB; - ColorMod roomColor; - float offsetLength; - uint8_t *local_190; - std_string barDoorPath; - std_string devilTreasureDoorPath; - std_string devilRoomDoorPath; - std_string ambushDoorPath; - std_string bossAmbushDoorPath; - std_string momsHeartDoorPath; - std_string mausoleumDoorPath; - std_string secretExitPath; - uint8_t local_c8 [44]; - std_string mineshaftDarkPath; - std_string mineshaftLightPath; - std_string anmPath; - std_string doorAnmPath; - std_string tmpString; - uint32_t stackCookie; - uint8_t *puStack_20; - void *savedExceptionList; - uint8_t *puStack_18; - uint32_t ehState; - ColorMod *color; - float colorizeA; - float colorizeB; - float colorizeG; - float colorizeR; - Game *game; - int *roomData; - void *targetRoomData; - int targetRoomType; - float tintA; - float tintB; - float tintG; - float tintR; - - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - ehState = 0xffffffff; - puStack_18 = &LAB_00afc928; - savedExceptionList = ExceptionList; - stackCookie = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U; - ExceptionList = &savedExceptionList; - puVar2 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - if ((this->_extraSprite)._loaded != 0) { - ANM2::Reset(&this->_extraSprite); - puVar2 = puStack_20; - } - puStack_20 = puVar2; - bVar1 = true; - this->_doorFlags = 0; - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(s_Open,4); - (GHIDRA_CAST(((this->_closeAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Close"),5); - offsetLength = 15.0; - if (this->_targetRoomIdx == -100) { - tmpString._size = 0; - tmpString._capacity = 0xf; - tmpString._buf[0] = '\0'; - tmpString._buf[1] = '\0'; - tmpString._buf[2] = '\0'; - tmpString._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = msvc::_Allocate(0x30); - tmpString._size = 0x22; - tmpString._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))),"gfx/grid/door_downpour_mirror.anm2",0x23); - ehState = 0; - ANM2::Load(&this->_sprite,&tmpString,1); - ehState = 0xffffffff; - if (0xf < tmpString._capacity) { - uVar8 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar8 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { -LAB_0070d535: - ehState = 0xffffffff; - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - this->_doorFlags = this->_doorFlags | 0x10; - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Break"),5); - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Break"),5); - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Closed"),6); - goto LAB_0070eb83; - } - if (this->_targetRoomIdx == -0x65) { - if (g_game->_currentDimensionIdx == 1) { - mineshaftLightPath._size = 0; - mineshaftLightPath._capacity = 0xf; - mineshaftLightPath._buf[0] = '\0'; - mineshaftLightPath._buf[1] = '\0'; - mineshaftLightPath._buf[2] = '\0'; - mineshaftLightPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftLightPath._buf)) + 0x0))) = msvc::_Allocate(0x30); - mineshaftLightPath._size = 0x28; - mineshaftLightPath._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(mineshaftLightPath._buf))) + 0x0))), - "gfx/grid/door_mines_mineshaft_light.anm2",0x29); - ehState = 1; - ANM2::Load(&this->_sprite,&mineshaftLightPath,1); - ehState = 0xffffffff; - if (0xf < mineshaftLightPath._capacity) { - uVar8 = mineshaftLightPath._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(mineshaftLightPath._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftLightPath._buf)) + 0x0))) + -4)); - uVar8 = mineshaftLightPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftLightPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - mineshaftLightPath._size = 0; - mineshaftLightPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftLightPath._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftLightPath._buf)) + 0x0))) & 0xffffff00; - } - else { - mineshaftDarkPath._size = 0; - mineshaftDarkPath._capacity = 0xf; - mineshaftDarkPath._buf[0] = '\0'; - mineshaftDarkPath._buf[1] = '\0'; - mineshaftDarkPath._buf[2] = '\0'; - mineshaftDarkPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftDarkPath._buf)) + 0x0))) = msvc::_Allocate(0x30); - mineshaftDarkPath._size = 0x27; - mineshaftDarkPath._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(mineshaftDarkPath._buf))) + 0x0))),"gfx/grid/door_mines_mineshaft_dark.anm2" - ,0x28); - ehState = 2; - ANM2::Load(&this->_sprite,&mineshaftDarkPath,1); - ehState = 0xffffffff; - if (0xf < mineshaftDarkPath._capacity) { - uVar8 = mineshaftDarkPath._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(mineshaftDarkPath._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftDarkPath._buf)) + 0x0))) + -4)); - uVar8 = mineshaftDarkPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftDarkPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - mineshaftDarkPath._size = 0; - mineshaftDarkPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftDarkPath._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(mineshaftDarkPath._buf)) + 0x0))) & 0xffffff00; - } - this->_doorFlags = this->_doorFlags | 0x20; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 4) { - bVar1 = false; - (GHIDRA_CAST(((this->_closeAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Collapse"),8); - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Collapsed"),9); - } - goto LAB_0070eb83; - } - iVar4 = this->_currentRoomType; - if (iVar4 == 7) { -LAB_0070e8c5: - anmPath._size = 0; - anmPath._capacity = 0xf; - anmPath._buf[0] = '\0'; - anmPath._buf[1] = '\0'; - anmPath._buf[2] = '\0'; - anmPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - anmPath._size = 0x15; - anmPath._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anmPath._buf))) + 0x0))),"gfx/door_sparkle.anm2",0x16); - ehState = 3; - ANM2::Load(&this->_sparkleSprite,&anmPath,1); - ehState = 0xffffffff; - if (0xf < anmPath._capacity) { - uVar8 = anmPath._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anmPath._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) + -4)); - uVar8 = anmPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - anmPath._size = 0; - anmPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) & 0xffffff00; -LAB_0070e980: - tmpString._size = 0; - tmpString._capacity = 0xf; - tmpString._buf[0] = '\0'; - tmpString._buf[1] = '\0'; - tmpString._buf[2] = '\0'; - tmpString._buf[3] = '\0'; - if (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)) == 0x10) { - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = msvc::_Allocate(0x30); - tmpString._size = 0x2a; - tmpString._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))),"gfx/grid/door_08_holeinwall _darkroom.anm2",0x2b - ); - ehState = 4; - ANM2::Load(&this->_sprite,&tmpString,1); - ehState = 0xffffffff; - if (0xf < tmpString._capacity) { - uVar8 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar8 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) & 0xffffff00; - } - else { - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = msvc::_Allocate(0x30); - tmpString._size = 0x20; - tmpString._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))),"gfx/grid/Door_08_HoleInWall.anm2",0x21); - ehState = 5; - ANM2::Load(&this->_sprite,&tmpString,0); - ehState = 0xffffffff; - if (0xf < tmpString._capacity) { - uVar8 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar8 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) & 0xffffff00; - Sprite::ReplaceSpritesheet - (GHIDRA_CAST(&this->_sprite),0, - (std_string *) - (GHIDRA_INT(g_game->_room) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)) * 0x13c + 0x1e24)); - ANM2::LoadGraphics(&this->_sprite,unk_00); - } - pvVar6 = g_game->_room; - tintR = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72d0)); - tintG = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72d4)); - tintB = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72d8)); - tintA = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72dc)); - colorizeB = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72f8)); - colorizeR = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72e0)); - colorizeG = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72e4)); - colorizeB = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72e8)); - colorizeA = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72ec)); - color = &(this->_sprite)._color; - if (color != &roomColor) { - *GHIDRA_CAST((this->_sprite)._color._offset) = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x72f0)); - color->_tint[0] = tintR; - (this->_sprite)._color._tint[1] = tintG; - (this->_sprite)._color._tint[2] = tintB; - (this->_sprite)._color._tint[3] = tintA; - (this->_sprite)._color._offset[2] = colorizeB; - (this->_sprite)._color._colorize[0] = colorizeR; - (this->_sprite)._color._colorize[1] = colorizeG; - (this->_sprite)._color._colorize[2] = colorizeB; - (this->_sprite)._color._colorize[3] = colorizeA; - } - this->_doorFlags = this->_doorFlags | 2; - offsetLength = 0.0; - goto LAB_0070eb83; - } - targetRoomType = this->_targetRoomType; - if ((((targetRoomType == 7) || (iVar4 == 8)) || (targetRoomType == 8)) || - ((iVar4 == 0x1d || (targetRoomType == 0x1d)))) { - if ((this->_targetRoomType == 7) || ((iVar4 == 8 || (this->_targetRoomType == 8)))) - goto LAB_0070e8c5; - goto LAB_0070e980; - } - iVar4 = get_secret_exit_kind(this); - if (iVar4 == 0) { - bVar3 = IsRoomType(this,10); - if ((bVar3 != 0) || - (((uVar8 = Level::GetCurses(GHIDRA_CAST(g_game)), (uVar8 & 0x10) != 0 && - (this->_targetRoomType == 1)) && (this->_currentRoomType == 1)))) { - msvc::string::string_from_cstr - (local_c8 + 0x14,GHIDRA_CAST("gfx/grid/Door_04_SelfSacrificeRoomDoor.anm2")); - ehState = 0xd; - ANM2::Load(&this->_sprite,GHIDRA_CAST((local_c8 + 0x14)),1); - ehState = 0xffffffff; - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::_Tidy_deallocate(); - bVar3 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x97); - if ((bVar3 != 0) || (this->_varData == 1)) { - uVar8 = 0; - bVar3 = extraout_CL_10; - if ((this->_sprite)._layerCount != 0) { - do { - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = GHIDRA_CAST(0x0); - (GHIDRA_CAST((tmpString._buf)))->msvc::string::assign(GHIDRA_CAST("gfx/grid/door_04_selfsacrificeroomdoor_nospikes.png"),0x33); - ehState = 0xe; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(uVar8,&tmpString); - ehState = 0xffffffff; - bVar3 = extraout_CL_11; - if (0xf < tmpString._capacity) { - uVar9 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar9) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar9 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) - goto LAB_0070d535; - } - operator_delete(pcVar7,uVar9); - bVar3 = extraout_CL_12; - } - uVar8 = uVar8 + 1; - } while (uVar8 < GHIDRA_UINT((this->_sprite)._layerCount)); - } - ANM2::LoadGraphics(&this->_sprite,bVar3); - this->_varData = 1; - } - this->_doorFlags = this->_doorFlags | 4; - goto LAB_0070eb83; - } - bVar3 = IsRoomType(this,9); - if (bVar3 != 0) { - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_05_ArcadeRoomDoor.anm2")) - ; - ehState = 0xf; - ANM2::Load(&this->_sprite,&doorAnmPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyClosed"),9); - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(s_Open,4); - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyOpen"),7); - ANM2::LoadGraphics(&this->_sprite,unk); - this->_doorFlags = this->_doorFlags | 1; - goto LAB_0070eb83; - } - if (this->_targetRoomType == 0x17) { - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_32_ExitDoor.anm2")); - ehState = 0x10; - ANM2::Load(&this->_sprite,&doorAnmPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(s_Open,4); - goto LAB_0070eb83; - } - bVar3 = IsRoomType(this,4); - game = g_game; - if (bVar3 != 0) { - bVar3 = Game::IsGreedMode(g_game); - if (((bVar3 == 0) || (game->_greedModeTreasureRoomIdx == this->_targetRoomIdx)) || - (game->_greedModeTreasureRoomIdx == game->_currentRoomIdx)) { - roomDesc = Game::GetCurrentRoomDesc(game); - if (((GHIDRA_UINT(roomDesc->Flags) >> 0xb & 1) == 0) && - (roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1), - (GHIDRA_UINT(roomDesc->Flags) >> 0xb & 1) == 0)) { - msvc::string::string_from_cstr - (doorAnmPath._buf,GHIDRA_CAST("gfx/grid/Door_02_TreasureRoomDoor.anm2")); - ehState = 0x13; - } - else { - msvc::string::string_from_cstr - (doorAnmPath._buf,GHIDRA_CAST("gfx/grid/Door_02_TreasureRoomDoor_Devil.anm2")); - ehState = 0x12; - } - } - else { - msvc::string::string_from_cstr - (doorAnmPath._buf,GHIDRA_CAST("gfx/grid/Door_31_TreasureRoomDoorGreed.anm2")); - ehState = 0x11; - } -LAB_0070dd51: - ANM2::Load(&this->_sprite,&doorAnmPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(s_Open,4); - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyOpen"),7); - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyClosed"),9); - goto LAB_0070eb83; - } - bVar3 = IsRoomType(this,0x18); - if (bVar3 != 0) { - msvc::string::string_from_cstr - (doorAnmPath._buf,GHIDRA_CAST("gfx/grid/Door_00x_PlanetariumDoor.anm2")); - ehState = 0x14; - goto LAB_0070dd51; - } - bVar3 = IsRoomType(this,0x11); - game = g_game; - if (bVar3 != 0) { - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_15_BossRushDoor.anm2")); - ehState = 0x15; - ANM2::Load(&this->_sprite,&doorAnmPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::_Tidy_deallocate(); -LAB_0070e789: - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Opened"),6); - goto LAB_0070eb83; - } - if ((this->_targetRoomIdx == -8) || (g_game->_currentRoomIdx == -8)) { - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/door_29_doortobluewomb.anm2")); - ehState = 0x16; - ANM2::Load(&this->_sprite,GHIDRA_CAST((local_c8 + 0x14)),0); - ehState = 0xffffffff; - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::_Tidy_deallocate(); - bVar3 = extraout_CL_07; - if ((g_game->_currentRoomIdx == -8) && (uVar8 = 0, (this->_sprite)._layerCount != 0)) { - do { - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = GHIDRA_CAST(0x0); - (GHIDRA_CAST((tmpString._buf)))->msvc::string::assign(GHIDRA_CAST("gfx/grid/door_29_doortobluewomb_blue.png"),0x28); - ehState = 0x17; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(uVar8,&tmpString); - ehState = 0xffffffff; - bVar3 = extraout_CL_08; - if (0xf < tmpString._capacity) { - uVar9 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar9) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar9 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) - goto LAB_0070d535; - } - operator_delete(pcVar7,uVar9); - bVar3 = extraout_CL_09; - } - uVar8 = uVar8 + 1; - } while (uVar8 < GHIDRA_UINT((this->_sprite)._layerCount)); - } - ANM2::LoadGraphics(&this->_sprite,bVar3); - goto LAB_0070e789; - } - if ((this->_targetRoomIdx == -7) || (g_game->_currentRoomIdx == -7)) { - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_24_MegaSatanDoor.anm2")); - ehState = 0x18; - ANM2::Load(&this->_sprite,GHIDRA_CAST((local_c8 + 0x14)),1); - ehState = 0xffffffff; - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST(((this->_closeAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Closed"),6); - goto LAB_0070eb83; - } - if (g_game->_stage == 9) { - bVar3 = IsRoomType(this,5); - if ((((bVar3 != 0) && (-1 < game->_currentRoomIdx)) && (-1 < this->_targetRoomIdx)) || - ((this->_targetRoomIdx == -9 || (game->_currentRoomIdx == -9)))) { - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/door_30_HushDoor.anm2")); - ehState = 0x19; - ANM2::Load(&this->_sprite,&doorAnmPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST(((this->_closeAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Closed"),6); - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Closed"),6); - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Opening"),7); - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Opening"),7); - goto LAB_0070eb83; - } - } - bVar3 = IsRoomType(this,5); - if (bVar3 == 0) { - bVar3 = IsRoomType(this,0xb); - if (bVar3 != 0) { - roomDesc = Game::GetCurrentRoomDesc(game); - targetRoomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - pvVar6 = roomDesc->Data; - if (((pvVar6 == (void *)0x0) || - (targetRoomData = targetRoomDesc->Data, targetRoomData == (void *)0x0)) || - (((*GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 8)) != 0xb || (*GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x10)) != 1)) && - ((*GHIDRA_CAST((GHIDRA_CAST(targetRoomData) + 8)) != 0xb || - (*GHIDRA_CAST((GHIDRA_CAST(targetRoomData) + 0x10)) != 1)))))) { - msvc::string::string_from_cstr - (ambushDoorPath._buf,GHIDRA_CAST("gfx/grid/Door_03_AmbushRoomDoor.anm2")); - ehState = 0x1c; - ANM2::Load(&this->_sprite,&ambushDoorPath,1); - pathString = &ambushDoorPath; - } - else { - msvc::string::string_from_cstr - (bossAmbushDoorPath._buf,GHIDRA_CAST("gfx/grid/Door_09_BossAmbushRoomDoor.anm2")); - ehState = 0x1b; - ANM2::Load(&this->_sprite,&bossAmbushDoorPath,1); - pathString = &bossAmbushDoorPath; - } - ehState = 0xffffffff; - (GHIDRA_CAST((pathString->_buf)))->msvc::string::_Tidy_deallocate(); - this->_doorFlags = this->_doorFlags | 8; - goto LAB_0070eb83; - } - bVar3 = IsRoomType(this,0xe); - if (bVar3 != 0) { - roomDesc = Game::GetCurrentRoomDesc(game); - if (((GHIDRA_UINT(roomDesc->Flags) >> 0xb & 1) == 0) && - (roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1), - (GHIDRA_UINT(roomDesc->Flags) >> 0xb & 1) == 0)) { - msvc::string::string_from_cstr - (devilRoomDoorPath._buf,GHIDRA_CAST("gfx/grid/Door_07_DevilRoomDoor.anm2")); - ehState = 0x1e; - ANM2::Load(&this->_sprite,&devilRoomDoorPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((devilRoomDoorPath._buf)))->msvc::string::_Tidy_deallocate(); - } - else { - msvc::string::string_from_cstr - (devilTreasureDoorPath._buf, - GHIDRA_CAST("gfx/grid/Door_02_TreasureRoomDoor_Devil.anm2")); - ehState = 0x1d; - ANM2::Load(&this->_sprite,&devilTreasureDoorPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((devilTreasureDoorPath._buf)))->msvc::string::_Tidy_deallocate(); - } - goto LAB_0070eb83; - } - bVar3 = IsRoomType(this,0xf); - if (bVar3 != 0) { - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_07_HolyRoomDoor.anm2")); - ehState = 0x1f; - ANM2::Load(&this->_sprite,GHIDRA_CAST((local_c8 + 0x14)),1); - ehState = 0xffffffff; - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::_Tidy_deallocate(); - goto LAB_0070eb83; - } - roomData = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 4)) + 0x10)); - if ((roomData != GHIDRA_CAST(0x0)) && (*roomData == 0x23)) { - sprite = &this->_sprite; - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_House.anm2")); - ehState = 0x20; - ANM2::Load(sprite,GHIDRA_CAST((local_c8 + 0x14)),0); - ehState = 0xffffffff; - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::_Tidy_deallocate(); - layer = ANM2::GetLayer(sprite,GHIDRA_CAST(0x3)); - layer->_visible = 0; - layer = ANM2::GetLayer(sprite,&DAT_00000004); - game = g_game; - layer->_visible = 0; - iVar4 = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 4)); - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(game),this->_targetRoomIdx,-1); - if ((iVar4 == 0) || - ((targetRoomType = *GHIDRA_CAST((iVar4 + 0x10)), targetRoomType == 0 || - (*GHIDRA_CAST((targetRoomType + 8)) != 1)))) { - targetRoomType = -1; - } - else { - targetRoomType = *GHIDRA_CAST((targetRoomType + 0x10)); - } - if (((roomDesc == GHIDRA_CAST(0x0)) || (pvVar6 = roomDesc->Data, pvVar6 == (void *)0x0) - ) || (*GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 8)) != 1)) { - iVar5 = -1; - } - else { - iVar5 = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x10)); - } - if ((targetRoomType == 0) || (iVar5 == 0)) { - uVar8 = 0; - if ((this->_sprite)._layerCount != 0) { - do { - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = GHIDRA_CAST(0x0); - (GHIDRA_CAST((tmpString._buf)))->msvc::string::assign(GHIDRA_CAST("gfx/grid/door_house_cracked.png"),0x1f); - ehState = 0x21; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(uVar8,&tmpString); - ehState = 0xffffffff; - if (0xf < tmpString._capacity) { - uVar9 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar9) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar9 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) - goto LAB_0070d535; - } - operator_delete(pcVar7,uVar9); - } - uVar8 = uVar8 + 1; - } while (uVar8 < GHIDRA_UINT((this->_sprite)._layerCount)); - } - } - else { - uVar8 = *GHIDRA_CAST((iVar4 + 0x44)); - if ((((uVar8 >> 10 & 1) != 0) || ((GHIDRA_UINT(roomDesc->Flags) >> 10 & 1) != 0)) || - (g_game->_currentDimensionIdx == 2)) { - uVar9 = 0; - if ((this->_sprite)._layerCount != 0) { - do { - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = GHIDRA_CAST(0x0); - (GHIDRA_CAST((tmpString._buf)))->msvc::string::assign(GHIDRA_CAST("gfx/grid/door_closet_red.png"),0x1c); - ehState = 0x22; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(uVar9,&tmpString); - ehState = 0xffffffff; - if (0xf < tmpString._capacity) { - uVar8 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar8 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) - goto LAB_0070d535; - } - operator_delete(pcVar7,uVar8); - } - uVar9 = uVar9 + 1; - } while (uVar9 < GHIDRA_UINT((this->_sprite)._layerCount)); - uVar8 = *GHIDRA_CAST((iVar4 + 0x44)); - } - if ((((uVar8 >> 10 & 1) != 0) && ((GHIDRA_UINT(roomDesc->Flags) >> 10 & 1) == 0)) && - (g_game->_stageType == 0)) { - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x3)); - layer->_visible = 1; - layer = ANM2::GetLayer(&this->_sprite,&DAT_00000004); - layer->_visible = 1; - } - } - } - sprite = &this->_sprite; - if (iVar5 == 2) { - (GHIDRA_CAST((GHIDRA_CAST(local_c8))))->Color::Color(0.9,0.7,1.0,1.0); - color = extraout_EAX; - layer = ANM2::GetLayer(sprite,GHIDRA_CAST(0x0)); - (GHIDRA_CAST((GHIDRA_CAST(&layer->_color))))->Color::operator_assign(color); - } - if (g_game->_stageType == 1) { - (GHIDRA_CAST((GHIDRA_CAST(local_c8))))->Color::Color(); - color = extraout_EAX_00; - layer = ANM2::GetLayer(sprite,GHIDRA_CAST(0x0)); - (GHIDRA_CAST((GHIDRA_CAST(&layer->_color))))->Color::__mul(color); - } - iVar4 = this->_direction; - (this->_sprite)._flipX = iVar4 == 3; - (this->_sprite)._flipY = iVar4 == 2; - ANM2::LoadGraphics(sprite,(uint8_t)iVar4); - goto LAB_0070eb83; - } - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_01_NormalDoor.anm2")); - ehState = 0x23; - ANM2::Load(&this->_sprite,GHIDRA_CAST((local_c8 + 0x14)),0); - ehState = 0xffffffff; - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::_Tidy_deallocate(); - game = g_game; - if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) >> 10 & 1) == 0) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - game = extraout_ECX; - if ((GHIDRA_UINT(roomDesc->Flags) >> 10 & 1) != 0) goto LAB_0070e564; - bVar3 = IsRoomType(this,2); - if (bVar3 != 0) { - local_190 = GHIDRA_CAST(0xb68c48); - bVar3 = extraout_CL; - goto LAB_0070e56f; - } - bVar3 = IsRoomType(this,0x14); - if (bVar3 != 0) { - local_190 = GHIDRA_CAST(0xb68c68); - bVar3 = extraout_CL_00; - goto LAB_0070e56f; - } - bVar3 = IsRoomType(this,0xc); - if (bVar3 != 0) { - local_190 = GHIDRA_CAST(0xb68c8c); - bVar3 = extraout_CL_01; - goto LAB_0070e56f; - } - bVar3 = IsRoomType(this,0x15); - if (bVar3 != 0) { - local_190 = GHIDRA_CAST(0xb68cb0); - bVar3 = extraout_CL_02; - goto LAB_0070e56f; - } - bVar3 = IsRoomType(this,0xd); - if (bVar3 != 0) { - local_190 = GHIDRA_CAST(0xb68da4); - bVar3 = extraout_CL_03; - goto LAB_0070e56f; - } - local_190 = (GHIDRA_CAST((GHIDRA_CAST((GHIDRA_INT(g_game->_room) + - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)) * 0x13c + - 0x1e0c)))))->msvc::string::c_str(); - bVar3 = extraout_CL_04; - if (local_190 != GHIDRA_CAST(0x0)) goto LAB_0070e56f; - } - else { -LAB_0070e564: - bVar3 = (uint8_t)game; - local_190 = GHIDRA_CAST(0xb68d30); -LAB_0070e56f: - uVar8 = 0; - if ((this->_sprite)._layerCount != 0) { - do { - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = GHIDRA_CAST(0x0); - pathEnd = local_190; - do { - bVar3 = *pathEnd; - pathEnd = pathEnd + 1; - } while (bVar3 != 0); - (GHIDRA_CAST((tmpString._buf)))->msvc::string::assign(local_190,GHIDRA_INT(pathEnd) - GHIDRA_INT((local_190 + 1))); - ehState = 0x24; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(uVar8,&tmpString); - ehState = 0xffffffff; - bVar3 = extraout_CL_05; - if (0xf < tmpString._capacity) { - uVar9 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar9) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar9 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) - goto LAB_0070d535; - } - operator_delete(pcVar7,uVar9); - bVar3 = extraout_CL_06; - } - uVar8 = uVar8 + 1; - } while (uVar8 < GHIDRA_UINT((this->_sprite)._layerCount)); - } - } - ANM2::LoadGraphics(&this->_sprite,bVar3); - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyClosed"),9); - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyOpen"),7); - goto LAB_0070eb83; - } - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_10_BossRoomDoor.anm2")); - ehState = 0x1a; - ANM2::Load(&this->_sprite,&doorAnmPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::_Tidy_deallocate(); - layer = ANM2::GetLayer(&this->_sprite,&DAT_00b1ce2c); - if (this->_targetRoomType == 5) { - layer->_visible = 1; - goto LAB_0070eb83; - } - goto LAB_0070db6f; - } - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(s_Open,4); - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyOpen"),7); - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("KeyClosed"),9); - iVar4 = get_secret_exit_kind(this); - switch(iVar4) { - case 1: - anmPath._size = 0; - anmPath._capacity = 0xf; - anmPath._buf[0] = '\0'; - anmPath._buf[1] = '\0'; - anmPath._buf[2] = '\0'; - anmPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - anmPath._size = 0x1b; - anmPath._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anmPath._buf))) + 0x0))),"gfx/grid/Door_Downpour.anm2",0x1c); - ehState = 6; - ANM2::Load(&this->_sprite,&anmPath,1); - ehState = 0xffffffff; - if (0xf < anmPath._capacity) { - uVar8 = anmPath._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anmPath._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) + -4)); - uVar8 = anmPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - anmPath._size = 0; - anmPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) & 0xffffff00; - break; - case 2: - tmpString._size = 0; - tmpString._capacity = 0xf; - tmpString._buf[0] = '\0'; - tmpString._buf[1] = '\0'; - tmpString._buf[2] = '\0'; - tmpString._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = msvc::_Allocate(0x20); - tmpString._size = 0x18; - tmpString._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))),"gfx/grid/Door_Mines.anm2",0x19); - ehState = 7; - ANM2::Load(&this->_sprite,&tmpString,1); - ehState = 0xffffffff; - if (0xf < tmpString._capacity) { - uVar8 = tmpString._capacity + 1; - pcVar7 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tmpString._buf))) + 0x0))); - if (0xfff < uVar8) { - pcVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4)); - uVar8 = tmpString._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar7))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar7,uVar8); - } - (GHIDRA_CAST((secretExitPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_Mines_Planks.anm2")); - ehState = 8; - ANM2::Load(&this->_extraSprite,&secretExitPath,1); - pathString = &secretExitPath; - goto LAB_0070db14; - case 3: - bVar3 = Level::HasPhotoDoor(GHIDRA_CAST(g_game)); - if (bVar3 == 0) { - (GHIDRA_CAST((mausoleumDoorPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_Mausoleum.anm2")); - ehState = 10; - ANM2::Load(&this->_sprite,&mausoleumDoorPath,1); - pathString = &mausoleumDoorPath; - goto LAB_0070db14; - } - (GHIDRA_CAST((secretExitPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_Mausoleum_Alt.anm2")); - ehState = 9; - ANM2::Load(&this->_sprite,&secretExitPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((secretExitPath._buf)))->msvc::string::_Tidy_deallocate(); - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x1)); - layer->_visible = 1; - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x2)); - layer->_visible = 0; - layer = ANM2::GetLayer(&this->_sprite,&DAT_00000004); - layer->_visible = 0; - this->_doorFlags = this->_doorFlags | 0x40; - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(s_Open,4); - break; - case 4: - (GHIDRA_CAST((momsHeartDoorPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_MomsHeart.anm2")); - ehState = 0xb; - ANM2::Load(&this->_sprite,&momsHeartDoorPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((momsHeartDoorPath._buf)))->msvc::string::_Tidy_deallocate(); - bVar1 = false; - if (g_game->_currentRoomIdx == -10) { - (GHIDRA_CAST(((this->_closeAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Disappear"),9); - } - break; - default: - (GHIDRA_CAST((doorAnmPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/Door_01_NormalDoor.anm2")); - ehState = 0xc; - ANM2::Load(&this->_sprite,&doorAnmPath,1); - pathString = &doorAnmPath; -LAB_0070db14: - ehState = 0xffffffff; - (GHIDRA_CAST((pathString->_buf)))->msvc::string::_Tidy_deallocate(); - } - if (this->_targetRoomType != 0x1b) { - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST("Background")); - if (layer != GHIDRA_CAST(0x0)) { - (layer->_color)._colorize[0] = 0.5; - (layer->_color)._colorize[1] = 0.5; - (layer->_color)._colorize[2] = 0.5; - (layer->_color)._colorize[3] = 0.6; - } - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST("Light")); - if (layer != GHIDRA_CAST(0x0)) { -LAB_0070db6f: - layer->_visible = 0; - } - } -LAB_0070eb83: - payToPlayOwner = - PlayerManager::FirstCollectibleOwner - (&g_game->_playerManager,0x17c,GHIDRA_CAST(&g_game->_playerManager),1); - if ((((payToPlayOwner != GHIDRA_CAST(0x0)) || (g_game->_challenge == 0x18)) && - ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1 || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2)))) && - ((this->_currentRoomType != 9 && (this->_targetRoomType != 9)))) { - pathString = &this->_openLockedAnimation; - if (0xf < (this->_openLockedAnimation)._capacity) { - pathString = *GHIDRA_CAST((this->_openLockedAnimation)._buf); - } - bVar3 = str_eq(GHIDRA_CAST(pathString),(this->_openLockedAnimation)._size,GHIDRA_CAST("KeyOpen"),7); - if ((bVar3 != 0) || (g_game->_challenge == 0x18)) { - pvVar6 = ANM2::GetAnimationData(&this->_sprite,GHIDRA_CAST("CoinClosed")); - if (pvVar6 != (void *)0x0) { - (GHIDRA_CAST(((this->_lockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("CoinClosed"),10); - (GHIDRA_CAST(((this->_openLockedAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("CoinOpen"),8); - } - this->_doorFlags = this->_doorFlags | 1; - } - } - colorizeB = ((this->_sprite)._rotation + 90.0) * 0.017453292; - tintR = sin(colorizeB); - colorizeB = cos(colorizeB); - (this->_sprite)._offset.x = colorizeB * offsetLength; - (this->_sprite)._offset.y = tintR * offsetLength; - bVar3 = (this->_extraSprite)._loaded; - (this->_extraSprite)._offset.x = colorizeB * offsetLength; - (this->_extraSprite)._offset.y = (this->_sprite)._offset.y; - if ((bVar3 == 0) && (bVar1)) { - iVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (iVar4 == 2) { - tmpString._size = 0; - tmpString._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) = (void *)0x0; - (GHIDRA_CAST((tmpString._buf)))->msvc::string::assign(GHIDRA_CAST("gfx/grid/door_16_doublelock.anm2"),0x20); - ehState = 0x25; - ANM2::Load(&this->_extraSprite,&tmpString,1); - if (0xf < tmpString._capacity) { - uVar8 = tmpString._capacity + 1; - pvVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)tmpString._buf)) + 0x0))); - if (0xfff < uVar8) { - pvVar6 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + -4); - uVar8 = tmpString._capacity + 0x24; - if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(tmpString._buf)) + 0x0))) + (-4 - GHIDRA_INT(pvVar6))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pvVar6,uVar8); - } - } - else if (iVar4 == 3) { - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/door_18_crackeddoor.anm2")); - ehState = 0x26; - ANM2::Load(&this->_extraSprite,GHIDRA_CAST((local_c8 + 0x14)),1); - (GHIDRA_CAST((local_c8 + 0x14)))->msvc::string::_Tidy_deallocate(); - } - else if ((iVar4 == 4) || (iVar4 == 6)) { - (GHIDRA_CAST((barDoorPath._buf)))->msvc::string::string_from_cstr(GHIDRA_CAST("gfx/grid/door_17_bardoor.anm2")); - ehState = 0x27; - ANM2::Load(&this->_extraSprite,&barDoorPath,1); - ehState = 0xffffffff; - (GHIDRA_CAST((barDoorPath._buf)))->msvc::string::_Tidy_deallocate(); - (GHIDRA_CAST(((this->_closeAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Closed"),6); - } - } - this->_isExtraVisible = 0; - ExceptionList = savedExceptionList; - return; -} - -// 0070ee40 -void GridEntity_Door::UpdateAnimation() -{ - int iVar1; - uint8_t bVar2; - LayerState *layer; - Entity_Player *player; - uint8_t *animNameCursor; - uint32_t uVar3; - int iVar4; - char *pcVar5; - std_string *expectedName; - uint8_t *variantPtr; - std_string *animName; - GridEntity_Door *variantRef; - Sprite *sprite; - bool bVar6; - EntityList_EL familiars; - int roomAge; - int spawnAge; - GridEntity_Door *local_18; - GridEntity_Door *local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - uint8_t *animData; - Game *game; - int variant; - - game = g_game; - local_8 = 0xffffffff; - puStack_c = &LAB_00afc96d; - local_10 = ExceptionList; - if ((this->_sprite)._loaded == 0) { - return; - } - ExceptionList = &local_10; - this->_isExtraVisible = 0; - roomAge = game->_frameCount; - pcVar5 = game->_room; - spawnAge = roomAge - this->_spawnFrame; - if (*pcVar5 == '\0') { - roomAge = -1; - } - else { - roomAge = roomAge - *GHIDRA_CAST((pcVar5 + 0x11f0)); - } - sprite = GHIDRA_CAST(&this->_sprite); - local_18 = this; - layer = ANM2::GetLayer(GHIDRA_CAST(sprite),GHIDRA_CAST(0x0)); - layer->_visible = 1; - iVar4 = this->_targetRoomType; - if (iVar4 == 0) { - ExceptionList = local_10; - return; - } - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if ((((iVar1 == 1) || (iVar1 == 4)) || (iVar1 == 3)) || (iVar1 == 5)) { - iVar1 = this->_currentRoomType; - if (((((iVar1 == 7) || (iVar4 == 7)) || ((iVar1 == 8 || ((iVar4 == 8 || (iVar1 == 0x1d)))))) || - (iVar4 == 0x1d)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 7)) { - ANM2::Play(GHIDRA_CAST(sprite),GHIDRA_CAST("Hidden"),0); - variantRef = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - else { - variantPtr = &(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))); - variant = *GHIDRA_CAST(variantPtr); - local_18 = GHIDRA_CAST(variantPtr); - if (variant == 1) { - if ((((iVar1 == 0x1b) || (iVar4 == 0x1b)) && - (iVar4 = get_secret_exit_kind(this), iVar4 == 3)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 3)) { - bVar2 = ANM2::SetAnimation(GHIDRA_CAST(sprite),&DAT_00b68d9c,1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - this->_previousState = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - this->_previousVariant = *GHIDRA_CAST(variantPtr); - ExceptionList = local_10; - return; - } - animName = &this->_lockedAnimation; - if (0xf < (this->_lockedAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - animData = (this->_sprite)._animState._animData; - if (animData == GHIDRA_CAST(0x0)) { -LAB_0070f2ee: - bVar2 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(animName),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameCursor = *GHIDRA_CAST(animData); - } - expectedName = animName; - do { - bVar2 = *animNameCursor; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[0]; - if (bVar2 != expectedName->_buf[0]) { -LAB_0070f2d0: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0070f2d5; - } - if (bVar2 == 0) break; - bVar2 = animNameCursor[1]; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[1]; - if (bVar2 != expectedName->_buf[1]) goto LAB_0070f2d0; - animNameCursor = animNameCursor + 2; - expectedName = GHIDRA_CAST((expectedName->_buf + 2)); - } while (bVar2 != 0); - uVar3 = 0; -LAB_0070f2d5: - if ((uVar3 != 0) || - ((animData[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_0070f2ee; - } - variantRef = local_18; -LAB_0070f30b: - local_14 = variantRef; - } - else if ((((variant == 4) || (variant == 3)) || (variant == 2)) || (variant == 6)) { - animName = &this->_closeAnimation; - if (0xf < (this->_closeAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - animData = (this->_sprite)._animState._animData; - if (animData == GHIDRA_CAST(0x0)) { -LAB_0070f4b6: - bVar2 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(animName),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameCursor = *GHIDRA_CAST(animData); - } - expectedName = animName; - do { - bVar2 = *animNameCursor; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[0]; - if (bVar2 != expectedName->_buf[0]) { -LAB_0070f4a0: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0070f4a5; - } - if (bVar2 == 0) break; - bVar2 = animNameCursor[1]; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[1]; - if (bVar2 != expectedName->_buf[1]) goto LAB_0070f4a0; - animNameCursor = animNameCursor + 2; - expectedName = GHIDRA_CAST((expectedName->_buf + 2)); - } while (bVar2 != 0); - uVar3 = 0; -LAB_0070f4a5: - if ((uVar3 != 0) || - ((animData[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_0070f4b6; - } - if ((this->_doorFlags & 0x20) == 0) { - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::SetLastFrame(); - } - variantRef = local_18; - local_14 = local_18; - if ((this->_extraSprite)._loaded != 0) { - iVar4 = *GHIDRA_CAST(local_18); - this->_isExtraVisible = 1; - if (iVar4 == 2) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 3) { - ANM2::Play(&this->_extraSprite,GHIDRA_CAST("TwoChains"),0); - goto LAB_0070f311; - } - if (this->_previousState == 3) { - pcVar5 = "OneChain"; - } - else { - player = Game::GetPlayer(g_game,0); - pcVar5 = "GoldenKeyOpenChain1"; - if (player->_hasGoldenKey == 0) { - pcVar5 = "KeyOpenChain1"; - } - } - ANM2::Play(&this->_extraSprite,GHIDRA_CAST(pcVar5),0); - local_14 = variantRef; - } - else { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 4) { - pcVar5 = "Damaged"; - } - else if (((iVar4 != 4) && (iVar4 != 6)) || (pcVar5 = "Appear", spawnAge < 0xb)) { - pcVar5 = GHIDRA_CAST(s_Idle); - } - ANM2::Play(&this->_extraSprite,GHIDRA_CAST(pcVar5),0); - if (((this->_currentRoomType == 0x1b) || (this->_targetRoomType == 0x1b)) && - (iVar4 = get_secret_exit_kind(this), iVar4 == 2)) { - iVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x2)); - layer->_visible = iVar4 != 4; - variantRef = local_18; - } - local_14 = variantRef; - } - } - } - else { - local_14 = GHIDRA_CAST(variantPtr); - if ((this->_closeAnimation)._size != 0) { - animName = &this->_closeAnimation; - if (0xf < (this->_closeAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - animData = (this->_sprite)._animState._animData; - if (animData == GHIDRA_CAST(0x0)) { -LAB_0070f3fe: - bVar2 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(animName),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameCursor = *GHIDRA_CAST(animData); - } - expectedName = animName; - do { - bVar2 = *animNameCursor; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[0]; - if (bVar2 != expectedName->_buf[0]) { -LAB_0070f3e0: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0070f3e5; - } - if (bVar2 == 0) break; - bVar2 = animNameCursor[1]; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[1]; - if (bVar2 != expectedName->_buf[1]) goto LAB_0070f3e0; - animNameCursor = animNameCursor + 2; - expectedName = GHIDRA_CAST((expectedName->_buf + 2)); - } while (bVar2 != 0); - uVar3 = 0; -LAB_0070f3e5: - if ((uVar3 != 0) || - ((animData[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_0070f3fe; - } - variantRef = local_18; - local_14 = local_18; - if (((this->_extraSprite)._loaded == 0) || (local_14 = local_18, *GHIDRA_CAST(local_18) == 8)) - goto LAB_0070f30e; - this->_isExtraVisible = 1; - ANM2::Play(&this->_extraSprite,GHIDRA_CAST("Appear"),0); - goto LAB_0070f30b; - } - } -LAB_0070f30e: - variantRef = local_14; - } -LAB_0070f311: - if (((spawnAge < roomAge) || - ((((this->_doorFlags & 8) != 0 && (this->_slot != g_game->_enterDoor)) && (spawnAge == 0)))) - && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::AdvancePosition - (&(this->_sprite)._animState, - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1); - } - goto LAB_0070f174; - } - if (((iVar4 == 5) && (-1 < this->_targetRoomIdx)) && (g_game->_stage == 9)) { - bVar6 = true; - } - else { - bVar6 = false; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) { - player = Game::GetPlayer(g_game,0); - if (((player->_hasGoldenKey == 0) || (bVar2 = IsRoomType(this,9), bVar2 != 0)) || - ((bVar2 = IsRoomType(this,0xb), bVar2 != 0 || - ((player = PlayerManager::FirstCollectibleOwner - (&g_game->_playerManager,0x17c,GHIDRA_CAST(&g_game->_playerManager),1), - player != GHIDRA_CAST(0x0) || (bVar6)))))) { - animName = &this->_openLockedAnimation; - if (0xf < (this->_openLockedAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - animData = (this->_sprite)._animState._animData; - if (animData != GHIDRA_CAST(0x0)) { - animNameCursor = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameCursor = *GHIDRA_CAST(animData); - } - expectedName = animName; - do { - bVar2 = *animNameCursor; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[0]; - if (bVar2 != expectedName->_buf[0]) { -LAB_0070efc2: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0070efc7; - } - if (bVar2 == 0) break; - bVar2 = animNameCursor[1]; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[1]; - if (bVar2 != expectedName->_buf[1]) goto LAB_0070efc2; - animNameCursor = animNameCursor + 2; - expectedName = GHIDRA_CAST((expectedName->_buf + 2)); - } while (bVar2 != 0); - uVar3 = 0; -LAB_0070efc7: - if ((uVar3 == 0) && - ((sprite = GHIDRA_CAST(&this->_sprite), animData[0x34] == 0 || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0070f148; - } - sprite = GHIDRA_CAST(&this->_sprite); - bVar2 = ANM2::SetAnimation(GHIDRA_CAST(sprite),GHIDRA_CAST(animName),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - goto LAB_0070f145; - } - } - else { - ANM2::Play(GHIDRA_CAST(sprite),GHIDRA_CAST("GoldenKeyOpen"),0); - } - } - else { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2) { - bVar2 = 0; - player = Game::GetPlayer(g_game,0); - pcVar5 = "KeyOpenChain2"; - if (player->_hasGoldenKey != 0) { - pcVar5 = "GoldenKeyOpenChain2"; - } - ANM2::Play(&this->_extraSprite,GHIDRA_CAST(pcVar5),bVar2); - this->_isExtraVisible = 1; - } - animName = &this->_openAnimation; - if (0xf < (this->_openAnimation)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - animData = (this->_sprite)._animState._animData; - if (animData == GHIDRA_CAST(0x0)) { -LAB_0070f0a0: - bVar2 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(animName),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameCursor = *GHIDRA_CAST(animData); - } - expectedName = animName; - do { - bVar2 = *animNameCursor; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[0]; - if (bVar2 != expectedName->_buf[0]) { -LAB_0070f085: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0070f08a; - } - if (bVar2 == 0) break; - bVar2 = animNameCursor[1]; - bVar6 = bVar2 < (uint8_t)expectedName->_buf[1]; - if (bVar2 != expectedName->_buf[1]) goto LAB_0070f085; - animNameCursor = animNameCursor + 2; - expectedName = GHIDRA_CAST((expectedName->_buf + 2)); - } while (bVar2 != 0); - uVar3 = 0; -LAB_0070f08a: - if ((uVar3 != 0) || ((animData[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_0070f0a0; - } - sprite = GHIDRA_CAST(&this->_sprite); - if (this->_targetRoomIdx == -7) { - EntityList::QuerySublist(GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&familiars,3,-1,-1,0,0); - local_8 = 0; - uVar3 = 0; - if (familiars._size != 0) { - do { - iVar4 = __RTDynamicCast(*GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(familiars)) + 0x4))) + uVar3 * 4)),0, - &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::Entity_Familiar::RTTI_Type_Descriptor,0); - if (*GHIDRA_CAST((iVar4 + 0x2c)) == 0xec) { - *GHIDRA_CAST((iVar4 + 0xd88)) = 1; - } - uVar3 = uVar3 + 1; - } while (uVar3 < GHIDRA_UINT(familiars._size)); - this = local_18; - } - local_8 = 0xffffffff; - (GHIDRA_CAST((&familiars)))->EntityList_Query::~EntityList_Query(); -LAB_0070f145: - sprite = GHIDRA_CAST(&this->_sprite); - } - } -LAB_0070f148: - if ((roomAge <= spawnAge) && - (((spawnAge < 10 && ((this->_doorFlags & 0x40) == 0)) || (spawnAge < 2)))) { - (GHIDRA_CAST((sprite)))->Sprite::SetLastFrame(); - this->_isExtraVisible = 0; - } - variantRef = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); -LAB_0070f174: - iVar4 = *GHIDRA_CAST(variantRef); - if (((iVar4 != 4) && (iVar4 != 6)) && - ((this->_previousVariant == 4 || (this->_previousVariant == 6)))) { - ANM2::Play(&this->_extraSprite,GHIDRA_CAST("Vanish"),0); - iVar4 = *GHIDRA_CAST(variantRef); - this->_isExtraVisible = 1; - } - this->_previousState = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - this->_previousVariant = iVar4; - ExceptionList = local_10; - return; -} - -// 0070f670 -uint8_t GridEntity_Door::CanTakeDamageFromTearEffects() -{ - return CONCAT31((uint3)(GHIDRA_UINT(this->_doorFlags) >> 0xc),~(uint8_t)(GHIDRA_UINT(this->_doorFlags) >> 4)) & - 0xffffff01; -} - -// 0070f680 -uint32_t GridEntity_Door::CanBlowOpen() -{ - uint8_t isCheck; - Entity_Player *padlockOwner; - int doorVariant; - int doorVariant; - Game *game; - void *room; - - if ((((g_game->_difficulty != 2) && (g_game->_difficulty != 3)) && - ((g_game->_stage == 0xb || (g_game->_stage == 0xc)))) && - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) & 1) == 0)) { - return 0; - } - if (this->_targetRoomType == 0) { - return 0; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - return 0; - } - if (g_game->_stage == 0xd) { - return 0; - } - isCheck = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x88); - game = g_game; - if (isCheck != 0) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) { - return 1; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2) { - return 1; - } - } - doorVariant = this->_currentRoomType; - if (doorVariant == 1) { - if (this->_targetRoomType == 1) { - doorVariant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if ((((doorVariant != 1) && (doorVariant != 4)) && (doorVariant != 2)) && (doorVariant != 5)) - { - return 1; - } -LAB_0070f748: - isCheck = IsRoomType(this,8); - if ((isCheck == 0) && (isCheck = IsRoomType(this,0x1d), isCheck == 0)) goto LAB_0070f79f; - } - else { -LAB_0070f73f: - if (this->_targetRoomType != 7) goto LAB_0070f748; - } - if (doorVariant == 5) goto LAB_0070f79f; - } - else if (doorVariant != 7) goto LAB_0070f73f; - if ((this->_targetRoomType != 5) && - (((room = game->_room, *GHIDRA_CAST((GHIDRA_CAST(room) + 0x7228)) == '\0' && (doorVariant != 6)) || - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x44)) & 1) != 0)))) { - if (doorVariant != 0xb) { - return 1; - } - if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x44)) >> 3 & 1) != 0) { - return 1; - } - } -LAB_0070f79f: - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 3) { - return 1; - } - if (((((this->_doorFlags & 9) != 0) || (this->_targetRoomType == 5)) || - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 5)) && - (padlockOwner = PlayerManager::FirstTrinketOwner(&game->_playerManager,0x88), - padlockOwner != GHIDRA_CAST(0x0))) { - doorVariant = Entity_Player::GetTrinketMultiplier(padlockOwner,0x88); - if (doorVariant == 2) { - if ((this->_doorFlags & 9) != 0) { - return 1; - } - doorVariant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - else { - if (doorVariant < 3) { - return 0; - } - doorVariant = this->_targetRoomType; - } - if (doorVariant == 5) { - return 1; - } - } - return 0; -} - -// 0070f810 -void GridEntity_Door::SpawnDust() -{ - Vector *doorDirection; - uint32_t rngResult; - uint32_t rngValue; - Entity *dustEntity; - int *dust; - int iVar1; - float fVar2; - float cosAngle; - float fVar3; - float negDirY; - uint8_t *sideSign; - int dustCount; - Vector dustVelocity; - Vector local_10; - float dirX; - int gridWidth; - - doorDirection = Isaac::GetAxisAlignedUnitVectorFromDir(&local_10,this->_direction); - dirX = doorDirection->x; - negDirY = -doorDirection->y; - rngResult = Random(); - dustCount = (rngResult & 3) + 3; - if (dustCount != 0) { - do { - rngResult = Random(); - rngValue = Random(); - fVar2 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * - 2.3283064e-10 * 5.0; - rngValue = Random(); - iVar1 = this->_gridIndex; - fVar3 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * - 2.3283064e-10 * 5.0 - 2.5; - dustVelocity.y = fVar3 * dirX + fVar2 * negDirY; - dustVelocity.x = fVar3 * negDirY + fVar2 * -dirX; - gridWidth = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - rngValue = Random(); - fVar2 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * - 2.3283064e-10 * 3.14; - fVar2 = fVar2 + fVar2; - rngValue = Random(); - fVar3 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * - 2.3283064e-10 * 20.0; - cosAngle = cos(fVar2); - local_10.x = cosAngle * fVar3 + (float)(iVar1 % gridWidth) * 40.0 + 40.0; - fVar2 = sin(fVar2); - local_10.y = fVar2 * fVar3 + (float)(iVar1 / gridWidth) * 40.0 + 120.0; - dustEntity = Game::SpawnEx(g_game,1000,0x3b,&local_10,&dustVelocity,GHIDRA_CAST(0x0),0,rngResult, - 0); - dust = GHIDRA_CAST(__RTDynamicCast(dustEntity,0,&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::Entity_Effect::RTTI_Type_Descriptor,0)); - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - sideSign = GHIDRA_CAST(0x3f800000); - if (((float)dust[0xcf] - ((float)(this->_gridIndex % iVar1) * 40.0 + 40.0)) * negDirY + - ((float)dust[0xd0] - ((float)(this->_gridIndex / iVar1) * 40.0 + 120.0)) * dirX < 0.0) { - sideSign = &DAT_bf800000; - } - rngResult = Random(); - dust[0x11d] = GHIDRA_INT((((float)((double)GHIDRA_INT(rngResult) + - __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 - * 10.0 + 2.0) * (float)sideSign)); - rngResult = Random(); - iVar1 = rngResult % 0xf + 0xf; - dust[0x117] = iVar1; - dust[0x118] = iVar1; - (**(code **)(*dust + 0xc))(); - dustCount = dustCount + -1; - } while (dustCount != 0); - } - return; -} - -// 0070fb60 -uint8_t GridEntity_Door::TryBlowOpen(uint8_t isFromExplosion, Entity *source) -{ - uint32_t *puVar1; - uint64_t qVar2; - char cVar3; - uint8_t bVar4; - ChallengeParam *challengeParams; - Entity_Player *player; - int iVar5; - ColorMod *color; - uint32_t rngResult; - ColorMod *color_00; - Entity *poof; - RoomDescriptor *targetRoomDesc; - ColorMod *color_01; - Vector *pVVar6; - ColorMod *color_02; - ColorMod *color_03; - uint32_t uVar7; - char *pcVar8; - int soundId; - Vector doorPos; - Color particleColor; - uint32_t stackCookie; - Game *game; - Manager *manager; - void *room; - int variant; - - stackCookie = __security_cookie ^ GHIDRA_UINT(&soundId); - if (((isFromExplosion == 0) && (source == GHIDRA_CAST(0x0))) && - (cVar3 = FUN_00711740(), cVar3 == '\0')) { - return 0; - } - if ((this->_doorFlags & 0x10) != 0) { - if (((g_game->_challenge != 0) || ((g_game->_dailyChallenge)._id != 0)) && - (challengeParams = Game::GetChallengeParams(g_game), challengeParams->_pathType == 2)) { - return 0; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - return 0; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - this->_isBusted = 1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - UpdateAnimation(this); - manager = g_manager; - soundId = 0x262; - seed_fart_sound_override(&soundId); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,1.0,0.0); - g_game->_levelStateFlags = g_game->_levelStateFlags | 0x800000; - if (source == GHIDRA_CAST(0x0)) { - return 1; - } - player = GHIDRA_CAST(Entity)::GetPlayerAncestor(source); - if (player == GHIDRA_CAST(0x0)) { - return 1; - } - Entity_Player::DonateLuck(player,-7); - return 1; - } - iVar5 = get_secret_exit_kind(this); - if (iVar5 == 4) { - if (source == GHIDRA_CAST(0x0)) { - return 0; - } - if (source->_type != 3) { - return 0; - } - if (source->_variant == 0xdf) { - (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&doorPos); - (GHIDRA_CAST((&particleColor)))->Color::Color(); - rngResult = Random(); - Game::SpawnParticles(g_game,&doorPos,4,rngResult % 5 + 6,8.0,color,100000.0,10); - (GHIDRA_CAST((&particleColor)))->Color::Color(); - rngResult = Random(); - Game::SpawnParticles(g_game,&doorPos,5,rngResult % 6 + 9,8.0,color_00,100000.0,0); - rngResult = Random(); - poof = Game::SpawnEx(g_game,1000,2,&doorPos,&g_vectorZero,GHIDRA_CAST(0x0),0,rngResult,0); - ANM2::Play(&poof->_sprite,GHIDRA_CAST("Poof_Large1"),0); - poof->_renderDepthOffset = 5.0; - manager = g_manager; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - this->_isBusted = 1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - soundId = 0x4d; - seed_fart_sound_override(&soundId); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,1.0,0.0); - manager = g_manager; - soundId = 0x1c; - seed_fart_sound_override(&soundId); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,1.0,0.0); - UpdateAnimation(this); - Game::UpdateVisibility(g_game); - game = g_game; - qVar2 = g_game->_gameStateFlags; - puVar1 = GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - *puVar1 = *puVar1 | 0x100000; - *GHIDRA_CAST(&game->_gameStateFlags) = GHIDRA_INT(qVar2); - return 1; - } - return 0; - } - iVar5 = this->_targetRoomType; - if (((iVar5 == 7) || (iVar5 == 8)) || (iVar5 == 0x1d)) { - bVar4 = 0xff; - iVar5 = this->_targetRoomIdx; - targetRoomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),iVar5,-1); - if ((targetRoomDesc->VisitedCount == 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 7)) { - (GHIDRA_CAST((GHIDRA_CAST(&g_manager->_musicManager))))->Music::PlayJingle(0x55,iVar5,bVar4); - } - } - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 7) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 0)) { - Level::UncoverHiddenDoor(GHIDRA_CAST(g_game),g_game->_currentRoomIdx,this->_slot); - } - if (((((g_game->_difficulty != 2) && (g_game->_difficulty != 3)) && - ((g_game->_stage == 0xb || (g_game->_stage == 0xc)))) && - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) & 1) == 0)) || - (((this->_targetRoomType == 0 || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2)) || (g_game->_stage == 0xd)))) - goto LAB_00710310; - bVar4 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x88); - if ((bVar4 == 0) || ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 1 && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 2)))) { - iVar5 = this->_currentRoomType; - if (iVar5 == 1) { - if (this->_targetRoomType == 1) { - variant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (((variant != 1) && (variant != 4)) && ((variant != 2 && (variant != 5)))) - goto LAB_00710063; -LAB_0070ff8f: - bVar4 = IsRoomType(this,8); - if ((bVar4 != 0) || (bVar4 = IsRoomType(this,0x1d), bVar4 != 0)) goto LAB_0070ffa9; - } - else { -LAB_0070ff86: - if (this->_targetRoomType != 7) goto LAB_0070ff8f; -LAB_0070ffa9: - if (iVar5 != 5) goto LAB_0070ffae; - } - } - else { - if (iVar5 != 7) goto LAB_0070ff86; -LAB_0070ffae: - if ((this->_targetRoomType != 5) && - ((((room = g_game->_room, *GHIDRA_CAST((GHIDRA_CAST(room) + 0x7228)) == '\0' && (iVar5 != 6)) || - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x44)) & 1) != 0)) && - ((iVar5 != 0xb || ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x44)) >> 3 & 1) != 0)))))) - goto LAB_00710063; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 3) { - if (((((this->_doorFlags & 9) != 0) || (this->_targetRoomType == 5)) || - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 5)) && - (player = PlayerManager::FirstTrinketOwner(&g_game->_playerManager,0x88), - player != GHIDRA_CAST(0x0))) { - iVar5 = Entity_Player::GetTrinketMultiplier(player,0x88); - if (iVar5 == 2) { - if ((this->_doorFlags & 9) != 0) goto LAB_00710063; - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - else { - if (iVar5 < 3) goto LAB_00710310; - iVar5 = this->_targetRoomType; - } - if (iVar5 == 5) goto LAB_00710063; - } -LAB_00710310: - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 7) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 0)) { - return 0; - } - if ((this->_currentRoomType == 6) || - (uVar7 = 8, *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x7228)) != '\0')) { - uVar7 = 4; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = uVar7; - if (isFromExplosion != 0) { - SpawnDust(this); - } - goto LAB_00710353; - } - } -LAB_00710063: - if (((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2)) && - (bVar4 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x88), bVar4 != 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - } - if (((this->_currentRoomType == 1) && (this->_targetRoomType == 1)) && - ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 3 && - ((GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Break"),5), isFromExplosion != 0)))) - { - (GHIDRA_CAST((&particleColor)))->Color::Color(); - rngResult = Random(); - pVVar6 = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&doorPos); - Game::SpawnParticles(g_game,pVVar6,0x1b,rngResult % 5 + 6,8.0,color_01,100000.0,0); - SpawnDust(this); - } - if (((this->_currentRoomType == 7) || (this->_targetRoomType == 7)) || - ((this->_currentRoomType == 8 || (this->_targetRoomType == 8)))) { -LAB_00710147: - pcVar8 = "Opened"; - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(GHIDRA_CAST("Opened"),6); - if (isFromExplosion != 0) { - (GHIDRA_CAST((&particleColor)))->Color::Color(); - rngResult = Random(); - pVVar6 = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&doorPos); - Game::SpawnParticles(g_game,pVVar6,4,rngResult % 5 + 6,8.0,color_02,100000.0,0); - SpawnDust(this); - manager = g_manager; - soundId = 0x89; - seed_fart_sound_override(&soundId); - pcVar8 = GHIDRA_CAST(0x3f800000); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,1.0,0.0); - } - } - else { - pcVar8 = GHIDRA_CAST(0x71013f); - bVar4 = IsRoomType(this,0x1d); - if (bVar4 != 0) goto LAB_00710147; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 3) { - (GHIDRA_CAST((&particleColor)))->Color::Color(); - rngResult = Random(); - pVVar6 = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&doorPos); - pcVar8 = GHIDRA_CAST(0x47c35000); - Game::SpawnParticles(g_game,pVVar6,0x1b,rngResult % 5 + 6,8.0,color_03,100000.0,0); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 4; -LAB_00710353: - UpdateAnimation(this); - return 0; - } - } - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (iVar5 != 1) { - if (((iVar5 == 7) && (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)) == 6)) || - (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x7228)) != '\0')) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 4; - } - else { - if (iVar5 == 3) { - FUN_0070bfa0(0x1e1,2,pcVar8,0x3f800000); - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - this->_isBusted = 1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - } - } - UpdateAnimation(this); - Game::UpdateVisibility(g_game); - if (isFromExplosion != 0) { - PersistentGameData::IncreaseEventCounter(&g_manager->_persistentGameData,199,1); - } - return 1; -} - -// 00710480 -uint8_t GridEntity_Door::TryUnlock(Entity_Player *player, uint8_t isForce) -{ - uint8_t bVar1; - char isDamaged; - int iVar2; - Entity_Player *trinketHolder; - Vector *pVVar3; - uint32_t rngResult; - Entity *particle; - uint8_t *pbVar4; - uint32_t uVar5; - uint8_t *pbVar6; - LayerState *layer; - RoomDescriptor *targetRoomDesc; - Entity_Player *trinketHolder; - uint32_t extraout_ECX; - char *wantedAnimNameStr; - ANM2 *sprite; - bool bVar7; - uint32_t in_stack_ffffff80; - float local_64; - uint32_t local_60; - float cosSpread; - float negDirY; - uint32_t slowParticleCount; - int particleCount; - Vector particleVelocity; - Vector particlePos; - Vector VStack_3c; - ColorMod local_34; - float dirX; - Game *game; - uint64_t gameStateFlags; - uint32_t *gameStateFlagsHigh; - Manager *manager; - code *takeDamage; - - game = g_game; - if ((this->_doorFlags & 0x10) != 0) { - return 0; - } - if (player->_isCoopGhost != 0) { - return 0; - } - if (isForce == 0) { - if (((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) && (this->_targetRoomType == 0x1b)) && - (iVar2 = get_secret_exit_kind(this), iVar2 == 3)) { - if ((this->_doorFlags & 0x40) != 0) { - local_64 = 0.0; - trinketHolder = GHIDRA_CAST(FUN_007103c0(&local_64)); - if (trinketHolder == GHIDRA_CAST(0x0)) { - return 0; - } - if (local_64 != 0.0) { - Entity_Player::TryRemoveTrinket(trinketHolder,GHIDRA_UINT(local_64)); - } - manager = g_manager; - local_60 = 8; - seed_fart_sound_override(GHIDRA_CAST(&local_60)); - bVar1 = 0; - iVar2 = 0x3f800000; - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(local_60,1.0,2,0,1.0,0.0); - (GHIDRA_CAST((GHIDRA_CAST(&g_manager->_musicManager))))->Music::PlayJingle(0x44,iVar2,bVar1); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - UpdateAnimation(this); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - sprite = &this->_sprite; - layer = ANM2::GetLayer(sprite,GHIDRA_CAST(0x1)); - layer->_visible = 0; - bVar7 = local_64 == 9.66896e-44; - layer = ANM2::GetLayer(sprite,GHIDRA_CAST(0x2)); - layer->_visible = bVar7; - layer = ANM2::GetLayer(sprite,&DAT_00000004); - layer->_visible = 0; - return 1; - } - if (((this->_sprite)._animState._animData != (void *)0x0) && - ((this->_sprite)._animState._isPlaying != 0)) { - pbVar6 = (this->_sprite)._animState._animData; - if (0xf < *GHIDRA_CAST((pbVar6 + 0x14))) { - pbVar6 = *GHIDRA_CAST(pbVar6); - } - pbVar4 = &DAT_00b68d9c; - do { - bVar1 = *pbVar6; - bVar7 = bVar1 < *pbVar4; - if (bVar1 != *pbVar4) { -LAB_007106c0: - uVar5 = -GHIDRA_UINT(bVar7) | 1; - goto LAB_007106c5; - } - if (bVar1 == 0) break; - bVar1 = pbVar6[1]; - bVar7 = bVar1 < pbVar4[1]; - if (bVar1 != pbVar4[1]) goto LAB_007106c0; - pbVar6 = pbVar6 + 2; - pbVar4 = pbVar4 + 2; - } while (bVar1 != 0); - uVar5 = 0; -LAB_007106c5: - if (uVar5 == 0) { - return 0; - } - } - iVar2 = Entity_Player::GetHealthType(player); - if ((iVar2 != 2) && (bVar1 = Entity_Player::HasInstantDeathCurse(trinketHolder), bVar1 == 0)) { - in_stack_ffffff80 = 0x7106fd; - bVar1 = Seeds::HasSeedEffect(&g_game->_seedEffects,0x49); - if (bVar1 == 0) { - EntityRef::EntityRef(GHIDRA_CAST(&local_34)); - takeDamage = *(code **)(*GHIDRA_CAST(player) + 0x20); - local_34._tint[0] = 0.0; - local_34._tint[1] = 1.40172e-41; - player->_damageCooldown = 0; - isDamaged = (*takeDamage)(0x40000000,0x12002080,0,extraout_ECX,0x1e); - if (isDamaged == '\0') { - return 0; - } - pVVar3 = Isaac::GetAxisAlignedUnitVectorFromDir(&VStack_3c,this->_direction); - dirX = pVVar3->x; - negDirY = -pVVar3->y; - in_stack_ffffff80 = Random(); - pVVar3 = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&VStack_3c); - Game::SpawnEx(g_game,1000,2,pVVar3,&g_vectorZero,GHIDRA_CAST(0x0),3,in_stack_ffffff80,0); - uVar5 = Random(); - slowParticleCount = (uVar5 & 1) + 2; - rngResult = Random(); - particleCount = (uVar5 & 1) + 8 + rngResult % 10; - local_60 = 0; - if (particleCount != 0) { - do { - uVar5 = local_60; - rngResult = Random(); - local_64 = ((float)((double)GHIDRA_INT(rngResult) + - __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 - * 30.0 - 15.0) * 0.017453292; - cosSpread = cos(local_64); - local_64 = sin(local_64); - rngResult = Random(); - particleVelocity.y = - (float)((double)GHIDRA_INT(rngResult) + - __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 15.0 - + 5.0; - particleVelocity.x = (-dirX * cosSpread - negDirY * local_64) * particleVelocity.y; - particleVelocity.y = (negDirY * cosSpread + -dirX * local_64) * particleVelocity.y; - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - particlePos.x = (float)(this->_gridIndex % iVar2) * 40.0 + 40.0 + particleVelocity.x; - particlePos.y = (float)(this->_gridIndex / iVar2) * 40.0 + 120.0 + particleVelocity.y; - in_stack_ffffff80 = Random(); - if (uVar5 < slowParticleCount) { - VStack_3c.x = particleVelocity.x * 0.2; - VStack_3c.y = particleVelocity.y * 0.2; - particle = Game::SpawnEx(g_game,1000,5,&particlePos,&VStack_3c,GHIDRA_CAST(0x0),0, - in_stack_ffffff80,0); - (**(code **)(*GHIDRA_CAST(particle) + 0xc))(); - local_60 = uVar5; - } - else { - particle = Game::SpawnEx(g_game,1000,5,&particlePos,&particleVelocity,GHIDRA_CAST(0x0), - 99,in_stack_ffffff80,0); - (**(code **)(*GHIDRA_CAST(particle) + 0xc))(); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(particle[1])) + 0x4)))) = 0xc1000000; - } - local_60 = local_60 + 1; - } while (GHIDRA_INT(local_60) < particleCount); - } - goto LAB_007109b9; - } - } - this->_varData = 0; -LAB_007109b9: - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = (this->_varData != 0) + 2; - UpdateAnimation(this); - if (this->_varData < 1) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - } - else { - this->_varData = this->_varData + -1; - } - FUN_0070bfa0(0x48,2,in_stack_ffffff80,0x3f800000); - return 1; - } - } - else if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 5) { - gameStateFlags = g_game->_gameStateFlags; - gameStateFlagsHigh = GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - *gameStateFlagsHigh = *gameStateFlagsHigh | 0x20000; - *GHIDRA_CAST(&game->_gameStateFlags) = GHIDRA_INT(gameStateFlags); - } - bVar7 = false; - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2)) { - in_stack_ffffff80 = 0x96; - bVar1 = Entity_Player::HasTrinket(player,0x96,0); - if (bVar1 != 0) { - isForce = 1; - bVar7 = true; - } - } - if (g_game->_stage == 9) { - in_stack_ffffff80 = 0x71051b; - iVar2 = Entity_Player::GetTrinketMultiplier(player,0xaf); - if (iVar2 < 2) goto LAB_00710a08; - isForce = 1; - } - else { -LAB_00710a08: - if (isForce == 0) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - return 0; - } - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 1) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 2)) { - return 0; - } - if ((this->_isExtraVisible != 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 3)) { - bVar1 = ANM2::IsPlaying(&this->_extraSprite,GHIDRA_CAST("GoldenKeyOpenChain1")); - if (bVar1 != 0) { - return 0; - } - in_stack_ffffff80 = 0x710a68; - bVar1 = ANM2::IsPlaying(&this->_extraSprite,GHIDRA_CAST("KeyOpenChain1")); - if (bVar1 != 0) { - return 0; - } - } - if ((this->_doorFlags & 1) == 0) { - if (this->_targetRoomType == 2) { - in_stack_ffffff80 = 0x53; - bVar1 = Entity_Player::HasTrinket(player,0x53,0); - if (bVar1 != 0) goto LAB_00710af5; - } - } - else if (0 < player->_numCoins) goto LAB_00710af5; - if (((this->_targetRoomType != 5) || (this->_targetRoomIdx < 0)) || (g_game->_stage != 9)) { - if ((this->_doorFlags & 1) != 0) { - return 0; - } - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2)) { - in_stack_ffffff80 = 0x710ade; - iVar2 = Entity_Player::GetTrinketMultiplier(player,0x13); - if (2 < iVar2) goto LAB_00710af5; - } - bVar1 = Entity_Player::TryUseKey(player); - if (bVar1 == 0) { - return 0; - } - } - } - } -LAB_00710af5: - if ((this->_doorFlags & 1) == 0) { - if (isForce == 0) goto LAB_00710b1b; - } - else if (isForce == 0) { - in_stack_ffffff80 = 0x710b0b; - Entity_Player::AddCoins(player,-1); - goto LAB_00710b1b; - } - this->_isUnlockedByPlayer = 1; -LAB_00710b1b: - if (((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 3)) && (isForce == 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 3; - UpdateAnimation(this); - return 1; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - UpdateAnimation(this); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - manager = g_manager; - if (((this->_targetRoomType == 5) && (-1 < this->_targetRoomIdx)) && (g_game->_stage == 9)) { - FUN_0070bfa0(0xe,2,in_stack_ffffff80,0x3e99999a); - } - else { - local_60 = 0x2d; - if ((this->_doorFlags & 1) == 0) { - local_60 = 0x9c; - } - seed_fart_sound_override(GHIDRA_CAST(&local_60)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(local_60,1.0,2,0,1.0,0.0); - } - if (bVar7) { - pbVar6 = (this->_sprite)._animState._animData; - if (pbVar6 != GHIDRA_CAST(0x0)) { - if ((this->_sprite)._animState._isPlaying != 0) { - pbVar4 = pbVar6; - if (0xf < *GHIDRA_CAST((pbVar6 + 0x14))) { - pbVar4 = *GHIDRA_CAST(pbVar6); - } - wantedAnimNameStr = "GoldenKeyOpen"; - do { - bVar1 = *pbVar4; - bVar7 = bVar1 < (uint8_t)*wantedAnimNameStr; - if (bVar1 != *wantedAnimNameStr) { -LAB_00710c35: - uVar5 = -GHIDRA_UINT(bVar7) | 1; - goto LAB_00710c3a; - } - if (bVar1 == 0) break; - bVar1 = pbVar4[1]; - bVar7 = bVar1 < (uint8_t)wantedAnimNameStr[1]; - if (bVar1 != wantedAnimNameStr[1]) goto LAB_00710c35; - pbVar4 = pbVar4 + 2; - wantedAnimNameStr = wantedAnimNameStr + 2; - } while (bVar1 != 0); - uVar5 = 0; -LAB_00710c3a: - if (uVar5 == 0) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("KeyOpen"),0); - pbVar6 = (this->_sprite)._animState._animData; - } - } - if ((pbVar6 != GHIDRA_CAST(0x0)) && ((this->_sprite)._animState._isPlaying != 0)) { - pbVar6 = (this->_sprite)._animState._animData; - if (pbVar6 == GHIDRA_CAST(0x0)) { - pbVar6 = &s_empty; - } - else if (0xf < *GHIDRA_CAST((pbVar6 + 0x14))) { - pbVar6 = *GHIDRA_CAST(pbVar6); - } - wantedAnimNameStr = "KeyOpen"; - do { - bVar1 = *pbVar6; - bVar7 = bVar1 < (uint8_t)*wantedAnimNameStr; - if (bVar1 != *wantedAnimNameStr) { -LAB_00710ca0: - uVar5 = -GHIDRA_UINT(bVar7) | 1; - goto LAB_00710ca5; - } - if (bVar1 == 0) break; - bVar1 = pbVar6[1]; - bVar7 = bVar1 < (uint8_t)wantedAnimNameStr[1]; - if (bVar1 != wantedAnimNameStr[1]) goto LAB_00710ca0; - pbVar6 = pbVar6 + 2; - wantedAnimNameStr = wantedAnimNameStr + 2; - } while (bVar1 != 0); - uVar5 = 0; -LAB_00710ca5: - if ((uVar5 == 0) && - (layer = ANM2::GetLayer(&this->_sprite,&DAT_00b1ce2c), layer != GHIDRA_CAST(0x0))) { - local_34._tint[0] = 1.0; - local_34._tint[1] = 1.0; - local_34._tint[2] = 1.0; - local_34._tint[3] = 1.0; - local_34._colorize[0] = 0.4; - local_34._colorize[1] = 0.6; - local_34._colorize[2] = 1.0; - local_34._colorize[3] = 1.0; - local_34._offset[0] = 0.0; - local_34._offset[1] = 0.0; - local_34._offset[2] = 0.0; - (GHIDRA_CAST((GHIDRA_CAST(&layer->_color))))->Color::operator_assign(&local_34); - } - } - } - targetRoomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - if (targetRoomDesc->Data != (void *)0x0) { - targetRoomDesc->Flags = targetRoomDesc->Flags | 0x40000; - } - } - return 1; -} - -// 00710d30 -void GridEntity_Door::Close(uint8_t isForce) -{ - int currentRoomType; - int targetRoomType; - - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 1) || (isForce != 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - UpdateAnimation(this); - currentRoomType = this->_currentRoomType; - if (((currentRoomType == 7) || - (((targetRoomType = this->_targetRoomType, targetRoomType == 7 || (currentRoomType == 8)) || - (targetRoomType == 8)))) || ((currentRoomType == 0x1d || (targetRoomType == 0x1d)))) { - (GHIDRA_CAST(((this->_openAnimation)._buf)))->msvc::string::assign(s_Open,4); - } - } - return; -} - -// 00710d90 -void GridEntity_Door::Bar() -{ - uint8_t isSpriteLoaded; - - isSpriteLoaded = (this->_extraSprite)._loaded; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 4; - if ((isSpriteLoaded == 0) || ((this->_doorFlags & 0x20) != 0)) { - LoadSprite(this); - } - UpdateAnimation(this); - return; -} - -// 00710dd0 -void GridEntity_Door::Open() -{ - uint32_t *puVar1; - uint64_t qVar2; - uint8_t isFromSecretRoom; - char cVar4; - int variant; - RoomDescriptor *targetRoom; - int currentRoomType; - Game *game; - bool isFromSecretRoom; - - if (((this->_doorFlags & 0x10U) != 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 8)) { - return; - } - if (((this->_doorFlags & 0x20U) != 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 4)) { - return; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - return; - } - variant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (variant == 7) { - return; - } - currentRoomType = this->_currentRoomType; - if (this->_targetRoomType == 0xb) { - if ((currentRoomType == 7) || (currentRoomType == 8)) { - isFromSecretRoom = true; - } - else { - isFromSecretRoom = false; - } - isFromSecretRoom = Level::CanOpenChallengeRoom(GHIDRA_CAST(g_game),this->_targetRoomIdx); - if (((isFromSecretRoom == 0) && (this->_isUnlockedByPlayer == 0)) && (!isFromSecretRoom)) { - return; - } - goto LAB_00710e57; - } - if (currentRoomType == 0xb) { - if (((g_game->_ambush)._isActive != 0) && (this->_isUnlockedByPlayer == 0)) { - return; - } - } - else { - isFromSecretRoom = IsRoomType(this,0); - if (isFromSecretRoom != 0) { - return; - } - if (variant != 4) { - if (variant == 6) { - cVar4 = FUN_00710f70(g_game->_greedModeWave); - if (cVar4 != '\0') { -LAB_00710f2b: - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 8) { - return; - } - } - } - else if ((variant != 1) || - (targetRoom = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1), - targetRoom->VisitedCount == 0)) goto LAB_00710f2b; - } - } - cVar4 = FUN_00711740(); - if (cVar4 == '\0') { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 5; - return; - } -LAB_00710e57: - game = g_game; - variant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (variant == 5) { - qVar2 = g_game->_gameStateFlags; - puVar1 = GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - *puVar1 = *puVar1 | 0x20000; - *GHIDRA_CAST(&game->_gameStateFlags) = GHIDRA_INT(qVar2); - variant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - } - if (((variant == 6) && (this->_targetRoomType == 4)) && - (this->_targetRoomIdx == g_game->_greedModeTreasureRoomIdx)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 1; - UpdateAnimation(this); - return; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - UpdateAnimation(this); - return; -} - -// 00710fa0 -void GridEntity_Door::SetRoomTypes(int CurrentRoomType, int TargetRoomType) -{ - uint8_t bVar1; - RoomDescriptor *currentRoomDesc; - RoomDescriptor *targetRoomDesc; - RoomDescriptor *roomDesc; - void *roomData; - uint32_t roomSubtype; - Entity_Player *taintedKeeper; - int iVar2; - int iVar3; - Game *game; - bool isGreedMode; - bool isMirrorWorld; - int targetType; - - game = g_game; - if ((g_game->_difficulty == 2) || (isGreedMode = false, g_game->_difficulty == 3)) { - isGreedMode = true; - } - this->_currentRoomType = CurrentRoomType; - this->_targetRoomType = TargetRoomType; - bVar1 = Level::HasMirrorDimension(GHIDRA_CAST(game)); - if ((bVar1 == 0) || (isMirrorWorld = true, g_game->_currentDimensionIdx != 1)) { - isMirrorWorld = false; - } - currentRoomDesc = - Level::GetRoomByIdx(GHIDRA_CAST(g_game),g_game->_currentRoomIdx,g_game->_currentDimensionIdx); - targetRoomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - if (((GHIDRA_UINT(currentRoomDesc->Flags) >> 10 & 1) != 0) || - ((GHIDRA_UINT(targetRoomDesc->Flags) >> 10 & 1) != 0)) { - if ((this->_currentRoomType == 7) || (this->_currentRoomType == 8)) { - this->_currentRoomType = 1; - } - if ((this->_targetRoomType == 7) || (this->_targetRoomType == 8)) { - this->_targetRoomType = 1; - } - } - iVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (iVar2 != 0) goto LAB_00711235; - iVar2 = g_game->_difficulty; - if ((iVar2 == 2) || (iVar2 == 3)) { - iVar3 = this->_targetRoomType; - if ((iVar3 == 0x17) && (g_game->_greedModeWave < GHIDRA_INT(((iVar2 == 3) + 10)))) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 6; - goto LAB_00711262; - } - } - else { - iVar3 = this->_targetRoomType; - } - iVar2 = this->_currentRoomType; - if ((((iVar2 != 7) && (iVar2 != 8)) && (iVar2 != 0x1d)) && (iVar2 != 10)) { - if (iVar3 == 0x1b) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - roomData = roomDesc->Data; - if (roomData != (void *)0x0) { -LAB_0071111e: - if (*GHIDRA_CAST((GHIDRA_CAST(roomData) + 0x10)) != 0) { -LAB_007111ae: - game = g_game; - if (this->_targetRoomType == 0x1b) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); -LAB_007111e8: - game = g_game; - if (roomDesc->Data == (void *)0x0) { - roomSubtype = 0; - } - else { - roomSubtype = *GHIDRA_CAST((GHIDRA_CAST(roomDesc->Data) + 0x10)); - } - switch(roomSubtype) { - case 2: - case 4: - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 3; - iVar2 = 3; - break; - case 3: - this->_varData = 1; - default: -switchD_007111fc_caseD_1: - iVar2 = 1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 1; - } - } - else { - if (this->_currentRoomType == 0x1b) { - roomDesc = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)); - goto LAB_007111e8; - } - if (this->_targetRoomType != 5) { - if (((this->_currentRoomType == 5) && - (iVar2 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x10)), iVar2 != 0)) && - (*GHIDRA_CAST((iVar2 + 0x10)) == 0x5a)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 3; - iVar2 = 3; - goto LAB_00711220; - } - goto switchD_007111fc_caseD_1; - } - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - game = g_game; - if ((roomDesc->Data == (void *)0x0) || (*GHIDRA_CAST((GHIDRA_CAST(roomDesc->Data) + 0x10)) != 0x5a)) - goto switchD_007111fc_caseD_1; - iVar2 = 3; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 3; - } -LAB_00711220: - if (game->_currentRoomIdx == -10) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; - iVar2 = 8; - } - goto LAB_00711235; - } - } - } - else if (iVar2 == 0x1b) { - roomData = *(void **)(*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x10); - if (roomData != (void *)0x0) goto LAB_0071111e; - } - else if (iVar3 == 5) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),this->_targetRoomIdx,-1); - if (roomDesc->Data != (void *)0x0) { - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(roomDesc->Data) + 0x10)); - goto joined_r0x007111a8; - } - } - else if ((iVar2 == 5) && (iVar2 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x10)), iVar2 != 0) - ) { - iVar2 = *GHIDRA_CAST((iVar2 + 0x10)); -joined_r0x007111a8: - if (iVar2 == 0x5a) goto LAB_007111ae; - } - } - game = g_game; - if (g_game->_currentRoomIdx != -0x10) { - iVar2 = this->_targetRoomIdx; - if (iVar2 != -0x65) { - if (iVar2 != -100) goto LAB_0071132c; - goto LAB_007113a8; - } - if (g_game->_currentDimensionIdx == 0) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 3; -LAB_00711244: - if (((GHIDRA_UINT(currentRoomDesc->Flags) >> 10 & 1) == 0) || - ((GHIDRA_UINT(targetRoomDesc->Flags) >> 10 & 1) != 0)) goto LAB_00711262; - goto LAB_0071125b; - } -LAB_0071132c: - iVar3 = this->_currentRoomType; - if (((iVar3 == 7) || (iVar3 == 8)) || ((iVar3 == 0x1d || (iVar3 == 10)))) goto LAB_007113fb; - targetType = this->_targetRoomType; - if (targetType == 9) goto LAB_007113a8; - if (g_game->_challenge == 0x18) { - if (((targetType != 7) && (targetType != 8)) && (targetType != 0xb)) { - if (targetType != 0x1d) goto LAB_007113a8; - goto LAB_0071137e; - } -LAB_007113be: - if (targetType == 2) { - if (!isMirrorWorld) { - if ((((g_game->_stage != 1) || (bVar1 = Level::IsAltPath(GHIDRA_CAST(g_game)), bVar1 != 0)) && - (bVar1 = Game::IsGreedMode(game), bVar1 == 0)) && - (taintedKeeper = PlayerManager::FirstPlayerByType(&game->_playerManager,0x21), - taintedKeeper == GHIDRA_CAST(0x0))) goto LAB_007113a8; - iVar2 = this->_targetRoomIdx; - } - } - else if (((targetType == 5) && (-1 < iVar2)) && (g_game->_stage == 9)) { -LAB_007113a8: - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 1; - goto LAB_00711244; - } -LAB_007113fb: - if (isGreedMode) goto LAB_00711401; -LAB_0071143f: - if ((iVar3 == 7) || (iVar3 == 8)) goto LAB_0071146d; -LAB_00711449: - if (iVar3 == 0x1d) goto LAB_0071146d; - targetType = this->_targetRoomType; - if ((targetType == 0x12) || (targetType == 0x13)) { - iVar2 = 3; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 3; -LAB_00711235: - if (((iVar2 != 1) && (iVar2 != 3)) && (iVar2 != 2)) goto LAB_00711262; - goto LAB_00711244; - } - if ((targetType == 0x15) || (targetType == 0x14)) { - iVar2 = 2; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 2; - goto LAB_00711235; - } - if (iVar3 != 6) goto LAB_0071146d; -LAB_0071147c: - if ((((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 4)) + 0x44)) & 1) == 0) && - (targetType = this->_targetRoomType, targetType != 7)) && - ((targetType != 8 && (targetType != 0x1d)))) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 4; - goto LAB_00711262; - } - } - else { -LAB_0071137e: - if (targetType != 4) { - if ((targetType == 0x18) || (targetType == 0xc)) goto LAB_007113a8; - goto LAB_007113be; - } - if (isMirrorWorld) goto LAB_007113fb; - if (g_game->_stage == 1) { - bVar1 = Level::IsAltPath(GHIDRA_CAST(g_game)); - iVar2 = this->_targetRoomIdx; - if (bVar1 == 0) goto LAB_007113fb; - } - if (!isGreedMode) goto LAB_007113a8; -LAB_00711401: - if (this->_targetRoomType != 4) goto LAB_0071143f; - if ((iVar3 != 7) && (iVar3 != 8)) { - if (iVar2 == game->_greedModeTreasureRoomIdx) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 1; - goto LAB_00711244; - } - goto LAB_00711449; - } -LAB_0071146d: - if (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x7228)) != '\0') goto LAB_0071147c; - } - if (iVar2 == -7) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 5; - goto LAB_00711262; - } - if (((((iVar3 == 7) || (iVar2 = this->_targetRoomType, iVar2 == 7)) || (iVar3 == 8)) || - ((iVar2 == 8 || (iVar3 == 0x1d)))) || (iVar2 == 0x1d)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 7; - goto LAB_00711262; - } - } -LAB_0071125b: - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 8; -LAB_00711262: - LoadSprite(this); - UpdateAnimation(this); - if (this->_targetRoomType == 0x1d) { - TryBlowOpen(this,0,GHIDRA_CAST(0x0)); - } - if (((this->_doorFlags & 0x20) != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::AdvancePosition - (&(this->_sprite)._animState, - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1); - } - return; -} - -// 00711590 -void GridEntity_Door::BeginBatches() -{ - int doorState; - - doorState = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if ((doorState == 0) || (doorState == 2)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - doorState = 1; - } - this->_previousState = doorState; - this->_previousVariant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 1000; - } - this->_updateCount = 0; - this->_targetRoomType = 0; - this->_currentRoomType = 0; - this->_targetRoomIdx = -1; - this->_isExtraVisible = 0; - this->_isBusted = 0; - this->_isUnlockedByPlayer = 0; - this->_doorFlags = 0; - this->_direction = -1; - return; -} - -// 00711630 -void GridEntity_Door::SetLocked(uint8_t isLocked) -{ - uint32_t doorVariant; - Game *game; - uint64_t stateFlags; - uint32_t *stateFlagsHigh; - - game = g_game; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 4) { - if (isLocked == 0) { - return; - } - } - else if ((isLocked == 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 5)) { - stateFlags = g_game->_gameStateFlags; - stateFlagsHigh = GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - *stateFlagsHigh = *stateFlagsHigh | 0x20000; - *GHIDRA_CAST(&game->_gameStateFlags) = GHIDRA_INT(stateFlags); - } - doorVariant = 8; - if (isLocked != 0) { - doorVariant = 1; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = doorVariant; - UpdateAnimation(this); - return; -} - -// 00711690 -uint32_t GridEntity_Door::IsTargetRoomArcade() -{ - int iVar1; - Entity_Player *owner; - - iVar1 = this->_targetRoomType; - if (iVar1 == 9) { - return 1; - } - if ((((((iVar1 == 2) || (iVar1 == 4)) || (iVar1 == 0x18)) || ((iVar1 == 0x14 || (iVar1 == 0x15)))) - || ((iVar1 = get_secret_exit_kind(this), iVar1 == 1 || (this->_targetRoomType == 0xc)))) && - (owner = PlayerManager::FirstCollectibleOwner - (&g_game->_playerManager,0x17c,GHIDRA_CAST(&g_game->_playerManager),1), - owner != GHIDRA_CAST(0x0))) { - return 1; - } - if (((g_game->_challenge == 0x18) && (iVar1 = this->_targetRoomType, iVar1 != 7)) && - ((iVar1 != 8 && ((iVar1 != 0xb && (iVar1 != 0x1d)))))) { - return 1; - } - return 0; -} - -// 00738170 -uint8_t GridEntity_Door::IsBusted() -{ - return this->_isBusted; -} - -// 00833290 -int GridEntity_Door::Slot() -{ - return this->_slot; -} - -// 0085e0b0 -Vector * GridEntity_Door::GetSpriteOffset() -{ - return &(this->_sprite)._offset; -} diff --git a/generated-src/grid_entity_fire.cpp b/generated-src/grid_entity_fire.cpp deleted file mode 100644 index 2701844..0000000 --- a/generated-src/grid_entity_fire.cpp +++ /dev/null @@ -1,563 +0,0 @@ -#include "classes.h" - -// 0067db00 -void GridEntity_Fire::BeginBatches() -{ - uint8_t bVar1; - uint32_t uVar2; - uint8_t *animNameChar; - EntityConfig_Entity *preloadEntry; - char *pcVar3; - uint8_t *expectedByte; - Manager *manager; - EntityConfig *entityConfig; - bool bVar4; - uint32_t local_98 [11]; - uint32_t local_6c [8]; - uint32_t local_4c; - uint32_t uStack_48; - uint32_t local_44; - uint8_t lowerBound [8]; - void *foundNode; - EntityConfig *local_34; - EntityConfig *local_30; - std_string anm2Path; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - uint8_t *animData; - - local_8 = 0xffffffff; - puStack_c = &LAB_00af7acd; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size); - ExceptionList = &local_10; - if (((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) < 2) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 0)) && - (uVar2 = Random(), uVar2 % 0x28 == 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 1; - } - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 0x578; - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1c; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/grid_fireplace.anm2",0x1d); - local_8 = 0; - ANM2::Load(&this->_sprite,&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar2 = anm2Path._capacity + 1; - pcVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar2) { - pcVar3 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar2 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar3))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar3,uVar2); - } - animData = (this->_sprite)._animState._animData; - if (animData == GHIDRA_CAST(0x0)) { -LAB_0067dc72: - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Flickering"),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameChar = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameChar = *GHIDRA_CAST(animData); - } - pcVar3 = "Flickering"; - do { - bVar1 = *animNameChar; - bVar4 = bVar1 < (uint8_t)*pcVar3; - if (bVar1 != *pcVar3) { -LAB_0067dc54: - uVar2 = -GHIDRA_UINT(bVar4) | 1; - goto LAB_0067dc59; - } - if (bVar1 == 0) break; - bVar1 = animNameChar[1]; - bVar4 = bVar1 < (uint8_t)pcVar3[1]; - if (bVar1 != pcVar3[1]) goto LAB_0067dc54; - animNameChar = animNameChar + 2; - pcVar3 = pcVar3 + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0067dc59: - if ((uVar2 != 0) || ((animData[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_0067dc72; - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1d; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/effect_005_fire.anm2",0x1e); - local_8 = 1; - ANM2::Load(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))),&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar2 = anm2Path._capacity + 1; - pcVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar2) { - pcVar3 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar2 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar3))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar3,uVar2); - } - animData = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x188)))); - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - if (animData == GHIDRA_CAST(0x0)) { -LAB_0067ddb6: - bVar1 = ANM2::SetAnimation(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))),GHIDRA_CAST("FireStage00"),1); - if (bVar1 != 0) { - AnimationState::Rewind(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x184))))); - (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x198))) = 1; - } - } - else { - animNameChar = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameChar = *GHIDRA_CAST(animData); - } - pcVar3 = "FireStage00"; - do { - bVar1 = *animNameChar; - bVar4 = bVar1 < (uint8_t)*pcVar3; - if (bVar1 != *pcVar3) { -LAB_0067dd92: - uVar2 = -GHIDRA_UINT(bVar4) | 1; - goto LAB_0067dd97; - } - if (bVar1 == 0) break; - bVar1 = animNameChar[1]; - bVar4 = bVar1 < (uint8_t)pcVar3[1]; - if (bVar1 != pcVar3[1]) goto LAB_0067dd92; - animNameChar = animNameChar + 2; - pcVar3 = pcVar3 + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0067dd97: - if ((uVar2 != 0) || ((animData[0x34] != 0 && ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x198))) == '\0')))) goto LAB_0067ddb6; - } - manager = g_manager; - local_34 = GHIDRA_CAST(0x3e800f00); - local_30 = &g_manager->_entityConfig; - _Find_lower_bound<>(lowerBound,&local_34); - entityConfig = &manager->_entityConfig; - if (((*GHIDRA_CAST((GHIDRA_CAST(foundNode) + 0xd)) == '\0') && (*GHIDRA_CAST((GHIDRA_CAST(foundNode) + 0x10)) < 0x3e800f01)) - && (foundNode != (entityConfig->_entities)._head)) { - preloadEntry = GHIDRA_CAST((GHIDRA_INT(foundNode) + 0x18)); - } - else { - preloadEntry = EntityConfig::GetEntity(entityConfig,1000,0,0); - } - if (preloadEntry != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(local_30,preloadEntry); - manager = g_manager; - } - local_30 = GHIDRA_CAST(&DAT_00500a00); - local_34 = &manager->_entityConfig; - _Find_lower_bound<>(lowerBound,&local_30); - if (((*GHIDRA_CAST((GHIDRA_CAST(foundNode) + 0xd)) == '\0') && - (*GHIDRA_CAST((GHIDRA_CAST(foundNode) + 0x10)) <= &DAT_00500a00)) && - (foundNode != (manager->_entityConfig)._entities._head)) { - preloadEntry = GHIDRA_CAST((GHIDRA_INT(foundNode) + 0x18)); - } - else { - preloadEntry = EntityConfig::GetEntity(&manager->_entityConfig,5,0,0); - } - if (preloadEntry != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(local_34,preloadEntry); - manager = g_manager; - } - local_30 = GHIDRA_CAST(&DAT_00501400); - entityConfig = &manager->_entityConfig; - _Find_lower_bound<>(lowerBound,&local_30); - if (((*GHIDRA_CAST((GHIDRA_CAST(foundNode) + 0xd)) == '\0') && - (*GHIDRA_CAST((GHIDRA_CAST(foundNode) + 0x10)) <= &DAT_00501400)) && - (foundNode != (entityConfig->_entities)._head)) { - preloadEntry = GHIDRA_CAST((GHIDRA_INT(foundNode) + 0x18)); - } - else { - preloadEntry = EntityConfig::GetEntity(entityConfig,5,0,0); - } - if (preloadEntry != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(entityConfig,preloadEntry); - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) { - local_4c = 0; - uStack_48 = 0; - local_44 = 0; - if (GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x1fc)))) != local_6c) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x20c)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x210)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x214)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x218)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x21c)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x1fc)))) = 0x3f28a8a9; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x200)))) = 0x3cc0c0c1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x204)))) = 0x3cc0c0c1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x208)))) = 0x3f800000; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x224)))) = 0; - } - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x268)))) = 0; - uVar2 = Random(); - anm2Path._size = 0; - anm2Path._capacity = 0xf; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x26c)))) = uVar2 % 3; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1a; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/Effect_Ember.anm2",0x1b); - local_8 = 2; - ANM2::Load(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x27c)))),&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar2 = anm2Path._capacity + 1; - pcVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar2) { - pcVar3 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar2 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar3))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar3,uVar2); - } - animData = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2b0)))); - if (animData != GHIDRA_CAST(0x0)) { - animNameChar = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - animNameChar = *GHIDRA_CAST(animData); - } - expectedByte = s_Idle; - do { - bVar1 = *animNameChar; - bVar4 = bVar1 < *expectedByte; - if (bVar1 != *expectedByte) { -LAB_0067e036: - uVar2 = -GHIDRA_UINT(bVar4) | 1; - goto LAB_0067e03b; - } - if (bVar1 == 0) break; - bVar1 = animNameChar[1]; - bVar4 = bVar1 < expectedByte[1]; - if (bVar1 != expectedByte[1]) goto LAB_0067e036; - animNameChar = animNameChar + 2; - expectedByte = expectedByte + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0067e03b: - if ((uVar2 == 0) && ((animData[0x34] == 0 || ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2c0))) != '\0')))) goto LAB_0067e078; - } - bVar1 = ANM2::SetAnimation(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x27c)))),s_Idle,1); - if (bVar1 != 0) { - AnimationState::Rewind(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2ac))))); - (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2c0))) = 1; - } -LAB_0067e078: - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) && (GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x324)))) != local_98)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x334)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x338)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x33c)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x340)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x344)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x324)))) = 0x3f800000; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x328)))) = 0x3e19999a; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x32c)))) = 0x3e19999a; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x330)))) = 0x3f800000; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x34c)))) = 0; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x270)))); - ExceptionList = local_10; - return; -} - -// 0067e0f0 -void GridEntity_Fire::Update() -{ - uint8_t bVar1; - LayerState *layer; - uint8_t *curAnimChar; - uint32_t uVar2; - int iVar3; - Entity_Player *nearestPlayer; - Vector *dirToPlayer; - Entity *projectile; - float *pfVar4; - uint8_t *expectedName; - float *pfVar5; - float *pfVar6; - float *pfVar7; - bool isLess; - float fVar8; - float deltaX; - float *particleVelYPtr; - Vector local_40; - Vector local_38; - Vector local_30; - Vector normalized; - float particleX; - float particleY; - float particleVelX; - float particleVelY; - uint32_t particleFrame; - float *particleLifetime; - char *room; - - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc))))) { - case 0: - ANM2::Play(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))),GHIDRA_CAST("FireStage00"),0); - break; - case 1: - ANM2::Play(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))),GHIDRA_CAST("FireStage01"),0); - break; - case 2: - ANM2::Play(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))),GHIDRA_CAST("FireStage02"),0); - break; - case 3: - ANM2::Play(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))),GHIDRA_CAST("FireStage03"),0); - break; - case 4: - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x188)))) != 0) { - (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x198))) = 0; - } - layer = ANM2::GetLayer(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))),GHIDRA_CAST(0x0)); - layer->_visible = 0; - } - if (3 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc))))) { - curAnimChar = (this->_sprite)._animState._animData; - if (curAnimChar == GHIDRA_CAST(0x0)) { -LAB_0067e2a3: - bVar1 = ANM2::SetAnimation(&this->_sprite,(&PTR_s_NoFire_00b64fdc)[*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x26c))))] - ,1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - if (0xf < *GHIDRA_CAST((curAnimChar + 0x14))) { - curAnimChar = *GHIDRA_CAST(curAnimChar); - } - expectedName = (&PTR_s_NoFire_00b64fdc)[*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x26c))))]; - do { - bVar1 = *curAnimChar; - isLess = bVar1 < *expectedName; - if (bVar1 != *expectedName) { -LAB_0067e288: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0067e28d; - } - if (bVar1 == 0) break; - bVar1 = curAnimChar[1]; - isLess = bVar1 < expectedName[1]; - if (bVar1 != expectedName[1]) goto LAB_0067e288; - curAnimChar = curAnimChar + 2; - expectedName = expectedName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0067e28d: - if ((uVar2 != 0) || - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' && - ((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0067e2a3; - } - iVar3 = 0; - goto LAB_0067e2c6; - } - curAnimChar = (this->_sprite)._animState._animData; - if (curAnimChar == GHIDRA_CAST(0x0)) { -LAB_0067e1fb: - bVar1 = ANM2::SetAnimation(&this->_sprite, - (&PTR_s_Flickering_00b64fd0)[*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x26c))))],1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - if (0xf < *GHIDRA_CAST((curAnimChar + 0x14))) { - curAnimChar = *GHIDRA_CAST(curAnimChar); - } - expectedName = (&PTR_s_Flickering_00b64fd0)[*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x26c))))]; - do { - bVar1 = *curAnimChar; - isLess = bVar1 < *expectedName; - if (bVar1 != *expectedName) { -LAB_0067e1e0: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0067e1e5; - } - if (bVar1 == 0) break; - bVar1 = curAnimChar[1]; - isLess = bVar1 < expectedName[1]; - if (bVar1 != expectedName[1]) goto LAB_0067e1e0; - curAnimChar = curAnimChar + 2; - expectedName = expectedName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0067e1e5: - if ((uVar2 != 0) || - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' && - ((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0067e1fb; - } - GridEntity::hurt_surroundings(GHIDRA_CAST(this),38.0,38.0,16.0,1,2,1); - iVar3 = 2; -LAB_0067e2c6: - this->_collisionClass = iVar3; - if ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x25d))) != '\0') { - AnimationState::Update(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x184))))); - AnimationState::Update(GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x1a4))))); - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - if (((((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x268)))) < 1)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) < 4)) && - ((uVar2 = Random(), uVar2 % 5 == 0 && (room = g_game->_room, *room != '\0')))) && - (0x3c < g_game->_frameCount - *GHIDRA_CAST((room + 0x11f0)))) { - local_38.x = (float)(this->_gridIndex % *GHIDRA_CAST((room + 0xc))) * 40.0 + 40.0; - local_38.y = (float)(this->_gridIndex / *GHIDRA_CAST((room + 0xc))) * 40.0 + 120.0; - nearestPlayer = Game::GetNearestPlayer(g_game,&local_38); - local_30.x = (nearestPlayer->_pos).x; - local_30.y = (nearestPlayer->_pos).y; - deltaX = local_30.x - local_38.x; - fVar8 = local_30.y - local_38.y; - local_40.x = deltaX; - local_40.y = fVar8; - dirToPlayer = (GHIDRA_CAST((&local_40)))->Vector::Normalized(&normalized); - local_38.x = dirToPlayer->x * 25.0 + local_38.x; - local_38.y = dirToPlayer->y * 25.0 + local_38.y; - fVar8 = sqrtf(fVar8 * fVar8 + deltaX * deltaX); - if (((fVar8 < 160.0) && - (bVar1 = Room::CheckLine(g_game->_room,&local_38,&local_30,3,0,0,0,GHIDRA_CAST(0x0)), - bVar1 != 0)) && (uVar2 = Random(), uVar2 % 0xf == 0)) { - uVar2 = Random(); - dirToPlayer = (GHIDRA_CAST((&local_40)))->Vector::Normalized(&normalized); - local_30.x = dirToPlayer->x * 5.0; - local_30.y = dirToPlayer->y * 5.0; - projectile = Game::SpawnEx(g_game,9,0,&local_38,&local_30,GHIDRA_CAST(0x0),0,uVar2,0); - iVar3 = __RTDynamicCast(projectile,0,&IsaacRepentancePlus::Entity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::Entity_Projectile::RTTI_Type_Descriptor,0); - *GHIDRA_CAST((iVar3 + 0x438)) = *GHIDRA_CAST((iVar3 + 0x438)) | 0x8000; - *GHIDRA_CAST((iVar3 + 0x43c)) = *GHIDRA_CAST((iVar3 + 0x43c)); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x268)))) = 0x54; - } - } - else if (0 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x268))))) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x268)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x268)))) + -1; - } - uVar2 = Random(); - pfVar4 = GHIDRA_CAST((uVar2 / 7)); - if ((uVar2 % 7 == 0) && - (pfVar4 = GHIDRA_CAST(((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))) - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x270))))) / 0x18)), - pfVar4 < &DAT_00000005)) { - uVar2 = Random(); - pfVar4 = GHIDRA_CAST((uVar2 % 0x1e)); - uVar2 = Random(); - local_38.x = (float)((double)GHIDRA_INT(uVar2) + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * - 2.3283064e-10 * -1.6 - 0.8; - uVar2 = Random(); - local_40.x = (float)((double)GHIDRA_INT(uVar2) + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * - 2.3283064e-10 * 0.4 - 0.2; - uVar2 = Random(); - fVar8 = -15.0 - (float)((double)GHIDRA_INT(uVar2) + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * - 2.3283064e-10 * 15.0; - uVar2 = Random(); - pfVar6 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))); - particleVelY = local_38.x; - particleFrame = 0; - particleX = (float)((double)GHIDRA_INT(uVar2) + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * - 2.3283064e-10 * 16.0 - 8.0; - particleVelX = local_40.x; - particleY = fVar8; - particleLifetime = pfVar4; - if (pfVar6 == *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x278))))) { - pfVar4 = GHIDRA_CAST(std)::vector<24byte>::_Emplace_reallocate(pfVar6,&particleX); - } - else { - *pfVar6 = particleX; - pfVar6[1] = fVar8; - pfVar6[2] = local_40.x; - pfVar6[3] = local_38.x; - pfVar6[4] = 0.0; - pfVar6[5] = (float)pfVar4; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))) + 0x18; - } - } - pfVar6 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x270)))); - if (pfVar6 != *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274))))) { - particleVelYPtr = pfVar6 + 3; - do { - pfVar7 = particleVelYPtr + -2; - *pfVar6 = particleVelYPtr[-1] + *pfVar6; - *pfVar7 = *pfVar7 + *particleVelYPtr; - uVar2 = Random(); - local_38.x = (float)((double)GHIDRA_INT(uVar2) + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * - 2.3283064e-10 * 0.1 - 0.05; - uVar2 = Random(); - particleVelYPtr[1] = (float)(GHIDRA_INT(particleVelYPtr[1]) + 1); - particleVelYPtr[-1] = - (((float)((double)GHIDRA_INT(uVar2) + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * - 2.3283064e-10 * 0.4 - 0.2) + particleVelYPtr[-1]) * 0.98; - *particleVelYPtr = (local_38.x + *particleVelYPtr) * 0.97; - if (GHIDRA_INT(particleVelYPtr[1]) < GHIDRA_INT(particleVelYPtr[2])) { - pfVar6 = pfVar6 + 6; - particleVelYPtr = particleVelYPtr + 6; - pfVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))); - } - else { - pfVar5 = particleVelYPtr + 3; - pfVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))); - if (pfVar5 != pfVar4) { - do { - pfVar7[-1] = *pfVar5; - pfVar5 = pfVar5 + 6; - *pfVar7 = pfVar7[6]; - pfVar7[1] = pfVar7[7]; - pfVar7[2] = pfVar7[8]; - pfVar7[3] = pfVar7[9]; - pfVar7[4] = pfVar7[10]; - pfVar7 = pfVar7 + 6; - } while (pfVar5 != pfVar4); - pfVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))); - } - pfVar4 = pfVar4 + -6; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x274)))) = pfVar4; - } - } while (pfVar6 != pfVar4); - } - return pfVar4; -} diff --git a/generated-src/grid_entity_gravity.cpp b/generated-src/grid_entity_gravity.cpp deleted file mode 100644 index f1dfd75..0000000 --- a/generated-src/grid_entity_gravity.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include "classes.h" - -// 0099b510 -void GridEntity_Gravity::BeginBatches() -{ - this->_collisionClass = 0; - return; -} - -// 0099b520 -void GridEntity_Gravity::guard_check_icall() -{ - void *pvVar1; - int iVar2; - code *pcVar3; - uint8_t isAnimSet; - int belowRow; - char *freeBlock; - int column; - uint32_t uVar4; - ANM2 *floorSprite; - RNG rng; - uint32_t local_6c; - ANM2 *sprite; - std_string itemDungeonPath; - std_string tilesPath; - uint8_t floorAnimName [32]; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - - local_8 = 0xffffffff; - puStack_c = &LAB_00b0d90d; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT((floorAnimName + 0x30)); - ExceptionList = &local_10; - pvVar1 = g_game->_room; - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)); - column = GHIDRA_INT(((((float)(this->_gridIndex % iVar2) * 40.0 + 40.0 + 0.0) - 40.0) / 40.0 + 0.5)); - belowRow = GHIDRA_INT(((((float)(this->_gridIndex / iVar2) * 40.0 + 120.0 + 40.0) - 120.0) / 40.0 + 0.5)) - ; - if (((((-1 < column) && (column < iVar2)) && (-1 < belowRow)) && - ((belowRow < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x10)) && - (uVar4 = iVar2 * belowRow + column, uVar4 < 0x1c0)))) && - ((iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + uVar4 * 4 + 0x24)), iVar2 != 0 && - ((iVar2 = *GHIDRA_CAST((iVar2 + 4)), iVar2 == 3 || (iVar2 == 0xf)))))) { - iVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - local_6c = 0xc; - rng._shift3 = 0xc; - sprite = &this->_sprite; - rng._shift1 = 5; - rng._shift2 = 0x15; - rng._seed = iVar2; - if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x1d18)) == 0x38) { - tilesPath._size = 0; - tilesPath._capacity = 0xf; - tilesPath._buf[0] = '\0'; - tilesPath._buf[1] = '\0'; - tilesPath._buf[2] = '\0'; - tilesPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - tilesPath._size = 0x1a; - tilesPath._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tilesPath._buf))) + 0x0))),"gfx/grid/Tiles_Rotgut.anm2",0x1b); - local_8 = 0; - ANM2::Load(&this->_sprite,&tilesPath,1); - local_8 = 0xffffffff; - if (0xf < tilesPath._capacity) { - uVar4 = tilesPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tilesPath._buf))) + 0x0))); - if (0xfff < uVar4) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) + -4)); - uVar4 = tilesPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(freeBlock,uVar4); - } - isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Floor"),1); - if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - } - pvVar1 = (this->_sprite)._animState._animData; - if (pvVar1 == (void *)0x0) { - uVar4 = 0; - } - else { - uVar4 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x30)); - } - uVar4 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(uVar4); - if ((this->_sprite)._animState._animData != (void *)0x0) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)GHIDRA_INT(uVar4)); - } - } - else { - if (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x1d18)) == 0x37) { - tilesPath._size = 0; - tilesPath._capacity = 0xf; - tilesPath._buf[0] = '\0'; - tilesPath._buf[1] = '\0'; - tilesPath._buf[2] = '\0'; - tilesPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) = msvc::_Allocate(0x30); - floorSprite = sprite; - tilesPath._size = 0x26; - tilesPath._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tilesPath._buf))) + 0x0))),"gfx/grid/Tiles_Itemdungeon_Gideon.anm2",0x27); - local_8 = 1; - ANM2::Load(sprite,&tilesPath,1); - local_8 = 0xffffffff; - if (0xf < tilesPath._capacity) { - uVar4 = tilesPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(tilesPath._buf))) + 0x0))); - if (0xfff < uVar4) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) + -4)); - uVar4 = tilesPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(freeBlock,uVar4); - } - tilesPath._size = 0; - tilesPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(tilesPath._buf)) + 0x0))) & 0xffffff00; - } - else { - itemDungeonPath._size = 0; - itemDungeonPath._capacity = 0xf; - itemDungeonPath._buf[0] = '\0'; - itemDungeonPath._buf[1] = '\0'; - itemDungeonPath._buf[2] = '\0'; - itemDungeonPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(itemDungeonPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - floorSprite = sprite; - itemDungeonPath._size = 0x1f; - itemDungeonPath._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(itemDungeonPath._buf))) + 0x0))),"gfx/grid/Tiles_Itemdungeon.anm2",0x20); - local_8 = 2; - ANM2::Load(sprite,&itemDungeonPath,1); - local_8 = 0xffffffff; - if (0xf < itemDungeonPath._capacity) { - uVar4 = itemDungeonPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(itemDungeonPath._buf))) + 0x0))); - if (0xfff < uVar4) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(itemDungeonPath._buf)) + 0x0))) + -4)); - uVar4 = itemDungeonPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(itemDungeonPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(freeBlock,uVar4); - } - itemDungeonPath._size = 0; - itemDungeonPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(itemDungeonPath._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(itemDungeonPath._buf)) + 0x0))) & 0xffffff00; - } - if (iVar2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar3 = (code *)swi(3); - (*pcVar3)(); - return; - } - sprintf_s(floorAnimName,0x1f,GHIDRA_CAST("Floor%u")); - ANM2::Play(floorSprite,floorAnimName,0); - } - } - ExceptionList = local_10; - return; -} - -// 0099b980 -void GridEntity_Gravity::Update() -{ - int *playerSlot; - void *playerListEnd; - int gridY; - PlayerManager *playerManager; - int player; - uint32_t i; - int gridWidth; - int player; - - playerManager = &g_game->_playerManager; - i = 0; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) { - do { - playerListEnd = (playerManager->_playerList)._end; - if (GHIDRA_INT(playerListEnd) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - playerListEnd = (playerManager->_playerList)._end; - } - playerSlot = (playerManager->_playerList)._begin; - if (i < GHIDRA_UINT((GHIDRA_INT(playerListEnd) - GHIDRA_INT(playerSlot) >> 2))) { - playerSlot = playerSlot + i; - } - player = *playerSlot; - player = GHIDRA_INT(((*GHIDRA_CAST((player + 0x33c)) - 40.0) / 40.0 + 0.5)); - gridY = GHIDRA_INT(((*GHIDRA_CAST((player + 0x340)) - 120.0) / 40.0 + 0.5)); - if ((((player < 0) || (gridWidth = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)), gridWidth <= player)) || - (gridY < 0)) || (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x10)) <= gridY)) { - player = -1; - } - else { - player = gridWidth * gridY + player; - } - if (player == this->_gridIndex) { - *GHIDRA_CAST((player + 0x168)) = *GHIDRA_CAST((player + 0x168)) | 0x8000; - *GHIDRA_CAST((player + 0x16c)) = *GHIDRA_CAST((player + 0x16c)); - } - i = i + 1; - playerManager = &g_game->_playerManager; - } while (i < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - return; -} diff --git a/generated-src/grid_entity_lock.cpp b/generated-src/grid_entity_lock.cpp deleted file mode 100644 index 9477420..0000000 --- a/generated-src/grid_entity_lock.cpp +++ /dev/null @@ -1,338 +0,0 @@ -#include "classes.h" - -// 00711780 -void GridEntity_Lock::BeginBatches() -{ - uint8_t isAnimSet; - Entity_Player *payToPlayOwner; - char *pcVar1; - uint32_t size; - std_string anm2Path; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afc99d; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size); - ExceptionList = &local_10; - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x18; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/grid_locks.anm2",0x19); - local_8 = 0; - ANM2::Load(&this->_sprite,&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - size = anm2Path._capacity + 1; - pcVar1 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < size) { - pcVar1 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - size = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar1))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar1,size); - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - payToPlayOwner = - PlayerManager::FirstCollectibleOwner - (&g_game->_playerManager,0x17c,GHIDRA_CAST(&g_game->_playerManager),1); - (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154))) = payToPlayOwner != GHIDRA_CAST(0x0); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0) { - pcVar1 = "IdleCoin"; - if (payToPlayOwner == GHIDRA_CAST(0x0)) { - pcVar1 = GHIDRA_CAST(s_Idle); - } - isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(pcVar1),1); - if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - } - this->_collisionClass = 4; - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 4000; - } - } - else { - isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Broken"),1); - if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - } - this->_collisionClass = 0; - } - ExceptionList = local_10; - return; -} - -// 00711950 -void GridEntity_Lock::Update() -{ - Entity_Player *player_00; - uint8_t isBreakTriggered; - uint32_t *playerSlot; - void *playerListEnd; - Game *game; - PlayerManager *playerManager; - uint32_t i; - float dx; - float dy; - Entity_Player *player; - int roomWidth; - - if (((this->_sprite)._animState._animData != (void *)0x0) && - (isBreakTriggered = - AnimationState::IsEventTriggered(&(this->_sprite)._animState,GHIDRA_CAST("Break")), - isBreakTriggered != 0)) { - this->_collisionClass = 0; - game = g_game; - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 0; - goto LAB_007119ac; - } - } - game = g_game; -LAB_007119ac: - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0) { - playerManager = &game->_playerManager; - i = 0; - if (GHIDRA_INT((game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 - != 0) { - do { - playerListEnd = (playerManager->_playerList)._end; - if (GHIDRA_INT(playerListEnd) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - playerListEnd = (playerManager->_playerList)._end; - game = g_game; - } - playerSlot = (playerManager->_playerList)._begin; - if (i < GHIDRA_UINT((GHIDRA_INT(playerListEnd) - GHIDRA_INT(playerSlot) >> 2))) { - playerSlot = playerSlot + i; - } - player_00 = GHIDRA_CAST(*playerSlot); - if ((player_00->_variant == 0) && - (roomWidth = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)), - dx = (player_00->_pos).x - ((float)(this->_gridIndex % roomWidth) * 40.0 + 40.0), - dy = (player_00->_pos).y - ((float)(this->_gridIndex / roomWidth) * 40.0 + 120.0), - dy * dy + dx * dx < 961.0)) { - try_unlock(this,player_00,0); - game = g_game; - } - playerManager = &game->_playerManager; - i = i + 1; - } while (i < GHIDRA_UINT((GHIDRA_INT((game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - return; -} - -// 00711af0 -void GridEntity_Lock::try_unlock(Entity_Player *player, uint8_t isForce) -{ - uint8_t isKeyUsed; - int paperClipMultiplier; - GridEntity_Lock *soundId [2]; - Manager *manager; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0) { - if (isForce == 0) { - soundId[0] = this; - if ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154))) == '\0') { - paperClipMultiplier = Entity_Player::GetTrinketMultiplier(player,0x13); - if ((paperClipMultiplier < 2) && - (isKeyUsed = Entity_Player::TryUseKey(player), isKeyUsed == 0)) { - return; - } - } - else { - if (player->_numCoins < 1) { - return; - } - Entity_Player::AddCoins(player,-1); - } - } - manager = g_manager; - soundId[0] = GHIDRA_CAST(0x9c); - if ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154))) != '\0') { - soundId[0] = GHIDRA_CAST(0x2d); - } - seed_fart_sound_override(GHIDRA_CAST(soundId)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(soundId[0]),1.0,2,0,1.0,0.0); - break_open(this,player); - } - return; -} - -// 00711bb0 -void GridEntity_Lock::break_open(Entity_Player *player) -{ - uint8_t bVar1; - int iVar2; - uint32_t uVar3; - int gridX; - void *trinketRngEnd; - uint32_t *trinketRng; - uint32_t *playerIt; - uint32_t variant; - char *anim; - RNG dropRng; - GridEntity_Lock *lock; - Vector local_10; - code *debugBreak; - Game *game; - Manager *manager; - void *trinketRngBegin; - - manager = g_manager; - local_10.y = 3.20897e-43; - lock = this; - seed_fart_sound_override(GHIDRA_CAST(&local_10.y)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_10.y),1.0,2,0,1.0,0.0); - if ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154))) == '\0') { - if ((player == GHIDRA_CAST(0x0)) || (anim = "BreakingGolden", player->_hasGoldenKey == 0)) { - anim = "Breaking"; - } - } - else { - anim = "BreakingCoin"; - } - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(anim),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - uVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - game = g_game; - dropRng._shift1 = 1; - dropRng._shift2 = 5; - dropRng._shift3 = 0x10; - if (uVar3 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - debugBreak = (code *)swi(3); - (*debugBreak)(); - return; - } - uVar3 = uVar3 >> 1 ^ uVar3; - uVar3 = uVar3 << 5 ^ uVar3; - local_10.y = (float)(uVar3 >> 0x10 ^ uVar3); - if (0.1 <= (float)((double)GHIDRA_INT(local_10.y) + __uint_to_double_fixup[-(GHIDRA_INT(local_10.y) >> 0x1f)]) * - 2.3283062e-10) { - return; - } - if (player == GHIDRA_CAST(0x0)) { - playerIt = (g_game->_playerManager)._playerList._begin; - if (playerIt != (g_game->_playerManager)._playerList._end) { - do { - player = GHIDRA_CAST(*playerIt); - if ((player->_variant == 0) && - (bVar1 = Entity_Player::HasTrinket(player,0x16,0), bVar1 != 0)) goto LAB_00711d1a; - playerIt = playerIt + 1; - } while (playerIt != (game->_playerManager)._playerList._end); - } - player = GHIDRA_CAST(0x0); - } -LAB_00711d1a: - if (local_10.y == 0.0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - debugBreak = (code *)swi(3); - (*debugBreak)(); - return; - } - uVar3 = GHIDRA_UINT(local_10.y) >> ((uint8_t)dropRng._shift1 & 0x1f) ^ GHIDRA_UINT(local_10.y); - uVar3 = uVar3 << ((uint8_t)dropRng._shift2 & 0x1f) ^ uVar3; - dropRng._seed = uVar3 >> 0x10 ^ uVar3; - local_10.y = (float)dropRng._seed; - if (0.25 <= (float)((double)dropRng._seed + __uint_to_double_fixup[-(dropRng._seed >> 0x1f)]) * - 2.3283062e-10) { -LAB_00711e7c: - if (local_10.y == 0.0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - debugBreak = (code *)swi(3); - (*debugBreak)(); - return; - } - uVar3 = GHIDRA_UINT(local_10.y) >> ((uint8_t)dropRng._shift1 & 0x1f) ^ GHIDRA_UINT(local_10.y); - uVar3 = uVar3 << ((uint8_t)dropRng._shift2 & 0x1f) ^ uVar3; - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - gridX = lock->_gridIndex % iVar2; - iVar2 = lock->_gridIndex / iVar2; - uVar3 = uVar3 >> 0x10 ^ uVar3; - variant = 0x14; - } - else { - if (player != GHIDRA_CAST(0x0)) { - trinketRngEnd = (player->_trinketRNGs)._end; - if (GHIDRA_INT((GHIDRA_INT(trinketRngEnd) - GHIDRA_INT((player->_trinketRNGs)._begin) & 0xfffffff0U)) < 0x161) { - KAGE_LogMessage(0x10,GHIDRA_CAST("Trinket ID out of bounds!\n")); - trinketRngEnd = (player->_trinketRNGs)._end; - } - trinketRngBegin = (player->_trinketRNGs)._begin; - uVar3 = (GHIDRA_INT(trinketRngEnd) - GHIDRA_INT(trinketRngBegin) >> 4) - 1; - if (0x16 < uVar3) { - uVar3 = 0x16; - } - trinketRng = GHIDRA_CAST((uVar3 * 0x10 + GHIDRA_INT(trinketRngBegin))); - uVar3 = *trinketRng; - if (uVar3 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - uVar3 = *trinketRng; - if (uVar3 == 0) { - debugBreak = (code *)swi(3); - (*debugBreak)(); - return; - } - } - uVar3 = uVar3 >> ((uint8_t)trinketRng[1] & 0x1f) ^ uVar3; - uVar3 = uVar3 << ((uint8_t)trinketRng[2] & 0x1f) ^ uVar3; - uVar3 = uVar3 >> ((uint8_t)trinketRng[3] & 0x1f) ^ uVar3; - *trinketRng = uVar3; - if (uVar3 != (uVar3 / 5) * 5) goto LAB_00711e7c; - } - uVar3 = (GHIDRA_CAST((&dropRng)))->RNG::Next(); - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - gridX = lock->_gridIndex % iVar2; - iVar2 = lock->_gridIndex / iVar2; - variant = 10; - } - local_10.x = (float)gridX * 40.0 + 40.0; - local_10.y = (float)iVar2 * 40.0 + 120.0; - Game::Spawn(g_game,5,variant,&local_10,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar3); - return; -} - -// 00712090 -void * GridEntity_Lock::GetWaterClipInfo(void *outInfo) -{ - uint32_t clipValue; - - clipValue = 0x26; - if (this->_collisionClass != 0) { - clipValue = 0x39; - } - *GHIDRA_CAST(outInfo) = clipValue; - *GHIDRA_CAST((GHIDRA_CAST(outInfo) + 4)) = 0; - return outInfo; -} diff --git a/generated-src/grid_entity_pit.cpp b/generated-src/grid_entity_pit.cpp deleted file mode 100644 index 7b644dd..0000000 --- a/generated-src/grid_entity_pit.cpp +++ /dev/null @@ -1,1310 +0,0 @@ -#include "classes.h" - -// 00712180 -void GridEntity_Pit::Update() -{ - code *pcVar1; - int64_t lVar2; - int64_t lVar3; - int64_t lVar4; - Entity *pEVar5; - uint8_t bVar6; - char cVar7; - RoomDescriptor *roomDesc; - Game *pGVar8; - LayerState *layer; - uint32_t uVar9; - uint32_t uVar10; - int iVar11; - int *piVar12; - ColorMod *extraout_EAX; - int unusedArg; - int unusedArg_00; - void *pvVar13; - int unusedArg_01; - uint32_t uVar14; - PlayerManager *playerManager; - bool bVar15; - float fVar16; - float scale; - uint64_t uVar17; - ColorMod *other; - uint8_t auStack_e4 [4]; - int spawnSubType; - Game *local_dc; - int local_d8 [2]; - int *local_d0; - Vector spawnPos; - uint32_t spawnType; - Entity *local_c0; - float local_bc; - int triggerKeyVariant; - uint32_t local_b4; - Entity *local_b0 [2]; - Game *local_a8; - int effectKeyVariant; - uint32_t startTimeHi; - float local_98 [5]; - Vector spawnVelocity; - int iStack_7c; - uint64_t local_78; - int local_70; - int iStack_6c; - Vector local_68; - int soundId; - GridEntity_Pit *pit; - uint8_t itemFindResult [8]; - int itemNode; - RNG RStack_48; - Color tintColor; - uint32_t local_c; - GridEntity_Pit *curPit; - Manager *manager; - uint32_t *spawnerSlot; - - local_c = __security_cookie ^ GHIDRA_UINT(auStack_e4); - pit = this; - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 3) && - ((roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),g_game->_currentRoomIdx, - g_game->_currentDimensionIdx), - (GHIDRA_UINT(roomDesc->Flags) >> 1 & 1) != 0 || - (bVar6 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x97), bVar6 != 0)))) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - if (1 < GHIDRA_UINT((this->_sprite)._layerCount)) { - pGVar8 = GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) + -2)); - local_dc = GHIDRA_CAST(0x0); - if (0 < GHIDRA_INT(pGVar8)) { - local_dc = pGVar8; - } - if (((this->_sprite)._animState._animData != (void *)0x0) && - ((1 < *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animation) + 0x80)) || - (KAGE_LogMessage(0x10,GHIDRA_CAST("LayerId out of bounds\n")), - 1 < *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animation) + 0x80)))))) { - pvVar13 = (this->_sprite)._animState._animData; - iVar11 = *GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x3c)); - if ((pvVar13 == (void *)0x0) || ((iVar11 < 0 || (*GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x1c)) <= iVar11)))) { - KAGE_LogMessage(0x10,GHIDRA_CAST("id out of bounds\n")); - } - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._layerFrames) + iVar11 * 4)) = 0; - AnimationState::AdvanceLayerPosition(&(this->_sprite)._animState,iVar11,(float)GHIDRA_INT(local_dc)); - } - iVar11 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x1)); - layer->_visible = 1 < iVar11; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 3) { - GridEntity::hurt_surroundings(GHIDRA_CAST(this),11.0,11.0,8.0,2,0x10000080,0); - } - iVar11 = this->_varData; - if (iVar11 != 0) { - if (iVar11 == 10) { - this->_varData = 1; - uVar9 = Random(); - iVar11 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_68.x = (float)(this->_gridIndex % iVar11) * 40.0 + 40.0; - local_68.y = (float)(this->_gridIndex / iVar11) * 40.0 + 120.0; - Game::SpawnEx(g_game,1000,0xf,&local_68,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar9,0); - manager = g_manager; - soundId = 0x89; - seed_fart_sound_override(&soundId); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,1.0,0.0); - this = pit; - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pit)) + 0xc)))) == 1) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pit)) + 0xc)))) == 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pit)) + 0xc)))) = 2; - UpdateCollision(pit); - } - } - else if (10 < iVar11) { - this->_varData = iVar11 + -1; - } - if ((1 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc))))) && (this->_varData != 2)) { - this->_varData = 2; - grid_mark_neighbors_dirty(this->_gridIndex); - } - } - pvVar13 = g_game->_room; - iVar11 = *GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x1d18)); - if (iVar11 != 0x20) { - if ((((iVar11 != 0x3a) && (iVar11 != 0x3b)) || ((g_game->_levelStateFlags & 0x400000U) == 0)) || - ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 0 || (uVar9 = Random(), uVar9 % 0x28 != 0)))) - goto LAB_00713310; - spawnVelocity.x = 0.0; - uVar9 = Random(); - iVar11 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - fVar16 = (float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10; - local_98[2] = -1.0 - (fVar16 + fVar16); - spawnPos.x = (float)(this->_gridIndex % iVar11) * 40.0 + 40.0; - spawnPos.y = (float)(this->_gridIndex / iVar11) * 40.0 + 120.0; - spawnVelocity.y = local_98[2]; - local_98[0] = (float)Random(); - local_a8 = g_game; - spawnSubType = 2; - local_d0 = GHIDRA_CAST(&DAT_0000003b); - spawnType = 1000; - lua_callback_run_pre_entity_spawn - (GHIDRA_CAST(&spawnType),GHIDRA_CAST(&local_d0),&spawnPos,&spawnVelocity,GHIDRA_CAST(0x0), - &spawnSubType,GHIDRA_CAST(local_98)); - piVar12 = local_d0; - if (*GHIDRA_CAST(&g_game->_deathmatchManager) < 2) { -LAB_00712ebb: - local_d8[0] = spawnSubType; - } - else { - pGVar8 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&((g_game->_deathmatchManager))) + 0xc)))); - local_dc = pGVar8; - uVar9 = Random(); - iVar11 = spawnSubType; - local_78 = 0x900000005; - local_c0 = GHIDRA_CAST(&DAT_00000007); - local_70 = 7; - if (spawnType != 5) goto LAB_00712ebb; - if (piVar12 < GHIDRA_CAST(0x12d)) { - if (piVar12 == GHIDRA_CAST(0x12c)) { - while ((local_d8[0] = spawnSubType, spawnSubType == 0 || - (cVar7 = (**(code **)(pGVar8->_stage + 0x24))(spawnSubType), cVar7 != '\0'))) { - if (uVar9 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar9 = uVar9 >> ((uint8_t)local_78 & 0x1f) ^ uVar9; - uVar9 = uVar9 << ((uint8_t)((uint64_t)local_78 >> 0x20) & 0x1f) ^ uVar9; - uVar9 = uVar9 >> ((uint8_t)local_c0 & 0x1f) ^ uVar9; - iVar11 = ItemPool::GetCardEx(uVar9,0x19,10,10,1); - RStack_48._shift1 = 5; - RStack_48._shift2 = 9; - RStack_48._shift3 = 7; - RStack_48._seed = uVar9; - spawnSubType = lua_callback_run_get_card(&RStack_48,iVar11,1,1,0); - } - } - else { - if (piVar12 == GHIDRA_CAST(0x46)) { - local_bc = (float)(GHIDRA_UINT(spawnSubType) >> 0xb); - do { - local_d8[0] = spawnSubType; - if (spawnSubType != 0) { - pcVar1 = *(code **)(pGVar8->_stage + 0x28); - iVar11 = ItemPool::GetPillEffect - (&g_game->_itemPool,spawnSubType,GHIDRA_CAST(0x0)); - cVar7 = (*pcVar1)(iVar11); - if (cVar7 == '\0') goto LAB_00712ec3; - pGVar8 = local_dc; - } - if (uVar9 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar9 = uVar9 >> ((uint8_t)local_78 & 0x1f) ^ uVar9; - uVar9 = uVar9 << ((uint8_t)((uint64_t)local_78 >> 0x20) & 0x1f) ^ uVar9; - uVar9 = uVar9 >> ((uint8_t)local_c0 & 0x1f) ^ uVar9; - uVar10 = ItemPool::GetPill(uVar9); - spawnSubType = uVar10 | (GHIDRA_UINT(local_bc) & 1) << 0xb; - } while( true ); - } - if (piVar12 != GHIDRA_CAST(0x64)) goto LAB_00712ebb; - local_d8[0] = spawnSubType; - if (spawnSubType == 0x19) { -LAB_00712d17: - bVar15 = false; - } - else { - local_bc = (float)spawnSubType; - msvc::set::find_node(itemFindResult,&local_bc); - if (((*GHIDRA_CAST((itemNode + 0xd)) == '\0') && (*GHIDRA_CAST((itemNode + 0x10)) <= iVar11)) && - (itemNode != pGVar8->_roomList[0].Dimension)) goto LAB_00712d17; - bVar15 = true; - } - if ((iVar11 == 0) || (bVar15)) { - spawnSubType = (**(code **)(pGVar8->_stage + 0x84))(0); - local_d8[0] = spawnSubType; - } - } - } - else { - if (piVar12 != GHIDRA_CAST(0x15e)) goto LAB_00712ebb; - while ((local_d8[0] = spawnSubType, spawnSubType == 0 || - (cVar7 = (**(code **)(pGVar8->_stage + 0x2c))(spawnSubType), cVar7 != '\0'))) { - spawnSubType = ItemPool::GetTrinket(&g_game->_itemPool,0); - } - } - } -LAB_00712ec3: - local_c0 = (GHIDRA_CAST((local_a8->_entityFactory)))->EntityFactory::Create(spawnType,0); - if (local_c0 != GHIDRA_CAST(0x0)) { - uVar17 = GetTimeNs(); - pEVar5 = local_c0; - uVar9 = GHIDRA_UINT((uVar17 >> 0x20)); - lVar2 = (uVar17 & 0xffffffff) * 0x431bde82; - lVar3 = (uint64_t)uVar9 * 0xd7b634db + ((uVar17 & 0xffffffff) * 0xd7b634db >> 0x20); - local_b0[0] = GHIDRA_CAST((lVar3 + lVar2)); - lVar2 = (uint64_t)uVar9 * 0x431bde82 + - (uint64_t) - CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)), - GHIDRA_INT(((uint64_t)lVar2 >> 0x20)) + - GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar3)))), - GHIDRA_INT(((uint64_t)(lVar3 + lVar2) >> 0x20))); - startTimeHi = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20)); - spawnerSlot = &local_c0->_spawnerEntity; - local_b4 = GHIDRA_UINT(lVar2) >> 0x12 | startTimeHi * 0x4000; - startTimeHi = startTimeHi >> 0x12; - local_c0->_spawnerType = 0; - local_c0->_spawnerVariant = 0; - if (*spawnerSlot != 0) { - local_b0[0] = GHIDRA_CAST(spawnerSlot); - msvc::multiset::erase(local_b0); - } - iVar11 = *GHIDRA_CAST(pEVar5); - *spawnerSlot = 0; - (pEVar5->_pos).x = spawnPos.x; - (pEVar5->_pos).y = spawnPos.y; - (pEVar5->_velocity).x = 0.0; - (pEVar5->_velocity).y = local_98[2]; - (**(code **)(iVar11 + 4))(spawnType,local_d0,local_d8[0],local_98[0]); - pGVar8 = local_a8; - pvVar13 = local_a8->_room; - iVar11 = *GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x1214)); - *GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x1214)) = iVar11 + 1; - pEVar5->_index = iVar11; - EntityList::AddEntity(GHIDRA_CAST((GHIDRA_INT(pvVar13) + 0x1218)),pEVar5); - bVar6 = Game::ShouldEraseEnemy(pEVar5); - if (bVar6 != 0) { - Entity::RemoveWithPoof(pEVar5,unusedArg_00); - } - if ((pEVar5->_exists != 0) && - ((pGVar8->_proceduralItemManager)._proceduralItems._begin != - (pGVar8->_proceduralItemManager)._proceduralItems._end)) { - effectKeyVariant = pEVar5->_variant; - local_a8 = GHIDRA_CAST(pEVar5->_type); - msvc::map::find(&local_dc,&local_a8); - pGVar8 = (pGVar8->_proceduralItemManager)._spawnTriggerTargets._head; - if (local_dc == pGVar8) { - local_d8[0] = pEVar5->_type; - local_d8[1] = 0xffffffff; - piVar12 = GHIDRA_CAST(std)::map::find(local_98 + 2,local_d8); - local_dc = GHIDRA_CAST(*piVar12); - if (local_dc == pGVar8) goto LAB_00713111; - } - uVar9 = 0; - playerManager = &g_game->_playerManager; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 != 0) { - do { - pvVar13 = (playerManager->_playerList)._end; - if (GHIDRA_INT(pvVar13) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar13 = (playerManager->_playerList)._end; - } - piVar12 = (playerManager->_playerList)._begin; - if (uVar9 < GHIDRA_UINT((GHIDRA_INT(pvVar13) - GHIDRA_INT(piVar12) >> 2))) { - piVar12 = piVar12 + uVar9; - } - trigger_set_dispatch((void *)(*piVar12 + 0x1fc8),6,pEVar5,&spawnPos,&spawnVelocity); - uVar9 = uVar9 + 1; - playerManager = &g_game->_playerManager; - } while (uVar9 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - } -LAB_00713111: - uVar17 = GetTimeNs(); - uVar9 = GHIDRA_UINT((uVar17 >> 0x20)); - lVar2 = (uVar17 & 0xffffffff) * 0x431bde82; - local_b0[0] = GHIDRA_CAST(((uint64_t)lVar2 >> 0x20)); - lVar3 = (uint64_t)uVar9 * 0x431bde82; - local_bc = (float)lVar3; - lVar4 = (uint64_t)uVar9 * 0xd7b634db + ((uVar17 & 0xffffffff) * 0xd7b634db >> 0x20); - local_68.x = (float)(lVar4 + lVar2); - lVar3 = lVar3 + (uint64_t) - CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar4 >> 0x20)), - GHIDRA_INT((&(local_b0[0]->_sprite)._filename + -3)) + - GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar4)))), - GHIDRA_INT(((uint64_t)(lVar4 + lVar2) >> 0x20))); - uVar14 = GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)); - uVar9 = GHIDRA_UINT(lVar3) >> 0x12 | uVar14 * 0x4000; - uVar10 = uVar9 - local_b4; - bVar15 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar10); - (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar10; - (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) = - (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) + (((uVar14 >> 0x12) - startTimeHi) - GHIDRA_UINT((uVar9 < local_b4))) - + GHIDRA_UINT(bVar15); - } - pEVar5 = local_c0; - uVar9 = Random(); - (GHIDRA_CAST((&tintColor)))->Color::Color(1.0,0.0,0.0, - (float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 * 0.2 + 0.1); - other = extraout_EAX; - layer = ANM2::GetLayer(&pEVar5->_sprite,GHIDRA_CAST(0x0)); - (GHIDRA_CAST((GHIDRA_CAST(&layer->_color))))->Color::operator_assign(other); - (GHIDRA_CAST((&iStack_7c)))->BlendMode::SetMode(2,unusedArg_01); - layer = ANM2::GetLayer(&pEVar5->_sprite,GHIDRA_CAST(0x0)); - layer->_blendMode[0] = iStack_7c; - layer->_blendMode[1] = GHIDRA_INT(local_78); - layer->_blendMode[2] = (*GHIDRA_CAST((GHIDRA_CAST(&(local_78)) + 0x4))); - layer->_blendMode[3] = local_70; - layer->_blendMode[4] = iStack_6c; - uVar9 = Random(); - *GHIDRA_CAST((pEVar5[1]._sprite._animDefaultName._buf + 4)) = - (float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * 2.3283064e-10 - * 10.0 + 2.0; - uVar9 = Random(); - iVar11 = uVar9 % 0x1e + 0x14; - *GHIDRA_CAST((pEVar5[1]._sprite._filename._buf + 4)) = iVar11; - *GHIDRA_CAST((pEVar5[1]._sprite._filename._buf + 8)) = iVar11; - uVar9 = Random(); - iVar11 = *GHIDRA_CAST(pEVar5); - scale = (float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 * 0.2 + 0.8; - fVar16 = scale * g_vectorOne.x; - (pEVar5->_sprite)._scale.y = scale * g_vectorOne.y; - (pEVar5->_sprite)._scale.x = fVar16; - (**(code **)(iVar11 + 0xc))(); - goto LAB_00713310; - } - if (((((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 4)) + 0x44)) >> 5 & 1) == 0) || - (*GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x7740)) <= 0.5)) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 0)) || - (uVar9 = Random(), uVar9 % 0x14 != 0)) goto LAB_00713310; - uVar9 = Random(); - local_98[0] = (float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 * -1.2800001; - uVar9 = Random(); - iVar11 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_bc = ((float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 - 0.5) * 0.4; - spawnVelocity.y = local_98[0]; - spawnPos.x = (float)(this->_gridIndex % iVar11) * 40.0 + 40.0; - spawnPos.y = (float)(this->_gridIndex / iVar11) * 40.0 + 120.0; - spawnVelocity.x = local_bc; - uVar9 = Random(); - spawnPos.x = ((float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 - 0.5) * 18.0 + spawnPos.x; - uVar9 = Random(); - spawnPos.y = ((float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 - 0.5) * 18.0 + spawnPos.y; - local_c0 = GHIDRA_CAST(Random()); - local_dc = g_game; - spawnSubType = 0; - local_b4 = 0x42; - spawnType = 1000; - lua_callback_run_pre_entity_spawn - (GHIDRA_CAST(&spawnType),GHIDRA_CAST(&local_b4),&spawnPos,&spawnVelocity,GHIDRA_CAST(0x0),&spawnSubType - ,GHIDRA_CAST(&local_c0)); - uVar9 = local_b4; - if (*GHIDRA_CAST(&g_game->_deathmatchManager) < 2) { -LAB_00712858: - local_d8[0] = spawnSubType; - } - else { - piVar12 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&((g_game->_deathmatchManager))) + 0xc)))); - local_d0 = piVar12; - uVar10 = Random(); - iVar11 = spawnSubType; - local_78 = 0x900000005; - local_a8 = GHIDRA_CAST(&DAT_00000007); - local_70 = 7; - if (spawnType != 5) goto LAB_00712858; - if (uVar9 < 0x12d) { - if (uVar9 == 300) { - while ((local_d8[0] = spawnSubType, spawnSubType == 0 || - (cVar7 = (**(code **)(*piVar12 + 0x24))(spawnSubType), cVar7 != '\0'))) { - if (uVar10 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar10 = uVar10 >> ((uint8_t)local_78 & 0x1f) ^ uVar10; - uVar10 = uVar10 << ((uint8_t)((uint64_t)local_78 >> 0x20) & 0x1f) ^ uVar10; - uVar10 = uVar10 >> ((uint8_t)local_a8 & 0x1f) ^ uVar10; - iVar11 = ItemPool::GetCardEx(uVar10,0x19,10,10,1); - RStack_48._shift1 = 5; - RStack_48._shift2 = 9; - RStack_48._shift3 = 7; - RStack_48._seed = uVar10; - spawnSubType = lua_callback_run_get_card(&RStack_48,iVar11,1,1,0); - } - } - else { - if (uVar9 == 0x46) { - local_98[2] = (float)(GHIDRA_UINT(spawnSubType) >> 0xb); - do { - local_d8[0] = spawnSubType; - if (spawnSubType != 0) { - pcVar1 = *(code **)(*piVar12 + 0x28); - iVar11 = ItemPool::GetPillEffect(&g_game->_itemPool,spawnSubType,GHIDRA_CAST(0x0)) - ; - cVar7 = (*pcVar1)(iVar11); - if (cVar7 == '\0') goto LAB_00712860; - piVar12 = local_d0; - } - if (uVar10 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar10 = uVar10 >> ((uint8_t)local_78 & 0x1f) ^ uVar10; - uVar10 = uVar10 << ((uint8_t)((uint64_t)local_78 >> 0x20) & 0x1f) ^ uVar10; - uVar10 = uVar10 >> ((uint8_t)local_a8 & 0x1f) ^ uVar10; - uVar9 = ItemPool::GetPill(uVar10); - spawnSubType = uVar9 | (GHIDRA_UINT(local_98[2]) & 1) << 0xb; - } while( true ); - } - if (uVar9 != 100) goto LAB_00712858; - local_d8[0] = spawnSubType; - if (spawnSubType == 0x19) { -LAB_007126b4: - bVar15 = false; - } - else { - local_a8 = GHIDRA_CAST(spawnSubType); - msvc::set::find_node(itemFindResult,&local_a8); - if (((*GHIDRA_CAST((itemNode + 0xd)) == '\0') && (*GHIDRA_CAST((itemNode + 0x10)) <= iVar11)) && - (itemNode != piVar12[8])) goto LAB_007126b4; - bVar15 = true; - } - if ((iVar11 == 0) || (bVar15)) { - spawnSubType = (**(code **)(*piVar12 + 0x84))(0); - local_d8[0] = spawnSubType; - } - } - } - else { - if (uVar9 != 0x15e) goto LAB_00712858; - while ((local_d8[0] = spawnSubType, spawnSubType == 0 || - (cVar7 = (**(code **)(*piVar12 + 0x2c))(spawnSubType), cVar7 != '\0'))) { - spawnSubType = ItemPool::GetTrinket(&g_game->_itemPool,0); - } - } - } -LAB_00712860: - local_b0[0] = (GHIDRA_CAST((local_dc->_entityFactory)))->EntityFactory::Create(spawnType,0); - if (local_b0[0] == GHIDRA_CAST(0x0)) goto LAB_00713310; - uVar17 = GetTimeNs(); - pEVar5 = local_b0[0]; - uVar9 = GHIDRA_UINT((uVar17 >> 0x20)); - lVar2 = (uVar17 & 0xffffffff) * 0x431bde82; - lVar3 = (uint64_t)uVar9 * 0xd7b634db + ((uVar17 & 0xffffffff) * 0xd7b634db >> 0x20); - local_98[2] = (float)(lVar3 + lVar2); - lVar2 = (uint64_t)uVar9 * 0x431bde82 + - (uint64_t) - CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)), - GHIDRA_INT(((uint64_t)lVar2 >> 0x20)) + GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar3)))), - GHIDRA_INT(((uint64_t)(lVar3 + lVar2) >> 0x20))); - startTimeHi = GHIDRA_UINT(((uint64_t)lVar2 >> 0x20)); - spawnerSlot = &local_b0[0]->_spawnerEntity; - local_d0 = GHIDRA_CAST((GHIDRA_UINT(lVar2) >> 0x12 | startTimeHi * 0x4000)); - startTimeHi = startTimeHi >> 0x12; - local_b0[0]->_spawnerType = 0; - local_b0[0]->_spawnerVariant = 0; - if (*spawnerSlot != 0) { - local_b0[0] = GHIDRA_CAST(spawnerSlot); - msvc::multiset::erase(local_b0); - } - iVar11 = *GHIDRA_CAST(pEVar5); - *spawnerSlot = 0; - (pEVar5->_pos).x = spawnPos.x; - (pEVar5->_pos).y = spawnPos.y; - (pEVar5->_velocity).x = local_bc; - (pEVar5->_velocity).y = local_98[0]; - (**(code **)(iVar11 + 4))(spawnType,local_b4,local_d8[0],local_c0); - pGVar8 = local_dc; - pvVar13 = local_dc->_room; - iVar11 = *GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x1214)); - *GHIDRA_CAST((GHIDRA_CAST(pvVar13) + 0x1214)) = iVar11 + 1; - pEVar5->_index = iVar11; - EntityList::AddEntity(GHIDRA_CAST((GHIDRA_INT(pvVar13) + 0x1218)),pEVar5); - bVar6 = Game::ShouldEraseEnemy(pEVar5); - if (bVar6 != 0) { - Entity::RemoveWithPoof(pEVar5,unusedArg); - } - if ((pEVar5->_exists != 0) && - ((pGVar8->_proceduralItemManager)._proceduralItems._begin != - (pGVar8->_proceduralItemManager)._proceduralItems._end)) { - triggerKeyVariant = pEVar5->_variant; - local_bc = (float)pEVar5->_type; - msvc::map::find(&local_dc,&local_bc); - pGVar8 = (pGVar8->_proceduralItemManager)._spawnTriggerTargets._head; - if (local_dc == pGVar8) { - local_98[0] = (float)pEVar5->_type; - local_98[1] = -NAN; - piVar12 = GHIDRA_CAST(std)::map::find(local_98 + 2,local_98); - local_dc = GHIDRA_CAST(*piVar12); - if (local_dc == pGVar8) goto LAB_00712ab1; - } - uVar9 = 0; - playerManager = &g_game->_playerManager; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> - 2 != 0) { - do { - pvVar13 = (playerManager->_playerList)._end; - if (GHIDRA_INT(pvVar13) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar13 = (playerManager->_playerList)._end; - } - piVar12 = (playerManager->_playerList)._begin; - if (uVar9 < GHIDRA_UINT((GHIDRA_INT(pvVar13) - GHIDRA_INT(piVar12) >> 2))) { - piVar12 = piVar12 + uVar9; - } - trigger_set_dispatch((void *)(*piVar12 + 0x1fc8),6,pEVar5,&spawnPos,&spawnVelocity); - uVar9 = uVar9 + 1; - playerManager = &g_game->_playerManager; - } while (uVar9 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - } -LAB_00712ab1: - uVar17 = GetTimeNs(); - uVar9 = GHIDRA_UINT((uVar17 >> 0x20)); - lVar2 = (uVar17 & 0xffffffff) * 0x431bde82; - local_b0[0] = GHIDRA_CAST(((uint64_t)lVar2 >> 0x20)); - lVar3 = (uint64_t)uVar9 * 0x431bde82; - local_bc = (float)lVar3; - lVar4 = (uint64_t)uVar9 * 0xd7b634db + ((uVar17 & 0xffffffff) * 0xd7b634db >> 0x20); - local_68.x = (float)(lVar4 + lVar2); - lVar3 = lVar3 + (uint64_t) - CONCAT14(CARRY4(GHIDRA_UINT(((uint64_t)lVar4 >> 0x20)), - GHIDRA_INT((&(local_b0[0]->_sprite)._filename + -3)) + - GHIDRA_UINT(CARRY4(GHIDRA_UINT(lVar2),GHIDRA_UINT(lVar4)))), - GHIDRA_INT(((uint64_t)(lVar4 + lVar2) >> 0x20))); - uVar10 = GHIDRA_UINT(((uint64_t)lVar3 >> 0x20)); - piVar12 = GHIDRA_CAST((GHIDRA_UINT(lVar3) >> 0x12 | uVar10 * 0x4000)); - uVar9 = GHIDRA_INT(piVar12) - GHIDRA_INT(local_d0); - bVar15 = CARRY4(GHIDRA_UINT(g_entitySpawnTimeMs),uVar9); - (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x0))) = GHIDRA_UINT(g_entitySpawnTimeMs) + uVar9; - (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) = - (*GHIDRA_CAST((GHIDRA_CAST(&(g_entitySpawnTimeMs)) + 0x4))) + (((uVar10 >> 0x12) - startTimeHi) - GHIDRA_UINT((piVar12 < local_d0))) + - GHIDRA_UINT(bVar15); -LAB_00713310: - curPit = pit; - if ((((g_game->_frameCount % 10 == 0) && - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) >> 5 & 1) != 0)) && - (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)) == 9)) && - ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pit)) + 0xc)))) == 0 && (uVar9 = Random(), uVar9 % 6 == 0)))) { - (GHIDRA_CAST((GHIDRA_CAST(curPit))))->GridEntity::Position(&spawnPos); - uVar9 = Random(); - spawnPos.x = ((float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 - 0.5) * 15.0 + spawnPos.x; - uVar9 = Random(); - spawnPos.y = ((float)((double)GHIDRA_INT(uVar9) + __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283064e-10 - 0.5) * 15.0 + spawnPos.y; - uVar9 = Random(); - Game::SpawnEx(g_game,1000,0x7c,&spawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar9,0); - } - return; -} - -// 00713760 -void GridEntity_Pit::BeginBatches() -{ - code *pcVar1; - uint8_t bVar2; - uint32_t uVar3; - uint32_t *randomBackdrop; - uint8_t *pbVar4; - void *pvVar5; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - char *pcVar6; - Game *game; - uint32_t startFrame; - uint32_t seed; - uint8_t *pbVar7; - Game *game; - bool isLess; - uint64_t local_6c; - uint8_t *local_64; - uint8_t *local_60; - uint32_t local_5c; - uint32_t local_58; - uint64_t local_50; - uint32_t local_48; - std_string spritesheetPath; - std_string anm2Path; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afca3d; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size); - ExceptionList = &local_10; - uVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if ((char)uVar3 < '\0') { - uVar3 = uVar3 & 0xffffff7f; - this->_varData = 1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = uVar3; - } - if ((uVar3 & 0xff00) != 0) { - *GHIDRA_CAST((this->_gridIndex + 0x746c + GHIDRA_INT(g_game->_room))) = (char)(uVar3 >> 8); - } - game = g_game; - this->_hasLadder = 0; - local_58 = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x1d18)); - if (game->_challenge == 0x2d) { - seed = game->_dungeonPlacementSeed; - uVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - local_6c = 0xf00000002; - local_5c = 0x19; - local_64 = GHIDRA_CAST(0x19); - local_50 = 0xf00000002; - local_48 = 0x19; - if (uVar3 == 0) { - local_60 = GHIDRA_CAST(seed); - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar3 = uVar3 >> 2 ^ uVar3; - uVar3 = uVar3 << 0xf ^ uVar3; - uVar3 = uVar3 >> 0x19 ^ uVar3; - if (uVar3 == (uVar3 / 10) * 10) { - seed = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - local_6c = 0x900000005; - local_5c = 7; - local_64 = &DAT_00000007; - } - local_60 = g_game->_room; - if (seed == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar3 = seed >> (sbyte)local_6c ^ seed; - uVar3 = uVar3 << (sbyte)((uint64_t)local_6c >> 0x20) ^ uVar3; - randomBackdrop = - GHIDRA_CAST((local_60 + ((uVar3 >> (sbyte)local_5c ^ uVar3) % 0x3e + 1) * 0x13c + 0x1d1c)); - game = g_game; - if ((randomBackdrop != GHIDRA_CAST(0x0)) && (randomBackdrop[0x2e] != 0)) { - local_58 = *randomBackdrop; - } - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 4)) + 0x44)) >> 5 & 1) == 0) { - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x16; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/grid_pit.anm2",0x17); - local_8 = 2; - ANM2::Load(&this->_sprite,&anm2Path,0); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar3 = anm2Path._capacity + 1; - pcVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - pcVar6 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar3 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar6))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar6,uVar3); - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - Sprite::ReplaceSpritesheet - (GHIDRA_CAST(&this->_sprite),0, - (std_string *) - (GHIDRA_INT(g_game->_room) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)) * 0x13c + 0x1dc4)); - } - else { - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1c; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/grid_pit_water.anm2",0x1d); - local_8 = 0; - ANM2::Load(&this->_sprite,&anm2Path,0); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar3 = anm2Path._capacity + 1; - pcVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - pcVar6 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar3 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar6))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar6,uVar3); - } - pbVar7 = (this->_sprite)._overlayAnimState._animData; - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - if (pbVar7 == GHIDRA_CAST(0x0)) { -LAB_00713a2c: - bVar2 = ANM2::SetOverlayAnimation(&this->_sprite,GHIDRA_CAST("highlights"),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._overlayAnimState); - (this->_sprite)._overlayAnimState._isPlaying = 1; - } - } - else { - pbVar4 = pbVar7; - if (0xf < *GHIDRA_CAST((pbVar7 + 0x14))) { - pbVar4 = *GHIDRA_CAST(pbVar7); - } - pcVar6 = "highlights"; - do { - bVar2 = *pbVar4; - isLess = bVar2 < (uint8_t)*pcVar6; - if (bVar2 != *pcVar6) { -LAB_00713a11: - uVar3 = -GHIDRA_UINT(isLess) | 1; - goto LAB_00713a16; - } - if (bVar2 == 0) break; - bVar2 = pbVar4[1]; - isLess = bVar2 < (uint8_t)pcVar6[1]; - if (bVar2 != pcVar6[1]) goto LAB_00713a11; - pbVar4 = pbVar4 + 2; - pcVar6 = pcVar6 + 2; - } while (bVar2 != 0); - uVar3 = 0; -LAB_00713a16: - if ((uVar3 != 0) || - ((pbVar7[0x34] != 0 && ((this->_sprite)._overlayAnimState._isPlaying == 0)))) - goto LAB_00713a2c; - } - pvVar5 = ANM2::GetAnimationData(&this->_sprite,GHIDRA_CAST("highlights")); - uVar3 = *GHIDRA_CAST((GHIDRA_CAST(pvVar5) + 0x30)); - if (uVar3 == 0) { - startFrame = 0; - } - else { - startFrame = Random(); - startFrame = startFrame % uVar3; - } - if ((this->_sprite)._overlayAnimState._animData != (void *)0x0) { - AnimationState::SetFrameFloat(&(this->_sprite)._overlayAnimState,(float)GHIDRA_INT(startFrame)); - } - pvVar5 = g_game->_room; - pbVar7 = GHIDRA_CAST((GHIDRA_INT(pvVar5) + *GHIDRA_CAST((GHIDRA_CAST(pvVar5) + 0x1d18)) * 0x13c + 0x1ddc)); - if (0xf < *GHIDRA_CAST((pbVar7 + 0x14))) { - pbVar7 = *GHIDRA_CAST(pbVar7); - } - if ((local_58 == 10) || (pbVar4 = pbVar7, local_58 == 0xb)) { - local_5c = 0x13; - if (*GHIDRA_CAST((GHIDRA_CAST(pvVar5) + 4)) == 0) { - local_58 = 0; -LAB_00713aee: - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - local_58 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar5) + 4)) + 0x58)); - if (local_58 == 0) goto LAB_00713aee; - uVar3 = local_58 >> 1 ^ local_58; - uVar3 = uVar3 << 5 ^ uVar3; - pbVar4 = GHIDRA_CAST("gfx/grid/grid_pit_acid_womb.png"); - if (((uVar3 >> 0x13 ^ uVar3) & 1) == 0) { - pbVar4 = pbVar7; - } - } - spritesheetPath._size = 0; - spritesheetPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) = GHIDRA_CAST(0x0); - pbVar7 = pbVar4; - do { - bVar2 = *pbVar7; - pbVar7 = pbVar7 + 1; - } while (bVar2 != 0); - (GHIDRA_CAST((spritesheetPath._buf)))->msvc::string::assign(pbVar4,GHIDRA_INT(pbVar7) - GHIDRA_INT((pbVar4 + 1))); - local_8 = 1; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(0,&spritesheetPath); - local_8 = 0xffffffff; - if (0xf < spritesheetPath._capacity) { - uVar3 = spritesheetPath._capacity + 1; - pcVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(spritesheetPath._buf))) + 0x0))); - if (0xfff < uVar3) { - pcVar6 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) + -4)); - uVar3 = spritesheetPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar6))))) - goto LAB_00713e5d; - } - operator_delete(pcVar6,uVar3); - } - } - game = g_game; - if (g_game->_challenge == 0x2c) { - uVar3 = Level::GetRoomStageType(GHIDRA_CAST(g_game),g_game->_currentRoomIdx); -LAB_00713caf: - game = g_game; - uVar3 = RoomConfig::GetStageID(game->_stage,uVar3,-1); - if (uVar3 == 6) { - local_60 = &DAT_0000004f; - msvc::set::find_node(&local_6c,&local_60); - if ((((local_64[0xd] == '\0') && (*GHIDRA_CAST((local_64 + 0x10)) < 0x50)) && - (local_64 != (game->_seedEffects)._seedEffects)) && - (0.5 < *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x7240)))) { - (*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) = msvc::_Allocate(0x40); - spritesheetPath._size = 0x39; - spritesheetPath._capacity = 0x3f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(spritesheetPath._buf))) + 0x0))), - "gfx/promo/gfuel/grid/grid_pit_floodedcaves_verycursed.png",0x3a); - local_8 = 3; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(0,&spritesheetPath); - local_8 = 0xffffffff; - if (0xf < spritesheetPath._capacity) { - uVar3 = spritesheetPath._capacity + 1; - pcVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(spritesheetPath._buf))) + 0x0))); - if (0xfff < uVar3) { - pcVar6 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) + -4)); - uVar3 = spritesheetPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar6))))) - goto LAB_00713e5d; - } - operator_delete(pcVar6,uVar3); - } - game = g_game; - } - } - } - else { - game = g_game; - if (g_game->_currentDimensionIdx != 2) { - uVar3 = g_game->_stageType; - goto LAB_00713caf; - } - } - pbVar7 = GHIDRA_CAST((GHIDRA_INT(game->_room) + *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x1d18)) * 0x13c + 0x1dac)); - if (0xf < *GHIDRA_CAST((pbVar7 + 0x14))) { - pbVar7 = *GHIDRA_CAST(pbVar7); - } - spritesheetPath._size = 0; - spritesheetPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) = GHIDRA_CAST(0x0); - pbVar4 = pbVar7; - do { - bVar2 = *pbVar4; - pbVar4 = pbVar4 + 1; - } while (bVar2 != 0); - (GHIDRA_CAST((spritesheetPath._buf)))->msvc::string::assign(pbVar7,GHIDRA_INT(pbVar4) - GHIDRA_INT((pbVar7 + 1))); - local_8 = 4; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(1,&spritesheetPath); - local_8 = 0xffffffff; - bVar2 = extraout_CL; - if (0xf < spritesheetPath._capacity) { - uVar3 = spritesheetPath._capacity + 1; - pcVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(spritesheetPath._buf))) + 0x0))); - if (0xfff < uVar3) { - pcVar6 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) + -4)); - uVar3 = spritesheetPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(spritesheetPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar6))))) { -LAB_00713e5d: - local_8 = 0xffffffff; - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar6,uVar3); - bVar2 = extraout_CL_00; - } - ANM2::LoadGraphics(&this->_sprite,bVar2); - bVar2 = ANM2::SetAnimation(&this->_sprite,&DAT_00b68fb8,1); - if (((bVar2 != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - } - (this->_sprite)._offset.x = 2.0; - (this->_sprite)._offset.y = 2.0; - ExceptionList = local_10; - return; -} - -// 00713ee0 -void GridEntity_Pit::update_sprite_edges() -{ - void *pvVar1; - uint8_t isAnimSet; - uint32_t gridY; - int iVar2; - uint32_t gridY; - int iVar4; - LayerState *pLVar5; - uint32_t gridX; - int iVar6; - int iVar7; - int iVar8; - uint32_t edgeFrame; - int cornerMask; - int bottomCornerCount; - AnimationState *animState; - - pvVar1 = g_game->_room; - edgeFrame = 0; - gridY = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)); - gridY = GHIDRA_UINT(this->_gridIndex) / gridY; - gridX = GHIDRA_UINT(this->_gridIndex) % gridY; - iVar6 = gridX - 1; - if ((((((-1 < iVar6) && (iVar6 < GHIDRA_INT(gridY))) && (-1 < GHIDRA_INT(gridY))) && - ((GHIDRA_INT(gridY) < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x10)) && (iVar8 = gridY * gridY + iVar6, -1 < iVar8)))) - && (iVar8 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + iVar8 * 4 + 0x24)), iVar8 != 0)) && - (*GHIDRA_CAST((iVar8 + 4)) == 7)) { - edgeFrame = 1; - } - iVar8 = gridY - 1; - if ((((-1 < GHIDRA_INT(gridX)) && (GHIDRA_INT(gridX) < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)))) && - ((-1 < iVar8 && - (((iVar8 < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x10)) && - (iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)) * iVar8 + gridX, -1 < iVar2)) && - (iVar2 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + iVar2 * 4 + 0x24)), iVar2 != 0)))))) && - (*GHIDRA_CAST((iVar2 + 4)) == 7)) { - edgeFrame = edgeFrame + 2; - } - iVar2 = gridX + 1; - if ((((-1 < iVar2) && (iVar2 < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)))) && - ((-1 < GHIDRA_INT(gridY) && - ((GHIDRA_INT(gridY) < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x10)) && - (iVar7 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)) * gridY + iVar2, -1 < iVar7)))))) && - ((iVar7 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + iVar7 * 4 + 0x24)), iVar7 != 0 && (*GHIDRA_CAST((iVar7 + 4)) == 7)))) - { - edgeFrame = edgeFrame + 4; - } - iVar7 = gridY + 1; - if ((((-1 < GHIDRA_INT(gridX)) && (GHIDRA_INT(gridX) < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)))) && (-1 < iVar7)) && - (((iVar7 < *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x10)) && - (iVar4 = gridX + *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0xc)) * iVar7, -1 < iVar4)) && - ((iVar4 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + iVar4 * 4 + 0x24)), iVar4 != 0 && (*GHIDRA_CAST((iVar4 + 4)) == 7))) - ))) { - edgeFrame = edgeFrame + 8; - } - if (edgeFrame == 0) { - gridY = Random(); - edgeFrame = (gridY & 1) << 4; - } - switch(edgeFrame) { - case 3: - iVar6 = FUN_00813420(iVar6,iVar8); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - edgeFrame = edgeFrame + 0xe; - } - break; - case 6: - iVar6 = FUN_00813420(iVar2,iVar8); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - edgeFrame = edgeFrame + 0xc; - } - break; - case 7: - iVar7 = 0; - iVar2 = FUN_00813420(iVar2,iVar8); - if ((iVar2 == 0) || (*GHIDRA_CAST((iVar2 + 4)) != 7)) { - iVar7 = 1; - } - iVar6 = FUN_00813420(iVar6,iVar8); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - iVar7 = iVar7 + 2; - } - if (iVar7 == 0) { - edgeFrame = 7; - } - else { - edgeFrame = iVar7 + 0x1a; - } - break; - case 9: - iVar6 = FUN_00813420(iVar6,iVar7); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - edgeFrame = edgeFrame + 10; - } - break; - case 0xb: - iVar6 = FUN_00813420(iVar6,iVar8); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - edgeFrame = edgeFrame + 0xf; - } - break; - case 0xc: - iVar6 = FUN_00813420(iVar2,iVar7); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - edgeFrame = edgeFrame + 8; - } - break; - case 0xd: - iVar4 = 0; - iVar8 = FUN_00813420(iVar2,iVar7); - if ((iVar8 == 0) || (*GHIDRA_CAST((iVar8 + 4)) != 7)) { - iVar4 = 1; - } - iVar6 = FUN_00813420(iVar6,iVar7); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - iVar4 = iVar4 + 2; - } - if (iVar4 == 0) { - edgeFrame = 0xd; - } - else { - edgeFrame = iVar4 + 0x1d; - } - break; - case 0xe: - iVar6 = FUN_00813420(iVar2,iVar8); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - edgeFrame = edgeFrame + 0xb; - } - break; - case 0xf: - cornerMask = 0; - iVar4 = FUN_00813420(iVar6,iVar8); - if ((iVar4 == 0) || (*GHIDRA_CAST((iVar4 + 4)) != 7)) { - cornerMask = 1; - } - iVar8 = FUN_00813420(iVar2,iVar8); - if ((iVar8 == 0) || (*GHIDRA_CAST((iVar8 + 4)) != 7)) { - cornerMask = cornerMask + 2; - } - if (cornerMask == 0) { - bottomCornerCount = 0; - iVar6 = FUN_00813420(iVar6,iVar7); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - bottomCornerCount = 1; - } - iVar6 = FUN_00813420(iVar2,iVar7); - if ((iVar6 == 0) || (*GHIDRA_CAST((iVar6 + 4)) != 7)) { - bottomCornerCount = bottomCornerCount + 1; - } - edgeFrame = 0x18; - if (bottomCornerCount != 2) { - edgeFrame = 0xf; - } - } - else { - edgeFrame = cornerMask + 0x14; - } - } - isAnimSet = ANM2::SetAnimation(&this->_sprite,&DAT_00b68fb8,1); - if (((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)edgeFrame), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - } - if (1 < GHIDRA_UINT((this->_sprite)._layerCount)) { - iVar8 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) + -2; - iVar6 = 0; - if (0 < iVar8) { - iVar6 = iVar8; - } - if (((this->_sprite)._animState._animData != (void *)0x0) && - ((animState = &(this->_sprite)._animState, - 1 < *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animation) + 0x80)) || - (KAGE_LogMessage(0x10,GHIDRA_CAST("LayerId out of bounds\n")), - 1 < *GHIDRA_CAST((GHIDRA_CAST(animState->_animation) + 0x80)))))) { - pvVar1 = (this->_sprite)._animState._animData; - iVar8 = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x3c)); - if ((pvVar1 == (void *)0x0) || ((iVar8 < 0 || (*GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x1c)) <= iVar8)))) { - KAGE_LogMessage(0x10,GHIDRA_CAST("id out of bounds\n")); - } - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._layerFrames) + iVar8 * 4)) = 0; - AnimationState::AdvanceLayerPosition(animState,iVar8,(float)iVar6); - } - iVar6 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - pLVar5 = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x1)); - pLVar5->_visible = 1 < iVar6; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) & 0xffffff00 | edgeFrame; - return; -} - -// 00714320 -void GridEntity_Pit::guard_check_icall() -{ - uint8_t isMegaMush; - int iVar1; - int iVar2; - uint32_t column; - uint32_t uVar3; - int iVar4; - uint32_t *playerSlot; - Game *game; - float playerColumnF; - int dx; - int rowsLeft; - uint32_t gridWidth; - Entity_Player *player; - void *playerListEnd; - char *room; - - game = g_game; - room = g_game->_room; - room[0x11f6] = '\x01'; - if ((*room == '\0') || (game->_frameCount - *GHIDRA_CAST((room + 0x11f0)) < 2)) { - update_sprite_edges(); - } - else { - uVar3 = this->_gridIndex; - gridWidth = *GHIDRA_CAST((room + 0xc)); - column = uVar3 % gridWidth; - dx = -1; - do { - iVar2 = dx + column; - rowsLeft = 3; - iVar4 = uVar3 / gridWidth - 1; - do { - if (((((-1 < iVar2) && (iVar2 < *GHIDRA_CAST((room + 0xc)))) && (-1 < iVar4)) && - ((iVar4 < *GHIDRA_CAST((room + 0x10)) && - (iVar1 = iVar4 * *GHIDRA_CAST((room + 0xc)) + dx + column, -1 < iVar1)))) && - ((iVar1 < 0x1c0 && - ((*GHIDRA_CAST((room + iVar1 * 4 + 0x24)) != 0 && - (*GHIDRA_CAST((*GHIDRA_CAST((room + iVar1 * 4 + 0x24)) + 4)) == 7)))))) { - update_sprite_edges(); - } - iVar4 = iVar4 + 1; - rowsLeft = rowsLeft + -1; - } while (rowsLeft != 0); - dx = dx + 1; - } while (dx < 2); - uVar3 = 0; - game = g_game; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) { - do { - playerListEnd = (game->_playerManager)._playerList._end; - playerSlot = (game->_playerManager)._playerList._begin; - if (GHIDRA_INT(playerListEnd) - GHIDRA_INT(playerSlot) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - playerListEnd = (game->_playerManager)._playerList._end; - playerSlot = (game->_playerManager)._playerList._begin; - game = g_game; - } - if (uVar3 < GHIDRA_UINT((GHIDRA_INT(playerListEnd) - GHIDRA_INT(playerSlot) >> 2))) { - playerSlot = playerSlot + uVar3; - } - player = GHIDRA_CAST(*playerSlot); - iVar2 = player->_entityGridCollisionClass; - if ((((iVar2 != 0) && (iVar2 != 3)) && (iVar2 != 1)) && - ((iVar2 != 2 && (player->_pitfallState == 0)))) { - playerColumnF = ((player->_pos).x - 40.0) / 40.0 + 0.5; - iVar4 = GHIDRA_INT(playerColumnF); - iVar2 = GHIDRA_INT((((player->_pos).y - 120.0) / 40.0 + 0.5)); - if (((iVar4 < 0) || - ((iVar1 = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)), iVar1 <= iVar4 || (iVar2 < 0)))) || - (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x10)) <= iVar2)) { - iVar2 = -1; - } - else { - iVar2 = iVar1 * iVar2 + GHIDRA_INT(playerColumnF); - } - iVar4 = this->_gridIndex; - if (iVar2 == iVar4) { - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)); - (player->_pos).x = (float)(iVar4 % iVar2) * 40.0 + 40.0; - (player->_pos).y = (float)(iVar4 / iVar2) * 40.0 + 120.0; - isMegaMush = TemporaryEffects::HasCollectibleEffect(&player->_temporaryeffects,0x271); - if (isMegaMush == 0) { - Entity_Player::PlayExtraAnimation(player,GHIDRA_CAST("FallIn")); - game = g_game; - player->_isControlsEnabled = 0; - player->_entityCollisionClass = 0; - player->_pitfallState = 1; - player->_pitfallTimer = 0; - } - } - } - uVar3 = uVar3 + 1; - } while (uVar3 < GHIDRA_UINT((GHIDRA_INT((game->_playerManager)._playerList._end) - - GHIDRA_INT((game->_playerManager)._playerList._begin) >> 2))); - UpdateCollision(this); - return; - } - } - UpdateCollision(this); - return; -} - -// 00714610 -void GridEntity_Pit::UpdateCollision() -{ - uint32_t gridPathValue; - uint32_t gridIdx; - void *room; - - room = g_game->_room; - if (((*GHIDRA_CAST((GHIDRA_CAST(room) + 0x1d18)) != 0x20) || - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x44)) >> 5 & 1) == 0)) || - (0.2 < *GHIDRA_CAST((GHIDRA_CAST(room) + 0x7740)) || *GHIDRA_CAST((GHIDRA_CAST(room) + 0x7740)) == 0.2)) { - gridIdx = this->_gridIndex; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) < 2) { - if (this->_hasLadder == 0) { - if (gridIdx < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(room) + gridIdx * 4 + 0x76c)) = 3000; - } - this->_collisionClass = 1; - return; - } - if (gridIdx < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(room) + gridIdx * 4 + 0x76c)) = 3000; - } - this->_collisionClass = 5; - return; - } - if (gridIdx < 0x1c0) { - gridPathValue = 0; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 3) { - gridPathValue = 999; - } - *GHIDRA_CAST((GHIDRA_CAST(room) + gridIdx * 4 + 0x76c)) = gridPathValue; - } - } - else if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(room) + this->_gridIndex * 4 + 0x76c)) = 0; - this->_collisionClass = 0; - return; - } - this->_collisionClass = 0; - return; -} - -// 007146e0 -void GridEntity_Pit::SetLadder(uint8_t isLadder) -{ - this->_hasLadder = isLadder; - UpdateCollision(this); - return; -} - -// 00714700 -void GridEntity_Pit::MakeBridge(int param_1, int param_2) -{ - uint32_t newState; - GridEntity_Pit *in_ECX; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) == 0) { - if (param_2 != 0) { - in_ECX->_varData = param_2; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) = 1; - return; - } - if (((param_1 == 0) || (*GHIDRA_CAST((param_1 + 4)) != 0x19)) || - (newState = 3, *GHIDRA_CAST((param_1 + 0x194)) != 1)) { - newState = 2; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) = newState; - UpdateCollision(in_ECX); - } - return; -} diff --git a/generated-src/grid_entity_poop.cpp b/generated-src/grid_entity_poop.cpp deleted file mode 100644 index 53ba818..0000000 --- a/generated-src/grid_entity_poop.cpp +++ /dev/null @@ -1,1494 +0,0 @@ -#include "classes.h" - -// 00456870 -void GridEntity_Poop::ReduceSpawnRate() -{ - this->_varData = 1; - return; -} - -// 00714770 -void GridEntity_Poop::Update() -{ - uint8_t bVar1; - uint32_t uVar2; - GridEntity_Poop *gigaPart; - RoomDescriptor *roomDesc; - void *pvVar3; - uint8_t *animNameCursor; - uint8_t *pbVar4; - char *expectedName; - uint64_t *allocCounter; - uint32_t *playerIt; - int iVar5; - PlayerManager *playerManager; - bool isLess; - float deltaX; - float fVar6; - ColorMod pulseColor; - Vector spawnPos; - Vector local_74; - float footprintR; - float fStack_68; - float fStack_64; - int iStack_60; - uint32_t local_5c; - float local_58; - float local_54; - GridEntity_Poop *local_50; - float local_4c; - uint8_t local_45; - uint8_t animName [32]; - uint32_t local_24; - uint8_t *puStack_20; - void *local_1c; - uint8_t *puStack_18; - uint32_t local_14; - uint64_t allocBytesBefore; - Game *game; - Entity_Player *player; - int prevHolyAura; - ColorMod *spriteColor; - - puStack_20 = animName + 0x40; - local_14 = 0xffffffff; - puStack_18 = &LAB_00afca70; - local_1c = ExceptionList; - uVar2 = __security_cookie ^ GHIDRA_UINT((animName + 0x34)); - ExceptionList = &local_1c; - local_50 = this; - local_24 = uVar2; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) - 7U < 4) { - iVar5 = 7; - puStack_20 = animName + 0x40; - do { - if ((iVar5 != *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))))) && - (gigaPart = get_giga_part(this,iVar5,0), gigaPart == GHIDRA_CAST(0x0))) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 0; - this->BeginBatches(uVar2); - break; - } - iVar5 = iVar5 + 1; - } while (iVar5 < 0xb); - } - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) && - (roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),g_game->_currentRoomIdx, - g_game->_currentDimensionIdx), - (GHIDRA_UINT(roomDesc->Flags) >> 1 & 1) != 0)) { - local_45 = (this->_sprite)._flipX; - this->_reviveTimer = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 0; - this->BeginBatches(); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 1000) { - local_54 = 4.2039e-45; - local_4c = 0.0; - local_58 = (float)(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) / 0xfa); - } - sprintf_s(animName,0x1f,GHIDRA_CAST("State%d")); - pvVar3 = ANM2::GetAnimationData(&this->_sprite,animName); - local_58 = *GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 0x30)); - bVar1 = ANM2::SetAnimation(&this->_sprite,animName,1); - if (((bVar1 != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)GHIDRA_INT(local_58)), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - } - (this->_sprite)._flipX = local_45; - uVar2 = Random(); - iVar5 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - spawnPos.x = (float)(local_50->_gridIndex % iVar5) * 40.0 + 40.0; - spawnPos.y = (float)(local_50->_gridIndex / iVar5) * 40.0 + 120.0; - Game::SpawnEx(g_game,1000,0xf,&spawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar2,0); - this = local_50; - } - if ((0 < this->_reviveTimer) && - (iVar5 = this->_reviveTimer + -1, this->_reviveTimer = iVar5, iVar5 < 1)) { - pbVar4 = (this->_sprite)._animState._animData; - if (pbVar4 == GHIDRA_CAST(0x0)) { -LAB_007149d5: - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Appear"),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = pbVar4; - if (0xf < *GHIDRA_CAST((pbVar4 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar4); - } - expectedName = "Appear"; - do { - bVar1 = *animNameCursor; - isLess = bVar1 < (uint8_t)*expectedName; - if (bVar1 != *expectedName) { -LAB_007149b7: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_007149bc; - } - if (bVar1 == 0) break; - bVar1 = animNameCursor[1]; - isLess = bVar1 < (uint8_t)expectedName[1]; - if (bVar1 != expectedName[1]) goto LAB_007149b7; - animNameCursor = animNameCursor + 2; - expectedName = expectedName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_007149bc: - if ((uVar2 != 0) || ((pbVar4[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_007149d5; - } - game = g_game; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(game->_room) + this->_gridIndex * 4 + 0x76c)) = 0x5dc; - } - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1000) { - this->_collisionClass = 0; - } - else { - this->_collisionClass = 3; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) { - if (*GHIDRA_CAST(&g_game->_deathmatchManager) < 2) { - fVar6 = 16.0; - } - else { - fVar6 = 4.0; - } - GridEntity::hurt_surroundings(GHIDRA_CAST(this),22.5,18.5,fVar6,1,0x200,1); - fVar6 = sin((float)g_game->_frameCount * 0.25); - spriteColor = &(this->_sprite)._color; - pulseColor._offset[0] = 0.0; - pulseColor._offset[1] = 0.0; - pulseColor._offset[2] = 0.0; - pulseColor._tint[0] = 1.0 - fVar6 * 0.1; - pulseColor._tint[1] = 1.0; - pulseColor._tint[2] = 1.0; - pulseColor._tint[3] = 1.0; - if (spriteColor != &pulseColor) { - (this->_sprite)._color._colorize[0] = 0.0; - (this->_sprite)._color._colorize[1] = 0.0; - (this->_sprite)._color._colorize[2] = 0.0; - (this->_sprite)._color._colorize[3] = 0.0; - spriteColor->_tint[0] = pulseColor._tint[0]; - (this->_sprite)._color._tint[1] = 1.0; - (this->_sprite)._color._tint[2] = 1.0; - (this->_sprite)._color._tint[3] = 1.0; - (this->_sprite)._color._offset[0] = 0.0; - (this->_sprite)._color._offset[1] = 0.0; - (this->_sprite)._color._offset[2] = 0.0; - } - } - } - if (((this->_sprite)._animState._animData == (void *)0x0) || - ((this->_sprite)._animState._isPlaying != 0)) goto LAB_00714c16; - pbVar4 = (this->_sprite)._animState._animData; - if (pbVar4 == GHIDRA_CAST(0x0)) { - pbVar4 = &s_empty; - } - else if (0xf < *GHIDRA_CAST((pbVar4 + 0x14))) { - pbVar4 = *GHIDRA_CAST(pbVar4); - } - expectedName = "Appear"; - do { - bVar1 = *pbVar4; - isLess = bVar1 < (uint8_t)*expectedName; - if (bVar1 != *expectedName) { -LAB_00714b81: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_00714b86; - } - if (bVar1 == 0) break; - bVar1 = pbVar4[1]; - isLess = bVar1 < (uint8_t)expectedName[1]; - if (bVar1 != expectedName[1]) goto LAB_00714b81; - pbVar4 = pbVar4 + 2; - expectedName = expectedName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_00714b86: - if (uVar2 != 0) goto LAB_00714c16; - pbVar4 = (this->_sprite)._animState._animData; - if (pbVar4 == GHIDRA_CAST(0x0)) { -LAB_00714be2: - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("State1"),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = pbVar4; - if (0xf < *GHIDRA_CAST((pbVar4 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar4); - } - expectedName = "State1"; - do { - bVar1 = *animNameCursor; - isLess = bVar1 < (uint8_t)*expectedName; - if (bVar1 != *expectedName) { -LAB_00714bc4: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_00714bc9; - } - if (bVar1 == 0) break; - bVar1 = animNameCursor[1]; - isLess = bVar1 < (uint8_t)expectedName[1]; - if (bVar1 != expectedName[1]) goto LAB_00714bc4; - animNameCursor = animNameCursor + 2; - expectedName = expectedName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_00714bc9: - if ((uVar2 != 0) || ((pbVar4[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_00714be2; - } - if ((this->_sprite)._animState._animData != (void *)0x0) { - AnimationState::AdvancePosition - (&(this->_sprite)._animState, - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1); - } -LAB_00714c16: - playerManager = &g_game->_playerManager; - local_45 = '\0'; - local_50 = GHIDRA_CAST(0x0); - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 - != 0) { - do { - pvVar3 = (playerManager->_playerList)._end; - playerIt = (playerManager->_playerList)._begin; - if (GHIDRA_INT(pvVar3) - GHIDRA_INT(playerIt) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar3 = (playerManager->_playerList)._end; - playerIt = (playerManager->_playerList)._begin; - } - if (local_50 < GHIDRA_UINT((GHIDRA_INT(pvVar3) - GHIDRA_INT(playerIt) >> 2))) { - playerIt = playerIt + GHIDRA_INT(local_50); - } - player = GHIDRA_CAST(*playerIt); - if (((((player->_variant == 0) && (iVar5 = player->_entityGridCollisionClass, iVar5 != 0)) && - (iVar5 != 3)) && ((iVar5 != 1 && (iVar5 != 2)))) && - (iVar5 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)), - fVar6 = ((float)(this->_gridIndex / iVar5) * 40.0 + 120.0) - (player->_pos).y, - deltaX = ((float)(this->_gridIndex % iVar5) * 40.0 + 40.0) - (player->_pos).x, - local_74.y = sqrtf(fVar6 * fVar6 + deltaX * deltaX), local_74.y < 21.0)) { - footprintR = 0.15294118; - fStack_68 = 0.09803922; - fStack_64 = 0.08627451; - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))))) { - case 1: - footprintR = 0.5764706; - fStack_68 = 0.07058824; - fStack_64 = 0.10980392; - break; - default: - goto switchD_00714d3f_caseD_2; - case 3: - footprintR = 0.84705883; - fStack_68 = 0.5058824; - fStack_64 = 0.0; - break; - case 4: - local_58 = 0.0; - local_4c = 0.0; - local_54 = 0.0; - uVar2 = Random(); - fStack_64 = local_58; - fStack_68 = local_4c; - switch(uVar2 % 6) { - case 0: - footprintR = 1.0; - fStack_68 = local_58; - local_54 = footprintR; - break; - case 1: - fStack_68 = 1.0; - footprintR = 1.0; - break; - case 2: - fStack_68 = 1.0; - footprintR = local_58; - local_4c = fStack_68; - break; - case 3: - fStack_68 = 1.0; - footprintR = local_54; - fStack_64 = 1.0; - break; - case 4: - footprintR = local_4c; - fStack_64 = 1.0; - break; - case 5: - footprintR = 1.0; - fStack_64 = 1.0; - break; - default: - footprintR = 1.0; - fStack_64 = 1.0; - fStack_68 = 1.0; - } - break; - case 5: - footprintR = 0.078431375; - fStack_68 = 0.078431375; - fStack_64 = 0.078431375; - break; - case 6: - footprintR = 0.44313726; - fStack_68 = 0.74509805; - fStack_64 = 0.8235294; - } - iStack_60 = 0x3f800000; - local_5c = 0; -switchD_00714d3f_caseD_2: - bVar1 = Entity_Player::is_footstep_triggered(player,-1); - if ((bVar1 != 0) && (player->_canFly == 0)) { - bVar1 = Entity_Player::is_footstep_triggered(player,0); - if (bVar1 == 0) { - (player->_footprintColor1)._offset[0] = footprintR; - (player->_footprintColor1)._offset[1] = fStack_68; - (player->_footprintColor1)._offset[2] = fStack_64; - } - else { - (player->_footprintColor2)._offset[0] = footprintR; - (player->_footprintColor2)._offset[1] = fStack_68; - (player->_footprintColor2)._offset[2] = fStack_64; - } - } - if ((this->_isUnderPlayer != 0) && (local_74.y < 20.0)) { - this->_collisionClass = 0; - local_45 = '\x01'; - } - } - playerManager = &g_game->_playerManager; - local_50 = GHIDRA_CAST((GHIDRA_INT(local_50) + 1)); - } while (local_50 < - GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - if ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x171))) != '\0') { - iVar5 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_74.x = (float)(this->_gridIndex % iVar5) * 40.0 + 40.0; - local_74.y = (float)(this->_gridIndex / iVar5) * 40.0 + 120.0; - EntityList::QueryRadius - (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),GHIDRA_CAST(&fStack_68),&local_74, - 16.0,0xffffffff); - uVar2 = 0; - if (local_5c != 0) { - do { - iVar5 = *GHIDRA_CAST((GHIDRA_CAST(fStack_64) + uVar2 * 4)); - if (((iVar5 != 0) && - (((1 < *GHIDRA_CAST(&g_game->_deathmatchManager) && (*GHIDRA_CAST((iVar5 + 0x28)) == 1)) || - (*GHIDRA_CAST((iVar5 + 0x28)) - 10U < 0x3de)))) && (3 < *GHIDRA_CAST((iVar5 + 0x184)))) { - this->_collisionClass = 0; - goto LAB_00714fce; - } - uVar2 = uVar2 + 1; - } while (uVar2 < local_5c); - } - (*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x171))) = 0; -LAB_00714fce: - if ((*GHIDRA_CAST((GHIDRA_CAST(&(fStack_68)) + 0x0))) == '\0') { - if (g_mainHeap == (void *)0x0) { - allocCounter = &g_allocatedBytesNoHeap; - } - else { - allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); - } - if (fStack_64 != 0.0) { - uVar2 = *GHIDRA_CAST((GHIDRA_CAST(fStack_64) + -4)); - allocBytesBefore = *allocCounter; - *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar2; - *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = - *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocBytesBefore) < uVar2)); - free((void *)(GHIDRA_INT(fStack_64) + -4)); - } - local_14 = 0xffffffff; - } - } - if (local_45 == '\0') { - this->_isUnderPlayer = 0; - } - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 6) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 1000)) { - playerManager = &g_game->_playerManager; - local_50 = GHIDRA_CAST(0x0); - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> - 2 != 0) { - do { - pvVar3 = (playerManager->_playerList)._end; - playerIt = (playerManager->_playerList)._begin; - if (GHIDRA_INT(pvVar3) - GHIDRA_INT(playerIt) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar3 = (playerManager->_playerList)._end; - playerIt = (playerManager->_playerList)._begin; - } - if (local_50 < GHIDRA_UINT((GHIDRA_INT(pvVar3) - GHIDRA_INT(playerIt) >> 2))) { - playerIt = playerIt + GHIDRA_INT(local_50); - } - player = GHIDRA_CAST(*playerIt); - iVar5 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - fVar6 = ((float)(this->_gridIndex / iVar5) * 40.0 + 120.0) - (player->_pos).y; - deltaX = ((float)(this->_gridIndex % iVar5) * 40.0 + 40.0) - (player->_pos).x; - local_74.y = (float)player; - fVar6 = sqrtf(fVar6 * fVar6 + deltaX * deltaX); - if (fVar6 < player->_size + 70.0) { - prevHolyAura = player->_hallowedGroundCountdown; - iVar5 = prevHolyAura + 4; - if (4 < iVar5) { - iVar5 = 4; - } - player->_hallowedGroundCountdown = iVar5; - if (0 < prevHolyAura != 0 < iVar5) { - player->_cacheFlags = player->_cacheFlags | 99; - Entity_Player::EvaluateItems(player); - } - } - playerManager = &g_game->_playerManager; - local_50 = GHIDRA_CAST((GHIDRA_INT(local_50) + 1)); - } while (local_50 < - GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - ExceptionList = local_1c; - return; -} - -// 00715940 -void GridEntity_Poop::BeginBatches() -{ - code *pcVar1; - uint8_t isSameSpritesheet; - uint8_t isSameSpritesheet; - int *playerSlot; - int iVar3; - uint32_t uVar4; - Entity *pEVar5; - EntityConfig_Entity *configEntry; - uint8_t *******pppppppbVar6; - uint8_t *pbVar7; - void *pvVar8; - LayerState *spawnLayer; - uint8_t *pbVar9; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - uint8_t extraout_CL_01; - uint8_t *extraout_ECX; - uint8_t *this_00; - char *pcVar10; - uint8_t *idleAnimName; - int iVar11; - PlayerManager *playerManager; - Manager *manager; - EntityConfig *entityConfig; - uint8_t *******spritesheetHeapBuf; - bool isLess; - float offsetX; - float offsetY; - uint32_t uVar12; - uint8_t coinFindResult [8]; - void *coinConfigNode; - uint8_t heartFindResult [8]; - void *heartConfigNode; - uint8_t effect58FindResult [8]; - void *effect58ConfigNode; - uint8_t effect43FindResult [8]; - void *effect43ConfigNode; - Vector effectSpawnPos; - Vector flySpawnPos; - uint8_t *heartConfigKey; - GridEntity_Poop *savedPoop; - Entity *local_1ac; - Game *local_1a8; - EntityConfig *local_1a4; - uint8_t isUnderPlayer; - std_string anm2Path; - std_string giantAnm2Path; - uint8_t *******spritesheetPathString [4]; - uint32_t spritesheetPathSize; - uint32_t spritesheetPathCapacity; - uint8_t spritesheetPath [256]; - uint8_t stateAnimName [32]; - uint8_t playStateAnimName [32]; - uint32_t stackCookie; - void *prevExceptionList; - uint8_t *puStack_c; - uint32_t ehState; - uint32_t castIsReference; - TypeDescriptor *castSrcType; - TypeDescriptor *castTargetType; - - local_1a8 = g_game; - ehState = 0xffffffff; - puStack_c = &LAB_00afcac6; - prevExceptionList = ExceptionList; - stackCookie = __security_cookie ^ GHIDRA_UINT((playStateAnimName + 0x30)); - ExceptionList = &prevExceptionList; - this->_varData = 0; - *GHIDRA_CAST(&this->_isUnderPlayer) = 0; - isUnderPlayer = 0; - savedPoop = this; - if (*GHIDRA_CAST(local_1a8->_room) != '\0') { - playerManager = &local_1a8->_playerManager; - local_1a4 = GHIDRA_CAST(0x0); - isUnderPlayer = 0; - if (GHIDRA_INT((local_1a8->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) - >> 2 != 0) { - do { - pvVar8 = (playerManager->_playerList)._end; - if (GHIDRA_INT(pvVar8) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar8 = (playerManager->_playerList)._end; - local_1a8 = g_game; - } - playerSlot = (playerManager->_playerList)._begin; - if (local_1a4 < GHIDRA_CAST((GHIDRA_INT(pvVar8) - GHIDRA_INT(playerSlot) >> 2))) { - playerSlot = playerSlot + GHIDRA_INT(local_1a4); - } - iVar3 = *playerSlot; - if (((((*GHIDRA_CAST((iVar3 + 0x2c)) == 0) && (iVar11 = *GHIDRA_CAST((iVar3 + 0x184)), iVar11 != 0)) && - (iVar11 != 3)) && ((iVar11 != 1 && (iVar11 != 2)))) && - (iVar11 = *GHIDRA_CAST((GHIDRA_CAST(local_1a8->_room) + 0xc)), - offsetY = *GHIDRA_CAST((iVar3 + 0x340)) - ((float)(this->_gridIndex / iVar11) * 40.0 + 120.0) - , offsetX = *GHIDRA_CAST((iVar3 + 0x33c)) - - ((float)(this->_gridIndex % iVar11) * 40.0 + 40.0), - offsetY * offsetY + offsetX * offsetX < 400.0)) { - this->_isUnderPlayer = 1; - isUnderPlayer = 1; - goto LAB_00715af4; - } - local_1a4 = GHIDRA_CAST((GHIDRA_INT(&(local_1a4->_entities)._head) + 1)); - playerManager = &local_1a8->_playerManager; - } while (local_1a4 < - (EntityConfig *) - (GHIDRA_INT((local_1a8->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2)); - isUnderPlayer = this->_isUnderPlayer; - } - } -LAB_00715af4: - iVar3 = 0; - if (isUnderPlayer == 0) { - iVar3 = 3; - } - this->_collisionClass = iVar3; - iVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (iVar3 == 2) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 1000) { - uVar4 = Random(); - castIsReference = 0; - castTargetType = &IsaacRepentancePlus::Entity_NPC::RTTI_Type_Descriptor; - iVar3 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - castSrcType = &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor; - uVar12 = 0; - flySpawnPos.x = (float)(savedPoop->_gridIndex % iVar3) * 40.0 + 40.0; - flySpawnPos.y = (float)(savedPoop->_gridIndex / iVar3) * 40.0 + 120.0; - pEVar5 = Game::Spawn(g_game,0x60,0,&flySpawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar4); - iVar3 = __RTDynamicCast(pEVar5,uVar12,castSrcType,castTargetType,castIsReference); - local_1a8 = g_game; - *GHIDRA_CAST((iVar3 + 0xb64)) = 0; - iVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((savedPoop)) + 0x8)))); - this = savedPoop; - goto LAB_00715bc8; - } - } - else { -LAB_00715bc8: - if ((iVar3 == 1) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1000)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - } - } - uVar12 = 0; - this->_reviveTimer = 0; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 1000) { - uVar12 = 0x5dc; - } - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(local_1a8->_room) + this->_gridIndex * 4 + 0x76c)) = uVar12; - } - manager = g_manager; - local_1a4 = GHIDRA_CAST(0x3e802b00); - local_1a8 = GHIDRA_CAST(&g_manager->_entityConfig); - _Find_lower_bound<>(effect43FindResult,&local_1a4); - entityConfig = &manager->_entityConfig; - if (((*GHIDRA_CAST((GHIDRA_CAST(effect43ConfigNode) + 0xd)) == '\0') && - (*GHIDRA_CAST((GHIDRA_CAST(effect43ConfigNode) + 0x10)) < 0x3e802b01)) && - (effect43ConfigNode != (entityConfig->_entities)._head)) { - configEntry = GHIDRA_CAST((GHIDRA_INT(effect43ConfigNode) + 0x18)); - } - else { - configEntry = EntityConfig::GetEntity(entityConfig,1000,0,0); - } - if (configEntry != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(GHIDRA_CAST(local_1a8),configEntry); - manager = g_manager; - } - local_1a8 = GHIDRA_CAST(0x3e803a00); - local_1a4 = &manager->_entityConfig; - _Find_lower_bound<>(effect58FindResult,&local_1a8); - if (((*GHIDRA_CAST((GHIDRA_CAST(effect58ConfigNode) + 0xd)) == '\0') && - (*GHIDRA_CAST((GHIDRA_CAST(effect58ConfigNode) + 0x10)) < 0x3e803a01)) && - (effect58ConfigNode != (manager->_entityConfig)._entities._head)) { - configEntry = GHIDRA_CAST((GHIDRA_INT(effect58ConfigNode) + 0x18)); - } - else { - configEntry = EntityConfig::GetEntity(&manager->_entityConfig,1000,0,0); - } - if (configEntry != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(local_1a4,configEntry); - manager = g_manager; - } - heartConfigKey = &DAT_00500a00; - local_1a4 = &manager->_entityConfig; - _Find_lower_bound<>(heartFindResult,&heartConfigKey); - if (((*GHIDRA_CAST((GHIDRA_CAST(heartConfigNode) + 0xd)) == '\0') && - (*GHIDRA_CAST((GHIDRA_CAST(heartConfigNode) + 0x10)) <= &DAT_00500a00)) && - (heartConfigNode != (manager->_entityConfig)._entities._head)) { - configEntry = GHIDRA_CAST((GHIDRA_INT(heartConfigNode) + 0x18)); - } - else { - configEntry = EntityConfig::GetEntity(&manager->_entityConfig,5,0,0); - } - if (configEntry != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(local_1a4,configEntry); - manager = g_manager; - } - local_1ac = GHIDRA_CAST(&DAT_00501400); - entityConfig = &manager->_entityConfig; - _Find_lower_bound<>(coinFindResult,&local_1ac); - if (((*GHIDRA_CAST((GHIDRA_CAST(coinConfigNode) + 0xd)) == '\0') && - (*GHIDRA_CAST((GHIDRA_CAST(coinConfigNode) + 0x10)) <= &DAT_00501400)) && - (coinConfigNode != (entityConfig->_entities)._head)) { - configEntry = GHIDRA_CAST((GHIDRA_INT(coinConfigNode) + 0x18)); - } - else { - configEntry = EntityConfig::GetEntity(entityConfig,5,0,0); - } - if (configEntry != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(entityConfig,configEntry); - } - (this->_rng)._seed = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - (this->_rng)._shift1 = 5; - (this->_rng)._shift2 = 9; - (this->_rng)._shift3 = 7; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) - 7U < 4) { - giantAnm2Path._size = 0; - giantAnm2Path._capacity = 0xf; - giantAnm2Path._buf[0] = '\0'; - giantAnm2Path._buf[1] = '\0'; - giantAnm2Path._buf[2] = '\0'; - giantAnm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(giantAnm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - giantAnm2Path._size = 0x1d; - giantAnm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(giantAnm2Path._buf))) + 0x0))),"gfx/grid/grid_poop_giant.anm2",0x1e); - ehState = 0; - ANM2::Load(&this->_sprite,&giantAnm2Path,1); - ehState = 0xffffffff; - if (0xf < giantAnm2Path._capacity) { - uVar4 = giantAnm2Path._capacity + 1; - pcVar10 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(giantAnm2Path._buf))) + 0x0))); - if (0xfff < uVar4) { - pcVar10 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(giantAnm2Path._buf)) + 0x0))) + -4)); - uVar4 = giantAnm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(giantAnm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar10))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar10,uVar4); - } - giantAnm2Path._size = 0; - giantAnm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(giantAnm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(giantAnm2Path._buf)) + 0x0))) & 0xffffff00; - goto LAB_007162ed; - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x17; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/grid_poop.anm2",0x18); - ehState = 1; - ANM2::Load(&this->_sprite,&anm2Path,0); - ehState = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar4 = anm2Path._capacity + 1; - pcVar10 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar4) { - pcVar10 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar4 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar10))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar10,uVar4); - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))))) { - case 0: - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - } - uVar4 = uVar4 >> ((uint8_t)(this->_rng)._shift1 & 0x1f) ^ uVar4; - uVar4 = uVar4 << ((uint8_t)(this->_rng)._shift2 & 0x1f) ^ uVar4; - (this->_rng)._seed = uVar4 >> ((uint8_t)(this->_rng)._shift3 & 0x1f) ^ uVar4; - pcVar10 = "gfx/grid/grid_poop_%u.png"; - goto LAB_00716065; - case 1: - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - } - uVar4 = uVar4 >> ((uint8_t)(this->_rng)._shift1 & 0x1f) ^ uVar4; - uVar4 = uVar4 << ((uint8_t)(this->_rng)._shift2 & 0x1f) ^ uVar4; - (this->_rng)._seed = uVar4 >> ((uint8_t)(this->_rng)._shift3 & 0x1f) ^ uVar4; - pcVar10 = "gfx/grid/grid_poop_red_%u.png"; - goto LAB_00716065; - case 2: - strncpy(GHIDRA_CAST(spritesheetPath),"gfx/grid/grid_poop_corn.png",0xff); - break; - case 3: - strncpy(GHIDRA_CAST(spritesheetPath),"gfx/grid/grid_poop_gold.png",0xff); - break; - case 4: - strncpy(GHIDRA_CAST(spritesheetPath),"gfx/grid/grid_poop_rainbow.png",0xff); - break; - case 5: - strncpy(GHIDRA_CAST(spritesheetPath),"gfx/grid/grid_poop_black.png",0xff); - break; - case 6: - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - } - uVar4 = uVar4 >> ((uint8_t)(this->_rng)._shift1 & 0x1f) ^ uVar4; - uVar4 = uVar4 << ((uint8_t)(this->_rng)._shift2 & 0x1f) ^ uVar4; - (this->_rng)._seed = uVar4 >> ((uint8_t)(this->_rng)._shift3 & 0x1f) ^ uVar4; - pcVar10 = "gfx/grid/grid_poop_white_%u.png"; -LAB_00716065: - sprintf_s(spritesheetPath,0xff,GHIDRA_CAST(pcVar10)); - break; - default: - KAGE_LogMessage(0x10,GHIDRA_CAST("Unknown poop variant: %d")); - break; - case 0xb: - strncpy(GHIDRA_CAST(spritesheetPath),"gfx/grid/grid_poop_charming.png",0xff); - } - pbVar7 = spritesheetPath; - spritesheetPathSize = 0; - spritesheetPathCapacity = 0xf; - spritesheetPathString[0] = GHIDRA_CAST(0x0); - do { - isSameSpritesheet = *pbVar7; - pbVar7 = pbVar7 + 1; - } while (isSameSpritesheet != 0); - (GHIDRA_CAST((GHIDRA_CAST(spritesheetPathString))))->msvc::string::assign(spritesheetPath, - GHIDRA_INT(pbVar7) - GHIDRA_INT((spritesheetPath + 1))); - spritesheetHeapBuf = spritesheetPathString[0]; - ehState = 2; - if ((this->_sprite)._layerCount < 1) { - isSameSpritesheet = extraout_CL; - } - else { - local_1ac = (this->_sprite)._layerState; - pbVar7 = &(*GHIDRA_CAST((GHIDRA_CAST((local_1ac)) + 0x8))); - if (0xf < *GHIDRA_CAST((GHIDRA_INT(&local_1ac->_pendingDamageFlags) + 4))) { - pbVar7 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_1ac)) + 0x8)))); - } - pppppppbVar6 = GHIDRA_CAST(spritesheetPathString); - if (0xf < spritesheetPathCapacity) { - pppppppbVar6 = spritesheetPathString[0]; - } - isSameSpritesheet = - str_eq(GHIDRA_CAST(pppppppbVar6),spritesheetPathSize,pbVar7,GHIDRA_UINT(local_1ac->_pendingDamageFlags) - ); - isSameSpritesheet = extraout_CL_00; - if (isSameSpritesheet == 0) { - this_00 = &(*GHIDRA_CAST((GHIDRA_CAST((local_1ac)) + 0x8))); - pEVar5 = local_1ac; - if (GHIDRA_CAST(this_00) != spritesheetPathString) { - pppppppbVar6 = GHIDRA_CAST(spritesheetPathString); - if (0xf < spritesheetPathCapacity) { - pppppppbVar6 = spritesheetHeapBuf; - } - (GHIDRA_CAST((this_00)))->msvc::string::assign(GHIDRA_CAST(pppppppbVar6),spritesheetPathSize); - pEVar5 = (this->_sprite)._layerState; - this_00 = extraout_ECX; - spritesheetHeapBuf = spritesheetPathString[0]; - } - isSameSpritesheet = (uint8_t)this_00; - *GHIDRA_CAST(&pEVar5->_subtype) = 0; - } - } - ehState = 0xffffffff; - if (0xf < spritesheetPathCapacity) { - uVar4 = spritesheetPathCapacity + 1; - pppppppbVar6 = spritesheetHeapBuf; - if (0xfff < uVar4) { - pppppppbVar6 = GHIDRA_CAST(spritesheetHeapBuf[-1]); - uVar4 = spritesheetPathCapacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST((GHIDRA_INT(spritesheetHeapBuf) + (-4 - GHIDRA_INT(pppppppbVar6))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pppppppbVar6,uVar4); - isSameSpritesheet = extraout_CL_01; - } - spritesheetPathSize = 0; - spritesheetPathCapacity = 0xf; - spritesheetPathString[0] = GHIDRA_CAST((GHIDRA_UINT(spritesheetPathString[0]) & 0xffffff00)); - ANM2::LoadGraphics(&this->_sprite,isSameSpritesheet); -LAB_007162ed: - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1000) { - iVar3 = 4; - } - else { - iVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) / 0xfa; - iVar11 = 3; - if (iVar3 < 3) { - iVar11 = iVar3; - } - iVar3 = 0; - if (0 < iVar11) { - iVar3 = iVar11; - } - } - if (*GHIDRA_CAST(g_game->_room) == '\0') { - sprintf_s(stateAnimName,0x1f,GHIDRA_CAST("State%d")); - pvVar8 = ANM2::GetAnimationData(&this->_sprite,stateAnimName); - local_1ac = *GHIDRA_CAST((GHIDRA_CAST(pvVar8) + 0x30)); - isSameSpritesheet = ANM2::SetAnimation(&this->_sprite,stateAnimName,1); - if (((isSameSpritesheet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)GHIDRA_INT(local_1ac)), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - } - } - else { - if (iVar3 == 0) { - pbVar7 = (this->_sprite)._animState._animData; - if (pbVar7 != GHIDRA_CAST(0x0)) { - if (0xf < *GHIDRA_CAST((pbVar7 + 0x14))) { - pbVar7 = *GHIDRA_CAST(pbVar7); - } - pcVar10 = "Appear"; - do { - isSameSpritesheet = *pbVar7; - isLess = isSameSpritesheet < (uint8_t)*pcVar10; - if (isSameSpritesheet != *pcVar10) { -LAB_00716370: - uVar4 = -GHIDRA_UINT(isLess) | 1; - goto LAB_00716375; - } - if (isSameSpritesheet == 0) break; - isSameSpritesheet = pbVar7[1]; - isLess = isSameSpritesheet < (uint8_t)pcVar10[1]; - if (isSameSpritesheet != pcVar10[1]) goto LAB_00716370; - pbVar7 = pbVar7 + 2; - pcVar10 = pcVar10 + 2; - } while (isSameSpritesheet != 0); - uVar4 = 0; -LAB_00716375: - if ((uVar4 == 0) && - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_00716493; - } - pcVar10 = "Appear"; - } - else { - sprintf_s(playStateAnimName,0x1f,GHIDRA_CAST("State%d")); - pbVar7 = (this->_sprite)._animState._animData; - if (pbVar7 != GHIDRA_CAST(0x0)) { - if (0xf < *GHIDRA_CAST((pbVar7 + 0x14))) { - pbVar7 = *GHIDRA_CAST(pbVar7); - } - pbVar9 = playStateAnimName; - do { - isSameSpritesheet = *pbVar7; - isLess = isSameSpritesheet < *pbVar9; - if (isSameSpritesheet != *pbVar9) { -LAB_007163e7: - uVar4 = -GHIDRA_UINT(isLess) | 1; - goto LAB_007163ec; - } - if (isSameSpritesheet == 0) break; - isSameSpritesheet = pbVar7[1]; - isLess = isSameSpritesheet < pbVar9[1]; - if (isSameSpritesheet != pbVar9[1]) goto LAB_007163e7; - pbVar7 = pbVar7 + 2; - pbVar9 = pbVar9 + 2; - } while (isSameSpritesheet != 0); - uVar4 = 0; -LAB_007163ec: - if ((uVar4 == 0) && - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_00716493; - } - pcVar10 = GHIDRA_CAST(playStateAnimName); - } - isSameSpritesheet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(pcVar10),1); - if (isSameSpritesheet != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } -LAB_00716493: - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - uVar4 = (this->_rng)._seed; - if (uVar4 == 0) { - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - } - uVar4 = uVar4 >> ((uint8_t)(this->_rng)._shift1 & 0x1f) ^ uVar4; - uVar4 = uVar4 << ((uint8_t)(this->_rng)._shift2 & 0x1f) ^ uVar4; - uVar4 = uVar4 >> ((uint8_t)(this->_rng)._shift3 & 0x1f) ^ uVar4; - (this->_rng)._seed = uVar4; - (this->_sprite)._flipX = ~(uint8_t)uVar4 & 1; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 6) { - ExceptionList = prevExceptionList; - return; - } - spawnLayer = ANM2::GetLayer(&this->_sprite,s_Spawn); - if (spawnLayer != GHIDRA_CAST(0x0)) { - (spawnLayer->_color)._colorize[0] = 1.9; - (spawnLayer->_color)._colorize[1] = 2.0; - (spawnLayer->_color)._colorize[2] = 2.0; - (spawnLayer->_color)._colorize[3] = 1.0; - (spawnLayer->_color)._offset[0] = 0.1; - (spawnLayer->_color)._offset[1] = 0.3; - (spawnLayer->_color)._offset[2] = 0.4; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1000) { - ExceptionList = prevExceptionList; - return; - } - uVar4 = Random(); - iVar3 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - effectSpawnPos.x = (float)(savedPoop->_gridIndex % iVar3) * 40.0 + 40.0; - effectSpawnPos.y = (float)(savedPoop->_gridIndex / iVar3) * 40.0 + 120.0; - pEVar5 = Game::Spawn(g_game,1000,0x70,&effectSpawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar4); - local_1ac = pEVar5; - if (*GHIDRA_CAST(g_game->_room) == '\0') { - pbVar7 = (pEVar5->_sprite)._animState._animData; - if (pbVar7 != GHIDRA_CAST(0x0)) { - pbVar9 = pbVar7; - if (0xf < *GHIDRA_CAST((pbVar7 + 0x14))) { - pbVar9 = *GHIDRA_CAST(pbVar7); - } - idleAnimName = s_Idle; - do { - isSameSpritesheet = *pbVar9; - isLess = isSameSpritesheet < *idleAnimName; - if (isSameSpritesheet != *idleAnimName) { -LAB_00716606: - uVar4 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0071660b; - } - if (isSameSpritesheet == 0) break; - isSameSpritesheet = pbVar9[1]; - isLess = isSameSpritesheet < idleAnimName[1]; - if (isSameSpritesheet != idleAnimName[1]) goto LAB_00716606; - pbVar9 = pbVar9 + 2; - idleAnimName = idleAnimName + 2; - } while (isSameSpritesheet != 0); - uVar4 = 0; -LAB_0071660b: - if ((uVar4 == 0) && ((pbVar7[0x34] == 0 || ((pEVar5->_sprite)._animState._isPlaying != 0)))) - goto LAB_00716637; - } - isSameSpritesheet = ANM2::SetAnimation(&pEVar5->_sprite,s_Idle,1); - if (isSameSpritesheet != 0) { - AnimationState::Rewind(&(pEVar5->_sprite)._animState); - (pEVar5->_sprite)._animState._isPlaying = 1; - } - } -LAB_00716637: - (local_1ac->_posOffset).x = 0.0; - (local_1ac->_posOffset).y = -4.0; - local_1ac->_renderZOffset = 10000; - ExceptionList = prevExceptionList; - return; -} - -// 007166f0 -void GridEntity_Poop::RespawnRedPoop() -{ - uint8_t isAnimSet; - void *animData; - int frameCount; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1000; - this->_reviveTimer = 0x78; - this->_collisionClass = 0; - animData = ANM2::GetAnimationData(&this->_sprite,GHIDRA_CAST("State5")); - frameCount = *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x30)); - isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("State5"),1); - if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)frameCount); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - } - } - return; -} - -// 00716760 -void GridEntity_Poop::spawn_hit_gibs(Vector *position, int poopVariant, int maxGibs) -{ - uint32_t rngResult; - uint32_t rngRoll; - Entity *pEVar1; - ColorMod *extraout_EAX; - ColorMod *extraout_EAX_00; - void *seedNode; - void *seedSetHead; - int count; - float fVar2; - double speedRoll; - int variant; - ColorMod *color; - uint8_t findResult [4]; - Vector local_74; - float local_6c; - void **local_68; - Color defaultColor; - ColorMod gibColor; - uint32_t local_c; - uint8_t auStack_8 [4]; - - local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4)); - if (maxGibs < 1) { - rngResult = 0; - } - else { - rngResult = Random(); - rngResult = rngResult % GHIDRA_UINT(maxGibs); - } - local_68 = &(g_game->_seedEffects)._seedEffects; - local_6c = 3.22299e-44; - msvc::set::find_node(findResult,&local_6c); - if ((*GHIDRA_CAST((GHIDRA_CAST(local_74.y) + 0xd)) == '\0') && (*GHIDRA_CAST((GHIDRA_CAST(local_74.y) + 0x10)) < 0x18)) { - seedNode = (void *)local_74.y; - seedSetHead = *local_68; - } - else { - seedNode = *local_68; - seedSetHead = seedNode; - } - gibColor._offset[0] = 0.0; - gibColor._offset[1] = 0.0; - gibColor._offset[2] = 0.0; - gibColor._tint[0] = 1.0; - gibColor._tint[1] = 1.0; - gibColor._tint[2] = 1.0; - gibColor._tint[3] = 1.0; - count = rngResult + 1; - if (seedNode != seedSetHead) { - count = (rngResult + 1) * 3; - } - gibColor._colorize[0] = 0.0; - gibColor._colorize[1] = 0.0; - gibColor._colorize[2] = 0.0; - gibColor._colorize[3] = 0.0; - if (poopVariant == 3) { - gibColor._tint[0] = 0.5; - gibColor._tint[1] = 0.5; - gibColor._tint[2] = 0.5; - gibColor._offset[0] = 0.55; - gibColor._offset[1] = 0.45; -LAB_00716828: - rngResult = Random(); - speedRoll = (double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]; - color = &gibColor; - } - else { - if (poopVariant == 1) { - gibColor._colorize[0] = 1.0; - gibColor._colorize[3] = 0.9; - goto LAB_00716828; - } - if (poopVariant == 4) { - if (count < 1) { - return; - } - do { - rngResult = Random(); - switch(rngResult % 5) { - case 0: - gibColor._colorize[0] = 1.0; - gibColor._colorize[1] = 0.0; - gibColor._colorize[2] = 0.0; - break; - case 1: - gibColor._colorize[0] = 0.0; - gibColor._colorize[1] = 1.0; - gibColor._colorize[2] = 0.0; - break; - case 2: - gibColor._colorize[0] = 0.5; - gibColor._colorize[1] = 0.5; - gibColor._colorize[2] = 1.0; - break; - case 3: - gibColor._colorize[0] = 1.0; - gibColor._colorize[1] = 0.0; - gibColor._colorize[2] = 1.0; - break; - case 4: - gibColor._colorize[0] = 1.0; - gibColor._colorize[1] = 1.0; - gibColor._colorize[2] = 0.0; - break; - default: - goto switchD_0071688e_default; - } - gibColor._colorize[3] = 1.0; -switchD_0071688e_default: - rngResult = Random(); - rngRoll = Random(); - fVar2 = (float)((double)GHIDRA_INT(rngRoll) + __uint_to_double_fixup[-(GHIDRA_INT(rngRoll) >> 0x1f)]) * - 2.3283064e-10 * 3.14; - local_68 = (void **)(fVar2 + fVar2); - rngRoll = Random(); - local_6c = (float)((double)GHIDRA_INT(rngRoll) + __uint_to_double_fixup[-(GHIDRA_INT(rngRoll) >> 0x1f)]) * - 2.3283064e-10 + 2.0; - local_74.x = cos((float)local_68); - local_74.x = local_74.x * local_6c; - fVar2 = sin((float)local_68); - local_74.y = fVar2 * 0.5 * local_6c; - pEVar1 = Game::Spawn(g_game,1000,0x3a,position,&local_74,GHIDRA_CAST(0x0),0,rngResult); - (**(code **)(*GHIDRA_CAST(pEVar1) + 0x3c))(&gibColor,0xffffffff,0xff,0,1); - (**(code **)(*GHIDRA_CAST(pEVar1) + 0xc))(); - count = count + -1; - if (count == 0) { - return; - } - } while( true ); - } - if (poopVariant == 5) { - gibColor._colorize[0] = 0.3; - gibColor._colorize[1] = 0.3; - gibColor._colorize[2] = 0.3; - gibColor._colorize[3] = 1.0; - goto LAB_00716828; - } - if (poopVariant == 6) { - gibColor._colorize[0] = 1.9; - gibColor._colorize[1] = 2.0; - gibColor._colorize[2] = 2.0; - gibColor._colorize[3] = 1.0; - gibColor._offset[0] = 0.1; - gibColor._offset[1] = 0.3; - gibColor._offset[2] = 0.4; - goto LAB_00716828; - } - if (poopVariant == 0xc) { - (GHIDRA_CAST((&defaultColor)))->Color::Color(); - rngResult = Random(); - speedRoll = (double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]; - variant = 0x23; - color = extraout_EAX; - goto LAB_00716adb; - } - if (poopVariant == 0xd) { - gibColor._colorize[0] = 1.0; - gibColor._colorize[1] = 0.2; - gibColor._colorize[3] = 0.9; - goto LAB_00716828; - } - if (poopVariant == 0xe) { - gibColor._colorize[0] = 0.3; - gibColor._colorize[1] = 1.0; - gibColor._colorize[2] = 0.2; - gibColor._colorize[3] = 0.9; - goto LAB_00716828; - } - (GHIDRA_CAST((&defaultColor)))->Color::Color(); - rngResult = Random(); - speedRoll = (double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]; - color = extraout_EAX_00; - } - variant = 0x3a; -LAB_00716adb: - Game::SpawnParticles - (g_game,position,variant,count,(float)speedRoll * 2.3283064e-10 + 2.0,color,100000.0,0); - return; -} - -// 00716b10 -void GridEntity_Poop::destroy_effects() -{ - ColorMod *color; - uint32_t seed; - Vector *in_ECX; - int in_EDX; - int *extraout_EDX; - float scaleY; - int breakSoundId; - float local_64; - Color particleColor; - Color splatColor; - float local_8; - Manager *manager; - - local_8 = (float)(__security_cookie ^ GHIDRA_UINT(((&splatColor)[1]._tint + 1))); - PersistentGameData::IncreaseEventCounter(&g_manager->_persistentGameData,5,1); - manager = g_manager; - if (in_EDX == 0xc) { - local_64 = 1.91978e-43; - seed_fart_sound_override(GHIDRA_CAST(&local_64)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_64),1.0,2,0,1.0,0.0); - (GHIDRA_CAST((&particleColor)))->Color::Color(); - Game::SpawnParticles(g_game,in_ECX,4,3,4.0,color,100000.0,0x30001); - return; - } - local_64 = 1.0; - if (in_EDX - 7U < 4) { - local_64 = 0.5; - } - breakSoundId = 0xed; - seed_fart_sound_override(&breakSoundId); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(breakSoundId,0.9,2,0,local_64,0.0); - seed = Random(); - Game::Spawn(g_game,1000,0x2b,in_ECX,&g_vectorZero,GHIDRA_CAST(0x0),0,seed); - (GHIDRA_CAST((&splatColor)))->Color::Color(); - if (in_EDX == 6) { - splatColor._colorize[0] = 1.9; - splatColor._colorize[1] = 2.0; - splatColor._colorize[2] = 2.0; - splatColor._colorize[3] = 1.0; - splatColor._offset[0] = 0.1; - splatColor._offset[1] = 0.3; - splatColor._offset[2] = 0.4; - } - else if (in_EDX == 1) { - splatColor._colorize[0] = 1.0; - splatColor._colorize[1] = 0.0; - splatColor._colorize[2] = 0.0; - splatColor._colorize[3] = 0.9; - } - else if (in_EDX == 3) { - splatColor._tint[0] = 0.5; - splatColor._tint[1] = 0.5; - splatColor._tint[2] = 0.5; - splatColor._tint[3] = 1.0; - splatColor._offset[0] = 0.55; - splatColor._offset[1] = 0.45; - splatColor._offset[2] = 0.0; - } - else { - if (in_EDX == 5) { - splatColor._colorize[0] = 0.3; - splatColor._colorize[1] = 0.3; - splatColor._colorize[2] = 0.3; - splatColor._colorize[3] = 1.0; - (**(code **)(*extraout_EDX + 0x3c))(&splatColor,0xffffffff,0xff,0,1); - return; - } - if (in_EDX == 0xd) { - splatColor._colorize[0] = 1.0; - splatColor._colorize[1] = 0.2; - splatColor._colorize[2] = 0.0; - splatColor._colorize[3] = 1.0; - (**(code **)(*extraout_EDX + 0x3c))(&splatColor,0xffffffff,0xff,0,1); - return; - } - if (in_EDX != 0xe) { - if (in_EDX - 7U < 4) { - scaleY = g_vectorOne.y * 2.0; - extraout_EDX[0x39] = GHIDRA_INT((g_vectorOne.x * 2.0)); - extraout_EDX[0x3a] = GHIDRA_INT(scaleY); - } - return; - } - splatColor._colorize[0] = 0.3; - splatColor._colorize[1] = 1.0; - splatColor._colorize[2] = 0.2; - splatColor._colorize[3] = 1.0; - } - (**(code **)(*extraout_EDX + 0x3c))(&splatColor,0xffffffff,0xff,0,1); - return; -} - -// 00718ac0 -GridEntity_Poop * GridEntity_Poop::get_giga_part(int variant, uint8_t isCreate) -{ - Room *this_00; - GridEntity *pGVar1; - ANM2 *pAVar2; - uint32_t uVar3; - GridEntity_Poop *pGVar4; - GridEntity *newPoop; - uint32_t uVar5; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afcb07; - local_10 = ExceptionList; - ExceptionList = &local_10; - uVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) - 7; - uVar5 = variant - 7; - if ((uVar3 < 4) && (uVar5 < 4)) { - this_00 = g_game->_room; - uVar3 = Room::GetGridIndexByTile - (this_00,(*GHIDRA_CAST((&DAT_00b690f0 + uVar5 * 8)) - - *GHIDRA_CAST((&DAT_00b690f0 + uVar3 * 8))) + - GHIDRA_UINT(this->_gridIndex) % GHIDRA_UINT(this_00->_gridWidth), - (*GHIDRA_CAST((&DAT_00b690f4 + uVar5 * 8)) - *GHIDRA_CAST((&DAT_00b690f4 + uVar3 * 8))) + - GHIDRA_UINT(this->_gridIndex) / GHIDRA_UINT(this_00->_gridWidth)); - if (uVar3 < 0x1c0) { - pGVar4 = this_00->_gridEntities[uVar3]; - if (((pGVar4 != GHIDRA_CAST(0x0)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pGVar4)) + 0x4)))) == 0xe)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pGVar4)) + 0x8)))) == variant)) { - ExceptionList = local_10; - return pGVar4; - } - } - else { - pGVar4 = GHIDRA_CAST(0x0); - } - if (isCreate != 0) { - if ((pGVar4 != GHIDRA_CAST(0x0)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pGVar4)) + 0x4)))) == 0xe)) { - Room::RemoveGridEntity(this_00,uVar3,0,1); - } - uVar5 = Random(); - if ((GHIDRA_INT(uVar3) < 0) || (0x1bf < GHIDRA_INT(uVar3))) { - KAGE_LogMessage(0x10,GHIDRA_CAST("SpawnGridEntity: Grid index invalid\n")); - } - if ((uVar3 < 0x1c0) && (this_00->_gridPaths[uVar3] < 0x385)) { - newPoop = operator_new(0x19c); - local_8 = 7; - if (newPoop == GHIDRA_CAST(0x0)) { - newPoop = GHIDRA_CAST(0x0); - } - else { - (GHIDRA_CAST((newPoop)))->GridEntity::GridEntity(); - *GHIDRA_CAST(newPoop) = IsaacRepentancePlus::GridEntity_Poop::vftable; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(newPoop[1])) + 0x4)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(newPoop[1])) + 0x14)))) = 0; - newPoop[1]._varData = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(newPoop[1])) + 0x4))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(newPoop[1])) + 0x20)))) = 0; - newPoop[1]._gridIndex = 0; - newPoop[1]._spawnFrame = 0; - newPoop[1]._rng._seed = 0; - newPoop[1]._rng._shift1 = GHIDRA_INT(g_vectorZero.x); - newPoop[1]._rng._shift2 = GHIDRA_INT(g_vectorZero.y); - newPoop[1]._rng._shift3 = GHIDRA_INT(g_vectorZero.x); - newPoop[1]._collisionClass = GHIDRA_INT(g_vectorZero.y); - pGVar1 = newPoop + 1; - (pGVar1->_sprite)._filename._buf[0] = '\0'; - (pGVar1->_sprite)._filename._buf[1] = '\0'; - (pGVar1->_sprite)._filename._buf[2] = '\0'; - (pGVar1->_sprite)._filename._buf[3] = '\0'; - pAVar2 = &newPoop[1]._sprite; - (pAVar2->_filename)._buf[4] = '\0'; - (pAVar2->_filename)._buf[5] = '\0'; - (pAVar2->_filename)._buf[6] = '\0'; - (pAVar2->_filename)._buf[7] = '\0'; - } - local_8 = 0xffffffff; - if (newPoop != GHIDRA_CAST(0x0)) { - newPoop->_gridIndex = uVar3; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((newPoop)) + 0x4)))) = 0xe; - if (this_00->_gridEntities[uVar3] != GHIDRA_CAST(0x0)) { - (*(code *)**GHIDRA_CAST(this_00->_gridEntities[uVar3]))(1); - } - this_00->_gridEntities[uVar3] = newPoop; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((newPoop)) + 0x8)))) = variant; - newPoop->_varData = 0; - (GHIDRA_CAST((newPoop)))->GridEntity::Init(uVar5); - pGVar4 = this_00->_gridEntities[uVar3]; - if (((pGVar4 != GHIDRA_CAST(0x0)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pGVar4)) + 0x4)))) == 0xe)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pGVar4)) + 0x8)))) == variant)) { - ExceptionList = local_10; - return pGVar4; - } - } - } - } - } - ExceptionList = local_10; - return GHIDRA_CAST(0x0); -} - -// 00718dd0 -void GridEntity_Poop::guard_check_icall() -{ - GridEntity_Poop *part; - GridEntity_Poop *secondPart; - uint32_t i; - GridEntity_Poop *gigaParts [3]; - GridEntity_Poop *local_8; - - local_8 = GHIDRA_CAST((__security_cookie ^ GHIDRA_UINT((gigaParts + 4)))); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 7) { - part = get_giga_part(this,8,1); - gigaParts[0] = part; - secondPart = get_giga_part(this,9,1); - gigaParts[1] = secondPart; - gigaParts[2] = get_giga_part(this,10,1); - if (((part != GHIDRA_CAST(0x0)) && (secondPart != GHIDRA_CAST(0x0))) && - (gigaParts[2] != GHIDRA_CAST(0x0))) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((part)) + 0xc)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((secondPart)) + 0xc)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((gigaParts[2])) + 0xc)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - return; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 0; - this->BeginBatches(); - i = 0; - do { - part = gigaParts[i]; - if (part != GHIDRA_CAST(0x0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((part)) + 0x8)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((part)) + 0xc)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - part->BeginBatches(); - } - i = i + 1; - } while (i < 3); - } - return; -} diff --git a/generated-src/grid_entity_pressure_plate.cpp b/generated-src/grid_entity_pressure_plate.cpp deleted file mode 100644 index c9f8571..0000000 --- a/generated-src/grid_entity_pressure_plate.cpp +++ /dev/null @@ -1,1795 +0,0 @@ -#include "classes.h" - -// 00983330 -void GridEntity_PressurePlate::Update() -{ - uint32_t gridIndex; - - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2) { - update_greed_button(this); - } - else { - update_press(); - } - gridIndex = this->_gridIndex; - if ((((0x1bf < gridIndex) || (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + gridIndex * 4 + 0x76c)) < 300)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0)) && (gridIndex < 0x1c0)) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + gridIndex * 4 + 0x76c)) = 300; - } - return; -} - -// 009833c0 -void GridEntity_PressurePlate::update_press() -{ - uint8_t bVar1; - uint8_t *pbVar2; - uint8_t *animNameCursor; - uint32_t uVar3; - int iVar4; - char *pcVar5; - uint8_t *offNameCursor; - uint64_t *allocCounter; - bool bVar6; - float dx; - float dy; - float pressRadiusSq; - float gridOriginY; - EntityList_EL nearbyEntities; - Vector local_18; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - Game *game; - Manager *manager; - uint64_t oldAllocated; - Entity_Player *presser; - - local_8 = 0xffffffff; - puStack_c = &LAB_00af245d; - local_10 = ExceptionList; - ExceptionList = &local_10; - iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_18.x = (float)(this->_gridIndex % iVar4) * 40.0 + 40.0; - local_18.y = (float)(this->_gridIndex / iVar4) * 40.0 + 120.0; - EntityList::QueryRadius - (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&nearbyEntities,&local_18,60.0,0x28); - local_8 = 0; - local_18.y = 0.0; - if ((float)nearbyEntities._size != 0.0) { - pressRadiusSq = 900.0; - gridOriginY = 120.0; - do { - presser = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + GHIDRA_INT(local_18.y) * 4)); - iVar4 = presser->_type; - if (((iVar4 == 1) && (presser->_isCoopGhost != 0)) || - ((presser->_dead == 0 && - ((((iVar4 == 1 && (presser->_isCoopGhost == 0)) && - (bVar1 = Entity_Player::IsHologram(presser), bVar1 == 0)) || - (((*GHIDRA_CAST(&g_game->_deathmatchManager) < 2 || (iVar4 != 1)) && - ((iVar4 - 10U < 0x3de && ((iVar4 == 0x36d || (iVar4 == 0x35)))))))))))) { - manager = g_manager; - iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - dy = ((float)(this->_gridIndex / iVar4) * 40.0 + gridOriginY) - (presser->_pos).y; - dx = ((float)(this->_gridIndex % iVar4) * 40.0 + 40.0) - (presser->_pos).x; - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0) && (dy * dy + dx * dx < pressRadiusSq)) { - if (((this->_sprite)._animState._animData == (void *)0x0) || - ((this->_sprite)._animState._isPlaying == 0)) goto LAB_00983599; - pbVar2 = (this->_sprite)._animState._animData; - if (0xf < *GHIDRA_CAST((pbVar2 + 0x14))) { - pbVar2 = *GHIDRA_CAST(pbVar2); - } - pcVar5 = "Switched"; - goto LAB_00983570; - } - } - local_18.y = (float)(GHIDRA_INT(local_18.y) + 1); - } while (GHIDRA_UINT(local_18.y) < GHIDRA_UINT(nearbyEntities._size)); - } - goto LAB_00983648; - while( true ) { - bVar1 = pbVar2[1]; - bVar6 = bVar1 < (uint8_t)pcVar5[1]; - if (bVar1 != pcVar5[1]) goto LAB_00983590; - pbVar2 = pbVar2 + 2; - pcVar5 = pcVar5 + 2; - if (bVar1 == 0) break; -LAB_00983570: - bVar1 = *pbVar2; - bVar6 = bVar1 < (uint8_t)*pcVar5; - if (bVar1 != *pcVar5) { -LAB_00983590: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_00983595; - } - if (bVar1 == 0) break; - } - uVar3 = 0; -LAB_00983595: - if (uVar3 != 0) { -LAB_00983599: - local_18.y = 6.57209e-43; - seed_fart_sound_override(GHIDRA_CAST(&local_18.y)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_18.y),1.0,2,0,1.0,0.0); - } - pbVar2 = (this->_sprite)._animState._animData; - if (pbVar2 != GHIDRA_CAST(0x0)) { - animNameCursor = pbVar2; - if (0xf < *GHIDRA_CAST((pbVar2 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar2); - } - pcVar5 = "Switched"; - do { - bVar1 = *animNameCursor; - bVar6 = bVar1 < (uint8_t)*pcVar5; - if (bVar1 != *pcVar5) { -LAB_00983610: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_00983615; - } - if (bVar1 == 0) break; - bVar1 = animNameCursor[1]; - bVar6 = bVar1 < (uint8_t)pcVar5[1]; - if (bVar1 != pcVar5[1]) goto LAB_00983610; - animNameCursor = animNameCursor + 2; - pcVar5 = pcVar5 + 2; - } while (bVar1 != 0); - uVar3 = 0; -LAB_00983615: - if ((uVar3 == 0) && ((pbVar2[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_00983648; - } - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Switched"),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } -LAB_00983648: - if ((((this->_sprite)._animState._animData == (void *)0x0) || - ((this->_sprite)._animState._isPlaying == 0)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 3; - pbVar2 = (this->_sprite)._animState._animData; - if (pbVar2 == GHIDRA_CAST(0x0)) { -LAB_009836b8: - bVar1 = ANM2::SetAnimation(&this->_sprite,&DAT_00b7cf1c,1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = pbVar2; - if (0xf < *GHIDRA_CAST((pbVar2 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar2); - } - offNameCursor = &DAT_00b7cf1c; - do { - bVar1 = *animNameCursor; - bVar6 = bVar1 < *offNameCursor; - if (bVar1 != *offNameCursor) { -LAB_009836a2: - uVar3 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_009836a7; - } - if (bVar1 == 0) break; - bVar1 = animNameCursor[1]; - bVar6 = bVar1 < offNameCursor[1]; - if (bVar1 != offNameCursor[1]) goto LAB_009836a2; - animNameCursor = animNameCursor + 2; - offNameCursor = offNameCursor + 2; - } while (bVar1 != 0); - uVar3 = 0; -LAB_009836a7: - if ((uVar3 != 0) || ((pbVar2[0x34] != 0 && ((this->_sprite)._animState._isPlaying == 0)))) - goto LAB_009836b8; - } - Reward(this); - } - game = g_game; - iVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if (iVar4 == 0) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 0) goto LAB_00983750; - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x11ec)) = 10; - iVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - } - if (((iVar4 == 4) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1)) && (pcVar5 = game->_room, *pcVar5 != '\0')) - { - iVar4 = game->_frameCount - *GHIDRA_CAST((pcVar5 + 0x11f0)); - if (iVar4 == 4) { - Reward(this); - } - else if ((4 < iVar4) && ((*GHIDRA_CAST((*GHIDRA_CAST((pcVar5 + 4)) + 0x44)) & 1) != 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 3; - } - } -LAB_00983750: - if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x0))) == '\0') { - if (g_mainHeap == (void *)0x0) { - allocCounter = &g_allocatedBytesNoHeap; - } - else { - allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); - } - if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) != 0) { - uVar3 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + -4)); - oldAllocated = *allocCounter; - *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar3; - *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = - *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(oldAllocated) < uVar3)); - free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + -4)); - } - } - ExceptionList = local_10; - return; -} - -// 009837b0 -void GridEntity_PressurePlate::update_greed_button_anim(uint8_t isRed) -{ - uint8_t bVar1; - char *animName; - - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc))))) { - case 0: - break; - case 1: - case 2: - if (isRed != 0) { - this->_nextGreedAnimation = "SwitchedRed"; - return; - } - bVar1 = Game::IsGreedFinalBoss(); - if (bVar1 != 0) { - this->_nextGreedAnimation = "SwitchedPentagram"; - return; - } - bVar1 = Game::IsGreedBoss(); - animName = "SwitchedSkull"; - if (bVar1 == 0) { - animName = "Switched"; - } - this->_nextGreedAnimation = animName; - return; - case 3: - bVar1 = Game::IsGreedFinalBoss(); - if (bVar1 != 0) { - this->_nextGreedAnimation = "OnPentagram"; - return; - } - bVar1 = Game::IsGreedBoss(); - animName = "OnSkull"; - if (bVar1 == 0) { - animName = "On"; - } - this->_nextGreedAnimation = animName; - default: - return; - } - if (isRed != 0) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("OffRedStart"),0); - this->_nextGreedAnimation = "OffRed"; - return; - } - bVar1 = Game::IsGreedFinalBoss(); - if (bVar1 != 0) { - this->_nextGreedAnimation = "OffPentagram"; - return; - } - bVar1 = Game::IsGreedBoss(); - animName = "OffSkull"; - if (bVar1 == 0) { - animName = "Off"; - } - this->_nextGreedAnimation = animName; - return; -} - -// 009838c0 -void GridEntity_PressurePlate::play_pending_animation() -{ - uint8_t *currentName; - uint32_t compareResult; - uint8_t *currentAnim; - uint8_t *targetName; - char *offRedStart; - bool isLess; - uint8_t ch; - - currentAnim = (this->_sprite)._animState._animData; - if (currentAnim == GHIDRA_CAST(0x0)) { - currentName = &s_empty; - } - else { - currentName = currentAnim; - if (0xf < *GHIDRA_CAST((currentAnim + 0x14))) { - currentName = *GHIDRA_CAST(currentAnim); - } - } - targetName = this->_nextGreedAnimation; - do { - ch = *currentName; - isLess = ch < *targetName; - if (ch != *targetName) { -LAB_00983903: - compareResult = -GHIDRA_UINT(isLess) | 1; - goto LAB_00983908; - } - if (ch == 0) break; - ch = currentName[1]; - isLess = ch < targetName[1]; - if (ch != targetName[1]) goto LAB_00983903; - currentName = currentName + 2; - targetName = targetName + 2; - } while (ch != 0); - compareResult = 0; -LAB_00983908: - if (compareResult != 0) { - if ((currentAnim != GHIDRA_CAST(0x0)) && ((this->_sprite)._animState._isPlaying != 0)) { - if (currentAnim == GHIDRA_CAST(0x0)) { - currentAnim = &s_empty; - } - else if (0xf < *GHIDRA_CAST((currentAnim + 0x14))) { - currentAnim = *GHIDRA_CAST(currentAnim); - } - offRedStart = "OffRedStart"; - do { - ch = *currentAnim; - isLess = ch < (uint8_t)*offRedStart; - if (ch != *offRedStart) { -LAB_00983953: - compareResult = -GHIDRA_UINT(isLess) | 1; - goto LAB_00983958; - } - if (ch == 0) break; - ch = currentAnim[1]; - isLess = ch < (uint8_t)offRedStart[1]; - if (ch != offRedStart[1]) goto LAB_00983953; - currentAnim = currentAnim + 2; - offRedStart = offRedStart + 2; - } while (ch != 0); - compareResult = 0; -LAB_00983958: - if (compareResult == 0) { - return; - } - } - ANM2::Play(&this->_sprite,this->_nextGreedAnimation,0); - } - return; -} - -// 009839f0 -void GridEntity_PressurePlate::update_greed_button() -{ - bool bVar1; - uint8_t bVar2; - uint8_t bVar3; - uint32_t *playerSlot; - uint8_t *animNameChar; - uint32_t uVar4; - int iVar5; - Entity_Player *this_00; - char *switchedAnimChar; - void *pvVar6; - PlayerManager *playerManager; - Game *game; - bool isLess; - float fVar7; - float deltaY; - uint32_t local_7c; - bool isWaveActive; - undefined3 uStack_77; - int waveTimer; - int effectEntry [3]; - uint32_t uStack_64; - EntityRef damageSource; - ColorMod flashColor; - Manager *manager; - Entity_Player *player; - int waveTimerNow; - - playerManager = &g_game->_playerManager; - isLess = false; - bVar1 = true; - waveTimer = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x723c)); - _isWaveActive = CONCAT31(uStack_77,0 < waveTimer); - local_7c = 0; - bVar2 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) & 1; - game = g_game; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 - != 0) { - do { - pvVar6 = (playerManager->_playerList)._end; - if (GHIDRA_INT(pvVar6) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar6 = (playerManager->_playerList)._end; - game = g_game; - } - playerSlot = (playerManager->_playerList)._begin; - if (local_7c < GHIDRA_UINT((GHIDRA_INT(pvVar6) - GHIDRA_INT(playerSlot) >> 2))) { - playerSlot = playerSlot + local_7c; - } - player = GHIDRA_CAST(*playerSlot); - if ((player->_variant == 0) && (player->_isCoopGhost == 0)) { - iVar5 = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)); - deltaY = ((float)(this->_gridIndex / iVar5) * 40.0 + 120.0) - (player->_pos).y; - fVar7 = ((float)(this->_gridIndex % iVar5) * 40.0 + 40.0) - (player->_pos).x; - fVar7 = deltaY * deltaY + fVar7 * fVar7; - if ((isLess) || (isLess = false, fVar7 < 625.0)) { - isLess = true; - } - if ((!bVar1) || (bVar1 = true, fVar7 <= 900.0)) { - bVar1 = false; - } - if ((fVar7 < 625.0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0)) { - if (0 < waveTimer) { - iVar5 = Entity_Player::GetHealthType(player); - if ((iVar5 == 2) || (bVar3 = Entity_Player::HasInstantDeathCurse(this_00), bVar3 != 0)) - { - game->_levelStateFlags = game->_levelStateFlags | 0x800; - } - else { - damageSource._type = 0; - damageSource._variant = 0; - damageSource._spawnerType = 0; - damageSource._spawnerVariant = 0; - damageSource._position.x = g_vectorZero.x; - damageSource._position.y = g_vectorZero.y; - damageSource._velocity.x = g_vectorZero.x; - damageSource._velocity.y = g_vectorZero.y; - damageSource._flags = 0; - damageSource._entity = (void *)0x0; - (**(code **)(*GHIDRA_CAST(player) + 0x20))(0x3f800000,0x10000080,0,&damageSource,0x1e); - game = g_game; - } - } - break; - } - } - playerManager = &game->_playerManager; - local_7c = local_7c + 1; - } while (local_7c < - GHIDRA_UINT((GHIDRA_INT((game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if ((iVar5 == 0) && (isLess)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - manager = g_manager; - if (((this->_sprite)._animState._animData == (void *)0x0) || - ((this->_sprite)._animState._isPlaying == 0)) { -LAB_00983c89: - local_7c = 0x1d5; - seed_fart_sound_override(GHIDRA_CAST(&local_7c)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(local_7c,1.0,2,0,1.0,0.0); - } - else { - animNameChar = (this->_sprite)._animState._animData; - if (0xf < *GHIDRA_CAST((animNameChar + 0x14))) { - animNameChar = *GHIDRA_CAST(animNameChar); - } - switchedAnimChar = "Switched"; - do { - bVar3 = *animNameChar; - isLess = bVar3 < (uint8_t)*switchedAnimChar; - if (bVar3 != *switchedAnimChar) { -LAB_00983c80: - uVar4 = -GHIDRA_UINT(isLess) | 1; - goto LAB_00983c85; - } - if (bVar3 == 0) break; - bVar3 = animNameChar[1]; - isLess = bVar3 < (uint8_t)switchedAnimChar[1]; - if (bVar3 != switchedAnimChar[1]) goto LAB_00983c80; - animNameChar = animNameChar + 2; - switchedAnimChar = switchedAnimChar + 2; - } while (bVar3 != 0); - uVar4 = 0; -LAB_00983c85: - if (uVar4 != 0) goto LAB_00983c89; - } - update_greed_button_anim(this,(uint8_t)_isWaveActive); - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - game = g_game; - } - if (((this->_sprite)._animState._animData == (void *)0x0) || - ((this->_sprite)._animState._isPlaying == 0)) { - if (iVar5 == 1) { - if (waveTimer < 1) { - Room::SpawnGreedModeWave(game->_room,0); - uVar4 = 0; - playerManager = &g_game->_playerManager; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 != 0) { - do { - pvVar6 = (playerManager->_playerList)._end; - if (GHIDRA_INT(pvVar6) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar6 = (playerManager->_playerList)._end; - } - playerSlot = (playerManager->_playerList)._begin; - if (uVar4 < GHIDRA_UINT((GHIDRA_INT(pvVar6) - GHIDRA_INT(playerSlot) >> 2))) { - playerSlot = playerSlot + uVar4; - } - player = GHIDRA_CAST(*playerSlot); - bVar3 = Entity_Player::HasCollectible(player,299,0); - if (((bVar3 != 0) || (iVar5 = Entity_Player::GetZodiacEffect(player), iVar5 == 299)) && - (bVar3 = TemporaryEffects::HasCollectibleEffect(&player->_temporaryeffects,299), - bVar3 == 0)) { - player->_taurusSpeedBonus = 0.0; - flashColor._colorize[0] = 0.0; - flashColor._colorize[1] = 0.0; - flashColor._colorize[2] = 0.0; - flashColor._colorize[3] = 0.0; - flashColor._offset[0] = 0.0; - flashColor._offset[1] = 0.0; - flashColor._offset[2] = 0.0; - flashColor._tint[0] = 1.0; - flashColor._tint[1] = 1.0; - flashColor._tint[2] = 1.0; - flashColor._tint[3] = 1.0; - (**(code **)(*GHIDRA_CAST(player) + 0x3c))(&flashColor,0xffffffff,0xff,0,1); - pvVar6 = (g_manager->_itemConfig)._collectibles._begin; - if ((0x4ac < GHIDRA_INT((GHIDRA_INT((g_manager->_itemConfig)._collectibles._end) - GHIDRA_INT(pvVar6) & - 0xfffffffcU))) && (iVar5 = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x4ac)), iVar5 != 0) - ) { - effectEntry[2] = *GHIDRA_CAST((iVar5 + 0x78)); - effectEntry[1] = 0; - uStack_64 = 0; - effectEntry[0] = iVar5; - TemporaryEffects::AddEffect(&player->_temporaryeffects,effectEntry,1,1); - } - } - uVar4 = uVar4 + 1; - playerManager = &g_game->_playerManager; - } while (uVar4 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - } - else { - *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x723c)) = 0xffffffff; - } - } - else if (iVar5 != 2) goto LAB_00983ea2; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 3; - update_greed_button_anim(this,(uint8_t)_isWaveActive); - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - game = g_game; - } -LAB_00983ea2: - waveTimerNow = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x723c)); - _isWaveActive = CONCAT31(uStack_77,0 < waveTimerNow); - if (iVar5 == 3) { - if (((!bVar1) || ((game->_difficulty == 3) + 0xb <= GHIDRA_UINT(game->_greedModeWave))) || - ((waveTimerNow < 1 && (bVar2 == 0)))) goto LAB_00983f0b; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - } - else { - if (((iVar5 != 0) || (0 < waveTimerNow)) || (bVar2 != 0)) goto LAB_00983f0b; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - } - update_greed_button_anim(this,0 < waveTimerNow); -LAB_00983f0b: - play_pending_animation(this); - return; -} - -// 00984550 -void GridEntity_PressurePlate::Reward() -{ - GridEntity_PressurePlate *door = this; - code *pcVar1; - Vector pos; - Vector pos_00; - Vector pos_01; - Vector pos_02; - Vector pos_03; - Vector pos_04; - Vector pos_05; - Vector pos_06; - GridEntity *pGVar2; - ANM2 *pAVar3; - uint8_t isTrapDoorAllowed; - int targetRoomType; - GridEntity *poop; - Vector *tmpPos; - uint32_t rngValue; - float fVar5; - Entity_Player *player; - RoomDescriptor *roomDesc; - Entity_Effect *timerEffect; - void *pvVar6; - int iVar7; - uint32_t uVar8; - Game *game; - float *positionsEnd; - float *positionsCapacity; - float fVar9; - RNG rng; - float *spawnPositions; - float *spawnPositionsEnd; - float *spawnPositionsCapacity; - Vector local_68; - Vector local_60; - Vector local_58; - Vector local_4c; - Vector local_44; - float local_3c; - void *local_38; - float local_34; - void *local_30; - float *local_2c; - uint32_t enemyVariant; - uint32_t local_24; - uint8_t *puStack_20; - void *local_1c; - uint8_t *puStack_18; - uint32_t local_14; - GridEntity_Door *door; - Manager *manager; - uint32_t *oldGridEntity; - Room *room; - uint32_t *roomFlags; - int targetRoomType; - - manager = g_manager; - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - local_14 = 0xffffffff; - puStack_18 = &LAB_00b0ce51; - local_1c = ExceptionList; - uVar8 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((door)) + 0x8)))); - local_58.y = (float)door; - if (uVar8 != 1) { - if (9 < uVar8) { - if (uVar8 < 0xe) { - ExceptionList = &local_1c; - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - Room::TriggerOutput(g_game->_room,uVar8 - 10); - ExceptionList = local_1c; - return; - } - return; - } - if (uVar8 != 9) { - if (uVar8 == 3) { - ExceptionList = &local_1c; - Level::raise_mineshaft_rail(GHIDRA_CAST(g_game)); - ExceptionList = local_1c; - return; - } - return; - } - ExceptionList = &local_1c; - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - tmpPos = (GHIDRA_CAST((GHIDRA_CAST(door))))->GridEntity::Position(&local_68); - player = Game::GetNearestPlayerEx(tmpPos,1,0,0); - if (player == GHIDRA_CAST(0x0)) { - player = Game::GetPlayer(g_game,0); - } - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c4)) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c0)); - targetRoomType = 0; - if (0 < iVar7) { - targetRoomType = iVar7; - } - if (targetRoomType < 1) { - ExceptionList = local_1c; - return; - } - SoundEffects::PlayWithFartOverride(0x10b,1.0,0x14,0,1.0); - SoundEffects::PlayWithFartOverride(0x21,1.0,0x14,0,1.0); - Game::ShakeScreen(g_game,0xf); - timerEffect = Entity_Effect::CreateTimer - (pressure_plate_kill_enemies_timer_callback,1,0xffffffff,0); - Entity::SetParent(GHIDRA_CAST(timerEffect),GHIDRA_CAST(player)); - ExceptionList = local_1c; - return; - } - uVar8 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((door)) + 0x14)))); - rng._shift1 = 5; - rng._shift2 = 9; - local_2c = GHIDRA_CAST(0x7); - rng._shift3 = 7; - if (uVar8 == 0) { - ExceptionList = &local_1c; - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar8 = uVar8 >> 5 ^ uVar8; - uVar8 = uVar8 << 9 ^ uVar8; - rng._seed = uVar8 >> 7 ^ uVar8; - local_38 = (void *)rng._seed; - if ((rng._seed & 1U) == 0) { - local_30 = (void *)0x10c; - ExceptionList = &local_1c; - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - seed_fart_sound_override(GHIDRA_CAST(&local_30)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_30),1.0,2,0,1.0,0.0); - targetRoomType = g_game->_room->_gridWidth; - local_58.x = (float)(door->_gridIndex % targetRoomType) * 40.0 + 40.0; - local_58.y = (float)(door->_gridIndex / targetRoomType) * 40.0 + 120.0; - Room::FindFreePickupSpawnPosition(g_game->_room,&local_4c,&local_58,0.0,1,0,0); - if (local_38 == (void *)0x0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar8 = GHIDRA_UINT(local_38) >> ((uint8_t)rng._shift1 & 0x1f) ^ GHIDRA_UINT(local_38); - uVar8 = uVar8 << ((uint8_t)rng._shift2 & 0x1f) ^ uVar8; - rng._seed = uVar8 >> ((uint8_t)local_2c & 0x1f) ^ uVar8; - uVar8 = GHIDRA_UINT(rng._seed) % 100; - if (uVar8 < 5) { - isTrapDoorAllowed = Level::CanSpawnTrapDoor(GHIDRA_CAST(g_game)); - if (isTrapDoorAllowed != 0) { - room = g_game->_room; - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - targetRoomType = Room::GetGridIndex(g_game->_room,&local_4c); - Room::SpawnGridEntity(room,targetRoomType,0x11,0,uVar8,0); - ExceptionList = local_1c; - return; - } - } - else if (9 < uVar8) { - if (uVar8 < 0xb) { - pvVar6 = g_game->_room; - local_30 = pvVar6; - local_38 = (void *)(GHIDRA_CAST((&rng)))->RNG::Next(); - uVar8 = Room::GetGridIndex(g_game->_room,&local_4c); - if ((GHIDRA_INT(uVar8) < 0) || (0x1bf < GHIDRA_INT(uVar8))) { - KAGE_LogMessage(0x10,GHIDRA_CAST("SpawnGridEntity: Grid index invalid\n")); - } - if (0x1bf < uVar8) { - ExceptionList = local_1c; - return; - } - if (900 < *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + uVar8 * 4 + 0x76c))) { - ExceptionList = local_1c; - return; - } - poop = operator_new(0x19c); - local_14 = 0x1e; - local_58.y = (float)poop; - if (poop == GHIDRA_CAST(0x0)) { - poop = GHIDRA_CAST(0x0); - } - else { - (GHIDRA_CAST((poop)))->GridEntity::GridEntity(); - *GHIDRA_CAST(poop) = IsaacRepentancePlus::GridEntity_Poop::vftable; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x4)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x14)))) = 0; - poop[1]._varData = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x4))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x20)))) = 0; - poop[1]._gridIndex = 0; - poop[1]._spawnFrame = 0; - poop[1]._rng._seed = 0; - fVar5 = g_vectorZero.y; - poop[1]._rng._shift1 = GHIDRA_INT(g_vectorZero.x); - poop[1]._rng._shift2 = GHIDRA_INT(fVar5); - fVar5 = g_vectorZero.y; - poop[1]._rng._shift3 = GHIDRA_INT(g_vectorZero.x); - poop[1]._collisionClass = GHIDRA_INT(fVar5); - pGVar2 = poop + 1; - (pGVar2->_sprite)._filename._buf[0] = '\0'; - (pGVar2->_sprite)._filename._buf[1] = '\0'; - (pGVar2->_sprite)._filename._buf[2] = '\0'; - (pGVar2->_sprite)._filename._buf[3] = '\0'; - pAVar3 = &poop[1]._sprite; - (pAVar3->_filename)._buf[4] = '\0'; - (pAVar3->_filename)._buf[5] = '\0'; - (pAVar3->_filename)._buf[6] = '\0'; - (pAVar3->_filename)._buf[7] = '\0'; - } - local_14 = 0xffffffff; - if (poop == GHIDRA_CAST(0x0)) { - ExceptionList = local_1c; - return; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((poop)) + 0x4)))) = 0xe; - poop->_gridIndex = uVar8; - oldGridEntity = *GHIDRA_CAST((GHIDRA_CAST(local_30) + uVar8 * 4 + 0x24)); - if (oldGridEntity != GHIDRA_CAST(0x0)) { - (**(code **)*oldGridEntity)(1); - } - *GHIDRA_CAST((GHIDRA_CAST(local_30) + uVar8 * 4 + 0x24)) = poop; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((poop)) + 0x8)))) = 0; - goto LAB_009848ac; - } - if (uVar8 < 0xc) { - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - Game::Spawn(g_game,5,100,&local_4c,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar8); - ExceptionList = local_1c; - return; - } - if (uVar8 < 0x1e) { - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(3); - local_30 = (void *)(uVar8 + 1); - if (GHIDRA_INT(local_30) < 1) { - ExceptionList = local_1c; - return; - } - do { - targetRoomType = g_game->_room->_gridWidth; - local_58.x = (float)(door->_gridIndex % targetRoomType) * 40.0 + 40.0; - local_58.y = (float)(door->_gridIndex / targetRoomType) * 40.0 + 120.0; - tmpPos = Room::FindFreePickupSpawnPosition(g_game->_room,&local_60,&local_58,0.0,1,0,0); - local_4c.x = tmpPos->x; - local_4c.y = tmpPos->y; - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - Game::Spawn(g_game,5,0x14,&local_4c,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar8); - local_30 = (void *)(GHIDRA_INT(local_30) + -1); - } while (local_30 != (void *)0x0); - ExceptionList = local_1c; - return; - } - if (uVar8 < 0x32) { - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(2); - local_30 = (void *)(uVar8 + 1); - if (GHIDRA_INT(local_30) < 1) { - ExceptionList = local_1c; - return; - } - do { - targetRoomType = g_game->_room->_gridWidth; - local_58.x = (float)(door->_gridIndex % targetRoomType) * 40.0 + 40.0; - local_58.y = (float)(door->_gridIndex / targetRoomType) * 40.0 + 120.0; - tmpPos = Room::FindFreePickupSpawnPosition(g_game->_room,&local_60,&local_58,0.0,1,0,0); - local_4c.x = tmpPos->x; - local_4c.y = tmpPos->y; - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - Game::Spawn(g_game,5,10,&local_4c,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar8); - local_30 = (void *)(GHIDRA_INT(local_30) + -1); - } while (local_30 != (void *)0x0); - ExceptionList = local_1c; - return; - } - if (uVar8 < 0x46) { - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(2); - local_30 = (void *)(uVar8 + 1); - if (GHIDRA_INT(local_30) < 1) { - ExceptionList = local_1c; - return; - } - do { - targetRoomType = g_game->_room->_gridWidth; - local_58.x = (float)(door->_gridIndex % targetRoomType) * 40.0 + 40.0; - local_58.y = (float)(door->_gridIndex / targetRoomType) * 40.0 + 120.0; - tmpPos = Room::FindFreePickupSpawnPosition(g_game->_room,&local_60,&local_58,0.0,1,0,0); - local_4c.x = tmpPos->x; - local_4c.y = tmpPos->y; - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - Game::Spawn(g_game,5,0x28,&local_4c,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar8); - local_30 = (void *)(GHIDRA_INT(local_30) + -1); - } while (local_30 != (void *)0x0); - ExceptionList = local_1c; - return; - } - if (uVar8 < 0x50) { - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - rngValue = (GHIDRA_CAST((&rng)))->RNG::RandomInt(4); - Game::Spawn(g_game,5,*GHIDRA_CAST((&DAT_00b7cfa0 + rngValue * 4)),&local_4c,&g_vectorZero, - GHIDRA_CAST(0x0),0,uVar8); - ExceptionList = local_1c; - return; - } - if (0x54 < uVar8) { - if (0x59 < uVar8) { - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - Game::Spawn(g_game,4,3,&local_4c,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar8); - ExceptionList = local_1c; - return; - } - local_58.y = local_4c.y + 0.0; - local_58.x = local_4c.x + 40.0; - room = g_game->_room; - pos_03.y = local_58.y; - pos_03.x = local_58.x; - local_38 = (void *)local_58.y; - targetRoomType = Room::GetGridCollisionAtPos(room,pos_03); - if (targetRoomType == 0) { -LAB_00984f49: - local_58.x = local_4c.x + 0.0; - local_58.y = local_4c.y + 40.0; - pos_05.y = local_58.y; - pos_05.x = local_58.x; - local_38 = (void *)local_58.x; - targetRoomType = Room::GetGridCollisionAtPos(room,pos_05); - if (targetRoomType == 0) goto LAB_00984fe7; - local_58.y = local_4c.y - 40.0; - local_58.x = (float)local_38; - pos_06.y = local_58.y; - pos_06.x = (float)local_38; - targetRoomType = Room::GetGridCollisionAtPos(room,pos_06); - if (targetRoomType == 0) goto LAB_00984fe7; - } - else { - local_58.x = local_4c.x - 40.0; - local_58.y = (float)local_38; - pos_04.y = (float)local_38; - pos_04.x = local_58.x; - targetRoomType = Room::GetGridCollisionAtPos(room,pos_04); - if (targetRoomType == 0) goto LAB_00984f49; - } - tmpPos = Room::GetCenterPos(&local_60); - tmpPos = Room::FindFreePickupSpawnPosition(room,&local_58,tmpPos,0.0,1,0,0); - local_4c.x = tmpPos->x; - local_4c.y = tmpPos->y; -LAB_00984fe7: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - Game::Spawn(g_game,6,8,&local_4c,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar8); - ExceptionList = local_1c; - return; - } - local_58.y = local_4c.y + 0.0; - local_58.x = local_4c.x + 40.0; - room = g_game->_room; - pos.y = local_58.y; - pos.x = local_58.x; - local_38 = (void *)local_58.y; - targetRoomType = Room::GetGridCollisionAtPos(room,pos); - if (targetRoomType == 0) { -LAB_00984de5: - local_58.x = local_4c.x + 0.0; - local_58.y = local_4c.y + 40.0; - pos_01.y = local_58.y; - pos_01.x = local_58.x; - local_38 = (void *)local_58.x; - targetRoomType = Room::GetGridCollisionAtPos(room,pos_01); - if (targetRoomType == 0) goto LAB_00984e83; - local_58.y = local_4c.y - 40.0; - local_58.x = (float)local_38; - pos_02.y = local_58.y; - pos_02.x = (float)local_38; - targetRoomType = Room::GetGridCollisionAtPos(room,pos_02); - if (targetRoomType == 0) goto LAB_00984e83; - } - else { - local_58.x = local_4c.x - 40.0; - local_58.y = (float)local_38; - pos_00.y = (float)local_38; - pos_00.x = local_58.x; - targetRoomType = Room::GetGridCollisionAtPos(room,pos_00); - if (targetRoomType == 0) goto LAB_00984de5; - } - tmpPos = Room::GetCenterPos(&local_60); - tmpPos = Room::FindFreePickupSpawnPosition(room,&local_58,tmpPos,0.0,1,0,0); - local_4c.x = tmpPos->x; - local_4c.y = tmpPos->y; -LAB_00984e83: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::Next(); - rngValue = (GHIDRA_CAST((&rng)))->RNG::RandomInt(2); - Game::Spawn(g_game,6,(-GHIDRA_UINT((rngValue != 0)) & 2) + 1,&local_4c,&g_vectorZero,GHIDRA_CAST(0x0),0, - uVar8); - ExceptionList = local_1c; - return; - } - pvVar6 = g_game->_room; - local_30 = pvVar6; - local_38 = (void *)(GHIDRA_CAST((&rng)))->RNG::Next(); - uVar8 = Room::GetGridIndex(g_game->_room,&local_4c); - if ((GHIDRA_INT(uVar8) < 0) || (0x1bf < GHIDRA_INT(uVar8))) { - KAGE_LogMessage(0x10,GHIDRA_CAST("SpawnGridEntity: Grid index invalid\n")); - } - if (0x1bf < uVar8) { - ExceptionList = local_1c; - return; - } - if (900 < *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + uVar8 * 4 + 0x76c))) { - ExceptionList = local_1c; - return; - } - poop = operator_new(0x19c); - local_14 = 7; - local_58.y = (float)poop; - if (poop == GHIDRA_CAST(0x0)) { - poop = GHIDRA_CAST(0x0); - } - else { - (GHIDRA_CAST((poop)))->GridEntity::GridEntity(); - *GHIDRA_CAST(poop) = IsaacRepentancePlus::GridEntity_Poop::vftable; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x4)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x14)))) = 0; - poop[1]._varData = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x4))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(poop[1])) + 0x20)))) = 0; - poop[1]._gridIndex = 0; - poop[1]._spawnFrame = 0; - poop[1]._rng._seed = 0; - fVar5 = g_vectorZero.y; - poop[1]._rng._shift1 = GHIDRA_INT(g_vectorZero.x); - poop[1]._rng._shift2 = GHIDRA_INT(fVar5); - fVar5 = g_vectorZero.y; - poop[1]._rng._shift3 = GHIDRA_INT(g_vectorZero.x); - poop[1]._collisionClass = GHIDRA_INT(fVar5); - pGVar2 = poop + 1; - (pGVar2->_sprite)._filename._buf[0] = '\0'; - (pGVar2->_sprite)._filename._buf[1] = '\0'; - (pGVar2->_sprite)._filename._buf[2] = '\0'; - (pGVar2->_sprite)._filename._buf[3] = '\0'; - pAVar3 = &poop[1]._sprite; - (pAVar3->_filename)._buf[4] = '\0'; - (pAVar3->_filename)._buf[5] = '\0'; - (pAVar3->_filename)._buf[6] = '\0'; - (pAVar3->_filename)._buf[7] = '\0'; - } - local_14 = 0xffffffff; - if (poop == GHIDRA_CAST(0x0)) { - ExceptionList = local_1c; - return; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((poop)) + 0x4)))) = 0xe; - poop->_gridIndex = uVar8; - oldGridEntity = *GHIDRA_CAST((GHIDRA_CAST(local_30) + uVar8 * 4 + 0x24)); - if (oldGridEntity != GHIDRA_CAST(0x0)) { - (**(code **)*oldGridEntity)(1); - } - *GHIDRA_CAST((GHIDRA_CAST(local_30) + uVar8 * 4 + 0x24)) = poop; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((poop)) + 0x8)))) = 3; -LAB_009848ac: - poop->_varData = 0; - (GHIDRA_CAST((poop)))->GridEntity::Init(GHIDRA_UINT(local_38)); - ExceptionList = local_1c; - return; - } - ExceptionList = &local_1c; - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((door)) + 0xc)))) != 4) { - local_30 = (void *)0x10b; - puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); - seed_fart_sound_override(GHIDRA_CAST(&local_30)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_30),1.0,2,0,1.0,0.0); - } - fVar5 = (float)(*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c0)) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c4))); - local_4c.y = 0.0; - if (0 < GHIDRA_INT(fVar5)) { - local_4c.y = fVar5; - } - local_24 = 0; - enemyVariant = 0; - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(3); - local_3c = (float)(uVar8 + 2); - if ((g_game->_difficulty == 2) || (g_game->_difficulty == 3)) { - switch(g_game->_stage) { - default: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: - goto switchD_0098532f_caseD_0; - case 1: - goto switchD_0098532f_caseD_1; - case 2: - goto switchD_0098532f_caseD_2; - case 3: - goto switchD_0098532f_caseD_3; - case 4: - goto switchD_0098532f_caseD_4; - case 5: - goto switchD_0098532f_caseD_5; - default: - break; - } - case 2: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: - goto switchD_0098532f_caseD_4; - case 1: - goto switchD_00985120_caseD_1; - case 2: - goto switchD_00985120_caseD_2; - case 3: - goto switchD_00985120_caseD_3; - case 4: - goto switchD_00985120_caseD_4; - case 5: - goto switchD_00985120_caseD_5; - default: - break; - } - case 3: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: - goto switchD_0098513a_caseD_0; - case 1: - goto switchD_0098513a_caseD_1; - case 2: - goto switchD_0098513a_caseD_2; - case 3: - goto switchD_0098513a_caseD_3; - case 4: - goto switchD_0098513a_caseD_4; - case 5: - goto switchD_0098513a_caseD_5; - default: - break; - } - case 4: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(5); - switch(uVar8) { - case 0: - goto switchD_00985154_caseD_0; - case 1: - goto switchD_00985154_caseD_1; - case 2: - goto switchD_00985154_caseD_2; - case 3: - goto switchD_00985154_caseD_3; - case 4: - goto switchD_00985154_caseD_4; - default: - break; - } - case 5: -switchD_00985342_caseD_5: -LAB_00985444: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(3); - if (uVar8 != 0) { - if (uVar8 == 1) { - local_24 = 0x32; - } - else if (uVar8 == 2) { - local_24 = 0x195; - } - break; - } -switchD_00985482_caseD_2: - local_24 = 0x194; - break; - case 6: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(4); - switch(uVar8) { - case 0: - goto switchD_00985482_caseD_0; - case 1: - goto switchD_00985482_caseD_1; - case 2: - goto switchD_00985482_caseD_2; - case 3: -switchD_00985482_caseD_3: - local_24 = 0xfc; - default: - break; - } - case 7: - local_24 = 0x66; - } - } - else { - switch(g_game->_stage) { - default: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: -switchD_0098532f_caseD_0: - local_24 = 0x12; - break; - case 1: -switchD_0098532f_caseD_1: - local_24 = 0xde; - break; - case 2: -switchD_0098532f_caseD_2: - local_24 = 0x100; - break; - case 3: -switchD_0098532f_caseD_3: - local_24 = 0xc; - break; - case 4: -switchD_0098532f_caseD_4: - local_24 = 0x17; - break; - case 5: -switchD_0098532f_caseD_5: - local_24 = 0x55; - default: - break; - } - goto switchD_0098532f_default; - case 3: - case 4: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: - goto switchD_0098532f_caseD_4; - case 1: -switchD_00985120_caseD_1: - local_24 = 0x19; - goto switchD_0098532f_default; - case 2: -switchD_00985120_caseD_2: - local_24 = 0x16; - goto switchD_0098532f_default; - case 3: -switchD_00985120_caseD_3: - local_24 = 0xcd; - goto switchD_0098532f_default; - case 4: -switchD_00985120_caseD_4: - local_24 = 0x1a; - goto switchD_0098532f_default; - case 5: -switchD_00985120_caseD_5: - local_24 = 0xea; - default: - goto switchD_0098532f_default; - } - case 5: - case 6: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: -switchD_0098513a_caseD_0: - local_24 = 0x26; - break; - case 1: -switchD_0098513a_caseD_1: - local_24 = 0x18; - break; - case 2: -switchD_0098513a_caseD_2: - local_24 = 0xe3; - break; - case 3: -switchD_0098513a_caseD_3: - local_24 = 0x29; - break; - case 4: -switchD_0098513a_caseD_4: - local_24 = 0xd1; - break; - case 5: -switchD_0098513a_caseD_5: - local_24 = 0xed; - default: - break; - } - goto switchD_0098532f_default; - case 7: - case 8: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(5); - switch(uVar8) { - case 0: -switchD_00985154_caseD_0: - local_24 = 0x39; - break; - case 1: -switchD_00985154_caseD_1: - local_24 = 0xdf; - break; - case 2: -switchD_00985154_caseD_2: - local_24 = 0x38; - break; - case 3: -switchD_00985154_caseD_3: - local_24 = 0xd5; - break; - case 4: -switchD_00985154_caseD_4: - local_24 = 0xd8; - default: - break; - } - goto switchD_0098532f_default; - case 9: -switchD_00985106_caseD_9: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(2); - if (uVar8 == 0) { - local_24 = 0x17; - enemyVariant = 1; - } - else if (uVar8 == 1) { - enemyVariant = 1; - local_24 = 0x101; - } - goto switchD_0098532f_default; - case 10: - if (g_game->_stageType == 0) goto LAB_00985444; -LAB_0098519e: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(3); - if (uVar8 != 0) { - if (uVar8 == 1) { - local_24 = 0x4f; - } - else if (uVar8 == 2) { - local_24 = 0x43; - } - goto switchD_0098532f_default; - } - break; - case 0xb: - if (g_game->_stageType == 0) { -LAB_009852f0: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(2); - if (uVar8 != 0) { - if (uVar8 != 1) goto switchD_0098532f_default; - goto switchD_00985482_caseD_3; - } - goto switchD_00985482_caseD_2; - } -LAB_009851e5: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(2); - if (uVar8 != 0) { - if (uVar8 != 1) goto switchD_0098532f_default; -switchD_00985482_caseD_1: - local_24 = 0x33; - enemyVariant = 1; - goto switchD_0098532f_default; - } - break; - case 0xc: - switch(*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18))) { - case 1: - case 2: - case 3: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: - goto switchD_0098532f_caseD_0; - case 1: - goto switchD_0098532f_caseD_1; - case 2: - goto switchD_0098532f_caseD_2; - case 3: - goto switchD_0098532f_caseD_3; - case 4: - goto switchD_0098532f_caseD_4; - case 5: - goto switchD_0098532f_caseD_5; - default: - goto switchD_0098532f_default; - } - case 4: - case 5: - case 6: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: - goto switchD_0098532f_caseD_4; - case 1: - goto switchD_00985120_caseD_1; - case 2: - goto switchD_00985120_caseD_2; - case 3: - goto switchD_00985120_caseD_3; - case 4: - goto switchD_00985120_caseD_4; - case 5: - goto switchD_00985120_caseD_5; - default: - goto switchD_0098532f_default; - } - case 7: - case 8: - case 9: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(6); - switch(uVar8) { - case 0: - goto switchD_0098513a_caseD_0; - case 1: - goto switchD_0098513a_caseD_1; - case 2: - goto switchD_0098513a_caseD_2; - case 3: - goto switchD_0098513a_caseD_3; - case 4: - goto switchD_0098513a_caseD_4; - case 5: - goto switchD_0098513a_caseD_5; - default: - goto switchD_0098532f_default; - } - case 10: - case 0xb: - case 0xc: - uVar8 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(5); - switch(uVar8) { - case 0: - goto switchD_00985154_caseD_0; - case 1: - goto switchD_00985154_caseD_1; - case 2: - goto switchD_00985154_caseD_2; - case 3: - goto switchD_00985154_caseD_3; - case 4: - goto switchD_00985154_caseD_4; - default: - goto switchD_0098532f_default; - } - case 0xd: - goto switchD_00985106_caseD_9; - case 0xe: - goto switchD_00985342_caseD_5; - case 0xf: - goto LAB_0098519e; - default: - goto LAB_009852f0; - case 0x11: - goto LAB_009851e5; - } - } -switchD_00985482_caseD_0: - local_24 = 0x14; - } -switchD_0098532f_default: - spawnPositions = GHIDRA_CAST(0x0); - positionsEnd = GHIDRA_CAST(0x0); - spawnPositionsEnd = GHIDRA_CAST(0x0); - spawnPositionsCapacity = GHIDRA_CAST(0x0); - local_14 = 0x2e; - pvVar6 = (void *)(GHIDRA_INT(g_game->_room) + 0x724); - local_2c = GHIDRA_CAST(0x0); - positionsCapacity = GHIDRA_CAST(0x0); - local_30 = pvVar6; - do { - targetRoomType = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + GHIDRA_INT(local_2c) * 4)); - if (targetRoomType != 0) { - targetRoomType = *GHIDRA_CAST((targetRoomType + 0x24)); - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_44.x = (float)(targetRoomType % iVar7) * 40.0 + 40.0; - local_44.y = (float)(targetRoomType / iVar7) * 40.0 + 120.0; - local_38 = (void *)local_44.x; - local_34 = local_44.y; - player = Game::GetNearestPlayer(g_game,&local_44); - fVar5 = local_34 - (player->_pos).y; - fVar9 = (float)local_38 - (player->_pos).x; - pvVar6 = local_30; - if (6400.0 < fVar5 * fVar5 + fVar9 * fVar9) { - targetRoomType = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(local_30) + GHIDRA_INT(local_2c) * 4)) + 0x24)); - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_60.x = (float)(targetRoomType % iVar7) * 40.0 + 40.0; - local_60.y = (float)(targetRoomType / iVar7) * 40.0 + 120.0; - if (positionsEnd == positionsCapacity) { - msvc::vector::_Emplace_reallocate(positionsEnd,&local_60); - positionsCapacity = spawnPositionsCapacity; - } - else { - *positionsEnd = local_60.x; - positionsEnd[1] = local_60.y; - spawnPositionsEnd = positionsEnd + 2; - } - pvVar6 = local_30; - positionsEnd = spawnPositionsEnd; - } - } - uVar8 = local_24; - local_2c = GHIDRA_CAST((GHIDRA_INT(local_2c) + 1)); - } while (local_2c < 8); - local_2c = positionsCapacity; - if (spawnPositions == positionsEnd) { - tmpPos = Room::GetCenterPos(&local_60); - if (positionsEnd == local_2c) { - msvc::vector::_Emplace_reallocate(positionsEnd,tmpPos); - local_2c = spawnPositionsCapacity; - positionsEnd = spawnPositionsEnd; - } - else { - fVar5 = tmpPos->y; - *positionsEnd = tmpPos->x; - positionsEnd[1] = fVar5; - spawnPositionsEnd = positionsEnd + 2; - positionsEnd = spawnPositionsEnd; - } - } - (GHIDRA_CAST((&rng)))->RNG::Next(); - local_24 = rng._seed & 3; - local_44.y = (float)(GHIDRA_INT(local_3c) + local_24); - local_30 = (void *)rng._seed; - if (GHIDRA_INT(local_24) < GHIDRA_INT(local_44.y)) { - do { - if (local_30 == (void *)0x0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - rngValue = GHIDRA_UINT(local_30) >> ((uint8_t)rng._shift1 & 0x1f) ^ GHIDRA_UINT(local_30); - rngValue = rngValue << ((uint8_t)rng._shift2 & 0x1f) ^ rngValue; - local_30 = (void *)(rngValue >> ((uint8_t)rng._shift3 & 0x1f) ^ rngValue); - tmpPos = Room::FindFreePickupSpawnPosition - (g_game->_room,&local_68, - (Vector *) - (spawnPositions + - (local_24 % GHIDRA_UINT((GHIDRA_INT(positionsEnd) - GHIDRA_INT(spawnPositions) >> 3))) * 2),0.0 - ,0,0,0); - rngValue = Random(); - local_34 = (float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * - 2.3283064e-10 * 3.14; - local_34 = local_34 + local_34; - rngValue = Random(); - local_38 = (void *)((float)((double)GHIDRA_INT(rngValue) + - __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * 2.3283064e-10); - fVar5 = sin(local_34); - local_3c = fVar5 * (float)local_38 * 20.0 + tmpPos->y; - fVar5 = cos(local_34); - local_60.x = fVar5 * (float)local_38 * 20.0 + tmpPos->x; - local_60.y = local_3c; - Game::Spawn(g_game,uVar8,enemyVariant,&local_60,&g_vectorZero,GHIDRA_CAST(0x0),0,GHIDRA_UINT(local_30)); - local_24 = local_24 + 1; - positionsEnd = spawnPositionsEnd; - } while (GHIDRA_INT(local_24) < GHIDRA_INT(local_44.y)); - } - pvVar6 = g_game->_room; - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x12c4)) + *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0x12c0)); - targetRoomType = 0; - if (0 < iVar7) { - targetRoomType = iVar7; - } - if (GHIDRA_INT(local_4c.y) < targetRoomType) { - local_30 = (void *)0x0; - targetRoomType = 0x724; - game = g_game; - do { - local_30 = (void *)(GHIDRA_INT(local_30) + 1); - if (local_30 < (void *)0x9) { - door = *GHIDRA_CAST((targetRoomType + GHIDRA_INT(game->_room))); - if ((door != GHIDRA_CAST(0x0)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((door)) + 0xc)))) != 1)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((door)) + 0xc)))) = 1; - (GHIDRA_CAST((door)))->GridEntity_Door::UpdateAnimation(); - iVar7 = door->_currentRoomType; - if (((iVar7 == 7) || - (((targetRoomType = door->_targetRoomType, targetRoomType == 7 || (iVar7 == 8)) || - (targetRoomType == 8)))) || ((iVar7 == 0x1d || (targetRoomType == 0x1d)))) { - (GHIDRA_CAST(((door->_openAnimation)._buf)))->msvc::string::assign(s_Open,4); - } - game = g_game; - } - } - targetRoomType = targetRoomType + 4; - } while (targetRoomType < 0x744); - if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 4)) + 0x44)) & 1) != 0) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(game),game->_currentRoomIdx,-1); - game = g_game; - roomDesc->Flags = roomDesc->Flags | 0x80; - } - roomFlags = GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 4)) + 0x44)); - *roomFlags = *roomFlags & 0xfffffffe; - pvVar6 = game->_room; - } - if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 4)) + 0x44)) & 1) == 0) { - *GHIDRA_CAST((GHIDRA_CAST(local_58.y) + 0xc)) = 4; - } - if (spawnPositions == GHIDRA_CAST(0x0)) { - ExceptionList = local_1c; - return; - } - deallocate(spawnPositions,GHIDRA_INT(local_2c) - GHIDRA_INT(spawnPositions) >> 3); - ExceptionList = local_1c; - return; -} - -// 00985f00 -void GridEntity_PressurePlate::BeginBatches() -{ - uint8_t bVar1; - int iVar2; - uint8_t *curAnimName; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - uint8_t extraout_CL_01; - uint8_t extraout_CL_02; - uint8_t extraout_CL_03; - uint8_t extraout_CL_04; - uint8_t extraout_CL_05; - uint8_t extraout_CL_06; - char *freeBlock; - uint8_t *expectedAnimName; - uint32_t uVar3; - bool isLess; - std_string gfxPath; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - uint8_t *animData; - - local_8 = 0xffffffff; - puStack_c = &LAB_00b0cee5; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&gfxPath)[1]._size); - ExceptionList = &local_10; - gfxPath._size = 0; - gfxPath._capacity = 0xf; - gfxPath._buf[0] = '\0'; - gfxPath._buf[1] = '\0'; - gfxPath._buf[2] = '\0'; - gfxPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) = msvc::_Allocate(0x30); - gfxPath._size = 0x20; - gfxPath._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))),"gfx/grid/grid_pressureplate.anm2",0x21); - local_8 = 0; - ANM2::Load(&this->_sprite,&gfxPath,0); - local_8 = 0xffffffff; - bVar1 = extraout_CL; - if (0xf < gfxPath._capacity) { - uVar3 = gfxPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + -4)); - uVar3 = gfxPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(freeBlock,uVar3); - bVar1 = extraout_CL_00; - } - this->_nextGreedAnimation = &s_empty; - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))))) { - case 0: - (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) = msvc::_Allocate(0x30); - gfxPath._size = 0x26; - gfxPath._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))),"gfx/grid/grid_pressureplate_silver.png",0x27); - local_8 = 1; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(0,&gfxPath); - local_8 = 0xffffffff; - bVar1 = extraout_CL_01; - if (0xf < gfxPath._capacity) { - uVar3 = gfxPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + -4)); - uVar3 = gfxPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) goto LAB_0098631e; - } - operator_delete(freeBlock,uVar3); - bVar1 = extraout_CL_02; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x11ec)) = 10; - } - break; - case 2: - gfxPath._size = 0; - gfxPath._capacity = 0xf; - gfxPath._buf[0] = '\0'; - gfxPath._buf[1] = '\0'; - gfxPath._buf[2] = '\0'; - gfxPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - gfxPath._size = 0x18; - gfxPath._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))),"gfx/grid/TimerPlate.anm2",0x19); - local_8 = 2; - ANM2::Load(&this->_timerPlate,&gfxPath,1); - local_8 = 0xffffffff; - if (0xf < gfxPath._capacity) { - uVar3 = gfxPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + -4)); - uVar3 = gfxPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(freeBlock,uVar3); - } - ANM2::Play(&this->_timerPlate,s_Idle,0); - bVar1 = extraout_CL_03; - break; - case 3: - (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))),"gfx/grid/grid_button_rail.png",0x1e); - local_8 = 3; - goto LAB_009861b7; - case 9: - (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))),"gfx/grid/grid_button_kill.png",0x1e); - local_8 = 4; -LAB_009861b7: - gfxPath._capacity = 0x1f; - gfxPath._size = 0x1d; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(0,&gfxPath); - local_8 = 0xffffffff; - bVar1 = extraout_CL_04; - if (0xf < gfxPath._capacity) { - uVar3 = gfxPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + -4)); - iVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) - GHIDRA_INT(freeBlock); -joined_r0x00986318: - uVar3 = gfxPath._capacity + 0x24; - if (0x1f < iVar2 - 4U) { -LAB_0098631e: - local_8 = 0xffffffff; - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } -LAB_009861f6: - local_8 = 0xffffffff; - operator_delete(freeBlock,uVar3); - bVar1 = extraout_CL_05; - } - break; - case 10: - case 0xb: - case 0xc: - case 0xd: - (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - gfxPath._size = 0x1f; - gfxPath._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))),"gfx/grid/grid_button_output.png",0x20); - local_8 = 5; - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(0,&gfxPath); - local_8 = 0xffffffff; - bVar1 = extraout_CL_06; - if (gfxPath._capacity < 0x10) break; - uVar3 = gfxPath._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(gfxPath._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) + -4)); - iVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(gfxPath._buf)) + 0x0))) - GHIDRA_INT(freeBlock); - goto joined_r0x00986318; - } - goto LAB_009861f6; - } - ANM2::LoadGraphics(&this->_sprite,bVar1); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2) { - update_greed_button_anim(this,0); - play_pending_animation(this); - } - else { - iVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if (iVar2 == 0) { - ANM2::Play(&this->_sprite,&DAT_00b7cf20,0); - } - else if ((iVar2 == 3) || (iVar2 == 4)) { - animData = (this->_sprite)._animState._animData; - if (animData != GHIDRA_CAST(0x0)) { - curAnimName = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - curAnimName = *GHIDRA_CAST(animData); - } - expectedAnimName = &DAT_00b7cf1c; - do { - bVar1 = *curAnimName; - isLess = bVar1 < *expectedAnimName; - if (bVar1 != *expectedAnimName) { -LAB_00986374: - uVar3 = -GHIDRA_UINT(isLess) | 1; - goto LAB_00986379; - } - if (bVar1 == 0) break; - bVar1 = curAnimName[1]; - isLess = bVar1 < expectedAnimName[1]; - if (bVar1 != expectedAnimName[1]) goto LAB_00986374; - curAnimName = curAnimName + 2; - expectedAnimName = expectedAnimName + 2; - } while (bVar1 != 0); - uVar3 = 0; -LAB_00986379: - if ((uVar3 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_009863c1; - } - bVar1 = ANM2::SetAnimation(&this->_sprite,&DAT_00b7cf1c,1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - } -LAB_009863c1: - (this->_greedModeRNG)._seed = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - (this->_greedModeRNG)._shift1 = 4; - (this->_greedModeRNG)._shift2 = 3; - (this->_greedModeRNG)._shift3 = 0x1b; - ExceptionList = local_10; - return; -} diff --git a/generated-src/grid_entity_rock.cpp b/generated-src/grid_entity_rock.cpp deleted file mode 100644 index 811cdd3..0000000 --- a/generated-src/grid_entity_rock.cpp +++ /dev/null @@ -1,1429 +0,0 @@ -#include "classes.h" - -// 005cd820 -uint8_t * GridEntity_Rock::GetRubbleAnim() -{ - std_string *rubbleAnim; - - rubbleAnim = &this->_rubbleAnim; - if (0xf < (this->_rubbleAnim)._capacity) { - rubbleAnim = *GHIDRA_CAST(rubbleAnim->_buf); - } - return GHIDRA_CAST(rubbleAnim); -} - -// 00718f80 -void GridEntity_Rock::update_collision() -{ - int iVar1; - Game *game; - - game = g_game; - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if ((iVar1 == 1) || (iVar1 == 4)) { - this->_collisionClass = 3; - iVar1 = this->_collisionClass; - if (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) { - iVar1 = 4; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x18) { - iVar1 = 4; - } - this->_collisionClass = iVar1; - } - else { - if (iVar1 == 2) { - this->_collisionClass = 0; - return; - } - if (iVar1 == 3) { - this->_collisionClass = 3; - return; - } - } - return; -} - -// 00718fe0 -void GridEntity_Rock::Update() -{ - Entity *ent; - uint8_t bVar1; - uint32_t uVar2; - Entity_Player *pEVar3; - int iVar4; - void *collectibleEffect; - Entity_Player **ppEVar5; - ColorMod *extraout_EAX; - ColorMod *color; - EntityRef *sourceRef; - RoomDescriptor *roomDesc; - float *collisionPoint; - int iVar6; - Entity_Player **ppEVar7; - code *extraout_EDX; - code *extraout_EDX_00; - uint32_t uVar8; - Game *game; - float fVar9; - float fVar10; - uint8_t local_90 [8]; - float fStack_88; - float fStack_84; - float local_80; - float fStack_7c; - float fStack_78; - float fStack_74; - float local_70; - float local_6c; - float local_68; - Vector rockPos; - Vector spawnPos; - Entity_Player *local_50 [4]; - Color local_40; - uint32_t stackCookie; - void *local_10; - uint8_t *puStack_c; - float local_8; - Manager *manager; - Room *room; - - local_8 = -NAN; - puStack_c = &LAB_00afcb3d; - local_10 = ExceptionList; - uVar2 = __security_cookie ^ GHIDRA_UINT((&local_40)[1]._colorize); - ExceptionList = &local_10; - iVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - game = g_game; - stackCookie = uVar2; - if ((iVar4 == 4) || (iVar4 == 0x16)) { -LAB_0071905d: - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 2) { - local_50[2] = GHIDRA_CAST(0x0); - local_50[3] = GHIDRA_CAST(0x0); - bVar1 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x3e); - if (bVar1 != 0) { - if (1 < *GHIDRA_CAST(&g_game->_deathmatchManager)) { - pEVar3 = GHIDRA_CAST(FUN_0090b0e0(uVar2)); - local_50[3] = GHIDRA_CAST(0x0); - bVar1 = Entity_Player::HasTrinket(pEVar3,0x3e,0); - if (bVar1 == 0) goto LAB_007191ab; - } - iVar6 = 300; - iVar4 = PlayerManager::GetTrinketMultiplier(&g_game->_playerManager,0x3e); - manager = g_manager; - if (2 < iVar4) { - iVar6 = 0x96; - } - if (*GHIDRA_CAST(g_game->_room) == '\0') { - iVar4 = -1; - } - else { - iVar4 = g_game->_frameCount - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x11f0)); - } - local_50[1] = GHIDRA_CAST((iVar4 % iVar6)); - local_50[3] = GHIDRA_CAST(0x0); - if (GHIDRA_INT(local_50[1]) < 0xb) { - if (local_50[1] == GHIDRA_CAST(0x0)) { - local_50[3] = GHIDRA_CAST(0x3f6); - seed_fart_sound_override(GHIDRA_CAST((local_50 + 3))); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_50[3]),1.0,2,0,1.0,0.0); - } - uVar2 = GHIDRA_INT((GHIDRA_INT(local_50[1]) - 5U)) >> 0x1f; - local_50[2] = (Entity_Player *) - (1.0 - (float)GHIDRA_INT(((GHIDRA_INT(local_50[1]) - 5U ^ uVar2) - uVar2)) / 5.0); - local_50[3] = local_50[2]; - } - } -LAB_007191ab: - game = g_game; - collectibleEffect = - TemporaryEffects::GetCollectibleEffect - (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x7310)),0x11f); - if (collectibleEffect == (void *)0x0) { - pEVar3 = local_50[3]; - } - else { - local_50[0] = GHIDRA_CAST(0x3f800000); - local_50[1] = GHIDRA_CAST(((float)*GHIDRA_CAST((GHIDRA_CAST(collectibleEffect) + 8)) / 30.0)); - ppEVar7 = local_50 + 1; - if (1.0 <= (float)local_50[1]) { - ppEVar7 = local_50; - } - ppEVar5 = local_50 + 2; - if ((float)local_50[3] < (float)*ppEVar7) { - ppEVar5 = ppEVar7; - } - pEVar3 = *ppEVar5; - } - if ((float)pEVar3 <= 0.0) { - if ((this->_sprite)._color._offset[0] == 0.0) goto LAB_0071926c; - (GHIDRA_CAST((&local_40)))->Color::Color(); - color = extraout_EAX; - } - else { - local_70 = (float)pEVar3 * 0.3; - color = GHIDRA_CAST(local_90); - local_80 = 0.0; - fStack_7c = 0.0; - fStack_78 = 0.0; - fStack_74 = 0.0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_90)) + 0x0))) = 1.0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_90)) + 0x4))) = 1.0; - fStack_88 = 1.0; - fStack_84 = 1.0; - local_6c = local_70; - local_68 = local_70; - } - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::SetColor(color); - } - } - else { - if ((g_game->_levelStateFlags & 0x2000U) == 0) { - iVar6 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x768)); - } - else { - iVar6 = -1; - } - if (((iVar6 == this->_gridIndex) && (iVar4 != 3)) && (iVar4 != 0x18)) goto LAB_0071905d; - } -LAB_0071926c: - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - game = g_game; - } - iVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if ((iVar4 == 1) || (iVar4 == 4)) { - iVar4 = this->_varData; - if (iVar4 != 0) { - if (iVar4 == 10) { - this->_varData = 1; - uVar2 = Random(); - iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - spawnPos.x = (float)(this->_gridIndex % iVar4) * 40.0 + 40.0; - spawnPos.y = (float)(this->_gridIndex / iVar4) * 40.0 + 120.0; - Game::Spawn(g_game,1000,0xf,&spawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar2); - sourceRef = EntityRef::EntityRef(GHIDRA_CAST((local_90 + 4))); - (*extraout_EDX_00)(1,sourceRef); - game = g_game; - } - else if (10 < iVar4) { - this->_varData = iVar4 + -1; - } - } - if (game->_frameCount % 0xf != 0) goto LAB_00719576; - uVar2 = Random(); - game = g_game; - if (uVar2 % 100 == 0) { - iVar6 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c0)) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c4)); - iVar4 = 0; - if (0 < iVar6) { - iVar4 = iVar6; - } - if (iVar4 < 1) goto LAB_00719576; - uVar2 = Random(); - local_50[3] = PlayerManager::RandomCollectibleOwner - (&game->_playerManager,0x2cd,uVar2,GHIDRA_CAST(0x0)); - if (local_50[3] != GHIDRA_CAST(0x0)) { - (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&rockPos); - game = g_game; - uVar2 = 0; - local_40._tint[3] = -26.0; - local_40._colorize[0] = 0.0; - local_40._colorize[1] = 26.0; - local_40._colorize[2] = 0.0; - local_40._colorize[3] = 0.0; - local_40._offset[0] = -26.0; - local_40._offset[1] = 0.0; - local_40._offset[2] = 26.0; - spawnPos.x = g_vectorZero.x; - spawnPos.y = g_vectorZero.y; - local_50[2] = GHIDRA_CAST(0x49742400); - do { - local_50[0] = GHIDRA_CAST((rockPos.x + local_40._tint[uVar2 * 2 + 3])); - local_50[1] = GHIDRA_CAST((rockPos.y + local_40._colorize[uVar2 * 2])); - room = game->_room; - iVar6 = GHIDRA_INT((((float)local_50[0] - 40.0) / 40.0 + 0.5)); - iVar4 = GHIDRA_INT((((float)local_50[1] - 120.0) / 40.0 + 0.5)); - if (((iVar6 < 0) || (room->_gridWidth <= iVar6)) || - ((iVar4 < 0 || (room->_gridHeight <= iVar4)))) { - iVar6 = -1; - } - else { - iVar6 = iVar4 * room->_gridWidth + iVar6; - } - uVar8 = Room::GetGridCollision(room,iVar6); - if ((uVar8 == 0) && - (fVar9 = (local_50[3]->_pos).x - (float)local_50[0], - fVar10 = (local_50[3]->_pos).y - (float)local_50[1], - pEVar3 = GHIDRA_CAST((fVar10 * fVar10 + fVar9 * fVar9)), - (float)pEVar3 < (float)local_50[2])) { - local_50[2] = pEVar3; - spawnPos.x = (float)local_50[0]; - spawnPos.y = (float)local_50[1]; - } - uVar2 = uVar2 + 1; - } while (uVar2 < 4); - if ((spawnPos.x == g_vectorZero.x) && (spawnPos.y == g_vectorZero.y)) goto LAB_00719576; - Entity_Player::AddBlueSpider(local_50[3],&spawnPos); - } - } - } - else { - if (iVar4 != 3) goto LAB_00719576; - iVar4 = this->_frameCnt; - this->_frameCnt = iVar4 + -1; - if (0 < iVar4) goto LAB_00719576; - sourceRef = EntityRef::EntityRef(GHIDRA_CAST((local_90 + 4))); - (*extraout_EDX)(0,sourceRef); - } - game = g_game; -LAB_00719576: - update_collision(this); - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x19)) { - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(game),game->_currentRoomIdx,game->_currentDimensionIdx); - if (((GHIDRA_UINT(roomDesc->Flags) >> 1 & 1) == 0) && - (bVar1 = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x97), bVar1 == 0)) { - iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - rockPos.x = (float)(this->_gridIndex % iVar4) * 40.0 + 40.0; - rockPos.y = (float)(this->_gridIndex / iVar4) * 40.0 + 120.0; - local_50[0] = GHIDRA_CAST(rockPos.x); - local_50[1] = GHIDRA_CAST(rockPos.y); - EntityList::QueryRadius - (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)), - GHIDRA_CAST((local_40._colorize + 3)),&rockPos,80.0,0xffffffff); - local_8 = 0.0; - local_50[2] = GHIDRA_CAST(0x0); - if (local_40._offset[2] != 0.0) { - do { - ent = *GHIDRA_CAST((GHIDRA_INT(local_40._offset[0]) + GHIDRA_INT(local_50[2]) * 4)); - if (ent->_entityCollisionClass != 0) { - if ((ent->_type == 1) || (ent->_type == 3)) { - fVar9 = 21.0; - } - else { - fVar9 = 25.0; - } - uVar2 = 0; - collisionPoint = (ent->_collisionPoints)._begin; - uVar8 = GHIDRA_INT((ent->_collisionPoints)._end) - GHIDRA_INT(collisionPoint) >> 3; - if (uVar8 != 0) { - do { - if ((ABS(((ent->_pos).x + *collisionPoint) - (float)local_50[0]) <= fVar9) && - (ABS(((ent->_pos).y + collisionPoint[1]) - (float)local_50[1]) <= fVar9)) { - if (*GHIDRA_CAST(&g_game->_deathmatchManager) < 2) { - fVar9 = 16.0; - } - else { - fVar9 = 4.0; - } - GridEntity::hurt_func(GHIDRA_CAST(this),ent,fVar9,1,0,1); - break; - } - uVar2 = uVar2 + 1; - collisionPoint = collisionPoint + 2; - } while (uVar2 < uVar8); - } - } - local_50[2] = GHIDRA_CAST((GHIDRA_INT(local_50[2]) + 1)); - } while (local_50[2] < GHIDRA_UINT(local_40._offset[2])); - } - if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_40._colorize[3])) + 0x0))) == '\0') { - local_8 = 1.4013e-45; - tracked_alloc(1,(void *)local_40._offset[0],0); - } - } - else { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 4; - (GHIDRA_CAST(((this->_anim)._buf)))->msvc::string::assign(GHIDRA_CAST("spiked_retracted"),0x10); - (GHIDRA_CAST(((this->_rubbleAnim)._buf)))->msvc::string::assign(GHIDRA_CAST("rubble"),6); - UpdateAnimFrame(this); - } - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x194)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - ExceptionList = local_10; - return; -} - -// 00719dd0 -void GridEntity_Rock::RenderTop(Vector *pos) -{ - void *pvVar1; - ANM2 *animation; - Vector *renderPos; - LayerState *topLayer; - Vector drawPos; - float savedOffsetXY [2]; - Color roomColor; - ColorMod savedColor; - Vector renderPosBuf; - float local_58; - float fStack_54; - float fStack_50; - float fStack_4c; - float local_48; - float fStack_44; - float fStack_40; - float fStack_3c; - ColorMod local_34; - int layerIndex; - float savedOffsetZ; - ColorMod *spriteColor; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 2) { - renderPos = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::get_render_position(&renderPosBuf); - drawPos.x = renderPos->x + pos->x; - drawPos.y = renderPos->y + pos->y; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x18) { - savedColor._tint[0] = (this->_sprite)._color._tint[0]; - savedColor._tint[1] = (this->_sprite)._color._tint[1]; - savedColor._tint[2] = (this->_sprite)._color._tint[2]; - savedColor._tint[3] = (this->_sprite)._color._tint[3]; - savedOffsetZ = (this->_sprite)._color._offset[2]; - spriteColor = &(this->_sprite)._color; - pvVar1 = g_game->_room; - savedColor._colorize[0] = (this->_sprite)._color._colorize[0]; - savedColor._colorize[1] = (this->_sprite)._color._colorize[1]; - savedColor._colorize[2] = (this->_sprite)._color._colorize[2]; - savedColor._colorize[3] = (this->_sprite)._color._colorize[3]; - savedOffsetXY = *(float (*) [2])(this->_sprite)._color._offset; - roomColor._tint[0] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72a4)); - roomColor._tint[1] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72a8)); - roomColor._tint[2] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72ac)); - roomColor._tint[3] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72b0)); - roomColor._colorize[0] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72b4)); - roomColor._colorize[1] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72b8)); - roomColor._colorize[2] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72bc)); - roomColor._colorize[3] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72c0)); - (*GHIDRA_CAST((GHIDRA_CAST(&(roomColor._offset)) + 0x0))) = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72c4)); - roomColor._offset[2] = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x72cc)); - (*GHIDRA_CAST((GHIDRA_CAST(&(savedColor._offset)) + 0x0))) = savedOffsetXY; - savedColor._offset[2] = savedOffsetZ; - local_58 = savedColor._tint[0]; - fStack_54 = savedColor._tint[1]; - fStack_50 = savedColor._tint[2]; - fStack_4c = savedColor._tint[3]; - local_48 = savedColor._colorize[0]; - fStack_44 = savedColor._colorize[1]; - fStack_40 = savedColor._colorize[2]; - fStack_3c = savedColor._colorize[3]; - (GHIDRA_CAST((&roomColor)))->Color::__mul(&savedColor); - if (spriteColor != &local_34) { - spriteColor->_tint[0] = roomColor._tint[0]; - (this->_sprite)._color._tint[1] = roomColor._tint[1]; - (this->_sprite)._color._tint[2] = roomColor._tint[2]; - (this->_sprite)._color._tint[3] = roomColor._tint[3]; - (this->_sprite)._color._colorize[0] = roomColor._colorize[0]; - (this->_sprite)._color._colorize[1] = roomColor._colorize[1]; - (this->_sprite)._color._colorize[2] = roomColor._colorize[2]; - (this->_sprite)._color._colorize[3] = roomColor._colorize[3]; - *GHIDRA_CAST((this->_sprite)._color._offset) = (*GHIDRA_CAST((GHIDRA_CAST(&(roomColor._offset)) + 0x0))); - (this->_sprite)._color._offset[2] = roomColor._offset[2]; - } - topLayer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x1)); - topLayer->_visible = 1; - pvVar1 = (this->_sprite)._animState._animData; - if (((pvVar1 != (void *)0x0) && - (animation = (this->_sprite)._animState._animation, 1 < animation->_layerCount)) && - (layerIndex = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x3c)), -1 < layerIndex)) { - AnimationLayer::RenderFrame - (GHIDRA_CAST((layerIndex * 0x10 + *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x18)))),&drawPos, - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._layerFrames) + layerIndex * 4)), - &g_vectorZero,&g_vectorZero,animation); - } - topLayer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x1)); - topLayer->_visible = 0; - if (spriteColor != &savedColor) { - spriteColor->_tint[0] = local_58; - (this->_sprite)._color._tint[1] = fStack_54; - (this->_sprite)._color._tint[2] = fStack_50; - (this->_sprite)._color._tint[3] = fStack_4c; - (this->_sprite)._color._colorize[0] = local_48; - (this->_sprite)._color._colorize[1] = fStack_44; - (this->_sprite)._color._colorize[2] = fStack_40; - (this->_sprite)._color._colorize[3] = fStack_3c; - *(float (*) [2])(this->_sprite)._color._offset = savedOffsetXY; - (this->_sprite)._color._offset[2] = savedOffsetZ; - } - } - } - return; -} - -// 00719f80 -void GridEntity_Rock::BeginBatches() -{ - code *pcVar1; - bool bVar2; - uint8_t bVar3; - int iVar4; - uint32_t uVar5; - char *pcVar6; - LayerState *layer; - std_string *animName; - void *pvVar7; - uint8_t extraout_CL; - int iVar8; - uint32_t gridPathValue; - uint32_t uVar9; - uint32_t uVar10; - float fVar11; - double dVar12; - uint64_t rngShift12; - Vector rubbleOffset; - uint32_t local_4c; - int local_48; - std_string anm2Path; - uint32_t stackCookie; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - Game *game; - float *rubbleOffsetSlot; - void **rubbleOffsetsEnd; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afcb7d; - local_10 = ExceptionList; - stackCookie = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size); - ExceptionList = &local_10; - (GHIDRA_CAST(((this->_anim)._buf)))->msvc::string::assign(GHIDRA_CAST("normal"),6); - (GHIDRA_CAST(((this->_rubbleAnim)._buf)))->msvc::string::assign(GHIDRA_CAST("rubble"),6); - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x17; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/grid_rock.anm2",0x18); - local_8 = 0; - ANM2::Load(&this->_sprite,&anm2Path,0); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar9 = anm2Path._capacity + 1; - pcVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar9) { - pcVar6 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar9 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar6))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar6,uVar9); - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - iVar8 = GHIDRA_INT(g_game->_room) + 0x1bc8; - iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)) * 0x13c + 0x154 + iVar8; - if (g_game->_challenge == 0x2d) { - uVar9 = g_game->_dungeonPlacementSeed; - uVar10 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - rngShift12 = 0x700000002; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_48)) + 0x0))) = 0x19; - if (uVar10 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar5 = uVar10 >> 2 ^ uVar10; - uVar5 = uVar5 << 7 ^ uVar5; - if ((uVar5 >> 0x19 ^ uVar5) % 10 == 0) { - rngShift12 = 0x900000005; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_48)) + 0x0))) = 7; - uVar9 = uVar10; - } - if (uVar9 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar9 = uVar9 >> (sbyte)rngShift12 ^ uVar9; - uVar9 = uVar9 << (sbyte)((uint64_t)rngShift12 >> 0x20) ^ uVar9; - iVar8 = GHIDRA_INT(g_game->_room) + ((uVar9 >> (sbyte)local_48 ^ uVar9) % 0x3e) * 0x13c + 0x1e58; - if ((iVar8 != 0) && (*GHIDRA_CAST((iVar8 + 0xa0)) != 0)) { - iVar4 = iVar8; - } - } - bVar3 = (uint8_t)iVar8; - if ((this->_sprite)._layerCount != 0) { - uVar9 = 0; - do { - (GHIDRA_CAST((GHIDRA_CAST(&this->_sprite))))->Sprite::ReplaceSpritesheet(uVar9,GHIDRA_CAST((iVar4 + 0x90))); - uVar9 = uVar9 + 1; - bVar3 = extraout_CL; - } while (uVar9 < GHIDRA_UINT((this->_sprite)._layerCount)); - } - animName = &this->_anim; - ANM2::LoadGraphics(&this->_sprite,bVar3); - local_48 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - bVar2 = false; - if (local_48 == 0) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 10000) { - this->_varData = 1; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 0; - } - bVar2 = true; - local_48 = 1; - } - iVar4 = this->_gridIndex; - if ((-1 < iVar4) && (iVar4 < 0x1c0)) { - gridPathValue = 0; - if (local_48 == 1) { - gridPathValue = 1000; - } - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + iVar4 * 4 + 0x76c)) = gridPathValue; - local_48 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - } - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4))))) { - case 3: - pcVar6 = "black"; - uVar9 = 5; - break; - case 4: - pcVar6 = "tinted"; - uVar9 = 6; - break; - case 5: - (GHIDRA_CAST((animName->_buf)))->msvc::string::assign(GHIDRA_CAST("bombrock"),8); - this->_frameCnt = GHIDRA_UINT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1)) * 4 + -1; - goto LAB_0071a3d7; - case 6: - (GHIDRA_CAST((animName->_buf)))->msvc::string::assign(&DAT_00b66e44,3); - pcVar6 = "rubble_alt"; - uVar9 = 10; - animName = &this->_rubbleAnim; - break; - default: - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) < 1000) || (GHIDRA_INT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) - 1000)) < 0)) - goto LAB_0071a3d7; - pcVar6 = &DAT_00b69228; - uVar9 = 3; - break; - case 0x16: - uVar9 = 9; - if (local_48 != 4) { - uVar9 = 0xc; - } - pcVar6 = "superspecial"; - if (local_48 == 4) { - pcVar6 = "ss_broken"; - } - break; - case 0x18: - (GHIDRA_CAST((animName->_buf)))->msvc::string::assign(GHIDRA_CAST("pillar"),6); - layer = ANM2::GetLayer(&this->_sprite,GHIDRA_CAST(0x1)); - layer->_visible = 0; - goto LAB_0071a3d7; - case 0x19: - uVar10 = 0x10; - uVar9 = 6; - if (local_48 != 4) { - uVar10 = 6; - } - pcVar6 = "spiked"; - if (local_48 == 4) { - pcVar6 = "spiked_retracted"; - } - (GHIDRA_CAST(((this->_anim)._buf)))->msvc::string::assign(GHIDRA_CAST(pcVar6),uVar10); - if (local_48 != 4) { - uVar9 = 0xd; - } - pcVar6 = "rubble_spiked"; - if (local_48 == 4) { - pcVar6 = "rubble"; - } - animName = &this->_rubbleAnim; - break; - case 0x1a: - (GHIDRA_CAST((animName->_buf)))->msvc::string::assign(&DAT_00b69144,4); - pcVar6 = "rubble_alt"; - uVar9 = 10; - animName = &this->_rubbleAnim; - break; - case 0x1b: - pcVar6 = "foolsgold"; - uVar9 = 9; - } - (GHIDRA_CAST((animName->_buf)))->msvc::string::assign(GHIDRA_CAST(pcVar6),uVar9); -LAB_0071a3d7: - animName = &this->_anim; - if (bVar2) { - if (0xf < (this->_anim)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - pvVar7 = ANM2::GetAnimationData(&this->_sprite,GHIDRA_CAST(animName)); - if (pvVar7 == (void *)0x0) { - KAGE_LogMessage(1,GHIDRA_CAST("[warn] GridEntityRock animation %s is NULL\n")); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 0; - } - else { - iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)); - if (iVar4 == 0) { - iVar4 = 0; - } - else { - iVar4 = *GHIDRA_CAST((iVar4 + 0x58)); - } - uVar9 = this->_gridIndex + iVar4; - uVar9 = uVar9 >> 5 ^ (uVar9 | 1); - uVar9 = uVar9 << 9 ^ uVar9; - uVar10 = 0; - if (*GHIDRA_CAST((GHIDRA_CAST(pvVar7) + 0x30)) != 0) { - uVar10 = (uVar9 >> 7 ^ uVar9) % *GHIDRA_CAST((GHIDRA_CAST(pvVar7) + 0x30)); - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = uVar10; - } - } - uVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - if (uVar9 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar9 = uVar9 >> 5 ^ uVar9; - uVar9 = uVar9 << 9 ^ uVar9; - uVar9 = uVar9 >> 7 ^ uVar9; - local_4c = (uVar9 & 1) + 1; - if (local_4c != 0) { - do { - if (uVar9 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar9 = uVar9 >> 5 ^ uVar9; - uVar9 = uVar9 << 9 ^ uVar9; - uVar9 = uVar9 >> 7 ^ uVar9; - dVar12 = floor((double)((float)((double)GHIDRA_INT(uVar9) + - __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283062e-10 * 16.0)); - fVar11 = 8.0 - (float)dVar12; - if (uVar9 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - (*pcVar1)(); - return; - } - uVar9 = uVar9 >> 5 ^ uVar9; - uVar9 = uVar9 << 9 ^ uVar9; - uVar9 = uVar9 >> 7 ^ uVar9; - dVar12 = floor((double)((float)((double)GHIDRA_INT(uVar9) + - __uint_to_double_fixup[-(GHIDRA_INT(uVar9) >> 0x1f)]) * - 2.3283062e-10 * 16.0)); - rubbleOffsetSlot = (this->_rubbleOffsets)._end; - rubbleOffset.x = 8.0 - (float)dVar12; - rubbleOffset.y = fVar11; - if (rubbleOffsetSlot == (this->_rubbleOffsets)._capacity) { - msvc::vector::_Emplace_reallocate(rubbleOffsetSlot,&rubbleOffset); - } - else { - *rubbleOffsetSlot = rubbleOffset.x; - rubbleOffsetSlot[1] = fVar11; - rubbleOffsetsEnd = &(this->_rubbleOffsets)._end; - *rubbleOffsetsEnd = (void *)(GHIDRA_INT(*rubbleOffsetsEnd) + 8); - } - local_4c = local_4c + -1; - } while (local_4c != 0); - } - } - animName = &this->_anim; - uVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if ((uVar9 < 1000) || (local_4c = uVar9 - 1000, GHIDRA_INT((uVar9 - 1000)) < 0)) { - local_4c = uVar9; - } - if (0xf < (this->_anim)._capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - bVar3 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(animName),1); - if (((bVar3 != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)GHIDRA_INT(local_4c)), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - } - game = g_game; - iVar4 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - if ((iVar4 == 1) || (iVar4 == 4)) { - this->_collisionClass = 3; - iVar8 = this->_collisionClass; - if (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) { - iVar8 = 4; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x18) { - iVar8 = 4; - } - this->_collisionClass = iVar8; - } - else if (iVar4 == 2) { - this->_collisionClass = 0; - } - else if (iVar4 == 3) { - this->_collisionClass = 3; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x194)))) = iVar4; - ExceptionList = local_10; - return; -} - -// 0071a760 -void GridEntity_Rock::guard_check_icall() -{ - uint32_t uVar1; - uint32_t uVar2; - void *neighborGrid; - GridEntity_Rock *neighborRock; - uint32_t uVar3; - int nextRow; - RNG rng; - Room *currentRoom; - GridEntity_Rock *rock; - uint32_t neighborIndices [3]; - GridEntity_Rock *neighborRocks [3]; - GridEntity_Rock *local_8; - uint32_t bigRockFrame; - int nextColumn; - Room *room; - - local_8 = GHIDRA_CAST((__security_cookie ^ GHIDRA_UINT((neighborRocks + 4)))); - rng._shift1 = 5; - rng._shift2 = 9; - rng._seed = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - rng._shift3 = 7; - if (((((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 2) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) == 1)) && - ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) < 1000 || (GHIDRA_INT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) - 1000)) < 0)))) && - (rock = this, uVar2 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(4), uVar2 != 0)) { - currentRoom = g_game->_room; - uVar2 = GHIDRA_UINT(this->_gridIndex) / GHIDRA_UINT(currentRoom->_gridWidth); - uVar3 = GHIDRA_UINT(this->_gridIndex) % GHIDRA_UINT(currentRoom->_gridWidth); - nextColumn = uVar3 + 1; - neighborIndices[0] = Room::GetGridIndexByTile(currentRoom,nextColumn,uVar2); - nextRow = uVar2 + 1; - neighborIndices[1] = Room::GetGridIndexByTile(currentRoom,uVar3,nextRow); - room = currentRoom; - neighborIndices[2] = Room::GetGridIndexByTile(currentRoom,nextColumn,nextRow); - uVar2 = 0; - neighborRocks[0] = GHIDRA_CAST(0x0); - uVar3 = 0; - neighborRocks[1] = GHIDRA_CAST(0x0); - neighborRocks[2] = GHIDRA_CAST(0x0); - do { - uVar1 = neighborIndices[uVar3]; - if (-1 < GHIDRA_INT(uVar1)) { - if (uVar1 < 0x1c0) { - neighborGrid = room->_gridEntities[uVar1]; - } - else { - neighborGrid = (void *)0x0; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0 - ); - if (((neighborRock != GHIDRA_CAST(0x0)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((neighborRock)) + 0x4)))) == 2)) && - ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((neighborRock)) + 0x8)))) < 1000 || - (GHIDRA_INT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((neighborRock)) + 0x8)))) - 1000)) < 0)))) { - uVar2 = uVar2 | 1 << (uVar3 & 0x1f); - neighborRocks[uVar3] = neighborRock; - } - } - uVar3 = uVar3 + 1; - } while (uVar3 < 3); - if ((uVar2 == 7) && (uVar3 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(4), uVar3 != 0)) { - uVar2 = (GHIDRA_CAST((&rng)))->RNG::RandomInt(7); - uVar2 = 7 - uVar2; - } - switch(uVar2) { - case 1: - case 5: - SetBigRockFrame(rock,0); - bigRockFrame = 1; - neighborRock = neighborRocks[0]; - break; - case 2: - case 3: - case 6: - SetBigRockFrame(rock,2); - bigRockFrame = 3; - neighborRock = neighborRocks[1]; - break; - default: - goto LAB_0071a909; - case 7: - SetBigRockFrame(rock,4); - SetBigRockFrame(neighborRocks[0],5); - SetBigRockFrame(neighborRocks[1],6); - bigRockFrame = 7; - neighborRock = neighborRocks[2]; - } - SetBigRockFrame(neighborRock,bigRockFrame); - } -LAB_0071a909: - return; -} - -// 0071a940 -void GridEntity_Rock::SetBigRockFrame(uint32_t param_2) -{ - uint8_t isAnimSet; - uint32_t variant; - std_string *name; - void *animData; - int iVar1; - uint32_t frame; - std_string *anim; - RNG rng; - - anim = &this->_anim; - if (GHIDRA_INT(param_2) < 0) { - (GHIDRA_CAST((anim->_buf)))->msvc::string::assign(GHIDRA_CAST("normal"),6); - name = anim; - if (0xf < (this->_anim)._capacity) { - name = *GHIDRA_CAST(anim->_buf); - } - animData = ANM2::GetAnimationData(&this->_sprite,GHIDRA_CAST(name)); - if (animData != (void *)0x0) { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)); - if (iVar1 == 0) { - iVar1 = 0; - } - else { - iVar1 = *GHIDRA_CAST((iVar1 + 0x58)); - } - rng._seed = this->_gridIndex + iVar1 | 1; - rng._shift1 = 5; - rng._shift2 = 9; - rng._shift3 = 7; - variant = (GHIDRA_CAST((&rng)))->RNG::RandomInt(*GHIDRA_CAST((GHIDRA_CAST(animData) + 0x30))); - goto LAB_0071a9e9; - } - KAGE_LogMessage(1,GHIDRA_CAST("[warn] GridEntityRock animation %s is NULL\n")); - variant = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = 0; - } - else { - (GHIDRA_CAST((anim->_buf)))->msvc::string::assign(&DAT_00b69228,3); - if (GHIDRA_INT(param_2) < 1) { - param_2 = 0; - } - variant = 7; - if (param_2 < 7) { - variant = param_2; - } - variant = variant + 1000; -LAB_0071a9e9: - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = variant; - if ((999 < variant) && (frame = variant - 1000, -1 < GHIDRA_INT((variant - 1000)))) goto LAB_0071aa1f; - } - frame = variant; -LAB_0071aa1f: - if (0xf < (this->_anim)._capacity) { - anim = *GHIDRA_CAST(anim->_buf); - } - isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(anim),1); - if (((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)GHIDRA_INT(frame)), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - } - return; -} - -// 0071aa70 -int GridEntity_Rock::GetBigRockFrame() -{ - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) < 1000) { - return -1; - } - return *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) - 1000; -} - -// 0071aa90 -void GridEntity_Rock::UpdateAnimFrame() -{ - uint8_t isAnimSet; - std_string *anim; - uint32_t frame; - uint32_t variant; - - variant = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if ((variant < 1000) || (frame = variant - 1000, GHIDRA_INT((variant - 1000)) < 0)) { - frame = variant; - } - anim = &this->_anim; - if (0xf < (this->_anim)._capacity) { - anim = *GHIDRA_CAST(anim->_buf); - } - isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(anim),1); - if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)GHIDRA_INT(frame)); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - } - return; -} - -// 0071aaf0 -void GridEntity_Rock::UpdateNeighbors() -{ - int bigRockPart; - uint32_t row; - GridEntity_Rock *neighborRock; - uint32_t neighborGrid; - uint32_t uVar1; - uint32_t uVar2; - uint32_t rightIndex; - uint32_t upIndex; - int downRowCheck; - uint32_t upRightIndex; - int downRow; - uint32_t leftIndex; - uint32_t upLeftIndex; - uint32_t downLeftIndex; - int leftColumn; - int rightColumn; - void *room; - int upRow; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) < 1000) { - return; - } - bigRockPart = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) - 1000; - if (bigRockPart < 0) { - return; - } - room = g_game->_room; - uVar1 = *GHIDRA_CAST((GHIDRA_CAST(room) + 0xc)); - row = GHIDRA_UINT(this->_gridIndex) / uVar1; - uVar2 = GHIDRA_UINT(this->_gridIndex) % uVar1; - leftColumn = uVar2 - 1; - if ((((leftColumn < 0) || (GHIDRA_INT(uVar1) <= leftColumn)) || (GHIDRA_INT(row) < 0)) || - (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= GHIDRA_INT(row))) { - leftIndex = 0xffffffff; - } - else { - leftIndex = leftColumn + uVar1 * row; - } - rightColumn = uVar2 + 1; - if (((rightColumn < 0) || (GHIDRA_INT(uVar1) <= rightColumn)) || - ((GHIDRA_INT(row) < 0 || (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= GHIDRA_INT(row))))) { - rightIndex = 0xffffffff; - } - else { - rightIndex = uVar1 * row + rightColumn; - } - upRow = row - 1; - if (((GHIDRA_INT(uVar2) < 0) || (GHIDRA_INT(uVar1) <= GHIDRA_INT(uVar2))) || - ((upRow < 0 || (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= upRow)))) { - upIndex = 0xffffffff; - if ((-1 < GHIDRA_INT(uVar2)) && (upIndex = 0xffffffff, GHIDRA_INT(uVar2) < GHIDRA_INT(uVar1))) goto LAB_0071abe5; -LAB_0071abf9: - uVar2 = 0xffffffff; - } - else { - upIndex = uVar1 * upRow + uVar2; -LAB_0071abe5: - downRowCheck = row + 1; - if ((downRowCheck < 0) || (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= downRowCheck)) goto LAB_0071abf9; - uVar2 = uVar1 * downRowCheck + uVar2; - } - downRow = row + 1; - if ((((leftColumn < 0) || (GHIDRA_INT(uVar1) <= leftColumn)) || (upRow < 0)) || - (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= upRow)) { - upLeftIndex = 0xffffffff; - } - else { - upLeftIndex = uVar1 * upRow + leftColumn; - } - if (((rightColumn < 0) || (GHIDRA_INT(uVar1) <= rightColumn)) || - ((upRow < 0 || (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= upRow)))) { - upRightIndex = 0xffffffff; - } - else { - upRightIndex = uVar1 * upRow + rightColumn; - } - if (((leftColumn < 0) || (GHIDRA_INT(uVar1) <= leftColumn)) || - ((downRow < 0 || (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= downRow)))) { - downLeftIndex = 0xffffffff; - } - else { - downLeftIndex = uVar1 * downRow + leftColumn; - } - if ((((rightColumn < 0) || (GHIDRA_INT(uVar1) <= rightColumn)) || (downRow < 0)) || - (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x10)) <= downRow)) { - uVar1 = 0xffffffff; - } - else { - uVar1 = uVar1 * downRow + rightColumn; - } - switch(bigRockPart) { - case 0: - if (rightIndex < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + rightIndex * 4 + 0x24)); - break; - } - goto LAB_0071aec2; - case 2: - if (0x1bf < uVar2) goto LAB_0071aec2; - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + uVar2 * 4 + 0x24)); - break; - case 3: - goto switchD_0071accd_caseD_3; - case 4: - if (uVar1 < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + uVar1 * 4 + 0x24)); - } - else { - neighborGrid = 0; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,1); - } - if (uVar2 < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + uVar2 * 4 + 0x24)); - } - else { - neighborGrid = 0; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,0); - } - if (0x1bf < rightIndex) goto LAB_0071aec2; - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + rightIndex * 4 + 0x24)); - break; - case 5: - if (uVar2 < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + uVar2 * 4 + 0x24)); - } - else { - neighborGrid = 0; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,1); - } - if (downLeftIndex < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + downLeftIndex * 4 + 0x24)); - } - else { - neighborGrid = 0; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,0); - } - case 1: - if (leftIndex < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + leftIndex * 4 + 0x24)); - } - else { -LAB_0071aec2: - neighborGrid = 0; - } - break; - case 6: - if (rightIndex < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + rightIndex * 4 + 0x24)); - } - else { - neighborGrid = 0; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,3); - } - if (upRightIndex < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + upRightIndex * 4 + 0x24)); - } - else { -LAB_0071ae8e: - neighborGrid = 0; - } - goto LAB_0071ae90; - case 7: - if (leftIndex < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + leftIndex * 4 + 0x24)); - } - else { - neighborGrid = 0; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,3); - } - if (0x1bf < upLeftIndex) goto LAB_0071ae8e; - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + upLeftIndex * 4 + 0x24)); -LAB_0071ae90: - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,2); - } -switchD_0071accd_caseD_3: - if (upIndex < 0x1c0) { - neighborGrid = *GHIDRA_CAST((GHIDRA_CAST(room) + upIndex * 4 + 0x24)); - break; - } - goto LAB_0071aec2; - default: - goto switchD_0071accd_default; - } - neighborRock = (GridEntity_Rock *) - __RTDynamicCast(neighborGrid,0, - &IsaacRepentancePlus::GridEntity::RTTI_Type_Descriptor, - &IsaacRepentancePlus::GridEntity_Rock::RTTI_Type_Descriptor,0); - if (neighborRock != GHIDRA_CAST(0x0)) { - SetBigRockFrame(neighborRock,0xffffffff); - } -switchD_0071accd_default: - return; -} - -// 0071af10 -void GridEntity_Rock::RegisterRockDestroyed(int GridEntityType) -{ - if (GridEntityType != 3) { - PersistentGameData::IncreaseEventCounter(&g_manager->_persistentGameData,2,1); - if (GridEntityType == 4) { - PersistentGameData::IncreaseEventCounter(&g_manager->_persistentGameData,3,1); - return; - } - if (GridEntityType == 0x16) { - PersistentGameData::IncreaseEventCounter(&g_manager->_persistentGameData,4,1); - } - } - return; -} - -// 0071af60 -void GridEntity_Rock::TrySpawnWorms() -{ - int iVar1; - code *pcVar2; - uint32_t wormCount; - uint32_t seed; - uint32_t rngResult; - Entity *worm; - float trig; - uint8_t local_20 [12]; - float local_14; - float rockY; - float angle; - float rockX; - - (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x4))) = 2; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x8))) = 7; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_14 = 1.26117e-44; - rockX = (float)(this->_gridIndex % iVar1) * 40.0 + 40.0; - rockY = (float)(this->_gridIndex / iVar1) * 40.0 + 120.0; - if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))) == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar2 = (code *)swi(3); - (*pcVar2)(); - return; - } - (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_UINT(local_20))) + 0x0))) >> 2 ^ (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))) << 7 ^ (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_UINT(local_20))) + 0x0))) >> 9 ^ (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))); - if (((((*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x0))) == ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_UINT(local_20))) + 0x0))) / 0x32) * 0x32) && - (iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))), iVar1 != 3)) && (iVar1 != 0x18)) && - ((iVar1 != 6 && (iVar1 != 0x1a)))) { - wormCount = (GHIDRA_CAST((GHIDRA_CAST(local_20))))->RNG::RandomInt(5); - wormCount = (GHIDRA_CAST((GHIDRA_CAST(local_20))))->RNG::RandomInt(wormCount + 1); - if (0 < GHIDRA_INT(wormCount)) { - do { - seed = Random(); - rngResult = Random(); - angle = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) - * 2.3283064e-10 * 3.14; - angle = angle + angle; - trig = cos(angle); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_20)) + 0x8))) = trig * 20.0 + rockX; - trig = sin(angle); - local_14 = trig * 20.0 + rockY; - worm = Game::Spawn(g_game,1000,0x3f,GHIDRA_CAST((local_20 + 8)),&g_vectorZero,GHIDRA_CAST(0x0),0, - seed); - (**(code **)(*GHIDRA_CAST(worm) + 0xc))(); - wormCount = wormCount - 1; - } while (wormCount != 0); - } - } - return; -} - -// 0071b100 -void GridEntity_Rock::PlayBreakSound(int GridEntityType, int BackdropType) -{ - int iVar1; - int soundId; - Manager *manager; - - if ((GridEntityType == 6) || (GridEntityType == 0x1a)) { - soundId = GridEntityType; - iVar1 = FUN_00718ee0(); - soundId = *GHIDRA_CAST((&DAT_00b1f3b8 + iVar1 * 4)); - } - else { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)); - if (((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) || - ((iVar1 == 0xd || (iVar1 == 0x22)))) || - ((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))) { - soundId = 0x4d; - } - else { - soundId = 0x89; - } - } - manager = g_manager; - seed_fart_sound_override(&soundId); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(soundId,1.0,2,0,1.0,0.0); - return; -} - -// 0071b1c0 -uint8_t GridEntity_Rock::TrySpawnLadder() -{ - uint8_t isHasStudFinder; - int iVar1; - uint32_t uVar2; - uint32_t Seed; - uint32_t gridCollision; - GridEntity *stairs; - void *pvVar3; - uint32_t *playerIt; - RNG *studFinderRng; - Room *room; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - Game *game; - Entity_Player *player; - void *trinketRngBegin; - - game = g_game; - local_8 = 0xffffffff; - puStack_c = &LAB_00afcbc7; - local_10 = ExceptionList; - ExceptionList = &local_10; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 3) { - playerIt = (g_game->_playerManager)._playerList._begin; - if (playerIt != (g_game->_playerManager)._playerList._end) { - do { - player = GHIDRA_CAST(*playerIt); - if ((player->_variant == 0) && - (isHasStudFinder = Entity_Player::HasTrinket(player,0x4a,0), isHasStudFinder != 0)) { - pvVar3 = (player->_trinketRNGs)._end; - if (GHIDRA_INT(pvVar3) - GHIDRA_INT((player->_trinketRNGs)._begin) >> 4 < 0x4b) { - KAGE_LogMessage(0x10,GHIDRA_CAST("Trinket ID out of bounds!\n")); - pvVar3 = (player->_trinketRNGs)._end; - } - trinketRngBegin = (player->_trinketRNGs)._begin; - uVar2 = (GHIDRA_INT(pvVar3) - GHIDRA_INT(trinketRngBegin) >> 4) - 1; - if (0x4a < uVar2) { - uVar2 = 0x4a; - } - studFinderRng = GHIDRA_CAST((uVar2 * 0x10 + GHIDRA_INT(trinketRngBegin))); - goto LAB_0071b23a; - } - playerIt = playerIt + 1; - } while (playerIt != (game->_playerManager)._playerList._end); - } - studFinderRng = GHIDRA_CAST(0x0); -LAB_0071b23a: - if (-1 < g_game->_currentRoomIdx) { - if ((g_game->_levelStateFlags & 0x2000U) == 0) { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x768)); - } - else { - iVar1 = -1; - } - if (iVar1 == this->_gridIndex) goto LAB_0071b300; - } - if (((g_game->_levelStateFlags & 0x2000U) == 0) && (studFinderRng != GHIDRA_CAST(0x0))) { - iVar1 = PlayerManager::GetTrinketMultiplier(&g_game->_playerManager,0x4a); - uVar2 = (GHIDRA_CAST((studFinderRng)))->RNG::RandomInt(GHIDRA_UINT((200 / (int64_t)iVar1))); - if (uVar2 == 0) { -LAB_0071b300: - game = g_game; - room = g_game->_room; - if (((GHIDRA_UINT(this->_gridIndex) < 0x1c0) && - (pvVar3 = room->_gridEntities[this->_gridIndex], pvVar3 != (void *)0x0)) && - (0 < *GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 0x3c)))) { - *GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 0x3c)) = 0; - room = game->_room; - } - Seed = Random(); - uVar2 = this->_gridIndex; - if ((GHIDRA_INT(uVar2) < 0) || (0x1bf < GHIDRA_INT(uVar2))) { - KAGE_LogMessage(0x10,GHIDRA_CAST("SpawnGridEntity: Grid index invalid\n")); - } - if ((uVar2 < 0x1c0) && - (gridCollision = Room::GetGridCollision(room,uVar2), GHIDRA_INT(gridCollision) < 1)) { - stairs = operator_new(0x154); - local_8 = 0x11; - if (stairs == GHIDRA_CAST(0x0)) { - stairs = GHIDRA_CAST(0x0); - } - else { - (GHIDRA_CAST((stairs)))->GridEntity::GridEntity(); - *GHIDRA_CAST(stairs) = IsaacRepentancePlus::GridEntity_Stairs::vftable; - } - local_8 = 0xffffffff; - if (stairs != GHIDRA_CAST(0x0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((stairs)) + 0x4)))) = 0x12; - stairs->_gridIndex = uVar2; - if (room->_gridEntities[uVar2] != GHIDRA_CAST(0x0)) { - (*(code *)**GHIDRA_CAST(room->_gridEntities[uVar2]))(1); - } - room->_gridEntities[uVar2] = stairs; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((stairs)) + 0x8)))) = 0; - stairs->_varData = 0; - (GHIDRA_CAST((stairs)))->GridEntity::Init(Seed); - } - } - g_game->_levelStateFlags = g_game->_levelStateFlags | 0x2000; - ExceptionList = local_10; - return 1; - } - } - } - ExceptionList = local_10; - return 0; -} diff --git a/generated-src/grid_entity_spikes.cpp b/generated-src/grid_entity_spikes.cpp deleted file mode 100644 index b3ad24b..0000000 --- a/generated-src/grid_entity_spikes.cpp +++ /dev/null @@ -1,788 +0,0 @@ -#include "classes.h" - -// 0071dfc0 -void GridEntity_Spikes::BeginBatches() -{ - int iVar1; - code *pcVar2; - uint8_t isDisabled; - uint8_t *curAnim; - std_string *psVar3; - Entity *bloodSplat; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - uint8_t extraout_CL_01; - uint8_t *expectedAnim; - char *pcVar4; - uint32_t uVar5; - bool bVar6; - float splatScaleY; - Vector local_34; - std_string local_2c; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - void *animData; - Game *game; - ANM2 *sprite; - - game = g_game; - local_8 = 0xffffffff; - puStack_c = &LAB_00afcc05; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&local_2c)[1]._size); - ExceptionList = &local_10; - this->_collisionClass = 0; - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(game->_room) + this->_gridIndex * 4 + 0x76c)) = 999; - } - sprite = &this->_sprite; - local_2c._size = 0; - local_2c._capacity = 0xf; - local_2c._buf[0] = '\0'; - local_2c._buf[1] = '\0'; - local_2c._buf[2] = '\0'; - local_2c._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = msvc::_Allocate(0x20); - local_2c._size = 0x19; - local_2c._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))),"gfx/grid/grid_spikes.anm2",0x1a); - local_8 = 0; - ANM2::Load(sprite,&local_2c,0); - local_8 = 0xffffffff; - isDisabled = extraout_CL; - if (0xf < local_2c._capacity) { - uVar5 = local_2c._capacity + 1; - pcVar4 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - if (0xfff < uVar5) { - pcVar4 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + -4)); - uVar5 = local_2c._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar4))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar4,uVar5); - isDisabled = extraout_CL_00; - } - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0xc))) & 0xffffffff; - local_2c._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) & 0xffffff00; - local_34.y = 0.0; - if ((this->_sprite)._layerCount != 0) { - do { - Sprite::ReplaceSpritesheet - (GHIDRA_CAST(sprite),GHIDRA_INT(local_34.y), - (std_string *) - (GHIDRA_INT(g_game->_room) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)) * 0x13c + 0x1e3c)); - local_34.y = (float)(GHIDRA_INT(local_34.y) + 1); - isDisabled = extraout_CL_01; - } while (GHIDRA_UINT(local_34.y) < GHIDRA_CAST((this->_sprite)._layerCount)); - } - ANM2::LoadGraphics(sprite,isDisabled); - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 8) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) % 100 == 0)) { - uVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - local_2c._buf[0xc] = '\x05'; - local_2c._buf[0xd] = '\0'; - local_2c._buf[0xe] = '\0'; - local_2c._buf[0xf] = '\0'; - local_2c._size = 9; - local_34.y = (float)&DAT_00000007; - if (uVar5 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar2 = (code *)swi(3); - (*pcVar2)(); - return; - } - uVar5 = uVar5 >> 5 ^ uVar5; - uVar5 = uVar5 << 9 ^ uVar5; - uVar5 = uVar5 >> 7 ^ uVar5; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) = (uVar5 & 3) + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) + 1; - if ((*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x1c))) == '\0') { - if (uVar5 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar2 = (code *)swi(3); - (*pcVar2)(); - return; - } - uVar5 = uVar5 >> 5 ^ uVar5; - uVar5 = uVar5 << 9 ^ uVar5; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x20)))) = uVar5 >> 7 ^ uVar5; - } - } - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); - (this->_rng)._seed = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x20)))); - (this->_rng)._shift1 = 5; - (this->_rng)._shift2 = 9; - (this->_rng)._shift3 = 7; - this->_timeout = 0x1e; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 9) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x1c) { - if (iVar1 == 1) { - curAnim = (this->_sprite)._animState._animData; - if (curAnim == GHIDRA_CAST(0x0)) { -LAB_0071e528: - isDisabled = ANM2::SetAnimation(sprite,GHIDRA_CAST("UnsummonPayment"),1); - if (isDisabled != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - if (0xf < *GHIDRA_CAST((curAnim + 0x14))) { - curAnim = *GHIDRA_CAST(curAnim); - } - pcVar4 = "UnsummonPayment"; - do { - isDisabled = *curAnim; - bVar6 = isDisabled < (uint8_t)*pcVar4; - if (isDisabled != *pcVar4) { -LAB_0071e510: - uVar5 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0071e515; - } - if (isDisabled == 0) break; - isDisabled = curAnim[1]; - bVar6 = isDisabled < (uint8_t)pcVar4[1]; - if (isDisabled != pcVar4[1]) goto LAB_0071e510; - curAnim = curAnim + 2; - pcVar4 = pcVar4 + 2; - } while (isDisabled != 0); - uVar5 = 0; -LAB_0071e515: - if ((uVar5 != 0) || - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' && - ((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0071e528; - } - animData = (this->_sprite)._animState._animData; - if (animData == (void *)0x0) { - local_2c._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0xc))) & 0xffffffff; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = GHIDRA_CAST(0x0); - } - else { - (GHIDRA_CAST((local_2c._buf)))->msvc::string::string(animData); - } - local_8 = 1; - psVar3 = &local_2c; - if (0xf < local_2c._capacity) { - psVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - } - isDisabled = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(psVar3),1); - if ((isDisabled != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - } - local_8 = 0xffffffff; - if (0xf < local_2c._capacity) { - uVar5 = local_2c._capacity + 1; - psVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c._buf))) + 0x0))); - if (0xfff < uVar5) { - psVar3 = GHIDRA_CAST((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + -0x18)))->_capacity); - uVar5 = local_2c._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) + (-4 - GHIDRA_INT(psVar3))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(psVar3,uVar5); - } - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0xc))) & 0xffffffff; - local_2c._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c._buf)) + 0x0))) & 0xffffff00; - if ((this->_sprite)._animState._animData != (void *)0x0) { - AnimationState::AdvancePosition - (&(this->_sprite)._animState, - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1); - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - goto LAB_0071e7e6; - } - if ((*GHIDRA_CAST(g_game->_room) == '\0') || - (g_game->_frameCount - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x11f0)) < 1)) { - curAnim = (this->_sprite)._animState._animData; - if (curAnim != GHIDRA_CAST(0x0)) { - if (0xf < *GHIDRA_CAST((curAnim + 0x14))) { - curAnim = *GHIDRA_CAST(curAnim); - } - pcVar4 = "PaymentSpike"; - do { - isDisabled = *curAnim; - bVar6 = isDisabled < (uint8_t)*pcVar4; - if (isDisabled != *pcVar4) { -LAB_0071e6e2: - uVar5 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0071e6e7; - } - if (isDisabled == 0) break; - isDisabled = curAnim[1]; - bVar6 = isDisabled < (uint8_t)pcVar4[1]; - if (isDisabled != pcVar4[1]) goto LAB_0071e6e2; - curAnim = curAnim + 2; - pcVar4 = pcVar4 + 2; - } while (isDisabled != 0); - uVar5 = 0; -LAB_0071e6e7: - if ((uVar5 == 0) && - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6; - } - pcVar4 = "PaymentSpike"; - } - else { - curAnim = (this->_sprite)._animState._animData; - if (curAnim != GHIDRA_CAST(0x0)) { - if (0xf < *GHIDRA_CAST((curAnim + 0x14))) { - curAnim = *GHIDRA_CAST(curAnim); - } - pcVar4 = "SummonPayment"; - do { - isDisabled = *curAnim; - bVar6 = isDisabled < (uint8_t)*pcVar4; - if (isDisabled != *pcVar4) { -LAB_0071e680: - uVar5 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0071e685; - } - if (isDisabled == 0) break; - isDisabled = curAnim[1]; - bVar6 = isDisabled < (uint8_t)pcVar4[1]; - if (isDisabled != pcVar4[1]) goto LAB_0071e680; - curAnim = curAnim + 2; - pcVar4 = pcVar4 + 2; - } while (isDisabled != 0); - uVar5 = 0; -LAB_0071e685: - if ((uVar5 == 0) && - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6; - } - pcVar4 = "SummonPayment"; - } - } - else { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)); - if (((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) || - ((iVar1 == 0xd || (iVar1 == 0x22)))) || - ((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))) { - bVar6 = true; - } - else { - bVar6 = false; - } - pcVar4 = "Spikes%02u"; - if (bVar6) { - pcVar4 = "WombSpikes%02u"; - } - sprintf_s(&DAT_00c80fa8,0x20,GHIDRA_CAST(pcVar4)); - curAnim = (this->_sprite)._animState._animData; - if (curAnim != GHIDRA_CAST(0x0)) { - if (0xf < *GHIDRA_CAST((curAnim + 0x14))) { - curAnim = *GHIDRA_CAST(curAnim); - } - expectedAnim = &DAT_00c80fa8; - do { - isDisabled = *curAnim; - bVar6 = isDisabled < *expectedAnim; - if (isDisabled != *expectedAnim) { -LAB_0071e7b0: - uVar5 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0071e7b5; - } - if (isDisabled == 0) break; - isDisabled = curAnim[1]; - bVar6 = isDisabled < expectedAnim[1]; - if (isDisabled != expectedAnim[1]) goto LAB_0071e7b0; - curAnim = curAnim + 2; - expectedAnim = expectedAnim + 2; - } while (isDisabled != 0); - uVar5 = 0; -LAB_0071e7b5: - if ((uVar5 == 0) && - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6; - } - pcVar4 = &DAT_00c80fa8; - } - isDisabled = ANM2::SetAnimation(sprite,GHIDRA_CAST(pcVar4),1); - if (isDisabled != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - goto LAB_0071e7e6; - } - uVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))); - if (uVar5 == 0) { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)); - if ((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) || - (((iVar1 == 0xd || (iVar1 == 0x22)) || - ((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))))) { - bVar6 = true; - } - else { - bVar6 = false; - } - local_34.y = 1.6766631e-38; - if (!bVar6) { - local_34.y = (float)&DAT_00b69280; - } - curAnim = (this->_sprite)._animState._animData; - if (curAnim != GHIDRA_CAST(0x0)) { - if (0xf < *GHIDRA_CAST((curAnim + 0x14))) { - curAnim = *GHIDRA_CAST(curAnim); - } - expectedAnim = GHIDRA_CAST(local_34.y); - do { - isDisabled = *curAnim; - bVar6 = isDisabled < *expectedAnim; - if (isDisabled != *expectedAnim) { -LAB_0071e477: - uVar5 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0071e47c; - } - if (isDisabled == 0) break; - isDisabled = curAnim[1]; - bVar6 = isDisabled < expectedAnim[1]; - if (isDisabled != expectedAnim[1]) goto LAB_0071e477; - curAnim = curAnim + 2; - expectedAnim = expectedAnim + 2; - } while (isDisabled != 0); - uVar5 = 0; -LAB_0071e47c: - if ((uVar5 == 0) && - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6; - } - isDisabled = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(local_34.y),1); - if (isDisabled != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - goto LAB_0071e7e6; - } - if (5 < uVar5) { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)); - if ((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) || - (((iVar1 == 0xd || (iVar1 == 0x22)) || - ((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))))) { - bVar6 = true; - } - else { - bVar6 = false; - } - local_34.y = 1.6766631e-38; - if (!bVar6) { - local_34.y = (float)&DAT_00b69280; - } - curAnim = (this->_sprite)._animState._animData; - if (curAnim == GHIDRA_CAST(0x0)) { -LAB_0071e3bb: - isDisabled = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(local_34.y),1); - if (isDisabled != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - if (0xf < *GHIDRA_CAST((curAnim + 0x14))) { - curAnim = *GHIDRA_CAST(curAnim); - } - expectedAnim = GHIDRA_CAST(local_34.y); - do { - isDisabled = *curAnim; - bVar6 = isDisabled < *expectedAnim; - if (isDisabled != *expectedAnim) { -LAB_0071e3a0: - uVar5 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0071e3a5; - } - if (isDisabled == 0) break; - isDisabled = curAnim[1]; - bVar6 = isDisabled < expectedAnim[1]; - if (isDisabled != expectedAnim[1]) goto LAB_0071e3a0; - curAnim = curAnim + 2; - expectedAnim = expectedAnim + 2; - } while (isDisabled != 0); - uVar5 = 0; -LAB_0071e3a5: - if ((uVar5 != 0) || - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' && - ((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0071e3bb; - } - this->_timeout = (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) + -5) * 0xc; - goto LAB_0071e7e6; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - this->_timeout = uVar5 * 0xc; - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x1d18)); - if (((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) || ((iVar1 == 0xd || (iVar1 == 0x22)))) - || ((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))) { - bVar6 = true; - } - else { - bVar6 = false; - } - local_34.y = 1.6734441e-38; - if (!bVar6) { - local_34.y = 1.6766497e-38; - } - curAnim = (this->_sprite)._animState._animData; - if (curAnim == GHIDRA_CAST(0x0)) { -LAB_0071e2db: - isDisabled = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(local_34.y),1); - if (isDisabled != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - if (0xf < *GHIDRA_CAST((curAnim + 0x14))) { - curAnim = *GHIDRA_CAST(curAnim); - } - expectedAnim = GHIDRA_CAST(local_34.y); - do { - isDisabled = *curAnim; - bVar6 = isDisabled < *expectedAnim; - if (isDisabled != *expectedAnim) { -LAB_0071e2c0: - uVar5 = -GHIDRA_UINT(bVar6) | 1; - goto LAB_0071e2c5; - } - if (isDisabled == 0) break; - isDisabled = curAnim[1]; - bVar6 = isDisabled < expectedAnim[1]; - if (isDisabled != expectedAnim[1]) goto LAB_0071e2c0; - curAnim = curAnim + 2; - expectedAnim = expectedAnim + 2; - } while (isDisabled != 0); - uVar5 = 0; -LAB_0071e2c5: - if ((uVar5 != 0) || - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' && - ((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0071e2db; - } - if ((this->_sprite)._animState._animData != (void *)0x0) { - AnimationState::AdvancePosition - (&(this->_sprite)._animState, - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1); - } -LAB_0071e7e6: - isDisabled = is_disabled(this); - if (isDisabled != 0) { - unsummon(this,1); - } - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 8) && (99 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))))) { - uVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); - local_2c._buf[0xc] = '\x02'; - local_2c._buf[0xd] = '\0'; - local_2c._buf[0xe] = '\0'; - local_2c._buf[0xf] = '\0'; - local_2c._size = 7; - if (uVar5 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar2 = (code *)swi(3); - (*pcVar2)(); - return; - } - uVar5 = uVar5 >> 2 ^ uVar5; - uVar5 = uVar5 << 7 ^ uVar5; - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_34.x = (float)(this->_gridIndex % iVar1) * 40.0 + 40.0; - local_34.y = (float)(this->_gridIndex / iVar1) * 40.0 + 120.0; - bloodSplat = Game::Spawn(g_game,1000,7,&local_34,&g_vectorZero,GHIDRA_CAST(0x0),0, - uVar5 >> 9 ^ uVar5); - splatScaleY = g_vectorOne.y * 1.8; - iVar1 = *GHIDRA_CAST(bloodSplat); - (bloodSplat->_sprite)._scale.x = g_vectorOne.x * 1.8; - (bloodSplat->_sprite)._scale.y = splatScaleY; - (**(code **)(iVar1 + 0xc))(); - } - ExceptionList = local_10; - return; -} - -// 0071e920 -uint8_t GridEntity_Spikes::is_disabled() -{ - uint8_t isFlatFileHeld; - RoomDescriptor *roomDesc; - Entity_Player *sanguineBondOwner; - - if (1 < *GHIDRA_CAST(&g_game->_deathmatchManager)) { - return 0; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x1c) { - return 0; - } - roomDesc = Level::GetRoomByIdx(GHIDRA_CAST(g_game),g_game->_currentRoomIdx, - g_game->_currentDimensionIdx); - if (((GHIDRA_UINT(roomDesc->Flags) >> 1 & 1) != 0) || - (isFlatFileHeld = PlayerManager::AnyoneHasTrinket(&g_game->_playerManager,0x97), - isFlatFileHeld != 0)) { - return 1; - } - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) < 100) && - ((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)) == 0xe && - (sanguineBondOwner = - PlayerManager::FirstCollectibleOwner - (&g_game->_playerManager,0x2b4,GHIDRA_CAST(&g_game->_playerManager),1), - sanguineBondOwner != GHIDRA_CAST(0x0))))) { - return 1; - } - return 0; -} - -// 0071e9b0 -void GridEntity_Spikes::Update() -{ - uint8_t isCheck; - char isCheck; - int iVar2; - char *anim; - uint32_t damageFlags; - ANM2 *this_00; - int extraout_EDX; - char *summonAnim; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 0) { - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 500; - } - goto LAB_0071ea6f; - } - damageFlags = 0x80; - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)); - if ((((iVar2 == 0xd) || (99 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))))) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x1c)) - && (damageFlags = 0x10000080, iVar2 == 0xd)) { -LAB_0071ea00: - isCheck = 1; - } - else { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 8) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 0x1c) goto LAB_0071ea4a; - goto LAB_0071ea00; - } - if (99 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))))) goto LAB_0071ea00; -LAB_0071ea4a: - isCheck = 0; - } - GridEntity::hurt_surroundings(GHIDRA_CAST(this),11.0,11.0,8.0,2,(uint64_t)damageFlags,isCheck); - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 999; - } -LAB_0071ea6f: - isCheck = is_disabled(this); - if (isCheck == 0) { - if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 9) && (0 < this->_timeout)) { - iVar2 = this->_timeout + -1; - this->_timeout = iVar2; - if (iVar2 < 1) { - this->_timeout = 0x3c; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = GHIDRA_UINT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0)); - } - else if (iVar2 == 5) { - isCheck = FUN_0071df80(); - if (isCheck == '\0') { - anim = "Unsummon"; - summonAnim = "Summon"; - } - else { - anim = "UnsummonWomb"; - summonAnim = "SummonWomb"; - } - if (extraout_EDX != 0) { - anim = summonAnim; - } - ANM2::Play(this_00,GHIDRA_CAST(anim),0); - } - } - } - else if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0) || - (((this->_sprite)._animState._animData != (void *)0x0 && - ((this->_sprite)._animState._isPlaying != 0)))) { - unsummon(this,0); - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - return; -} - -// 0071eb30 -void GridEntity_Spikes::unsummon(uint8_t isInstant) -{ - void *other; - char isWomb; - uint8_t bVar1; - uint8_t *curAnimChar; - uint32_t uVar2; - uint8_t *****curAnimNameData; - char *animName; - bool isLess; - uint8_t *****curAnimName [4]; - uint32_t curAnimNameSize; - uint32_t curAnimNameCapacity; - uint32_t securityCookie; - void *local_10; - uint8_t *puStack_c; - uint8_t ****local_8; - uint8_t *animData; - - local_8 = GHIDRA_CAST(0xffffffff); - puStack_c = &LAB_00af18ad; - local_10 = ExceptionList; - securityCookie = __security_cookie ^ GHIDRA_UINT((curAnimName + 0xb)); - ExceptionList = &local_10; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - this->_timeout = -1; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0x1c) { - animData = (this->_sprite)._animState._animData; - if (animData != GHIDRA_CAST(0x0)) { - curAnimChar = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - curAnimChar = *GHIDRA_CAST(animData); - } - animName = "UnsummonPayment"; - do { - bVar1 = *curAnimChar; - isLess = bVar1 < (uint8_t)*animName; - if (bVar1 != *animName) { -LAB_0071ebb0: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0071ebb5; - } - if (bVar1 == 0) break; - bVar1 = curAnimChar[1]; - isLess = bVar1 < (uint8_t)animName[1]; - if (bVar1 != animName[1]) goto LAB_0071ebb0; - curAnimChar = curAnimChar + 2; - animName = animName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0071ebb5: - if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_0071ecaa; - } - animName = "UnsummonPayment"; - } - else { - isWomb = FUN_0071df80(securityCookie); - animData = (this->_sprite)._animState._animData; - if (isWomb == '\0') { - if (animData != GHIDRA_CAST(0x0)) { - curAnimChar = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - curAnimChar = *GHIDRA_CAST(animData); - } - animName = "Unsummon"; - do { - bVar1 = *curAnimChar; - isLess = bVar1 < (uint8_t)*animName; - if (bVar1 != *animName) { -LAB_0071ec72: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0071ec77; - } - if (bVar1 == 0) break; - bVar1 = curAnimChar[1]; - isLess = bVar1 < (uint8_t)animName[1]; - if (bVar1 != animName[1]) goto LAB_0071ec72; - curAnimChar = curAnimChar + 2; - animName = animName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0071ec77: - if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_0071ecaa; - } - animName = "Unsummon"; - } - else { - if (animData != GHIDRA_CAST(0x0)) { - curAnimChar = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - curAnimChar = *GHIDRA_CAST(animData); - } - animName = "UnsummonWomb"; - do { - bVar1 = *curAnimChar; - isLess = bVar1 < (uint8_t)*animName; - if (bVar1 != *animName) { -LAB_0071ec20: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0071ec25; - } - if (bVar1 == 0) break; - bVar1 = curAnimChar[1]; - isLess = bVar1 < (uint8_t)animName[1]; - if (bVar1 != animName[1]) goto LAB_0071ec20; - curAnimChar = curAnimChar + 2; - animName = animName + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0071ec25: - if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_0071ecaa; - } - animName = "UnsummonWomb"; - } - } - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(animName),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } -LAB_0071ecaa: - if (isInstant != 0) { - other = (this->_sprite)._animState._animData; - if (other == (void *)0x0) { - curAnimNameCapacity = 0xf; - curAnimNameSize = 0; - curAnimName[0] = GHIDRA_CAST(0x0); - } - else { - (GHIDRA_CAST((GHIDRA_CAST(curAnimName))))->msvc::string::string(other); - } - local_8 = GHIDRA_CAST(0x0); - curAnimNameData = GHIDRA_CAST(curAnimName); - if (0xf < curAnimNameCapacity) { - curAnimNameData = curAnimName[0]; - } - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(curAnimNameData),1); - if ((bVar1 != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) { - AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0); - if ((this->_sprite)._animState._animData != (void *)0x0) { - (this->_sprite)._animState._isPlaying = 0; - } - } - local_8 = GHIDRA_CAST(0xffffffff); - if (0xf < curAnimNameCapacity) { - uVar2 = curAnimNameCapacity + 1; - curAnimNameData = curAnimName[0]; - if (0xfff < uVar2) { - curAnimNameData = GHIDRA_CAST(curAnimName[0][-1]); - uVar2 = curAnimNameCapacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST((GHIDRA_INT(curAnimName[0]) + (-4 - GHIDRA_INT(curAnimNameData))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(curAnimNameData,uVar2); - } - curAnimNameSize = 0; - curAnimNameCapacity = 0xf; - curAnimName[0] = GHIDRA_CAST((GHIDRA_UINT(curAnimName[0]) & 0xffffff00)); - if ((this->_sprite)._animState._animData != (void *)0x0) { - AnimationState::AdvancePosition - (&(this->_sprite)._animState, - *GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1); - } - } - ExceptionList = local_10; - return; -} diff --git a/generated-src/grid_entity_stairs.cpp b/generated-src/grid_entity_stairs.cpp deleted file mode 100644 index e4df9c3..0000000 --- a/generated-src/grid_entity_stairs.cpp +++ /dev/null @@ -1,388 +0,0 @@ -#include "classes.h" - -// 0099bad0 -void GridEntity_Stairs::BeginBatches() -{ - uint8_t bVar1; - uint8_t *curAnimName; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - uint8_t extraout_CL_01; - uint8_t extraout_CL_02; - char *pcVar2; - uint32_t uVar3; - bool isLess; - uint32_t local_3c; - uint32_t local_38; - uint32_t local_34; - uint32_t local_30; - uint8_t local_2c [8]; - float local_24; - float local_20; - uint32_t pathSize; - uint32_t local_18; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - uint8_t *animData; - ANM2 *sprite; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afcc05; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT((local_2c + 0x28)); - ExceptionList = &local_10; - pathSize = 0; - if ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) >> 0xd & 1) == 0) { - sprite = &this->_sprite; - local_18 = 0xf; - local_2c[0] = '\0'; - local_2c[1] = '\0'; - local_2c[2] = '\0'; - local_2c[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) = msvc::_Allocate(0x30); - pathSize = 0x24; - local_18 = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c))) + 0x0))),"gfx/grid/door_20_secrettrapdoor.anm2",0x25); - local_8 = 0; - ANM2::Load(sprite,GHIDRA_CAST(local_2c),0); - local_8 = 0xffffffff; - bVar1 = extraout_CL; - if (0xf < local_18) { - uVar3 = local_18 + 1; - pcVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c))) + 0x0))); - if (0xfff < uVar3) { - pcVar2 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) + -4)); - uVar3 = local_18 + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) + (-4 - GHIDRA_INT(pcVar2))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar2,uVar3); - bVar1 = extraout_CL_00; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) = msvc::_Allocate(0x30); - pathSize = 0x20; - local_18 = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c))) + 0x0))),"gfx/grid/secretshop_trapdoor.png",0x21); - local_8 = 1; - (GHIDRA_CAST((GHIDRA_CAST(sprite))))->Sprite::ReplaceSpritesheet(0,GHIDRA_CAST(local_2c)); - local_8 = 0xffffffff; - bVar1 = extraout_CL_01; - if (0xf < local_18) { - uVar3 = local_18 + 1; - pcVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2c))) + 0x0))); - if (0xfff < uVar3) { - pcVar2 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) + -4)); - uVar3 = local_18 + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) + (-4 - GHIDRA_INT(pcVar2))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar2,uVar3); - bVar1 = extraout_CL_02; - } - } - ANM2::LoadGraphics(sprite,bVar1); - animData = (this->_sprite)._animState._animData; - if (animData != GHIDRA_CAST(0x0)) { - curAnimName = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - curAnimName = *GHIDRA_CAST(animData); - } - pcVar2 = "Closed"; - do { - bVar1 = *curAnimName; - isLess = bVar1 < (uint8_t)*pcVar2; - if (bVar1 != *pcVar2) { -LAB_0099bcf0: - uVar3 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0099bcf5; - } - if (bVar1 == 0) break; - bVar1 = curAnimName[1]; - isLess = bVar1 < (uint8_t)pcVar2[1]; - if (bVar1 != pcVar2[1]) goto LAB_0099bcf0; - curAnimName = curAnimName + 2; - pcVar2 = pcVar2 + 2; - } while (bVar1 != 0); - uVar3 = 0; -LAB_0099bcf5: - if (uVar3 == 0) { - if (animData[0x34] == 0) { - ExceptionList = local_10; - return; - } - if ((this->_sprite)._animState._isPlaying != 0) { - ExceptionList = local_10; - return; - } - } - } - bVar1 = ANM2::SetAnimation(sprite,GHIDRA_CAST("Closed"),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - } - else { - local_3c = 0; - local_38 = 0; - local_34 = 0; - local_30 = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) = g_vectorZero.x; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x4))) = g_vectorZero.y; - local_24 = g_vectorZero.x; - local_20 = g_vectorZero.y; - local_18 = 0; - this->Destroy(1,&local_3c,local_14); - } - ExceptionList = local_10; - return; -} - -// 0099bd50 -void GridEntity_Stairs::Update() -{ - uint64_t qVar1; - uint8_t bVar2; - uint8_t *curAnimChar; - int returnRoomIdx; - char cVar3; - uint32_t extraout_ECX; - uint32_t extraout_ECX_00; - char *expectedName; - uint32_t uVar4; - uint64_t *allocatedBytes; - Game *game; - bool isLess; - float fVar5; - float deltaX; - double dVar6; - int iVar7; - EntityList_EL nearbyEntities; - Vector stairsPos; - Vector local_24; - float playerDistance; - float local_18; - char isGreedLocked; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - int gridWidth; - - local_8 = 0xffffffff; - puStack_c = &LAB_00b0d94d; - local_10 = ExceptionList; - ExceptionList = &local_10; - if ((((g_game->_difficulty != 2) && (g_game->_difficulty != 3)) || - (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)) != 1)) || - (isGreedLocked = '\x01', (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) & 1) != 0)) { - isGreedLocked = '\0'; - } - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - local_24.x = (float)(this->_gridIndex % iVar7) * 40.0 + 40.0; - local_24.y = (float)(this->_gridIndex / iVar7) * 40.0 + 120.0; - local_24.y = (float)Game::GetNearestPlayerEx(&local_24,1,0,0); - local_18 = (float)(extraout_ECX & 0xffffff00); - playerDistance = 1e+09; - if (GHIDRA_CAST(local_24.y) != GHIDRA_CAST(0x0)) { - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - deltaX = ((float)(this->_gridIndex % iVar7) * 40.0 + 40.0) - - ((GHIDRA_CAST(local_24.y))->_pos).x; - fVar5 = ((float)(this->_gridIndex / iVar7) * 40.0 + 120.0) - - ((GHIDRA_CAST(local_24.y))->_pos).y; - playerDistance = sqrtf(fVar5 * fVar5 + deltaX * deltaX); - local_18 = (float)CONCAT31((int3)(GHIDRA_UINT(extraout_ECX_00) >> 8),playerDistance < 50.0); - } - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - stairsPos.x = (float)(this->_gridIndex % iVar7) * 40.0 + 40.0; - stairsPos.y = (float)(this->_gridIndex / iVar7) * 40.0 + 120.0; - EntityList::QueryRadius - (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),&nearbyEntities,&stairsPos,20.0,1); - game = g_game; - cVar3 = SUB41(local_18,0); - uVar4 = 0; - local_8 = 0; - fVar5 = local_18; - if (nearbyEntities._size != 0) { - do { - cVar3 = SUB41(fVar5,0); - if (cVar3 != '\0') break; - iVar7 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + uVar4 * 4)); - if ((*GHIDRA_CAST((iVar7 + 0x28)) == 3) && - (fVar5 = (float)(GHIDRA_UINT(fVar5) & 0xff), *GHIDRA_CAST((iVar7 + 0x2c)) == 900)) { - fVar5 = 1.4013e-45; - } - cVar3 = SUB41(fVar5,0); - uVar4 = uVar4 + 1; - } while (uVar4 < GHIDRA_UINT(nearbyEntities._size)); - } - if (((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) & 1) == 0) || (cVar3 != '\0')) { - if ((this->_sprite)._animState._animData != (void *)0x0) { - local_18 = (this->_sprite)._animState._animFrame; - dVar6 = floor((double)local_18); - local_18 = (float)dVar6; - if (9 < GHIDRA_INT(dVar6)) goto LAB_0099bf89; - } -LAB_0099c032: - curAnimChar = (this->_sprite)._animState._animData; - if (curAnimChar == GHIDRA_CAST(0x0)) { -LAB_0099c083: - bVar2 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Closed"),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - game = g_game; - } - else { - if (0xf < *GHIDRA_CAST((curAnimChar + 0x14))) { - curAnimChar = *GHIDRA_CAST(curAnimChar); - } - expectedName = "Closed"; - do { - bVar2 = *curAnimChar; - isLess = bVar2 < (uint8_t)*expectedName; - if (bVar2 != *expectedName) { -LAB_0099c068: - uVar4 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0099c06d; - } - if (bVar2 == 0) break; - bVar2 = curAnimChar[1]; - isLess = bVar2 < (uint8_t)expectedName[1]; - if (bVar2 != expectedName[1]) goto LAB_0099c068; - curAnimChar = curAnimChar + 2; - expectedName = expectedName + 2; - } while (bVar2 != 0); - uVar4 = 0; -LAB_0099c06d: - if ((uVar4 != 0) || - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' && - ((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0099c083; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - } - else { -LAB_0099bf89: - if (isGreedLocked != '\0') goto LAB_0099c032; - curAnimChar = (this->_sprite)._animState._animData; - if (curAnimChar == GHIDRA_CAST(0x0)) { -LAB_0099bfeb: - bVar2 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Open Animation"),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } - game = g_game; - } - else { - if (0xf < *GHIDRA_CAST((curAnimChar + 0x14))) { - curAnimChar = *GHIDRA_CAST(curAnimChar); - } - expectedName = "Open Animation"; - do { - bVar2 = *curAnimChar; - isLess = bVar2 < (uint8_t)*expectedName; - if (bVar2 != *expectedName) { -LAB_0099bfd0: - uVar4 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0099bfd5; - } - if (bVar2 == 0) break; - bVar2 = curAnimChar[1]; - isLess = bVar2 < (uint8_t)expectedName[1]; - if (bVar2 != expectedName[1]) goto LAB_0099bfd0; - curAnimChar = curAnimChar + 2; - expectedName = expectedName + 2; - } while (bVar2 != 0); - uVar4 = 0; -LAB_0099bfd5: - if ((uVar4 != 0) || - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' && - ((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0099bfeb; - } - if (((this->_sprite)._animState._animData == (void *)0x0) || - ((this->_sprite)._animState._isPlaying == 0)) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - } - } - if ((((GHIDRA_CAST(local_24.y) != GHIDRA_CAST(0x0)) && (playerDistance < 21.0)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1)) && - (((*GHIDRA_CAST((GHIDRA_CAST(local_24.y) + 0x1398)) == 0 && (*GHIDRA_CAST((GHIDRA_CAST(local_24.y) + 0x139a)) == 0)) || - ((*(void **)(GHIDRA_CAST(local_24.y) + 0x1410) != (void *)0x0 && - (*(void **)(GHIDRA_CAST(local_24.y) + 0x1410) == *(void **)(GHIDRA_CAST(local_24.y) + 0x1e68))))))) { - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))))) { - case 0: - iVar7 = -4; - break; - case 1: - iVar7 = -0xb; - break; - case 2: - iVar7 = -0xd; - break; - case 3: - Game::StartRoomTransition(game,game->_startingRoomIdx,-1,2,GHIDRA_CAST(local_24.y),-1); - goto LAB_0099c224; - default: - goto LAB_0099c12a; - } - Game::StartRoomTransition(game,iVar7,-1,2,GHIDRA_CAST(local_24.y),-1); - game = g_game; -LAB_0099c12a: - fVar5 = g_vectorZero.y; - local_24.y = (float)game->_currentRoomIdx; - returnRoomIdx = game->_lastRoomIdx; - if (GHIDRA_INT(local_24.y) < 0) { - (game->_dungeonReturnPosition).x = g_vectorZero.x; - (game->_dungeonReturnPosition).y = fVar5; - if (returnRoomIdx < -0x13) { - returnRoomIdx = -0x14; - } - else if (0xa7 < returnRoomIdx) { - returnRoomIdx = 0xa8; - } - } - else { - iVar7 = this->_gridIndex; - gridWidth = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)); - returnRoomIdx = GHIDRA_INT(GHIDRA_CAST(0xa8)); - if (GHIDRA_INT(local_24.y) < 0xa8) { - returnRoomIdx = GHIDRA_INT(local_24.y); - } - (game->_dungeonReturnPosition).x = (float)(iVar7 % gridWidth) * 40.0 + 40.0; - (game->_dungeonReturnPosition).y = (float)(iVar7 / gridWidth) * 40.0 + 120.0; - } - game->_dungeonReturnRoomIndex = returnRoomIdx; - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } -LAB_0099c224: - if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x0))) == '\0') { - if (g_mainHeap == (void *)0x0) { - allocatedBytes = &g_allocatedBytesNoHeap; - } - else { - allocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); - } - if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) != 0) { - uVar4 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + -4)); - qVar1 = *allocatedBytes; - *GHIDRA_CAST(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar4; - *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) = - *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar4)); - free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + -4)); - } - } - ExceptionList = local_10; - return; -} diff --git a/generated-src/grid_entity_statue.cpp b/generated-src/grid_entity_statue.cpp deleted file mode 100644 index 3ae758e..0000000 --- a/generated-src/grid_entity_statue.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "classes.h" - -// 0042cdf0 -void GridEntity_Statue::Render() -{ - return; -} - -// 00838520 -void GridEntity_Statue::Update() -{ - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1) { - this->_collisionClass = 3; - return; - } - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - this->_collisionClass = 0; - } - return; -} - -// 00838ae0 -void GridEntity_Statue::BeginBatches() -{ - uint32_t seed; - int iVar1; - Entity *statueEffect; - uint32_t gridPathValue; - int gridX; - uint32_t variant; - Vector spawnPos; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) < 1) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 1; - } - else if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 1) goto LAB_00838bf3; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 0) { - seed = Random(); - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - gridX = this->_gridIndex % iVar1; - iVar1 = this->_gridIndex / iVar1; - variant = 6; - } - else { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) != 1) goto LAB_00838bf3; - seed = Random(); - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - gridX = this->_gridIndex % iVar1; - iVar1 = this->_gridIndex / iVar1; - variant = 9; - } - spawnPos.x = (float)gridX * 40.0 + 40.0; - spawnPos.y = (float)iVar1 * 40.0 + 120.0; - statueEffect = Game::SpawnEx(g_game,1000,variant,&spawnPos,&g_vectorZero,GHIDRA_CAST(0x0),0,seed,0); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))) = statueEffect; -LAB_00838bf3: - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - gridPathValue = 0; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1) { - gridPathValue = 1000; - } - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = gridPathValue; - } - return; -} diff --git a/generated-src/grid_entity_teleporter.cpp b/generated-src/grid_entity_teleporter.cpp deleted file mode 100644 index 19b6c7a..0000000 --- a/generated-src/grid_entity_teleporter.cpp +++ /dev/null @@ -1,256 +0,0 @@ -#include "classes.h" - -// 00838c30 -void GridEntity_Teleporter::Update() -{ - uint8_t bVar1; - int iVar2; - uint8_t *curAnimChar; - uint32_t uVar3; - Entity_Player *player; - Vector *destPos; - char *wantAnimChar; - int cellsScanned; - bool bVar4; - int in_stack_ffffffc8; - uint8_t auVar5 [12]; - uint8_t in_stack_ffffffd0 [16]; - uint8_t auVar6 [16]; - uint8_t auVar7 [16]; - uint8_t auVar8 [16]; - uint8_t auVar9 [16]; - Vector local_10; - GridEntity *otherTeleporter; - - auVar5 = (*GHIDRA_CAST((GHIDRA_CAST(&(in_stack_ffffffd0)) + 0x0))); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 1) { - iVar2 = FUN_00839070(); - if (iVar2 == 0) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - } - goto LAB_00838e61; - } - curAnimChar = (this->_sprite)._animState._animData; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 2) { - if ((curAnimChar != GHIDRA_CAST(0x0)) && ((this->_sprite)._animState._isPlaying != 0)) { - if (0xf < *GHIDRA_CAST((curAnimChar + 0x14))) { - curAnimChar = *GHIDRA_CAST(curAnimChar); - } - wantAnimChar = "TurnOff"; - do { - bVar1 = *curAnimChar; - bVar4 = bVar1 < (uint8_t)*wantAnimChar; - if (bVar1 != *wantAnimChar) { -LAB_00838ca0: - uVar3 = -GHIDRA_UINT(bVar4) | 1; - goto LAB_00838ca5; - } - if (bVar1 == 0) break; - bVar1 = curAnimChar[1]; - bVar4 = bVar1 < (uint8_t)wantAnimChar[1]; - if (bVar1 != wantAnimChar[1]) goto LAB_00838ca0; - curAnimChar = curAnimChar + 2; - wantAnimChar = wantAnimChar + 2; - } while (bVar1 != 0); - uVar3 = 0; -LAB_00838ca5: - if (uVar3 == 0) goto LAB_00838e61; - } - ANM2::Play(&this->_sprite,GHIDRA_CAST("IdleOff"),0); - goto LAB_00838e61; - } - if ((curAnimChar == GHIDRA_CAST(0x0)) || ((this->_sprite)._animState._isPlaying == 0)) { -LAB_00838d09: - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar6)) + 0x8))) = "IdleOn"; - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar6)) + 0x0))) = 0x838d1800000000; - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar6)) + 0xc))) = 0; - ANM2::Play(&this->_sprite,GHIDRA_CAST("IdleOn"),0); - auVar5 = (*GHIDRA_CAST((GHIDRA_CAST(&(auVar6)) + 0x0))); - } - else { - if (0xf < *GHIDRA_CAST((curAnimChar + 0x14))) { - curAnimChar = *GHIDRA_CAST(curAnimChar); - } - wantAnimChar = "TurnOn"; - do { - bVar1 = *curAnimChar; - bVar4 = bVar1 < (uint8_t)*wantAnimChar; - if (bVar1 != *wantAnimChar) { -LAB_00838d00: - uVar3 = -GHIDRA_UINT(bVar4) | 1; - goto LAB_00838d05; - } - if (bVar1 == 0) break; - bVar1 = curAnimChar[1]; - bVar4 = bVar1 < (uint8_t)wantAnimChar[1]; - if (bVar1 != wantAnimChar[1]) goto LAB_00838d00; - curAnimChar = curAnimChar + 2; - wantAnimChar = wantAnimChar + 2; - } while (bVar1 != 0); - uVar3 = 0; -LAB_00838d05: - if (uVar3 != 0) goto LAB_00838d09; - } - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar7)) + 0xc))) = 0x838d1f; - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar7)) + 0x0))) = auVar5; - player = GHIDRA_CAST(FUN_00839070()); - if (player != GHIDRA_CAST(0x0)) { - uVar3 = this->_gridIndex; - local_10.x = (float)g_game->_room; - cellsScanned = 0; - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(local_10.x) + 0x10)) * *GHIDRA_CAST((GHIDRA_CAST(local_10.x) + 0xc)); - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(auVar7)) + 0x0))); - if (0 < iVar2 + -2) { - do { - uVar3 = GHIDRA_INT((uVar3 + 1)) % iVar2; - if ((((uVar3 < 0x1c0) && - (otherTeleporter = *GHIDRA_CAST((GHIDRA_CAST(local_10.x) + uVar3 * 4 + 0x24)), - otherTeleporter != GHIDRA_CAST(0x0))) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((otherTeleporter)) + 0x4)))) == 0x17) - ) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((otherTeleporter)) + 0x8)))) == *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))))) { - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x8))) = 1; - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0xc))) = 1; - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar9)) + 0x8))) = (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x8))); - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar9)) + 0x4))) = &local_10; - (*GHIDRA_CAST((GHIDRA_CAST(&(auVar9)) + 0x0))) = 0x838dba; - destPos = (GHIDRA_CAST((otherTeleporter)))->GridEntity::Position(&local_10); - Entity_Player::Teleport(player,destPos,auVar9[8],auVar9[0xc]); - destPos = (GHIDRA_CAST((otherTeleporter)))->GridEntity::Position(&local_10); - Game::DamageRadius(destPos,GHIDRA_CAST(player),4,0,in_stack_ffffffc8,50.0,g_tearFlagsNone, - 40.0,30.0); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((otherTeleporter)) + 0xc)))) == 0) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((otherTeleporter)) + 0xc)))) = 1; - } - goto LAB_00838e61; - } - cellsScanned = cellsScanned + 1; - } while (cellsScanned < iVar2 + -2); - } - iVar2 = *GHIDRA_CAST((GHIDRA_CAST(local_10.x) + 8)); - if ((iVar2 == 0x19) || (iVar2 == 0x1a)) { - iVar2 = Level::QueryRoomTypeIndex(GHIDRA_CAST(g_game),(iVar2 == 0x19) + 0x19,0,&this->_rng,1); - if (-1 < iVar2) { - Game::StartRoomTransition(g_game,iVar2,-1,3,player,-1); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&((g_game->_roomTransition))) + 0x20)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) + 1; - } - } - else { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 2; - } - } -LAB_00838e61: - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 999; - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - return; -} - -// 00838eb0 -void GridEntity_Teleporter::BeginBatches() -{ - uint8_t *pbVar1; - uint8_t bVar2; - uint32_t uVar3; - uint8_t **anm2Paths; - uint8_t *cursor; - void *ptr; - char *idleOnCursor; - bool isLess; - std_string anm2Path; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - Game *game; - - game = g_game; - local_8 = 0xffffffff; - puStack_c = &LAB_00af6ebd; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_INT(&anm2Path) + 0x28U; - ExceptionList = &local_10; - if (g_game->_challenge == 0x2c) { - uVar3 = Level::GetRoomStageType(GHIDRA_CAST(g_game),g_game->_currentRoomIdx); -LAB_00838f10: - uVar3 = RoomConfig::GetStageID(game->_stage,uVar3,-1); - } - else { - if (g_game->_currentDimensionIdx != 2) { - uVar3 = g_game->_stageType; - goto LAB_00838f10; - } - uVar3 = 0x23; - } - anm2Paths = &PTR_s_gfx_grid_grid_teleporter_gehenna_00c5c470; - anm2Path._size = 0; - if (uVar3 != 0x20) { - anm2Paths = &PTR_s_gfx_grid_grid_teleporter_anm2_00c5c454; - } - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (void *)0x0; - pbVar1 = anm2Paths[*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8))))]; - cursor = pbVar1; - do { - bVar2 = *cursor; - cursor = cursor + 1; - } while (bVar2 != 0); - (GHIDRA_CAST((anm2Path._buf)))->msvc::string::assign(pbVar1,GHIDRA_INT(cursor) - GHIDRA_INT((pbVar1 + 1))); - local_8 = 0; - ANM2::Load(&this->_sprite,&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar3 = anm2Path._capacity + 1; - ptr = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)anm2Path._buf)) + 0x0))); - if (0xfff < uVar3) { - ptr = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4); - uVar3 = anm2Path._capacity + 0x24; - if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(ptr,uVar3); - } - pbVar1 = (this->_sprite)._animState._animData; - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - if (pbVar1 != GHIDRA_CAST(0x0)) { - cursor = pbVar1; - if (0xf < *GHIDRA_CAST((pbVar1 + 0x14))) { - cursor = *GHIDRA_CAST(pbVar1); - } - idleOnCursor = "IdleOn"; - do { - bVar2 = *cursor; - isLess = bVar2 < (uint8_t)*idleOnCursor; - if (bVar2 != *idleOnCursor) { -LAB_00839000: - uVar3 = -GHIDRA_UINT(isLess) | 1; - goto LAB_00839005; - } - if (bVar2 == 0) break; - bVar2 = cursor[1]; - isLess = bVar2 < (uint8_t)idleOnCursor[1]; - if (bVar2 != idleOnCursor[1]) goto LAB_00839000; - cursor = cursor + 2; - idleOnCursor = idleOnCursor + 2; - } while (bVar2 != 0); - uVar3 = 0; -LAB_00839005: - if ((uVar3 == 0) && ((pbVar1[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_00839038; - } - bVar2 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("IdleOn"),1); - if (bVar2 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } -LAB_00839038: - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x11f5)) = 0; - ExceptionList = local_10; - return; -} diff --git a/generated-src/grid_entity_tnt.cpp b/generated-src/grid_entity_tnt.cpp deleted file mode 100644 index a3ce249..0000000 --- a/generated-src/grid_entity_tnt.cpp +++ /dev/null @@ -1,176 +0,0 @@ -#include "classes.h" - -// 0071ee90 -void GridEntity_TNT::BeginBatches() -{ - uint8_t bVar1; - EntityConfig_Entity *entity; - uint8_t *currentAnimChar; - char *ptr; - uint8_t *idleAnimChar; - uint32_t uVar2; - EntityConfig *entityConfig; - bool isLess; - uint8_t lowerBoundResult [8]; - void *lowerBoundNode; - GridEntity_TNT *self; - uint32_t entityKey; - std_string anm2Path; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - uint8_t *animData; - - local_8 = 0xffffffff; - puStack_c = &LAB_00af32ed; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size); - ExceptionList = &local_10; - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 1000; - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - self = this; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x16; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/grid_tnt.anm2",0x17); - local_8 = 0; - ANM2::Load(&this->_sprite,&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar2 = anm2Path._capacity + 1; - ptr = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar2) { - ptr = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar2 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(ptr,uVar2); - } - anm2Path._size = 0; - entityConfig = &g_manager->_entityConfig; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - entityKey = 0x3e801b00; - _Find_lower_bound<>(lowerBoundResult,&entityKey); - if (((*GHIDRA_CAST((GHIDRA_CAST(lowerBoundNode) + 0xd)) == '\0') && - (*GHIDRA_CAST((GHIDRA_CAST(lowerBoundNode) + 0x10)) < 0x3e801b01)) && - (lowerBoundNode != (entityConfig->_entities)._head)) { - entity = GHIDRA_CAST((GHIDRA_INT(lowerBoundNode) + 0x18)); - } - else { - entity = EntityConfig::GetEntity(entityConfig,1000,0,0); - } - if (entity != GHIDRA_CAST(0x0)) { - EntityConfig::PreloadResources(entityConfig,entity); - } - animData = (this->_sprite)._animState._animData; - if (animData != GHIDRA_CAST(0x0)) { - currentAnimChar = animData; - if (0xf < *GHIDRA_CAST((animData + 0x14))) { - currentAnimChar = *GHIDRA_CAST(animData); - } - idleAnimChar = s_Idle; - do { - bVar1 = *currentAnimChar; - isLess = bVar1 < *idleAnimChar; - if (bVar1 != *idleAnimChar) { -LAB_0071f028: - uVar2 = -GHIDRA_UINT(isLess) | 1; - goto LAB_0071f02d; - } - if (bVar1 == 0) break; - bVar1 = currentAnimChar[1]; - isLess = bVar1 < idleAnimChar[1]; - if (bVar1 != idleAnimChar[1]) goto LAB_0071f028; - currentAnimChar = currentAnimChar + 2; - idleAnimChar = idleAnimChar + 2; - } while (bVar1 != 0); - uVar2 = 0; -LAB_0071f02d: - if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0)))) - goto LAB_0071f059; - } - bVar1 = ANM2::SetAnimation(&this->_sprite,s_Idle,1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } -LAB_0071f059: - self->_frameCnt = GHIDRA_UINT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0xc)))) < 4)) * 4 + -1; - ExceptionList = local_10; - return; -} - -// 0071f090 -void GridEntity_TNT::Update() -{ - uint8_t isBlownPlaying; - int collisionClass; - uint32_t seed; - Vector *gridPos; - uint32_t extraout_ECX; - Vector posBuf; - - collisionClass = 2; - if (3 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc))))) { - collisionClass = 0; - } - this->_collisionClass = collisionClass; - switch(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc))))) { - case 0: - case 1: - ANM2::Play(&this->_sprite,s_Idle,0); - return; - case 2: - ANM2::Play(&this->_sprite,GHIDRA_CAST("IdleMedium"),0); - return; - case 3: - goto LAB_0071f222; - case 4: - isBlownPlaying = ANM2::IsPlaying(&this->_sprite,GHIDRA_CAST("Blown")); - if (isBlownPlaying == 0) { - this->_frameCnt = this->_frameCnt + -1; - if (this->_frameCnt < 1) { - ANM2::Play(&this->_sprite,GHIDRA_CAST("Blown"),0); - if (this->_frameCnt != 0) { - return; - } - seed = Random(); - gridPos = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&posBuf); - Game::SpawnEx(g_game,1000,1,gridPos,&g_vectorZero,GHIDRA_CAST(0x0),0,seed,0); - gridPos = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&posBuf); - Game::spawn_bomb_crater(g_game,gridPos,GHIDRA_CAST(0x0),1.0); - gridPos = (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&posBuf); - Game::BombDamage(g_game,gridPos,100.0,75.0,0,GHIDRA_CAST(0x0),g_tearFlagsNone,0x1004,0); - (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&posBuf); - spawn_rock_particles(); - (GHIDRA_CAST((GHIDRA_CAST(this))))->GridEntity::Position(&posBuf); - FUN_0071f4b0(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))),extraout_ECX); - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 900; - return; - } - return; - } - } - else if (this->_frameCnt < 1) { - return; - } -LAB_0071f222: - ANM2::Play(&this->_sprite,GHIDRA_CAST("ReadyToExplode"),0); - return; - default: - return; - } -} diff --git a/generated-src/grid_entity_trap_door.cpp b/generated-src/grid_entity_trap_door.cpp deleted file mode 100644 index 0deeeea..0000000 --- a/generated-src/grid_entity_trap_door.cpp +++ /dev/null @@ -1,1169 +0,0 @@ -#include "classes.h" - -// 0071f630 -void GridEntity_TrapDoor::BeginBatches() -{ - uint8_t bVar1; - uint32_t forcedCurses; - uint32_t preventedCurses; - LayerState *layer; - Vector *position; - Entity *effect; - char *pcVar2; - ChallengeParam *challengeParams; - uint8_t extraout_CL; - uint8_t extraout_CL_00; - uint8_t unk; - uint8_t extraout_CL_01; - uint8_t extraout_CL_02; - uint8_t extraout_CL_03; - uint8_t extraout_CL_04; - char *freeBlock; - uint32_t uVar3; - int iVar4; - Vector local_54; - int local_4c; - char isHardMode; - char *tmpPath [4]; - uint32_t tmpPathSize; - uint32_t tmpPathCapacity; - std_string anm2Path; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - uint32_t curses; - void *room; - int *roomData; - ANM2 *sprite; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afcc85; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size); - ExceptionList = &local_10; - local_4c = g_game->_stage; - if ((g_game->_difficulty == 2) || (g_game->_difficulty == 3)) { - isHardMode = '\x01'; - } - else { - isHardMode = '\0'; - } - uVar3 = g_game->_debugCurses; - curses = g_game->_curses; - forcedCurses = Seeds::GetForcedCurses(); - preventedCurses = Seeds::GetPreventedCurses(); - iVar4 = local_4c; - if (((~preventedCurses & (forcedCurses | uVar3 | curses) & 2) != 0) && (isHardMode == '\0')) { - iVar4 = local_4c + 1; - } - local_4c = g_game->_currentRoomIdx; - if (((iVar4 == 9) && (local_4c == -9)) || (*GHIDRA_CAST((GHIDRA_CAST(local_54.y) + 0x18)) == 1)) { - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1a; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/VoidTrapdoor.anm2",0x1b); - local_8 = 0; - ANM2::Load(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar3 = anm2Path._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar3 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(freeBlock,uVar3); - } - *GHIDRA_CAST((GHIDRA_CAST(local_54.y) + 8)) = 1; - goto LAB_0071feb0; - } - room = g_game->_room; - if (*GHIDRA_CAST((GHIDRA_CAST(room) + 8)) == 0x1b) { - sprite = GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)); - iVar4 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x10)); - if (iVar4 != 0) { - iVar4 = *GHIDRA_CAST((iVar4 + 0x10)); - if (iVar4 == 1) { - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1f; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/trapdoor_downpour.anm2",0x20); - local_8 = 1; - ANM2::Load(sprite,&anm2Path,1); - local_8 = 0xffffffff; - if (anm2Path._capacity < 0x10) goto LAB_0071feb0; - uVar3 = anm2Path._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar3 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - goto LAB_0071fb7a; - } - if (iVar4 == 2) { - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1c; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/trapdoor_mines.anm2",0x1d); - local_8 = 2; - ANM2::Load(sprite,&anm2Path,1); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar3 = anm2Path._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar3 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(freeBlock,uVar3); - } - if (1 < GHIDRA_UINT((GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)))->_layerCount)) { - layer = ANM2::GetLayer(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),GHIDRA_CAST(0x1)); - layer->_visible = 0; - } - ANM2::Play(sprite,GHIDRA_CAST("Closed"),0); - uVar3 = Random(); - position = (GHIDRA_CAST((GHIDRA_CAST(local_54.y))))->GridEntity::Position(&local_54); - effect = Game::Spawn(g_game,1000,0x8b,position,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar3); - iVar4 = *GHIDRA_CAST(effect); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(effect[1])) + 0x40)))) = *GHIDRA_CAST((GHIDRA_CAST(local_54.y) + 0x24)); - (**(code **)(iVar4 + 0xc))(); - goto LAB_0071feb0; - } - anm2Path._size = iVar4 - 3; - if (anm2Path._size == 0) { - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(iVar4 + 0x2d); - anm2Path._size = 0x20; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/trapdoor_mausoleum.anm2",0x21); - local_8 = 3; - goto LAB_0071f766; - } - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1e; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/Door_11_TrapDoor.anm2",0x1f); - local_8 = 4; - ANM2::Load(sprite,&anm2Path,1); - local_8 = 0xffffffff; - if (anm2Path._capacity < 0x10) goto LAB_0071feb0; - uVar3 = anm2Path._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - uVar3 = anm2Path._capacity + 0x24; - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - if (GHIDRA_CAST(0x1f) < - GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(*GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4))))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - } - else { - if (((*GHIDRA_CAST((GHIDRA_CAST(room) + 8)) != 5) || - (roomData = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(room) + 4)) + 0x10)), *roomData != 0)) || - (roomData[4] != 0x58)) { - if (((1 < iVar4 - 6U) || (isHardMode != '\0')) && - (((iVar4 != 3 || (isHardMode == '\0')) && (local_4c != -8)))) { - tmpPathSize = 0; - tmpPathCapacity = 0xf; - tmpPath[0] = GHIDRA_CAST(0x0); - (GHIDRA_CAST((GHIDRA_CAST(tmpPath))))->msvc::string::assign(GHIDRA_CAST("gfx/grid/Door_11_TrapDoor.anm2"),0x1e); - local_8 = 9; - ANM2::Load(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),GHIDRA_CAST(tmpPath),1); - local_8 = 0xffffffff; - if (0xf < tmpPathCapacity) { - uVar3 = tmpPathCapacity + 1; - freeBlock = tmpPath[0]; - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST((tmpPath[0] + -4)); - uVar3 = tmpPathCapacity + 0x24; - if (GHIDRA_CAST(0x1f) < tmpPath[0] + (-4 - GHIDRA_INT(freeBlock))) goto LAB_0071f7a4; - } - operator_delete(freeBlock,uVar3); - } - tmpPathSize = 0; - tmpPathCapacity = 0xf; - tmpPath[0] = GHIDRA_CAST((GHIDRA_UINT(tmpPath[0]) & 0xffffff00)); - goto LAB_0071feb0; - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - anm2Path._size = 0x1e; - anm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/Door_11_Wombhole.anm2",0x1f); - local_8 = 6; - ANM2::Load(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),&anm2Path,0); - local_8 = 0xffffffff; - if (0xf < anm2Path._capacity) { - uVar3 = anm2Path._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - uVar3 = anm2Path._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) - goto LAB_0071f7a4; - } - operator_delete(freeBlock,uVar3); - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) & 0xffffff00; - if (local_4c == -8) { - tmpPath[0] = msvc::_Allocate(0x30); - tmpPathSize = 0x22; - tmpPathCapacity = 0x2f; - builtin_strncpy(tmpPath[0],"gfx/grid/door_11_wombhole_blue.png",0x23); - local_8 = 7; - (GHIDRA_CAST((GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)))))->Sprite::ReplaceSpritesheet(0,GHIDRA_CAST(tmpPath)); - local_8 = 0xffffffff; - bVar1 = extraout_CL; - if (0xf < tmpPathCapacity) { - uVar3 = tmpPathCapacity + 1; - freeBlock = tmpPath[0]; - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST((tmpPath[0] + -4)); - pcVar2 = tmpPath[0] + (-4 - GHIDRA_INT(freeBlock)); -joined_r0x0071fe08: - uVar3 = tmpPathCapacity + 0x24; - if (GHIDRA_CAST(0x1f) < pcVar2) { -LAB_0071f7a4: - local_8 = 0xffffffff; - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } -LAB_0071fe0e: - local_8 = 0xffffffff; - operator_delete(freeBlock,uVar3); - bVar1 = extraout_CL_04; - } - } - else { - bVar1 = Level::IsMausoleumHeartStage(GHIDRA_CAST(g_game)); - if (bVar1 == 0) { - if (iVar4 == 7) { - bVar1 = Level::IsAltPath(GHIDRA_CAST(g_game)); - if (bVar1 == 0) { - ANM2::LoadGraphics(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),unk); - goto LAB_0071feb0; - } - } - else if (((iVar4 != 6) && - ((bVar1 = extraout_CL_00, iVar4 != 5 || - (uVar3 = Level::filter_curses(GHIDRA_CAST(g_game),2), bVar1 = extraout_CL_01, - uVar3 == 0)))) || - (challengeParams = Game::GetChallengeParams(g_game), bVar1 = extraout_CL_02, - challengeParams->_pathType != 2)) goto LAB_0071fe18; - } - tmpPath[0] = msvc::_Allocate(0x20); - tmpPathSize = 0x1f; - tmpPathCapacity = 0x1f; - builtin_strncpy(tmpPath[0],"gfx/grid/door_11_corpsehole.png",0x20); - local_8 = 8; - (GHIDRA_CAST((GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)))))->Sprite::ReplaceSpritesheet(0,GHIDRA_CAST(tmpPath)); - local_8 = 0xffffffff; - bVar1 = extraout_CL_03; - if (0xf < tmpPathCapacity) { - uVar3 = tmpPathCapacity + 1; - freeBlock = tmpPath[0]; - if (0xfff < uVar3) { - freeBlock = *GHIDRA_CAST((tmpPath[0] + -4)); - pcVar2 = tmpPath[0] + (-4 - GHIDRA_INT(freeBlock)); - goto joined_r0x0071fe08; - } - goto LAB_0071fe0e; - } - } -LAB_0071fe18: - ANM2::LoadGraphics(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),bVar1); - goto LAB_0071feb0; - } - anm2Path._size = 0; - anm2Path._capacity = 0xf; - anm2Path._buf[0] = '\0'; - anm2Path._buf[1] = '\0'; - anm2Path._buf[2] = '\0'; - anm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) = msvc::_Allocate(0x30); - anm2Path._size = 0x21; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))),"gfx/grid/trapdoor_corpse_big.anm2",0x22); - local_8 = 5; -LAB_0071f766: - anm2Path._capacity = 0x2f; - ANM2::Load(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),&anm2Path,1); - local_8 = 0xffffffff; - if (anm2Path._capacity < 0x10) goto LAB_0071feb0; - uVar3 = anm2Path._capacity + 1; - freeBlock = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anm2Path._buf))) + 0x0))); - if (0xfff < uVar3) { - uVar3 = anm2Path._capacity + 0x24; - freeBlock = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4)); - if (GHIDRA_CAST(0x1f) < - GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(*GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anm2Path._buf)) + 0x0))) + -4))))))) - goto LAB_0071f7a4; - } - } -LAB_0071fb7a: - local_8 = 0xffffffff; - operator_delete(freeBlock,uVar3); -LAB_0071feb0: - *GHIDRA_CAST((GHIDRA_CAST(local_54.y) + 0xc)) = 0; - ANM2::Play(GHIDRA_CAST((GHIDRA_INT(local_54.y) + 0x40)),GHIDRA_CAST("Closed"),0); - ExceptionList = local_10; - return; -} - -// 0071fef0 -void GridEntity_TrapDoor::Update() -{ - uint32_t *puVar1; - char *pcVar2; - uint64_t qVar3; - undefined3 uVar4; - uint8_t bVar5; - Entity_Player *pEVar6; - uint32_t forcedCurses; - uint32_t preventedCurses; - int iVar7; - uint8_t *animNameCursor; - uint8_t *pbVar8; - char *******pppppppcVar9; - uint32_t *playerSlot; - ChallengeParam *challengeParams; - uint32_t preventedCurses; - uint32_t uVar11; - int *piVar12; - char *pcVar13; - void *pvVar14; - Level *this_00; - Game *this_01; - undefined3 extraout_var; - uint32_t extraout_EDX; - int extraout_EDX_00; - int extraout_EDX_01; - uint64_t *allocatedBytes; - Game *game; - GridEntity_TrapDoor *trapDoor; - PlayerManager *playerManager; - int iVar15; - uint32_t uVar16; - bool bVar17; - float deltaY; - float deltaX; - double dVar18; - EntityList_EL nearbyEntities; - float local_58; - uint32_t local_54; - GridEntity_TrapDoor *savedTrapDoor; - Vector local_4c; - Entity_Player *local_44; - float local_40; - int *local_3c; - char local_35; - int *local_34; - char local_2d; - char *******spritePath [4]; - uint32_t spritePathSize; - uint32_t spritePathCapacity; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - char ******local_8; - Manager *manager; - RoomDescriptor *roomDesc; - - game = g_game; - local_8 = GHIDRA_CAST(0xffffffff); - puStack_c = &LAB_00afccc9; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT((spritePath + 10)); - ExceptionList = &local_10; - local_54 = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))) + 1; - iVar15 = *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0xc)); - local_4c.x = (float)(this->_gridIndex % iVar15) * 40.0 + 40.0; - local_4c.y = (float)(this->_gridIndex / iVar15) * 40.0 + 120.0; - savedTrapDoor = this; - local_44 = Game::GetNearestPlayerEx(&local_4c,1,0,0); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = false; - local_40 = 1e+09; - local_58 = 21.0; - pvVar14 = g_game->_room; - if ((((*GHIDRA_CAST((GHIDRA_CAST(pvVar14) + 8)) == 5) && - (piVar12 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar14) + 4)) + 0x10)), *piVar12 == 0)) && - (piVar12[4] == 0x58)) && (this->_varData != 1)) { - local_35 = '\x01'; - local_58 = 34.0; - } - else { - local_35 = '\0'; - } - iVar15 = this->_gridIndex; - if (local_44 == GHIDRA_CAST(0x0)) { - local_3c = *GHIDRA_CAST((GHIDRA_CAST(pvVar14) + 0xc)); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))) = extraout_var; - } - else { - local_3c = *GHIDRA_CAST((GHIDRA_CAST(pvVar14) + 0xc)); - deltaY = ((float)(iVar15 / GHIDRA_INT(local_3c)) * 40.0 + 120.0) - (local_44->_pos).y; - deltaX = ((float)(iVar15 % GHIDRA_INT(local_3c)) * 40.0 + 40.0) - (local_44->_pos).x; - local_40 = sqrtf(deltaY * deltaY + deltaX * deltaX); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = local_40 < 50.0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))) = (undefined3)(GHIDRA_UINT(extraout_EDX) >> 8); - } - if (((g_manager->_netplayManager != *GHIDRA_CAST((g_manager + 1))) && - (1 < GHIDRA_UINT((*GHIDRA_CAST((g_manager + 1)) - g_manager->_netplayManager >> 2)))) && - ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) < 2 && ((*GHIDRA_CAST((GHIDRA_CAST(pvVar14) + 8)) == 5 && (local_35 == '\0')))))) - { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))) = (undefined3)(GHIDRA_UINT(this) >> 8); - if (((bool)(char)local_34 == false) && (0x95 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x154)))))) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = false; - } - else { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = true; - } - } - uVar4 = (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))); - bVar17 = (bool)(char)local_34; - local_4c.x = (float)(iVar15 % GHIDRA_INT(local_3c)) * 40.0 + 40.0; - local_4c.y = (float)(iVar15 / GHIDRA_INT(local_3c)) * 40.0 + 120.0; - EntityList::QueryRadius(GHIDRA_CAST((GHIDRA_INT(pvVar14) + 0x1218)),&nearbyEntities,&local_4c,20.0,1); - preventedCurses = 0; - local_8 = GHIDRA_CAST(0x0); - if (nearbyEntities._size != 0) { - do { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))) = uVar4; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = bVar17; - if ((bool)(char)local_34 != false) break; - iVar15 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + preventedCurses * 4)); - if (*GHIDRA_CAST((iVar15 + 0x28)) == 3) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = false; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))) = 0; - if (*GHIDRA_CAST((iVar15 + 0x2c)) == 900) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = true; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))) = 0; - } - } - preventedCurses = preventedCurses + 1; - bVar17 = (bool)(char)local_34; - uVar4 = (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))); - } while (preventedCurses < GHIDRA_UINT(nearbyEntities._size)); - } - if ((((g_game->_difficulty != 2) && (g_game->_difficulty != 3)) && - (pEVar6 = PlayerManager::FirstCollectibleOwner - (&g_game->_playerManager,0x226,GHIDRA_CAST(&g_game->_playerManager),1), - pEVar6 != GHIDRA_CAST(0x0))) && (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)) != 3)) { - iVar15 = g_game->_stage; - preventedCurses = g_game->_debugCurses; - uVar11 = g_game->_curses; - forcedCurses = Seeds::GetForcedCurses(); - preventedCurses = Seeds::GetPreventedCurses(); - game = g_game; - iVar7 = iVar15 + 1; - if ((~preventedCurses & (forcedCurses | preventedCurses | uVar11) & 2) == 0) { - iVar7 = iVar15; - } - if (iVar7 == 6) { - if ((*GHIDRA_CAST((*GHIDRA_CAST(ThreadLocalStoragePointer) + 0xc)) < g_invalidRoomDescriptorGuard) && - (_Init_thread_header(), g_invalidRoomDescriptorGuard == -1)) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 1; - RoomDescriptor::constructor(&g_roomDescriptorDummy); - _atexit(FUN_00b15b30); - local_8 = GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_UINT(local_8))) + 0x1))) << 8)); - _Init_thread_footer(&g_invalidRoomDescriptorGuard); - } - roomDesc = &g_roomDescriptorDummy; - if (GHIDRA_UINT(game->_currentDimensionIdx) < 3) { - roomDesc = game->_roomList + 0x1ff; - } - if ((GHIDRA_UINT(roomDesc->Flags) >> 3 & 1) == 0) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = '\x01'; - } - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x1))) = 0; - } - } - game = g_game; - local_4c.y = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)); - if ((GHIDRA_CAST(local_4c.y) == GHIDRA_CAST(0x1b)) && - ((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 4)) + 0x44)) & 1) == 0)) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = '\x01'; - } - local_3c = GHIDRA_CAST(g_game->_stage); - if (((0 < GHIDRA_INT(local_3c)) && (GHIDRA_INT(local_3c) < 7)) && - ((g_game->_gameStateFlags & 0x1000000000000) != 0)) { - (*GHIDRA_CAST((GHIDRA_CAST(&(local_34)) + 0x0))) = '\x01'; - } - if ((g_game->_dailyChallenge)._id == 0) { - pvVar14 = (g_manager->_challengeParams)._begin; - uVar11 = (GHIDRA_INT((g_manager->_challengeParams)._end) - GHIDRA_INT(pvVar14)) / 0xa4 - 1; - preventedCurses = -GHIDRA_UINT((g_game->_challenge != 0)) & g_game->_challenge; - if (uVar11 <= preventedCurses) { - preventedCurses = uVar11; - } - challengeParams = GHIDRA_CAST((preventedCurses * 0xa4 + GHIDRA_INT(pvVar14))); - } - else { - challengeParams = &(g_game->_dailyChallenge)._params; - } - if (challengeParams->_pathType == 2) { - preventedCurses = g_game->_curses; - uVar11 = g_game->_debugCurses; - forcedCurses = Seeds::GetForcedCurses(); - preventedCurses = Seeds::GetPreventedCurses(); - piVar12 = GHIDRA_CAST((GHIDRA_INT(local_3c) + 1)); - if ((~preventedCurses & (forcedCurses | preventedCurses | uVar11) & 2) == 0) { - piVar12 = local_3c; - } - local_3c = piVar12; - if (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x1b) { - preventedCurses = game->_curses; - uVar11 = game->_debugCurses; - forcedCurses = Seeds::GetForcedCurses(); - preventedCurses = Seeds::GetPreventedCurses(); - preventedCurses = (~preventedCurses & (forcedCurses | preventedCurses | uVar11)) >> 1; - if ((local_3c == GHIDRA_CAST(0x2)) || (((preventedCurses & 1) != 0 && (local_3c == GHIDRA_CAST(0x1))))) { - bVar17 = true; - } - else { - bVar17 = false; - } - if ((local_3c == GHIDRA_CAST(&DAT_00000004)) || (((preventedCurses & 1) != 0 && (local_3c == GHIDRA_CAST(0x3))))) { - local_2d = '\x01'; - } - else { - local_2d = '\0'; - } - if ((bVar17) && ((game->_stageType == 4 || (game->_stageType == 5)))) { - pEVar6 = PlayerManager::FirstCollectibleOwner - (&game->_playerManager,0x272,GHIDRA_CAST(&game->_playerManager),1); - if (pEVar6 == GHIDRA_CAST(0x0)) goto LAB_0072040a; - game = g_game; - } - if ((local_2d == '\0') || - (((game->_stageType != 4 && (game->_stageType != 5)) || - (pEVar6 = PlayerManager::FirstCollectibleOwner - (&game->_playerManager,0x273,GHIDRA_CAST(&game->_playerManager),1), - pEVar6 != GHIDRA_CAST(0x0))))) goto LAB_00720400; - } - else { - if (piVar12 != GHIDRA_CAST(&DAT_00000006)) { - preventedCurses = game->_curses; - uVar11 = game->_debugCurses; - forcedCurses = Seeds::GetForcedCurses(); - preventedCurses = Seeds::GetPreventedCurses(); - if (((~preventedCurses & (forcedCurses | preventedCurses | uVar11) & 2) == 0) || - (local_3c != GHIDRA_CAST(&DAT_00000005))) goto LAB_00720400; - } - if (((game->_stageType != 4) && (game->_stageType != 5)) || - (((bVar5 = Level::IsMausoleumHeartStage(GHIDRA_CAST(game)), bVar5 != 0 || - (GHIDRA_CAST(local_4c.y) == GHIDRA_CAST(0x12))) || - (GHIDRA_CAST(local_4c.y) == GHIDRA_CAST(0x3))))) goto LAB_00720400; - } -LAB_0072040a: - trapDoor = savedTrapDoor; - piVar12 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((savedTrapDoor)) + 0xc)))); - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((savedTrapDoor)) + 0xc)))) != 0) goto LAB_00720515; - pbVar8 = (savedTrapDoor->_sprite)._animState._animData; - local_34 = piVar12; - if (pbVar8 == GHIDRA_CAST(0x0)) { -LAB_00720469: - bVar5 = ANM2::SetAnimation(&savedTrapDoor->_sprite,GHIDRA_CAST("Closed"),1); - if (bVar5 != 0) { - AnimationState::Rewind(&(trapDoor->_sprite)._animState); - (trapDoor->_sprite)._animState._isPlaying = 1; - } - } - else { - animNameCursor = pbVar8; - if (0xf < *GHIDRA_CAST((pbVar8 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar8); - } - pcVar13 = "Closed"; - do { - bVar5 = *animNameCursor; - bVar17 = bVar5 < (uint8_t)*pcVar13; - if (bVar5 != *pcVar13) { -LAB_00720453: - preventedCurses = -GHIDRA_UINT(bVar17) | 1; - goto LAB_00720458; - } - if (bVar5 == 0) break; - bVar5 = animNameCursor[1]; - bVar17 = bVar5 < (uint8_t)pcVar13[1]; - if (bVar5 != pcVar13[1]) goto LAB_00720453; - animNameCursor = animNameCursor + 2; - pcVar13 = pcVar13 + 2; - } while (bVar5 != 0); - preventedCurses = 0; -LAB_00720458: - if ((preventedCurses != 0) || - ((pbVar8[0x34] != 0 && ((savedTrapDoor->_sprite)._animState._isPlaying == 0)))) - goto LAB_00720469; - } - piVar12 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((trapDoor)) + 0xc)))); -LAB_0072048e: - game = g_game; - } - else { -LAB_00720400: - if ((char)local_34 != '\0') goto LAB_0072040a; - piVar12 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((savedTrapDoor)) + 0xc)))); -LAB_00720515: - trapDoor = savedTrapDoor; - local_3c = piVar12; - local_34 = piVar12; - if (*piVar12 == 1) goto LAB_0072048e; - game = g_game; - if (g_game->_challenge != 0x1f) { - if ((savedTrapDoor->_sprite)._animState._animData == (void *)0x0) { -LAB_007205c9: - pbVar8 = (savedTrapDoor->_sprite)._animState._animData; - if (pbVar8 != GHIDRA_CAST(0x0)) { - animNameCursor = pbVar8; - if (0xf < *GHIDRA_CAST((pbVar8 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar8); - } - pcVar13 = "Open Animation"; - do { - bVar5 = *animNameCursor; - bVar17 = bVar5 < (uint8_t)*pcVar13; - if (bVar5 != *pcVar13) { -LAB_00720600: - preventedCurses = -GHIDRA_UINT(bVar17) | 1; - goto LAB_00720605; - } - if (bVar5 == 0) break; - bVar5 = animNameCursor[1]; - bVar17 = bVar5 < (uint8_t)pcVar13[1]; - if (bVar5 != pcVar13[1]) goto LAB_00720600; - animNameCursor = animNameCursor + 2; - pcVar13 = pcVar13 + 2; - } while (bVar5 != 0); - preventedCurses = 0; -LAB_00720605: - if ((preventedCurses == 0) && - ((pbVar8[0x34] == 0 || ((savedTrapDoor->_sprite)._animState._isPlaying != 0)))) - goto LAB_00720642; - } - bVar5 = ANM2::SetAnimation(&savedTrapDoor->_sprite,GHIDRA_CAST("Open Animation"),1); - if (bVar5 != 0) { - AnimationState::Rewind(&(trapDoor->_sprite)._animState); - (trapDoor->_sprite)._animState._isPlaying = 1; - } - } - else { - pbVar8 = (savedTrapDoor->_sprite)._animState._animData; - if ((savedTrapDoor->_sprite)._animState._isPlaying == 0) { - if (0xf < *GHIDRA_CAST((pbVar8 + 0x14))) { - pbVar8 = *GHIDRA_CAST(pbVar8); - } - pcVar13 = "Open Animation"; - do { - bVar5 = *pbVar8; - bVar17 = bVar5 < (uint8_t)*pcVar13; - if (bVar5 != *pcVar13) { -LAB_007205c0: - preventedCurses = -GHIDRA_UINT(bVar17) | 1; - goto joined_r0x007205c7; - } - if (bVar5 == 0) break; - bVar5 = pbVar8[1]; - bVar17 = bVar5 < (uint8_t)pcVar13[1]; - if (bVar5 != pcVar13[1]) goto LAB_007205c0; - pbVar8 = pbVar8 + 2; - pcVar13 = pcVar13 + 2; - } while (bVar5 != 0); - preventedCurses = 0; - } - else { - if (0xf < *GHIDRA_CAST((pbVar8 + 0x14))) { - pbVar8 = *GHIDRA_CAST(pbVar8); - } - pcVar13 = "Open Animation"; - do { - bVar5 = *pbVar8; - bVar17 = bVar5 < (uint8_t)*pcVar13; - if (bVar5 != *pcVar13) { -LAB_00720580: - preventedCurses = -GHIDRA_UINT(bVar17) | 1; - goto joined_r0x007205c7; - } - if (bVar5 == 0) break; - bVar5 = pbVar8[1]; - bVar17 = bVar5 < (uint8_t)pcVar13[1]; - if (bVar5 != pcVar13[1]) goto LAB_00720580; - pbVar8 = pbVar8 + 2; - pcVar13 = pcVar13 + 2; - } while (bVar5 != 0); - preventedCurses = 0; - } -joined_r0x007205c7: - if (preventedCurses != 0) goto LAB_007205c9; - } -LAB_00720642: - game = g_game; - if (((trapDoor->_sprite)._animState._animData == (void *)0x0) || - ((trapDoor->_sprite)._animState._isPlaying == 0)) { -LAB_00720701: - local_2d = '\0'; - } - else { - pbVar8 = (trapDoor->_sprite)._animState._animData; - if (0xf < *GHIDRA_CAST((pbVar8 + 0x14))) { - pbVar8 = *GHIDRA_CAST(pbVar8); - } - pcVar13 = "Open Animation"; - do { - bVar5 = *pbVar8; - bVar17 = bVar5 < (uint8_t)*pcVar13; - if (bVar5 != *pcVar13) { -LAB_00720690: - preventedCurses = -GHIDRA_UINT(bVar17) | 1; - goto LAB_00720695; - } - if (bVar5 == 0) break; - bVar5 = pbVar8[1]; - bVar17 = bVar5 < (uint8_t)pcVar13[1]; - if (bVar5 != pcVar13[1]) goto LAB_00720690; - pbVar8 = pbVar8 + 2; - pcVar13 = pcVar13 + 2; - } while (bVar5 != 0); - preventedCurses = 0; -LAB_00720695: - if (preventedCurses != 0) goto LAB_00720701; - local_4c.y = (trapDoor->_sprite)._animState._animFrame; - dVar18 = floor((double)local_4c.y); - local_4c.y = (float)dVar18; - if (GHIDRA_INT(dVar18) != 1) goto LAB_00720701; - (GHIDRA_CAST((GHIDRA_CAST(spritePath))))->msvc::string::string(&trapDoor->_sprite); - local_54 = 3; - pppppppcVar9 = GHIDRA_CAST(spritePath); - if (0xf < spritePathCapacity) { - pppppppcVar9 = spritePath[0]; - } - iVar15 = _strnicmp(GHIDRA_CAST(pppppppcVar9),"gfx/grid/Door_11_TrapDoor",0x19); - local_2d = '\x01'; - game = g_game; - if (iVar15 != 0) goto LAB_00720701; - } - if ((local_54 & 1) != 0) { - if (0xf < spritePathCapacity) { - preventedCurses = spritePathCapacity + 1; - pppppppcVar9 = spritePath[0]; - if (0xfff < preventedCurses) { - pppppppcVar9 = GHIDRA_CAST(spritePath[0][-1]); - preventedCurses = spritePathCapacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST((GHIDRA_INT(spritePath[0]) + (-4 - GHIDRA_INT(pppppppcVar9))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pppppppcVar9,preventedCurses); - game = g_game; - } - spritePathSize = 0; - spritePathCapacity = 0xf; - spritePath[0] = GHIDRA_CAST((GHIDRA_UINT(spritePath[0]) & 0xffffff00)); - } - manager = g_manager; - if (local_2d != '\0') { - local_54 = 0x395; - seed_fart_sound_override(GHIDRA_CAST(&local_54)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(local_54,1.0,2,0,1.0,0.0); - game = g_game; - } - piVar12 = local_3c; - if (((trapDoor->_sprite)._animState._animData == (void *)0x0) || - ((trapDoor->_sprite)._animState._isPlaying == 0)) { - local_34 = local_3c; - *local_3c = 1; - } - else { - local_34 = local_3c; - } - } - } - if ((game->_difficulty == 2) || (game->_difficulty == 3)) { - if (((*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 4)) + 0x44)) & 1) == 0) && - (trapDoor->_spawnFrame <= *GHIDRA_CAST((GHIDRA_CAST(game->_room) + 0x11f0)))) { - pbVar8 = (trapDoor->_sprite)._animState._animData; - if (pbVar8 == GHIDRA_CAST(0x0)) { -LAB_007207ef: - bVar5 = ANM2::SetAnimation(&trapDoor->_sprite,GHIDRA_CAST("Closed"),1); - if (bVar5 != 0) { - AnimationState::Rewind(&(trapDoor->_sprite)._animState); - (trapDoor->_sprite)._animState._isPlaying = 1; - } - game = g_game; - } - else { - animNameCursor = pbVar8; - if (0xf < *GHIDRA_CAST((pbVar8 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar8); - } - pcVar13 = "Closed"; - do { - bVar5 = *animNameCursor; - bVar17 = bVar5 < (uint8_t)*pcVar13; - if (bVar5 != *pcVar13) { -LAB_007207d1: - preventedCurses = -GHIDRA_UINT(bVar17) | 1; - goto LAB_007207d6; - } - if (bVar5 == 0) break; - bVar5 = animNameCursor[1]; - bVar17 = bVar5 < (uint8_t)pcVar13[1]; - if (bVar5 != pcVar13[1]) goto LAB_007207d1; - animNameCursor = animNameCursor + 2; - pcVar13 = pcVar13 + 2; - } while (bVar5 != 0); - preventedCurses = 0; -LAB_007207d6: - if ((preventedCurses != 0) || - ((pbVar8[0x34] != 0 && ((trapDoor->_sprite)._animState._isPlaying == 0)))) - goto LAB_007207ef; - } - *local_34 = 0; - piVar12 = local_34; - } - } - if (*piVar12 == 1) { - bVar5 = Level::IsMausoleumHeartStage(GHIDRA_CAST(game)); - if ((bVar5 == 0) || (trapDoor->_varData != 0)) { - pbVar8 = (trapDoor->_sprite)._animState._animData; - if (pbVar8 != GHIDRA_CAST(0x0)) { - animNameCursor = pbVar8; - if (0xf < *GHIDRA_CAST((pbVar8 + 0x14))) { - animNameCursor = *GHIDRA_CAST(pbVar8); - } - pcVar13 = "Opened"; - do { - bVar5 = *animNameCursor; - bVar17 = bVar5 < (uint8_t)*pcVar13; - if (bVar5 != *pcVar13) { -LAB_007208b0: - preventedCurses = -GHIDRA_UINT(bVar17) | 1; - goto LAB_007208b5; - } - if (bVar5 == 0) break; - bVar5 = animNameCursor[1]; - bVar17 = bVar5 < (uint8_t)pcVar13[1]; - if (bVar5 != pcVar13[1]) goto LAB_007208b0; - animNameCursor = animNameCursor + 2; - pcVar13 = pcVar13 + 2; - } while (bVar5 != 0); - preventedCurses = 0; -LAB_007208b5: - if ((preventedCurses == 0) && - ((pbVar8[0x34] == 0 || ((trapDoor->_sprite)._animState._isPlaying != 0)))) - goto LAB_007208e8; - } - bVar5 = ANM2::SetAnimation(&trapDoor->_sprite,GHIDRA_CAST("Opened"),1); - if (bVar5 != 0) { - AnimationState::Rewind(&(trapDoor->_sprite)._animState); - (trapDoor->_sprite)._animState._isPlaying = 1; - } - } - else { - bVar5 = ANM2::SetAnimation(&trapDoor->_sprite,GHIDRA_CAST("Opened"),1); - if (((bVar5 != 0) && ((trapDoor->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(trapDoor->_sprite)._animState,0.0), - (trapDoor->_sprite)._animState._animData != (void *)0x0)) { - (trapDoor->_sprite)._animState._isPlaying = 0; - } - } -LAB_007208e8: - piVar12 = local_34; - game = g_game; - } - pEVar6 = local_44; - manager = g_manager; - if (((local_44 == GHIDRA_CAST(0x0)) || (local_58 <= local_40)) || (*piVar12 != 1)) - goto LAB_00720a92; - if ((local_44->_isPlayingExtraAnimation != 0) || (local_44->_isPlayingItemAnimation != 0)) { - if ((local_44->_heldEntity == (void *)0x0) || - (local_44->_heldEntity != (void *)local_44->_twinPlayer)) goto LAB_00720a92; - } - if (local_35 != '\0') { - local_40 = 1.47417e-42; - seed_fart_sound_override(GHIDRA_CAST(&local_40)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_40),1.0,2,0,1.0,0.0); - game = g_game; - g_game->_leaveDoor = -1; - Game::StartRoomTransition(game,-10,-1,0x16,local_44,-1); - preventedCurses = 0; - playerManager = &g_game->_playerManager; - game = g_game; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) >> - 2 != 0) { - do { - pvVar14 = (playerManager->_playerList)._end; - if (GHIDRA_INT(pvVar14) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - pvVar14 = (playerManager->_playerList)._end; - game = g_game; - } - playerSlot = (playerManager->_playerList)._begin; - if (preventedCurses < GHIDRA_UINT((GHIDRA_INT(pvVar14) - GHIDRA_INT(playerSlot) >> 2))) { - playerSlot = playerSlot + preventedCurses; - } - pEVar6 = GHIDRA_CAST(*playerSlot); - if (pEVar6->_variant == 0) { - Entity_Player::PlayExtraAnimation(pEVar6,GHIDRA_CAST("Trapdoor")); - game = g_game; - iVar15 = savedTrapDoor->_gridIndex; - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - (pEVar6->_moveToTarget).x = (float)(iVar15 % iVar7) * 40.0 + 40.0; - (pEVar6->_moveToTarget).y = (float)(iVar15 / iVar7) * 40.0 + 120.0; - } - playerManager = &game->_playerManager; - preventedCurses = preventedCurses + 1; - } while (preventedCurses < GHIDRA_UINT((GHIDRA_INT((game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - goto LAB_00720a92; - } - if (game->_currentRoomIdx == -0x14) { - Game::StartRoomTransition(game,-2,-1,2,local_44,-1); - } - else { - local_40 = 1.47417e-42; - seed_fart_sound_override(GHIDRA_CAST(&local_40)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_40),1.0,2,0,1.0,0.0); - if ((*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 8)) == 0x1b) || - (bVar5 = Level::IsMausoleumHeartStage(GHIDRA_CAST(g_game)), bVar5 != 0)) { - game = g_game; - qVar3 = g_game->_gameStateFlags; - puVar1 = GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - *puVar1 = *puVar1 | 0x1000; - *GHIDRA_CAST(&game->_gameStateFlags) = GHIDRA_INT(qVar3); - bVar5 = Level::HasPhotoDoor(GHIDRA_CAST(game)); - game = g_game; - if (bVar5 == 0) goto LAB_00720c10; - qVar3 = g_game->_gameStateFlags; - puVar1 = GHIDRA_CAST((GHIDRA_INT(&g_game->_gameStateFlags) + 4)); - *puVar1 = *puVar1 | 0x8000; - *GHIDRA_CAST(&game->_gameStateFlags) = GHIDRA_INT(qVar3); - } - else { -LAB_00720c10: - game = g_game; - } - bVar5 = Game::IsInTimedSet(game,0x10); - if (bVar5 == 0) { - if (10 < game->_stage) { - iVar15 = _get_index_plus_one_if_kind_4_5(); - Seeds::ForgetStageSeed(&game->_seedEffects,iVar15); - game = g_game; - } - if (trapDoor->_varData == 1) { - Game::StartStageTransition(game,0,3,GHIDRA_CAST(0x0)); - pEVar6 = local_44; - } - else { - preventedCurses = Level::filter_curses(GHIDRA_CAST(game),2); - game = g_game; - local_2d = preventedCurses != 0; - bVar5 = Level::IsAltPath(GHIDRA_CAST(g_game)); - if ((bVar5 == 0) || - ((extraout_EDX_00 != 2 && ((extraout_EDX_00 != 1 || (local_2d == '\0')))))) { - local_35 = '\0'; - } - else { - local_35 = '\x01'; - } - bVar5 = Level::IsAltPath(this_00); - if ((bVar5 == 0) || - ((extraout_EDX_01 != 4 && ((extraout_EDX_01 != 3 || (local_2d == '\0')))))) { - local_2d = '\0'; - } - else { - local_2d = '\x01'; - } - challengeParams = Game::GetChallengeParams(this_01); - if ((challengeParams->_pathType == 2) && (game->_challenge != 0x2c)) { - if (local_35 == '\0') { -LAB_00720d10: - if (local_2d != '\0') { - pEVar6 = PlayerManager::FirstCollectibleOwner - (&game->_playerManager,0x273,GHIDRA_CAST(&game->_playerManager),1); - if (pEVar6 == GHIDRA_CAST(0x0)) goto LAB_00720d35; - game = g_game; - } - goto LAB_00720e0b; - } - pEVar6 = PlayerManager::FirstCollectibleOwner - (&game->_playerManager,0x272,GHIDRA_CAST(&game->_playerManager),1); - if (pEVar6 != GHIDRA_CAST(0x0)) { - game = g_game; - goto LAB_00720d10; - } -LAB_00720d35: - Game::StartRoomTransition(g_game,g_game->_startingRoomIdx,-1,0x16,local_44,0); - preventedCurses = 0; - game = g_game; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) { - do { - local_4c.y = (float)Game::GetPlayer(game,preventedCurses); - if ((GHIDRA_CAST(local_4c.y))->_variant == 0) { - Entity_Player::PlayExtraAnimation(GHIDRA_CAST(local_4c.y),GHIDRA_CAST("Trapdoor")); - game = g_game; - iVar15 = trapDoor->_gridIndex; - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - (GHIDRA_CAST((GHIDRA_INT(local_4c.y) + 0x1b1c)))->x = (float)(iVar15 % iVar7) * 40.0 + 40.0; - (GHIDRA_CAST((GHIDRA_INT(local_4c.y) + 0x1b1c)))->y = (float)(iVar15 / iVar7) * 40.0 + 120.0; - } - else { - game = g_game; - } - preventedCurses = preventedCurses + 1; - } while (preventedCurses < GHIDRA_UINT((GHIDRA_INT((game->_playerManager)._playerList._end) - - GHIDRA_INT((game->_playerManager)._playerList._begin) >> 2))); - pEVar6 = local_44; - goto LAB_00720b0f; - } - } - else { -LAB_00720e0b: - Game::StartStageTransition(game,0,0,GHIDRA_CAST(0x0)); - } - pEVar6 = local_44; - } - } - else { - Game::StartStageTransition(game,1,0,GHIDRA_CAST(0x0)); - pEVar6 = local_44; - } - } -LAB_00720b0f: - Entity_Player::PlayExtraAnimation(pEVar6,GHIDRA_CAST("Trapdoor")); - game = g_game; - iVar15 = trapDoor->_gridIndex; - iVar7 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - (pEVar6->_moveToTarget).x = (float)(iVar15 % iVar7) * 40.0 + 40.0; - (pEVar6->_moveToTarget).y = (float)(iVar15 / iVar7) * 40.0 + 120.0; -LAB_00720a92: - trapDoor = savedTrapDoor; - pcVar13 = game->_room; - local_4c.y = (float)pcVar13; - if (((*pcVar13 != '\0') && - (iVar15 = game->_frameCount - *GHIDRA_CAST((pcVar13 + 0x11f0)), iVar15 == (iVar15 / 0xf) * 0xf)) && - (((game->_stage == 9 && (game->_currentRoomIdx == -9)) || (savedTrapDoor->_varData == 1)))) { - bVar17 = game->_currentRoomIdx != -7; - if (bVar17) { - local_44 = GHIDRA_CAST(0x3d4ccccd); - } - else { - local_44 = GHIDRA_CAST(0x3cf5c28f); - } - uVar16 = 6; - if (bVar17) { - uVar16 = 0xd; - } - if (*local_34 != 1) { - local_44 = GHIDRA_CAST(((float)local_44 * 0.2)); - } - iVar15 = savedTrapDoor->_gridIndex; - *GHIDRA_CAST((pcVar13 + 0x70fc)) = *GHIDRA_CAST((pcVar13 + 0x70fc)) + 1; - local_4c.y = (float)(iVar15 % *GHIDRA_CAST((pcVar13 + 0xc))) * 40.0 + 40.0; - local_40 = (float)(iVar15 / *GHIDRA_CAST((pcVar13 + 0xc))) * 40.0 + 120.0; - local_58 = (float)(*GHIDRA_CAST((pcVar13 + 0x70fc)) & 0x80000001); - if (GHIDRA_INT(local_58) < 0) { - local_58 = (float)((GHIDRA_INT(local_58) - 1U | 0xfffffffe) + 1); - } - if (1 < GHIDRA_UINT(local_58)) { - KAGE_LogMessage(0x10,GHIDRA_CAST("Shockwave id is too large!")); - } - iVar15 = GHIDRA_INT(local_58) + 0x407; - *GHIDRA_CAST((pcVar13 + iVar15 * 0x1c)) = local_4c.y; - *GHIDRA_CAST((pcVar13 + iVar15 * 0x1c + 4)) = local_40; - pcVar2 = pcVar13 + iVar15 * 0x1c + 8; - pcVar2[0] = '\0'; - pcVar2[1] = '\0'; - pcVar2[2] = '\0'; - pcVar2[3] = '\0'; - *GHIDRA_CAST((pcVar13 + iVar15 * 0x1c + 0xc)) = local_44; - pcVar2 = pcVar13 + iVar15 * 0x1c + 0x10; - pcVar2[0] = -0xc; - pcVar2[1] = -3; - pcVar2[2] = 'T'; - pcVar2[3] = '<'; - pcVar2 = pcVar13 + iVar15 * 0x1c + 0x14; - pcVar2[0] = '\0'; - pcVar2[1] = '\0'; - pcVar2[2] = '\0'; - pcVar2[3] = '\0'; - *GHIDRA_CAST((pcVar13 + iVar15 * 0x1c + 0x18)) = uVar16; - } - if ((trapDoor->_sprite)._loaded != 0) { - AnimationState::Update(&(trapDoor->_sprite)._animState); - AnimationState::Update(&(trapDoor->_sprite)._overlayAnimState); - } - if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x0))) == '\0') { - if (g_mainHeap == (void *)0x0) { - allocatedBytes = &g_allocatedBytesNoHeap; - } - else { - allocatedBytes = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); - } - if ((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) != 0) { - preventedCurses = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + -4)); - qVar3 = *allocatedBytes; - *GHIDRA_CAST(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - preventedCurses; - *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) = - *GHIDRA_CAST((GHIDRA_CAST(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar3) < preventedCurses)); - free((void *)((*GHIDRA_CAST((GHIDRA_CAST(&(nearbyEntities)) + 0x4))) + -4)); - } - } - ExceptionList = local_10; - return; -} diff --git a/generated-src/grid_entity_wall.cpp b/generated-src/grid_entity_wall.cpp deleted file mode 100644 index c658e3c..0000000 --- a/generated-src/grid_entity_wall.cpp +++ /dev/null @@ -1,195 +0,0 @@ -#include "classes.h" - -// 007210d0 -void GridEntity_Wall::BeginBatches() -{ - void *room; - char *pathBuffer; - char *ptr; - uint32_t size; - std_string dungeonAnm2Path; - std_string bossDungeonAnm2Path; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - Game *game; - uint32_t pathCapacity; - void *savedExceptionList; - - savedExceptionList = ExceptionList; - game = g_game; - local_8 = 0xffffffff; - puStack_c = &LAB_00afcd0d; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&bossDungeonAnm2Path)[1]._size); - ExceptionList = &local_10; - this->_collisionClass = 4; - room = game->_room; - if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) { - *GHIDRA_CAST((GHIDRA_CAST(room) + this->_gridIndex * 4 + 0x76c)) = 1000; - room = game->_room; - } - if (*GHIDRA_CAST((GHIDRA_CAST(room) + 8)) != 0x10) { - ExceptionList = savedExceptionList; - return; - } - if (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x1d18)) == 0x37) { - bossDungeonAnm2Path._size = 0; - bossDungeonAnm2Path._capacity = 0xf; - bossDungeonAnm2Path._buf[0] = '\0'; - bossDungeonAnm2Path._buf[1] = '\0'; - bossDungeonAnm2Path._buf[2] = '\0'; - bossDungeonAnm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(bossDungeonAnm2Path._buf)) + 0x0))) = msvc::_Allocate(0x30); - bossDungeonAnm2Path._size = 0x26; - bossDungeonAnm2Path._capacity = 0x2f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(bossDungeonAnm2Path._buf))) + 0x0))),"gfx/grid/Tiles_Itemdungeon_Gideon.anm2", - 0x27); - local_8 = 0; - } - else { - if (*GHIDRA_CAST((GHIDRA_CAST(room) + 0x1d18)) != 0x38) { - dungeonAnm2Path._size = 0; - dungeonAnm2Path._capacity = 0xf; - dungeonAnm2Path._buf[0] = '\0'; - dungeonAnm2Path._buf[1] = '\0'; - dungeonAnm2Path._buf[2] = '\0'; - dungeonAnm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(dungeonAnm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - dungeonAnm2Path._size = 0x1f; - dungeonAnm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(dungeonAnm2Path._buf))) + 0x0))),"gfx/grid/Tiles_Itemdungeon.anm2",0x20); - local_8 = 2; - ANM2::Load(&this->_sprite,&dungeonAnm2Path,1); - if (dungeonAnm2Path._capacity < 0x10) { - ExceptionList = local_10; - return; - } - pathBuffer = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(dungeonAnm2Path._buf))) + 0x0))); - pathCapacity = dungeonAnm2Path._capacity; - goto LAB_007211c8; - } - bossDungeonAnm2Path._size = 0; - bossDungeonAnm2Path._capacity = 0xf; - bossDungeonAnm2Path._buf[0] = '\0'; - bossDungeonAnm2Path._buf[1] = '\0'; - bossDungeonAnm2Path._buf[2] = '\0'; - bossDungeonAnm2Path._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(bossDungeonAnm2Path._buf)) + 0x0))) = msvc::_Allocate(0x20); - bossDungeonAnm2Path._size = 0x1a; - bossDungeonAnm2Path._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(bossDungeonAnm2Path._buf))) + 0x0))),"gfx/grid/Tiles_Rotgut.anm2",0x1b); - local_8 = 1; - } - ANM2::Load(&this->_sprite,&bossDungeonAnm2Path,1); - if (bossDungeonAnm2Path._capacity < 0x10) { - ExceptionList = local_10; - return; - } - pathBuffer = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(bossDungeonAnm2Path._buf))) + 0x0))); - pathCapacity = bossDungeonAnm2Path._capacity; -LAB_007211c8: - size = pathCapacity + 1; - ptr = pathBuffer; - if (0xfff < size) { - ptr = *GHIDRA_CAST((pathBuffer + -4)); - size = pathCapacity + 0x24; - if (GHIDRA_CAST(0x1f) < pathBuffer + (-4 - GHIDRA_INT(ptr))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(ptr,size); - ExceptionList = local_10; - return; -} - -// 00721310 -void GridEntity_Wall::guard_check_icall() -{ - uint8_t isAnimSet; - uint32_t row; - void *gridBelow; - uint32_t column; - int iVar1; - void *pvVar2; - char *anim; - Vector local_34; - uint8_t animNameBuf [32]; - uint32_t local_c; - uint32_t gridWidth; - Room *room; - - local_c = __security_cookie ^ GHIDRA_UINT(&local_34); - room = g_game->_room; - if (room->_roomType != 0x10) { - return; - } - if (room->_backdropType != 0x38) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 1) { - anim = "Decoration1"; - } - else if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x8)))) == 2) { - anim = "Decoration2"; - } - else { - local_34.x = (float)(this->_gridIndex % room->_gridWidth) * 40.0 + 40.0 + 0.0; - local_34.y = ((float)(this->_gridIndex / room->_gridWidth) * 40.0 + 120.0) - 40.0; - Room::GetGridEntityFromPos(room,&local_34); - Random(); - sprintf_s(animNameBuf,0x1f,&DAT_00b69520); - anim = GHIDRA_CAST(animNameBuf); - } - ANM2::Play(&this->_sprite,GHIDRA_CAST(anim),0); - return; - } - gridWidth = room->_gridWidth; - row = GHIDRA_UINT(this->_gridIndex) / gridWidth; - column = GHIDRA_UINT(this->_gridIndex) % gridWidth; - iVar1 = row - 1; - if ((((GHIDRA_INT(column) < 0) || (GHIDRA_INT(gridWidth) <= GHIDRA_INT(column))) || (iVar1 < 0)) || - (room->_gridHeight <= iVar1)) { - pvVar2 = (void *)0x0; - if ((-1 < GHIDRA_INT(column)) && (GHIDRA_INT(column) < GHIDRA_INT(gridWidth))) goto LAB_00721391; - } - else { - iVar1 = gridWidth * iVar1 + column; - if (iVar1 < 0) { - pvVar2 = (void *)0x0; - } - else { - pvVar2 = room->_gridEntities[iVar1]; - } -LAB_00721391: - iVar1 = row + 1; - if (((-1 < iVar1) && (iVar1 < room->_gridHeight)) && - (iVar1 = gridWidth * iVar1 + column, -1 < iVar1)) { - gridBelow = room->_gridEntities[iVar1]; - goto LAB_007213a9; - } - } - gridBelow = (void *)0x0; -LAB_007213a9: - local_34.x = 1.676745e-38; - if (((pvVar2 == (void *)0x0) || (*GHIDRA_CAST((GHIDRA_CAST(pvVar2) + 4)) == 1)) || - (*GHIDRA_CAST((GHIDRA_CAST(pvVar2) + 4)) == 0x13)) { - local_34.x = 1.6767439e-38; - } - else if (((gridBelow == (void *)0x0) || (*GHIDRA_CAST((GHIDRA_CAST(gridBelow) + 4)) == 1)) || - (*GHIDRA_CAST((GHIDRA_CAST(gridBelow) + 4)) == 0x13)) { - local_34.x = 1.676754e-38; - } - pvVar2 = ANM2::GetAnimationData(&this->_sprite,GHIDRA_CAST(local_34.x)); - if (pvVar2 != (void *)0x0) { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(pvVar2) + 0x30)); - isAnimSet = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST(local_34.x),1); - if (((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)(GHIDRA_INT(column) % iVar1)), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - return; - } - } - return; -} diff --git a/generated-src/grid_entity_web.cpp b/generated-src/grid_entity_web.cpp deleted file mode 100644 index a2d4f9e..0000000 --- a/generated-src/grid_entity_web.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include "classes.h" - -// 00721540 -void GridEntity_Web::BeginBatches() -{ - uint8_t bVar1; - uint8_t *curAnimName; - uint32_t startFrame; - void *animData; - char *pcVar2; - uint32_t startFrame; - bool bVar4; - std_string anmPath; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t local_8; - - local_8 = 0xffffffff; - puStack_c = &LAB_00afc99d; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&anmPath)[1]._size); - ExceptionList = &local_10; - this->_collisionClass = 0; - anmPath._size = 0; - anmPath._capacity = 0xf; - anmPath._buf[0] = '\0'; - anmPath._buf[1] = '\0'; - anmPath._buf[2] = '\0'; - anmPath._buf[3] = '\0'; - (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) = msvc::_Allocate(0x20); - anmPath._size = 0x16; - anmPath._capacity = 0x1f; - builtin_strncpy((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anmPath._buf))) + 0x0))),"gfx/grid/grid_web.anm2",0x17); - local_8 = 0; - ANM2::Load(&this->_sprite,&anmPath,1); - local_8 = 0xffffffff; - if (0xf < anmPath._capacity) { - startFrame = anmPath._capacity + 1; - pcVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(anmPath._buf))) + 0x0))); - if (0xfff < startFrame) { - pcVar2 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) + -4)); - startFrame = anmPath._capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar2))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pcVar2,startFrame); - } - anmPath._size = 0; - anmPath._capacity = 0xf; - (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(anmPath._buf)) + 0x0))) & 0xffffff00; - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) != 0) { - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Bombed"),1); - if (bVar1 == 0) { - ExceptionList = local_10; - return; - } - if ((this->_sprite)._animState._animData == (void *)0x0) { - ExceptionList = local_10; - return; - } - AnimationState::SetFrameFloat(&(this->_sprite)._animState,0.0); - if ((this->_sprite)._animState._animData == (void *)0x0) { - ExceptionList = local_10; - return; - } - (this->_sprite)._animState._isPlaying = 0; - ExceptionList = local_10; - return; - } - curAnimName = (this->_sprite)._animState._animData; - if (curAnimName != GHIDRA_CAST(0x0)) { - if (0xf < *GHIDRA_CAST((curAnimName + 0x14))) { - curAnimName = *GHIDRA_CAST(curAnimName); - } - pcVar2 = "Swaying"; - do { - bVar1 = *curAnimName; - bVar4 = bVar1 < (uint8_t)*pcVar2; - if (bVar1 != *pcVar2) { -LAB_00721670: - startFrame = -GHIDRA_UINT(bVar4) | 1; - goto LAB_00721675; - } - if (bVar1 == 0) break; - bVar1 = curAnimName[1]; - bVar4 = bVar1 < (uint8_t)pcVar2[1]; - if (bVar1 != pcVar2[1]) goto LAB_00721670; - curAnimName = curAnimName + 2; - pcVar2 = pcVar2 + 2; - } while (bVar1 != 0); - startFrame = 0; -LAB_00721675: - if ((startFrame == 0) && - ((*GHIDRA_CAST((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' || - ((this->_sprite)._animState._isPlaying != 0)))) goto LAB_007216ad; - } - bVar1 = ANM2::SetAnimation(&this->_sprite,GHIDRA_CAST("Swaying"),1); - if (bVar1 != 0) { - AnimationState::Rewind(&(this->_sprite)._animState); - (this->_sprite)._animState._isPlaying = 1; - } -LAB_007216ad: - animData = (this->_sprite)._animState._animData; - if ((animData == (void *)0x0) || (startFrame = *GHIDRA_CAST((GHIDRA_CAST(animData) + 0x30)), startFrame == 0)) { - startFrame = 0; - } - else { - startFrame = Random(); - startFrame = startFrame % startFrame; - animData = (this->_sprite)._animState._animData; - } - if ((animData != (void *)0x0) && - (AnimationState::SetFrameFloat(&(this->_sprite)._animState,(float)GHIDRA_INT(startFrame)), - (this->_sprite)._animState._animData != (void *)0x0)) { - (this->_sprite)._animState._isPlaying = 0; - } - startFrame = Random(); - (this->_sprite)._flipX = ~(uint8_t)startFrame & 1; - startFrame = Random(); - (this->_sprite)._rotation = ((float)(startFrame & 3) + 0.0) * 90.0; - ExceptionList = local_10; - return; -} - -// 00721780 -void GridEntity_Web::Update() -{ - int iVar1; - ColorMod color; - uint8_t auVar2 [32]; - uint8_t isHasEvilCharm; - uint32_t uVar3; - float *maxAxisDistance; - uint32_t *puVar4; - PlayerManager *playerManager; - bool isEveryFourthFrame; - float distanceY; - float distanceX; - EntityRef sourceRef; - Entity_Player *player; - void *playersEnd; - - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) == 0) { - uVar3 = g_game->_frameCount & 0x80000003; - isEveryFourthFrame = uVar3 == 0; - if (GHIDRA_INT(uVar3) < 0) { - isEveryFourthFrame = (uVar3 - 1 | 0xfffffffc) == 0xffffffff; - } - if (isEveryFourthFrame) { - playerManager = &g_game->_playerManager; - uVar3 = 0; - if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin) - >> 2 != 0) { - do { - playersEnd = (playerManager->_playerList)._end; - puVar4 = (playerManager->_playerList)._begin; - if (GHIDRA_INT(playersEnd) - GHIDRA_INT(puVar4) >> 2 == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("PlayerManager::GetPlayer() : There are no players! \n")); - playersEnd = (playerManager->_playerList)._end; - puVar4 = (playerManager->_playerList)._begin; - } - if (uVar3 < GHIDRA_UINT((GHIDRA_INT(playersEnd) - GHIDRA_INT(puVar4) >> 2))) { - puVar4 = puVar4 + uVar3; - } - player = GHIDRA_CAST(*puVar4); - iVar1 = player->_entityGridCollisionClass; - if ((((iVar1 != 0) && (iVar1 != 3)) && (iVar1 != 1)) && (iVar1 != 2)) { - isHasEvilCharm = Entity_Player::HasCollectible(player,0x278,0); - if ((isHasEvilCharm != 0) || - (isHasEvilCharm = - TemporaryEffects::HasCollectibleEffect(&player->_temporaryeffects,0x278), - isHasEvilCharm != 0)) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 10) goto LAB_007219cb; - (*GHIDRA_CAST((GHIDRA_CAST((player)) + 0x26d4))) = (*GHIDRA_CAST((GHIDRA_CAST((player)) + 0x26d4))) != '\0'; - } - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0xc)); - distanceY = ABS((player->_pos).y - ((float)(this->_gridIndex / iVar1) * 40.0 + 120.0)); - distanceX = ABS((player->_pos).x - ((float)(this->_gridIndex % iVar1) * 40.0 + 40.0)); - maxAxisDistance = &distanceY; - if (distanceY <= distanceX) { - maxAxisDistance = &distanceX; - } - if (*maxAxisDistance <= 21.0 && *maxAxisDistance != 21.0) { - sourceRef._type = 0; - sourceRef._variant = 0; - sourceRef._spawnerType = 0; - sourceRef._spawnerVariant = 0; - sourceRef._position.x = g_vectorZero.x; - sourceRef._position.y = g_vectorZero.y; - sourceRef._velocity.x = g_vectorZero.x; - sourceRef._velocity.y = g_vectorZero.y; - sourceRef._flags = 0; - sourceRef._entity = (void *)0x0; - auVar2 = ZEXT1632(CONCAT412(0x3f800000,CONCAT48(0x3fa66666,0x3f8000003f800000))); - color._offset[0] = 0.15686275; - color._tint[0] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0x0))); - color._tint[1] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0x4))); - color._tint[2] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0x8))); - color._tint[3] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0xc))); - color._colorize[0] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0x10))); - color._colorize[1] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0x14))); - color._colorize[2] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0x18))); - color._colorize[3] = (*GHIDRA_CAST((GHIDRA_CAST(&((float)auVar2)) + 0x1c))); - color._offset[1] = 0.15686275; - color._offset[2] = 0.15686275; - Entity::AddSlowing(GHIDRA_CAST(player),&sourceRef,4,0.75,color,0); - } - } -LAB_007219cb: - uVar3 = uVar3 + 1; - playerManager = &g_game->_playerManager; - } while (uVar3 < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) - - GHIDRA_INT((playerManager->_playerList)._begin) >> 2))); - } - } - } - if ((this->_sprite)._loaded != 0) { - AnimationState::Update(&(this->_sprite)._animState); - AnimationState::Update(&(this->_sprite)._overlayAnimState); - } - return; -} diff --git a/generated-src/isaac_repentance_plus/weapon.cpp b/generated-src/isaac_repentance_plus/weapon.cpp deleted file mode 100644 index d86cd29..0000000 --- a/generated-src/isaac_repentance_plus/weapon.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "classes.h" - -// 009f3290 -IsaacRepentancePlus::Weapon::~Weapon() -{ - Entity_Player *pEVar1; - Entity_Player *ownerPlayer; - uint32_t *technology2LaserRef; - Weapon *local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t uStack_8; - - uStack_8 = 0xffffffff; - puStack_c = &LAB_00af09f0; - local_10 = ExceptionList; - ExceptionList = &local_10; - pEVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - *GHIDRA_CAST(this) = vftable; - if ((((pEVar1 == GHIDRA_CAST(0x0)) || (ownerPlayer = pEVar1, pEVar1->_type != 1)) && - (ownerPlayer = GHIDRA_CAST(0x0), pEVar1 != GHIDRA_CAST(0x0))) && (pEVar1->_type == 3)) - { - pEVar1->_chargeBarSprites[5]._numEvents = 0; - } - else if (ownerPlayer != GHIDRA_CAST(0x0)) { - local_14 = this; - ::Entity_Player::stop_costume_item_anims(ownerPlayer); - } - technology2LaserRef = &this->_technology2Laser; - if (*technology2LaserRef != 0) { - local_14 = GHIDRA_CAST(technology2LaserRef); - msvc::multiset::erase(&local_14); - *technology2LaserRef = 0; - } - ExceptionList = local_10; - return; -} diff --git a/generated-src/l_room_tile_desc.cpp b/generated-src/l_room_tile_desc.cpp deleted file mode 100644 index 4c8f124..0000000 --- a/generated-src/l_room_tile_desc.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "classes.h" - -// 0081fb70 -void * LRoomTileDesc::GetRandomTile(void *ret, uint32_t seed) -{ - code *pcVar1; - uint32_t uVar2; - void *pvVar3; - uint32_t height2; - uint32_t width1; - uint32_t area1; - uint32_t uVar4; - uint32_t rngState; - uint32_t areaRoll; - uint32_t width2; - int iVar5; - - uVar2 = *GHIDRA_CAST((this + 4)) - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1)))); - width1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[2])) + 0x2)))) - *GHIDRA_CAST(this); - height2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[9])) + 0x1)))) - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[6])) + 0x2)))); - width2 = *GHIDRA_CAST((this + 8)) - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[5])) + 0x1)))); - area1 = GHIDRA_INT((uVar2 * width1)) >> 0x1f; - area1 = (uVar2 * width1 ^ area1) - area1; - uVar4 = GHIDRA_INT((height2 * width2)) >> 0x1f; - uVar4 = ((height2 * width2 ^ uVar4) - uVar4) + area1; - if (seed == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - pvVar3 = (void *)(*pcVar1)(); - return pvVar3; - } - rngState = seed >> 1 ^ seed; - rngState = rngState << 9 ^ rngState; - areaRoll = 0; - rngState = rngState >> 0x1d ^ rngState; - if (uVar4 != 0) { - areaRoll = rngState % uVar4; - } - if (areaRoll < area1) { - if (rngState == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - pvVar3 = (void *)(*pcVar1)(); - return pvVar3; - } - rngState = rngState >> 1 ^ rngState; - rngState = rngState << 9 ^ rngState; - rngState = rngState >> 0x1d ^ rngState; - uVar4 = 0; - if (width1 != 0) { - uVar4 = rngState % width1; - } - if (rngState == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - pvVar3 = (void *)(*pcVar1)(); - return pvVar3; - } - rngState = rngState >> 1 ^ rngState; - rngState = rngState << 9 ^ rngState; - if (uVar2 == 0) { - uVar2 = 0; - } - else { - uVar2 = (rngState >> 0x1d ^ rngState) % uVar2; - } - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[1])) + 0x1)))); - *GHIDRA_CAST(ret) = *GHIDRA_CAST(this) + uVar4; - *GHIDRA_CAST((GHIDRA_CAST(ret) + 4)) = iVar5 + uVar2; - return ret; - } - if (rngState == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - pvVar3 = (void *)(*pcVar1)(); - return pvVar3; - } - rngState = rngState >> 1 ^ rngState; - rngState = rngState << 9 ^ rngState; - rngState = rngState >> 0x1d ^ rngState; - uVar2 = 0; - if (width2 != 0) { - uVar2 = rngState % width2; - } - iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[5])) + 0x1)))) + uVar2; - if (rngState == 0) { - KAGE_LogMessage(0x10,GHIDRA_CAST("RNG Seed is zero!\n")); - pcVar1 = (code *)swi(3); - pvVar3 = (void *)(*pcVar1)(); - return pvVar3; - } - rngState = rngState >> 1 ^ rngState; - rngState = rngState << 9 ^ rngState; - if (height2 == 0) { - *GHIDRA_CAST((GHIDRA_CAST(ret) + 4)) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[6])) + 0x2)))); - *GHIDRA_CAST(ret) = iVar5; - return ret; - } - *GHIDRA_CAST((GHIDRA_CAST(ret) + 4)) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(this[6])) + 0x2)))) + (rngState >> 0x1d ^ rngState) % height2; - *GHIDRA_CAST(ret) = iVar5; - return ret; -} diff --git a/generated-src/npc_helper.cpp b/generated-src/npc_helper.cpp index 01621b9..060e5da 100644 --- a/generated-src/npc_helper.cpp +++ b/generated-src/npc_helper.cpp @@ -2073,7 +2073,7 @@ void NpcHelper::gideon_spawn_stairs(Entity_NPC *npc) stairs = GHIDRA_CAST(0x0); } else { - (GHIDRA_CAST((stairs)))->GridEntity::GridEntity(); + GridEntity::GridEntity(stairs); *GHIDRA_CAST(stairs) = IsaacRepentancePlus::GridEntity_Stairs::vftable; } local_8 = 0xffffffff; @@ -2087,7 +2087,7 @@ void NpcHelper::gideon_spawn_stairs(Entity_NPC *npc) pRVar2->_gridEntities[uVar3] = stairs; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((stairs)) + 0x8)))) = 1; stairs->_varData = 0; - (GHIDRA_CAST((stairs)))->GridEntity::Init(local_14); + GridEntity::Init(stairs,local_14); } } } @@ -6847,7 +6847,7 @@ LAB_005290ba: } } LAB_00529272: - local_120 = (GHIDRA_CAST((local_11c->_entityFactory)))->EntityFactory::Create(GHIDRA_UINT(local_f4),0); + local_120 = EntityFactory::Create(local_11c->_entityFactory,GHIDRA_UINT(local_f4),0); if (local_120 == GHIDRA_CAST(0x0)) goto LAB_00529568; timeNs = GetTimeNs(); pEVar11 = local_120; @@ -7073,7 +7073,7 @@ LAB_00529876: } } LAB_00529a2e: - pEVar11 = (GHIDRA_CAST((local_f4->_entityFactory)))->EntityFactory::Create(GHIDRA_UINT(local_120),0); + pEVar11 = EntityFactory::Create(local_f4->_entityFactory,GHIDRA_UINT(local_120),0); if (pEVar11 != GHIDRA_CAST(0x0)) { timeNs = GetTimeNs(); uVar7 = GHIDRA_UINT((timeNs >> 0x20)); @@ -9384,7 +9384,7 @@ void NpcHelper::raglich_slam_spawn_grid(Entity_NPC *npc) pit = GHIDRA_CAST(0x0); } else { - (GHIDRA_CAST((pit)))->GridEntity::GridEntity(); + GridEntity::GridEntity(pit); *GHIDRA_CAST(pit) = IsaacRepentancePlus::GridEntity_Pit::vftable; } local_8 = -NAN; @@ -9398,7 +9398,7 @@ void NpcHelper::raglich_slam_spawn_grid(Entity_NPC *npc) *GHIDRA_CAST((GHIDRA_CAST(room) + gridIndex * 4 + 0x24)) = pit; *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pit)) + 0x8)))) = 0; pit->_varData = 0; - (GHIDRA_CAST((pit)))->GridEntity::Init(gridSeed); + GridEntity::Init(pit,gridSeed); } gridX = column; } diff --git a/generated-src/rail_manager.cpp b/generated-src/rail_manager.cpp deleted file mode 100644 index a8665f0..0000000 --- a/generated-src/rail_manager.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "classes.h" - -// 009e2f20 -void RailManager::Render(Vector *offset) -{ - RailManager *frontAnimState = this; - uint8_t bVar1; - int gridSize; - AnimationState *frontAnimState; - uint32_t gridIndex; - float pixelScale; - double dVar2; - double dVar3; - int gridEntityOffset; - Vector renderPos; - int gridWidth; - - bVar1 = ANM2::SetAnimation(&frontAnimState->_sprite,&DAT_00b804d8,1); - if (((bVar1 != 0) && ((frontAnimState->_sprite)._animState._animData != (void *)0x0)) && - (AnimationState::SetFrameFloat(&(frontAnimState->_sprite)._animState,0.0), - (frontAnimState->_sprite)._animState._animData != (void *)0x0)) { - (frontAnimState->_sprite)._animState._isPlaying = 0; - } - gridIndex = 0; - gridSize = *GHIDRA_CAST((GHIDRA_CAST(frontAnimState->_room) + 0x10)) * *GHIDRA_CAST((GHIDRA_CAST(frontAnimState->_room) + 0xc)); - if (0 < gridSize) { - gridEntityOffset = 0x24; - do { - bVar1 = (frontAnimState->_sprite)._filename._buf[gridIndex - 0x1c0]; - if (-1 < (char)bVar1) { - if (gridIndex < 0x1c0) { - gridWidth = *GHIDRA_CAST((gridEntityOffset + GHIDRA_INT(frontAnimState->_room))); - if ((gridWidth != 0) && (*GHIDRA_CAST((gridWidth + 4)) == 7)) goto LAB_009e3195; - if ((bVar1 == 0xff) || ((bVar1 & 0x40) == 0)) goto LAB_009e2fd2; - bVar1 = bVar1 & 0x3f; - if ((frontAnimState->_sprite)._animState._animData != (void *)0x0) goto LAB_009e2fe1; - } - else { -LAB_009e2fd2: - if ((frontAnimState->_sprite)._animState._animData != (void *)0x0) { - bVar1 = bVar1 & 0xf; -LAB_009e2fe1: - AnimationState::SetFrameFloat(&(frontAnimState->_sprite)._animState,(float)bVar1); - } - } - gridWidth = *GHIDRA_CAST((GHIDRA_CAST(frontAnimState->_room) + 0xc)); - pixelScale = g_displayPixelRatio * g_screenPointScale; - dVar2 = floor((double)(((((float)(GHIDRA_INT(gridIndex) % gridWidth) * 40.0 + 40.0) - 60.0) * 0.65 - + (g_screenWidth - 338.0) * 0.5) * pixelScale + 0.5)); - dVar3 = floor((double)(((((float)(GHIDRA_INT(gridIndex) / gridWidth) * 40.0 + 120.0) - 140.0) * - 0.65 + (g_screenHeight - 182.0) * 0.5) * pixelScale + 0.5)); - renderPos.x = (float)dVar2 / pixelScale + offset->x; - renderPos.y = (float)dVar3 / pixelScale + offset->y; - if ((frontAnimState->_sprite)._loaded != 0) { - if ((frontAnimState->_sprite)._overlayRenderFirst == 0) { - AnimationState::Render - (&(frontAnimState->_sprite)._animState,&renderPos,&g_vectorZero,&g_vectorZero); - frontAnimState = &(frontAnimState->_sprite)._overlayAnimState; - } - else { - AnimationState::Render - (&(frontAnimState->_sprite)._overlayAnimState,&renderPos,&g_vectorZero,&g_vectorZero); - frontAnimState = &(frontAnimState->_sprite)._animState; - } - AnimationState::Render(frontAnimState,&renderPos,&g_vectorZero,&g_vectorZero); - } - } -LAB_009e3195: - gridEntityOffset = gridEntityOffset + 4; - gridIndex = gridIndex + 1; - } while (GHIDRA_INT(gridIndex) < gridSize); - } - return; -} diff --git a/generated-src/sprite.cpp b/generated-src/sprite.cpp index 0d6fa6d..1e02a35 100644 --- a/generated-src/sprite.cpp +++ b/generated-src/sprite.cpp @@ -187,44 +187,6 @@ LayerState * Sprite::GetLayer(uint8_t *layerName) return layer; } -// 0040b590 -KColor * Sprite::GetTexel(KColor *param_2, float param_3, float param_4, float param_5, float param_6, float param_7, int param_8) -{ - float fVar1; - float fVar2; - float fVar3; - Vector samplePos; - Vector samplePos_00; - Vector renderPos; - Vector renderPos_00; - KColor *candidateTexel; - KColor candidateTexelBuf; - - samplePos.y = param_4; - samplePos.x = param_3; - renderPos.y = param_6; - renderPos.x = param_5; - ANM2::GetTexel(&this->_overlayAnimState,param_2,param_8,samplePos,renderPos,param_7); - if (param_2->_alpha <= param_7 && param_7 != param_2->_alpha) { - samplePos_00.y = param_4; - samplePos_00.x = param_3; - renderPos_00.y = param_6; - renderPos_00.x = param_5; - candidateTexel = - ANM2::GetTexel(&this->_animState,&candidateTexelBuf,param_8,samplePos_00,renderPos_00, - param_7); - fVar1 = candidateTexel->_green; - fVar2 = candidateTexel->_blue; - fVar3 = candidateTexel->_alpha; - param_2->_red = candidateTexel->_red; - param_2->_green = fVar1; - param_2->_blue = fVar2; - param_2->_alpha = fVar3; - param_2->_unk = candidateTexel->_unk; - } - return param_2; -} - // 0040bff0 void Sprite::LoadGraphics() { diff --git a/generated-src/stage_transition.cpp b/generated-src/stage_transition.cpp index 0f3741c..a2b2f49 100644 --- a/generated-src/stage_transition.cpp +++ b/generated-src/stage_transition.cpp @@ -180,7 +180,7 @@ LAB_0092f849: } if (*GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x7240)) <= 0.2) { uVar4 = Random(); - trapdoorPos = (GHIDRA_CAST((trapdoorGrid)))->GridEntity::Position(&spawnPos); + trapdoorPos = GridEntity::Position(trapdoorGrid,&spawnPos); spawnedEffect = Game::Spawn(g_game,1000,0xf,trapdoorPos,&g_vectorZero,GHIDRA_CAST(0x0),2,uVar4); savedFlags = spawnedEffect->_flags; @@ -195,7 +195,7 @@ LAB_0092f849: } else { uVar4 = Random(); - trapdoorPos = (GHIDRA_CAST((trapdoorGrid)))->GridEntity::Position(&spawnPos); + trapdoorPos = GridEntity::Position(trapdoorGrid,&spawnPos); spawnedEffect = Game::Spawn(g_game,1000,99,trapdoorPos,&g_vectorZero,GHIDRA_CAST(0x0),0,uVar4); fVar10 = (spawnedEffect->_sprite)._scale.x; diff --git a/generated-src/stubs.cpp b/generated-src/stubs.cpp index ac4f286..2aa789a 100644 --- a/generated-src/stubs.cpp +++ b/generated-src/stubs.cpp @@ -8230,10 +8230,6 @@ void Ambush::Update() { generated_stub("Ambush::Update 00834350"); } void BeamRenderer::Begin(ANM2 *anm2, uint32_t layer, uint8_t isUseOverlay, uint8_t isUnk) { generated_stub("BeamRenderer::Begin 0041e480"); } void BeamRenderer::Add(Vector *point, ColorMod *color, float spritesheetCoordinate, float width) { generated_stub("BeamRenderer::Add 0041e720"); } void BeamRenderer::End() { generated_stub("BeamRenderer::End 0041e960"); } -void BeastArena::get_scroll_speed() { generated_stub("BeastArena::get_scroll_speed 00592260"); } -void BeastArena::init() { generated_stub("BeastArena::init 00839b80"); } -void BeastArena::update() { generated_stub("BeastArena::update 0083a080"); } -void BeastArena::render_light() { generated_stub("BeastArena::render_light 0083a1b0"); } BitSet128 * BitSet128::operator_and(BitSet128 *outResult, BitSet128 *a, BitSet128 *b) { generated_stub("BitSet128::operator_and 00417170"); } uint8_t BitSet128::IsNonZero() { generated_stub("BitSet128::IsNonZero 004171b0"); } BitSet128 * BitSet128::operator__(BitSet128 *other) { generated_stub("BitSet128::operator__ 00435bf0"); } @@ -8268,7 +8264,6 @@ Color::Color(float r, float g, float b, float redOffset, float greenOffset, floa Color::Color(uint32_t param_1, int param_2, int param_3, int param_4) { generated_stub("Color::Color 00435ad0"); } Color::Color(uint32_t param_1, uint32_t param_2, uint32_t param_3, uint32_t param_4, uint32_t param_5, uint32_t param_6, uint32_t param_7, uint32_t param_8) { generated_stub("Color::Color 00435b50"); } void Color::assign(uint32_t *param_1) { generated_stub("Color::assign 00456380"); } -void Color::apply_to_kcolor(KColor *outColor, ColorMod *color, KColor *input) { generated_stub("Color::apply_to_kcolor 004e46d0"); } void Color::Reset() { generated_stub("Color::Reset 00682ed0"); } void Color::SetTint(float r, float g, float b, float a) { generated_stub("Color::SetTint 00682f20"); } void Color::SetColorize(float red, float green, float blue, float amount) { generated_stub("Color::SetColorize 00682fb0"); } @@ -8392,8 +8387,6 @@ Vector * Vector::__div_assign(float *divisor) { generated_stub("Vector::__div_as uint8_t Vector::operator_eq(Vector *other) { generated_stub("Vector::operator_eq 00a10600"); } uint8_t Vector::operator_ne(Vector *other) { generated_stub("Vector::operator_ne 00a10630"); } Vector * Vector::__unm(Vector *outResult) { generated_stub("Vector::__unm 00a10660"); } -Entity * EntityFactory::Create(uint32_t type, uint8_t force) { generated_stub("EntityFactory::Create 006f0090"); } -void EntityFactory::constructor() { generated_stub("EntityFactory::constructor 006f2a10"); } EntityList_Query::~EntityList_Query() { generated_stub("EntityList_Query::~EntityList_Query 004175b0"); } void EntitySaveState::constructor() { generated_stub("EntitySaveState::constructor 004d3080"); } void EntitySaveState::copy(void *other) { generated_stub("EntitySaveState::copy 004d3130"); } @@ -8423,172 +8416,6 @@ uint32_t GameStatePlayer::read_part3() { generated_stub("GameStatePlayer::read_p void * Game_StateSlot::operator_assign(void *other) { generated_stub("Game_StateSlot::operator_assign 006f8a40"); } void * GlitchedCollectibleGfx::constructor() { generated_stub("GlitchedCollectibleGfx::constructor 009dc6e0"); } void GlitchedItemSet::recalculate() { generated_stub("GlitchedItemSet::recalculate 009e0500"); } -GridEntity::~GridEntity() { generated_stub("GridEntity::~GridEntity 00709cb0"); } -void GridEntity::guard_check_icall() { generated_stub("GridEntity::guard_check_icall 0040c200"); } -void GridEntity::Update() { generated_stub("GridEntity::Update 00af05d3"); } -void GridEntity::Render() { generated_stub("GridEntity::Render 00af05d3"); } -uint8_t GridEntity::Hurt() { generated_stub("GridEntity::Hurt 006a80c0"); } -uint8_t GridEntity::Destroy(uint8_t isImmediate) { generated_stub("GridEntity::Destroy 00709c10"); } -void * GridEntity::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity::GetWaterClipInfo 00709f90"); } -uint8_t GridEntity::CanTakeDamageFromTearEffects() { generated_stub("GridEntity::CanTakeDamageFromTearEffects 00709c30"); } -void GridEntity::BeginBatches() { generated_stub("GridEntity::BeginBatches 00af05d3"); } -int GridEntity::GetType() { generated_stub("GridEntity::GetType 004073c0"); } -ANM2 * GridEntity::GetSprite() { generated_stub("GridEntity::GetSprite 00428930"); } -int GridEntity::GetVariant() { generated_stub("GridEntity::GetVariant 0043eec0"); } -int GridEntity::GetGridIndex() { generated_stub("GridEntity::GetGridIndex 004e4830"); } -int GridEntity::VarData() { generated_stub("GridEntity::VarData 0067efc0"); } -void GridEntity::SetType(uint32_t param_1) { generated_stub("GridEntity::SetType 00709c00"); } -GridEntity::GridEntity() { generated_stub("GridEntity::GridEntity 00709c40"); } -void GridEntity::Init(uint32_t Seed) { generated_stub("GridEntity::Init 00709db0"); } -Vector * GridEntity::Position(Vector *outPosition) { generated_stub("GridEntity::Position 00709df0"); } -Vector * GridEntity::get_render_position(Vector *outPosition) { generated_stub("GridEntity::get_render_position 00709e50"); } -uint8_t GridEntity::IsBreakableRock() { generated_stub("GridEntity::IsBreakableRock 0070b2a0"); } -GridEntity * GridEntity::InitSubclass(uint32_t flags) { generated_stub("GridEntity::InitSubclass 0070ba00"); } -uint8_t GridEntity::IsEasyCrushableOrWalkable() { generated_stub("GridEntity::IsEasyCrushableOrWalkable 0070bec0"); } -uint8_t GridEntity::IsDangerousCrushableOrWalkable() { generated_stub("GridEntity::IsDangerousCrushableOrWalkable 0070bf10"); } -void GridEntity::SetVariant(int variant) { generated_stub("GridEntity::SetVariant 00738140"); } -void GridEntity::trigger_output(GridEntity *gridEntity) { generated_stub("GridEntity::trigger_output 00823150"); } -RNG * GridEntity::GetRNG() { generated_stub("GridEntity::GetRNG 0085dda0"); } -void GridEntity::HurtWithSource() { generated_stub("GridEntity::HurtWithSource 008c5cd9"); } -void GridEntity::PostInit() { generated_stub("GridEntity::PostInit 008c5ce8"); } -void GridEntity_Decoration::Update() { generated_stub("GridEntity_Decoration::Update 0099a8e0"); } -void GridEntity_Decoration::Render() { generated_stub("GridEntity_Decoration::Render 0099ac00"); } -void * GridEntity_Decoration::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Decoration::GetWaterClipInfo 00714750"); } -void GridEntity_Decoration::BeginBatches() { generated_stub("GridEntity_Decoration::BeginBatches 0099acc0"); } -GridEntity_Door::~GridEntity_Door() { generated_stub("GridEntity_Door::~GridEntity_Door 0070bb20"); } -void GridEntity_Door::Update() { generated_stub("GridEntity_Door::Update 0070c5c0"); } -void GridEntity_Door::Render() { generated_stub("GridEntity_Door::Render 0070d1e0"); } -uint8_t GridEntity_Door::Destroy(uint8_t isImmediate) { generated_stub("GridEntity_Door::Destroy 0070f5e0"); } -void * GridEntity_Door::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Door::GetWaterClipInfo 00711720"); } -uint8_t GridEntity_Door::CanTakeDamageFromTearEffects() { generated_stub("GridEntity_Door::CanTakeDamageFromTearEffects 0070f670"); } -void GridEntity_Door::BeginBatches() { generated_stub("GridEntity_Door::BeginBatches 00711590"); } -uint8_t GridEntity_Door::IsOpen() { generated_stub("GridEntity_Door::IsOpen 00435fc0"); } -uint8_t GridEntity_Door::IsLocked() { generated_stub("GridEntity_Door::IsLocked 00435fd0"); } -int GridEntity_Door::Direction() { generated_stub("GridEntity_Door::Direction 005cd5e0"); } -uint8_t GridEntity_Door::IsRoomType(int roomType) { generated_stub("GridEntity_Door::IsRoomType 005cd5f0"); } -int GridEntity_Door::TargetRoomIndex() { generated_stub("GridEntity_Door::TargetRoomIndex 0060cfe0"); } -bool GridEntity_Door::IsKeyFamiliarTarget() { generated_stub("GridEntity_Door::IsKeyFamiliarTarget 0060cff0"); } -int GridEntity_Door::get_secret_exit_kind() { generated_stub("GridEntity_Door::get_secret_exit_kind 0070d360"); } -void GridEntity_Door::LoadSprite() { generated_stub("GridEntity_Door::LoadSprite 0070d3f0"); } -void GridEntity_Door::UpdateAnimation() { generated_stub("GridEntity_Door::UpdateAnimation 0070ee40"); } -uint32_t GridEntity_Door::CanBlowOpen() { generated_stub("GridEntity_Door::CanBlowOpen 0070f680"); } -void GridEntity_Door::SpawnDust() { generated_stub("GridEntity_Door::SpawnDust 0070f810"); } -uint8_t GridEntity_Door::TryBlowOpen(uint8_t isFromExplosion, Entity *source) { generated_stub("GridEntity_Door::TryBlowOpen 0070fb60"); } -uint8_t GridEntity_Door::TryUnlock(Entity_Player *player, uint8_t isForce) { generated_stub("GridEntity_Door::TryUnlock 00710480"); } -void GridEntity_Door::Close(uint8_t isForce) { generated_stub("GridEntity_Door::Close 00710d30"); } -void GridEntity_Door::Bar() { generated_stub("GridEntity_Door::Bar 00710d90"); } -void GridEntity_Door::Open() { generated_stub("GridEntity_Door::Open 00710dd0"); } -void GridEntity_Door::SetRoomTypes(int CurrentRoomType, int TargetRoomType) { generated_stub("GridEntity_Door::SetRoomTypes 00710fa0"); } -void GridEntity_Door::SetLocked(uint8_t isLocked) { generated_stub("GridEntity_Door::SetLocked 00711630"); } -uint32_t GridEntity_Door::IsTargetRoomArcade() { generated_stub("GridEntity_Door::IsTargetRoomArcade 00711690"); } -uint8_t GridEntity_Door::IsBusted() { generated_stub("GridEntity_Door::IsBusted 00738170"); } -int GridEntity_Door::Slot() { generated_stub("GridEntity_Door::Slot 00833290"); } -Vector * GridEntity_Door::GetSpriteOffset() { generated_stub("GridEntity_Door::GetSpriteOffset 0085e0b0"); } -GridEntity_Fire::~GridEntity_Fire() { generated_stub("GridEntity_Fire::~GridEntity_Fire 0070ba00"); } -void GridEntity_Fire::Update() { generated_stub("GridEntity_Fire::Update 0067e0f0"); } -void GridEntity_Fire::Render() { generated_stub("GridEntity_Fire::Render 0067e880"); } -uint8_t GridEntity_Fire::Hurt() { generated_stub("GridEntity_Fire::Hurt 0067ea60"); } -void GridEntity_Fire::BeginBatches() { generated_stub("GridEntity_Fire::BeginBatches 0067db00"); } -void GridEntity_Gravity::guard_check_icall() { generated_stub("GridEntity_Gravity::guard_check_icall 0099b520"); } -void GridEntity_Gravity::Update() { generated_stub("GridEntity_Gravity::Update 0099b980"); } -void GridEntity_Gravity::Render() { generated_stub("GridEntity_Gravity::Render 0071edb0"); } -void GridEntity_Gravity::BeginBatches() { generated_stub("GridEntity_Gravity::BeginBatches 0099b510"); } -GridEntity_Lock::~GridEntity_Lock() { generated_stub("GridEntity_Lock::~GridEntity_Lock 0070bdd0"); } -void GridEntity_Lock::Update() { generated_stub("GridEntity_Lock::Update 00711950"); } -void GridEntity_Lock::Render() { generated_stub("GridEntity_Lock::Render 00711f30"); } -void * GridEntity_Lock::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Lock::GetWaterClipInfo 00712090"); } -void GridEntity_Lock::BeginBatches() { generated_stub("GridEntity_Lock::BeginBatches 00711780"); } -void GridEntity_Lock::try_unlock(Entity_Player *player, uint8_t isForce) { generated_stub("GridEntity_Lock::try_unlock 00711af0"); } -void GridEntity_Lock::break_open(Entity_Player *player) { generated_stub("GridEntity_Lock::break_open 00711bb0"); } -GridEntity_Pit::~GridEntity_Pit() { generated_stub("GridEntity_Pit::~GridEntity_Pit 007120d0"); } -void GridEntity_Pit::guard_check_icall() { generated_stub("GridEntity_Pit::guard_check_icall 00714320"); } -void GridEntity_Pit::Update() { generated_stub("GridEntity_Pit::Update 00712180"); } -void GridEntity_Pit::Render() { generated_stub("GridEntity_Pit::Render 00713440"); } -void * GridEntity_Pit::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Pit::GetWaterClipInfo 00714750"); } -void GridEntity_Pit::BeginBatches() { generated_stub("GridEntity_Pit::BeginBatches 00713760"); } -void GridEntity_Pit::update_sprite_edges() { generated_stub("GridEntity_Pit::update_sprite_edges 00713ee0"); } -void GridEntity_Pit::UpdateCollision() { generated_stub("GridEntity_Pit::UpdateCollision 00714610"); } -void GridEntity_Pit::SetLadder(uint8_t isLadder) { generated_stub("GridEntity_Pit::SetLadder 007146e0"); } -void GridEntity_Pit::MakeBridge(int param_1, int param_2) { generated_stub("GridEntity_Pit::MakeBridge 00714700"); } -GridEntity_Poop::~GridEntity_Poop() { generated_stub("GridEntity_Poop::~GridEntity_Poop 0070bc60"); } -void GridEntity_Poop::guard_check_icall() { generated_stub("GridEntity_Poop::guard_check_icall 00718dd0"); } -void GridEntity_Poop::Update() { generated_stub("GridEntity_Poop::Update 00714770"); } -void GridEntity_Poop::Render() { generated_stub("GridEntity_Poop::Render 007151e0"); } -uint8_t GridEntity_Poop::Hurt() { generated_stub("GridEntity_Poop::Hurt 00715330"); } -void * GridEntity_Poop::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Poop::GetWaterClipInfo 007166b0"); } -void GridEntity_Poop::BeginBatches() { generated_stub("GridEntity_Poop::BeginBatches 00715940"); } -void GridEntity_Poop::ReduceSpawnRate() { generated_stub("GridEntity_Poop::ReduceSpawnRate 00456870"); } -void GridEntity_Poop::RespawnRedPoop() { generated_stub("GridEntity_Poop::RespawnRedPoop 007166f0"); } -void GridEntity_Poop::spawn_hit_gibs(Vector *position, int poopVariant, int maxGibs) { generated_stub("GridEntity_Poop::spawn_hit_gibs 00716760"); } -void GridEntity_Poop::destroy_effects() { generated_stub("GridEntity_Poop::destroy_effects 00716b10"); } -GridEntity_Poop * GridEntity_Poop::get_giga_part(int variant, uint8_t isCreate) { generated_stub("GridEntity_Poop::get_giga_part 00718ac0"); } -GridEntity_PressurePlate::~GridEntity_PressurePlate() { generated_stub("GridEntity_PressurePlate::~GridEntity_PressurePlate 0070bd00"); } -void GridEntity_PressurePlate::Update() { generated_stub("GridEntity_PressurePlate::Update 00983330"); } -void GridEntity_PressurePlate::Render() { generated_stub("GridEntity_PressurePlate::Render 00985c10"); } -void * GridEntity_PressurePlate::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_PressurePlate::GetWaterClipInfo 00986430"); } -void GridEntity_PressurePlate::BeginBatches() { generated_stub("GridEntity_PressurePlate::BeginBatches 00985f00"); } -void GridEntity_PressurePlate::update_press() { generated_stub("GridEntity_PressurePlate::update_press 009833c0"); } -void GridEntity_PressurePlate::update_greed_button_anim(uint8_t isRed) { generated_stub("GridEntity_PressurePlate::update_greed_button_anim 009837b0"); } -void GridEntity_PressurePlate::play_pending_animation() { generated_stub("GridEntity_PressurePlate::play_pending_animation 009838c0"); } -void GridEntity_PressurePlate::update_greed_button() { generated_stub("GridEntity_PressurePlate::update_greed_button 009839f0"); } -void GridEntity_PressurePlate::Reward() { generated_stub("GridEntity_PressurePlate::Reward 00984550"); } -GridEntity_Rock::~GridEntity_Rock() { generated_stub("GridEntity_Rock::~GridEntity_Rock 0070b950"); } -void GridEntity_Rock::guard_check_icall() { generated_stub("GridEntity_Rock::guard_check_icall 0071a760"); } -void GridEntity_Rock::Update() { generated_stub("GridEntity_Rock::Update 00718fe0"); } -void GridEntity_Rock::Render() { generated_stub("GridEntity_Rock::Render 00719ad0"); } -uint8_t GridEntity_Rock::Destroy(uint8_t isImmediate) { generated_stub("GridEntity_Rock::Destroy 007197d0"); } -void * GridEntity_Rock::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Rock::GetWaterClipInfo 0071deb0"); } -void GridEntity_Rock::BeginBatches() { generated_stub("GridEntity_Rock::BeginBatches 00719f80"); } -uint8_t * GridEntity_Rock::GetRubbleAnim() { generated_stub("GridEntity_Rock::GetRubbleAnim 005cd820"); } -void GridEntity_Rock::update_collision() { generated_stub("GridEntity_Rock::update_collision 00718f80"); } -void GridEntity_Rock::RenderTop(Vector *pos) { generated_stub("GridEntity_Rock::RenderTop 00719dd0"); } -void GridEntity_Rock::SetBigRockFrame(uint32_t param_2) { generated_stub("GridEntity_Rock::SetBigRockFrame 0071a940"); } -int GridEntity_Rock::GetBigRockFrame() { generated_stub("GridEntity_Rock::GetBigRockFrame 0071aa70"); } -void GridEntity_Rock::UpdateAnimFrame() { generated_stub("GridEntity_Rock::UpdateAnimFrame 0071aa90"); } -void GridEntity_Rock::UpdateNeighbors() { generated_stub("GridEntity_Rock::UpdateNeighbors 0071aaf0"); } -void GridEntity_Rock::RegisterRockDestroyed(int GridEntityType) { generated_stub("GridEntity_Rock::RegisterRockDestroyed 0071af10"); } -void GridEntity_Rock::TrySpawnWorms() { generated_stub("GridEntity_Rock::TrySpawnWorms 0071af60"); } -void GridEntity_Rock::PlayBreakSound(int GridEntityType, int BackdropType) { generated_stub("GridEntity_Rock::PlayBreakSound 0071b100"); } -uint8_t GridEntity_Rock::TrySpawnLadder() { generated_stub("GridEntity_Rock::TrySpawnLadder 0071b1c0"); } -GridEntity_Spikes::~GridEntity_Spikes() { generated_stub("GridEntity_Spikes::~GridEntity_Spikes 0070bdd0"); } -void GridEntity_Spikes::Update() { generated_stub("GridEntity_Spikes::Update 0071e9b0"); } -void GridEntity_Spikes::Render() { generated_stub("GridEntity_Spikes::Render 0071edb0"); } -void GridEntity_Spikes::BeginBatches() { generated_stub("GridEntity_Spikes::BeginBatches 0071dfc0"); } -uint8_t GridEntity_Spikes::is_disabled() { generated_stub("GridEntity_Spikes::is_disabled 0071e920"); } -void GridEntity_Spikes::unsummon(uint8_t isInstant) { generated_stub("GridEntity_Spikes::unsummon 0071eb30"); } -void GridEntity_Stairs::Update() { generated_stub("GridEntity_Stairs::Update 0099bd50"); } -void GridEntity_Stairs::Render() { generated_stub("GridEntity_Stairs::Render 0071edb0"); } -void * GridEntity_Stairs::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Stairs::GetWaterClipInfo 00714750"); } -void GridEntity_Stairs::BeginBatches() { generated_stub("GridEntity_Stairs::BeginBatches 0099bad0"); } -GridEntity_Statue::~GridEntity_Statue() { generated_stub("GridEntity_Statue::~GridEntity_Statue 0070bdd0"); } -void GridEntity_Statue::Update() { generated_stub("GridEntity_Statue::Update 00838520"); } -void GridEntity_Statue::Render() { generated_stub("GridEntity_Statue::Render 0042cdf0"); } -uint8_t GridEntity_Statue::Destroy(uint8_t isImmediate) { generated_stub("GridEntity_Statue::Destroy 00838560"); } -void GridEntity_Statue::BeginBatches() { generated_stub("GridEntity_Statue::BeginBatches 00838ae0"); } -GridEntity_TNT::~GridEntity_TNT() { generated_stub("GridEntity_TNT::~GridEntity_TNT 0070bdd0"); } -void GridEntity_TNT::Update() { generated_stub("GridEntity_TNT::Update 0071f090"); } -void GridEntity_TNT::Render() { generated_stub("GridEntity_TNT::Render 0071edb0"); } -uint8_t GridEntity_TNT::Hurt() { generated_stub("GridEntity_TNT::Hurt 0071f250"); } -uint8_t GridEntity_TNT::Destroy(uint8_t isImmediate) { generated_stub("GridEntity_TNT::Destroy 0071f2b0"); } -void GridEntity_TNT::BeginBatches() { generated_stub("GridEntity_TNT::BeginBatches 0071ee90"); } -void GridEntity_Teleporter::Update() { generated_stub("GridEntity_Teleporter::Update 00838c30"); } -void GridEntity_Teleporter::Render() { generated_stub("GridEntity_Teleporter::Render 00711f30"); } -void * GridEntity_Teleporter::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Teleporter::GetWaterClipInfo 00714750"); } -void GridEntity_Teleporter::BeginBatches() { generated_stub("GridEntity_Teleporter::BeginBatches 00838eb0"); } -GridEntity_TrapDoor::~GridEntity_TrapDoor() { generated_stub("GridEntity_TrapDoor::~GridEntity_TrapDoor 0070bdd0"); } -void GridEntity_TrapDoor::Update() { generated_stub("GridEntity_TrapDoor::Update 0071fef0"); } -void GridEntity_TrapDoor::Render() { generated_stub("GridEntity_TrapDoor::Render 0071edb0"); } -void * GridEntity_TrapDoor::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_TrapDoor::GetWaterClipInfo 00714750"); } -void GridEntity_TrapDoor::BeginBatches() { generated_stub("GridEntity_TrapDoor::BeginBatches 0071f630"); } -void GridEntity_Wall::guard_check_icall() { generated_stub("GridEntity_Wall::guard_check_icall 00721310"); } -void GridEntity_Wall::Update() { generated_stub("GridEntity_Wall::Update 0040c200"); } -void GridEntity_Wall::Render() { generated_stub("GridEntity_Wall::Render 00720fe0"); } -void GridEntity_Wall::BeginBatches() { generated_stub("GridEntity_Wall::BeginBatches 007210d0"); } -void GridEntity_Web::Update() { generated_stub("GridEntity_Web::Update 00721780"); } -void GridEntity_Web::Render() { generated_stub("GridEntity_Web::Render 0071edb0"); } -uint8_t GridEntity_Web::Destroy(uint8_t isImmediate) { generated_stub("GridEntity_Web::Destroy 00721a10"); } -void * GridEntity_Web::GetWaterClipInfo(void *outInfo) { generated_stub("GridEntity_Web::GetWaterClipInfo 00714750"); } -void GridEntity_Web::BeginBatches() { generated_stub("GridEntity_Web::BeginBatches 00721540"); } void HallucinationOverlay::Render(Vector *offset) { generated_stub("HallucinationOverlay::Render 00839550"); } HomingLaser * HomingLaser::operator_assign(HomingLaser *other) { generated_stub("HomingLaser::operator_assign 0085e000"); } HomingLaser::HomingLaser() { generated_stub("HomingLaser::HomingLaser 0099c290"); } @@ -8611,7 +8438,6 @@ int InputManager::FirstLocalDeviceID() { generated_stub("InputManager::FirstLoca float InputManager::GetActionValue(int action, int controllerIndex, Entity *entity, int unused) { generated_stub("InputManager::GetActionValue 009562d0"); } void InviteFriendsMenu::load_graphics() { generated_stub("InviteFriendsMenu::load_graphics 009c4100"); } void InviteFriendsMenu::Render() { generated_stub("InviteFriendsMenu::Render 009c51e0"); } -IsaacRepentancePlus::Weapon::~Weapon() { generated_stub("IsaacRepentancePlus::Weapon::~Weapon 009f3290"); } IsaacsBodyData::~IsaacsBodyData() { generated_stub("IsaacsBodyData::~IsaacsBodyData 0060d530"); } ItemOverlay::~ItemOverlay() { generated_stub("ItemOverlay::~ItemOverlay 009abd80"); } void ItemOverlay::Update(uint8_t unk) { generated_stub("ItemOverlay::Update 009aca90"); } @@ -9352,7 +9178,6 @@ void KColor::SetFromARGB(uint32_t argb) { generated_stub("KColor::SetFromARGB 00 KColor * KColor::set_from_argb_signed(uint32_t argb) { generated_stub("KColor::set_from_argb_signed 00a0f610"); } KColor::KColor(float red, float green, float blue, float alpha) { generated_stub("KColor::KColor 00a0f690"); } void KColor::hsl_to_rgb(KColor *out, KColor *in) { generated_stub("KColor::hsl_to_rgb 00a0fb60"); } -void * LRoomTileDesc::GetRandomTile(void *ret, uint32_t seed) { generated_stub("LRoomTileDesc::GetRandomTile 0081fb70"); } void Lobby::refresh_members() { generated_stub("Lobby::refresh_members 00a71c40"); } void LobbyList::clear() { generated_stub("LobbyList::clear 0091e730"); } void LobbyLocalhost::read_welcome_message(void *data) { generated_stub("LobbyLocalhost::read_welcome_message 00a9f2b0"); } @@ -9595,7 +9420,6 @@ void ProceduralEffect::roll_params(int conditionType, int actionType, uint32_t s ProjectileParams::ProjectileParams() { generated_stub("ProjectileParams::ProjectileParams 0043ef30"); } void Quad::rotate(Vector *pivot, float angle) { generated_stub("Quad::rotate 00a10760"); } void Quad::scale(Vector *pivot, Vector *scale) { generated_stub("Quad::scale 00a10950"); } -void RailManager::Render(Vector *offset) { generated_stub("RailManager::Render 009e2f20"); } void RebirthSaveData::Clear() { generated_stub("RebirthSaveData::Clear 009e3dc0"); } void RebirthSaveData::repair_counters() { generated_stub("RebirthSaveData::repair_counters 009e4af0"); } ReferenceCountBase::~ReferenceCountBase() { generated_stub("ReferenceCountBase::~ReferenceCountBase 0040cbb0"); } @@ -9633,7 +9457,6 @@ void Sprite::SetOverlayFrame(std_string *animName, int frame) { generated_stub(" uint8_t Sprite::IsEventTriggered(void *eventName) { generated_stub("Sprite::IsEventTriggered 0040b000"); } uint8_t Sprite::WasEventTriggered(std_string *eventName) { generated_stub("Sprite::WasEventTriggered 0040b060"); } LayerState * Sprite::GetLayer(uint8_t *layerName) { generated_stub("Sprite::GetLayer 0040b200"); } -KColor * Sprite::GetTexel(KColor *param_2, float param_3, float param_4, float param_5, float param_6, float param_7, int param_8) { generated_stub("Sprite::GetTexel 0040b590"); } void Sprite::LoadGraphics() { generated_stub("Sprite::LoadGraphics 0040bff0"); } Vector * Sprite::Scale() { generated_stub("Sprite::Scale 00417200"); } long double Sprite::Rotation() { generated_stub("Sprite::Rotation 00417210"); } @@ -9667,9 +9490,6 @@ void SteamCloudFile::vfunc_8() { generated_stub("SteamCloudFile::vfunc_8 0040c20 uint32_t SteamCloudFile::FUN_00a253e0(uint8_t *param_1) { generated_stub("SteamCloudFile::FUN_00a253e0 00683820"); } void SteamCloudFile::vfunc_11() { generated_stub("SteamCloudFile::vfunc_11 0040c200"); } void SteamCloudFile::FUN_00a25450() { generated_stub("SteamCloudFile::FUN_00a25450 006839b0"); } -void TearParams::constructor() { generated_stub("TearParams::constructor 005cd690"); } -TearParams * TearParams::operator_(TearParams *other) { generated_stub("TearParams::operator_ 006075a0"); } -void TearParams::copy(void *other) { generated_stub("TearParams::copy 0065b490"); } void TexturePtr::release() { generated_stub("TexturePtr::release 0040c440"); } UmbilicalBabyData::~UmbilicalBabyData() { generated_stub("UmbilicalBabyData::~UmbilicalBabyData 00431790"); } uint32_t UmbilicalBabyData::last_point() { generated_stub("UmbilicalBabyData::last_point 00435590"); } @@ -9677,153 +9497,251 @@ void UserProfile::find_or_create() { generated_stub("UserProfile::find_or_create void VideoPlayer::play(uint8_t *fileName, float volume) { generated_stub("VideoPlayer::play 009f2ee0"); } void VideoPlayer::unload() { generated_stub("VideoPlayer::unload 00a62880"); } void VideoPlayer::render(uint8_t param_1) { generated_stub("VideoPlayer::render 00a62b10"); } -Weapon::~Weapon() { generated_stub("Weapon::~Weapon 009f3260"); } -void Weapon::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon::Init 009f34d0"); } -void Weapon::Update(char param_2) { generated_stub("Weapon::Update 009f34f0"); } -void Weapon::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon::Fire 009f3540"); } -void Weapon::Reset() { generated_stub("Weapon::Reset 009f3480"); } -void Weapon::ClearReferences() { generated_stub("Weapon::ClearReferences 009f3320"); } -long double Weapon::GetMaxCharge() { generated_stub("Weapon::GetMaxCharge 009f3130"); } -long double Weapon::GetChargeBarAmount() { generated_stub("Weapon::GetChargeBarAmount 009f4150"); } -void Weapon::vfunc_8() { generated_stub("Weapon::vfunc_8 009f3130"); } -uint32_t Weapon::GetFocusEntity() { generated_stub("Weapon::GetFocusEntity 009f3140"); } -uint32_t Weapon::GetMainEntity() { generated_stub("Weapon::GetMainEntity 009f3140"); } -void Weapon::guard_check_icall() { generated_stub("Weapon::guard_check_icall 0040c200"); } -uint32_t Weapon::GetMarkedTargetVariant() { generated_stub("Weapon::GetMarkedTargetVariant 009f3140"); } -uint8_t Weapon::CanShutDoors() { generated_stub("Weapon::CanShutDoors 005ccc00"); } -uint8_t Weapon::CanTriggerCursedEyeTeleport() { generated_stub("Weapon::CanTriggerCursedEyeTeleport 005ccc00"); } -uint8_t Weapon::CanTriggerKidneyStone() { generated_stub("Weapon::CanTriggerKidneyStone 005ccc00"); } -uint8_t Weapon::CanOverrideForgottenThrow() { generated_stub("Weapon::CanOverrideForgottenThrow 005ccc00"); } -uint8_t Weapon::is_held_item(ANM2 *sprite, std_string *animName, void *itemDesc) { generated_stub("Weapon::is_held_item 0075a2b0"); } -uint8_t Weapon::IsAxisAligned() { generated_stub("Weapon::IsAxisAligned 009f3360"); } -Vector * Weapon::get_aim_direction(Vector *outDir, Vector *defaultDir) { generated_stub("Weapon::get_aim_direction 009f33e0"); } -Vector * Weapon::get_owner_position(Vector *outPos) { generated_stub("Weapon::get_owner_position 009f3bd0"); } -float Weapon::get_damage() { generated_stub("Weapon::get_damage 009f3c80"); } -BitSet128 * Weapon::get_owner_tear_flags(BitSet128 *outFlags) { generated_stub("Weapon::get_owner_tear_flags 009f3d00"); } -ColorMod * Weapon::get_tear_color(ColorMod *outColor) { generated_stub("Weapon::get_tear_color 009f3db0"); } -ColorMod * Weapon::get_laser_color(ColorMod *outColor) { generated_stub("Weapon::get_laser_color 009f3f60"); } -void * Weapon::GetMultiShotParams(void *outParams, int unusedArg) { generated_stub("Weapon::GetMultiShotParams 009f41c0"); } -void Weapon::stop_costume_item_anim(int collectibleId) { generated_stub("Weapon::stop_costume_item_anim 009f4ff0"); } -uint8_t Weapon::IsItemAnimFinished(uint32_t collectibleID) { generated_stub("Weapon::IsItemAnimFinished 009f50f0"); } -uint8_t Weapon::is_c_section_anim_finished(int unused) { generated_stub("Weapon::is_c_section_anim_finished 009f5510"); } -void Weapon::SetBlinkTime(int delay, int unused) { generated_stub("Weapon::SetBlinkTime 009f56c0"); } -void Weapon::SetHeadLockTime(int Time) { generated_stub("Weapon::SetHeadLockTime 009f5720"); } -void Weapon::set_head_direction(int direction) { generated_stub("Weapon::set_head_direction 009f5780"); } -Vector * Weapon::get_tear_movement_inheritance(Vector *outResult, Vector *direction) { generated_stub("Weapon::get_tear_movement_inheritance 009f5890"); } -Vector * Weapon::GetOwnerLaserOffset(Vector *outOffset, int laserOffsetId, Vector *direction) { generated_stub("Weapon::GetOwnerLaserOffset 009f5a30"); } -Entity_Tear * Weapon::fire_tear(Vector *position, Vector *velocity, uint32_t flags, int unused, float damageMultiplier, float positionStep) { generated_stub("Weapon::fire_tear 009f5ad0"); } -Entity_Bomb * Weapon::fire_bomb(Weapon *weapon, Vector *position, Vector *velocity) { generated_stub("Weapon::fire_bomb 009f5d60"); } -Entity_Laser * Weapon::fire_brimstone_with_color(Vector *direction, float damageMult, uint32_t unk2) { generated_stub("Weapon::fire_brimstone_with_color 009f6570"); } -Entity_Laser * Weapon::fire_laser(Vector *position, uint32_t offsetId, Vector *direction, uint8_t isLeftEye, uint8_t isOneHit, float damageScale) { generated_stub("Weapon::fire_laser 009f6610"); } -Entity_Knife * Weapon::fire_knife(Entity *parent, uint32_t variant, uint8_t isCantOverwrite, int unused1, int unused2, float rotationOffset) { generated_stub("Weapon::fire_knife 009f6a60"); } -Entity_Knife * Weapon::FireSword(Entity *param_2, uint32_t param_3, float param_4, uint8_t param_5, uint8_t param_6, uint32_t param_7, Entity *param_8) { generated_stub("Weapon::FireSword 009f6c50"); } -void Weapon::TriggerTearEffects(Vector *direction, int count) { generated_stub("Weapon::TriggerTearEffects 009f7930"); } Weapon_Bombs::~Weapon_Bombs() { generated_stub("Weapon_Bombs::~Weapon_Bombs 009f9880"); } -void Weapon_Bombs::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Bombs::Fire 009f9b60"); } -uint32_t Weapon_Bombs::GetFocusEntity() { generated_stub("Weapon_Bombs::GetFocusEntity 009fa190"); } -uint32_t Weapon_Bombs::GetMainEntity() { generated_stub("Weapon_Bombs::GetMainEntity 009f3150"); } -uint32_t Weapon_Bombs::GetMarkedTargetVariant() { generated_stub("Weapon_Bombs::GetMarkedTargetVariant 009fa1b0"); } -uint8_t Weapon_Bombs::CanShutDoors() { generated_stub("Weapon_Bombs::CanShutDoors 00709c30"); } +void Weapon_Bombs::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Bombs::Init 009f34d0"); } +void Weapon_Bombs::Update(char param_2) { generated_stub("Weapon_Bombs::Update 009f34f0"); } +void Weapon_Bombs::Fire(Vector *param_1, uint8_t param_2, uint8_t param_3) { generated_stub("Weapon_Bombs::Fire 009f9b60"); } +void Weapon_Bombs::Reset() { generated_stub("Weapon_Bombs::Reset 009f3480"); } +void Weapon_Bombs::ClearReferences() { generated_stub("Weapon_Bombs::ClearReferences 009f3320"); } +long double Weapon_Bombs::GetMaxCharge() { generated_stub("Weapon_Bombs::GetMaxCharge 009f3130"); } +long double Weapon_Bombs::GetChargeBarAmount() { generated_stub("Weapon_Bombs::GetChargeBarAmount 009f4150"); } +void Weapon_Bombs::vfunc_8() { generated_stub("Weapon_Bombs::vfunc_8 009f3130"); } +Entity * Weapon_Bombs::GetFocusEntity() { generated_stub("Weapon_Bombs::GetFocusEntity 009fa190"); } +Entity * Weapon_Bombs::GetMainEntity() { generated_stub("Weapon_Bombs::GetMainEntity 009f3150"); } +void Weapon_Bombs::guard_check_icall() { generated_stub("Weapon_Bombs::guard_check_icall 0040c200"); } +int Weapon_Bombs::GetMarkedTargetVariant() { generated_stub("Weapon_Bombs::GetMarkedTargetVariant 009fa1b0"); } +uint8_t Weapon_Bombs::CanTakeDamageFromTearEffects() { generated_stub("Weapon_Bombs::CanTakeDamageFromTearEffects 00709c30"); } +uint8_t Weapon_Bombs::CanShutDoors() { generated_stub("Weapon_Bombs::CanShutDoors 005ccc00"); } +void Weapon_Bombs::vfunc_15() { generated_stub("Weapon_Bombs::vfunc_15 005ccc00"); } +void Weapon_Bombs::vfunc_16() { generated_stub("Weapon_Bombs::vfunc_16 005ccc00"); } Weapon_Bone::~Weapon_Bone() { generated_stub("Weapon_Bone::~Weapon_Bone 009f9aa0"); } -void Weapon_Bone::Update(char param_2) { generated_stub("Weapon_Bone::Update 009fa220"); } -void Weapon_Bone::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Bone::Fire 009fa450"); } +void Weapon_Bone::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Bone::Init 009f34d0"); } +void Weapon_Bone::Update(uint8_t isInterpolated) { generated_stub("Weapon_Bone::Update 009fa220"); } +void Weapon_Bone::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Bone::Fire 009fa450"); } void Weapon_Bone::Reset() { generated_stub("Weapon_Bone::Reset 009fed90"); } void Weapon_Bone::ClearReferences() { generated_stub("Weapon_Bone::ClearReferences 009fedf0"); } long double Weapon_Bone::GetMaxCharge() { generated_stub("Weapon_Bone::GetMaxCharge 009feeb0"); } -uint32_t Weapon_Bone::GetFocusEntity() { generated_stub("Weapon_Bone::GetFocusEntity 0085e1b0"); } -uint32_t Weapon_Bone::GetMainEntity() { generated_stub("Weapon_Bone::GetMainEntity 009f3150"); } -void Weapon_Bone::guard_check_icall() { generated_stub("Weapon_Bone::guard_check_icall 009fef20"); } +long double Weapon_Bone::GetChargeBarAmount() { generated_stub("Weapon_Bone::GetChargeBarAmount 009f4150"); } +void Weapon_Bone::vfunc_8() { generated_stub("Weapon_Bone::vfunc_8 009f3130"); } +int Weapon_Bone::CountSeedEffects() { generated_stub("Weapon_Bone::CountSeedEffects 0085e1b0"); } +Entity * Weapon_Bone::GetMainEntity() { generated_stub("Weapon_Bone::GetMainEntity 009f3150"); } +void Weapon_Bone::TriggerNewRoom() { generated_stub("Weapon_Bone::TriggerNewRoom 009fef20"); } +uint32_t Weapon_Bone::GetFocusEntity() { generated_stub("Weapon_Bone::GetFocusEntity 009f3140"); } +uint8_t Weapon_Bone::CanShutDoors() { generated_stub("Weapon_Bone::CanShutDoors 005ccc00"); } uint8_t Weapon_Bone::CanTriggerCursedEyeTeleport() { generated_stub("Weapon_Bone::CanTriggerCursedEyeTeleport 009ff1a0"); } uint8_t Weapon_Bone::CanTriggerKidneyStone() { generated_stub("Weapon_Bone::CanTriggerKidneyStone 009ff210"); } uint8_t Weapon_Bone::CanOverrideForgottenThrow() { generated_stub("Weapon_Bone::CanOverrideForgottenThrow 009ff230"); } void Weapon_Bone::init_club(int *param_1) { generated_stub("Weapon_Bone::init_club 009ff0c0"); } Weapon_Brimstone::~Weapon_Brimstone() { generated_stub("Weapon_Brimstone::~Weapon_Brimstone 009f9a20"); } -void Weapon_Brimstone::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Brimstone::Fire 009ff360"); } +void Weapon_Brimstone::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Brimstone::Init 009f34d0"); } +void Weapon_Brimstone::Update(char param_2) { generated_stub("Weapon_Brimstone::Update 009f34f0"); } +void Weapon_Brimstone::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Brimstone::Fire 009ff360"); } +void Weapon_Brimstone::Reset() { generated_stub("Weapon_Brimstone::Reset 009f3480"); } void Weapon_Brimstone::ClearReferences() { generated_stub("Weapon_Brimstone::ClearReferences 00a02790"); } long double Weapon_Brimstone::GetMaxCharge() { generated_stub("Weapon_Brimstone::GetMaxCharge 00a00f30"); } +long double Weapon_Brimstone::GetChargeBarAmount() { generated_stub("Weapon_Brimstone::GetChargeBarAmount 009f4150"); } +void Weapon_Brimstone::vfunc_8() { generated_stub("Weapon_Brimstone::vfunc_8 009f3130"); } uint32_t Weapon_Brimstone::GetFocusEntity() { generated_stub("Weapon_Brimstone::GetFocusEntity 00a02870"); } uint32_t Weapon_Brimstone::GetMainEntity() { generated_stub("Weapon_Brimstone::GetMainEntity 009f3160"); } -uint32_t Weapon_Brimstone::GetMarkedTargetVariant() { generated_stub("Weapon_Brimstone::GetMarkedTargetVariant 00a02800"); } +void Weapon_Brimstone::guard_check_icall() { generated_stub("Weapon_Brimstone::guard_check_icall 0040c200"); } +int Weapon_Brimstone::GetMarkedTargetVariant() { generated_stub("Weapon_Brimstone::GetMarkedTargetVariant 00a02800"); } +uint8_t Weapon_Brimstone::CanShutDoors() { generated_stub("Weapon_Brimstone::CanShutDoors 005ccc00"); } +uint8_t Weapon_Brimstone::CanTriggerCursedEyeTeleport() { generated_stub("Weapon_Brimstone::CanTriggerCursedEyeTeleport 005ccc00"); } +uint8_t Weapon_Brimstone::CanTriggerKidneyStone() { generated_stub("Weapon_Brimstone::CanTriggerKidneyStone 005ccc00"); } +uint8_t Weapon_Brimstone::CanOverrideForgottenThrow() { generated_stub("Weapon_Brimstone::CanOverrideForgottenThrow 005ccc00"); } void Weapon_Brimstone::fire_c_section_fetuses() { generated_stub("Weapon_Brimstone::fire_c_section_fetuses 00a00d10"); } void Weapon_Brimstone::init_laser(Entity_Laser *laser) { generated_stub("Weapon_Brimstone::init_laser 00a00f90"); } void Weapon_Brimstone::fire(float Speed, uint8_t IgnoreStatusEffects) { generated_stub("Weapon_Brimstone::fire 00a02890"); } -void Weapon_Deathmatch::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Deathmatch::Fire 00a031b0"); } -long double Weapon_Deathmatch::GetMaxCharge() { generated_stub("Weapon_Deathmatch::GetMaxCharge 00a036b0"); } -void Weapon_Fetus::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Fetus::Fire 00a036e0"); } -long double Weapon_Fetus::GetMaxCharge() { generated_stub("Weapon_Fetus::GetMaxCharge 00a03f60"); } -uint32_t Weapon_Fetus::GetMarkedTargetVariant() { generated_stub("Weapon_Fetus::GetMarkedTargetVariant 009fa1b0"); } -uint8_t Weapon_Fetus::CanTriggerKidneyStone() { generated_stub("Weapon_Fetus::CanTriggerKidneyStone 00709c30"); } +Weapon_Deathmatch::~Weapon_Deathmatch() { generated_stub("Weapon_Deathmatch::~Weapon_Deathmatch 009f3260"); } +void Weapon_Deathmatch::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Deathmatch::Init 009f34d0"); } +void Weapon_Deathmatch::Update(char param_2) { generated_stub("Weapon_Deathmatch::Update 009f34f0"); } +void Weapon_Deathmatch::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Deathmatch::Fire 00a031b0"); } +void Weapon_Deathmatch::Reset() { generated_stub("Weapon_Deathmatch::Reset 009f3480"); } +void Weapon_Deathmatch::ClearReferences() { generated_stub("Weapon_Deathmatch::ClearReferences 009f3320"); } +float Weapon_Deathmatch::GetMaxCharge() { generated_stub("Weapon_Deathmatch::GetMaxCharge 00a036b0"); } +long double Weapon_Deathmatch::GetChargeBarAmount() { generated_stub("Weapon_Deathmatch::GetChargeBarAmount 009f4150"); } +void Weapon_Deathmatch::vfunc_8() { generated_stub("Weapon_Deathmatch::vfunc_8 009f3130"); } +uint32_t Weapon_Deathmatch::GetFocusEntity() { generated_stub("Weapon_Deathmatch::GetFocusEntity 009f3140"); } +void Weapon_Deathmatch::vfunc_10() { generated_stub("Weapon_Deathmatch::vfunc_10 009f3140"); } +void Weapon_Deathmatch::guard_check_icall() { generated_stub("Weapon_Deathmatch::guard_check_icall 0040c200"); } +void Weapon_Deathmatch::vfunc_12() { generated_stub("Weapon_Deathmatch::vfunc_12 009f3140"); } +uint8_t Weapon_Deathmatch::CanShutDoors() { generated_stub("Weapon_Deathmatch::CanShutDoors 005ccc00"); } +void Weapon_Deathmatch::vfunc_14() { generated_stub("Weapon_Deathmatch::vfunc_14 005ccc00"); } +void Weapon_Deathmatch::vfunc_15() { generated_stub("Weapon_Deathmatch::vfunc_15 005ccc00"); } +void Weapon_Deathmatch::vfunc_16() { generated_stub("Weapon_Deathmatch::vfunc_16 005ccc00"); } +Weapon_Fetus::~Weapon_Fetus() { generated_stub("Weapon_Fetus::~Weapon_Fetus 009f3260"); } +void Weapon_Fetus::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Fetus::Init 009f34d0"); } +void Weapon_Fetus::Update(char param_2) { generated_stub("Weapon_Fetus::Update 009f34f0"); } +void Weapon_Fetus::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Fetus::Fire 00a036e0"); } +void Weapon_Fetus::Reset() { generated_stub("Weapon_Fetus::Reset 009f3480"); } +void Weapon_Fetus::ClearReferences() { generated_stub("Weapon_Fetus::ClearReferences 009f3320"); } +float Weapon_Fetus::GetMaxCharge() { generated_stub("Weapon_Fetus::GetMaxCharge 00a03f60"); } +long double Weapon_Fetus::GetChargeBarAmount() { generated_stub("Weapon_Fetus::GetChargeBarAmount 009f4150"); } +void Weapon_Fetus::vfunc_8() { generated_stub("Weapon_Fetus::vfunc_8 009f3130"); } +uint32_t Weapon_Fetus::GetFocusEntity() { generated_stub("Weapon_Fetus::GetFocusEntity 009f3140"); } +void Weapon_Fetus::vfunc_10() { generated_stub("Weapon_Fetus::vfunc_10 009f3140"); } +void Weapon_Fetus::guard_check_icall() { generated_stub("Weapon_Fetus::guard_check_icall 0040c200"); } +int Weapon_Fetus::GetMarkedTargetVariant() { generated_stub("Weapon_Fetus::GetMarkedTargetVariant 009fa1b0"); } +uint8_t Weapon_Fetus::CanShutDoors() { generated_stub("Weapon_Fetus::CanShutDoors 005ccc00"); } +void Weapon_Fetus::vfunc_14() { generated_stub("Weapon_Fetus::vfunc_14 005ccc00"); } +uint8_t Weapon_Fetus::CanTakeDamageFromTearEffects() { generated_stub("Weapon_Fetus::CanTakeDamageFromTearEffects 00709c30"); } +void Weapon_Fetus::vfunc_16() { generated_stub("Weapon_Fetus::vfunc_16 005ccc00"); } Weapon_Knife::~Weapon_Knife() { generated_stub("Weapon_Knife::~Weapon_Knife 009f99b0"); } -void Weapon_Knife::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Knife::Fire 00a03f90"); } +void Weapon_Knife::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Knife::Init 009f34d0"); } +void Weapon_Knife::Update(char param_2) { generated_stub("Weapon_Knife::Update 009f34f0"); } +void Weapon_Knife::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Knife::Fire 00a03f90"); } +void Weapon_Knife::Reset() { generated_stub("Weapon_Knife::Reset 009f3480"); } void Weapon_Knife::ClearReferences() { generated_stub("Weapon_Knife::ClearReferences 00a04f90"); } -long double Weapon_Knife::GetMaxCharge() { generated_stub("Weapon_Knife::GetMaxCharge 00a05010"); } -uint32_t Weapon_Knife::GetFocusEntity() { generated_stub("Weapon_Knife::GetFocusEntity 009fa190"); } -uint32_t Weapon_Knife::GetMainEntity() { generated_stub("Weapon_Knife::GetMainEntity 009f3150"); } -void Weapon_Knife::guard_check_icall() { generated_stub("Weapon_Knife::guard_check_icall 009fef20"); } -uint32_t Weapon_Knife::GetMarkedTargetVariant() { generated_stub("Weapon_Knife::GetMarkedTargetVariant 009fa1b0"); } -uint8_t Weapon_Knife::CanShutDoors() { generated_stub("Weapon_Knife::CanShutDoors 00a05060"); } +float Weapon_Knife::GetMaxCharge() { generated_stub("Weapon_Knife::GetMaxCharge 00a05010"); } +long double Weapon_Knife::GetChargeBarAmount() { generated_stub("Weapon_Knife::GetChargeBarAmount 009f4150"); } +void Weapon_Knife::vfunc_8() { generated_stub("Weapon_Knife::vfunc_8 009f3130"); } +Entity * Weapon_Knife::GetFocusEntity() { generated_stub("Weapon_Knife::GetFocusEntity 009fa190"); } +Entity * Weapon_Knife::GetMainEntity() { generated_stub("Weapon_Knife::GetMainEntity 009f3150"); } +void Weapon_Knife::TriggerNewRoom() { generated_stub("Weapon_Knife::TriggerNewRoom 009fef20"); } +int Weapon_Knife::GetMarkedTargetVariant() { generated_stub("Weapon_Knife::GetMarkedTargetVariant 009fa1b0"); } +uint8_t Weapon_Knife::SupportsTractorBeam() { generated_stub("Weapon_Knife::SupportsTractorBeam 00a05060"); } +uint8_t Weapon_Knife::CanShutDoors() { generated_stub("Weapon_Knife::CanShutDoors 005ccc00"); } +void Weapon_Knife::vfunc_15() { generated_stub("Weapon_Knife::vfunc_15 005ccc00"); } +void Weapon_Knife::vfunc_16() { generated_stub("Weapon_Knife::vfunc_16 005ccc00"); } void Weapon_Knife::init_knife(Entity_Knife *knife) { generated_stub("Weapon_Knife::init_knife 00a05070"); } Weapon_Laser::~Weapon_Laser() { generated_stub("Weapon_Laser::~Weapon_Laser 009f9930"); } -void Weapon_Laser::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Laser::Fire 00a052b0"); } +void Weapon_Laser::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Laser::Init 009f34d0"); } +void Weapon_Laser::Update(char param_2) { generated_stub("Weapon_Laser::Update 009f34f0"); } +void Weapon_Laser::Fire(Vector *param_1, uint8_t param_2, uint8_t param_3) { generated_stub("Weapon_Laser::Fire 00a052b0"); } void Weapon_Laser::Reset() { generated_stub("Weapon_Laser::Reset 00a052a0"); } void Weapon_Laser::ClearReferences() { generated_stub("Weapon_Laser::ClearReferences 00a063b0"); } long double Weapon_Laser::GetMaxCharge() { generated_stub("Weapon_Laser::GetMaxCharge 00a06870"); } -uint32_t Weapon_Laser::GetFocusEntity() { generated_stub("Weapon_Laser::GetFocusEntity 009fa190"); } -uint32_t Weapon_Laser::GetMainEntity() { generated_stub("Weapon_Laser::GetMainEntity 009f3150"); } -uint32_t Weapon_Laser::GetMarkedTargetVariant() { generated_stub("Weapon_Laser::GetMarkedTargetVariant 00a02800"); } +long double Weapon_Laser::GetChargeBarAmount() { generated_stub("Weapon_Laser::GetChargeBarAmount 009f4150"); } +void Weapon_Laser::vfunc_8() { generated_stub("Weapon_Laser::vfunc_8 009f3130"); } +Entity * Weapon_Laser::GetFocusEntity() { generated_stub("Weapon_Laser::GetFocusEntity 009fa190"); } +Entity * Weapon_Laser::GetMainEntity() { generated_stub("Weapon_Laser::GetMainEntity 009f3150"); } +void Weapon_Laser::guard_check_icall() { generated_stub("Weapon_Laser::guard_check_icall 0040c200"); } +int Weapon_Laser::GetMarkedTargetVariant() { generated_stub("Weapon_Laser::GetMarkedTargetVariant 00a02800"); } +uint8_t Weapon_Laser::CanShutDoors() { generated_stub("Weapon_Laser::CanShutDoors 005ccc00"); } uint8_t Weapon_Laser::CanTriggerCursedEyeTeleport() { generated_stub("Weapon_Laser::CanTriggerCursedEyeTeleport 00a068e0"); } -uint8_t Weapon_Laser::CanTriggerKidneyStone() { generated_stub("Weapon_Laser::CanTriggerKidneyStone 00a05060"); } +uint8_t Weapon_Laser::SupportsTractorBeam() { generated_stub("Weapon_Laser::SupportsTractorBeam 00a05060"); } +void Weapon_Laser::vfunc_16() { generated_stub("Weapon_Laser::vfunc_16 005ccc00"); } void Weapon_Laser::init_laser(Weapon *weapon, Entity_Laser *laser) { generated_stub("Weapon_Laser::init_laser 00a06330"); } Weapon_Ludovico::~Weapon_Ludovico() { generated_stub("Weapon_Ludovico::~Weapon_Ludovico 009f9880"); } -void Weapon_Ludovico::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Ludovico::Fire 00a06a30"); } +void Weapon_Ludovico::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Ludovico::Init 009f34d0"); } +void Weapon_Ludovico::Update(char param_2) { generated_stub("Weapon_Ludovico::Update 009f34f0"); } +void Weapon_Ludovico::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Ludovico::Fire 00a06a30"); } +void Weapon_Ludovico::Reset() { generated_stub("Weapon_Ludovico::Reset 009f3480"); } void Weapon_Ludovico::ClearReferences() { generated_stub("Weapon_Ludovico::ClearReferences 00a063b0"); } -uint32_t Weapon_Ludovico::GetFocusEntity() { generated_stub("Weapon_Ludovico::GetFocusEntity 009f3150"); } -uint32_t Weapon_Ludovico::GetMainEntity() { generated_stub("Weapon_Ludovico::GetMainEntity 009f3150"); } -void Weapon_MonstrosLung::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_MonstrosLung::Fire 00a07d50"); } -long double Weapon_MonstrosLung::GetMaxCharge() { generated_stub("Weapon_MonstrosLung::GetMaxCharge 00a08c80"); } +long double Weapon_Ludovico::GetMaxCharge() { generated_stub("Weapon_Ludovico::GetMaxCharge 009f3130"); } +long double Weapon_Ludovico::GetChargeBarAmount() { generated_stub("Weapon_Ludovico::GetChargeBarAmount 009f4150"); } +void Weapon_Ludovico::vfunc_8() { generated_stub("Weapon_Ludovico::vfunc_8 009f3130"); } +Entity * Weapon_Ludovico::GetMainEntity() { generated_stub("Weapon_Ludovico::GetMainEntity 009f3150"); } +void Weapon_Ludovico::vfunc_10() { generated_stub("Weapon_Ludovico::vfunc_10 009f3150"); } +void Weapon_Ludovico::guard_check_icall() { generated_stub("Weapon_Ludovico::guard_check_icall 0040c200"); } +uint32_t Weapon_Ludovico::GetFocusEntity() { generated_stub("Weapon_Ludovico::GetFocusEntity 009f3140"); } +uint8_t Weapon_Ludovico::CanShutDoors() { generated_stub("Weapon_Ludovico::CanShutDoors 005ccc00"); } +void Weapon_Ludovico::vfunc_14() { generated_stub("Weapon_Ludovico::vfunc_14 005ccc00"); } +void Weapon_Ludovico::vfunc_15() { generated_stub("Weapon_Ludovico::vfunc_15 005ccc00"); } +void Weapon_Ludovico::vfunc_16() { generated_stub("Weapon_Ludovico::vfunc_16 005ccc00"); } +Weapon_MonstrosLung::~Weapon_MonstrosLung() { generated_stub("Weapon_MonstrosLung::~Weapon_MonstrosLung 009f3260"); } +void Weapon_MonstrosLung::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_MonstrosLung::Init 009f34d0"); } +void Weapon_MonstrosLung::Update(char param_2) { generated_stub("Weapon_MonstrosLung::Update 009f34f0"); } +void Weapon_MonstrosLung::Fire() { generated_stub("Weapon_MonstrosLung::Fire 00a07d50"); } +void Weapon_MonstrosLung::Reset() { generated_stub("Weapon_MonstrosLung::Reset 009f3480"); } +void Weapon_MonstrosLung::ClearReferences() { generated_stub("Weapon_MonstrosLung::ClearReferences 009f3320"); } +float Weapon_MonstrosLung::GetMaxCharge() { generated_stub("Weapon_MonstrosLung::GetMaxCharge 00a08c80"); } +long double Weapon_MonstrosLung::GetChargeBarAmount() { generated_stub("Weapon_MonstrosLung::GetChargeBarAmount 009f4150"); } +void Weapon_MonstrosLung::vfunc_8() { generated_stub("Weapon_MonstrosLung::vfunc_8 009f3130"); } +uint32_t Weapon_MonstrosLung::GetFocusEntity() { generated_stub("Weapon_MonstrosLung::GetFocusEntity 009f3140"); } +uint32_t Weapon_MonstrosLung::GetMainEntity() { generated_stub("Weapon_MonstrosLung::GetMainEntity 009f3140"); } +void Weapon_MonstrosLung::guard_check_icall() { generated_stub("Weapon_MonstrosLung::guard_check_icall 0040c200"); } uint32_t Weapon_MonstrosLung::GetMarkedTargetVariant() { generated_stub("Weapon_MonstrosLung::GetMarkedTargetVariant 00a08cd0"); } -uint8_t Weapon_MonstrosLung::CanShutDoors() { generated_stub("Weapon_MonstrosLung::CanShutDoors 00709c30"); } +uint8_t Weapon_MonstrosLung::CanTakeDamageFromTearEffects() { generated_stub("Weapon_MonstrosLung::CanTakeDamageFromTearEffects 00709c30"); } +uint8_t Weapon_MonstrosLung::CanShutDoors() { generated_stub("Weapon_MonstrosLung::CanShutDoors 005ccc00"); } +uint8_t Weapon_MonstrosLung::CanTriggerKidneyStone() { generated_stub("Weapon_MonstrosLung::CanTriggerKidneyStone 005ccc00"); } +uint8_t Weapon_MonstrosLung::CanOverrideForgottenThrow() { generated_stub("Weapon_MonstrosLung::CanOverrideForgottenThrow 005ccc00"); } void Weapon_MonstrosLung::FireBurst(uint32_t param_1, int param_2) { generated_stub("Weapon_MonstrosLung::FireBurst 00a08700"); } Weapon_Rockets::~Weapon_Rockets() { generated_stub("Weapon_Rockets::~Weapon_Rockets 009f9880"); } -void Weapon_Rockets::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Rockets::Fire 00a08d40"); } +void Weapon_Rockets::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_Rockets::Init 009f34d0"); } +void Weapon_Rockets::Update(char param_2) { generated_stub("Weapon_Rockets::Update 009f34f0"); } +void Weapon_Rockets::Fire(Vector *aimDirection, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Rockets::Fire 00a08d40"); } +void Weapon_Rockets::Reset() { generated_stub("Weapon_Rockets::Reset 009f3480"); } void Weapon_Rockets::ClearReferences() { generated_stub("Weapon_Rockets::ClearReferences 00a063b0"); } -uint32_t Weapon_Rockets::GetFocusEntity() { generated_stub("Weapon_Rockets::GetFocusEntity 009f3150"); } -uint32_t Weapon_Rockets::GetMainEntity() { generated_stub("Weapon_Rockets::GetMainEntity 009f3150"); } -uint32_t Weapon_Rockets::GetMarkedTargetVariant() { generated_stub("Weapon_Rockets::GetMarkedTargetVariant 00a099a0"); } +long double Weapon_Rockets::GetMaxCharge() { generated_stub("Weapon_Rockets::GetMaxCharge 009f3130"); } +long double Weapon_Rockets::GetChargeBarAmount() { generated_stub("Weapon_Rockets::GetChargeBarAmount 009f4150"); } +void Weapon_Rockets::vfunc_8() { generated_stub("Weapon_Rockets::vfunc_8 009f3130"); } +Entity * Weapon_Rockets::GetMainEntity() { generated_stub("Weapon_Rockets::GetMainEntity 009f3150"); } +void Weapon_Rockets::vfunc_10() { generated_stub("Weapon_Rockets::vfunc_10 009f3150"); } +void Weapon_Rockets::guard_check_icall() { generated_stub("Weapon_Rockets::guard_check_icall 0040c200"); } +int Weapon_Rockets::GetMarkedTargetVariant() { generated_stub("Weapon_Rockets::GetMarkedTargetVariant 00a099a0"); } +uint8_t Weapon_Rockets::CanShutDoors() { generated_stub("Weapon_Rockets::CanShutDoors 005ccc00"); } +void Weapon_Rockets::vfunc_14() { generated_stub("Weapon_Rockets::vfunc_14 005ccc00"); } +void Weapon_Rockets::vfunc_15() { generated_stub("Weapon_Rockets::vfunc_15 005ccc00"); } +void Weapon_Rockets::vfunc_16() { generated_stub("Weapon_Rockets::vfunc_16 005ccc00"); } Weapon_SpiritSword::~Weapon_SpiritSword() { generated_stub("Weapon_SpiritSword::~Weapon_SpiritSword 009f9930"); } -void Weapon_SpiritSword::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_SpiritSword::Fire 00a099e0"); } +void Weapon_SpiritSword::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_SpiritSword::Init 009f34d0"); } +void Weapon_SpiritSword::Update(char param_2) { generated_stub("Weapon_SpiritSword::Update 009f34f0"); } +void Weapon_SpiritSword::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_SpiritSword::Fire 00a099e0"); } void Weapon_SpiritSword::Reset() { generated_stub("Weapon_SpiritSword::Reset 00a0a6f0"); } void Weapon_SpiritSword::ClearReferences() { generated_stub("Weapon_SpiritSword::ClearReferences 00a063b0"); } long double Weapon_SpiritSword::GetMaxCharge() { generated_stub("Weapon_SpiritSword::GetMaxCharge 00a0a700"); } -uint32_t Weapon_SpiritSword::GetMainEntity() { generated_stub("Weapon_SpiritSword::GetMainEntity 009f3150"); } -Weapon_Tears::~Weapon_Tears() { generated_stub("Weapon_Tears::~Weapon_Tears 009f9900"); } -void Weapon_Tears::Update(char param_2) { generated_stub("Weapon_Tears::Update 00a0d870"); } -void Weapon_Tears::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_Tears::Fire 00a0a720"); } -void Weapon_Tears::Reset() { generated_stub("Weapon_Tears::Reset 00a0d850"); } -long double Weapon_Tears::GetMaxCharge() { generated_stub("Weapon_Tears::GetMaxCharge 00a0d8e0"); } -uint32_t Weapon_Tears::GetMarkedTargetVariant() { generated_stub("Weapon_Tears::GetMarkedTargetVariant 009fa1b0"); } -uint8_t Weapon_Tears::CanShutDoors() { generated_stub("Weapon_Tears::CanShutDoors 00a05060"); } -uint8_t Weapon_Tears::CanTriggerCursedEyeTeleport() { generated_stub("Weapon_Tears::CanTriggerCursedEyeTeleport 00a0d950"); } -uint8_t Weapon_Tears::CanTriggerKidneyStone() { generated_stub("Weapon_Tears::CanTriggerKidneyStone 00a05060"); } -void Weapon_TechX::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_TechX::Fire 00a0d9c0"); } -long double Weapon_TechX::GetMaxCharge() { generated_stub("Weapon_TechX::GetMaxCharge 00a0e260"); } +long double Weapon_SpiritSword::GetChargeBarAmount() { generated_stub("Weapon_SpiritSword::GetChargeBarAmount 009f4150"); } +void Weapon_SpiritSword::vfunc_8() { generated_stub("Weapon_SpiritSword::vfunc_8 009f3130"); } +uint32_t Weapon_SpiritSword::GetFocusEntity() { generated_stub("Weapon_SpiritSword::GetFocusEntity 009f3140"); } +Entity * Weapon_SpiritSword::GetMainEntity() { generated_stub("Weapon_SpiritSword::GetMainEntity 009f3150"); } +void Weapon_SpiritSword::guard_check_icall() { generated_stub("Weapon_SpiritSword::guard_check_icall 0040c200"); } +void Weapon_SpiritSword::vfunc_12() { generated_stub("Weapon_SpiritSword::vfunc_12 009f3140"); } +uint8_t Weapon_SpiritSword::CanShutDoors() { generated_stub("Weapon_SpiritSword::CanShutDoors 005ccc00"); } +void Weapon_SpiritSword::vfunc_14() { generated_stub("Weapon_SpiritSword::vfunc_14 005ccc00"); } +void Weapon_SpiritSword::vfunc_15() { generated_stub("Weapon_SpiritSword::vfunc_15 005ccc00"); } +void Weapon_SpiritSword::vfunc_16() { generated_stub("Weapon_SpiritSword::vfunc_16 005ccc00"); } +Weapon_TechX::~Weapon_TechX() { generated_stub("Weapon_TechX::~Weapon_TechX 009f3260"); } +void Weapon_TechX::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_TechX::Init 009f34d0"); } +void Weapon_TechX::Update(char param_2) { generated_stub("Weapon_TechX::Update 009f34f0"); } +void Weapon_TechX::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_TechX::Fire 00a0d9c0"); } +void Weapon_TechX::Reset() { generated_stub("Weapon_TechX::Reset 009f3480"); } +void Weapon_TechX::ClearReferences() { generated_stub("Weapon_TechX::ClearReferences 009f3320"); } +float Weapon_TechX::GetMaxCharge() { generated_stub("Weapon_TechX::GetMaxCharge 00a0e260"); } +long double Weapon_TechX::GetChargeBarAmount() { generated_stub("Weapon_TechX::GetChargeBarAmount 009f4150"); } +void Weapon_TechX::vfunc_8() { generated_stub("Weapon_TechX::vfunc_8 009f3130"); } +uint32_t Weapon_TechX::GetFocusEntity() { generated_stub("Weapon_TechX::GetFocusEntity 009f3140"); } +void Weapon_TechX::vfunc_10() { generated_stub("Weapon_TechX::vfunc_10 009f3140"); } +void Weapon_TechX::guard_check_icall() { generated_stub("Weapon_TechX::guard_check_icall 0040c200"); } uint32_t Weapon_TechX::GetMarkedTargetVariant() { generated_stub("Weapon_TechX::GetMarkedTargetVariant 00a08cd0"); } -uint8_t Weapon_TechX::CanShutDoors() { generated_stub("Weapon_TechX::CanShutDoors 00709c30"); } -uint8_t Weapon_TechX::CanTriggerKidneyStone() { generated_stub("Weapon_TechX::CanTriggerKidneyStone 00709c30"); } +uint8_t Weapon_TechX::CanTakeDamageFromTearEffects() { generated_stub("Weapon_TechX::CanTakeDamageFromTearEffects 00709c30"); } +uint8_t Weapon_TechX::CanShutDoors() { generated_stub("Weapon_TechX::CanShutDoors 005ccc00"); } +void Weapon_TechX::vfunc_15() { generated_stub("Weapon_TechX::vfunc_15 00709c30"); } +void Weapon_TechX::vfunc_16() { generated_stub("Weapon_TechX::vfunc_16 005ccc00"); } Weapon_UmbilicalWhip::~Weapon_UmbilicalWhip() { generated_stub("Weapon_UmbilicalWhip::~Weapon_UmbilicalWhip 009f9880"); } -void Weapon_UmbilicalWhip::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_UmbilicalWhip::Fire 00a0e270"); } -void Weapon_UmbilicalWhip::Reset() { generated_stub("Weapon_UmbilicalWhip::Reset 0040c200"); } +void Weapon_UmbilicalWhip::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_UmbilicalWhip::Init 009f34d0"); } +void Weapon_UmbilicalWhip::Update(char param_2) { generated_stub("Weapon_UmbilicalWhip::Update 009f34f0"); } +void Weapon_UmbilicalWhip::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_UmbilicalWhip::Fire 00a0e270"); } +void Weapon_UmbilicalWhip::guard_check_icall() { generated_stub("Weapon_UmbilicalWhip::guard_check_icall 0040c200"); } void Weapon_UmbilicalWhip::ClearReferences() { generated_stub("Weapon_UmbilicalWhip::ClearReferences 00a063b0"); } -long double Weapon_UmbilicalWhip::GetChargeBarAmount() { generated_stub("Weapon_UmbilicalWhip::GetChargeBarAmount 009f3130"); } -uint32_t Weapon_UmbilicalWhip::GetMainEntity() { generated_stub("Weapon_UmbilicalWhip::GetMainEntity 009f3150"); } -uint8_t Weapon_UmbilicalWhip::CanShutDoors() { generated_stub("Weapon_UmbilicalWhip::CanShutDoors 00709c30"); } +long double Weapon_UmbilicalWhip::GetMaxCharge() { generated_stub("Weapon_UmbilicalWhip::GetMaxCharge 009f3130"); } +void Weapon_UmbilicalWhip::vfunc_7() { generated_stub("Weapon_UmbilicalWhip::vfunc_7 009f3130"); } +void Weapon_UmbilicalWhip::vfunc_8() { generated_stub("Weapon_UmbilicalWhip::vfunc_8 009f3130"); } +uint32_t Weapon_UmbilicalWhip::GetFocusEntity() { generated_stub("Weapon_UmbilicalWhip::GetFocusEntity 009f3140"); } +Entity * Weapon_UmbilicalWhip::GetMainEntity() { generated_stub("Weapon_UmbilicalWhip::GetMainEntity 009f3150"); } +void Weapon_UmbilicalWhip::vfunc_11() { generated_stub("Weapon_UmbilicalWhip::vfunc_11 0040c200"); } +void Weapon_UmbilicalWhip::vfunc_12() { generated_stub("Weapon_UmbilicalWhip::vfunc_12 009f3140"); } +uint8_t Weapon_UmbilicalWhip::CanTakeDamageFromTearEffects() { generated_stub("Weapon_UmbilicalWhip::CanTakeDamageFromTearEffects 00709c30"); } +uint8_t Weapon_UmbilicalWhip::CanShutDoors() { generated_stub("Weapon_UmbilicalWhip::CanShutDoors 005ccc00"); } +void Weapon_UmbilicalWhip::vfunc_15() { generated_stub("Weapon_UmbilicalWhip::vfunc_15 005ccc00"); } +void Weapon_UmbilicalWhip::vfunc_16() { generated_stub("Weapon_UmbilicalWhip::vfunc_16 005ccc00"); } Weapon_UrnOfSouls::~Weapon_UrnOfSouls() { generated_stub("Weapon_UrnOfSouls::~Weapon_UrnOfSouls 009f97e0"); } -void Weapon_UrnOfSouls::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_UrnOfSouls::Fire 00a0e630"); } +void Weapon_UrnOfSouls::Init(uint32_t param_2, uint32_t param_3) { generated_stub("Weapon_UrnOfSouls::Init 009f34d0"); } +void Weapon_UrnOfSouls::Update(char param_2) { generated_stub("Weapon_UrnOfSouls::Update 009f34f0"); } +void Weapon_UrnOfSouls::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) { generated_stub("Weapon_UrnOfSouls::Fire 00a0e630"); } void Weapon_UrnOfSouls::Reset() { generated_stub("Weapon_UrnOfSouls::Reset 00a0f410"); } void Weapon_UrnOfSouls::ClearReferences() { generated_stub("Weapon_UrnOfSouls::ClearReferences 00a0f420"); } -long double Weapon_UrnOfSouls::GetChargeBarAmount() { generated_stub("Weapon_UrnOfSouls::GetChargeBarAmount 009f3130"); } -uint32_t Weapon_UrnOfSouls::GetMainEntity() { generated_stub("Weapon_UrnOfSouls::GetMainEntity 009f3170"); } -uint8_t Weapon_UrnOfSouls::CanShutDoors() { generated_stub("Weapon_UrnOfSouls::CanShutDoors 00709c30"); } +long double Weapon_UrnOfSouls::GetMaxCharge() { generated_stub("Weapon_UrnOfSouls::GetMaxCharge 009f3130"); } +void Weapon_UrnOfSouls::vfunc_7() { generated_stub("Weapon_UrnOfSouls::vfunc_7 009f3130"); } +void Weapon_UrnOfSouls::vfunc_8() { generated_stub("Weapon_UrnOfSouls::vfunc_8 009f3130"); } +uint32_t Weapon_UrnOfSouls::GetFocusEntity() { generated_stub("Weapon_UrnOfSouls::GetFocusEntity 009f3140"); } +Entity * Weapon_UrnOfSouls::GetMainEntity() { generated_stub("Weapon_UrnOfSouls::GetMainEntity 009f3170"); } +void Weapon_UrnOfSouls::guard_check_icall() { generated_stub("Weapon_UrnOfSouls::guard_check_icall 0040c200"); } +void Weapon_UrnOfSouls::vfunc_12() { generated_stub("Weapon_UrnOfSouls::vfunc_12 009f3140"); } +uint8_t Weapon_UrnOfSouls::CanTakeDamageFromTearEffects() { generated_stub("Weapon_UrnOfSouls::CanTakeDamageFromTearEffects 00709c30"); } +uint8_t Weapon_UrnOfSouls::CanShutDoors() { generated_stub("Weapon_UrnOfSouls::CanShutDoors 005ccc00"); } +void Weapon_UrnOfSouls::vfunc_15() { generated_stub("Weapon_UrnOfSouls::vfunc_15 005ccc00"); } +void Weapon_UrnOfSouls::vfunc_16() { generated_stub("Weapon_UrnOfSouls::vfunc_16 005ccc00"); } uint32_t WeightedOutcomePicker::PickOutcome(RNG rng) { generated_stub("WeightedOutcomePicker::PickOutcome 0049cbf0"); } msvc::exception::~exception() { generated_stub("msvc::exception::~exception 0040ce20"); } char * msvc::exception::FUN_0040d0d0() { generated_stub("msvc::exception::FUN_0040d0d0 0040d0d0"); } @@ -9959,7 +9877,6 @@ int FUN_004074a0() { generated_stub("FUN_004074a0 004074a0"); } void Isaac::SwapANM2(ANM2 *left, ANM2 *right) { generated_stub("Isaac::SwapANM2 00407ae0"); } void _empty_check_0x34() { generated_stub("_empty_check_0x34 0040a7c0"); } void FUN_0040bcb0(uint8_t *param_1) { generated_stub("FUN_0040bcb0 0040bcb0"); } -void guard_check_icall() { generated_stub("guard_check_icall 0040c200"); } void FUN_0040c230() { generated_stub("FUN_0040c230 0040c230"); } bool FUN_0040c2d0() { generated_stub("FUN_0040c2d0 0040c2d0"); } void FUN_0040c2f0() { generated_stub("FUN_0040c2f0 0040c2f0"); } @@ -10061,7 +9978,6 @@ int FUN_00417920() { generated_stub("FUN_00417920 00417920"); } void FUN_00417dd0() { generated_stub("FUN_00417dd0 00417dd0"); } void FUN_00417df0() { generated_stub("FUN_00417df0 00417df0"); } void FUN_00417e50() { generated_stub("FUN_00417e50 00417e50"); } -void render_entity_light_masks(float *param_1) { generated_stub("render_entity_light_masks 00419b50"); } int FUN_0041b770(int param_1) { generated_stub("FUN_0041b770 0041b770"); } void FUN_0041c670() { generated_stub("FUN_0041c670 0041c670"); } int FUN_0041c6f0(uint32_t param_1) { generated_stub("FUN_0041c6f0 0041c6f0"); } @@ -10150,7 +10066,6 @@ StageTransition * FUN_00428b50() { generated_stub("FUN_00428b50 00428b50"); } void FUN_00428b60(void *param_1, uint32_t param_2) { generated_stub("FUN_00428b60 00428b60"); } void FUN_00428ce0() { generated_stub("FUN_00428ce0 00428ce0"); } uint32_t FUN_00428d30(uint32_t param_1) { generated_stub("FUN_00428d30 00428d30"); } -void update_cutscene_state_machine() { generated_stub("update_cutscene_state_machine 004291c0"); } void FUN_00429810(uint32_t param_1) { generated_stub("FUN_00429810 00429810"); } void FUN_00429f20() { generated_stub("FUN_00429f20 00429f20"); } int FUN_00429f30(uint32_t param_1) { generated_stub("FUN_00429f30 00429f30"); } @@ -11105,7 +11020,6 @@ int Isaac::Random(int Max) { generated_stub("Isaac::Random 0067f010"); } uint32_t FUN_0067f030() { generated_stub("FUN_0067f030 0067f030"); } Vector * RandomVector(Vector *out, uint32_t seed) { generated_stub("RandomVector 0067f0d0"); } Vector * Isaac::GetAxisAlignedUnitVectorFromDir(Vector *outVector, int direction) { generated_stub("Isaac::GetAxisAlignedUnitVectorFromDir 0067f1d0"); } -int vector_to_direction(Vector *vec) { generated_stub("vector_to_direction 0067f260"); } void FUN_0067f2e0() { generated_stub("FUN_0067f2e0 0067f2e0"); } void * string_split(void *outTokens, std_string *text, uint8_t delimiter) { generated_stub("string_split 0067f420"); } uint8_t string_to_bool(void *self) { generated_stub("string_to_bool 0067f600"); } @@ -11276,7 +11190,6 @@ void FUN_006b5f40() { generated_stub("FUN_006b5f40 006b5f40"); } void play_sound_with_fart_seed(int soundId, float volume, int frameDelay, uint8_t isLoop, float pitch) { generated_stub("play_sound_with_fart_seed 006b6470"); } void * spawn_rock_particles(float *param_1, float *param_2) { generated_stub("spawn_rock_particles 006b68c0"); } void FUN_006b6e40(float *param_1, int param_2) { generated_stub("FUN_006b6e40 006b6e40"); } -void FUN_006b7cc0(float *param_1) { generated_stub("FUN_006b7cc0 006b7cc0"); } int _Entity::GetAncestorField(uint32_t param_1) { generated_stub("_Entity::GetAncestorField 006b7d20"); } void vector_0x3c_tidy() { generated_stub("vector_0x3c_tidy 006b7d40"); } void FUN_006b7db0(uint32_t *param_1) { generated_stub("FUN_006b7db0 006b7db0"); } @@ -11388,7 +11301,6 @@ void FUN_00709850() { generated_stub("FUN_00709850 00709850"); } void FUN_007098c0() { generated_stub("FUN_007098c0 007098c0"); } void FUN_00709930() { generated_stub("FUN_00709930 00709930"); } int FUN_00709bc0() { generated_stub("FUN_00709bc0 00709bc0"); } -GridEntity * Isaac::CreateGridEntity(int type, uint32_t gridIndex) { generated_stub("Isaac::CreateGridEntity 0070b2e0"); } bool FUN_0070be60() { generated_stub("FUN_0070be60 0070be60"); } uint8_t FUN_0070bf60() { generated_stub("FUN_0070bf60 0070bf60"); } uint8_t is_grid_type_floor_special(int gridType) { generated_stub("is_grid_type_floor_special 0070bf80"); } @@ -11533,7 +11445,6 @@ void FUN_007538b0() { generated_stub("FUN_007538b0 007538b0"); } void FUN_007538c0() { generated_stub("FUN_007538c0 007538c0"); } uint8_t FUN_007538d0() { generated_stub("FUN_007538d0 007538d0"); } uint32_t FUN_007538e0() { generated_stub("FUN_007538e0 007538e0"); } -int FUN_00753940() { generated_stub("FUN_00753940 00753940"); } void FUN_007539a0() { generated_stub("FUN_007539a0 007539a0"); } int FUN_00753bf0() { generated_stub("FUN_00753bf0 00753bf0"); } void FUN_00753c40(uint32_t param_1) { generated_stub("FUN_00753c40 00753c40"); } @@ -11698,7 +11609,6 @@ void FUN_007e92e0(uint32_t param_1, uint32_t param_2) { generated_stub("FUN_007e void FUN_007e93d0(int param_1) { generated_stub("FUN_007e93d0 007e93d0"); } void FUN_007ea0c0() { generated_stub("FUN_007ea0c0 007ea0c0"); } void FUN_007ea5d0() { generated_stub("FUN_007ea5d0 007ea5d0"); } -void init_room_render_surfaces() { generated_stub("init_room_render_surfaces 007ea630"); } void FUN_007ebc40() { generated_stub("FUN_007ebc40 007ebc40"); } uint32_t FUN_007ed240() { generated_stub("FUN_007ed240 007ed240"); } uint8_t entity_type_is_saved(int type, int variant, uint32_t subType, int spawnerType, uint8_t isRoomFlag) { generated_stub("entity_type_is_saved 007eed10"); } @@ -11714,7 +11624,6 @@ uint32_t FUN_0081e220() { generated_stub("FUN_0081e220 0081e220"); } void FUN_0081fae0(uint32_t *param_1) { generated_stub("FUN_0081fae0 0081fae0"); } uint32_t FUN_008207a0() { generated_stub("FUN_008207a0 008207a0"); } void FUN_00821940() { generated_stub("FUN_00821940 00821940"); } -void FUN_00823540() { generated_stub("FUN_00823540 00823540"); } int FUN_00823ec0() { generated_stub("FUN_00823ec0 00823ec0"); } uint32_t FUN_00827180(float *param_1) { generated_stub("FUN_00827180 00827180"); } void FUN_00827f30() { generated_stub("FUN_00827f30 00827f30"); } @@ -11802,7 +11711,6 @@ void FUN_008452f0(SourceQuad *param_1, void *param_2, ColorMod *param_3) { gener void collectible_icon_render(void *param_1, ColorMod *param_2, int *param_3, int *param_4) { generated_stub("collectible_icon_render 00848c20"); } void FUN_0084a870(float *param_1) { generated_stub("FUN_0084a870 0084a870"); } void FUN_0084abc0(uint32_t *param_1, float *param_2, uint32_t *param_3, uint32_t *param_4) { generated_stub("FUN_0084abc0 0084abc0"); } -void FUN_0084bab0(Vector *param_1, ColorMod *param_2, int param_3) { generated_stub("FUN_0084bab0 0084bab0"); } void FUN_0084bba0() { generated_stub("FUN_0084bba0 0084bba0"); } void FUN_0084bbc0(uint32_t *param_1) { generated_stub("FUN_0084bbc0 0084bbc0"); } void FUN_0084bc00(uint32_t *param_1) { generated_stub("FUN_0084bc00 0084bc00"); } @@ -11983,7 +11891,6 @@ void FUN_00865260() { generated_stub("FUN_00865260 00865260"); } uint32_t Catch_008652e9() { generated_stub("Catch_008652e9 008652e9"); } int lua_callback_run_get_card(RNG *rng, int card, uint8_t isPlaying, uint8_t isRunes, uint8_t isOnlyRunes) { generated_stub("lua_callback_run_get_card 00865340"); } uint8_t * Catch_00865424() { generated_stub("Catch_00865424 00865424"); } -uint32_t * lua_callback_run_get_shader_params(uint32_t *param_1, void *param_2) { generated_stub("lua_callback_run_get_shader_params 00865490"); } uint8_t * Catch_008655b7() { generated_stub("Catch_008655b7 008655b7"); } char * FUN_00865660(char *param_1, uint32_t *param_2) { generated_stub("FUN_00865660 00865660"); } uint32_t FUN_008658c0(uint32_t param_1, uint32_t *param_2) { generated_stub("FUN_008658c0 008658c0"); } @@ -14284,7 +14191,6 @@ void FUN_009baa10(char param_1) { generated_stub("FUN_009baa10 009baa10"); } int FUN_009bac00(int param_1) { generated_stub("FUN_009bac00 009bac00"); } uint32_t FUN_009be9c0() { generated_stub("FUN_009be9c0 009be9c0"); } void entity_vector_set_flag_410(void *self, uint8_t value) { generated_stub("entity_vector_set_flag_410 009bea10"); } -Vector * players_center_position(void *self, Vector *outPosition, uint8_t isUseCache) { generated_stub("players_center_position 009beba0"); } void FUN_009bfc00() { generated_stub("FUN_009bfc00 009bfc00"); } void FUN_009bfc20() { generated_stub("FUN_009bfc20 009bfc20"); } void FUN_009bfc40() { generated_stub("FUN_009bfc40 009bfc40"); } @@ -14361,7 +14267,6 @@ void FUN_009e24f0(uint32_t *param_1, uint32_t param_2) { generated_stub("FUN_009 void FUN_009e2520(void *param_1) { generated_stub("FUN_009e2520 009e2520"); } void FUN_009e2580(int *param_1, uint32_t *param_2) { generated_stub("FUN_009e2580 009e2580"); } int * FUN_009e2760(int *param_1, uint32_t *param_2) { generated_stub("FUN_009e2760 009e2760"); } -void anm2_member_at_1c4_destroy(void *self) { generated_stub("anm2_member_at_1c4_destroy 009e27c0"); } uint8_t room_grid_flood_fill(void *self, uint32_t startIndex, uint32_t targetIndex) { generated_stub("room_grid_flood_fill 009e3560"); } int FUN_009e3d30() { generated_stub("FUN_009e3d30 009e3d30"); } void FUN_009e3d60() { generated_stub("FUN_009e3d60 009e3d60"); } @@ -14438,26 +14343,16 @@ void Catch_All_009f229d() { generated_stub("Catch_All_009f229d 009f229d"); } uint32_t * FUN_009f2410(uint32_t *param_1) { generated_stub("FUN_009f2410 009f2410"); } void FUN_009f2480() { generated_stub("FUN_009f2480 009f2480"); } void * map_int_ImagePtr_subscript(void *self, int *key) { generated_stub("map_int_ImagePtr_subscript 009f2e20"); } -void FUN_009f3180() { generated_stub("FUN_009f3180 009f3180"); } void FUN_009f3c10() { generated_stub("FUN_009f3c10 009f3c10"); } void FUN_009f3c40() { generated_stub("FUN_009f3c40 009f3c40"); } void FUN_009f4130() { generated_stub("FUN_009f4130 009f4130"); } -void * FUN_009f4230(void *param_1, int param_2, int param_3, float param_4, float param_5, float param_6, short param_7, float param_8, float param_9, float param_10, float param_11, int param_12, float param_13, uint8_t param_14, short param_15) { generated_stub("FUN_009f4230 009f4230"); } Entity_Player * FUN_009f4fc0() { generated_stub("FUN_009f4fc0 009f4fc0"); } -int FUN_009f57f0() { generated_stub("FUN_009f57f0 009f57f0"); } void FUN_009f5810(uint8_t param_1) { generated_stub("FUN_009f5810 009f5810"); } -uint32_t FUN_009f5830() { generated_stub("FUN_009f5830 009f5830"); } -uint32_t FUN_009f5850() { generated_stub("FUN_009f5850 009f5850"); } -uint32_t FUN_009f5870() { generated_stub("FUN_009f5870 009f5870"); } -int FUN_009f5aa0() { generated_stub("FUN_009f5aa0 009f5aa0"); } Entity_Tear * fire_fetus_tear(void *self, Vector *position, Vector *velocity, int fireFlags, Entity *source, float damageMultiplier, int unused) { generated_stub("fire_fetus_tear 009f6e60"); } -Weapon * Isaac::CreateWeapon(int weaponType, Entity *owner) { generated_stub("Isaac::CreateWeapon 009f9020"); } -void Isaac::DestoryWeapon(Weapon **weapon) { generated_stub("Isaac::DestoryWeapon 009f9050"); } uint32_t * FUN_009f9080() { generated_stub("FUN_009f9080 009f9080"); } uint32_t * FUN_009f90f0() { generated_stub("FUN_009f90f0 009f90f0"); } uint32_t * FUN_009f9170() { generated_stub("FUN_009f9170 009f9170"); } uint32_t * FUN_009f91f0() { generated_stub("FUN_009f91f0 009f91f0"); } -uint32_t * FUN_009f9260() { generated_stub("FUN_009f9260 009f9260"); } uint32_t * FUN_009f92d0() { generated_stub("FUN_009f92d0 009f92d0"); } uint32_t * FUN_009f9350() { generated_stub("FUN_009f9350 009f9350"); } uint32_t * FUN_009f93d0() { generated_stub("FUN_009f93d0 009f93d0"); } diff --git a/generated-src/tear_params.cpp b/generated-src/tear_params.cpp deleted file mode 100644 index a5ce628..0000000 --- a/generated-src/tear_params.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include "classes.h" - -// 005cd690 -void TearParams::constructor() -{ - this->_tearVariant = 0; - this->_bombVariant = 0; - (this->_tearColor)._tint[0] = 1.0; - (this->_tearColor)._tint[1] = 1.0; - (this->_tearColor)._tint[2] = 1.0; - (this->_tearColor)._tint[3] = 1.0; - (this->_tearColor)._colorize[0] = 0.0; - (this->_tearColor)._colorize[1] = 0.0; - (this->_tearColor)._colorize[2] = 0.0; - (this->_tearColor)._colorize[3] = 0.0; - (this->_tearColor)._offset[0] = 0.0; - (this->_tearColor)._offset[1] = 0.0; - (this->_tearColor)._offset[2] = 0.0; - *GHIDRA_CAST(&(this->_flags)._l) = 0; - *GHIDRA_CAST((GHIDRA_INT(&(this->_flags)._l) + 4)) = 0; - *GHIDRA_CAST(&(this->_flags)._h) = 0; - *GHIDRA_CAST((GHIDRA_INT(&(this->_flags)._h) + 4)) = 0; - this->_tearDamage = 3.5; - this->_tearScale = 1.0; - this->_tearHeight = -23.75; - this[1]._tearVariant = 0x3f800000; - this[1]._bombVariant = 0x3fd9999a; - this[1]._tearColor._tint[0] = 1.0; - this[1]._tearColor._tint[1] = 0.0; - return; -} - -// 006075a0 -TearParams * TearParams::operator_(TearParams *other) -{ - float fVar1; - float fVar2; - float fVar3; - uint32_t uVar4; - uint32_t uVar5; - uint64_t qVar6; - - this->_tearVariant = other->_tearVariant; - this->_bombVariant = other->_bombVariant; - if (&this->_tearColor != &other->_tearColor) { - fVar1 = (other->_tearColor)._tint[1]; - fVar2 = (other->_tearColor)._tint[2]; - fVar3 = (other->_tearColor)._tint[3]; - (this->_tearColor)._tint[0] = (other->_tearColor)._tint[0]; - (this->_tearColor)._tint[1] = fVar1; - (this->_tearColor)._tint[2] = fVar2; - (this->_tearColor)._tint[3] = fVar3; - fVar1 = (other->_tearColor)._colorize[1]; - fVar2 = (other->_tearColor)._colorize[2]; - fVar3 = (other->_tearColor)._colorize[3]; - (this->_tearColor)._colorize[0] = (other->_tearColor)._colorize[0]; - (this->_tearColor)._colorize[1] = fVar1; - (this->_tearColor)._colorize[2] = fVar2; - (this->_tearColor)._colorize[3] = fVar3; - *GHIDRA_CAST((this->_tearColor)._offset) = *GHIDRA_CAST((other->_tearColor)._offset); - (this->_tearColor)._offset[2] = (other->_tearColor)._offset[2]; - } - uVar4 = *GHIDRA_CAST((GHIDRA_INT(&(other->_flags)._l) + 4)); - qVar6 = (other->_flags)._h; - uVar5 = *GHIDRA_CAST((GHIDRA_INT(&(other->_flags)._h) + 4)); - *GHIDRA_CAST(&(this->_flags)._l) = GHIDRA_INT((other->_flags)._l); - *GHIDRA_CAST((GHIDRA_INT(&(this->_flags)._l) + 4)) = uVar4; - *GHIDRA_CAST(&(this->_flags)._h) = GHIDRA_INT(qVar6); - *GHIDRA_CAST((GHIDRA_INT(&(this->_flags)._h) + 4)) = uVar5; - this->_tearDamage = other->_tearDamage; - this->_tearScale = other->_tearScale; - this->_tearHeight = other->_tearHeight; - this[1]._tearVariant = other[1]._tearVariant; - this[1]._bombVariant = other[1]._bombVariant; - this[1]._tearColor._tint[0] = other[1]._tearColor._tint[0]; - this[1]._tearColor._tint[1] = other[1]._tearColor._tint[1]; - return this; -} - -// 0065b490 -void TearParams::copy(void *other) -{ - float fVar1; - float fVar2; - float fVar3; - uint32_t uVar4; - uint32_t uVar5; - uint32_t uVar6; - - this->_tearVariant = *GHIDRA_CAST(other); - this->_bombVariant = *GHIDRA_CAST((GHIDRA_CAST(other) + 4)); - fVar1 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0xc)); - fVar2 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x10)); - fVar3 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x14)); - (this->_tearColor)._tint[0] = *GHIDRA_CAST((GHIDRA_CAST(other) + 8)); - (this->_tearColor)._tint[1] = fVar1; - (this->_tearColor)._tint[2] = fVar2; - (this->_tearColor)._tint[3] = fVar3; - fVar1 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x1c)); - fVar2 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x20)); - fVar3 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x24)); - (this->_tearColor)._colorize[0] = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x18)); - (this->_tearColor)._colorize[1] = fVar1; - (this->_tearColor)._colorize[2] = fVar2; - (this->_tearColor)._colorize[3] = fVar3; - *GHIDRA_CAST((this->_tearColor)._offset) = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x28)); - (this->_tearColor)._offset[2] = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x30)); - uVar4 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x3c)); - uVar5 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x40)); - uVar6 = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x44)); - *GHIDRA_CAST(&(this->_flags)._l) = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x38)); - *GHIDRA_CAST((GHIDRA_INT(&(this->_flags)._l) + 4)) = uVar4; - *GHIDRA_CAST(&(this->_flags)._h) = uVar5; - *GHIDRA_CAST((GHIDRA_INT(&(this->_flags)._h) + 4)) = uVar6; - this->_tearDamage = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x48)); - this->_tearScale = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x4c)); - this->_tearHeight = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x50)); - this[1]._tearVariant = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x54)); - this[1]._bombVariant = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x58)); - this[1]._tearColor._tint[0] = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x5c)); - this[1]._tearColor._tint[1] = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x60)); - return; -} diff --git a/generated-src/weapon.cpp b/generated-src/weapon.cpp deleted file mode 100644 index 5b29acd..0000000 --- a/generated-src/weapon.cpp +++ /dev/null @@ -1,2479 +0,0 @@ -#include "classes.h" - -// 0075a2b0 -uint8_t Weapon::is_held_item(ANM2 *sprite, std_string *animName, void *itemDesc) -{ - int *this; - uint8_t isCollectible; - void *animData; - int itemType; - - if (itemDesc == (void *)0x0) { - if (animName->_size != 0) { - if (0xf < animName->_capacity) { - animName = *GHIDRA_CAST(animName->_buf); - } - animData = ANM2::GetAnimationData(sprite,GHIDRA_CAST(animName)); - if (animData != (void *)0x0) { - return 1; - } - } - return 0; - } - itemType = *GHIDRA_CAST(itemDesc); - if ((((itemType != 1) && (itemType != 3)) && (itemType != 4)) || - (*GHIDRA_CAST((GHIDRA_CAST(itemDesc) + 4)) != 0x76)) { - return *(void **)sprite[1]._filename._buf == itemDesc; - } - this = *GHIDRA_CAST(sprite[1]._filename._buf); - if (this != GHIDRA_CAST(0x0)) { - if (*this == 0) { - switch(this[1]) { - case 0xb: - case 0x2d: - case 0x56: - case 99: - return 1; - } - } - else { - isCollectible = this->Item::IsCollectible(); - if (isCollectible != 0) { - return this[1] == 0x76; - } - if (*this == 2) { - return this[1] == 0xa2; - } - } - } - return 0; -} - -// 009f3130 -void Weapon::vfunc_8() -{ - return (long double)0; -} - -// 009f3140 -uint32_t Weapon::GetMarkedTargetVariant() -{ - return 0; -} - -// 009f3320 -void Weapon::ClearReferences() -{ - Weapon *local_8; - uint32_t *laserRef; - - laserRef = &this->_technology2Laser; - if (GHIDRA_CAST(*laserRef) != GHIDRA_CAST(0x0)) { - local_8 = this; - (**(code **)(*GHIDRA_CAST(*laserRef) + 0x28))(); - if (*laserRef != 0) { - local_8 = GHIDRA_CAST(laserRef); - msvc::multiset::erase(&local_8); - *laserRef = 0; - } - } - return; -} - -// 009f3360 -uint8_t Weapon::IsAxisAligned() -{ - uint8_t isHasItem; - Entity_Player *player; - - player = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (((player != GHIDRA_CAST(0x0)) && - (((player->_type == 1 || - ((player->_type == 3 && - (player = *GHIDRA_CAST(&player->_isControlsEnabled), player != GHIDRA_CAST(0x0)))) - ) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x28)))) == g_vectorZero.x)))) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2c)))) == g_vectorZero.y)) { - isHasItem = Entity_Player::HasCollectible(player,0x1d1,0); - if (isHasItem == 0) { - isHasItem = Entity_Player::HasCollectible(player,0x18a,0); - if (isHasItem == 0) { - return 1; - } - } - } - return 0; -} - -// 009f33e0 -Vector * Weapon::get_aim_direction(Vector *outDir, Vector *defaultDir) -{ - uint8_t isHasMarked; - float *ownerAimDir; - Entity_Player *this_00; - float dirX; - - this_00 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (((this_00 != GHIDRA_CAST(0x0)) && - ((this_00->_type == 1 || - ((this_00->_type == 3 && - (this_00 = *GHIDRA_CAST(&this_00->_isControlsEnabled), this_00 != GHIDRA_CAST(0x0)) - ))))) && ((this->_modifiers & 0x40000000U) == 0)) { - isHasMarked = Entity_Player::HasCollectible(this_00,0x18a,0); - if ((((isHasMarked == 0) || (this_00->_markedTarget == (void *)0x0)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x28)))) == g_vectorZero.x)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2c)))) == g_vectorZero.y)) { - ownerAimDir = GHIDRA_CAST(FUN_00753940()); - dirX = *ownerAimDir; - outDir->y = ownerAimDir[1]; - outDir->x = dirX; - return outDir; - } - } - dirX = defaultDir->x; - outDir->y = defaultDir->y; - outDir->x = dirX; - return outDir; -} - -// 009f3480 -void Weapon::Reset() -{ - this->ClearReferences(); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x1c)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) = 0x41200000; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x18)))) = 0x3f800000; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x38)))) = 0; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x20)))) = g_vectorZero.x; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x24)))) = g_vectorZero.y; - return; -} - -// 009f34d0 -void Weapon::Init(uint32_t param_2, uint32_t param_3) -{ - this->Reset(); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) = param_3; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x30)))) = param_2; - return; -} - -// 009f34f0 -void Weapon::Update(char param_2) -{ - float charge; - - if ((param_2 == '\0') && (charge = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))), -1.0 < charge)) { - if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 0) { - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = charge - *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x39c)); - return; - } - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = charge - 1.0; - } - return; -} - -// 009f3540 -void Weapon::Fire(Vector *position, uint8_t isShooting, uint8_t isInterpolated) -{ - int *piVar1; - uint32_t uVar2; - uint64_t qVar3; - uint64_t qVar4; - uint8_t bVar5; - char cVar6; - Vector *pVVar7; - Vector *ownerPos; - Entity_Laser *laser; - ColorMod *laserColorPtr; - int rollResult; - Entity_Player *ownerPlayer; - uint32_t notExplosiveLoHi; - int extraout_ECX; - int iVar8; - int extraout_ECX_00; - int extraout_ECX_01; - int extraout_ECX_02; - int extraout_ECX_03; - uint32_t notExplosiveHiHi; - uint32_t notExplosiveHiLo; - Entity_Player *player; - uint32_t uVar9; - Entity_NPC *pEVar10; - Entity_NPC *ownerPlayer; - float fVar12; - uint8_t auStack_68 [4]; - Entity_Laser *local_64; - float aimDirY; - Entity_NPC *local_5c; - Entity_Player *player2; - Entity_NPC *local_54; - Vector local_50; - Vector scratchVec; - Weapon *local_40; - Weapon *local_3c; - ColorMod laserColor; - uint32_t local_c; - Manager *manager; - - local_c = __security_cookie ^ GHIDRA_UINT(auStack_68); - local_54 = GHIDRA_CAST(position); - ownerPlayer = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (ownerPlayer == GHIDRA_CAST(0x0)) { -LAB_009f35c4: - player2 = GHIDRA_CAST(0x0); -LAB_009f35ca: - local_3c = GHIDRA_CAST(0x0); - } - else if (ownerPlayer->_type == 1) { - local_3c = GHIDRA_CAST(ownerPlayer->_luck); - player2 = ownerPlayer; - } - else { - if (ownerPlayer->_type == 3) { - player2 = *GHIDRA_CAST(&ownerPlayer->_isControlsEnabled); -LAB_009f35aa: - ownerPlayer = *GHIDRA_CAST(&ownerPlayer->_isControlsEnabled); - if (ownerPlayer == GHIDRA_CAST(0x0)) goto LAB_009f35ca; - } - else { - if (ownerPlayer == GHIDRA_CAST(0x0)) goto LAB_009f35c4; - player2 = GHIDRA_CAST(0x0); - if (ownerPlayer->_type != 1) { - if (ownerPlayer->_type == 3) goto LAB_009f35aa; - goto LAB_009f35ca; - } - } - local_3c = GHIDRA_CAST(ownerPlayer->_luck); - } - ownerPlayer = player2; - local_40 = this; - if (player2 == GHIDRA_CAST(0x0)) { -LAB_009f3b99: - piVar1 = GHIDRA_CAST(this->_technology2Laser); - if ((piVar1 != GHIDRA_CAST(0x0)) && (*GHIDRA_CAST((GHIDRA_CAST(piVar1) + 0x173)) == '\0')) { - (**(code **)(*piVar1 + 0x28))(); - } - return; - } - Entity_Player::HasCollectible(player2,0x18a,0); - bVar5 = Entity_Player::HasCollectible(ownerPlayer,0x98,0); - if ((bVar5 == 0) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x30)))) == 0xf)) goto LAB_009f3b99; - local_64 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_54)) + 0x0)))); - aimDirY = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_54)) + 0x4)))); - local_50.x = (float)local_64; - local_50.y = aimDirY; - bVar5 = IsAxisAligned(this); - if (bVar5 == 0) { - fVar12 = sqrtf((float)local_64 * (float)local_64 + aimDirY * aimDirY); - if (0.0 < fVar12) { - aimDirY = (1.0 / fVar12) * aimDirY; - local_64 = GHIDRA_CAST(((float)local_64 * (1.0 / fVar12))); - local_50.x = (float)local_64; - local_50.y = aimDirY; - } - } - else { - pVVar7 = Vector::ToCardinal(&scratchVec,&local_50); - local_64 = GHIDRA_CAST(pVVar7->x); - aimDirY = pVVar7->y; - local_50.x = (float)local_64; - local_50.y = aimDirY; - } - if ((isShooting == 0) || (((float)local_64 == g_vectorZero.x && (aimDirY == g_vectorZero.y)))) { - if (*GHIDRA_CAST(&g_game->_roomTransition) != 0) { - return; - } - if (isShooting != 0) { - return; - } - goto LAB_009f3b99; - } - pEVar10 = GHIDRA_CAST(this->_technology2Laser); - local_54 = GHIDRA_CAST(&this->_technology2Laser); - local_5c = pEVar10; - if (pEVar10 == GHIDRA_CAST(0x0)) { - fVar12 = 1.0; - pVVar7 = &local_50; - uVar9 = 1; - ownerPlayer = pEVar10; - ownerPos = get_owner_position(this,&scratchVec); - laser = fire_laser(this,ownerPos,uVar9,pVVar7,(uint8_t)pEVar10,(uint8_t)ownerPlayer,fVar12); - laser->_disableInitSound = 1; - manager = g_manager; - local_64 = laser; - if (((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 0) && (*GHIDRA_CAST(g_game->_room) != '\0')) && - (1 < g_game->_frameCount - *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x11f0)))) { - local_5c = GHIDRA_CAST(0x86); - seed_fart_sound_override(GHIDRA_CAST(&local_5c)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_5c),1.0,2,0,1.0,0.0); - } - pEVar10 = local_54; - qVar3 = (laser->_tearFlags)._l; - uVar9 = *GHIDRA_CAST((GHIDRA_INT(&(laser->_tearFlags)._l) + 4)); - qVar4 = (laser->_tearFlags)._h; - uVar2 = *GHIDRA_CAST((GHIDRA_INT(&(laser->_tearFlags)._h) + 4)); - laser->_timeout = -1; - laser->_disableFollowParent = 0; - notExplosiveHiLo = ~GHIDRA_UINT(g_tearFlagExplosive._h); - notExplosiveHiHi = ~(*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagExplosive._h)) + 0x4))); - notExplosiveLoHi = ~(*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagExplosive._l)) + 0x4))); - *GHIDRA_CAST(&(local_64->_tearFlags)._l) = ~GHIDRA_UINT(g_tearFlagExplosive._l) & GHIDRA_UINT(qVar3); - *GHIDRA_CAST((GHIDRA_INT(&(local_64->_tearFlags)._l) + 4)) = notExplosiveLoHi & uVar9; - *GHIDRA_CAST(&(local_64->_tearFlags)._h) = notExplosiveHiLo & GHIDRA_UINT(qVar4); - *GHIDRA_CAST((GHIDRA_INT(&(local_64->_tearFlags)._h) + 4)) = notExplosiveHiHi & uVar2; - if (*GHIDRA_CAST(local_54) != local_64) { - if (*GHIDRA_CAST(local_54) != GHIDRA_CAST(0x0)) { - local_5c = local_54; - msvc::multiset::erase(&local_5c); - } - *GHIDRA_CAST(pEVar10) = local_64; - msvc::multiset::insert(pEVar10); - } - local_64->_damageMultiplier = 0.13; - (*GHIDRA_CAST((GHIDRA_CAST((local_64)) + 0x517))) = 1; - (**(code **)(*GHIDRA_CAST(local_64) + 0xc))(); - aimDirY = local_50.y; - local_64 = GHIDRA_CAST(local_50.x); - player = player2; -LAB_009f39d5: - this = local_40; - ownerPlayer = player; - } - else if (isInterpolated == 0) { - fVar12 = atan2f(aimDirY,(float)local_64); - Entity_NPC::SetAimAngle(local_5c,fVar12 * 57.295776); - GetOwnerLaserOffset(this,&scratchVec,1,&local_50); - player = player2; - (local_5c->_posOffset).y = scratchVec.y; - local_5c->_stateFrame = GHIDRA_INT(scratchVec.x); - (local_5c->_posOffset).x = 0.0; - (local_5c->_pathfinder)._entity = (void *)0x0; - uVar9 = *GHIDRA_CAST((GHIDRA_INT(&(ownerPlayer->_tearFlags)._l) + 4)); - qVar3 = (ownerPlayer->_tearFlags)._h; - uVar2 = *GHIDRA_CAST((GHIDRA_INT(&(ownerPlayer->_tearFlags)._h) + 4)); - notExplosiveHiLo = ~GHIDRA_UINT(g_tearFlagExplosive._h); - notExplosiveHiHi = ~(*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagExplosive._h)) + 0x4))); - notExplosiveLoHi = ~(*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagExplosive._l)) + 0x4))); - (local_5c->_pathfinder)._direction = - ~GHIDRA_UINT(g_tearFlagExplosive._l) & GHIDRA_UINT((ownerPlayer->_tearFlags)._l); - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&((local_5c->_pathfinder))) + 0x18)))) = notExplosiveLoHi & uVar9; - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&((local_5c->_pathfinder))) + 0x1c)))) = notExplosiveHiLo & GHIDRA_UINT(qVar3); - (local_5c->_pathfinder)._gridIndex = notExplosiveHiHi & uVar2; - laserColorPtr = Entity_Player::get_laser_color_copy(player2,&laserColor); - pEVar10 = local_5c; - (**(code **)(*GHIDRA_CAST(local_5c) + 0x3c))(laserColorPtr,0xffffffff,0xff,0,1); - if ((aimDirY <= -0.5) || ((float)local_64 <= -0.5)) { - pEVar10->_renderDepthOffset = -10.0; - } - else { - pEVar10->_renderDepthOffset = 3000.0; - } - goto LAB_009f39d5; - } - cVar6 = FUN_0097e7c0(); - iVar8 = extraout_ECX; - if (cVar6 == '\0') goto LAB_009f3b6a; - bVar5 = Entity_Player::HasCollectible(ownerPlayer,0x37,0); - if (bVar5 == 0) { -LAB_009f3a27: - bVar5 = Entity_Player::HasCollectible(ownerPlayer,0x57,0); - iVar8 = extraout_ECX_00; - if (bVar5 == 0) goto LAB_009f3b6a; - iVar8 = 0x50 - GHIDRA_INT(((float)local_3c * 5.0)); - if (iVar8 < 1) { - iVar8 = 1; - } - rollResult = Isaac::Random(iVar8); - iVar8 = extraout_ECX_01; - if (rollResult != 0) goto LAB_009f3b6a; - } - else { - iVar8 = 0x14 - GHIDRA_INT(((float)local_3c * 1.5)); - if (iVar8 < 1) { - iVar8 = 1; - } - iVar8 = Isaac::Random(iVar8); - if (iVar8 != 0) goto LAB_009f3a27; - } - scratchVec.x = (float)(GHIDRA_UINT(local_64) ^ 0x80000000); - scratchVec.y = (float)(GHIDRA_UINT(aimDirY) ^ 0x80000000); - local_40 = GHIDRA_CAST(scratchVec.y); - local_3c = GHIDRA_CAST(scratchVec.x); - pVVar7 = get_owner_position(this,&local_50); - laser = fire_laser(this,pVVar7,5,&scratchVec,0,1,0.13); - (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); - bVar5 = Entity_Player::HasCollectible(ownerPlayer,0x57,0); - iVar8 = extraout_ECX_02; - if (bVar5 != 0) { - scratchVec.x = aimDirY; - scratchVec.y = (float)local_3c; - pVVar7 = get_owner_position(this,&local_50); - laser = fire_laser(this,pVVar7,5,&scratchVec,0,1,0.13); - (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); - scratchVec.x = (float)local_40; - scratchVec.y = (float)local_64; - pVVar7 = get_owner_position(this,&local_50); - laser = fire_laser(this,pVVar7,5,&scratchVec,0,1,0.13); - (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); - iVar8 = extraout_ECX_03; - } -LAB_009f3b6a: - SetBlinkTime(this,5,iVar8); - return; -} - -// 009f3bd0 -Vector * Weapon::get_owner_position(Vector *outPos) -{ - int iVar1; - float posX; - - posX = g_vectorZero.x; - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (iVar1 == 0) { - outPos->y = g_vectorZero.y; - outPos->x = posX; - return outPos; - } - posX = *GHIDRA_CAST((iVar1 + 0x33c)); - outPos->y = *GHIDRA_CAST((iVar1 + 0x340)); - outPos->x = posX; - return outPos; -} - -// 009f3c80 -float Weapon::get_damage() -{ - int iVar1; - Entity_Player *this_00; - uint8_t isHasBffs; - float damage; - - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (iVar1 != 0) { - if (*GHIDRA_CAST((iVar1 + 0x28)) == 1) { - return *GHIDRA_CAST((iVar1 + 0x1470)); - } - if ((*GHIDRA_CAST((iVar1 + 0x28)) == 3) && - (this_00 = *GHIDRA_CAST((iVar1 + 0x410)), this_00 != GHIDRA_CAST(0x0))) { - damage = this_00->_damage; - if (this_00->_playerType != 0xd) { - damage = damage * 0.5; - } - isHasBffs = Entity_Player::HasCollectible(this_00,0xf7,0); - if (isHasBffs == 0) { - return damage; - } - return damage + damage; - } - } - return 3.5; -} - -// 009f3d00 -BitSet128 * Weapon::get_owner_tear_flags(BitSet128 *outFlags) -{ - uint8_t isBabyBender; - Entity_Player *familiarOwner; - Entity_Player *this_00; - uint32_t *flagsDword; - uint64_t highFlags; - uint32_t highFlagsHigh; - uint32_t lowFlagsHigh; - - familiarOwner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (familiarOwner == GHIDRA_CAST(0x0)) { -LAB_009f3d28: - this_00 = GHIDRA_CAST(0x0); - if ((familiarOwner != GHIDRA_CAST(0x0)) && (familiarOwner->_type == 3)) goto LAB_009f3d36; - } - else { - if (familiarOwner->_type != 1) { - if (familiarOwner->_type == 3) { - this_00 = *GHIDRA_CAST(&familiarOwner->_isControlsEnabled); - goto LAB_009f3d36; - } - goto LAB_009f3d28; - } - this_00 = familiarOwner; - } - familiarOwner = GHIDRA_CAST(0x0); -LAB_009f3d36: - *GHIDRA_CAST(&outFlags->_l) = 0; - *GHIDRA_CAST((GHIDRA_INT(&outFlags->_l) + 4)) = 0; - *GHIDRA_CAST(&outFlags->_h) = 0; - *GHIDRA_CAST((GHIDRA_INT(&outFlags->_h) + 4)) = 0; - if (this_00 != GHIDRA_CAST(0x0)) { - lowFlagsHigh = *GHIDRA_CAST((GHIDRA_INT(&(this_00->_tearFlags)._l) + 4)); - highFlags = (this_00->_tearFlags)._h; - highFlagsHigh = *GHIDRA_CAST((GHIDRA_INT(&(this_00->_tearFlags)._h) + 4)); - *GHIDRA_CAST(&outFlags->_l) = GHIDRA_INT((this_00->_tearFlags)._l); - *GHIDRA_CAST((GHIDRA_INT(&outFlags->_l) + 4)) = lowFlagsHigh; - *GHIDRA_CAST(&outFlags->_h) = GHIDRA_INT(highFlags); - *GHIDRA_CAST((GHIDRA_INT(&outFlags->_h) + 4)) = highFlagsHigh; - if (familiarOwner != GHIDRA_CAST(0x0)) { - isBabyBender = Entity_Player::HasTrinket(this_00,0x7f,0); - if (isBabyBender != 0) { - *GHIDRA_CAST(&outFlags->_l) = GHIDRA_UINT(outFlags->_l) | GHIDRA_UINT(g_tearFlagHoming._l); - flagsDword = GHIDRA_CAST((GHIDRA_INT(&outFlags->_l) + 4)); - *flagsDword = *flagsDword | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagHoming._l)) + 0x4))); - *GHIDRA_CAST(&outFlags->_h) = GHIDRA_UINT(outFlags->_h) | GHIDRA_UINT(g_tearFlagHoming._h); - flagsDword = GHIDRA_CAST((GHIDRA_INT(&outFlags->_h) + 4)); - *flagsDword = *flagsDword | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagHoming._h)) + 0x4))); - return outFlags; - } - } - } - return outFlags; -} - -// 009f3db0 -ColorMod * Weapon::get_tear_color(ColorMod *outColor) -{ - uint8_t bVar1; - Entity_Player *this_00; - Entity_Player *pEVar2; - float local_XMM0_Da_398; - ColorMod local_60; - ColorMod local_34; - float colorizeA; - float colorizeB; - float colorizeG; - float colorizeR; - float temp_30305f054e2662; - float temp_32305f054e2662; - float temp_34305f054e2662; - float temp_36305f054e2662; - - pEVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (pEVar2 == GHIDRA_CAST(0x0)) { -LAB_009f3dd9: - this_00 = GHIDRA_CAST(0x0); - if ((pEVar2 != GHIDRA_CAST(0x0)) && (pEVar2->_type == 3)) goto LAB_009f3de7; - } - else { - if (pEVar2->_type != 1) { - if (pEVar2->_type == 3) { - this_00 = *GHIDRA_CAST(&pEVar2->_isControlsEnabled); - goto LAB_009f3de7; - } - goto LAB_009f3dd9; - } - this_00 = pEVar2; - } - pEVar2 = GHIDRA_CAST(0x0); -LAB_009f3de7: - outColor->_tint[0] = 1.0; - outColor->_tint[1] = 1.0; - outColor->_tint[2] = 1.0; - outColor->_tint[3] = 1.0; - outColor->_colorize[0] = 0.0; - outColor->_colorize[1] = 0.0; - outColor->_colorize[2] = 0.0; - outColor->_colorize[3] = 0.0; - outColor->_offset[0] = 0.0; - outColor->_offset[1] = 0.0; - outColor->_offset[2] = 0.0; - if (this_00 != GHIDRA_CAST(0x0)) { - temp_30305f054e2662 = (this_00->_tearColor)._tint[0]; - temp_32305f054e2662 = (this_00->_tearColor)._tint[1]; - temp_34305f054e2662 = (this_00->_tearColor)._tint[2]; - temp_36305f054e2662 = (this_00->_tearColor)._tint[3]; - local_XMM0_Da_398 = (this_00->_tearColor)._offset[2]; - colorizeR = (this_00->_tearColor)._colorize[0]; - colorizeG = (this_00->_tearColor)._colorize[1]; - colorizeB = (this_00->_tearColor)._colorize[2]; - colorizeA = (this_00->_tearColor)._colorize[3]; - if (outColor != &local_60) { - *GHIDRA_CAST(outColor->_offset) = *GHIDRA_CAST((this_00->_tearColor)._offset); - outColor->_tint[0] = temp_30305f054e2662; - outColor->_tint[1] = temp_32305f054e2662; - outColor->_tint[2] = temp_34305f054e2662; - outColor->_tint[3] = temp_36305f054e2662; - outColor->_offset[2] = local_XMM0_Da_398; - outColor->_colorize[0] = colorizeR; - outColor->_colorize[1] = colorizeG; - outColor->_colorize[2] = colorizeB; - outColor->_colorize[3] = colorizeA; - } - if (pEVar2 != GHIDRA_CAST(0x0)) { - bVar1 = Entity_Player::HasTrinket(this_00,0x7f,0); - if (bVar1 == 0) { - if ((char)pEVar2->_chargeBarSprites[5]._shadowLayerIndex != '\0') { - outColor->_colorize[0] = 2.4; - outColor->_colorize[1] = 2.4; - outColor->_colorize[2] = 2.4; - outColor->_colorize[3] = 1.0; - } - } - else { - local_34._offset[0] = 0.21568629; - local_34._offset[1] = 0.019607844; - local_34._offset[2] = 0.37254903; - if (outColor != &local_34) { - outColor->_colorize[0] = 0.0; - outColor->_colorize[1] = 0.0; - outColor->_colorize[2] = 0.0; - outColor->_colorize[3] = 0.0; - outColor->_offset[0] = 0.21568629; - outColor->_offset[1] = 0.019607844; - outColor->_tint[0] = 0.4; - outColor->_tint[1] = 0.15; - outColor->_tint[2] = 0.38; - outColor->_tint[3] = 1.0; - outColor->_offset[2] = 0.37254903; - } - } - } - if (g_manager->_netplayManager != *GHIDRA_CAST((g_manager + 1))) { - bVar1 = NetplayManager::IsIdxLocalPlayer - (GHIDRA_CAST(&g_manager->_netplayManager),this_00->_controllerIndex); - if (bVar1 == 0) { - if ((g_game == GHIDRA_CAST(0x0)) || (*GHIDRA_CAST(&g_game->_deathmatchManager) < 2)) { - local_XMM0_Da_398 = (float)(g_manager->_optionsConfig)._onlinePlayerOpacity * 0.09 + 0.1; - } - else { - local_XMM0_Da_398 = 1.0; - } - outColor->_tint[3] = local_XMM0_Da_398 * outColor->_tint[3]; - } - } - } - return outColor; -} - -// 009f3f60 -ColorMod * Weapon::get_laser_color(ColorMod *outColor) -{ - float fVar1; - float fVar2; - float fVar3; - float fVar4; - float fVar5; - float fVar6; - float fVar7; - float fVar8; - uint8_t bVar9; - Entity_Player *this_00; - Entity_Familiar *ownerFamiliar; - float fVar10; - ColorMod local_8c; - ColorMod greenLaserColor; - ColorMod purpleLaserColor; - - ownerFamiliar = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (GHIDRA_CAST(ownerFamiliar) == GHIDRA_CAST(0x0)) { -LAB_009f3f8c: - this_00 = GHIDRA_CAST(0x0); - if ((GHIDRA_CAST(ownerFamiliar) != GHIDRA_CAST(0x0)) && - ((GHIDRA_CAST(ownerFamiliar))->_type == 3)) goto LAB_009f3f9a; - } - else { - if ((GHIDRA_CAST(ownerFamiliar))->_type != 1) { - if ((GHIDRA_CAST(ownerFamiliar))->_type == 3) { - this_00 = *GHIDRA_CAST(&(GHIDRA_CAST(ownerFamiliar))->_isControlsEnabled); - goto LAB_009f3f9a; - } - goto LAB_009f3f8c; - } - this_00 = GHIDRA_CAST(ownerFamiliar); - } - ownerFamiliar = GHIDRA_CAST(0x0); -LAB_009f3f9a: - outColor->_tint[0] = 1.0; - outColor->_tint[1] = 1.0; - outColor->_tint[2] = 1.0; - outColor->_tint[3] = 1.0; - outColor->_colorize[0] = 0.0; - outColor->_colorize[1] = 0.0; - outColor->_colorize[2] = 0.0; - outColor->_colorize[3] = 0.0; - outColor->_offset[0] = 0.0; - outColor->_offset[1] = 0.0; - outColor->_offset[2] = 0.0; - if (this_00 != GHIDRA_CAST(0x0)) { - fVar1 = (this_00->_laserColor)._tint[0]; - fVar2 = (this_00->_laserColor)._tint[1]; - fVar3 = (this_00->_laserColor)._tint[2]; - fVar4 = (this_00->_laserColor)._tint[3]; - fVar10 = (this_00->_laserColor)._offset[2]; - fVar5 = (this_00->_laserColor)._colorize[0]; - fVar6 = (this_00->_laserColor)._colorize[1]; - fVar7 = (this_00->_laserColor)._colorize[2]; - fVar8 = (this_00->_laserColor)._colorize[3]; - if (outColor != &local_8c) { - *GHIDRA_CAST(outColor->_offset) = *GHIDRA_CAST((this_00->_laserColor)._offset); - outColor->_tint[0] = fVar1; - outColor->_tint[1] = fVar2; - outColor->_tint[2] = fVar3; - outColor->_tint[3] = fVar4; - outColor->_offset[2] = fVar10; - outColor->_colorize[0] = fVar5; - outColor->_colorize[1] = fVar6; - outColor->_colorize[2] = fVar7; - outColor->_colorize[3] = fVar8; - } - if (GHIDRA_CAST(ownerFamiliar) != GHIDRA_CAST(0x0)) { - bVar9 = Entity_Player::HasTrinket(this_00,0x7f,0); - if (bVar9 == 0) { - if ((char)(GHIDRA_CAST(ownerFamiliar))->_chargeBarSprites[5]._shadowLayerIndex != '\0') - { - greenLaserColor._offset[0] = 1.0; - greenLaserColor._colorize[0] = 0.0; - greenLaserColor._colorize[1] = 0.0; - greenLaserColor._colorize[2] = 0.0; - greenLaserColor._colorize[3] = 0.0; - greenLaserColor._tint[0] = 0.2; - greenLaserColor._tint[1] = 1.0; - greenLaserColor._tint[2] = 0.0; - greenLaserColor._tint[3] = 1.0; - greenLaserColor._offset[1] = 1.0; - greenLaserColor._offset[2] = 0.0; - (GHIDRA_CAST((GHIDRA_CAST(outColor))))->Color::operator_assign(&greenLaserColor); - } - } - else { - purpleLaserColor._offset[0] = 0.3529412; - purpleLaserColor._offset[1] = 0.0; - purpleLaserColor._offset[2] = 0.7058824; - if (outColor != &purpleLaserColor) { - outColor->_colorize[0] = 0.0; - outColor->_colorize[1] = 0.0; - outColor->_colorize[2] = 0.0; - outColor->_colorize[3] = 0.0; - outColor->_offset[0] = 0.3529412; - outColor->_offset[1] = 0.0; - outColor->_tint[0] = 0.4; - outColor->_tint[1] = 0.15; - outColor->_tint[2] = 0.38; - outColor->_tint[3] = 1.0; - outColor->_offset[2] = 0.7058824; - } - } - } - if (g_manager->_netplayManager != *GHIDRA_CAST((g_manager + 1))) { - bVar9 = NetplayManager::IsIdxLocalPlayer - (GHIDRA_CAST(&g_manager->_netplayManager),this_00->_controllerIndex); - if (bVar9 == 0) { - if ((g_game == GHIDRA_CAST(0x0)) || (*GHIDRA_CAST(&g_game->_deathmatchManager) < 2)) { - fVar10 = (float)(g_manager->_optionsConfig)._onlinePlayerOpacity * 0.09 + 0.1; - } - else { - fVar10 = 1.0; - } - outColor->_tint[3] = fVar10 * outColor->_tint[3]; - } - } - } - return outColor; -} - -// 009f4150 -long double Weapon::GetChargeBarAmount() -{ - long double maxChargeResult; - float maxCharge; - float maxCharge; - - if ((GHIDRA_UINT(this->_modifiers) >> 7 & 1) != 0) { - return (long double)0; - } - maxChargeResult = (long double)this->GetMaxCharge(); - maxCharge = (float)maxChargeResult; - if ((0.0 < maxCharge) && - ((maxCharge = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))), 1.0 < maxCharge || (maxCharge <= maxCharge)))) { - maxCharge = maxCharge / maxCharge; - if (maxCharge <= 0.0) { - maxCharge = 0.0; - } - if (1.0 <= maxCharge) { - maxCharge = 1.0; - } - return (long double)maxCharge; - } - return (long double)0.0; -} - -// 009f41c0 -void * Weapon::GetMultiShotParams(void *outParams, int unusedArg) -{ - Entity_Player *ownerPlayer; - - ownerPlayer = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((ownerPlayer == GHIDRA_CAST(0x0)) || - ((ownerPlayer->_type != 1 && - ((ownerPlayer->_type != 3 || - (ownerPlayer = *GHIDRA_CAST(&ownerPlayer->_isControlsEnabled), - ownerPlayer == GHIDRA_CAST(0x0))))))) { - *GHIDRA_CAST(outParams) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 4)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 8)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 0xc)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 0x10)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 0x14)) = 1; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 0x18)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 0x1c)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 0x1e)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(outParams) + 0x20)) = 0; - return outParams; - } - Entity_Player::GetMultiShotParams(ownerPlayer,outParams,*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x30))))); - return outParams; -} - -// 009f4ff0 -void Weapon::stop_costume_item_anim(int collectibleId) -{ - int iVar1; - uint8_t isHeldItem; - ItemConfig_Item *itemDesc; - int iVar2; - int *spriteIndex; - ANM2 *sprite; - int slotsLeft; - std_string emptyAnimName; - uint32_t local_14; - void *local_10; - uint8_t *puStack_c; - uint32_t uStack_8; - - uStack_8 = 0xffffffff; - puStack_c = &LAB_00aff10d; - local_10 = ExceptionList; - local_14 = __security_cookie ^ GHIDRA_UINT(&(&emptyAnimName)[1]._size); - ExceptionList = &local_10; - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((((iVar1 == 0) || (iVar2 = iVar1, *GHIDRA_CAST((iVar1 + 0x28)) != 1)) && (iVar2 = 0, iVar1 != 0)) && - (*GHIDRA_CAST((iVar1 + 0x28)) == 3)) { - *GHIDRA_CAST((iVar1 + 0xd4c)) = 0; - } - else if ((iVar2 != 0) && - (itemDesc = ItemConfig::GetCollectible(&g_manager->_itemConfig,collectibleId), - *GHIDRA_CAST((iVar2 + 0x20a9)) == '\0')) { - spriteIndex = GHIDRA_CAST((iVar2 + 0x122c)); - slotsLeft = 0xf; - do { - if (-1 < *spriteIndex) { - emptyAnimName._capacity = 0xf; - emptyAnimName._size = 0; - emptyAnimName._buf[0] = '\0'; - emptyAnimName._buf[1] = '\0'; - emptyAnimName._buf[2] = '\0'; - emptyAnimName._buf[3] = '\0'; - sprite = GHIDRA_CAST((*spriteIndex * 0x130 + *GHIDRA_CAST((iVar2 + 0x1220)))); - isHeldItem = is_held_item(sprite,&emptyAnimName,itemDesc); - if (isHeldItem != 0) { - sprite[1]._filename._buf[8] = '\0'; - } - } - spriteIndex = spriteIndex + 4; - slotsLeft = slotsLeft + -1; - } while (slotsLeft != 0); - } - ExceptionList = local_10; - return; -} - -// 009f50f0 -uint8_t Weapon::IsItemAnimFinished(uint32_t collectibleID) -{ - Entity_Player *pEVar1; - uint8_t bVar2; - ItemConfig_Item *itemDesc; - void *pvVar3; - bool isTmpStringLive; - ANM2 *sprite; - uint32_t capacity; - uint32_t size; - uint32_t slot; - PlayerCostumeMap *spriteIndex; - Entity_Player *player; - uint8_t isAllFinished; - uint8_t emptyAnimName [16]; - uint32_t emptyAnimNameSize; - uint32_t emptyAnimNameCapacity; - void *tmpString [4]; - uint32_t tmpStringSize; - uint32_t tmpStringCapacity; - uint32_t local_18; - void *local_10; - uint8_t *puStack_c; - void *pvStack_8; - bool isHeldItem; - - pvStack_8 = (void *)0xffffffff; - puStack_c = &LAB_00b103c6; - local_10 = ExceptionList; - local_18 = __security_cookie ^ GHIDRA_UINT((tmpString + 0xb)); - isTmpStringLive = false; - pEVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((((pEVar1 == GHIDRA_CAST(0x0)) || (player = pEVar1, pEVar1->_type != 1)) && - (player = GHIDRA_CAST(0x0), pEVar1 != GHIDRA_CAST(0x0))) && - (player = GHIDRA_CAST(0x0), pEVar1->_type == 3)) { - if (((pEVar1->_chargeBarSprites[5]._numEvents != 0) && - ((pEVar1->_sprite)._animState._animData != (void *)0x0)) && - ((pEVar1->_sprite)._animState._isPlaying != 0)) { - return 0; - } - } - else if (player != GHIDRA_CAST(0x0)) { - emptyAnimNameCapacity = 0xf; - emptyAnimNameSize = 0; - emptyAnimName[0] = 0; - emptyAnimName[1] = 0; - emptyAnimName[2] = 0; - emptyAnimName[3] = 0; - ExceptionList = &local_10; - itemDesc = ItemConfig::GetCollectible(&g_manager->_itemConfig,collectibleID); - bVar2 = 1; - spriteIndex = player->_playerCostumeMap; - isAllFinished = 1; - slot = 0; - do { - if (-1 < spriteIndex->_index) { - sprite = GHIDRA_CAST((spriteIndex->_index * 0x130 + GHIDRA_INT((player->_costumeSpriteDescs)._begin))); - if (sprite[1]._filename._buf[8] == '\0') { - capacity = tmpStringCapacity; -LAB_009f51e9: - isHeldItem = false; - } - else { - capacity = 0xf; - tmpStringCapacity = 0xf; - tmpStringSize = 0; - tmpString[0] = (void *)0x0; - isTmpStringLive = true; - bVar2 = is_held_item(sprite,GHIDRA_CAST(tmpString),itemDesc); - if (bVar2 == 0) goto LAB_009f51e9; - isHeldItem = true; - } - if ((isTmpStringLive) && (isTmpStringLive = false, 0xf < capacity)) { - size = capacity + 1; - pvVar3 = tmpString[0]; - if (0xfff < size) { - pvVar3 = *(void **)(GHIDRA_INT(tmpString[0]) + -4); - size = capacity + 0x24; - if (0x1f < GHIDRA_UINT((GHIDRA_INT(tmpString[0]) + (-4 - GHIDRA_INT(pvVar3))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(pvVar3,size); - } - bVar2 = isAllFinished; - if (isHeldItem) { - bVar2 = ANM2::IsFinishedImpl(sprite,emptyAnimName); - if ((bVar2 != 0) && - ((pvVar3 = (sprite->_animState)._animData, pvVar3 == (void *)0x0 || - (*GHIDRA_CAST((GHIDRA_CAST(pvVar3) + 0x34)) == '\0')))) { - ExceptionList = local_10; - return 1; - } - isAllFinished = 0; - bVar2 = isAllFinished; - } - } - spriteIndex = spriteIndex + 1; - slot = slot + 1; - if (0xe < slot) { - ExceptionList = local_10; - return bVar2; - } - } while( true ); - } - return 1; -} - -// 009f5510 -uint8_t Weapon::is_c_section_anim_finished(int unused) -{ - int iVar1; - uint8_t isFinished; - ItemConfig_Item *cSectionItem; - int iVar2; - uint8_t ******ppppppbVar3; - bool isTmpStringLive; - uint32_t capacity; - uint32_t uVar4; - uint8_t ******animNameData; - int *spriteIndex; - uint32_t slot; - uint8_t ******animName [4]; - uint32_t animNameSize; - uint32_t animNameCapacity; - uint32_t local_18; - void *local_10; - uint8_t *puStack_c; - uint8_t *****local_8; - bool isSubAnim; - - local_8 = GHIDRA_CAST(0xffffffff); - puStack_c = &LAB_00b1040e; - local_10 = ExceptionList; - local_18 = __security_cookie ^ GHIDRA_UINT((animName + 0xb)); - ExceptionList = &local_10; - isTmpStringLive = false; - iVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((iVar1 == 0) || (*GHIDRA_CAST((iVar1 + 0x28)) != 1)) { - isFinished = IsItemAnimFinished(this,0x2a6); - } - else { - cSectionItem = ItemConfig::GetCollectible(&g_manager->_itemConfig,0x2a6); - spriteIndex = GHIDRA_CAST((iVar1 + 0x122c)); - slot = 0; - do { - if (((-1 < *spriteIndex) && ((char)spriteIndex[3] != '\0')) && - (iVar2 = *spriteIndex * 0x130 + *GHIDRA_CAST((iVar1 + 0x1220)), - *GHIDRA_CAST((iVar2 + 0x114)) == cSectionItem)) { - if (*GHIDRA_CAST((iVar2 + 100)) == '\0') { - capacity = animNameCapacity; - animNameData = animName[0]; -LAB_009f561f: - isSubAnim = false; - } - else { - if (*(void **)(iVar2 + 0x54) == (void *)0x0) { - animNameSize = 0; - animNameCapacity = 0xf; - animName[0] = GHIDRA_CAST(0x0); - } - else { - (GHIDRA_CAST((GHIDRA_CAST(animName))))->msvc::string::string(*(void **)(iVar2 + 0x54)); - } - capacity = animNameCapacity; - animNameData = animName[0]; - isTmpStringLive = true; - uVar4 = 7; - if (animNameSize < 7) { - uVar4 = animNameSize; - } - ppppppbVar3 = GHIDRA_CAST(animName); - if (0xf < animNameCapacity) { - ppppppbVar3 = animName[0]; - } - iVar2 = string_compare(GHIDRA_CAST(ppppppbVar3),uVar4,GHIDRA_CAST("SubAnim"),7); - if (iVar2 != 0) goto LAB_009f561f; - isSubAnim = true; - } - local_8 = GHIDRA_CAST(0xffffffff); - if ((isTmpStringLive) && (isTmpStringLive = false, 0xf < capacity)) { - uVar4 = capacity + 1; - ppppppbVar3 = animNameData; - if (0xfff < uVar4) { - ppppppbVar3 = GHIDRA_CAST(animNameData[-1]); - uVar4 = capacity + 0x24; - if (GHIDRA_CAST(0x1f) < GHIDRA_CAST((GHIDRA_INT(animNameData) + (-4 - GHIDRA_INT(ppppppbVar3))))) { - /* WARNING: Subroutine does not return */ - _invalid_parameter_noinfo_noreturn(); - } - } - operator_delete(ppppppbVar3,uVar4); - } - if (isSubAnim) { - ExceptionList = local_10; - return 0; - } - } - slot = slot + 1; - spriteIndex = spriteIndex + 4; - } while (slot < 0xf); - isFinished = 1; - } - ExceptionList = local_10; - return isFinished; -} - -// 009f56c0 -void Weapon::SetBlinkTime(int delay, int unused) -{ - int blinkTime; - int owner; - - owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((((owner == 0) || (blinkTime = owner, *GHIDRA_CAST((owner + 0x28)) != 1)) && - (blinkTime = 0, owner != 0)) && (*GHIDRA_CAST((owner + 0x28)) == 3)) { - blinkTime = *GHIDRA_CAST((owner + 0xd50)); - if (*GHIDRA_CAST((owner + 0xd50)) < delay) { - blinkTime = delay; - } - *GHIDRA_CAST((owner + 0xd50)) = blinkTime; - } - else if (blinkTime != 0) { - owner = *GHIDRA_CAST((blinkTime + 0x1338)); - if (*GHIDRA_CAST((blinkTime + 0x1338)) < delay) { - owner = delay; - } - *GHIDRA_CAST((blinkTime + 0x1338)) = owner; - return; - } - return; -} - -// 009f5720 -void Weapon::SetHeadLockTime(int Time) -{ - int *piVar1; - int *longerTime; - int player; - int owner; - - owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((((owner == 0) || (player = owner, *GHIDRA_CAST((owner + 0x28)) != 1)) && (player = 0, owner != 0)) - && (*GHIDRA_CAST((owner + 0x28)) == 3)) { - piVar1 = GHIDRA_CAST((owner + 0xda8)); - longerTime = &Time; - if (Time <= *piVar1) { - longerTime = piVar1; - } - *piVar1 = *longerTime; - } - else if (player != 0) { - piVar1 = &Time; - if (Time <= *GHIDRA_CAST((player + 0x133c))) { - piVar1 = GHIDRA_CAST((player + 0x133c)); - } - *GHIDRA_CAST((player + 0x133c)) = *piVar1; - return; - } - return; -} - -// 009f5780 -void Weapon::set_head_direction(int direction) -{ - uint8_t bVar1; - Entity_Player *pEVar2; - uint8_t *headAnimNameEnd; - Entity_Player *ownerPlayer; - uint8_t *headAnimName; - - pEVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if ((((pEVar2 == GHIDRA_CAST(0x0)) || (ownerPlayer = pEVar2, pEVar2->_type != 1)) && - (ownerPlayer = GHIDRA_CAST(0x0), pEVar2 != GHIDRA_CAST(0x0))) && (pEVar2->_type == 3)) - { - pEVar2->_chargeBarSprites[5]._scale.x = (float)direction; - } - else if (ownerPlayer != GHIDRA_CAST(0x0)) { - ownerPlayer->_headDirection = direction; - if (direction != -1) { - headAnimName = (&PTR_s_HeadLeft_00b60b30)[direction]; - headAnimNameEnd = headAnimName; - do { - bVar1 = *headAnimNameEnd; - headAnimNameEnd = headAnimNameEnd + 1; - } while (bVar1 != 0); - (GHIDRA_CAST(((ownerPlayer->_headAnim)._buf)))->msvc::string::assign(headAnimName, - GHIDRA_INT(headAnimNameEnd) - GHIDRA_INT((headAnimName + 1))); - return; - } - } - return; -} - -// 009f5890 -Vector * Weapon::get_tear_movement_inheritance(Vector *outResult, Vector *direction) -{ - Entity_Player *pEVar1; - uint8_t isHasMarked; - float fVar2; - float inheritX; - float inheritY; - float projY; - Vector dirNormal; - int familiarPlayer; - - pEVar1 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (((pEVar1 != GHIDRA_CAST(0x0)) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x28)))) == g_vectorZero.x)) && - (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2c)))) == g_vectorZero.y)) { - if (pEVar1->_type == 1) { - Entity_Player::GetTearMovementInheritance(pEVar1,outResult,direction,0); - return outResult; - } - if (pEVar1->_type == 3) { - pEVar1 = *GHIDRA_CAST(&pEVar1->_isControlsEnabled); - isHasMarked = Entity_Player::HasCollectible(pEVar1,0x18a,0); - if ((isHasMarked == 0) || (pEVar1->_markedTarget == (void *)0x0)) { - familiarPlayer = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x410)); - inheritX = *GHIDRA_CAST((familiarPlayer + 0x360)) * 0.6; - inheritY = *GHIDRA_CAST((familiarPlayer + 0x364)) * 0.6; - inheritX = inheritX + inheritX; - inheritY = inheritY + inheritY; - if ((direction->x != g_vectorZero.x) || (direction->y != g_vectorZero.y)) { - (GHIDRA_CAST((direction)))->Vector::Normalized(&dirNormal); - fVar2 = inheritY * dirNormal.y + inheritX * dirNormal.x; - projY = dirNormal.y * fVar2; - fVar2 = dirNormal.x * fVar2; - if (fVar2 * dirNormal.x + projY * dirNormal.y < 0.0) { - inheritX = inheritX - fVar2; - inheritY = inheritY - projY; - } - } - outResult->x = inheritX; - outResult->y = inheritY; - return outResult; - } - } - } - outResult->x = g_vectorZero.x; - outResult->y = g_vectorZero.y; - return outResult; -} - -// 009f5a30 -Vector * Weapon::GetOwnerLaserOffset(Vector *outOffset, int laserOffsetId, Vector *direction) -{ - Entity_Player *this_00; - int *ownerType; - float zeroY; - - zeroY = g_vectorZero.y; - this_00 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (this_00 != GHIDRA_CAST(0x0)) { - ownerType = &this_00->_type; - if ((*ownerType != 1) && (this_00 = GHIDRA_CAST(0x0), *ownerType == 3)) { - FUN_00631a00(outOffset,laserOffsetId,direction); - return outOffset; - } - if (this_00 != GHIDRA_CAST(0x0)) { - Entity_Player::GetLaserOffset(this_00,outOffset,laserOffsetId,direction); - return outOffset; - } - } - outOffset->x = g_vectorZero.x; - outOffset->y = zeroY; - return outOffset; -} - -// 009f5ad0 -Entity_Tear * Weapon::fire_tear(Vector *position, Vector *velocity, uint32_t flags, int unused, float damageMultiplier, float positionStep) -{ - Entity_Player *this_00; - Entity_Tear *shooter; - uint32_t randomValue; - int seededVariant; - float shooterVelocityX; - float fVar2; - float shooterVelocityY; - float newPosY; - int iStack_18; - Weapon *local_14; - uint32_t *local_10; - float local_c; - Entity_Player *shooter; - - this_00 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (this_00 != GHIDRA_CAST(0x0)) { - if (this_00->_type == 1) { - shooter = Entity_Player::FireTear - (this_00,position,*velocity,flags,GHIDRA_CAST(this_00),damageMultiplier); - } - else { - if (this_00->_type != 3) goto LAB_009f5b91; - shooter = Entity_Player::FireTear - (*GHIDRA_CAST(&this_00->_isControlsEnabled),position,*velocity,flags, - GHIDRA_CAST(this_00),damageMultiplier); - local_c = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (shooter->_spawnerEntity != 0) { - local_10 = &shooter->_spawnerEntity; - msvc::multiset::erase(&local_10); - } - shooter->_spawnerEntity = local_c; - if (local_c != 0.0) { - msvc::multiset::insert(&shooter->_spawnerEntity); - } - } - local_14 = this; - if (shooter != GHIDRA_CAST(0x0)) goto LAB_009f5c1f; - } -LAB_009f5b91: - randomValue = Random(); - shooter = (Entity_Tear *) - Game::SpawnEx(g_game,2,0,position,velocity,*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))),0,randomValue,0); - (**(code **)(*GHIDRA_CAST(shooter) + 0x40))(damageMultiplier * shooter->_collisionDamage); - local_14 = *GHIDRA_CAST((iStack_18 + 4)); - if (shooter->_parent != 0) { - local_10 = &shooter->_parent; - msvc::multiset::erase(&local_10); - } - shooter->_parent = local_14; - if (local_14 != GHIDRA_CAST(0x0)) { - msvc::multiset::insert(&shooter->_parent); - } - (**(code **)(*GHIDRA_CAST(shooter) + 0xc))(); -LAB_009f5c1f: - shooter = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_14)) + 0x4)))); - if ((shooter != GHIDRA_CAST(0x0)) && (shooter->_type == 1)) { - seededVariant = Entity_Player::get_seeded_variant(shooter); - if (seededVariant == 2) { - local_c = (shooter->_velocity).x; - local_10 = GHIDRA_CAST((shooter->_velocity).y); - randomValue = Random(); - fVar2 = (float)((double)GHIDRA_INT(randomValue) + __uint_to_double_fixup[-(GHIDRA_INT(randomValue) >> 0x1f)] - ) * 2.3283064e-10 * 0.2 + 0.8; - (shooter->_velocity).y = fVar2 * (float)local_10; - (shooter->_velocity).x = fVar2 * local_c; - } - } - fVar2 = (shooter->_velocity).x * positionStep + (shooter->_pos).x; - newPosY = (shooter->_velocity).y * positionStep + (shooter->_pos).y; - (shooter->_pos).x = fVar2; - (shooter->_pos).y = newPosY; - shooter = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_14)) + 0x4)))); - if ((shooter != GHIDRA_CAST(0x0)) && - ((this_00 == GHIDRA_CAST(0x0) || (this_00 == shooter)))) { - if (shooter->_type == 1) { - shooterVelocityX = (shooter->_lastVelocity).x; - shooterVelocityY = (shooter->_lastVelocity).y; - shooterVelocityX = shooterVelocityX + shooterVelocityX; - shooterVelocityY = shooterVelocityY + shooterVelocityY; - } - else { - shooterVelocityX = (shooter->_velocity).x; - shooterVelocityY = (shooter->_velocity).y; - } - (shooter->_pos).y = newPosY - shooterVelocityY * positionStep; - (shooter->_pos).x = fVar2 - shooterVelocityX * positionStep; - } - return shooter; -} - -// 009f5d60 -Entity_Bomb * Weapon::fire_bomb(Weapon *weapon, Vector *position, Vector *velocity) -{ - Entity_Player *source; - uint32_t uVar1; - int iVar2; - Entity_Bomb *pEVar3; - uint32_t seed; - Entity_Player *player; - float speedSq; - float local_10; - int *local_c [2]; - Manager *manager; - uint32_t *parentSlot; - - source = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))); - if (source != GHIDRA_CAST(0x0)) { - if (source->_type == 1) { - player = source; - } - else { - if (source->_type != 3) goto LAB_009f5eb6; - player = *GHIDRA_CAST(&source->_isControlsEnabled); - } - pEVar3 = Entity_Player::FireBomb(player,position,velocity,GHIDRA_CAST(source)); - manager = g_manager; - if (pEVar3 != GHIDRA_CAST(0x0)) { - if ((pEVar3->_variant == 0x13) || (pEVar3->_variant == 0x14)) { - local_10 = 8.21161e-43; - if (0.7 < pEVar3->_scale || pEVar3->_scale == 0.7) { - local_10 = 8.1976e-43; - } - seed_fart_sound_override(GHIDRA_CAST(&local_10)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_10),1.0,2,0,1.0,0.0); - } - local_10 = (pEVar3->_velocity).x; - local_c[0] = GHIDRA_CAST((pEVar3->_velocity).y); - speedSq = local_10 * local_10 + (float)local_c[0] * (float)local_c[0]; - if (speedSq < 36.0) { - speedSq = sqrtf(speedSq); - if (0.0 < speedSq) { - local_10 = local_10 * (1.0 / speedSq); - local_c[0] = GHIDRA_CAST(((float)local_c[0] * (1.0 / speedSq))); - } - (pEVar3->_velocity).x = local_10 * 6.0; - (pEVar3->_velocity).y = (float)local_c[0] * 6.0; - } - return pEVar3; - } - } -LAB_009f5eb6: - seed = Random(); - pEVar3 = (Entity_Bomb *) - Game::SpawnEx(g_game,4,0,position,velocity,*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))),0,seed,0); - parentSlot = &pEVar3->_parent; - uVar1 = *GHIDRA_CAST((GHIDRA_INT(&pEVar3->_flags) + 4)); - *GHIDRA_CAST(&pEVar3->_flags) = GHIDRA_UINT(pEVar3->_flags) | 0x4000000; - *GHIDRA_CAST((GHIDRA_INT(&pEVar3->_flags) + 4)) = uVar1; - iVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))); - if (*parentSlot != 0) { - local_c[0] = parentSlot; - msvc::multiset::erase(local_c); - } - *parentSlot = iVar2; - if (iVar2 != 0) { - msvc::multiset::insert(parentSlot); - } - (**(code **)(*GHIDRA_CAST(pEVar3) + 0xc))(); - return pEVar3; -} - -// 009f6570 -Entity_Laser * Weapon::fire_brimstone_with_color(Vector *direction, float damageMult, uint32_t unk2) -{ - Entity *entity; - Entity_Laser *pEVar1; - ColorMod *laserColor; - uint8_t auStack_44 [4]; - Vector ownerPos; - ColorMod colorBuffer; - uint32_t local_c; - code *setColorFn; - - local_c = __security_cookie ^ GHIDRA_UINT(auStack_44); - entity = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (entity == GHIDRA_CAST(0x0)) { - ownerPos.x = g_vectorZero.x; - ownerPos.y = g_vectorZero.y; - } - else { - ownerPos.x = (entity->_pos).x; - ownerPos.y = (entity->_pos).y; - } - pEVar1 = FireBrimstone(entity,&ownerPos,direction,damageMult,ownerPos.y,unk2); - setColorFn = *(code **)(*GHIDRA_CAST(pEVar1) + 0x3c); - laserColor = get_laser_color(this,&colorBuffer); - (*setColorFn)(laserColor,0xffffffff,0xff,0,1); - return pEVar1; -} - -// 009f6610 -Entity_Laser * Weapon::fire_laser(Vector *position, uint32_t offsetId, Vector *direction, uint8_t isLeftEye, uint8_t isOneHit, float damageScale) -{ - int iVar1; - code *pcVar2; - Entity *pEVar3; - Entity_Laser *pEVar4; - uint32_t uVar5; - BitSet128 *ownerTearFlags; - ColorMod *laserColor; - float fVar6; - float fVar7; - uint32_t flagsHighLo; - uint32_t flagsHighHi; - uint8_t auStack_f8 [14]; - uint8_t savedIsOneHit; - uint8_t savedIsLeftEye; - Weapon *weapon; - Entity_Player *local_e4; - float local_e0; - Vector local_dc; - Vector *savedPosition; - uint32_t savedOffsetId; - Vector laserPos; - float savedDamageScale; - uint8_t local_c0 [8]; - uint64_t uStack_b8; - TearParams TStack_a8; - float fStack_54; - ColorMod local_40; - uint32_t local_14; - Entity_Player *owner; - - local_14 = __security_cookie ^ GHIDRA_UINT(auStack_f8); - savedPosition = position; - savedIsLeftEye = isLeftEye; - local_e0 = (float)CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_e0)) + 0x1))),isLeftEye); - savedIsOneHit = isOneHit; - local_e4 = GHIDRA_CAST(CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_e4)) + 0x1))),isOneHit)); - owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - savedOffsetId = offsetId; - local_dc.x = (float)direction; - savedDamageScale = damageScale; - weapon = this; - if (owner == GHIDRA_CAST(0x0)) goto LAB_009f690b; - if (owner->_type == 1) { - pEVar4 = Entity_Player::FireTechLaser - (owner,position,offsetId,direction,isLeftEye,isOneHit,GHIDRA_CAST(0x0), - damageScale); - } - else { - if (owner->_type != 3) goto LAB_009f690b; - local_e4 = *GHIDRA_CAST(&owner->_isControlsEnabled); - local_e0 = atan2f(direction->y,direction->x); - uVar5 = savedOffsetId; - GetOwnerLaserOffset(this,&laserPos,savedOffsetId,direction); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_c0)) + 0x4))) = laserPos.y; - laserPos.x = laserPos.x + savedPosition->x; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_c0)) + 0x0))) = 0.0; - laserPos.y = savedPosition->y + 0.0; - pEVar4 = Entity_Laser::ShootAngle - (2,&laserPos,local_e0 * 57.295776,3,GHIDRA_CAST(local_c0), - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))),0); - pEVar4->_oneHit = savedIsOneHit; - pEVar4->_disableFollowParent = 1; - if ((uVar5 == 2) && (uVar5 = Random(), uVar5 % 100 < 5)) { - uVar5 = Random(); - uVar5 = uVar5 % 0x54; - fVar7 = (float)(1 << (uVar5 & 0x1f)); - uStack_b8 = 0; - fVar6 = 0.0; - if (0x1f < uVar5) { - fVar6 = fVar7; - } - fVar7 = (float)(GHIDRA_UINT(fVar7) ^ GHIDRA_UINT(fVar6)); - if (0x3f < uVar5) { - fVar6 = fVar7; - } - (*GHIDRA_CAST((GHIDRA_CAST(&(uStack_b8)) + 0x0))) = 0; - (*GHIDRA_CAST((GHIDRA_CAST(&(uStack_b8)) + 0x4))) = 0; - flagsHighLo = (uint32_t)uStack_b8; - flagsHighHi = (*GHIDRA_CAST((GHIDRA_CAST(&(uStack_b8)) + 0x4))); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_c0)) + 0x0))) = fVar7; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_c0)) + 0x4))) = fVar6; - } - else { - ownerTearFlags = get_owner_tear_flags(weapon,GHIDRA_CAST(local_c0)); - fVar7 = *GHIDRA_CAST(&ownerTearFlags->_l); - fVar6 = *GHIDRA_CAST((GHIDRA_INT(&ownerTearFlags->_l) + 4)); - flagsHighLo = (uint32_t)ownerTearFlags->_h; - flagsHighHi = *GHIDRA_CAST((GHIDRA_INT(&ownerTearFlags->_h) + 4)); - } - iVar1 = *GHIDRA_CAST(pEVar4); - *GHIDRA_CAST(&(pEVar4->_tearFlags)._l) = fVar7; - *GHIDRA_CAST((GHIDRA_INT(&(pEVar4->_tearFlags)._l) + 4)) = fVar6; - *GHIDRA_CAST(&(pEVar4->_tearFlags)._h) = flagsHighLo; - *GHIDRA_CAST((GHIDRA_INT(&(pEVar4->_tearFlags)._h) + 4)) = flagsHighHi; - pcVar2 = *(code **)(iVar1 + 0x3c); - laserColor = get_laser_color(weapon,&local_40); - (*pcVar2)(laserColor,0xffffffff,0xff,0,1); - if (local_e4 != GHIDRA_CAST(0x0)) { - if (savedOffsetId == 1) { - pcVar2 = *(code **)(*GHIDRA_CAST(pEVar4) + 0x40); - fVar7 = get_damage(weapon); - (*pcVar2)(fVar7); - } - else { - pEVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))); - uVar5 = Random(); - Entity_Player::GetTearHitParams - (local_e4,&TStack_a8,3,savedDamageScale,(uVar5 & 1) * 2 + -1,pEVar3); - (**(code **)(*GHIDRA_CAST(pEVar4) + 0x40))(TStack_a8._tearDamage); - pEVar4->_mass = fStack_54 * pEVar4->_mass; - } - } - pEVar4->_entityGridCollisionClass = 6; - if (savedIsLeftEye == 0) { - if ((*GHIDRA_CAST((GHIDRA_CAST(local_dc.x) + 4)) <= -0.5) || (*GHIDRA_CAST(local_dc.x) <= -0.5)) - goto LAB_009f68d2; - fVar7 = 3000.0; - } - else if ((*GHIDRA_CAST((GHIDRA_CAST(local_dc.x) + 4)) < -0.5) || (0.5 < *GHIDRA_CAST(local_dc.x))) { -LAB_009f68d2: - fVar7 = -10.0; - } - else { - fVar7 = 3000.0; - } - pEVar4->_renderDepthOffset = fVar7; - (*GHIDRA_CAST((GHIDRA_CAST((pEVar4)) + 0x517))) = 1; - direction = GHIDRA_CAST(local_dc.x); - } - if (pEVar4 != GHIDRA_CAST(0x0)) { - return pEVar4; - } -LAB_009f690b: - pEVar3 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))); - fVar7 = atan2f(direction->y,direction->x); - if (pEVar3 == GHIDRA_CAST(0x0)) { - local_dc.x = g_vectorZero.x; - local_dc.y = g_vectorZero.y; - } - else { - local_dc.x = (pEVar3->_pos).x; - local_dc.y = (pEVar3->_pos).y; - } - pEVar4 = Entity_Laser::ShootAngle(2,&local_dc,fVar7 * 57.295776,3,&g_vectorZero,pEVar3,0); - return pEVar4; -} - -// 009f6a60 -Entity_Knife * Weapon::fire_knife(Entity *parent, uint32_t variant, uint8_t isCantOverwrite, int unused1, int unused2, float rotationOffset) -{ - Entity_Player *spawnerRef; - Entity_Player *ownerPlayer; - Entity_Knife *pEVar2; - Weapon *local_c [2]; - uint32_t *spawnerRef; - - spawnerRef = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - pEVar2 = GHIDRA_CAST(0x0); - local_c[0] = this; - if (spawnerRef != GHIDRA_CAST(0x0)) { - if (spawnerRef->_type == 1) { - ownerPlayer = spawnerRef; - } - else { - if (spawnerRef->_type != 3) goto LAB_009f6aa7; - ownerPlayer = *GHIDRA_CAST(&spawnerRef->_isControlsEnabled); - } - pEVar2 = Entity_Player::FireKnife(ownerPlayer,parent,variant,rotationOffset,isCantOverwrite,0); - } -LAB_009f6aa7: - spawnerRef = &pEVar2->_spawnerEntity; - if (pEVar2->_spawnerEntity != 0) { - local_c[0] = GHIDRA_CAST(spawnerRef); - msvc::multiset::erase(local_c); - } - *spawnerRef = spawnerRef; - if (spawnerRef != GHIDRA_CAST(0x0)) { - msvc::multiset::insert(spawnerRef); - } - return pEVar2; -} - -// 009f6c50 -Entity_Knife * Weapon::FireSword(Entity *param_2, uint32_t param_3, float param_4, uint8_t param_5, uint8_t param_6, uint32_t param_7, Entity *param_8) -{ - Entity_Player *parentRef; - Entity_Knife *knife; - uint32_t randomValue; - Entity_Player *source; - Entity_Player *player; - int *local_94; - Vector spawnPos; - uint32_t seed; - Entity *local_84; - Entity_Player *ownerEntity; - float rotation; - TearParams hitParams; - uint32_t local_c; - uint32_t flagsHigh; - int owner; - uint32_t *parentRef; - - local_c = __security_cookie ^ GHIDRA_UINT(&player); - local_84 = param_2; - local_94 = GHIDRA_CAST(param_3); - parentRef = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - player = GHIDRA_CAST(0x0); - if (parentRef != GHIDRA_CAST(0x0)) { - if (parentRef->_type == 1) { - player = parentRef; - } - else if (parentRef->_type == 3) { - player = *GHIDRA_CAST(&parentRef->_isControlsEnabled); - } - } - ownerEntity = parentRef; - rotation = param_4; - seed = Random(); - owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); - if (owner == 0) { - spawnPos.x = g_vectorZero.x; - spawnPos.y = g_vectorZero.y; - } - else { - spawnPos.x = *GHIDRA_CAST((owner + 0x33c)); - spawnPos.y = *GHIDRA_CAST((owner + 0x340)); - } - knife = (Entity_Knife *) - Game::SpawnEx(g_game,8,GHIDRA_UINT(local_94),&spawnPos,&g_vectorZero,GHIDRA_CAST(parentRef),0,seed,0); - if ((knife == GHIDRA_CAST(0x0)) || (knife->_type != 8)) { - knife = GHIDRA_CAST(0x0); - } - parentRef = &knife->_parent; - if (knife->_parent != 0) { - local_94 = parentRef; - msvc::multiset::erase(&local_94); - } - *parentRef = local_84; - if (local_84 != GHIDRA_CAST(0x0)) { - msvc::multiset::insert(parentRef); - } - parentRef = player; - (knife->_posOffset).x = 0.0; - (knife->_posOffset).y = -10.0; - if (player != GHIDRA_CAST(0x0)) { - source = ownerEntity; - randomValue = Random(); - Entity_Player::GetTearHitParams - (parentRef,&hitParams,0xd,1.0,(randomValue & 1) * 2 + -1,GHIDRA_CAST(source)); - (**(code **)(*GHIDRA_CAST(knife) + 0x3c))(&hitParams._tearColor,0xffffffff,0xff,0,1); - owner = *GHIDRA_CAST(knife); - *GHIDRA_CAST(&(knife->_tearFlags)._l) = hitParams._tearColor._colorize[3]; - *GHIDRA_CAST((GHIDRA_INT(&(knife->_tearFlags)._l) + 4)) = hitParams._tearColor._offset[0]; - *GHIDRA_CAST(&(knife->_tearFlags)._h) = hitParams._tearColor._offset[1]; - *GHIDRA_CAST((GHIDRA_INT(&(knife->_tearFlags)._h) + 4)) = hitParams._tearColor._offset[2]; - (**(code **)(owner + 0x40))((*GHIDRA_CAST((GHIDRA_CAST(&(hitParams)) + 0x34)))); - } - if (360.0 < ABS(rotation)) { - rotation = fmodf(rotation,360.0); - } - if (rotation <= 180.0) { - if (rotation < -180.0) { - rotation = rotation + 360.0; - } - } - else { - rotation = rotation - 360.0; - } - knife->_rotationOffset = rotation; - if (param_5 != 0) { - flagsHigh = *GHIDRA_CAST((GHIDRA_INT(&knife->_flags) + 4)); - *GHIDRA_CAST(&knife->_flags) = GHIDRA_UINT(knife->_flags) | 0x200000; - *GHIDRA_CAST((GHIDRA_INT(&knife->_flags) + 4)) = flagsHigh; - } - return knife; -} - -// 009f7930 -void Weapon::TriggerTearEffects(Vector *direction, int count) -{ - BitSet128 flags; - BitSet128 flags_00; - BitSet128 flags_01; - BitSet128 flags_02; - BitSet128 flags_03; - uint8_t isHasCollectible; - Vector *inheritedVelocity; - Entity_Tear *tear; - int iVar1; - uint32_t uVar2; - void *owner; - uint32_t greedFlags0; - uint32_t greedFlags2; - int extraout_EDX; - float *extraout_EDX_00; - Entity_Player *player; - int *unaff_EDI; - uint32_t uVar3; - Weapon *weapon; - bool bVar4; - bool bVar5; - float fVar6; - EntityPtr EVar7; - float fVar8; - float pencilVelX; - uint8_t auStackY_374 [128]; - int iVar9; - EntityPtr EStack_2b8; - float fStack_2b4; - EntityPtr local_2ac; - Vector local_2a8; - Entity_Tear *local_2a0; - uint8_t isBirdsEye; - uint8_t isGhostPepper; - int i; - Vector VStack_290; - uint8_t local_288 [8]; - float local_280; - float fStack_27c; - float pencilSpreadAngle; - float aimDirX; - float aimDirY; - Vector triggerPos; - Vector spiderOrigin; - Vector firePos; - uint8_t auStack_248 [8]; - uint8_t auStack_240 [8]; - uint8_t local_238 [8]; - float pencilVelY; - Vector pencilSpawnPos [2]; - uint32_t uStack_218; - uint32_t uStack_214; - uint32_t local_210; - uint32_t uStack_20c; - uint32_t uStack_208; - uint32_t uStack_204; - uint32_t uStack_200; - uint32_t uStack_1fc; - float pvpFlags0; - uint32_t pvpFlags1; - uint32_t pvpFlags2; - uint32_t pvpFlags3; - Vector spiderPos; - uint8_t local_1c0 [48]; - uint8_t inheritedVelBuffer [8]; - Vector pencilInheritedVel [6]; - uint32_t uStack_158; - uint32_t tornCardVariant; - uint8_t tornCardColor [4]; - uint32_t uStack_14c; - uint32_t uStack_148; - uint32_t uStack_144; - uint32_t uStack_140; - uint32_t uStack_13c; - uint32_t uStack_138; - uint32_t uStack_134; - uint32_t uStack_130; - uint64_t uStack_12c; - uint32_t uStack_124; - uint32_t uStack_120; - uint32_t uStack_11c; - uint32_t uStack_118; - uint32_t uStack_114; - uint32_t uStack_110; - float fStack_10c; - float fStack_108; - float tornCardHeight; - uint32_t hitParamsVariant; - uint8_t hitParamsColor [48]; - uint32_t hitParamsFlags0; - uint32_t hitParamsFlags1; - uint32_t hitParamsFlags2; - uint32_t hitParamsFlags3; - float fStack_a4; - float hitParamsHeight; - ColorMod tearTint; - float heartTint0; - float heartTint1; - float heartTint2; - float heartTint3; - float heartColorize0; - float heartColorize1; - float heartColorize2; - float heartColorize3; - float heartOffset0; - float heartOffset1; - float heartOffset2; - uint32_t local_14; - Game *game; - Manager *manager; - float ownerPosY; - - local_14 = __security_cookie ^ GHIDRA_UINT(&EStack_2b8); - local_2ac = (EntityPtr)direction; - if (count < 1) { - return; - } - VStack_290.y = (float)this->_owner; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x0))) = this; - if ((EntityPtr)VStack_290.y == (EntityPtr)0x0) { -LAB_009f79d6: - player = GHIDRA_CAST(0x0); - VStack_290.y = 0.0; - } - else { - if (*GHIDRA_CAST((GHIDRA_CAST(VStack_290.y) + 0x28)) != 1) { - if (*GHIDRA_CAST((GHIDRA_CAST(VStack_290.y) + 0x28)) != 3) goto LAB_009f79d6; - player = *GHIDRA_CAST((GHIDRA_CAST(VStack_290.y) + 0x410)); - VStack_290.y = (float)player; - if ((EntityPtr)player == (EntityPtr)0x0) goto LAB_009f79dc; - } - player = GHIDRA_CAST(VStack_290.y); - if (*GHIDRA_CAST((GHIDRA_CAST(VStack_290.y) + 0x1600)) == 0) { - local_2a8.x = (float)(GHIDRA_INT(VStack_290.y) + 0x1580); - uVar3 = 0; - do { - if (*GHIDRA_CAST(local_2a8.x) == 0x143) { - Entity_Player::AddActiveCharge(player,count,uVar3,0,0,1); - } - uVar3 = uVar3 + 1; - local_2a8.x = (float)(GHIDRA_INT(local_2a8.x) + 0x20); - } while (uVar3 < 4); - } - } -LAB_009f79dc: - EVar7 = local_2ac; - if ((((*GHIDRA_CAST(local_2ac) == g_vectorZero.x) && - (*GHIDRA_CAST((GHIDRA_CAST(local_2ac) + 4)) == g_vectorZero.y)) && - (EVar7 = (EntityPtr)((*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x0))) + 0x20), - *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x0))) + 0x20)) == g_vectorZero.x)) && - ((*GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x0))) + 0x24)) == g_vectorZero.y && ((EntityPtr)player != (EntityPtr)0x0) - ))) { - EVar7 = (EntityPtr)(GHIDRA_INT(player) + 0x1630); - } - aimDirX = *GHIDRA_CAST(EVar7); - fVar6 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(EVar7)))) + 0x4)))); - i = 0; - aimDirY = fVar6; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_238)) + 0x0))) = aimDirX; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_238)) + 0x4))) = fVar6; - do { - weapon = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_288))) + 0x0))); - if ((EntityPtr)player == (EntityPtr)0x0) { -LAB_009f8615: - *GHIDRA_CAST((weapon + 1)) = *GHIDRA_CAST((weapon + 1)) + 1; - if ((EntityPtr)player != (EntityPtr)0x0) goto LAB_009f8620; - } - else { - owner = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x0))) + 4); - if (owner == (void *)0x0) { - triggerPos.x = g_vectorZero.x; - triggerPos.y = g_vectorZero.y; - } - else { - triggerPos.x = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x33c)); - triggerPos.y = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x340)); - } - trigger_set_dispatch - ((void *)(GHIDRA_INT(player) + 0x1fc8),1,GHIDRA_CAST(0x0),&triggerPos,GHIDRA_CAST(local_238)); - isHasCollectible = Entity_Player::HasCollectible(player,0xd9,0); - if (isHasCollectible != 0) { - FUN_009f3c10(); - fVar6 = fVar6 + fVar6; - local_2ac = (EntityPtr)(0x14 - GHIDRA_INT(fVar6)); - if (GHIDRA_INT(local_2ac) < 1) { - local_2ac = (EntityPtr)0x1; - } - if (((local_2ac == (EntityPtr)0x0) || (uVar3 = Random(), uVar3 % GHIDRA_UINT(local_2ac) == 0)) && - ((local_2ac = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1370)), - GHIDRA_UINT(local_2ac) <= GHIDRA_CAST(&DAT_00000004) || - (((isHasCollectible = Entity_Player::HasCollectible(player,0xf8,0), - isHasCollectible != 0 || - (isHasCollectible = - TemporaryEffects::HasCollectibleEffect - (GHIDRA_CAST((GHIDRA_INT(player) + 0x1508)),0xf8), - isHasCollectible != 0)) && (GHIDRA_UINT(local_2ac) <= GHIDRA_CAST(&DAT_00000009))))))) { - owner = *(void **)(GHIDRA_CAST(weapon) + 4); - if (owner == (void *)0x0) { - spiderOrigin.x = g_vectorZero.x; - spiderOrigin.y = g_vectorZero.y; - fVar6 = g_vectorZero.y; - } - else { - spiderOrigin.x = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x33c)); - spiderOrigin.y = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x340)); - } - Room::FindFreePickupSpawnPosition(g_game->_room,&spiderPos,&spiderOrigin,0.0,0,0,0); - *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1370)) = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1370)) + 1; - spawn_blue_spider(&spiderPos,GHIDRA_CAST(player),&g_vectorZero); - } - } - isHasCollectible = Entity_Player::HasCollectible(player,0x23d,0); - if (isHasCollectible != 0) { - uVar3 = Random(); - if ((uVar3 & 3) == 0) { - Isaac::GetAxisAlignedUnitVectorFromDir - (GHIDRA_CAST((local_288 + 4)),*GHIDRA_CAST((GHIDRA_CAST(player) + 0x1628))); - local_2ac = (EntityPtr)((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_288)) + 0x4))) * 10.0); - local_2a0 = GHIDRA_CAST((local_280 * 10.0)); - iVar9 = 0x9f7c3f; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x4))) = local_2ac; - local_280 = (float)local_2a0; - inheritedVelocity = - get_tear_movement_inheritance - (weapon,GHIDRA_CAST((inheritedVelBuffer + 4)),GHIDRA_CAST((local_288 + 4))); - owner = *(void **)(GHIDRA_CAST(weapon) + 4); - if (owner == (void *)0x0) { -LAB_009f7c88: - fVar6 = 1.0; - } - else if (*GHIDRA_CAST((GHIDRA_CAST(owner) + 0x28)) == 1) { - fVar6 = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x1464)); - } - else { - if ((*GHIDRA_CAST((GHIDRA_CAST(owner) + 0x28)) != 3) || (*GHIDRA_CAST((GHIDRA_CAST(owner) + 0x410)) == 0)) - goto LAB_009f7c88; - fVar6 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(owner) + 0x410)) + 0x1464)); - } - local_2ac = (EntityPtr)(fVar6 * ((float)local_2ac + inheritedVelocity->x)); - local_2a0 = GHIDRA_CAST((fVar6 * ((float)local_2a0 + inheritedVelocity->y))); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x4))) = local_2ac; - local_280 = (float)local_2a0; - if (1 < count) { - uVar3 = Random(); - owner = *(void **)(GHIDRA_CAST(weapon) + 4); - local_280 = (float)((double)GHIDRA_INT(uVar3) + __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) - * 2.3283064e-10 * 0.2 + 0.9; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x4))) = (float)local_2ac * local_280; - local_280 = (float)local_2a0 * local_280; - } - if (owner == (void *)0x0) { - firePos.x = g_vectorZero.x; - firePos.y = g_vectorZero.y; - } - else { - firePos.x = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x33c)); - firePos.y = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x340)); - } - tear = fire_tear(weapon,&firePos,GHIDRA_CAST((local_288 + 4)),0x47,iVar9,1.0,0.0); - local_2ac = (EntityPtr) - (*GHIDRA_CAST((GHIDRA_INT(&(tear->_tearFlags)._h) + 4)) & (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagOrbit._h)) + 0x4)))); - if (((GHIDRA_UINT((tear->_tearFlags)._l) & GHIDRA_UINT(g_tearFlagOrbit._l)) == 0 && - (*GHIDRA_CAST((GHIDRA_INT(&(tear->_tearFlags)._l) + 4)) & (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagOrbit._l)) + 0x4)))) == 0) && - ((GHIDRA_UINT((tear->_tearFlags)._h) & GHIDRA_UINT(g_tearFlagOrbit._h)) == 0 && - local_2ac == (EntityPtr)0x0)) { - tear->_fallingSpeed = tear->_fallingSpeed - 7.0; - tear->_fallingAccel = tear->_fallingAccel * 0.01; - } - local_210 = (GHIDRA_UINT((tear->_tearFlags)._l) | GHIDRA_UINT(g_tearFlagOrbitAdvanced._l) | - GHIDRA_UINT(g_tearFlagSpectral._l)) & - ~(GHIDRA_UINT(g_tearFlagBoomerang._l) | GHIDRA_UINT(g_tearFlagOccult._l)); - uStack_20c = (*GHIDRA_CAST((GHIDRA_INT(&(tear->_tearFlags)._l) + 4)) | - (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagOrbitAdvanced._l)) + 0x4))) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagSpectral._l)) + 0x4)))) & - ~((*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagBoomerang._l)) + 0x4))) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagOccult._l)) + 0x4)))); - uStack_208 = (GHIDRA_UINT((tear->_tearFlags)._h) | GHIDRA_UINT(g_tearFlagOrbitAdvanced._h) | - GHIDRA_UINT(g_tearFlagSpectral._h)) & - ~(GHIDRA_UINT(g_tearFlagBoomerang._h) | GHIDRA_UINT(g_tearFlagOccult._h)); - uStack_204 = (*GHIDRA_CAST((GHIDRA_INT(&(tear->_tearFlags)._h) + 4)) | - (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagOrbitAdvanced._h)) + 0x4))) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagSpectral._h)) + 0x4)))) & - ~((*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagBoomerang._h)) + 0x4))) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagOccult._h)) + 0x4)))); - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_02._l)) + 0x4))) = uStack_20c; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_02._l)) + 0x0))) = local_210; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_02._h)) + 0x0))) = uStack_208; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_02._h)) + 0x4))) = uStack_204; - local_2a0 = tear; - Entity_Tear::SetTearFlags(tear,flags_02); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x28))) = (tear->_sprite)._color._offset[2]; - tearTint._colorize[0] = 0.0; - tearTint._colorize[1] = 0.0; - tearTint._colorize[2] = 0.0; - tearTint._colorize[3] = 0.0; - tearTint._offset[0] = 0.0; - tearTint._tint[0] = 1.5; - tearTint._tint[1] = 2.0; - tearTint._tint[2] = 2.0; - tearTint._tint[3] = 1.0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x0))) = (tear->_sprite)._color._tint[0]; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x4))) = (tear->_sprite)._color._tint[1]; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x8))) = (tear->_sprite)._color._tint[2]; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0xc))) = (tear->_sprite)._color._tint[3]; - tearTint._offset[1] = 0.0; - tearTint._offset[2] = 0.0; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x10))) = (tear->_sprite)._color._colorize[0]; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x14))) = (tear->_sprite)._color._colorize[1]; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x18))) = (tear->_sprite)._color._colorize[2]; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x1c))) = (tear->_sprite)._color._colorize[3]; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c0)) + 0x20))) = *GHIDRA_CAST((tear->_sprite)._color._offset); - (GHIDRA_CAST((GHIDRA_CAST(local_1c0))))->Color::__mul(&tearTint); - heartTint0 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x0))); - heartTint1 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x4))); - heartTint2 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x8))); - heartTint3 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0xc))); - heartOffset2 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x28))); - heartColorize0 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x10))); - heartColorize1 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x14))); - heartColorize2 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x18))); - heartColorize3 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x1c))); - heartOffset0 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x20))); - heartOffset1 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x24))); - fVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c0)) + 0x20))); - (**(code **)(*GHIDRA_CAST(tear) + 0x3c))(); - player = GHIDRA_CAST(VStack_290.y); - } - } - if ((*GHIDRA_CAST((GHIDRA_CAST(player) + 0x2ef8)) == 0) || (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x2ef8)) != 0x9d)) { - iVar9 = Entity_Player::GetTrinketMultiplier(player,0x9d); - bVar5 = false; - bVar4 = iVar9 == 0; -LAB_009f7fe7: - if (!bVar4 && bVar5 == iVar9 < 0) goto LAB_009f7ff2; - } - else { - if (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x2ef0)) == '\0') { - iVar1 = Entity_Player::GetTrinketMultiplier(player,0x9d); - bVar5 = SBORROW4(iVar1,1); - iVar9 = iVar1 + -1; - bVar4 = iVar1 == 1; - goto LAB_009f7fe7; - } -LAB_009f7ff2: - local_2a8.y = 2.10195e-44; - iVar9 = Entity_Player::GetTrinketMultiplier(player,0x9d); - if (iVar9 == 2) { - local_2a8.y = 1.4013e-44; - } - else if (iVar9 == 3) { - local_2a8.y = 7.00649e-45; - } - if (*GHIDRA_CAST(((uint32_t)weapon + 1)) % GHIDRA_UINT(local_2a8.y) == 0) { - Entity_Player::GetTearHitParams(); - isHasCollectible = Entity_Player::HasCollectible(player,0x95,0); - if (isHasCollectible == 0) { - fStack_10c = fStack_10c + 40.0; - fStack_108 = fStack_108 + 0.3; - } - uStack_11c = uStack_11c | - GHIDRA_UINT(g_tearFlagExplosive._l) | GHIDRA_UINT(g_tearFlagPoison._l) | - GHIDRA_UINT(g_tearFlagBoomerang._l); - uStack_114 = uStack_114 | - GHIDRA_UINT(g_tearFlagExplosive._h) | GHIDRA_UINT(g_tearFlagPoison._h) | - GHIDRA_UINT(g_tearFlagBoomerang._h); - uStack_158 = 0; - uStack_124 = 0; - uStack_118 = uStack_118 | - (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagExplosive._l)) + 0x4))) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagPoison._l)) + 0x4))) | - (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagBoomerang._l)) + 0x4))); - uStack_110 = uStack_110 | - (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagExplosive._h)) + 0x4))) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagPoison._h)) + 0x4))) | - (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagBoomerang._h)) + 0x4))); - uStack_14c = 0x3f000000; - uStack_148 = 0x3f666666; - uStack_144 = 0x3ecccccd; - uStack_140 = 0x3f800000; - uStack_13c = 0; - uStack_138 = 0; - uStack_134 = 0; - uStack_130 = 0; - uStack_12c = 0; - Isaac::GetAxisAlignedUnitVectorFromDir(&local_2a8,*GHIDRA_CAST((GHIDRA_CAST(player) + 0x1628))); - local_2a8.x = local_2a8.x * 16.0; - local_2a8.y = local_2a8.y * 16.0; - inheritedVelocity = - get_tear_movement_inheritance(weapon,GHIDRA_CAST((local_1c0 + 0x28)),&local_2a8); - local_2a8.x = local_2a8.x + inheritedVelocity->x; - local_2a8.y = local_2a8.y + inheritedVelocity->y; - uVar3 = Random(); - owner = *(void **)(GHIDRA_CAST(weapon) + 4); - if (owner == (void *)0x0) { - fVar6 = g_vectorZero.x; - fVar8 = g_vectorZero.y; - } - else { - fVar6 = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x33c)); - fVar8 = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x340)); - } - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_248)) + 0x4))) = fVar6 + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x164c)) + local_2a8.x; - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_240)) + 0x0))) = fVar8 + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1650)) + local_2a8.y; - tear = (Entity_Tear *) - Game::SpawnEx(g_game,2,tornCardVariant,GHIDRA_CAST((auStack_248 + 4)),&local_2a8, - GHIDRA_CAST(player),0,uVar3,0); - tear->_height = tornCardHeight; - fVar6 = Entity_Tear::get_height_offset_y(tear,tornCardHeight); - game = g_game; - (tear->_posOffset).y = fVar6; - if ((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) && - (fVar6 = tear->_height, (tear->_posOffset).y = -18.0, -5.1 < fVar6)) { - tear->_height = -5.1; - } - (**(code **)(*GHIDRA_CAST(tear) + 0x40))(); - (*GHIDRA_CAST((GHIDRA_CAST(&(flags._l)) + 0x4))) = uStack_11c; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags._l)) + 0x0))) = uStack_120; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags._h)) + 0x0))) = uStack_118; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags._h)) + 0x4))) = uStack_114; - Entity_Tear::SetTearFlags(tear,flags); - fVar6 = fStack_10c; - if (fStack_10c <= 0.01) { - fVar6 = 0.01; - } - tear->_baseScale = fVar6; - tear->_fScale = fVar6; - Entity_Tear::ResetSpriteScale(tear); - (**(code **)(*GHIDRA_CAST(tear) + 0x3c))(tornCardColor,0xffffffff,0xff,0,1); - if (tear->_parent != (EntityPtr)0x0) { - msvc::multiset::erase(auStackY_374 + 0x9c); - } - tear->_parent = (EntityPtr)player; - msvc::multiset::insert(&tear->_parent); - uVar3 = Random(); - tear->_tearIdx = uVar3; - tear->_canTriggerStreakEnd = 0; - fVar6 = pow(0.9,50.0); - fVar6 = (fVar6 - 1.0) * -9.491221; - tear->_fallingAccel = 0.8; - if (fVar6 <= 0.01) { - fVar6 = 0.01; - } - tear->_fallingSpeed = ((-5.0 - tear->_height) - (50.0 - fVar6) * 9.0) / fVar6; - (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); - fVar6 = (tear->_pos).x - (tear->_velocity).x; - fVar8 = (tear->_velocity).y; - (tear->_pos).x = fVar6; - (tear->_pos).y = (tear->_pos).y - fVar8; - weapon = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_288))) + 0x0))); - } - } - if (((*GHIDRA_CAST((GHIDRA_CAST(player) + 0x2c)) == 1) && (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x1aec)) == 0x16)) && - (uVar3 = Random(), uVar3 % 0x32 == 0)) { - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c4)) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c0)); - iVar9 = 0; - if (0 < iVar1) { - iVar9 = iVar1; - } - if (0 < iVar9) { - owner = weapon->_owner; - if (owner == (void *)0x0) { - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_248)) + 0x0))) = g_vectorZero.x; - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_248)) + 0x4))) = g_vectorZero.y; - fVar6 = g_vectorZero.y; - } - else { - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_248)) + 0x0))) = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x33c)); - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_248)) + 0x4))) = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x340)); - } - Entity_Player::AddBlueFlies(player,1,GHIDRA_CAST(auStack_248),GHIDRA_CAST(0x0)); - } - } - isBirdsEye = Entity_Player::HasCollectible(player,0x268,0); - isGhostPepper = Entity_Player::HasCollectible(player,0x1ef,0); - if ((isBirdsEye == 0) || (isGhostPepper == 0)) { - local_2a8.x = 2.8026e-45; - if (isBirdsEye == 0) { - if (isGhostPepper == 0) goto LAB_009f8615; - } - else { - local_2a8.y = 2.8026e-45; - if (isGhostPepper != 0) goto LAB_009f84ed; - } - local_2a8.y = 2.8026e-45; - local_2a8.x = 2.8026e-45; - } - else { - local_2a8.y = 1.4013e-45; - local_2a8.x = 1.4013e-45; - } -LAB_009f84ed: - FUN_009f3c10(); - local_2ac = (EntityPtr)(extraout_EDX - GHIDRA_INT(fVar6)); - if (extraout_EDX - GHIDRA_INT(fVar6) < GHIDRA_INT(local_2a8.y)) { - local_2ac = (EntityPtr)local_2a8.x; - } - if (local_2ac != (EntityPtr)0x0) { - uVar3 = Random(); - if (uVar3 % GHIDRA_UINT(local_2ac) != 0) goto LAB_009f8615; - } - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_240)) + 0x0))) = aimDirX; - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_240)) + 0x4))) = aimDirY; - fVar6 = aimDirY; - if (isBirdsEye == 0) { - if (isGhostPepper != 0) { -LAB_009f858f: - local_2ac = (EntityPtr)Entity_Player::ShootBlueCandle(player,GHIDRA_CAST(auStack_240)); - if (1 < *GHIDRA_CAST(&g_game->_deathmatchManager)) { - Random(); - Entity_Player::GetTearHitParams(); - fVar6 = (fStack_a4 * 4.0 * *GHIDRA_CAST((GHIDRA_CAST(player) + 0x157c))) / - *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1470)); - (**(code **)(*unaff_EDI + 0x40))(); - *GHIDRA_CAST((weapon + 1)) = *GHIDRA_CAST((weapon + 1)) + 1; - goto LAB_009f8620; - } - } - goto LAB_009f8615; - } - if (isGhostPepper != 0) { - uVar3 = Random(); - if ((uVar3 & 1) != 0) goto LAB_009f858f; - } - Entity_Player::ShootRedCandle(player,GHIDRA_CAST(auStack_240)); - *GHIDRA_CAST((weapon + 1)) = *GHIDRA_CAST((weapon + 1)) + 1; -LAB_009f8620: - isHasCollectible = Entity_Player::HasCollectible(player,0x1c2,0); - if (isHasCollectible != 0) { - if (*GHIDRA_CAST((weapon + 1)) % 0x14 == 0) { - Entity_Player::GetTearHitParams(); - unaff_EDI = GHIDRA_CAST((local_280 * 10.0)); - fStack_2b4 = fStack_27c * 10.0; - VStack_290.x = (float)unaff_EDI; - VStack_290.y = fStack_2b4; - inheritedVelocity = - get_tear_movement_inheritance(weapon,GHIDRA_CAST(inheritedVelBuffer),&VStack_290); - owner = weapon->_owner; - if ((owner == (void *)0x0) || - ((*GHIDRA_CAST((GHIDRA_CAST(owner) + 0x28)) != 1 && - ((*GHIDRA_CAST((GHIDRA_CAST(owner) + 0x28)) != 3 || - (owner = *(void **)(GHIDRA_CAST(owner) + 0x410), owner == (void *)0x0)))))) { - fVar6 = 1.0; - } - else { - fVar6 = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x1464)); - } - fVar8 = fVar6 * ((float)unaff_EDI + inheritedVelocity->x); - EStack_2b8 = (EntityPtr)(fVar6 * (fStack_2b4 + inheritedVelocity->y)); - VStack_290.x = fVar8; - VStack_290.y = (float)EStack_2b8; - if (1 < count) { - uVar3 = Random(); - fVar6 = (float)((double)GHIDRA_INT(uVar3) + __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) * - 2.3283064e-10 * 0.2 + 0.9; - VStack_290.x = fVar6 * fVar8; - VStack_290.y = (float)EStack_2b8 * fVar6; - } - fVar6 = VStack_290.x; - EStack_2b8 = (EntityPtr)VStack_290.y; - uVar3 = Random(); - owner = weapon->_owner; - if (owner == (void *)0x0) { - fVar8 = g_vectorZero.x; - ownerPosY = g_vectorZero.y; - } - else { - fVar8 = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x33c)); - ownerPosY = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x340)); - } - (*GHIDRA_CAST((GHIDRA_CAST(&(auStack_240)) + 0x4))) = fVar8 + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x164c)) + fVar6; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_238)) + 0x0))) = ownerPosY + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1650)) + (float)EStack_2b8; - tear = (Entity_Tear *) - Game::SpawnEx(g_game,2,0x14,GHIDRA_CAST((auStack_240 + 4)),&VStack_290, - GHIDRA_CAST(player),0,uVar3,0); - tear->_height = hitParamsHeight; - fVar6 = Entity_Tear::get_height_offset_y(tear,hitParamsHeight); - game = g_game; - (tear->_posOffset).y = fVar6; - if ((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) && - (fVar6 = tear->_height, (tear->_posOffset).y = -18.0, -5.1 < fVar6)) { - tear->_height = -5.1; - } - if (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x1368)) < 1) { - (**(code **)(*GHIDRA_CAST(tear) + 0x40))(); - greedFlags0 = hitParamsFlags0 | GHIDRA_UINT(g_tearFlagMidas._l); - uVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagMidas._l)) + 0x4))) | hitParamsFlags1; - greedFlags2 = hitParamsFlags2 | GHIDRA_UINT(g_tearFlagMidas._h); - uVar2 = hitParamsFlags3 | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagMidas._h)) + 0x4))); - uStack_208 = greedFlags0; - uStack_204 = uVar3; - uStack_200 = greedFlags2; - uStack_1fc = uVar2; - } - else { - Entity_Player::AddCoins(player,-1); - (**(code **)(*GHIDRA_CAST(tear) + 0x40))(); - greedFlags0 = hitParamsFlags0 | GHIDRA_UINT(g_tearFlagMidas._l) | GHIDRA_UINT(g_tearFlagCoinDrop._l); - uVar3 = (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagMidas._l)) + 0x4))) | hitParamsFlags1 | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagCoinDrop._l)) + 0x4))); - greedFlags2 = hitParamsFlags2 | GHIDRA_UINT(g_tearFlagMidas._h) | GHIDRA_UINT(g_tearFlagCoinDrop._h); - uVar2 = hitParamsFlags3 | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagMidas._h)) + 0x4))) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagCoinDrop._h)) + 0x4))); - uStack_218 = greedFlags0; - uStack_214 = uVar3; - local_210 = greedFlags2; - uStack_20c = uVar2; - } - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_00._l)) + 0x4))) = uVar3; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_00._l)) + 0x0))) = greedFlags0; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_00._h)) + 0x0))) = greedFlags2; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_00._h)) + 0x4))) = uVar2; - Entity_Tear::SetTearFlags(tear,flags_00); - if (tear->_parent != (EntityPtr)0x0) { - msvc::multiset::erase(auStackY_374 + 0xb0); - } - tear->_parent = (EntityPtr)player; - msvc::multiset::insert(&tear->_parent); - uVar3 = Random(); - tear->_tearIdx = uVar3; - tear->_canTriggerStreakEnd = 0; - uVar3 = Random(); - tear->_fallingSpeed = - ((float)((double)GHIDRA_INT(uVar3) + __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) * - 2.3283064e-10 * 0.2 - *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1478))) - 7.0; - tear->_fallingAccel = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x147c)) * 0.01; - (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); - manager = g_manager; - fVar6 = (tear->_pos).x - (tear->_velocity).x; - fVar8 = (tear->_velocity).y; - local_2a8.x = 3.83956e-43; - (tear->_pos).x = fVar6; - (tear->_pos).y = (tear->_pos).y - fVar8; - seed_fart_sound_override(GHIDRA_CAST(&local_2a8)); - (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_2a8.x),1.0,2,0,1.0,0.0); - player = GHIDRA_CAST(VStack_290.y); - weapon = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_288))) + 0x0))); - } - } - isHasCollectible = Entity_Player::HasCollectible(player,0x1bc,0); - if ((isHasCollectible != 0) && (*GHIDRA_CAST((weapon + 1)) % 0xf == 0)) { - local_2ac = (EntityPtr)0xc; - do { - Entity_Player::GetTearHitParams(); - Isaac::GetAxisAlignedUnitVectorFromDir(GHIDRA_CAST(local_288),*GHIDRA_CAST((GHIDRA_CAST(player) + 0x1628))) - ; - fVar6 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_288)) + 0x0))) * 10.0; - EVar7 = (EntityPtr)((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_288)) + 0x4))) * 10.0); - EStack_2b8 = EVar7; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x0))) = fVar6; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x4))) = EVar7; - get_tear_movement_inheritance(weapon,pencilInheritedVel,GHIDRA_CAST(local_288)); - FUN_009f3c40(); - pencilVelX = (fVar6 + *extraout_EDX_00) * (float)EVar7; - EStack_2b8 = (EntityPtr)(((float)EStack_2b8 + extraout_EDX_00[1]) * (float)EVar7); - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x0))) = pencilVelX; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_288)) + 0x4))) = EStack_2b8; - uVar3 = Random(); - pencilSpreadAngle = - (float)((double)GHIDRA_INT(uVar3) + __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) * - 2.3283064e-10 * 3.14; - pencilSpreadAngle = pencilSpreadAngle + pencilSpreadAngle; - uVar3 = Random(); - fStack_2b4 = (float)((double)GHIDRA_INT(uVar3) + __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) * - 2.3283064e-10; - fVar6 = cos(pencilSpreadAngle); - fVar6 = fVar6 * fStack_2b4 * 3.5 + pencilVelX; - (*GHIDRA_CAST((GHIDRA_CAST(&(local_238)) + 0x4))) = fVar6; - fVar8 = sin(pencilSpreadAngle); - fStack_2b4 = fVar8 * fStack_2b4 * 3.5 + (float)EStack_2b8; - pencilVelY = fStack_2b4; - uVar3 = Random(); - owner = weapon->_owner; - if (owner == (void *)0x0) { - fVar8 = g_vectorZero.x; - ownerPosY = g_vectorZero.y; - } - else { - fVar8 = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x33c)); - ownerPosY = *GHIDRA_CAST((GHIDRA_CAST(owner) + 0x340)); - } - pencilSpawnPos[0].x = fVar8 + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x164c)) + fVar6; - pencilSpawnPos[0].y = ownerPosY + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1650)) + fStack_2b4; - tear = (Entity_Tear *) - Game::SpawnEx(g_game,2,hitParamsVariant,pencilSpawnPos,GHIDRA_CAST((local_238 + 4)), - GHIDRA_CAST(player),0,uVar3,0); - tear->_height = hitParamsHeight; - fVar6 = Entity_Tear::get_height_offset_y(tear,hitParamsHeight); - game = g_game; - (tear->_posOffset).y = fVar6; - if ((*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) && - (fVar6 = tear->_height, (tear->_posOffset).y = -18.0, -5.1 < fVar6)) { - tear->_height = -5.1; - } - (**(code **)(*GHIDRA_CAST(tear) + 0x40))(); - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_01._l)) + 0x4))) = hitParamsFlags1; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_01._l)) + 0x0))) = hitParamsFlags0; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_01._h)) + 0x0))) = hitParamsFlags2; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_01._h)) + 0x4))) = hitParamsFlags3; - Entity_Tear::SetTearFlags(tear,flags_01); - uVar3 = Random(); - uVar2 = Random(); - fVar6 = (((float)(uVar3 & 1) + 0.0) * 0.4 + 0.9 + - (float)((double)GHIDRA_INT(uVar2) + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * - 2.3283064e-10 * 0.05) * fStack_a4; - if (fVar6 <= 0.01) { - fVar6 = 0.01; - } - tear->_baseScale = fVar6; - tear->_fScale = fVar6; - Entity_Tear::ResetSpriteScale(tear); - (**(code **)(*GHIDRA_CAST(tear) + 0x3c))(hitParamsColor,0xffffffff,0xff,0,1); - if (tear->_parent != (EntityPtr)0x0) { - msvc::multiset::erase(auStackY_374 + 0xa8); - } - player = GHIDRA_CAST(EStack_2b8); - tear->_parent = EStack_2b8; - msvc::multiset::insert(&tear->_parent); - uVar3 = Random(); - tear->_tearIdx = uVar3; - tear->_canTriggerStreakEnd = 0; - uVar3 = Random(); - tear->_fallingSpeed = - (float)((double)GHIDRA_INT(uVar3) + __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) * - 2.3283064e-10 * 0.2 - *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1478)); - tear->_fallingAccel = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x147c)); - (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); - game = g_game; - fVar6 = (tear->_pos).x - (tear->_velocity).x; - fVar8 = (tear->_velocity).y; - (tear->_pos).x = fVar6; - (tear->_pos).y = (tear->_pos).y - fVar8; - if (1 < *GHIDRA_CAST(&game->_deathmatchManager)) { - fVar6 = (float)(GHIDRA_UINT((tear->_tearFlags)._l) | _DAT_00c34b10); - pvpFlags1 = *GHIDRA_CAST((GHIDRA_INT(&(tear->_tearFlags)._l) + 4)) | DAT_00c34b14; - pvpFlags2 = GHIDRA_UINT((tear->_tearFlags)._h) | _DAT_00c34b18; - pvpFlags3 = *GHIDRA_CAST((GHIDRA_INT(&(tear->_tearFlags)._h) + 4)) | DAT_00c34b1c; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_03._l)) + 0x4))) = pvpFlags1; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_03._l)) + 0x0))) = fVar6; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_03._h)) + 0x0))) = pvpFlags2; - (*GHIDRA_CAST((GHIDRA_CAST(&(flags_03._h)) + 0x4))) = pvpFlags3; - pvpFlags0 = fVar6; - Entity_Tear::SetTearFlags(tear,flags_03); - } - isHasCollectible = Entity_Player::HasCollectible(player,0x95,0); - if (isHasCollectible == 0) { - tear->_fallingAccel = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x147c)) + 0.5; - uVar3 = Random(); - fVar6 = (5.0 - (float)((double)GHIDRA_INT(uVar3) + - __uint_to_double_fixup[-(GHIDRA_INT(uVar3) >> 0x1f)]) * 2.3283064e-10 * - 15.0) - *GHIDRA_CAST((GHIDRA_CAST(player) + 0x1478)); - tear->_fallingSpeed = fVar6; - } - local_2ac = (EntityPtr)(GHIDRA_INT(&(GHIDRA_CAST((GHIDRA_INT(local_2ac) + -0x40c)))->_luaBridgeRef) + 3); - weapon = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_288))) + 0x0))); - } while (local_2ac != (EntityPtr)0x0); - } - } - i = i + 1; - if (count <= i) { - return; - } - } while( true ); -} diff --git a/generated-src/weapon_bombs.cpp b/generated-src/weapon_bombs.cpp index a2f062b..759af20 100644 --- a/generated-src/weapon_bombs.cpp +++ b/generated-src/weapon_bombs.cpp @@ -1,43 +1,199 @@ #include "classes.h" +// 009f9b60 +void Weapon_Bombs::Fire(Vector *param_1, uint8_t param_2, uint8_t param_3) +{ + Vector shotDirection; + uint8_t isAxisAligned; + Vector *vecResult; + uint32_t rngResult; + Entity_Bomb *firedBomb; + Weapon *in_ECX; + int unusedArg; + Entity_Bomb *oldLink; + uint32_t randomShotsLeft; + int bomb; + Entity_Bomb *linkSlot; + float fVar1; + float fVar2; + float fVar3; + float shotSpeed; + Vector local_80; + Vector local_78; + uint32_t isLudovico; + Weapon *weapon; + Vector aimDirection; + Vector spawnPos; + Vector scratchVec; + Vector multiShotOffset; + Vector multiShotVelocity; + uint32_t multiShotParams; + float fStack_3c; + float fStack_38; + float fStack_34; + float local_30; + int iStack_2c; + float fStack_28; + uint32_t uStack_24; + uint32_t local_20; + + weapon = in_ECX; + Weapon::Fire(in_ECX,param_1,param_2,param_3); + bomb = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))); + isLudovico = GHIDRA_UINT(in_ECX->_modifiers) >> 4 & 0xffffff01; + if (bomb == 0) { + spawnPos.x = g_vectorZero.x; + spawnPos.y = g_vectorZero.y; + } + else { + spawnPos.x = *GHIDRA_CAST((bomb + 0x33c)); + spawnPos.y = *GHIDRA_CAST((bomb + 0x340)); + if ((*GHIDRA_CAST((bomb + 0x28)) == 1) || + ((*GHIDRA_CAST((bomb + 0x28)) == 3 && (bomb = *GHIDRA_CAST((bomb + 0x410)), bomb != 0)))) { + shotSpeed = *GHIDRA_CAST((bomb + 0x1464)); + goto LAB_009f9c09; + } + } + shotSpeed = 1.0; +LAB_009f9c09: + if ((param_2 == 0) || (0.0 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) || *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) == 0.0)) + { + if ((char)isLudovico == '\0') { + return; + } + } + else if (((char)isLudovico == '\0') || (*GHIDRA_CAST((in_ECX + 1)) == 0)) { + if (param_3 != 0) { + return; + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x10)))); + Weapon::SetBlinkTime(in_ECX,7 - GHIDRA_INT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x10)))) * -0.45)),bomb); + aimDirection.x = param_1->x; + aimDirection.y = param_1->y; + isAxisAligned = Weapon::IsAxisAligned(in_ECX); + if (isAxisAligned == 0) { + fVar2 = sqrtf(aimDirection.x * aimDirection.x + aimDirection.y * aimDirection.y); + if (0.0 < fVar2) { + aimDirection.x = aimDirection.x * (1.0 / fVar2); + aimDirection.y = aimDirection.y * (1.0 / fVar2); + } + } + else { + vecResult = Vector::ToCardinal(&scratchVec,&aimDirection); + aimDirection.x = vecResult->x; + aimDirection.y = vecResult->y; + } + Weapon::TriggerTearEffects(in_ECX,&aimDirection,1); + fVar2 = aimDirection.x * 12.0; + fVar3 = aimDirection.y * 12.0; + vecResult = Weapon::get_tear_movement_inheritance(in_ECX,&scratchVec,&g_vectorZero); + fVar2 = fVar2 + vecResult->x; + fVar3 = fVar3 + vecResult->y; + Weapon::GetMultiShotParams(in_ECX,&multiShotParams,unusedArg); + local_78.x = -fVar3; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_24)) + 0x1))) != '\0') { + local_80.x = -fVar2 * shotSpeed; + local_80.y = local_78.x * shotSpeed; + Weapon::fire_bomb(in_ECX,&spawnPos,&local_80); + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_24)) + 0x2))) != '\0') { + local_78.x = local_78.x * shotSpeed; + local_78.y = fVar2 * shotSpeed; + Weapon::fire_bomb(in_ECX,&spawnPos,&local_78); + local_78.x = fVar3 * shotSpeed; + local_78.y = -fVar2 * shotSpeed; + Weapon::fire_bomb(in_ECX,&spawnPos,&local_78); + } + for (randomShotsLeft = local_20 & 0xffff; randomShotsLeft != 0; + randomShotsLeft = randomShotsLeft - 1) { + rngResult = Random(); + local_78.x = (float)((double)GHIDRA_INT(rngResult) + + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 360.0 + * 0.017453292; + local_80.x = cos(local_78.x); + fVar1 = sin(local_78.x); + scratchVec.x = (local_80.x * fVar2 - fVar1 * fVar3) * shotSpeed; + scratchVec.y = (fVar1 * fVar2 + local_80.x * fVar3) * shotSpeed; + Weapon::fire_bomb(in_ECX,&spawnPos,&scratchVec); + } + local_80.x = 0.0; + local_78.x = 0.0; + if ((short)multiShotParams < 1) { + return; + } + do { + shotDirection.y = fVar3; + shotDirection.x = fVar2; + Entity_Player::GetMultiShotPositionVelocity + (&multiShotOffset,GHIDRA_INT(local_78.x),5,shotDirection,shotSpeed,(short)multiShotParams, + fStack_3c,fStack_38,fStack_34,local_30,iStack_2c,fStack_28,(uint8_t)uStack_24, + (short)local_20); + scratchVec.x = spawnPos.x + multiShotOffset.x; + scratchVec.y = spawnPos.y + multiShotOffset.y; + firedBomb = Weapon::fire_bomb(in_ECX,&scratchVec,&multiShotVelocity); + if ((char)isLudovico != '\0') { + if (GHIDRA_CAST(local_80.x) == GHIDRA_CAST(0x0)) { + oldLink = *GHIDRA_CAST((in_ECX + 1)); + linkSlot = GHIDRA_CAST((in_ECX + 1)); + if (oldLink != firedBomb) goto LAB_009f9fda; + } + else { + oldLink = *GHIDRA_CAST((GHIDRA_CAST(local_80.x) + 0x3c0)); + linkSlot = GHIDRA_CAST((GHIDRA_INT(local_80.x) + 0x3c0)); +LAB_009f9fda: + if (oldLink != GHIDRA_CAST(0x0)) { + local_80.x = (float)linkSlot; + msvc::multiset::erase(&local_80); + } + *GHIDRA_CAST(linkSlot) = firedBomb; + if (firedBomb != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(linkSlot); + } + } + in_ECX = weapon; + local_80.x = (float)firedBomb; + } + local_78.x = (float)(GHIDRA_INT(local_78.x) + 1); + if (GHIDRA_INT((short)multiShotParams) <= GHIDRA_INT(local_78.x)) { + return; + } + } while( true ); + } + bomb = *GHIDRA_CAST((in_ECX + 1)); + if ((bomb != 0) && (param_2 != 0)) { + aimDirection.x = param_1->x; + aimDirection.y = param_1->y; + if (1.0 < aimDirection.x * aimDirection.x + aimDirection.y * aimDirection.y) { + (GHIDRA_CAST((&aimDirection)))->Vector::Normalize(); + } + fVar2 = *GHIDRA_CAST((bomb + 0x36c)); + fVar3 = aimDirection.x * shotSpeed * 1.2 * 0.5; + fVar1 = aimDirection.y * shotSpeed * 1.2 * 0.5; + if (fVar2 != 0.0) { + *GHIDRA_CAST((bomb + 0x360)) = + (fVar3 * *GHIDRA_CAST((bomb + 0x39c))) / fVar2 + *GHIDRA_CAST((bomb + 0x360)); + *GHIDRA_CAST((bomb + 0x364)) = + (fVar1 * *GHIDRA_CAST((bomb + 0x39c))) / fVar2 + *GHIDRA_CAST((bomb + 0x364)); + bomb = *GHIDRA_CAST((in_ECX + 1)); + } + for (bomb = *GHIDRA_CAST((bomb + 0x3c0)); bomb != 0; bomb = *GHIDRA_CAST((bomb + 0x3c0))) { + fVar2 = *GHIDRA_CAST((bomb + 0x36c)); + if (fVar2 != 0.0) { + *GHIDRA_CAST((bomb + 0x360)) = + (*GHIDRA_CAST((bomb + 0x39c)) * fVar3) / fVar2 + *GHIDRA_CAST((bomb + 0x360)); + *GHIDRA_CAST((bomb + 0x364)) = + (fVar1 * *GHIDRA_CAST((bomb + 0x39c))) / fVar2 + *GHIDRA_CAST((bomb + 0x364)); + } + } + } + return; +} + // 009fa190 -uint32_t Weapon_Bombs::GetFocusEntity() +Entity * Weapon_Bombs::GetFocusEntity() { if ((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 4 & 1) == 0) { return GHIDRA_CAST(0x0); } return *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); } - -// 009fa1b0 -uint32_t Weapon_Bombs::GetMarkedTargetVariant() -{ - void *player = this; - uint8_t isHasItem; - int targetVariant; - Entity_Player *player; - - if ((*GHIDRA_CAST((GHIDRA_CAST(player) + 0x34)) >> 4 & 1) != 0) { - return 0; - } - player = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); - if (player != GHIDRA_CAST(0x0)) { - if (player->_type == 1) goto LAB_009fa1e0; - if (player->_type == 3) { - player = *GHIDRA_CAST(&player->_isControlsEnabled); - goto LAB_009fa1e0; - } - } - player = GHIDRA_CAST(0x0); -LAB_009fa1e0: - isHasItem = Entity_Player::HasCollectible(player,0x18a,0); - if (isHasItem == 0) { - return 0; - } - isHasItem = Entity_Player::HasCollectible(player,0x23c,0); - targetVariant = 0x1e; - if (isHasItem != 0) { - targetVariant = 0x99; - } - return targetVariant; -} diff --git a/generated-src/weapon_bone.cpp b/generated-src/weapon_bone.cpp index 39263d2..0a89639 100644 --- a/generated-src/weapon_bone.cpp +++ b/generated-src/weapon_bone.cpp @@ -1,5 +1,2423 @@ #include "classes.h" +// 009fa220 +void Weapon_Bone::Update(uint8_t isInterpolated) +{ + void *player = this; + int iVar1; + uint8_t isCheck; + Entity_Player *owner; + float *extraout_EAX; + Entity_Player *player; + Entity_Player *playerOwner; + float fVar2; + float offsetX; + float chargeStep; + float flyingOffsetX; + Vector flyingOffset; + + owner = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + playerOwner = owner; + if (owner == GHIDRA_CAST(0x0)) { +LAB_009fa24f: + player = GHIDRA_CAST(0x0); + if ((owner != GHIDRA_CAST(0x0)) && (owner->_type == 1)) goto LAB_009fa25f; + } + else { + if (owner->_type == 1) { + player = owner; + goto LAB_009fa25f; + } + if (owner->_type != 3) goto LAB_009fa24f; + player = *GHIDRA_CAST(&owner->_isControlsEnabled); + } + playerOwner = GHIDRA_CAST(0x0); +LAB_009fa25f: + if (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x30)) == 0xb) { + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x10)) = 0x41700000; + if ((player != GHIDRA_CAST(0x0)) && + (isCheck = Entity_Player::HasCollectible(player,0x3b,0), isCheck != 0)) { + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x10)) = 0x40c00000; + } + owner = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x34)) = 0x80000000; + } + fVar2 = -10.0; + offsetX = 0.0; + if (owner != GHIDRA_CAST(0x0)) { + if (playerOwner == GHIDRA_CAST(0x0)) { + offsetX = (owner->_sprite)._scale.x * 0.0; + if (owner->_type == 3) { + fVar2 = (owner->_sprite)._scale.y * -20.0; + } + else { + fVar2 = (owner->_sprite)._scale.y * -10.0; + } + } + else { + fVar2 = (playerOwner->_playerSpriteScale).x; + if (fVar2 <= 1.0) { + fVar2 = 1.0; + } + iVar1 = playerOwner->_entityGridCollisionClass; + if ((((iVar1 == 0) || (iVar1 == 3)) || (iVar1 == 1)) || (iVar1 == 2)) { + Entity_Player::GetFlyingOffset(playerOwner,&flyingOffset); + flyingOffsetX = *extraout_EAX / 0.65 + 0.0; + flyingOffset.x = extraout_EAX[1] / 0.65 - 10.0; + } + else { + flyingOffsetX = 0.0; + flyingOffset.x = -10.0; + } + isCheck = TemporaryEffects::HasCollectibleEffect(&playerOwner->_temporaryeffects,0x271); + if (isCheck != 0) { + fVar2 = fVar2 * 4.0; + } + offsetX = flyingOffsetX * fVar2 + (playerOwner->_posOffset).x; + fVar2 = flyingOffset.x * fVar2 + (playerOwner->_posOffset).y; + } + } + chargeStep = 1.0; + iVar1 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x44)); + if (iVar1 != 0) { + *GHIDRA_CAST((iVar1 + 0x34c)) = offsetX; + *GHIDRA_CAST((iVar1 + 0x350)) = fVar2; + } + iVar1 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x48)); + if (iVar1 != 0) { + *GHIDRA_CAST((iVar1 + 0x34c)) = offsetX; + *GHIDRA_CAST((iVar1 + 0x350)) = fVar2; + } + iVar1 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x4c)); + if (iVar1 != 0) { + *GHIDRA_CAST((iVar1 + 0x34c)) = offsetX; + *GHIDRA_CAST((iVar1 + 0x350)) = fVar2; + } + iVar1 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x50)); + if (iVar1 != 0) { + *GHIDRA_CAST((iVar1 + 0x34c)) = offsetX; + *GHIDRA_CAST((iVar1 + 0x350)) = fVar2; + } + if ((isInterpolated == 0) && (-1.0 < *GHIDRA_CAST((GHIDRA_CAST(player) + 0xc)))) { + if (*GHIDRA_CAST((GHIDRA_CAST(player) + 4)) != 0) { + chargeStep = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(player) + 4)) + 0x39c)); + } + *GHIDRA_CAST((GHIDRA_CAST(player) + 0xc)) = *GHIDRA_CAST((GHIDRA_CAST(player) + 0xc)) - chargeStep; + } + return; +} + +// 009fa450 +void Weapon_Bone::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + Entity_Bomb *pEVar1; + code *pcVar2; + Manager *pMVar3; + uint8_t bVar4; + Vector *pVVar5; + uint32_t uVar6; + TearParams *pTVar7; + BitSet128 *pBVar8; + Vector *pVVar9; + Entity_Player **ppEVar10; + int *effectIt; + std_string *anim; + float *clampedValue; + uint32_t rngResult; + Entity_Bomb **ppEVar11; + Entity_Tear *fetusTear; + Entity_Knife *club; + char cVar12; + uint8_t extraout_CL; + uint8_t extraout_CL_00; + Entity_Player *pEVar13; + int unusedCollectibleId; + int extraout_ECX; + int extraout_ECX_00; + undefined3 uVar20; + uint32_t rngResult; + int *piVar15; + int extraout_ECX_01; + uint3 uVar21; + int iVar16; + float *extraout_ECX_02; + float *extraout_ECX_03; + float *extraout_ECX_04; + void *pvVar17; + float *pfVar18; + int unused; + float *extraout_ECX_05; + Entity_Player *pEVar19; + float *extraout_ECX_06; + float *extraout_ECX_07; + float *extraout_ECX_08; + int extraout_ECX_09; + int extraout_ECX_10; + float *extraout_ECX_11; + int unused_00; + float *extraout_ECX_12; + Entity_Knife *extraout_ECX_13; + Entity_Knife *extraout_ECX_14; + Entity_Knife *extraout_ECX_15; + Entity_Knife *unused_01; + float *extraout_ECX_16; + int extraout_ECX_17; + int extraout_ECX_18; + float *extraout_ECX_19; + float *extraout_ECX_20; + float *extraout_ECX_21; + uint8_t *puVar22; + int *extraout_EDX; + Entity_Player *this_00; + void **heldEntitySlot; + float fVar23; + uint8_t auVar24 [16]; + float fVar25; + float fVar26; + Entity_Bomb *pEVar27; + float fVar28; + double dVar29; + undefined3 in_stack_00000009; + undefined3 in_stack_0000000d; + int iVar30; + BitSet128 *b; + Entity *pEVar31; + uint8_t local_2f8 [36]; + uint32_t uStack_2d4; + uint8_t *local_2d0; + float fStack_2cc; + int lanesPerEye; + float fStack_2c4; + float fStack_2c0; + float local_2bc; + void *pvStack_2b8; + float fStack_2b4; + uint8_t *puStack_2b0; + uint8_t local_2ac [8]; + Vector local_2a4; + uint32_t local_29c; + Entity_Bomb *local_298; + Entity_Player *maxCharge; + uint32_t isBrimstone; + Vector *aimDirection; + uint32_t local_288; + Entity_Bomb *local_284; + float damageMultiplier; + uint8_t local_27c [8]; + Vector local_274; + Vector ownerVelocityX; + Vector local_264; + uint32_t isCursedEye; + Vector local_258; + float local_250; + Vector local_24c; + uint32_t isCSection; + Vector ownerPos; + Vector local_238; + Entity_Player *shotSpeed; + int weaponType; + Entity_Player *chargeThreshold; + Entity_Player *maxFireDelay; + Vector local_220; + Vector local_218; + Entity_Player *newCharge; + Entity_Player *clubScale; + uint8_t *local_208; + char isEpicFetus; + char isReleased; + Entity_Player *local_200; + char local_1f9; + Vector shotDirection; + Vector local_1f0; + Entity_Player *ownerPlayer; + Vector local_1e4; + uint8_t isChocolateMilk; + Entity_Bomb *local_1d8; + uint16_t local_1d2; + Entity_Knife *heldClub; + Entity_Player *player; + char isChargeMode; + char isDrFetus; + uint8_t local_1c6; + uint8_t local_1c5; + uint8_t local_1c4 [8]; + int tearBombVariant; + Color tearColor; + BitSet128 tearFlags; + Entity_Player *tearDamage; + float tearScale; + float tearHeight; + uint32_t uStack_16c; + uint32_t local_168; + float local_164; + float local_160; + TearParams local_158; + Color flashColor; + uint8_t local_c4 [24]; + float fStack_ac; + float fStack_a8; + Vector local_a4; + uint8_t *local_9c; + uint8_t chargeColor [40]; + uint8_t *puStack_70; + uint8_t local_6c [28]; + uint8_t local_50 [4]; + void *pvStack_4c; + void *pvStack_48; + uint8_t *puStack_44; + uint8_t clubFlashColor [32]; + Vector VStack_20; + uint8_t *puStack_18; + void *securityCookie; + void *local_10; + uint8_t *puStack_c; + uint32_t local_8; + uint32_t *bombFlagsHigh; + int *effectsEnd; + Entity_Player *owner; + uint64_t savedBombFlags; + + local_8 = -NAN; + puStack_c = &LAB_00b106ce; + local_10 = ExceptionList; + securityCookie = (void *)(__security_cookie ^ GHIDRA_UINT((clubFlashColor + 0x3c))); + ExceptionList = &local_10; + aimDirection = direction; + iVar30 = _isShooting; + owner = _isInterpolated; + ownerVelocityX.y = (float)this; + Weapon::Fire(this,direction,isShooting,isInterpolated); + weaponType = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x30)); + pEVar19 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + pEVar13 = pEVar19; + if (pEVar19 == GHIDRA_CAST(0x0)) { +LAB_009fa53d: + ownerPlayer = GHIDRA_CAST(0x0); + player = pEVar19; + if (pEVar19 == GHIDRA_CAST(0x0)) { +LAB_009fa4db: + } + else { + ownerPlayer = GHIDRA_CAST(0x0); + if (pEVar19->_type == 1) goto LAB_009fa525; + } + this_00 = ownerPlayer; + if (pEVar19 != GHIDRA_CAST(0x0)) { + player = GHIDRA_CAST(0x0); + if (pEVar19->_type == 1) goto LAB_009fa525; + ownerPlayer = this_00; + if (pEVar19->_type == 3) { + player = GHIDRA_CAST(0x0); + pEVar13 = *GHIDRA_CAST(&pEVar19->_isControlsEnabled); + if (*GHIDRA_CAST(&pEVar19->_isControlsEnabled) != GHIDRA_CAST(0x0)) + goto LAB_009fa525; + } + } + shotSpeed = GHIDRA_CAST(0x3f800000); + player = GHIDRA_CAST(0x0); + if (pEVar19 != GHIDRA_CAST(0x0)) goto LAB_009fa572; + ownerPos.x = g_vectorZero.x; + player = GHIDRA_CAST(0x0); + shotSpeed = GHIDRA_CAST(0x3f800000); + ownerPos.y = g_vectorZero.y; + } + else { + if (pEVar19->_type != 1) { + if (pEVar19->_type != 3) goto LAB_009fa53d; + ownerPlayer = *GHIDRA_CAST(&pEVar19->_isControlsEnabled); + goto LAB_009fa4db; + } + player = pEVar19; + ownerPlayer = pEVar19; +LAB_009fa525: + shotSpeed = GHIDRA_CAST(pEVar13->_shotspeed); + this_00 = ownerPlayer; +LAB_009fa572: + ownerPos.x = (pEVar19->_pos).x; + ownerPos.y = (pEVar19->_pos).y; + } + local_200 = player; + uVar6 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)); + isChocolateMilk = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) & 1; + isCursedEye = uVar6 >> 1 & 0xffffff01; + isBrimstone = uVar6 >> 2 & 0xffffff01; + local_1f0.y = (float)this_00; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = shotSpeed; + local_250 = (float)(uVar6 >> 3 & 0xffffff01); + if ((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x30)) == 0xb) || (this_00 == GHIDRA_CAST(0x0))) { +LAB_009fa64b: + isDrFetus = '\0'; + if ((weaponType != 0xb) && (this_00 != GHIDRA_CAST(0x0))) goto LAB_009fa65b; +LAB_009fa671: + isEpicFetus = '\0'; + } + else { + owner = GHIDRA_CAST(0x0); + iVar30 = 0x34; + bVar4 = Entity_Player::HasCollectible(this_00,0x34,0); + if (bVar4 == 0) goto LAB_009fa64b; + owner = GHIDRA_CAST(0x0); + iVar30 = 0xa8; + bVar4 = Entity_Player::HasCollectible(this_00,0xa8,0); + if (bVar4 != 0) goto LAB_009fa64b; + isDrFetus = '\x01'; +LAB_009fa65b: + owner = GHIDRA_CAST(0x0); + iVar30 = 0xa8; + bVar4 = Entity_Player::HasCollectible(this_00,0xa8,0); + if (bVar4 == 0) goto LAB_009fa671; + isEpicFetus = '\x01'; + } + if (((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 4 & 1) == 0) || (local_1f9 = '\x01', isEpicFetus != '\0')) { + local_1f9 = '\0'; + } + if ((weaponType == 0xb) || (this_00 == GHIDRA_CAST(0x0))) { +LAB_009fa6bd: + local_1c6 = '\0'; + } + else { + owner = GHIDRA_CAST(0x2c0); + iVar30 = 0x9fa6b2; + bVar4 = TemporaryEffects::HasCollectibleEffect(&this_00->_temporaryeffects,0x2c0); + local_1c6 = '\x01'; + if (bVar4 == 0) goto LAB_009fa6bd; + } + isCSection = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 0xb & 0xffffff01; + uVar6 = isCSection; + if (((isChocolateMilk == 0) && ((char)isCursedEye == '\0')) && ((char)isBrimstone == '\0')) { + isChargeMode = '\0'; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_250)) + 0x0))) != '\0') goto LAB_009fa703; + } + else { +LAB_009fa703: + isChargeMode = '\x01'; + } + if (((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 7 & 1) != 0) || (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) <= 0.0)) { + pfVar18 = GHIDRA_CAST((GHIDRA_INT(this) + 0x10)); + local_1e4.y = 0.001; + local_1c5 = 1; + player = local_200; + shotSpeed = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))); + clampedValue = &local_1e4.y; + if (0.001 < *pfVar18 || *pfVar18 == 0.001) { + clampedValue = pfVar18; + } + ownerPlayer = GHIDRA_CAST(local_1f0.y); + chargeThreshold = GHIDRA_CAST(*clampedValue); + local_1e4.y = (float)chargeThreshold; + maxFireDelay = chargeThreshold; + this_00 = GHIDRA_CAST(local_1f0.y); + if ((char)isCSection != '\0') { + isChargeMode = '\x01'; + local_1c5 = 1; + isDrFetus = isDrFetus; + goto LAB_009fa822; + } + } + else { + pfVar18 = GHIDRA_CAST((GHIDRA_INT(this) + 0x10)); + local_1e4.y = 0.001; + local_1c5 = 0; + clampedValue = &local_1e4.y; + if (0.001 < *pfVar18 || *pfVar18 == 0.001) { + clampedValue = pfVar18; + } + chargeThreshold = GHIDRA_CAST(*clampedValue); + maxFireDelay = chargeThreshold; +LAB_009fa822: + local_1e4.y = (float)chargeThreshold; + } + isReleased = '\0'; + isCSection = uVar6; + chargeThreshold = GHIDRA_CAST(local_1e4.y); + maxFireDelay = GHIDRA_CAST(local_1e4.y); + if (this_00 == GHIDRA_CAST(0x0)) { +LAB_009fa84b: + local_200 = GHIDRA_CAST(0x1); + if (local_1c6 != '\0') { + local_200 = GHIDRA_CAST(0x3); + } + } + else { + owner = GHIDRA_CAST(0x0); + iVar30 = 0x72; + bVar4 = Entity_Player::HasCollectible(this_00,0x72,0); + if (bVar4 == 0) goto LAB_009fa84b; + local_200 = GHIDRA_CAST(0x2); + } + fVar23 = 2.0; + if (weaponType == 0xb) { + local_200 = GHIDRA_CAST(&DAT_00000009); + } + if ((((char)isCursedEye == '\0') && ((char)isCSection == '\0')) || (isChocolateMilk != 0)) { + fVar23 = 3.0; + } + local_1c6 = isShooting; + maxCharge = GHIDRA_CAST((fVar23 * (float)maxFireDelay)); + local_258.y = fVar23 * (float)maxFireDelay; + chargeThreshold = GHIDRA_CAST(((float)chargeThreshold + local_1e4.y)); + if ((isEpicFetus != '\0') && (player != GHIDRA_CAST(0x0))) { + if ((isShooting == 0) || + ((((pvVar17 = player->_heldEntity, pvVar17 == (void *)0x0 || + (*GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x171)) != '\0')) || (*GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x28)) != 1000)) || + (*GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x2c)) != 0x76)))) { + if ((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x58)) != GHIDRA_CAST(0x0)) && (isInterpolated == 0)) { + owner = GHIDRA_CAST(0x9fab42); + (**(code **)(**GHIDRA_CAST((GHIDRA_CAST(this) + 0x58)) + 0x28))(); + } + } + else { + iVar30 = 10; + owner = player; + Weapon::SetBlinkTime(this,10,GHIDRA_INT(player)); + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x58)) == 0) { + if (isInterpolated == 0) { + owner = GHIDRA_CAST(Random()); + iVar30 = 0; + local_1f0.y = (float)Game::Spawn(g_game,1000,0x1e,&ownerPos,&g_vectorZero, + *GHIDRA_CAST((GHIDRA_CAST(this) + 4)),0,GHIDRA_UINT(owner)); + ((GHIDRA_CAST(local_1f0.y))->_bodySprite)._animState._animFrame = 0.0; + *GHIDRA_CAST(&((GHIDRA_CAST(local_1f0.y))->_bodySprite)._animState._isPlaying) = 0; + pEVar19 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x58)); + if (pEVar19 != GHIDRA_CAST(local_1f0.y)) { + if (pEVar19 != GHIDRA_CAST(0x0)) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST((GHIDRA_INT(this) + 0x58)); + msvc::multiset::erase(); + } + owner = GHIDRA_CAST((GHIDRA_INT(this) + 0x58)); + *GHIDRA_CAST(owner) = local_1f0.y; + iVar30 = 0x9fa9ca; + msvc::multiset::insert(); + pEVar19 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x58)); + } + if (pEVar19 != GHIDRA_CAST(0x0)) goto LAB_009fa9d5; + } + } + else { +LAB_009fa9d5: + local_238.x = aimDirection->x; + local_238.y = aimDirection->y; + local_208 = GHIDRA_CAST(local_238.y); + local_1e4.y = local_238.x; + if (1.0 < local_238.x * local_238.x + local_238.y * local_238.y) { + (GHIDRA_CAST((&local_238)))->Vector::Normalize(); + local_208 = GHIDRA_CAST(local_238.y); + local_1e4.y = local_238.x; + } + owner = GHIDRA_CAST(0x0); + iVar30 = 0x166; + local_238.x = local_1e4.y; + local_238.y = (float)local_208; + bVar4 = Entity_Player::HasCollectible(player,0x166,0); + if (bVar4 == 0) { +LAB_009faadb: + pEVar19 = GHIDRA_CAST(local_1e4.y); + } + else { + owner = GHIDRA_CAST(0x0); + iVar30 = 0xf5; + bVar4 = Entity_Player::HasCollectible(player,0xf5,0); + if (bVar4 != 0) goto LAB_009faadb; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = cos(0.7853982); + owner = GHIDRA_CAST(0x9faa98); + fVar23 = sin(0.7853982); + fVar25 = fVar23 * (float)local_208; + local_208 = (uint8_t *) + (fVar23 * local_1e4.y + (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) * (float)local_208); + pEVar19 = GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) * local_1e4.y - fVar25)); + } + iVar16 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x58)); + *GHIDRA_CAST((iVar16 + 0x360)) = + (float)pEVar19 * 8.0 * *GHIDRA_CAST((iVar16 + 0x39c)) + *GHIDRA_CAST((iVar16 + 0x360)); + *GHIDRA_CAST((iVar16 + 0x364)) = + (float)local_208 * 8.0 * *GHIDRA_CAST((iVar16 + 0x39c)) + *GHIDRA_CAST((iVar16 + 0x364)); + } + } + } + iVar16 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + clubScale = GHIDRA_CAST(0x3f800000); + if (iVar16 != 0) { + if (player == GHIDRA_CAST(0x0)) { + pVVar9 = GHIDRA_CAST((iVar16 + 0xe4)); + pVVar5 = GHIDRA_CAST(local_1c4); + if (*GHIDRA_CAST((iVar16 + 0x28)) != 3) { + if (1.0 < pVVar9->x) { + pVVar5 = pVVar9; + } + goto LAB_009fabed; + } + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = pVVar9->x * 0.8; + local_1f0.y = 0.8; + if ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) <= 0.8) { + pVVar5 = GHIDRA_CAST(&local_1f0.y); + } + } + else { + local_238.x = (player->_playerSpriteScale).x; + local_238.y = (player->_playerSpriteScale).y; + pVVar5 = &local_238; + if (local_238.x <= 1.0) { + pVVar5 = GHIDRA_CAST(local_1c4); + } +LAB_009fabed: + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0x3f800000); + } + clubScale = GHIDRA_CAST(pVVar5->x); + } + if ((this_00 != GHIDRA_CAST(0x0)) && (weaponType != 0xb)) { + bVar4 = TemporaryEffects::HasCollectibleEffect(&this_00->_temporaryeffects,0x271); + if (bVar4 != 0) { + clubScale = GHIDRA_CAST(((float)clubScale * 4.0)); + } + owner = GHIDRA_CAST(0x0); + iVar30 = 0xa9; + bVar4 = Entity_Player::HasCollectible(this_00,0xa9,0); + if (bVar4 == 0) { + owner = GHIDRA_CAST(0x0); + iVar30 = 0x213; + bVar4 = Entity_Player::HasCollectible(this_00,0x213,0); + if (bVar4 != 0) { + clubScale = GHIDRA_CAST(((float)clubScale * 1.5)); + } + } + else { + clubScale = GHIDRA_CAST(((float)clubScale + (float)clubScale)); + } + } + if ((local_1f9 != '\0') && (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x54)) == 0)) { + TearParams::constructor(GHIDRA_CAST((local_1c4 + 4))); + if (this_00 != GHIDRA_CAST(0x0)) { + pEVar31 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + uVar6 = Random(); + this_00 = ownerPlayer; + pTVar7 = Entity_Player::GetTearHitParams + (ownerPlayer,&local_158,8,1.0,(uVar6 & 1) * 2 + -1,pEVar31); + TearParams::operator_(GHIDRA_CAST((local_1c4 + 4)),pTVar7); + } + uVar6 = Random(); + local_238.x = ownerPos.x + 0.0; + local_238.y = ownerPos.y + 5.0; + local_1d8 = (Entity_Bomb *) + Game::Spawn(g_game,2,(*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x4))),&local_238,&g_vectorZero, + *GHIDRA_CAST((GHIDRA_CAST(this) + 4)),2,uVar6); + if ((local_1d8 == GHIDRA_CAST(0x0)) || (local_1d8->_type != 2)) { + local_1d8 = GHIDRA_CAST(0x0); + } + local_1f0.y = (float)&local_1d8->_parent; + local_218.y = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (local_1d8->_parent != 0) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = local_1f0.y; + msvc::multiset::erase(); + } + *GHIDRA_CAST(local_1f0.y) = local_218.y; + if (GHIDRA_CAST(local_218.y) != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + } + Entity_Projectile::SetHeight(GHIDRA_CAST(local_1d8),-40.0); + owner = tearDamage; + (**(code **)(*GHIDRA_CAST(local_1d8) + 0x40))(); + b = &g_tearFlagSpectral; + pBVar8 = BitSet128::operator_or(GHIDRA_CAST(local_50),&tearFlags,&g_tearFlagLudovico); + pBVar8 = BitSet128::operator_or(GHIDRA_CAST(&local_2bc),pBVar8,b); + Entity_Tear::SetTearFlags(GHIDRA_CAST(local_1d8),*pBVar8); + iVar30 = 1; + (**(code **)(*GHIDRA_CAST(local_1d8) + 0x3c))(); + fVar23 = sqrtf((float)tearDamage); + local_1f0.y = 0.01; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = (float)tearDamage * 0.04 + 1.5 + fVar23 * 0.15; + pfVar18 = GHIDRA_CAST(local_1c4); + if ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) <= 0.01) { + pfVar18 = &local_1f0.y; + } + fVar23 = *pfVar18; + local_1d8->_bounceCount = GHIDRA_INT(fVar23); + local_1d8->_fallAcceleration = fVar23; + Entity_Tear::ResetSpriteScale(GHIDRA_CAST(local_1d8)); + (**(code **)(*GHIDRA_CAST(local_1d8) + 0xc))(); + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x54)) != local_1d8) { + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x54)) != GHIDRA_CAST(0x0)) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST((GHIDRA_INT(this) + 0x54)); + msvc::multiset::erase(); + } + owner = GHIDRA_CAST((GHIDRA_INT(this) + 0x54)); + *GHIDRA_CAST(owner) = local_1d8; + iVar30 = 0x9faefd; + msvc::multiset::insert(); + } + } + if ((weaponType == 0xb) || (this_00 == GHIDRA_CAST(0x0))) { +LAB_009faf2a: + local_1f9 = '\0'; + if ((weaponType != 0xb) && (this_00 != GHIDRA_CAST(0x0))) goto LAB_009faf3a; +LAB_009faf4d: + cVar12 = '\0'; + } + else { + owner = GHIDRA_CAST(0x0); + iVar30 = 0x57; + bVar4 = Entity_Player::HasCollectible(this_00,0x57,0); + if (bVar4 == 0) goto LAB_009faf2a; + local_1f9 = '\x01'; +LAB_009faf3a: + owner = GHIDRA_CAST(0x0); + iVar30 = 0x37; + bVar4 = Entity_Player::HasCollectible(this_00,0x37,0); + if (bVar4 == 0) goto LAB_009faf4d; + cVar12 = '\x01'; + } + pEVar19 = local_200; + local_1d2 = CONCAT11(cVar12,(uint8_t)local_1d2); + local_208 = GHIDRA_CAST(0x0); + do { + if ((local_208 == GHIDRA_CAST(0x0)) || + (((local_208 == GHIDRA_CAST(0x1) && (cVar12 != '\0')) || (local_1f9 != '\0')))) { + local_1f0.y = (float)(GHIDRA_INT(this) + GHIDRA_INT(local_208) * 4 + 0x44); + piVar15 = *GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT(local_208) * 4 + 0x44)); + if (piVar15 != GHIDRA_CAST(0x0)) { + if ((piVar15[10] == 8) && (GHIDRA_CAST(piVar15[0xb]) == pEVar19)) goto LAB_009fb07f; + owner = GHIDRA_CAST(0x9faff5); + (**(code **)(*piVar15 + 0x28))(); + } + local_218.y = (float)Weapon::fire_bone_club + (this,*GHIDRA_CAST((GHIDRA_CAST(this) + 4)),GHIDRA_UINT(pEVar19),1,iVar30, + GHIDRA_INT(owner),0.0); + if (*GHIDRA_CAST(local_1f0.y) != GHIDRA_CAST(local_218.y)) { + if (*GHIDRA_CAST(local_1f0.y) != GHIDRA_CAST(0x0)) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = local_1f0.y; + iVar30 = 0x9fb038; + msvc::multiset::erase(); + } + *GHIDRA_CAST(local_1f0.y) = local_218.y; + if (GHIDRA_CAST(local_218.y) != GHIDRA_CAST(0x0)) { + iVar30 = 0x9fb050; + msvc::multiset::insert(); + } + } + *GHIDRA_CAST((GHIDRA_CAST(local_218.y) + 0x438)) = (&DAT_00b81710)[GHIDRA_INT(local_208)]; + *GHIDRA_CAST((GHIDRA_CAST(local_218.y) + 0x467)) = local_208 == GHIDRA_CAST(0x0); + owner = GHIDRA_CAST(0x9fb079); + (**(code **)(*GHIDRA_CAST(local_218.y) + 0xc))(); + } + else { + local_1f0.y = (float)(GHIDRA_INT(this) + GHIDRA_INT(local_208) * 4 + 0x44); + if (*GHIDRA_CAST(local_1f0.y) != GHIDRA_CAST(0x0)) { + owner = GHIDRA_CAST(0x9faf94); + (**(code **)(**GHIDRA_CAST(local_1f0.y) + 0x28))(); + if (*GHIDRA_CAST(local_1f0.y) != 0) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = local_1f0.y; + owner = GHIDRA_CAST(local_1c4); + iVar30 = 0x9fafbc; + msvc::multiset::erase(); + *GHIDRA_CAST(local_1f0.y) = 0; + } + } + } +LAB_009fb07f: + pEVar13 = ownerPlayer; + local_208 = local_208 + 1; + cVar12 = (*GHIDRA_CAST((GHIDRA_CAST(&(local_1d2)) + 0x1))); + } while (local_208 < &DAT_00000004); + heldClub = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + shotDirection.y = aimDirection->y; + shotDirection.x = aimDirection->x; + if (shotDirection.y == 0.0) { + if (shotDirection.x == 0.0) { + shotDirection.x = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); + shotDirection.y = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)); + } + if (((shotDirection.y == 0.0) && (shotDirection.x == 0.0)) && (player != GHIDRA_CAST(0x0))) + { + switch(player->_headDirection) { + case 0: + shotDirection.x = (float)&DAT_bf800000; + break; + case 1: + shotDirection.y = (float)&DAT_bf800000; + break; + case 2: + shotDirection.x = 1.0; + break; + case 3: + shotDirection.y = 1.0; + } + } + } + bVar4 = Weapon::IsAxisAligned(this); + if (bVar4 != 0) { + pVVar9 = Vector::ToCardinal(&local_274,&shotDirection); + shotDirection.x = (float)pVVar9->x; + shotDirection.y = (float)pVVar9->y; + } + local_218.y = shotDirection.y; + local_1f0.y = shotDirection.x; + if ((((player != GHIDRA_CAST(0x0)) && (iVar30 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)), iVar30 != 0)) && + (*GHIDRA_CAST((iVar30 + 0x28)) == 1)) && + ((0 < *GHIDRA_CAST((iVar30 + 0x145c)) || + ((*GHIDRA_CAST((iVar30 + 0x2c)) == 1 && (*GHIDRA_CAST((iVar30 + 0x1aec)) == 8)))))) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = (float)GHIDRA_INT(*GHIDRA_CAST((iVar30 + 0x1578))) * 45.0 * 0.017453292; + local_2a4.y = cos((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))); + fVar23 = sin((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))); + shotDirection.x = (float)(local_2a4.y * local_1f0.y - fVar23 * local_218.y); + shotDirection.y = (float)(local_2a4.y * local_218.y + fVar23 * local_1f0.y); + ownerPlayer = pEVar13; + } + if ((heldClub->_isSwinging == 0) && (heldClub->_isFlying == 0)) { + local_1f0.y = (float)(GHIDRA_INT(this) + 0x44); + local_1e4.y = 0.0; + owner = GHIDRA_CAST(shotDirection.y); + pEVar19 = GHIDRA_CAST(shotDirection.x); + do { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = *GHIDRA_CAST(local_1f0.y); + if ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) != GHIDRA_CAST(0x0)) { + fVar23 = atan2f((float)owner,(float)pEVar19); + fVar23 = fVar23 * 57.295776 + + *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST((GHIDRA_INT(local_1e4.y) + 0xb7f600))))) + 0x1c08))) + 0x508)) + ; + if (360.0 < ABS(fVar23)) { + fVar23 = fmodf(fVar23,360.0); + } + if (fVar23 <= 180.0) { + if (fVar23 < -180.0) { + fVar23 = fVar23 + 360.0; + } + } + else { + fVar23 = fVar23 - 360.0; + } + *GHIDRA_CAST((((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) + 0x41c)))->_animDefaultName)._buf + 4)) = fVar23; + owner = GHIDRA_CAST(shotDirection.y); + pEVar19 = GHIDRA_CAST(shotDirection.x); + } + local_1e4.y = (float)&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(local_1e4.y)))) + 0x4))); + local_1f0.y = (float)(GHIDRA_INT(local_1f0.y) + 4); + } while (GHIDRA_UINT(local_1e4.y) < GHIDRA_CAST(0x10)); + if ((*GHIDRA_CAST((GHIDRA_CAST((heldClub)) + 0x466))) == '\0') { + heldClub->_rotationOffset = 0.0; + } + iVar30 = g_game->_frameCount - heldClub->_spawnFrame; + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) <= 0.0) { + if (iVar30 < 2) { + local_1f0.y = (float)clubScale; + } + else { + fVar23 = (heldClub->_sprite)._scale.x; + local_1f0.y = ((float)clubScale - fVar23) * 0.5 + fVar23; + } + } + else { + if (1 < iVar30) goto LAB_009fb512; + local_1f0.y = (float)clubScale; + } + local_1e4.y = (float)(GHIDRA_INT(this) + 0x44); + local_218.y = 5.60519e-45; + do { + if (*GHIDRA_CAST(local_1e4.y) != 0) { + init_club(); + iVar30 = *GHIDRA_CAST(local_1e4.y); + fVar23 = local_1f0.y * g_vectorOne.y; + *GHIDRA_CAST((iVar30 + 0xe4)) = local_1f0.y * g_vectorOne.x; + *GHIDRA_CAST((iVar30 + 0xe8)) = fVar23; + } + owner = GHIDRA_CAST((GHIDRA_INT(local_218.y) + -0x2f00)); + local_1e4.y = (float)&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(local_1e4.y)))) + 0x4))); + local_218.y = (float)&(*GHIDRA_CAST((GHIDRA_CAST((owner)) + 0x2eff))); + } while (&(*GHIDRA_CAST((GHIDRA_CAST((owner)) + 0x2eff))) != GHIDRA_CAST(0x0)); + } +LAB_009fb512: + if (local_1c6 == 0) { + if (((char)isBrimstone != '\0') && (bVar4 = Weapon::IsItemAnimFinished(this,0x76), bVar4 != 0)) + { + Weapon::stop_costume_item_anim(this,0x76); + } + if ((char)isCursedEye != '\0') { + Weapon::stop_costume_item_anim(this,0x13c); + } + if ((isChocolateMilk != 0) && (bVar4 = Weapon::IsItemAnimFinished(this,0x45), bVar4 != 0)) { + Weapon::stop_costume_item_anim(this,0x45); + } + if (((*GHIDRA_CAST((GHIDRA_CAST(&(local_250)) + 0x0))) != '\0') && (bVar4 = Weapon::IsItemAnimFinished(this,0xe5), bVar4 != 0)) { + Weapon::stop_costume_item_anim(this,0xe5); + } + if (((char)isCSection != '\0') && + (bVar4 = Weapon::is_c_section_anim_finished(this,isCSection), bVar4 != 0)) { + Weapon::update_c_section_charge_anim(this,unusedCollectibleId,0,aimDirection,0.0); + } + } + if (isInterpolated != 0) { + ExceptionList = local_10; + return; + } + owner = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)); + newCharge = owner; + if (local_1c6 == 0) { + if ((isChargeMode != '\0') || + (((player != GHIDRA_CAST(0x0) && (player->_heldEntity != (void *)0x0)) || + ((char)isCSection != '\0')))) { + if (0.0 < (float)owner) { + newCharge = GHIDRA_CAST(0x0); + if (0.0 <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc))) { + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x5c)) = 0; + } + } + goto LAB_009fba4f; + } + if (1.0 < (float)owner) { + EntityList::QuerySublist + (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),GHIDRA_CAST(&local_2bc),8,1,-1,0,0) + ; + local_8 = 5.60519e-45; + local_200 = GHIDRA_CAST(0x0); + iVar30 = extraout_ECX; + if (puStack_2b0 != GHIDRA_CAST(0x0)) { + do { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = *GHIDRA_CAST((GHIDRA_CAST(pvStack_2b8) + GHIDRA_INT(local_200) * 4)); + iVar30 = ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))))->_parent; + if ((iVar30 != 0) && + ((iVar30 == *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) || + (*GHIDRA_CAST((iVar30 + 0x3bc)) == *GHIDRA_CAST((GHIDRA_CAST(this) + 4)))))) { + fVar23 = *GHIDRA_CAST(((((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))))->_bodySprite)._animDefaultName. + _buf + 8)) * 0.5; + if (360.0 < ABS(fVar23)) { + fVar23 = fmodf(fVar23,360.0); + iVar30 = extraout_ECX_00; + } + if (fVar23 <= 180.0) { + if (fVar23 < -180.0) { + fVar23 = fVar23 + 360.0; + } + } + else { + fVar23 = fVar23 - 360.0; + } + *GHIDRA_CAST((((GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) + 0x41c)))->_animDefaultName)._buf + 8)) = fVar23; + } + local_200 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_200)) + 0x1)))); + } while (local_200 < puStack_2b0); + pEVar13 = ownerPlayer; + } + Weapon::SetBlinkTime(this,7 - GHIDRA_INT(((float)maxFireDelay * -0.45)),iVar30); + Weapon::TriggerTearEffects(this,&shotDirection,1); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = (float)maxFireDelay * 3.0; + local_1f0.y = 300.0; + maxFireDelay = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))); + pfVar18 = GHIDRA_CAST(local_1c4); + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) <= (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))) { + pfVar18 = GHIDRA_CAST((GHIDRA_INT(this) + 0x14)); + } + local_200 = GHIDRA_CAST(*pfVar18); + if ((pEVar13 == GHIDRA_CAST(0x0)) || + (bVar4 = Entity_Player::HasCollectible(pEVar13,0xe9,0), bVar4 == 0)) { + fVar23 = 300.0; + local_1e4.y = 0.2; + local_250 = (float)local_200 / (float)maxFireDelay; + pfVar18 = &local_250; + if ((float)local_200 / (float)maxFireDelay <= 0.2) { + pfVar18 = &local_1e4.y; + } + local_218.y = (float)*pfVar18; + if (pEVar13 == GHIDRA_CAST(0x0)) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0x43820000); + } + else { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = pEVar13->_tearrange; + } + } + else { + local_1e4.y = 0.2; + local_1f0.y = 100000.0; + fVar23 = 100000.0; + local_250 = (float)local_200 / (float)maxFireDelay; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = pEVar13->_tearrange; + pfVar18 = &local_250; + if ((float)local_200 / (float)maxFireDelay <= 0.2) { + pfVar18 = &local_1e4.y; + } + local_218.y = (float)*pfVar18; + } + local_1e4.y = 0.2; + local_200 = GHIDRA_CAST(0x43480000); + pfVar18 = GHIDRA_CAST(local_1c4); + if (fVar23 <= (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))) { + pfVar18 = &local_1f0.y; + } + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST((*pfVar18 * 0.9)); + ppEVar10 = GHIDRA_CAST(local_1c4); + if (*pfVar18 * 0.9 <= 200.0) { + ppEVar10 = &local_200; + } + uVar6 = 0; + owner = *ppEVar10; + local_200 = GHIDRA_CAST((GHIDRA_INT(this) + 0x44)); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = owner; + do { + club = *GHIDRA_CAST(local_200); + if ((club != GHIDRA_CAST(0x0)) && ((uVar6 == 0 || ((*GHIDRA_CAST((GHIDRA_CAST((club)) + 0x466))) != '\0')))) { + Entity_Knife::Shoot(club,local_218.y,(float)owner); + owner = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))); + } + uVar6 = uVar6 + 1; + local_200 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_200)) + 0x4)))); + } while (uVar6 < 4); + Weapon::SetHeadLockTime(this,2); + if (player != GHIDRA_CAST(0x0)) { + Entity_Player::TryForgottenThrow(player,&shotDirection); + } + local_8 = -NAN; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_2bc)) + 0x0))) == '\0') { + local_8 = 7.00649e-45; + tracked_alloc(1,pvStack_2b8,0); + } + } + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) != 0) { + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) + 0x466)) = 0; + } + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)) != 0) { + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)) + 0x466)) = 0; + } + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) != 0) { + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) + 0x466)) = 0; + } + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x50)) != 0) { + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x50)) + 0x466)) = 0; + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = g_vectorZero.x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = g_vectorZero.y; + owner = GHIDRA_CAST(0x0); +LAB_009fb9ec: + club = heldClub; + goto LAB_009fb9f2; + } +LAB_009fba4f: + iVar30 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (((iVar30 == 0) || (*GHIDRA_CAST((iVar30 + 0x28)) != 1)) || + (piVar15 = GHIDRA_CAST(isCSection), *GHIDRA_CAST((iVar30 + 0x18f8)) < 1)) { + uVar20 = (undefined3)(GHIDRA_UINT(player) >> 8); + if ((player == GHIDRA_CAST(0x0)) || ((player->_temporaryeffects)._disabled != 0)) { + rngResult = CONCAT31(uVar20,local_1c5); + } + else { + effectIt = (player->_temporaryeffects)._effects._begin; + effectsEnd = (player->_temporaryeffects)._effects._end; + if (effectIt == effectsEnd) { + rngResult = CONCAT31(uVar20,local_1c5); + } + else { + do { + piVar15 = GHIDRA_CAST(*effectIt); + if ((*piVar15 == 0) && (piVar15[1] == 0x78)) goto LAB_009fbb0b; + effectIt = effectIt + 4; + rngResult = CONCAT31(CONCAT21((short)(GHIDRA_UINT(player) >> 0x10),isDrFetus),local_1c5); + ownerPlayer = pEVar13; + } while (effectIt != effectsEnd); + isDrFetus = isDrFetus; + player = player; + } + } + if ((char)rngResult == '\0') { + if ((char)isCSection != '\0') goto LAB_009fbb7b; + } + else { + if (isChargeMode == '\0') goto LAB_009fbb11; +LAB_009fbb7b: + if ((((local_1c6 != 0) && ((float)maxCharge <= (float)owner)) && + (local_1c6 = 0, 0.0 < (float)owner)) && + (newCharge = GHIDRA_CAST(0x0), 0.0 <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)))) { + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x5c)) = 0; + } + isReleased = '\x01'; + } + } + else { +LAB_009fbb0b: + rngResult = CONCAT31((int3)(GHIDRA_UINT(piVar15) >> 8),local_1c5); +LAB_009fbb11: + isChargeMode = '\0'; + newCharge = owner; + local_1f0.y = (float)owner; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = 0; + if ((char)rngResult != '\0') { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0x3f800000); + isReleased = '\x01'; + pfVar18 = GHIDRA_CAST(local_1c4); + if (1.0 <= (float)owner) { + pfVar18 = &local_1f0.y; + } + newCharge = GHIDRA_CAST(*pfVar18); + } + } + pEVar19 = player; + pfVar18 = GHIDRA_CAST((GHIDRA_INT(this) + 0x14)); + iVar30 = CONCAT22((short)(GHIDRA_UINT(rngResult) >> 0x10),CONCAT11(local_1c6,(char)rngResult)); + if ((local_1c6 == 0) || ((heldClub->_isSwinging != 0 && ((char)rngResult == '\0')))) { + if ((isChargeMode == '\0') && (local_1c6 != 0)) goto LAB_009fbc0f; +LAB_009fbc27: + if ((((player != GHIDRA_CAST(0x0)) && (player->_heldEntity != (void *)0x0)) && + (local_1c6 == 0)) || + ((((char)isCSection != '\0' && (local_1c6 == 0)) && + ((*GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) <= 0.0 && *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) != 0.0 && + (1.0 < *pfVar18)))))) goto LAB_009fbcd3; + owner = newCharge; + if (((isChocolateMilk == 0) && ((char)isBrimstone == '\0')) && ((*GHIDRA_CAST((GHIDRA_CAST(&(local_250)) + 0x0))) == '\0')) { + if ((char)isCursedEye != '\0') goto LAB_009fbc86; + goto LAB_009fdeca; + } + if ((char)isCursedEye == '\0') { + if (local_1c6 == 0) { + if ((0.0 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) || *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) == 0.0) || + (*pfVar18 <= 1.0)) goto LAB_009fb9ec; + goto LAB_009fbcd3; + } + } + else { +LAB_009fbc86: + if (local_1c6 == 0) { + if ((0.0 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) || *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) == 0.0) || + (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x5c)) < 1)) goto LAB_009fb9ec; + goto LAB_009fbcd3; + } + } + } + else { + if (isChargeMode != '\0') { + if (*pfVar18 <= 1.0 && *pfVar18 != 1.0) { + *pfVar18 = 1.0; + newCharge = GHIDRA_CAST(0x3f800000); + } + goto LAB_009fbc27; + } +LAB_009fbc0f: + if (((0.0 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) || *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) == 0.0) || + (0.0 < *pfVar18)) || (heldClub->_isFlying != 0)) goto LAB_009fbc27; +LAB_009fbcd3: + Weapon::GetMultiShotParams(this,local_2f8 + 8,iVar30); + iVar30 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) = maxFireDelay; + iVar16 = extraout_ECX_01; + if (iVar30 != 0) { + uVar21 = (uint3)(GHIDRA_UINT(extraout_ECX_01) >> 8); + if (*GHIDRA_CAST((iVar30 + 0x28)) == 1) { + iVar16 = CONCAT31(uVar21,*GHIDRA_CAST((iVar30 + 0x1578))); + } + else if ((iVar30 == 0) || (iVar16 = GHIDRA_UINT(uVar21) << 8, *GHIDRA_CAST((iVar30 + 0x28)) != 1)) + goto LAB_009fbd18; + cVar12 = (char)iVar16; + iVar16 = CONCAT31((int3)(GHIDRA_UINT(iVar16) >> 8),-cVar12); + *GHIDRA_CAST((iVar30 + 0x1578)) = -cVar12; + } +LAB_009fbd18: + Weapon::SetBlinkTime(this,7 - GHIDRA_INT(((float)maxFireDelay * -0.45)),iVar16); + Weapon::TriggerTearEffects(this,&shotDirection,1); + pfVar18 = &local_1f0.y; + local_1f0.y = 0.5; + damageMultiplier = 1.0; + local_2bc = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_2f8)) + 0x8))); + pvStack_2b8 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)local_2f8)) + 0xc))); + fStack_2b4 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_2f8)) + 0x10))); + puStack_2b0 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_2f8))) + 0x14))); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = 1.0 / ((float)clubScale * 0.5 + 0.5); + clampedValue = GHIDRA_CAST(local_1c4); + if ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) <= 0.5) { + clampedValue = pfVar18; + } + fStack_2cc = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_2f8)) + 0x18))); + lanesPerEye = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x1c))); + fStack_2c4 = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_2f8)) + 0x20))); + fStack_2c0 = uStack_2d4; + local_208 = local_2d0; + local_238.y = *clampedValue; + local_1d2 = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x8))); + if (pEVar19 != GHIDRA_CAST(0x0)) { + pvVar17 = pEVar19->_heldEntity; + local_1f0.y = (float)&pEVar19->_heldEntity; + if (pvVar17 != (void *)0x0) { + fVar23 = (pEVar19->_pos).y; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x33c)) = (pEVar19->_pos).x; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x340)) = fVar23; + owner = pEVar19->_heldEntity; + local_1e4.y = (float)owner; + if (owner->_type == 4) { + savedBombFlags = owner->_flags; + bombFlagsHigh = GHIDRA_CAST((GHIDRA_INT(&owner->_flags) + 4)); + *bombFlagsHigh = *bombFlagsHigh & 0xfdffffdf; + *GHIDRA_CAST(&owner->_flags) = GHIDRA_INT(savedBombFlags); + owner->_renderZOffset = 0; + local_218.y = 0.0; + if (0 < (*GHIDRA_CAST((GHIDRA_CAST(&((short)local_2f8)) + 0x8)))) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_INT((short)local_2f8))) + 0x8))) / 2; + do { + owner = GHIDRA_CAST(local_1e4.y); + FUN_009f4230(local_27c,local_218.y,5,shotDirection.x,shotDirection.y,shotSpeed); + if (local_218.y == (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))) { + (*GHIDRA_CAST((GHIDRA_CAST(&(((GHIDRA_CAST((GHIDRA_INT(local_1e4.y) + 0x41c)))->_animState))) + 0x15))) = 1; + } + else { + owner = GHIDRA_CAST(Weapon)::fire_bomb(this,&ownerPos,&g_vectorZero); + iVar30 = *GHIDRA_CAST((GHIDRA_CAST(player->_heldEntity) + 0x410)); + *GHIDRA_CAST(&owner->_isControlsEnabled) = iVar30; + owner->_controlsCooldown = iVar30; + anim = ANM2::GetAnimation(GHIDRA_CAST(&(GHIDRA_CAST((GHIDRA_INT(local_1e4.y) + 0x48)))->_animState), + GHIDRA_CAST((local_c4 + 0x14))); + local_8 = 0.0; + if (0xf < anim->_capacity) { + anim = *GHIDRA_CAST(anim->_buf); + } + ANM2::Play(&owner->_sprite,GHIDRA_CAST(anim),0); + local_8 = -NAN; + (GHIDRA_CAST((local_c4 + 0x14)))->msvc::string::_Tidy_deallocate(); + if ((owner->_sprite)._animState._animData != (void *)0x0) { + AnimationState::SetFrameFloat + (&(owner->_sprite)._animState, + (float)GHIDRA_INT(((GHIDRA_CAST((GHIDRA_INT(local_1e4.y) + 0x48)))->_animState)). + _animFrame); + } + } + owner->_entityCollisionClass = 4; + owner->_entityGridCollisionClass = 6; + local_2a4.y = local_274.y; + local_1d8 = GHIDRA_CAST(local_274.x); + if ((owner->_variant == 0x13) || (owner->_variant == 0x14)) { + fVar23 = atan2f(local_274.y,local_274.x); + *GHIDRA_CAST((GHIDRA_INT((owner->_bodySprite)._filename._buf) + 0xc)) = fVar23 * 57.295776; + } + else { + *GHIDRA_CAST((owner->_bodySprite)._filename._buf) = -5.0; + } + (owner->_posOffset).x = 0.0; + (owner->_posOffset).y = -14.0; + fVar25 = sqrtf(local_2a4.y * local_2a4.y + (float)local_1d8 * (float)local_1d8); + pEVar27 = local_1d8; + fVar23 = local_2a4.y; + if (0.0 < fVar25) { + pEVar27 = GHIDRA_CAST(((float)local_1d8 * (1.0 / fVar25))); + fVar23 = local_2a4.y * (1.0 / fVar25); + } + fVar25 = (player->_lastVelocity).x * 0.6; + iVar30 = *GHIDRA_CAST(owner); + fVar26 = (player->_lastVelocity).y * 0.6; + (owner->_velocity).x = (float)pEVar27 * 20.0 + fVar25 + fVar25; + (owner->_velocity).y = fVar23 * 20.0 + fVar26 + fVar26; + (**(code **)(iVar30 + 0x40))(); + local_218.y = (float)(GHIDRA_INT(local_218.y) + 1); + (owner->_bodySprite)._filename._size = 0x41700000; + } while (GHIDRA_INT(local_218.y) < GHIDRA_INT(local_1d2)); + } + } + else if ((owner->_type == 1000) && (owner->_variant == 0x76)) { + iVar30 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x58)); + if (iVar30 == 0) { + local_220.x = ownerPos.x + shotDirection.x * 80.0; + local_220.y = ownerPos.y + shotDirection.y * 80.0; + } + else { + local_220.x = *GHIDRA_CAST((iVar30 + 0x33c)); + local_220.y = *GHIDRA_CAST((iVar30 + 0x340)); + } + bombFlagsHigh = GHIDRA_CAST((GHIDRA_INT(&owner->_flags) + 4)); + *bombFlagsHigh = *bombFlagsHigh & 0xffffffdf; + *GHIDRA_CAST(&owner->_flags) = GHIDRA_INT(owner->_flags); + local_218.y = (float)(local_220.x - ownerPos.x); + local_1d8 = GHIDRA_CAST((local_220.y - ownerPos.y)); + owner->_renderZOffset = 0; + (owner->_posOffset).x = 0.0; + (owner->_posOffset).y = 0.0; + (owner->_bodySprite)._animState._animData = (void *)0x1; + local_1e4.y = 0.0; + if (0 < (*GHIDRA_CAST((GHIDRA_CAST(&((short)local_2f8)) + 0x8)))) { + local_220.x = 1.0; + local_24c.y = (float)((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_INT((short)local_2f8))) + 0x8))) / 2); + local_220.y = 0.0; + do { + FUN_009f4230(local_27c,local_1e4.y,5,local_220.x,local_220.y,shotSpeed); + fVar23 = atan2f(local_274.y,local_274.x); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = fVar23 * 57.295776 * 0.017453292; + local_2a4.y = cos((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))); + fVar23 = sin((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = ownerPos.x + (local_218.y * local_2a4.y - (float)local_1d8 * fVar23) + ; + local_2a4.y = ownerPos.y + (float)local_1d8 * local_2a4.y + local_218.y * fVar23; + if (local_1e4.y == local_24c.y) { + pEVar19 = owner; + } + else { + uVar6 = Random(); + pEVar19 = (Entity_Player *) + Game::Spawn(g_game,1000,0x76,&ownerPos,&g_vectorZero, + *GHIDRA_CAST((GHIDRA_CAST(this) + 4)),0,uVar6); + } + local_1e4.y = (float)&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(local_1e4.y)))) + 0x1))); + (pEVar19->_targetPosition).y = local_2a4.y; + (pEVar19->_bodySprite)._animState._animData = (void *)local_1e4.y; + (pEVar19->_targetPosition).x = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))); + } while (GHIDRA_INT(local_1e4.y) < GHIDRA_INT(local_1d2)); + } + } + *GHIDRA_CAST((*GHIDRA_CAST(local_1f0.y) + 0x171)) = 1; + pfVar18 = GHIDRA_CAST(0x0); + if (*GHIDRA_CAST(local_1f0.y) != 0) { + local_24c.y = local_1f0.y; + msvc::multiset::erase(); + pfVar18 = extraout_ECX_02; + } + *GHIDRA_CAST(local_1f0.y) = 0; + } + } + if (isChocolateMilk != 0) { + pfVar18 = GHIDRA_CAST(local_1c4); + local_24c.y = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) / (float)maxFireDelay - 1.0) + 1.0; + clampedValue = &local_24c.y; + if (1.0 <= (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))) { + clampedValue = pfVar18; + } + damageMultiplier = *clampedValue; + } + if (((*GHIDRA_CAST((GHIDRA_CAST(&(local_250)) + 0x0))) != '\0') && ((float)chargeThreshold <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)))) { + Weapon::UpdateHeadChargeAnimation(this,0xe5,2,&shotDirection,-1.0); + local_220.x = shotDirection.x * 10.0; + local_220.y = shotDirection.y * 10.0; + local_1e4.y = local_220.y; + local_1d8 = GHIDRA_CAST(local_220.x); + pVVar9 = Weapon::get_tear_movement_inheritance(this,&local_274,&local_220); + owner = ownerPlayer; + local_1d8 = GHIDRA_CAST(((float)local_1d8 + pVVar9->x)); + local_1e4.y = local_1e4.y + pVVar9->y; + if ((ownerPlayer == GHIDRA_CAST(0x0)) || + (bVar4 = Entity_Player::HasCollectible(ownerPlayer,0x95,0), bVar4 == 0)) { + local_1f0.y = 1.68156e-44; + if (owner != GHIDRA_CAST(0x0)) goto LAB_009fc57a; + } + else { + uVar6 = Random(); + fVar23 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * + 2.3283064e-10 * 0.2 + 0.7; + local_1d8 = GHIDRA_CAST(((float)local_1d8 * fVar23)); + local_1e4.y = local_1e4.y * fVar23; +LAB_009fc57a: + local_1f0.y = 1.68156e-44; + bVar4 = Entity_Player::HasCollectible(owner,0x213,0); + if (bVar4 != 0) { + bVar4 = Entity_Player::HasCollectible(owner,0x76,0); + local_1f0.y = (float)(GHIDRA_UINT((bVar4 == 0)) * 2 + 5); + } + } + bVar4 = Entity_Player::HasCollectible(owner,0x34,0); + owner = GHIDRA_CAST(local_1f0.y); + if (bVar4 != 0) { + owner = GHIDRA_CAST(&DAT_00000005); + } + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = lanesPerEye; + local_24c.y = (float)(GHIDRA_INT((&(owner->_sprite)._filename + -3)) + + GHIDRA_INT((((float)GHIDRA_INT(owner) / 5.0) * (float)GHIDRA_INT(local_1d2)))) / + (float)lanesPerEye; + iVar30 = 0x9fc63a; + dVar29 = ceil((double)local_24c.y); + local_218.y = (float)dVar29; + local_2a4.y = 0.0; + pfVar18 = extraout_ECX_03; + if (0 < (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_INT(local_1c4))) + 0x0)))) { + do { + fVar25 = local_2a4.y; + fVar23 = 0.0; + if (1 < (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_INT(local_1c4))) + 0x0)))) { + local_1f0.y = (float)((*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x20))) ^ 0x80000000); + local_24c.y = (*GHIDRA_CAST((GHIDRA_CAST(&((float)GHIDRA_INT(local_1c4))) + 0x0))) - 1.0; + if (local_24c.y == 0.0) { + iVar30 = 0x9fc6b2; + KAGE_LogMessage(0x10,GHIDRA_CAST("Start and End parameters cannot be the same!")); + } + fVar23 = ((float)GHIDRA_INT(fVar25) - 0.0) / (local_24c.y - 0.0); + auVar24 = ZEXT416(GHIDRA_UINT(fVar23)); + if (fVar23 <= 0.0) { + auVar24 = ZEXT816(0); + } + if (1.0 <= (*GHIDRA_CAST((GHIDRA_CAST(&(auVar24)) + 0x0)))) { + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar24)) + 0x0))) = 0x3f800000; + } + fVar23 = ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_2f8)) + 0x20))) - local_1f0.y) * (*GHIDRA_CAST((GHIDRA_CAST(&(auVar24)) + 0x0))) + local_1f0.y; + } + local_24c.y = fVar23 * 0.017453292; + local_1f0.y = cos(local_24c.y); + fVar23 = sin(local_24c.y); + fVar28 = (float)local_1d8 * local_1f0.y; + fVar26 = local_1e4.y * local_1f0.y; + local_1f0.y = 0.0; + pfVar18 = extraout_ECX_04; + if (0 < GHIDRA_INT(local_218.y)) { + local_264.y = (fVar28 - local_1e4.y * fVar23) * (float)shotSpeed; + local_220.y = (fVar26 + (float)local_1d8 * fVar23) * (float)shotSpeed; + do { + uVar6 = Random(); + fVar23 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + local_24c.y = fVar23 + fVar23; + local_284 = GHIDRA_CAST(sin(local_24c.y)); + uVar6 = Random(); + local_298 = (Entity_Bomb *) + ((float)((double)GHIDRA_INT(uVar6) + + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * 2.3283064e-10); + fVar23 = cos(local_24c.y); + local_274.x = fVar23 * (float)local_298 * 3.5 + local_264.y; + local_274.y = (float)local_298 * (float)local_284 * 3.5 + local_220.y; + pEVar27 = GHIDRA_CAST(Weapon)::fire_tear(this,&ownerPos,&local_274,0,iVar30,1.0,0.0) + ; + local_284 = pEVar27; + if ((pEVar27->_variant == 0x1d) && (uVar6 = Random(), (uVar6 & 3) != 0)) { + pvStack_48 = (void *)0x0; + puStack_44 = &DAT_0000000f; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_6c)) + 0x14))) = (void *)0x0; + (GHIDRA_CAST((local_6c + 0x14)))->msvc::string::assign(GHIDRA_CAST("gfx/tears_brokenbone.png"),0x18); + local_8 = 1.4013e-45; + iVar30 = 0x9fc8f0; + Sprite::ReplaceSpritesheet + (GHIDRA_CAST(&pEVar27->_sprite),0,GHIDRA_CAST((local_6c + 0x14))); + local_8 = -NAN; + bVar4 = extraout_CL; + if (&DAT_0000000f < puStack_44) { + puVar22 = puStack_44 + 1; + pvVar17 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)local_6c)) + 0x14))); + if (GHIDRA_CAST(0xfff) < puVar22) { + pvVar17 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(local_6c)) + 0x14))) + -4); + puVar22 = puStack_44 + 0x24; + if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(local_6c)) + 0x14))) + (-4 - GHIDRA_INT(pvVar17))))) { + /* WARNING: Subroutine does not return */ + _invalid_parameter_noinfo_noreturn(); + } + } + iVar30 = 0x9fc928; + operator_delete(pvVar17,GHIDRA_UINT(puVar22)); + bVar4 = extraout_CL_00; + } + ANM2::LoadGraphics(&pEVar27->_sprite,bVar4); + } + if (ownerPlayer == GHIDRA_CAST(0x0)) { +LAB_009fc98a: + pEVar27->_explosionDamage = ownerPlayer->_tearfallaccel + 0.5; + uVar6 = Random(); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pEVar27)) + 0x414)))) = + (ownerPlayer->_tearfallspeed - + (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * + 2.3283064e-10 * 15.0) + 5.0; + } + else { + iVar30 = 0x9fc94c; + bVar4 = Entity_Player::HasCollectible(ownerPlayer,0x95,0); + if (bVar4 == 0) { + local_50 = *(uint8_t (*) [4])&(GHIDRA_CAST(&pEVar27->_rocketAngle))->_l; + pvStack_4c = (void *)pEVar27->_rocketSpeed; + pvStack_48 = *(void **)&pEVar27->_collisionCooldown; + puStack_44 = GHIDRA_CAST(pEVar27->_scale); + pBVar8 = BitSet128::operator_and + (GHIDRA_CAST(&fStack_a8),GHIDRA_CAST(local_50), + &g_tearFlagHydrobounce); + if ((GHIDRA_INT(pBVar8->_l) == 0 && *GHIDRA_CAST((GHIDRA_INT(&pBVar8->_l) + 4)) == 0) && + (GHIDRA_INT(pBVar8->_h) == 0 && *GHIDRA_CAST((GHIDRA_INT(&pBVar8->_h) + 4)) == 0)) + goto LAB_009fc98a; + } + } + uVar6 = Random(); + rngResult = Random(); + pEVar27 = local_284; + local_298 = GHIDRA_CAST(0x3c23d70a); + local_284 = (Entity_Bomb *) + ((((float)(uVar6 & 1) + 0.0) * 0.4 + 0.9 + + (float)((double)GHIDRA_INT(rngResult) + + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 + * 0.05) * local_284->_fallAcceleration); + ppEVar11 = &local_284; + if ((float)local_284 <= 0.01) { + ppEVar11 = &local_298; + } + pEVar1 = *ppEVar11; + pEVar27->_bounceCount = GHIDRA_INT(pEVar1); + pEVar27->_fallAcceleration = (float)pEVar1; + Entity_Tear::ResetSpriteScale(GHIDRA_CAST(pEVar27)); + pfVar18 = GHIDRA_CAST(GHIDRA_INT(local_218.y)); + local_1f0.y = (float)(GHIDRA_INT(local_1f0.y) + 1); + } while (GHIDRA_INT(local_1f0.y) < GHIDRA_INT(pfVar18)); + fVar25 = local_2a4.y; + } + local_2a4.y = (float)(GHIDRA_INT(fVar25) + 1); + } while (GHIDRA_INT(local_2a4.y) < (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_INT(local_1c4))) + 0x0)))); + } + } + if (((char)isBrimstone != '\0') && ((float)chargeThreshold <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)))) { + Weapon::UpdateHeadChargeAnimation(this,0x76,2,&shotDirection,-1.0); + local_220.y = atan2f(shotDirection.y,shotDirection.x); + local_220.y = local_220.y * 57.295776; + local_1e4.y = 0.0; + do { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = *GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT(local_1e4.y) * 4 + 0x44)); + pEVar27 = GHIDRA_CAST(local_1e4.y); + if (((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) != GHIDRA_CAST(0x0)) && + ((GHIDRA_CAST(local_1e4.y) == GHIDRA_CAST(0x0) || + (((GHIDRA_CAST(local_1e4.y) == GHIDRA_CAST(0x1) && ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_2d4)) + 0x1))) != '\0')) || + ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_2d4)) + 0x2))) != '\0')))))) { + pcVar2 = *(code **)(*(*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) + 0x3c); + if (ownerPlayer == GHIDRA_CAST(0x0)) { + (GHIDRA_CAST((&flashColor)))->Color::Reset(); + flashColor._tint[0] = 1.0; + flashColor._tint[1] = 0.0; + flashColor._tint[2] = 0.0; + flashColor._tint[3] = 1.0; + flashColor._offset[0] = 0.0; + flashColor._offset[1] = 0.0; + flashColor._offset[2] = 0.0; + } + else { + (GHIDRA_CAST((GHIDRA_CAST(local_6c))))->Color::Reset(); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_6c)) + 0x0))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_6c)) + 0x4))) = 0.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_6c)) + 0x8))) = 0.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_6c)) + 0xc))) = 1.0; + pvStack_4c = (void *)0x0; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x0))) = (ownerPlayer->_laserColor)._tint[0]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x4))) = (ownerPlayer->_laserColor)._tint[1]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x8))) = (ownerPlayer->_laserColor)._tint[2]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0xc))) = (ownerPlayer->_laserColor)._tint[3]; + pvStack_48 = (void *)0x0; + puStack_44 = GHIDRA_CAST(0x0); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x10))) = (ownerPlayer->_laserColor)._colorize[0]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x14))) = (ownerPlayer->_laserColor)._colorize[1]; + fStack_ac = (ownerPlayer->_laserColor)._colorize[2]; + fStack_a8 = (ownerPlayer->_laserColor)._colorize[3]; + local_a4.x = (ownerPlayer->_laserColor)._offset[0]; + local_a4.y = (ownerPlayer->_laserColor)._offset[1]; + local_9c = GHIDRA_CAST((ownerPlayer->_laserColor)._offset[2]); + (GHIDRA_CAST((GHIDRA_CAST(local_c4))))->Color::__mul(GHIDRA_CAST(local_6c)); + puStack_70 = local_9c; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x0))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x4))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x8))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x8))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0xc))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x10))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x10))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x14))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_c4)) + 0x14))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x18))) = fStack_ac; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x1c))) = fStack_a8; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x20))) = local_a4; + } + rngResult = 1; + uVar6 = 1; + (*pcVar2)(); + pEVar27 = GHIDRA_CAST(local_1e4.y); + if (GHIDRA_CAST(local_1e4.y) == GHIDRA_CAST(0x0)) { + if (0 < local_1d2) { + local_29c = 0x3f800000; + local_298 = GHIDRA_CAST(local_1e4.y); + iVar30 = 0; + do { + fVar23 = fStack_2c4; + fVar25 = fStack_2c0; + FUN_009f4230(local_2ac,iVar30,10,local_29c,local_298,shotSpeed); + fVar26 = atan2f(local_2a4.y,local_2a4.x); + local_264.y = (fVar26 * 57.295776 + local_220.y) * 0.017453292; + local_284 = GHIDRA_CAST(sin(local_264.y)); + pEVar31 = GHIDRA_CAST(0x9fcd6b); + fVar26 = cos(local_264.y); + local_274.y = (float)local_284 * 6.0; + local_274.x = fVar26 * 6.0; + local_24c.x = ownerPos.x + fVar26 * 30.0; + local_24c.y = ownerPos.y + (float)local_284 * 30.0; + Weapon::fire_brimstone_ball + (this,&local_24c,&local_274,GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) + 0x34c)) + ,GHIDRA_UINT(fVar23),GHIDRA_UINT(fVar25),pEVar31); + iVar30 = iVar30 + 1; + } while (iVar30 < local_1d2); + } + pEVar27 = GHIDRA_CAST(local_1e4.y); + } + else { + fVar23 = atan2f(shotDirection.y,shotDirection.x); + fVar23 = fVar23 * 57.295776 + (float)(&DAT_00b81710)[GHIDRA_INT(pEVar27)]; + if (360.0 < ABS(fVar23)) { + fVar23 = fmodf(fVar23,360.0); + } + if (fVar23 <= 180.0) { + if (fVar23 < -180.0) { + fVar23 = fVar23 + 360.0; + } + } + else { + fVar23 = fVar23 - 360.0; + } + local_264.y = fVar23 * 0.017453292; + local_284 = GHIDRA_CAST(sin(local_264.y)); + pEVar31 = GHIDRA_CAST(0x9fd007); + fVar23 = cos(local_264.y); + local_1f0.y = (float)local_284 * 6.0; + local_1f0.x = fVar23 * 6.0; + local_218.x = ownerPos.x + fVar23 * 30.0; + local_218.y = ownerPos.y + (float)local_284 * 30.0; + Weapon::fire_brimstone_ball + (this,&local_218,&local_1f0, + GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT(pEVar27) * 4 + 0x44)) + 0x34c)),uVar6, + rngResult,pEVar31); + } + } + pMVar3 = g_manager; + local_1e4.y = (float)&(*GHIDRA_CAST((GHIDRA_CAST((pEVar27)) + 0x1))); + } while (GHIDRA_UINT(local_1e4.y) < &DAT_00000004); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0x7); + seed_fart_sound_override(GHIDRA_CAST(local_1c4)); + (GHIDRA_CAST((&pMVar3->_sfxManager)))->SoundEffects::Play((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))),0.5,2,0,1.0,0.0); + Weapon::SetBlinkTime(this,0x24,unused); + pfVar18 = extraout_ECX_05; + } + if (((char)isCSection != '\0') && ((float)chargeThreshold <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)))) { + Weapon::update_c_section_charge_anim(this,GHIDRA_INT(pfVar18),2,aimDirection,-1.0); + fVar23 = atan2f(shotDirection.y,shotDirection.x); + local_284 = GHIDRA_CAST((fVar23 * 57.295776)); + local_1f0.y = 0.0; + do { + fVar23 = local_1f0.y; + if (*GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT(local_1f0.y) * 4 + 0x44)) != 0) { + if (local_1f0.y == 0.0) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0x0); + if (0 < local_1d2) { + local_24c.x = 1.0; + local_24c.y = 0.0; + local_298 = GHIDRA_CAST(0x3c23d70a); + do { + FUN_009f4230(local_50,(*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))),10,local_24c.x,local_24c.y,shotSpeed); + fVar23 = atan2f((float)puStack_44,(float)pvStack_48); + local_220.y = (fVar23 * 57.295776 + (float)local_284) * 0.017453292; + local_264.y = sin(local_220.y); + iVar30 = 0x9fd2a2; + fVar23 = cos(local_220.y); + local_2a4.y = local_264.y * 10.0; + local_2a4.x = fVar23 * 10.0; + local_1e4.x = ownerPos.x + fVar23 * 4.0; + local_1e4.y = ownerPos.y + local_264.y * 4.0; + fetusTear = fire_fetus_tear(this,&local_1e4,&local_2a4,0,*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + ,1.0,iVar30); + local_220.y = fetusTear->_fScale * 1.2; + pfVar18 = &local_220.y; + if (local_220.y <= 0.01) { + pfVar18 = GHIDRA_CAST(&local_298); + } + fVar23 = *pfVar18; + fetusTear->_baseScale = fVar23; + fetusTear->_fScale = fVar23; + Entity_Tear::ResetSpriteScale(fetusTear); + fetusTear->_tearRange = fetusTear->_tearRange + fetusTear->_tearRange; + (**(code **)(*GHIDRA_CAST(fetusTear) + 0xc))(); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) + 1; + } while ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_INT(local_1c4))) + 0x0))) < GHIDRA_INT(local_1d2)); + } + } + else if (((local_1f0.y == 1.4013e-45) && ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_2d4)) + 0x1))) != '\0')) || + ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_2d4)) + 0x2))) != '\0')) { + fVar25 = atan2f(shotDirection.y,shotDirection.x); + fVar23 = fVar25 * 57.295776 + (float)(&DAT_00b81710)[GHIDRA_INT(fVar23)]; + if (360.0 < ABS(fVar23)) { + fVar23 = fmodf(fVar23,360.0); + } + if (fVar23 <= 180.0) { + if (fVar23 < -180.0) { + fVar23 = fVar23 + 360.0; + } + } + else { + fVar23 = fVar23 - 360.0; + } + local_220.y = fVar23 * 0.017453292; + local_264.y = sin(local_220.y); + iVar30 = 0x9fd0d2; + fVar23 = cos(local_220.y); + local_274.y = local_264.y * 10.0; + local_274.x = fVar23 * 10.0; + local_218.x = ownerPos.x + fVar23 * 4.0; + local_218.y = ownerPos.y + local_264.y * 4.0; + fetusTear = fire_fetus_tear(this,&local_218,&local_274,0,*GHIDRA_CAST((GHIDRA_CAST(this) + 4)),1.0 + ,iVar30); + local_264.y = 0.01; + local_220.y = fetusTear->_fScale * 1.2; + pVVar9 = &local_220; + if (local_220.y <= 0.01) { + pVVar9 = &local_264; + } + fVar23 = pVVar9->y; + fetusTear->_baseScale = fVar23; + fetusTear->_fScale = fVar23; + Entity_Tear::ResetSpriteScale(fetusTear); + fetusTear->_tearRange = fetusTear->_tearRange + fetusTear->_tearRange; + (**(code **)(*GHIDRA_CAST(fetusTear) + 0xc))(); + } + } + local_1f0.y = (float)(GHIDRA_INT(local_1f0.y) + 1); + } while (GHIDRA_UINT(local_1f0.y) < &DAT_00000004); + } + if ((char)isCursedEye == '\0') { + local_1e4.y = 1.4013e-45; + } + else { + local_1e4.y = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x5c)); + } + fVar23 = 0.0; + EntityList::QuerySublist + (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),GHIDRA_CAST(local_27c),8,1,-1,0,0); + rngResult = (*GHIDRA_CAST((GHIDRA_CAST(&(local_27c)) + 0x4))); + local_8 = 2.8026e-45; + fVar25 = 0.0; + if (local_274.y != 0.0) { + fVar26 = local_274.y; + club = heldClub; + do { + piVar15 = *GHIDRA_CAST((rngResult + GHIDRA_INT(fVar25) * 4)); + if (GHIDRA_CAST(piVar15[0xef]) == club) { + (**(code **)(*piVar15 + 0x28))(); + fVar26 = local_274.y; + club = heldClub; + } + fVar25 = (float)(GHIDRA_INT(fVar25) + 1); + } while (GHIDRA_UINT(fVar25) < GHIDRA_UINT(fVar26)); + this = (void *)ownerVelocityX.y; + } + local_1d8 = GHIDRA_CAST(0x0); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0x0); + do { + owner = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))); + if ((*GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) * 4)) != 0) && + (((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) == GHIDRA_CAST(0x0) || + ((((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) == GHIDRA_CAST(0x1) && ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_2d4)) + 0x1))) != '\0')) + || ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_2d4)) + 0x2))) != '\0')))))) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x4))) = 0.0; + tearBombVariant = 0; + (GHIDRA_CAST((&tearColor)))->Color::Color(); + tearFlags._l = 0; + tearFlags._h = 0; + tearDamage = GHIDRA_CAST(0x40600000); + tearScale = 1.0; + tearHeight = -23.75; + uStack_16c = 0x3f800000; + local_168 = 0x3fd9999a; + local_164 = 1.0; + local_160 = 0.0; + piVar15 = extraout_EDX; + if (ownerPlayer != GHIDRA_CAST(0x0)) { + pEVar31 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x4)))); + uVar6 = Random(); + pTVar7 = Entity_Player::GetTearHitParams + (ownerPlayer,&local_158,10,1.0,(uVar6 & 1) * 2 + -1,pEVar31); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x4))) = pTVar7->_tearVariant; + tearBombVariant = pTVar7->_bombVariant; + if (&tearColor != GHIDRA_CAST(&pTVar7->_tearColor)) { + tearColor._tint[0] = (pTVar7->_tearColor)._tint[0]; + tearColor._tint[1] = (pTVar7->_tearColor)._tint[1]; + tearColor._tint[2] = (pTVar7->_tearColor)._tint[2]; + tearColor._tint[3] = (pTVar7->_tearColor)._tint[3]; + tearColor._colorize[0] = (pTVar7->_tearColor)._colorize[0]; + tearColor._colorize[1] = (pTVar7->_tearColor)._colorize[1]; + tearColor._colorize[2] = (pTVar7->_tearColor)._colorize[2]; + tearColor._colorize[3] = (pTVar7->_tearColor)._colorize[3]; + (*GHIDRA_CAST((GHIDRA_CAST(&(tearColor._offset)) + 0x0))) = *GHIDRA_CAST((pTVar7->_tearColor)._offset); + tearColor._offset[2] = (pTVar7->_tearColor)._offset[2]; + } + tearFlags._l = (pTVar7->_flags)._l; + tearFlags._h = (pTVar7->_flags)._h; + tearDamage = GHIDRA_CAST(pTVar7->_tearDamage); + tearScale = pTVar7->_tearScale; + tearHeight = pTVar7->_tearHeight; + uStack_16c = pTVar7[1]._tearVariant; + local_168 = pTVar7[1]._bombVariant; + local_164 = pTVar7[1]._tearColor._tint[0]; + piVar15 = *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) * 4)); + local_160 = pTVar7[1]._tearColor._tint[1]; + owner = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))); + } + fVar23 = 0.0; + ownerVelocityX.y = damageMultiplier * (float)tearDamage; + pfVar18 = &ownerVelocityX.y; + if ((float)(damageMultiplier * (float)tearDamage) <= (float)local_1d8) { + pfVar18 = GHIDRA_CAST(&local_1d8); + } + local_1d8 = GHIDRA_CAST(*pfVar18); + (**(code **)(*piVar15 + 0x3c))(); + iVar30 = *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + GHIDRA_INT(owner) * 4)); + *GHIDRA_CAST((iVar30 + 0x410)) = (uint32_t)tearFlags._l; + *GHIDRA_CAST((iVar30 + 0x414)) = (*GHIDRA_CAST((GHIDRA_CAST(&(tearFlags._l)) + 0x4))); + *GHIDRA_CAST((iVar30 + 0x418)) = (uint32_t)tearFlags._h; + *GHIDRA_CAST((iVar30 + 0x41c)) = (*GHIDRA_CAST((GHIDRA_CAST(&(tearFlags._h)) + 0x4))); + (**(code **)(**GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + GHIDRA_INT(owner) * 4)) + 0x40))(); + fVar25 = atan2f(shotDirection.y,shotDirection.x); + fVar25 = fVar25 * 57.295776 + (float)(&DAT_00b81710)[GHIDRA_INT(owner)]; + if (360.0 < ABS(fVar25)) { + fVar25 = fmodf(fVar25,360.0); + } + if (fVar25 <= 180.0) { + if (fVar25 < -180.0) { + fVar25 = fVar25 + 360.0; + } + } + else { + fVar25 = fVar25 - 360.0; + } + *GHIDRA_CAST((*GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + GHIDRA_INT(owner) * 4)) + 0x438)) = fVar25 + ; + iVar30 = *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + GHIDRA_INT(owner) * 4)); + *GHIDRA_CAST((iVar30 + 0x4ec)) = SUB42(local_1e4.y,0); + *GHIDRA_CAST((iVar30 + 0x4ee)) = 0; + Entity_Knife::SetAttackAnimation + (*GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + GHIDRA_INT(owner) * 4))); + *GHIDRA_CAST((*GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + GHIDRA_INT(owner) * 4)) + 0x466)) = + isChargeMode == '\0'; + } + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = &(*GHIDRA_CAST((GHIDRA_CAST((owner)) + 0x1))); + } while ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_UINT(local_1c4))) + 0x0))) < GHIDRA_CAST(0x4)); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0x0); + if (0 < local_1d2) { + local_288 = 0x3f800000; + ownerVelocityX.y = (float)(GHIDRA_INT(local_1d2) / 2); + local_284 = GHIDRA_CAST(0x0); + do { + rngResult = (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))); + fVar23 = fStack_2c0; + FUN_009f4230(local_50,(*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))),10,local_288,local_284,shotSpeed); + fVar25 = atan2f((float)puStack_44,(float)pvStack_48); + fVar25 = fVar25 * 57.295776; + local_264.y = fVar25; + if ((float)rngResult == ownerVelocityX.y) { + if (360.0 < ABS(fVar25)) { + fVar25 = fmodf(fVar25,360.0); + } + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = rngResult; + if (fVar25 <= 180.0) { + if (fVar25 < -180.0) { + fVar25 = fVar25 + 360.0; + } + heldClub->_rotationOffset = fVar25; + } + else { + heldClub->_rotationOffset = fVar25 - 360.0; + } + } + else { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x4))) = 0.0; + tearBombVariant = 0; + pEVar31 = GHIDRA_CAST(0x9fd86a); + (GHIDRA_CAST((&tearColor)))->Color::Color(); + tearFlags._l = 0; + tearFlags._h = 0; + tearDamage = GHIDRA_CAST(0x40600000); + tearScale = 1.0; + tearHeight = -23.75; + uStack_16c = 0x3f800000; + local_168 = 0x3fd9999a; + local_164 = 1.0; + local_160 = 0.0; + if (ownerPlayer != GHIDRA_CAST(0x0)) { + pEVar31 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x4)))); + uVar6 = Random(); + fVar23 = (float)((uVar6 & 1) * 2 - 1); + pTVar7 = Entity_Player::GetTearHitParams + (ownerPlayer,&local_158,10,1.0,GHIDRA_INT(fVar23),pEVar31); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x4))) = pTVar7->_tearVariant; + tearBombVariant = pTVar7->_bombVariant; + if (&tearColor != GHIDRA_CAST(&pTVar7->_tearColor)) { + tearColor._tint[0] = (pTVar7->_tearColor)._tint[0]; + tearColor._tint[1] = (pTVar7->_tearColor)._tint[1]; + tearColor._tint[2] = (pTVar7->_tearColor)._tint[2]; + tearColor._tint[3] = (pTVar7->_tearColor)._tint[3]; + tearColor._colorize[0] = (pTVar7->_tearColor)._colorize[0]; + tearColor._colorize[1] = (pTVar7->_tearColor)._colorize[1]; + tearColor._colorize[2] = (pTVar7->_tearColor)._colorize[2]; + tearColor._colorize[3] = (pTVar7->_tearColor)._colorize[3]; + (*GHIDRA_CAST((GHIDRA_CAST(&(tearColor._offset)) + 0x0))) = *GHIDRA_CAST((pTVar7->_tearColor)._offset); + tearColor._offset[2] = (pTVar7->_tearColor)._offset[2]; + } + tearFlags._l = (pTVar7->_flags)._l; + tearFlags._h = (pTVar7->_flags)._h; + tearDamage = GHIDRA_CAST(pTVar7->_tearDamage); + tearScale = pTVar7->_tearScale; + tearHeight = pTVar7->_tearHeight; + uStack_16c = pTVar7[1]._tearVariant; + local_168 = pTVar7[1]._bombVariant; + local_164 = pTVar7[1]._tearColor._tint[0]; + local_160 = pTVar7[1]._tearColor._tint[1]; + } + local_220.y = damageMultiplier * (float)tearDamage; + pfVar18 = &local_220.y; + if (damageMultiplier * (float)tearDamage <= (float)local_1d8) { + pfVar18 = GHIDRA_CAST(&local_1d8); + } + local_1d8 = GHIDRA_CAST(*pfVar18); + club = Weapon::fire_bone_club + (this,GHIDRA_CAST(heldClub),GHIDRA_UINT(local_200),0,GHIDRA_INT(fVar23),GHIDRA_INT(pEVar31), + local_264.y); + fVar23 = 0.0; + (**(code **)(*GHIDRA_CAST(club) + 0x3c))(); + iVar30 = *GHIDRA_CAST(club); + *GHIDRA_CAST(&(club->_tearFlags)._l) = (uint32_t)tearFlags._l; + *GHIDRA_CAST((GHIDRA_INT(&(club->_tearFlags)._l) + 4)) = (*GHIDRA_CAST((GHIDRA_CAST(&(tearFlags._l)) + 0x4))); + *GHIDRA_CAST(&(club->_tearFlags)._h) = (uint32_t)tearFlags._h; + *GHIDRA_CAST((GHIDRA_INT(&(club->_tearFlags)._h) + 4)) = (*GHIDRA_CAST((GHIDRA_CAST(&(tearFlags._h)) + 0x4))); + (**(code **)(iVar30 + 0x40))(); + (club->_sprite)._scale.x = (heldClub->_sprite)._scale.x; + (club->_sprite)._scale.y = (heldClub->_sprite)._scale.y; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((club)) + 0x4ec)))) = SUB42(local_1e4.y,0); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((club)) + 0x4ee)))) = 0; + Entity_Knife::SetAttackAnimation(club); + (**(code **)(*GHIDRA_CAST(club) + 0xc))(); + } + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = &((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0)))(*GHIDRA_CAST((GHIDRA_CAST(()))) + 0x1)); + } while ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_INT(local_1c4))) + 0x0))) < GHIDRA_INT(local_1d2)); + } + for ((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_UINT(local_208) & 0xffff; + (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) != GHIDRA_CAST(0x0); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = &(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0)))(*GHIDRA_CAST((GHIDRA_CAST(( + -0x2f00))))) + 0x2eff)))) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x4))) = 0.0; + tearBombVariant = 0; + (GHIDRA_CAST((&tearColor)))->Color::Color(); + tearFlags._l = 0; + tearFlags._h = 0; + tearDamage = GHIDRA_CAST(0x40600000); + tearScale = 1.0; + tearHeight = -23.75; + uStack_16c = 0x3f800000; + local_168 = 0x3fd9999a; + local_164 = 1.0; + local_160 = 0.0; + if (ownerPlayer != GHIDRA_CAST(0x0)) { + pEVar31 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x4)))); + uVar6 = Random(); + fVar23 = (float)((uVar6 & 1) * 2 - 1); + pTVar7 = Entity_Player::GetTearHitParams(ownerPlayer,&local_158,10,1.0,GHIDRA_INT(fVar23),pEVar31); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x4))) = pTVar7->_tearVariant; + tearBombVariant = pTVar7->_bombVariant; + if (&tearColor != GHIDRA_CAST(&pTVar7->_tearColor)) { + tearColor._tint[0] = (pTVar7->_tearColor)._tint[0]; + tearColor._tint[1] = (pTVar7->_tearColor)._tint[1]; + tearColor._tint[2] = (pTVar7->_tearColor)._tint[2]; + tearColor._tint[3] = (pTVar7->_tearColor)._tint[3]; + tearColor._colorize[0] = (pTVar7->_tearColor)._colorize[0]; + tearColor._colorize[1] = (pTVar7->_tearColor)._colorize[1]; + tearColor._colorize[2] = (pTVar7->_tearColor)._colorize[2]; + tearColor._colorize[3] = (pTVar7->_tearColor)._colorize[3]; + (*GHIDRA_CAST((GHIDRA_CAST(&(tearColor._offset)) + 0x0))) = *GHIDRA_CAST((pTVar7->_tearColor)._offset); + tearColor._offset[2] = (pTVar7->_tearColor)._offset[2]; + } + tearFlags._l = (pTVar7->_flags)._l; + tearFlags._h = (pTVar7->_flags)._h; + tearDamage = GHIDRA_CAST(pTVar7->_tearDamage); + tearScale = pTVar7->_tearScale; + tearHeight = pTVar7->_tearHeight; + uStack_16c = pTVar7[1]._tearVariant; + local_168 = pTVar7[1]._bombVariant; + local_164 = pTVar7[1]._tearColor._tint[0]; + local_160 = pTVar7[1]._tearColor._tint[1]; + } + ownerVelocityX.y = damageMultiplier * (float)tearDamage; + pfVar18 = &ownerVelocityX.y; + if ((float)(damageMultiplier * (float)tearDamage) <= (float)local_1d8) { + pfVar18 = GHIDRA_CAST(&local_1d8); + } + local_1d8 = GHIDRA_CAST(*pfVar18); + iVar30 = 0x9fdc3d; + uVar6 = Random(); + club = Weapon::fire_bone_club + (this,GHIDRA_CAST(heldClub),GHIDRA_UINT(local_200),0,GHIDRA_INT(fVar23),iVar30, + (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) + * 2.3283064e-10 * 360.0); + fVar23 = 0.0; + (**(code **)(*GHIDRA_CAST(club) + 0x3c))(); + iVar30 = *GHIDRA_CAST(club); + *GHIDRA_CAST(&(club->_tearFlags)._l) = (uint32_t)tearFlags._l; + *GHIDRA_CAST((GHIDRA_INT(&(club->_tearFlags)._l) + 4)) = (*GHIDRA_CAST((GHIDRA_CAST(&(tearFlags._l)) + 0x4))); + *GHIDRA_CAST(&(club->_tearFlags)._h) = (uint32_t)tearFlags._h; + *GHIDRA_CAST((GHIDRA_INT(&(club->_tearFlags)._h) + 4)) = (*GHIDRA_CAST((GHIDRA_CAST(&(tearFlags._h)) + 0x4))); + (**(code **)(iVar30 + 0x40))(); + (club->_sprite)._scale.x = (heldClub->_sprite)._scale.x; + (club->_sprite)._scale.y = (heldClub->_sprite)._scale.y; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((club)) + 0x4ec)))) = SUB42(local_1e4.y,0); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((club)) + 0x4ee)))) = 0; + Entity_Knife::SetAttackAnimation(club); + (**(code **)(*GHIDRA_CAST(club) + 0xc))(); + } + uVar6 = Random(); + pMVar3 = g_manager; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0xfc); + local_238.y = ((float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * + 2.3283064e-10 * 0.2 + 0.9) * local_238.y; + seed_fart_sound_override(GHIDRA_CAST(local_1c4)); + (GHIDRA_CAST((&pMVar3->_sfxManager)))->SoundEffects::Play((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))),1.0,1,0,local_238.y,0.0); + if ((20.0 < (float)local_1d8) && (1.5 < (float)clubScale)) { + Game::ShakeScreen(g_game,GHIDRA_INT(((float)clubScale * 5.0))); + } + if (isChargeMode == '\0') { + owner = GHIDRA_CAST(0x3f800000); + if (isReleased == '\0') goto LAB_009fde0f; + if ((GHIDRA_CAST(this))->_pendingDamage <= 1.0 && + (GHIDRA_CAST(this))->_pendingDamage != 1.0) { + (GHIDRA_CAST(this))->_pendingDamage = 1.0; + } + } + else { + owner = GHIDRA_CAST(0x0); +LAB_009fde0f: + newCharge = owner; + } + *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + 0x18)) = 0; + (GHIDRA_CAST(this))->_index = GHIDRA_INT(g_vectorZero.x); + (GHIDRA_CAST(this))->_collisionIndex = GHIDRA_INT(g_vectorZero.y); + if ((char)isCursedEye != '\0') { + owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x4)))); + if (((owner == GHIDRA_CAST(0x0)) || (pEVar19 = owner, owner->_type != 1)) && + ((pEVar19 = GHIDRA_CAST(0x0), owner != GHIDRA_CAST(0x0) && (owner->_type == 3)))) { + owner->_chargeBarSprites[5]._numEvents = 0; + } + else if (pEVar19 != GHIDRA_CAST(0x0)) { + Entity_Player::stop_costume_item_anims(pEVar19); + } + } + pEVar19 = player; + if (player != GHIDRA_CAST(0x0)) { + Entity_Player::TryForgottenThrow(player,&shotDirection); + } + if (local_27c[0] == '\0') { + local_8 = 4.2039e-45; + tracked_alloc(1,(*GHIDRA_CAST((GHIDRA_CAST(&((void *)local_27c)) + 0x4))),0); + } + local_8 = -NAN; + iVar30 = GHIDRA_UINT(local_1c6) << 8; + pfVar18 = &(GHIDRA_CAST(this))->_pendingDamage; +LAB_009fdeca: + owner = newCharge; + if ((char)(GHIDRA_UINT(iVar30) >> 8) == '\0') goto LAB_009fb9ec; + } + owner = newCharge; + if (weaponType == 0xb) goto LAB_009fb9ec; + if (((heldClub->_isSwinging != 0) && (isReleased == '\0')) || (*pfVar18 < 1.0)) { + club = heldClub; + goto LAB_009fb9f2; + } + (GHIDRA_CAST((GHIDRA_CAST(clubFlashColor))))->Color::Reset(); + pfVar18 = &local_258.y; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x0))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x4))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x8))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0xc))) = (void *)0x0; + local_238.y = 1.001; + owner = GHIDRA_CAST(((float)newCharge + 1.0)); + clampedValue = &local_238.y; + if (1.001 <= (float)maxCharge) { + clampedValue = pfVar18; + } + newCharge = GHIDRA_CAST(*clampedValue); + if ((float)owner <= (float)newCharge) { + newCharge = owner; + } + if (pEVar19 == GHIDRA_CAST(0x0)) goto LAB_009fe321; + pfVar18 = GHIDRA_CAST(CONCAT31((int3)(GHIDRA_UINT(pfVar18) >> 8),isEpicFetus)); + if ((isDrFetus != '\0') || (isEpicFetus != '\0')) { + heldEntitySlot = &pEVar19->_heldEntity; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = heldEntitySlot; + if (*heldEntitySlot == (void *)0x0) { + if (isChargeMode == '\0') { + fVar23 = 1.0; + } + else { + fVar23 = (float)maxCharge - 30.0; + if (fVar23 <= 2.0) { + fVar23 = 2.0; + } + } + if ((GHIDRA_CAST(this))->_pendingDamage == fVar23) { + if (isEpicFetus == '\0') { + local_274.x = (player->_pos).x; + local_274.y = (player->_pos).y; + pEVar27 = Weapon::fire_bomb(this,&local_274,&g_vectorZero); + if (*(*GHIDRA_CAST((GHIDRA_CAST(&((void **)local_1c4)) + 0x0))) != (void *)0x0) { + local_258.y = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))); + msvc::multiset::erase(); + } + *(*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) = pEVar27; + if (pEVar27 != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + } + savedBombFlags = pEVar27->_flags; + bombFlagsHigh = GHIDRA_CAST((GHIDRA_INT(&pEVar27->_flags) + 4)); + *bombFlagsHigh = *bombFlagsHigh | 0x2000020; + *GHIDRA_CAST(&pEVar27->_flags) = GHIDRA_INT(savedBombFlags); + pEVar27->_explosionCountdown1 = 0x2d; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pEVar27)) + 0x414)))) = 0x2d; + pEVar27->_entityCollisionClass = 0; + pEVar27->_entityGridCollisionClass = 0; + pEVar27->_visible = 0; + fVar23 = atan2f(shotDirection.y,shotDirection.x); + pEVar27->_rocketAngle = fVar23 * 57.295776; + if ((pEVar27->_variant == 0x13) || (pEVar27->_variant == 0x14)) { + ANM2::Play(&pEVar27->_sprite,s_Idle,0); + (pEVar27->_sprite)._rotation = 0.0; + } + } + else { + uVar6 = Random(); + local_274.x = (player->_pos).x; + local_274.y = (player->_pos).y; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = + Game::Spawn(g_game,1000,0x76,&local_274,&g_vectorZero, + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x4)))),0,uVar6); + if (*heldEntitySlot != (void *)0x0) { + local_258.y = (float)heldEntitySlot; + msvc::multiset::erase(); + } + *heldEntitySlot = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)local_1c4)) + 0x0))); + if ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))) != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + } + savedBombFlags = ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))))->_flags; + bombFlagsHigh = GHIDRA_CAST((GHIDRA_INT(&((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))))->_flags) + 4)); + *bombFlagsHigh = *bombFlagsHigh | 0x20; + ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))))->_visible = 0; + *GHIDRA_CAST(&((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_1c4))) + 0x0))))->_flags) = GHIDRA_INT(savedBombFlags); + } + pMVar3 = g_manager; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = GHIDRA_CAST(0xc9); + seed_fart_sound_override(GHIDRA_CAST(local_1c4)); + (GHIDRA_CAST((&pMVar3->_sfxManager)))->SoundEffects::Play((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))),1.0,2,0,1.0,0.0); + pfVar18 = extraout_ECX_06; + } + } + pEVar19 = player; + } + pvVar17 = pEVar19->_heldEntity; + if (pvVar17 == (void *)0x0) goto LAB_009fe321; + fVar23 = (pEVar19->_pos).y; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x33c)) = (pEVar19->_pos).x; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x340)) = fVar23; + pvVar17 = pEVar19->_heldEntity; + fVar23 = (pEVar19->_velocity).y; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x360)) = (pEVar19->_velocity).x; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x364)) = fVar23; + switch(pEVar19->_headDirection) { + case 0: + fVar23 = (pEVar19->_sprite)._scale.x * 8.0; + break; + case 1: + fVar23 = (pEVar19->_sprite)._scale.x * -12.0; + goto LAB_009fe24e; + case 2: + fVar23 = (pEVar19->_sprite)._scale.x * -8.0; +LAB_009fe24e: + fVar25 = (pEVar19->_sprite)._scale.y; + pvVar17 = pEVar19->_heldEntity; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x34c)) = fVar23; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x350)) = fVar25 * -4.0; + *GHIDRA_CAST((GHIDRA_CAST(pEVar19->_heldEntity) + 0x354)) = 0xffffffff; + goto LAB_009fe2f0; + default: + fVar23 = (pEVar19->_sprite)._scale.x * 12.0; + } + fVar25 = (pEVar19->_sprite)._scale.y; + pvVar17 = pEVar19->_heldEntity; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x34c)) = fVar23; + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x350)) = fVar25 * -4.0; + *GHIDRA_CAST((GHIDRA_CAST(pEVar19->_heldEntity) + 0x354)) = 0; +LAB_009fe2f0: + pvVar17 = pEVar19->_heldEntity; + if (*GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x28)) == 4) { + fVar23 = atan2f(shotDirection.y,shotDirection.x); + *GHIDRA_CAST((GHIDRA_CAST(pvVar17) + 0x428)) = fVar23 * 57.295776; + pfVar18 = extraout_ECX_07; + } +LAB_009fe321: + club = heldClub; + if ((char)isCursedEye == '\0') { + if (isChocolateMilk != 0) goto LAB_009fe472; + if ((char)isBrimstone != '\0') goto LAB_009fe5d9; + if ((float)maxCharge <= (GHIDRA_CAST(this))->_pendingDamage) { + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0xc))) = (void *)0x3f800000; + VStack_20.x = 0.2; + VStack_20.y = 0.2; + puStack_18 = GHIDRA_CAST(0x3e4ccccd); + (GHIDRA_CAST((GHIDRA_CAST(clubFlashColor))))->Color::__mul(&heldClub->_color); + pfVar18 = extraout_ECX_08; + } + } + else { + if ((float)maxCharge < (GHIDRA_CAST(this))->_pendingDamage || + (float)maxCharge == (GHIDRA_CAST(this))->_pendingDamage) { + Weapon::UpdateHeadChargeAnimation(this,0x13c,1,&shotDirection,-1.0); + club = heldClub; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0xc))) = (void *)0x3f800000; + VStack_20.x = 0.2; + VStack_20.y = 0.2; + puStack_18 = GHIDRA_CAST(0x3e4ccccd); + (GHIDRA_CAST((GHIDRA_CAST(clubFlashColor))))->Color::__mul(&heldClub->_color); + iVar30 = extraout_ECX_10; + } + else { + Weapon::UpdateHeadChargeAnimation(this,0x13c,0,&shotDirection,0.0); + iVar30 = extraout_ECX_09; + club = heldClub; + } + Weapon::SetBlinkTime(this,1,iVar30); + uVar6 = GHIDRA_UINT((((float)newCharge * 5.0) / (float)maxCharge)); + *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + 0x18)) = uVar6; + if ((1.0 < (float)newCharge) && (uVar6 == 0)) { + *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + 0x18)) = 1; + } + pfVar18 = extraout_ECX_11; + if (isChocolateMilk != 0) { +LAB_009fe472: + fVar23 = (GHIDRA_CAST(this))->_pendingDamage; + if ((float)maxCharge <= fVar23) { + puVar22 = &DAT_bf800000; + } + else { + puVar22 = GHIDRA_CAST(((fVar23 / (float)maxCharge) * 18.0)); + } + Weapon::UpdateHeadChargeAnimation + (this,0x45,GHIDRA_UINT(((float)maxCharge <= fVar23)),&shotDirection,(float)puVar22); + Weapon::SetBlinkTime(this,1,unused_00); + fVar25 = ((float)newCharge / (float)maxFireDelay - 1.0) * 0.5 + 1.0; + fVar23 = 1.0; + if (1.0 <= fVar25) { + fVar23 = fVar25; + } + fVar23 = fVar23 * (float)clubScale; + fVar25 = fVar23; + if ((heldClub->_isSwinging != 0) && (fVar25 = (heldClub->_sprite)._scale.x, fVar25 <= fVar23)) + { + fVar25 = fVar23; + } + iVar30 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44)))); + if (iVar30 != 0) { + fVar23 = fVar25 * g_vectorOne.y; + *GHIDRA_CAST((iVar30 + 0xe4)) = fVar25 * g_vectorOne.x; + *GHIDRA_CAST((iVar30 + 0xe8)) = fVar23; + } + iVar30 = *GHIDRA_CAST(((GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + 4)))->_filename)._buf); + if (iVar30 != 0) { + fVar23 = fVar25 * g_vectorOne.y; + *GHIDRA_CAST((iVar30 + 0xe4)) = fVar25 * g_vectorOne.x; + *GHIDRA_CAST((iVar30 + 0xe8)) = fVar23; + } + iVar30 = *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + 8)); + if (iVar30 != 0) { + fVar23 = fVar25 * g_vectorOne.y; + *GHIDRA_CAST((iVar30 + 0xe4)) = fVar25 * g_vectorOne.x; + *GHIDRA_CAST((iVar30 + 0xe8)) = fVar23; + } + iVar30 = *GHIDRA_CAST((&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x44))) + 0xc)); + pfVar18 = extraout_ECX_12; + club = heldClub; + if (iVar30 != 0) { + fVar23 = fVar25 * g_vectorOne.y; + *GHIDRA_CAST((iVar30 + 0xe4)) = fVar25 * g_vectorOne.x; + *GHIDRA_CAST((iVar30 + 0xe8)) = fVar23; + } + } + if ((char)isBrimstone != '\0') { +LAB_009fe5d9: + if ((float)chargeThreshold <= (GHIDRA_CAST(this))->_pendingDamage) { + Weapon::UpdateHeadChargeAnimation(this,0x76,1,&shotDirection,-1.0); + owner = ownerPlayer; + (GHIDRA_CAST((GHIDRA_CAST(chargeColor))))->Color::Reset(); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x0))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x4))) = 0.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x8))) = 0.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0xc))) = (void *)0x3f800000; + if (owner != GHIDRA_CAST(0x0)) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x0))) = (owner->_laserColor)._tint[0]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x4))) = (owner->_laserColor)._tint[1]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x8))) = (owner->_laserColor)._tint[2]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0xc))) = (owner->_laserColor)._tint[3]; + local_2d0 = GHIDRA_CAST((owner->_laserColor)._offset[2]); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x10))) = (owner->_laserColor)._colorize[0]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x14))) = (owner->_laserColor)._colorize[1]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x18))) = (owner->_laserColor)._colorize[2]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x1c))) = (owner->_laserColor)._colorize[3]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x20))) = (owner->_laserColor)._offset[0]; + uStack_2d4 = (owner->_laserColor)._offset[1]; + (GHIDRA_CAST((GHIDRA_CAST(local_2f8))))->Color::__mul(GHIDRA_CAST(chargeColor)); + puStack_70 = local_2d0; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x0))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x4))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x8))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x8))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0xc))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x10))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x10))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x14))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x14))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x18))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x18))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x1c))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x1c))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x20))) = (*GHIDRA_CAST((GHIDRA_CAST(&(local_2f8)) + 0x20))); + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x24))) = uStack_2d4; + } + club = heldClub; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x0))); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x4))); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x8))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x8))); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0xc))); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x10))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x10))); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x14))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x14))); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x18))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x18))); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x1c))) = (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x1c))); + VStack_20.x = (*GHIDRA_CAST((GHIDRA_CAST(&((float)chargeColor)) + 0x20))); + VStack_20.y = (*GHIDRA_CAST((GHIDRA_CAST(&((float)chargeColor)) + 0x24))); + puStack_18 = puStack_70; + iVar30 = Entity::GetIntervalTicks(GHIDRA_CAST(heldClub),2.0,0.0); + unused_01 = extraout_ECX_14; + if (iVar30 != 0) { + unused_01 = extraout_ECX_14; + if ((club->_sprite)._animState._animData != (void *)0x0) { + pfVar18 = AnimationState::GetNullFrameById(&(club->_sprite)._animState,0); + unused_01 = extraout_ECX_15; + if (pfVar18 != GHIDRA_CAST(0x0)) { + local_238.y = *pfVar18 / 0.65; + local_1e4.y = pfVar18[1] / 0.65; + local_258.y = (club->_sprite)._rotation * 0.017453292; + ownerVelocityX.y = cos(local_258.y); + fVar23 = sin(local_258.y); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = (local_238.y * ownerVelocityX.y - local_1e4.y * fVar23) * 1.2; + local_1e4.y = (local_1e4.y * ownerVelocityX.y + local_238.y * fVar23) * 1.2; + local_258.y = cos(1.5707964); + fVar23 = sin(1.5707964); + local_200 = (Entity_Player *) + (local_258.y * (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) - local_1e4.y * fVar23); + local_1f0.y = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) * fVar23 + local_258.y * local_1e4.y; + fVar23 = sqrtf((float)local_200 * (float)local_200 + local_1f0.y * local_1f0.y); + if (0.0 < fVar23) { + local_200 = GHIDRA_CAST(((float)local_200 * (1.0 / fVar23))); + local_1f0.y = local_1f0.y * (1.0 / fVar23); + } + local_238.y = (club->_sprite)._scale.y; + uVar6 = Random(); + local_258.y = (float)((double)GHIDRA_INT(uVar6) + + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * 2.3283064e-10; + ownerVelocityX.y = (club->_pos).x; + local_220.y = (club->_pos).y; + uVar6 = Random(); + fVar23 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * + 2.3283064e-10; + local_264.x = fVar23 * (float)local_200 * local_258.y * local_238.y * 10.0 + + local_258.y * (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0))) + ownerVelocityX.y; + local_264.y = fVar23 * local_1f0.y * local_258.y * local_238.y * 10.0 + + local_258.y * local_1e4.y + local_220.y; + local_238.y = (float)Random(); + iVar30 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(this)))) + 0x4)))); + pVVar9 = &ownerVelocityX; + if (iVar30 == 0) { + local_274.x = g_vectorZero.x; + local_274.y = g_vectorZero.y; + pVVar9 = &local_274; + } + else { + ownerVelocityX.x = *GHIDRA_CAST((iVar30 + 0x360)); + ownerVelocityX.y = *GHIDRA_CAST((iVar30 + 0x364)); + } + uVar6 = Random(); + fVar23 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_1c4)) + 0x0))) = fVar23 + fVar23; + uVar6 = Random(); + local_200 = (Entity_Player *) + ((float)((double)GHIDRA_INT(uVar6) + + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * 2.3283064e-10); + fVar23 = cos((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))); + local_258.y = fVar23 * (float)local_200; + fVar23 = sin((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_1c4)) + 0x0)))); + local_258.x = local_258.y + local_258.y + pVVar9->x * 0.2 + 0.0; + local_258.y = (fVar23 * (float)local_200 + fVar23 * (float)local_200 + pVVar9->y * 0.2 + ) - 1.0; + pEVar31 = Game::Spawn(g_game,1000,0x6f,&local_264,&local_258,GHIDRA_CAST(0x0),0, + GHIDRA_UINT(local_238.y)); + if (ownerPlayer != GHIDRA_CAST(0x0)) { + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x0))) = (ownerPlayer->_laserColor)._tint[0]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x4))) = (ownerPlayer->_laserColor)._tint[1]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x8))) = (ownerPlayer->_laserColor)._tint[2]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0xc))) = (ownerPlayer->_laserColor)._tint[3]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x10))) = (ownerPlayer->_laserColor)._colorize[0]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x14))) = (ownerPlayer->_laserColor)._colorize[1]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x18))) = (ownerPlayer->_laserColor)._colorize[2]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x1c))) = (ownerPlayer->_laserColor)._colorize[3]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x20))) = (ownerPlayer->_laserColor)._offset[0]; + (*GHIDRA_CAST((GHIDRA_CAST(&(chargeColor)) + 0x24))) = (ownerPlayer->_laserColor)._offset[1]; + puStack_70 = GHIDRA_CAST((ownerPlayer->_laserColor)._offset[2]); + (**(code **)(*GHIDRA_CAST(pEVar31) + 0x3c))(); + } + uVar6 = Random(); + fVar25 = (float)((double)GHIDRA_INT(uVar6) + __uint_to_double_fixup[-(GHIDRA_INT(uVar6) >> 0x1f)]) * + 2.3283064e-10 * 0.3 + 0.3; + fVar23 = (heldClub->_sprite)._scale.x; + (pEVar31->_sprite)._scale.y = fVar25 * (heldClub->_sprite)._scale.y; + (pEVar31->_sprite)._scale.x = fVar25 * fVar23; + (pEVar31->_posOffset).x = (heldClub->_posOffset).x; + (pEVar31->_posOffset).y = (heldClub->_posOffset).y; + pEVar31->_renderDepthOffset = -100.0; + unused_01 = heldClub; + club = heldClub; + } + } + } + } + else { + Weapon::UpdateHeadChargeAnimation + (this,0x76,0,&shotDirection, + ((GHIDRA_CAST(this))->_pendingDamage / (float)chargeThreshold) * 18.0); + unused_01 = extraout_ECX_13; + } + Weapon::SetBlinkTime(this,1,GHIDRA_INT(unused_01)); + pfVar18 = extraout_ECX_16; + } + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_250)) + 0x0))) != '\0') { + if ((float)chargeThreshold <= (GHIDRA_CAST(this))->_pendingDamage) { + Weapon::UpdateHeadChargeAnimation(this,0xe5,1,&shotDirection,-1.0); + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x0))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x4))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0x8))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(clubFlashColor)) + 0xc))) = (void *)0x3f800000; + VStack_20.x = 0.2; + VStack_20.y = 0.2; + puStack_18 = GHIDRA_CAST(0x3e4ccccd); + (GHIDRA_CAST((GHIDRA_CAST(clubFlashColor))))->Color::__mul(&club->_color); + iVar30 = extraout_ECX_18; + } + else { + Weapon::UpdateHeadChargeAnimation + (this,0xe5,0,&shotDirection, + ((GHIDRA_CAST(this))->_pendingDamage / (float)chargeThreshold) * 18.0); + iVar30 = extraout_ECX_17; + } + Weapon::SetBlinkTime(this,1,iVar30); + pfVar18 = extraout_ECX_19; + } + if ((char)isCSection != '\0') { + local_258.y = (GHIDRA_CAST(this))->_pendingDamage; + if ((float)chargeThreshold <= local_258.y) { + puVar22 = &DAT_bf800000; + iVar30 = 1; +LAB_009fece6: + Weapon::update_c_section_charge_anim(this,GHIDRA_INT(pfVar18),iVar30,aimDirection,(float)puVar22); + pfVar18 = extraout_ECX_21; + } + else { + bVar4 = Weapon::is_c_section_anim_finished(this,GHIDRA_INT(pfVar18)); + pfVar18 = extraout_ECX_20; + if (bVar4 != 0) { + puVar22 = GHIDRA_CAST(((local_258.y / (float)chargeThreshold) * 18.0)); + iVar30 = 0; + goto LAB_009fece6; + } + } + Weapon::SetBlinkTime(this,1,GHIDRA_INT(pfVar18)); + } + iVar30 = Entity::GetIntervalTicks(GHIDRA_CAST(club),4.0,0.0); + if ((iVar30 != 0) && (0.0 < (*GHIDRA_CAST((GHIDRA_CAST(&((float)clubFlashColor)) + 0xc))))) { + (**(code **)(*GHIDRA_CAST(club) + 0x3c))(); + } + pVVar9 = Weapon::get_aim_direction(this,&local_274,&shotDirection); + (GHIDRA_CAST(this))->_index = GHIDRA_INT(pVVar9->x); + (GHIDRA_CAST(this))->_collisionIndex = GHIDRA_INT(pVVar9->y); + owner = newCharge; +LAB_009fb9f2: + if (club->_isFlying != 0) { + Weapon::SetHeadLockTime(this,2); + } + (GHIDRA_CAST(this))->_pendingDamage = (float)owner; + ExceptionList = local_10; + return; +} + // 009fed90 void Weapon_Bone::Reset() { @@ -85,7 +2503,7 @@ long double Weapon_Bone::GetMaxCharge() } // 009fef20 -void Weapon_Bone::guard_check_icall() +void Weapon_Bone::TriggerNewRoom() { uint8_t bVar1; uint8_t *pbVar2; @@ -220,11 +2638,11 @@ void Weapon_Bone::init_club(int *param_1) (**(code **)(GHIDRA_CAST(local_4c._l) + 0x40))(); return; } - pCVar3 = (GHIDRA_CAST((in_ECX)))->Weapon::get_tear_color(&tearColor); + pCVar3 = Weapon::get_tear_color(in_ECX,&tearColor); this = GHIDRA_CAST(0xff); iVar5 = -1; (**(code **)(GHIDRA_CAST(local_4c._l) + 0x3c))(pCVar3,0xffffffff,0xff,0); - tearFlags = (GHIDRA_CAST((in_ECX)))->Weapon::get_owner_tear_flags(GHIDRA_CAST((local_50 + -0xc))); + tearFlags = Weapon::get_owner_tear_flags(in_ECX,GHIDRA_CAST((local_50 + -0xc))); iVar4 = *GHIDRA_CAST((GHIDRA_INT(&tearFlags->_l) + 4)); qVar2 = tearFlags->_h; iVar1 = *GHIDRA_CAST((GHIDRA_INT(&tearFlags->_h) + 4)); @@ -233,7 +2651,7 @@ void Weapon_Bone::init_club(int *param_1) param_1[0x106] = GHIDRA_INT(qVar2); param_1[0x107] = iVar1; setDamageFn = *(code **)(*param_1 + 0x40); - damage = this->Weapon::get_damage(); + damage = Weapon::get_damage(this); (*setDamageFn)(damage); if ((*GHIDRA_CAST((iVar5 + 0x34)) >> 7 & 1) == 0) { iVar4 = 0x40400000; @@ -254,7 +2672,7 @@ uint8_t Weapon_Bone::CanTriggerCursedEyeTeleport() if (((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x30)) != 0xb) && (iVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)), iVar1 != 0)) && (*GHIDRA_CAST((iVar1 + 0x28)) == 1)) { if ((*GHIDRA_CAST((iVar1 + 0x140c)) != 0) && - (iVar1 = this->GetMarkedTargetVariant(), iVar1 != 0)) { + (iVar1 = this->GetFocusEntity(), iVar1 != 0)) { return 0; } if (0.0 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14))) { diff --git a/generated-src/weapon_brimstone.cpp b/generated-src/weapon_brimstone.cpp index 3833448..b0c4b12 100644 --- a/generated-src/weapon_brimstone.cpp +++ b/generated-src/weapon_brimstone.cpp @@ -6,6 +6,1090 @@ uint32_t Weapon_Brimstone::GetMainEntity() return this->_mainLaser; } +// 009ff360 +void Weapon_Brimstone::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + int *piVar1; + uint8_t bVar2; + uint8_t bVar3; + char cVar8; + undefined3 extraout_var; + float *pfVar4; + uint16_t uVar9; + uint32_t uVar5; + Vector *pVVar6; + uint32_t uVar7; + std_string *str; + Vector *aimDirection; + int ownerAsPlayer; + ItemConfig_Item *item; + Entity_Laser *laser; + float *extraout_EAX; + uint8_t *extraout_ECX; + Entity_Player *pEVar10; + uint3 uVar13; + uint32_t extraout_ECX_00; + int extraout_ECX_01; + int extraout_ECX_02; + int unused; + void *pvVar11; + int unusedCollectibleId; + int unusedCollectibleId_00; + int extraout_ECX_03; + int extraout_ECX_04; + int unusedCollectibleId_01; + int extraout_ECX_05; + int extraout_ECX_06; + int unusedCollectibleId_02; + int unused_00; + int unusedCollectibleId_03; + Entity_Player *ownerPlayer; + uint8_t *extraout_ECX_07; + uint8_t *puVar12; + int iVar14; + uint32_t uVar15; + ANM2 *sprite; + Entity *this_00; + bool bVar16; + long double fVar17; + float fVar18; + Entity_Player *pEVar19; + float fVar20; + uint32_t *puVar21; + uint32_t multiShotParams; + uint32_t uStack_d4; + uint32_t uStack_d0; + uint32_t uStack_cc; + uint32_t local_c8; + uint32_t uStack_c4; + uint32_t uStack_c0; + uint32_t uStack_bc; + uint32_t local_b8; + Vector local_b4; + Vector local_ac; + Vector local_a4; + Vector leftDirX; + uint32_t isCSection; + Vector local_90; + char isHasMarked; + Vector backDirX; + char isHasBrimstone; + uint32_t local_78; + Vector *shootDirection; + uint32_t local_70; + Entity_Player *local_6c; + uint8_t isChocolateMilk; + char local_65; + Entity_Player *local_64; + Vector local_60; + Vector local_58; + uint8_t local_4e; + char local_4d; + Entity_Player *local_4c; + char local_46; + char isFullyCharged; + char animSuffix [8]; + uint8_t local_3c [8]; + Vector local_34; + uint8_t local_2c [20]; + uint32_t tmpStringCapacity; + uint32_t local_14; + void *local_10; + uint8_t *puStack_c; + uint32_t local_8; + Entity_Player *owner; + + local_8 = 0xffffffff; + puStack_c = &LAB_00b1072e; + local_10 = ExceptionList; + local_14 = __security_cookie ^ GHIDRA_UINT((local_2c + 0x28)); + ExceptionList = &local_10; + shootDirection = direction; + local_70 = 0; + local_58.y = 0.0; + Weapon::Fire(GHIDRA_CAST(this),direction,isShooting,isInterpolated); + uVar15 = this->_modifiers; + local_b4.y = 1.0; + local_90.y = 1.0; + local_78 = uVar15 >> 4 & 0xffffff01; + local_a4.y = (float)(uVar15 >> 5 & 0xffffff01); + leftDirX.y = (float)(uVar15 >> 9 & 0xffffff01); + owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); + isCSection = uVar15 >> 0xb & 0xffffff01; + if (owner == GHIDRA_CAST(0x0)) { + backDirX.y = g_vectorZero.x; + local_4c = GHIDRA_CAST(g_vectorZero.y); +LAB_009ff4b6: + ownerPlayer = GHIDRA_CAST(0x0); + local_64 = owner; + if (owner == GHIDRA_CAST(0x0)) { +LAB_009ff44f: + local_6c = ownerPlayer; + } + else { + local_6c = GHIDRA_CAST(0x0); + if (owner->_type == 1) { + local_b4.y = owner->_shotspeed; + goto LAB_009ff4eb; + } + } + ownerPlayer = local_6c; + if (owner != GHIDRA_CAST(0x0)) { + local_64 = GHIDRA_CAST(0x0); + if (owner->_type == 1) { +LAB_009ff48a: + local_64 = GHIDRA_CAST(0x0); + local_b4.y = owner->_shotspeed; + local_6c = ownerPlayer; + goto LAB_009ff4eb; + } + local_6c = ownerPlayer; + if (owner->_type == 3) { + owner = GHIDRA_CAST((GHIDRA_CAST(&owner->_isControlsEnabled))->x); + local_64 = GHIDRA_CAST(0x0); + if (owner != GHIDRA_CAST(0x0)) goto LAB_009ff48a; + } + } + local_64 = GHIDRA_CAST(0x0); + } + else { + backDirX.y = (float)(owner->_pos).x; + local_4c = GHIDRA_CAST((owner->_pos).y); + if (owner->_type != 1) { + if (owner->_type != 3) goto LAB_009ff4b6; + ownerPlayer = GHIDRA_CAST((GHIDRA_CAST(&owner->_isControlsEnabled))->x); + goto LAB_009ff44f; + } + local_b4.y = owner->_shotspeed; + local_6c = owner; + local_64 = owner; + ownerPlayer = owner; + } +LAB_009ff4eb: + puVar12 = &(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10))); + local_ac.y = 0.001; + pfVar4 = &local_ac.y; + if (0.001 < *GHIDRA_CAST(puVar12) || *GHIDRA_CAST(puVar12) == 0.001) { + pfVar4 = GHIDRA_CAST(puVar12); + } + local_ac.y = *pfVar4; + local_58.y = (float)*pfVar4; + if (ownerPlayer == GHIDRA_CAST(0x0)) { +LAB_009ff534: + isHasBrimstone = '\0'; + } + else { + bVar2 = Entity_Player::HasCollectible(ownerPlayer,0x76,0); + pfVar4 = GHIDRA_CAST(CONCAT31(extraout_var,bVar2)); + isHasBrimstone = '\x01'; + puVar12 = extraout_ECX; + if (bVar2 == 0) goto LAB_009ff534; + } + owner = local_6c; + if ((char)local_78 == '\0') { + isChocolateMilk = (uint8_t)this->_modifiers & 1; + if (((GHIDRA_UINT(this->_modifiers) >> 7 & 1) != 0) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) <= 1.0)) { + local_4e = 1; + local_46 = '\x01'; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_a4.y)) + 0x0))) != '\0') goto LAB_009ff579; + } + else { + local_4e = 0; +LAB_009ff579: + local_46 = '\0'; + } + if ((ownerPlayer == GHIDRA_CAST(0x0)) || + ((bVar2 = Entity_Player::HasCollectible(ownerPlayer,0x18a,0), bVar2 == 0 && + (bVar2 = Entity_Player::HasCollectible(ownerPlayer,0x23c,0), bVar2 == 0)))) { + local_4d = '\0'; + if (ownerPlayer != GHIDRA_CAST(0x0)) goto LAB_009ff5b3; +LAB_009ff5cc: + isHasMarked = '\0'; + } + else { + local_4d = '\x01'; +LAB_009ff5b3: + bVar2 = Entity_Player::HasCollectible(ownerPlayer,0x18a,0); + isHasMarked = '\x01'; + if (bVar2 == 0) goto LAB_009ff5cc; + } + iVar14 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); + if ((iVar14 == 0) || + ((*GHIDRA_CAST((iVar14 + 0x28)) != 1 && + ((*GHIDRA_CAST((iVar14 + 0x28)) != 3 || (iVar14 = *GHIDRA_CAST((iVar14 + 0x410)), iVar14 == 0)))))) { + iVar14 = 0; + } + else { + iVar14 = *GHIDRA_CAST((iVar14 + 0x140c)); + } + if ((local_4d == '\0') || (iVar14 == 0)) { + owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x28)))); + pEVar10 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x2c)))); + } + else { + owner = *GHIDRA_CAST((iVar14 + 0x33c)); + pEVar10 = *GHIDRA_CAST((iVar14 + 0x340)); + } + local_60.x = (float)owner; + local_60.y = (float)pEVar10; + uVar9 = (uint16_t)(GHIDRA_UINT(&local_60) >> 0x10); + bVar2 = (uint8_t)&local_60; + uVar5 = CONCAT22(uVar9,(uint16_t)bVar2); + uVar13 = (uint3)(GHIDRA_UINT(pEVar10) >> 8); + if (((float)owner == g_vectorZero.x) && + (uVar5 = CONCAT22(uVar9,(uint16_t)bVar2), (float)pEVar10 == g_vectorZero.y)) { + iVar14 = GHIDRA_UINT(uVar13) << 8; + } + else { + iVar14 = CONCAT31(uVar13,1); + } + local_4c = GHIDRA_CAST(CONCAT22((short)(GHIDRA_UINT(uVar5) >> 0x10),(uint16_t)(uint8_t)uVar5)); + local_78 = CONCAT31((int3)(GHIDRA_UINT(local_4c) >> 8),isShooting); + isFullyCharged = '\0'; + local_65 = (char)iVar14; + pEVar19 = local_4c; + if (local_4e != 0) { + if (local_ac.y <= *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14))))) { +LAB_009ff696: + pEVar19 = GHIDRA_CAST(0x100); + isFullyCharged = '\x01'; + } + else if ((isShooting != 0) && (local_46 != '\0')) { + if ((this->_mainLaser != 0) && (4 < *GHIDRA_CAST((this->_mainLaser + 0x458)))) goto LAB_009ff696; + pEVar19 = GHIDRA_CAST(0x0); + } + } + cVar8 = (char)(GHIDRA_UINT(pEVar19) >> 8); + backDirX.y = (float)*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))); + if (((float)*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) < 0.0) || + (local_4d = '\0', 0.0 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))))) { + local_4d = '\x01'; + } + if (cVar8 == '\0') { + if (((isInterpolated == 0) && (isShooting != 0)) && ((char)iVar14 != '\0')) { + pEVar19 = GHIDRA_CAST(local_ac.y); + if (isChocolateMilk != 0) { + pVVar6 = Weapon::get_owner_position(GHIDRA_CAST(this),&local_34); + fVar18 = (float)pEVar10 - pVVar6->y; + fVar20 = (float)owner - pVVar6->x; + fVar18 = sqrtf(fVar18 * fVar18 + fVar20 * fVar20); + iVar14 = CONCAT31((int3)(GHIDRA_UINT(extraout_ECX_00) >> 8),local_65); + fVar18 = (fVar18 - 50.0) / 250.0; + if (fVar18 <= 0.0) { + fVar18 = 0.0; + } + if (1.0 <= fVar18) { + fVar18 = 1.0; + } + pEVar19 = (Entity_Player *) + ((local_ac.y * 2.5 - local_ac.y * 0.25) * fVar18 + local_ac.y * 0.25); + } + local_4c = GHIDRA_CAST(0x0); + local_78 = local_78 & 0xff; + if ((float)pEVar19 <= *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14))))) { + local_78 = 0; + } + } + if ((((this->_mainLaser != 0) && + (ownerAsPlayer = *GHIDRA_CAST((this->_mainLaser + 0x3bc)), ownerAsPlayer != 0)) && + (*GHIDRA_CAST((ownerAsPlayer + 0x28)) != 1000)) && + (((ownerPlayer == GHIDRA_CAST(0x0) || ((char)iVar14 != '\0')) || + (ownerPlayer->_twinPlayer != 0)))) { + local_78 = local_78 & 0xffffff00; + } + cVar8 = isFullyCharged; + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(leftDirX.y)) + 0x0))) == '\0') { + if ((char)local_78 != '\0') { +LAB_009ffb5c: + if (cVar8 == '\0') goto LAB_009ffb64; + } +LAB_009ffebb: + local_4c = GHIDRA_CAST(0x3a83126f); + pfVar4 = GHIDRA_CAST(&local_4c); + if (0.001 <= local_ac.y) { + pfVar4 = &local_58.y; + } + owner = GHIDRA_CAST(*pfVar4); + if (isChocolateMilk != 0) { + local_58.y = 0.001; + local_4c = GHIDRA_CAST((local_ac.y * 0.25)); + pfVar4 = &local_58.y; + if (0.001 <= local_ac.y * 0.25) { + pfVar4 = GHIDRA_CAST(&local_4c); + } + owner = GHIDRA_CAST(*pfVar4); + } + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) < (float)owner) { + if (this->_mainLaser == 0) { + iVar14 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); + if (((iVar14 == 0) || (ownerAsPlayer = iVar14, *GHIDRA_CAST((iVar14 + 0x28)) != 1)) && + ((ownerAsPlayer = 0, iVar14 != 0 && (*GHIDRA_CAST((iVar14 + 0x28)) == 3)))) { + ownerAsPlayer = *GHIDRA_CAST((iVar14 + 0xd50)); +LAB_00a0049b: + if (1 < ownerAsPlayer) goto LAB_00a004a0; + } + else { + iVar14 = 0; + if (ownerAsPlayer != 0) { + ownerAsPlayer = *GHIDRA_CAST((ownerAsPlayer + 0x1338)); + goto LAB_00a0049b; + } + } +LAB_00a004ba: + Weapon::stop_costume_item_anim(GHIDRA_CAST(this),0x76); + iVar14 = extraout_ECX_06; + } + else { +LAB_00a004a0: + if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 0) && (*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x28)) == 1)) { + bVar2 = Weapon::IsItemAnimFinished(GHIDRA_CAST(this),0x76); + iVar14 = extraout_ECX_05; + if (bVar2 != 0) goto LAB_00a004ba; + } + } + if ((((this->_mainLaser == 0) && (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 0)) && + (*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x28)) == 1)) && + (((char)isCSection != '\0' && + (bVar2 = Weapon::is_c_section_anim_finished(GHIDRA_CAST(this),iVar14), bVar2 != 0)))) { + Weapon::update_c_section_charge_anim + (GHIDRA_CAST(this),unusedCollectibleId_02,0,shootDirection,0.0); + } + } + else { + uVar15 = GHIDRA_UINT(local_4e) << 7 | 0x800; + if ((char)isCSection == '\0') { + uVar15 = GHIDRA_UINT(local_4e) << 7; + } + pVVar6 = shootDirection; + if ((char)iVar14 == '\0') { + pVVar6 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x20)))); + } + local_6c = GHIDRA_CAST(pVVar6->x); + local_64 = GHIDRA_CAST(pVVar6->y); + local_70 = uVar15; + local_60.x = (float)local_6c; + local_60.y = (float)local_64; + bVar2 = Weapon::IsAxisAligned(GHIDRA_CAST(this)); + if (bVar2 == 0) { + fVar18 = sqrtf((float)local_64 * (float)local_64 + (float)local_6c * (float)local_6c); + iVar14 = extraout_ECX_04; + if (0.0 < fVar18) { + local_64 = GHIDRA_CAST(((1.0 / fVar18) * (float)local_64)); + local_60.x = (1.0 / fVar18) * (float)local_6c; + goto LAB_009fffc8; + } + } + else { + pVVar6 = Vector::ToCardinal(&local_34,&local_60); + local_60.x = pVVar6->x; + local_64 = GHIDRA_CAST(pVVar6->y); + iVar14 = extraout_ECX_03; +LAB_009fffc8: + local_6c = GHIDRA_CAST(local_60.x); + local_60.y = (float)local_64; + } + if (local_46 == '\0') { + if (isChocolateMilk == 0) { + fVar18 = 1.0; + } + else { + fVar18 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) / local_ac.y; + if (fVar18 <= 0.1) { + fVar18 = 0.1; + } + if (2.5 <= fVar18) { + fVar18 = 2.5; + } + local_90.y = fVar18; + } + } + else { + fVar18 = (30.0 / (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x10)))) + 1.0)) * 0.2; + local_90.y = fVar18; + if (isChocolateMilk != 0) { + fVar18 = fVar18 * 1.25; + local_90.y = fVar18; + } + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(leftDirX.y)) + 0x0))) != '\0') { + uVar15 = uVar15 | 0x200; + local_70 = uVar15; + if (isHasBrimstone == '\0') { + local_90.y = fVar18 * 0.5; + } + } + Weapon::GetMultiShotParams(GHIDRA_CAST(this),&multiShotParams,iVar14); + fVar18 = atan2f((float)local_64,(float)local_6c); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x44)))) = fVar18 * 57.295776; + if ((char)isCSection == '\0') { + Weapon::UpdateHeadChargeAnimation(GHIDRA_CAST(this),0x76,2,&local_60,-1.0); + } + else { + Weapon::update_c_section_charge_anim + (GHIDRA_CAST(this),unusedCollectibleId_01,2,&local_60,-1.0); + } + local_64 = GHIDRA_CAST(0x0); + local_4c = GHIDRA_CAST(0x0); + if (0 < (short)multiShotParams) { + do { + FUN_009f4230(local_2c + 8,local_4c,2,local_60.x,local_60.y,local_b4.y,multiShotParams, + uStack_d4,uStack_d0,uStack_cc,local_c8,uStack_c4,uStack_c0,uStack_bc, + local_b8); + owner = (Entity_Player *) + Weapon::fire_brimstone_with_color + (GHIDRA_CAST(this),GHIDRA_CAST((local_2c + 0x10)),local_90.y,uVar15); + (**(code **)(*GHIDRA_CAST(owner) + 0xc))(); + if (local_64 == GHIDRA_CAST(0x0)) { + local_64 = owner; + if (GHIDRA_CAST(this->_mainLaser) != owner) { + if (GHIDRA_CAST(this->_mainLaser) != GHIDRA_CAST(0x0)) { + local_58.y = (float)&this->_mainLaser; + msvc::multiset::erase(&local_58.y); + } + puVar21 = &this->_mainLaser; + *puVar21 = owner; + goto LAB_00a001a4; + } + } + else { + puVar21 = &owner->_parent; + if (owner->_parent != 0) { + local_58.y = (float)puVar21; + msvc::multiset::erase(&local_58.y); + } + *puVar21 = local_64; +LAB_00a001a4: + msvc::multiset::insert(puVar21); + } + local_4c = GHIDRA_CAST((GHIDRA_INT(local_4c) + 1)); + uVar15 = local_70; + } while (GHIDRA_INT(local_4c) < GHIDRA_INT((short)multiShotParams)); + } + local_4c = GHIDRA_CAST((local_b8 & 0xffff)); + uVar7 = local_70; + while( true ) { + local_70 = uVar7; + if (local_4c == GHIDRA_CAST(0x0)) break; + uVar7 = Random(); + fVar18 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + local_58.y = fVar18 + fVar18; + backDirX.y = sin(local_58.y); + local_b4.x = cos(local_58.y); + local_b4.y = backDirX.y; + leftDirX.y = (float)Weapon::fire_brimstone_with_color + (GHIDRA_CAST(this),&local_b4,local_90.y,uVar15); + backDirX.y = (float)this->_mainLaser; + puVar21 = &(GHIDRA_CAST(leftDirX.y))->_parent; + if (*puVar21 != 0) { + local_58.y = (float)puVar21; + msvc::multiset::erase(&local_58.y); + } + *puVar21 = backDirX.y; + if (GHIDRA_CAST(backDirX.y) != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(puVar21); + } + (**(code **)(*GHIDRA_CAST(leftDirX.y) + 0xc))(); + local_4c = GHIDRA_CAST((GHIDRA_INT(local_4c) - 1)); + uVar15 = local_70; + uVar7 = local_70; + } + (*GHIDRA_CAST((GHIDRA_CAST(&(uStack_bc)) + 0x1))) = (char)(GHIDRA_UINT(uStack_bc) >> 8); + bVar16 = (*GHIDRA_CAST((GHIDRA_CAST(&(uStack_bc)) + 0x1))) != '\0'; + owner = GHIDRA_CAST(0x0); + if (bVar16) { + local_58.x = (float)(GHIDRA_UINT(local_60.x) ^ 0x80000000); + local_58.y = (float)(GHIDRA_UINT(local_60.y) ^ 0x80000000); + leftDirX.y = (float)Weapon::fire_brimstone_with_color + (GHIDRA_CAST(this),&local_58,local_90.y,uVar7); + backDirX.y = (float)this->_mainLaser; + local_4c = GHIDRA_CAST(&(GHIDRA_CAST(leftDirX.y))->_parent); + if ((GHIDRA_CAST(leftDirX.y))->_parent != 0) { + local_58.y = (float)local_4c; + msvc::multiset::erase(&local_58.y); + } + *GHIDRA_CAST(local_4c) = backDirX.y; + if (GHIDRA_CAST(backDirX.y) != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(local_4c); + } + (**(code **)(*GHIDRA_CAST(leftDirX.y) + 0xc))(); + owner = local_4c; + } + local_4c = owner; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_bc)) + 0x2))) != '\0') { + local_58.x = (float)(GHIDRA_UINT(local_60.y) ^ 0x80000000); + local_58.y = local_60.x; + leftDirX.y = (float)Weapon::fire_brimstone_with_color + (GHIDRA_CAST(this),&local_58,local_90.y,uVar7); + backDirX.y = (float)this->_mainLaser; + local_4c = GHIDRA_CAST(&(GHIDRA_CAST(leftDirX.y))->_parent); + if ((GHIDRA_CAST(leftDirX.y))->_parent != 0) { + local_58.y = (float)local_4c; + msvc::multiset::erase(&local_58.y); + } + *GHIDRA_CAST(local_4c) = backDirX.y; + if (backDirX.y != 0.0) { + msvc::multiset::insert(local_4c); + } + (**(code **)(*GHIDRA_CAST(leftDirX.y) + 0xc))(); + owner = GHIDRA_CAST((GHIDRA_UINT(local_60.x) ^ 0x80000000)); + local_60.x = local_60.y; + local_60.y = (float)owner; + backDirX.y = (float)Weapon::fire_brimstone_with_color + (GHIDRA_CAST(this),&local_60,local_90.y,uVar7); + local_4c = GHIDRA_CAST(this->_mainLaser); + puVar21 = &(GHIDRA_CAST(backDirX.y))->_parent; + if (*puVar21 != 0) { + local_58.y = (float)puVar21; + msvc::multiset::erase(&local_58.y); + } + *puVar21 = local_4c; + if (local_4c != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(puVar21); + } + (**(code **)(*GHIDRA_CAST(backDirX.y) + 0xc))(); + } + if (((*GHIDRA_CAST((GHIDRA_CAST(&(local_a4.y)) + 0x0))) != '\0') && ((char)isCSection != '\0')) { + fire_c_section_fetuses(this); + } + } + if ((GHIDRA_CAST(this->_mainLaser) == GHIDRA_CAST(0x0)) || (isInterpolated != 0)) { +LAB_00a00882: + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) = 0; + } + else { + iVar14 = Entity::GetIntervalTicks(GHIDRA_CAST(this->_mainLaser),4.0,0.0); + Weapon::TriggerTearEffects(GHIDRA_CAST(this),shootDirection,iVar14); + if (((*GHIDRA_CAST((GHIDRA_CAST(&(local_a4.y)) + 0x0))) == '\0') && + ((iVar14 = Entity::GetIntervalTicks(GHIDRA_CAST(this->_mainLaser),4.0,0.0), iVar14 != 0 && + ((char)isCSection != '\0')))) { + fire_c_section_fetuses(this); + } + if ((isHasMarked != '\0') || ((local_46 != '\0' && (isFullyCharged != '\0')))) { + EntityList::QuerySublist + (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),GHIDRA_CAST(local_3c),7,-1,-1,0 + ,0); + local_8 = 0; + fVar18 = atan2f(shootDirection->y,shootDirection->x); + owner = GHIDRA_CAST((fVar18 * 57.295776)); + leftDirX.y = local_34.y; + local_4c = GHIDRA_CAST(0x0); + backDirX.y = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_3c)) + 0x4))); + local_64 = owner; + if (GHIDRA_CAST(local_34.y) != GHIDRA_CAST(0x0)) { + do { + iVar14 = *GHIDRA_CAST((GHIDRA_INT((&(GHIDRA_CAST((GHIDRA_INT(backDirX.y) + 0x48)))->_filename + -3)) + + GHIDRA_INT(local_4c) * 4)); + if ((iVar14 == this->_mainLaser) || (*GHIDRA_CAST((iVar14 + 0x3bc)) == this->_mainLaser)) { + local_58.y = *GHIDRA_CAST((iVar14 + 0x41c)); + fVar18 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x44)))); + *GHIDRA_CAST((iVar14 + 0x4c0)) = 1; + *GHIDRA_CAST((iVar14 + 0x4c4)) = 0; + fVar18 = angle_difference(local_58.y,(local_58.y - fVar18) + (float)owner); + *GHIDRA_CAST((iVar14 + 0x4c8)) = fVar18; + if (0.0 <= fVar18) { + uVar5 = 0x41000000; + } + else { + uVar5 = 0xc1000000; + } + *GHIDRA_CAST((iVar14 + 0x4cc)) = uVar5; + fVar18 = sin(local_58.y * 0.017453292); + if (fVar18 <= -0.5) { + uVar5 = 0xc1200000; + } + else { + uVar5 = 0x453b8000; + } + *GHIDRA_CAST((iVar14 + 0x358)) = uVar5; + if ((local_46 == '\0') || (isFullyCharged == '\0')) { + owner = local_64; + } + else { + Weapon::GetOwnerLaserOffset(GHIDRA_CAST(this),&local_60,4,shootDirection); + *GHIDRA_CAST((iVar14 + 0x34c)) = local_60.x; + *GHIDRA_CAST((iVar14 + 0x350)) = local_60.y; + owner = local_64; + if (*GHIDRA_CAST((iVar14 + 0x458)) < 8) { + *GHIDRA_CAST((iVar14 + 0x458)) = 8; + } + } + } + local_4c = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_4c)) + 0x1)))); + } while (local_4c < GHIDRA_UINT(leftDirX.y)); + } + local_58.y = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x44)))); + fVar18 = angle_difference(local_58.y,(float)owner); + if (fVar18 <= -8.0) { + fVar18 = -8.0; + } + if (8.0 <= fVar18) { + fVar18 = 8.0; + } + fVar18 = local_58.y + fVar18; + if (360.0 < ABS(fVar18)) { + fVar18 = fmodf(fVar18,360.0); + } + if (fVar18 <= 180.0) { + if (fVar18 < -180.0) { + fVar18 = fVar18 + 360.0; + } + } + else { + fVar18 = fVar18 - 360.0; + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x44)))) = fVar18; + bVar2 = Weapon::IsItemAnimFinished(GHIDRA_CAST(this),0x76); + pVVar6 = shootDirection; + if (bVar2 == 0) { + if ((char)isCSection == '\0') { + Weapon::UpdateHeadChargeAnimation(GHIDRA_CAST(this),0x76,2,shootDirection,-2.0); + if (((isFullyCharged != '\0') && (local_46 != '\0')) && + ((((owner = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))), owner != GHIDRA_CAST(0x0) && + (ownerPlayer = owner, owner->_type == 1)) || + ((ownerPlayer = GHIDRA_CAST(0x0), owner == GHIDRA_CAST(0x0) || + (owner->_type != 3)))) && (ownerPlayer != GHIDRA_CAST(0x0))))) { + pvVar11 = (g_manager->_itemConfig)._collectibles._begin; + if (GHIDRA_INT((g_manager->_itemConfig)._collectibles._end) - GHIDRA_INT(pvVar11) >> 2 < 0x77) { + item = GHIDRA_CAST(0x0); + } + else { + item = *GHIDRA_CAST((GHIDRA_CAST(pvVar11) + 0x1d8)); + } + ownerAsPlayer = 0xa0083e; + iVar14 = Entity_Player::get_costume_anim_frame + (ownerPlayer,ownerPlayer,item,GHIDRA_INT(ownerPlayer)); + if (0xf < iVar14) { + Weapon::play_brimstone_costume_shoot + (GHIDRA_CAST(this),ownerAsPlayer,GHIDRA_INT(ownerPlayer),pVVar6,8.0); + } + } + } + else { + Weapon::update_c_section_charge_anim + (GHIDRA_CAST(this),unusedCollectibleId_03,2,shootDirection,0.0); + } + } + local_8 = 0xffffffff; + if (local_3c[0] == '\0') { + local_8 = 1; + tracked_alloc(1,(void *)backDirX.y,0); + local_8 = 0xffffffff; + } + goto LAB_00a00882; + } + Weapon::SetHeadLockTime(GHIDRA_CAST(this),2); + if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) == 0) || (*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x28)) != 3)) + goto LAB_00a00882; + Weapon::SetBlinkTime(GHIDRA_CAST(this),10,unused_00); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) = 0; + } + } + else { + if ((char)local_78 == '\0') goto LAB_009ffebb; + if (((isInterpolated != 0) || (0.0 < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))))) || (0.0 <= backDirX.y)) + goto LAB_009ffb5c; + if (cVar8 != '\0') goto LAB_009ffebb; + local_64 = GHIDRA_CAST((GHIDRA_UINT(local_4e) << 7)); + local_58.x = shootDirection->x; + local_58.y = shootDirection->y; + bVar2 = Weapon::IsAxisAligned(GHIDRA_CAST(this)); + if (bVar2 == 0) { + (GHIDRA_CAST((&local_58)))->Vector::Normalize(); + local_4c = GHIDRA_CAST(local_58.x); + iVar14 = extraout_ECX_02; + } + else { + pVVar6 = Vector::ToCardinal(&local_60,&local_58); + local_4c = GHIDRA_CAST(pVVar6->x); + local_58.y = pVVar6->y; + iVar14 = extraout_ECX_01; + } + backDirX.y = local_58.y; + local_58.x = (float)local_4c; + Weapon::GetMultiShotParams(GHIDRA_CAST(this),&multiShotParams,iVar14); + fVar18 = atan2f(backDirX.y,(float)local_4c); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x44)))) = fVar18 * 57.295776; + Weapon::UpdateHeadChargeAnimation(GHIDRA_CAST(this),0x76,3,&local_58,-1.0); + Weapon::SetBlinkTime(GHIDRA_CAST(this),10,unused); + iVar14 = 0; + local_4e = 0; + if (0 < (short)multiShotParams) { + do { + FUN_009f4230(local_2c + 8,iVar14,10,local_58.x,local_58.y,local_b4.y,multiShotParams, + uStack_d4,uStack_d0,uStack_cc,local_c8,uStack_c4,uStack_c0,uStack_bc,local_b8 + ); + if (local_4e == 0) { + bVar2 = fire_hitscan(this,&g_vectorZero,GHIDRA_CAST((local_2c + 0x10)),GHIDRA_INT(local_64),1.0); + local_4e = 0; + if (bVar2 != 0) goto LAB_009ff93e; + } + else { +LAB_009ff93e: + local_4e = 1; + } + iVar14 = iVar14 + 1; + } while (iVar14 < (short)multiShotParams); + } + uVar15 = local_b8 & 0xffff; + owner = local_64; + bVar2 = local_4e; + while( true ) { + local_64 = owner; + if (uVar15 == 0) break; + if (bVar2 == 0) { + uVar7 = Random(); + fVar18 = (float)((double)GHIDRA_INT(uVar7) + __uint_to_double_fixup[-(GHIDRA_INT(uVar7) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + local_4c = GHIDRA_CAST((fVar18 + fVar18)); + backDirX.y = sin((float)local_4c); + local_60.x = cos((float)local_4c); + local_60.y = backDirX.y; + bVar3 = fire_hitscan(this,&g_vectorZero,&local_60,GHIDRA_INT(local_64),1.0); + bVar2 = 0; + if (bVar3 != 0) goto LAB_009ff9ec; + } + else { +LAB_009ff9ec: + bVar2 = 1; + } + uVar15 = uVar15 - 1; + owner = local_64; + } + (*GHIDRA_CAST((GHIDRA_CAST(&(uStack_bc)) + 0x1))) = (char)(GHIDRA_UINT(uStack_bc) >> 8); + if ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_bc)) + 0x1))) == '\0') { + if (bVar2 != 0) goto LAB_009ffafb; +LAB_009ffa68: + if ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_bc)) + 0x2))) != '\0') { + leftDirX.x = -local_58.y; + leftDirX.y = local_58.x; + bVar2 = fire_hitscan(this,&g_vectorZero,&leftDirX,GHIDRA_INT(owner),1.0); + if (bVar2 == 0) { + ownerPlayer = GHIDRA_CAST((GHIDRA_UINT(local_58.x) ^ 0x80000000)); + local_58.x = local_58.y; + local_58.y = (float)ownerPlayer; + bVar2 = fire_hitscan(this,&g_vectorZero,&local_58,GHIDRA_INT(owner),1.0); + if (bVar2 == 0) goto LAB_009ffae1; + } + goto LAB_009ffafb; + } +LAB_009ffae1: + owner = local_6c; + if ((local_6c != GHIDRA_CAST(0x0)) && + (bVar2 = TemporaryEffects::HasNullEffect(&local_6c->_temporaryeffects,0x7f), bVar2 != 0)) + goto LAB_009ffafe; + } + else { + if (bVar2 == 0) { + backDirX.y = (float)(GHIDRA_UINT(local_58.y) ^ 0x80000000); + backDirX.x = -local_58.x; + bVar2 = fire_hitscan(this,&g_vectorZero,&backDirX,GHIDRA_INT(owner),1.0); + if (bVar2 == 0) goto LAB_009ffa68; + } +LAB_009ffafb: + owner = local_6c; +LAB_009ffafe: + fVar17 = (long double)this->GetMaxCharge(); + local_4c = GHIDRA_CAST((float)fVar17); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) = + ((float)local_4c - *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14))))) * 0.5 + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); + if (owner != GHIDRA_CAST(0x0)) { + TemporaryEffects::RemoveNullEffect(&owner->_temporaryeffects,0x7f,-1); + } + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0xc)))) = local_ac.y; + local_4d = '\x01'; +LAB_009ffb64: + piVar1 = GHIDRA_CAST(this->_mainLaser); + if (((piVar1 != GHIDRA_CAST(0x0)) && (piVar1[0xef] != 0)) && (*GHIDRA_CAST((piVar1[0xef] + 0x28)) != 1000) + ) { + (**(code **)(*piVar1 + 0x28))(); + } + local_a4.y = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); + local_46 = '\0'; + if ((GHIDRA_CAST(local_a4.y) != GHIDRA_CAST(0x0)) && + ((GHIDRA_CAST(local_a4.y))->_type == 1)) { + pvVar11 = (g_manager->_itemConfig)._collectibles._begin; + if (GHIDRA_INT((g_manager->_itemConfig)._collectibles._end) - GHIDRA_INT(pvVar11) >> 2 < 0x77) { + local_4c = GHIDRA_CAST(0x0); + } + else { + local_4c = *GHIDRA_CAST((GHIDRA_CAST(pvVar11) + 0x1d8)); + } + leftDirX.y = (float)(GHIDRA_CAST(local_a4.y))->_playerCostumeMap; + backDirX.y = 0.0; + do { + if ((-1 < *GHIDRA_CAST(leftDirX.y)) && (*GHIDRA_CAST((GHIDRA_CAST(leftDirX.y) + 0xc)) == '\0')) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x10))) = 0; + sprite = GHIDRA_CAST((*GHIDRA_CAST(leftDirX.y) * 0x130 + + GHIDRA_INT((GHIDRA_CAST((GHIDRA_INT(local_a4.y) + 0x1220)))->_begin))); + tmpStringCapacity = 0xf; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) = (void *)0x0; + (GHIDRA_CAST((local_2c)))->msvc::string::assign(&s_empty,0); + local_70 = local_70 | 2; + bVar2 = Weapon::is_held_item(sprite,GHIDRA_CAST(local_2c),local_4c); + if ((bVar2 == 0) || + (((sprite->_animState)._animData == (void *)0x0 || + (local_65 = '\x01', (sprite->_animState)._isPlaying == 0)))) { + local_65 = '\0'; + } + local_8 = 0xffffffff; + if (((local_70 & 2) != 0) && (local_70 = local_70 & 0xfffffffd, 0xf < tmpStringCapacity) + ) { + uVar15 = tmpStringCapacity + 1; + pvVar11 = (*GHIDRA_CAST((GHIDRA_CAST(&((void *)local_2c)) + 0x0))); + if (0xfff < uVar15) { + pvVar11 = *(void **)((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) + -4); + uVar15 = tmpStringCapacity + 0x24; + if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x0))) + (-4 - GHIDRA_INT(pvVar11))))) { + /* WARNING: Subroutine does not return */ + _invalid_parameter_noinfo_noreturn(); + } + } + operator_delete(pvVar11,uVar15); + } + if (local_65 != '\0') { + if ((sprite != GHIDRA_CAST(0x0)) && (bVar2 = ANM2::IsPlaying(sprite,&s_empty), bVar2 != 0)) + { + ANM2::GetAnimation(GHIDRA_CAST(&sprite->_animState),GHIDRA_CAST(local_2c)); + local_8 = 3; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_UINT(local_2c))) + 0x10))) < 8) { +LAB_009ffd27: + local_46 = '\0'; + } + else { + str = GHIDRA_CAST(FUN_00651a90(animSuffix,(*GHIDRA_CAST((GHIDRA_CAST(&(local_2c)) + 0x10))) - 8,0xffffffff)); + local_70 = local_70 | 1; + bVar2 = str_eq_cstr(str,GHIDRA_CAST("ShootAlt")); + local_46 = '\x01'; + if (bVar2 == 0) goto LAB_009ffd27; + } + if ((local_70 & 1) != 0) { + (GHIDRA_CAST((animSuffix)))->msvc::string::_Tidy_deallocate(); + } + local_8 = 0xffffffff; + (GHIDRA_CAST((local_2c)))->msvc::string::_Tidy_deallocate(); + } + break; + } + } + backDirX.y = (float)&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(backDirX.y)))) + 0x1))); + leftDirX.y = (float)&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(leftDirX.y)))) + 0x10))); + } while (GHIDRA_UINT(backDirX.y) < &DAT_0000000f); + } + if (local_4d == '\0') { +LAB_009ffde2: + pVVar6 = shootDirection; + } + else { + fVar17 = (long double)this->GetMaxCharge(); + pVVar6 = shootDirection; + local_4c = GHIDRA_CAST((float)fVar17); + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) < (float)local_4c) { + owner = GHIDRA_CAST(((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) / (float)local_4c) * 18.0)); + local_4c = owner; + if ((char)isCSection == '\0') { + if (local_46 == '\0') { + Weapon::UpdateHeadChargeAnimation(GHIDRA_CAST(this),0x76,0,shootDirection,(float)owner); + } + } + else { + bVar2 = Weapon::is_c_section_anim_finished(GHIDRA_CAST(this),unusedCollectibleId); + if (bVar2 != 0) { + owner = local_4c; + Weapon::update_c_section_charge_anim + (GHIDRA_CAST(this),unusedCollectibleId_00,0,shootDirection,(float)local_4c); + } + } + if (isInterpolated == 0) { + FUN_009f4130(); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))) = (float)owner + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x14)))); + } + goto LAB_009ffde2; + } + if ((char)isCSection == '\0') { + if (local_46 != '\0') goto LAB_009ffde2; + Weapon::UpdateHeadChargeAnimation(GHIDRA_CAST(this),0x76,1,shootDirection,-1.0); + } + else { + Weapon::update_c_section_charge_anim + (GHIDRA_CAST(this),unusedCollectibleId,1,shootDirection,-1.0); + } + } + bVar2 = Weapon::IsAxisAligned(GHIDRA_CAST(this)); + if (bVar2 == 0) { + aimDirection = Weapon::get_aim_direction(GHIDRA_CAST(this),&local_34,pVVar6); + } + else { + local_60.x = (float)pVVar6->x; + aimDirection = &local_60; + local_60.y = (float)pVVar6->y; + } + fVar18 = aimDirection->x; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x20)))) = fVar18; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x24)))) = aimDirection->y; + Weapon::SetBlinkTime(GHIDRA_CAST(this),1,GHIDRA_INT(fVar18)); + } + } + else { + local_90.y = 1.0; + this_00 = GHIDRA_CAST(this->_mainLaser); + local_a4.x = backDirX.y; + local_a4.y = (float)local_4c; + if (this_00 != GHIDRA_CAST(0x0)) { + local_a4.x = (this_00->_pos).x; + local_a4.y = (this_00->_pos).y; + } + if (isInterpolated == 0) { + bVar2 = Entity_Player::HasCollectible(local_6c,0x44,0); + local_70 = 1; + if (bVar2 != 0) { + local_70 = 9; + } + if (((*GHIDRA_CAST((GHIDRA_CAST(&(leftDirX.y)) + 0x0))) != '\0') && (isHasBrimstone == '\0')) { + local_90.y = 0.5; + } + iVar14 = Entity_Player::GetCollectibleNum(owner,0x76,0); + if (1 < iVar14) { + local_90.y = local_90.y + local_90.y; + } + if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) != 0) && (*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x28)) == 3)) { + local_90.y = local_90.y * 0.5; + } + if (1.5 < local_90.y) { + bVar16 = local_70 == 9; + local_70 = 0xb; + local_90.y = local_90.y * 0.5; + if (bVar16) { + local_70 = 0xe; + } + } + this_00 = GHIDRA_CAST(this->_mainLaser); + pfVar4 = GHIDRA_CAST(&this->_mainLaser); + if ((this_00 != GHIDRA_CAST(0x0)) && + ((this_00->_subtype != 1 || (this_00->_variant != local_70)))) { + (**(code **)(*GHIDRA_CAST(this_00) + 0x28))(); + if (this->_mainLaser != 0) { + local_58.y = (float)&this->_mainLaser; + msvc::multiset::erase(&local_58.y); + this->_mainLaser = 0; + } +LAB_00a009e9: + uVar15 = Random(); + laser = (Entity_Laser *) + Game::Spawn(g_game,7,local_70,&local_a4,&g_vectorZero,*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))),1 + ,uVar15); + if ((laser == GHIDRA_CAST(0x0)) || (laser->_type != 7)) { + laser = GHIDRA_CAST(0x0); + } + (laser->_posOffset).x = 0.0; + (laser->_posOffset).y = -20.0; + Entity::SetParent(GHIDRA_CAST(laser),*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4))))); + laser->_renderDepthOffset = 3000.0; + laser->_scale = local_90.y; + Entity_Laser::ResetSpriteScale(laser); + init_laser(this,laser); + (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); + EntityPtr::Set(GHIDRA_CAST(&this->_mainLaser),GHIDRA_CAST(laser)); + this_00 = GHIDRA_CAST(this->_mainLaser); + pfVar4 = extraout_EAX; + puVar12 = extraout_ECX_07; + goto LAB_00a00a7b; + } + if (this_00 == GHIDRA_CAST(0x0)) goto LAB_00a009e9; + } + else { +LAB_00a00a7b: + if (this_00 == GHIDRA_CAST(0x0)) { + uVar15 = CONCAT31((int3)(GHIDRA_UINT(puVar12) >> 8),isShooting); + goto LAB_009ffe67; + } + } + local_78 = CONCAT31((int3)(GHIDRA_UINT(pfVar4) >> 8),isShooting); + if (isShooting == 0) { + ownerAsPlayer = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c4)) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c0)); + iVar14 = 0; + if (0 < ownerAsPlayer) { + iVar14 = ownerAsPlayer; + } + if (iVar14 < 1) { + fVar18 = backDirX.y - (this_00->_pos).x; + fVar20 = (float)local_4c - (this_00->_pos).y; + if (10000.0 < fVar20 * fVar20 + fVar18 * fVar18) { + local_60.x = fVar18; + local_60.y = fVar20; + pVVar6 = (GHIDRA_CAST((&local_60)))->Vector::Normalized(&local_34); + local_60.x = pVVar6->x * 0.3 * 0.5; + local_60.y = pVVar6->y * 0.3 * 0.5; + goto LAB_00a00bb9; + } + } + } + else { + local_60.x = shootDirection->x; + local_60.y = shootDirection->y; + if (1.0 < local_60.x * local_60.x + local_60.y * local_60.y) { + (GHIDRA_CAST((&local_60)))->Vector::Normalize(); + } + local_60.x = local_60.x * 2.0 * 0.5 * local_b4.y; + local_60.y = local_60.y * 2.0 * 0.5 * local_b4.y; +LAB_00a00bb9: + Entity::AddVelocity_divided(this_00,&local_60,0); + } + puVar21 = &this->_mainLaser; + if (isInterpolated == 0) { + init_laser(this,GHIDRA_CAST(*puVar21)); + laser = GHIDRA_CAST(*puVar21); + laser->_scale = local_90.y; + Entity_Laser::ResetSpriteScale(laser); + if ((local_64 != GHIDRA_CAST(0x0)) && + (iVar14 = Entity::GetIntervalTicks(GHIDRA_CAST(local_64),local_ac.y,0.0), iVar14 != 0)) { + iVar14 = *puVar21; + if (iVar14 != 0) { + local_58.x = *GHIDRA_CAST((iVar14 + 0x33c)); + local_58.y = *GHIDRA_CAST((iVar14 + 0x340)); + local_60.x = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x33c)); + local_60.y = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x340)); + bVar2 = (GHIDRA_CAST((&local_58)))->Vector::operator_ne(&local_60); + if (bVar2 != 0) { + local_60.x = *GHIDRA_CAST((*puVar21 + 0x33c)) - *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x33c)) + ; + local_60.y = *GHIDRA_CAST((*puVar21 + 0x340)) - *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))) + 0x340)) + ; + pVVar6 = (GHIDRA_CAST((&local_60)))->Vector::Normalized(&local_ac); + Weapon::TriggerTearEffects(GHIDRA_CAST(this),pVVar6,1); + goto LAB_009ffe64; + } + } + pVVar6 = MusicManager::RandomVector(&local_90); + Weapon::TriggerTearEffects(GHIDRA_CAST(this),pVVar6,1); + } + } + } +LAB_009ffe64: + uVar15 = local_78; +LAB_009ffe67: + if ((char)isCSection != '\0') { + if (this->_mainLaser == 0) { + if (((char)uVar15 != '\0') || + (bVar2 = Weapon::is_c_section_anim_finished(GHIDRA_CAST(this),uVar15), bVar2 != 0)) { + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x3c)))) = shootDirection->x; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x40)))) = shootDirection->y; + } + } + else { + local_58.y = *GHIDRA_CAST((this->_mainLaser + 0x41c)) * 0.017453292; + local_4c = GHIDRA_CAST(cos(local_58.y)); + fVar18 = sin(local_58.y); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x3c)))) = local_4c; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x40)))) = fVar18; + } + } + ExceptionList = local_10; + return; +} + // 00a00d10 void Weapon_Brimstone::fire_c_section_fetuses() { @@ -134,7 +1218,7 @@ void Weapon_Brimstone::init_laser(Entity_Laser *laser) local_c = __security_cookie ^ GHIDRA_UINT(auStack_50); local_4c = laser; - tearFlags = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::get_owner_tear_flags(&tearFlagsResult); + tearFlags = Weapon::get_owner_tear_flags(GHIDRA_CAST(this),&tearFlagsResult); tearFlagsLowHigh = *GHIDRA_CAST((GHIDRA_INT(&tearFlags->_l) + 4)); tearFlagsHigh = tearFlags->_h; tearFlagsHighHigh = *GHIDRA_CAST((GHIDRA_INT(&tearFlags->_h) + 4)); @@ -144,11 +1228,11 @@ void Weapon_Brimstone::init_laser(Entity_Laser *laser) *GHIDRA_CAST(&(laser->_tearFlags)._h) = GHIDRA_INT(tearFlagsHigh); *GHIDRA_CAST((GHIDRA_INT(&(laser->_tearFlags)._h) + 4)) = tearFlagsHighHigh; laserMethod = *(code **)(iVar1 + 0x3c); - laserColor = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::get_laser_color(&laserColorResult); + laserColor = Weapon::get_laser_color(GHIDRA_CAST(this),&laserColorResult); piVar2 = GHIDRA_CAST(0x0); (*laserMethod)(laserColor,0xffffffff,0xff,0,1); laserMethod = *(code **)(*piVar2 + 0x40); - damage = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::get_damage(); + damage = Weapon::get_damage(GHIDRA_CAST(this)); (*laserMethod)(damage); return; } @@ -182,7 +1266,7 @@ void Weapon_Brimstone::ClearReferences() } // 00a02800 -uint32_t Weapon_Brimstone::GetMarkedTargetVariant() +int Weapon_Brimstone::GetMarkedTargetVariant() { uint8_t isHasItem; Entity_Player *owner; @@ -269,7 +1353,7 @@ void Weapon_Brimstone::fire(float Speed, uint8_t IgnoreStatusEffects) stackCookie = __security_cookie ^ GHIDRA_UINT(auStack_a8); aimDir = GHIDRA_CAST(Speed); damageMultiplier = in_XMM2_Da; - (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::GetMultiShotParams(multiShotParams,GHIDRA_INT(this)); + Weapon::GetMultiShotParams(GHIDRA_CAST(this),multiShotParams,GHIDRA_INT(this)); iVar5 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((this)) + 0x4)))); if (iVar5 == 0) { LAB_00a02903: @@ -308,7 +1392,7 @@ LAB_00a02934: (&local_80,GHIDRA_INT(local_98),2,*GHIDRA_CAST(Speed),(*GHIDRA_CAST((GHIDRA_CAST(&((float)local_a4)) + 0x0))), multiShotParams[0],fStack_6c,fStack_68,fStack_64,local_60,iStack_5c,fStack_58, auStack_54[0],(*GHIDRA_CAST((GHIDRA_CAST(&(auStack_54)) + 0x4)))); - pEVar4 = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::fire_brimstone_with_color(&local_78,damageMultiplier,0); + pEVar4 = Weapon::fire_brimstone_with_color(GHIDRA_CAST(this),&local_78,damageMultiplier,0); (**(code **)(*GHIDRA_CAST(pEVar4) + 0xc))(); if (local_8c == GHIDRA_CAST(0x0)) { local_8c = pEVar4; @@ -358,7 +1442,7 @@ LAB_00a02da1: Weapon::FireBrimstone(pEVar2,GHIDRA_CAST((local_a4 + 4)),&local_80,damageMultiplier,fVar8,0) ; setColorFn = *(code **)(*(*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_a4))) + 0x0))) + 0x3c); - laserColor = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::get_laser_color(GHIDRA_CAST((auStack_54 + 0x14))); + laserColor = Weapon::get_laser_color(GHIDRA_CAST(this),GHIDRA_CAST((auStack_54 + 0x14))); piVar9 = GHIDRA_CAST(0x0); (*setColorFn)(laserColor,0xffffffff,0xff); (*GHIDRA_CAST((GHIDRA_CAST(&(local_a4)) + 0x4))) = this->_mainLaser; @@ -393,7 +1477,7 @@ LAB_00a02da1: Weapon::FireBrimstone(pEVar2,GHIDRA_CAST((local_a4 + 4)),&local_80,damageMultiplier,fVar8,0) ; setColorFn = *(code **)(*(*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_a4))) + 0x0))) + 0x3c); - laserColor = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::get_laser_color(GHIDRA_CAST((auStack_54 + 0x14))); + laserColor = Weapon::get_laser_color(GHIDRA_CAST(this),GHIDRA_CAST((auStack_54 + 0x14))); piVar9 = GHIDRA_CAST(0x0); (*setColorFn)(laserColor,0xffffffff,0xff); fVar8 = (float)this->_mainLaser; @@ -427,7 +1511,7 @@ LAB_00a02da1: (*GHIDRA_CAST((GHIDRA_CAST(&(local_a4)) + 0x0))) = Weapon::FireBrimstone(pEVar2,GHIDRA_CAST((local_a4 + 4)),&local_80,damageMultiplier,fVar8,0); setColorFn = *(code **)(*(*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_a4))) + 0x0))) + 0x3c); - laserColor = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::get_laser_color(GHIDRA_CAST((auStack_54 + 0x14))); + laserColor = Weapon::get_laser_color(GHIDRA_CAST(this),GHIDRA_CAST((auStack_54 + 0x14))); piVar10 = GHIDRA_CAST(0x0); piVar9 = GHIDRA_CAST(0xffffffff); (*setColorFn)(laserColor,0xffffffff,0xff); @@ -454,7 +1538,7 @@ LAB_00a02da1: pEVar4 = Weapon::FireBrimstone(pEVar2,GHIDRA_CAST((auStack_a8 + -0xc)),&VStack_94,local_9c,fVar8,0) ; setColorFn = *(code **)(*GHIDRA_CAST(pEVar4) + 0x3c); - laserColor = (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::get_laser_color(GHIDRA_CAST(auStack_54)); + laserColor = Weapon::get_laser_color(GHIDRA_CAST(this),GHIDRA_CAST(auStack_54)); (*setColorFn)(laserColor,0xffffffff,0xff,0,1); iVar5 = this->_mainLaser; piVar10 = piVar9 + 0xef; @@ -469,7 +1553,7 @@ LAB_00a02da1: return; } Weapon::UpdateHeadChargeAnimation(GHIDRA_CAST(this),0x76,3,GHIDRA_CAST(Speed),-1.0); - (GHIDRA_CAST((GHIDRA_CAST(this))))->Weapon::SetBlinkTime(10,unused); + Weapon::SetBlinkTime(GHIDRA_CAST(this),10,unused); isAnyHit = 0; iVar5 = 0; VStack_94.x = (float)(GHIDRA_UINT(VStack_94.x) & 0xffffff); diff --git a/generated-src/weapon_deathmatch.cpp b/generated-src/weapon_deathmatch.cpp index ef00505..8493bf1 100644 --- a/generated-src/weapon_deathmatch.cpp +++ b/generated-src/weapon_deathmatch.cpp @@ -1,7 +1,171 @@ #include "classes.h" +// 00a031b0 +void Weapon_Deathmatch::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + uint8_t bVar1; + Vector *pVVar2; + uint32_t rngResult; + Vector *position; + Entity_Bomb *bomb; + int iVar3; + uint32_t scaleRoll; + int unused; + int unused_00; + long double maxCharge; + float fVar4; + float fVar5; + float fVar6; + float maxCharge; + uint8_t auVar8 [12]; + float fVar9; + uint8_t *charge; + int ownerPlayer; + Vector bombVelocity; + Vector VStack_18; + Vector VStack_10; + + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) = 0x41a00000; + Weapon::Fire(this,direction,isShooting,isInterpolated); + if (isInterpolated != 0) { + return; + } + ownerPlayer = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (ownerPlayer != 0) { + if (*GHIDRA_CAST((ownerPlayer + 0x28)) == 1) goto LAB_00a03209; + if (*GHIDRA_CAST((ownerPlayer + 0x28)) == 3) { + ownerPlayer = *GHIDRA_CAST((ownerPlayer + 0x410)); + goto LAB_00a03209; + } + } + ownerPlayer = 0; +LAB_00a03209: + fVar9 = 0.001; + if (0.001 <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10))) { + fVar9 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)); + } + maxCharge = (long double)this->GetMaxCharge(); + VStack_10.x = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); + VStack_10.y = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)); + fVar4 = (float)maxCharge; + bVar1 = Weapon::IsAxisAligned(this); + fVar5 = 1.0; + if (bVar1 == 0) { + pVVar2 = Weapon::get_aim_direction(this,&VStack_18,&VStack_10); + maxCharge = pVVar2->x; + fVar6 = pVVar2->y; + fVar5 = sqrtf(maxCharge * maxCharge + fVar6 * fVar6); + if (0.0 < fVar5) { + maxCharge = pVVar2->x * (1.0 / fVar5); + fVar6 = pVVar2->y * (1.0 / fVar5); + } + fVar5 = 1.0; + VStack_10.x = maxCharge; + } + else { + pVVar2 = Vector::ToCardinal(&VStack_18,&VStack_10); + fVar6 = pVVar2->y; + VStack_10.x = pVVar2->x; + } + maxCharge = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)); + VStack_10.y = fVar6; + if (isShooting == 0) { + auVar8 = ZEXT812(0x3a83126f); + if ((*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x0))) <= fVar9) { + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x4))); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x0))) = fVar9; + } + fVar9 = (*GHIDRA_CAST((GHIDRA_CAST(&(auVar8)) + 0x0))); + if (fVar9 <= maxCharge) { + Weapon::UpdateHeadChargeAnimation(this,0xe5,2,&VStack_10,-1.0); + if (fVar4 <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14))) { + fVar4 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)); + } + if (fVar9 <= fVar4) { + fVar4 = fVar9; + } + unused = 7 - GHIDRA_INT((fVar4 * -0.45)); + iVar3 = 0xb; + if (0xb < unused) { + iVar3 = unused; + } + Weapon::SetBlinkTime(this,iVar3,unused); + pVVar2 = Weapon::get_tear_movement_inheritance(this,&VStack_18,&VStack_10); + bombVelocity.x = pVVar2->x; + fVar9 = pVVar2->y; + VStack_18.x = fVar9; + FUN_009f3c40(); + rngResult = Random(); + fVar4 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + fVar4 = fVar4 + fVar4; + rngResult = Random(); + fVar5 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * + 2.3283064e-10; + rngResult = Random(); + fVar6 = (float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * + 2.3283064e-10 * 0.6 + 0.4; + maxCharge = cos(fVar4); + bombVelocity.x = (maxCharge * fVar5 * 3.5 + (VStack_10.x * 10.0 + bombVelocity.x) * fVar9) * fVar6 + ; + fVar4 = sin(fVar4); + pVVar2 = &bombVelocity; + bombVelocity.y = (fVar4 * fVar5 * 3.5 + (VStack_10.y * 10.0 + VStack_18.x) * fVar9) * fVar6; + position = Weapon::get_owner_position(this,&VStack_10); + bomb = Weapon::fire_bomb(this,position,pVVar2); + if (ownerPlayer != 0) { + bomb->_fallAcceleration = 0.8; + rngResult = Random(); + bomb->_fallSpeed = + -1.0 - (float)((double)GHIDRA_INT(rngResult) + + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 8.0; + rngResult = Random(); + iVar3 = bomb->_explosionCountdown1 - rngResult % 0xf; + if (iVar3 < 0xf) { + iVar3 = 0xf; + } + bomb->_explosionCountdown1 = iVar3; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((bomb)) + 0x414)))) = iVar3; + } + rngResult = Random(); + scaleRoll = Random(); + bomb->_loadCostumes = 1; + bomb->_explosionDamage = 25.0; + fVar9 = (float)((double)GHIDRA_INT(scaleRoll) + __uint_to_double_fixup[-(GHIDRA_INT(scaleRoll) >> 0x1f)]) * + 2.3283064e-10 * 0.15 + ((float)(rngResult & 1) + 0.0) * 0.2 + 0.4; + bomb->_radiusMultiplier = fVar9 * bomb->_radiusMultiplier; + bomb->_scale = fVar9 * bomb->_scale; + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = 0; + bVar1 = Weapon::IsItemAnimFinished(this,0xe5); + if (bVar1 != 0) { + FUN_009f4fc0(); + return; + } + } + else { + if (fVar4 <= maxCharge) { + charge = &DAT_bf800000; + iVar3 = 1; + } + else { + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) != 0) { + fVar5 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x39c)); + } + iVar3 = 0; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = fVar5 + maxCharge; + charge = GHIDRA_CAST((((fVar5 + maxCharge) / fVar4) * 18.0)); + } + Weapon::UpdateHeadChargeAnimation(this,0xe5,iVar3,direction,(float)charge); + Weapon::SetBlinkTime(this,1,unused_00); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = direction->x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = direction->y; + } + return; +} + // 00a036b0 -long double Weapon_Deathmatch::GetMaxCharge() +float Weapon_Deathmatch::GetMaxCharge() { float maxCharge; diff --git a/generated-src/weapon_fetus.cpp b/generated-src/weapon_fetus.cpp index 7fce3af..6912092 100644 --- a/generated-src/weapon_fetus.cpp +++ b/generated-src/weapon_fetus.cpp @@ -1,7 +1,407 @@ #include "classes.h" +// 00a036e0 +void Weapon_Fetus::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + void *player = this; + Entity *source; + Vector shotDirection; + uint8_t bVar1; + uint32_t uVar2; + Entity_Player *owner; + int ownerPlayer; + float *pfVar3; + ANM2 *pAVar4; + Vector *pVVar5; + Entity_Tear *tear; + uint8_t *animName; + Vector *newAimDirection; + Entity_Player *player; + int extraout_ECX; + int unusedArg; + int extraout_ECX_00; + ANM2 *this_00; + ANM2 *extraout_ECX_01; + void *pvVar6; + ANM2 *extraout_ECX_02; + int unusedCollectibleId; + int extraout_ECX_03; + ANM2 *extraout_ECX_04; + int extraout_ECX_05; + int extraout_ECX_06; + Entity_Player *ownerAsPlayer; + long double fVar7; + float fVar8; + uint8_t *puVar9; + int iVar10; + short multiShotParams [2]; + float fStack_a0; + float fStack_9c; + float fStack_98; + float fStack_94; + int iStack_90; + float fStack_8c; + char isShootingBackwards; + char isShootingSideways; + uint32_t uStack_88; + uint32_t numRandomDirTears; + Weapon *weapon; + float spreadAngle; + Vector scratchVec; + Vector local_70; + Vector firePos; + Vector aimDirection; + Vector local_58; + Vector *directionLocal; + float local_4c; + char isMarked; + float local_44; + float local_40; + uint64_t subAnimName; + float local_34; + float local_30; + Vector local_2c; + uint32_t local_24; + uint8_t *puStack_20; + void *local_1c; + uint8_t *puStack_18; + uint32_t local_14; + + puStack_20 = GHIDRA_CAST((GHIDRA_INT(register0x00000010) + -4)); + local_14 = (void *)0xffffffff; + puStack_18 = &LAB_00b107dd; + local_1c = ExceptionList; + uVar2 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U; + ExceptionList = &local_1c; + directionLocal = direction; + weapon = player; + local_24 = uVar2; + Weapon::Fire(player,direction,isShooting,isInterpolated); + owner = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + ownerAsPlayer = owner; + if (owner == GHIDRA_CAST(0x0)) { +LAB_00a03762: + player = GHIDRA_CAST(0x0); + if ((owner == GHIDRA_CAST(0x0)) || (owner->_type != 1)) { +LAB_00a03770: + if ((owner == GHIDRA_CAST(0x0)) || + ((ownerAsPlayer = GHIDRA_CAST(0x0), owner->_type != 1 && + ((owner->_type != 3 || + (owner = *GHIDRA_CAST(&owner->_isControlsEnabled), owner == GHIDRA_CAST(0x0))))) + )) { + local_70.y = 1.0; + ownerAsPlayer = GHIDRA_CAST(0x0); + goto LAB_00a037a2; + } + } + local_70.y = owner->_shotspeed; + } + else { + if (owner->_type != 1) { + if (owner->_type != 3) goto LAB_00a03762; + player = *GHIDRA_CAST(&owner->_isControlsEnabled); + goto LAB_00a03770; + } + local_70.y = owner->_shotspeed; + player = owner; + } +LAB_00a037a2: + local_70.y = local_70.y * 1.25; + if (player == GHIDRA_CAST(0x0)) { +LAB_00a037c7: + isMarked = '\0'; + } + else { + bVar1 = Entity_Player::HasCollectible(player,0x18a,0); + isMarked = '\x01'; + if (bVar1 == 0) goto LAB_00a037c7; + } + local_40 = (float)(*GHIDRA_CAST((GHIDRA_CAST(player) + 0x34)) >> 7 & 0xffffff01); + fVar7 = (long double)(**(code **)(*GHIDRA_CAST(player) + 0x18))(uVar2); + iVar10 = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + fVar8 = (float)fVar7; + local_44 = fVar8; + if (iVar10 == 0) { +LAB_00a0382d: + firePos.x = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x28)); + firePos.y = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x2c)); + } + else { + if (*GHIDRA_CAST((iVar10 + 0x28)) == 1) { + ownerPlayer = iVar10; + } + else if ((*GHIDRA_CAST((iVar10 + 0x28)) != 3) || + (ownerPlayer = *GHIDRA_CAST((iVar10 + 0x410)), ownerPlayer == 0)) goto LAB_00a0382d; + ownerPlayer = *GHIDRA_CAST((ownerPlayer + 0x140c)); + if ((ownerPlayer == 0) || (isMarked == '\0')) goto LAB_00a0382d; + firePos.x = *GHIDRA_CAST((ownerPlayer + 0x33c)); + firePos.y = *GHIDRA_CAST((ownerPlayer + 0x340)); + } + bVar1 = (firePos.x == g_vectorZero.x) << 6 | (NAN(firePos.x) || NAN(g_vectorZero.x)) << 2 | 2U | + firePos.x < g_vectorZero.x; + if (firePos.x == g_vectorZero.x) { + bVar1 = (firePos.y == g_vectorZero.y) << 6 | (NAN(firePos.y) || NAN(g_vectorZero.y)) << 2 | 2U | + firePos.y < g_vectorZero.y; + } + local_4c = (float)CONCAT31(CONCAT21((short)(GHIDRA_UINT(&firePos) >> 0x10),bVar1),isShooting); + if (((iVar10 != 0) && (*GHIDRA_CAST((iVar10 + 0x28)) == 1)) && (0 < *GHIDRA_CAST((iVar10 + 0x18f8)))) { + local_40 = 1.0; + pfVar3 = &local_40; + if (1.0 <= fVar8) { + pfVar3 = &local_44; + } + fVar8 = *pfVar3; + } + if ((-1000.0 < fVar8) && + (local_4c = (float)GHIDRA_UINT(isShooting), fVar8 <= *GHIDRA_CAST((GHIDRA_CAST(player) + 0x14)))) { + local_4c = 0.0; + } + aimDirection.x = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x20)); + aimDirection.y = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x24)); + bVar1 = Weapon::IsAxisAligned(player); + if (bVar1 == 0) { + fVar8 = sqrtf(aimDirection.y * aimDirection.y + aimDirection.x * aimDirection.x); + iVar10 = extraout_ECX_00; + if (0.0 < fVar8) { + aimDirection.x = (1.0 / fVar8) * aimDirection.x; + aimDirection.y = (float)(aimDirection.y * (1.0 / fVar8)); + } + } + else { + puVar9 = GHIDRA_CAST(0x0); + if (ABS(aimDirection.x) <= ABS(aimDirection.y)) { + aimDirection.x = 0.0; + if (0.0 <= aimDirection.y) { + puVar9 = GHIDRA_CAST(0x3f800000); + } + else { + puVar9 = &DAT_bf800000; + } + } + else if (0.0 <= aimDirection.x) { + aimDirection.x = 1.0; + } + else { + aimDirection.x = (float)&DAT_bf800000; + } + iVar10 = extraout_ECX; + aimDirection.y = (float)puVar9; + } + fVar8 = 1.0; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_4c)) + 0x0))) == '\0') { + if (isInterpolated == 0) { + this_00 = GHIDRA_CAST(&local_44); + local_40 = 1.0; + pAVar4 = GHIDRA_CAST(&local_40); + if (1.0 <= local_44) { + pAVar4 = this_00; + } + if (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x14)) < *GHIDRA_CAST((pAVar4->_filename)._buf)) { +LAB_00a03e32: + pVVar5 = directionLocal; + } + else { + *GHIDRA_CAST((GHIDRA_CAST(player) + 0xc)) = local_44 / 3.0; + if (ownerAsPlayer == GHIDRA_CAST(0x0)) { + ownerPlayer = 7 - GHIDRA_INT((local_44 * -0.15)); + iVar10 = 0xb; + if (0xb < ownerPlayer) { + iVar10 = ownerPlayer; + } + Weapon::SetBlinkTime(player,iVar10,ownerPlayer); + } + Weapon::TriggerTearEffects(player,&aimDirection,1); + Weapon::get_owner_position(player,&firePos); + local_4c = aimDirection.x * 10.0; + local_44 = aimDirection.y * 10.0; + pVVar5 = Weapon::get_tear_movement_inheritance(player,&scratchVec,&aimDirection); + local_4c = local_4c + pVVar5->x; + local_44 = local_44 + pVVar5->y; + iVar10 = unusedArg; + Weapon::GetMultiShotParams(player,multiShotParams,unusedArg); + local_40 = -local_44; + if (isShootingBackwards != '\0') { + local_58.x = -local_4c * local_70.y; + local_58.y = local_40 * local_70.y; + tear = fire_fetus_tear(player,&firePos,&local_58,0,*GHIDRA_CAST((GHIDRA_CAST(player) + 4)),1.0,iVar10); + iVar10 = 0xa03a92; + (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); + } + if (isShootingSideways != '\0') { + local_58.x = local_4c * local_70.y; + local_58.y = local_40 * local_70.y; + tear = fire_fetus_tear(player,&firePos,&local_58,0,*GHIDRA_CAST((GHIDRA_CAST(player) + 4)),1.0,iVar10); + iVar10 = 0xa03adf; + (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); + local_58.x = -local_4c * local_70.y; + local_58.y = local_44 * local_70.y; + tear = fire_fetus_tear(player,&firePos,&local_58,0,*GHIDRA_CAST((GHIDRA_CAST(player) + 4)),1.0,iVar10); + (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); + } + local_40 = (float)(numRandomDirTears & 0xffff); + if (local_40 != 0.0) { + do { + source = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + uVar2 = Random(); + spreadAngle = ((float)((double)GHIDRA_INT(uVar2) + + __uint_to_double_fixup[-(GHIDRA_INT(uVar2) >> 0x1f)]) * 2.3283064e-10 * + 50.0 - 25.0) * 0.017453292; + local_58.y = cos(spreadAngle); + iVar10 = 0xa03b99; + fVar8 = sin(spreadAngle); + scratchVec.x = (local_4c * local_58.y - local_44 * fVar8) * local_70.y; + scratchVec.y = (local_4c * fVar8 + local_44 * local_58.y) * local_70.y; + tear = fire_fetus_tear(player,&firePos,&scratchVec,0,source,1.0,iVar10); + (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); + local_40 = (float)(GHIDRA_INT(local_40) - 1); + } while (local_40 != 0.0); + local_40 = 0.0; + } + iVar10 = 0; + if (0 < multiShotParams[0]) { + local_58.x = local_4c; + local_58.y = local_44; + do { + shotDirection.y = local_58.y; + shotDirection.x = local_58.x; + uVar2 = numRandomDirTears; + Entity_Player::GetMultiShotPositionVelocity + (&local_34,iVar10,9,shotDirection,local_70.y,multiShotParams[0],fStack_a0, + fStack_9c,fStack_98,fStack_94,iStack_90,fStack_8c,(uint8_t)uStack_88, + (short)numRandomDirTears); + scratchVec.x = firePos.x + local_34; + scratchVec.y = local_30 + firePos.y; + tear = fire_fetus_tear(player,&scratchVec,&local_2c,0,*GHIDRA_CAST((GHIDRA_CAST(player) + 4)),1.0, + uVar2); + (**(code **)(*GHIDRA_CAST(tear) + 0xc))(); + iVar10 = iVar10 + 1; + } while (iVar10 < multiShotParams[0]); + } + pVVar5 = directionLocal; + this_00 = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + local_58.y = (float)this_00; + if ((this_00 != GHIDRA_CAST(0x0)) && ((this_00->_animDefaultName)._size == 1)) { + fVar8 = 2.10195e-44; + local_2c.y = 2.10195e-44; + local_14 = (void *)0x0; + local_34 = (float)0x6f6f6853; + local_2c.x = 1.82169e-44; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x0))) = 'S'; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x1))) = 'u'; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x2))) = 'b'; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x3))) = 'A'; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x4))) = 'n'; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x5))) = 'i'; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x6))) = 'm'; + (*GHIDRA_CAST((GHIDRA_CAST(&(subAnimName)) + 0x7))) = '_'; + local_30 = (float)CONCAT22((*GHIDRA_CAST((GHIDRA_CAST(&(local_30)) + 0x2))),0x74); + pvVar6 = (g_manager->_itemConfig)._collectibles._begin; + if (GHIDRA_INT((g_manager->_itemConfig)._collectibles._end) - GHIDRA_INT(pvVar6) >> 2 < 0x2a7) { + local_40 = 0.0; + } + else { + local_40 = *GHIDRA_CAST((GHIDRA_CAST(pvVar6) + 0xa98)); + } + pfVar3 = this_00[0x10]._championColor._colorize + 2; + iVar10 = 0xf; + do { + if ((-1 < GHIDRA_INT(*pfVar3)) && (*GHIDRA_CAST((pfVar3 + 3)) != '\0')) { + this_00 = GHIDRA_CAST((GHIDRA_INT(*pfVar3) * 0x130 + + GHIDRA_INT(((GHIDRA_CAST((GHIDRA_INT(local_58.y) + 0x1140)))->_championColor)._tint[3]) + )); + if (*GHIDRA_CAST(this_00[1]._filename._buf) == local_40) { + animName = GHIDRA_CAST(&subAnimName); + if (0xf < GHIDRA_UINT(fVar8)) { + animName = GHIDRA_CAST(subAnimName); + } + ANM2::PlayOverlay(this_00,animName,1); + this_00 = extraout_ECX_01; + fVar8 = local_2c.y; + } + } + player = weapon; + pfVar3 = pfVar3 + 4; + iVar10 = iVar10 + -1; + } while (iVar10 != 0); + local_14 = (void *)0xffffffff; + if (0xf < GHIDRA_UINT(fVar8)) { + uVar2 = GHIDRA_INT(fVar8) + 1; + pvVar6 = GHIDRA_CAST(subAnimName); + if (0xfff < uVar2) { + pvVar6 = *(void **)(GHIDRA_INT(GHIDRA_CAST(subAnimName)) + -4); + uVar2 = GHIDRA_INT(fVar8) + 0x24; + if (0x1f < GHIDRA_UINT((GHIDRA_INT(GHIDRA_CAST(subAnimName)) + (-4 - GHIDRA_INT(pvVar6))))) { + /* WARNING: Subroutine does not return */ + _invalid_parameter_noinfo_noreturn(); + } + } + operator_delete(pvVar6,uVar2); + this_00 = extraout_ECX_02; + } + goto LAB_00a03e32; + } + Weapon::UpdateHeadChargeAnimation(player,0x2a6,2,directionLocal,-1.0); + this_00 = extraout_ECX_04; + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x14)))) = 0; + bVar1 = Weapon::is_c_section_anim_finished(player,GHIDRA_INT(this_00)); + iVar10 = unusedCollectibleId; + if (bVar1 != 0) { + Weapon::update_c_section_charge_anim(player,unusedCollectibleId,0,pVVar5,0.0); + iVar10 = extraout_ECX_03; + } + } + else { + pVVar5 = directionLocal; + } + bVar1 = Weapon::is_c_section_anim_finished(player,iVar10); + if (bVar1 == 0) { + ExceptionList = local_1c; + return; + } + goto LAB_00a03f31; + } + local_40 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x14)); + if (local_44 <= local_40) { + puVar9 = &DAT_bf800000; + ownerPlayer = 1; +LAB_00a03f02: + pVVar5 = directionLocal; + Weapon::update_c_section_charge_anim(player,iVar10,ownerPlayer,directionLocal,(float)puVar9); + iVar10 = extraout_ECX_06; + } + else { + if (isInterpolated == 0) { + if (*GHIDRA_CAST((GHIDRA_CAST(player) + 4)) != 0) { + fVar8 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(player) + 4)) + 0x39c)); + } + local_40 = local_40 + fVar8; + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x14)) = local_40; + } + bVar1 = Weapon::is_c_section_anim_finished(player,iVar10); + iVar10 = extraout_ECX_05; + pVVar5 = directionLocal; + if (bVar1 != 0) { + puVar9 = GHIDRA_CAST(((local_40 / local_44) * 18.0)); + ownerPlayer = 0; + goto LAB_00a03f02; + } + } + if (isInterpolated == 0) { + Weapon::SetBlinkTime(player,1,iVar10); + newAimDirection = Weapon::get_aim_direction(player,&local_70,pVVar5); + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x20)) = newAimDirection->x; + *GHIDRA_CAST((GHIDRA_CAST(player) + 0x24)) = newAimDirection->y; + } +LAB_00a03f31: + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x3c)))) = pVVar5->x; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x40)))) = pVVar5->y; + ExceptionList = local_1c; + return; +} + // 00a03f60 -long double Weapon_Fetus::GetMaxCharge() +float Weapon_Fetus::GetMaxCharge() { float maxCharge; diff --git a/generated-src/weapon_knife.cpp b/generated-src/weapon_knife.cpp index 45521ab..7a7a130 100644 --- a/generated-src/weapon_knife.cpp +++ b/generated-src/weapon_knife.cpp @@ -1,5 +1,795 @@ #include "classes.h" +// 00a03f90 +void Weapon_Knife::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + void *pvVar1; + int iVar2; + uint32_t uVar3; + Entity_Knife *pEVar4; + uint8_t bVar5; + Entity_Knife **ppEVar6; + float aimTargetX; + uint16_t uVar10; + undefined3 uVar9; + Vector *tmpVec; + BitSet128 *maskedTearFlags; + Entity_Knife **ppEVar7; + uint32_t rngValue; + int iVar8; + Entity *parent; + float aimTargetY; + Entity_Player *ownerPlayer; + int iVar11; + int iVar12; + char cVar13; + float fVar14; + uint32_t uVar15; + int *piVar16; + uint32_t *puVar17; + bool bVar18; + float fVar19; + undefined3 in_stack_00000009; + undefined3 in_stack_0000000d; + Entity_Knife aEStackY_7ffffdb4 [1636800]; + Entity_Knife *pEVar20; + Weapon_MultiShotParams *outParams; + Entity_Player *pEVar21; + uint8_t local_94 [12]; + float fStack_88; + Entity_Knife *knifeRange; + uint8_t multiShotParams [29]; + uint8_t bStack_63; + uint8_t bStack_62; + uint32_t uStack_60; + Entity_Knife *local_5c; + Vector local_58; + Entity_Knife *local_50; + float local_4c; + float shotSpeed; + uint32_t local_44; + uint8_t orbitTearFlags [4]; + Entity_Knife *knifeList; + Vector local_38; + float local_30; + Entity_Knife *local_2c; + char isMomsEye; + Weapon *local_24; + Entity_Player *local_20; + uint32_t *local_1c; + Entity_Player *local_18; + char isMarkedAim; + void *local_10; + uint8_t *puStack_c; + void *local_8; + Entity_Knife *knife; + + local_8 = (void *)0xffffffff; + puStack_c = &LAB_00b1081d; + local_10 = ExceptionList; + ExceptionList = &local_10; + pEVar20 = _isShooting; + knife = _isInterpolated; + local_24 = this; + Weapon::Fire(this,direction,isShooting,isInterpolated); + local_18 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + local_30 = 0.0; + local_20 = GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 4 & 0xffffff01)); + local_44 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 6 & 0xffffff01; + if (local_18 == GHIDRA_CAST(0x0)) { +LAB_00a04011: + pEVar21 = GHIDRA_CAST(0x0); + if ((local_18 == GHIDRA_CAST(0x0)) || (local_18->_type != 1)) { +LAB_00a04022: + local_18 = GHIDRA_CAST(0x0); + } + } + else { + if (local_18->_type != 1) { + if (local_18->_type != 3) goto LAB_00a04011; + pEVar21 = *GHIDRA_CAST(&(GHIDRA_CAST(&local_18->_isControlsEnabled))->_l); + goto LAB_00a04022; + } + pEVar21 = local_18; + } + if (pEVar21 == GHIDRA_CAST(0x0)) { +LAB_00a04043: + isMarkedAim = '\0'; + } + else { + knife = GHIDRA_CAST(0x0); + pEVar20 = GHIDRA_CAST(0x18a); + bVar5 = Entity_Player::HasCollectible(pEVar21,0x18a,0); + isMarkedAim = '\x01'; + if (bVar5 == 0) goto LAB_00a04043; + } + ppEVar7 = GHIDRA_CAST((GHIDRA_INT(this) + 0x10)); + local_5c = GHIDRA_CAST(0x3a83126f); + ppEVar6 = &local_5c; + if (0.001 < (float)*ppEVar7 || (float)*ppEVar7 == 0.001) { + ppEVar6 = ppEVar7; + } + local_2c = *ppEVar6; + if (local_18 == GHIDRA_CAST(0x0)) { + fVar14 = 0.0; + } + else { + knife = GHIDRA_CAST(0x6e); + pEVar20 = GHIDRA_CAST(0xa0407f); + bVar5 = TemporaryEffects::HasNullEffect(&local_18->_temporaryeffects,0x6e); + fVar14 = 0.0; + if (bVar5 != 0) { + fVar14 = 7.00649e-45; + } + local_30 = fVar14; + } + if (pEVar21 == GHIDRA_CAST(0x0)) { + fVar19 = 260.0; + } + else { + fVar19 = pEVar21->_tearrange; + } + knifeRange = GHIDRA_CAST((fVar19 * 0.6)); + parent = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (parent == GHIDRA_CAST(0x0)) { +LAB_00a04100: + shotSpeed = 1.0; + } + else if (parent->_type == 1) { + shotSpeed = parent[5]._pendingDamage; + } + else { + if ((parent->_type != 3) || (*GHIDRA_CAST((parent + 1)) == 0)) goto LAB_00a04100; + shotSpeed = *GHIDRA_CAST((*GHIDRA_CAST((parent + 1)) + 0x1464)); + } + local_50 = knifeRange; + if ((char)local_20 != '\0') { + if (isInterpolated != 0) goto LAB_00a04e59; + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) == 0) { + _isInterpolated = Weapon::fire_knife(this,parent,GHIDRA_UINT(fVar14),1,GHIDRA_INT(pEVar20),GHIDRA_INT(knife),0.0); + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) != _isInterpolated) { + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) != GHIDRA_CAST(0x0)) { + local_58.y = (float)(GHIDRA_INT(this) + 0x44); + msvc::multiset::erase(); + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) = _isInterpolated; + if (_isInterpolated != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + } + } + if (pEVar21 != GHIDRA_CAST(0x0)) { + init_knife(this,_isInterpolated); + } + (**(code **)&(*GHIDRA_CAST((GHIDRA_CAST(((*GHIDRA_CAST(_isInterpolated)))) + 0xc))))(); + } + knife = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + local_50 = knife; + init_knife(this,knife); + if ((local_18 != GHIDRA_CAST(0x0)) && + (iVar8 = Entity::GetIntervalTicks(GHIDRA_CAST(local_18),(float)local_2c,0.0), iVar8 != 0)) { + if (knife == GHIDRA_CAST(0x0)) { +LAB_00a04c17: + tmpVec = MusicManager::RandomVector(&local_38); + } + else { + local_58.y = (knife->_pos).y; + local_58.x = (knife->_pos).x; + local_38.x = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x33c)); + local_38.y = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x340)); + bVar5 = (GHIDRA_CAST((&local_58)))->Vector::operator_ne(&local_38); + if (bVar5 == 0) goto LAB_00a04c17; + local_38.x = (knife->_pos).x - *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x33c)); + local_38.y = (knife->_pos).y - *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x340)); + tmpVec = (GHIDRA_CAST((&local_38)))->Vector::Normalized(&local_58); + } + Weapon::TriggerTearEffects(this,tmpVec,1); + } + pEVar20 = g_game->_room; + if ((*GHIDRA_CAST(pEVar20) != '\0') && (g_game->_frameCount == pEVar20[3]._entityRef3._type)) { + tmpVec = Weapon::get_owner_position(this,&local_38); + pEVar20 = GHIDRA_CAST(tmpVec->x); + (knife->_pos).x = (float)pEVar20; + (knife->_pos).y = tmpVec->y; + } + pEVar21 = GHIDRA_CAST(multiShotParams); + Weapon::GetMultiShotParams(this,pEVar21,GHIDRA_INT(pEVar20)); + local_2c = GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&((short)multiShotParams)) + 0x0))) + -1)); + _isInterpolated = GHIDRA_CAST(0x0); + knifeList = GHIDRA_CAST(0x0); + if (GHIDRA_INT(local_2c) < 0) { + local_2c = GHIDRA_CAST(0x0); + } + ownerPlayer = GHIDRA_CAST(0x0); + local_20 = GHIDRA_CAST(0x0); + local_38.x = 0.0; + local_18 = GHIDRA_CAST(0x0); + local_38.y = 0.0; + local_8 = (void *)0x0; + local_44 = knife->_child; + if (local_44 != 0) { + do { + if (GHIDRA_CAST(local_38.x) == ownerPlayer) { + pEVar20 = GHIDRA_CAST(&local_44); + pEVar21 = GHIDRA_CAST(local_38.x); + msvc::vector::_Emplace_reallocate(); + ownerPlayer = GHIDRA_CAST(local_38.y); + } + else { + *GHIDRA_CAST(local_38.x) = local_44; + local_38.x = (float)(GHIDRA_INT(local_38.x) + 4); + } + local_44 = *GHIDRA_CAST((local_44 + 0x3c0)); + } while (local_44 != 0); + local_44 = 0; + local_20 = GHIDRA_CAST(local_38.x); + local_18 = ownerPlayer; + } + pEVar4 = knifeList; + local_58.y = (float)(GHIDRA_INT(local_20) - GHIDRA_INT(knifeList) >> 2); + local_38.x = (float)local_20; + _isInterpolated = knifeList; + if (GHIDRA_UINT(local_58.y) < local_2c) { + local_2c = GHIDRA_CAST((GHIDRA_INT(local_2c) - GHIDRA_INT(local_58.y))); + if (0 < GHIDRA_INT(local_2c)) { + do { + ownerPlayer = GHIDRA_CAST(local_38.x); + _isInterpolated = + Weapon::fire_knife(local_24,GHIDRA_CAST(knife),GHIDRA_UINT(local_30),0,GHIDRA_INT(pEVar21), + GHIDRA_INT(pEVar20),0.0); + pEVar21 = GHIDRA_CAST(0xa04d23); + pEVar20 = _isInterpolated; + init_knife(local_24,_isInterpolated); + if (ownerPlayer == local_18) { + pEVar20 = GHIDRA_CAST(&isInterpolated); + msvc::vector::_Emplace_reallocate(); + local_18 = GHIDRA_CAST(local_38.y); + } + else { + *GHIDRA_CAST(ownerPlayer) = _isInterpolated; + local_38.x = (float)(GHIDRA_INT(ownerPlayer) + 4); + ownerPlayer = pEVar21; + } + local_2c = GHIDRA_CAST((GHIDRA_INT(local_2c[-1]._sprite._color._offset) + 0x40f)); + pEVar21 = ownerPlayer; + } while (local_2c != GHIDRA_CAST(0x0)); + _isInterpolated = knifeList; + local_2c = GHIDRA_CAST(0x0); + } +LAB_00a04d8c: + fVar14 = (float)(GHIDRA_INT(local_38.x) - GHIDRA_INT(_isInterpolated) >> 2); + local_30 = 0.0; + pEVar20 = _isInterpolated; + if (fVar14 != 0.0) { + do { + local_50 = *(Entity_Knife **) + (GHIDRA_INT((&(pEVar20->_sprite)._filename + -3)) + GHIDRA_INT(local_30) * 4); + if (knife->_child != 0) { + local_58.y = (float)&knife->_child; + msvc::multiset::erase(); + pEVar20 = _isInterpolated; + } + knife->_child = local_50; + if (local_50 != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + pEVar20 = _isInterpolated; + } + knife = *GHIDRA_CAST((GHIDRA_INT((&(pEVar20->_sprite)._filename + -3)) + GHIDRA_INT(local_30) * 4)); + if (g_game->_frameCount == knife->_spawnFrame) { + (**(code **)(*GHIDRA_CAST(knife) + 0xc))(); + knife = *(Entity_Knife **) + (GHIDRA_INT((&(_isInterpolated->_sprite)._filename + -3)) + GHIDRA_INT(local_30) * 4); + pEVar20 = _isInterpolated; + } + local_30 = (float)(GHIDRA_INT(local_30) + 1); + } while (GHIDRA_UINT(local_30) < GHIDRA_UINT(fVar14)); + } + } + else { + pEVar20 = knifeList; + if (local_2c < GHIDRA_UINT(local_58.y)) { + knife = local_2c; + do { + (**(code **)(**GHIDRA_CAST((GHIDRA_INT((&(pEVar4->_sprite)._filename + -3)) + GHIDRA_INT(knife) * 4)) + 0x28) + )(); + knife = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((knife)) + 0x1)))); + } while (knife < GHIDRA_UINT(local_58.y)); + pEVar21 = GHIDRA_CAST((GHIDRA_INT((&(pEVar4->_sprite)._filename + -3)) + GHIDRA_INT(local_2c) * 4)); + local_38.x = (float)local_20; + if (pEVar21 != local_20) { + local_38.x = (float)pEVar21; + } + knife = local_50; + goto LAB_00a04d8c; + } + } + if (pEVar20 != GHIDRA_CAST(0x0)) { + uVar15 = GHIDRA_INT(local_18) - GHIDRA_INT(pEVar20) & 0xfffffffc; + knife = pEVar20; + if (0xfff < uVar15) { + knife = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(pEVar20[-1])) + 0x51c)))); + uVar15 = uVar15 + 0x23; + if (0x1f < GHIDRA_UINT((GHIDRA_INT(pEVar20) + (-4 - GHIDRA_INT(knife))))) { + /* WARNING: Subroutine does not return */ + _invalid_parameter_noinfo_noreturn(); + } + } + operator_delete(knife,uVar15); + } + this = local_24; +LAB_00a04e59: + iVar8 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + if (iVar8 == 0) { + ExceptionList = local_10; + return; + } + if (isShooting == 0) { + ExceptionList = local_10; + return; + } + shotSpeed = shotSpeed * 5.0; + fVar14 = direction->x; + _isInterpolated = GHIDRA_CAST(direction->y); + fVar19 = fVar14 * fVar14 + (float)_isInterpolated * (float)_isInterpolated; + if ((1.0 < fVar19) && (fVar19 = sqrtf(fVar19), 0.0 < fVar19)) { + fVar14 = direction->x * (1.0 / fVar19); + _isInterpolated = GHIDRA_CAST((direction->y * (1.0 / fVar19))); + } + fVar19 = *GHIDRA_CAST((iVar8 + 0x36c)); + if (fVar19 == 0.0) { + ExceptionList = local_10; + return; + } + *GHIDRA_CAST((iVar8 + 0x364)) = + (*GHIDRA_CAST((iVar8 + 0x39c)) * shotSpeed * (float)_isInterpolated * 0.5) / fVar19 + + *GHIDRA_CAST((iVar8 + 0x364)); + *GHIDRA_CAST((iVar8 + 0x360)) = + (*GHIDRA_CAST((iVar8 + 0x39c)) * shotSpeed * fVar14 * 0.5) / fVar19 + *GHIDRA_CAST((iVar8 + 0x360)) + ; + ExceptionList = local_10; + return; + } + if ((parent == GHIDRA_CAST(0x0)) || + ((((parent->_type != 1 && + ((parent->_type != 3 || (parent = *GHIDRA_CAST((parent + 1)), parent == GHIDRA_CAST(0x0))))) || + (pvVar1 = parent[4]._entityPtrReferrers._head, pvVar1 == (void *)0x0)) || + (isMarkedAim == '\0')))) { + aimTargetX = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x28)); + aimTargetY = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x2c)); + } + else { + aimTargetX = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x33c)); + aimTargetY = *GHIDRA_CAST((GHIDRA_CAST(pvVar1) + 0x340)); + } + uVar10 = (uint16_t)(GHIDRA_UINT(&local_38) >> 0x10); + uVar9 = CONCAT21(uVar10,(aimTargetX == g_vectorZero.x) << 6 | + (NAN(aimTargetX) || NAN(g_vectorZero.x)) << 2 | 2U | + aimTargetX < g_vectorZero.x); + if ((aimTargetX != g_vectorZero.x) || + (uVar9 = CONCAT21(uVar10,(aimTargetY == g_vectorZero.y) << 6 | + (NAN(aimTargetY) || NAN(g_vectorZero.y)) << 2 | 2U | + aimTargetY < g_vectorZero.y), aimTargetY != g_vectorZero.y)) { + isMarkedAim = '\x01'; + } + else { + isMarkedAim = '\0'; + } + local_24 = GHIDRA_CAST(CONCAT31(uVar9,isShooting)); + local_5c = GHIDRA_CAST(0x3dcccccd); + local_38.x = aimTargetX; + local_38.y = aimTargetY; + if (((isInterpolated == 0) && (isShooting != 0)) && (isMarkedAim != '\0')) { + pEVar20 = GHIDRA_CAST(0xa041bd); + tmpVec = Weapon::get_owner_position(this,&local_38); + fVar14 = aimTargetY - tmpVec->y; + fVar19 = aimTargetX - tmpVec->x; + knife = GHIDRA_CAST(0xa041d7); + fVar14 = sqrtf(fVar14 * fVar14 + fVar19 * fVar19); + fVar19 = (fVar14 - 50.0) / 250.0; + if (fVar19 <= 0.0) { + fVar19 = 0.0; + } + if (1.0 <= fVar19) { + fVar19 = 1.0; + } + fVar19 = (((float)local_2c * 4.0 - 5.0) * fVar19 + 5.0) - 1.0; + if ((0.0 < fVar19) && + (local_5c = GHIDRA_CAST((fVar14 / ((fVar19 / (float)local_2c) * 4.0))), + (float)local_5c <= 0.1)) { + local_5c = GHIDRA_CAST(0x3dcccccd); + } + local_24 = GHIDRA_CAST((GHIDRA_UINT(local_24) & 0xff)); + if (fVar19 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14))) { + local_24 = GHIDRA_CAST(0x0); + } + } + if (pEVar21 == GHIDRA_CAST(0x0)) { +LAB_00a0427f: + _isShooting = GHIDRA_CAST((GHIDRA_UINT(_isShooting) & 0xffffff)); + if (pEVar21 != GHIDRA_CAST(0x0)) goto LAB_00a04287; +LAB_00a0429a: + isMomsEye = '\0'; + } + else { + knife = GHIDRA_CAST(0x0); + pEVar20 = GHIDRA_CAST(0x57); + bVar5 = Entity_Player::HasCollectible(pEVar21,0x57,0); + if (bVar5 == 0) goto LAB_00a0427f; + _isShooting = GHIDRA_CAST(CONCAT13(1,_isShooting)); +LAB_00a04287: + knife = GHIDRA_CAST(0x0); + pEVar20 = GHIDRA_CAST(0x37); + bVar5 = Entity_Player::HasCollectible(pEVar21,0x37,0); + if (bVar5 == 0) goto LAB_00a0429a; + isMomsEye = '\x01'; + } + uVar15 = 0; + do { + if (((uVar15 == 0) || ((uVar15 == 1 && (isMomsEye != '\0')))) || + ((*GHIDRA_CAST((GHIDRA_CAST(&(in_stack_00000009)) + 0x2))) != '\0')) { + if (*GHIDRA_CAST((GHIDRA_CAST(this) + uVar15 * 4 + 0x44)) == 0) { + local_20 = (Entity_Player *) + Weapon::fire_knife(this,*GHIDRA_CAST((GHIDRA_CAST(this) + 4)),GHIDRA_UINT(local_30),1,GHIDRA_INT(pEVar20) + ,GHIDRA_INT(knife),0.0); + pEVar21 = *GHIDRA_CAST((GHIDRA_CAST(this) + uVar15 * 4 + 0x44)); + puVar17 = GHIDRA_CAST((GHIDRA_INT(this) + uVar15 * 4 + 0x44)); + if (pEVar21 != local_20) { + if (pEVar21 != GHIDRA_CAST(0x0)) { + pEVar20 = GHIDRA_CAST(0xa04339); + local_1c = puVar17; + msvc::multiset::erase(); + puVar17 = GHIDRA_CAST((GHIDRA_INT(this) + uVar15 * 4 + 0x44)); + } + *puVar17 = local_20; + if (local_20 != GHIDRA_CAST(0x0)) { + pEVar20 = GHIDRA_CAST(0xa0434e); + msvc::multiset::insert(); + } + } + *GHIDRA_CAST(((local_20->_bodySprite)._animDefaultName._buf + 4)) = (&DAT_00b81710)[uVar15] + ; + knife = GHIDRA_CAST(0xa04363); + (**(code **)(*GHIDRA_CAST(local_20) + 0xc))(); + } + } + else { + piVar16 = *GHIDRA_CAST((GHIDRA_CAST(this) + uVar15 * 4 + 0x44)); + if (piVar16 != GHIDRA_CAST(0x0)) { + knife = GHIDRA_CAST(0xa042c8); + (**(code **)(*piVar16 + 0x28))(); + if (*GHIDRA_CAST((GHIDRA_CAST(this) + uVar15 * 4 + 0x44)) != 0) { + knife = GHIDRA_CAST(&local_20); + pEVar20 = GHIDRA_CAST(0xa042eb); + local_20 = GHIDRA_CAST((GHIDRA_INT(this) + uVar15 * 4 + 0x44)); + msvc::multiset::erase(); + *GHIDRA_CAST((GHIDRA_CAST(this) + uVar15 * 4 + 0x44)) = 0; + } + } + } + uVar15 = uVar15 + 1; + } while (uVar15 < 4); + local_20 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + if (local_20 == GHIDRA_CAST(0x0)) { + ExceptionList = local_10; + return; + } + puVar17 = GHIDRA_CAST((GHIDRA_INT(this) + 0x44)); + _isShooting = GHIDRA_CAST(0x4); + do { + if (GHIDRA_CAST(*puVar17) != GHIDRA_CAST(0x0)) { + init_knife(this,GHIDRA_CAST(*puVar17)); + } + puVar17 = puVar17 + 1; + _isShooting = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(_isShooting[-1])) + 0x51f)))); + } while (_isShooting != GHIDRA_CAST(0x0)); + Weapon::IsAxisAligned(this); + cVar13 = *GHIDRA_CAST((GHIDRA_CAST(local_20) + 0x464)); + if (((cVar13 == '\0') || ((char)local_44 != '\0')) || (isMarkedAim != '\0')) { + _isShooting = GHIDRA_CAST(direction->x); + local_1c = GHIDRA_CAST(direction->y); + if ((((char)local_24 == '\0') && (cVar13 == '\0')) && + ((0.0 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) && (isMarkedAim == '\0')))) { + _isShooting = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); + local_1c = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)); + } + if (((float)local_1c == 0.0) && ((float)_isShooting == 0.0)) { + if (local_18 == GHIDRA_CAST(0x0)) { + if (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x28)) == 3) { + switch(*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0xd58))) { + case 0: + goto LAB_00a0445a; + case 1: + goto LAB_00a04464; + case 2: + goto LAB_00a044dd; + case 3: + local_1c = GHIDRA_CAST(0x3f800000); + } + } + } + else { + switch(local_18->_headDirection) { + case 0: +LAB_00a0445a: + _isShooting = GHIDRA_CAST(&DAT_bf800000); + break; + case 1: +LAB_00a04464: + local_1c = GHIDRA_CAST(&DAT_bf800000); + break; + case 2: +LAB_00a044dd: + _isShooting = GHIDRA_CAST(0x3f800000); + break; + case 3: + local_1c = GHIDRA_CAST(0x3f800000); + } + } + } + if (((char)local_44 != '\0') && (isMarkedAim == '\0')) { + if (ABS((float)_isShooting) <= ABS((float)local_1c)) { + _isShooting = GHIDRA_CAST(0x0); + if (0.0 <= (float)local_1c) { + local_1c = GHIDRA_CAST(0x3f800000); + } + else { + local_1c = GHIDRA_CAST(&DAT_bf800000); + } + } + else { + local_1c = GHIDRA_CAST(0x0); + if (0.0 <= (float)_isShooting) { + _isShooting = GHIDRA_CAST(0x3f800000); + } + else { + _isShooting = GHIDRA_CAST(&DAT_bf800000); + } + } + } + piVar16 = GHIDRA_CAST((GHIDRA_INT(this) + 0x44)); + local_18 = GHIDRA_CAST(0x0); + do { + if (*piVar16 != 0) { + fVar14 = atan2f((float)local_1c,(float)_isShooting); + fVar14 = fVar14 * 57.295776 + *GHIDRA_CAST((GHIDRA_INT(&DAT_00b81710) + GHIDRA_INT(local_18))); + if (360.0 < ABS(fVar14)) { + fVar14 = fmodf(fVar14,360.0); + } + if (fVar14 <= 180.0) { + if (fVar14 < -180.0) { + fVar14 = fVar14 + 360.0; + } + } + else { + fVar14 = fVar14 - 360.0; + } + *GHIDRA_CAST((*piVar16 + 0x438)) = fVar14; + local_4c = (float)*piVar16; + *GHIDRA_CAST((GHIDRA_CAST(local_4c) + 0x43c)) = 0; + } + local_18 = GHIDRA_CAST((GHIDRA_INT(local_18) + 4)); + piVar16 = piVar16 + 1; + } while (local_18 < 0x10); + cVar13 = *GHIDRA_CAST((GHIDRA_CAST(local_20) + 0x464)); + } + pEVar21 = local_20; + local_2c = GHIDRA_CAST(((float)local_2c * 4.0)); + if ((char)local_24 == '\0') { + if ((cVar13 == '\0') && (fVar14 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)), 0.0 < fVar14)) { + local_4c = (float)local_2c; + if (fVar14 <= (float)local_2c) { + local_4c = fVar14; + } + Weapon::TriggerTearEffects(this,direction,1); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_94)) + 0x0))) = *GHIDRA_CAST((GHIDRA_CAST(pEVar21) + 0x410)); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_94)) + 0x4))) = *GHIDRA_CAST((GHIDRA_CAST(pEVar21) + 0x414)); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_94)) + 0x8))) = *GHIDRA_CAST((GHIDRA_CAST(pEVar21) + 0x418)); + fStack_88 = *GHIDRA_CAST((GHIDRA_CAST(pEVar21) + 0x41c)); + local_18 = GHIDRA_CAST(0x43960000); + _isShooting = GHIDRA_CAST(0x43960000); + outParams = GHIDRA_CAST(0xa046fd); + maskedTearFlags = + BitSet128::operator_and + (GHIDRA_CAST(orbitTearFlags),GHIDRA_CAST(local_94),&g_tearFlagOrbit); + if ((GHIDRA_INT(maskedTearFlags->_l) != 0 || *GHIDRA_CAST((GHIDRA_INT(&maskedTearFlags->_l) + 4)) != 0) || + (GHIDRA_INT(maskedTearFlags->_h) != 0 || *GHIDRA_CAST((GHIDRA_INT(&maskedTearFlags->_h) + 4)) != 0)) { + local_18 = GHIDRA_CAST(0x47c35000); + _isShooting = GHIDRA_CAST(0x47c35000); + } + ownerPlayer = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if ((ownerPlayer == GHIDRA_CAST(0x0)) || + ((ownerPlayer->_type != 1 && + ((ownerPlayer->_type != 3 || + (ownerPlayer = *GHIDRA_CAST(&ownerPlayer->_isControlsEnabled), + ownerPlayer == GHIDRA_CAST(0x0))))))) { + _isInterpolated = GHIDRA_CAST(0x0); + (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0x14))) = 1.4013e-45; + (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0x0))) = 0; + uVar15 = 0; + (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0x18))) = 0.0; + stack0xffffff9c = GHIDRA_CAST((GHIDRA_UINT(stack0xffffff9c) & 0xff000000)); + (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0x4))) = 0.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0x8))) = 0.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0xc))) = 0.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0x10))) = 0.0; + local_24 = GHIDRA_CAST(0x0); + uStack_60 = uStack_60 & 0xffff0000; + } + else { + outParams = GHIDRA_CAST(multiShotParams); + Entity_Player::GetMultiShotParams(ownerPlayer,outParams,*GHIDRA_CAST((GHIDRA_CAST(this) + 0x30))); + register0x0000001e = (uint16_t)(GHIDRA_UINT(pEVar21) >> 0x10); + _isInterpolated = (*GHIDRA_CAST((GHIDRA_CAST(&(multiShotParams)) + 0x0))); + uVar15 = GHIDRA_UINT(CONCAT11(bStack_63,bStack_62)); + local_24 = GHIDRA_CAST((uStack_60 & 0xffff)); + } + direction = GHIDRA_CAST(0x0); + do { + uVar3 = _isInterpolated; + knife = *GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT(direction) * 4 + 0x44)); + if (knife != GHIDRA_CAST(0x0)) { + if (direction != GHIDRA_CAST(0x0)) { + if (direction == GHIDRA_CAST(0x1)) { + cVar13 = (char)(uVar15 >> 8); + } + else { + if (direction < GHIDRA_CAST(0x2)) goto LAB_00a04912; + cVar13 = (char)uVar15; + } + if (cVar13 == '\0') goto LAB_00a04912; + } + ppEVar7 = &knifeRange; + if ((float)local_18 <= (float)local_50) { + ppEVar7 = GHIDRA_CAST(&isShooting); + } + pEVar20 = *ppEVar7; + if ((float)pEVar20 <= (float)local_5c) { + pEVar20 = local_5c; + } + outParams = GHIDRA_CAST((local_4c / (float)local_2c)); + Entity_Knife::Shoot(knife,(float)outParams,(float)pEVar20); + puVar17 = GHIDRA_CAST(0x0); + if (0 < (short)uVar3) { + local_38.x = 1.0; + local_1c = GHIDRA_CAST((GHIDRA_INT((short)uVar3) / 2)); + local_38.y = 0.0; + do { + outParams = stack0xffffff9c; + FUN_009f4230(local_94,puVar17,4,local_38.x,local_38.y,shotSpeed); + iVar8 = 0xa04873; + fVar14 = atan2f(fStack_88,(*GHIDRA_CAST((GHIDRA_CAST(&((float)local_94)) + 0x8)))); + fVar14 = fVar14 * 57.295776; + local_58.y = *GHIDRA_CAST((GHIDRA_CAST(this) + GHIDRA_INT(direction) * 4 + 0x44)); + if (puVar17 == local_1c) { + if (360.0 < ABS(fVar14)) { + fVar14 = fmodf(fVar14,360.0); + } + if (fVar14 <= 180.0) { + if (fVar14 < -180.0) { + fVar14 = fVar14 + 360.0; + } + *GHIDRA_CAST((GHIDRA_CAST(local_58.y) + 0x43c)) = fVar14; + } + else { + *GHIDRA_CAST((GHIDRA_CAST(local_58.y) + 0x43c)) = fVar14 - 360.0; + } + } + else { + knife = Weapon::fire_knife(this,GHIDRA_CAST(local_58.y),GHIDRA_UINT(local_30),0,GHIDRA_INT(outParams) + ,iVar8,fVar14); + (**(code **)(*GHIDRA_CAST(knife) + 0xc))(); + } + puVar17 = GHIDRA_CAST((GHIDRA_INT(puVar17) + 1)); + } while (GHIDRA_INT(puVar17) < GHIDRA_INT((short)_isInterpolated)); + } + } +LAB_00a04912: + direction = GHIDRA_CAST((GHIDRA_INT(&direction->x) + 1)); + uVar15 = GHIDRA_UINT(CONCAT11(bStack_63,bStack_62)); + } while (GHIDRA_INT(direction) < 4); + for (uVar15 = GHIDRA_UINT(local_24) & 0xffff; uVar15 != 0; uVar15 = uVar15 - 1) { + iVar8 = 0xa04937; + rngValue = Random(); + knife = Weapon::fire_knife(this,*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)),GHIDRA_UINT(local_30),0, + GHIDRA_INT(outParams),iVar8, + (float)((double)GHIDRA_INT(rngValue) + + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * + 2.3283064e-10 * 360.0); + (**(code **)(*GHIDRA_CAST(knife) + 0xc))(); + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = 0; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = g_vectorZero.x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = g_vectorZero.y; + } + } + else if (cVar13 == '\0') { + if (isInterpolated == 0) { + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) == 0) { + fVar14 = 1.0; + } + else { + fVar14 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x39c)); + } + fVar14 = fVar14 + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)); + fVar19 = (float)local_2c; + if (fVar14 <= (float)local_2c) { + fVar19 = fVar14; + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = fVar19; + } + tmpVec = Weapon::get_aim_direction(this,&local_38,direction); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = tmpVec->x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = tmpVec->y; + } + if (((*GHIDRA_CAST((GHIDRA_CAST(local_20) + 0x464)) == '\0') || + (25.0 < *GHIDRA_CAST((GHIDRA_CAST(local_20) + 0x444)) || *GHIDRA_CAST((GHIDRA_CAST(local_20) + 0x444)) == 25.0)) || + (*GHIDRA_CAST((GHIDRA_CAST(local_20) + 0x448)) <= 0.0)) { + iVar8 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (((iVar8 != 0) && (iVar11 = iVar8, *GHIDRA_CAST((iVar8 + 0x28)) == 1)) || + ((iVar11 = 0, iVar8 == 0 || (*GHIDRA_CAST((iVar8 + 0x28)) != 3)))) { + if (iVar11 != 0) { + iVar8 = *GHIDRA_CAST((iVar11 + 0x1338)); + if (iVar8 < 7) { + iVar8 = 7; + } + *GHIDRA_CAST((iVar11 + 0x1338)) = iVar8; + } + goto LAB_00a04a62; + } + iVar11 = *GHIDRA_CAST((iVar8 + 0xd50)); + iVar12 = 7; + bVar18 = SBORROW4(iVar11,7); + iVar2 = iVar11 + -7; + } + else { + iVar8 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (((iVar8 != 0) && (iVar11 = iVar8, *GHIDRA_CAST((iVar8 + 0x28)) == 1)) || + ((iVar11 = 0, iVar8 == 0 || (*GHIDRA_CAST((iVar8 + 0x28)) != 3)))) { + if (iVar11 != 0) { + iVar8 = *GHIDRA_CAST((iVar11 + 0x1338)); + if (iVar8 < 0xf) { + iVar8 = 0xf; + } + *GHIDRA_CAST((iVar11 + 0x1338)) = iVar8; + } + goto LAB_00a04a62; + } + iVar11 = *GHIDRA_CAST((iVar8 + 0xd50)); + iVar12 = 0xf; + bVar18 = SBORROW4(iVar11,0xf); + iVar2 = iVar11 + -0xf; + } + if (bVar18 != iVar2 < 0) { + iVar11 = iVar12; + } + *GHIDRA_CAST((iVar8 + 0xd50)) = iVar11; +LAB_00a04a62: + if (((*GHIDRA_CAST((GHIDRA_CAST(local_20) + 0x464)) != '\0') && (isMarkedAim == '\0')) && + ((char)local_44 == '\0')) { + iVar8 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (((iVar8 == 0) || (iVar11 = iVar8, *GHIDRA_CAST((iVar8 + 0x28)) != 1)) && + ((iVar11 = 0, iVar8 != 0 && (*GHIDRA_CAST((iVar8 + 0x28)) == 3)))) { + iVar11 = *GHIDRA_CAST((iVar8 + 0xda8)); + if (iVar11 < 2) { + iVar11 = 2; + } + *GHIDRA_CAST((iVar8 + 0xda8)) = iVar11; + ExceptionList = local_10; + return; + } + if (iVar11 != 0) { + iVar8 = *GHIDRA_CAST((iVar11 + 0x133c)); + if (iVar8 < 2) { + iVar8 = 2; + } + *GHIDRA_CAST((iVar11 + 0x133c)) = iVar8; + ExceptionList = local_10; + return; + } + } + ExceptionList = local_10; + return; +} + // 00a04f90 void Weapon_Knife::ClearReferences() { @@ -35,7 +825,7 @@ void Weapon_Knife::ClearReferences() } // 00a05010 -long double Weapon_Knife::GetMaxCharge() +float Weapon_Knife::GetMaxCharge() { float baseCharge; @@ -50,7 +840,7 @@ long double Weapon_Knife::GetMaxCharge() } // 00a05060 -uint8_t Weapon_Knife::CanShutDoors() +uint8_t Weapon_Knife::SupportsTractorBeam() { return ~(uint8_t)(*GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 4) & 1; } @@ -111,12 +901,12 @@ LAB_00a05166: } LAB_00a0517d: virtualFn = *(code **)(*GHIDRA_CAST(knife) + 0x3c); - tearColor = (GHIDRA_CAST((local_4c)))->Weapon::get_tear_color(&tearColorOut); + tearColor = Weapon::get_tear_color(local_4c,&tearColorOut); tearFlagsWord1 = 1; fStack_6c = 3.57331e-43; (*virtualFn)(tearColor,0xffffffff); if ((GHIDRA_UINT(unaff_EDI->_modifiers) >> 4 & 1) == 0) { - ownerTearFlags = (GHIDRA_CAST((unaff_EDI)))->Weapon::get_owner_tear_flags(GHIDRA_CAST((auStack_58 + -4))); + ownerTearFlags = Weapon::get_owner_tear_flags(unaff_EDI,GHIDRA_CAST((auStack_58 + -4))); tearFlagsWord1 = *GHIDRA_CAST((GHIDRA_INT(&ownerTearFlags->_l) + 4)); tearFlagsHigh = ownerTearFlags->_h; tearFlagsWord3 = *GHIDRA_CAST((GHIDRA_INT(&ownerTearFlags->_h) + 4)); @@ -126,7 +916,7 @@ LAB_00a0517d: *GHIDRA_CAST((GHIDRA_INT(&(knife->_tearFlags)._h) + 4)) = tearFlagsWord3; } else { - ownerTearFlags = (GHIDRA_CAST((unaff_EDI)))->Weapon::get_owner_tear_flags(GHIDRA_CAST((auStack_58 + -4))); + ownerTearFlags = Weapon::get_owner_tear_flags(unaff_EDI,GHIDRA_CAST((auStack_58 + -4))); ludoFlagsWord2 = GHIDRA_UINT(ownerTearFlags->_h) | GHIDRA_UINT(g_tearFlagLudovico._h); ludoFlagsWord3 = *GHIDRA_CAST((GHIDRA_INT(&ownerTearFlags->_h) + 4)) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagLudovico._h)) + 0x4))); ludoFlagsWord1 = *GHIDRA_CAST((GHIDRA_INT(&ownerTearFlags->_l) + 4)) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagLudovico._l)) + 0x4))); @@ -136,7 +926,7 @@ LAB_00a0517d: *GHIDRA_CAST((GHIDRA_INT(&(knife->_tearFlags)._h) + 4)) = ludoFlagsWord3; } virtualFn = *(code **)(*GHIDRA_CAST(knife) + 0x40); - fVar1 = (GHIDRA_CAST((unaff_EDI)))->Weapon::get_damage(); + fVar1 = Weapon::get_damage(unaff_EDI); (*virtualFn)(fVar1); if ((*GHIDRA_CAST((tearFlagsWord1 + 4)) != 0) && (*GHIDRA_CAST((*GHIDRA_CAST((tearFlagsWord1 + 4)) + 0x28)) == 3)) { fVar1 = g_vectorOne.x * 0.75; diff --git a/generated-src/weapon_laser.cpp b/generated-src/weapon_laser.cpp index 8c02676..172c8a3 100644 --- a/generated-src/weapon_laser.cpp +++ b/generated-src/weapon_laser.cpp @@ -8,6 +8,621 @@ void Weapon_Laser::Reset() return; } +// 00a052b0 +void Weapon_Laser::Fire(Vector *param_1, uint8_t param_2, uint8_t param_3) +{ + uint8_t isMarkedAim; + Entity_Player *pEVar2; + uint32_t isCursedEye; + Vector *vecResult; + int *ludoLaser; + Entity_Laser *newLudoLaser; + int iVar3; + char isMonstrosLung; + Weapon *in_ECX; + uint32_t unused; + int unused_00; + int unusedArg; + int unused_01; + int extraout_ECX; + int unused_02; + int unused_03; + int extraout_ECX_00; + int extraout_ECX_01; + int extraout_ECX_02; + int extraout_ECX_03; + int extraout_ECX_04; + Entity_Player *ownerPlayer; + int iVar4; + int extraout_ECX_05; + int extraout_ECX_06; + uint8_t bVar5; + int ownerEntity; + uint32_t isCursedEye; + long double maxCharge; + float fVar7; + float fVar8; + float fVar9; + double dVar10; + uint8_t isFiring; + float fStack_60; + uint8_t local_5c [8]; + float fStack_54; + float local_50; + Vector local_4c; + Vector scratchVec; + Vector aimDirection; + Vector ownerPos; + uint8_t multiShotParams [29]; + char isFireBackward; + char isFireSideways; + uint16_t uStack_c; + bool isChargeWeapon; + bool isFireReady; + bool isMarkedAim; + + isFiring = param_2; + Weapon::Fire(in_ECX,param_1,param_2,param_3); + isCursedEye = in_ECX->_modifiers; + local_50 = (float)(isCursedEye >> 6 & 0xffffff01); + pEVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = pEVar2; + if (pEVar2 == GHIDRA_CAST(0x0)) { + ownerPos.x = g_vectorZero.x; + ownerPos.y = g_vectorZero.y; +LAB_00a0534f: + ownerPlayer = GHIDRA_CAST(0x0); + if ((pEVar2 == GHIDRA_CAST(0x0)) || (pEVar2->_type != 1)) { +LAB_00a05373: + if ((pEVar2 == GHIDRA_CAST(0x0)) || + ((pEVar2->_type != 1 && + ((pEVar2->_type != 3 || + (pEVar2 = *GHIDRA_CAST(&pEVar2->_isControlsEnabled), pEVar2 == GHIDRA_CAST(0x0)) + ))))) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x0))) = 1.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = GHIDRA_CAST(0x0); + } + else { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = GHIDRA_CAST(0x0); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x0))) = pEVar2->_shotspeed; + } + } + else { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x0))) = pEVar2->_shotspeed; + } + } + else { + ownerPos.x = (pEVar2->_pos).x; + ownerPos.y = (pEVar2->_pos).y; + if (pEVar2->_type != 1) { + if (pEVar2->_type != 3) goto LAB_00a0534f; + ownerPlayer = *GHIDRA_CAST(&pEVar2->_isControlsEnabled); + goto LAB_00a05373; + } + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x0))) = pEVar2->_shotspeed; + ownerPlayer = pEVar2; + } + if ((isCursedEye >> 4 & 1) != 0) { + if (param_3 == 0) { + ludoLaser = *GHIDRA_CAST((in_ECX + 1)); + if (ludoLaser == GHIDRA_CAST(0x0)) { +LAB_00a05f6a: + if (ludoLaser != GHIDRA_CAST(0x0)) goto LAB_00a05f6e; + } + else { + if ((ludoLaser[0xb] != 2) || (ludoLaser[0xc] != 1)) { + (**(code **)(*ludoLaser + 0x28))(); + ludoLaser = *GHIDRA_CAST((in_ECX + 1)); + goto LAB_00a05f6a; + } +LAB_00a05f6e: + if (*GHIDRA_CAST((GHIDRA_CAST(ludoLaser) + 0x173)) == '\0') goto LAB_00a06048; + } + isCursedEye = Random(); + newLudoLaser = (Entity_Laser *) + Game::SpawnEx(g_game,7,2,&ownerPos,&g_vectorZero,*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + ,1,isCursedEye,0); + if ((newLudoLaser == GHIDRA_CAST(0x0)) || (newLudoLaser->_type != 7)) { + newLudoLaser = GHIDRA_CAST(0x0); + } + (newLudoLaser->_posOffset).x = 0.0; + (newLudoLaser->_posOffset).y = -20.0; + local_4c.x = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))); + if (newLudoLaser->_parent != 0) { + scratchVec.x = (float)&newLudoLaser->_parent; + msvc::multiset::erase(); + } + newLudoLaser->_parent = local_4c.x; + if (local_4c.x != 0.0) { + msvc::multiset::insert(); + } + newLudoLaser->_renderDepthOffset = 3000.0; + init_laser(in_ECX,newLudoLaser); + (**(code **)(*GHIDRA_CAST(newLudoLaser) + 0xc))(); + if (*GHIDRA_CAST((in_ECX + 1)) != newLudoLaser) { + if (*GHIDRA_CAST((in_ECX + 1)) != GHIDRA_CAST(0x0)) { + scratchVec.x = (float)(in_ECX + 1); + msvc::multiset::erase(); + } + *GHIDRA_CAST((in_ECX + 1)) = newLudoLaser; + msvc::multiset::insert(); + } + } +LAB_00a06048: + ownerEntity = *GHIDRA_CAST((in_ECX + 1)); + if (ownerEntity == 0) { + return; + } + fVar9 = param_1->x; + fVar7 = param_1->y; + fVar8 = fVar7 * fVar7 + fVar9 * fVar9; + local_50 = fVar7; + local_4c.x = fVar9; + if (1.0 < fVar8) { + fVar8 = sqrtf(fVar8); + fVar9 = local_4c.x; + fVar7 = local_50; + if (0.0 < fVar8) { + fVar7 = local_50 * (1.0 / fVar8); + fVar9 = local_4c.x * (1.0 / fVar8); + } + } + if (param_2 == 0) { + iVar4 = *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c4)) + *GHIDRA_CAST((GHIDRA_CAST(g_game->_room) + 0x12c0)); + iVar3 = 0; + if (0 < iVar4) { + iVar3 = iVar4; + } + if (0 < iVar3) goto LAB_00a06200; + fVar7 = ownerPos.x - *GHIDRA_CAST((ownerEntity + 0x33c)); + fVar9 = ownerPos.y - *GHIDRA_CAST((ownerEntity + 0x340)); + if (fVar9 * fVar9 + fVar7 * fVar7 <= 10000.0) goto LAB_00a06200; + aimDirection.x = ownerPos.x - *GHIDRA_CAST((ownerEntity + 0x33c)); + aimDirection.y = ownerPos.y - *GHIDRA_CAST((ownerEntity + 0x340)); + vecResult = (GHIDRA_CAST((&aimDirection)))->Vector::Normalized(&scratchVec); + fVar8 = *GHIDRA_CAST((ownerEntity + 0x36c)); + fVar9 = vecResult->x * 0.3 * 0.5; + fVar7 = vecResult->y * 0.3 * 0.5; + } + else { + fVar8 = *GHIDRA_CAST((ownerEntity + 0x36c)); + fVar9 = fVar9 * 2.0 * 0.5 * (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))); + fVar7 = fVar7 * 2.0 * 0.5 * (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))); + } + if (fVar8 != 0.0) { + *GHIDRA_CAST((ownerEntity + 0x364)) = + (fVar7 * *GHIDRA_CAST((ownerEntity + 0x39c))) / fVar8 + *GHIDRA_CAST((ownerEntity + 0x364)); + *GHIDRA_CAST((ownerEntity + 0x360)) = + (fVar9 * *GHIDRA_CAST((ownerEntity + 0x39c))) / fVar8 + *GHIDRA_CAST((ownerEntity + 0x360)); + } +LAB_00a06200: + if (param_3 != 0) { + return; + } + init_laser(in_ECX,*GHIDRA_CAST((in_ECX + 1))); + if ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_5c))) + 0x4))) == GHIDRA_CAST(0x0)) { + return; + } + ownerEntity = Entity::GetIntervalTicks + ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_5c))) + 0x4))),*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x10)))),0.0); + if (ownerEntity == 0) { + return; + } + ownerEntity = *GHIDRA_CAST((in_ECX + 1)); + if (ownerEntity != 0) { + scratchVec.x = *GHIDRA_CAST((ownerEntity + 0x33c)); + scratchVec.y = *GHIDRA_CAST((ownerEntity + 0x340)); + aimDirection.x = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + 0x33c)); + aimDirection.y = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + 0x340)); + bVar5 = (GHIDRA_CAST((&scratchVec)))->Vector::operator_ne(&aimDirection); + if (bVar5 != 0) { + aimDirection.x = + *GHIDRA_CAST((ownerEntity + 0x33c)) - *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + 0x33c)); + aimDirection.y = + *GHIDRA_CAST((ownerEntity + 0x340)) - *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + 0x340)); + vecResult = (GHIDRA_CAST((&aimDirection)))->Vector::Normalized(&scratchVec); + Weapon::TriggerTearEffects(in_ECX,vecResult,1); + return; + } + } + vecResult = MusicManager::RandomVector(&aimDirection); + Weapon::TriggerTearEffects(in_ECX,vecResult,1); + return; + } + isCursedEye = isCursedEye >> 1; + bVar5 = (uint8_t)in_ECX->_modifiers & 1; + unused = CONCAT31((uint3)(isCursedEye >> 0xb),(char)(isCursedEye >> 3)) & 0xffffff01; + if ((((isCursedEye >> 3 & 1) != 0) || (bVar5 != 0)) || (isChargeWeapon = false, (isCursedEye & 1) != 0)) + { + isChargeWeapon = true; + } + if ((ownerPlayer == GHIDRA_CAST(0x0)) || + ((isMarkedAim = Entity_Player::HasCollectible(ownerPlayer,0x18a,0), isMarkedAim == 0 && + (isMarkedAim = Entity_Player::HasCollectible(ownerPlayer,0x23c,0), isMarkedAim == 0)))) { + isMarkedAim = false; + } + else { + isMarkedAim = true; + } + if (((GHIDRA_UINT(in_ECX->_modifiers) >> 7 & 1) != 0) || + (isFireReady = false, *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x10)))) <= 0.0)) { + isFireReady = true; + } + maxCharge = (long double)(**(code **)(*GHIDRA_CAST(in_ECX) + 0x18))(); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x0))) = (BADTYPE)maxCharge; + if ((isCursedEye & 1) != 0) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x0))) = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))) * 0.5; + } + ownerEntity = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))); + isMonstrosLung = (char)unused; + if (((ownerEntity != 0) && (*GHIDRA_CAST((ownerEntity + 0x28)) == 1)) && + (0 < *GHIDRA_CAST((ownerEntity + 0x18f8)))) { + if ((isMonstrosLung == '\0') && (bVar5 == 0)) { +LAB_00a054d2: + if (((isCursedEye & 1) == 0) || (GHIDRA_INT(in_ECX[1]._technology2Laser) < 1)) goto LAB_00a054e1; + } + else { + local_4c.x = 5.0; + vecResult = GHIDRA_CAST(local_5c); + if (5.0 <= (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0)))) { + vecResult = &local_4c; + } + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) < vecResult->x) goto LAB_00a054d2; + } + isFiring = 0; + } +LAB_00a054e1: + if ((((param_3 == 0) && (isFiring != 0)) && (isFireReady)) && + ((((isMonstrosLung != '\0' || (bVar5 != 0)) && + (fVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))), (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))) <= fVar9)) || + (((isCursedEye & 1) != 0 && + (((fVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))), 0.0 < fVar9 && + (4 < GHIDRA_INT(in_ECX[1]._technology2Laser))) || + ((fVar9 <= 0.0 && (0 < GHIDRA_INT(in_ECX[1]._technology2Laser))))))))))) { + local_4c.x = 1e-05; + isFiring = 0; + vecResult = &local_4c; + if (1e-05 <= fVar9) { + vecResult = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))); + } + fVar9 = vecResult->x; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(in_ECX[1])) + 0x4)))) = fVar9; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) = fVar9; + } + if ((ownerEntity == 0) || + ((((*GHIDRA_CAST((ownerEntity + 0x28)) != 1 && + ((*GHIDRA_CAST((ownerEntity + 0x28)) != 3 || + (ownerEntity = *GHIDRA_CAST((ownerEntity + 0x410)), ownerEntity == 0)))) || + (ownerEntity = *GHIDRA_CAST((ownerEntity + 0x140c)), ownerEntity == 0)) || (!isMarkedAim)))) { + fVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x28)))); + fVar7 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x2c)))); + } + else { + fVar9 = *GHIDRA_CAST((ownerEntity + 0x33c)); + fVar7 = *GHIDRA_CAST((ownerEntity + 0x340)); + } + if ((fVar9 == g_vectorZero.x) && (fVar7 == g_vectorZero.y)) { + isMarkedAim = false; + } + else { + isMarkedAim = true; + } + scratchVec.x = fVar9; + scratchVec.y = fVar7; + if (((param_3 == 0) && (isFiring != 0)) && (isMarkedAim)) { + vecResult = Weapon::get_owner_position(in_ECX,&scratchVec); + fVar7 = fVar7 - vecResult->y; + fVar9 = fVar9 - vecResult->x; + fVar7 = sqrtf(fVar7 * fVar7 + fVar9 * fVar9); + fVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))); + fVar7 = (fVar7 - 50.0) / 250.0; + if (fVar7 <= 0.0) { + fVar7 = 0.0; + } + if (1.0 <= fVar7) { + fVar7 = 1.0; + } + if (fVar9 <= 0.0) { + ownerEntity = 1; + } + else { + ownerEntity = GHIDRA_INT((fVar7 * 4.0 + 1.0)); + } + if (((bVar5 != 0) && ((((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))) - 5.0) * fVar7 + 5.0) - 1.0 < fVar9)) || + ((isMonstrosLung != '\0' && ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))) < fVar9)))) { + isFiring = 0; + } + else if ((isCursedEye & 1) != 0) { + if (ownerEntity <= GHIDRA_INT(in_ECX[1]._technology2Laser)) { + isFiring = 0; + } + } + } + isCursedEye = 0; + local_4c.x = 1.4013e-45; + if (isChargeWeapon) { + if (isFiring == 0) { + if ((bVar5 == 0) || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) <= 0.0)) { + if ((isMonstrosLung == '\0') || (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) < (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))))) { + if ((isCursedEye & 1) != 0) { + if (0 < GHIDRA_INT(in_ECX[1]._technology2Laser)) { + isCursedEye = 1; + } + } + } + else { + isCursedEye = 1; + } + } + else { + isCursedEye = 1; + } + } + if (param_3 != 0) { + if (isCursedEye == 0) { + return; + } + Weapon::SetBlinkTime(in_ECX,1,unused); + return; + } + } + else if (isFiring != 0) { + if (param_3 != 0) { + return; + } + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) <= 0.0 && *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) != 0.0) { + do { + if (7 < isCursedEye) break; + isCursedEye = isCursedEye + 1; + fVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x10)))) + 1.0 + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0xc)))) = fVar9; + } while (fVar9 < 0.0); + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(in_ECX[1])) + 0x4)))) = 0; + } + aimDirection.x = param_1->x; + aimDirection.y = param_1->y; + if (param_2 == 0) { + aimDirection.x = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x20)))); + aimDirection.y = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x24)))); + } + isMarkedAim = Weapon::IsAxisAligned(in_ECX); + fStack_60 = aimDirection.x; + if (isMarkedAim == 0) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = aimDirection.y; + fVar9 = sqrtf(aimDirection.y * aimDirection.y + aimDirection.x * aimDirection.x); + if (fVar9 <= 0.0) { + pEVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_5c))) + 0x4))); + } + else { + aimDirection.y = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4))) * (1.0 / fVar9); + fStack_60 = (1.0 / fVar9) * fStack_60; + pEVar2 = GHIDRA_CAST(aimDirection.y); + aimDirection.x = fStack_60; + } + } + else { + vecResult = Vector::ToCardinal(&scratchVec,&aimDirection); + fStack_60 = vecResult->x; + aimDirection.y = vecResult->y; + pEVar2 = GHIDRA_CAST(aimDirection.y); + aimDirection.x = fStack_60; + } + if (isCursedEye == 0) goto LAB_00a05c7f; + if (isMonstrosLung != '\0') { + Weapon::UpdateHeadChargeAnimation(in_ECX,0xe5,2,&aimDirection,-1.0); + fStack_60 = aimDirection.x; + pEVar2 = GHIDRA_CAST(aimDirection.y); + } + fStack_60 = fStack_60 * 10.0; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = (float)pEVar2 * 10.0; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_50)) + 0x0))) == '\0') { + vecResult = Weapon::get_tear_movement_inheritance(in_ECX,&scratchVec,&aimDirection); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = vecResult->y * 0.4 + (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4))); + fStack_60 = vecResult->x * 0.4 + fStack_60; + } + fVar9 = sqrtf(fStack_60 * fStack_60 + (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4))) * (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4)))); + if (fVar9 <= 0.0) { + aimDirection.y = (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4))); + } + else { + fStack_60 = fStack_60 * (1.0 / fVar9); + aimDirection.y = (float)((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4))) * (1.0 / fVar9)); + } + aimDirection.x = fStack_60; + Weapon::SetBlinkTime(in_ECX,7 - GHIDRA_INT((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x10)))) * -0.45)),unused_00); + Weapon::TriggerTearEffects(in_ECX,&aimDirection,1); + Weapon::GetMultiShotParams(in_ECX,multiShotParams,unusedArg); + fVar9 = 0.0; + if (isMonstrosLung != '\0') { + fVar9 = 1.68156e-44; + } + if (bVar5 == 0) { + fStack_60 = 1.0; + if (isMonstrosLung != '\0') goto LAB_00a05a05; + } + else { + fVar7 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(in_ECX[1])) + 0x4)))) + 1.0; + if (isMonstrosLung == '\0') { + fStack_60 = (fVar7 * 4.0) / ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))) + 1.0); + if (fStack_60 <= 0.1) { + fStack_60 = 0.1; + } + if (4.0 <= fStack_60) { + fStack_60 = 4.0; + } + } + else { + fStack_60 = (fVar7 * 2.5) / ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))) + 1.0); + if (fStack_60 <= 0.02) { + fStack_60 = 0.02; + } + if (2.5 <= fStack_60) { + fStack_60 = 2.5; + } +LAB_00a05a05: + if (fStack_60 < 1.0) { + scratchVec.x = (float)GHIDRA_INT(fVar9); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = scratchVec.x * fStack_60; + dVar10 = ceil((*GHIDRA_CAST((GHIDRA_CAST(&((double)(float)local_5c)) + 0x4)))); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = (BADTYPE)dVar10; + fVar9 = local_4c.x; + if (1 < GHIDRA_INT(dVar10)) { + fVar9 = (float)GHIDRA_INT(dVar10); + } + fStack_60 = fStack_60 * (scratchVec.x / (float)GHIDRA_INT(fVar9)); + } + } + } + ownerEntity = *GHIDRA_CAST(ThreadLocalStoragePointer); + if (*GHIDRA_CAST((ownerEntity + 0xc)) < DAT_00c943b4) { + _Init_thread_header(); + ownerEntity = extraout_ECX_05; + if (DAT_00c943b4 == -1) { + _atexit(GHIDRA_CAST<_func_4879 *>(&LAB_00b16b00)); + _Init_thread_footer(); + ownerEntity = extraout_ECX_06; + } + } + DAT_00c943bc = DAT_00c943b8; + isCursedEye = 0; + if (isMonstrosLung != '\0') { + isCursedEye = 6; + } + fire_lasers(in_ECX,&ownerPos,&aimDirection,isCursedEye,fStack_60,multiShotParams,GHIDRA_INT(fVar9),ownerEntity) + ; + ownerEntity = unused_01; + if (isFireBackward != '\0') { + scratchVec.x = -aimDirection.x; + scratchVec.y = -aimDirection.y; + fire_lasers(in_ECX,&ownerPos,&scratchVec,5,fStack_60,(void *)0x0,GHIDRA_INT(fVar9),unused_01); + ownerEntity = extraout_ECX; + } + if (isFireSideways != '\0') { + scratchVec.x = aimDirection.y; + scratchVec.y = -aimDirection.x; + fire_lasers(in_ECX,&ownerPos,&scratchVec,5,fStack_60,(void *)0x0,GHIDRA_INT(fVar9),ownerEntity); + scratchVec.x = -aimDirection.y; + scratchVec.y = aimDirection.x; + fire_lasers(in_ECX,&ownerPos,&scratchVec,5,fStack_60,(void *)0x0,GHIDRA_INT(fVar9),unused_02); + } + for (local_4c.x = (float)GHIDRA_UINT(uStack_c); local_4c.x != 0.0; + local_4c.x = (float)(GHIDRA_INT(local_4c.x) - 1)) { + isCursedEye = Random(); + fVar7 = (float)((double)GHIDRA_INT(isCursedEye) + __uint_to_double_fixup[-(GHIDRA_INT(isCursedEye) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + scratchVec.x = fVar7 + fVar7; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = cos(scratchVec.x); + fStack_54 = sin(scratchVec.x); + fire_lasers(in_ECX,&ownerPos,GHIDRA_CAST((local_5c + 4)),5,fStack_60,(void *)0x0,GHIDRA_INT(fVar9), + unused_03); + } + isCursedEye = 0; + local_4c.x = 0.0; + if (DAT_00c943bc - DAT_00c943b8 >> 2 != 0) { + local_50 = (float)(GHIDRA_UINT(local_50) ^ 1); + do { + *GHIDRA_CAST((*GHIDRA_CAST((DAT_00c943b8 + isCursedEye * 4)) + 0x4e4)) = SUB41(local_50,0); + (**(code **)(**GHIDRA_CAST((DAT_00c943b8 + isCursedEye * 4)) + 0xc))(); + isCursedEye = isCursedEye + 1; + } while (isCursedEye < GHIDRA_UINT((DAT_00c943bc - DAT_00c943b8 >> 2))); + } +LAB_00a05c7f: + if (isChargeWeapon) { + if (isFiring == 0) { + if (0 < GHIDRA_INT(in_ECX[1]._technology2Laser)) { + in_ECX[1]._technology2Laser = in_ECX[1]._technology2Laser + -1; + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) = 0; + if ((isMonstrosLung == '\0') || (bVar5 = Weapon::IsItemAnimFinished(in_ECX,0xe5), bVar5 != 0)) + { + pEVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))); + if (((pEVar2 == GHIDRA_CAST(0x0)) || (ownerPlayer = pEVar2, pEVar2->_type != 1)) && + ((ownerPlayer = GHIDRA_CAST(0x0), pEVar2 != GHIDRA_CAST(0x0) && + (pEVar2->_type == 3)))) { + pEVar2->_chargeBarSprites[5]._numEvents = 0; + } + else if (ownerPlayer != GHIDRA_CAST(0x0)) { + Entity_Player::stop_costume_item_anims(ownerPlayer); + } + } + } + else { + pEVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = pEVar2; + if ((bVar5 != 0) || (isMonstrosLung != '\0')) { + if ((*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0))) <= (float)pEVar2) { + Weapon::UpdateHeadChargeAnimation(in_ECX,0xe5,1,&aimDirection,-1.0); + Weapon::UpdateHeadChargeAnimation(in_ECX,0x44,1,&aimDirection,-1.0); + ownerEntity = extraout_ECX_01; + } + else { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = ((float)pEVar2 / (*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x0)))) * 18.0; + Weapon::UpdateHeadChargeAnimation(in_ECX,0xe5,0,&aimDirection,(*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4)))); + Weapon::UpdateHeadChargeAnimation(in_ECX,0x44,0,&aimDirection,(*GHIDRA_CAST((GHIDRA_CAST(&((float)local_5c)) + 0x4)))); + ownerEntity = extraout_ECX_00; + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) == 0) { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) + 1.0; + } + else { + (*GHIDRA_CAST((GHIDRA_CAST(&(local_5c)) + 0x4))) = + *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + 0x39c)) + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))); + } + } + pEVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_5c))) + 0x4))); + Weapon::SetBlinkTime(in_ECX,8,ownerEntity); + } + if ((isCursedEye & 1) != 0) { + maxCharge = (long double)(**(code **)(*GHIDRA_CAST(in_ECX) + 0x18))(); + local_4c.x = (float)maxCharge; + if (local_4c.x <= *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14))))) { + Weapon::UpdateHeadChargeAnimation(in_ECX,0x44,1,&aimDirection,-1.0); + Weapon::UpdateHeadChargeAnimation(in_ECX,0x13c,1,&aimDirection,-1.0); + ownerEntity = extraout_ECX_04; + pEVar2 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_5c))) + 0x4))); + } + else { + ownerEntity = extraout_ECX_02; + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) != 0) { + fVar9 = (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) / local_4c.x) * 18.0; + if (*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + 0x28)) == 1) { + Weapon::UpdateHeadChargeAnimation(in_ECX,0x44,0,&aimDirection,fVar9); + fVar9 = 0.0; + } + Weapon::UpdateHeadChargeAnimation(in_ECX,0x13c,0,&aimDirection,fVar9); + ownerEntity = extraout_ECX_03; + } + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) == 0) { + pEVar2 = GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) + 1.0)); + } + else { + pEVar2 = (Entity_Player *) + (*GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x4)))) + 0x39c)) + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) + ); + } + } + Weapon::SetBlinkTime(in_ECX,1,ownerEntity); + in_ECX[1]._technology2Laser = GHIDRA_INT(((((float)pEVar2 + 1.0) * 5.0) / (local_4c.x + 1.0))); + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x14)))) = pEVar2; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(in_ECX[1])) + 0x4)))) = pEVar2; + } + if (param_2 != 0) { + bVar5 = Weapon::IsAxisAligned(in_ECX); + if (bVar5 == 0) { + vecResult = Weapon::get_aim_direction(in_ECX,&local_4c,&aimDirection); + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x20)))) = vecResult->x; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x24)))) = vecResult->y; + return; + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x20)))) = aimDirection.x; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((in_ECX)) + 0x24)))) = aimDirection.y; + return; + } + } + return; +} + // 00a06330 void Weapon_Laser::init_laser(Weapon *weapon, Entity_Laser *laser) { @@ -25,7 +640,7 @@ void Weapon_Laser::init_laser(Weapon *weapon, Entity_Laser *laser) code *virtualFn; local_c = __security_cookie ^ GHIDRA_UINT((auStack_8 + 4)); - tearFlags = (GHIDRA_CAST((weapon)))->Weapon::get_owner_tear_flags(&tearFlagsOut); + tearFlags = Weapon::get_owner_tear_flags(weapon,&tearFlagsOut); tearFlagsWord1 = *GHIDRA_CAST((GHIDRA_INT(&tearFlags->_l) + 4)); tearFlagsHigh = tearFlags->_h; tearFlagsWord3 = *GHIDRA_CAST((GHIDRA_INT(&tearFlags->_h) + 4)); @@ -35,10 +650,10 @@ void Weapon_Laser::init_laser(Weapon *weapon, Entity_Laser *laser) *GHIDRA_CAST(&(laser->_tearFlags)._h) = GHIDRA_INT(tearFlagsHigh); *GHIDRA_CAST((GHIDRA_INT(&(laser->_tearFlags)._h) + 4)) = tearFlagsWord3; virtualFn = *(code **)(iVar1 + 0x3c); - laserColor = (GHIDRA_CAST((weapon)))->Weapon::get_laser_color(&laserColorOut); + laserColor = Weapon::get_laser_color(weapon,&laserColorOut); (*virtualFn)(laserColor,0xffffffff,0xff,0,1); virtualFn = *(code **)(*GHIDRA_CAST(laser) + 0x40); - damage = (GHIDRA_CAST((weapon)))->Weapon::get_damage(); + damage = Weapon::get_damage(weapon); (*virtualFn)(damage); return; } diff --git a/generated-src/weapon_ludovico.cpp b/generated-src/weapon_ludovico.cpp new file mode 100644 index 0000000..198beac --- /dev/null +++ b/generated-src/weapon_ludovico.cpp @@ -0,0 +1,635 @@ +#include "classes.h" + +// 00a06a30 +void Weapon_Ludovico::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + void *orbitTear = this; + uint32_t *puVar1; + Entity *pEVar2; + uint8_t bVar3; + uint32_t uVar4; + int iVar5; + Vector *pVVar6; + TearParams *hitParams; + BitSet128 *pBVar7; + Entity_Tear **ppEVar8; + Entity_Tear *orbitTear; + uint32_t rngResult; + Entity_Player *extraout_ECX; + Entity_Player *extraout_ECX_00; + Entity_Player *extraout_ECX_01; + Entity_Player *extraout_ECX_02; + Entity_Player *pEVar9; + Entity_Player *extraout_ECX_03; + Entity_Player *extraout_ECX_04; + int extraout_ECX_05; + int *piVar10; + Entity_Player *player; + int *piVar11; + Entity_Tear *extraout_EDX; + uint64_t *allocatedBytesPtr; + Entity_Tear *pEVar12; + uint8_t *puVar13; + Weapon *weapon; + int *piVar14; + float fVar15; + float fVar16; + short multiShotParams [18]; + BitSet128 notExplosiveFlags; + BitSet128 tearFlagsTmp; + uint8_t local_16c [8]; + int iStack_164; + Entity_Tear *pEStack_160; + uint8_t notExplosiveFlags2 [4]; + Entity_Tear *orbitTearsBegin; + int *orbitTearsEnd; + int *orbitTearsCap; + void *childTearsBegin; + int *childTearsEnd; + int *local_144; + int *childTearsCap; + uint8_t local_13c [8]; + Vector VStack_134; + Vector local_12c; + uint8_t local_124 [8]; + Vector local_11c; + Entity_Tear *luck; + float shotSpeed; + int *local_10c; + Entity_Player *ownerPlayer; + Weapon *self; + Entity_Tear *local_100; + Vector local_fc; + Entity_Tear *local_f4; + Entity_Tear *local_f0; + int *local_ec; + Entity_Tear *local_e8; + TearParams tearParams; + TearParams hitParamsBuf; + uint32_t local_14; + void *local_10; + uint8_t *puStack_c; + float local_8; + uint64_t allocatedBytes; + Game *game; + + local_8 = -NAN; + puStack_c = &LAB_00b10866; + local_10 = ExceptionList; + uVar4 = __security_cookie ^ GHIDRA_UINT(((&hitParamsBuf)[1]._tearColor._colorize + 3)); + ExceptionList = &local_10; + local_f4 = GHIDRA_CAST(direction); + self = orbitTear; + local_14 = uVar4; + Weapon::Fire(orbitTear,direction,isShooting,isInterpolated); + pEVar9 = *GHIDRA_CAST((GHIDRA_CAST(orbitTear) + 4)); + if (pEVar9 == GHIDRA_CAST(0x0)) { +LAB_00a06a9a: + ownerPlayer = GHIDRA_CAST(0x0); + if (pEVar9 != GHIDRA_CAST(0x0)) goto LAB_00a06aa0; + local_f0 = GHIDRA_CAST(g_vectorZero.x); + local_ec = GHIDRA_CAST(g_vectorZero.y); + ownerPlayer = GHIDRA_CAST(0x0); +LAB_00a06b2b: + luck = GHIDRA_CAST(0x0); + if (pEVar9 != GHIDRA_CAST(0x0)) goto LAB_00a06b3a; +LAB_00a06b6d: + shotSpeed = 1.0; + } + else { + if (pEVar9->_type == 1) { + ownerPlayer = pEVar9; + } + else { + if (pEVar9->_type != 3) goto LAB_00a06a9a; + ownerPlayer = *GHIDRA_CAST(&pEVar9->_isControlsEnabled); + } +LAB_00a06aa0: + local_f0 = GHIDRA_CAST((pEVar9->_pos).x); + local_ec = GHIDRA_CAST((pEVar9->_pos).y); + if (pEVar9->_type == 1) { + player = pEVar9; + } + else if ((pEVar9->_type != 3) || + (player = *GHIDRA_CAST(&pEVar9->_isControlsEnabled), player == GHIDRA_CAST(0x0) + )) goto LAB_00a06b2b; + luck = GHIDRA_CAST(player->_luck); +LAB_00a06b3a: + if ((pEVar9->_type != 1) && + ((pEVar9->_type != 3 || + (pEVar9 = *GHIDRA_CAST(&pEVar9->_isControlsEnabled), pEVar9 == GHIDRA_CAST(0x0))))) + goto LAB_00a06b6d; + shotSpeed = pEVar9->_shotspeed; + } + player = ownerPlayer; + local_12c.y = (float)(GHIDRA_INT(orbitTear) + 0x44); + piVar14 = *GHIDRA_CAST((GHIDRA_CAST(orbitTear) + 0x44)); + local_10c = piVar14; + if ((piVar14 == GHIDRA_CAST(0x0)) || (piVar14[10] != 2)) { + if (isInterpolated != 0) { + ExceptionList = local_10; + return; + } + if (piVar14 != GHIDRA_CAST(0x0)) { + (**(code **)(*piVar14 + 0x28))(uVar4); + } + TearParams::constructor(&tearParams); + weapon = self; + if (player != GHIDRA_CAST(0x0)) { + pEVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0x4)))); + if ((pEVar2 == GHIDRA_CAST(0x0)) || (pEVar2->_type != 1)) { + iVar5 = 0; + } + else { + iVar5 = GHIDRA_INT(*GHIDRA_CAST((pEVar2[5]._sprite._championColor._tint + 3))); + } + hitParams = Entity_Player::GetTearHitParams(player,&hitParamsBuf,8,1.0,iVar5,pEVar2); + TearParams::operator_(&tearParams,hitParams); + } + uVar4 = Random(); + local_11c.x = (float)local_f0 + 0.0; + local_11c.y = (float)local_ec + 5.0; + orbitTear = (Entity_Tear *) + Game::Spawn(g_game,2,tearParams._tearVariant,&local_11c,&g_vectorZero, + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))),0,uVar4); + if ((orbitTear == GHIDRA_CAST(0x0)) || (orbitTear->_type != 2)) { + orbitTear = GHIDRA_CAST(0x0); + } + VStack_134.y = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))); + puVar1 = &orbitTear->_parent; + if (*puVar1 != 0) { + local_fc.y = (float)puVar1; + msvc::multiset::erase(&local_fc.y); + } + *puVar1 = VStack_134.y; + if (VStack_134.y != 0.0) { + msvc::multiset::insert(puVar1); + } + orbitTear->_height = -40.0; + fVar15 = Entity_Tear::get_height_offset_y(orbitTear,-40.0); + game = g_game; + (orbitTear->_posOffset).y = fVar15; + if (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) { + (orbitTear->_posOffset).y = -18.0; + } + (**(code **)(*GHIDRA_CAST(orbitTear) + 0x40))(tearParams._tearDamage); + pBVar7 = BitSet128::operator_or(&tearFlagsTmp,&tearParams._flags,&g_tearFlagLudovico); + Entity_Tear::SetTearFlags(orbitTear,*pBVar7); + (**(code **)(*GHIDRA_CAST(orbitTear) + 0x3c))(&tearParams._tearColor,0xffffffff,0xff,0,1); + fVar15 = sqrtf(tearParams._tearDamage); + fVar15 = fVar15 * 0.15 + tearParams._tearDamage * 0.04 + 1.5; + if (fVar15 <= 0.01) { + fVar15 = 0.01; + } + orbitTear->_baseScale = fVar15; + orbitTear->_fScale = fVar15; + Entity_Tear::ResetSpriteScale(orbitTear); + (**(code **)(*GHIDRA_CAST(orbitTear) + 0xc))(); + fVar15 = local_12c.y; + if (*GHIDRA_CAST(local_12c.y) == orbitTear) { + ExceptionList = local_10; + return; + } + if (*GHIDRA_CAST(local_12c.y) != GHIDRA_CAST(0x0)) { + local_fc.y = local_12c.y; + msvc::multiset::erase(&local_fc.y); + } + *GHIDRA_CAST(fVar15) = orbitTear; + msvc::multiset::insert(fVar15); + ExceptionList = local_10; + return; + } + if (isInterpolated != 0) { + ExceptionList = local_10; + return; + } + if (isShooting != 0) { + local_fc.x = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_f4)) + 0x0)))); + local_100 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_f4)) + 0x4)))); + local_fc.y = (float)local_100; + local_e8 = GHIDRA_CAST(local_fc.x); + if (1.0 < local_fc.x * local_fc.x + (float)local_100 * (float)local_100) { + (GHIDRA_CAST((&local_fc)))->Vector::Normalize(); + local_e8 = GHIDRA_CAST(local_fc.x); + pEVar9 = extraout_ECX; + } + local_100 = GHIDRA_CAST(local_fc.y); + local_fc.x = (float)local_e8; + if (player != GHIDRA_CAST(0x0)) { + bVar3 = Entity_Player::HasCollectible(player,0x166,0); + pEVar9 = extraout_ECX_00; + if (bVar3 != 0) { + bVar3 = Entity_Player::HasCollectible(player,0xf5,0); + pEVar9 = extraout_ECX_01; + if (bVar3 == 0) { + local_f0 = GHIDRA_CAST(cos(0.7853982)); + fVar15 = sin(0.7853982); + fVar16 = (float)local_e8 * fVar15; + local_e8 = GHIDRA_CAST(((float)local_e8 * (float)local_f0 - fVar15 * (float)local_100)); + local_100 = GHIDRA_CAST(((float)local_f0 * (float)local_100 + fVar16)); + pEVar9 = extraout_ECX_02; + } + } + } + fVar15 = (float)piVar14[0xdb]; + if (fVar15 != 0.0) { + piVar14[0xd9] = + GHIDRA_INT((((float)piVar14[0xe7] * (float)local_100 * shotSpeed * 3.0) / fVar15 + + (float)piVar14[0xd9])); + piVar14[0xd8] = + GHIDRA_INT((((float)piVar14[0xe7] * (float)local_e8 * shotSpeed * 3.0) / fVar15 + + (float)piVar14[0xd8])); + } + } + weapon = self; + if (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0x4)))) != GHIDRA_CAST(0x0)) { + iVar5 = Entity::GetIntervalTicks(*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0x4)))),*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0x10)))),0.0); + pEVar9 = extraout_ECX_03; + if (iVar5 != 0) { + iVar5 = *GHIDRA_CAST((weapon + 1)); + if (iVar5 == 0) { +LAB_00a06df7: + pVVar6 = MusicManager::RandomVector(&local_fc); + } + else { + VStack_134.x = *GHIDRA_CAST((iVar5 + 0x33c)); + VStack_134.y = *GHIDRA_CAST((iVar5 + 0x340)); + local_fc.x = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))) + 0x33c)); + local_fc.y = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))) + 0x340)); + bVar3 = (GHIDRA_CAST((&VStack_134)))->Vector::operator_ne(&local_fc); + if (bVar3 == 0) goto LAB_00a06df7; + local_fc.x = *GHIDRA_CAST((*GHIDRA_CAST((weapon + 1)) + 0x33c)) - + *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))) + 0x33c)); + local_fc.y = *GHIDRA_CAST((*GHIDRA_CAST((weapon + 1)) + 0x340)) - + *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))) + 0x340)); + pVVar6 = (GHIDRA_CAST((&local_fc)))->Vector::Normalized(&local_11c); + } + Weapon::TriggerTearEffects(weapon,pVVar6,1); + pEVar9 = extraout_ECX_04; + } + } + Weapon::GetMultiShotParams(weapon,multiShotParams,GHIDRA_INT(pEVar9)); + local_e8 = GHIDRA_CAST((multiShotParams[0] + -1)); + local_100 = (void *)0x0; + childTearsBegin = (void *)0x0; + if (GHIDRA_INT(local_e8) < 0) { + local_e8 = GHIDRA_CAST(0x0); + } + piVar11 = GHIDRA_CAST(0x0); + local_ec = GHIDRA_CAST(0x0); + childTearsEnd = GHIDRA_CAST(0x0); + childTearsCap = GHIDRA_CAST(0x0); + local_144 = GHIDRA_CAST(0x0); + local_8 = 0.0; + local_f4 = GHIDRA_CAST(piVar14[0xf0]); + if (local_f4 != GHIDRA_CAST(0x0)) { + do { + if (childTearsEnd == piVar11) { + msvc::vector::_Emplace_reallocate(childTearsEnd,&local_f4); + piVar11 = local_144; + } + else { + *childTearsEnd = GHIDRA_INT(local_f4); + childTearsEnd = childTearsEnd + 1; + } + local_f4 = GHIDRA_CAST(local_f4->_child); + } while (local_f4 != GHIDRA_CAST(0x0)); + local_100 = childTearsBegin; + childTearsCap = piVar11; + local_ec = childTearsEnd; + } + piVar11 = local_ec; + orbitTear = local_100; + local_f4 = GHIDRA_CAST((GHIDRA_INT(local_ec) - GHIDRA_INT(local_100) >> 2)); + childTearsBegin = local_100; + childTearsEnd = local_ec; + if (local_f4 < local_e8) { + TearParams::constructor(&tearParams); + orbitTear = extraout_EDX; + if (ownerPlayer != GHIDRA_CAST(0x0)) { + iVar5 = FUN_009f57f0(); + hitParams = Entity_Player::GetTearHitParams + (ownerPlayer,&hitParamsBuf,8,1.0,iVar5,*GHIDRA_CAST((extraout_ECX_05 + 4)) + ); + TearParams::operator_(&tearParams,hitParams); + orbitTear = local_e8; + } + local_e8 = GHIDRA_CAST((GHIDRA_INT(orbitTear) - GHIDRA_INT(local_f4))); + if (0 < GHIDRA_INT(local_e8)) { + local_ec = piVar14 + 0x3c; + local_f4 = GHIDRA_CAST(0x3c23d70a); + do { + uVar4 = Random(); + local_fc.x = (float)piVar14[0xcf] + 0.0; + local_fc.y = (float)piVar14[0xd0] + 5.0; + orbitTear = (Entity_Tear *) + Game::Spawn(g_game,2,tearParams._tearVariant,&local_fc,&g_vectorZero, + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0x4)))),4,uVar4); + if ((orbitTear == GHIDRA_CAST(0x0)) || (orbitTear->_type != 2)) { + orbitTear = GHIDRA_CAST(0x0); + } + if (orbitTear->_parent != 0) { + local_f0 = GHIDRA_CAST(&orbitTear->_parent); + msvc::multiset::erase(&local_f0); + } + orbitTear->_parent = local_10c; + msvc::multiset::insert(&orbitTear->_parent); + orbitTear->_height = -40.0; + fVar15 = Entity_Tear::get_height_offset_y(orbitTear,-40.0); + game = g_game; + (orbitTear->_posOffset).y = fVar15; + if (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) { + (orbitTear->_posOffset).y = -18.0; + } + (**(code **)(*GHIDRA_CAST(orbitTear) + 0x40))(local_10c[0xe2]); + pBVar7 = (GHIDRA_CAST((&g_tearFlagExplosive)))->BitSet128::__bnot(GHIDRA_CAST(notExplosiveFlags2)); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_16c)) + 0x0))) = local_10c[0x10a]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_16c)) + 0x4))) = local_10c[0x10b]; + iStack_164 = local_10c[0x10c]; + pEStack_160 = GHIDRA_CAST(local_10c[0x10d]); + pBVar7 = BitSet128::operator_and(GHIDRA_CAST(local_124),GHIDRA_CAST(local_16c),pBVar7); + Entity_Tear::SetTearFlags(orbitTear,*pBVar7); + (**(code **)(*GHIDRA_CAST(orbitTear) + 0x3c))(local_ec,0xffffffff,0xff,0,1); + local_f0 = GHIDRA_CAST(((float)local_10c[0x108] * 0.5)); + ppEVar8 = &local_f0; + if ((float)local_10c[0x108] * 0.5 <= 0.01) { + ppEVar8 = &local_f4; + } + pEVar12 = *ppEVar8; + orbitTear->_baseScale = (float)pEVar12; + orbitTear->_fScale = (float)pEVar12; + Entity_Tear::ResetSpriteScale(orbitTear); + orbitTear->_entityGridCollisionClass = 0; + local_f0 = orbitTear; + if (piVar11 == childTearsCap) { + msvc::vector::_Emplace_reallocate(piVar11,&local_f0); + childTearsCap = local_144; + } + else { + *piVar11 = GHIDRA_INT(orbitTear); + childTearsEnd = piVar11 + 1; + } + local_e8 = GHIDRA_CAST((GHIDRA_INT(local_e8) + -1)); + piVar11 = childTearsEnd; + piVar14 = local_10c; + } while (local_e8 != GHIDRA_CAST(0x0)); + local_100 = childTearsBegin; + } +LAB_00a07202: + puVar13 = GHIDRA_CAST((GHIDRA_INT(piVar11) - GHIDRA_INT(local_100) >> 2)); + local_e8 = GHIDRA_CAST(0x0); + orbitTear = local_100; + piVar11 = piVar14; + if (puVar13 != GHIDRA_CAST(0x0)) { + do { + local_ec = *GHIDRA_CAST((GHIDRA_CAST(orbitTear) + GHIDRA_INT(local_e8) * 4)); + local_f0 = GHIDRA_CAST((piVar11 + 0xf0)); + if (*GHIDRA_CAST(local_f0) != 0) { + local_12c.y = (float)local_f0; + msvc::multiset::erase(&local_12c.y); + orbitTear = local_100; + } + *GHIDRA_CAST(local_f0) = local_ec; + if (local_ec != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(local_f0); + orbitTear = local_100; + } + piVar11 = *GHIDRA_CAST((GHIDRA_CAST(orbitTear) + GHIDRA_INT(local_e8) * 4)); + if (g_game->_frameCount == piVar11[0xca]) { + (**(code **)(*piVar11 + 0xc))(); + piVar11 = *GHIDRA_CAST((GHIDRA_CAST(local_100) + GHIDRA_INT(local_e8) * 4)); + orbitTear = local_100; + } + local_e8 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_e8)) + 0x1)))); + } while (local_e8 < puVar13); + } + } + else if (local_e8 < local_f4) { + pEVar12 = local_e8; + do { + local_f0 = luck; + (**(code **)(**GHIDRA_CAST((GHIDRA_CAST(orbitTear) + GHIDRA_INT(pEVar12) * 4)) + 0x28))(); + pEVar12 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((pEVar12)) + 0x1)))); + } while (pEVar12 < local_f4); + luck = local_f0; + piVar10 = GHIDRA_CAST((GHIDRA_INT(orbitTear) + GHIDRA_INT(local_e8) * 4)); + piVar11 = local_ec; + piVar14 = local_10c; + if (piVar10 != local_ec) { + piVar11 = piVar10; + childTearsEnd = piVar10; + } + goto LAB_00a07202; + } + pEVar9 = ownerPlayer; + if (ownerPlayer != GHIDRA_CAST(0x0)) { + bVar3 = Entity_Player::HasCollectible(ownerPlayer,0xe5,0); + if (bVar3 != 0) { + piVar11 = GHIDRA_CAST(0x0); + local_f0 = GHIDRA_CAST(0x0); + orbitTearsBegin = GHIDRA_CAST(0x0); + orbitTearsEnd = GHIDRA_CAST(0x0); + local_ec = GHIDRA_CAST(0x0); + orbitTearsCap = GHIDRA_CAST(0x0); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x0))) = 1; + EntityList::QuerySublist + (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),GHIDRA_CAST(local_16c),2,-1,5,0,0); + local_8 = (float)CONCAT31((*GHIDRA_CAST((GHIDRA_CAST(&(local_8)) + 0x1))),2); + local_e8 = pEStack_160; + if (pEStack_160 == GHIDRA_CAST(0x0)) { + orbitTear = GHIDRA_CAST(0x0); + } + else { + piVar10 = GHIDRA_CAST(0x0); + local_f4 = (*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_16c))) + 0x4))); + do { + if (*GHIDRA_CAST((*GHIDRA_CAST(local_f4) + 0x3bc)) == piVar14) { + if (piVar11 == piVar10) { + msvc::vector::_Emplace_reallocate(piVar11,local_f4); + local_ec = orbitTearsCap; + piVar10 = orbitTearsCap; + piVar11 = orbitTearsEnd; + } + else { + *piVar11 = *GHIDRA_CAST(local_f4); + orbitTearsEnd = piVar11 + 1; + piVar11 = orbitTearsEnd; + } + } + local_f4 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_f4)) + 0x4)))); + local_e8 = GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_e8[-1])) + 0x847)))); + } while (local_e8 != GHIDRA_CAST(0x0)); + local_f0 = orbitTearsBegin; + local_e8 = GHIDRA_CAST(0x0); + orbitTear = orbitTearsBegin; + } + weapon = self; + if (GHIDRA_INT(piVar11) - GHIDRA_INT(orbitTear) < 4) { + pEVar2 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0x4)))); + if ((pEVar2 == GHIDRA_CAST(0x0)) || (pEVar2->_type != 1)) { + iVar5 = 0; + } + else { + iVar5 = GHIDRA_INT(*GHIDRA_CAST((pEVar2[5]._sprite._championColor._tint + 3))); + } + Entity_Player::GetTearHitParams(ownerPlayer,&tearParams,8,1.0,iVar5,pEVar2); + local_fc.y = 0.01; + local_10c = GHIDRA_CAST(&DAT_00000005); + do { + uVar4 = Random(); + fVar15 = (float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + local_12c.y = fVar15 + fVar15; + VStack_134.y = sin(local_12c.y); + uVar4 = Random(); + local_e8 = (Entity_Tear *) + ((float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) * + 2.3283064e-10 * 20.0 + 5.0); + fVar15 = cos(local_12c.y); + local_f4 = GHIDRA_CAST((fVar15 * (float)local_e8)); + local_e8 = GHIDRA_CAST(((float)local_e8 * VStack_134.y)); + uVar4 = Random(); + local_11c.x = (float)local_f4 + (float)piVar14[0xcf]; + local_11c.y = (float)local_e8 + (float)piVar14[0xd0]; + orbitTear = (Entity_Tear *) + Game::Spawn(g_game,2,tearParams._tearVariant,&local_11c,&g_vectorZero, + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((weapon)) + 0x4)))),5,uVar4); + if ((orbitTear == GHIDRA_CAST(0x0)) || (orbitTear->_type != 2)) { + orbitTear = GHIDRA_CAST(0x0); + } + (orbitTear->_parentOffset).x = (float)local_f4; + (orbitTear->_parentOffset).y = (float)local_e8; + if (orbitTear->_parent != 0) { + VStack_134.y = (float)&orbitTear->_parent; + msvc::multiset::erase(&VStack_134.y); + } + orbitTear->_parent = piVar14; + msvc::multiset::insert(&orbitTear->_parent); + orbitTear->_height = -40.0; + fVar15 = Entity_Tear::get_height_offset_y(orbitTear,-40.0); + game = g_game; + (orbitTear->_posOffset).y = fVar15; + if (*GHIDRA_CAST((GHIDRA_CAST(game->_room) + 8)) == 0x10) { + (orbitTear->_posOffset).y = -18.0; + } + (**(code **)(*GHIDRA_CAST(orbitTear) + 0x40))(piVar14[0xe2]); + pBVar7 = (GHIDRA_CAST((&g_tearFlagExplosive)))->BitSet128::__bnot(¬ExplosiveFlags); + (*GHIDRA_CAST((GHIDRA_CAST(&(local_13c)) + 0x0))) = piVar14[0x10a]; + (*GHIDRA_CAST((GHIDRA_CAST(&(local_13c)) + 0x4))) = piVar14[0x10b]; + VStack_134.x = (float)piVar14[0x10c]; + VStack_134.y = (float)piVar14[0x10d]; + pBVar7 = BitSet128::operator_and(&tearFlagsTmp,GHIDRA_CAST(local_13c),pBVar7); + Entity_Tear::SetTearFlags(orbitTear,*pBVar7); + (**(code **)(*GHIDRA_CAST(orbitTear) + 0x3c))(piVar14 + 0x3c,0xffffffff,0xff,0,1); + uVar4 = Random(); + VStack_134.y = ((float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)] + ) * 2.3283064e-10 * 0.75 + 0.5) * (float)piVar14[0x108]; + pVVar6 = &VStack_134; + if (VStack_134.y <= 0.01) { + pVVar6 = &local_fc; + } + fVar15 = pVVar6->y; + orbitTear->_baseScale = fVar15; + orbitTear->_fScale = fVar15; + Entity_Tear::ResetSpriteScale(orbitTear); + local_10c = GHIDRA_CAST((GHIDRA_INT(local_10c) + -1)); + orbitTear->_entityGridCollisionClass = 0; + weapon = self; + } while (local_10c != GHIDRA_CAST(0x0)); + } + if (local_16c[0] == '\0') { + if (g_mainHeap == (void *)0x0) { + allocatedBytesPtr = &g_allocatedBytesNoHeap; + } + else { + allocatedBytesPtr = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(GHIDRA_CAST(local_16c))) + 0x4))) != GHIDRA_CAST(0x0)) { + uVar4 = *GHIDRA_CAST(&(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_16c)) + 0x4)))(*GHIDRA_CAST((GHIDRA_CAST(( + -0x848))))) + 0x844)))); + allocatedBytes = *allocatedBytesPtr; + *GHIDRA_CAST(allocatedBytesPtr) = GHIDRA_UINT(*allocatedBytesPtr) - uVar4; + *GHIDRA_CAST((GHIDRA_CAST(allocatedBytesPtr) + 4)) = + *GHIDRA_CAST((GHIDRA_CAST(allocatedBytesPtr) + 4)) - GHIDRA_UINT((GHIDRA_UINT(allocatedBytes) < uVar4)); + free(&(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_16c)) + 0x4)))(*GHIDRA_CAST((GHIDRA_CAST(( + -0x848))))) + 0x844)))); + } + } + local_8 = (float)(GHIDRA_UINT(local_8) & 0xffffff00); + if (local_f0 != GHIDRA_CAST(0x0)) { + uVar4 = GHIDRA_INT(local_ec) - GHIDRA_INT(local_f0) & 0xfffffffc; + orbitTear = local_f0; + if (0xfff < uVar4) { + orbitTear = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(local_f0[-1])) + 0x844)))); + uVar4 = uVar4 + 0x23; + if (0x1f < GHIDRA_UINT((GHIDRA_INT(local_f0) + (-4 - GHIDRA_INT(orbitTear))))) goto LAB_00a07ae8; + } + operator_delete(orbitTear,uVar4); + } + pEVar9 = ownerPlayer; + } + iVar5 = Entity::GetIntervalTicks(GHIDRA_CAST(pEVar9),*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((self)) + 0x10)))),0.0); + if (iVar5 != 0) { + iVar5 = 0xa07781; + bVar3 = Entity_Player::HasCollectible(pEVar9,0x57,0); + if ((bVar3 != 0) && + ((local_fc.y = (float)__ftoui3(), GHIDRA_CAST(local_fc.y) == GHIDRA_CAST(0x0) || + (uVar4 = Random(), uVar4 % GHIDRA_UINT(local_fc.y) == 0)))) { + local_11c.x = shotSpeed * 10.0; + VStack_134.x = (float)piVar14[0xcf]; + VStack_134.y = (float)piVar14[0xd0]; + local_11c.y = shotSpeed * 0.0; + local_fc.y = local_11c.x; + local_ec = GHIDRA_CAST(local_11c.y); + Weapon::fire_tear(self,&VStack_134,&local_11c,6,iVar5,1.0,0.0); + VStack_134.y = shotSpeed * -10.0; + local_12c.x = (float)piVar14[0xcf]; + local_12c.y = (float)piVar14[0xd0]; + local_11c.y = (float)local_ec; + local_11c.x = VStack_134.y; + Weapon::fire_tear(self,&local_12c,&local_11c,6,iVar5,1.0,0.0); + local_fc.x = (float)piVar14[0xcf]; + local_11c.x = (float)local_ec; + local_11c.y = local_fc.y; + local_fc.y = (float)piVar14[0xd0]; + Weapon::fire_tear(self,&local_fc,&local_11c,6,iVar5,1.0,0.0); + local_fc.x = (float)piVar14[0xcf]; + local_fc.y = (float)piVar14[0xd0]; + local_11c.x = (float)local_ec; + local_11c.y = VStack_134.y; + Weapon::fire_tear(self,&local_fc,&local_11c,6,iVar5,1.0,0.0); + } + iVar5 = 0xa079a4; + bVar3 = Entity_Player::HasCollectible(pEVar9,0x37,0); + if ((bVar3 != 0) && + ((uVar4 = __ftoui3(), uVar4 == 0 || (rngResult = Random(), rngResult % uVar4 == 0)))) { + uVar4 = Random(); + shotSpeed = shotSpeed * 10.0; + fVar15 = (float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + local_fc.y = fVar15 + fVar15; + fVar15 = cos(local_fc.y); + local_11c.x = fVar15 * shotSpeed; + fVar15 = sin(local_fc.y); + VStack_134.x = (float)piVar14[0xcf]; + local_11c.y = fVar15 * shotSpeed; + VStack_134.y = (float)piVar14[0xd0]; + Weapon::fire_tear(self,&VStack_134,&local_11c,6,iVar5,1.0,0.0); + } + } + } + if (local_100 != (void *)0x0) { + uVar4 = GHIDRA_INT(childTearsCap) - GHIDRA_INT(local_100) & 0xfffffffc; + orbitTear = local_100; + if (0xfff < uVar4) { + orbitTear = *GHIDRA_CAST((GHIDRA_CAST(local_100) + -4)); + uVar4 = uVar4 + 0x23; + if (0x1f < GHIDRA_UINT((GHIDRA_INT(local_100) + (-4 - GHIDRA_INT(orbitTear))))) { +LAB_00a07ae8: + /* WARNING: Subroutine does not return */ + _invalid_parameter_noinfo_noreturn(); + } + } + operator_delete(orbitTear,uVar4); + } + ExceptionList = local_10; + return; +} diff --git a/generated-src/weapon_monstros_lung.cpp b/generated-src/weapon_monstros_lung.cpp index b8384d0..77c6f61 100644 --- a/generated-src/weapon_monstros_lung.cpp +++ b/generated-src/weapon_monstros_lung.cpp @@ -77,7 +77,7 @@ LAB_00a08780: local_30.y = fVar1; if (player == GHIDRA_CAST(0x0)) { LAB_00a08a1b: - tear = (GHIDRA_CAST((in_ECX)))->Weapon::fire_tear(&firePos,&local_30,0,in_stack_ffffff94,in_XMM3_Da,0.0); + tear = Weapon::fire_tear(in_ECX,&firePos,&local_30,0,in_stack_ffffff94,in_XMM3_Da,0.0); if (1 < *GHIDRA_CAST(&g_game->_deathmatchManager)) { local_20 = GHIDRA_UINT((tear->_tearFlags)._l) | _DAT_00c34b10; in_stack_ffffff94 = *GHIDRA_CAST((GHIDRA_INT(&(tear->_tearFlags)._l) + 4)) | DAT_00c34b14; @@ -175,7 +175,7 @@ LAB_00a08b44: } // 00a08c80 -long double Weapon_MonstrosLung::GetMaxCharge() +float Weapon_MonstrosLung::GetMaxCharge() { float baseCharge; float chargeMultiplier; diff --git a/generated-src/weapon_rockets.cpp b/generated-src/weapon_rockets.cpp index 822cbb8..18f4ab2 100644 --- a/generated-src/weapon_rockets.cpp +++ b/generated-src/weapon_rockets.cpp @@ -1,7 +1,510 @@ #include "classes.h" +// 00a08d40 +void Weapon_Rockets::Fire(Vector *aimDirection, uint8_t isShooting, uint8_t isInterpolated) +{ + void *player = this; + int iVar1; + uint64_t qVar2; + uint8_t bVar3; + char extraout_AL; + short rocketCount; + uint32_t uVar4; + Entity *mainTarget; + Entity *extraTarget; + int iVar5; + BitSet128 *maskedFlags; + Vector *pVVar6; + Entity_Player *extraout_ECX; + float *unusedArg; + Entity_Player *pEVar7; + float *extraout_ECX_00; + float *extraout_ECX_01; + float *extraout_ECX_02; + float *extraout_ECX_03; + int extraout_ECX_04; + int extraout_ECX_05; + uint64_t *allocCounter; + Entity_Player *player; + Weapon *pWVar8; + Entity_Player *familiar; + bool bVar9; + float fVar10; + float fVar11; + float fVar12; + undefined3 in_stack_00000009; + undefined3 in_stack_0000000d; + uint32_t uVar13; + TypeDescriptor *pTVar14; + TypeDescriptor *pTVar15; + uint32_t uVar16; + short multiShotParams [14]; + char local_6b; + char local_6a; + uint16_t local_68; + BitSet128 tearFlags; + BitSet128 local_54; + Vector tmpPos; + Vector local_3c; + float angleSin; + uint32_t *local_30; + Weapon *weapon; + Vector local_28; + float local_20; + float local_1c; + float local_18; + uint32_t local_14; + void *local_10; + uint8_t *puStack_c; + uint32_t local_8; + uint32_t *parentRef; + int *targetRef; + + local_8 = 0xffffffff; + puStack_c = &LAB_00b1089d; + local_10 = ExceptionList; + ExceptionList = &local_10; + local_1c = (float)_isInterpolated; + local_30 = GHIDRA_CAST(_isShooting); + weapon = player; + Weapon::Fire(player,aimDirection,isShooting,isInterpolated); + pEVar7 = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + _isShooting = pEVar7; + if (pEVar7 == GHIDRA_CAST(0x0)) { +LAB_00a08dcb: + player = GHIDRA_CAST(0x0); + if ((pEVar7 != GHIDRA_CAST(0x0)) && (pEVar7->_type == 1)) goto LAB_00a08dde; +LAB_00a08da6: + _isShooting = GHIDRA_CAST(0x0); + if ((pEVar7 == GHIDRA_CAST(0x0)) || (pEVar7->_type != 3)) goto LAB_00a08dde; + local_14 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x34)) >> 0x1f; + _isShooting = GHIDRA_CAST(0x0); + familiar = pEVar7; +LAB_00a08e26: + pEVar7 = *GHIDRA_CAST(&pEVar7->_isControlsEnabled); + if (pEVar7 == GHIDRA_CAST(0x0)) goto LAB_00a08e3a; + local_28.y = (float)pEVar7->_markedTarget; + } + else { + if (pEVar7->_type != 1) { + if (pEVar7->_type != 3) goto LAB_00a08dcb; + player = *GHIDRA_CAST(&pEVar7->_isControlsEnabled); + goto LAB_00a08da6; + } + player = pEVar7; +LAB_00a08dde: + local_14 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x34)) >> 0x1f; + familiar = GHIDRA_CAST(0x0); + bVar3 = (uint8_t)(*GHIDRA_CAST((GHIDRA_CAST(player) + 0x34)) >> 0x1f); + _isInterpolated = GHIDRA_CAST(CONCAT13(bVar3,_isInterpolated)); + if (pEVar7 != GHIDRA_CAST(0x0)) { + local_14 = CONCAT31((int3)(GHIDRA_UINT(player) >> 8),bVar3); + if (pEVar7->_type == 1) { + local_14 = GHIDRA_UINT(bVar3); + local_28.y = (float)pEVar7->_markedTarget; + goto LAB_00a08e3c; + } + if (pEVar7->_type == 3) goto LAB_00a08e26; + } +LAB_00a08e3a: + local_28.y = 0.0; + } +LAB_00a08e3c: + if ((((char)local_14 == '\0') && (GHIDRA_CAST(local_28.y) != GHIDRA_CAST(0x0))) && + (player != GHIDRA_CAST(0x0))) { + bVar3 = Entity_Player::HasCollectible(player,0x18a,0); + pEVar7 = extraout_ECX; + if (bVar3 == 0) goto LAB_00a08e63; + unusedArg = GHIDRA_CAST(CONCAT31((int3)(GHIDRA_UINT(extraout_ECX) >> 8),1)); + } + else { +LAB_00a08e63: + unusedArg = GHIDRA_CAST((GHIDRA_UINT(pEVar7) & 0xffffff00)); + } + iVar5 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x44)); + local_3c.y = (float)(GHIDRA_INT(player) + 0x44); + _isInterpolated = GHIDRA_CAST(CONCAT13((char)unusedArg,_isInterpolated)); + if (iVar5 != 0) { + if ((char)unusedArg == '\0') { + pVVar6 = GHIDRA_CAST(aimDirection->x); + local_18 = aimDirection->y; + fVar11 = (float)pVVar6 * (float)pVVar6 + local_18 * local_18; + aimDirection = pVVar6; + if (1.0 < fVar11) { + fVar11 = sqrtf(fVar11); + unusedArg = extraout_ECX_00; + if (0.0 < fVar11) { + aimDirection = GHIDRA_CAST(((float)pVVar6 * (1.0 / fVar11))); + local_18 = local_18 * (1.0 / fVar11); + } + } + if (player == GHIDRA_CAST(0x0)) { +LAB_00a08fb1: + fVar11 = local_18; + } + else { + bVar3 = Entity_Player::HasCollectible(player,0x166,0); + unusedArg = extraout_ECX_01; + if (bVar3 == 0) goto LAB_00a08fb1; + bVar3 = Entity_Player::HasCollectible(player,0xf5,0); + unusedArg = extraout_ECX_02; + if (bVar3 != 0) goto LAB_00a08fb1; + local_20 = cos(0.7853982); + fVar11 = sin(0.7853982); + fVar10 = (float)aimDirection * fVar11; + aimDirection = GHIDRA_CAST(((float)aimDirection * local_20 - local_18 * fVar11)); + unusedArg = extraout_ECX_03; + fVar11 = local_18 * local_20 + fVar10; + } + iVar5 = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x44)); + *GHIDRA_CAST((iVar5 + 0x360)) = + (float)aimDirection * 8.0 * *GHIDRA_CAST((iVar5 + 0x39c)) + *GHIDRA_CAST((iVar5 + 0x360)); + *GHIDRA_CAST((iVar5 + 0x364)) = + fVar11 * 8.0 * *GHIDRA_CAST((iVar5 + 0x39c)) + *GHIDRA_CAST((iVar5 + 0x364)); + } + else { + unusedArg = GHIDRA_CAST((iVar5 + 0x33c)); + fVar11 = (GHIDRA_CAST((GHIDRA_INT(local_28.y) + 0x33c)))->x; + fVar10 = (GHIDRA_CAST((GHIDRA_INT(local_28.y) + 0x33c)))->y; + if (familiar != GHIDRA_CAST(0x0)) { + fVar10 = (fVar10 + (familiar->_pos).y) - + *GHIDRA_CAST((*GHIDRA_CAST(&familiar->_isControlsEnabled) + 0x340)); + fVar11 = (fVar11 + (familiar->_pos).x) - + *GHIDRA_CAST((*GHIDRA_CAST(&familiar->_isControlsEnabled) + 0x33c)); + } + *unusedArg = fVar11; + *GHIDRA_CAST((iVar5 + 0x340)) = fVar10; + } + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_1c)) + 0x0))) != '\0') { + ExceptionList = local_10; + return; + } + Weapon::GetMultiShotParams(player,multiShotParams,GHIDRA_INT(unusedArg)); + iVar5 = extraout_ECX_04; + if ((char)local_14 == '\0') { +LAB_00a09039: + rocketCount = multiShotParams[0]; + } + else { + bVar3 = Entity_Player::HasCollectible(player,0x164,0); + iVar5 = extraout_ECX_05; + if (bVar3 == 0) goto LAB_00a09039; + rocketCount = multiShotParams[0] * 2; + } + if (((char)local_30 != '\0') || ((*GHIDRA_CAST((GHIDRA_CAST(&(in_stack_0000000d)) + 0x2))) != '\0')) { + Weapon::SetBlinkTime(player,10,iVar5); + if (((*GHIDRA_CAST((GHIDRA_CAST(player) + 0x44)) == 0) || + ((extraout_AL != '\0' && (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(player) + 0x44)) + 0x173)) != '\0')))) && + ((*GHIDRA_CAST((GHIDRA_CAST(player) + 0xc)) <= 0.0 && *GHIDRA_CAST((GHIDRA_CAST(player) + 0xc)) != 0.0 || + ((char)local_14 != '\0')))) { + local_20 = (float)((rocketCount * 5 + 0x14) * 2); + iVar5 = *GHIDRA_CAST((GHIDRA_CAST(player) + 4)); + if (iVar5 == 0) { + tmpPos.x = g_vectorZero.x; + tmpPos.y = g_vectorZero.y; + } + else { + tmpPos.x = *GHIDRA_CAST((iVar5 + 0x33c)); + tmpPos.y = *GHIDRA_CAST((iVar5 + 0x340)); + } + local_18 = g_vectorOne.x; + local_1c = g_vectorOne.y; + if (familiar != GHIDRA_CAST(0x0)) { + local_18 = g_vectorOne.x * 0.8; + local_1c = g_vectorOne.y * 0.8; + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(in_stack_0000000d)) + 0x2))) != '\0') { + tmpPos.x = (GHIDRA_CAST((GHIDRA_INT(local_28.y) + 0x33c)))->x; + tmpPos.y = (GHIDRA_CAST((GHIDRA_INT(local_28.y) + 0x33c)))->y; + } + uVar4 = Random(); + mainTarget = Game::Spawn(g_game,1000,0x1e,&tmpPos,&g_vectorZero,*GHIDRA_CAST((GHIDRA_CAST(player) + 4)),0, + uVar4); + (mainTarget->_sprite)._scale.x = local_18; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(&(mainTarget[1])) + 0x40)))) = GHIDRA_INT(rocketCount); + *GHIDRA_CAST((mainTarget[1]._sprite._filename._buf + 4)) = local_20; + *GHIDRA_CAST((mainTarget[1]._sprite._filename._buf + 8)) = local_20; + (mainTarget->_sprite)._scale.y = local_1c; + if (((*GHIDRA_CAST((GHIDRA_CAST(&(in_stack_0000000d)) + 0x2))) != '\0') && (familiar == GHIDRA_CAST(0x0))) { + mainTarget->_visible = 0; + } + targetRef = GHIDRA_CAST((GHIDRA_INT(player) + 0x44)); + local_28.y = (float)mainTarget; + if (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x44)) != mainTarget) { + if (*GHIDRA_CAST((GHIDRA_CAST(player) + 0x44)) != GHIDRA_CAST(0x0)) { + _isInterpolated = targetRef; + msvc::multiset::erase(&isInterpolated); + } + *targetRef = GHIDRA_INT(mainTarget); + msvc::multiset::insert(targetRef); + } + if (local_6b != '\0') { + uVar4 = Random(); + uVar16 = 0; + pTVar15 = &IsaacRepentancePlus::Entity_Effect::RTTI_Type_Descriptor; + pTVar14 = &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor; + uVar13 = 0; + extraTarget = Game::Spawn(g_game,1000,0x1e,&tmpPos,&g_vectorZero,*GHIDRA_CAST((GHIDRA_CAST(player) + 4)) + ,0,uVar4); + iVar5 = __RTDynamicCast(extraTarget,uVar13,pTVar14,pTVar15,uVar16); + if (*GHIDRA_CAST((iVar5 + 0x3bc)) != 0) { + _isInterpolated = GHIDRA_CAST((iVar5 + 0x3bc)); + msvc::multiset::erase(&isInterpolated); + } + *GHIDRA_CAST((iVar5 + 0x3bc)) = mainTarget; + msvc::multiset::insert(GHIDRA_CAST((iVar5 + 0x3bc))); + *GHIDRA_CAST((iVar5 + 0x45c)) = local_20; + *GHIDRA_CAST((iVar5 + 0x460)) = local_20; + *GHIDRA_CAST((iVar5 + 0xe4)) = local_18; + *GHIDRA_CAST((iVar5 + 0xe8)) = local_1c; + *GHIDRA_CAST((iVar5 + 0x450)) = GHIDRA_INT(rocketCount); + *GHIDRA_CAST((iVar5 + 0x30)) = 1; + } + if (local_6a != '\0') { + _isInterpolated = GHIDRA_CAST(0x2); + do { + uVar4 = Random(); + uVar16 = 0; + pTVar15 = &IsaacRepentancePlus::Entity_Effect::RTTI_Type_Descriptor; + pTVar14 = &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor; + uVar13 = 0; + mainTarget = Game::Spawn(g_game,1000,0x1e,&tmpPos,&g_vectorZero, + *GHIDRA_CAST((GHIDRA_CAST(player) + 4)),0,uVar4); + iVar5 = __RTDynamicCast(mainTarget,uVar13,pTVar14,pTVar15,uVar16); + parentRef = GHIDRA_CAST((iVar5 + 0x3bc)); + if (*GHIDRA_CAST((iVar5 + 0x3bc)) != 0) { + local_30 = parentRef; + msvc::multiset::erase(&local_30); + } + mainTarget = GHIDRA_CAST(local_28.y); + *parentRef = local_28.y; + msvc::multiset::insert(parentRef); + *GHIDRA_CAST((iVar5 + 0x45c)) = local_20; + *GHIDRA_CAST((iVar5 + 0x460)) = local_20; + *GHIDRA_CAST((iVar5 + 0x450)) = GHIDRA_INT(rocketCount); + *GHIDRA_CAST((iVar5 + 0x30)) = _isInterpolated; + _isInterpolated = GHIDRA_CAST((GHIDRA_INT(_isInterpolated) + 1)); + *GHIDRA_CAST((iVar5 + 0xe4)) = local_18; + *GHIDRA_CAST((iVar5 + 0xe8)) = local_1c; + } while (GHIDRA_INT(_isInterpolated) < 4); + } + _isInterpolated = GHIDRA_CAST(GHIDRA_UINT(local_68)); + while (_isInterpolated != GHIDRA_CAST(0x0)) { + uVar4 = Random(); + uVar16 = 0; + pTVar15 = &IsaacRepentancePlus::Entity_Effect::RTTI_Type_Descriptor; + pTVar14 = &IsaacRepentancePlus::Entity::RTTI_Type_Descriptor; + uVar13 = 0; + extraTarget = Game::Spawn(g_game,1000,0x1e,&tmpPos,&g_vectorZero,*GHIDRA_CAST((GHIDRA_CAST(player) + 4)) + ,0,uVar4); + local_28.y = (float)__RTDynamicCast(extraTarget,uVar13,pTVar14,pTVar15,uVar16); + parentRef = GHIDRA_CAST((GHIDRA_INT(local_28.y) + 0x3bc)); + if (*GHIDRA_CAST((GHIDRA_CAST(local_28.y) + 0x3bc)) != 0) { + local_30 = parentRef; + msvc::multiset::erase(&local_30); + } + *parentRef = mainTarget; + msvc::multiset::insert(parentRef); + fVar11 = local_28.y; + *GHIDRA_CAST((GHIDRA_CAST(local_28.y) + 0x45c)) = local_20; + *GHIDRA_CAST((GHIDRA_CAST(local_28.y) + 0x460)) = local_20; + *GHIDRA_CAST((GHIDRA_CAST(local_28.y) + 0xe4)) = local_18; + *GHIDRA_CAST((GHIDRA_CAST(local_28.y) + 0xe8)) = local_1c; + *GHIDRA_CAST((GHIDRA_CAST(local_28.y) + 0x450)) = GHIDRA_INT(rocketCount); + *GHIDRA_CAST((GHIDRA_CAST(local_28.y) + 0x30)) = 4; + uVar4 = Random(); + fVar10 = (float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + local_30 = GHIDRA_CAST((fVar10 + fVar10)); + angleSin = sin((float)local_30); + uVar4 = Random(); + local_28.y = (float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) * + 2.3283064e-10 * 80.0 + 10.0; + fVar10 = cos((float)local_30); + _isInterpolated = GHIDRA_CAST((GHIDRA_INT(_isInterpolated) - 1)); + *GHIDRA_CAST((GHIDRA_CAST(fVar11) + 0x34c)) = fVar10 * local_28.y; + *GHIDRA_CAST((GHIDRA_CAST(fVar11) + 0x350)) = local_28.y * angleSin; + } + *GHIDRA_CAST((GHIDRA_CAST(player) + 0xc)) = *GHIDRA_CAST((GHIDRA_CAST(player) + 0x10)); + _isInterpolated = GHIDRA_CAST(0x0); + } + } + pWVar8 = GHIDRA_CAST((GHIDRA_INT(player) + 0x44)); + if (*GHIDRA_CAST(pWVar8) == 0) goto LAB_00a09959; + Weapon::get_owner_tear_flags(player,&tearFlags); + maskedFlags = BitSet128::operator_and(&local_54,&tearFlags,&g_tearFlagAttractor); + if ((GHIDRA_INT(maskedFlags->_l) != 0 || *GHIDRA_CAST((GHIDRA_INT(&maskedFlags->_l) + 4)) != 0) || + (GHIDRA_INT(maskedFlags->_h) != 0 || *GHIDRA_CAST((GHIDRA_INT(&maskedFlags->_h) + 4)) != 0)) { + tmpPos.x = *GHIDRA_CAST((*GHIDRA_CAST(pWVar8) + 0x33c)); + tmpPos.y = *GHIDRA_CAST((*GHIDRA_CAST(pWVar8) + 0x340)); + Game::AttractEntities(g_game,&tmpPos,(void *)0x0,(void *)0x0,10.0,250.0); + EntityList::QuerySublist + (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),GHIDRA_CAST(&local_54),1000,0x1e,-1,0 + ,0); + iVar5 = (*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))); + uVar4 = 0; + local_8 = 0; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._h)) + 0x4))) != 0) { + do { + iVar1 = *GHIDRA_CAST((iVar5 + uVar4 * 4)); + if (*GHIDRA_CAST((iVar1 + 0x3bc)) == *GHIDRA_CAST(pWVar8)) { + tmpPos.x = *GHIDRA_CAST((iVar1 + 0x33c)); + tmpPos.y = *GHIDRA_CAST((iVar1 + 0x340)); + Game::AttractEntities(g_game,&tmpPos,(void *)0x0,(void *)0x0,10.0,250.0); + } + uVar4 = uVar4 + 1; + } while (uVar4 < (*GHIDRA_CAST((GHIDRA_CAST(&(local_54._h)) + 0x4)))); + player = weapon; + } + local_8 = 0xffffffff; + if ((char)local_54._l == '\0') { + if (g_mainHeap == (void *)0x0) { + allocCounter = &g_allocatedBytesNoHeap; + } + else { + allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))) != 0) { + uVar4 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))) + -4)); + qVar2 = *allocCounter; + *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4; + *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = + *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar4)); + free(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))) + -4))); + } + local_8 = 0xffffffff; + } + } + maskedFlags = BitSet128::operator_and(&local_54,&tearFlags,&g_tearFlagHoming); + if ((GHIDRA_INT(maskedFlags->_l) != 0 || *GHIDRA_CAST((GHIDRA_INT(&maskedFlags->_l) + 4)) != 0) || + (GHIDRA_INT(maskedFlags->_h) != 0 || *GHIDRA_CAST((GHIDRA_INT(&maskedFlags->_h) + 4)) != 0)) { + tmpPos.x = *GHIDRA_CAST((*GHIDRA_CAST(pWVar8) + 0x33c)); + tmpPos.y = *GHIDRA_CAST((*GHIDRA_CAST(pWVar8) + 0x340)); + EntityList::QueryRadius + (GHIDRA_CAST((GHIDRA_INT(g_game->_room) + 0x1218)),GHIDRA_CAST(&local_54),&tmpPos,200.0, + 8); + fVar11 = 999999.0; + uVar4 = 0; + aimDirection = GHIDRA_CAST(0x0); + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._h)) + 0x4))) != 0) { + _isInterpolated = *GHIDRA_CAST(&g_game->_deathmatchManager); + do { + pVVar6 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))) + uVar4 * 4)); + if ((GHIDRA_INT(_isInterpolated) < 2) || (pVVar6[5].x != 1.4013e-45)) { + fVar10 = pVVar6[5].x; + if ((GHIDRA_INT(fVar10) - 10U < 0x3de) && + (((fVar10 != 4.62428e-44 && (fVar10 != 2.38221e-44)) && (fVar10 != 4.09179e-43)))) { + if (fVar10 == 1.24015e-42) { + bVar9 = pVVar6[5].y == 1.4013e-44; + } + else { + if ((fVar10 == 1.34525e-42) || (fVar10 == 1.35225e-42)) goto LAB_00a0972d; + bVar9 = fVar10 == 3.43318e-43; + } + if (!bVar9) goto LAB_00a096e7; + } +LAB_00a0972d: + iVar5 = *GHIDRA_CAST(local_3c.y); + } + else { +LAB_00a096e7: + if (*GHIDRA_CAST((GHIDRA_INT(&pVVar6[0x2e].x) + 3)) != '\0') goto LAB_00a0972d; + iVar5 = *GHIDRA_CAST(local_3c.y); + fVar12 = *GHIDRA_CAST((iVar5 + 0x340)) - pVVar6[0x68].x; + fVar10 = *GHIDRA_CAST((iVar5 + 0x33c)) - pVVar6[0x67].y; + fVar10 = fVar12 * fVar12 + fVar10 * fVar10; + if (fVar10 < fVar11) { + fVar11 = fVar10; + aimDirection = pVVar6; + } + } + uVar4 = uVar4 + 1; + } while (uVar4 < (*GHIDRA_CAST((GHIDRA_CAST(&(local_54._h)) + 0x4)))); + player = weapon; + if (aimDirection != GHIDRA_CAST(0x0)) { + _isInterpolated = GHIDRA_CAST((aimDirection[0x68].x - *GHIDRA_CAST((iVar5 + 0x340)))); + fVar10 = aimDirection[0x67].y - *GHIDRA_CAST((iVar5 + 0x33c)); + fVar11 = sqrtf((float)_isInterpolated * (float)_isInterpolated + fVar10 * fVar10); + targetRef = _isInterpolated; + if (0.0 < fVar11) { + fVar10 = fVar10 * (1.0 / fVar11); + targetRef = GHIDRA_CAST(((float)_isInterpolated * (1.0 / fVar11))); + } + fVar11 = *GHIDRA_CAST((iVar5 + 0x36c)); + if (fVar11 != 0.0) { + *GHIDRA_CAST((iVar5 + 0x364)) = + (*GHIDRA_CAST((iVar5 + 0x39c)) * (float)targetRef) / fVar11 + *GHIDRA_CAST((iVar5 + 0x364)); + *GHIDRA_CAST((iVar5 + 0x360)) = + (*GHIDRA_CAST((iVar5 + 0x39c)) * fVar10) / fVar11 + *GHIDRA_CAST((iVar5 + 0x360)); + } + } + } + if ((char)local_54._l == '\0') { + if (g_mainHeap == (void *)0x0) { + allocCounter = &g_allocatedBytesNoHeap; + } + else { + allocCounter = GHIDRA_CAST((GHIDRA_INT(g_mainHeap) + 0x30)); + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))) != 0) { + uVar4 = *GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))) + -4)); + qVar2 = *allocCounter; + *GHIDRA_CAST(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar4; + *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) = + *GHIDRA_CAST((GHIDRA_CAST(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar4)); + free(GHIDRA_CAST(((*GHIDRA_CAST((GHIDRA_CAST(&(local_54._l)) + 0x4))) + -4))); + } + local_8 = 0xffffffff; + } + pWVar8 = GHIDRA_CAST((GHIDRA_INT(player) + 0x44)); + } + if ((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x4)))) == GHIDRA_CAST(0x0)) || + (iVar5 = Entity::GetIntervalTicks + (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x4)))), + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x10)))),0.0), iVar5 == 0)) + goto LAB_00a09959; + iVar5 = *GHIDRA_CAST(pWVar8); + if (iVar5 == 0) { +LAB_00a098fd: + uVar4 = Random(); + fVar11 = (float)((double)GHIDRA_INT(uVar4) + __uint_to_double_fixup[-(GHIDRA_INT(uVar4) >> 0x1f)]) * + 2.3283064e-10 * 3.14; + fVar11 = fVar11 + fVar11; + local_28.x = cos(fVar11); + local_28.y = sin(fVar11); + pVVar6 = &local_28; + } + else { + fVar11 = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x4)))) + 0x33c)); + fVar10 = *GHIDRA_CAST((*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x4)))) + 0x340)); + if ((*GHIDRA_CAST((iVar5 + 0x33c)) == fVar11) && (*GHIDRA_CAST((iVar5 + 0x340)) == fVar10)) + goto LAB_00a098fd; + _isInterpolated = GHIDRA_CAST((*GHIDRA_CAST((iVar5 + 0x340)) - fVar10)); + fVar11 = *GHIDRA_CAST((iVar5 + 0x33c)) - fVar11; + local_3c.x = fVar11; + local_3c.y = (float)_isInterpolated; + fVar10 = sqrtf((float)_isInterpolated * (float)_isInterpolated + fVar11 * fVar11); + if (0.0 < fVar10) { + local_3c.y = (1.0 / fVar10) * (float)_isInterpolated; + local_3c.x = (1.0 / fVar10) * fVar11; + } + pVVar6 = &local_3c; + } + Weapon::TriggerTearEffects(player,pVVar6,1); +LAB_00a09959: + if ((*GHIDRA_CAST(pWVar8) != 0) && (*GHIDRA_CAST((*GHIDRA_CAST(pWVar8) + 0x173)) != '\0')) { + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0xc)))) = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(player)))) + 0x10)))); + if (((char)local_14 != '\0') && (_isShooting != GHIDRA_CAST(0x0))) { + Entity_Player::ResetItemState(_isShooting); + } + } + ExceptionList = local_10; + return; +} + // 00a099a0 -uint32_t Weapon_Rockets::GetMarkedTargetVariant() +int Weapon_Rockets::GetMarkedTargetVariant() { void *player = this; uint8_t isHasMarked; diff --git a/generated-src/weapon_spirit_sword.cpp b/generated-src/weapon_spirit_sword.cpp index 81d11f9..72e8a2e 100644 --- a/generated-src/weapon_spirit_sword.cpp +++ b/generated-src/weapon_spirit_sword.cpp @@ -1,5 +1,581 @@ #include "classes.h" +// 00a099e0 +void Weapon_SpiritSword::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + void *maskedFlags = this; + uint8_t bVar1; + uint8_t bVar2; + Vector *clampedScale; + Vector *pVVar3; + int iVar4; + float *clampedCharge; + Entity_Knife *knife; + Vector **ppVVar5; + BitSet128 *maskedFlags; + uint8_t *animName; + Entity *unusedArg; + Entity_Player *extraout_EDX; + Entity_Player *extraout_EDX_00; + Entity_Player *player; + uint32_t uVar6; + void *pvVar7; + float *pfVar8; + float fVar9; + float fVar10; + float nextCharge; + undefined3 in_stack_00000009; + undefined3 in_stack_0000000d; + Entity aEStackY_7ffffc64 [2064887]; + uint32_t uVar11; + uint32_t uVar12; + short *outParams; + short *psVar13; + Entity *player; + short multiShotParams [14]; + char isShootingBackwards; + char isShootingSideways; + uint16_t numRandomDirKnives; + uint8_t knifeFlags [4]; + void *pvStack_60; + Vector VStack_5c; + Vector local_54; + uint8_t flagTest [8]; + Vector local_44; + float minPitch; + float scalePitch; + Vector local_34; + Vector local_2c; + uint32_t swordVariant; + Entity_Player *ownerPlayer; + float speedMultiplier; + float swordScale; + char isMomsKnife; + void *local_10; + uint8_t *puStack_c; + uint32_t local_8; + Game *game; + Manager *manager; + int *swordKnife; + + local_8 = 0xffffffff; + puStack_c = &LAB_00b108cd; + local_10 = ExceptionList; + ExceptionList = &local_10; + pVVar3 = direction; + local_34.y = (float)maskedFlags; + Weapon::Fire(maskedFlags,direction,isShooting,isInterpolated); + bVar2 = (uint8_t)pVVar3; + local_2c.y = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 4)); + ownerPlayer = GHIDRA_CAST(local_2c.y); + if (GHIDRA_CAST(local_2c.y) == GHIDRA_CAST(0x0)) { + speedMultiplier = 1.0; +LAB_00a09a65: + ownerPlayer = GHIDRA_CAST(0x0); + if (GHIDRA_CAST(local_2c.y) != GHIDRA_CAST(0x0)) { + ownerPlayer = GHIDRA_CAST(0x0); + if ((GHIDRA_CAST(local_2c.y))->_type == 1) goto LAB_00a09a88; + } +LAB_00a09a81: + local_2c.y = 0.0; + } + else { + speedMultiplier = (GHIDRA_CAST(local_2c.y))->_speedMultiplier; + if ((GHIDRA_CAST(local_2c.y))->_type != 1) { + if ((GHIDRA_CAST(local_2c.y))->_type != 3) goto LAB_00a09a65; + ownerPlayer = *GHIDRA_CAST(&(GHIDRA_CAST(local_2c.y))->_isControlsEnabled); + goto LAB_00a09a81; + } + } +LAB_00a09a88: + player = ownerPlayer; + if (ownerPlayer == GHIDRA_CAST(0x0)) { +LAB_00a09aaf: + swordVariant = 10; + isMomsKnife = '\0'; + if (player != GHIDRA_CAST(0x0)) goto LAB_00a09abe; + } + else { + Entity_Player::HasCollectible(ownerPlayer,0x18a,0); + bVar2 = 0xa5; + bVar1 = Entity_Player::HasCollectible(player,0x72,0); + if (bVar1 == 0) goto LAB_00a09aaf; + isMomsKnife = '\x01'; +LAB_00a09abe: + bVar2 = 0xc9; + bVar1 = Entity_Player::HasCollectible(player,0x44,0); + swordVariant = 10; + if (bVar1 != 0) { + swordVariant = 0xb; + } + } + iVar4 = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 4)); + swordScale = 1.0; + if (iVar4 != 0) { + if (GHIDRA_CAST(local_2c.y) == GHIDRA_CAST(0x0)) { + pVVar3 = GHIDRA_CAST((iVar4 + 0xe4)); + clampedScale = &local_34; + if (*GHIDRA_CAST((iVar4 + 0x28)) != 3) { + if (1.0 < pVVar3->x) { + clampedScale = pVVar3; + } + goto LAB_00a09b5e; + } + local_34.x = pVVar3->x * 0.8; + local_2c.x = 0.8; + if (local_34.x <= 0.8) { + clampedScale = &local_2c; + } + } + else { + local_54.x = (GHIDRA_CAST((GHIDRA_INT(local_2c.y) + 0x14f0)))->x; + local_54.y = (GHIDRA_CAST((GHIDRA_INT(local_2c.y) + 0x14f0)))->y; + clampedScale = &local_54; + if (local_54.x <= 1.0) { + clampedScale = &local_34; + } +LAB_00a09b5e: + local_34.x = 1.0; + } + swordScale = clampedScale->x; + } + if (player != GHIDRA_CAST(0x0)) { + bVar2 = TemporaryEffects::HasCollectibleEffect(&player->_temporaryeffects,0x271); + if (bVar2 != 0) { + swordScale = swordScale * 4.0; + } + bVar2 = 0xa6; + bVar1 = Entity_Player::HasCollectible(player,0xa9,0); + if (bVar1 == 0) { + bVar2 = 200; + bVar1 = Entity_Player::HasCollectible(player,0x213,0); + if (bVar1 != 0) { + swordScale = swordScale * 1.5; + } + } + else { + swordScale = swordScale + swordScale; + } + } + minPitch = 0.5; + scalePitch = 1.0 / (swordScale * 0.5 + 0.5); + pfVar8 = &scalePitch; + if (scalePitch <= 0.5) { + pfVar8 = &minPitch; + } + if ((isInterpolated == 0) && (0.0 < *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x48)))) { + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x48)) = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x48)) - speedMultiplier; + } + if (isShooting == 0) { + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x4c)) = 0; + } + local_54.y = direction->y; + local_54.x = direction->x; + if (local_54.y == 0.0) { + if (local_54.x == 0.0) { + local_54.x = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x20)); + local_54.y = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x24)); + } + if (((local_54.y == 0.0) && (local_54.x == 0.0)) && + (GHIDRA_CAST(local_2c.y) != GHIDRA_CAST(0x0))) { + switch(*GHIDRA_CAST((GHIDRA_CAST(local_2c.y) + 0x1628))) { + case 0: + local_54.x = (float)&DAT_bf800000; + break; + case 1: + local_54.y = (float)&DAT_bf800000; + break; + case 2: + local_54.x = 1.0; + break; + case 3: + local_54.y = 1.0; + } + } + } + local_2c.x = (float)pfVar8; + bVar1 = Weapon::IsAxisAligned(maskedFlags); + if (bVar1 == 0) { + local_34.x = local_54.y; + } + else { + pVVar3 = Vector::ToCardinal(&VStack_5c,&local_54); + local_54.x = pVVar3->x; + local_34.x = pVVar3->y; + } + direction = GHIDRA_CAST(local_54.x); + local_54.y = local_34.x; + if ((((GHIDRA_CAST(local_2c.y) != GHIDRA_CAST(0x0)) && + (iVar4 = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 4)), iVar4 != 0)) && (*GHIDRA_CAST((iVar4 + 0x28)) == 1)) && + ((0 < *GHIDRA_CAST((iVar4 + 0x145c)) || + ((*GHIDRA_CAST((iVar4 + 0x2c)) == 1 && (*GHIDRA_CAST((iVar4 + 0x1aec)) == 8)))))) { + local_2c.y = (float)GHIDRA_INT(*GHIDRA_CAST((iVar4 + 0x1578))) * 45.0 * 0.017453292; + local_44.y = cos(local_2c.y); + fVar9 = sin(local_2c.y); + local_54.x = local_44.y * (float)direction - fVar9 * local_34.x; + local_54.y = fVar9 * (float)direction + local_44.y * local_34.x; + } + if (isInterpolated != 0) { + ExceptionList = local_10; + return; + } + if ((SUB41(_isShooting,0) != '\0') && (*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0xc)) <= 0.0)) { + swordKnife = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)); + local_2c.y = (float)(GHIDRA_INT(maskedFlags) + 0x44); + if (swordKnife != GHIDRA_CAST(0x0)) { + if (*GHIDRA_CAST((GHIDRA_CAST(swordKnife) + 0x466)) != '\0') goto LAB_00a0a43d; + (**(code **)(*swordKnife + 0x28))(); + } + game = g_game; + if (*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x4c)) == '\0') { + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0xc)) = 0x3f800000; + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x14)) = 0; + if (1 < *GHIDRA_CAST(&game->_deathmatchManager)) { + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0xc)) = 0x41f00000; + } + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x4c)) = 1; + if ((ownerPlayer == GHIDRA_CAST(0x0)) || + (ownerPlayer->_soulHearts + ownerPlayer->_redHearts < ownerPlayer->_maxHearts)) { + iVar4 = FUN_009f57f0(); + player = GHIDRA_CAST(-iVar4); + uVar12 = 0xa09e81; + FUN_009f5810(player); + _isInterpolated = GHIDRA_CAST((GHIDRA_UINT(_isInterpolated) & 0xffffff)); + player = extraout_EDX_00; + if (extraout_EDX_00 != GHIDRA_CAST(0x0)) goto LAB_00a09e89; + } + else { + _isInterpolated = GHIDRA_CAST(CONCAT13(1,_isInterpolated)); + iVar4 = FUN_009f57f0(); + FUN_009f5810(-iVar4); + player = extraout_EDX; +LAB_00a09e89: + player = GHIDRA_CAST(0x0); + uVar12 = 0xde; + bVar2 = 0x97; + bVar1 = Entity_Player::HasCollectible(player,0xde,0); + if (bVar1 != 0) { + uVar6 = 0; + pvVar7 = g_game->_room; + if (*GHIDRA_CAST((GHIDRA_CAST(pvVar7) + 0x1264)) != 0) { + do { + iVar4 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvVar7) + 0x125c)) + uVar6 * 4)); + if ((((iVar4 != 0) && (*GHIDRA_CAST((iVar4 + 0x28)) == 2)) && + (*GHIDRA_CAST((iVar4 + 0x2c)) == 0x2f)) && + ((*GHIDRA_CAST((iVar4 + 0x3c8)) == *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 4)) && + (1 < *GHIDRA_CAST((iVar4 + 0x438)))))) { + *GHIDRA_CAST((iVar4 + 0x438)) = 1; + } + uVar6 = uVar6 + 1; + } while (uVar6 < *GHIDRA_CAST((GHIDRA_CAST(pvVar7) + 0x1264))); + pfVar8 = GHIDRA_CAST(local_2c.x); + } + } + } + pVVar3 = direction; + direction = GHIDRA_CAST((GHIDRA_UINT(direction) & 0xffffff)); + if (((*GHIDRA_CAST((GHIDRA_CAST(&(in_stack_0000000d)) + 0x2))) != '\0') && (*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x48)) <= 0.0)) { + _isInterpolated = + GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x10)) + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x10)))); + local_44.y = 60.0; + direction = GHIDRA_CAST(CONCAT13(1,(int3)pVVar3)); + clampedCharge = GHIDRA_CAST(&isInterpolated); + if (60.0 <= (float)_isInterpolated) { + clampedCharge = &local_44.y; + } + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x48)) = *clampedCharge; + } + if (*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)) != GHIDRA_CAST(0x0)) { + player = GHIDRA_CAST(0xa09f46); + (**(code **)(**GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)) + 0x28))(); + } + pvStack_60 = (void *)0x0; + VStack_5c.x = 0.0; + VStack_5c.y = 0.0; + local_8 = 0; + local_44.y = (float)Weapon::FireSword(maskedFlags,*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 4)),swordVariant,0.0,1, + bVar2,uVar12,player); + knife = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)); + _isInterpolated = GHIDRA_CAST((GHIDRA_INT(maskedFlags) + 0x44)); + if (knife != GHIDRA_CAST(local_44.y)) { + if (knife != GHIDRA_CAST(0x0)) { + msvc::multiset::erase(&isInterpolated); + } + *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)) = local_44.y; + knife = GHIDRA_CAST(local_44.y); + if (GHIDRA_CAST(local_44.y) != GHIDRA_CAST(0x0)) { + _isInterpolated = GHIDRA_CAST(local_44.y); + msvc::multiset::insert(GHIDRA_CAST((GHIDRA_INT(maskedFlags) + 0x44))); + knife = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)); + } + } + _isInterpolated = knife; + fVar9 = atan2f(local_54.y,local_54.x); + _isInterpolated->_rotation = fVar9 * 57.295776; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(direction)) + 0x3))) != '\0') { + iVar4 = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)); + *GHIDRA_CAST((iVar4 + 0x168)) = *GHIDRA_CAST((iVar4 + 0x168)) | 0x400000; + *GHIDRA_CAST((iVar4 + 0x16c)) = *GHIDRA_CAST((iVar4 + 0x16c)); + } + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)) + 0x4ec)) = 1; + _isInterpolated = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)); + msvc::vector::_Emplace_reallocate(0,&isInterpolated); + outParams = multiShotParams; + uVar11 = 0xa0a02d; + player = unusedArg; + Weapon::GetMultiShotParams(maskedFlags,outParams,GHIDRA_INT(unusedArg)); + if (isShootingBackwards != '\0') { + knife = Weapon::FireSword(maskedFlags,*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)),swordVariant,180.0,0, + (uint8_t)uVar11,GHIDRA_UINT(outParams),player); + player = GHIDRA_CAST(0xa0a061); + _isInterpolated = knife; + fVar9 = atan2f(local_54.y,local_54.x); + knife->_rotation = fVar9 * 57.295776; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((knife)) + 0x4ec)))) = 1; + if (VStack_5c.x == VStack_5c.y) { + player = GHIDRA_CAST(&isInterpolated); + uVar11 = 0xa0a09d; + outParams = GHIDRA_CAST(VStack_5c.x); + msvc::vector::_Emplace_reallocate(VStack_5c.x,player); + } + else { + *GHIDRA_CAST(VStack_5c.x) = _isInterpolated; + VStack_5c.x = (float)(GHIDRA_INT(VStack_5c.x) + 4); + } + } + psVar13 = GHIDRA_CAST(VStack_5c.x); + if (isShootingSideways != '\0') { + _isInterpolated = + Weapon::FireSword(GHIDRA_CAST(local_34.y),*GHIDRA_CAST(local_2c.y),swordVariant,90.0,0, + (uint8_t)uVar11,GHIDRA_UINT(outParams),player); + player = GHIDRA_CAST(0xa0a0d9); + fVar9 = atan2f(local_54.y,local_54.x); + _isInterpolated->_rotation = fVar9 * 57.295776; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((_isInterpolated)) + 0x4ec)))) = 1; + if (psVar13 == GHIDRA_CAST(VStack_5c.y)) { + player = GHIDRA_CAST(&isInterpolated); + uVar11 = 0xa0a112; + msvc::vector::_Emplace_reallocate(psVar13,player); + } + else { + *GHIDRA_CAST(psVar13) = _isInterpolated; + VStack_5c.x = (float)psVar13 + 2; + psVar13 = outParams; + } + outParams = GHIDRA_CAST(VStack_5c.x); + _isInterpolated = + Weapon::FireSword(GHIDRA_CAST(local_34.y),*GHIDRA_CAST(local_2c.y),swordVariant,-90.0,0, + (uint8_t)uVar11,GHIDRA_UINT(psVar13),player); + fVar9 = atan2f(local_54.y,local_54.x); + _isInterpolated->_rotation = fVar9 * 57.295776; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((_isInterpolated)) + 0x4ec)))) = 1; + if (outParams == GHIDRA_CAST(VStack_5c.y)) { + uVar11 = 0xa0a17d; + msvc::vector::_Emplace_reallocate(outParams,&isInterpolated); + } + else { + *GHIDRA_CAST(outParams) = _isInterpolated; + VStack_5c.x = (float)outParams + 2; + outParams = psVar13; + } + } + fVar9 = local_34.y; + direction = GHIDRA_CAST(GHIDRA_UINT(numRandomDirKnives)); + if (direction != GHIDRA_CAST(0x0)) { + do { + psVar13 = GHIDRA_CAST(VStack_5c.x); + player = GHIDRA_CAST(0xa0a197); + uVar12 = Random(); + _isInterpolated = + Weapon::FireSword(GHIDRA_CAST(fVar9),*GHIDRA_CAST((GHIDRA_CAST(fVar9) + 0x44)),swordVariant, + (float)((double)GHIDRA_INT(uVar12) + + __uint_to_double_fixup[-(GHIDRA_INT(uVar12) >> 0x1f)]) * + 2.3283064e-10 * 360.0,0,(uint8_t)uVar11,GHIDRA_UINT(outParams),player); + fVar10 = atan2f(local_54.y,local_54.x); + _isInterpolated->_rotation = fVar10 * 57.295776; + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((_isInterpolated)) + 0x4ec)))) = 1; + if (psVar13 == GHIDRA_CAST(VStack_5c.y)) { + uVar11 = 0xa0a21c; + msvc::vector::_Emplace_reallocate(psVar13,&isInterpolated); + } + else { + *GHIDRA_CAST(psVar13) = _isInterpolated; + VStack_5c.x = (float)psVar13 + 2; + psVar13 = outParams; + } + direction = GHIDRA_CAST((GHIDRA_INT(&direction[-1].y) + 3)); + outParams = psVar13; + } while (direction != GHIDRA_CAST(0x0)); + direction = GHIDRA_CAST(0x0); + pfVar8 = GHIDRA_CAST(local_2c.x); + } + _isInterpolated = GHIDRA_CAST(0x0); + fVar9 = swordScale; + if (2 < g_game->_frameCount - *GHIDRA_CAST((*GHIDRA_CAST(local_2c.y) + 0x328))) { + fVar9 = *GHIDRA_CAST((*GHIDRA_CAST(local_2c.y) + 0xe4)); + fVar9 = (swordScale - fVar9) * 0.5 + fVar9; + } + uVar12 = 0; + uVar6 = GHIDRA_INT(VStack_5c.x) - GHIDRA_INT(pvStack_60) >> 2; + if (uVar6 != 0) { + do { + iVar4 = *GHIDRA_CAST((GHIDRA_CAST(pvStack_60) + uVar12 * 4)); + if ((((iVar4 != 0) && (*GHIDRA_CAST((iVar4 + 0x28)) == 8)) && (*GHIDRA_CAST((iVar4 + 0x30)) == 0)) && + ((*GHIDRA_CAST((iVar4 + 0x3bc)) == *GHIDRA_CAST(local_2c.y) || (iVar4 == *GHIDRA_CAST(local_2c.y))))) { + fVar10 = fVar9 * g_vectorOne.y; + *GHIDRA_CAST((iVar4 + 0xe4)) = fVar9 * g_vectorOne.x; + *GHIDRA_CAST((iVar4 + 0xe8)) = fVar10; + } + uVar12 = uVar12 + 1; + } while (uVar12 < uVar6); + uVar12 = 0; + do { + Entity_Knife::SetAttackAnimation(*GHIDRA_CAST((GHIDRA_CAST(pvStack_60) + uVar12 * 4))); + (**(code **)(**GHIDRA_CAST((GHIDRA_CAST(pvStack_60) + uVar12 * 4)) + 0xc))(); + direction = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(pvStack_60) + uVar12 * 4)) + 0x388)); + ppVVar5 = &direction; + if ((float)direction <= (float)_isInterpolated) { + ppVVar5 = GHIDRA_CAST(&isInterpolated); + } + uVar12 = uVar12 + 1; + _isInterpolated = GHIDRA_CAST(*ppVVar5); + } while (uVar12 < uVar6); + pfVar8 = GHIDRA_CAST(local_2c.x); + } + uVar12 = Random(); + manager = g_manager; + direction = GHIDRA_CAST(0xfc); + local_44.y = ((float)((double)GHIDRA_INT(uVar12) + __uint_to_double_fixup[-(GHIDRA_INT(uVar12) >> 0x1f)]) * + 2.3283064e-10 * 0.2 + 1.1) * *pfVar8; + seed_fart_sound_override(GHIDRA_CAST(&direction)); + (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(direction),1.0,1,0,local_44.y,0.0); + if ((20.0 < (float)_isInterpolated) && (1.5 < swordScale)) { + Game::ShakeScreen(g_game,GHIDRA_INT((swordScale * 5.0))); + } + maskedFlags = (void *)local_34.y; + Weapon::TriggerTearEffects(GHIDRA_CAST(local_34.y),&local_54,1); + local_8 = 0xffffffff; + if (pvStack_60 != (void *)0x0) { + uVar12 = GHIDRA_INT(VStack_5c.y) - GHIDRA_INT(pvStack_60) & 0xfffffffc; + pvVar7 = pvStack_60; + if (0xfff < uVar12) { + pvVar7 = *(void **)(GHIDRA_CAST(pvStack_60) + -4); + uVar12 = uVar12 + 0x23; + if (0x1f < GHIDRA_UINT((GHIDRA_INT(pvStack_60) + (-4 - GHIDRA_INT(pvVar7))))) { + /* WARNING: Subroutine does not return */ + _invalid_parameter_noinfo_noreturn(); + } + } + operator_delete(pvVar7,uVar12); + } + } + } +LAB_00a0a43d: + if (*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)) == 0) { + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x14)))) = 0; + ExceptionList = local_10; + return; + } + if ((SUB41(_isShooting,0) != '\0') || + (*GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x14)))) < *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x10)))) * 4.0)) { + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)) + 0x466)) = SUB41(_isShooting,0); + iVar4 = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)); + if (*GHIDRA_CAST((iVar4 + 0x466)) == '\0') { + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x14)))) = 0; + } + else { + fVar9 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x10)))) * 4.0; + if (*GHIDRA_CAST((iVar4 + 0x465)) == '\0') { + nextCharge = speedMultiplier + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x14)))); + fVar10 = fVar9; + if (nextCharge <= fVar9) { + fVar10 = nextCharge; + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x14)))) = fVar10; + *GHIDRA_CAST((iVar4 + 0x4e8)) = fVar9 <= fVar10; + } + else { + *GHIDRA_CAST((iVar4 + 0x4e8)) = fVar9 <= *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x14)))); + } + } + } + else { + Weapon::GetMultiShotParams(maskedFlags,multiShotParams,GHIDRA_INT(_isShooting)); + Entity_Knife::SpinAttack(*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)),multiShotParams[0],0); + if ((isMomsKnife != '\0') && + (knife = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)), knife != GHIDRA_CAST(0x0))) { + if (ownerPlayer == GHIDRA_CAST(0x0)) { + fVar9 = 260.0; + } + else { + fVar9 = ownerPlayer->_tearrange; + } + knifeFlags = SUB84((knife->_tearFlags)._l,0); + pvStack_60 = *(void **)(GHIDRA_INT(&(knife->_tearFlags)._l) + 4); + VStack_5c.x = *GHIDRA_CAST(&(knife->_tearFlags)._h); + VStack_5c.y = *GHIDRA_CAST((GHIDRA_INT(&(knife->_tearFlags)._h) + 4)); + fVar9 = fVar9 * 0.6; + fVar10 = 300.0; + maskedFlags = BitSet128::operator_and + (GHIDRA_CAST(flagTest),GHIDRA_CAST(knifeFlags),&g_tearFlagOrbit); + bVar2 = (GHIDRA_CAST((maskedFlags)))->BitSet128::IsNonZero(); + if (bVar2 != 0) { + fVar10 = 100000.0; + } + if (fVar10 <= fVar9) { + fVar9 = fVar10; + } + Entity_Knife::Shoot(knife,1.0,fVar9); + } + *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST(((GHIDRA_CAST(maskedFlags)))) + 0x14)))) = 0; + Weapon::TriggerTearEffects(maskedFlags,&local_54,6); + } + animName = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)) + 0x7c)); + if (animName == GHIDRA_CAST(0x0)) { + animName = &s_empty; + } + else if (0xf < *GHIDRA_CAST((animName + 0x14))) { + animName = *GHIDRA_CAST(animName); + } + iVar4 = strncmp(GHIDRA_CAST(animName),"Spin",4); + if (iVar4 == 0) { + Entity::GetNullOffset(*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)),&local_44,&DAT_00b1d3b0); + fVar9 = local_44.y; + if (ABS(local_44.y) < ABS(local_44.x)) { + iVar4 = 2; + if (local_44.x < 0.0) { + iVar4 = 0; + } + goto LAB_00a0a674; + } + } + else { + _isShooting = (float)(*GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)))[1]._type * 0.017453292; + _isInterpolated = GHIDRA_CAST(cos(_isShooting)); + fVar9 = sin(_isShooting); + if (ABS(fVar9) < ABS((float)_isInterpolated)) { + iVar4 = 2; + if ((float)_isInterpolated < 0.0) { + iVar4 = 0; + } + goto LAB_00a0a674; + } + } + iVar4 = GHIDRA_UINT((0.0 <= fVar9)) * 2 + 1; +LAB_00a0a674: + Weapon::set_head_direction(maskedFlags,iVar4); + Weapon::SetHeadLockTime(maskedFlags,1); + swordKnife = *GHIDRA_CAST((GHIDRA_CAST(maskedFlags) + 0x44)); + if ((((char)swordKnife[0x119] == '\0') && (*GHIDRA_CAST((GHIDRA_CAST(swordKnife) + 0x465)) == '\0')) && + (*GHIDRA_CAST((GHIDRA_CAST(swordKnife) + 0x466)) == '\0')) { + (**(code **)(*swordKnife + 0x28))(); + ExceptionList = local_10; + return; + } + ExceptionList = local_10; + return; +} + // 00a0a6f0 void Weapon_SpiritSword::Reset() { diff --git a/generated-src/weapon_tears.cpp b/generated-src/weapon_tears.cpp deleted file mode 100644 index d39b495..0000000 --- a/generated-src/weapon_tears.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "classes.h" - -// 00a0d850 -void Weapon_Tears::Reset() -{ - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)) = 0; - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) = 0; - return; -} - -// 00a0d8e0 -long double Weapon_Tears::GetMaxCharge() -{ - float chargeMultiplier; - uint32_t weaponFlags; - - weaponFlags = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)); - chargeMultiplier = 1.0; - if ((weaponFlags >> 8 & 1) == 0) { - if ((weaponFlags & 1) != 0) { - chargeMultiplier = 2.5; - } - if ((weaponFlags >> 1 & 1) != 0) { - chargeMultiplier = chargeMultiplier + chargeMultiplier; - } - if (chargeMultiplier <= 1.0) { - return 0.0; - } - } - else { - chargeMultiplier = 12.0; - } - return (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) + 1.0) * chargeMultiplier - 1.0; -} - -// 00a0d950 -uint8_t Weapon_Tears::CanTriggerCursedEyeTeleport() -{ - int iVar1; - long double fVar2; - - iVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); - if ((iVar1 != 0) && (*GHIDRA_CAST((iVar1 + 0x28)) == 1)) { - if ((*GHIDRA_CAST((iVar1 + 0x140c)) != 0) && - (iVar1 = this->GetMarkedTargetVariant(), iVar1 != 0)) { - return 0; - } - if ((((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 8 & 1) == 0) && (0.0 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)))) && - (fVar2 = (long double)this->GetMaxCharge(), - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) <= (float)fVar2 && (float)fVar2 != *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14))) - ) { - return 1; - } - } - return 0; -} diff --git a/generated-src/weapon_tech_x.cpp b/generated-src/weapon_tech_x.cpp index 606442d..1ac68db 100644 --- a/generated-src/weapon_tech_x.cpp +++ b/generated-src/weapon_tech_x.cpp @@ -1,7 +1,297 @@ #include "classes.h" +// 00a0d9c0 +void Weapon_TechX::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + Vector shotDirection; + bool bVar1; + bool bVar2; + uint8_t bVar3; + uint8_t isAxisAligned; + int ownerPlayer; + Vector *pVVar4; + Entity_Laser *laser; + uint32_t rngResult; + Entity_Player *pEVar5; + int extraout_ECX; + int unusedArg; + Entity_Player *player; + int extraout_ECX_00; + int extraout_ECX_01; + uint32_t randomLasersLeft; + float fVar6; + float fVar7; + float cosAngle; + float fVar8; + float fVar9; + float fVar10; + float fVar11; + float releaseCharge; + Vector local_70; + Vector aimDirection; + Vector local_60; + Vector scratchVec; + float fStack_50; + float fStack_4c; + Vector VStack_48; + uint32_t local_40; + float fStack_3c; + float fStack_38; + float fStack_34; + float fStack_30; + int iStack_2c; + float fStack_28; + uint32_t uStack_24; + uint32_t uStack_20; + int ownerEntity; + + Weapon::Fire(this,direction,isShooting,isInterpolated); + if (isInterpolated != 0) { + return; + } + pEVar5 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (pEVar5 == GHIDRA_CAST(0x0)) { +LAB_00a0da10: + player = GHIDRA_CAST(0x0); + if (pEVar5 != GHIDRA_CAST(0x0)) { + if (pEVar5->_type == 1) goto LAB_00a0da2f; + if (pEVar5->_type == 3) goto LAB_00a0da23; + } +LAB_00a0da39: + fVar6 = 1.0; + } + else if (pEVar5->_type == 1) { + fVar6 = pEVar5->_shotspeed; + player = pEVar5; + } + else { + if (pEVar5->_type != 3) goto LAB_00a0da10; + player = *GHIDRA_CAST(&pEVar5->_isControlsEnabled); +LAB_00a0da23: + pEVar5 = *GHIDRA_CAST(&pEVar5->_isControlsEnabled); + if (pEVar5 == GHIDRA_CAST(0x0)) goto LAB_00a0da39; +LAB_00a0da2f: + fVar6 = pEVar5->_shotspeed; + } + if (player == GHIDRA_CAST(0x0)) { +LAB_00a0da62: + bVar1 = false; + } + else { + bVar3 = Entity_Player::HasCollectible(player,0x18a,0); + bVar1 = true; + if (bVar3 == 0) goto LAB_00a0da62; + } + if (((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) >> 7 & 1) != 0) || + (bVar2 = false, *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) <= 0.0)) { + bVar2 = true; + } + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + releaseCharge = -1000.0; + if (ownerEntity == 0) { +LAB_00a0dae1: + fVar11 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x28)); + fVar8 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x2c)); + } + else { + if (*GHIDRA_CAST((ownerEntity + 0x28)) == 1) { + ownerPlayer = ownerEntity; + } + else if ((*GHIDRA_CAST((ownerEntity + 0x28)) != 3) || + (ownerPlayer = *GHIDRA_CAST((ownerEntity + 0x410)), ownerPlayer == 0)) goto LAB_00a0dae1; + ownerPlayer = *GHIDRA_CAST((ownerPlayer + 0x140c)); + if ((ownerPlayer == 0) || (!bVar1)) goto LAB_00a0dae1; + fVar11 = *GHIDRA_CAST((ownerPlayer + 0x33c)); + fVar8 = *GHIDRA_CAST((ownerPlayer + 0x340)); + } + if ((fVar11 == g_vectorZero.x) && (fVar8 == g_vectorZero.y)) { + bVar1 = false; + } + else { + bVar1 = true; + } + local_60.x = fVar11; + local_60.y = fVar8; + if (isShooting != 0) { + if (bVar2) { + releaseCharge = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) * 3.0; + } + else if (bVar1) { + pVVar4 = Weapon::get_owner_position(this,&scratchVec); + fVar8 = fVar8 - pVVar4->y; + fVar11 = fVar11 - pVVar4->x; + fVar11 = sqrtf(fVar8 * fVar8 + fVar11 * fVar11); + releaseCharge = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)); + fVar11 = (fVar11 - 50.0) / 250.0; + if (fVar11 <= 0.0) { + fVar11 = 0.0; + } + if (1.0 <= fVar11) { + fVar11 = 1.0; + } + releaseCharge = (releaseCharge * 3.0 - releaseCharge) * fVar11 + releaseCharge; + } + } + if ((((ownerEntity != 0) && (*GHIDRA_CAST((ownerEntity + 0x28)) == 1)) && + (0 < *GHIDRA_CAST((ownerEntity + 0x18f8)))) && + (releaseCharge = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)), releaseCharge < 1.0)) { + releaseCharge = 1.0; + } + bVar3 = isShooting; + if ((-1000.0 < releaseCharge) && (releaseCharge <= *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)))) { + bVar3 = 0; + } + aimDirection.x = direction->x; + aimDirection.y = direction->y; + if (isShooting == 0) { + aimDirection.x = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); + aimDirection.y = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)); + } + isAxisAligned = Weapon::IsAxisAligned(this); + if (isAxisAligned == 0) { + fVar11 = sqrtf(aimDirection.x * aimDirection.x + aimDirection.y * aimDirection.y); + ownerEntity = extraout_ECX_00; + if (0.0 < fVar11) { + aimDirection.x = (1.0 / fVar11) * aimDirection.x; + aimDirection.y = aimDirection.y * (1.0 / fVar11); + } + } + else { + pVVar4 = Vector::ToCardinal(&scratchVec,&aimDirection); + aimDirection.x = pVVar4->x; + aimDirection.y = pVVar4->y; + ownerEntity = extraout_ECX; + } + fVar9 = 1.0; + fVar11 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)); + fVar8 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)); + if (bVar3 == 0) { + if (fVar11 < 1.0) { + fVar9 = 1.0; + } + else { + fVar9 = fVar11; + } + if ((fVar9 <= fVar8) || ((-1000.0 < releaseCharge && (releaseCharge <= fVar8)))) { + *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) = fVar11; + ownerPlayer = 7 - GHIDRA_INT((fVar11 * -0.45)); + ownerEntity = 0xb; + if (0xb < ownerPlayer) { + ownerEntity = ownerPlayer; + } + Weapon::SetBlinkTime(this,ownerEntity,ownerPlayer); + Weapon::TriggerTearEffects(this,&aimDirection,1); + Weapon::get_owner_position(this,&local_60); + fVar8 = aimDirection.x * 10.0; + fVar9 = aimDirection.y * 10.0; + pVVar4 = Weapon::get_tear_movement_inheritance(this,&scratchVec,&aimDirection); + fVar10 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) + 1.0; + fVar8 = fVar8 + pVVar4->x; + fVar11 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) + 1.0; + fVar9 = fVar9 + pVVar4->y; + if (fVar10 * 3.0 <= fVar11) { + fVar11 = fVar10 * 3.0; + } + fVar10 = (fVar11 - fVar10) / (fVar10 + fVar10); + fVar11 = fVar10 * 45.0 + 15.0; + Weapon::GetMultiShotParams(this,&local_40,unusedArg); + fVar10 = fVar10 * 0.75 + 0.25; + if ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_24)) + 0x1))) != '\0') { + local_70.x = -fVar8 * fVar6; + local_70.y = -fVar9 * fVar6; + laser = Weapon::fire_tech_x_laser(this,&local_60,&local_70,fVar11,fVar10); + (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); + } + if ((*GHIDRA_CAST((GHIDRA_CAST(&(uStack_24)) + 0x2))) != '\0') { + local_70.x = fVar8 * fVar6; + local_70.y = fVar6 * -fVar9; + laser = Weapon::fire_tech_x_laser(this,&local_60,&local_70,fVar11,fVar10); + (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); + local_70.x = -fVar8 * fVar6; + local_70.y = fVar9 * fVar6; + laser = Weapon::fire_tech_x_laser(this,&local_60,&local_70,fVar11,fVar10); + (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); + } + for (randomLasersLeft = uStack_20 & 0xffff; randomLasersLeft != 0; + randomLasersLeft = randomLasersLeft - 1) { + rngResult = Random(); + local_70.x = (float)((double)GHIDRA_INT(rngResult) + + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) * 2.3283064e-10 * 0.5 + + 0.5; + rngResult = Random(); + fVar7 = ((float)((double)GHIDRA_INT(rngResult) + __uint_to_double_fixup[-(GHIDRA_INT(rngResult) >> 0x1f)]) + * 2.3283064e-10 * 50.0 - 25.0) * 0.017453292; + cosAngle = cos(fVar7); + fVar7 = sin(fVar7); + scratchVec.x = (fVar8 * cosAngle - fVar9 * fVar7) * fVar6; + scratchVec.y = (fVar9 * cosAngle + fVar8 * fVar7) * fVar6; + laser = Weapon::fire_tech_x_laser + (this,&local_60,&scratchVec,local_70.x * fVar11,local_70.x * fVar10); + (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); + } + ownerEntity = 0; + if (0 < (short)local_40) { + local_70.x = fVar8; + local_70.y = fVar9; + do { + shotDirection.y = local_70.y; + shotDirection.x = local_70.x; + Entity_Player::GetMultiShotPositionVelocity + (&fStack_50,ownerEntity,9,shotDirection,fVar6,(short)local_40,fStack_3c, + fStack_38,fStack_34,fStack_30,iStack_2c,fStack_28,(uint8_t)uStack_24, + (short)uStack_20); + scratchVec.x = local_60.x + fStack_50; + scratchVec.y = fStack_4c + local_60.y; + laser = Weapon::fire_tech_x_laser(this,&scratchVec,&VStack_48,fVar11,fVar10); + (**(code **)(*GHIDRA_CAST(laser) + 0xc))(); + ownerEntity = ownerEntity + 1; + } while (ownerEntity < (short)local_40); + } + pEVar5 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if ((((pEVar5 == GHIDRA_CAST(0x0)) || (player = pEVar5, pEVar5->_type != 1)) && + (player = GHIDRA_CAST(0x0), pEVar5 != GHIDRA_CAST(0x0))) && (pEVar5->_type == 3)) + { + pEVar5->_chargeBarSprites[5]._numEvents = 0; + } + else if (player != GHIDRA_CAST(0x0)) { + Entity_Player::stop_costume_item_anims(player); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = 0; + goto LAB_00a0e1fe; + } + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = 0; + } + else { + if (fVar11 * 3.0 <= fVar8) { + Weapon::UpdateHeadChargeAnimation(this,0x18b,1,direction,-1.0); + ownerEntity = extraout_ECX_01; + } + else { + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) != 0) { + fVar9 = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x39c)); + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = fVar8 + fVar9; + } + Weapon::SetBlinkTime(this,1,ownerEntity); + } +LAB_00a0e1fe: + if (isShooting != 0) { + bVar3 = Weapon::IsAxisAligned(this); + if (bVar3 != 0) { + fVar6 = direction->y; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = direction->x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = fVar6; + return; + } + pVVar4 = Weapon::get_aim_direction(this,&local_60,direction); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = pVVar4->x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = pVVar4->y; + } + return; +} + // 00a0e260 -long double Weapon_TechX::GetMaxCharge() +float Weapon_TechX::GetMaxCharge() { return *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) * 3.0; } diff --git a/generated-src/weapon_umbilical_whip.cpp b/generated-src/weapon_umbilical_whip.cpp new file mode 100644 index 0000000..a7020d5 --- /dev/null +++ b/generated-src/weapon_umbilical_whip.cpp @@ -0,0 +1,144 @@ +#include "classes.h" + +// 00a0e270 +void Weapon_UmbilicalWhip::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + uint8_t isAxisAligned; + Vector *vecResult; + uint32_t seed; + int *whip; + int *extraout_ECX; + int *unused; + Entity *whipEntity; + float fVar1; + float ownerY; + Entity_Player *local_2c; + Vector VStack_28; + Vector VStack_20; + Vector aimDirection; + Vector scratchVec; + uint32_t flagsHigh; + Manager *manager; + int owner; + + Weapon::Fire(this,direction,isShooting,isInterpolated); + local_2c = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (local_2c == GHIDRA_CAST(0x0)) { +LAB_00a0e2c3: + local_2c = GHIDRA_CAST(0x0); + } + else { + if (local_2c->_type != 1) { + if (local_2c->_type != 3) goto LAB_00a0e2c3; + local_2c = *GHIDRA_CAST(&local_2c->_isControlsEnabled); + if (local_2c == GHIDRA_CAST(0x0)) goto LAB_00a0e2cb; + } + Entity_Player::HasCollectible(local_2c,0x18a,0); + } +LAB_00a0e2cb: + whip = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + owner = 0; + if (whip != GHIDRA_CAST(0x0)) { + owner = (*GHIDRA_CAST((GHIDRA_CAST(whip) + 0x171)) != '\0') + 1; + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x1c)) = owner; + if ((isShooting != 0) && + (*GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) <= 0.0 && *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) != 0.0)) { + if (isInterpolated != 0) { + return; + } + unused = whip; + if ((whip != GHIDRA_CAST(0x0)) && (whip[0x362] == 1)) { + (**(code **)(*whip + 0x28))(); + whip = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + unused = extraout_ECX; + } + if (whip == GHIDRA_CAST(0x0)) { + fVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) = fVar1 + fVar1; + Weapon::SetBlinkTime(this,7 - GHIDRA_INT((fVar1 * -0.45)),GHIDRA_INT(unused)); + aimDirection.x = direction->x; + aimDirection.y = direction->y; + isAxisAligned = Weapon::IsAxisAligned(this); + if (isAxisAligned == 0) { + (GHIDRA_CAST((&aimDirection)))->Vector::Normalize(); + } + else { + vecResult = Vector::ToCardinal(&VStack_20,&aimDirection); + aimDirection.x = vecResult->x; + aimDirection.y = vecResult->y; + } + VStack_28.x = aimDirection.x * 10.0; + VStack_20.x = aimDirection.y * 10.0; + vecResult = Weapon::get_tear_movement_inheritance(this,&scratchVec,&aimDirection); + VStack_28.x = vecResult->x * 0.4 + VStack_28.x; + VStack_28.y = vecResult->y * 0.4 + VStack_20.x; + vecResult = (GHIDRA_CAST((&VStack_28)))->Vector::Normalized(&scratchVec); + aimDirection.x = vecResult->x; + aimDirection.y = vecResult->y; + seed = Random(); + vecResult = Weapon::get_owner_position(this,&scratchVec); + VStack_28.x = (float)Game::SpawnEx(g_game,3,0xf0,vecResult,&g_vectorZero,GHIDRA_CAST(local_2c),0, + seed,0); + whipEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + whip = GHIDRA_CAST((GHIDRA_INT(this) + 0x44)); + if (whipEntity != GHIDRA_CAST(VStack_28.x)) { + if (whipEntity != GHIDRA_CAST(0x0)) { + VStack_20.x = (float)whip; + msvc::multiset::erase(&VStack_20); + } + *whip = GHIDRA_INT(VStack_28.x); + whipEntity = GHIDRA_CAST(0x0); + if (GHIDRA_CAST(VStack_28.x) != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(whip); + whipEntity = GHIDRA_CAST(*whip); + } + } + flagsHigh = *GHIDRA_CAST((GHIDRA_INT(&whipEntity->_flags) + 4)); + *GHIDRA_CAST(&whipEntity->_flags) = GHIDRA_UINT(whipEntity->_flags) & 0xfffffffb; + *GHIDRA_CAST((GHIDRA_INT(&whipEntity->_flags) + 4)) = flagsHigh; + vecResult = (GHIDRA_CAST((&aimDirection)))->Vector::Normalized(&scratchVec); + fVar1 = vecResult->y; + owner = *whip; + *GHIDRA_CAST((owner + 0x334)) = vecResult->x; + *GHIDRA_CAST((owner + 0x338)) = fVar1; + (**(code **)(*GHIDRA_CAST(*whip) + 0xc))(); + manager = g_manager; + local_2c = GHIDRA_CAST(0x1ee); + seed_fart_sound_override(GHIDRA_CAST(&local_2c)); + (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_2c),1.0,2,0,1.0,0.0); + Weapon::TriggerTearEffects(this,&aimDirection,1); + whip = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)); + } + } + if (whip == GHIDRA_CAST(0x0)) { + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x3c)) = g_vectorZero.x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x40)) = g_vectorZero.y; + } + else { + owner = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (owner == 0) { + fVar1 = g_vectorZero.x; + ownerY = g_vectorZero.y; + } + else { + fVar1 = *GHIDRA_CAST((owner + 0x33c)); + ownerY = *GHIDRA_CAST((owner + 0x340)); + } + local_2c = GHIDRA_CAST(((float)whip[0xcf] - fVar1)); + VStack_28.x = (float)whip[0xd0] - ownerY; + fVar1 = sqrtf((float)local_2c * (float)local_2c + VStack_28.x * VStack_28.x); + if (fVar1 <= 0.0) { + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x3c)) = local_2c; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x40)) = VStack_28.x; + } + else { + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x3c)) = (float)local_2c * (1.0 / fVar1); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x40)) = VStack_28.x * (1.0 / fVar1); + } + } + if ((isShooting == 0) && (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) != 0)) { + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) + 0xd88)) = 1; + } + return; +} diff --git a/generated-src/weapon_urn_of_souls.cpp b/generated-src/weapon_urn_of_souls.cpp index 50c94cc..d547f07 100644 --- a/generated-src/weapon_urn_of_souls.cpp +++ b/generated-src/weapon_urn_of_souls.cpp @@ -1,11 +1,492 @@ #include "classes.h" // 009f3170 -uint32_t Weapon_UrnOfSouls::GetMainEntity() +Entity * Weapon_UrnOfSouls::GetMainEntity() { return *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)); } +// 00a0e630 +void Weapon_UrnOfSouls::Fire(Vector *direction, uint8_t isShooting, uint8_t isInterpolated) +{ + Entity_Laser *pEVar1; + Entity_Player *pEVar2; + Entity *spawner; + uint8_t auVar3 [16]; + uint8_t auVar4 [16]; + uint8_t bVar5; + Vector *pVVar6; + uint32_t rngValue; + Entity_Player *ownerPlayer; + Entity_Tear *pEVar7; + Entity_Laser *laser; + int *extraout_EDX; + float twinDx; + float twinDx; + float twinDy; + uint8_t *puVar9; + uint8_t *aimX; + float fVar10; + uint8_t auVar11 [16]; + uint8_t auVar12 [16]; + Entity_Tear *local_90; + Entity_Tear *local_8c; + Vector aimDir; + uint8_t *local_80; + Entity_Player *player; + Vector ownerPos; + Vector local_70; + Vector VStack_68; + Entity_Laser *pEStack_60; + uint32_t uStack_5c; + uint32_t uStack_58; + uint32_t uStack_54; + Vector local_48; + ColorMod soulColor; + Entity_NPC *flameLaser; + Manager *manager; + int ownerEntity; + Entity_Tear *soulTear; + BitSet128 temp_7df6acc38b0; + int *urnEffect; + uint32_t urnPosY; + int urnState; + + local_90 = GHIDRA_CAST(direction); + Weapon::Fire(this,direction,isShooting,isInterpolated); + pEVar2 = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + player = pEVar2; + if (pEVar2 == GHIDRA_CAST(0x0)) { +LAB_00a0e69d: + ownerPlayer = GHIDRA_CAST(0x0); + if ((pEVar2 == GHIDRA_CAST(0x0)) || (pEVar2->_type != 1)) { +LAB_00a0e6af: + player = GHIDRA_CAST(0x0); + if (pEVar2 == GHIDRA_CAST(0x0)) { + local_48.x = 1.0; + player = GHIDRA_CAST(0x0); + goto LAB_00a0e6d5; + } + } + local_48.x = pEVar2->_speedMultiplier; + } + else { + if (pEVar2->_type != 1) { + if (pEVar2->_type != 3) goto LAB_00a0e69d; + ownerPlayer = *GHIDRA_CAST(&pEVar2->_isControlsEnabled); + goto LAB_00a0e6af; + } + local_48.x = pEVar2->_speedMultiplier; + ownerPlayer = pEVar2; + } +LAB_00a0e6d5: + pEVar2 = player; + if (ownerPlayer != GHIDRA_CAST(0x0)) { + Entity_Player::HasCollectible(ownerPlayer,0x18a,0); + } + ownerPlayer = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + local_70.x = *GHIDRA_CAST(local_90); + local_80 = *GHIDRA_CAST(&(*GHIDRA_CAST((GHIDRA_CAST((local_90)) + 0x4)))); + if ((local_70.x == g_vectorZero.x) && ((float)local_80 == g_vectorZero.y)) { + local_70.x = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); + local_80 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)); + } + aimDir.x = local_70.x; + aimDir.y = (float)local_80; + if ((local_70.x == g_vectorZero.x) && ((float)local_80 == g_vectorZero.y)) { + puVar9 = local_80; + aimX = GHIDRA_CAST(local_70.x); + if (pEVar2 == GHIDRA_CAST(0x0)) { + if (ownerPlayer->_type == 3) { + switch(ownerPlayer->_chargeBarSprites[5]._scale.x) { + case 0.0: + goto LAB_00a0e785; + case 1.4013e-45: + goto LAB_00a0e7a6; + case 2.8026e-45: + goto LAB_00a0e798; + case 4.2039e-45: + goto LAB_00a0e7ce; + } + } + } + else { + switch(pEVar2->_headDirection) { + case 0: +LAB_00a0e785: + aimX = &DAT_bf800000; + aimDir.x = (float)&DAT_bf800000; + break; + case 1: +LAB_00a0e7a6: + aimDir.y = (float)&DAT_bf800000; + puVar9 = &DAT_bf800000; + break; + case 2: +LAB_00a0e798: + aimDir.x = 1.0; + aimX = GHIDRA_CAST(0x3f800000); + break; + case 3: +LAB_00a0e7ce: + aimDir.y = 1.0; + puVar9 = GHIDRA_CAST(0x3f800000); + } + } + } + else { + twinDx = sqrtf(local_70.x * local_70.x + (float)local_80 * (float)local_80); + ownerPlayer = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (twinDx <= 0.0) { + puVar9 = local_80; + aimX = GHIDRA_CAST(local_70.x); + } + else { + aimDir.y = (1.0 / twinDx) * (float)local_80; + aimDir.x = (1.0 / twinDx) * local_70.x; + puVar9 = GHIDRA_CAST(aimDir.y); + aimX = GHIDRA_CAST(aimDir.x); + } + } + local_8c = GHIDRA_CAST(0x0); + if ((ownerPlayer != GHIDRA_CAST(0x0)) && (ownerPlayer->_type == 1)) { + bVar5 = Entity_Player::HasCollectible(ownerPlayer,0x3b,0); + local_8c = GHIDRA_CAST(GHIDRA_UINT((bVar5 != 0))); + puVar9 = GHIDRA_CAST(aimDir.y); + aimX = GHIDRA_CAST(aimDir.x); + } + urnEffect = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)); + soulTear = GHIDRA_CAST((GHIDRA_INT(this) + 0x4c)); + if (((urnEffect == GHIDRA_CAST(0x0)) || + ((GHIDRA_CAST(urnEffect[0xc]) != local_8c && + ((**(code **)(*urnEffect + 0x28))(), puVar9 = GHIDRA_CAST(aimDir.y), + aimX = GHIDRA_CAST(aimDir.x), *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) == 0)))) && (isInterpolated == 0)) + { + local_90 = GHIDRA_CAST(Random()); + spawner = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + if (spawner == GHIDRA_CAST(0x0)) { + ownerPos.x = g_vectorZero.x; + ownerPos.y = g_vectorZero.y; + } + else { + ownerPos.x = (spawner->_pos).x; + ownerPos.y = (spawner->_pos).y; + } + local_8c = (Entity_Tear *) + Game::SpawnEx(g_game,1000,0xb2,&ownerPos,&g_vectorZero,spawner,GHIDRA_UINT(local_8c), + GHIDRA_UINT(local_90),0); + pEVar7 = *GHIDRA_CAST(soulTear); + if (pEVar7 != local_8c) { + if (pEVar7 != GHIDRA_CAST(0x0)) { + local_90 = soulTear; + msvc::multiset::erase(); + } + *GHIDRA_CAST(soulTear) = local_8c; + pEVar7 = GHIDRA_CAST(0x0); + if (local_8c != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + pEVar7 = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)); + } + } + local_70.x = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + local_8c = GHIDRA_CAST(&pEVar7->_parent); + if (*GHIDRA_CAST(local_8c) != 0) { + local_90 = local_8c; + msvc::multiset::erase(); + } + *GHIDRA_CAST(local_8c) = local_70.x; + if (GHIDRA_CAST(local_70.x) != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + } + *GHIDRA_CAST((*GHIDRA_CAST(soulTear) + 0x450)) = 0xfffffffc; + ownerEntity = *GHIDRA_CAST(soulTear); + *GHIDRA_CAST((ownerEntity + 0x34c)) = 0; + *GHIDRA_CAST((ownerEntity + 0x350)) = 0xc1700000; + ownerEntity = __RTDynamicCast(*GHIDRA_CAST((GHIDRA_CAST(this) + 4))); + if (((ownerEntity != 0) && (g_manager->_netplayManager != *GHIDRA_CAST((g_manager + 1)))) && + (bVar5 = NetplayManager::IsIdxLocalPlayer + (GHIDRA_CAST(&g_manager->_netplayManager), + *GHIDRA_CAST((ownerEntity + 0x1618))), bVar5 == 0)) { + ownerEntity = *GHIDRA_CAST(soulTear); + soulColor._tint[0] = *GHIDRA_CAST((ownerEntity + 0xf0)); + soulColor._tint[1] = *GHIDRA_CAST((ownerEntity + 0xf4)); + soulColor._tint[2] = *GHIDRA_CAST((ownerEntity + 0xf8)); + fVar10 = *GHIDRA_CAST((ownerEntity + 0xfc)); + soulColor._colorize[0] = *GHIDRA_CAST((ownerEntity + 0x100)); + soulColor._colorize[1] = *GHIDRA_CAST((ownerEntity + 0x104)); + soulColor._colorize[2] = *GHIDRA_CAST((ownerEntity + 0x108)); + soulColor._colorize[3] = *GHIDRA_CAST((ownerEntity + 0x10c)); + twinDx = *GHIDRA_CAST((ownerEntity + 0x110)); + soulColor._offset[1] = *GHIDRA_CAST((ownerEntity + 0x114)); + soulColor._offset[2] = *GHIDRA_CAST((ownerEntity + 0x118)); + soulColor._tint[3] = fVar10; + soulColor._offset[0] = twinDx; + FUN_00925df0(); + soulColor._tint[3] = twinDx * fVar10; + (**(code **)(*extraout_EDX + 0x3c))(&soulColor); + } + twinDx = atan2f(aimDir.y,aimDir.x); + twinDx = twinDx * 57.295776; + if (0.0 < twinDx) { + twinDx = twinDx + 90.0; + } + else { + twinDx = twinDx - 90.0; + } + *GHIDRA_CAST((*GHIDRA_CAST(soulTear) + 0xec)) = twinDx; + (**(code **)(**GHIDRA_CAST(soulTear) + 0xc))(); + puVar9 = GHIDRA_CAST(aimDir.y); + aimX = GHIDRA_CAST(aimDir.x); + } + if (*GHIDRA_CAST(soulTear) == 0) { + return; + } + twinDx = atan2f((float)puVar9,(float)aimX); + *GHIDRA_CAST((*GHIDRA_CAST(soulTear) + 0x474)) = twinDx * 57.295776; + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x50)); + if (ownerEntity != 0) { + urnPosY = *GHIDRA_CAST((*GHIDRA_CAST(soulTear) + 0x340)); + *GHIDRA_CAST((ownerEntity + 0x33c)) = *GHIDRA_CAST((*GHIDRA_CAST(soulTear) + 0x33c)); + *GHIDRA_CAST((ownerEntity + 0x340)) = urnPosY; + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x50)); + local_90 = *GHIDRA_CAST((ownerEntity + 0x41c)); + twinDx = LerpAngleDeg((float)local_90,*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) + 0xec)),0.15); + *GHIDRA_CAST((ownerEntity + 0x418)) = twinDx; + *GHIDRA_CAST((ownerEntity + 0x41c)) = twinDx; + *GHIDRA_CAST((ownerEntity + 0x420)) = local_90; + *GHIDRA_CAST((ownerEntity + 0xec)) = twinDx - 90.0; + } + if (isInterpolated != 0) { + return; + } + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)); + urnState = *GHIDRA_CAST((ownerEntity + 0x450)); + if (urnState < 0) goto LAB_00a0f3a4; + if (((isShooting != 0) && (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) <= 0.0)) && + ((player != GHIDRA_CAST(0x0) && + ((0 < player->_urnSouls || (0 < player->_effectiveSoulCharge)))))) { + if ((urnState == 3) || (urnState == 4)) { + *GHIDRA_CAST((ownerEntity + 0x450)) = 3; + } + else if (urnState == 0) { + *GHIDRA_CAST((ownerEntity + 0x450)) = 1; + Weapon::get_owner_position(this,&ownerPos); + manager = g_manager; + local_8c = GHIDRA_CAST(0x216); + seed_fart_sound_override(GHIDRA_CAST(&local_8c)); + (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_8c),1.6,1,0,1.0,0.0); + } + pEVar2 = player; + ownerEntity = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) + 0x450)); + if ((ownerEntity == 2) || (ownerEntity == 3)) { + if (player->_urnSouls < 1) { + if (0 < player->_effectiveSoulCharge) { + Entity_Player::AddSoulCharge(player,-1); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) = 0x41c80000; + } + } + else { + Entity_Player::AddUrnSouls(player,0xffffffff); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) = 0x41700000; + } + if ((0.0 < *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44))) && + (bVar5 = Entity_Player::HasCollectible(pEVar2,0x248,0), bVar5 != 0)) { + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar11)) + 0x8))) = 0; + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar11)) + 0x4))) = &ownerPos; + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar11)) + 0x0))) = 0xa0ec9d; + pVVar6 = Weapon::get_owner_position(this,&ownerPos); + Entity_Player::AddWisp(pEVar2,0x280,pVVar6,auVar11[8],auVar11[0xc]); + } + } + } + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)); + urnState = *GHIDRA_CAST((ownerEntity + 0x450)); + if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) <= 0.0) { + if ((urnState == 2) || (urnState == 3)) { + Weapon::get_owner_position(this,&ownerPos); + manager = g_manager; + local_90 = GHIDRA_CAST(0x218); + seed_fart_sound_override(GHIDRA_CAST(&local_90)); + (GHIDRA_CAST((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_90),1.6,1,0,1.0,0.0); + manager = g_manager; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)) = 0; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = g_vectorZero.x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = g_vectorZero.y; + SFXManager::Stop(&manager->_sfxManager,0x216); + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) + 0x450)) = 4; + } + goto LAB_00a0f3a4; + } + if ((urnState != 2) && (urnState != 3)) goto LAB_00a0f3a4; + twinDx = local_48.x / 90.0 + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)); + local_70.x = 1.0; + if (twinDx <= 1.0) { + local_70.x = twinDx; + } + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)) = local_70.x; + Weapon::get_owner_position(this,&ownerPos); + local_90 = GHIDRA_CAST((*GHIDRA_CAST((ownerEntity + 0xec)) * 0.017453292)); + local_8c = GHIDRA_CAST(cos((float)local_90)); + local_90 = GHIDRA_CAST(sin((float)local_90)); + twinDx = local_70.x * 6.0 + 6.0; + local_70.x = twinDx * (float)local_90; + pEStack_60 = GHIDRA_CAST((twinDx * (float)local_8c)); + rngValue = Random(); + VStack_68.x = ((float)((double)GHIDRA_INT(rngValue) + __uint_to_double_fixup[-(GHIDRA_INT(rngValue) >> 0x1f)]) * + 2.3283064e-10 * 16.0 - 8.0) * 0.017453292; + local_80 = GHIDRA_CAST(cos(VStack_68.x)); + twinDx = sin(VStack_68.x); + pEVar2 = player; + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)); + fVar10 = (float)local_80 * (float)pEStack_60; + local_80 = GHIDRA_CAST(((float)local_80 * local_70.x + twinDx * (float)pEStack_60)); + VStack_68.x = fVar10 - twinDx * local_70.x; + fVar10 = (float)local_8c * -0.4 * local_48.x; + ownerPos.x = (float)local_8c + (float)local_8c + ownerPos.x; + twinDx = (float)local_90 * -0.4 * local_48.x; + ownerPos.y = (float)local_90 + (float)local_90 + ownerPos.y; + *GHIDRA_CAST((ownerEntity + 0x364)) = + *GHIDRA_CAST((ownerEntity + 0x39c)) * twinDx + *GHIDRA_CAST((ownerEntity + 0x364)); + *GHIDRA_CAST((ownerEntity + 0x360)) = + *GHIDRA_CAST((ownerEntity + 0x39c)) * fVar10 + *GHIDRA_CAST((ownerEntity + 0x360)); + if (((player != GHIDRA_CAST(0x0)) && (ownerEntity = player->_twinPlayer, ownerEntity != 0)) && + (twinDx = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x33c)) - *GHIDRA_CAST((ownerEntity + 0x33c)), + twinDy = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) + 0x340)) - *GHIDRA_CAST((ownerEntity + 0x340)), + twinDy * twinDy + twinDx * twinDx < 6400.0)) { + *GHIDRA_CAST((ownerEntity + 0x364)) = + twinDx * *GHIDRA_CAST((ownerEntity + 0x39c)) + *GHIDRA_CAST((ownerEntity + 0x364)); + *GHIDRA_CAST((ownerEntity + 0x360)) = + *GHIDRA_CAST((ownerEntity + 0x39c)) * fVar10 + *GHIDRA_CAST((ownerEntity + 0x360)); + } + VStack_68.y = (float)local_80; + pEStack_60 = GHIDRA_CAST(VStack_68.x); + pVVar6 = Weapon::get_tear_movement_inheritance(this,&local_48,&VStack_68); + VStack_68.x = (float)pEStack_60 + pVVar6->x; + VStack_68.y = (float)local_80 + pVVar6->y; + if (*GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) + 0x30)) == 1) { + twinDx = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)); + ownerEntity = _get_index_plus_one_if_kind_4_5(); + pEVar1 = GHIDRA_CAST((GHIDRA_INT(this) + 0x50)); + laser = *GHIDRA_CAST(pEVar1); + local_48.x = ((float)ownerEntity * 0.3 + 2.8) * 1.5 * (twinDx * 0.19999999 + 0.8); + if (laser == GHIDRA_CAST(0x0)) { + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)); + local_70.x = *GHIDRA_CAST((ownerEntity + 0x33c)); + local_70.y = *GHIDRA_CAST((ownerEntity + 0x340)); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar12)) + 0x8))) = ownerEntity; + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar12)) + 0x4))) = &pEStack_60; + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar12)) + 0xc))) = 0; + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar12)) + 0x0))) = 8; + uStack_5c = 0xc1700000; + pEStack_60 = laser; + twinDx = atan2f((float)local_90,(float)local_8c); + VStack_68.x = (float)Entity_Laser::ShootAngle + (1,&local_70,twinDx * 57.295776,(*GHIDRA_CAST((GHIDRA_CAST(&(auVar12)) + 0x0))),(*GHIDRA_CAST((GHIDRA_CAST(&(auVar12)) + 0x4))), + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar12)) + 0x8))),auVar12[0xc]); + laser = *GHIDRA_CAST(pEVar1); + if (laser != GHIDRA_CAST(VStack_68.x)) { + if (laser != GHIDRA_CAST(0x0)) { + pEStack_60 = pEVar1; + msvc::multiset::erase(); + } + *GHIDRA_CAST(pEVar1) = VStack_68.x; + laser = GHIDRA_CAST(0x0); + if (GHIDRA_CAST(VStack_68.x) != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + laser = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x50)); + } + } + laser->_spawnerType = 1; + *GHIDRA_CAST((*GHIDRA_CAST(pEVar1) + 0x38)) = 0; + (**(code **)(**GHIDRA_CAST(pEVar1) + 0x40))(); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar3)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagShielded._l)) + 0x4))); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar3)) + 0x0))) = GHIDRA_UINT(g_tearFlagShielded._l); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar3)) + 0x8))) = GHIDRA_UINT(g_tearFlagShielded._h); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar3)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagShielded._h)) + 0x4))); + *(uint8_t (*) [16])(*GHIDRA_CAST(pEVar1) + 0x428) = auVar3; + (**(code **)(**GHIDRA_CAST(pEVar1) + 0xc))(); + laser = *GHIDRA_CAST(pEVar1); + if (laser == GHIDRA_CAST(0x0)) goto LAB_00a0f2ba; + } + (**(code **)(*GHIDRA_CAST(laser) + 0x40))(); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar4)) + 0x4))) = (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagShielded._l)) + 0x4))); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar4)) + 0x0))) = GHIDRA_UINT(g_tearFlagShielded._l); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar4)) + 0x8))) = GHIDRA_UINT(g_tearFlagShielded._h); + (*GHIDRA_CAST((GHIDRA_CAST(&(auVar4)) + 0xc))) = (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagShielded._h)) + 0x4))); + *(uint8_t (*) [16])(*GHIDRA_CAST(pEVar1) + 0x428) = auVar4; + *GHIDRA_CAST((*GHIDRA_CAST(pEVar1) + 0x458)) = 8; + flameLaser = *GHIDRA_CAST(pEVar1); + twinDx = LerpAngleDeg((flameLaser->_pathfinder)._movementTarget.y, + *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) + 0xec)),0.3); + Entity_NPC::SetAimAngle(flameLaser,twinDx); + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x50)); + twinDx = sin(*GHIDRA_CAST((ownerEntity + 0x41c)) * 0.017453292); + if (twinDx <= -0.5) { + *GHIDRA_CAST((ownerEntity + 0x358)) = 0xc1200000; + } + else { + *GHIDRA_CAST((ownerEntity + 0x358)) = 0x453b8000; + } + } + else { + rngValue = Random(); + local_90 = (Entity_Tear *) + Game::SpawnEx(g_game,2,0x2e,&ownerPos,&VStack_68,GHIDRA_CAST(pEVar2),0,rngValue,0); + VStack_68.x = (float)&local_90->_parent; + if (local_90->_parent != 0) { + pEStack_60 = GHIDRA_CAST(VStack_68.x); + msvc::multiset::erase(); + } + *GHIDRA_CAST(VStack_68.x) = pEVar2; + if (pEVar2 != GHIDRA_CAST(0x0)) { + msvc::multiset::insert(); + } + soulTear = local_90; + Entity_Tear::SetTearFlags(local_90,g_tearFlagPiercing); + soulTear->_tearRange = 160.0; + rngValue = (GHIDRA_CAST((&soulTear->_dropRNG)))->RNG::RandomInt(8); + if (rngValue == 0) { + pEStack_60 = GHIDRA_CAST((GHIDRA_UINT((soulTear->_tearFlags)._l) | GHIDRA_UINT(g_tearFlagShielded._l))); + uStack_5c = *GHIDRA_CAST((GHIDRA_INT(&(soulTear->_tearFlags)._l) + 4)) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagShielded._l)) + 0x4))); + uStack_58 = GHIDRA_UINT((soulTear->_tearFlags)._h) | GHIDRA_UINT(g_tearFlagShielded._h); + uStack_54 = *GHIDRA_CAST((GHIDRA_INT(&(soulTear->_tearFlags)._h) + 4)) | (*GHIDRA_CAST((GHIDRA_CAST(&(g_tearFlagShielded._h)) + 0x4))); + (*GHIDRA_CAST((GHIDRA_CAST(&(temp_7df6acc38b0._l)) + 0x4))) = uStack_5c; + (*GHIDRA_CAST((GHIDRA_CAST(&(temp_7df6acc38b0._l)) + 0x0))) = pEStack_60; + (*GHIDRA_CAST((GHIDRA_CAST(&(temp_7df6acc38b0._h)) + 0x0))) = uStack_58; + (*GHIDRA_CAST((GHIDRA_CAST(&(temp_7df6acc38b0._h)) + 0x4))) = uStack_54; + Entity_Tear::SetTearFlags(soulTear,temp_7df6acc38b0); + } + twinDx = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)); + ownerEntity = _get_index_plus_one_if_kind_4_5(); + soulTear->_mass = 0.0; + pEStack_60 = GHIDRA_CAST((((float)ownerEntity * 0.3 + 2.3) * (twinDx * 0.19999999 + 0.8))); + twinDx = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)) * 0.40000004 + 0.7; + if (twinDx <= 0.01) { + twinDx = 0.01; + } + soulTear->_baseScale = twinDx; + soulTear->_fScale = twinDx; + Entity_Tear::ResetSpriteScale(soulTear); + (**(code **)(*GHIDRA_CAST(soulTear) + 0x40))(); + soulTear->_fallingAccel = 0.1; + (**(code **)(*GHIDRA_CAST(soulTear) + 0xc))(); + } +LAB_00a0f2ba: + Game::ShakeScreen(g_game,3); + Weapon::TriggerTearEffects(this,&aimDir,1); + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x44)) - 1.0; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = aimDir.x; + *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = aimDir.y; +LAB_00a0f3a4: + ownerEntity = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)); + *GHIDRA_CAST((ownerEntity + 0x478)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x48)); + urnState = *GHIDRA_CAST((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x4c)) + 0x450)); + if (((urnState == 2) || (urnState == 3)) || (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x50)) != 0)) { + Weapon::SetBlinkTime(this,4,ownerEntity); + } + return; +} + // 00a0f410 void Weapon_UrnOfSouls::Reset() { diff --git a/scripts/source_tree.py b/scripts/source_tree.py index 4490230..cfc418d 100644 --- a/scripts/source_tree.py +++ b/scripts/source_tree.py @@ -566,11 +566,15 @@ def stub_define(owner, decl, addr): # a declaration as a definition that stops label = (f'{owner}::' if owner else '') + name + (f' {addr:08x}' if addr else '') return text.replace(name + '(', (f'{owner}::' if owner else '') + name + '(', 1) + f' {{ generated_stub("{label}"); }}\n' incomplete = {t for t in forward if t not in done} | {c for c in curatedClasses if '::' in c} -srcText = ''.join(open(os.path.join(root, n), errors='replace').read() for root, _, names_ in os.walk(srcDir) for n in names_ if n.endswith('.cpp')) +srcTexts = [open(os.path.join(root, n), errors='replace').read() for root, _, names_ in os.walk(srcDir) for n in names_ if n.endswith('.cpp')] +def src_defines(owner, method): # src/ defines owner::method: qualified, or by its short name at top level or inside its namespace block + space, _, short = owner.rpartition('::') + pattern = re.compile(rf'(?= ROOMSHAPE_LTL && shape <= ROOMSHAPE_LBR; +} + +static bool is_narrow_shape(RoomShape shape) +{ + return shape == ROOMSHAPE_IH || shape == ROOMSHAPE_IV || shape == ROOMSHAPE_IIV || shape == ROOMSHAPE_IIH; +} + +// The wall details of a backdrop with them: the Downpour's pipes, the Mines' and Ashpit's (dark in a pitch black room or +// the abandoned mineshaft), Mausoleum's chains and Gehenna's. None for the others. +static std::string_view wall_details_path_get(uint32_t backdropId) +{ + bool isDark = g_game->room->descriptor->flags & ROOM_FLAG_PITCH_BLACK; + + switch (backdropId) + { + case BACKDROP_DOWNPOUR: return "gfx/backdrop/01x_downpour_pipes.anm2"; + case BACKDROP_MINES: + case BACKDROP_MINES_SHAFT: + if (isDark || backdropId == BACKDROP_MINES_SHAFT) return "gfx/backdrop/03x_mines_details_dark.anm2"; + return "gfx/backdrop/03x_mines_details.anm2"; + case BACKDROP_MAUSOLEUM4: return "gfx/backdrop/05x_mausoleum_chains.anm2"; + case BACKDROP_ASHPIT: + case BACKDROP_ASHPIT_SHAFT: + if (isDark || backdropId == BACKDROP_ASHPIT_SHAFT) return "gfx/backdrop/04x_ashpit_details_dark.anm2"; + return "gfx/backdrop/04x_ashpit_details.anm2"; + case BACKDROP_GEHENNA: return "gfx/backdrop/06x_gehenna_details.anm2"; + default: return {}; + } +} + +// Mega Satan's floor, drawn once into the floor surface from its second idle animation, then left on the first. +static void mega_satan_floor_render(Backdrop& backdrop) +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + + graphics.SetRenderTarget(backdrop.floorBuffer.get(), KAGE::Graphics::TARGET_OWN_SIZE); + graphics.Clear(); + KAGE::Graphics::BlendMode savedBlend = graphics.blendMode; + graphics.blend_set(KAGE::Graphics::BLEND_NORMAL); + backdrop.floorSprite.Play("Idle2"); + graphics.isCullOffscreen = false; + backdrop.floorSprite.Render({.position = vector_make(MEGA_SATAN_FLOOR_X + backdrop.roomTopLeft.x, + MEGA_SATAN_FLOOR_Y + backdrop.roomTopLeft.y)}); + graphics.isCullOffscreen = true; + graphics.blendMode = savedBlend; + graphics.Present(KAGE::Graphics::PRESENT_FINISH); + backdrop.floorSprite.Play("Idle1"); +} + +// 0093da00 Loads the room's backdrop graphics and draws its surfaces: the controls sprites once, then the one sprite +// floors (the Error room's, Mega Satan's drawn into the floor surface, the Planetarium's by the room's shape, Home's +// closets by their side and Dogma's), or the walls and floor sheets, the water, an L or narrow room's floor and the +// wall details, drawn into the wall and floor surfaces. The render target is back as it was after. +void Backdrop::load_details() +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + RoomConfig_Room* data = g_game->room->descriptor ? g_game->room->descriptor->data : nullptr; + RoomShape shape = data ? data->shape : ROOMSHAPE_1x1; + BackdropConfig& config = configs[backdropId]; + + isTempSurfaceUsed = false; + floorSprite.Reset(); + wallDetailSprite.Reset(); + if (!controlsSprite.isLoaded) controlsSprite.Load("gfx/backdrop/controls.anm2", GRAPHICS_LOAD); + if (!controlsButtonsSprite.isLoaded) controlsButtonsSprite.Load("gfx/backdrop/controls_buttons.anm2", GRAPHICS_LOAD); + auto size = graphics.isScreenTarget ? KAGE::Graphics::TARGET_SCREEN_SIZE : KAGE::Graphics::TARGET_OWN_SIZE; + graphics.render_target_push(graphics.renderTarget, size, KAGE::Graphics::PRESENT_FLUSH); + waterGfx.reset(); + + switch (backdropId) + { + case BACKDROP_ERROR_ROOM: + case BACKDROP_MEGA_SATAN: + floorSprite.Load(config.gfx, GRAPHICS_LOAD); + if (backdropId == BACKDROP_MEGA_SATAN) mega_satan_floor_render(*this); + break; + case BACKDROP_PLANETARIUM: + floorSprite.Load(config.gfx, GRAPHICS_LOAD); + floorSprite.SetFrame("Idle", 0); + for (int i = 0; i < (int)floorSprite.layerStates.size(); i++) floorSprite.GetLayer(i)->isVisible = i + 1 == shape; + break; + case BACKDROP_CLOSET: + case BACKDROP_CLOSET_B: + case BACKDROP_DOGMA: + floorSprite.Load(config.gfx, GRAPHICS_LOAD); + floorSprite.SetFrame("Idle", backdropId == BACKDROP_DOGMA ? 0 : data->subtype - (int)HOME_CLOSET_FIRST_SUBTYPE); + graphics.isCullOffscreen = false; + render_ashpit_ash(); + graphics.isCullOffscreen = true; + break; + default: + { + if (!config.gfx.empty()) gfx = Manager::LoadImage(config.gfx); + if (!config.waterGfx.empty()) + { + waterGfx = Manager::LoadImage(config.waterGfx); + if (waterGfx && (waterGfx->wrapS != 0 || waterGfx->wrapT != 0)) waterGfx->wrap_set(0, 0); + } + if (is_l_shape(g_game->room->descriptor->data->shape) && !config.lFloorGfx.empty()) + nlFloorGfx = Manager::LoadImage(config.lFloorGfx); + else if (!config.nFloorGfx.empty() && is_narrow_shape((RoomShape)g_game->room->GetRoomShape())) + nlFloorGfx = Manager::LoadImage(config.nFloorGfx); + + std::string_view detailsPath = wall_details_path_get(backdropId); + if (!detailsPath.empty()) + { + wallDetailSprite.Load(detailsPath, GRAPHICS_LOAD); + wallDetailSprite.Play(wallDetailSprite.GetDefaultAnimationName()); + } + if (!gfx) break; + + graphics.isCullOffscreen = false; + render_ashpit_ash(); + pre_render_walls(); + graphics.isCullOffscreen = true; + gfx.reset(); + nlFloorGfx.reset(); + } + } + graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH); +} void Backdrop::pre_render_walls() { reconstruction_missing("Backdrop::pre_render_walls 00937420"); } void Backdrop::PreRenderControls() { reconstruction_missing("Backdrop::PreRenderControls 00934770"); } void Backdrop::render_control_icon() { reconstruction_missing("Backdrop::render_control_icon 00935010"); } diff --git a/src/beast_arena.cpp b/src/beast_arena.cpp new file mode 100644 index 0000000..7c35bc5 --- /dev/null +++ b/src/beast_arena.cpp @@ -0,0 +1,88 @@ +#include "beast_arena.h" +#include "game.h" +#include "log.h" +#include "room.h" + +constexpr int STAGE_ID_HOME = 35; +constexpr int BACKGROUND_LAYER_COUNT = 15; +constexpr int BACKGROUND_GLOW_LAYER = 8; +constexpr int BACKGROUND_ADDITIVE_LAYER = 13; +constexpr int BACKGROUND_MULTIPLY_LAYER = 14; +constexpr unsigned int WRAP_REPEAT = 0; +constexpr unsigned int WRAP_CLAMP = 1; +constexpr float BACKGROUND_PARALLAX = 0.1f; + +// The background's layer blending: plain alpha, the glow over what is behind it, added light, and a darkening multiply. +// The source factor takes premultiplied alpha into account. +static std::array blend_get(int layerId) +{ + int source = KAGE::Graphics::manager.isPremultipliedAlpha ? BLEND_FACTOR_ONE : BLEND_FACTOR_SRC_ALPHA; + + if (layerId == BACKGROUND_GLOW_LAYER) + return {BLEND_EQUATION_ADD, source, BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, BLEND_FACTOR_ONE, + BLEND_FACTOR_ONE_MINUS_SRC_ALPHA}; + if (layerId == BACKGROUND_ADDITIVE_LAYER) + return {BLEND_EQUATION_ADD, source, BLEND_FACTOR_ONE, BLEND_FACTOR_ONE, BLEND_FACTOR_ONE}; + if (layerId == BACKGROUND_MULTIPLY_LAYER) + return {BLEND_EQUATION_ADD, BLEND_FACTOR_ZERO, BLEND_FACTOR_SRC_COLOR, BLEND_FACTOR_ZERO, BLEND_FACTOR_SRC_COLOR}; + return {BLEND_EQUATION_ADD, BLEND_FACTOR_ONE, BLEND_FACTOR_ZERO, BLEND_FACTOR_ONE, BLEND_FACTOR_ZERO}; +} + +// 00839b80 Turns on in Home's Beast crawlspace: loads the hell background once, wraps its layers sideways, sets their +// blending and stops the scroll. +void BeastArena::init() +{ + RoomConfig_Room* config = g_game->room->descriptor->data; + + isActive = config && config->type == ROOM_DUNGEON && config->stageId == STAGE_ID_HOME; + if (!isActive) return; + + if (!background.isLoaded) + { + background.Load("gfx/backdrop/hell/background.anm2", GRAPHICS_DEFER); + background.bitflags |= ANIM_RENDER_SHADER_KEPT; + background.LoadGraphics(); + background.Play(background.GetDefaultAnimationName(), PLAY_FORCED); + } + for (LayerState& layer : background.layerStates) + { + layer.wrapSMode = WRAP_REPEAT; + layer.wrapTMode = WRAP_CLAMP; + } + for (int i = 0; i < BACKGROUND_LAYER_COUNT; i++) background.GetLayer(i)->blendMode = blend_get(i); + scrollRendered = 0; + scrollSpeed = 0; + scroll = 0; +} + +// 0083a080 Animates the background, scrolls it, and carries the room's entities along: a tenth as far on the +// background sorting layer, the players and familiars not at all. The Beast's second variant moves its target too, +// and the players collide with the grid where they are. +void BeastArena::update() +{ + if (!isActive) return; + + background.Update(); + scroll += scrollSpeed; + scrollRendered = scroll; + + for (Entity* entity : g_game->room->entityList.updateEL) + { + if (entity->type == ENTITY_PLAYER) + { + entity->PlayerCollideWithGrid(GRID_COLLISION_APPLY); + continue; + } + if (entity->type == ENTITY_FAMILIAR) continue; + + float shift = entity->sortingLayer == SORTING_BACKGROUND ? scrollSpeed * BACKGROUND_PARALLAX : scrollSpeed; + entity->pos.x += shift; + if (entity->type == ENTITY_BEAST && entity->variant == 1) entity->targetPosition.x += scrollSpeed; + } +} + +// 0083a1b0 Draws the background's light layer over the screen, following the camera. +void BeastArena::render_light() +{ + reconstruction_missing("BeastArena::render_light 0083a1b0"); +} diff --git a/src/beast_arena.h b/src/beast_arena.h new file mode 100644 index 0000000..fb88a15 --- /dev/null +++ b/src/beast_arena.h @@ -0,0 +1,19 @@ +#pragma once + +#include "anm2.h" + +// Construction and destruction are the defaults. The scroll speed's getter (00592260) is the public field. +// The scrolling hell of the Beast's fight (Room's beastArena): active in Home's Beast crawlspace, where its background +// scrolls by scrollSpeed and carries everything but the players and familiars along. +struct BeastArena +{ + ANM2 background; + float scroll = 0; + float scrollRendered = 0; + float scrollSpeed = 0; + bool isActive = false; + + void init(); + void update(); + void render_light(); +}; diff --git a/src/camera.cpp b/src/camera.cpp index 8d828a9..ddf4fc5 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -67,9 +67,7 @@ constexpr float NET_VIEW_HALF_HEIGHT = 207.6923f; constexpr int LASER_VARIANT_THICK_RED = 1; constexpr int LASER_VARIANT_THICKER_RED = 3; constexpr int ITEM_STATE_LUDOVICO_CHARGE = 49; -constexpr int WEAPON_TYPE_BRIMSTONE = 2; constexpr int COLLECTIBLE_LUDOVICO_TECHNIQUE = 329; -constexpr int WEAPON_TYPE_KNIFE = 4; static float random_unit() { @@ -260,8 +258,7 @@ Vector Camera::get_enemy_focus_offset() if (!isVersusPlayer && !isEnemy) continue; if (!enemy->CanShutDoors() || !enemy->isVisible) continue; - Vector center; - players_center_position(&g_game->playerManager, ¢er, true); + Vector center = g_game->playerManager.players_center_position(CENTER_CACHED); float dx = enemy->pos.x - center.x; float dy = enemy->pos.y - center.y; float distance = std::sqrt(dx * dx + dy * dy); @@ -305,8 +302,7 @@ void Camera::update_focus_position(bool isSkipFocusBuffer) return; } - Vector center; - players_center_position(&g_game->playerManager, ¢er, true); + Vector center = g_game->playerManager.players_center_position(CENTER_CACHED); bool isSolo = g_game->playerManager.playerList.size() == 1; float lead = isSolo ? AIM_LEAD : 0; @@ -321,12 +317,12 @@ void Camera::update_focus_position(bool isSkipFocusBuffer) if (lead < std::sqrt(pull.y * pull.y + pull.x * pull.x) && aimLength > 0) aim = vector_make(lead / aimLength * aim.x, lead / aimLength * aim.y); - if (!player->HasWeaponType(WEAPON_TYPE_KNIFE) || player->HasCollectible(COLLECTIBLE_LUDOVICO_TECHNIQUE)) aim = pull; + if (!player->HasWeaponType(WEAPON_KNIFE) || player->HasCollectible(COLLECTIBLE_LUDOVICO_TECHNIQUE)) aim = pull; else if (Entity_Knife* knife = dynamic_cast(focus); knife && knife->isFlying) aim = vector_make(pull.x + lead * player->lastDirection.x, pull.y + lead * player->lastDirection.y); } - bool isBrimstoneAim = player->HasWeaponType(WEAPON_TYPE_BRIMSTONE) && !player->HasCollectible(COLLECTIBLE_LUDOVICO_TECHNIQUE) && + bool isBrimstoneAim = player->HasWeaponType(WEAPON_BRIMSTONE) && !player->HasCollectible(COLLECTIBLE_LUDOVICO_TECHNIQUE) && !player->isPlayingExtraAnimation && !player->isPlayingItemAnimation; if (player->itemState == ITEM_STATE_LUDOVICO_CHARGE || isBrimstoneAim) { @@ -344,10 +340,9 @@ void Camera::update_focus_position(bool isSkipFocusBuffer) velocityOffsets.push(vector_make(player->velocity.x * velocityLead, player->velocity.y * velocityLead)); enemyOffsets.push(get_enemy_focus_offset()); - Vector spreadCenter; + Vector spreadCenter = g_game->playerManager.players_center_position(CENTER_CACHED); Vector spread = vector_make(0, 0); int mainPlayers = 0; - players_center_position(&g_game->playerManager, &spreadCenter, true); for (Entity_Player* other : g_game->playerManager.playerList) { if (other->variant != PLAYER_VARIANT_COOP_BABY) continue; @@ -431,8 +426,7 @@ void Camera::shake_update() // 009446e0 The follow camera: lags after the players' center (or the focus position), faster while far from it. void Camera::update_follow() { - Vector center; - players_center_position(&g_game->playerManager, ¢er, true); + Vector center = g_game->playerManager.players_center_position(CENTER_CACHED); if (isShouldOverride && focusPositions.count > 0) center = focusPositions.back(); shake_update(); @@ -452,8 +446,7 @@ void Camera::update_follow() // room's edges, and scrolls the room there. Level::Init runs it once a floor's first room is loaded. void Camera::position_center() { - Vector center; - players_center_position(&g_game->playerManager, ¢er, false); + Vector center = g_game->playerManager.players_center_position(CENTER_FRESH); if (isShouldOverride && focusPositions.count > 0) center = focusPositions.back(); Vector offset = to_camera(center); diff --git a/src/entity.cpp b/src/entity.cpp index dab1f31..fe88e95 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -1296,12 +1296,6 @@ bool Entity::is_grid_collision_at(const Vector&) reconstruction_missing("Entity::is_grid_collision_at 006ab240"); } -// 006ab440 -void Entity::PlayerCollideWithGrid(GridCollisionMode) -{ - reconstruction_missing("Entity::PlayerCollideWithGrid 006ab440"); -} - // 006ace60 bool Entity::TakeDamage(float, uint64_t, const EntityRef&, int) { diff --git a/src/entity_collision.cpp b/src/entity_collision.cpp new file mode 100644 index 0000000..68f7805 --- /dev/null +++ b/src/entity_collision.cpp @@ -0,0 +1,293 @@ +#include "entity_player.h" +#include "game.h" +#include "grid_entity_door.h" +#include "log.h" +#include "room.h" +#include + +// What crushes rocks on contact: The Nail, Leo (worn or rolled by Zodiac), Thunder Thighs, Stompy and Mega Mush. +constexpr int COLLECTIBLE_THE_NAIL = 83; +constexpr int COLLECTIBLE_LEO = 302; +constexpr int COLLECTIBLE_THUNDER_THIGHS = 314; +constexpr int PLAYERFORM_STOMPY = 13; + +// A poop's reach for a player's collision: a giga poop's quarter from its shared center, any other from its cell's. +constexpr int POOP_GIGA_FIRST = 7; +constexpr int POOP_GIGA_LAST = 10; +constexpr float POOP_GIGA_REACH = 38; +constexpr float POOP_REACH = 18; +constexpr float POOP_GIGA_QUARTER = 20; +constexpr std::array POOP_GIGA_CENTER_X = {POOP_GIGA_QUARTER, -POOP_GIGA_QUARTER, POOP_GIGA_QUARTER, + -POOP_GIGA_QUARTER}; +constexpr std::array POOP_GIGA_CENTER_Y = {POOP_GIGA_QUARTER, POOP_GIGA_QUARTER, -POOP_GIGA_QUARTER, + -POOP_GIGA_QUARTER}; + +// The grid collision a player passes, through the Lost's mirror door or past a wall it is pushed out of. +constexpr uint32_t GRID_COLLISION_WALL_EXCEPT_PLAYER = 5; +constexpr int MIRROR_DIMENSION = 1; + +// The Beast's dungeon keeps players this far above its floor's center line. +constexpr float BEAST_DUNGEON_OFFSET_Y = 20; +// A wall hit keeps this much of the speed into it, and pushes back this much more. +constexpr float WALL_BOUNCE = 0.9f; +constexpr float WALL_PUSH = 0.1f; +constexpr float NORMAL_EPSILON = 0.001f; +constexpr float PUSH_OUT_MIN_SPEED = 2; +constexpr int PUSH_OUT_STEPS_GROUND = 12; +constexpr int PUSH_OUT_STEPS = 6; + +// The room types whose doors Notched Axe hacks open. +constexpr int ROOM_TYPE_SECRET = 7; +constexpr int ROOM_TYPE_SUPERSECRET = 8; + +// A world position's cell index in the room, or -1 off its grid. +static int grid_index_at(Room& room, Vector position) +{ + int column = (int)((position.x - GRID_ORIGIN_X) / GRID_CELL_SIZE + 0.5f); + int row = (int)((position.y - GRID_ORIGIN_Y) / GRID_CELL_SIZE + 0.5f); + if (column < 0 || column >= room.gridWidth || row < 0 || row >= room.gridHeight) return -1; + return room.gridWidth * row + column; +} + +// The grid entity on a cell, or none past the grid. +static GridEntity* grid_entity_at(Room& room, int gridIndex) +{ + return gridIndex >= 0 && gridIndex < ROOM_GRID_CELLS ? room.gridEntities[gridIndex] : nullptr; +} + +// 006b5fd0 The grid collision a player meets at a position: a poop only within its reach, the Lost's way through a +// mirror door, and walls for anyone but a main player. +uint32_t Entity_Player::get_grid_collision_at(Vector position) +{ + Room& room = *g_game->room; + int gridIndex = grid_index_at(room, position); + uint32_t collision = room.GetGridCollision(gridIndex); + GridEntity* grid = grid_entity_at(room, gridIndex); + if (collision == COLLISION_SOLID && grid && grid->type == GRID_POOP) + { + bool isGiga = grid->variant >= POOP_GIGA_FIRST && grid->variant <= POOP_GIGA_LAST; + Vector center = room.GetGridPosition(grid->gridIndex); + if (isGiga) + { + center.x += POOP_GIGA_CENTER_X[grid->variant - POOP_GIGA_FIRST]; + center.y += POOP_GIGA_CENTER_Y[grid->variant - POOP_GIGA_FIRST]; + } + float dx = position.x - center.x; + float dy = position.y - center.y; + float reach = isGiga ? POOP_GIGA_REACH : POOP_REACH; + if (dy * dy + dx * dx > reach * reach) collision = COLLISION_NONE; + } + + if (collision == COLLISION_WALL) + { + if (type != ENTITY_PLAYER || !grid || grid->type != GRID_DOOR) return COLLISION_WALL; + GridEntity_Door& door = static_cast(*grid); + if (!(door.doorFlags & DOOR_FLAG_MIRROR) || door.state == DOOR_STATE_OPEN) return COLLISION_WALL; + bool isSpirit = GetHealthType() == HEALTH_NO_HEALTH || HasInstantDeathCurse(); + if (!isSpirit && g_game->currentDimensionIdx != MIRROR_DIMENSION) return COLLISION_WALL; + collision = GRID_COLLISION_WALL_EXCEPT_PLAYER; + } + else if (collision != GRID_COLLISION_WALL_EXCEPT_PLAYER) return collision; + + // The original reads a non-player's fields here. A non-player meets the wall. + if (type != ENTITY_PLAYER || variant != 0 || isCoopGhost || parent || IsHologram()) return COLLISION_WALL; + return collision; +} + +// 007c3380 Whether the player crushes rocks it walks into. +bool Entity_Player::CanCrushRocks() +{ + return temporaryEffects.HasCollectibleEffect(COLLECTIBLE_THE_NAIL) || HasCollectible(COLLECTIBLE_LEO) || + temporaryEffects.HasCollectibleEffect(COLLECTIBLE_LEO) || GetZodiacEffect() == COLLECTIBLE_LEO || + HasCollectible(COLLECTIBLE_THUNDER_THIGHS) || HasPlayerForm(PLAYERFORM_STOMPY) || + temporaryEffects.HasCollectibleEffect(COLLECTIBLE_MEGA_MUSH); +} + +// Mega Mush's stomp on a block, pillar or lock: the cell becomes a plain rock (the original's inlined +// Room::SpawnGridEntity), which the stomp breaks. +static void mega_mush_crush(Room& room, Entity& player, GridEntity& grid, int gridIndex) +{ + uint32_t seed = grid.spawnSeed; + GridEntity* old = room.gridEntities[gridIndex]; + if (old && old->type != GRID_DECORATION) + { + room.gridPaths[gridIndex] = GRID_PATH_FREED; + room.gridEntities[gridIndex] = nullptr; + delete old; + } + if (room.gridPaths[gridIndex] <= GRID_PATH_FREED) + { + GridEntity* rock = CreateGridEntity(GRID_ROCK, gridIndex); + delete room.gridEntities[gridIndex]; + room.gridEntities[gridIndex] = rock; + rock->variant = 0; + rock->varData = 0; + rock->Init(seed); + } + if (room.gridEntities[gridIndex]) room.gridEntities[gridIndex]->Destroy(false, EntityRef(&player)); +} + +// A crushed rock bridges the pit beyond it, on the axis the player came along. +static void crush_bridge(Room& room, Entity& player, GridEntity& rock) +{ + Vector center = room.GetGridPosition(rock.gridIndex); + float dx = center.x - player.pos.x; + float dy = center.y - player.pos.y; + float directionX = 0; + float directionY = 0; + if (std::abs(dx) > std::abs(dy)) directionX = dx < 0 ? -1 : 1; + else directionY = dy < 0 ? -1 : 1; + + int beyond = grid_index_at( + room, vector_make(center.x + directionX * GRID_CELL_SIZE, center.y + directionY * GRID_CELL_SIZE)); + if (beyond < 0) return; + GridEntity* pit = grid_entity_at(room, beyond); + if (pit && pit->type == GRID_PIT) reconstruction_missing("Room::TryMakeBridge 0081e6e0"); +} + +// What a player does to the grid entity at one of its collision points: Mega Mush stomps blocks and kicks doors and +// webs, rock crushers break what they touch, Notched Axe opens secret doors. Returns whether the point is spent on it. +static bool player_grid_act(Room& room, Entity_Player& player, GridEntity* grid, int gridIndex, uint32_t collision) +{ + if (player.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_MEGA_MUSH) && grid) + { + bool isStompable = grid->type == GRID_ROCKB || grid->type == GRID_PILLAR || grid->type == GRID_LOCK; + if (isStompable && collision != COLLISION_NONE) + { + mega_mush_crush(room, player, *grid, gridIndex); + return true; + } + if (grid->type == GRID_DOOR && collision == COLLISION_WALL) + { + static_cast(grid)->TryBlowOpen(true, &player); + return true; + } + if (grid->type == GRID_SPIDERWEB) grid->Destroy(false, EntityRef(&player)); + } + if (!grid) return false; + + bool isSolid = collision == COLLISION_SOLID || collision == COLLISION_OBJECT; + bool isCrusher = player.CanCrushRocks() || + (grid->type == GRID_POOP && player.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_MARS)); + bool isBreakable = grid->collisionClass == COLLISION_SOLID || grid->collisionClass == COLLISION_OBJECT; + if (isSolid && isCrusher && isBreakable && grid->Destroy(false, EntityRef(&player))) + { + crush_bridge(room, player, *grid); + return true; + } + + if (collision != COLLISION_WALL || grid->type != GRID_DOOR || player.itemState != COLLECTIBLE_NOTCHED_AXE) + return false; + GridEntity_Door& door = static_cast(*grid); + bool isSecret = door.currentRoomType == ROOM_TYPE_SECRET || door.targetRoomType == ROOM_TYPE_SECRET || + door.currentRoomType == ROOM_TYPE_SUPERSECRET || door.targetRoomType == ROOM_TYPE_SUPERSECRET; + if (!isSecret) return false; + if (GridEntity* target = grid_entity_at(room, gridIndex)) target->Destroy(false, EntityRef(&player)); + return true; +} + +// Keeps a player inside the room: out of the walls, and in the Beast's dungeon above its floor's line. +static void player_room_clamp(Entity& player, Room& room, GridCollisionMode mode) +{ + bool isSimulated = mode == GRID_COLLISION_SIMULATE; + Vector clamped = room.GetClampedPositionImpl(player.pos, 0, 0, 0, 0); + if (room.IsBeastDungeon()) + { + float margin = player.size; + Vector lifted = room.GetClampedPositionImpl(vector_make(player.pos.x, player.pos.y - BEAST_DUNGEON_OFFSET_Y), + margin, margin, margin, margin); + lifted.y += BEAST_DUNGEON_OFFSET_Y; + if (!isSimulated) player.isCollidesWithGrid = player.pos.x != lifted.x || player.pos.y != lifted.y; + player.pos = lifted; + return; + } + + Entity_Player& self = static_cast(player); + if (room.GetGridIndex(player.pos) >= 0 && self.get_grid_collision_at(player.pos) != COLLISION_WALL) return; + if (!isSimulated) player.isCollidesWithGrid = player.pos.x != clamped.x || player.pos.y != clamped.y; + if (room.roomType != ROOM_DUNGEON) player.pos = clamped; +} + +// 006ab440 A player's collision with the room's grid: clamped into the room, acting on what its collision points touch, +// then pushed out along the walls' normal and slowed against them. Simulating (Interpolate's prediction) only moves the +// position. +void Entity::PlayerCollideWithGrid(GridCollisionMode mode) +{ + Entity_Player* player = dynamic_cast(this); + // The original carries on with a non-player and crashes on its effects. It stops here instead. + if (!player) + { + KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"Called PlayerCollideWithGrid with " + "Entity type != Entity_Player\n"); + return; + } + bool isSimulated = mode == GRID_COLLISION_SIMULATE; + if (!isSimulated) isCollidesWithGrid = false; + if (entityGridCollisionClass == GRIDCOLL_NONE || collisionPoints.empty() || minecart) return; + + Room& room = *g_game->room; + player_room_clamp(*this, room, mode); + + Vector normal{}; + for (const Vector& point : collisionPoints) + { + Vector position = vector_make(pos.x + point.x, pos.y + point.y); + int gridIndex = grid_index_at(room, position); + if (gridIndex < 0) continue; + GridEntity* grid = grid_entity_at(room, gridIndex); + uint32_t collision = player->get_grid_collision_at(position); + if (!isSimulated && player_grid_act(room, *player, grid, gridIndex, collision)) continue; + + bool isWall = collision == COLLISION_WALL || (collision == COLLISION_SOLID && grid && grid->type == GRID_DOOR); + bool isBlocked = collision != COLLISION_NONE && collision != GRID_COLLISION_WALL_EXCEPT_PLAYER; + if ((entityGridCollisionClass == GRIDCOLL_WALLS && isWall) || + (entityGridCollisionClass == GRIDCOLL_GROUND && isBlocked)) + { + normal.x += point.x; + normal.y += point.y; + } + } + + float lengthSquared = normal.x * normal.x + normal.y * normal.y; + if (lengthSquared < NORMAL_EPSILON) + { + if (!isSimulated) gridCollisionNormal = {}; + return; + } + float length = std::sqrt(lengthSquared); + if (length > 0) + { + normal.x *= 1 / length; + normal.y *= 1 / length; + } + if (!isSimulated) gridCollisionNormal = normal; + + float approach = -normal.x * velocity.x - normal.y * velocity.y; + if (approach < 0 && !isSimulated) + { + isCollidesWithGrid = true; + gridCollisionVelocity = velocity; + float push = approach * WALL_BOUNCE - WALL_PUSH; + velocity.x += push * gridCollisionNormal.x; + velocity.y += push * gridCollisionNormal.y; + } + + float depth = std::sqrt(normal.y * sizeMulti.y * (normal.y * sizeMulti.y) + + normal.x * sizeMulti.x * (normal.x * sizeMulti.x)) * + size; + float speed = std::sqrt(velocity.x * velocity.x + velocity.y * velocity.y); + float freeDepth = depth - std::max(speed, PUSH_OUT_MIN_SPEED); + float blockedDepth = depth; + bool isGround = entityGridCollisionClass == GRIDCOLL_GROUND; + for (int step = 0; step < (isGround ? PUSH_OUT_STEPS_GROUND : PUSH_OUT_STEPS); step++) + { + float middle = (blockedDepth - freeDepth) * 0.5f + freeDepth; + uint32_t collision = + player->get_grid_collision_at(vector_make(normal.x * middle + pos.x, normal.y * middle + pos.y)); + bool isFree = isGround ? collision == COLLISION_NONE || collision == GRID_COLLISION_WALL_EXCEPT_PLAYER + : collision != COLLISION_WALL; + (isFree ? freeDepth : blockedDepth) = middle; + } + pos.x += normal.x * (freeDepth - depth); + pos.y += normal.y * (freeDepth - depth); +} diff --git a/src/entity_effect.cpp b/src/entity_effect.cpp index 395c144..a6a86a0 100644 --- a/src/entity_effect.cpp +++ b/src/entity_effect.cpp @@ -1,12 +1,77 @@ #include "entity_effect.h" +#include "entity_tear.h" +#include "game.h" #include "log.h" +#include "lua_engine.h" +#include "manager.h" +#include "room.h" +#include "sfx_manager.h" #include #include +#include // The creep variants the players leave (holy water trail, black, red, white, holy water, green, Lemon Mishap, Lemon // Party, 204, Black Powder, milk, Black Powder's pentagram). constexpr std::array PLAYER_CREEPS = {54, 45, 46, 44, 37, 53, 32, 78, 204, 92, 90, 93}; +constexpr int EFFECT_BLOOD_SPLAT = 7; +constexpr int EFFECT_BULLET_POOF = 11; +constexpr int EFFECT_TEAR_POOF_A = 12; +constexpr int EFFECT_TEAR_POOF_B = 13; +constexpr int EFFECT_RIPPLE_POOF = 14; +constexpr int EFFECT_TEAR_POOF_SMALL = 79; +constexpr int EFFECT_TEAR_POOF_VERYSMALL = 80; +constexpr int EFFECT_IMPACT = 97; +constexpr int EFFECT_BOOMERANG = 60; +constexpr int EFFECT_PORTAL_TELEPORT = 161; +constexpr int EFFECT_TIMER = 119; +constexpr int EFFECT_ENEMY_SOUL = 179; +constexpr int EFFECT_ANIMA_CHAIN = 193; +constexpr int EFFECT_REDEMPTION = 185; + +// The variants whose Init, Update and Render are reconstructed: the tear poofs and the blood stains. +constexpr std::array EFFECT_RECONSTRUCTED_VARIANTS = { + EFFECT_BLOOD_SPLAT, EFFECT_BULLET_POOF, EFFECT_TEAR_POOF_A, EFFECT_TEAR_POOF_B, + EFFECT_RIPPLE_POOF, EFFECT_TEAR_POOF_SMALL, EFFECT_TEAR_POOF_VERYSMALL, EFFECT_IMPACT}; +// The poofs that turn with their rotation. +constexpr std::array EFFECT_TURNED_POOFS = {EFFECT_TEAR_POOF_A, EFFECT_TEAR_POOF_B, EFFECT_TEAR_POOF_SMALL, + EFFECT_TEAR_POOF_VERYSMALL, EFFECT_IMPACT}; + +// The blood stain animations by the scale it was spawned at: the first whose limit is above it, the last past all. +constexpr std::array STAIN_SCALE_LIMITS = {0.4f, 0.6f, 0.8f, 1.2f, 2.0f}; +constexpr std::array STAIN_ANIMATIONS = {"Size1BloodStains", "Size2BloodStains", "Size3BloodStains", + "Size4BloodStains", "Size5BloodStains", "Size6BloodStains"}; +constexpr float STAIN_ALPHA_MIN = 0.5f; +constexpr float STAIN_ALPHA_STEP = 0.1f; +constexpr int STAIN_ALPHA_STEPS = 6; + +// The ripple poof's animations for small spawn scales, which it draws larger. +constexpr float RIPPLE_TINY_SCALE = 0.5f; +constexpr float RIPPLE_SMALL_SCALE = 0.75f; +constexpr float RIPPLE_TINY_GROWTH = 2; +constexpr float RIPPLE_SMALL_GROWTH = 1.33333f; + +constexpr float PAUSE_VELOCITY_DECAY = 0.6f; +constexpr float RIGHT_ANGLE = 90; +constexpr int SOUND_BOOMERANG_LOOP = 837; +constexpr int SOUND_PORTAL_ENTITY_LOOP = 846; +constexpr int SOUND_CHAIN_LOOP = 503; +constexpr int LUA_CALLBACK_POST_EFFECT_INIT = 54; +constexpr int LUA_CALLBACK_POST_EFFECT_UPDATE = 55; +constexpr int LUA_CALLBACK_POST_EFFECT_RENDER = 56; + +// Stops where a mod has a function for one of the effect's Lua callbacks, which LuaEngine does not run yet. +static void lua_callback_check(int callback, const char* name) +{ + if (static_cast(g_luaEngine)->enabledCallbacks[callback]) reconstruction_missing(name); +} + +template +static bool is_listed(const std::array& list, int value) +{ + return std::find(list.begin(), list.end(), value) != list.end(); +} + // 0060c400 Only a boss spawn pentagram holds the doors shut. bool Entity_Effect::CanShutDoors() { @@ -45,62 +110,226 @@ bool Entity_Effect::IsPlayerCreep(int effectVariant) return std::find(PLAYER_CREEPS.begin(), PLAYER_CREEPS.end(), effectVariant) != PLAYER_CREEPS.end(); } -// The rest of Entity_Effect is not reconstructed yet. - -// 005cdb20 -void Entity_Effect::Init(int, int, int, uint32_t) +// 005cdb20 Starts the effect from its config's sprite with no timeout, rotation or extra data. A crawlspace removes +// its blood stains at once. The tear poofs face a random quarter turn and the ripple a random side. +// Only the tear poofs and the blood stains are reconstructed yet. +void Entity_Effect::Init(int entityType, int entityVariant, int entitySubType, uint32_t seed) { - reconstruction_missing("Entity_Effect::Init 005cdb20"); + extraData.reset(); + Entity::Init(entityType, entityVariant, entitySubType, seed); + hitList.clear(); + maxHitPoints = 0; + if (config) + { + sprite.Load(config->anm2Path, GRAPHICS_DEFER); + sprite.Play(sprite.GetDefaultAnimationName()); + } + + state = 0; + timeout = -1; + lifespan = 1; + parentOffset = {}; + rotation = 0; + isFollowing = false; + scale = 1; + minRadius = 0; + maxRadius = 0; + damageSource = 0; + varData = {}; + if (!is_listed(EFFECT_RECONSTRUCTED_VARIANTS, variant)) + reconstruction_missing("Entity_Effect::Init 005cdb20: this effect variant"); + if (g_game->room->roomType == ROOM_DUNGEON && variant == EFFECT_BLOOD_SPLAT) + { + isVisible = false; + return Remove(); + } + + if (variant == EFFECT_BLOOD_SPLAT) sortingLayer = SORTING_BACKGROUND; + if (variant == EFFECT_RIPPLE_POOF) + { + sortingLayer = SORTING_BACKGROUND; + sprite.isFlipX = Random() & 1; + } + entityGridCollisionClass = GRIDCOLL_NONE; + entityCollisionClass = ENTCOLL_NONE; + if (is_listed(EFFECT_TURNED_POOFS, variant)) + { + rotation = (float)(Random() & 3) * RIGHT_ANGLE; + isUnknown176 = true; + } + if (variant == EFFECT_IMPACT) sprite.isFlipX = !(Random() & 1); + + sprite.LoadGraphics(); + if (g_game->deathmatchManager.is_active()) + reconstruction_missing("Entity_Effect::Init 005cdb20: the versus mode's entity registration"); + lua_callback_check(LUA_CALLBACK_POST_EFFECT_INIT, "LuaEngine::PostEffectInit 00861330"); } -// 005d4380 +// 005d4380 Runs the effect for a frame at the room's time scale, held in place while paused and kept on its parent +// while following it, then counts its timeout down to its death. void Entity_Effect::Update() { - reconstruction_missing("Entity_Effect::Update 005d4380"); + speedMultiplier = g_game->room->GetTimeScale(this); + if (pauseTimer != 0) + { + uint64_t savedFlags = flags; + bool wasDead = isDead; + + if (pausePosition.x == 0 && pausePosition.y == 0) pausePosition = pos; + if (pauseTimer > 0) pauseTimer--; + pos = pausePosition; + velocity = vector_make(velocity.x * PAUSE_VELOCITY_DECAY, velocity.y * PAUSE_VELOCITY_DECAY); + AddEntityFlags(FLAG_NO_SPRITE_UPDATE); + Entity::Update(); + flags = savedFlags; + if (wasDead == isDead) return; + } + + Entity::Update(); + if (isFollowing && parent) + { + pos = vector_make(parent->pos.x + parentOffset.x, parent->pos.y + parentOffset.y); + velocity = parent->velocity; + posOffset = parent->posOffset; + } + else if (isFollowing) + { + velocity = {}; + isFollowing = false; + } + + if (variant == EFFECT_BLOOD_SPLAT) stain_update(); + else poof_update(); + if (timeout > 0 && --timeout < 1) isDead = true; + pausePosition = pos; + lua_callback_check(LUA_CALLBACK_POST_EFFECT_UPDATE, "LuaEngine::PostEffectUpdate 00861410"); } -// 005d2520 +// Turns a poof by its rotation, mirrored unless flipped, and removes it once its animation ends. A ripple first +// draws its small sizes larger with their own animations. +void Entity_Effect::poof_update() +{ + if (variant == EFFECT_RIPPLE_POOF && state == 0) + { + float spawnScale = sprite.scale.x; + if (spawnScale <= RIPPLE_TINY_SCALE) + { + sprite.scale = vector_make(sprite.scale.x * RIPPLE_TINY_GROWTH, sprite.scale.y * RIPPLE_TINY_GROWTH); + sprite.Play("Poof_Tiny"); + } + else if (spawnScale <= RIPPLE_SMALL_SCALE) + { + sprite.scale = vector_make(sprite.scale.x * RIPPLE_SMALL_GROWTH, sprite.scale.y * RIPPLE_SMALL_GROWTH); + sprite.Play("Poof_Small"); + } + state = 1; + } + sprite.rotation = sprite.isFlipX ? rotation : -rotation; + if (sprite.IsFinished()) Remove(); +} + +// Settles a blood stain on its first update: the stain animation for the scale it was spawned at on a random frame, +// its own scale, random flips, a random strength for an opaque color, and the floor to be drawn into. +// A glowing stain, whose color is brighter than white, fades with a light instead, which is not reconstructed yet. +void Entity_Effect::stain_update() +{ + if (state != 0) reconstruction_missing("Entity_Effect::Update 005d4380: a glowing blood stain's fade"); + float spawnScale = sprite.scale.x; + sprite.scale = vector_make(scale, scale); + + auto limit = std::find_if(STAIN_SCALE_LIMITS.begin(), STAIN_SCALE_LIMITS.end(), + [spawnScale](float scaleLimit) { return spawnScale < scaleLimit; }); + const char* animation = STAIN_ANIMATIONS[limit - STAIN_SCALE_LIMITS.begin()]; + if (const AnimationData* data = sprite.GetAnimationData(animation)) + sprite.SetFrame(animation, (int)(data->length == 0 ? 0 : Random() % (uint32_t)data->length)); + sprite.isFlipX = Random() % 2 == 0; + sprite.isFlipY = Random() % 2 == 0; + + ColorMod stainColor = sprite.color; + bool isGlowing = color._tint[3] > 1; + if (stainColor._tint[3] >= 1) + stainColor._tint[3] = (float)(Random() % STAIN_ALPHA_STEPS) * STAIN_ALPHA_STEP + STAIN_ALPHA_MIN; + sprite.color = stainColor; + if (isGlowing) reconstruction_missing("Entity_Effect::Update 005d4380: a glowing blood stain"); + AddEntityFlags(FLAG_RENDER_FLOOR); +} + +// 005d2520 Moves the effect half a step between updates, keeping a following effect on its parent. void Entity_Effect::Interpolate() { - reconstruction_missing("Entity_Effect::Interpolate 005d2520"); + if (pauseTimer != 0) return; + + Entity::Interpolate(); + if (!isFollowing || !parent) return; + pos = vector_make(parent->pos.x + parentOffset.x, parent->pos.y + parentOffset.y); + posOffset = parent->posOffset; } -// 00607620 -void Entity_Effect::Render(const Vector&) +// 00607620 Draws the effect's sprite at its place on screen. +void Entity_Effect::Render(const Vector& offset) { - reconstruction_missing("Entity_Effect::Render 00607620"); + if (!isVisible) return; + + Vector screen = render_position_get(vector_make(pos.x + posOffset.x, pos.y + posOffset.y), RENDER_SNAPPED); + renderPosition = vector_make(screen.x + offset.x, screen.y + offset.y); + sprite.Render(SpriteDraw{renderPosition, {}, {}}); + lua_callback_check(LUA_CALLBACK_POST_EFFECT_RENDER, "LuaEngine::PostEffectRender 008614f0"); } -// 005d2420 +// 005d2420 Stops the boomerang and portal loops unless another such effect still plays them, then removes it. void Entity_Effect::Remove() { - reconstruction_missing("Entity_Effect::Remove 005d2420"); + bool isBoomerangShared = false; + bool isPortalShared = false; + + for (Entity* entity : g_game->room->entityList.updateEL) + { + if (entity->type != ENTITY_EFFECT || entity == this) continue; + if (entity->variant == EFFECT_BOOMERANG) isBoomerangShared = true; + else if (entity->variant == EFFECT_PORTAL_TELEPORT) isPortalShared = true; + } + if (!isBoomerangShared) g_manager->sfxManager.Stop(SOUND_BOOMERANG_LOOP); + if (!isPortalShared) g_manager->sfxManager.Stop(SOUND_PORTAL_ENTITY_LOOP); + Entity::Remove(); } -// 0060c370 +// 0060c370 Glowing Hourglass removes a timer, and sets Redemption back to idle. void Entity_Effect::TriggerGlowingHourglass() { - reconstruction_missing("Entity_Effect::guard_check_icall 0060c370"); + if (variant == EFFECT_REDEMPTION) + reconstruction_missing("Entity_Effect::TriggerGlowingHourglass 0060c370: Redemption's idle restart"); + if (variant == EFFECT_TIMER) Remove(); } -// 0060abb0 +// 0060abb0 Gives an enemy soul to the player it flew to and stops a hidden Anima chain's sound, then lets go of its +// links and extra data. void Entity_Effect::ClearReferences() { - reconstruction_missing("Entity_Effect::ClearReferences 0060abb0"); + if (variant == EFFECT_ENEMY_SOUL && target && target->type == ENTITY_PLAYER) + reconstruction_missing("Entity_Effect::ClearReferences 0060abb0: the Urn of Souls' soul"); + if (variant == EFFECT_ANIMA_CHAIN && subtype == 0 && !isVisible) g_manager->sfxManager.Stop(SOUND_CHAIN_LOOP); + Entity::ClearReferences(); + extraData.reset(); } +// 004564b0 Follows an entity, keeping the offset it has from it now. +// The original reads a null entity's position and crashes. This only lets go of the parent. +void Entity_Effect::FollowParent(Entity* newParent) +{ + parent = newParent; + if (!newParent) return; + isFollowing = true; + parentOffset = vector_make(pos.x - newParent->pos.x, pos.y - newParent->pos.y); +} + +// The rest of Entity_Effect is not reconstructed yet. + // 00435290 void Entity_Effect::render_player_target(const Vector&, int) { reconstruction_missing("Entity_Effect::render_player_target 00435290"); } -// 004564b0 -void Entity_Effect::FollowParent(Entity*) -{ - reconstruction_missing("Entity_Effect::FollowParent 004564b0"); -} - // 005d2a70 void Entity_Effect::update_mr_me() { diff --git a/src/entity_effect.h b/src/entity_effect.h index 8f19274..6f091c2 100644 --- a/src/entity_effect.h +++ b/src/entity_effect.h @@ -12,6 +12,7 @@ constexpr int EFFECT_SPAWN_PENTAGRAM = 203; // Field accessors (00435e60, 00435eb0, 004d7770, 005784c0, 0060ce20) are the public fields. // An effect (Lua's EntityEffect): a visual or a hazard such as creep, a poof or a light beam, with its timeout, its // fall, the per-variant data it keeps and the extra data some variants share. +// Only the tear poofs and the blood stains are reconstructed yet: Init stops at any other variant. struct Entity_Effect : Entity { // The base of the extra data some variants keep (MrMeData, PickupGhostData, SpriteTrailData). @@ -63,4 +64,8 @@ struct Entity_Effect : Entity void update_variant178_shooter(bool isPositionOnly); static Entity_Effect* CreateLootPreview(void* lootlist, const Vector& pos, Entity* owner, Entity_Effect* effect); void setup_loot_preview(void* lootQueue); + +private: + void poof_update(); + void stain_update(); }; diff --git a/src/entity_factory.cpp b/src/entity_factory.cpp new file mode 100644 index 0000000..14bf343 --- /dev/null +++ b/src/entity_factory.cpp @@ -0,0 +1,1223 @@ +#include "entity_factory.h" +#include "entity_bomb.h" +#include "entity_effect.h" +#include "entity_familiar.h" +#include "entity_knife.h" +#include "entity_laser.h" +#include "entity_npc.h" +#include "entity_pickup.h" +#include "entity_player.h" +#include "entity_projectile.h" +#include "entity_slot.h" +#include "entity_tear.h" +#include "entity_text.h" +#include "game.h" +#include "grid_entity.h" +#include "lua_engine.h" +#include "manager.h" +#include "platform.h" +#include "room.h" +#include +#include + +constexpr uint64_t NS_PER_MS = 1000000; + +// The Lua callbacks a spawn runs (ModCallbacks ids), which wait for their bindings. +constexpr int MC_PRE_ENTITY_SPAWN = 24; +constexpr int MC_PRE_ROOM_ENTITY_SPAWN = 71; + +// An entity made by a Delirium form (by the original's use: Delirium's look and lowered thresholds), which its own +// spawns inherit. +constexpr uint64_t FLAG_DELIRIUM_FORM = 1ull << 60; +constexpr int SPAWN_STATUS_FRAMES = 90; + +// The entity types, variants and boss ids spawning and layouts single out. +constexpr int ENTITY_GAPER = 10; +constexpr int ENTITY_GUSHER = 11; +constexpr int ENTITY_HORF = 12; +constexpr int ENTITY_POOTER = 14; +constexpr int ENTITY_CLOTTY = 15; +constexpr int ENTITY_MULLIGAN = 16; +constexpr int ENTITY_HIVE = 22; +constexpr int ENTITY_CHARGER = 23; +constexpr int ENTITY_GLOBIN = 24; +constexpr int ENTITY_BOOMFLY = 25; +constexpr int ENTITY_MAW = 26; +constexpr int ENTITY_HOST = 27; +constexpr int ENTITY_HOPPER = 29; +constexpr int ENTITY_BOIL = 30; +constexpr int ENTITY_BABY = 38; +constexpr int ENTITY_VIS = 39; +constexpr int ENTITY_GUTS = 40; +constexpr int ENTITY_KNIGHT = 41; +constexpr int ENTITY_STONEHEAD = 42; +constexpr int ENTITY_FLAMINGHOPPER = 54; +constexpr int ENTITY_LEECH = 55; +constexpr int ENTITY_MEMBRAIN = 57; +constexpr int ENTITY_PARA_BITE = 58; +constexpr int ENTITY_EYE = 60; +constexpr int ENTITY_SUCKER = 61; +constexpr int ENTITY_SPIDER = 85; +constexpr int ENTITY_WALKINGBOIL = 88; +constexpr int ENTITY_BABY_LONG_LEGS = 206; +constexpr int ENTITY_CRAZY_LONG_LEGS = 207; +constexpr int ENTITY_FATTY = 208; +constexpr int ENTITY_DEATHS_HEAD = 212; +constexpr int ENTITY_DIP = 217; +constexpr int ENTITY_SQUIRT = 220; +constexpr int ENTITY_SKINNY = 226; +constexpr int ENTITY_NERVE_ENDING = 231; +constexpr int ENTITY_HUSH_GAPER = 297; +constexpr int ENTITY_GREED_GAPER = 299; +constexpr int ENTITY_MUSHROOM = 300; +constexpr int ENTITY_STONEY = 302; +constexpr int ENTITY_SUB_HORF = 812; +constexpr int ENTITY_STRIDER = 814; +constexpr int ENTITY_GYRO = 824; +constexpr int ENTITY_ROTGUT = 911; +constexpr int ENTITY_DOGMA = 950; +constexpr int EFFECT_CRAWLSPACE_LADDER = 192; +constexpr int BOSS_SATAN = 24; + +constexpr int PICKUP_HEART = 10; +constexpr int CARD_SPECIAL_CHANCE = 25; +constexpr int CARD_RUNE_CHANCE = 10; +constexpr int PICKUP_COIN = 20; +constexpr int PICKUP_KEY = 30; +constexpr int PICKUP_BOMB = 40; +constexpr int PICKUP_CHEST = 50; +constexpr int PICKUP_MIMIC_CHEST = 56; +constexpr int PICKUP_WOODEN_CHEST = 57; +constexpr int PICKUP_HAUNTED_CHEST = 58; +constexpr int PICKUP_LOCKED_CHEST = 60; +constexpr int PICKUP_GRAB_BAG = 69; +constexpr int PICKUP_LIL_BATTERY = 90; +constexpr int PICKUP_COLLECTIBLE = 100; +constexpr int PICKUP_SHOP_ITEM = 150; +constexpr int PICKUP_TAROT_CARD = 300; +constexpr int PICKUP_RANDOM_CARD = 301; +constexpr int COLLECTIBLE_DIRTY_MIND = 576; +constexpr int COLLECTIBLE_KNIFE_PIECE_1 = 626; +constexpr int COLLECTIBLE_KNIFE_PIECE_2 = 627; +constexpr int COLLECTIBLE_INNER_CHILD = 688; +constexpr int COLLECTIBLE_FLIP = 711; +constexpr int TRINKET_MECONIUM = 91; + +constexpr int SLOT_MACHINE = 1; +constexpr int SLOT_BEGGAR = 4; +constexpr int SLOT_DEVIL_BEGGAR = 5; +constexpr int SLOT_KEY_MASTER = 7; +constexpr int SLOT_SHELL_GAME = 6; +constexpr int SLOT_DONATION = 8; +constexpr int SLOT_CLOSET_TAINTED = 14; +constexpr int SLOT_HELL_GAME = 15; +constexpr int SLOT_CRANE_GAME = 16; +constexpr int SLOT_CONFESSIONAL = 17; +constexpr int SLOT_ROTTEN_BEGGAR = 18; +constexpr int SHOPKEEPER_SPECIAL = 3; +constexpr int SHOPKEEPER_SECRET_SPECIAL = 4; +constexpr int EFFECT_VARIANT_TRAPDOOR_MARKER = 39; +// The stairs a stage with no next one is left by, and the trapdoor to the Void. +constexpr int STAIRS_VARIANT_EXIT = 3; +constexpr int TRAPDOOR_VARIANT_VOID = 1; +// A Nerve Ending this close to a door stays plain, and the Boom Fly subtype that rolls its own. +constexpr int NERVE_DOOR_DISTANCE = 4; +constexpr int BOOMFLY_DRAGONFLY_SUBTYPE = 100; + +// The layout entry types that are not entities: grid entities, their markers, rails and the trapdoor. +enum EntryType : int +{ + ENTRY_EFFECT = 999, + ENTRY_ROCK = 1000, + ENTRY_ROCK_BOMB = 1001, + ENTRY_ROCK_ALT = 1002, + ENTRY_ROCK_TINTED = 1003, + ENTRY_ROCK_SUPER_TINTED = 1004, + ENTRY_ROCK_ALT2 = 1008, + ENTRY_ROCK_MARKED = 1009, + ENTRY_ROCK_SPIKED = 1010, + ENTRY_ROCK_GOLD = 1011, + ENTRY_TNT = 1300, + ENTRY_FIREPLACE = 1400, + ENTRY_FIREPLACE_RED = 1410, + ENTRY_POOP_RED = 1490, + ENTRY_POOP_RAINBOW = 1494, + ENTRY_POOP_CORN = 1495, + ENTRY_POOP_GOLDEN = 1496, + ENTRY_POOP_BLACK = 1497, + ENTRY_POOP_HOLY = 1498, + ENTRY_POOP_GIGA = 1499, + ENTRY_POOP = 1500, + ENTRY_POOP_CHARMING = 1501, + ENTRY_BLOCK = 1900, + ENTRY_PILLAR = 1901, + ENTRY_SPIKES = 1930, + ENTRY_SPIKES_ONOFF = 1931, + ENTRY_COBWEB = 1940, + ENTRY_WALL = 1999, + ENTRY_PIT = 3000, + ENTRY_PIT_CRAWLSPACE = 3001, + ENTRY_PIT_ALT = 3002, + ENTRY_PIT_MARKED = 3009, + ENTRY_LOCK = 4000, + ENTRY_PRESSURE_PLATE = 4500, + ENTRY_STATUE_DEVIL = 5000, + ENTRY_STATUE_ANGEL = 5001, + ENTRY_RAIL = 6000, + ENTRY_RAIL_PIT = 6001, + ENTRY_TELEPORTER = 6100, + ENTRY_TRAPDOOR = 9000, + ENTRY_STAIRS = 9100, + ENTRY_GRAVITY = 10000, + ENTRY_TRIGGER_OUTPUT = 969, + ENTRY_QUEST_DOOR = 970 +}; + +// The poop variants a layout's poop can turn into (Lua's PoopVariant). +enum PoopVariant : int +{ + POOP_NORMAL, + POOP_RED, + POOP_CORN, + POOP_GOLDEN, + POOP_RAINBOW, + POOP_BLACK, + POOP_HOLY, + POOP_GIGA, + POOP_CHARMING = 11 +}; + +// The achievements a layout entry waits for. +enum EntryAchievement : int +{ + ACHIEVEMENT_HEART_HALF_SOUL = 33, + ACHIEVEMENT_HEART_GOLDEN = 224, + ACHIEVEMENT_BOMB_GOLDEN = 226, + ACHIEVEMENT_COIN_STICKY = 240, + ACHIEVEMENT_COIN_LUCKY = 242, + ACHIEVEMENT_SHOPKEEPER_SECRET = 243, + ACHIEVEMENT_SHOPKEEPER_SPECIAL = 247, + ACHIEVEMENT_DARK_ROOM_END = 320, + ACHIEVEMENT_SUPER_TINTED_ROCK = 323, + ACHIEVEMENT_HEART_SCARED = 328, + ACHIEVEMENT_KEY_CHARGED = 333, + ACHIEVEMENT_ENEMY_VARIANTS = 348, + ACHIEVEMENT_HEART_BONE = 391, + ACHIEVEMENT_HEART_ROTTEN = 411, + ACHIEVEMENT_TAINTED_CLOSET = 434, + ACHIEVEMENT_WOODEN_CHEST = 601, + ACHIEVEMENT_GRAB_BAG_BLACK = 604, + ACHIEVEMENT_POOP_CHARMING = 605, + ACHIEVEMENT_CRANE_GAME = 607, + ACHIEVEMENT_HELL_GAME = 608, + ACHIEVEMENT_MIMIC_CHEST = 609, + ACHIEVEMENT_HAUNTED_CHEST = 611, + ACHIEVEMENT_ROCK_VARIANTS = 612, + ACHIEVEMENT_COIN_GOLDEN = 613, + ACHIEVEMENT_ROTTEN_BEGGAR = 614, + ACHIEVEMENT_LIL_BATTERY_GOLDEN = 615, + ACHIEVEMENT_CONFESSIONAL = 616 +}; + +// The xorshifts layout spawning draws with, as their shift triples. +constexpr RNG ENTRY_RNG = {0, 5, 9, 7}; +constexpr RNG TRANSFORM_RNG = {0, 1, 21, 20}; +constexpr RNG SLOT_RNG = {0, 11, 17, 13}; +constexpr RNG DIRTY_MIND_RNG = {0, 1, 5, 19}; +constexpr RNG MECONIUM_RNG = {0, 2, 7, 25}; +constexpr RNG ROCK_ELLIPSE_RNG = {0, 3, 3, 26}; + +// Dirty Mind's chance to turn a rock into a dip, by luck. +constexpr float DIRTY_MIND_CHANCE = 0.0625f; +constexpr float DIRTY_MIND_LUCK_CHANCE = 0.005f; +constexpr float DIRTY_MIND_CHANCE_MAX = 0.1f; + +// The ellipse of golden rocks a room may get: its radii over two draws each, wider in the Mines. +constexpr float ELLIPSE_RADIUS_X = 0.5f; +constexpr float ELLIPSE_RADIUS_Y = 0.3f; +constexpr float ELLIPSE_SPREAD_X = 1.25f; +constexpr float ELLIPSE_SPREAD_Y = 0.3f; +constexpr float ELLIPSE_MINES_SPREAD_X = 1.8f; +constexpr float ELLIPSE_MINES_SPREAD_Y = 0.5f; +constexpr int STAGE_ID_MINES = 29; +constexpr int STAGE_ID_ASHPIT = 30; +constexpr float DEGREES_TO_RADIANS = 0.017453292f; +constexpr float FULL_TURN = 360; + +// The odds layouts roll with (one in n). +constexpr int ROCK_ROLLS = 1001; +constexpr int ROCK_BOMB_ROLLS = 10; +constexpr int ROCK_ALT_ROLLS = 16; +constexpr int SUPER_TINTED_ODDS = 20; +constexpr int ELLIPSE_ODDS = 10; +constexpr int CORN_ODDS = 40; +constexpr int FIREPLACE_RED_ODDS = 40; +constexpr int CHARMING_ODDS = 100; +constexpr int ODDS_PERCENT = 100; +constexpr int TENTH = 10; +constexpr int MECONIUM_CHANCE = 33; +constexpr int MECONIUM_CHANCE_DOUBLE = 66; +constexpr int MECONIUM_CHANCE_TRIPLE = 100; +constexpr int SHOPKEEPER_ODDS_MASK = 3; +constexpr int PIT_MARKED_VARIANT = 128; +constexpr int ROCK_MARKED_VARIANT = 10000; +constexpr int TELEPORTER_STATE_ACTIVE = 2; +constexpr int MIRROR_DIMENSION = 1; +constexpr int TREASURE_SUBTYPE_MIRROR = 34; +constexpr int BOSS_SUBTYPE_MOTHER = 88; +constexpr int TREASURE_SUBTYPE_CHOICE = 1; +constexpr int TREASURE_SUBTYPE_CHOICE_ALT = 3; +constexpr uint32_t ROOM_CONFIG_FLAG_NO_TRANSFORMS = 1 << 0; +constexpr uint32_t ROOM_CONFIG_FLAG_NO_ALT_ROCKS = 1 << 1; +constexpr uint32_t ROOM_CONFIG_FLAG_AFTERBIRTH_HAZARDS = 1 << 3; + +// The stages layouts tell apart (after Curse of the Labyrinth's and Greed's shifts). +constexpr int STAGE_GREED_LAST = 5; +constexpr int STAGE_GREED_SHOP = 10; +constexpr int STAGE_BACKWARDS_LAST = 6; +constexpr int STAGE_WOMB_2 = 8; +constexpr int STAGE_BLUE_WOMB = 9; +constexpr int STAGE_SHEOL = 10; +constexpr int STAGE_DARK_ROOM = 11; +constexpr int STAGE_VOID_ENTRY = 12; +constexpr int STAGE_LABYRINTH_SHIFT = 1; +constexpr uint32_t CURSE_LABYRINTH = 1 << 1; +constexpr int SPECIAL_DAILY_GOLDEN_FATTY = 7; +constexpr int CHALLENGE_GOLDEN_FATTY = 32; + +template static std::unique_ptr entity_make() +{ + return std::make_unique(); +} + +// The pools' classes, sizes and names, in PoolId order. +static constexpr std::array POOL_DESCS = {{ + {entity_make, "Entity_Effect", 0x400}, + {entity_make, "Entity_Familiar", 0x40}, + {entity_make, "Entity_Bomb", 0x40}, + {entity_make, "Entity_Projectile", 0x200}, + {entity_make, "Entity_Tear", 0x200}, + {entity_make, "Entity_Laser", 0x80}, + {entity_make, "Entity_Pickup", 0x200}, + {entity_make, "Entity_Slot", 0x80}, + {entity_make, "Entity_NPC", 0x200}, + {entity_make, "Entity_Text", 0x80}, + {entity_make, "Entity_Knife", 0x40}, +}}; + +// 006f2a10 Sizes every pool. Their slots are made on first use. +EntityFactory::EntityFactory() +{ + for (size_t i = 0; i < pools.size(); i++) + { + pools[i].desc = &POOL_DESCS[i]; + pools[i].slots.resize(POOL_DESCS[i].size); + } +} + +// 006f0090 A free entity of the type's class: the next one after the last handed out. A full pool hands out an entity +// it may overwrite, removing it first, unless mode keeps it. +Entity* EntityFactory::Create(int type, PoolMode mode) +{ + PoolId pool = ENTITY_POOL_NPC; + switch (type) + { + case ENTITY_PLAYER: log_printf(LOG_ASSERT, "EntityFactory cannot spawn Entity_Player.\n"); return nullptr; + case ENTITY_TEAR: pool = ENTITY_POOL_TEAR; break; + case ENTITY_FAMILIAR: pool = ENTITY_POOL_FAMILIAR; break; + case ENTITY_BOMB: pool = ENTITY_POOL_BOMB; break; + case ENTITY_PICKUP: pool = ENTITY_POOL_PICKUP; break; + case ENTITY_SLOT: pool = ENTITY_POOL_SLOT; break; + case ENTITY_LASER: pool = ENTITY_POOL_LASER; break; + case ENTITY_KNIFE: pool = ENTITY_POOL_KNIFE; break; + case ENTITY_PROJECTILE: pool = ENTITY_POOL_PROJECTILE; break; + case ENTITY_EFFECT: pool = ENTITY_POOL_EFFECT; break; + case ENTITY_TEXT: pool = ENTITY_POOL_TEXT; break; + } + return pools[pool].Create(mode); +} + +// The slot at the cursor, made when first reached. +Entity& EntityPool::slot_get() +{ + std::unique_ptr& slot = slots[cursor]; + if (!slot) slot = desc->make(); + return *slot; +} + +// Moves the cursor to the next slot. +Entity& EntityPool::slot_next() +{ + cursor = (cursor + 1) % slots.size(); + return slot_get(); +} + +// The next free entity, or with every one in use (after two more tries than it has) one to overwrite: the first that +// allows it, else whichever the search stopped on. +Entity* EntityPool::Create(PoolMode mode) +{ + uint32_t size = slots.size(); + for (uint32_t tries = 0; tries < size + 2; tries++) + if (!slot_next().isValid) return &slot_get(); + if (mode == POOL_KEEP) return nullptr; + + bool isOverwritable = slot_get().CanOverwrite(); + for (uint32_t tries = 0; !isOverwritable && tries <= size; tries++) isOverwritable = slot_next().CanOverwrite(); + if (!isOverwritable) log_printf(LOG_WARN, "Overwritten an entity with don't overwrite flag at index %d!\n", cursor); + + Entity& entity = slot_get(); + log_printf(LOG_WARN, + "Entity pool array %s is full, overwriting at index %d! (frame " + "count: %d)\n", + desc->name, cursor, entity.FrameCount()); + entity.isRemovedByFactory = true; + entity.Remove(); + entity.ClearReferences(); + entity.isRemovedByFactory = false; + return &entity; +} + +// The enemy creeps (red, green, yellow, white, black) and the player's creeps a friendly spawner leaves instead. +constexpr int CREEP_ENEMY_FIRST = 22; +constexpr std::array CREEP_FRIENDLY = {46, 53, 204, 44, 45}; + +// The player's creep a friendly entity leaves instead of an enemy's. +static int creep_friendly_variant(int variant) +{ + uint32_t creep = variant - CREEP_ENEMY_FIRST; + return creep < CREEP_FRIENDLY.size() ? CREEP_FRIENDLY[creep] : variant; +} + +// What a spawn takes from the active enemy that made it: its Delirium form or friendliness, and from an enemy its +// marks, shrinking, scale and health multiplier. +static void spawner_inherit(Entity& entity, Entity& spawner, int type, int variant) +{ + if (spawner.HasEntityFlags(FLAG_DELIRIUM_FORM)) + { + entity.AddEntityFlags(FLAG_DELIRIUM_FORM); + if (type != ENTITY_PROJECTILE && type != ENTITY_LASER) entity.AddEntityFlags(FLAG_PERSISTENT); + entity.AddCharmed(EntityRef(spawner.charmSource.entity), -1, false, false); + if (type >= ENTITY_FIRST_ENEMY && type < ENTITY_EFFECT) + ANM2::LoadDeliriumForm(entity.sprite, type, variant, true); + } + else if (spawner.HasEntityFlags(FLAG_FRIENDLY)) entity.AddCharmed(EntityRef(), -1, false, false); + + Entity_NPC* spawnerNpc = dynamic_cast(&spawner); + Entity_NPC* npc = dynamic_cast(&entity); + if (!spawnerNpc || !npc) return; + + if (!npc->HasEntityFlags(FLAG_NO_STATUS_EFFECTS)) + { + if (spawner.HasEntityFlags(FLAG_BRIMSTONE_MARKED)) npc->AddBrimstoneMark(EntityRef(), SPAWN_STATUS_FRAMES); + if (spawner.HasEntityFlags(FLAG_SHRINK)) + { + npc->AddShrink(EntityRef(), SPAWN_STATUS_FRAMES, false); + if (npc->shrinkCountdown > 0) + { + npc->AddEntityFlags(FLAG_SHRINK); + npc->shrinkStatus1 = npc->shrinkStatus2; + } + } + } + + npc->SetScale(npc->scale * spawnerNpc->scaleMulti); + npc->scaleMulti *= spawnerNpc->scaleMulti; + npc->hitPointsMulti *= spawnerNpc->hitPointsMulti; + npc->maxHitPoints *= spawnerNpc->hitPointsMulti; + npc->health *= spawnerNpc->hitPointsMulti; + // A boss also takes the spawner's link at 0xf54 (set_entity_ptr_f54), which Entity_NPC does not hold yet. +} + +// 00428b20 Spawns an entity into the current room, overwriting one when its pool is full. +Entity* Game::Spawn(const EntitySpawn& spawn) +{ + return game_spawn(spawn, POOL_OVERWRITE); +} + +// 006fe410 Game::SpawnEx: takes an entity from its pool, places and inits it, and adds it to the room. A spawn of an +// active enemy inherits from it, an erased enemy vanishes in a poof, and a TMTRAINER item may react. +Entity* game_spawn(const EntitySpawn& spawn, PoolMode mode) +{ + Game& game = *g_game; + if (static_cast(g_luaEngine)->enabledCallbacks[MC_PRE_ENTITY_SPAWN]) + reconstruction_missing("lua_callback_run_pre_entity_spawn 008646e0"); + if (game.deathmatchManager.state >= DEATHMATCH_INTRO) + reconstruction_missing("Game::SpawnEx 006fe410: a versus match's " + "blacklisted pickups (0042b560)"); + + Entity* spawner = spawn.spawner; + int variant = spawn.variant; + if (spawner && spawner->IsFriendly() && spawn.type == ENTITY_EFFECT) variant = creep_friendly_variant(variant); + + Entity* entity = game.entityFactory->Create(spawn.type, mode); + if (!entity) return nullptr; + uint64_t startMs = GetTimeNs() / NS_PER_MS; + + entity->spawnerType = spawner ? spawner->type : 0; + entity->spawnerVariant = spawner ? spawner->variant : 0; + entity->spawnerEntity = spawner; + entity->pos = spawn.position; + entity->velocity = spawn.velocity; + entity->Init(spawn.type, variant, spawn.subType, spawn.seed); + entity->index = game.room->entityIndexCounter++; + game.room->entityList.AddEntity(entity); + + if (spawner && spawner->IsActiveEnemy(DEAD_INCLUDED)) spawner_inherit(*entity, *spawner, spawn.type, variant); + if (entity_is_erased(*entity)) Entity::RemoveWithPoof(entity); + + std::set>& triggers = game.proceduralItemManager.spawnTriggerTargets; + bool isTriggered = triggers.contains({entity->type, entity->variant}) || triggers.contains({entity->type, -1}); + if (entity->isExists && !game.proceduralItemManager.proceduralItems.empty() && isTriggered && + !game.playerManager.playerList.empty()) + reconstruction_missing("trigger_set_dispatch 009e0680: a TMTRAINER item's spawn trigger"); + + g_entitySpawnTimeMs += GetTimeNs() / NS_PER_MS - startMs; + return entity; +} + +// 007078f0 Game::ShouldEraseEnemy: whether Eraser erased the entity's kind this run. Dogma and a versus match's +// friendly enemies never are. +bool entity_is_erased(Entity& entity) +{ + Game& game = *g_game; + bool isEnemy = entity.type == ENTITY_PLAYER ? game.deathmatchManager.state >= DEATHMATCH_INTRO + : entity.type >= ENTITY_FIRST_ENEMY && entity.type < ENTITY_EFFECT; + if (entity.type == ENTITY_DOGMA || (isEnemy && entity.IsFriendly()) || game.erasedEntities.empty()) return false; + + int type = entity.type; + int variant = entity.variant; + int subType = entity.subtype; + erased_enemy_id_fix(type, variant, subType); + for (ErasedEnemy& erased : game.erasedEntities) + if (erased.type == type && (erased.variant < 0 || erased.variant == variant) && + (erased.subtype < 0 || erased.subtype == subType)) + return true; + return false; +} + +// 007076d0 Game::FixErasedEnemyID: the kind Eraser records for an enemy, folding champions and variants of one enemy +// together. +void erased_enemy_id_fix(int& type, int& variant, int& subType) +{ + if (subType > 0) subType = 0; + switch (type) + { + case ENTITY_GAPER: + case ENTITY_HUSH_GAPER: + case ENTITY_GREED_GAPER: + type = ENTITY_GAPER; + if (variant > 0) variant = 0; + break; + case ENTITY_GUSHER: + case ENTITY_FATTY: + if (variant == 1) variant = 0; + break; + case ENTITY_BABY_LONG_LEGS: + case ENTITY_CRAZY_LONG_LEGS: + case ENTITY_DIP: + case ENTITY_GYRO: + if (variant > 0) variant = 0; + break; + case ENTITY_SUB_HORF: type = ENTITY_HORF; break; + case ENTITY_STRIDER: type = ENTITY_SPIDER; break; + } +} + +// Whether an achievement is unlocked, as every one is in a daily or a debug run. +static bool unlocked(int achievement) +{ + return g_manager->persistentGameData.Unlocked(achievement); +} + +// The stage layouts read: one deeper under Curse of the Labyrinth, and Greed's floors mapped onto the normal ones. +static int stage_effective() +{ + Game& game = *g_game; + uint32_t curses = (Seeds::GetForcedCurses() | game.debugCurses | game.curses) & ~Seeds::GetPreventedCurses(); + int stage = (int)game.stage + (curses & CURSE_LABYRINTH ? STAGE_LABYRINTH_SHIFT : 0); + if (game.difficulty != DIFFICULTY_GREED && game.difficulty != DIFFICULTY_GREEDIER) return stage; + if (stage < STAGE_GREED_LAST) return stage * 2 - 1; + return stage == STAGE_GREED_LAST ? STAGE_GREED_SHOP : 0; +} + +// A layout pickup or slot that waits for an achievement: matched by type, variant and subtype (-1 for any), and the +// variant or subtype it is until then (-1 keeps it). +struct LockedEntry +{ + int type = 0; + int variant = 0; + int subtype = -1; + int achievement = 0; + int lockedVariant = -1; + int lockedSubtype = -1; +}; + +constexpr std::array LOCKED_ENTRIES = {{ + {ENTITY_PICKUP, PICKUP_BOMB, 4, ACHIEVEMENT_BOMB_GOLDEN, -1, 0}, + {ENTITY_PICKUP, PICKUP_HEART, 7, ACHIEVEMENT_HEART_GOLDEN, -1, 0}, + {ENTITY_PICKUP, PICKUP_HEART, 8, ACHIEVEMENT_HEART_HALF_SOUL, -1, HEART_SOUL}, + {ENTITY_PICKUP, PICKUP_HEART, 9, ACHIEVEMENT_HEART_SCARED, -1, HEART_RED}, + {ENTITY_PICKUP, PICKUP_HEART, 11, ACHIEVEMENT_HEART_BONE, -1, 2}, + {ENTITY_PICKUP, PICKUP_HEART, 12, ACHIEVEMENT_HEART_ROTTEN, -1, 2}, + {ENTITY_PICKUP, PICKUP_COIN, 5, ACHIEVEMENT_COIN_LUCKY, -1, 0}, + {ENTITY_PICKUP, PICKUP_COIN, 6, ACHIEVEMENT_COIN_STICKY, -1, 0}, + {ENTITY_PICKUP, PICKUP_COIN, 7, ACHIEVEMENT_COIN_GOLDEN, -1, 0}, + {ENTITY_PICKUP, PICKUP_KEY, 4, ACHIEVEMENT_KEY_CHARGED, -1, 0}, + {ENTITY_PICKUP, PICKUP_GRAB_BAG, 2, ACHIEVEMENT_GRAB_BAG_BLACK, -1, 0}, + {ENTITY_PICKUP, PICKUP_LIL_BATTERY, 4, ACHIEVEMENT_LIL_BATTERY_GOLDEN, -1, 0}, + {ENTITY_PICKUP, PICKUP_MIMIC_CHEST, -1, ACHIEVEMENT_MIMIC_CHEST, PICKUP_CHEST, -1}, + {ENTITY_PICKUP, PICKUP_HAUNTED_CHEST, -1, ACHIEVEMENT_HAUNTED_CHEST, PICKUP_CHEST, -1}, + {ENTITY_PICKUP, PICKUP_WOODEN_CHEST, -1, ACHIEVEMENT_WOODEN_CHEST, PICKUP_LOCKED_CHEST, -1}, + {ENTITY_SLOT, SLOT_HELL_GAME, -1, ACHIEVEMENT_HELL_GAME, SLOT_DEVIL_BEGGAR, -1}, + {ENTITY_SLOT, SLOT_ROTTEN_BEGGAR, -1, ACHIEVEMENT_ROTTEN_BEGGAR, SLOT_KEY_MASTER, -1}, + {ENTITY_SLOT, SLOT_CRANE_GAME, -1, ACHIEVEMENT_CRANE_GAME, SLOT_MACHINE, -1}, +}}; + +// A locked card a layout names becomes a random unlocked one. +static void entry_card_replace(RoomEntry& entry, uint32_t seed) +{ + std::vector>& cards = g_manager->itemConfig.cards; + if (entry.subtype == 0 || entry.subtype >= cards.size() || !cards[entry.subtype]) return; + int achievement = cards[entry.subtype]->achievementId; + if (achievement < 0 || unlocked(achievement)) return; + + int card = ItemPool::GetCardEx((int)seed, CARD_SPECIAL_CHANCE, CARD_RUNE_CHANCE, CARD_RUNE_CHANCE, true); + RNG cardRng = {seed, ENTRY_RNG._shift1, ENTRY_RNG._shift2, ENTRY_RNG._shift3}; + entry.subtype = lua_callback_run_get_card(&cardRng, card, true, true, false); +} + +// A pickup or slot a layout names that is not unlocked yet becomes its basic kind. The Confessional is a soul heart +// until then, and the closet's slot is Inner Child or a shopkeeper once the character's tainted self is unlocked. +static void entry_locked_replace(RoomEntry& entry, RNG& rng) +{ + if (entry.type == ENTITY_PICKUP) + { + uint32_t cardSeed = rng.Next(); + if (entry.variant == PICKUP_TAROT_CARD) return entry_card_replace(entry, cardSeed); + } + else if (entry.type == ENTITY_SLOT && entry.variant == SLOT_CONFESSIONAL) + { + if (!unlocked(ACHIEVEMENT_CONFESSIONAL)) + entry = {.type = ENTITY_PICKUP, .weight = entry.weight, .subtype = HEART_SOUL, .variant = PICKUP_HEART}; + return; + } + else if (entry.type == ENTITY_SLOT && entry.variant == SLOT_CLOSET_TAINTED) + { + int playerType = g_game->GetPlayer(0)->playerType; + if (playerType < COMPLETION_PLAYER_TYPE_COUNT && + !unlocked(COMPLETION_MARKS[playerType][COMPLETION_TAINTED].achievement)) + return; + bool isInnerChild = unlocked(ACHIEVEMENT_TAINTED_CLOSET); + entry.type = isInnerChild ? ENTITY_PICKUP : ENTITY_SHOPKEEPER; + entry.variant = isInnerChild ? PICKUP_COLLECTIBLE : 0; + entry.subtype = isInnerChild ? COLLECTIBLE_INNER_CHILD : 0; + return; + } + + for (const LockedEntry& locked : LOCKED_ENTRIES) + { + bool isMatch = (int)entry.type == locked.type && entry.variant == locked.variant && + (locked.subtype < 0 || entry.subtype == locked.subtype); + if (!isMatch || unlocked(locked.achievement)) continue; + if (locked.lockedVariant >= 0) entry.variant = locked.lockedVariant; + if (locked.lockedSubtype >= 0) entry.subtype = locked.lockedSubtype; + return; + } +} + +// Where a layout's trapdoor leads instead: stairs up where no stage follows, the heavenly door on the Cathedral's road +// or the backwards path, or the Void's portal at the end of the Dark Room. +static void trapdoor_transform(Room& room, RoomEntry& entry, int stage, RNG& rng) +{ + Game& game = *g_game; + auto stairs = [&] { + entry.type = ENTRY_STAIRS; + entry.variant = STAIRS_VARIANT_EXIT; + }; + auto heaven = [&] { + entry.type = ENTRY_EFFECT; + entry.variant = EFFECT_VARIANT_TRAPDOOR_MARKER; + }; + + if (game.difficulty == DIFFICULTY_GREED || game.difficulty == DIFFICULTY_GREEDIER) + { + if (game.currentRoomIdx == ROOM_GENESIS_IDX && !game.IsNextStageAvailable()) stairs(); + return; + } + bool isBackwards = game.gameStateFlags & 1ull << LEVEL_GAME_STATE_BACKWARDS_PATH; + if (game.stage >= 1 && game.stage <= STAGE_BACKWARDS_LAST && isBackwards) return heaven(); + + bool isInChallenge = game.challenge != 0 || game.dailyChallenge._id != 0; + bool isCathedralAllowed = !isInChallenge || game.GetChallengeParams().pathType == PATH_TYPE_CATHEDRAL; + bool isCathedralForced = isInChallenge && game.GetChallengeParams().pathType == PATH_TYPE_CATHEDRAL; + if (stage == STAGE_DARK_ROOM && room.roomType == ROOM_ERROR) + { + ChallengeParam& params = game.GetChallengeParams(); + bool isVoidOpen = + params.endStage == STAGE_VOID_ENTRY || (!isInChallenge && unlocked(ACHIEVEMENT_DARK_ROOM_END)); + int endStage = isVoidOpen ? STAGE_VOID_ENTRY : STAGE_DARK_ROOM; + if (params.isPathTypeSet && params.endStage != 0) endStage = params.endStage; + bool isHome = params.isPathTypeSet && params.pathType == PATH_TYPE_HOME; + if (!isHome && endStage >= STAGE_VOID_ENTRY) + { + entry.variant = TRAPDOOR_VARIANT_VOID; + return; + } + } + + if (room.roomType == ROOM_ERROR && !game.IsNextStageAvailable()) return stairs(); + bool isHeavenward = room.roomType == ROOM_ANGEL; + if (!isHeavenward && room.roomType == ROOM_ERROR && (stage == STAGE_WOMB_2 || stage == STAGE_BLUE_WOMB)) + isHeavenward = (rng.RandomInt(2) == 0 && isCathedralAllowed) || isCathedralForced; + if (!isHeavenward) + isHeavenward = + (stage >= STAGE_SHEOL && game.stageType != STAGETYPE_ORIGINAL) || game.currentRoomIdx == ROOM_GENESIS_IDX; + if (!isHeavenward) return; + if (!game.IsNextStageAvailable()) stairs(); + else if (Level::IsStageWithinEnd(STAGE_SHEOL, true)) heaven(); +} + +// The enemy variants a stage's alternate floor, or a lucky roll, swaps into a layout. Returns whether one was swapped. +static bool enemy_variant_transform(Room& room, RoomEntry& entry, int stage, int gridIndex, RNG& rng) +{ + Game& game = *g_game; + uint32_t stageType = game.stageType; + bool isAfterbirth = stageType == STAGETYPE_AFTERBIRTH; + bool isCavesOld = + (stage == 3 || stage == 4) && stageType != STAGETYPE_REPENTANCE && stageType != STAGETYPE_REPENTANCE_B; + bool isBurningBasement = isAfterbirth && (stage == 1 || stage == 2); + bool isFloodedCaves = isAfterbirth && (stage == 3 || stage == 4); + bool isDankDepths = isAfterbirth && (stage == 5 || stage == 6); + bool isScarredWomb = isAfterbirth && (stage == 7 || stage == 8); + bool isUnlocked = unlocked(ACHIEVEMENT_ENEMY_VARIANTS); + auto morph = [&](int type, int variant) { + entry.type = type; + entry.variant = variant; + return true; + }; + auto roll = [&](bool isAllowed, int odds, int below, int variant) { + if (!isAllowed || rng.RandomInt(odds) >= (uint32_t)below) return false; + entry.variant = variant; + return true; + }; + + switch (entry.type) + { + case ENTITY_STONEY: + if (game.dailyChallenge._specialDailyId == SPECIAL_DAILY_GOLDEN_FATTY || + game.challenge == CHALLENGE_GOLDEN_FATTY) + return roll(true, 5, 1, 10); + return false; + case ENTITY_GAPER: return roll(isBurningBasement, 5, 3, 2); + case ENTITY_HORF: return rng.RandomInt(60) == 0 && morph(ENTITY_SUB_HORF, 0); + case ENTITY_HIVE: return roll(isFloodedCaves, 2, 1, 1); + case ENTITY_CHARGER: return roll(isFloodedCaves, 2, 1, 1); + case ENTITY_GLOBIN: return roll(isDankDepths, 2, 1, 2); + case ENTITY_BOOMFLY: return roll(isFloodedCaves, 2, 1, 2); + case ENTITY_HOST: return isCavesOld && rng.RandomInt(5) == 0 && isUnlocked && morph(ENTITY_MUSHROOM, 0); + case ENTITY_HOPPER: + return entry.variant == 0 && isBurningBasement && rng.RandomInt(5) < 3 && morph(ENTITY_FLAMINGHOPPER, 0); + case ENTITY_MRMAW: return roll(true, 15, 1, 2); + case ENTITY_VIS: return roll(entry.variant != 2 && isScarredWomb, 2, 1, 3); + case ENTITY_GUTS: + case ENTITY_PARA_BITE: return roll(isScarredWomb, 2, 1, 1); + case ENTITY_KNIGHT: return roll(entry.variant == 0, 60, 1, 2); + case ENTITY_SPIDER: + { + bool isRepentance = stageType == STAGETYPE_REPENTANCE || stageType == STAGETYPE_REPENTANCE_B; + return isRepentance && (stage == 1 || stage == 2) && morph(ENTITY_STRIDER, 0); + } + case ENTITY_FATTY: + if (isUnlocked && entry.variant == 1 && rng.RandomInt(10) == 0) return morph(ENTITY_STONEY, 0); + return roll(isBurningBasement, 5, 3, 2); + case ENTITY_DEATHS_HEAD: + case ENTITY_SQUIRT: return roll(isDankDepths, 2, 1, 1); + case ENTITY_SKINNY: return roll(isBurningBasement, 5, 2, 2); + case ENTITY_NERVE_ENDING: + { + if (rng.RandomInt(5) != 0 || !isUnlocked) return false; + int column = (uint32_t)gridIndex % room.gridWidth; + int row = (uint32_t)gridIndex / room.gridWidth; + for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) + { + int door = room.doorGridPositions[slot]; + int distance = std::abs(door / room.gridWidth - row) + std::abs(door % room.gridWidth - column); + if ((room.descriptor->allowedDoors & 1 << slot) && distance < NERVE_DOOR_DISTANCE) return false; + } + entry.variant = 1; + return true; + } + } + return false; +} + +// The rare variants a basic enemy of a layout may be: its alternate look (one in 21 or more), or its second variant +// (one in 100). +static void enemy_rare_variant_roll(RoomEntry& entry, int stage, RNG& rng) +{ + bool isCommon = false; + bool isUncommon = false; + bool isRare = false; + if (entry.variant == 0) + { + switch (entry.type) + { + case ENTITY_POOTER: + case ENTITY_MULLIGAN: + case ENTITY_GLOBIN: + case ENTITY_MAW: + case ENTITY_HOST: isCommon = true; break; + case ENTITY_BOOMFLY: isCommon = stage > 2; break; + case ENTITY_HOPPER: + case ENTITY_BOIL: + case ENTITY_BABY: + case ENTITY_STONEHEAD: + case ENTITY_MEMBRAIN: + case ENTITY_SUCKER: + case ENTITY_WALKINGBOIL: isUncommon = true; break; + case ENTITY_VIS: isUncommon = (stage == 7 || stage == 8) && g_game->stageType == STAGETYPE_WOTL; break; + case ENTITY_KNIGHT: + case ENTITY_LEECH: + case ENTITY_EYE: isRare = true; break; + } + } + switch (entry.type) + { + case ENTITY_CLOTTY: + case ENTITY_MULLIGAN: + case ENTITY_MAW: + case ENTITY_BOIL: + case ENTITY_VIS: + case ENTITY_LEECH: + case ENTITY_WALKINGBOIL: + if (rng.RandomInt(ODDS_PERCENT) == 0) entry.variant = 2; + } + + bool isAlternate = false; + if (isRare || ((isCommon || isUncommon) && rng.RandomInt(21) != 0)) + isAlternate = !((isUncommon || rng.RandomInt(25) != 0) && rng.RandomInt(ODDS_PERCENT) != 0); + else isAlternate = isCommon || isUncommon; + if (isAlternate) entry.variant = 1; + + if (entry.type == ENTITY_BOOMFLY && entry.variant == 3 && entry.subtype == BOOMFLY_DRAGONFLY_SUBTYPE) + entry.subtype = rng.RandomInt(2); +} + +// 007ec100 Room::TransformEntry: what a layout entry really spawns: fireplaces and random cards resolved, locked +// pickups and slots swapped for unlocked ones, the trapdoor's destination, Devil treasure for sale, rare slots, enemy +// redirection, and the stage's enemy variants. +void room_entry_transform(Room& room, RoomEntry& entry, int gridIndex, uint32_t seed) +{ + Game& game = *g_game; + RNG rng = {seed, TRANSFORM_RNG._shift1, TRANSFORM_RNG._shift2, TRANSFORM_RNG._shift3}; + if (entry.type == ENTRY_FIREPLACE || entry.type == ENTRY_FIREPLACE_RED) + { + entry.variant = entry.type == ENTRY_FIREPLACE_RED || rng.Next() % FIREPLACE_RED_ODDS == 0; + entry.type = ENTITY_FIREPLACE; + } + if (static_cast(g_luaEngine)->enabledCallbacks[MC_PRE_ROOM_ENTITY_SPAWN]) + reconstruction_missing("LuaEngine::Callback_PreEntitySpawn 00866490"); + if (entry.type == ENTITY_PICKUP && entry.variant == PICKUP_RANDOM_CARD) + { + entry.variant = PICKUP_TAROT_CARD; + uint32_t cardSeed = rng.Next(); + int card = ItemPool::GetCardEx((int)cardSeed, 0, 1, 0, true); + RNG cardRng = {cardSeed, ENTRY_RNG._shift1, ENTRY_RNG._shift2, ENTRY_RNG._shift3}; + entry.subtype = lua_callback_run_get_card(&cardRng, card, false, true, true); + } + entry_locked_replace(entry, rng); + + int stage = stage_effective(); + if (entry.type == ENTRY_TRAPDOOR) trapdoor_transform(room, entry, stage, rng); + + bool isDevilTreasure = room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE; + if (room.roomType == ROOM_TREASURE && isDevilTreasure && entry.type == ENTITY_PICKUP && + entry.variant == PICKUP_COLLECTIBLE && entry.subtype == 0) + entry.variant = PICKUP_SHOP_ITEM; + if (entry.type == ENTITY_SLOT) + { + RNG slotRng = {seed, SLOT_RNG._shift1, SLOT_RNG._shift2, SLOT_RNG._shift3}; + bool isHellGame = + entry.variant == SLOT_SHELL_GAME && unlocked(ACHIEVEMENT_HELL_GAME) && game.devilRoomDeals > 0; + bool isRotten = entry.variant == SLOT_BEGGAR && unlocked(ACHIEVEMENT_ROTTEN_BEGGAR); + if (isHellGame && slotRng.RandomInt(4) == 0) entry.variant = SLOT_HELL_GAME; + else if (isRotten && slotRng.RandomInt(15) == 0) entry.variant = SLOT_ROTTEN_BEGGAR; + } + if (entry.type >= 1 && entry.type <= ENTRY_EFFECT) + { + int type = entry.type; + int variant = entry.variant; + Entity_NPC::Redirect(&type, &variant); + entry.type = type; + entry.variant = variant; + } + + if (room.has_room_config_flag(ROOM_CONFIG_FLAG_NO_TRANSFORMS) || room.roomType == ROOM_SECRET_EXIT) return; + if (enemy_variant_transform(room, entry, stage, gridIndex, rng)) return; + enemy_rare_variant_roll(entry, stage, rng); +} + +// 00822cf0 Room::add_trigger_output_index: adds a cell to one of the room's trigger output groups. +void room_trigger_output_index_add(Room& room, int group, int gridIndex) +{ + if ((uint32_t)group < OUTPUT_GROUP_COUNT) room.outputGroupGridIndices[group].insert(gridIndex); +} + +// 00822d20 Room::add_trigger_output_cell: adds the cell at a column and row, when it is inside the room. +void room_trigger_output_cell_add(Room& room, int group, int column, int row) +{ + if (column >= 0 && row >= 0 && column < room.gridWidth && row < room.gridHeight) + room_trigger_output_index_add(room, group, room.GetGridIndexByTile(column, row)); +} + +// The grimaces, stone shooters and other hazards a cleared room still spawns (Poky only past its first variant). +constexpr std::array PERSISTENT_ENTITIES = { + ENTITY_STONEHEAD, 202, 203, 218, 235, 236, 804, 809, 852, 877, 893}; +constexpr int ENTITY_POKY = 44; + +// 007ed2a0 Room::IsPersistentRoomEntity: whether a cleared room still spawns the entity. +bool room_entity_is_persistent(int type, int variant) +{ + if (type == ENTITY_POKY) return variant != 0; + return type == ENTITY_MINECART || + std::find(PERSISTENT_ENTITIES.begin(), PERSISTENT_ENTITIES.end(), type) != PERSISTENT_ENTITIES.end(); +} + +// Whether a layout entry is a rock that hazards and Dirty Mind may replace (not the room's tinted one). +static bool entry_is_plain_rock(Room& room, int type, int gridIndex) +{ + return (type == ENTRY_ROCK && room.tintedRockIdx != gridIndex) || type == ENTRY_ROCK_BOMB || type == ENTRY_ROCK_ALT; +} + +// Whether the room's golden rock ellipse covers a cell: one room in ten with the achievement, an ellipse placed and +// turned at random from the room's decoration seed. +static bool rock_ellipse_contains(Room& room, int gridIndex) +{ + if (!unlocked(ACHIEVEMENT_ROCK_VARIANTS)) return false; + RNG rng = {room.descriptor->decorationSeed, ROCK_ELLIPSE_RNG._shift1, ROCK_ELLIPSE_RNG._shift2, + ROCK_ELLIPSE_RNG._shift3}; + if (rng.RandomInt(ELLIPSE_ODDS) != 0) return false; + + float centerY = rng.RandomFloat() * (float)room.gridHeight; + float centerX = rng.RandomFloat() * (float)room.gridWidth; + int stageId = g_game->GetStageID(); + bool isMines = stageId == STAGE_ID_MINES || g_game->GetStageID() == STAGE_ID_ASHPIT; + float spreadX = isMines ? ELLIPSE_MINES_SPREAD_X : ELLIPSE_SPREAD_X; + float spreadY = isMines ? ELLIPSE_MINES_SPREAD_Y : ELLIPSE_SPREAD_Y; + float radiusY = (rng.RandomFloat() + rng.RandomFloat()) * spreadY + ELLIPSE_RADIUS_Y; + float radiusX = (rng.RandomFloat() + rng.RandomFloat()) * spreadX + ELLIPSE_RADIUS_X; + float angle = -(rng.RandomFloat() * FULL_TURN) * DEGREES_TO_RADIANS; + float cosine = (float)std::cos((double)angle); + float sine = (float)std::sin((double)angle); + + float dx = (float)((uint32_t)gridIndex % room.gridWidth) - centerX; + float dy = (float)((uint32_t)gridIndex / room.gridWidth) - centerY; + float x = (dx * cosine - sine * dy) / radiusX; + float y = (dx * sine + cosine * dy) / radiusY; + return y * y + x * x <= 1; +} + +// A layout poop's variant: the entry's, and for a plain or corny one the chance of a rarer kind, then Meconium's chance +// of black. Each counts toward the room's poops. +static int poop_variant_roll(Room& room, int variant, RNG& rng) +{ + if (variant == POOP_NORMAL) + { + if (rng.RandomInt(CORN_ODDS) == 0) variant = POOP_CORN; + else if (rng.RandomInt(CHARMING_ODDS) == 0 && unlocked(ACHIEVEMENT_POOP_CHARMING)) variant = POOP_CHARMING; + } + if (variant == POOP_CORN) + { + uint32_t roll = rng.RandomInt(CORN_ODDS); + if (roll == 1 || roll == 2) variant = POOP_GOLDEN; + else if (roll >= 5 && roll <= 7) variant = POOP_RAINBOW; + } + + Entity_Player* owner = g_game->playerManager.FirstTrinketOwner(TRINKET_MECONIUM); + if (owner) + { + RNG meconiumRng = {rng._seed, MECONIUM_RNG._shift1, MECONIUM_RNG._shift2, MECONIUM_RNG._shift3}; + int multiplier = owner->GetTrinketMultiplier(TRINKET_MECONIUM); + int chance = multiplier == 2 ? MECONIUM_CHANCE_DOUBLE + : multiplier == 3 ? MECONIUM_CHANCE_TRIPLE + : MECONIUM_CHANCE; + if ((int)meconiumRng.RandomInt(ODDS_PERCENT) < chance) variant = POOP_BLACK; + } + room.descriptor->poopCount++; + return variant; +} + +// The layout's plain rock: bomb rocks one in a hundred, golden ones in the room's ellipse, alternate ones rarely, and +// on the tinted rock's cell a tinted or super tinted rock. +static GridEntityType rock_type_roll(Room& room, int gridIndex, RNG& rng) +{ + bool isGolden = rock_ellipse_contains(room, gridIndex); + uint32_t roll = rng.RandomInt(ROCK_ROLLS); + if (room.tintedRockIdx == gridIndex) + { + bool isSuper = rng.RandomInt(SUPER_TINTED_ODDS) == 0 && unlocked(ACHIEVEMENT_SUPER_TINTED_ROCK); + return isSuper ? GRID_ROCK_SS : GRID_ROCKT; + } + if (roll < ROCK_BOMB_ROLLS) return GRID_ROCK_BOMB; + if (isGolden) return GRID_ROCK_GOLD; + return roll < ROCK_ALT_ROLLS ? GRID_ROCK_ALT : GRID_ROCK; +} + +// A layout entry's grid entity type that maps one to one, with its variant (-1 keeps the entry's). +struct GridEntry +{ + int entryType = 0; + GridEntityType gridType = GRID_DECORATION; + int variant = -1; +}; + +constexpr std::array GRID_ENTRIES = {{ + {ENTRY_ROCK_BOMB, GRID_ROCK_BOMB}, + {ENTRY_ROCK_ALT, GRID_ROCK_ALT}, + {ENTRY_ROCK_TINTED, GRID_ROCKT}, + {ENTRY_ROCK_SUPER_TINTED, GRID_ROCK_SS}, + {ENTRY_ROCK_ALT2, GRID_ROCK_ALT2}, + {ENTRY_ROCK_MARKED, GRID_ROCK, ROCK_MARKED_VARIANT}, + {ENTRY_ROCK_SPIKED, GRID_ROCK_SPIKED}, + {ENTRY_TNT, GRID_TNT}, + {ENTRY_FIREPLACE, GRID_FIREPLACE, 0}, + {ENTRY_FIREPLACE_RED, GRID_FIREPLACE, 1}, + {ENTRY_BLOCK, GRID_ROCKB}, + {ENTRY_PILLAR, GRID_PILLAR}, + {ENTRY_SPIKES, GRID_SPIKES}, + {ENTRY_SPIKES_ONOFF, GRID_SPIKES_ONOFF}, + {ENTRY_COBWEB, GRID_SPIDERWEB}, + {ENTRY_WALL, GRID_WALL}, + {ENTRY_LOCK, GRID_LOCK}, + {ENTRY_PRESSURE_PLATE, GRID_PRESSURE_PLATE}, + {ENTRY_STATUE_DEVIL, GRID_STATUE, 0}, + {ENTRY_STATUE_ANGEL, GRID_STATUE, 1}, + {ENTRY_GRAVITY, GRID_GRAVITY}, +}}; + +// The poop entries' variants, from ENTRY_POOP_RED on (-1 for the gaps). +constexpr std::array POOP_ENTRY_VARIANTS = {POOP_RED, -1, -1, -1, + POOP_RAINBOW, POOP_CORN, POOP_GOLDEN, POOP_BLACK, + POOP_HOLY, POOP_GIGA, POOP_NORMAL, POOP_CHARMING}; + +// Places a layout's grid entity on a free cell: rocks and poops rolled, pits counted, the crawlspace's ladder spawned, +// the trapdoor's destination kept in its data. +static bool grid_entry_spawn(Room& room, RoomEntry& entry, int gridIndex, uint32_t seed, RNG& rng) +{ + int type = entry.type; + int variant = entry.variant; + int varData = 0; + bool isPlain = !room.has_room_config_flag(ROOM_CONFIG_FLAG_NO_ALT_ROCKS) && entry.subtype == 0; + GridEntityType gridType = GRID_DECORATION; + if (type == ENTRY_ROCK) gridType = isPlain ? rock_type_roll(room, gridIndex, rng) : GRID_ROCK; + else if (type == ENTRY_ROCK_GOLD) gridType = unlocked(ACHIEVEMENT_ROCK_VARIANTS) ? GRID_ROCK_GOLD : GRID_ROCK; + else if (type >= ENTRY_POOP_RED && type <= ENTRY_POOP_CHARMING && POOP_ENTRY_VARIANTS[type - ENTRY_POOP_RED] >= 0) + { + gridType = GRID_POOP; + variant = POOP_ENTRY_VARIANTS[type - ENTRY_POOP_RED]; + if (isPlain) variant = poop_variant_roll(room, variant, rng); + } + else if (type == ENTRY_PIT || type == ENTRY_PIT_ALT || type == ENTRY_PIT_MARKED || type == ENTRY_PIT_CRAWLSPACE) + { + gridType = GRID_PIT; + if (type == ENTRY_PIT_MARKED) variant = PIT_MARKED_VARIANT; + if (type == ENTRY_PIT_CRAWLSPACE) + { + Vector position = room.GetGridPosition(gridIndex); + g_game + ->Spawn({.position = position, + .subType = entry.subtype, + .type = ENTITY_EFFECT, + .variant = EFFECT_CRAWLSPACE_LADDER, + .seed = rng.Next()}) + ->Update(); + } + room.descriptor->pitsCount++; + } + else if (type == ENTRY_TRAPDOOR) + { + gridType = GRID_TRAPDOOR; + varData = variant; + variant = 0; + } + else if (type == ENTRY_STAIRS) gridType = GRID_STAIRS; + else if (type == ENTRY_TELEPORTER) gridType = GRID_TELEPORTER; + for (const GridEntry& grid : GRID_ENTRIES) + { + if (grid.entryType != type) continue; + gridType = grid.gridType; + if (grid.variant >= 0) variant = grid.variant; + } + + GridEntity* grid = CreateGridEntity(gridType, gridIndex); + if (!grid) return false; + room.gridEntities[gridIndex] = grid; + grid->variant = variant; + grid->varData = varData; + if (gridType == GRID_TELEPORTER) grid->state = entry.subtype != 0 ? TELEPORTER_STATE_ACTIVE : 0; + grid->Init(seed); + return true; +} + +// Spawns a layout entry's entity on its cell, unless the room was cleared and it is an enemy that stays dead. A pickup +// loses its wait, and in rooms of choices it joins the first group of options. +static bool entity_entry_spawn(Room& room, RoomEntry& entry, const RoomEntrySpawn& spawn, RNG& rng) +{ + Game& game = *g_game; + int type = entry.type; + RoomDescriptor& descriptor = *room.descriptor; + bool isCleared = descriptor.flags & ROOM_DESCRIPTOR_FLAG_CLEAR; + if (!isCleared && room.roomType == ROOM_BOSS && (descriptor.flags & ROOM_DESCRIPTOR_FLAG_ROTGUT_CLEARED)) + isCleared = type != ENTITY_ROTGUT; + if (type == ENTITY_PICKUP && game.IsMausoleumHeartStage()) return false; + if (type == ENTITY_MINECART && (descriptor.flags & ROOM_DESCRIPTOR_FLAG_SACRIFICE_DONE)) return false; + if (isCleared && !room_entity_is_persistent(type, entry.variant) && + !game.seedEffects.HasSeedEffect(SEED_PACIFIST) && !game.seedEffects.HasSeedEffect(SEED_ENEMIES_RESPAWN) && + spawn.mode == ENTRY_SPAWN && !entity_type_is_saved(type, entry.variant, entry.subtype, 0, true)) + return false; + + int gridIndex = spawn.gridIndex; + if ((uint32_t)gridIndex < ROOM_GRID_CELLS && room.gridEntities[gridIndex]) + room.gridEntities[gridIndex]->Destroy(true, EntityRef()); + Vector position = room.GetGridPosition(gridIndex); + Entity* entity = game.Spawn( + {.position = position, .subType = entry.subtype, .type = type, .variant = entry.variant, .seed = rng.Next()}); + // The original writes through a failed spawn's null. It is not spawned then. + if (!entity) return false; + entity->spawnGridIndex = gridIndex; + + Entity_Pickup* pickup = entity->type == ENTITY_PICKUP ? dynamic_cast(entity) : nullptr; + if (pickup) + { + pickup->wait = 0; + bool isKnifePiece = + pickup->subtype == COLLECTIBLE_KNIFE_PIECE_1 || pickup->subtype == COLLECTIBLE_KNIFE_PIECE_2; + if (pickup->type == ENTITY_PICKUP && pickup->variant == PICKUP_COLLECTIBLE && isKnifePiece) + pickup->cycleCollectibleCount = 0; + bool isFlippable = Entity_Pickup::CanRerollVariant(pickup->variant, pickup->subtype) && + (!Entity_Pickup::IsChest(pickup->variant) || pickup->subtype != 0) && + pickup->variant == PICKUP_COLLECTIBLE; + if (game.playerManager.FirstCollectibleOwner(COLLECTIBLE_FLIP, LAZARUS_SHARE_CHECK) && !pickup->isDead && + isFlippable) + reconstruction_missing("Room::SpawnEntry 007ed310: Flip's ghost item (EntitySaveState)"); + pickup->altPedestalANM2.Reset(); + } + if (entity_type_is_saved(type, entry.variant, entry.subtype, 0, false)) + descriptor.restrictedGridIndexes.insert(gridIndex); + + bool isTreasureChoice = + room.roomType == ROOM_TREASURE && (descriptor.data->subtype == TREASURE_SUBTYPE_CHOICE || + descriptor.data->subtype == TREASURE_SUBTYPE_CHOICE_ALT || game.IsAltPath()); + bool isChoiceRoom = room.roomType == ROOM_BOSSRUSH || isTreasureChoice || room.roomType == ROOM_PLANETARIUM || + room.roomType == ROOM_ANGEL; + if (isChoiceRoom && type == ENTITY_PICKUP && entry.variant == PICKUP_COLLECTIBLE && entity->type == ENTITY_PICKUP) + static_cast(entity)->optionsPickupIndex = 1; + + // Online the line starts with the netplay frame, which offline play never has. + log_printf(LOG_INFO, "Spawn Entity with Type(%d), Variant(%d), Pos(%.2f,%.2f)\n", type, entry.variant, + (double)position.x, (double)position.y); + if (spawn.outEntity) *spawn.outEntity = entity; + return true; +} + +// 007ed310 Room::SpawnEntry: spawns a layout entry on a cell after its transforms: an entity, a grid entity on a free +// cell, a rail, or a trigger output. Hazards of the Afterbirth floors, Dirty Mind's dips, TNT barrels, the trapdoor's +// replacements and the special shopkeepers are decided here. A respawn skips the grid entities. +bool room_entry_spawn(Room& room, RoomEntry entry, const RoomEntrySpawn& spawn) +{ + Game& game = *g_game; + int gridIndex = spawn.gridIndex; + RNG rng = {spawn.seed, ENTRY_RNG._shift1, ENTRY_RNG._shift2, ENTRY_RNG._shift3}; + room_entry_transform(room, entry, gridIndex, spawn.seed); + auto replace = [&](int type) { + entry.type = type; + entry.variant = 0; + entry.subtype = 0; + }; + + bool isPickup = entry.type == ENTITY_PICKUP; + if (game.currentRoomIdx == ROOM_GENESIS_IDX && isPickup && entry.variant == PICKUP_COLLECTIBLE) return false; + RoomConfig_Room* data = room.descriptor->data; + if (game.HasMirrorDimension() && spawn.mode == ENTRY_SPAWN && game.currentDimensionIdx == MIRROR_DIMENSION && + isPickup && !(data->type == ROOM_TREASURE && data->subtype == TREASURE_SUBTYPE_MIRROR)) + return false; + + if (room.has_room_config_flag(ROOM_CONFIG_FLAG_AFTERBIRTH_HAZARDS) && + entry_is_plain_rock(room, entry.type, gridIndex) && game.stageType == STAGETYPE_AFTERBIRTH && + data->type == ROOM_DEFAULT && rng.Next() % TENTH == 0) + { + if (game.stage == 1 || game.stage == 2) + { + entry.type = ENTITY_FIREPLACE; + entry.variant = rng.RandomInt(FIREPLACE_RED_ODDS) == 0; + entry.subtype = 0; + } + else if (game.stage == 3 || game.stage == 4) replace(ENTRY_PIT); + else if (game.stage == 5 || game.stage == 6) replace(ENTRY_SPIKES); + else if (game.stage == 7 || game.stage == 8) replace(ENTRY_POOP_RED); + } + + if (room.roomType == ROOM_SHOP && room.descriptor->gridIndex < 0 && entry.type == ENTITY_SLOT) + return entry.variant != SLOT_DONATION && entity_entry_spawn(room, entry, spawn, rng); + + if (entry_is_plain_rock(room, entry.type, gridIndex) && room.roomType != ROOM_DUNGEON) + { + RNG dirtyRng = {spawn.seed, DIRTY_MIND_RNG._shift1, DIRTY_MIND_RNG._shift2, DIRTY_MIND_RNG._shift3}; + Entity_Player* owner = + game.playerManager.RandomCollectibleOwner(COLLECTIBLE_DIRTY_MIND, dirtyRng.Next(), nullptr); + float chance = + owner ? std::min(owner->luck * DIRTY_MIND_LUCK_CHANCE + DIRTY_MIND_CHANCE, DIRTY_MIND_CHANCE_MAX) : 0; + if (owner && dirtyRng.RandomFloat() <= chance) replace(ENTRY_POOP); + } + if (entry.type == ENTRY_TNT && rng.Next() % TENTH == 0) replace(ENTITY_MOVABLE_TNT); + if (entry.type == ENTRY_TRAPDOOR || (entry.type == ENTRY_EFFECT && entry.variant == EFFECT_VARIANT_TRAPDOOR_MARKER)) + { + bool isDeadEnd = room.roomType != ROOM_ERROR && room.roomType != ROOM_SECRET_EXIT && + game.currentRoomIdx != ROOM_GENESIS_IDX && + !(room.roomType == ROOM_BOSS && data->subtype == BOSS_SUBTYPE_MOTHER); + if (!game.IsNextStageAvailable() && isDeadEnd) replace(ENTRY_COBWEB); + else if (game.HasMirrorDimension() && game.currentDimensionIdx == MIRROR_DIMENSION) replace(0); + } + if (entry.type == ENTITY_SHOPKEEPER) + { + if (entry.variant == 0 && (rng.Next() & SHOPKEEPER_ODDS_MASK) == 0 && unlocked(ACHIEVEMENT_SHOPKEEPER_SPECIAL)) + entry.variant = SHOPKEEPER_SPECIAL; + else if (entry.variant == 1 && (rng.Next() & SHOPKEEPER_ODDS_MASK) == 0 && + unlocked(ACHIEVEMENT_SHOPKEEPER_SECRET)) + entry.variant = SHOPKEEPER_SECRET_SPECIAL; + } + if (entry.type == ENTRY_STATUE_DEVIL && game.bossPool.removedBosses[BOSS_SATAN]) + { + replace(ENTRY_ROCK); + entry.subtype = 1; + } + + int type = entry.type; + bool isEntity = type >= 1 && type <= ENTRY_EFFECT; + if (!isEntity && spawn.mode == ENTRY_RESPAWN) return false; + if (type == ENTRY_QUEST_DOOR) return true; + if (type == ENTRY_TRIGGER_OUTPUT) + { + int column = (uint32_t)gridIndex % room.gridWidth; + int row = (uint32_t)gridIndex / room.gridWidth; + room_trigger_output_cell_add(room, entry.variant, column - 1, row); + room_trigger_output_cell_add(room, entry.variant, column + 1, row); + room_trigger_output_cell_add(room, entry.variant, column, row - 1); + room_trigger_output_cell_add(room, entry.variant, column, row + 1); + return true; + } + if (type == ENTRY_RAIL || type == ENTRY_RAIL_PIT) room.railManager.rails[gridIndex] = entry.variant; + if (type == ENTRY_RAIL) return true; + if (isEntity) + { + if (type == ENTRY_EFFECT) entry.type = ENTITY_EFFECT; + return entity_entry_spawn(room, entry, spawn, rng); + } + if (type == ENTRY_RAIL_PIT) + { + entry.type = ENTRY_PIT; + entry.variant = 0; + } + if (room.gridEntities[gridIndex]) return false; + return grid_entry_spawn(room, entry, gridIndex, spawn.seed, rng); +} diff --git a/src/entity_factory.h b/src/entity_factory.h new file mode 100644 index 0000000..789786c --- /dev/null +++ b/src/entity_factory.h @@ -0,0 +1,93 @@ +#pragma once + +#include "entity.h" +#include +#include +#include + +struct EntitySpawn; +struct RoomEntry; + +// Whether EntityFactory::Create overwrites an entity in use when its pool is full (SpawnEx's flag 1 keeps them). +enum PoolMode +{ + POOL_OVERWRITE, + POOL_KEEP +}; + +// EntityFactory's pools, one per entity class. +enum PoolId +{ + ENTITY_POOL_EFFECT, + ENTITY_POOL_FAMILIAR, + ENTITY_POOL_BOMB, + ENTITY_POOL_PROJECTILE, + ENTITY_POOL_TEAR, + ENTITY_POOL_LASER, + ENTITY_POOL_PICKUP, + ENTITY_POOL_SLOT, + ENTITY_POOL_NPC, + ENTITY_POOL_TEXT, + ENTITY_POOL_KNIFE, + ENTITY_POOL_COUNT +}; + +// A pool's class, its size, and its name in the pool full warning. +struct PoolDesc +{ + std::unique_ptr (*make)() = nullptr; + const char* name = ""; + uint32_t size = 0; +}; + +// One class's entities. A slot is made the first time Create reaches it and reused once its entity leaves the room. +// Create cycles from the slot it handed out last. +struct EntityPool +{ + std::vector> slots; + const PoolDesc* desc = nullptr; + uint32_t cursor = 0; + + Entity* Create(PoolMode mode); + +private: + Entity& slot_get(); + Entity& slot_next(); +}; + +// The entity pools of a run (Game::entityFactory): every entity but the players lives in one, so spawning never +// allocates once a slot exists. The original built all its pools in its constructor (006f2a10) and freed them in Game's +// destructor. Slots are made on first use instead, which a new entity cannot tell apart. Its pool of plain Entity_Dummy +// objects was never handed out, so it is gone. +struct EntityFactory +{ + std::array pools; + + EntityFactory(); + Entity* Create(int type, PoolMode mode); +}; + +// How Room::SpawnEntry places a layout entry, as when the room is entered or when its enemies respawn. +enum EntryMode +{ + ENTRY_SPAWN, + ENTRY_RESPAWN +}; + +// A layout entry spawned on a cell, and where to hand back the entity it made. +struct RoomEntrySpawn +{ + Entity** outEntity = nullptr; + int gridIndex = 0; + uint32_t seed = 0; + EntryMode mode = ENTRY_SPAWN; +}; + +Entity* game_spawn(const EntitySpawn& spawn, PoolMode mode); +bool entity_is_erased(Entity& entity); +void erased_enemy_id_fix(int& type, int& variant, int& subType); +bool room_entry_spawn(Room& room, RoomEntry entry, const RoomEntrySpawn& spawn); +void room_entry_transform(Room& room, RoomEntry& entry, int gridIndex, uint32_t seed); +bool room_entity_is_persistent(int type, int variant); +void room_trigger_output_index_add(Room& room, int group, int gridIndex); +void room_trigger_output_cell_add(Room& room, int group, int column, int row); diff --git a/src/entity_familiar.h b/src/entity_familiar.h index bb7f83e..35e710e 100644 --- a/src/entity_familiar.h +++ b/src/entity_familiar.h @@ -2,6 +2,7 @@ #include "entity.h" #include "anm2.h" +#include "weapon.h" #include #include @@ -28,7 +29,7 @@ struct Entity_Familiar : Entity Entity_Player* player = nullptr; Entity_Player* sirenOriginalPlayer = nullptr; ItemConfig_Item* item = nullptr; - Weapon* weapon = nullptr; + WeaponPtr weapon; Vector formationOffset{}; Vector formationTargetOffset{}; Vector orbitDistance{}; diff --git a/src/entity_player.cpp b/src/entity_player.cpp index d7dcec2..f829045 100644 --- a/src/entity_player.cpp +++ b/src/entity_player.cpp @@ -188,8 +188,7 @@ Entity_Player::~Entity_Player() // 00755470 Starts a player of a variant: a character (subtype is the player type), a co-op baby (subtype is the skin) // or an extra player. Seeds one generator per collectible, trinket, pill effect and card, resets every stat and // counter, loads the sprites, picks the controller, puts on the skin, and gives a character its starting health and -// pickups. The original makes the tears weapon through Isaac::CreateWeapon, which is not taken over: the slot stays -// empty. +// pickups. Every player starts with the tears weapon. void Entity_Player::Init(int entityType, int entityVariant, int subType, uint32_t seed) { Manager& manager = *g_manager; @@ -345,10 +344,20 @@ void Entity_Player::stats_reset() bloodLustCounter = 0; deadCatLives = 0; damageCooldown = 0; - weapons.fill(nullptr); + weaponTypes.fill(false); + weaponTypes[WEAPON_TEARS] = true; + for (WeaponPtr& weapon : weapons) weapon.reset(); + weapons[1] = weapon_create(WEAPON_TEARS, this); markedTarget = nullptr; heldEntity = nullptr; tractorBeam = 0; + shootHeldFrames = 0; + azazelsRageLaser = nullptr; + shootDirectionHistory.clear(); + lastShootTime = 0; + doubleTapFrames = 0; + ibsChargeBar = 0; + isIbsChargeSoundPending = true; megaBlastLaser = nullptr; breathOfLifeEffect = nullptr; itemState = 0; diff --git a/src/entity_player.h b/src/entity_player.h index 24461eb..b78c652 100644 --- a/src/entity_player.h +++ b/src/entity_player.h @@ -5,6 +5,7 @@ #include "kage_graphics.h" #include "online_emotes.h" #include "temporary_effects.h" +#include "weapon.h" #include #include #include @@ -136,6 +137,9 @@ enum Direction : int DIRECTION_DOWN }; +// The head animations the player turns to, by direction. +constexpr std::string_view PLAYER_HEAD_ANIMS[] = {"HeadLeft", "HeadUp", "HeadRight", "HeadDown"}; + // The layers of the player's sprite, in the order its .anm2 lists them: the glow, the body, the head and the top // layers costumes can cover. enum PlayerSpriteLayer : int @@ -463,8 +467,17 @@ struct EntityDesc bool isPlayerControlled = false; }; +// What the shoot actions ask for this frame: a direction, whether any is held, and whether opposite ones cancel. +struct ShootInput +{ + Vector direction{}; + bool isOpposing = false; + bool isPressed = false; +}; + RNG rng_make(uint32_t seed, uint32_t shiftIndex); bool is_run_unlocked(int achievement); +Direction vector_to_direction(const Vector& v); int scale_for_hard_difficulty(int value); std::string costume_path_apply_skin_color(const std::string& path, int skinColor, int playerType, bool* isSkinColorFound, bool* isCharacterFound); @@ -631,7 +644,10 @@ public: uint8_t wildCardItemType = WILD_CARD_NONE; bool isHeldItemVisible = false; - std::array weapons{}; + std::array weapons; + std::array weaponTypes{}; + std::deque shootDirectionHistory; + EntityPtr azazelsRageLaser; Vector aimDirection{}; Vector lastDirection{}; Vector lastVelocity{}; @@ -641,14 +657,18 @@ public: Vector tearsOffset{}; float bodyAngle = 0; float heightVelocity = 0; + float ibsChargeBar = 0; + int64_t lastShootTime = 0; int actionHoldDrop = 0; int bombPlaceDelay = 0; int controllerIndex = -1; int controlsCooldown = 0; + int doubleTapFrames = 0; int fireBlockCooldown = 0; int glowingHourglassIndex = -1; int lastActionTriggers = 0; int playerIndex = -1; + int shootHeldFrames = 0; int slipperyTimer = 0; int tractorBeam = 0; Direction fireDirection = DIRECTION_NONE; @@ -657,6 +677,7 @@ public: bool areOpposingShootDirectionsPressed = false; bool canShoot = true; bool isControlsEnabled = true; + bool isIbsChargeSoundPending = true; EntityRef lastDamageSource; uint64_t lastDamageFlags = 0; @@ -865,6 +886,15 @@ public: bool IsInvisible(); Vector GetBodyMoveDirection(); + // Shooting. + Entity_Tear* FireTear(const PosVel& shot, uint32_t fireFlags, Entity* source, float damageMultiplier); + TearParams GetTearHitParams(WeaponType weaponType, float damageScale, int displacement, Entity* source); + Weapon_MultiShotParams GetMultiShotParams(WeaponType weaponType); + static PosVel GetMultiShotPositionVelocity(int loopIndex, WeaponType weaponType, const Vector& shotDirection, + float shotSpeed, const Weapon_MultiShotParams& params); + Vector GetTearMovementInheritance(const Vector& shotDirection, InheritMode mode); + Vector delayed_shoot_direction(); + void ClearReferences() override; bool CanShutDoors() override; bool IsValidTarget(Entity* other) override; @@ -920,7 +950,9 @@ private: void walk_velocity_update(Vector walkInput); bool walking_items_has(); void walk_animation_update(); - void head_animation_update(); + void shoot_input_read(ShootInput& input); + void head_turn(Vector toward); + void charge_store_changed(int effectiveCharge, int oldCharge); void render_back(const Vector& position); ANM2& layer_sprite(int layer); int layer_id(int layer); diff --git a/src/entity_player_frame.cpp b/src/entity_player_frame.cpp index 8bc858c..461423b 100644 --- a/src/entity_player_frame.cpp +++ b/src/entity_player_frame.cpp @@ -1,9 +1,11 @@ #include "entity_player.h" +#include "entity_effect.h" #include "game.h" #include "key_configs.h" #include "log.h" #include "manager.h" #include "menu_manager.h" +#include "platform.h" #include "room.h" #include #include @@ -25,6 +27,34 @@ constexpr float EMOTE_MOVING_SPEED = 0.1f; constexpr float GRAVITY_PULL = 0.225f; constexpr int MARS_TAP_FRAMES_MAX = 10000; +constexpr float FIRE_DIRECTION_MIN = 0.01f; +constexpr float SHOOT_CHARGE_DEAD_ZONE = 0.5f; +constexpr float SHOOT_INPUT_MIN = 0.001f; +constexpr int64_t NANOSECONDS_PER_MILLISECOND = 1000000; +constexpr int BLINK_CLOSED_FRAME = 2; +constexpr int BLINK_CLOSED_FROM = 9; +constexpr int HELD_ITEM_STATE_FRIEND_BALL = 604; +constexpr int HELD_ITEM_STATE_SUPLEX = 709; +constexpr int ITEM_STATE_DOCTORS_REMOTE = 47; +constexpr int ITEM_STATE_SHOOP_DA_WHOOP = 49; +constexpr int POINTY_RIB_BLINK = 7; +constexpr int SHOOP_BLINK = 10; +constexpr int SHOOT_HISTORY_SIZE = 3; +constexpr int SPECIAL_DAILY_BUTTER_BEAN = 41; +constexpr int SUPLEX_LANDING = 2; + +constexpr int COLLECTIBLE_EPIPHORA = 368; +constexpr int COLLECTIBLE_HOW_TO_JUMP = 282; +constexpr int COLLECTIBLE_POINTY_RIB = 544; +constexpr int COLLECTIBLE_URN_OF_SOULS = 640; +constexpr int TRINKET_TEARDROP_CHARM = 139; +// The effects that stop the player shooting while on: Gamekid, My Little Unicorn and Unicorn Stump. +constexpr int NO_SHOOT_EFFECTS[] = {93, 77, 298}; +// The items whose shooting update_shooting does not write yet: No. 2, Maw of the Void, Revelation, Montezuma's +// Revenge, Trinity Shield, the double tap items (GB Bug, Divine Intervention, Hemoptysis, Lil Portal), Spear of +// Destiny, Bone Spurs and Tech.5. +constexpr int SHOOTING_ITEMS[] = {378, 399, 643, 680, 243, 405, 568, 726, 681, 400, 683, 244}; + // The room render passes the player draws its overlays in: the room itself and the water's surface. static bool is_overlay_pass() { @@ -55,6 +85,33 @@ static float action_value(ButtonAction action, int controllerIndex) return value; } +// Whether an action is held on a controller, or on any device for -1, as the input manager's pressed test reads it. +static bool is_action_held(ButtonAction action, int controllerIndex) +{ + KAGE::Input::Manager& input = KAGE::Input::manager; + + for (int i = 0; i < input.get_device_count(); i++) + { + std::shared_ptr device = input.get_device(i); + if (!device || !device->isConnected || (controllerIndex != -1 && device->id != controllerIndex)) continue; + for (int button : g_manager->keyConfigs.binding_get(*device, action)) + if (button != KAGE::Input::BUTTON_NONE && device->is_button_pressed(button)) return true; + } + return false; +} + +// 0067f260 The direction a vector mostly points in, down when it is zero. +Direction vector_to_direction(const Vector& v) +{ + if (std::fabs(v.y) < std::fabs(v.x)) return v.x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT; + return v.y >= 0 ? DIRECTION_DOWN : DIRECTION_UP; +} + +static bool is_zero(Vector v) +{ + return v.x == 0 && v.y == 0; +} + // The axis a vector mostly points along, as a unit vector (Vector::ToCardinal). static Vector vector_cardinal(Vector v) { @@ -130,8 +187,8 @@ Vector Entity_Player::GetShootingJoystick() // movement. Vector Entity_Player::GetBodyMoveDirection() { - if (weapons[0] || weapons[1]) - reconstruction_missing("Entity_Player::GetBodyMoveDirection 00779900 (the weapon's aim)"); + Weapon* weapon = weapons[0] ? weapons[0].get() : weapons[1].get(); + if (weapon && !is_zero(weapon->bodyDirection)) return weapon->bodyDirection; if (HasCollectible(COLLECTIBLE_MONTEZUMAS_REVENGE) && (montezumaLaser || montezumaChargeTimer > 0)) reconstruction_missing("Entity_Player::GetBodyMoveDirection 00779900 (Montezuma's Revenge)"); return recentMovementVector; @@ -348,47 +405,228 @@ void Entity_Player::walk_animation_update() sprite.playbackSpeed = speed; } -// Turns the head to where the player walks, as update_shooting does when nothing is shot, and shows it. -void Entity_Player::head_animation_update() +// Turns the head the way a vector points. +void Entity_Player::head_turn(Vector toward) { - if (headDirectionTime < 0 && (movementVector.x != 0 || movementVector.y != 0)) + headDirection = vector_to_direction(toward); + headAnim = PLAYER_HEAD_ANIMS[headDirection]; +} + +// 007b9f60 Where the mouse aims the player's shots, offline only the keyboard player's while the option is on. Mouse +// aiming (the left button held) is not written yet. +bool Entity_Player::GetMouseAimTarget(Vector&, bool) +{ + if (!g_manager->optionsConfig.isMouseControlEnabled || controllerIndex != 0) return false; + reconstruction_missing("Entity_Player::GetMouseAimTarget 007b9f60 (mouse aiming)"); +} + +// Reads the shoot actions, or the movement ones under the seeds that shoot with movement: whether any is held, +// whether opposite ones are, and the direction the mouse or the shooting joystick gives. Notes the time of a real +// direction, and drops a weak one while a charging weapon holds a charge. +void Entity_Player::shoot_input_read(ShootInput& input) +{ + Game& game = *g_game; + bool isMovementShooting = game.seedEffects.HasSeedEffect(SEED_SHOOT_IN_MOVEMENT_DIRECTION) || + game.seedEffects.HasSeedEffect(SEED_SHOOT_OPPOSITE_MOVEMENT_DIRECTION); + int first = isMovementShooting ? ACTION_LEFT : ACTION_SHOOT_LEFT; + bool isLeft = is_action_held((ButtonAction)first, controllerIndex); + bool isRight = is_action_held((ButtonAction)(first + 1), controllerIndex); + bool isUp = is_action_held((ButtonAction)(first + 2), controllerIndex); + bool isDown = is_action_held((ButtonAction)(first + 3), controllerIndex); + + input.isOpposing = (isDown && isUp) || (isLeft && isRight); + bool isMouse = GetMouseAimTarget(input.direction, false); + input.isPressed = isMouse || isLeft || isRight || isUp || isDown; + if (!isMouse) input.direction = vector_add(input.direction, GetShootingJoystick()); + if (game.deathmatchManager.is_active() && HasEntityFlags(FLAG_CONFUSION)) + input.direction = vector_make(-input.direction.x, -input.direction.y); + + Vector& aim = input.direction; + if (aim.x * aim.x + aim.y * aim.y > SHOOT_INPUT_MIN) + lastShootTime = (int64_t)(GetTimeNs() / NANOSECONDS_PER_MILLISECOND); + + Weapon* weapon = weapons[0] ? weapons[0].get() : weapons[1].get(); + if (!weapon || weapon->GetMaxCharge() <= 0 || weapon->charge <= 0 || input.isOpposing) return; + if (std::sqrt(aim.x * aim.x + aim.y * aim.y) >= SHOOT_CHARGE_DEAD_ZONE) return; + aim = {}; + input.isPressed = false; +} + +// 0077b020 Shooting, each frame: reads the shoot input, turns the head to the shot (or to the walk when idle), counts +// the weapons' delays down and fires them, blinks the eyes while shooting and keeps the recent shot directions. The +// items, item states and characters that change shooting stop the game until reached. +void Entity_Player::update_shooting() +{ + Game& game = *g_game; + bool isInterpolation = HasEntityFlags(FLAG_INTERPOLATION_UPDATE); + bool isInputAllowed = isControlsEnabled && controlsCooldown < 1 && !HasEntityFlags(FLAG_FEAR); + ShootInput input; + + if (target && target->isDead) { - if (std::fabs(movementVector.x) <= std::fabs(movementVector.y)) - { - headAnim = movementVector.y >= 0 ? "HeadDown" : "HeadUp"; - headDirection = movementVector.y >= 0 ? DIRECTION_DOWN : DIRECTION_UP; - } - else - { - headAnim = movementVector.x >= 0 ? "HeadRight" : "HeadLeft"; - headDirection = movementVector.x >= 0 ? DIRECTION_RIGHT : DIRECTION_LEFT; - } + entityCollisionClass = ENTCOLL_ALL; + target = nullptr; } - if (fireBlockCooldown < 1) fireDirection = DIRECTION_NONE; - if (!HasEntityFlags(FLAG_INTERPOLATION_UPDATE)) + if (playerType == PLAYER_THESOUL_B && itemState == 0) isInputAllowed = false; + else if (isInputAllowed) + { + bool isFree = (!isPlayingExtraAnimation && !isPlayingItemAnimation) || bodySprite.IsFinished("LiftItem"); + bool isPresent = entityCollisionClass != ENTCOLL_NONE || suplexState == SUPLEX_LANDING || isCoopGhost || + HasEntityFlags(FLAG_HELD) || temporaryEffects.HasCollectibleEffect(COLLECTIBLE_HOW_TO_JUMP) || + IsHologram(); + if (isFree && isPresent) shoot_input_read(input); + } + + if (variant == PLAYER_VARIANT_COOP_BABY && babySkin == BABY_YBAB) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (the mirrored baby's aim)"); + if (peeBurstCooldown > 0) reconstruction_missing("Entity_Player::update_shooting 0077b020 (Kidney Stone's burst)"); + if ((isPlayingExtraAnimation || isPlayingItemAnimation) && heldEntity && itemState != HELD_ITEM_STATE_FRIEND_BALL && + itemState != HELD_ITEM_STATE_SUPLEX) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (dropping the held entity)"); + + TemporaryEffect* taurus = temporaryEffects.GetCollectibleEffect(COLLECTIBLE_TAURUS); + bool isShootingBlocked = + std::ranges::any_of(NO_SHOOT_EFFECTS, [&](int id) { return temporaryEffects.HasCollectibleEffect(id); }) || + (taurus && taurus->cooldown != 0) || fireBlockCooldown > 0; + if (isShootingBlocked) + { + input.direction = {}; + input.isPressed = false; + } + if (itemStateCooldown > 0) reconstruction_missing("Entity_Player::update_shooting 0077b020 (item state cooldown)"); + if (itemStateCooldown != 0) input.direction = {}; + + Vector shootDirection = input.direction; + bool isShootHeld = itemStateCooldown == 0 && input.isPressed; + bool isDirectionHeld = !is_zero(shootDirection); + if (!isDirectionHeld && isShootHeld) shootDirection = vector_make(-lastDirection.x, -lastDirection.y); + bool isAiming = !is_zero(shootDirection); + bool canFire = isCoopGhost || canShoot; + Vector headAim = shootDirection; + + if ((weapons[1] && weapons[1]->GetMarkedTargetVariant()) || suplexState == SUPLEX_LANDING) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (Marked and suplex targets)"); + if (markedTarget && !isInterpolation) + { + markedTarget->Remove(); + markedTarget = nullptr; + } + + if (game.dailyChallenge._specialDailyId == SPECIAL_DAILY_BUTTER_BEAN) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (the Butter Bean daily)"); + if (game.stageTransition._state == 0 && isInputAllowed && fireBlockCooldown < 1) + shootHeldFrames = isShootHeld ? shootHeldFrames + 1 : 0; + if (megaBlastDuration > 0 || azazelsRageLaser) canFire = false; + canFire = canFire && fireBlockCooldown < 1; + if (isUrethraBlocked && fireBlockCooldown < 1 && isInputAllowed) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (the blocked urethra)"); + if (ibsCharge < 1) + { + isIbsChargeSoundPending = true; + ibsChargeBar = 0; + } + else if (fireBlockCooldown < 1 && isInputAllowed && itemState == 0) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (IBS)"); + + if (headDirectionTime < 0) + { + if (GetFocusEntity()) reconstruction_missing("Entity_Player::update_shooting 0077b020 (aiming at a focus)"); + if (!is_zero(headAim)) head_turn(headAim); + } + if (fireBlockCooldown < 1) + { + fireDirection = DIRECTION_NONE; + if (std::fabs(shootDirection.y) + std::fabs(shootDirection.x) > FIRE_DIRECTION_MIN) + fireDirection = vector_to_direction(shootDirection); + } + + for (int item : SHOOTING_ITEMS) + if (HasCollectible(item)) reconstruction_missing("Entity_Player::update_shooting 0077b020 (shooting items)"); + bool isFireReady = IsExtraAnimationFinished() && game.stageTransition._state == 0 && isInputAllowed; + if (isFireReady && playerType == PLAYER_EVE_B && !isInterpolation) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (Tainted Eve's clots)"); + + uint32_t modifiers = (uint32_t)GetWeaponModifiers(); + if (itemState == ITEM_STATE_DOCTORS_REMOTE || temporaryEffects.HasCollectibleEffect(COLLECTIBLE_NOTCHED_AXE) || + temporaryEffects.HasCollectibleEffect(COLLECTIBLE_URN_OF_SOULS) || playerType == PLAYER_LILITH_B) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (overriding weapons)"); + weapons[0].reset(); + for (int slot = 1; slot < WEAPON_SLOT_COUNT; slot++) + if (weapons[slot]) weapons[slot]->modifiers = modifiers; + for (int slot = 1; slot < WEAPON_SLOT_COUNT; slot++) + if (weapons[slot]) weapons[slot]->Update(isInterpolation); + + if (itemState == ITEM_STATE_SHOOP_DA_WHOOP && isAiming) blinkTime = SHOOP_BLINK; + int blinkFrame = blinkTime >= BLINK_CLOSED_FROM ? BLINK_CLOSED_FRAME : 0; + if (!isInterpolation) { if (blinkTime > -1) blinkTime--; if (headDirectionTime > -1) headDirectionTime--; } - if (variant == PLAYER_VARIANT_PLAYER && IsExtraAnimationFinished()) sprite.SetOverlayFrame(headAnim, 0); + if (float lengthSquared = shootDirection.x * shootDirection.x + shootDirection.y * shootDirection.y; + lengthSquared > 1) + { + float length = std::sqrt(lengthSquared); + shootDirection = vector_make(shootDirection.x / length, shootDirection.y / length); + } + if (HasCollectible(COLLECTIBLE_POINTY_RIB) || + (playerType == PLAYER_LILITH && HasCollectible(COLLECTIBLE_BIRTHRIGHT))) + blinkTime = std::max(blinkTime, POINTY_RIB_BLINK); + doubleTapFrames++; + if (!isInterpolation && IsFrame(2, 0) && + (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_SCISSORS) || HasEntityFlags(FLAG_BLEED_OUT))) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (the headless blood spray)"); + if (HasTrinket(TRINKET_TEARDROP_CHARM)) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (the luck trinket)"); + if (itemState != 0) reconstruction_missing("Entity_Player::update_shooting 0077b020 (item states)"); + if (canFire && isFireReady) trigger_fire_item_effects(shootDirection, isShootHeld); + + if (!isShootHeld && blinkTime < 0 && headDirectionTime < 0 && game.roomTransition.mode == TRANSITION_NONE) + { + Vector body = GetBodyMoveDirection(); + Direction faced = is_zero(body) ? moveDirection : vector_to_direction(body); + headDirection = faced == DIRECTION_NONE ? DIRECTION_DOWN : faced; + headAnim = PLAYER_HEAD_ANIMS[headDirection]; + } + if (!IsFullSpriteRendering()) + { + if (variant != PLAYER_VARIANT_PLAYER || isCoopGhost) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (co-op babies' and ghosts' heads)"); + sprite.SetOverlayFrame(headAnim, blinkFrame); + for (PlayerCostumeMap& map : playerCostumeMap) + if (map.index >= 0 && !map.isBodyLayer) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (head costumes)"); + } + if (isFireReady && HasCollectible(COLLECTIBLE_EPIPHORA)) + reconstruction_missing("Entity_Player::update_shooting 0077b020 (Epiphora)"); + + if (fireBlockCooldown > 0) return; + aimDirection = shootDirection; + areOpposingShootDirectionsPressed = input.isOpposing; + if (!isDirectionHeld) + { + shootDirectionHistory.clear(); + return; + } + lastDirection = shootDirection; + shootDirectionHistory.push_back(shootDirection); + while (shootDirectionHistory.size() > SHOOT_HISTORY_SIZE) shootDirectionHistory.pop_front(); } // 00782af0 The player's frame. Only the frame of a plain character is reconstructed: the base entity moves it, it walks -// by its input, its head turns where it walks and its body animates. Items, effects, held and queued items, extra -// animations and the shooting, bomb, item, pocket and drop actions stop the game until reached. +// by its input, shoots, and its body animates. Items, effects, held and queued items, extra animations and the bomb, +// item, pocket and drop actions stop the game until reached. void Entity_Player::Update() { if (!is_evaluation_plain() || isPlayingExtraAnimation || isPlayingItemAnimation || heldEntity || queuedItem.item) reconstruction_missing("Entity_Player::Update 00782af0 (items, effects and extra animations)"); - for (ButtonAction action : {ACTION_SHOOT_LEFT, ACTION_SHOOT_RIGHT, ACTION_SHOOT_UP, ACTION_SHOOT_DOWN, ACTION_BOMB, - ACTION_ITEM, ACTION_PILL_CARD, ACTION_DROP}) + for (ButtonAction action : {ACTION_BOMB, ACTION_ITEM, ACTION_PILL_CARD, ACTION_DROP}) if (isControlsEnabled && action_value(action, controllerIndex) > 0) - reconstruction_missing( - "Entity_Player::update_shooting 0077b020 (shooting, bombs, items, pockets and drop)"); + reconstruction_missing("Entity_Player::Update 00782af0 (bombs, items, pockets and drop)"); Entity::Update(); update_body_animations(); - head_animation_update(); + update_shooting(); walk_animation_update(); } diff --git a/src/entity_player_health.cpp b/src/entity_player_health.cpp index 089d5ed..495a7b5 100644 --- a/src/entity_player_health.cpp +++ b/src/entity_player_health.cpp @@ -734,3 +734,48 @@ void Entity_Player::SyncConsumables(Entity_Player* target, uint32_t mask) } if (mask & CONSUMABLE_POOP_MANA) target->poopMana = poopMana; } + +// Flashes the charge bar of each active item a store of charges now charges further, with the charge sound (the full +// one when it fills), then lets the bulb trinkets evaluate the stats again. The store is Bethany's soul charges or +// Tainted Bethany's blood charges, given as now and before. +void Entity_Player::charge_store_changed(int effectiveCharge, int oldCharge) +{ + constexpr int SOUND_BATTERY_CHARGE = 171; + constexpr int SOUND_ITEM_RECHARGE = 218; + constexpr uint32_t TRINKET_DIM_BULB = 100; + constexpr uint32_t TRINKET_VIBRANT_BULB = 101; + constexpr int POCKET_SLOT = 3; + constexpr int RED_KEY_SLOT = 2; + + for (int slot = 0; slot < ACTIVE_SLOT_COUNT; slot++) + { + ActiveItemDesc& active = activeItems[slot]; + ItemConfig_Item* item = g_manager->itemConfig.GetCollectible(active.item); + bool isRedRedemptionKey = + slot == RED_KEY_SLOT && active.item == COLLECTIBLE_RED_KEY && g_game->challenge == CHALLENGE_RED_REDEMPTION; + int maxCharge = + slot == POCKET_SLOT || isRedRedemptionKey ? 0 : GetCollectibleMaxCharge(active.item, active.varData); + if (!item || GetActiveMaxCharge(slot) == 1 || maxCharge <= 0) continue; + + int total = GetTotalActiveCharge(slot); + int before = total - effectiveCharge + oldCharge; + if (before >= total || before >= maxCharge) continue; + g_game->hud.FlashChargeBar(this, slot); + sound_play(total < maxCharge ? SOUND_BATTERY_CHARGE : SOUND_ITEM_RECHARGE); + } + if (!HasTrinket(TRINKET_VIBRANT_BULB) && !HasTrinket(TRINKET_DIM_BULB)) return; + cacheFlags |= CACHE_DAMAGE | CACHE_FIREDELAY | CACHE_SHOTSPEED | CACHE_RANGE | CACHE_LUCK; + EvaluateItems(); +} + +// 007d2b70 Bethany's soul charges changed from oldSoulCharge: flashes the actives they now charge further. +void Entity_Player::apply_soul_charge_to_actives(int oldSoulCharge) +{ + if (playerType == PLAYER_BETHANY) charge_store_changed(effectiveSoulCharge, oldSoulCharge); +} + +// 007d2df0 Tainted Bethany's blood charges changed from oldBloodCharge: flashes the actives they now charge further. +void Entity_Player::blood_charge_changed(int oldBloodCharge) +{ + if (playerType == PLAYER_BETHANY_B) charge_store_changed(effectiveBloodCharge, oldBloodCharge); +} diff --git a/src/entity_player_items.cpp b/src/entity_player_items.cpp index ae45493..2b07d49 100644 --- a/src/entity_player_items.cpp +++ b/src/entity_player_items.cpp @@ -467,3 +467,75 @@ RNG& Entity_Player::GetTrinketRNG(int id) if (id < 0 || id >= (int)trinketRNGs.size()) log_printf(LOG_ASSERT, "Trinket ID out of bounds!\n"); return trinketRNGs[std::min((size_t)(uint32_t)id, trinketRNGs.size() - 1)]; } + +// 007c7960 The zodiac sign Zodiac lends this floor, rolled from the stage seed, or none without Zodiac. A zero stage +// seed stops the original in the debugger: here it lends none. +int Entity_Player::GetZodiacEffect() +{ + constexpr std::array ZODIAC_SIGNS = {300, 299, 318, 301, 302, 303, 304, 305, 306, 307, 308, 309}; + constexpr uint32_t ROLL_SHIFTS[] = {2, 7, 9}; + if (!HasCollectible(COLLECTIBLE_ZODIAC)) return 0; + + uint32_t seed = g_game->seedEffects.GetStageSeed(g_game->stage); + if (seed == 0) return 0; + seed ^= seed >> ROLL_SHIFTS[0]; + seed ^= seed << ROLL_SHIFTS[1]; + return ZODIAC_SIGNS[((seed >> ROLL_SHIFTS[2]) ^ seed) % ZODIAC_SIGNS.size()]; +} + +// 007a8350 The effects a new room gives back: Holy Mantle's shield (and the Blanket's in a boss room), the shields +// Holy Mantle stacks and Holy Card keep, Camo Undies, and the effects of the items that last the floor. A shield +// broken in the last room is taken away first. The other items and trinkets with room effects stop the game until +// reached. +void Entity_Player::TriggerNewRoom_TemporaryEffects() +{ + // Redemption, Taurus, Whore of Babylon, Empty Vessel, Scapular, Purity, the crowns and Sol. + constexpr int ROOM_ITEMS[] = {673, 299, 122, 409, 142, 407, 415, 442, 588}; + // Liberty Cap, Broken Syringe, Mom's Lock, Modeling Clay, Umbilical Cord and Dice Bag. + constexpr int ROOM_TRINKETS[] = {32, 132, 153, 166, 33, 154}; + constexpr int BLANKET = 535; + constexpr int CAMO_UNDIES = 497; + constexpr int NULLITEM_HOLY_CARD = 46; + ItemConfig& items = g_manager->itemConfig; + ItemConfig_Item* mantle = items.GetCollectible(COLLECTIBLE_HOLY_MANTLE); + + for (int item : ROOM_ITEMS) + if (HasCollectible(item)) + reconstruction_missing("Entity_Player::TriggerNewRoom_TemporaryEffects 007a8350 (room items)"); + for (int trinket : ROOM_TRINKETS) + if (HasTrinket((uint32_t)trinket)) + reconstruction_missing("Entity_Player::TriggerNewRoom_TemporaryEffects 007a8350 (room trinkets)"); + if (modelingClayEffect != 0 || GetZodiacEffect() == COLLECTIBLE_TAURUS) + reconstruction_missing("Entity_Player::TriggerNewRoom_TemporaryEffects 007a8350 (Modeling Clay and Taurus)"); + + if (holyMantleState == 0) + { + if (HasCollectible(COLLECTIBLE_HOLY_MANTLE) && !temporaryEffects.HasCollectibleEffect(COLLECTIBLE_HOLY_MANTLE)) + temporaryEffects.AddCollectibleEffect(COLLECTIBLE_HOLY_MANTLE, true, 1); + if (HasCollectible(BLANKET) && g_game->room->roomType == ROOM_BOSS) + { + temporaryEffects.AddCollectibleEffect(COLLECTIBLE_HOLY_MANTLE, true, 1); + temporaryEffects.AddCollectibleEffect(BLANKET, true, 1); + } + } + else + { + if (mantle) temporaryEffects.RemoveEffect(mantle, 1); + TemporaryEffect* shield = + temporaryEffects.isDisabled ? nullptr : temporaryEffects.GetCollectibleEffect(COLLECTIBLE_HOLY_MANTLE); + if (!shield || shield->count < 1) RemoveCostume(mantle); + } + + for (int i = 0; mantle && i < holyMantleStacks >> 4; i++) + temporaryEffects.AddEffect(TemporaryEffect(mantle), true, 1); + if (mantle && temporaryEffects.HasNullEffect(NULLITEM_HOLY_CARD)) + temporaryEffects.AddEffect(TemporaryEffect(mantle), true, 1); + if (ItemConfig_Item* undies = items.GetCollectible(CAMO_UNDIES); + undies && variant == PLAYER_VARIANT_PLAYER && HasCollectible(CAMO_UNDIES)) + temporaryEffects.AddEffect(TemporaryEffect(undies), true, 1); + if (!hasCurseMistEffect && !isCoopGhost) + for (int id : levelEffectItems) + if (ItemConfig_Item* item = items.GetCollectible(id)) + temporaryEffects.AddEffect(TemporaryEffect(item), true, 1); + holyMantleState = holyMantleState > 1; +} diff --git a/src/entity_player_missing.cpp b/src/entity_player_missing.cpp index e3b09d2..170fe09 100644 --- a/src/entity_player_missing.cpp +++ b/src/entity_player_missing.cpp @@ -46,7 +46,6 @@ int Entity_Player::GetActiveItem(int) { reconstruction_missing("Entity_Player::G bool Entity_Player::AreControlsEnabled() { reconstruction_missing("Entity_Player::AreControlsEnabled 00505cc0"); } bool Entity_Player::IsItemQueueEmpty() { reconstruction_missing("Entity_Player::IsItemQueueEmpty 0056ff90"); } void Entity_Player::StopExtraAnimation() { reconstruction_missing("Entity_Player::StopExtraAnimation 0058e230"); } -bool Entity_Player::HasWeaponType(int) { reconstruction_missing("Entity_Player::HasWeaponType 005b1780"); } void Entity_Player::moms_bracelet_grab() { reconstruction_missing("Entity_Player::moms_bracelet_grab 005b1a20"); } void Entity_Player::UseRedKey() { reconstruction_missing("Entity_Player::UseRedKey 005b2360"); } void Entity_Player::use_card_hagalaz(RNG*) { reconstruction_missing("Entity_Player::use_card_hagalaz 005b23f0"); } @@ -78,10 +77,6 @@ ColorMod Entity_Player::get_laser_color_copy() { reconstruction_missing("Entity_Player::get_laser_color_copy 00665c20"); } -uint32_t Entity_Player::get_grid_collision_at(Vector) -{ - reconstruction_missing("Entity_Player::get_grid_collision_at 006b5fd0"); -} bool Entity_Player::HasFullHearts() { reconstruction_missing("Entity_Player::HasFullHearts 006dacd0"); } void Entity_Player::set_last_damage(uint64_t, const EntityRef&) { @@ -90,7 +85,6 @@ void Entity_Player::set_last_damage(uint64_t, const EntityRef&) void Entity_Player::SetSoulCharge(int) { reconstruction_missing("Entity_Player::SetSoulCharge 006f0020"); } void Entity_Player::SetBloodCharge(int) { reconstruction_missing("Entity_Player::SetBloodCharge 006f0030"); } PocketItem& Entity_Player::GetPocketItem(int) { reconstruction_missing("Entity_Player::GetPocketItem 00753900"); } -void Entity_Player::EnableWeaponType(int, bool) { reconstruction_missing("Entity_Player::EnableWeaponType 00753980"); } void Entity_Player::QueueExtraAnimation(std::string_view) { reconstruction_missing("Entity_Player::QueueExtraAnimation 007539c0"); @@ -169,26 +163,14 @@ bool Entity_Player::TryRemoveSmeltedTrinket(uint32_t) } bool Entity_Player::replace_trinket() { reconstruction_missing("Entity_Player::replace_trinket 00772530"); } void Entity_Player::SetFullHearts() { reconstruction_missing("Entity_Player::SetFullHearts 007791f0"); } -Entity* Entity_Player::GetFocusEntity() { reconstruction_missing("Entity_Player::GetFocusEntity 00779320"); } -int Entity_Player::GetWeaponModifiers() { reconstruction_missing("Entity_Player::GetWeaponModifiers 00779a20"); } -void Entity_Player::update_shooting() { reconstruction_missing("Entity_Player::update_shooting 0077b020"); } TearFlags Entity_Player::GetBombFlags(bool) { reconstruction_missing("Entity_Player::GetBombFlags 00780560"); } TearFlags Entity_Player::check_bomb_tearflags(const TearFlags&) { reconstruction_missing("Entity_Player::check_bomb_tearflags 00780ec0"); } void Entity_Player::update_bomb_input() { reconstruction_missing("Entity_Player::update_bomb_input 00780f40"); } -void Entity_Player::trigger_fire_item_effects(Vector, bool) -{ - reconstruction_missing("Entity_Player::trigger_fire_item_effects 007826d0"); -} const char* Entity_Player::GetDeathAnimName() { reconstruction_missing("Entity_Player::GetDeathAnimName 007828f0"); } -Entity* Entity_Player::GetActiveWeaponEntity() -{ - reconstruction_missing("Entity_Player::GetActiveWeaponEntity 00782a40"); -} uint32_t Entity_Player::CanTurnHead() { reconstruction_missing("Entity_Player::CanTurnHead 00782a60"); } -float Entity_Player::FireDelay() { reconstruction_missing("Entity_Player::FireDelay 00782a70"); } void Entity_Player::RemoveCollectibleByHistoryIndex(int, bool) { reconstruction_missing("Entity_Player::RemoveCollectibleByHistoryIndex 0078fec0"); @@ -235,10 +217,6 @@ void Entity_Player::ShootCandle(Vector) { reconstruction_missing("Entity_Player: int Entity_Player::GetTrinket(uint32_t) { reconstruction_missing("Entity_Player::GetTrinket 007a6430"); } void Entity_Player::room_exit(bool) { reconstruction_missing("Entity_Player::room_exit 007a6680"); } void Entity_Player::room_enter() { reconstruction_missing("Entity_Player::room_enter 007a6c50"); } -void Entity_Player::TriggerNewRoom_TemporaryEffects() -{ - reconstruction_missing("Entity_Player::TriggerNewRoom_TemporaryEffects 007a8350"); -} void Entity_Player::TriggerRoomClear() { reconstruction_missing("Entity_Player::TriggerRoomClear 007a8fd0"); } bool Entity_Player::HasPlayerForm(int) { reconstruction_missing("Entity_Player::HasPlayerForm 007aa7c0"); } bool Entity_Player::CanAddCollectible(int) { reconstruction_missing("Entity_Player::CanAddCollectible 007aa800"); } @@ -292,10 +270,6 @@ void Entity_Player::TryRemoveNullCostume(int) reconstruction_missing("Entity_Player::TryRemoveNullCostume 007ad400"); } uint32_t Entity_Player::GetMaxPocketItems() { reconstruction_missing("Entity_Player::GetMaxPocketItems 007ad440"); } -void Entity_Player::stop_costume_item_anims() -{ - reconstruction_missing("Entity_Player::stop_costume_item_anims 007ad4e0"); -} void Entity_Player::ClearCollectibleAnim(int) { reconstruction_missing("Entity_Player::ClearCollectibleAnim 007ad5a0"); @@ -337,10 +311,6 @@ void Entity_Player::TryDecreaseGlowingHourglassUses(int, bool) { reconstruction_missing("Entity_Player::TryDecreaseGlowingHourglassUses 007b9e10"); } -bool Entity_Player::GetMouseAimTarget(Vector&, bool) -{ - reconstruction_missing("Entity_Player::GetMouseAimTarget 007b9f60"); -} void Entity_Player::update_baby_skin_effects() { reconstruction_missing("Entity_Player::update_baby_skin_effects 007ba2b0"); @@ -372,7 +342,6 @@ bool Entity_Player::HasInvincibility(uint64_t, const EntityRef&) reconstruction_missing("Entity_Player::HasInvincibility 007c3100"); } bool Entity_Player::HasPoisonImmunity() { reconstruction_missing("Entity_Player::HasPoisonImmunity 007c3320"); } -bool Entity_Player::CanCrushRocks() { reconstruction_missing("Entity_Player::CanCrushRocks 007c3380"); } bool Entity_Player::CanPickRedHearts() { reconstruction_missing("Entity_Player::CanPickRedHearts 007c3410"); } bool Entity_Player::CanPickSoulHearts() { reconstruction_missing("Entity_Player::CanPickSoulHearts 007c3460"); } bool Entity_Player::CanPickBlackHearts() { reconstruction_missing("Entity_Player::CanPickBlackHearts 007c3550"); } @@ -387,7 +356,6 @@ bool Entity_Player::CanUsePill(int) { reconstruction_missing("Entity_Player::Can void Entity_Player::UsePill(int, int, uint32_t) { reconstruction_missing("Entity_Player::UsePill 007c4180"); } void Entity_Player::AddDeadEyeCharge() { reconstruction_missing("Entity_Player::AddDeadEyeCharge 007c78b0"); } void Entity_Player::ClearDeadEyeCharge() { reconstruction_missing("Entity_Player::ClearDeadEyeCharge 007c78e0"); } -int Entity_Player::GetZodiacEffect() { reconstruction_missing("Entity_Player::GetZodiacEffect 007c7960"); } void Entity_Player::update_purity_glow() { reconstruction_missing("Entity_Player::update_purity_glow 007c7c60"); } void Entity_Player::trigger_immaculate_conception(bool) { @@ -481,19 +449,11 @@ int Entity_Player::GetEffectiveSoulCharge() { reconstruction_missing("Entity_Player::GetEffectiveSoulCharge 007d2b50"); } -void Entity_Player::apply_soul_charge_to_actives(int) -{ - reconstruction_missing("Entity_Player::apply_soul_charge_to_actives 007d2b70"); -} void Entity_Player::AddBloodCharge(int) { reconstruction_missing("Entity_Player::AddBloodCharge 007d2d40"); } int Entity_Player::GetEffectiveBloodCharge() { reconstruction_missing("Entity_Player::GetEffectiveBloodCharge 007d2dd0"); } -void Entity_Player::blood_charge_changed(int) -{ - reconstruction_missing("Entity_Player::blood_charge_changed 007d2df0"); -} void Entity_Player::AddRottenHearts(int, bool) { reconstruction_missing("Entity_Player::AddRottenHearts 007d2fc0"); } bool Entity_Player::CanPickRottenHearts() { reconstruction_missing("Entity_Player::CanPickRottenHearts 007d3180"); } void Entity_Player::UpdateBookOfVirtues(bool) { reconstruction_missing("Entity_Player::UpdateBookOfVirtues 007d3200"); } diff --git a/src/entity_player_weapons.cpp b/src/entity_player_weapons.cpp new file mode 100644 index 0000000..b48706e --- /dev/null +++ b/src/entity_player_weapons.cpp @@ -0,0 +1,483 @@ +#include "entity_effect.h" +#include "entity_player.h" +#include "entity_tear.h" +#include "game.h" +#include "log.h" +#include "lua_engine.h" +#include "manager.h" +#include "menu_manager.h" +#include "room.h" +#include +#include + +constexpr float CROSS_EYED_ANGLE = 0.7853982f; +constexpr float DEAD_EYE_STEP = 0.125f; +constexpr float DEGREES_TO_RADIANS = 0.017453292f; +constexpr float DEGREES_PER_RADIAN = 57.295776f; +constexpr float DUNGEON_TEAR_HEIGHT_MAX = -5.1f; +constexpr float DUNGEON_TEAR_OFFSET_Y = -18; +constexpr float EXPLOSIVE_TEAR_SCALE = 0.5f; +constexpr float INHERIT_SCALE = 0.6f; +constexpr float LANE_HALF_ARC = 90; +constexpr float LANE_SPREAD_X = 1.15f; +constexpr float LANE_SPREAD_Y = 0.8f; +constexpr float QUADSPLIT_TEAR_SCALE = 1.2f; +constexpr float RANDOM_UNIT = 2.3283064e-10f; +constexpr float SPREAD_CLAMP = 90; +constexpr float TEAR_FALL_SPREAD = 0.2f; +constexpr float TEAR_SCALE_DAMAGE = 0.01f; +constexpr float TEAR_SCALE_MIN = 0.01f; +constexpr float TEAR_SCALE_ROOT = 0.23f; +constexpr float TEAR_SCALE_SIZE = 0.55f; +constexpr float HOLOGRAM_TEAR_ALPHA = 0.2f; +constexpr int TINT_ALPHA = 3; +constexpr float WIZ_EYE_ANGLE = 45; +// How much each extra tear widens a volley's tears and lasers, by what adds it, and how the other weapons follow. +constexpr float SPREAD_ITEM_LASER = 2.333f; +constexpr float SPREAD_ITEM_TEARS = 2.167f; +constexpr float SPREAD_LUNG_LASER = 2.7f; +constexpr float SPREAD_LUNG_TEARS = 2.4f; +constexpr float SPREAD_MULTIPLIER_LASER = 2.33f; +constexpr float SPREAD_MULTIPLIER_TEARS = 2.17f; +constexpr float SPREAD_TWINS_TEARS = 0.4f; +constexpr float SPREAD_WIZ_LASER = 3; +constexpr float SPREAD_KNIFE_SCALE = 2.14f; +constexpr float SPREAD_TECH_X_SCALE = 2.4f; +constexpr float SPREAD_BONE_SCALE = 3; +constexpr float MOMS_EYE_CHANCE = 0.5f; +constexpr float MOMS_EYE_LUCK = 0.1f; +constexpr float LOKIS_HORNS_CHANCE = 0.25f; +constexpr float LOKIS_HORNS_LUCK = 0.05f; +constexpr int LUNG_TEARS_PER_COPY = 5; +constexpr int LUNG_RANDOM_ROCKETS = 2; +constexpr int LUNG_RANDOM_LASERS = 3; +constexpr int LUNG_RANDOM_RANGE = 3; +constexpr int EYE_SORE_ROLL_MASK = 3; +constexpr int BOOKWORM_ROLL_MASK = 3; +constexpr int CONJOINED_EXTRA_TEARS = 2; +constexpr float WIZ_EYE_ANGLE_MAX = 55; +constexpr int DEAD_EYE_STEPS = 8; +constexpr int DARK_ARTS_STEPS = 16; +constexpr float DARK_ARTS_STEP = 0.0625f; +constexpr int MAX_TEARS = 16; +constexpr int MAX_EYES = 8; +constexpr int RED_STEW_BLOOD_FRAMES = 90; +constexpr int BABY_TECHNOLOGY = 16; +constexpr int BABY_TWENTY_TWENTY = 65; +constexpr int PLAYERFORM_CONJOINED = 7; +constexpr int PLAYERFORM_BOOKWORM = 10; +constexpr int TRANSFORMATION_COUNT = 3; +constexpr int LUA_CALLBACK_POST_FIRE_TEAR = 61; +constexpr int TEAR_COLOR_PRIORITY = 255; + +constexpr int COLLECTIBLE_20_20 = 245; +constexpr int COLLECTIBLE_ALMOND_MILK = 561; +constexpr int COLLECTIBLE_ANTI_GRAVITY = 222; +constexpr int COLLECTIBLE_BRIMSTONE_WEAPON = 118; +constexpr int COLLECTIBLE_C_SECTION = 678; +constexpr int COLLECTIBLE_CHOCOLATE_MILK = 69; +constexpr int COLLECTIBLE_CURSED_EYE_WEAPON = 316; +constexpr int COLLECTIBLE_DEAD_TOOTH = 446; +constexpr int COLLECTIBLE_DR_FETUS = 52; +constexpr int COLLECTIBLE_EPIC_FETUS = 168; +constexpr int COLLECTIBLE_EVIL_EYE = 410; +constexpr int COLLECTIBLE_EYE_SORE = 558; +constexpr int COLLECTIBLE_INNER_EYE = 2; +constexpr int COLLECTIBLE_LARGE_ZIT = 502; +constexpr int COLLECTIBLE_LEAD_PENCIL = 444; +constexpr int COLLECTIBLE_LOKIS_HORNS = 87; +constexpr int COLLECTIBLE_LUDOVICO = 329; +constexpr int COLLECTIBLE_MARKED = 394; +constexpr int COLLECTIBLE_MOMS_EYE = 55; +constexpr int COLLECTIBLE_MOMS_KNIFE = 114; +constexpr int COLLECTIBLE_MONSTROS_LUNG = 229; +constexpr int COLLECTIBLE_NEPTUNUS = 597; +constexpr int COLLECTIBLE_STAPLER = 708; +constexpr int COLLECTIBLE_STYE = 731; +constexpr int COLLECTIBLE_TECH_X = 395; +constexpr int COLLECTIBLE_TECHNOLOGY = 68; +constexpr int COLLECTIBLE_THE_WIZ = 358; +constexpr int COLLECTIBLE_TRACTOR_BEAM = 397; +constexpr int NULLITEM_REVERSE_HANGED_MAN = 65; +constexpr int NULLITEM_DARK_ARTS = 111; + +// The items GetWeaponModifiers turns into modifier bits, in the order it asks. +constexpr std::pair MODIFIER_ITEMS[] = { + {COLLECTIBLE_CHOCOLATE_MILK, WEAPON_MOD_CHOCOLATE_MILK}, {COLLECTIBLE_CURSED_EYE_WEAPON, WEAPON_MOD_CURSED_EYE}, + {COLLECTIBLE_BRIMSTONE_WEAPON, WEAPON_MOD_BRIMSTONE}, {COLLECTIBLE_MONSTROS_LUNG, WEAPON_MOD_MONSTROS_LUNG}, + {COLLECTIBLE_LUDOVICO, WEAPON_MOD_LUDOVICO_TECHNIQUE}, {COLLECTIBLE_ANTI_GRAVITY, WEAPON_MOD_ANTI_GRAVITY}, + {COLLECTIBLE_TRACTOR_BEAM, WEAPON_MOD_TRACTOR_BEAM}, {COLLECTIBLE_NEPTUNUS, WEAPON_MOD_NEPTUNUS}}; +// The items whose copies past the first each add a tear to the volley. +constexpr int SPREAD_ITEMS[] = {COLLECTIBLE_TECHNOLOGY, COLLECTIBLE_MOMS_KNIFE, COLLECTIBLE_DR_FETUS, + COLLECTIBLE_EPIC_FETUS, COLLECTIBLE_LUDOVICO, COLLECTIBLE_TECH_X}; + +// A vector turned by an angle in radians. +static Vector vector_rotate(Vector v, float radians) +{ + float cosine = std::cos(radians); + float sine = std::sin(radians); + return vector_make(v.x * cosine - v.y * sine, v.y * cosine + v.x * sine); +} + +static Vector vector_scale(Vector v, float scale) { return vector_make(v.x * scale, v.y * scale); } + +// The weapon in charge: the one overriding the rest, or the main one. +static Weapon* weapon_main(std::array& weapons) +{ + return weapons[0] ? weapons[0].get() : weapons[1].get(); +} + +// 005b1780 Whether the player has a weapon type. +bool Entity_Player::HasWeaponType(int weaponType) +{ + return weaponType >= 0 && weaponType < WEAPON_TYPE_COUNT && weaponTypes[weaponType]; +} + +// 00753980 Gives or takes a weapon type, which EvaluateItems makes weapons of. Out of range types write past the array +// in the original: here they are ignored. +void Entity_Player::EnableWeaponType(int weaponType, bool isSet) +{ + if (weaponType >= 0 && weaponType < WEAPON_TYPE_COUNT) weaponTypes[weaponType] = isSet; +} + +// 00779320 What the camera and the head follow: the Marked target, or what a weapon (past the overriding slot) aims. +Entity* Entity_Player::GetFocusEntity() +{ + if (markedTarget) return markedTarget; + for (int slot = 1; slot < WEAPON_SLOT_COUNT; slot++) + if (Entity* focus = weapons[slot] ? weapons[slot]->GetFocusEntity() : nullptr) return focus; + return nullptr; +} + +// 00779a20 The modifier bits the player's items, Tainted Azazel's sneeze and C Section give its weapons. +int Entity_Player::GetWeaponModifiers() +{ + uint32_t modifiers = 0; + + for (auto [item, modifier] : MODIFIER_ITEMS) + if (HasCollectible(item)) modifiers |= modifier; + if (HasCollectible(COLLECTIBLE_SOY_MILK) || HasCollectible(COLLECTIBLE_ALMOND_MILK)) + modifiers |= WEAPON_MOD_SOY_MILK; + if (playerType == PLAYER_AZAZEL_B) modifiers |= WEAPON_MOD_AZAZELS_SNEEZE; + if (HasCollectible(COLLECTIBLE_C_SECTION)) modifiers |= WEAPON_MOD_C_SECTION; + return (int)modifiers; +} + +// 00782a40 The entity the weapon in charge fires as, if any. +Entity* Entity_Player::GetActiveWeaponEntity() +{ + Weapon* weapon = weapon_main(weapons); + return weapon ? weapon->GetMainEntity() : nullptr; +} + +// 00782a70 The fire delay of the weapon in charge. +float Entity_Player::FireDelay() +{ + Weapon* weapon = weapon_main(weapons); + return weapon ? weapon->fireDelay : 0; +} + +// 00753940 The shot direction of a few frames ago, as weapons aim with it: the oldest kept, or the last one. +Vector Entity_Player::delayed_shoot_direction() +{ + return shootDirectionHistory.empty() ? lastDirection : shootDirectionHistory.front(); +} + +// 007ad4e0 Stops the item animations of the costumes the player wears, unless it is a co-op ghost. +void Entity_Player::stop_costume_item_anims() +{ + if (isCoopGhost) return; + for (PlayerCostumeMap& map : playerCostumeMap) + if (map.index >= 0) costumeSpriteDescs[map.index].isItemAnimPlay = false; +} + +// 007826d0 What firing does each frame: the items that react to shots (not written yet), then the weapon in charge +// fires, or every weapon does. Offline every player is local, so the deathmatch's check is not written yet. +void Entity_Player::trigger_fire_item_effects(Vector direction, bool isShotFired) +{ + if (g_game->deathmatchManager.is_active()) + reconstruction_missing("Entity_Player::trigger_fire_item_effects 007826d0 (deathmatch)"); + if (HasCollectible(COLLECTIBLE_DEAD_TOOTH) || HasCollectible(COLLECTIBLE_LARGE_ZIT)) + reconstruction_missing("Entity_Player::trigger_fire_item_effects 007826d0 (Dead Tooth and Large Zit)"); + + bool isInterpolated = HasEntityFlags(FLAG_INTERPOLATION_UPDATE); + if (weapons[0]) + { + weapons[0]->Fire(direction, isShotFired, isInterpolated); + return; + } + for (int slot = 1; slot < WEAPON_SLOT_COUNT; slot++) + if (weapons[slot]) weapons[slot]->Fire(direction, isShotFired, isInterpolated); +} + +// 007aaea0 The share of the player's movement its shots carry: twice six tenths of its last velocity, without the part +// against the shot. None while Marked aims or tears leave from a shifted head, unless always asked. +Vector Entity_Player::GetTearMovementInheritance(const Vector& shotDirection, InheritMode mode) +{ + bool isShifted = + (tearsOffset.x != 0 || tearsOffset.y != 0) && (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_SCISSORS) || + temporaryEffects.HasCollectibleEffect(COLLECTIBLE_DECAP_ATTACK)); + if (mode == INHERIT_CHECKED && ((HasCollectible(COLLECTIBLE_MARKED) && markedTarget) || isShifted)) return {}; + + Vector inherited = vector_make(lastVelocity.x * INHERIT_SCALE, lastVelocity.y * INHERIT_SCALE); + inherited = vector_make(inherited.x + inherited.x, inherited.y + inherited.y); + if (shotDirection.x == 0 && shotDirection.y == 0) return inherited; + + float length = std::sqrt(shotDirection.x * shotDirection.x + shotDirection.y * shotDirection.y); + Vector normal = length > 0 ? vector_scale(shotDirection, 1 / length) : shotDirection; + float along = inherited.x * normal.x + inherited.y * normal.y; + Vector projection = vector_scale(normal, along); + if (projection.y * shotDirection.y + projection.x * shotDirection.x < 0) + inherited = vector_make(inherited.x - projection.x, inherited.y - projection.y); + return inherited; +} + +// 00781b90 How the player's volleys spread: extra tears for each copy of the weapon items past the first, Monstro's +// Lung, Mutant Spider, Inner Eye, 20/20 and Bookworm's chance, The Wiz's eyes, Conjoined's cross-eyed pair, Mom's Eye +// and Loki's Horns' backward and sideways shots, and Eye Sore's and the Lung's random ones. +Weapon_MultiShotParams Entity_Player::GetMultiShotParams(WeaponType weaponType) +{ + Weapon_MultiShotParams params; + int extraTears = 0; + + for (int item : SPREAD_ITEMS) extraTears += std::max(0, GetCollectibleNum(item) - 1); + if (extraTears != 0) + { + params.numTears = (short)(params.numTears + extraTears); + params.spreadAngleLaser += (float)extraTears * SPREAD_ITEM_LASER; + params.spreadAngleTears += (float)extraTears * SPREAD_ITEM_TEARS; + } + int lungTears = std::max(0, GetCollectibleNum(COLLECTIBLE_MONSTROS_LUNG) - 1); + if (lungTears != 0) + { + params.numTears = (short)(params.numTears + lungTears * LUNG_TEARS_PER_COPY); + params.spreadAngleLaser += (float)lungTears * SPREAD_LUNG_LASER; + params.spreadAngleTears += (float)lungTears * SPREAD_LUNG_TEARS; + } + + int spiders = GetCollectibleNum(COLLECTIBLE_MUTANT_SPIDER) + (playerType == PLAYER_KEEPER_B); + int innerEyes = temporaryEffects.HasNullEffect(NULLITEM_REVERSE_HANGED_MAN) + (playerType == PLAYER_KEEPER) + + GetCollectibleNum(COLLECTIBLE_INNER_EYE) + + temporaryEffects.HasCollectibleEffect(COLLECTIBLE_INNER_EYE); + int twins = temporaryEffects.HasCollectibleEffect(COLLECTIBLE_20_20) + GetCollectibleNum(COLLECTIBLE_20_20) + + (babySkin == BABY_TWENTY_TWENTY); + bool isMultiplied = spiders != 0 || innerEyes != 0; + if (isMultiplied) + { + int extra = spiders * 2 + 1 + innerEyes; + params.numTears = (short)(params.numTears + extra); + params.spreadAngleLaser += (float)extra * SPREAD_MULTIPLIER_LASER; + params.spreadAngleTears += (float)extra * SPREAD_MULTIPLIER_TEARS; + } + if (twins != 0) params.numTears = (short)(params.numTears + twins - (isMultiplied ? 1 : 0)); + + bool isBookwormShot = weaponType != WEAPON_LUDOVICO_TECHNIQUE && !hasCurseMistEffect && !isCoopGhost && + playerForms[PLAYERFORM_BOOKWORM] >= TRANSFORMATION_COUNT && + (Random() & BOOKWORM_ROLL_MASK) == 0; + if (isBookwormShot) params.numTears++; + if (isBookwormShot || twins != 0) + { + params.spreadAngleTears *= SPREAD_TWINS_TEARS; + params.spreadAngleLaser += (float)twins + (float)twins; + } + + int wizards = temporaryEffects.HasCollectibleEffect(COLLECTIBLE_THE_WIZ) + GetCollectibleNum(COLLECTIBLE_THE_WIZ); + int tears = params.numTears; + if (wizards != 0) + { + params.numEyesActive = std::min(params.numEyesActive + wizards, MAX_EYES); + params.spreadAngleLaser += (float)wizards * SPREAD_WIZ_LASER; + tears = (short)(params.numTears + wizards); + if (tears % params.numEyesActive != 0) + tears = (short)(tears + params.numEyesActive - tears % params.numEyesActive); + params.multiEyeAngle = std::min((float)wizards * WIZ_EYE_ANGLE, WIZ_EYE_ANGLE_MAX); + } + if (!hasCurseMistEffect && !isCoopGhost && playerForms[PLAYERFORM_CONJOINED] >= TRANSFORMATION_COUNT) + { + params.isCrossEyed = wizards == 0; + tears = (short)(tears + CONJOINED_EXTRA_TEARS); + } + + tears = std::min(tears, MAX_TEARS); + params.numLanesPerEye = (short)(tears / params.numEyesActive); + params.spreadAngleKnife = params.spreadAngleLaser * SPREAD_KNIFE_SCALE; + params.numTears = (short)(params.numLanesPerEye * params.numEyesActive); + params.spreadAngleTechX = std::min(params.spreadAngleTears * SPREAD_TECH_X_SCALE, SPREAD_CLAMP); + params.spreadAngleTears = std::min(params.spreadAngleTears, SPREAD_CLAMP); + params.spreadAngleLaser = std::min(params.spreadAngleLaser, SPREAD_CLAMP); + + bool isMomsEye = HasCollectible(COLLECTIBLE_MOMS_EYE); + bool isLokisHorns = HasCollectible(COLLECTIBLE_LOKIS_HORNS); + bool isLung = HasCollectible(COLLECTIBLE_MONSTROS_LUNG); + if (weaponType == WEAPON_LUDOVICO_TECHNIQUE) + { + params.isShootingBackwards = isMomsEye || isLokisHorns; + params.isShootingSideways = isLokisHorns; + } + else if ((isMomsEye && (float)Random() * RANDOM_UNIT < luck * MOMS_EYE_LUCK + MOMS_EYE_CHANCE) || + (isLokisHorns && (float)Random() * RANDOM_UNIT < luck * LOKIS_HORNS_LUCK + LOKIS_HORNS_CHANCE)) + { + params.isShootingBackwards = true; + params.isShootingSideways = isLokisHorns; + } + + if (HasCollectible(COLLECTIBLE_EYE_SORE)) + { + uint32_t first = Random(); + uint32_t second = Random(); + params.numRandomDirTears = (short)std::max(0, (int)(first & EYE_SORE_ROLL_MASK) - EYE_SORE_ROLL_MASK + + (int)(second & EYE_SORE_ROLL_MASK)); + } + else if (isLung && weaponType == WEAPON_ROCKETS) + params.numRandomDirTears = (short)(Random() % LUNG_RANDOM_RANGE + LUNG_RANDOM_ROCKETS); + else if (isLung && (weaponType == WEAPON_BRIMSTONE || weaponType == WEAPON_TECH_X)) + params.numRandomDirTears = (short)(Random() % LUNG_RANDOM_RANGE + LUNG_RANDOM_LASERS); + return params; +} + +// 00782160 Where shot loopIndex of a volley starts and how fast it goes: the eyes fan out over The Wiz's angle, the +// lanes of an eye spread over the weapon's angle (tears, Tech X and bombs also start along an arc), and Conjoined's +// last two shots go off at 45 degrees. +PosVel Entity_Player::GetMultiShotPositionVelocity(int loopIndex, WeaponType weaponType, const Vector& shotDirection, + float shotSpeed, const Weapon_MultiShotParams& params) +{ + float spreadAngle = params.spreadAngleTears; + if (weaponType == WEAPON_LASER || weaponType == WEAPON_BRIMSTONE) spreadAngle = params.spreadAngleLaser; + else if (weaponType == WEAPON_TECH_X) spreadAngle = params.spreadAngleTechX; + else if (weaponType == WEAPON_KNIFE) spreadAngle = params.spreadAngleKnife; + else if (weaponType == WEAPON_BONE) spreadAngle = params.spreadAngleKnife * SPREAD_BONE_SCALE; + + PosVel shot; + if (params.isCrossEyed && loopIndex >= params.numTears - 2) + { + float angle = loopIndex == params.numTears - 1 ? CROSS_EYED_ANGLE : -CROSS_EYED_ANGLE; + shot.velocity = vector_scale(vector_rotate(shotDirection, angle), shotSpeed); + return shot; + } + + float eyeAngle = 0; + if (params.numEyesActive > 1) + { + float t = std::clamp((float)(loopIndex % params.numEyesActive) / ((float)params.numEyesActive - 1), 0.0f, 1.0f); + eyeAngle = (params.multiEyeAngle + params.multiEyeAngle) * t - params.multiEyeAngle; + } + Vector aimed = vector_rotate(shotDirection, eyeAngle * DEGREES_TO_RADIANS); + shot.velocity = vector_scale(aimed, shotSpeed); + if (params.numLanesPerEye <= 1) return shot; + + float lane = std::clamp((float)(loopIndex / params.numEyesActive) / ((float)params.numLanesPerEye - 1), 0.0f, 1.0f); + if (weaponType == WEAPON_TEARS || weaponType == WEAPON_TECH_X || weaponType == WEAPON_BOMBS) + { + float arc = (lane * (LANE_HALF_ARC + LANE_HALF_ARC) - LANE_HALF_ARC) * DEGREES_TO_RADIANS; + float length = std::sqrt(aimed.y * aimed.y + aimed.x * aimed.x); + Vector offset = vector_make(std::cos(arc) * LANE_SPREAD_X * length, std::sin(arc) * LANE_SPREAD_Y * length); + shot.position = vector_rotate(offset, std::atan2(aimed.y, aimed.x) * DEGREES_PER_RADIAN * DEGREES_TO_RADIANS); + } + shot.velocity = + vector_rotate(shot.velocity, ((spreadAngle + spreadAngle) * lane - spreadAngle) * DEGREES_TO_RADIANS); + return shot; +} + +// 007bf6c0 What a tear from the player is fired with: its stats, flags and color, the eye it leaves from, and a scale +// from its damage. Only a plain player's tears are written yet: items, effects, familiars and other characters stop the +// game until reached. +TearParams Entity_Player::GetTearHitParams(WeaponType weaponType, float damageScale, int displacement, Entity* source) +{ + if ((source && source->IsFamiliar()) || !is_evaluation_plain() || redStewBonusDuration > RED_STEW_BLOOD_FRAMES) + reconstruction_missing("Entity_Player::GetTearHitParams 007bf6c0 (items, effects and familiars)"); + + TearParams params; + params.tearDamage = damageScale * damage; + params.tearHeight = tearHeight; + params.tearFlags = tearFlags; + params.tearColor = tearColor; + float baseDamage = params.tearDamage; + float scaleMultiplier = 1; + + bool isOneEyed = playerType == PLAYER_CAIN || HasCollectible(COLLECTIBLE_LEAD_PENCIL) || + !weaponTypes[WEAPON_TEARS] || HasCollectible(COLLECTIBLE_CURSED_EYE_WEAPON) || + HasCollectible(COLLECTIBLE_STAPLER) || playerType == PLAYER_CAIN_B; + bool isLeftEye = displacement < 0 || (isOneEyed && (Random() & 1) == 0); + params.tearDisplacement = isLeftEye ? -1 : (displacement >= 1 ? 1 : 0); + + if (weaponType == WEAPON_TEARS || weaponType == WEAPON_FETUS) + { + bool isLudovico = params.tearFlags.test(TEAR_LUDOVICO); + if (params.tearFlags.test(TEAR_EXPLOSIVE) && !isLudovico) scaleMultiplier = EXPLOSIVE_TEAR_SCALE; + if (params.tearFlags.test(TEAR_QUADSPLIT) && !isLudovico) params.tearScale *= QUADSPLIT_TEAR_SCALE; + if ((playerType == PLAYER_THEFORGOTTEN || playerType == PLAYER_THEFORGOTTEN_B) && + params.tearVariant != TEAR_SCHYTHE) + params.tearVariant = TEAR_BONE; + if (weaponType == WEAPON_FETUS) params.tearVariant = TEAR_FETUS; + } + + float size = params.tearScale > 1 ? std::log(params.tearScale) + 1 : params.tearScale; + params.tearScale = + (std::sqrt(baseDamage) * TEAR_SCALE_ROOT + size * TEAR_SCALE_SIZE + baseDamage * TEAR_SCALE_DAMAGE) * + scaleMultiplier; + if (IsHologram()) params.tearColor._tint[TINT_ALPHA] = HOLOGRAM_TEAR_ALPHA; + return params; +} + +// 00790af0 Fires a tear with the player's hit params from a shot (from the player's tear offset when it shoots it +// itself): its height, fall, scale, color, range, Dead Eye's (or Dark Arts') glow and an index, updated once and moved +// back a frame. +// The Marked target holds no tear back, and extra shots drop the Tractor Beam and end no streak. The co-op baby's +// lasers, Stye, Evil Eye and the Lua callback are not written yet. +Entity_Tear* Entity_Player::FireTear(const PosVel& shot, uint32_t fireFlags, Entity* source, float damageMultiplier) +{ + if (variant == PLAYER_VARIANT_COOP_BABY && babySkin == BABY_TECHNOLOGY) + reconstruction_missing("Entity_Player::FireTear 00790af0 (the laser baby)"); + + Vector position = shot.position; + if (source && source == this) position = vector_add(position, tearsOffset); + TearParams params = GetTearHitParams(WEAPON_TEARS, damageMultiplier, tearDisplacement, source); + if (HasCollectible(COLLECTIBLE_MARKED)) params.tearFlags.reset(TEAR_WAIT); + if (fireFlags & TEAR_FIRE_NO_TRACTOR_BEAM) params.tearFlags.reset(TEAR_TRACTOR_BEAM); + + EntitySpawn spawn{.position = vector_add(shot.velocity, position), + .velocity = shot.velocity, + .spawner = this, + .type = ENTITY_TEAR, + .variant = params.tearVariant}; + spawn.seed = Random(); + Entity_Tear* tear = g_game->Spawn(spawn)->ToTear(); + tear->velocity = vector_scale(tear->velocity, params.speedMultiplier); + tear->height = params.tearHeight; + tear->posOffset.y = tear->get_height_offset_y(params.tearHeight); + if (g_game->room->roomType == ROOM_DUNGEON) + { + tear->posOffset.y = DUNGEON_TEAR_OFFSET_Y; + if (params.tearHeight > DUNGEON_TEAR_HEIGHT_MAX) tear->height = DUNGEON_TEAR_HEIGHT_MAX; + } + float fallSpread = params.tearFlags.test(TEAR_POP) ? 0 : (float)Random() * RANDOM_UNIT * TEAR_FALL_SPREAD; + tear->fallingSpeed = fallSpread - tearFallingSpeed; + tear->SetCollisionDamage(params.tearDamage); + tear->SetTearFlags(params.tearFlags); + tear->baseScale = std::max(params.tearScale, TEAR_SCALE_MIN); + tear->fScale = tear->baseScale; + tear->ResetSpriteScale(); + tear->fallingAccel = tearFallingAcceleration; + tear->SetColor(params.tearColor, -1, TEAR_COLOR_PRIORITY, false, true); + tear->tearRange = tearRange; + tear->parent = this; + if (fireFlags & TEAR_FIRE_NO_STREAK_END) tear->isCanTriggerStreakEnd = false; + + float deadEye = deadEyeCharges > 0 ? (float)std::min((int)deadEyeCharges, DEAD_EYE_STEPS) * DEAD_EYE_STEP : 0; + float intensity = deadEye; + if (int darkArts = temporaryEffects.GetNullEffectNum(NULLITEM_DARK_ARTS); darkArts > 0) + intensity = std::max((float)std::min(darkArts, DARK_ARTS_STEPS) * DARK_ARTS_STEP, deadEye); + if (HasCollectible(COLLECTIBLE_STYE)) reconstruction_missing("Entity_Player::FireTear 00790af0 (Stye)"); + if (intensity > 0) tear->SetDeadEyeIntensity(intensity); + tear->mass *= params.massMultiplier; + tear->knockbackMultiplier = params.knockbackMultiplier; + tear->tearIdx = firedTearCount++; + tear->Update(); + tear->pos = vector_make(tear->pos.x - tear->velocity.x, tear->pos.y - tear->velocity.y); + + if (static_cast(g_luaEngine)->enabledCallbacks.test(LUA_CALLBACK_POST_FIRE_TEAR)) + reconstruction_missing("lua_callback_run_post_fire_tear 00863f70"); + if (HasCollectible(COLLECTIBLE_EVIL_EYE) && !(fireFlags & TEAR_FIRE_NO_EVIL_EYE)) + reconstruction_missing("Entity_Player::FireTear 00790af0 (Evil Eye)"); + return tear; +} diff --git a/src/entity_projectile.cpp b/src/entity_projectile.cpp index fd2b118..ed41d39 100644 --- a/src/entity_projectile.cpp +++ b/src/entity_projectile.cpp @@ -89,12 +89,6 @@ void Entity_Projectile::update_height_collision() reconstruction_missing("Entity_Projectile::update_height_collision 0065b500"); } -// 00675fc0 -void Entity_Projectile::SetHeight(float) -{ - reconstruction_missing("Entity_Projectile::SetHeight 00675fc0"); -} - // 0067a080 void Entity_Projectile::Deflect(Entity*, const Vector&) { diff --git a/src/entity_projectile.h b/src/entity_projectile.h index 08cc525..bf8177b 100644 --- a/src/entity_projectile.h +++ b/src/entity_projectile.h @@ -47,7 +47,6 @@ struct Entity_Projectile : Entity void AddProjectileFlags(uint64_t added); void Reflect(Entity* unused, const Vector& newVelocity); void update_height_collision(); - void SetHeight(float height); void Deflect(Entity* newSpawner, const Vector& velocity); void AddChangeFlags(uint64_t added); void AddScale(float amount); diff --git a/src/entity_tear.cpp b/src/entity_tear.cpp index d85e337..efb1b95 100644 --- a/src/entity_tear.cpp +++ b/src/entity_tear.cpp @@ -1,5 +1,857 @@ #include "entity_tear.h" +#include "entity_effect.h" +#include "entity_familiar.h" +#include "entity_player.h" +#include "game.h" +#include "grid_entity.h" #include "log.h" +#include "lua_engine.h" +#include "manager.h" +#include "room.h" +#include "sfx_manager.h" +#include +#include +#include +#include + +constexpr float TEAR_HEIGHT_START = -23; +constexpr float TEAR_DAMAGE_DEFAULT = 3.5f; +constexpr float TEAR_FALL_SPREAD = 0.2f; +constexpr float TEAR_HOMING_FRICTION = 0.85f; +constexpr float TEAR_KNOCKBACK_MULTIPLIER = 1.7f; +constexpr float TEAR_RANGE_DEFAULT = 260; +constexpr float TEAR_SCALE_MIN = 0.01f; +constexpr float TEAR_FLOOR_HEIGHT = -5; +constexpr float TEAR_GRID_HIT_HEIGHT = -60; +constexpr float CRAWLSPACE_OFFSET_Y = -18; +constexpr float CRAWLSPACE_HEIGHT_MAX = -5.1f; +constexpr float CRAWLSPACE_RANGE_SHARE = 0.6f; +constexpr float CRAWLSPACE_SINK_HEIGHT = -10; +constexpr float CRAWLSPACE_SINK_SPEED = 0.5f; +constexpr float CRAWLSPACE_ROOM_MARGIN = -256; +constexpr float CRAWLSPACE_FIRE_RAISE = 4; +constexpr float CRAWLSPACE_LEVEL_SLOPE = 0.05f; +constexpr float GRAVITY_MIN_ACCEL = 0.001f; +constexpr float GRAVITY_PULL = 0.1f; +constexpr float GRAVITY_FALL_DRAG = 0.9f; +constexpr float HOVER_HEIGHT_BOB = 0.5f; +constexpr int HOVER_BOB_FRAMES = 15; +constexpr float ROOM_SLOWDOWN_SCALE = 0.75f; +constexpr float DEGREES_PER_RADIAN = 57.295776f; +constexpr float RANDOM_UNIT_SCALE = 2.3283064e-10f; +constexpr float RANDOM_DIRECTION_HALF_TURN = 3.14f; + +// The height offset a tear flying without gravity draws at: a fixed lift, and a curve near the floor. +constexpr float HOVER_OFFSET_SCALE = 0.4f; +constexpr float HOVER_OFFSET_LIFT = -15; +constexpr float HOVER_FLOOR_DISTANCE = 8.5f; +constexpr float FIXED_HEIGHT_OFFSET = -8; +constexpr float GFUEL_NAIL_OFFSET = -12; + +// The scale each RegularTear%d animation (1 to 13) draws at, the one a tear plays being the first at least its scale +// less the margin. A grown tear scales its layers by its scale over its animation's. +constexpr std::array TEAR_ANIMATION_SCALES = {0.25f, 0.5f, 0.625f, 0.75f, 0.875f, 1.0f, 1.125f, + 1.375f, 1.625f, 1.875f, 2.125f, 2.5f, 2.75f}; +constexpr float TEAR_ANIMATION_MARGIN = 0.05f; +constexpr int TEAR_ANIMATION_BASE = 100; +constexpr int TEAR_ANIMATION_NAME_SIZE = 32; +constexpr float TEAR_EFFECT_SCALE = 0.45f; +// The tear effect sprite's flag for drawing behind the tear. +constexpr unsigned int TEAR_EFFECT_BEHIND = 1 << 13; +constexpr float GFUEL_SIZE_DIVISOR = 3; + +// The splash a dying tear leaves: the poof sizes by its scale, the sounds, and the stains blood tears leave. +constexpr float POOF_SCALE_SMALL = 0.4f; +constexpr float POOF_SCALE_LARGE = 0.8f; +constexpr float POOF_VOLUME_SMALL = 0.85f; +constexpr float POOF_VOLUME_TINY = 0.7f; +constexpr float SWORD_BEAM_VOLUME = 0.3f; +constexpr float SWORD_BEAM_PITCH = 2; +constexpr float SWORD_BEAM_PITCH_SPREAD = 0.5f; +constexpr int SWORD_BEAM_POOF_SUBTYPE = 22; +constexpr float RIGHT_ANGLE = 90; +constexpr int STAIN_COUNT_MAX = 5; +constexpr float STAIN_SPREAD = 24; +constexpr float STAIN_SCALE = 0.3f; +constexpr float STAIN_ALPHA = 0.08f; +constexpr float MASCARA_ALPHA = 0.2f; +constexpr float MASCARA_ALPHA_SPREAD = 0.3f; +constexpr ColorMod STAIN_COLOR = {{0, 0, 0, STAIN_ALPHA}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod NUMBER_ONE_STAIN_COLOR = {{0, 0, 0, 0.5f}, {0, 0, 0, 0}, {150 / 255.0f, 150 / 255.0f, 0}}; +// The tint a room's slowdown (the Broken Watch's) lays over a tear for two frames. +constexpr ColorMod SLOWDOWN_COLOR = {{1, 1, 1.3f, 1}, {0, 0, 0, 0}, {40 / 255.0f, 40 / 255.0f, 40 / 255.0f}}; +constexpr int SLOWDOWN_COLOR_FRAMES = 2; +constexpr int COLOR_PRIORITY_TOP = 255; + +// What the tear's grid hit does to rocks: one hit, two for a strong tear. +constexpr float STRONG_TEAR_DAMAGE = 10; +// The grid path below which a wall the players pass stops tears. +constexpr int GRID_PATH_TEAR_WALL = 3000; +// A tear spawned with FLAG_NO_SPIKE_DAMAGE starts with more friction, easing off over its first updates. +constexpr float LAUNCH_DRAG_TIME = 5; +constexpr float LAUNCH_DRAG_FRICTION = 0.55f; + +constexpr int EFFECT_BLOOD_SPLAT = 7; +constexpr int EFFECT_BULLET_POOF = 11; +constexpr int EFFECT_TEAR_POOF_A = 12; +constexpr int EFFECT_TEAR_POOF_B = 13; +constexpr int EFFECT_TEAR_POOF_SMALL = 79; +constexpr int EFFECT_TEAR_POOF_VERYSMALL = 80; + +constexpr int SOUND_TEAR_FIRE = 153; +constexpr int SOUND_FETUS_FIRE = 237; +constexpr float FETUS_FIRE_PITCH = 1.2f; +constexpr int SOUND_TEAR_IMPACTS = 150; +constexpr int SOUND_SPLATTER = 258; +constexpr int SOUND_SWORD_BEAM_IMPACT = 49; +constexpr int SOUND_TECH_SWORD_BEAM_IMPACT = 134; + +constexpr int COLLECTIBLE_NUMBER_ONE = 6; +constexpr int COLLECTIBLE_EVES_MASCARA = 310; +constexpr int COLLECTIBLE_DEAD_EYE = 373; +constexpr uint32_t CHALLENGE_ONANS_STREAK = 29; + +// Onan's Streak punishes a tear that misses with a hit to its player. +constexpr float STREAK_DAMAGE = 1; +constexpr uint64_t DAMAGE_INVINCIBLE = 1ull << 13; +constexpr int STREAK_DAMAGE_COUNTDOWN = 30; + +constexpr int LUA_CALLBACK_POST_TEAR_INIT = 39; +constexpr int LUA_CALLBACK_POST_TEAR_UPDATE = 40; +constexpr int LUA_CALLBACK_POST_TEAR_RENDER = 41; +constexpr uint32_t GRAPHICS_PREMULTIPLIED_ALPHA = 4; +constexpr const char* GFUEL_NAIL_ANM2 = "gfx/promo/gfuel/bullet tear.anm2"; +constexpr const char* GFUEL_NAIL_BLOOD_ANM2 = "gfx/promo/gfuel/missile.anm2"; + +// The variants whose splash and flight are reconstructed: plain tears and the ones that only change the sprite. +constexpr std::array TEAR_PLAIN_VARIANTS = { + TEAR_BLUE, TEAR_BLOOD, TEAR_LOST_CONTACT, TEAR_CUPID_BLUE, TEAR_CUPID_BLOOD, + TEAR_PUPULA, TEAR_PUPULA_BLOOD, TEAR_GODS_FLESH, TEAR_GODS_FLESH_BLOOD, TEAR_MULTIDIMENSIONAL, + TEAR_GLAUCOMA, TEAR_GLAUCOMA_BLOOD, TEAR_NEEDLE, TEAR_BELIAL, TEAR_HUNGRY, + TEAR_FIST, TEAR_ICE, TEAR_SWORD_BEAM, TEAR_TECH_SWORD_BEAM}; +// The variants whose splash is a bullet poof rather than a tear poof. +constexpr std::array TEAR_BULLET_POOF_VARIANTS = {TEAR_BLOOD, TEAR_CUPID_BLOOD, TEAR_PUPULA_BLOOD, + TEAR_GODS_FLESH_BLOOD, TEAR_GLAUCOMA_BLOOD, TEAR_BELIAL, + TEAR_FIST}; +// The variants that point along their flight. +constexpr std::array TEAR_ROTATED_VARIANTS = { + TEAR_CUPID_BLUE, TEAR_CUPID_BLOOD, TEAR_NAIL, TEAR_PUPULA, TEAR_PUPULA_BLOOD, TEAR_NAIL_BLOOD, TEAR_NEEDLE, + TEAR_EYE, TEAR_EYE_BLOOD, TEAR_COIN, TEAR_FIST, TEAR_ICE, TEAR_KEY, TEAR_KEY_BLOOD, + TEAR_ERASER, TEAR_SWORD_BEAM, TEAR_TECH_SWORD_BEAM}; +// The variants that stain the floor where they splash. +constexpr std::array TEAR_STAINING_VARIANTS = {TEAR_BLUE, TEAR_GLAUCOMA, TEAR_GODS_FLESH, TEAR_HUNGRY}; +// The variants that play BloodTear%d, Tooth%dMove, Rotate%d or Stone%dMove rather than RegularTear%d. +constexpr std::array BLOOD_ANIMATION_VARIANTS = {TEAR_BLOOD, TEAR_CUPID_BLOOD, TEAR_PUPULA_BLOOD, + TEAR_GODS_FLESH_BLOOD, TEAR_EYE_BLOOD, TEAR_GLAUCOMA_BLOOD}; +constexpr std::array STONE_ANIMATION_VARIANTS = {TEAR_STONE, TEAR_BOOGER, TEAR_EGG, + TEAR_RAZOR, TEAR_BONE, TEAR_SPORE}; + +// The splash a dying tear leaves: its poof and its sound. +struct TearSplash +{ + float pitch = 1; + float volume = 1; + int effect = 0; + int sound = 0; + int subType = 0; +}; + +template +static bool is_listed(const std::array& list, int value) +{ + return std::find(list.begin(), list.end(), value) != list.end(); +} + +static Vector vector_add(Vector a, Vector b) +{ + return vector_make(a.x + b.x, a.y + b.y); +} + +static Vector vector_sub(Vector a, Vector b) +{ + return vector_make(a.x - b.x, a.y - b.y); +} + +static float vector_length(Vector v) +{ + return std::sqrt(v.x * v.x + v.y * v.y); +} + +// A random fraction of one, as random_float makes it. +static float random_unit() +{ + return (float)Random() * RANDOM_UNIT_SCALE; +} + +// A random number below max, or 0 for none. +static int random_below(int max) +{ + return max == 0 ? 0 : (int)(Random() % (uint32_t)max); +} + +// A random unit direction, as MusicManager::RandomVector draws it. +static Vector random_direction() +{ + float angle = random_unit() * RANDOM_DIRECTION_HALF_TURN; + angle += angle; + return vector_make(std::cos(angle), std::sin(angle)); +} + +// How much of a per-tick factor is left over a step of timeScale ticks (Math::timescale_factor). +static float timescale_factor(float factor, float timeScale) +{ + return timeScale == 1 ? factor : factor / ((factor + timeScale) - factor * timeScale); +} + +// Whether the current room is a crawlspace, where tears drop under gravity. +static bool is_crawlspace() +{ + return g_game->room->roomType == ROOM_DUNGEON; +} + +// Stops where a mod has a function for one of the tear's Lua callbacks, which LuaEngine does not run yet. +static void lua_callback_check(int callback, const char* name) +{ + if (static_cast(g_luaEngine)->enabledCallbacks[callback]) reconstruction_missing(name); +} + +// Whether the player is another machine's in an online game, whose shots the game fades. +static bool is_remote_player(Entity_Player* player) +{ + NetplayManager& netplay = g_manager->netplayManager; + return player && netplay.is_online() && !netplay.IsIdxLocalPlayer(player->controllerIndex); +} + +// Makes a sprite layer add its light to what is under it. +static void layer_additive_set(ANM2& sprite, int layerId) +{ + LayerState* layer = sprite.GetLayer(layerId); + bool isPremultiplied = g_graphicsManager_flags & GRAPHICS_PREMULTIPLIED_ALPHA; + + layer->blendMode[BLEND_EQUATION] = BLEND_EQUATION_ADD; + layer->blendMode[BLEND_RGB_SOURCE] = isPremultiplied ? BLEND_FACTOR_ONE : BLEND_FACTOR_SRC_ALPHA; + layer->blendMode[BLEND_RGB_DEST] = BLEND_FACTOR_ONE; + layer->blendMode[BLEND_ALPHA_SOURCE] = BLEND_FACTOR_ONE; + layer->blendMode[BLEND_ALPHA_DEST] = BLEND_FACTOR_ONE; +} + +// Plays a sound at a volume and pitch, through the fart seeds. +static void sound_play(int sound, float volume, float pitch) +{ + seed_fart_sound_override(&sound); + g_manager->sfxManager.Play(sound, {.volume = volume, .pitch = pitch}); +} + +// In Onan's Streak, a tear that misses hurts its player. +static void streak_end(Entity_Player& player) +{ + if (g_game->challenge != CHALLENGE_ONANS_STREAK) return; + player.TakeDamage(STREAK_DAMAGE, DAMAGE_INVINCIBLE, EntityRef(), STREAK_DAMAGE_COUNTDOWN); +} + +// 006660a0 Starts a tear 23 high with a slight random fall, base damage and scale, no flags, links or targets, and +// the sprite of its config. The brimstone balloon's glow and the G-Fuel nails' sprites add light. +void Entity_Tear::Init(int entityType, int entityVariant, int entitySubType, uint32_t seed) +{ + Entity::Init(entityType, entityVariant, entitySubType, seed); + if (config) sprite.Load(config->anm2Path, GRAPHICS_LOAD); + entityGridCollisionClass = GRIDCOLL_BULLET; + collisionDamage = TEAR_DAMAGE_DEFAULT; + baseDamage = TEAR_DAMAGE_DEFAULT; + + float fallSpread = random_unit(); + fallingAccel = 0; + height = TEAR_HEIGHT_START; + fallingSpeed = (fallSpread - 0.5f) * TEAR_FALL_SPREAD; + posOffset.y = get_height_offset_y(TEAR_HEIGHT_START); + if (is_crawlspace()) posOffset.y = CRAWLSPACE_OFFSET_Y; + + homingFriction = TEAR_HOMING_FRICTION; + fScale = 1; + baseScale = 1; + rotation = 0; + scaleAnimNum = -1; + knockbackMultiplier = TEAR_KNOCKBACK_MULTIPLIER; + maxHitPoints = 0; + tearFlags.reset(); + waitFrames = 0; + continueVelocity = {}; + hitList.clear(); + posDisplacement = {}; + parentOffset = {}; + stickTarget = nullptr; + stickDiff = {}; + techZeroLaser = nullptr; + techZeroTarget = nullptr; + laserShotLaser = nullptr; + linkPrev = nullptr; + linkNext = nullptr; + + deadEyeIntensity = 0; + isMultidimensionalTouched = false; + isPrismTouched = false; + isFireSoundPending = true; + isCanTriggerStreakEnd = true; + isHovering = false; + isFireSoundMuted = false; + holdOffset = {}; + holdTimer = 0; + popBounceCount = 0; + hitCount = 0; + deathFlags = 0; + if (variant == TEAR_BALLOON_BRIMSTONE) layer_additive_set(sprite, 1); + + orbitAngle = 0; + orbitRadius = 0; + orbitVelocity = {}; + tearRange = TEAR_RANGE_DEFAULT; + tearIdx = -1; + + bool isGFuelNail = (variant == TEAR_NAIL || variant == TEAR_NAIL_BLOOD) && g_game->seedEffects.HasSeedEffect(SEED_G_FUEL); + if (isGFuelNail) + { + sprite.Load(variant == TEAR_NAIL ? GFUEL_NAIL_ANM2 : GFUEL_NAIL_BLOOD_ANM2, GRAPHICS_LOAD); + layer_additive_set(sprite, variant == TEAR_NAIL ? 0 : 1); + } + lua_callback_check(LUA_CALLBACK_POST_TEAR_INIT, "LuaEngine::PostTearInit 008629c0"); +} + +// 006670f0 Flies the tear for a frame, or splashes and removes it once it has died. While held it bobs at its +// parent, and while waiting it hovers until its player stops firing. +void Entity_Tear::Update() +{ + if (isFireSoundPending) + { + play_fire_sound(); + isFireSoundPending = false; + } + if (tearFlags.any()) reconstruction_missing("Entity_Tear::Update 006670f0: the tear flags' effects"); + if (!is_listed(TEAR_PLAIN_VARIANTS, variant)) + reconstruction_missing("Entity_Tear::Update 006670f0: this tear variant's flight and splash"); + + Room& room = *g_game->room; + speedMultiplier = g_game->room->GetTimeScale(this); + if (room.HasSlowDown()) speedMultiplier *= ROOM_SLOWDOWN_SCALE; + if (hold_update()) return; + + if (is_crawlspace() && height >= CRAWLSPACE_HEIGHT_MAX && updateTime > tearRange * CRAWLSPACE_RANGE_SHARE) + { + isDead = true; + deathFlags = TEAR_DEATH_FORCED; + } + wait_update(); + if (laserShotLaser) + { + isVisible = true; + entityCollisionClass = ENTCOLL_ALL; + laserShotLaser->Remove(); + laserShotLaser = nullptr; + } + if (isDead) return death_update(); + + flight_update(); + if (is_crawlspace() && !room.IsPositionInRoom(pos, CRAWLSPACE_ROOM_MARGIN)) Remove(); + if (room.HasSlowDown()) SetColor(SLOWDOWN_COLOR, SLOWDOWN_COLOR_FRAMES, COLOR_PRIORITY_TOP, false, true); + lua_callback_check(LUA_CALLBACK_POST_TEAR_UPDATE, "LuaEngine::PostTearUpdate 00862aa0"); +} + +// Counts down a held tear, pinning it bobbing at its parent and updating it there. Whether it is still held. +// Once the hold ends the tear takes the velocity it was held with. +bool Entity_Tear::hold_update() +{ + if (holdTimer <= 0) return false; + if (--holdTimer == 0) + { + velocity = holdVelocity; + return false; + } + + if (parent) pos = vector_add(parent->pos, holdOffset); + velocity = {}; + SetHeight(height + ((holdTimer / HOVER_BOB_FRAMES & 1) == 0 ? HOVER_HEIGHT_BOB : -HOVER_HEIGHT_BOB)); + Entity::Update(); + return true; +} + +// Counts down a waiting tear, which ends at once when its player stops firing and then flies on with the velocity +// it waited with. It bobs while it waits. +void Entity_Tear::wait_update() +{ + if (waitFrames <= 0) return; + + Entity* owner = parent; + if (owner && owner->type == ENTITY_FAMILIAR) owner = static_cast(owner)->player; + else if (owner && owner->type != ENTITY_PLAYER) owner = nullptr; + Entity_Player* player = owner ? owner->ToPlayer() : nullptr; + if (player && player->fireDirection == DIRECTION_NONE) waitFrames = 1; + + if (--waitFrames == 0) + { + velocity = vector_add(velocity, continueVelocity); + continueVelocity = {}; + } + SetHeight(height + ((waitFrames / HOVER_BOB_FRAMES & 1) == 0 ? HOVER_HEIGHT_BOB : -HOVER_HEIGHT_BOB)); +} + +// The splash of a dying tear by its variant: a bullet poof for the blood-like ones, a tear poof sized by its scale +// (the larger one above the floor) for the rest, and the sword beams' own. +static TearSplash splash_get(Entity_Tear& tear) +{ + TearSplash splash; + + if (tear.variant == TEAR_SWORD_BEAM || tear.variant == TEAR_TECH_SWORD_BEAM) + { + splash.sound = tear.variant == TEAR_SWORD_BEAM ? SOUND_SWORD_BEAM_IMPACT : SOUND_TECH_SWORD_BEAM_IMPACT; + splash.pitch = random_unit() * SWORD_BEAM_PITCH_SPREAD + SWORD_BEAM_PITCH; + splash.effect = EFFECT_TEAR_POOF_A; + splash.subType = SWORD_BEAM_POOF_SUBTYPE; + splash.volume = SWORD_BEAM_VOLUME; + } + else if (is_listed(TEAR_BULLET_POOF_VARIANTS, tear.variant)) + { + splash.effect = EFFECT_BULLET_POOF; + splash.sound = SOUND_TEAR_IMPACTS; + } + else if (tear.fScale < POOF_SCALE_SMALL) + { + splash.volume = POOF_VOLUME_TINY; + splash.sound = SOUND_SPLATTER; + splash.effect = EFFECT_TEAR_POOF_VERYSMALL; + } + else if (tear.fScale < POOF_SCALE_LARGE) + { + splash.volume = POOF_VOLUME_SMALL; + splash.sound = SOUND_SPLATTER; + splash.effect = EFFECT_TEAR_POOF_SMALL; + } + else + { + bool isHigh = tear.height <= TEAR_FLOOR_HEIGHT; + splash.sound = isHigh ? SOUND_TEAR_IMPACTS : SOUND_SPLATTER; + splash.effect = isHigh ? EFFECT_TEAR_POOF_A : EFFECT_TEAR_POOF_B; + } + return splash; +} + +// Splashes the dead tear: its sound, its poof in its color at its height, the stains some leave, then removes it. +// Game::Spawn returning nothing crashes the original. This skips the poof. +void Entity_Tear::death_update() +{ + TearSplash splash = splash_get(*this); + if (splash.sound) sound_play(splash.sound, splash.volume, splash.pitch); + + uint32_t seed = Random(); + Entity* poof = g_game->Spawn({.position = pos, .spawner = this, .subType = splash.subType, .type = ENTITY_EFFECT, + .variant = splash.effect, .seed = seed}); + if (poof) + { + poof->posOffset = posOffset; + if (splash.effect != EFFECT_TEAR_POOF_SMALL && splash.effect != EFFECT_TEAR_POOF_VERYSMALL) + { + bool isPupula = variant == TEAR_PUPULA || variant == TEAR_PUPULA_BLOOD; + float scale = fScale * (isPupula ? POOF_SCALE_SMALL : POOF_SCALE_LARGE); + poof->sprite.scale = vector_make(scale, scale); + poof->sprite.rotation = (float)random_below(4) * RIGHT_ANGLE; + } + poof->SetColor(sprite.color, -1, COLOR_PRIORITY_TOP, false, true); + if (is_remote_player(spawnerEntity ? spawnerEntity->ToPlayer() : nullptr)) + reconstruction_missing("Entity_Tear::Update 006670f0: a remote player's faded splash"); + } + if (is_listed(TEAR_STAINING_VARIANTS, variant)) blood_stains_spawn(); + Remove(); +} + +// Leaves up to four faint stains around the splash, Eve's Mascara's darker and Number One's yellow. +void Entity_Tear::blood_stains_spawn() +{ + int count = random_below(STAIN_COUNT_MAX); + Entity_Player* player = GetRootPlayer(); + + for (int i = 0; i < count; i++) + { + uint32_t seed = Random(); + Vector direction = random_direction(); + float distance = random_unit() * STAIN_SPREAD; + Vector position = vector_add(pos, vector_make(direction.x * distance, direction.y * distance)); + Entity* stain = g_game->Spawn( + {.position = position, .type = ENTITY_EFFECT, .variant = EFFECT_BLOOD_SPLAT, .seed = seed}); + if (!stain) continue; + + ColorMod color = STAIN_COLOR; + stain->sprite.scale = vector_make(STAIN_SCALE, STAIN_SCALE); + if (player && player->HasCollectible(COLLECTIBLE_EVES_MASCARA)) + color._tint[3] = random_unit() * MASCARA_ALPHA_SPREAD + MASCARA_ALPHA; + else if (player && player->HasCollectible(COLLECTIBLE_NUMBER_ONE)) color = NUMBER_ONE_STAIN_COLOR; + stain->SetColor(color, -1, COLOR_PRIORITY_TOP, false, true); + stain->Update(); + } +} + +// Flies the living tear: points it along its flight, lets it die on the floor or a wall, sizes its sprite, moves it, +// and lets it fall by its speed and acceleration. +void Entity_Tear::flight_update() +{ + sprite.rotation = 0; + if (is_listed(TEAR_ROTATED_VARIANTS, variant)) + { + Vector direction = velocity; + if (waitFrames >= 1) direction = continueVelocity; + else if (fallingAccel > GRAVITY_MIN_ACCEL) direction.y += fallingSpeed; + sprite.rotation = std::atan2(direction.y, direction.x) * DEGREES_PER_RADIAN; + } + + if (HasEntityFlags(FLAG_NO_SPIKE_DAMAGE)) + { + if (updateTime >= LAUNCH_DRAG_TIME) ClearEntityFlags(FLAG_NO_SPIKE_DAMAGE); + else friction *= updateTime / LAUNCH_DRAG_TIME * (1 - LAUNCH_DRAG_FRICTION) + LAUNCH_DRAG_FRICTION; + } + if (height > TEAR_FLOOR_HEIGHT) floor_hit(); + else grid_hit(); + + if (g_game->deathmatchManager.is_active()) + reconstruction_missing("Entity_Tear::Update 006670f0: the versus mode's tear reflections"); + fScale = std::max(baseScale, TEAR_SCALE_MIN); + ResetSpriteScale(); + if (g_game->seedEffects.HasSeedEffect(SEED_BLACK_ISAAC)) + reconstruction_missing("Entity_Tear::Update 006670f0: Black Isaac's tear color"); + + Vector previous = pos; + Entity::Update(); + posDisplacement = vector_sub(pos, previous); + if (waitFrames >= 1 || isDead || stickTarget) return; + + fallingSpeed = speedMultiplier * GRAVITY_PULL + timescale_factor(GRAVITY_FALL_DRAG, speedMultiplier) * fallingSpeed + + speedMultiplier * fallingAccel; + SetHeight(speedMultiplier * fallingSpeed + height); + if (!is_crawlspace()) return; + + if (fallingAccel >= GRAVITY_MIN_ACCEL) velocity.y += fallingAccel; + else if (height > CRAWLSPACE_SINK_HEIGHT) velocity.y += CRAWLSPACE_SINK_SPEED; + if (g_game->room->IsBeastDungeon()) reconstruction_missing("Entity_Tear::Update 006670f0: the Beast's lava"); +} + +// The tear reached the floor: it dies there, ending its player's streak. +void Entity_Tear::floor_hit() +{ + isDead = true; + deathFlags |= TEAR_DEATH_FLOOR; + apply_death_flag_effects(nullptr); + if (!parent || !isCanTriggerStreakEnd) return; + + if (Entity_Player* player = parent->ToPlayer()) + { + if (player->HasCollectible(COLLECTIBLE_DEAD_EYE)) player->ClearDeadEyeCharge(); + streak_end(*player); + } +} + +// The tear hit the grid, or stands on a wall: it dies, hurting the rocks and poop it touches. Missing anything but +// poop or TNT ends its player's streak. +void Entity_Tear::grid_hit() +{ + Room& room = *g_game->room; + int gridIndex = room.GetGridIndex(pos); + uint32_t collision = room.GetGridCollision(gridIndex); + bool isWall = collision == COLLISION_WALL; + int gridPath = gridIndex >= 0 ? room.gridPaths[gridIndex] : 0; + bool isPlayerWall = collision == COLLISION_WALL_EXCEPT_PLAYER && gridPath < GRID_PATH_TEAR_WALL; + + if (!isCollidesWithGrid) return; + if (height <= TEAR_GRID_HIT_HEIGHT && !isWall && !isPlayerWall) return; + + isDead = true; + deathFlags |= TEAR_DEATH_GRID; + if (isWall || collision == COLLISION_WALL_EXCEPT_PLAYER) deathFlags |= TEAR_DEATH_WALL; + apply_death_flag_effects(nullptr); + try_make_bridges(pos); + if (!parent || !isCanTriggerStreakEnd) return; + + Entity_Player* player = parent->ToPlayer(); + GridEntity* grid = room.GetGridEntity(gridIndex); + if (!player || (grid && (grid->type == GRID_POOP || grid->type == GRID_TNT))) return; + streak_end(*player); + if (player->HasCollectible(COLLECTIBLE_DEAD_EYE)) player->ClearDeadEyeCharge(); +} + +// 00679400 Moves the tear half a step for the frame between updates and places its sprite at the height it will +// fall to. A held tear stays at its parent. +void Entity_Tear::Interpolate() +{ + if (holdTimer > 0) + { + if (parent) pos = vector_add(parent->pos, holdOffset); + return; + } + if (tearFlags.any()) reconstruction_missing("Entity_Tear::Interpolate 00679400: the tear flags' motion"); + + Entity::Interpolate(); + if (waitFrames >= 1 || isDead) return; + posOffset.y = is_crawlspace() ? CRAWLSPACE_OFFSET_Y + : get_height_offset_y(fallingSpeed * speedMultiplier * 0.5f + height); +} + +// 006790c0 Draws the tear with its halo, its tear effect behind or in front, and Dead Eye's glow. +void Entity_Tear::Render(const Vector& offset) +{ + if (!isExists || !isVisible) return; + + renderPosition = vector_add(render_position_get(vector_add(pos, posOffset), RENDER_SNAPPED), offset); + SpriteDraw draw = {renderPosition, {}, {}}; + bool isEffectBehind = tearEffectANM2.bitflags & TEAR_EFFECT_BEHIND; + if (tearFlags[TEAR_GLOW]) tearHaloANM2.Render(draw); + if (tearEffectANM2.isLoaded && isEffectBehind) tearEffectANM2.Render(draw); + if (is_remote_player(spawnerEntity ? spawnerEntity->ToPlayer() : nullptr)) + reconstruction_missing("Entity_Tear::Render 006790c0: a remote player's faded tear"); + + Entity::Render(offset); + if (tearEffectANM2.isLoaded && !isEffectBehind) tearEffectANM2.Render(draw); + if (deadEyeIntensity != 0) deadEyeANM2.Render(draw); + lua_callback_check(LUA_CALLBACK_POST_TEAR_RENDER, "LuaEngine::PostTearRender 00862b80"); +} + +// 00675fa0 Sets the damage it deals, and the damage it started with. +void Entity_Tear::SetCollisionDamage(float damage) +{ + collisionDamage = damage; + baseDamage = damage; +} + +// 006666c0 Removes its lasers and attached effect, lets go of its sprites and links, joining the tears linked on +// either side of it, and removes the rest of a Ludovico chain. +void Entity_Tear::ClearReferences() +{ + if (techZeroLaser) techZeroLaser->Remove(); + if (laserShotLaser) laserShotLaser->Remove(); + Entity::ClearReferences(); + tearHaloANM2.Reset(); + tearEffectANM2.Reset(); + deadEyeANM2.Reset(); + stickTarget = nullptr; + techZeroLaser = nullptr; + techZeroTarget = nullptr; + laserShotLaser = nullptr; + + if (linkPrev && linkNext) + { + Entity* previous = linkPrev; + Entity* next = linkNext; + if (previous->type == ENTITY_TEAR) static_cast(previous)->linkNext = next; + if (next->type == ENTITY_TEAR) static_cast(next)->linkPrev = previous; + } + linkPrev = nullptr; + linkNext = nullptr; + if (attachedEffect) attachedEffect->Remove(); + + if (!tearFlags[TEAR_LUDOVICO]) return; + for (Entity* link = child; link && link->type == ENTITY_TEAR; link = link->child) link->Remove(); +} + +// 00673660 Lets a mod's MC_PRE_TEAR_COLLISION decide first, then ignores low collisions, a dead tear and its own +// player. Whether the collision is ignored. +bool Entity_Tear::HandleCollision(Entity* collider, bool isLow) +{ + LuaResult result = static_cast(g_luaEngine)->PreTearCollision(this, collider, isLow); + if (result != LUA_RESULT_NIL) return result == LUA_RESULT_TRUE; + if (!isLow || isDead) return false; + if (GetPlayerAncestor() == collider) return true; + if (collider->type == ENTITY_PLAYER && IsDescendantOf(collider)) return true; + reconstruction_missing("Entity_Tear::HandleCollision 00673660: the hit on what it collides with"); +} + +// 00665b00 The player at the end of its spawner chain, or none when that is not a player. +Entity_Player* Entity_Tear::GetRootPlayer() +{ + Entity* root = this; + while (root->spawnerEntity) root = root->spawnerEntity; + return root->type == ENTITY_PLAYER ? static_cast(root) : nullptr; +} + +// 00666d40 Plays its fire sound unless muted, then sets up the flight its flags give it. In a crawlspace it starts +// a little higher, dropping when fired sideways. +void Entity_Tear::play_fire_sound() +{ + isFireSoundPending = false; + bool isSilent = variant == TEAR_CHAOS_CARD || variant == TEAR_FIRE || variant == TEAR_GRIDENT || isFireSoundMuted; + bool isFetus = variant == TEAR_FETUS; + bool isGFuelNail = + (variant == TEAR_NAIL || variant == TEAR_NAIL_BLOOD) && g_game->seedEffects.HasSeedEffect(SEED_G_FUEL); + if (!isSilent && !isGFuelNail) + sound_play(isFetus ? SOUND_FETUS_FIRE : SOUND_TEAR_FIRE, 1, isFetus ? FETUS_FIRE_PITCH : 1); + if (tearFlags.any()) reconstruction_missing("Entity_Tear::play_fire_sound 00666d40: the tear flags' flight"); + if (!is_crawlspace()) return; + + pos.y -= CRAWLSPACE_FIRE_RAISE; + if (fallingAccel > 0 && velocity.y < std::fabs(velocity.x)) velocity.y = fallingSpeed * 0.5f + velocity.y; + if (std::fabs(velocity.y) >= std::fabs(velocity.x)) return; + + float length = vector_length(velocity); + float directionY = length > 0 ? velocity.y * (1 / length) : velocity.y; + if (directionY > 0 && directionY < CRAWLSPACE_LEVEL_SLOPE) velocity.y = 0; +} + +// 00676020 Where the sprite draws for a height: at the height itself while it falls, lifted on a curve near the +// floor while it hovers, and fixed for the flames and sword beams that do not fall. +float Entity_Tear::get_height_offset_y(float tearHeight) +{ + bool isHovering = fallingAccel <= GRAVITY_MIN_ACCEL || this->isHovering; + bool isFixed = variant == TEAR_FIRE || ((variant == TEAR_SWORD_BEAM || variant == TEAR_TECH_SWORD_BEAM) && isHovering); + if (isFixed) return FIXED_HEIGHT_OFFSET; + + bool isNail = variant == TEAR_NAIL || variant == TEAR_NAIL_BLOOD; + if (isNail && g_game->seedEffects.HasSeedEffect(SEED_G_FUEL) && isHovering) return GFUEL_NAIL_OFFSET; + if (!isHovering) return tearHeight; + + float aboveFloor = std::max(height + HOVER_FLOOR_DISTANCE, 0.0f); + return (height * HOVER_OFFSET_SCALE + HOVER_OFFSET_LIFT) + aboveFloor * aboveFloor; +} + +// 00675fc0 Sets the height and the sprite offset it draws at. A crawlspace keeps the sprite level and the tear above +// the floor. +void Entity_Tear::SetHeight(float tearHeight) +{ + height = tearHeight; + posOffset.y = get_height_offset_y(tearHeight); + if (!is_crawlspace()) return; + + posOffset.y = CRAWLSPACE_OFFSET_Y; + if (tearHeight > CRAWLSPACE_HEIGHT_MAX) height = CRAWLSPACE_HEIGHT_MAX; +} + +// 00676120 Sets its scale and the scale it returns to, at least a hundredth, and sizes its sprite to it. +void Entity_Tear::SetScale(float scale) +{ + scale = std::max(scale, TEAR_SCALE_MIN); + baseScale = scale; + fScale = scale; + ResetSpriteScale(); +} + +// 00676be0 Applies what its flags do when it dies, splitting it or chaining lightning. A tear without flags does +// nothing. +void Entity_Tear::apply_death_flag_effects(Entity*) +{ + if (tearFlags.any()) reconstruction_missing("Entity_Tear::apply_death_flag_effects 00676be0"); +} + +// Whether a variant plays an animation sized to its scale. +static bool is_sized_variant(int variant) +{ + return variant <= TEAR_METALLIC || (variant >= TEAR_LOST_CONTACT && variant <= TEAR_FIST) || variant == TEAR_ICE || + variant == TEAR_SPORE; +} + +// The sized animation's name for a variant and its number. +static std::string sized_animation_name(int variant, int number) +{ + const char* format = "RegularTear%d"; + if (is_listed(BLOOD_ANIMATION_VARIANTS, variant)) format = "BloodTear%d"; + else if (variant == TEAR_TOOTH || variant == TEAR_BLACK_TOOTH) format = "Tooth%dMove"; + else if (variant == TEAR_COIN) format = "Rotate%d"; + else if (is_listed(STONE_ANIMATION_VARIANTS, variant)) format = "Stone%dMove"; + + char name[TEAR_ANIMATION_NAME_SIZE]; + std::snprintf(name, sizeof(name), format, number); + return name; +} + +// Plays the animation of its variant and size when that changed: the first sized one at least its scale, or a +// fixed one. The scale its layers draw at, its scale over the animation's where no animation matches it. +float Entity_Tear::animation_update() +{ + int animationBase = variant * TEAR_ANIMATION_BASE; + + if (is_sized_variant(variant)) + { + auto found = std::find_if(TEAR_ANIMATION_SCALES.begin(), TEAR_ANIMATION_SCALES.end() - 1, + [this](float scale) { return fScale <= scale + TEAR_ANIMATION_MARGIN; }); + bool isLargest = found == TEAR_ANIMATION_SCALES.end() - 1; + int number = (int)(found - TEAR_ANIMATION_SCALES.begin()) + 1; + if (scaleAnimNum != animationBase + number) + { + sprite.Play(sized_animation_name(variant, number)); + scaleAnimNum = animationBase + number; + } + return isLargest || tearFlags[TEAR_GROW] || tearFlags[TEAR_LUDOVICO] ? fScale / *found : 1; + } + + switch (variant) + { + case TEAR_FIRE_MIND: + case TEAR_DARK_MATTER: + case TEAR_MYSTERIOUS: + { + if (scaleAnimNum != animationBase) + { + sprite.Play("MoveHori"); + scaleAnimNum = animationBase; + } + Vector direction = waitFrames > 0 ? continueVelocity : vector_make(velocity.x, fallingSpeed + velocity.y); + sprite.rotation = std::atan2(direction.y, direction.x) * DEGREES_PER_RADIAN; + return fScale / TEAR_ANIMATION_SCALES.back(); + } + case TEAR_SCHYTHE: + case TEAR_ROCK: + case TEAR_FETUS: + reconstruction_missing("Entity_Tear::ResetSpriteScale 00677780: this tear variant's animation"); + case TEAR_CHAOS_CARD: + if (isDead) return 1; + if (scaleAnimNum != animationBase) + { + sprite.Play("Rotate"); + scaleAnimNum = animationBase; + } + sprite.isFlipX = velocity.x < 0; + return 1; + case TEAR_GRIDENT: + return 1; + case TEAR_FIRE: + sprite.Play("Flickering"); + layer_additive_set(sprite, 0); + return 1; + case TEAR_SWORD_BEAM: + case TEAR_TECH_SWORD_BEAM: + sprite.Play("Idle"); + return fScale; + default: + if (scaleAnimNum != animationBase) + { + sprite.Play("Idle"); + scaleAnimNum = animationBase; + } + return 1; + } +} + +// 00677780 Plays the animation for its size and variant, sizes its layers and effect sprites with its size +// multiplier (a third as wide for the G-Fuel nails), and its collision and shadow with its scale. +void Entity_Tear::ResetSpriteScale() +{ + float layerScale = animation_update(); + float sizeX = sizeMulti.x; + float sizeY = sizeMulti.y; + bool isNail = variant == TEAR_NAIL || variant == TEAR_NAIL_BLOOD; + + if (variant > TEAR_FETUS) layerScale = fScale; + else if (isNail && g_game->seedEffects.HasSeedEffect(SEED_G_FUEL)) sizeX /= GFUEL_SIZE_DIVISOR; + for (LayerState& layer : sprite.layerStates) layer.size = vector_make(layerScale * sizeX, layerScale * sizeY); + + float effectScale = fScale * TEAR_EFFECT_SCALE; + Vector effectSize = vector_make(effectScale * sizeX, effectScale * sizeY); + if (tearFlags[TEAR_GLOW]) + { + tearHaloANM2.scale = effectSize; + tearHaloANM2.Update(); + } + tearEffectANM2.scale = effectSize; + tearEffectANM2.Update(); + if (deadEyeIntensity != 0) + { + deadEyeANM2.scale = effectSize; + deadEyeANM2.Update(); + } + SetSize(config->collisionRadius * fScale, sizeMulti, config->gridCollisionPoints); + shadowSize = config->shadowSize * fScale * (sizeX + sizeY) * 0.5f; +} // 00678060 Whether it was not split off another tear. bool Entity_Tear::is_not_familiar_spawned() @@ -7,55 +859,36 @@ bool Entity_Tear::is_not_familiar_spawned() return !parent || parent->type != ENTITY_TEAR; } -// The rest of Entity_Tear is not reconstructed yet. - -// 006660a0 -void Entity_Tear::Init(int, int, int, uint32_t) +// 0067d560 Hurts the rocks, poop and other solid grid entities its collision points touch at a position, once each. +// Whether it touched any. +bool Entity_Tear::try_make_bridges(const Vector& position) { - reconstruction_missing("Entity_Tear::Init 006660a0"); + if (tearFlags.any()) reconstruction_missing("Entity_Tear::try_make_bridges 0067d560: the tear flags' grid hits"); + Room& room = *g_game->room; + std::vector cells; + int damage = collisionDamage > STRONG_TEAR_DAMAGE ? 2 : 1; + bool isHitSolid = false; + + for (Vector point : collisionPoints) + { + int cell = room.GetGridIndex(vector_add(position, point)); + if (cell >= 0) cells.push_back(cell); + } + std::sort(cells.begin(), cells.end()); + cells.erase(std::unique(cells.begin(), cells.end()), cells.end()); + + for (int cell : cells) + { + GridEntity* grid = room.GetGridEntity(cell); + if (!grid || grid->collisionClass == COLLISION_NONE || grid->collisionClass == COLLISION_PIT) continue; + + isHitSolid = true; + grid->Hurt(damage, EntityRef(this)); + } + return isHitSolid; } -// 006670f0 -void Entity_Tear::Update() -{ - reconstruction_missing("Entity_Tear::Update 006670f0"); -} - -// 00679400 -void Entity_Tear::Interpolate() -{ - reconstruction_missing("Entity_Tear::Interpolate 00679400"); -} - -// 006790c0 -void Entity_Tear::Render(const Vector&) -{ - reconstruction_missing("Entity_Tear::Render 006790c0"); -} - -// 00675fa0 -void Entity_Tear::SetCollisionDamage(float) -{ - reconstruction_missing("Entity_Tear::SetCollisionDamage 00675fa0"); -} - -// 006666c0 -void Entity_Tear::ClearReferences() -{ - reconstruction_missing("Entity_Tear::ClearReferences 006666c0"); -} - -// 00673660 -bool Entity_Tear::HandleCollision(Entity*, bool) -{ - reconstruction_missing("Entity_Tear::HandleCollision 00673660"); -} - -// 00665b00 -Entity_Player* Entity_Tear::GetRootPlayer() -{ - reconstruction_missing("Entity_Tear::GetRootPlayer 00665b00"); -} +// The rest of Entity_Tear is not reconstructed yet: the tear flags' behaviours. // 006668c0 void Entity_Tear::apply_wiggle(float) @@ -69,42 +902,12 @@ void Entity_Tear::update_wiggle() reconstruction_missing("Entity_Tear::update_wiggle 00666ba0"); } -// 00666d40 -void Entity_Tear::play_fire_sound() -{ - reconstruction_missing("Entity_Tear::play_fire_sound 00666d40"); -} - -// 00676020 -float Entity_Tear::get_height_offset_y(float) -{ - reconstruction_missing("Entity_Tear::get_height_offset_y 00676020"); -} - -// 00676120 -void Entity_Tear::SetScale(float) -{ - reconstruction_missing("Entity_Tear::SetScale 00676120"); -} - // 00676150 void Entity_Tear::SetTearFlags(TearFlags) { reconstruction_missing("Entity_Tear::SetTearFlags 00676150"); } -// 00676be0 -void Entity_Tear::apply_death_flag_effects(Entity*) -{ - reconstruction_missing("Entity_Tear::apply_death_flag_effects 00676be0"); -} - -// 00677780 -void Entity_Tear::ResetSpriteScale() -{ - reconstruction_missing("Entity_Tear::ResetSpriteScale 00677780"); -} - // 00678080 void Entity_Tear::fire_split_projectiles(bool) { @@ -147,12 +950,6 @@ void Entity_Tear::apply_link_spring_forces() reconstruction_missing("Entity_Tear::apply_link_spring_forces 0067aaf0"); } -// 0067d560 -bool Entity_Tear::try_make_bridges(float*) -{ - reconstruction_missing("Entity_Tear::try_make_bridges 0067d560"); -} - // 006b5320 void Entity_Tear::reroll_hit_entity(int) { diff --git a/src/entity_tear.h b/src/entity_tear.h index 3bfcd2c..3ace806 100644 --- a/src/entity_tear.h +++ b/src/entity_tear.h @@ -7,7 +7,80 @@ // Lua's TearFlags bits that the entity code reads. enum TearFlagBit : int { - TEAR_SHIELDED = 34 + TEAR_GROW = 7, + TEAR_EXPLOSIVE = 12, + TEAR_WAIT = 17, + TEAR_QUADSPLIT = 18, + TEAR_GLOW = 31, + TEAR_SHIELDED = 34, + TEAR_TRACTOR_BEAM = 42, + TEAR_POP = 58, + TEAR_LUDOVICO = 127 +}; + +// Lua's TearVariant: the look of a tear, which also picks its splash. +enum TearVariant : int +{ + TEAR_BLUE = 0, + TEAR_BLOOD = 1, + TEAR_TOOTH = 2, + TEAR_METALLIC = 3, + TEAR_BOBS_HEAD = 4, + TEAR_FIRE_MIND = 5, + TEAR_DARK_MATTER = 6, + TEAR_MYSTERIOUS = 7, + TEAR_SCHYTHE = 8, + TEAR_CHAOS_CARD = 9, + TEAR_LOST_CONTACT = 10, + TEAR_CUPID_BLUE = 11, + TEAR_CUPID_BLOOD = 12, + TEAR_NAIL = 13, + TEAR_PUPULA = 14, + TEAR_PUPULA_BLOOD = 15, + TEAR_GODS_FLESH = 16, + TEAR_GODS_FLESH_BLOOD = 17, + TEAR_DIAMOND = 18, + TEAR_EXPLOSIVO = 19, + TEAR_COIN = 20, + TEAR_MULTIDIMENSIONAL = 21, + TEAR_STONE = 22, + TEAR_NAIL_BLOOD = 23, + TEAR_GLAUCOMA = 24, + TEAR_GLAUCOMA_BLOOD = 25, + TEAR_BOOGER = 26, + TEAR_EGG = 27, + TEAR_RAZOR = 28, + TEAR_BONE = 29, + TEAR_BLACK_TOOTH = 30, + TEAR_NEEDLE = 31, + TEAR_BELIAL = 32, + TEAR_EYE = 33, + TEAR_EYE_BLOOD = 34, + TEAR_BALLOON = 35, + TEAR_HUNGRY = 36, + TEAR_BALLOON_BRIMSTONE = 37, + TEAR_BALLOON_BOMB = 38, + TEAR_FIST = 39, + TEAR_GRIDENT = 40, + TEAR_ICE = 41, + TEAR_ROCK = 42, + TEAR_KEY = 43, + TEAR_KEY_BLOOD = 44, + TEAR_ERASER = 45, + TEAR_FIRE = 46, + TEAR_SWORD_BEAM = 47, + TEAR_SPORE = 48, + TEAR_TECH_SWORD_BEAM = 49, + TEAR_FETUS = 50 +}; + +// Why a tear died, as deathFlags collects them. +enum TearDeath : uint32_t +{ + TEAR_DEATH_GRID = 1 << 0, + TEAR_DEATH_WALL = 1 << 1, + TEAR_DEATH_FLOOR = 1 << 2, + TEAR_DEATH_FORCED = 1 << 6 }; // Construction and destruction (00665ea0, 00665cf0) are the defaults. @@ -15,6 +88,8 @@ enum TearFlagBit : int // 0060cd00, 0085dd60, 0085dd70, 0085dd90) are the public fields. // A player's tear (Lua's EntityTear): its height and fall, scale and damage, the tear flags that change how it flies // and hits, the entity it sticks to, and the tears and lasers it links to. +// Only a plain tear is reconstructed yet: Update and Interpolate stop at any tear flag or special variant, and +// HandleCollision past its early checks. struct Entity_Tear : Entity { ANM2 deadEyeANM2; @@ -26,9 +101,9 @@ struct Entity_Tear : Entity EntityPtr laserShotLaser; EntityPtr linkNext; EntityPtr linkPrev; + EntityPtr stickTarget; EntityPtr techZeroLaser; EntityPtr techZeroTarget; - Entity* stickTarget = nullptr; Vector continueVelocity{}; Vector holdOffset{}; Vector holdVelocity{}; @@ -76,7 +151,8 @@ struct Entity_Tear : Entity void apply_wiggle(float strength); void update_wiggle(); void play_fire_sound(); - float get_height_offset_y(float height); + float get_height_offset_y(float tearHeight); + void SetHeight(float tearHeight); void SetScale(float scale); void SetTearFlags(TearFlags flags); void apply_death_flag_effects(Entity* target); @@ -85,10 +161,20 @@ struct Entity_Tear : Entity void fire_split_projectiles(bool isHalved); void SetDeadEyeIntensity(float intensity); Entity_Tear* MakeMultidimensionalCopy(Entity* spawner); - void ChangeVariant(int variant); + void ChangeVariant(int newVariant); int find_nearest_linkable_tear(); Entity_Tear* find_link_partner(); void apply_link_spring_forces(); - static bool try_make_bridges(float*); + bool try_make_bridges(const Vector& position); void reroll_hit_entity(int unused); + +private: + float animation_update(); + bool hold_update(); + void wait_update(); + void death_update(); + void blood_stains_spawn(); + void flight_update(); + void floor_hit(); + void grid_hit(); }; diff --git a/src/fx_layers.cpp b/src/fx_layers.cpp index 56de643..423a42b 100644 --- a/src/fx_layers.cpp +++ b/src/fx_layers.cpp @@ -62,7 +62,6 @@ constexpr int STAGE_TYPE_REPENTANCE = 4; constexpr int STAGE_TYPE_COUNT = 5; constexpr uint32_t CURSE_DARKNESS = 1; constexpr uint32_t CHALLENGE_DELETE_THIS = 45; -constexpr int SECRET_EXIT_CORPSE = 4; constexpr int BACKDROP_PLANETARIUM = 35; constexpr int BACKDROP_MAUSOLEUM_HEART = 39; constexpr int BACKDROP_DUNGEON_BEAST = 57; @@ -745,7 +744,7 @@ void FXLayers::LoadConfig(std::string_view path, int levelStage, int levelStageT if (g_game->difficulty == DIFFICULTY_GREED || g_game->difficulty == DIFFICULTY_GREEDIER) stage = levelStage <= CHAPTER_LAST ? levelStage * 2 - 1 : (levelStage == GREED_STAGE_SHEOL ? STAGE_SHEOL : 0); backdropType = room.backdropType; - if (level.get_secret_exit_kind() == SECRET_EXIT_CORPSE && g_game->currentRoomIdx == ROOM_SECRET_EXIT_IDX) + if (level.get_secret_exit_kind() == SECRET_EXIT_MOMS_HEART && g_game->currentRoomIdx == ROOM_SECRET_EXIT_IDX) { stage = STAGE_WOMB; stageType = 0; @@ -918,18 +917,14 @@ void FXLayers::Update(PlayerFollow follow) } } - Vector center{}; if ((playersCenter.x != 0 || playersCenter.y != 0) && follow == PLAYER_FOLLOW_EASE) { - players_center_position(&g_game->playerManager, ¢er, true); + Vector center = g_game->playerManager.players_center_position(CENTER_CACHED); playersCenter.x = (center.x - playersCenter.x) * PLAYERS_CENTER_EASE + playersCenter.x; playersCenter.y = (center.y - playersCenter.y) * PLAYERS_CENTER_EASE + playersCenter.y; } else - { - players_center_position(&g_game->playerManager, ¢er, false); - playersCenter = center; - } + playersCenter = g_game->playerManager.players_center_position(CENTER_FRESH); } // 00996b30 Grows a vein's branches at load, fully grown, at the nulls of its sprite that point to the players' side, diff --git a/src/game.cpp b/src/game.cpp index f5ea4b4..4738aad 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -538,8 +538,8 @@ void Game::Fadein(float speed, FadeIcon icon, KColor color) } // 006f9000 Copies the run into a game state to save: its rules and seeds, the counters and histories of the run, the -// Ascent's saved stages, the nightmare stage bar, the ambush wave, the score, the boss and item pools, then the floor -// (after leaving the room), the players and the versus rules. +// item and boss pools, the TMTRAINER seeds, the floor (after leaving the room), the players, the Ascent's saved +// stages, the nightmare stage bar, the ambush wave, the score and the versus rules. // The saved flags are the first 53 of the run's state flags. void Game::store_game_state(GameState& state) { @@ -577,6 +577,14 @@ void Game::store_game_state(GameState& state) state.pixelationDuration = pixelationDuration; state.magicSkinUses = magicSkinUses; state.erasedEntities = erasedEntities; + itemPool.StoreGameState(state.itemPool); + bossPool.store_game_state(state.bossPool); + if (!proceduralItemManager.proceduralItems.empty()) + reconstruction_missing("Game::store_game_state 006f9000: the TMTRAINER items' seeds (ProceduralItem +0x8)"); + + reconstruction_missing("Game::store_game_state 006f9000: Room::on_leave 007efa50"); + Level::store_game_state(state); + playerManager.store_game_state(&state); state.isAscent = ascentTimer > 0; state.backwardsStages = backwardsStages; @@ -585,14 +593,8 @@ void Game::store_game_state(GameState& state) state.isAmbushActive = ambush._isActive; state.ambushWave = ambush._currentWave > 0 ? ambush._currentWave - 1 : ambush._currentWave; scoreSheet.store_state(state.scoreSheet); - - bossPool.store_game_state(state.bossPool); - if (!proceduralItemManager.proceduralItems.empty()) - reconstruction_missing("Game::store_game_state 006f9000: the TMTRAINER items' seeds (ProceduralItem +0x8)"); - itemPool.StoreGameState(state.itemPool); - reconstruction_missing("Game::store_game_state 006f9000: Room::on_leave 007efa50, Level::store_game_state " - "00747e10, PlayerManager::store_game_state 009bd150 and the versus rules " - "(DeathmatchTypeBase slot 1 and StoreGameState 0042bd70)"); + reconstruction_missing("Game::store_game_state 006f9000: the versus rules (DeathmatchTypeBase slot 1 and its " + "StoreGameState)"); } // 009b5cb0 Closes the pause screen for a new run on Resume, with its paper's animation stopped, the options listed @@ -613,9 +615,9 @@ void Game::Exit(bool) reconstruction_missing("Game::Exit 006fa0c0"); } -void Game::Update() +void Game::save_rewind_state(int) { - reconstruction_missing("Game::Update 006fadc0"); + reconstruction_missing("Game::save_rewind_state 00705ee0"); } constexpr const char* BLOOM_SHADER = "Bloom"; @@ -816,10 +818,7 @@ static void overlays_render(Game& game) if (game.gameOver._state != 0) game.gameOver.Render(); game.leaderboard.Render(); popups.render_layer(2); - - for (auto& mod : g_manager->modManager.mods) - if (mod->isLoaded && !mod->shaders.empty()) - reconstruction_missing("Game::Render 006fbc10: the mods' shaders 008f74c0"); + g_manager->modManager.shaders_render(); } // Resolves the effect surfaces in turn (the room snapshot, bloom, pixelation, hallucination, old TV), then draws the @@ -890,7 +889,11 @@ void Game::Render() bool isOldTv = seedEffects.HasSeedEffect(SEED_OLD_TV); bool isTransitionShown = roomTransition.mode == TRANSITION_OUT || roomTransition.mode == TRANSITION_IN; - if (isWindowResizePending) reconstruction_missing("Game::recreate_render_targets 007084c0"); + if (isWindowResizePending) + { + recreate_render_targets(); + isWindowResizePending = false; + } room->render_lighting(); if (isFighting) deathmatchManager.type->vfunc_5(); if (isOldTv) effect_pass_begin(oldTvSurface); @@ -981,8 +984,3 @@ ChallengeParam& Game::GetChallengeParams() return g_manager->GetChallengeParams((int)challenge); } -// 00428b20 Spawns an entity into the current room. -Entity* Game::Spawn(const EntitySpawn&) -{ - reconstruction_missing("Game::Spawn 00428b20"); -} diff --git a/src/game.h b/src/game.h index dfd7458..d762575 100644 --- a/src/game.h +++ b/src/game.h @@ -5,6 +5,7 @@ #include "challenge_params.h" #include "console.h" #include "deathmatch_manager.h" +#include "entity_factory.h" #include "game_state.h" #include "generic_prompt.h" #include "hud.h" @@ -127,6 +128,24 @@ struct EntitySpawn uint32_t seed = 0; }; +// Where the run goes once its fade out covers the screen (Game's fadeOutTarget). The online ones wait for the lobby. +enum FadeOutTarget : int +{ + FADEOUT_NONE, + FADEOUT_MENU_SAVE, + FADEOUT_MENU_GAME, + FADEOUT_MENU_ONLINE, + FADEOUT_MENU_TITLE, + FADEOUT_RESTART, + FADEOUT_RESTART_HELD, + FADEOUT_VICTORY_LAP, + FADEOUT_ONLINE_LOBBY, + FADEOUT_ONLINE_WAIT, + FADEOUT_ARENA, + FADEOUT_MENU_ONLINE_LOBBY, + FADEOUT_TARGET_COUNT +}; + // Whether a fade in shows the loading icon. enum FadeIcon { @@ -280,9 +299,14 @@ public: void Start(int playerType, uint32_t startChallenge, const Seeds& seeds, Difficulty startDifficulty); void Fadein(float speed, FadeIcon icon, KColor color); + void SetColorModifier(const ColorModState& color, bool isLerp, float rate); + void save_rewind_state(int leaveDoor); + void Fadeout(float speed, FadeOutTarget target, KColor color = kcolor_rgba(0, 0, 0, 1)); void store_game_state(GameState& state); static void Exit(bool isSaving); void Update(); + void interpolate_update(); + void recreate_render_targets(); void Render(); bool IsPaused(); bool IsGreedMode(); diff --git a/src/game_state.cpp b/src/game_state.cpp index a3487f8..24bd4ea 100644 --- a/src/game_state.cpp +++ b/src/game_state.cpp @@ -1,8 +1,13 @@ #include "game_state.h" #include "log.h" +#include "persistent_game_data.h" #include "platform.h" #include +// The header a saved run starts with (version 169, with its terminator), and the key its checksum is scrambled with. +constexpr char SAVE_HEADER[] = "ISAACNG_GSR0169"; +constexpr uint32_t CHECKSUM_KEY = 0x96696996; + // 009c79a0 Empties the saved run and drops both availabilities, keeping the files it is saved to. void GameState::Clear() { @@ -25,8 +30,55 @@ void GameState::DeleteRerun() std::remove(rerunPath.c_str()); } +// A saved run as it is written: its bytes, and the checksum (CRC-32 from Checksum's seed) over all of them after the +// header. +struct StateWriter +{ + std::vector bytes; + Checksum checksum; + + void write_bytes(std::span data) + { + bytes.insert(bytes.end(), data.begin(), data.end()); + checksum.Update(data); + } + + template void write(Value value) { write_bytes({(const uint8_t*)&value, sizeof(Value)}); } +}; + +// 009c9340 Writes the saved run in the original's format: the unchecked header, then the run's rules, flags and +// counters, the ambush and the score, the floor, the players, the pools, the seeds, the histories, the Ascent's stages +// and the versus rules, closed by the checksum of everything after the header, scrambled. +// The format is written up to the score sheet so far. The rest waits for the floor's and the players' states. +std::vector GameState::write() +{ + StateWriter writer; + writer.bytes.assign(SAVE_HEADER, SAVE_HEADER + sizeof(SAVE_HEADER)); + + writer.write(challenge); + writer.write((uint8_t)isRerun); + writer.write((uint8_t)seeds.isCustomRun); + writer.write((uint8_t)isConsoleUsedThisRun); + writer.write(difficulty); + writer.write((uint16_t)gameStateFlags.size()); + for (size_t i = 0; i < gameStateFlags.size(); i++) writer.write((uint8_t)gameStateFlags[i]); + + for (int counter : {lastDevilRoomStage, treasureRoomsVisited, planetariumsVisited, stagesWithoutHeartsPicked, + stagesWithoutDamage, devilRoomDeals, shopVisits, donationModGreed, donationModAngel, + reviveMachineCoinsLeft, reviveMachineUses, bossRushParTime, blueWombParTime, frameCount, + timeCounter, stageNameNumeral, victoryLap, lastLevelWithoutHalfHp}) + writer.write(counter); + writer.write((uint8_t)isAmbushActive); + writer.write(ambushWave); + reconstruction_missing("GameState::write 009c9340: the score sheet (write_score_sheet 009d77e0) and on"); + + checksum = writer.checksum.value_get(); + uint32_t sealed = checksum ^ CHECKSUM_KEY; + writer.bytes.insert(writer.bytes.end(), (const uint8_t*)&sealed, (const uint8_t*)&sealed + sizeof(sealed)); + return writer.bytes; +} + // Not reconstructed yet: each stops the game where it is reached. // Netplay is offline, so read always reads a run as this machine's own (the original's isLocalRun). bool GameState::read(std::span) { reconstruction_missing("GameState::read 009cc1a0"); } bool GameState::read_rerun(std::span) { reconstruction_missing("GameState::read_rerun 009d7d50"); } -std::vector GameState::write() { reconstruction_missing("GameState::write 009c9340"); } diff --git a/src/game_state.h b/src/game_state.h index 89b8c24..40d0fb4 100644 --- a/src/game_state.h +++ b/src/game_state.h @@ -1,6 +1,7 @@ #pragma once #include "boss_pool.h" +#include "item_pool.h" #include "nightmare_scene.h" #include "score_sheet.h" #include "seeds.h" diff --git a/src/game_update.cpp b/src/game_update.cpp new file mode 100644 index 0000000..52992f1 --- /dev/null +++ b/src/game_update.cpp @@ -0,0 +1,527 @@ +#include "entity_player.h" +#include "game.h" +#include "grid_entity_door.h" +#include "log.h" +#include "lua_engine.h" +#include "manager.h" +#include "menu_manager.h" +#include "room.h" +#include "room_render.h" +#include +#include +#include + +constexpr uint32_t STAGE_BLUE_WOMB = 9; +constexpr uint32_t STAGE_HOME = 13; +constexpr int STAGE_ID_SPECIAL_ROOMS = 0; +constexpr int BOSS_MEGA_SATAN = 55; +constexpr int BOSS_MOTHER = 88; +constexpr int SOUND_TRAPDOOR_LOOP = 1008; +constexpr float TRAPDOOR_LOOP_FADE = 0.05f; +constexpr float TRAPDOOR_HEARING_DISTANCE = 200; +constexpr float TRAPDOOR_VOLUME_MIN = 0.6f; +constexpr float TRAPDOOR_PAN_DISTANCE = 300; +constexpr float TRAPDOOR_PAN_MAX = 0.75f; + +constexpr float LIGHTNING_DECAY = 0.75f; +constexpr float LIGHTNING_CUTOFF = 0.05f; +constexpr float DARKNESS_FALL = 1.0f / 30; +constexpr float DARKNESS_RISE = 1.0f / 21; +constexpr float VICTORY_LAP_FADE_SPEED = 0.08f; +constexpr int ASCENT_FRAMES = 90; +constexpr int ASCENT_SHAKE_DIVISOR = 6; +constexpr int ASCENT_SHAKE_BASE = 2; +constexpr int DEATH_CERTIFICATE_SHAKE = 10; +constexpr int HUD_REFRESH_INTERVAL = 30; +constexpr int ITEM_OVERLAY_PLAYING = 2; +constexpr uint64_t FADE_IN_ICON_MS = 3000; +constexpr uint64_t NS_PER_MS = 1000000; +constexpr int REVIVE_CLOSE_FRAMES = 8; +constexpr int DIMENSION_DEATH_CERTIFICATE = 2; +// The room's render surface, its size and margin, centered on the screen. +constexpr float ROOM_SURFACE_WIDTH = 338; +constexpr float ROOM_SURFACE_HEIGHT = 182; +constexpr float ROOM_SURFACE_MARGIN = 52; +constexpr int EVENT_EDEN_TOKENS = 21; +constexpr int EVENT_STREAK_COUNTER = 22; + +constexpr int STAGE_TRANSITION_START = 1; +constexpr int STAGE_TRANSITION_LANDING = 4; +constexpr int MC_POST_UPDATE = 1; + +// The menu each menu fade out returns to. +constexpr std::array FADEOUT_MENUS = {MENU_NONE, MENU_SAVE, MENU_GAME, MENU_ONLINE, MENU_TITLE}; + +// Whether two color modifiers are the same in every component. +static bool is_color_mod_equal(const ColorModState& a, const ColorModState& b) +{ + return a._red == b._red && a._green == b._green && a._blue == b._blue && a._amount == b._amount && + a._brightness == b._brightness && a._contrast == b._contrast; +} + +// Queues a menu to fade to from black, as a finished fade out does. +static void menu_queue(MenuState menu) +{ + Manager& manager = *g_manager; + + manager.pendingMenuState = menu; + manager.pendingMenuFadeColor = kcolor_rgba(0, 0, 0, 1); + manager.isMenuPending = true; +} + +// 006f5290 Starts fading the run out in a color toward a target, from the cover reached so far. +void Game::Fadeout(float speed, FadeOutTarget target, KColor color) +{ + if (target < 0 || target >= FADEOUT_TARGET_COUNT) + return KAGE_LogMessage(LOG_ERROR, (uint8_t*)"Invalid target specified to Game::Fadeout()\n"); + + fadeSpeed = speed; + fadeOutTarget = target; + fadeOutColor = kcolor_rgba(color._red, color._green, color._blue, fadeOutColor._alpha + speed); +} + +// 00708630 Plays the loop of an open trapdoor's hum: in Mother's boss room from its trapdoor, or from the door of an +// uncleared boss room next door (not Mother's or Mega Satan's) while this room is cleared or has no boss. It fades in +// and pans with the first player's place. Anywhere else it fades out. Never in Greed mode, the Blue Womb or Home. +static void trapdoor_loop_sfx_update(Game& game) +{ + Room* room = game.room.get(); + SFXManager& sfx = g_manager->sfxManager; + bool isAllowed = game.difficulty != DIFFICULTY_GREED && game.difficulty != DIFFICULTY_GREEDIER && + game.stage != STAGE_BLUE_WOMB && game.stage != STAGE_HOME; + auto is_special_boss = [](RoomConfig_Room* config, int bossId) { + return config && config->stageId == STAGE_ID_SPECIAL_ROOMS && config->subtype == bossId; + }; + std::optional source; + + if (!isAllowed) room = nullptr; + if (room && room->roomType == ROOM_BOSS && is_special_boss(room->descriptor->data, BOSS_MOTHER)) + { + source = Vector{}; + for (int i = 0; i < std::min(room->gridWidth * room->gridHeight, ROOM_GRID_CELLS); i++) + { + GridEntity* entity = room->gridEntities[i]; + if (!entity || entity->type != GRID_TRAPDOOR) continue; + + source = entity->Position(); + break; + } + } + for (GridEntity_Door* door : room ? room->doors : decltype(room->doors){}) + { + if (source) break; + if (!door || door->targetRoomType != ROOM_BOSS) continue; + + RoomDescriptor* next = game.GetRoomByIdx(door->targetRoomIdx); + bool isSpecial = is_special_boss(next->data, BOSS_MOTHER) || is_special_boss(next->data, BOSS_MEGA_SATAN); + bool isNextCleared = next->flags & ROOM_DESCRIPTOR_FLAG_CLEAR; + if (isSpecial || isNextCleared || (!room->IsClear() && room->bossId != 0)) continue; + + source = door->Position(); + break; + } + + if (!source) + { + if (!sfx.IsPlaying(SOUND_TRAPDOOR_LOOP)) return; + if (game.trapdoorLoopVolume < TRAPDOOR_LOOP_FADE) return sfx.Stop(SOUND_TRAPDOOR_LOOP); + + game.trapdoorLoopVolume -= TRAPDOOR_LOOP_FADE; + sfx.AdjustVolume(SOUND_TRAPDOOR_LOOP, game.trapdoorLoopVolume); + return; + } + + float distanceVolume = 1; + float pan = 0; + if (Entity_Player* player = game.playerManager.get_first_local_main_player()) + { + Vector offset = vector_make(source->x - player->pos.x, source->y - player->pos.y); + float distance = std::sqrt(offset.x * offset.x + offset.y * offset.y); + + if (distance > 0) + distanceVolume = std::min(std::max(TRAPDOOR_HEARING_DISTANCE / distance, TRAPDOOR_VOLUME_MIN), 1.0f); + pan = std::max(std::min(offset.x / TRAPDOOR_PAN_DISTANCE, TRAPDOOR_PAN_MAX), -TRAPDOOR_PAN_MAX); + } + + if (!sfx.IsPlaying(SOUND_TRAPDOOR_LOOP)) + { + int soundId = SOUND_TRAPDOOR_LOOP; + seed_fart_sound_override(&soundId); + sfx.Play(soundId, {.volume = game.trapdoorLoopVolume, .frameDelay = 0, .loop = SOUND_LOOP}); + return; + } + game.trapdoorLoopVolume = std::min(game.trapdoorLoopVolume + TRAPDOOR_LOOP_FADE, 1.0f); + sfx.AdjustVolume(SOUND_TRAPDOOR_LOOP, game.trapdoorLoopVolume * distanceVolume); + sfx.pan_adjust(SOUND_TRAPDOOR_LOOP, pan); +} + +// 004291c0 Ticks the versus match's timer. Its intro, countdown, fight and result states never run offline, as no +// match starts there. +static void deathmatch_update(DeathmatchManager& deathmatch) +{ + deathmatch.timer++; + if (deathmatch.state >= DEATHMATCH_INTRO && deathmatch.state <= DEATHMATCH_RESULT) + reconstruction_missing("update_cutscene_state_machine 004291c0: the versus match's states"); +} + +// Runs where a finished fade out leads: a menu, a restart (Eden's costs a token, and without one goes to the menus), +// the victory lap or the versus arena. Holding restart also ends the win streak. +// Netplay is offline, so the online targets restart at once or wait for a lobby that never comes. +static void fadeout_finish(Game& game) +{ + PersistentGameData& data = g_manager->persistentGameData; + int target = game.fadeOutTarget; + auto is_eden = [&game]() { + int playerType = game.GetPlayer(0)->playerType; + return playerType == PLAYER_EDEN || playerType == PLAYER_EDEN_B; + }; + + switch (target) + { + case FADEOUT_MENU_SAVE: + case FADEOUT_MENU_GAME: + case FADEOUT_MENU_ONLINE: + case FADEOUT_MENU_TITLE: + menu_queue(FADEOUT_MENUS[target]); + break; + case FADEOUT_RESTART: + if (is_eden() && data.eventCounters[EVENT_EDEN_TOKENS] == 0) + { + menu_queue(MENU_GAME); + break; + } + if (is_eden()) data.IncreaseEventCounter(EVENT_EDEN_TOKENS, -1); + Manager::RestartGame(); + break; + case FADEOUT_RESTART_HELD: + { + bool isEden = is_eden(); + data.IncreaseEventCounter(EVENT_STREAK_COUNTER, -data.eventCounters[EVENT_STREAK_COUNTER]); + if (isEden && data.eventCounters[EVENT_EDEN_TOKENS] != 0) data.IncreaseEventCounter(EVENT_EDEN_TOKENS, -1); + Manager::RestartGame(); + break; + } + case FADEOUT_VICTORY_LAP: + reconstruction_missing("Game::NextVictoryLap 006f7ac0"); + case FADEOUT_ARENA: + game.deathmatchManager.enter_arena(); + break; + case FADEOUT_MENU_ONLINE_LOBBY: + menu_queue(MENU_ONLINE_LOBBY); + break; + } + + g_manager->achievementOverlay.isPopupBlocked = false; + if (target != FADEOUT_ONLINE_LOBBY && target != FADEOUT_ONLINE_WAIT) game.fadeOutTarget = FADEOUT_NONE; +} + +// Steps the fade out: back toward clear with no target, else toward black (refreshing the HUD), finishing at full +// cover. Whether the HUD's post update is due, which a clear screen skips. +static bool fadeout_update(Game& game) +{ + float& alpha = game.fadeOutColor._alpha; + + if (alpha <= 0) return false; + if (game.fadeOutTarget == FADEOUT_NONE) + { + alpha = std::max(alpha - game.fadeSpeed, 0.0f); + return true; + } + + alpha += game.fadeSpeed; + game.hud.refresh_request(HUD_REFRESH_PLAYER); + if (alpha < 1) return true; + + alpha = 1; + fadeout_finish(game); + return true; +} + +// The game over screen's frame: the looping sounds stop once, the pause paper steps and the co-op revive menu closes. +// The online vote count is left out: netplay is offline. +static void game_over_update(Game& game) +{ + if (game.gameOver._isStopSoundsPending) + { + g_manager->sfxManager.StopLoopingSounds(); + game.gameOver._isStopSoundsPending = false; + } + game.pauseScreen.animation_update(); + + RevivePlayerMenu& revive = game.revivePlayerMenu; + if (revive.state == REVIVE_MENU_HIDDEN) return; + revive.state = REVIVE_MENU_CLOSING; + revive.closeTimer = REVIVE_CLOSE_FRAMES; + revive.controllerIndex = -1; +} + +// Steps the fade in, unless the loading icon has not shown its three seconds yet. Once clear (or at once when instant) +// the floor's name shows and the players move, outside a versus match, and the loading icons are freed. +// Whether the fade still covers the screen. +static bool fadein_update(Game& game) +{ + Manager& manager = *g_manager; + float& alpha = game.fadeInColor._alpha; + bool isInstant = game.isInstantFadeIn; + + if (alpha <= 0) return false; + + uint64_t elapsed = GetTimeNs() / NS_PER_MS - manager.loadImagesTime; + if (!manager.netplayManager.is_online() && !isInstant && elapsed <= FADE_IN_ICON_MS) return true; + + alpha -= game.fadeSpeed; + game.hud.refresh_request(HUD_REFRESH_FULL); + if (alpha > 0 && !isInstant) return true; + + game.isInstantFadeIn = false; + alpha = 0; + if (game.deathmatchManager.state < DEATHMATCH_INTRO) + { + game.ShowName(false); + for (Entity_Player* player : game.playerManager.playerList) player->isControlsEnabled = true; + } + manager.loadImages = {}; + return false; +} + +// Whether the item overlay or the yes/no prompt holds the frame: the prompt (a yes starts the victory lap's fade) and +// the online stats screen with no overlay up, else the overlay's own update unless the pause screen is open offline. +static bool overlays_update(Game& game) +{ + bool isOffline = !g_manager->netplayManager.is_online(); + + if (game.itemOverlay._state == 0) + { + if (game.genericPrompt.IsActive()) + { + game.genericPrompt.Update(PROMPT_INPUT_SKIP); + if (!game.genericPrompt.isOnlineVote && game.genericPrompt.submittedSelection == PROMPT_ANSWER_YES) + game.Fadeout(VICTORY_LAP_FADE_SPEED, FADEOUT_VICTORY_LAP); + return true; + } + return game.onlineStatsScreen.isActive; + } + + if (game.pauseScreen.state != PAUSE_HIDDEN && isOffline) return false; + game.itemOverlay.Update(0); + if (game.itemOverlay._state != ITEM_OVERLAY_PLAYING) return false; + + game.hud.PostUpdate(); + if (game.pauseScreen.state != PAUSE_HIDDEN) game.pauseScreen.animation_update(); + return true; +} + +// The run's own timers: the floor's name on the map button, the boss overlay, the Ascent's rumble into the next stage, +// the Death Certificate floor's exit, the clocks (a HUD refresh every second) and the darkness, dizziness and +// pixelation effects around the room's and the players' updates. +static void timers_update(Game& game) +{ + game.framesSinceRoomTransition++; + game.minimap.Update(); + if (game.bossOverlay._state != 0) BossOverlay::update(); + + if (game.ascentTimer > 0) + { + game.ascentTimer++; + game.screenShakeTimer = game.ascentTimer / ASCENT_SHAKE_DIVISOR + ASCENT_SHAKE_BASE; + if (game.ascentTimer >= ASCENT_FRAMES) + { + game.screenShakeTimer = 0; + game.ascentTimer = 0; + game.screenShakeOffset = {}; + reconstruction_missing("Game::StartStageTransition 006fdc10, at the Ascent's end"); + } + } + if (game.deathCertificateExitTimer > 0) + { + game.screenShakeTimer = DEATH_CERTIFICATE_SHAKE; + if (--game.deathCertificateExitTimer < 1) + { + game.deathCertificateExitTimer = 0; + if (game.currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) + { + game.leaveDoor = -1; + reconstruction_missing("Game::StartRoomTransition 006fd7c0, out of the Death Certificate floor"); + } + } + } + + game.timeCounter++; + if (++game.frameCount % HUD_REFRESH_INTERVAL == 0) game.hud.refresh_request(HUD_REFRESH_PLAYER); +} + +// Moves the darkness toward full while its timeout runs and back to none after, the dizziness toward its target and +// the pixelation's timer down. +static void screen_effects_update(Game& game) +{ + if (game.darknessTimeout < 1) game.darknessModifier = std::max(game.darknessModifier - DARKNESS_FALL, 0.0f); + else + { + game.darknessModifier = std::min(game.darknessModifier + DARKNESS_RISE, 1.0f); + game.darknessTimeout--; + } + + float step = game.dizzyIntensityChangeSpeed; + float target = game.dizzyTargetIntensity; + float& dizzy = game.dizzyIntensity; + if (dizzy != target && step < std::fabs(dizzy - target)) dizzy += target <= dizzy ? -step : step; + else dizzy = target; + + if (game.pixelationTimer > 0) game.pixelationTimer--; +} + +// 006fadc0 One 30 Hz tick of the run. Unless the console holds it: the trapdoor hum, the HUD, the versus timer, the +// screen effects' timers, the color modifier's lerp, the lightning and the fade out. Then the first thing still +// playing takes the tick: a hit stop, the game over or leaderboard screen, a stage or room transition, the prompt or +// item overlay, the fade in, the pause screen (opened when the window loses focus) or the co-op revive menu. Otherwise +// the run's timers count, the room and the players update, and the mods' post update runs. +// The online stats are not registered: Game's onlinePlayerStats stays a generated vector, as do the debug renderer's +// shapes, which never exist while DebugRenderer is generated. +void Game::Update() +{ + if (console.update_state()) return; + + trapdoor_loop_sfx_update(*this); + hud.Update(); + deathmatch_update(deathmatchManager); + if (bloomTimer > 0) bloomTimer--; + if (screenShakeTimer > 0 && --screenShakeTimer < 1) screenShakeOffset = {}; + if (hallucinationTimer > 0) hallucinationTimer--; + if (isColorModifierLerped) + { + currentColorModifier.move_toward(&targetColorModifier._red, &lerpColorModifier._red); + if (is_color_mod_equal(currentColorModifier, targetColorModifier)) isColorModifierLerped = false; + } + if (lightningIntensity > 0) lightningIntensity = lightningIntensity <= LIGHTNING_CUTOFF ? 0 : lightningIntensity * LIGHTNING_DECAY; + if (fadeout_update(*this)) hud.PostUpdate(); + + if (freezeFrames > 0) + { + freezeFrames--; + return hud.PostUpdate(); + } + if (gameOver._state != 0) return game_over_update(*this); + if (leaderboard.displayState != LEADERBOARD_HIDDEN) return leaderboard.Update(); + if (stageTransition._state != 0) + { + stageTransition.Update(); + return hud.PostUpdate(); + } + if (roomTransition.mode != TRANSITION_NONE) + { + roomTransition.Update(); + minimap.Update(); + hud.PostUpdate(); + if (roomTransition.mode != TRANSITION_NONE && roomTransition.bossIntroBossId != 0) framesSinceRoomTransition = 0; + return; + } + if (overlays_update(*this)) return; + if (fadein_update(*this)) return hud.PostUpdate(); + + Manager& manager = *g_manager; + bool isOffline = !manager.netplayManager.is_online(); + if (!manager.isWindowFocused && manager.optionsConfig.isPauseOnFocusLostEnabled && isOffline && + pauseScreen.state == PAUSE_HIDDEN) + pauseScreen.Show(); + if (pauseScreen.state != PAUSE_HIDDEN) + { + pauseScreen.animation_update(); + room->entityList.typeCache.clear(); + if (pauseScreen.is_pausing()) return; + } + if (isOffline && revivePlayerMenu.state != REVIVE_MENU_HIDDEN) return revivePlayerMenu.Update(); + + timers_update(*this); + room->Update(); + playerManager.Update(); + screen_effects_update(*this); + hud.PostUpdate(); + if (static_cast(g_luaEngine)->enabledCallbacks[MC_POST_UPDATE]) + reconstruction_missing("LuaEngine::PostUpdate 008607a0"); +} + +// 006fd3f0 The in-between update of odd frames with interpolation on, unless the console holds it. A room transition +// advances half a frame. During a room transition's start or landing (or, with none, a stage transition's), the +// players run a full update flagged as an interpolation one and the transition's entities interpolate. Then, unless +// the run is paused or the window lost focus (with pause on focus loss), the players update and collide with the grid +// again while everything else interpolates half a step, and the extra players update. +// The Beast arena's scroll and the stage transition's trapdoor landing scale stop the game: neither is modelled yet. +void Game::interpolate_update() +{ + Manager& manager = *g_manager; + EntityList_EL& entities = room->entityList.updateEL; + auto player_update = [](Entity& player) { + player.flags |= FLAG_INTERPOLATION_UPDATE; + player.Update(); + player.flags &= ~FLAG_INTERPOLATION_UPDATE; + }; + auto transition_update = [&](bool isStageTransition) { + for (size_t i = 0; i < entities.size(); i++) + { + Entity& entity = *entities[i]; + if (entity.is_player()) + { + player_update(entity); + if (isStageTransition) reconstruction_missing("StageTransition::update_player_trapdoor_scale 0092f050"); + } + else if (entity.flags & FLAG_TRANSITION_UPDATE) entity.Interpolate(); + } + }; + + if (console.update_state()) return; + + int stageState = stageTransition._state; + if (roomTransition.mode != TRANSITION_NONE) + { + if (roomTransition.frame != roomTransition.duration) roomTransition.progress += 0.5f / roomTransition.duration; + if (roomTransition.mode == TRANSITION_START || roomTransition.mode == TRANSITION_LANDING) transition_update(false); + } + else if (stageState == STAGE_TRANSITION_START || stageState == STAGE_TRANSITION_LANDING) transition_update(true); + + bool isFocusPaused = !manager.isWindowFocused && manager.optionsConfig.isPauseOnFocusLostEnabled && + !manager.netplayManager.is_online(); + if (IsPaused() || isFocusPaused) return; + + for (size_t i = 0; i < entities.size(); i++) + { + Entity& entity = *entities[i]; + if (!entity.is_player()) + { + entity.Interpolate(); + continue; + } + entity.flags |= FLAG_INTERPOLATION_UPDATE; + entity.Update(); + entity.PlayerCollideWithGrid(GRID_COLLISION_APPLY); + entity.flags &= ~FLAG_INTERPOLATION_UPDATE; + } + if (room->IsBeastDungeon()) reconstruction_missing("Game::interpolate_update 006fd3f0: the Beast arena's scroll"); + + room->isUnknown7220 = true; + for (size_t i = 0; i < playerManager.extraPlayers.size(); i++) player_update(*playerManager.extraPlayers[i]); +} + +// 007084c0 Remakes the render surfaces at the new window size: the room transition's, the rooms' sized by the screen +// (with the room's render surface placed again), the run's effects', the console's wrapping and the mods' shader targets. +void Game::recreate_render_targets() +{ + RoomSurfaces& rooms = roomSurfaces; + + roomTransition.surfaces_create(); + for (KAGE::Graphics::ImagePtr* surface : + {&rooms.shadow, &rooms.lightOverlay, &rooms.shockwave, &rooms.waterOverlay, &rooms.floorWater, &rooms.floorWaterV2, + &rooms.dizzy, &rooms.texturedPit, &rooms.dust, &rooms.dustTemp, &rooms.heatWave, &rooms.mirror}) + *surface = nullptr; + room_surfaces_init(); + room->isUnknown11f6 = true; + room->renderSurfaceTopLeft = vector_make((g_screenWidth - ROOM_SURFACE_WIDTH) * 0.5f - ROOM_SURFACE_MARGIN, + (g_screenHeight - ROOM_SURFACE_HEIGHT) * 0.5f - ROOM_SURFACE_MARGIN); + + for (KAGE::Graphics::ImagePtr* surface : + {&pixelationSurface, &bloomSurface, &oldTvSurface, &hallucinationSurface, &hallucinationSnapshot, &colormodSurface}) + *surface = nullptr; + create_render_surfaces(); + console.lines_wrap(); + g_manager->modManager.shader_render_targets_release(); + g_manager->modManager.create_shader_render_targets(); +} diff --git a/src/generic_prompt.h b/src/generic_prompt.h index 8421e47..d4a08b7 100644 --- a/src/generic_prompt.h +++ b/src/generic_prompt.h @@ -83,8 +83,6 @@ public: void SetText(const std::array& lines); void Update(PromptInput input); void Render(); - -private: void handle_input(); }; diff --git a/src/grid_entity.cpp b/src/grid_entity.cpp new file mode 100644 index 0000000..f889f1b --- /dev/null +++ b/src/grid_entity.cpp @@ -0,0 +1,302 @@ +#include "grid_entity.h" +#include "game.h" +#include "grid_entity_decoration.h" +#include "grid_entity_door.h" +#include "grid_entity_fire.h" +#include "grid_entity_gravity.h" +#include "grid_entity_lock.h" +#include "grid_entity_pit.h" +#include "grid_entity_poop.h" +#include "grid_entity_pressure_plate.h" +#include "grid_entity_rock.h" +#include "grid_entity_spikes.h" +#include "grid_entity_stairs.h" +#include "grid_entity_statue.h" +#include "grid_entity_teleporter.h" +#include "grid_entity_tnt.h" +#include "grid_entity_trap_door.h" +#include "grid_entity_wall.h" +#include "grid_entity_web.h" +#include "log.h" +#include "manager.h" +#include "room.h" +#include "seeds.h" +#include + +// What a pit's output trigger spawns and plays as it fills. +constexpr int EFFECT_POOF01 = 15; +constexpr int SOUND_ROCK_CRUMBLE = 137; + +// TNT still standing before its output trigger blows it up. +constexpr int TNT_STATE_STANDING_LAST = 3; + +// Plays a sound effect, unless the seeds swap it for a fart. +void grid_sound_play(int sound, SoundPlay play) +{ + seed_fart_sound_override(&sound); + g_manager->sfxManager.Play(sound, play); +} + +// 0070b2e0 A new grid entity of a type's class on a cell, not yet initialized, or null for a type with none. +GridEntity* CreateGridEntity(GridEntityType type, int gridIndex) +{ + GridEntity* entity = nullptr; + switch (type) + { + case GRID_DECORATION: + entity = new GridEntity_Decoration(); + break; + case GRID_ROCK: + case GRID_ROCKB: + case GRID_ROCKT: + case GRID_ROCK_BOMB: + case GRID_ROCK_ALT: + case GRID_ROCK_SS: + case GRID_PILLAR: + case GRID_ROCK_SPIKED: + case GRID_ROCK_ALT2: + case GRID_ROCK_GOLD: + entity = new GridEntity_Rock(); + break; + case GRID_PIT: + entity = new GridEntity_Pit(); + break; + case GRID_SPIKES: + case GRID_SPIKES_ONOFF: + case GRID_SPIKES_ALT: + entity = new GridEntity_Spikes(); + break; + case GRID_SPIDERWEB: + entity = new GridEntity_Web(); + break; + case GRID_LOCK: + entity = new GridEntity_Lock(); + break; + case GRID_TNT: + entity = new GridEntity_TNT(); + break; + case GRID_FIREPLACE: + entity = new GridEntity_Fire(); + break; + case GRID_POOP: + entity = new GridEntity_Poop(); + break; + case GRID_WALL: + entity = new GridEntity_Wall(); + break; + case GRID_DOOR: + entity = new GridEntity_Door(); + break; + case GRID_TRAPDOOR: + entity = new GridEntity_TrapDoor(); + break; + case GRID_STAIRS: + entity = new GridEntity_Stairs(); + break; + case GRID_GRAVITY: + entity = new GridEntity_Gravity(); + break; + case GRID_PRESSURE_PLATE: + entity = new GridEntity_PressurePlate(); + break; + case GRID_STATUE: + entity = new GridEntity_Statue(); + break; + case GRID_TELEPORTER: + entity = new GridEntity_Teleporter(); + break; + default: + return nullptr; + } + + entity->type = type; + entity->gridIndex = gridIndex; + return entity; +} + +// 00709db0 Seeds the entity and sets up its type, counting the spawn on the frame it happens. +void GridEntity::Init(uint32_t seed) +{ + spawnSeed = seed; + collisionClass = COLLISION_NONE; + subclass_init(); + spawnCount++; + isInitialized = true; + spawnFrame = g_game->frameCount; +} + +// The entity as the room saves its cell. +GridEntityDesc GridEntity::desc_save() +{ + return {type, variant, state, spawnCount, spawnSeed, varData, isInitialized, {}, variableSeed}; +} + +// The entity as a room's saved cell describes it. +void GridEntity::desc_load(const GridEntityDesc& desc) +{ + type = (GridEntityType)desc._type; + variant = desc._variant; + state = desc._state; + spawnCount = desc._spawnCount; + spawnSeed = desc._spawnSeed; + varData = desc._varData; + isInitialized = desc._initialized; + variableSeed = desc._variableSeed; +} + +// 00709df0 The center of the entity's cell in the world. +Vector GridEntity::Position() +{ + return g_game->room->GetGridPosition(gridIndex); +} + +// 00709e50 Where the entity's cell draws on screen, snapped to the display's pixels. +Vector GridEntity::get_render_position() +{ + return render_position_get(Position(), RENDER_SNAPPED); +} + +// Draws the sprite on the entity's cell, moved by an offset. +void GridEntity::sprite_render(const Vector& offset) +{ + Vector position = get_render_position(); + sprite.Render({.position = vector_make(position.x + offset.x, position.y + offset.y)}); +} + +// 0071edb0 Draws the sprite in the room's floor color. +void GridEntity::Render(const Vector& offset) +{ + sprite.color = g_game->room->floorColor; + sprite_render(offset); +} + +// 006a80c0 Takes no damage. +bool GridEntity::Hurt(int, const EntityRef&) +{ + return false; +} + +// 00709c10 Destroying is a hurt of 4. +bool GridEntity::Destroy(bool, const EntityRef& source) +{ + return Hurt(4, source); +} + +// 00709f90 Water clips solidly around the cell. +WaterClipInfo GridEntity::GetWaterClipInfo() +{ + return {WATER_CLIP_SOLID, 0}; +} + +// 00709c30 Tear effects can damage it. +bool GridEntity::CanTakeDamageFromTearEffects() +{ + return true; +} + +// Sets the room's grid path on the entity's cell. +void GridEntity::path_set(int value) +{ + if ((uint32_t)gridIndex < ROOM_GRID_CELLS) + g_game->room->gridPaths[gridIndex] = value; +} + +// 0070b2a0 Whether the entity is a rock that bombs and crushing break. +bool GridEntity::IsBreakableRock() +{ + switch (type) + { + case GRID_ROCK: + case GRID_ROCKT: + case GRID_ROCK_BOMB: + case GRID_ROCK_ALT: + case GRID_ROCK_SS: + case GRID_ROCK_SPIKED: + case GRID_ROCK_ALT2: + case GRID_ROCK_GOLD: + return true; + default: + return false; + } +} + +// 0070bec0 Whether a crushing entity walks through without harm: a free cell, a breakable rock or poop but red poop. +bool GridEntity::IsEasyCrushableOrWalkable() +{ + if ((uint32_t)gridIndex >= ROOM_GRID_CELLS || g_game->room->gridPaths[gridIndex] <= 0) + return true; + + bool isRock = type == GRID_ROCK || type == GRID_ROCK_ALT || type == GRID_ROCKT || type == GRID_ROCK_SS || + type == GRID_ROCK_ALT2; + return isRock || (type == GRID_POOP && variant != POOP_RED); +} + +// 0070bf10 Whether crushing it hurts: a free cell, TNT, a bomb rock, spikes or red poop. +bool GridEntity::IsDangerousCrushableOrWalkable() +{ + if ((uint32_t)gridIndex >= ROOM_GRID_CELLS || g_game->room->gridPaths[gridIndex] < GRID_PATH_SOLID) + return true; + + bool isHazard = type == GRID_TNT || type == GRID_ROCK_BOMB || type == GRID_SPIKES || type == GRID_SPIKES_ONOFF; + return isHazard || (type == GRID_POOP && variant == POOP_RED); +} + +// 00709fb0 Hurts one entity the way an exploding or breaking grid entity does. +void GridEntity::hurt_func(Entity&, const GridHurt&) +{ + reconstruction_missing("GridEntity::hurt_func 00709fb0"); +} + +// 0070b170 Hurts every colliding entity near the cell, players within their own distance. +void GridEntity::hurt_surroundings(const GridHurt& hurt) +{ + Vector position = Position(); + EntityList_EL& entities = g_game->room->entityList.updateEL; + for (size_t i = 0; i < entities.size(); i++) + { + Entity& entity = *entities[i]; + float radius = entity.type == ENTITY_PLAYER ? hurt.playerDistance : hurt.distance; + float dx = entity.pos.x - position.x; + float dy = entity.pos.y - position.y; + float distance = std::sqrt(dy * dy + dx * dx); + if (distance < radius + entity.size && entity.entityCollisionClass != ENTCOLL_NONE) + hurt_func(entity, hurt); + } +} + +// 00823150 Fires a pressure plate's output on the entity: TNT explodes, plates switch, event rocks break, event pits +// fill with a poof and teleporters toggle. +void GridEntity::trigger_output() +{ + switch (type) + { + case GRID_TNT: + if ((uint32_t)state <= TNT_STATE_STANDING_LAST) + Destroy(true, EntityRef()); + break; + case GRID_PRESSURE_PLATE: + if (state == 0) + sprite.Play("Switched"); + break; + case GRID_ROCK: + if (varData != 0 && state == ROCK_STATE_STANDING) + Destroy(true, EntityRef()); + break; + case GRID_PIT: + if (varData != 0 && state == PIT_STATE_EMPTY) + { + uint32_t seed = Random(); + g_game->Spawn({.position = Position(), .type = ENTITY_EFFECT, .variant = EFFECT_POOF01, .seed = seed}); + grid_sound_play(SOUND_ROCK_CRUMBLE); + state = PIT_STATE_FILLED; + static_cast(this)->UpdateCollision(); + } + break; + case GRID_TELEPORTER: + sprite.Play(state == TELEPORTER_STATE_OFF ? "TurnOn" : "TurnOff"); + state = state == TELEPORTER_STATE_OFF ? TELEPORTER_STATE_ON : TELEPORTER_STATE_OFF; + break; + default: + break; + } +} diff --git a/src/grid_entity.h b/src/grid_entity.h new file mode 100644 index 0000000..aab82ef --- /dev/null +++ b/src/grid_entity.h @@ -0,0 +1,135 @@ +#pragma once + +#include "anm2.h" +#include "classes.h" +#include "entity.h" +#include "sfx_manager.h" +#include + +// The grid entity types (Lua's GridEntityType). The last, which Lua leaves unnamed, makes spikes. +enum GridEntityType : int +{ + GRID_NULL, + GRID_DECORATION, + GRID_ROCK, + GRID_ROCKB, + GRID_ROCKT, + GRID_ROCK_BOMB, + GRID_ROCK_ALT, + GRID_PIT, + GRID_SPIKES, + GRID_SPIKES_ONOFF, + GRID_SPIDERWEB, + GRID_LOCK, + GRID_TNT, + GRID_FIREPLACE, + GRID_POOP, + GRID_WALL, + GRID_DOOR, + GRID_TRAPDOOR, + GRID_STAIRS, + GRID_GRAVITY, + GRID_PRESSURE_PLATE, + GRID_STATUE, + GRID_ROCK_SS, + GRID_TELEPORTER, + GRID_PILLAR, + GRID_ROCK_SPIKED, + GRID_ROCK_ALT2, + GRID_ROCK_GOLD, + GRID_SPIKES_ALT +}; + +// What a grid entity blocks (Lua's GridCollisionClass). +enum GridCollision : int +{ + COLLISION_NONE, + COLLISION_PIT, + COLLISION_OBJECT, + COLLISION_SOLID, + COLLISION_WALL, + COLLISION_WALL_EXCEPT_PLAYER +}; + +// The room's grid path a grid entity claims for its cell: freed when it breaks, solid while it stands. +constexpr int GRID_PATH_FREED = 900; +constexpr int GRID_PATH_SOLID = 1000; + +// The seeds and RNG a grid entity holds before Init seeds it. +constexpr uint32_t GRID_SEED_DEFAULT = 0x16a9de81; +constexpr RNG GRID_RNG_DEFAULT = {0xaa17414f, 5, 9, 7}; + +// How water clips around a grid entity (REPENTOGON's WaterClipInfo): which sides, and how far. +struct WaterClipInfo +{ + uint32_t flags = 0; + float value = 0; +}; + +// The water clips the grid entities use. +constexpr uint32_t WATER_CLIP_SOLID = 0x39; +constexpr uint32_t WATER_CLIP_FLAT = 0x26; +constexpr uint32_t WATER_CLIP_RAISED = 0x19; + +// What hurt_func and hurt_surroundings deal to the entities near a grid entity. +struct GridHurt +{ + uint64_t damageFlags = 0; + float damage = 0; + float distance = 0; + float playerDistance = 0; + int playerDamage = 0; + bool isIgnoreGridCollisionClass = false; +}; + +// Construction, destruction and the deleting destructors (00709c40, 00709cb0, 00709d40) are the defaults. The field +// accessors (004073c0, 00428930, 0043eec0, 004e4830, 0067efc0, 00709c00, 00738140, 0085dda0) are the public fields. +// Lua's Hurt, Destroy, PostInit and Update (0085ddb0, 0085de20, 008c5cd9, 008c5ce8, 008c5cfc) are the virtual calls, +// with a default EntityRef for the source. An obstacle on one cell of the room's grid (Lua's GridEntity): rocks, pits, +// poop, spikes, doors, walls and the rest. Its type, variant, state and seeds are the GridEntityDesc a room saves for +// the cell. +struct GridEntity +{ + ANM2 sprite; + RNG rng = GRID_RNG_DEFAULT; + GridEntityType type = GRID_NULL; + GridCollision collisionClass = COLLISION_NONE; + int gridIndex = 0; + int spawnCount = 0; + int spawnFrame = 0; + int state = 0; + int varData = 0; + int variant = 0; + uint32_t spawnSeed = GRID_SEED_DEFAULT; + uint32_t variableSeed = GRID_SEED_DEFAULT; + bool isInitialized = false; + + virtual ~GridEntity() = default; + virtual void PostInit() + {} + virtual void Update() = 0; + virtual void Render(const Vector& offset); + virtual bool Hurt(int damage, const EntityRef& source); + virtual bool Destroy(bool isImmediate, const EntityRef& source); + virtual WaterClipInfo GetWaterClipInfo(); + virtual bool CanTakeDamageFromTearEffects(); + // Slot 8, which the decompile calls BeginBatches: what a type sets up before its first update. + virtual void subclass_init() = 0; + + void Init(uint32_t seed); + GridEntityDesc desc_save(); + void desc_load(const GridEntityDesc& desc); + Vector Position(); + Vector get_render_position(); + void sprite_render(const Vector& offset); + void path_set(int value); + bool IsBreakableRock(); + bool IsEasyCrushableOrWalkable(); + bool IsDangerousCrushableOrWalkable(); + void hurt_func(Entity& entity, const GridHurt& hurt); + void hurt_surroundings(const GridHurt& hurt); + void trigger_output(); +}; + +GridEntity* CreateGridEntity(GridEntityType type, int gridIndex); +void grid_sound_play(int sound, SoundPlay play = {}); diff --git a/src/grid_entity_decoration.cpp b/src/grid_entity_decoration.cpp new file mode 100644 index 0000000..9eff794 --- /dev/null +++ b/src/grid_entity_decoration.cpp @@ -0,0 +1,122 @@ +#include "grid_entity_decoration.h" +#include "entity_player.h" +#include "game.h" +#include "log.h" +#include "room.h" +#include "seeds.h" +#include +#include +#include + +constexpr int BACKDROP_CAVES = 4; +constexpr int BACKDROP_CATACOMBS = 5; +constexpr int BACKDROP_GREED_SHOP = 20; +constexpr int BACKDROP_DUNGEON_GIDEON = 55; +constexpr int BACKDROP_DUNGEON_ROTGUT = 56; + +// The G FUEL seed's props: on the second and later floors, every fifth seed, and always on these stages. +constexpr int GFUEL_STAGES[] = {3, 4, 11}; +constexpr uint32_t GFUEL_SEED_STEP = 5; + +// How many props Init draws before keeping one that suits the room. +constexpr int DECORATION_ATTEMPTS = 20; + +// 0099acc0 Picks the prop: a crawlspace's ladder, Greed's props, or one of the backdrop's (G FUEL's on its seed) drawn +// from the cell's decoration seed until it suits the backdrop and the room has no puddle yet. Counts the puddles. +void GridEntity_Decoration::subclass_init() +{ + if (variant == DECORATION_HIDDEN) + return; + + Room& room = *g_game->room; + bool isGreed = g_game->difficulty == DIFFICULTY_GREED || g_game->difficulty == DIFFICULTY_GREEDIER; + int backdrop = room.backdropType; + uint32_t seed = gridIndex + room.GetDecorationSeed(); + RNG rng = {seed, 5, 9, 7}; + if (room.roomType == ROOM_DUNGEON) + { + if (backdrop == BACKDROP_DUNGEON_ROTGUT) + { + sprite.Load("gfx/grid/Tiles_Rotgut.anm2", GRAPHICS_LOAD); + if (variant == DECORATION_LADDER_LOW) + sprite.SetFrame("Ladder", 0); + if (variant == DECORATION_LADDER_MIDDLE) + sprite.SetFrame("Ladder", 1); + if (variant == DECORATION_LADDER_HIGH) + sprite.SetFrame("Ladder", 2); + return; + } + + bool isGideon = backdrop == BACKDROP_DUNGEON_GIDEON; + sprite.Load(isGideon ? "gfx/grid/Tiles_Itemdungeon_Gideon.anm2" : "gfx/grid/Tiles_Itemdungeon.anm2", + GRAPHICS_LOAD); + if (variant == DECORATION_LADDER_LOW) + sprite.Play("Ladder1"); + if (variant == DECORATION_LADDER_MIDDLE) + sprite.Play("Ladder2"); + if (variant == DECORATION_LADDER_HIGH) + sprite.Play("Ladder3"); + return; + } + if (isGreed && (variant == DECORATION_LADDER_LOW || backdrop == BACKDROP_GREED_SHOP)) + { + sprite.Load("gfx/grid/Props_12_Greed.anm2", GRAPHICS_LOAD); + sprite.PlayRandom(rng.Next()); + return; + } + + std::string path = room.backdrop.configs[backdrop].props; + int stage = (int)g_game->stage; + bool isGfuelStage = std::find(std::begin(GFUEL_STAGES), std::end(GFUEL_STAGES), stage) != std::end(GFUEL_STAGES) || + (stage > 1 && seed % GFUEL_SEED_STEP == 0); + if (g_game->seedEffects.HasSeedEffect(SEED_G_FUEL) && isGfuelStage) + path = "gfx/promo/gfuel/grid/props_gfuel.anm2"; + if (path.empty()) + return; + + sprite.Load(path, GRAPHICS_LOAD); + for (int attempt = 0; attempt < DECORATION_ATTEMPTS; attempt++) + { + sprite.PlayRandom(rng.Next()); + const std::string& name = sprite.GetAnimation(); + bool isWrongCaves = name.rfind("Caves") != std::string::npos && backdrop != BACKDROP_CAVES; + bool isWrongCatacombs = name.rfind("Catacombs") != std::string::npos && backdrop != BACKDROP_CATACOMBS; + bool isExtraPuddle = name.find("Puddle") != std::string::npos && room.unknown721c != 0; + if (!isWrongCaves && !isWrongCatacombs && !isExtraPuddle) + break; + } + if (sprite.GetAnimation().find("Puddle") != std::string::npos) + room.unknown721c++; +} + +// 0099a8e0 Animates the prop. A puddle stays on its frame and stains the next footprint of a player walking on it. +// Sampling the puddle's color waits for Sprite::GetTexel (0040b590). +void GridEntity_Decoration::Update() +{ + if (variant == DECORATION_HIDDEN || !sprite.isLoaded) + return; + + sprite.Update(); + if (sprite.GetAnimation().find("Puddle") == std::string::npos) + return; + + if (sprite.animState.animData) + sprite.animState.isPlaying = false; + for (Entity_Player* player : g_game->playerManager.playerList) + if (player->entityGridCollisionClass == GRIDCOLL_GROUND) + reconstruction_missing("GridEntity_Decoration::Update 0099a8e0: a " + "puddle's color (Sprite::GetTexel 0040b590)"); +} + +// 0099ac00 Draws the prop in the room's floor color. +void GridEntity_Decoration::Render(const Vector& offset) +{ + if (variant != DECORATION_HIDDEN && sprite.isLoaded) + GridEntity::Render(offset); +} + +// 00714750 Water lies flat over the prop. +WaterClipInfo GridEntity_Decoration::GetWaterClipInfo() +{ + return {WATER_CLIP_FLAT, 0}; +} diff --git a/src/grid_entity_decoration.h b/src/grid_entity_decoration.h new file mode 100644 index 0000000..98db7b7 --- /dev/null +++ b/src/grid_entity_decoration.h @@ -0,0 +1,19 @@ +#pragma once + +#include "grid_entity.h" + +// The decoration variant that shows nothing, and the crawlspace ladders' variants. +constexpr int DECORATION_HIDDEN = 1000; +constexpr int DECORATION_LADDER_LOW = 10; +constexpr int DECORATION_LADDER_MIDDLE = 20; +constexpr int DECORATION_LADDER_HIGH = 30; + +// A floor prop of the room's backdrop (Lua's GRID_DECORATION), or a crawlspace's ladder. Puddles stain the footprints +// of the players walking over them. +struct GridEntity_Decoration : GridEntity +{ + void subclass_init() override; + void Update() override; + void Render(const Vector& offset) override; + WaterClipInfo GetWaterClipInfo() override; +}; diff --git a/src/grid_entity_door.cpp b/src/grid_entity_door.cpp new file mode 100644 index 0000000..c6a34d8 --- /dev/null +++ b/src/grid_entity_door.cpp @@ -0,0 +1,1217 @@ +#include "grid_entity_door.h" +#include "entity_familiar.h" +#include "game.h" +#include "log.h" +#include "manager.h" +#include "room.h" +#include "seeds.h" +#include + +// The rooms a door can lead to off the map: the Downpour's mirror and the Mines' shaft. +constexpr int DOOR_TARGET_MIRROR = -100; +constexpr int DOOR_TARGET_MINESHAFT = -101; + +// The stage of the Blue Womb, the dimension of Downpour's mirror world and of Home's dark closet, and Home's stage. +constexpr uint32_t STAGE_BLUE_WOMB = 9; +constexpr uint32_t STAGE_DARK_ROOM = 11; +constexpr uint32_t STAGE_VOID = 12; +constexpr uint32_t STAGE_HOME = 13; +constexpr int DIMENSION_MIRROR = 1; +constexpr int DIMENSION_DEATH_CERTIFICATE = 2; +constexpr int STAGE_ID_HOME = 35; +constexpr int BACKDROP_DARK_ROOM = 16; + +// The secret exits get_secret_exit_kind tells apart, by the exit room's subtype, and the boss subtype of Mom's Heart's +// exit. +constexpr int BOSS_SUBTYPE_MOMS_HEART = 90; + +// Home's rooms by subtype: the closet doors crack on the first, tint on the second. +constexpr int HOME_SUBTYPE_CRACKED = 0; +constexpr int HOME_SUBTYPE_TINTED = 2; +constexpr int HOME_SUBTYPE_CLOSET = 3; +constexpr int HOME_LAYER_LIGHT_FIRST = 3; +constexpr int HOME_LAYER_LIGHT_LAST = 4; +constexpr ColorMod HOME_TINTED_COLOR = {{0.9f, 0.7f, 1, 1}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr float HOME_ALT_TINT[3] = {0.5f, 0.5f, 0.54f}; + +// Greed mode's exit stays barred until this wave, one more on Greedier. +constexpr int GREED_EXIT_WAVE = 10; + +// A room the blue map redirects to a blue room. +constexpr uint32_t ROOM_DESCRIPTOR_FLAG_BLUE_REDIRECT = 1 << 18; + +// The run state bits doors set and read: Mega Satan's door unlocked, and Mom's Heart's exit opened. +constexpr uint64_t GAME_STATE_MEGA_SATAN_DOOR_OPENED = 1ull << 49; +constexpr uint64_t GAME_STATE_HEART_EXIT_OPENED = 1ull << 52; + +// The items, trinkets and challenge doors answer to. +constexpr int COLLECTIBLE_PAY_TO_PLAY = 380; +constexpr int TRINKET_SHINY_ROCK = 62; +constexpr int TRINKET_BROKEN_PADLOCK = 136; +constexpr int TRINKET_FLAT_FILE = 151; +constexpr uint32_t CHALLENGE_PAY_TO_PLAY = 24; +constexpr int FAMILIAR_KEY_FULL = 236; +constexpr int FAMILIAR_STATE_KEY_DOOR = 1; +constexpr int ONLINE_STAT_SECRET_DOORS_BOMBED = 19; + +// How far a door's sprite stands out from the wall, and the angles its sprites turn to by direction. +constexpr float DOOR_SPRITE_OFFSET = 15; +constexpr float DOOR_ANGLES[4] = {-90, 0, 90, 180}; +constexpr float RIGHT_ANGLE = 90; +constexpr float DEG_TO_RAD = 0.017453292f; + +// The frame a closing or opening door plays its sound on, and the sounds. +constexpr int DOOR_SOUND_FRAME = 2; +constexpr int DOOR_SOUND_DELAY = 10; +constexpr int SOUND_DOOR_HEAVY_CLOSE = 35; +constexpr int SOUND_METAL_DOOR_CLOSE = 46; +constexpr int SOUND_METAL_DOOR_OPEN = 47; +constexpr int SOUND_HELLBOSS_GROUNDPOUND = 52; +constexpr int SOUND_MEAT_FEET_SLOW = 68; +constexpr int SOUND_UNLOCK = 156; +constexpr int SOUND_SHINYROCK_SHIMMER = 1014; +constexpr float GROUNDPOUND_PITCH = 0.33f; + +// The frames after its spawn a door shows its open or barred animation from the start. +constexpr int DOOR_APPEAR_FRAMES = 11; +constexpr int DOOR_SETTLE_FRAMES = 10; +constexpr int DOOR_PHOTO_SETTLE_FRAMES = 2; + +// In co-op, a door back to the room just left waits this many updates before it opens. +constexpr int DOOR_REOPEN_DELAY = 30; + +// The cursed door's spikes, as a box around the door's cell by direction: left, top, right and bottom. +constexpr float SPIKE_BOXES[4][4] = {{-43, -20, 15, 20}, {-20, -43, 20, 15}, {-15, -20, 43, 20}, {-20, -15, 20, 43}}; +constexpr uint64_t DAMAGE_CURSED_DOOR = 1ull << 16; +constexpr uint64_t DAMAGE_NO_PENALTIES = 1ull << 28; + +// The Shiny Rock's sparkle: every so many frames, faster with a stronger rock. +constexpr int SPARKLE_PERIOD = 300; +constexpr int SPARKLE_PERIOD_STRONG = 150; +constexpr int SPARKLE_STRONG_MULTIPLIER = 3; + +// A blue redirected room's background, and the light flickering through Home's closet door. +constexpr ColorMod BLUE_REDIRECT_COLOR = {{1, 1, 1, 1}, {0.8f, 1.1f, 1.8f, 0.8f}, {0, 0, 0}}; +constexpr float CLOSET_LIGHT_BASE = 0.5f; +constexpr float CLOSET_LIGHT_RANGE = 0.2f; +constexpr float UINT_TO_UNIT = 2.3283064e-10f; + +// Whether a room type is one of the secret rooms walls hide. +static bool is_secret_room_type(int roomType) +{ + return roomType == ROOM_SECRET || roomType == ROOM_SUPERSECRET || roomType == ROOM_ULTRASECRET; +} + +// Whether a room type is a secret or super secret room. +static bool is_hidden_room_type(int roomType) +{ + return roomType == ROOM_SECRET || roomType == ROOM_SUPERSECRET; +} + +// Whether a room descriptor has a flag. +static bool has_room_flag(RoomDescriptor* room, uint32_t flag) +{ + return room->flags & flag; +} + +// The subtype of a room's layout, or -1 for a room without one or of another type. +static int room_subtype_get(RoomDescriptor* room, int type) +{ + if (!room || !room->data || room->data->type != type) + return -1; + return room->data->subtype; +} + +// Gives every layer of a sprite the same spritesheet. +static void spritesheets_replace(ANM2& sprite, std::string_view path) +{ + for (int layer = 0; layer < (int)sprite.layerStates.size(); layer++) + sprite.ReplaceSpritesheet(layer, path); +} + +// Shows or hides a sprite's layer, when it has one. +static void layer_show(ANM2& sprite, int layerId, bool isVisible) +{ + if (LayerState* layer = sprite.GetLayer(layerId)) + layer->isVisible = isVisible; +} + +// 007eea90 Puts a door on a slot that has none, reusing a door already on its cell, facing the slot's wall. The +// original indexes the grid with an invalid cell: such a slot gets no door here. +void Room::MakeDoor(int slot) +{ + if (doors[slot]) + return; + + int gridIndex = doorGridPositions[slot]; + if (gridIndex < 0) + { + KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"invalid GridIndex while spawning door (slot %d)"); + return; + } + + GridEntity_Door* door = dynamic_cast(gridEntities[gridIndex]); + if (!door) + { + door = static_cast(CreateGridEntity(GRID_DOOR, gridIndex)); + door->variant = DOOR_UNSPECIFIED; + door->state = DOOR_STATE_INIT; + delete gridEntities[gridIndex]; + gridEntities[gridIndex] = door; + } + door->Init(Random()); + + door->direction = (Direction)(slot % 4); + float angle = DOOR_ANGLES[door->direction]; + door->sprite.rotation = angle; + door->extraSprite.rotation = angle; + door->sparkleSprite.rotation = angle; + door->slot = slot; + doors[slot] = door; +} + +// 00711590 Closes a door that starts open and blocks its cell. Its rooms, direction and look come later. +void GridEntity_Door::subclass_init() +{ + if (state == DOOR_STATE_INIT || state == DOOR_STATE_OPEN) + state = DOOR_STATE_CLOSED; + previousState = state; + previousVariant = variant; + path_set(GRID_PATH_SOLID); + + updateCount = 0; + targetRoomType = ROOM_NULL; + currentRoomType = ROOM_NULL; + targetRoomIdx = -1; + isExtraVisible = false; + isBusted = false; + isUnlockedByPlayer = false; + doorFlags = 0; + direction = DIRECTION_NONE; +} + +// 00435fc0 Whether the door stands open. +bool GridEntity_Door::IsOpen() +{ + return state == DOOR_STATE_OPEN; +} + +// 00435fd0 Whether the door is locked some way a key, bomb or familiar opens. +bool GridEntity_Door::IsLocked() +{ + return variant == DOOR_LOCKED || variant == DOOR_LOCKED_BARRED || variant == DOOR_LOCKED_CRACKED || + variant == DOOR_LOCKED_DOUBLE || variant == DOOR_LOCKED_KEYFAMILIAR; +} + +// 005cd5f0 Whether either room the door joins is of a type. +bool GridEntity_Door::IsRoomType(int roomType) +{ + return currentRoomType == roomType || targetRoomType == roomType; +} + +// 0060cff0 Whether the key pieces' familiar opens the door. +bool GridEntity_Door::IsKeyFamiliarTarget() +{ + return variant == DOOR_LOCKED_KEYFAMILIAR; +} + +// 0070f670 Tear effects hurt every door but the mirror. +bool GridEntity_Door::CanTakeDamageFromTearEffects() +{ + return !(doorFlags & DOOR_FLAG_MIRROR); +} + +// 00711720 Water does not clip around doors. +WaterClipInfo GridEntity_Door::GetWaterClipInfo() +{ + return {0, 0}; +} + +// 0070d360 Which secret exit the door leads to or from, by the exit room's subtype, or Mom's Heart's exit for a boss +// room of its subtype. +int GridEntity_Door::get_secret_exit_kind() +{ + Room& room = *g_game->room; + if (targetRoomType == ROOM_SECRET_EXIT) + { + RoomDescriptor* target = g_game->GetRoomByIdx(targetRoomIdx); + return target->data ? target->data->subtype : SECRET_EXIT_NONE; + } + if (currentRoomType == ROOM_SECRET_EXIT) + return room.descriptor->data ? room.descriptor->data->subtype : SECRET_EXIT_NONE; + + RoomDescriptor* boss = nullptr; + if (targetRoomType == ROOM_BOSS) + boss = g_game->GetRoomByIdx(targetRoomIdx); + else if (currentRoomType == ROOM_BOSS) + boss = room.descriptor; + else + return SECRET_EXIT_NONE; + bool isHeartExit = boss->data && boss->data->subtype == BOSS_SUBTYPE_MOMS_HEART; + return isHeartExit ? SECRET_EXIT_MOMS_HEART : SECRET_EXIT_NONE; +} + +// 00711690 Whether coins open the door: an arcade, or a room the Pay To Play item or challenge locks with coins. +bool GridEntity_Door::IsTargetRoomArcade() +{ + if (targetRoomType == ROOM_ARCADE) + return true; + + bool isKeyRoom = targetRoomType == ROOM_SHOP || targetRoomType == ROOM_TREASURE || + targetRoomType == ROOM_PLANETARIUM || targetRoomType == ROOM_CHEST || + targetRoomType == ROOM_DICE || get_secret_exit_kind() == SECRET_EXIT_DOWNPOUR || + targetRoomType == ROOM_LIBRARY; + if (isKeyRoom && g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_PAY_TO_PLAY, LAZARUS_SHARE_CHECK)) + return true; + return g_game->challenge == CHALLENGE_PAY_TO_PLAY && !is_secret_room_type(targetRoomType) && + targetRoomType != ROOM_CHALLENGE; +} + +// The lock an unspecified door gets from the rooms it joins (SetRoomTypes' choice): Greed's exit until its wave, the +// secret exits and Mom's Heart's exit, keys for the rooms worth one, cracks and coins for the special rooms, bars on a +// miniboss's room until it is clear, the key pieces for Mega Satan, and hidden for secret rooms. +static int door_lock_pick(GridEntity_Door& door, bool isGreed, bool isMirrorWorld) +{ + Room& room = *g_game->room; + int cur = door.currentRoomType; + int tgt = door.targetRoomType; + int idx = door.targetRoomIdx; + if (isGreed && tgt == ROOM_GREED_EXIT && + g_game->greedModeWave < GREED_EXIT_WAVE + (g_game->difficulty == DIFFICULTY_GREEDIER)) + return DOOR_LOCKED_GREED; + + bool isSecretSide = is_secret_room_type(cur) || cur == ROOM_CURSE; + int exitKind = door.get_secret_exit_kind(); + if (!isSecretSide && exitKind != SECRET_EXIT_NONE) + { + if (exitKind == SECRET_EXIT_MAUSOLEUM) + door.varData = 1; + if (g_game->currentRoomIdx == ROOM_SECRET_EXIT_IDX) + return DOOR_UNLOCKED; + return exitKind == SECRET_EXIT_MINES || exitKind == SECRET_EXIT_MOMS_HEART ? DOOR_LOCKED_CRACKED : DOOR_LOCKED; + } + if (g_game->currentRoomIdx == ROOM_BLUE_ROOM_IDX) + return DOOR_UNLOCKED; + if (idx == DOOR_TARGET_MINESHAFT && g_game->currentDimensionIdx == 0) + return DOOR_LOCKED_CRACKED; + if (idx == DOOR_TARGET_MIRROR) + return DOOR_LOCKED; + + if (!isSecretSide) + { + bool isPayToPlay = + g_game->challenge == CHALLENGE_PAY_TO_PLAY && !is_secret_room_type(tgt) && tgt != ROOM_CHALLENGE; + bool isFirstFloor = g_game->stage == 1 && !g_game->IsAltPath(); + bool isTreasureLocked = tgt == ROOM_TREASURE && !isMirrorWorld && !isFirstFloor && !isGreed; + bool isShopLocked = tgt == ROOM_SHOP && !isMirrorWorld && !isFirstFloor && !g_game->IsGreedMode() && + !g_game->playerManager.FirstPlayerByType(PLAYER_KEEPER_B); + bool isHushLocked = tgt == ROOM_BOSS && idx >= 0 && g_game->stage == STAGE_BLUE_WOMB; + if (tgt == ROOM_ARCADE || isPayToPlay || tgt == ROOM_PLANETARIUM || tgt == ROOM_LIBRARY || isTreasureLocked || + isShopLocked || isHushLocked) + return DOOR_LOCKED; + } + + bool isBarCheck = room.isSurpriseMiniboss; + if (!is_hidden_room_type(cur)) + { + if (isGreed && tgt == ROOM_TREASURE && idx == (int)g_game->greedModeTreasureRoomIdx) + return DOOR_LOCKED; + if (cur != ROOM_ULTRASECRET) + { + if (tgt == ROOM_ISAACS || tgt == ROOM_BARREN) + return DOOR_LOCKED_CRACKED; + if (tgt == ROOM_DICE || tgt == ROOM_CHEST) + return DOOR_LOCKED_DOUBLE; + isBarCheck = isBarCheck || cur == ROOM_MINIBOSS; + } + } + bool isClear = room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_CLEAR; + if (isBarCheck && !isClear && !is_secret_room_type(tgt)) + return DOOR_LOCKED_BARRED; + if (idx == ROOM_MEGA_SATAN_IDX) + return DOOR_LOCKED_KEYFAMILIAR; + if (is_secret_room_type(cur) || is_secret_room_type(tgt)) + return DOOR_HIDDEN; + return DOOR_UNLOCKED; +} + +// 00710fa0 Joins two room types, picks the lock of a door that has none from them and loads the sprite to match. A red +// room's secret doors are plain, and its key, chain and crack locks open on the way out of the red rooms. +void GridEntity_Door::SetRoomTypes(int current, int target) +{ + bool isGreed = g_game->difficulty == DIFFICULTY_GREED || g_game->difficulty == DIFFICULTY_GREEDIER; + currentRoomType = current; + targetRoomType = target; + bool isMirrorWorld = g_game->HasMirrorDimension() && g_game->currentDimensionIdx == DIMENSION_MIRROR; + bool isCurrentRed = has_room_flag(g_game->GetRoomByIdx(g_game->currentRoomIdx, g_game->currentDimensionIdx), + ROOM_DESCRIPTOR_FLAG_RED_ROOM); + bool isTargetRed = has_room_flag(g_game->GetRoomByIdx(targetRoomIdx), ROOM_DESCRIPTOR_FLAG_RED_ROOM); + if (isCurrentRed || isTargetRed) + { + if (is_hidden_room_type(currentRoomType)) + currentRoomType = ROOM_DEFAULT; + if (is_hidden_room_type(targetRoomType)) + targetRoomType = ROOM_DEFAULT; + } + + if (variant == DOOR_UNSPECIFIED) + variant = door_lock_pick(*this, isGreed, isMirrorWorld); + bool isKeyLock = variant == DOOR_LOCKED || variant == DOOR_LOCKED_DOUBLE || variant == DOOR_LOCKED_CRACKED; + if (isKeyLock && isCurrentRed && !isTargetRed) + variant = DOOR_UNLOCKED; + + LoadSprite(); + UpdateAnimation(); + if (targetRoomType == ROOM_ULTRASECRET) + TryBlowOpen(false, nullptr); + if (doorFlags & DOOR_FLAG_MINESHAFT) + sprite.SetLastFrame(); +} + +// Loads the normal door, its spritesheet red for the red rooms, the special rooms' own, or the backdrop's. +static void normal_door_load(GridEntity_Door& door) +{ + Room& room = *g_game->room; + door.sprite.Load("gfx/grid/Door_01_NormalDoor.anm2", GRAPHICS_DEFER); + bool isRed = has_room_flag(room.descriptor, ROOM_DESCRIPTOR_FLAG_RED_ROOM) || + has_room_flag(g_game->GetRoomByIdx(door.targetRoomIdx), ROOM_DESCRIPTOR_FLAG_RED_ROOM); + std::string_view sheet = room.backdrop.configs[room.backdropType].door; + if (isRed) + sheet = "gfx/grid/door_00_reddoor.png"; + else if (door.IsRoomType(ROOM_SHOP)) + sheet = "gfx/grid/door_00_shopdoor.png"; + else if (door.IsRoomType(ROOM_CHEST)) + sheet = "gfx/grid/door_02b_chestroomdoor.png"; + else if (door.IsRoomType(ROOM_LIBRARY)) + sheet = "gfx/grid/door_13_librarydoor.png"; + else if (door.IsRoomType(ROOM_DICE)) + sheet = "gfx/grid/door_00_diceroomdoor.png"; + else if (door.IsRoomType(ROOM_SACRIFICE)) + sheet = "gfx/grid/door_00_sacrificeroomdoor.png"; + spritesheets_replace(door.sprite, sheet); + door.sprite.LoadGraphics(); + door.lockedAnimation = "KeyClosed"; + door.openLockedAnimation = "KeyOpen"; +} + +// Loads Home's closet and bedroom doors: cracked into the first rooms, red in the red rooms and the dark closet, with +// the light through the crack only on the way out of a red room. +static void house_door_load(GridEntity_Door& door) +{ + Room& room = *g_game->room; + ANM2& sprite = door.sprite; + sprite.Load("gfx/grid/Door_House.anm2", GRAPHICS_DEFER); + layer_show(sprite, HOME_LAYER_LIGHT_FIRST, false); + layer_show(sprite, HOME_LAYER_LIGHT_LAST, false); + + RoomDescriptor* target = g_game->GetRoomByIdx(door.targetRoomIdx); + int currentSubtype = room_subtype_get(room.descriptor, ROOM_DEFAULT); + int targetSubtype = room_subtype_get(target, ROOM_DEFAULT); + if (currentSubtype == HOME_SUBTYPE_CRACKED || targetSubtype == HOME_SUBTYPE_CRACKED) + spritesheets_replace(sprite, "gfx/grid/door_house_cracked.png"); + else + { + bool isCurrentRed = has_room_flag(room.descriptor, ROOM_DESCRIPTOR_FLAG_RED_ROOM); + bool isTargetRed = has_room_flag(target, ROOM_DESCRIPTOR_FLAG_RED_ROOM); + if (isCurrentRed || isTargetRed || g_game->currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) + { + spritesheets_replace(sprite, "gfx/grid/door_closet_red.png"); + if (isCurrentRed && !isTargetRed && g_game->stageType == 0) + { + layer_show(sprite, HOME_LAYER_LIGHT_FIRST, true); + layer_show(sprite, HOME_LAYER_LIGHT_LAST, true); + } + } + } + + LayerState* base = sprite.GetLayer(0); + if (base && targetSubtype == HOME_SUBTYPE_TINTED) + base->color = HOME_TINTED_COLOR; + if (base && g_game->stageType == 1) + for (int i = 0; i < 3; i++) + base->color._tint[i] *= HOME_ALT_TINT[i]; + sprite.isFlipX = door.direction == DIRECTION_DOWN; + sprite.isFlipY = door.direction == DIRECTION_RIGHT; + sprite.LoadGraphics(); +} + +// Loads the door between rooms without a secret exit, by the rooms it joins: +// spiked for curse rooms and the Curse of the Cursed, the special rooms' own doors, Home's doors, or the normal door. +static void special_door_load(GridEntity_Door& door) +{ + Room& room = *g_game->room; + ANM2& sprite = door.sprite; + int currentIdx = g_game->currentRoomIdx; + bool isCursedFloor = g_game->GetCurses() & CURSE_OF_THE_CURSED; + if (door.IsRoomType(ROOM_CURSE) || + (isCursedFloor && door.targetRoomType == ROOM_DEFAULT && door.currentRoomType == ROOM_DEFAULT)) + { + sprite.Load("gfx/grid/Door_04_SelfSacrificeRoomDoor.anm2", GRAPHICS_LOAD); + if (g_game->playerManager.AnyoneHasTrinket(TRINKET_FLAT_FILE) || door.varData == 1) + { + spritesheets_replace(sprite, "gfx/grid/door_04_selfsacrificeroomdoor_nospikes.png"); + sprite.LoadGraphics(); + door.varData = 1; + } + door.doorFlags |= DOOR_FLAG_SPIKED; + return; + } + if (door.IsRoomType(ROOM_ARCADE)) + { + sprite.Load("gfx/grid/Door_05_ArcadeRoomDoor.anm2", GRAPHICS_LOAD); + door.lockedAnimation = "KeyClosed"; + door.openAnimation = "Open"; + door.openLockedAnimation = "KeyOpen"; + sprite.LoadGraphics(); + door.doorFlags |= DOOR_FLAG_COIN_LOCK; + return; + } + if (door.targetRoomType == ROOM_GREED_EXIT) + { + sprite.Load("gfx/grid/Door_32_ExitDoor.anm2", GRAPHICS_LOAD); + door.openAnimation = "Open"; + return; + } + + bool isTreasure = door.IsRoomType(ROOM_TREASURE); + if (isTreasure || door.IsRoomType(ROOM_PLANETARIUM)) + { + int greedIdx = (int)g_game->greedModeTreasureRoomIdx; + bool isGreedSide = g_game->IsGreedMode() && greedIdx != door.targetRoomIdx && greedIdx != currentIdx; + bool isDevilTreasure = + has_room_flag(g_game->GetCurrentRoomDesc(), ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE) || + has_room_flag(g_game->GetRoomByIdx(door.targetRoomIdx), ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE); + const char* path = "gfx/grid/Door_00x_PlanetariumDoor.anm2"; + if (isTreasure && isGreedSide) + path = "gfx/grid/Door_31_TreasureRoomDoorGreed.anm2"; + else if (isTreasure && isDevilTreasure) + path = "gfx/grid/Door_02_TreasureRoomDoor_Devil.anm2"; + else if (isTreasure) + path = "gfx/grid/Door_02_TreasureRoomDoor.anm2"; + sprite.Load(path, GRAPHICS_LOAD); + door.openAnimation = "Open"; + door.openLockedAnimation = "KeyOpen"; + door.lockedAnimation = "KeyClosed"; + return; + } + if (door.IsRoomType(ROOM_BOSSRUSH)) + { + sprite.Load("gfx/grid/Door_15_BossRushDoor.anm2", GRAPHICS_LOAD); + door.openAnimation = "Opened"; + return; + } + if (door.targetRoomIdx == ROOM_BLUE_WOMB_IDX || currentIdx == ROOM_BLUE_WOMB_IDX) + { + sprite.Load("gfx/grid/door_29_doortobluewomb.anm2", GRAPHICS_DEFER); + if (currentIdx == ROOM_BLUE_WOMB_IDX) + spritesheets_replace(sprite, "gfx/grid/door_29_doortobluewomb_blue.png"); + sprite.LoadGraphics(); + door.openAnimation = "Opened"; + return; + } + if (door.targetRoomIdx == ROOM_MEGA_SATAN_IDX || currentIdx == ROOM_MEGA_SATAN_IDX) + { + sprite.Load("gfx/grid/Door_24_MegaSatanDoor.anm2", GRAPHICS_LOAD); + door.closeAnimation = "Closed"; + return; + } + + bool isHushBoss = door.IsRoomType(ROOM_BOSS) && currentIdx >= 0 && door.targetRoomIdx >= 0; + bool isVoid = door.targetRoomIdx == ROOM_THE_VOID_IDX || currentIdx == ROOM_THE_VOID_IDX; + if (g_game->stage == STAGE_BLUE_WOMB && (isHushBoss || isVoid)) + { + sprite.Load("gfx/grid/door_30_HushDoor.anm2", GRAPHICS_LOAD); + door.closeAnimation = "Closed"; + door.lockedAnimation = "Closed"; + door.openLockedAnimation = "Opening"; + door.openAnimation = "Opening"; + return; + } + if (door.IsRoomType(ROOM_BOSS)) + { + sprite.Load("gfx/grid/Door_10_BossRoomDoor.anm2", GRAPHICS_LOAD); + if (LayerState* key = sprite.GetLayer("Key")) + key->isVisible = door.targetRoomType == ROOM_BOSS; + return; + } + if (door.IsRoomType(ROOM_CHALLENGE)) + { + RoomConfig_Room* current = g_game->GetCurrentRoomDesc()->data; + RoomConfig_Room* target = g_game->GetRoomByIdx(door.targetRoomIdx)->data; + auto is_boss_challenge = [](RoomConfig_Room* data) { + return data->type == ROOM_CHALLENGE && data->subtype == 1; + }; + bool isBoss = current && target && (is_boss_challenge(current) || is_boss_challenge(target)); + sprite.Load(isBoss ? "gfx/grid/Door_09_BossAmbushRoomDoor.anm2" : "gfx/grid/Door_03_AmbushRoomDoor.anm2", + GRAPHICS_LOAD); + door.doorFlags |= DOOR_FLAG_AMBUSH; + return; + } + if (door.IsRoomType(ROOM_DEVIL)) + { + bool isDevilTreasure = + has_room_flag(g_game->GetCurrentRoomDesc(), ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE) || + has_room_flag(g_game->GetRoomByIdx(door.targetRoomIdx), ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE); + sprite.Load(isDevilTreasure ? "gfx/grid/Door_02_TreasureRoomDoor_Devil.anm2" + : "gfx/grid/Door_07_DevilRoomDoor.anm2", + GRAPHICS_LOAD); + return; + } + if (door.IsRoomType(ROOM_ANGEL)) + { + sprite.Load("gfx/grid/Door_07_HolyRoomDoor.anm2", GRAPHICS_LOAD); + return; + } + + RoomConfig_Room* data = room.descriptor->data; + if (data && data->stageId == STAGE_ID_HOME) + house_door_load(door); + else + normal_door_load(door); +} + +// Loads the door into or out of a secret exit, or out of Mom's Heart's room. +// Returns whether its extra sprite may load. +static bool exit_door_load(GridEntity_Door& door, int exitKind) +{ + ANM2& sprite = door.sprite; + bool isExtraAllowed = true; + door.openAnimation = "Open"; + door.openLockedAnimation = "KeyOpen"; + door.lockedAnimation = "KeyClosed"; + switch (exitKind) + { + case SECRET_EXIT_DOWNPOUR: + sprite.Load("gfx/grid/Door_Downpour.anm2", GRAPHICS_LOAD); + break; + case SECRET_EXIT_MINES: + sprite.Load("gfx/grid/Door_Mines.anm2", GRAPHICS_LOAD); + door.extraSprite.Load("gfx/grid/Door_Mines_Planks.anm2", GRAPHICS_LOAD); + break; + case SECRET_EXIT_MAUSOLEUM: + if (!g_game->HasPhotoDoor()) + { + sprite.Load("gfx/grid/Door_Mausoleum.anm2", GRAPHICS_LOAD); + break; + } + sprite.Load("gfx/grid/Door_Mausoleum_Alt.anm2", GRAPHICS_LOAD); + layer_show(sprite, 1, true); + layer_show(sprite, 2, false); + layer_show(sprite, 4, false); + door.doorFlags |= DOOR_FLAG_PHOTO; + door.openLockedAnimation = "Open"; + break; + case SECRET_EXIT_MOMS_HEART: + sprite.Load("gfx/grid/Door_MomsHeart.anm2", GRAPHICS_LOAD); + isExtraAllowed = false; + if (g_game->currentRoomIdx == ROOM_SECRET_EXIT_IDX) + door.closeAnimation = "Disappear"; + break; + default: + sprite.Load("gfx/grid/Door_01_NormalDoor.anm2", GRAPHICS_LOAD); + break; + } + + if (door.targetRoomType != ROOM_SECRET_EXIT) + { + if (LayerState* background = sprite.GetLayer("Background")) + { + background->color._colorize[0] = 0.5f; + background->color._colorize[1] = 0.5f; + background->color._colorize[2] = 0.5f; + background->color._colorize[3] = 0.6f; + } + if (LayerState* light = sprite.GetLayer("Light")) + light->isVisible = false; + } + return isExtraAllowed; +} + +// 0070d3f0 Loads the sprites for the rooms the door joins: the mirror, the mineshaft, a hole in the wall for secret +// rooms (sparkling for the Shiny Rock), the secret exits, or the special rooms' doors. Pay To Play turns key locks into +// coin locks. The sprite stands out from the wall, and the extra sprite shows the chains, cracks or bars. +void GridEntity_Door::LoadSprite() +{ + Room& room = *g_game->room; + if (extraSprite.isLoaded) + extraSprite.Reset(); + bool isExtraAllowed = true; + doorFlags = 0; + openAnimation = "Open"; + closeAnimation = "Close"; + float offsetLength = DOOR_SPRITE_OFFSET; + if (targetRoomIdx == DOOR_TARGET_MIRROR) + { + sprite.Load("gfx/grid/door_downpour_mirror.anm2", GRAPHICS_LOAD); + doorFlags |= DOOR_FLAG_MIRROR; + openAnimation = "Break"; + openLockedAnimation = "Break"; + lockedAnimation = "Closed"; + } + else if (targetRoomIdx == DOOR_TARGET_MINESHAFT) + { + bool isLight = g_game->currentDimensionIdx == DIMENSION_MIRROR; + sprite.Load(isLight ? "gfx/grid/door_mines_mineshaft_light.anm2" : "gfx/grid/door_mines_mineshaft_dark.anm2", + GRAPHICS_LOAD); + doorFlags |= DOOR_FLAG_MINESHAFT; + if (variant == DOOR_LOCKED_BARRED) + { + isExtraAllowed = false; + closeAnimation = "Collapse"; + lockedAnimation = "Collapsed"; + } + } + else if (is_secret_room_type(currentRoomType) || is_secret_room_type(targetRoomType)) + { + if (is_hidden_room_type(currentRoomType) || is_hidden_room_type(targetRoomType)) + sparkleSprite.Load("gfx/door_sparkle.anm2", GRAPHICS_LOAD); + if (room.backdropType == BACKDROP_DARK_ROOM) + sprite.Load("gfx/grid/door_08_holeinwall _darkroom.anm2", GRAPHICS_LOAD); + else + { + sprite.Load("gfx/grid/Door_08_HoleInWall.anm2", GRAPHICS_DEFER); + sprite.ReplaceSpritesheet(0, room.backdrop.configs[room.backdropType].holeInWall); + sprite.LoadGraphics(); + } + sprite.color = room.wallColor; + doorFlags |= DOOR_FLAG_HOLE_IN_WALL; + offsetLength = 0; + } + else if (int exitKind = get_secret_exit_kind()) + isExtraAllowed = exit_door_load(*this, exitKind); + else + special_door_load(*this); + + bool isPayToPlay = g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_PAY_TO_PLAY, LAZARUS_SHARE_CHECK) || + g_game->challenge == CHALLENGE_PAY_TO_PLAY; + bool isKeyLocked = variant == DOOR_LOCKED || variant == DOOR_LOCKED_DOUBLE; + bool isArcadeSide = currentRoomType == ROOM_ARCADE || targetRoomType == ROOM_ARCADE; + if (isPayToPlay && isKeyLocked && !isArcadeSide && + (openLockedAnimation == "KeyOpen" || g_game->challenge == CHALLENGE_PAY_TO_PLAY)) + { + if (sprite.GetAnimationData("CoinClosed")) + { + lockedAnimation = "CoinClosed"; + openLockedAnimation = "CoinOpen"; + } + doorFlags |= DOOR_FLAG_COIN_LOCK; + } + + float angle = (sprite.rotation + RIGHT_ANGLE) * DEG_TO_RAD; + sprite.offset = vector_make(std::cos(angle) * offsetLength, std::sin(angle) * offsetLength); + extraSprite.offset = sprite.offset; + if (!extraSprite.isLoaded && isExtraAllowed) + { + if (variant == DOOR_LOCKED_DOUBLE) + extraSprite.Load("gfx/grid/door_16_doublelock.anm2", GRAPHICS_LOAD); + else if (variant == DOOR_LOCKED_CRACKED) + extraSprite.Load("gfx/grid/door_18_crackeddoor.anm2", GRAPHICS_LOAD); + else if (variant == DOOR_LOCKED_BARRED || variant == DOOR_LOCKED_GREED) + { + extraSprite.Load("gfx/grid/door_17_bardoor.anm2", GRAPHICS_LOAD); + closeAnimation = "Closed"; + } + } + isExtraVisible = false; +} + +// 0070ee40 Plays the animation for the door's state and lock: hidden, locked, barred or chained shut, closed, or open +// (with the golden key's, coins' or chains' own). A door older than the room skips to the end of it, as does a door +// that just spawned open. A lock removed lets its bars vanish. +void GridEntity_Door::UpdateAnimation() +{ + if (!sprite.isLoaded) + return; + + isExtraVisible = false; + int spawnAge = g_game->frameCount - spawnFrame; + int roomAge = g_game->room->GetFrameCount(); + layer_show(sprite, 0, true); + if (targetRoomType == ROOM_NULL) + return; + + bool isShut = state == DOOR_STATE_CLOSED || state == DOOR_STATE_DAMAGED || state == DOOR_STATE_HALF_OPEN || + state == DOOR_STATE_OPEN_DENIED; + bool isExitSide = currentRoomType == ROOM_SECRET_EXIT || targetRoomType == ROOM_SECRET_EXIT; + if (isShut) + { + bool isSecret = is_secret_room_type(currentRoomType) || is_secret_room_type(targetRoomType); + if (isSecret && variant == DOOR_HIDDEN) + sprite.Play("Hidden"); + else if (variant == DOOR_LOCKED) + { + if (isExitSide && get_secret_exit_kind() == SECRET_EXIT_MAUSOLEUM && state == DOOR_STATE_HALF_OPEN) + { + sprite.Play("Feed", PLAY_FORCED); + previousState = state; + previousVariant = variant; + return; + } + sprite.Play(lockedAnimation); + } + else if (variant == DOOR_LOCKED_BARRED || variant == DOOR_LOCKED_CRACKED || variant == DOOR_LOCKED_DOUBLE || + variant == DOOR_LOCKED_GREED) + { + sprite.Play(closeAnimation); + if (!(doorFlags & DOOR_FLAG_MINESHAFT)) + sprite.SetLastFrame(); + if (extraSprite.isLoaded) + { + isExtraVisible = true; + if (variant == DOOR_LOCKED_DOUBLE) + { + const char* chain = "TwoChains"; + if (state == DOOR_STATE_HALF_OPEN && previousState == DOOR_STATE_HALF_OPEN) + chain = "OneChain"; + else if (state == DOOR_STATE_HALF_OPEN) + chain = g_game->GetPlayer(0)->hasGoldenKey ? "GoldenKeyOpenChain1" : "KeyOpenChain1"; + extraSprite.Play(chain); + } + else + { + bool isBars = variant == DOOR_LOCKED_BARRED || variant == DOOR_LOCKED_GREED; + const char* name = "Idle"; + if (state == DOOR_STATE_DAMAGED) + name = "Damaged"; + else if (isBars && spawnAge >= DOOR_APPEAR_FRAMES) + name = "Appear"; + extraSprite.Play(name); + if (isExitSide && get_secret_exit_kind() == SECRET_EXIT_MINES) + layer_show(sprite, 2, state != DOOR_STATE_DAMAGED); + } + } + } + else if (!closeAnimation.empty()) + { + sprite.Play(closeAnimation); + if (extraSprite.isLoaded && variant != DOOR_UNLOCKED) + { + isExtraVisible = true; + extraSprite.Play("Appear"); + } + } + + bool isAmbushBehind = (doorFlags & DOOR_FLAG_AMBUSH) && slot != g_game->enterDoor && spawnAge == 0; + if (spawnAge < roomAge || isAmbushBehind) + sprite.SetLastFrame(); + } + else + { + bool isHushBoss = targetRoomType == ROOM_BOSS && targetRoomIdx >= 0 && g_game->stage == STAGE_BLUE_WOMB; + if (variant == DOOR_LOCKED) + { + bool isGoldenKey = g_game->GetPlayer(0)->hasGoldenKey; + bool isOwnLock = + IsRoomType(ROOM_ARCADE) || IsRoomType(ROOM_CHALLENGE) || + g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_PAY_TO_PLAY, LAZARUS_SHARE_CHECK) || isHushBoss; + sprite.Play(!isGoldenKey || isOwnLock ? std::string_view(openLockedAnimation) : "GoldenKeyOpen"); + } + else + { + if (variant == DOOR_LOCKED_DOUBLE) + { + extraSprite.Play(g_game->GetPlayer(0)->hasGoldenKey ? "GoldenKeyOpenChain2" : "KeyOpenChain2"); + isExtraVisible = true; + } + sprite.Play(openAnimation); + if (targetRoomIdx == ROOM_MEGA_SATAN_IDX) + for (Entity* entity : g_game->room->entityList.updateEL) + if (entity->type == ENTITY_FAMILIAR && entity->variant == FAMILIAR_KEY_FULL) + static_cast(entity)->state = FAMILIAR_STATE_KEY_DOOR; + } + + int settleFrames = doorFlags & DOOR_FLAG_PHOTO ? DOOR_PHOTO_SETTLE_FRAMES : DOOR_SETTLE_FRAMES; + if (roomAge <= spawnAge && spawnAge < settleFrames) + { + sprite.SetLastFrame(); + isExtraVisible = false; + } + } + + bool isBars = variant == DOOR_LOCKED_BARRED || variant == DOOR_LOCKED_GREED; + bool wasBars = previousVariant == DOOR_LOCKED_BARRED || previousVariant == DOOR_LOCKED_GREED; + if (!isBars && wasBars) + { + extraSprite.Play("Vanish"); + isExtraVisible = true; + } + previousState = state; + previousVariant = variant; +} + +// Whether a door may open now: in co-op, a door back to the room just left waits a moment. +static bool is_reopen_ready(GridEntity_Door& door) +{ + bool isBack = door.targetRoomIdx == g_game->lastRoomIdx && g_manager->netplayManager.is_online(); + return !isBack || door.updateCount > DOOR_REOPEN_DELAY; +} + +// 0070c5c0 Opens Mega Satan's and Mom's Heart's doors once their flags say so, blocks the cell while the door is shut +// or opening, sounds its closing and an ambush door's opening, and plays Opened once an open animation ends. A cursed +// door's spikes hurt the players touching them. An ambush door the challenge cannot start closes again. Then animates, +// shakes the screen on the animation's events, colors blue redirected rooms and Home's closet light, and sparkles a +// hidden room's door for the Shiny Rock. +void GridEntity_Door::Update() +{ + Room& room = *g_game->room; + updateCount++; + if (variant == DOOR_LOCKED_KEYFAMILIAR && (g_game->gameStateFlags & GAME_STATE_MEGA_SATAN_DOOR_OPENED)) + { + variant = DOOR_UNLOCKED; + UpdateAnimation(); + Open(); + } + + bool isHeartExitOpen = + get_secret_exit_kind() == SECRET_EXIT_MOMS_HEART && (g_game->gameStateFlags & GAME_STATE_HEART_EXIT_OPENED); + bool isLockedShut = IsLocked() || state != DOOR_STATE_OPEN; + if (isHeartExitOpen && isLockedShut && (room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_CLEAR)) + { + if (variant != DOOR_LOCKED_BARRED) + { + if (variant == DOOR_LOCKED_KEYFAMILIAR) + g_game->gameStateFlags |= GAME_STATE_MEGA_SATAN_DOOR_OPENED; + variant = DOOR_UNLOCKED; + UpdateAnimation(); + } + Open(); + } + + bool isOpening = sprite.animState.animData && sprite.animState.isPlaying; + bool isWaitedOpen = targetRoomIdx == ROOM_MEGA_SATAN_IDX || g_game->currentRoomIdx == ROOM_MEGA_SATAN_IDX || + (targetRoomType == ROOM_BOSS && g_game->stage == STAGE_BLUE_WOMB) || + (targetRoomType == ROOM_SECRET_EXIT && g_game->HasPhotoDoor()); + if (state == DOOR_STATE_OPEN && !(doorFlags & DOOR_FLAG_MIRROR)) + { + if (!isWaitedOpen || !isOpening) + collisionClass = COLLISION_WALL_EXCEPT_PLAYER; + } + else + { + collisionClass = COLLISION_WALL; + const AnimationData* data = sprite.animState.animData; + if (sprite.IsPlaying(closeAnimation) && data && !data->isLooping && sprite.GetFrame() == DOOR_SOUND_FRAME) + { + int sound = doorFlags & DOOR_FLAG_AMBUSH ? SOUND_METAL_DOOR_CLOSE : SOUND_DOOR_HEAVY_CLOSE; + grid_sound_play(sound, {.frameDelay = DOOR_SOUND_DELAY}); + } + } + + if ((doorFlags & DOOR_FLAG_AMBUSH) && state == DOOR_STATE_OPEN && sprite.IsPlaying(openAnimation)) + { + const AnimationData* data = sprite.animState.animData; + if ((!data || !data->isLooping) && sprite.GetFrame() == DOOR_SOUND_FRAME) + grid_sound_play(SOUND_METAL_DOOR_OPEN, {.frameDelay = DOOR_SOUND_DELAY}); + } + + bool isExitPlain = (doorFlags & DOOR_FLAG_COIN_LOCK) || targetRoomType == ROOM_GREED_EXIT; + bool isIdle = !sprite.animState.animData || !sprite.animState.isPlaying; + bool isSecret = is_secret_room_type(currentRoomType) || is_secret_room_type(targetRoomType); + if (variant == DOOR_UNLOCKED && isExitPlain && currentRoomType == ROOM_DEFAULT && isIdle) + { + if (state == DOOR_STATE_OPEN) + sprite.Play("Opened"); + else if (state == DOOR_STATE_CLOSED) + sprite.Play("Closed"); + } + else if (isSecret || (targetRoomType == ROOM_BOSS && + !(g_game->GetRoomByIdx(targetRoomIdx)->flags & ROOM_DESCRIPTOR_FLAG_CLEAR))) + { + if (sprite.IsFinished(openAnimation)) + sprite.Play("Opened"); + } + + bool isCursedFloor = (g_game->GetCurses() & CURSE_OF_THE_CURSED) && targetRoomType == ROOM_DEFAULT && + currentRoomType == ROOM_DEFAULT; + if ((doorFlags & DOOR_FLAG_SPIKED) && (uint32_t)direction < 4 && varData == 0) + { + Vector cell = Position(); + const float* box = SPIKE_BOXES[direction]; + for (Entity_Player* player : g_game->playerManager.playerList) + { + bool isExposed = + player->entityGridCollisionClass == GRIDCOLL_GROUND || room.roomType == ROOM_CURSE || isCursedFloor; + bool isInside = cell.x + box[0] <= player->pos.x && cell.y + box[1] <= player->pos.y && + player->pos.x <= cell.x + box[2] && player->pos.y <= cell.y + box[3]; + if (!isExposed || !isInside) + continue; + + g_game->save_rewind_state(slot); + player->TakeDamage(1, DAMAGE_CURSED_DOOR | DAMAGE_NO_PENALTIES, EntityRef(), 0); + } + } + + bool isAmbushOpen = targetRoomType == ROOM_CHALLENGE && (doorFlags & DOOR_FLAG_AMBUSH) && !isBusted && + currentRoomType != ROOM_ULTRASECRET && + !(room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_RED_ROOM) && state != DOOR_STATE_CLOSED && + !isUnlockedByPlayer; + if (isAmbushOpen && !g_game->CanOpenChallengeRoom(targetRoomIdx)) + Close(false); + + sprite.Update(); + extraSprite.Update(); + if (sprite.animState.animData) + { + if (sprite.WasEventTriggered("ScreenshakeStop")) + reconstruction_missing("GridEntity_Door::Update 0070c5c0: Game::ShakeScreen"); + else if (sprite.WasEventTriggered("ScreenshakeStart")) + { + reconstruction_missing("GridEntity_Door::Update 0070c5c0: Game::ShakeScreen"); + if (sprite.IsEventTriggered("ScreenshakeStart")) + grid_sound_play(SOUND_HELLBOSS_GROUNDPOUND, {.pitch = GROUNDPOUND_PITCH}); + } + } + if (targetRoomType == ROOM_SECRET_EXIT && get_secret_exit_kind() == SECRET_EXIT_MAUSOLEUM && + sprite.animState.animData) + { + if (sprite.IsEventTriggered("Sound")) + { + if (g_game->HasPhotoDoor()) + grid_sound_play(SOUND_HELLBOSS_GROUNDPOUND, {.pitch = GROUNDPOUND_PITCH}); + else + { + grid_sound_play(SOUND_MEAT_FEET_SLOW); + if (variant == DOOR_UNLOCKED) + grid_sound_play(SOUND_UNLOCK); + } + } + if (sprite.IsEventTriggered("FX")) + reconstruction_missing("GridEntity_Door::Update 0070c5c0: Game::ShakeScreen and SpawnDust"); + } + + RoomDescriptor* target = g_game->GetRoomByIdx(targetRoomIdx); + if (target->flags & ROOM_DESCRIPTOR_FLAG_BLUE_REDIRECT) + if (LayerState* background = sprite.GetLayer("Background")) + background->color = BLUE_REDIRECT_COLOR; + + RoomConfig_Room* data = room.descriptor->data; + bool isCloset = + data && data->stageId == STAGE_ID_HOME && room_subtype_get(target, ROOM_DEFAULT) == HOME_SUBTYPE_CLOSET; + if (isCloset && g_game->stageType == 1) + { + float alpha = (float)Random() * UINT_TO_UNIT * CLOSET_LIGHT_RANGE + CLOSET_LIGHT_BASE; + layer_show(sprite, HOME_LAYER_LIGHT_FIRST, true); + if (LayerState* light = sprite.GetLayer(HOME_LAYER_LIGHT_FIRST)) + light->color = {{0.9f, 0.93f, 1, alpha}, {0, 0, 0, 0}, {0, 0, 0}}; + if (LayerState* base = sprite.GetLayer(0)) + base->color = {{1, 1, 1, 1}, {3, 3, 3.2f, alpha}, {0, 0, 0}}; + } + + int shinyRock = g_game->playerManager.GetTrinketMultiplier(TRINKET_SHINY_ROCK); + bool isSparkled = currentRoomType == ROOM_SECRET || targetRoomType == ROOM_SECRET || + (shinyRock >= SPARKLE_STRONG_MULTIPLIER && + (currentRoomType == ROOM_SUPERSECRET || targetRoomType == ROOM_SUPERSECRET)); + if (state != DOOR_STATE_OPEN && shinyRock > 1 && isSparkled) + { + int period = shinyRock >= SPARKLE_STRONG_MULTIPLIER ? SPARKLE_PERIOD_STRONG : SPARKLE_PERIOD; + if (room.GetFrameCount() % period == 0) + { + grid_sound_play(SOUND_SHINYROCK_SHIMMER); + sparkleSprite.Play("Sparkle", PLAY_FORCED); + } + } + sparkleSprite.Update(); +} + +// 0070d1e0 Draws a visible door in the walls' color, its chains or bars, and the Shiny Rock's sparkle on a shut hidden +// room's door. +void GridEntity_Door::Render(const Vector& offset) +{ + if (sprite.color._tint[3] <= 0) + return; + + Vector position = get_render_position(); + SpriteDraw draw = {.position = vector_make(position.x + offset.x, position.y + offset.y)}; + sprite.color = g_game->room->wallColor; + sprite.Render(draw); + if (isExtraVisible) + extraSprite.Render(draw); + + int shinyRock = g_game->playerManager.GetTrinketMultiplier(TRINKET_SHINY_ROCK); + if (shinyRock <= 1 || state == DOOR_STATE_OPEN) + return; + + bool isSparkled = currentRoomType == ROOM_SECRET || targetRoomType == ROOM_SECRET || + (shinyRock >= SPARKLE_STRONG_MULTIPLIER && IsRoomType(ROOM_SUPERSECRET)); + if (isSparkled) + sparkleSprite.Render(draw); +} + +// 00710dd0 Opens the door, unless its lock or its rooms keep it shut: the mirror until broken, a collapsed shaft, a +// hidden room, Greed's exit before its wave, a key lock to a room not yet visited, an ambush in progress, or a +// challenge room that cannot start. In co-op a door back to the last room may refuse for a moment. A Greed treasure +// room's door locks instead of opening. +void GridEntity_Door::Open() +{ + if ((doorFlags & DOOR_FLAG_MIRROR) && variant != DOOR_UNLOCKED) + return; + if ((doorFlags & DOOR_FLAG_MINESHAFT) && variant == DOOR_LOCKED_BARRED) + return; + if (state == DOOR_STATE_OPEN || variant == DOOR_HIDDEN) + return; + + if (targetRoomType == ROOM_CHALLENGE) + { + bool isFromHidden = is_hidden_room_type(currentRoomType); + if (!g_game->CanOpenChallengeRoom(targetRoomIdx) && !isUnlockedByPlayer && !isFromHidden) + return; + } + else + { + if (currentRoomType == ROOM_CHALLENGE) + { + if (g_game->ambush._isActive && !isUnlockedByPlayer) + return; + } + else + { + if (IsRoomType(ROOM_NULL)) + return; + + bool isGreedExitBarred = + targetRoomType == ROOM_GREED_EXIT && + g_game->greedModeWave < GREED_EXIT_WAVE + (g_game->difficulty == DIFFICULTY_GREEDIER); + bool isVisitedKeyLock = variant == DOOR_LOCKED && g_game->GetRoomByIdx(targetRoomIdx)->visitedCount != 0; + bool isStuck = + variant == DOOR_LOCKED_GREED ? isGreedExitBarred : variant != DOOR_LOCKED_BARRED && !isVisitedKeyLock; + if (isStuck && variant != DOOR_UNLOCKED) + return; + } + if (!is_reopen_ready(*this)) + { + state = DOOR_STATE_OPEN_DENIED; + return; + } + } + + if (variant == DOOR_LOCKED_KEYFAMILIAR) + g_game->gameStateFlags |= GAME_STATE_MEGA_SATAN_DOOR_OPENED; + if (variant == DOOR_LOCKED_GREED && targetRoomType == ROOM_TREASURE && + targetRoomIdx == (int)g_game->greedModeTreasureRoomIdx) + { + variant = DOOR_LOCKED; + UpdateAnimation(); + return; + } + state = DOOR_STATE_OPEN; + variant = DOOR_UNLOCKED; + UpdateAnimation(); +} + +// 00710d30 Closes the door, unless it already is and the close is not forced. A secret room's door opens back through +// its plain animation. +void GridEntity_Door::Close(bool isForce) +{ + if (state == DOOR_STATE_CLOSED && !isForce) + return; + + state = DOOR_STATE_CLOSED; + UpdateAnimation(); + if (is_secret_room_type(currentRoomType) || is_secret_room_type(targetRoomType)) + openAnimation = "Open"; +} + +// 00710d90 Bars the door shut, loading the bars when it has none or is the mineshaft's. +void GridEntity_Door::Bar() +{ + state = DOOR_STATE_CLOSED; + variant = DOOR_LOCKED_BARRED; + if (!extraSprite.isLoaded || (doorFlags & DOOR_FLAG_MINESHAFT)) + LoadSprite(); + UpdateAnimation(); +} + +// 00711630 Locks the door with a key, or unlocks it. Bars stay until unlocked, and unlocking Mega Satan's door records +// it. +void GridEntity_Door::SetLocked(bool isLocked) +{ + if (variant == DOOR_LOCKED_BARRED && !isLocked) + return; + if (variant == DOOR_LOCKED_KEYFAMILIAR && !isLocked) + g_game->gameStateFlags |= GAME_STATE_MEGA_SATAN_DOOR_OPENED; + variant = isLocked ? DOOR_LOCKED : DOOR_UNLOCKED; + UpdateAnimation(); +} + +// 0070f680 Whether a bomb opens the door: not on the Dark Room, Chest or Void before the room is clear, nor on Home. +// The Broken Padlock opens key locks, every plain door between normal rooms opens, and a secret room's wall opens +// unless a boss, an uncleared miniboss or an unfinished challenge holds the room. Cracks always open, and a stronger +// padlock opens coin, ambush, key piece and boss doors. +bool GridEntity_Door::CanBlowOpen() +{ + Room& room = *g_game->room; + bool isGreed = g_game->difficulty == DIFFICULTY_GREED || g_game->difficulty == DIFFICULTY_GREEDIER; + bool isClear = room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_CLEAR; + if (!isGreed && (g_game->stage == STAGE_DARK_ROOM || g_game->stage == STAGE_VOID) && !isClear) + return false; + if (targetRoomType == ROOM_NULL || state == DOOR_STATE_OPEN || g_game->stage == STAGE_HOME) + return false; + if (g_game->playerManager.AnyoneHasTrinket(TRINKET_BROKEN_PADLOCK) && + (variant == DOOR_LOCKED || variant == DOOR_LOCKED_DOUBLE)) + return true; + + bool isSecretWall = false; + if (currentRoomType == ROOM_DEFAULT && targetRoomType == ROOM_DEFAULT) + { + bool isKeyed = variant == DOOR_LOCKED || variant == DOOR_LOCKED_BARRED || variant == DOOR_LOCKED_DOUBLE || + variant == DOOR_LOCKED_KEYFAMILIAR; + if (!isKeyed) + return true; + } + else + { + bool isTargetSecret = + targetRoomType == ROOM_SECRET || IsRoomType(ROOM_SUPERSECRET) || IsRoomType(ROOM_ULTRASECRET); + isSecretWall = currentRoomType == ROOM_SECRET || (isTargetSecret && currentRoomType != ROOM_BOSS); + } + bool isHeld = (room.isSurpriseMiniboss || currentRoomType == ROOM_MINIBOSS) && !isClear; + bool isChallengeHeld = + currentRoomType == ROOM_CHALLENGE && !(room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_CHALLENGE_DONE); + if (isSecretWall && targetRoomType != ROOM_BOSS && !isHeld && !isChallengeHeld) + return true; + if (variant == DOOR_LOCKED_CRACKED) + return true; + + bool isSpecialLock = (doorFlags & (DOOR_FLAG_COIN_LOCK | DOOR_FLAG_AMBUSH)) || targetRoomType == ROOM_BOSS || + variant == DOOR_LOCKED_KEYFAMILIAR; + Entity_Player* owner = isSpecialLock ? g_game->playerManager.FirstTrinketOwner(TRINKET_BROKEN_PADLOCK) : nullptr; + if (!owner) + return false; + + int multiplier = owner->GetTrinketMultiplier(TRINKET_BROKEN_PADLOCK); + if (multiplier == 2) + return (doorFlags & (DOOR_FLAG_COIN_LOCK | DOOR_FLAG_AMBUSH)) || variant == DOOR_LOCKED_KEYFAMILIAR; + return multiplier >= 3 && targetRoomType == ROOM_BOSS; +} + +// 0070f5e0 Blows the door open. A player's bomb opening a secret room never visited counts in the online stats. +bool GridEntity_Door::Destroy(bool, const EntityRef& source) +{ + bool isBlownOpen = TryBlowOpen(true, source.entity); + bool isPlayerBomb = source.type == ENTITY_PLAYER || source.spawnerType == ENTITY_PLAYER; + if (!isBlownOpen || !isPlayerBomb || !is_hidden_room_type(targetRoomType)) + return isBlownOpen; + + if (g_game->GetRoomByIdx(targetRoomIdx)->visitedCount == 0 && source.entity) + if (Entity* player = source.entity->GetPlayerAncestor()) + Player_stats_add(&g_game->onlinePlayerStats, ONLINE_STAT_SECRET_DOORS_BOMBED, (Entity_Player*)player, 1); + return isBlownOpen; +} + +// 0070fb60 Opens the door to an explosion or a key-free opener, cracking secret walls and breaking bars. +bool GridEntity_Door::TryBlowOpen(bool, Entity*) +{ + reconstruction_missing("GridEntity_Door::TryBlowOpen 0070fb60"); +} + +// 00710480 Unlocks the door with a player's key, coins or the golden key. +bool GridEntity_Door::TryUnlock(Entity_Player&, bool) +{ + reconstruction_missing("GridEntity_Door::TryUnlock 00710480"); +} + +// 0070f810 Puffs dust from the wall around the door. +void GridEntity_Door::SpawnDust() +{ + reconstruction_missing("GridEntity_Door::SpawnDust 0070f810"); +} diff --git a/src/grid_entity_door.h b/src/grid_entity_door.h new file mode 100644 index 0000000..8ebdc38 --- /dev/null +++ b/src/grid_entity_door.h @@ -0,0 +1,94 @@ +#pragma once + +#include "entity_player.h" +#include "grid_entity.h" +#include + +// How a door is locked (Lua's DoorVariant). +enum DoorVariant : int +{ + DOOR_UNSPECIFIED, + DOOR_LOCKED, + DOOR_LOCKED_DOUBLE, + DOOR_LOCKED_CRACKED, + DOOR_LOCKED_BARRED, + DOOR_LOCKED_KEYFAMILIAR, + DOOR_LOCKED_GREED, + DOOR_HIDDEN, + DOOR_UNLOCKED +}; + +// Where a door stands: closed, open, with one of two chains left, damaged, or held shut for a moment. +enum DoorState : int +{ + DOOR_STATE_INIT, + DOOR_STATE_CLOSED, + DOOR_STATE_OPEN, + DOOR_STATE_HALF_OPEN, + DOOR_STATE_DAMAGED, + DOOR_STATE_OPEN_DENIED +}; + +// What kind of door LoadSprite made, in GridEntity_Door::doorFlags. +enum DoorFlag : uint32_t +{ + DOOR_FLAG_COIN_LOCK = 1 << 0, + DOOR_FLAG_HOLE_IN_WALL = 1 << 1, + DOOR_FLAG_SPIKED = 1 << 2, + DOOR_FLAG_AMBUSH = 1 << 3, + DOOR_FLAG_MIRROR = 1 << 4, + DOOR_FLAG_MINESHAFT = 1 << 5, + DOOR_FLAG_PHOTO = 1 << 6 +}; + +// Construction and destruction (0070bb20) are the defaults. +// The field accessors (005cd5e0, 0060cfe0, 00738170, 00833290, 0085e0b0) are the public fields. A door between two +// rooms (Lua's GridEntityDoor): the room types on either side pick its sprite, its variant how it is locked, its state +// whether it stands open. The extra sprite shows chains, bars and planks, the sparkle sprite the Shiny Rock's hint at +// secret rooms. +struct GridEntity_Door : GridEntity +{ + ANM2 extraSprite; + ANM2 sparkleSprite; + std::string closeAnimation; + std::string lockedAnimation; + std::string openAnimation; + std::string openLockedAnimation; + Direction direction = DIRECTION_NONE; + int currentRoomType = 0; + int previousState = 0; + int previousVariant = 0; + int slot = 0; + int targetRoomIdx = -1; + int targetRoomType = 0; + int updateCount = 0; + uint32_t doorFlags = 0; + bool isBusted = false; + bool isExtraVisible = false; + bool isUnlockedByPlayer = false; + + void subclass_init() override; + void Update() override; + void Render(const Vector& offset) override; + bool Destroy(bool isImmediate, const EntityRef& source) override; + WaterClipInfo GetWaterClipInfo() override; + bool CanTakeDamageFromTearEffects() override; + + bool IsOpen(); + bool IsLocked(); + bool IsRoomType(int roomType); + bool IsKeyFamiliarTarget(); + bool IsTargetRoomArcade(); + bool CanBlowOpen(); + int get_secret_exit_kind(); + void SetRoomTypes(int current, int target); + void LoadSprite(); + void UpdateAnimation(); + void Open(); + void Close(bool isForce); + void Bar(); + void SetLocked(bool isLocked); + bool TryBlowOpen(bool isFromExplosion, Entity* source); + bool TryUnlock(Entity_Player& player, bool isForce); + void SpawnDust(); +}; diff --git a/src/grid_entity_fire.cpp b/src/grid_entity_fire.cpp new file mode 100644 index 0000000..515259b --- /dev/null +++ b/src/grid_entity_fire.cpp @@ -0,0 +1,26 @@ +#include "grid_entity_fire.h" +#include "log.h" + +// 0067db00 Loads the fire and its embers. +void GridEntity_Fire::subclass_init() +{ + reconstruction_missing("GridEntity_Fire::subclass_init 0067db00"); +} + +// 0067e0f0 Burns down as it is hurt, hurts what touches it and drifts its embers. +void GridEntity_Fire::Update() +{ + reconstruction_missing("GridEntity_Fire::Update 0067e0f0"); +} + +// 0067e880 Draws the fire and its embers. +void GridEntity_Fire::Render(const Vector&) +{ + reconstruction_missing("GridEntity_Fire::Render 0067e880"); +} + +// 0067ea60 Puts the fire out a stage. +bool GridEntity_Fire::Hurt(int, const EntityRef&) +{ + reconstruction_missing("GridEntity_Fire::Hurt 0067ea60"); +} diff --git a/src/grid_entity_fire.h b/src/grid_entity_fire.h new file mode 100644 index 0000000..a5e5eb3 --- /dev/null +++ b/src/grid_entity_fire.h @@ -0,0 +1,29 @@ +#pragma once + +#include "grid_entity.h" +#include + +// An ember drifting up from a fire: where it is, how it moves, and how long it has left. +struct FireEmber +{ + Vector position{}; + Vector velocity{}; + int frame = 0; + int lifetime = 0; +}; + +// Destruction (0070ba00) is the default. +// A fireplace (Lua's GRID_FIREPLACE grid version): a fire burning on its cell, its embers drifting up. +struct GridEntity_Fire : GridEntity +{ + ANM2 emberSprite; + ANM2 fireSprite; + std::vector embers; + int flickerVariant = 0; + int hurtCooldown = 0; + + void subclass_init() override; + void Update() override; + void Render(const Vector& offset) override; + bool Hurt(int damage, const EntityRef& source) override; +}; diff --git a/src/grid_entity_gravity.cpp b/src/grid_entity_gravity.cpp new file mode 100644 index 0000000..2aa7dd4 --- /dev/null +++ b/src/grid_entity_gravity.cpp @@ -0,0 +1,20 @@ +#include "grid_entity_gravity.h" +#include "log.h" + +// 0099b510 Blocks nothing. +void GridEntity_Gravity::subclass_init() +{ + collisionClass = COLLISION_NONE; +} + +// 0099b520 Loads the cell's look from the walls around it. +void GridEntity_Gravity::PostInit() +{ + reconstruction_missing("GridEntity_Gravity::PostInit 0099b520"); +} + +// 0099b980 Pulls the players in the column. +void GridEntity_Gravity::Update() +{ + reconstruction_missing("GridEntity_Gravity::Update 0099b980"); +} diff --git a/src/grid_entity_gravity.h b/src/grid_entity_gravity.h new file mode 100644 index 0000000..c02157d --- /dev/null +++ b/src/grid_entity_gravity.h @@ -0,0 +1,11 @@ +#pragma once + +#include "grid_entity.h" + +// A crawlspace's gravity cell (Lua's GRID_GRAVITY), which pulls the players toward the ladder. +struct GridEntity_Gravity : GridEntity +{ + void subclass_init() override; + void PostInit() override; + void Update() override; +}; diff --git a/src/grid_entity_lock.cpp b/src/grid_entity_lock.cpp new file mode 100644 index 0000000..d08fff7 --- /dev/null +++ b/src/grid_entity_lock.cpp @@ -0,0 +1,38 @@ +#include "grid_entity_lock.h" +#include "log.h" + +// 00711780 Loads the block, a coin block under Pay To Play. +void GridEntity_Lock::subclass_init() +{ + reconstruction_missing("GridEntity_Lock::subclass_init 00711780"); +} + +// 00711950 Animates the block and unblocks the cell once it breaks. +void GridEntity_Lock::Update() +{ + reconstruction_missing("GridEntity_Lock::Update 00711950"); +} + +// 00711f30 Draws the sprite on its cell. +void GridEntity_Lock::Render(const Vector& offset) +{ + sprite_render(offset); +} + +// 00712090 Water clips around the block while it stands. +WaterClipInfo GridEntity_Lock::GetWaterClipInfo() +{ + return {collisionClass != COLLISION_NONE ? WATER_CLIP_SOLID : WATER_CLIP_FLAT, 0}; +} + +// 00711af0 Breaks the block with a player's key or coins. +void GridEntity_Lock::try_unlock(Entity_Player&, bool) +{ + reconstruction_missing("GridEntity_Lock::try_unlock 00711af0"); +} + +// 00711bb0 Breaks the block open. +void GridEntity_Lock::break_open(Entity_Player&) +{ + reconstruction_missing("GridEntity_Lock::break_open 00711bb0"); +} diff --git a/src/grid_entity_lock.h b/src/grid_entity_lock.h new file mode 100644 index 0000000..f87b6bf --- /dev/null +++ b/src/grid_entity_lock.h @@ -0,0 +1,18 @@ +#pragma once + +#include "entity_player.h" +#include "grid_entity.h" + +// Destruction (0070bdd0) is the default. +// A key block (Lua's GRID_LOCK), or a coin block under Pay To Play. +struct GridEntity_Lock : GridEntity +{ + bool isCoinLock = false; + + void subclass_init() override; + void Update() override; + void Render(const Vector& offset) override; + WaterClipInfo GetWaterClipInfo() override; + void try_unlock(Entity_Player& player, bool isForce); + void break_open(Entity_Player& player); +}; diff --git a/src/grid_entity_pit.cpp b/src/grid_entity_pit.cpp new file mode 100644 index 0000000..d0aca04 --- /dev/null +++ b/src/grid_entity_pit.cpp @@ -0,0 +1,93 @@ +#include "grid_entity_pit.h" +#include "game.h" +#include "grid_entity_rock.h" +#include "log.h" +#include "room.h" + +// The grid path a pit claims, and a spiked bridge's. +constexpr int GRID_PATH_PIT = 3000; +constexpr int GRID_PATH_SPIKED_BRIDGE = 999; + +// Lava cooler than this leaves the Mines' lava pits walkable. +constexpr float LAVA_COOLED = 0.2f; + +// 00713760 Loads the pit's sprite from the backdrop, its edges joined to the pits around it. +void GridEntity_Pit::subclass_init() +{ + reconstruction_missing("GridEntity_Pit::subclass_init 00713760"); +} + +// 00714320 Joins the pit's edges to its neighbours once the room is laid out. +void GridEntity_Pit::PostInit() +{ + reconstruction_missing("GridEntity_Pit::PostInit 00714320"); +} + +// 00712180 Swallows what falls in, fills into a bridge and animates the lava. +void GridEntity_Pit::Update() +{ + reconstruction_missing("GridEntity_Pit::Update 00712180"); +} + +// 00713440 Draws the pit or its bridge. +void GridEntity_Pit::Render(const Vector&) +{ + reconstruction_missing("GridEntity_Pit::Render 00713440"); +} + +// 00714750 Water lies flat over the pit. +WaterClipInfo GridEntity_Pit::GetWaterClipInfo() +{ + return {WATER_CLIP_FLAT, 0}; +} + +// 00713ee0 Picks the pit's frame from the pits around it. +void GridEntity_Pit::update_sprite_edges() +{ + reconstruction_missing("GridEntity_Pit::update_sprite_edges 00713ee0"); +} + +// 00714610 Claims the cell as a pit (climbable with a ladder) until it is bridged. Cooled lava claims nothing. +void GridEntity_Pit::UpdateCollision() +{ + Room& room = *g_game->room; + if (room.HasLava() && room.lavaIntensity < LAVA_COOLED) + { + path_set(0); + collisionClass = COLLISION_NONE; + return; + } + if (state < PIT_STATE_FILLED) + { + path_set(GRID_PATH_PIT); + collisionClass = hasLadder ? COLLISION_WALL_EXCEPT_PLAYER : COLLISION_PIT; + return; + } + path_set(state == PIT_STATE_FILLED_SPIKED ? GRID_PATH_SPIKED_BRIDGE : 0); + collisionClass = COLLISION_NONE; +} + +// 007146e0 Puts a ladder over the pit, or takes it away. +void GridEntity_Pit::SetLadder(bool isLadder) +{ + hasLadder = isLadder; + UpdateCollision(); +} + +// 00714700 Bridges an empty pit with a rock (spiked for a spiked rock that stood), or with a pressure plate's varData +// when the plate fires. +void GridEntity_Pit::MakeBridge(GridEntity_Rock* rock, int bridgeVarData) +{ + if (state != PIT_STATE_EMPTY) + return; + + if (bridgeVarData != 0) + { + varData = bridgeVarData; + state = PIT_STATE_BRIDGE_PENDING; + return; + } + bool isSpiked = rock && rock->type == GRID_ROCK_SPIKED && rock->previousState == ROCK_STATE_STANDING; + state = isSpiked ? PIT_STATE_FILLED_SPIKED : PIT_STATE_FILLED; + UpdateCollision(); +} diff --git a/src/grid_entity_pit.h b/src/grid_entity_pit.h new file mode 100644 index 0000000..1b729ff --- /dev/null +++ b/src/grid_entity_pit.h @@ -0,0 +1,33 @@ +#pragma once + +#include "grid_entity.h" + +struct GridEntity_Rock; + +// A pit empty, about to be bridged by a pressure plate, bridged, and bridged by a spiked rock. +enum PitState : int +{ + PIT_STATE_EMPTY, + PIT_STATE_BRIDGE_PENDING, + PIT_STATE_FILLED, + PIT_STATE_FILLED_SPIKED +}; + +// Destruction (007120d0) is the default. +// A pit (Lua's GridEntityPit): it swallows what walks in until a rock fills it into a bridge. Its sprite joins the pits +// around it. A ladder lets the players climb across. +struct GridEntity_Pit : GridEntity +{ + bool hasLadder = false; + + void subclass_init() override; + void PostInit() override; + void Update() override; + void Render(const Vector& offset) override; + WaterClipInfo GetWaterClipInfo() override; + + void update_sprite_edges(); + void UpdateCollision(); + void SetLadder(bool isLadder); + void MakeBridge(GridEntity_Rock* rock, int bridgeVarData); +}; diff --git a/src/grid_entity_poop.cpp b/src/grid_entity_poop.cpp new file mode 100644 index 0000000..5971bf8 --- /dev/null +++ b/src/grid_entity_poop.cpp @@ -0,0 +1,85 @@ +#include "grid_entity_poop.h" +#include "game.h" +#include "log.h" +#include "room.h" + +// A red poop's state while it grows back, and how many frames that takes. +constexpr int POOP_STATE_REVIVING = 1000; +constexpr int RED_POOP_REVIVE_FRAMES = 120; + +// 00715940 Loads the poop for its variant and the seeds. +void GridEntity_Poop::subclass_init() +{ + reconstruction_missing("GridEntity_Poop::subclass_init 00715940"); +} + +// 00718dd0 Joins a giant poop's parts once the room is laid out. +void GridEntity_Poop::PostInit() +{ + reconstruction_missing("GridEntity_Poop::PostInit 00718dd0"); +} + +// 00714770 Grows red poop back, animates the poop and its effects. +void GridEntity_Poop::Update() +{ + reconstruction_missing("GridEntity_Poop::Update 00714770"); +} + +// 007151e0 Draws the poop. +void GridEntity_Poop::Render(const Vector&) +{ + reconstruction_missing("GridEntity_Poop::Render 007151e0"); +} + +// 00715330 Breaks the poop a stage, spawning gibs and, at the last, its drops. +bool GridEntity_Poop::Hurt(int, const EntityRef&) +{ + reconstruction_missing("GridEntity_Poop::Hurt 00715330"); +} + +// 007166b0 Water clips around the poop unless it is growing back. +WaterClipInfo GridEntity_Poop::GetWaterClipInfo() +{ + return {state != POOP_STATE_REVIVING ? WATER_CLIP_SOLID : WATER_CLIP_FLAT, 0}; +} + +// 007166f0 Starts a red poop growing back from its last broken frame. +void GridEntity_Poop::RespawnRedPoop() +{ + if (variant != POOP_RED) + return; + + state = POOP_STATE_REVIVING; + reviveTimer = RED_POOP_REVIVE_FRAMES; + collisionClass = COLLISION_NONE; + const AnimationData* data = sprite.GetAnimationData("State5"); + if (!sprite.SetAnimation("State5") || !sprite.animState.animData) + return; + + sprite.animState.SetFrameFloat((float)(data ? data->length : 0)); + sprite.animState.isPlaying = false; +} + +// 00716760 Spawns the gibs a poop of a variant throws when hit, at most so many. +void GridEntity_Poop::spawn_hit_gibs(const Vector&, int, int) +{ + reconstruction_missing("GridEntity_Poop::spawn_hit_gibs 00716760"); +} + +// 00716b10 Spawns a broken poop's effects: the golden poop's sparkle, the black poop's creep and the rest. +void GridEntity_Poop::destroy_effects() +{ + reconstruction_missing("GridEntity_Poop::destroy_effects 00716b10"); +} + +// 007178c0 Spawns what a broken poop drops. +void GridEntity_Poop::spawn_drops() +{ + reconstruction_missing("GridEntity_Poop::spawn_drops 007178c0"); +} + +// 00718ac0 Another part of the giant poop this part belongs to, created when asked and missing. +GridEntity_Poop* GridEntity_Poop::get_giga_part(int, bool) +{ + reconstruction_missing("GridEntity_Poop::get_giga_part 00718ac0"); +} diff --git a/src/grid_entity_poop.h b/src/grid_entity_poop.h new file mode 100644 index 0000000..0461298 --- /dev/null +++ b/src/grid_entity_poop.h @@ -0,0 +1,50 @@ +#pragma once + +#include "grid_entity.h" +#include + +// The kinds of poop (Lua's PoopGridEntityVariant). +enum PoopVariant : int +{ + POOP_NORMAL, + POOP_RED, + POOP_CORNY, + POOP_GOLDEN, + POOP_RAINBOW, + POOP_BLACK, + POOP_WHITE, + POOP_GIGA_TOP_LEFT, + POOP_GIGA_TOP_RIGHT, + POOP_GIGA_BOTTOM_LEFT, + POOP_GIGA_BOTTOM_RIGHT, + POOP_CHARMING +}; + +// Destruction (0070bc60) is the default. ReduceSpawnRate (00456870) sets varData to 1. A poop (Lua's GridEntityPoop): +// it breaks in four hits into gibs and drops. Red poop grows back. +struct GridEntity_Poop : GridEntity +{ + std::string stateAnimation; + Vector unknown184{}; + Vector unknown18c{}; + Vector unknown194{}; + int reviveTimer = 0; + int unknown174 = 0; + int unknown178 = 0; + int unknown17c = 0; + int unknown180 = 0; + bool isUnderPlayer = false; + + void subclass_init() override; + void PostInit() override; + void Update() override; + void Render(const Vector& offset) override; + bool Hurt(int damage, const EntityRef& source) override; + WaterClipInfo GetWaterClipInfo() override; + + void RespawnRedPoop(); + static void spawn_hit_gibs(const Vector& position, int poopVariant, int maxGibs); + void destroy_effects(); + void spawn_drops(); + GridEntity_Poop* get_giga_part(int partVariant, bool isCreate); +}; diff --git a/src/grid_entity_pressure_plate.cpp b/src/grid_entity_pressure_plate.cpp new file mode 100644 index 0000000..97e6516 --- /dev/null +++ b/src/grid_entity_pressure_plate.cpp @@ -0,0 +1,56 @@ +#include "grid_entity_pressure_plate.h" +#include "log.h" + +// 00985f00 Loads the plate for its variant. +void GridEntity_PressurePlate::subclass_init() +{ + reconstruction_missing("GridEntity_PressurePlate::subclass_init 00985f00"); +} + +// 00983330 Presses the plate under a player and runs Greed's button. +void GridEntity_PressurePlate::Update() +{ + reconstruction_missing("GridEntity_PressurePlate::Update 00983330"); +} + +// 00985c10 Draws the plate and Greed's timer. +void GridEntity_PressurePlate::Render(const Vector&) +{ + reconstruction_missing("GridEntity_PressurePlate::Render 00985c10"); +} + +// 00986430 Water stands raised around the plate. +WaterClipInfo GridEntity_PressurePlate::GetWaterClipInfo() +{ + return {WATER_CLIP_RAISED, 0}; +} + +// 009833c0 Fires the plate's effect when pressed. +void GridEntity_PressurePlate::update_press() +{ + reconstruction_missing("GridEntity_PressurePlate::update_press 009833c0"); +} + +// 009837b0 Plays Greed's button's animation. +void GridEntity_PressurePlate::update_greed_button_anim(bool) +{ + reconstruction_missing("GridEntity_PressurePlate::update_greed_button_anim 009837b0"); +} + +// 009838c0 Plays the queued Greed animation. +void GridEntity_PressurePlate::play_pending_animation() +{ + reconstruction_missing("GridEntity_PressurePlate::play_pending_animation 009838c0"); +} + +// 009839f0 Runs Greed mode's wave button. +void GridEntity_PressurePlate::update_greed_button() +{ + reconstruction_missing("GridEntity_PressurePlate::update_greed_button 009839f0"); +} + +// 00984550 Spawns a reward plate's reward. +void GridEntity_PressurePlate::Reward() +{ + reconstruction_missing("GridEntity_PressurePlate::Reward 00984550"); +} diff --git a/src/grid_entity_pressure_plate.h b/src/grid_entity_pressure_plate.h new file mode 100644 index 0000000..c903766 --- /dev/null +++ b/src/grid_entity_pressure_plate.h @@ -0,0 +1,23 @@ +#pragma once + +#include "grid_entity.h" + +// Destruction (0070bd00) is the default. +// A pressure plate (Lua's GRID_PRESSURE_PLATE): pressed, it fires the room's outputs, opens doors or rewards. Greed +// mode's button counts down its timer plate. +struct GridEntity_PressurePlate : GridEntity +{ + ANM2 timerPlate; + RNG greedModeRNG = GRID_RNG_DEFAULT; + const char* nextGreedAnimation = nullptr; + + void subclass_init() override; + void Update() override; + void Render(const Vector& offset) override; + WaterClipInfo GetWaterClipInfo() override; + void update_press(); + void update_greed_button_anim(bool isRed); + void play_pending_animation(); + void update_greed_button(); + void Reward(); +}; diff --git a/src/grid_entity_rock.cpp b/src/grid_entity_rock.cpp new file mode 100644 index 0000000..cffdc21 --- /dev/null +++ b/src/grid_entity_rock.cpp @@ -0,0 +1,563 @@ +#include "grid_entity_rock.h" +#include "game.h" +#include "log.h" +#include "manager.h" +#include "room.h" +#include "seeds.h" +#include +#include +#include + +// The variant a big rock's frame is stored above, and its last frame. +constexpr int BIG_ROCK_VARIANT = 1000; +constexpr int BIG_ROCK_LAST_FRAME = 7; + +// The big rock frames by cell: two wide, two tall or four, and the neighbours PostInit joins, by bit. +constexpr int BIG_FRAME_WIDE_LEFT = 0; +constexpr int BIG_FRAME_WIDE_RIGHT = 1; +constexpr int BIG_FRAME_TALL_TOP = 2; +constexpr int BIG_FRAME_TALL_BOTTOM = 3; +constexpr int BIG_FRAME_TOP_LEFT = 4; +constexpr uint32_t BIG_ROCK_RIGHT = 1 << 0; +constexpr uint32_t BIG_ROCK_BELOW = 1 << 1; +constexpr uint32_t BIG_ROCK_DIAGONAL = 1 << 2; +constexpr uint32_t BIG_ROCK_ALL = BIG_ROCK_RIGHT | BIG_ROCK_BELOW | BIG_ROCK_DIAGONAL; + +// A layout's rock that a pressure plate's event breaks, a bomb rock's fuse once primed, and the rubble's scatter. +constexpr int ROCK_VARIANT_EVENT = 10000; +constexpr int BOMB_ROCK_FUSE = 3; +constexpr float RUBBLE_SPREAD = 16; +constexpr float RUBBLE_SPREAD_HALF = 8; +constexpr float RUBBLE_UNIT = 2.3283062e-10f; + +// The challenge whose rocks come from every backdrop, and how often a rock picks from its own seed. +constexpr uint32_t CHALLENGE_DELETE_THIS = 45; +constexpr uint32_t MIXED_BACKDROP_ODDS = 10; + +// The Shiny Rock's glint: its period, faster for a stronger rock, the frames it lasts, peaking halfway, and how bright. +// The Book of Secrets glows for its effect's last frames. +constexpr int TRINKET_SHINY_ROCK = 62; +constexpr int TRINKET_FLAT_FILE = 151; +constexpr int COLLECTIBLE_BOOK_OF_SECRETS = 287; +constexpr int COLLECTIBLE_KEEPERS_KIN = 717; +constexpr int SOUND_SHINYROCK_SHIMMER = 1014; +constexpr int SHINE_PERIOD = 300; +constexpr int SHINE_PERIOD_STRONG = 150; +constexpr int SHINE_FRAMES = 11; +constexpr int SHINE_PEAK = 5; +constexpr float SHINE_OFFSET = 0.3f; +constexpr float SECRETS_GLOW_FRAMES = 30; +constexpr uint32_t LEVEL_STATE_DUNGEON_ROCK_BROKEN = 1 << 13; + +// An event rock's countdown breaks it at this varData. Keeper's Kin lets a spider out one check in so many. +constexpr int ROCK_EVENT_COUNTDOWN_END = 10; +constexpr int SPIDER_CHECK_FRAMES = 15; +constexpr uint32_t SPIDER_ODDS = 100; +constexpr int EFFECT_POOF01 = 15; + +// The event counters breaking rocks advance. +constexpr int EVENT_ROCKS_DESTROYED = 2; +constexpr int EVENT_TINTED_ROCKS_DESTROYED = 3; +constexpr int EVENT_SS_ROCKS_DESTROYED = 4; + +// The break sounds: the alternate rocks' by their kind, the fleshy floors', and the plain one. +constexpr int ALT_ROCK_SOUNDS[] = {0, 78, 79, 137, 77, 138}; +constexpr int SOUND_MEAT_IMPACTS = 77; +constexpr int SOUND_ROCK_CRUMBLE = 137; +constexpr int FLESHY_BACKDROPS[] = {10, 11, 12, 13, 34, 43, 44, 48}; + +// Which alternate rock (urn, mushroom, skull, polyp, bucket) a backdrop shows: +// the room's for none given. +static int alt_rock_type_get(int backdropType) +{ + if (backdropType == 0) + backdropType = g_game->room->backdropType; + switch (backdropType) + { + case 4: + case 5: + case 6: + case 23: + case 32: + case 37: + case 46: + case 58: + case 59: + return 2; + case 7: + case 8: + case 9: + case 14: + case 16: + case 30: + case 33: + case 38: + case 39: + case 40: + case 41: + case 42: + case 47: + return 3; + case 10: + case 11: + case 12: + case 13: + case 34: + case 43: + case 44: + case 48: + return 4; + case 31: + case 36: + case 45: + return 5; + default: + return 1; + } +} + +// Whether the rock shows a frame of a big rock. +static bool is_big(GridEntity_Rock& rock) +{ + return (uint32_t)rock.variant >= BIG_ROCK_VARIANT && rock.variant - BIG_ROCK_VARIANT >= 0; +} + +// 0071a760 Makes a plain rock spawned for the first time the top left of a big rock, three times in four, with the +// plain rocks right, below and diagonally of it: two of them side by side or stacked, or all four. +void GridEntity_Rock::PostInit() +{ + RNG rng = {spawnSeed, 5, 9, 7}; + if (type != GRID_ROCK || state != ROCK_STATE_STANDING || spawnCount != 1 || is_big(*this) || rng.RandomInt(4) == 0) + return; + + Room& room = *g_game->room; + int column = (uint32_t)gridIndex % (uint32_t)room.gridWidth; + int row = (uint32_t)gridIndex / (uint32_t)room.gridWidth; + std::array cells = {room.GetGridIndexByTile(column + 1, row), room.GetGridIndexByTile(column, row + 1), + room.GetGridIndexByTile(column + 1, row + 1)}; + std::array rocks{}; + uint32_t mask = 0; + for (int i = 0; i < 3; i++) + { + GridEntity_Rock* rock = dynamic_cast(room.GetGridEntity(cells[i])); + if (cells[i] < 0 || !rock || rock->type != GRID_ROCK || is_big(*rock)) + continue; + + mask |= 1 << i; + rocks[i] = rock; + } + if (mask == BIG_ROCK_ALL && rng.RandomInt(4) != 0) + mask = BIG_ROCK_ALL - rng.RandomInt(BIG_ROCK_ALL); + + switch (mask) + { + case BIG_ROCK_RIGHT: + case BIG_ROCK_RIGHT | BIG_ROCK_DIAGONAL: + SetBigRockFrame(BIG_FRAME_WIDE_LEFT); + rocks[0]->SetBigRockFrame(BIG_FRAME_WIDE_RIGHT); + break; + case BIG_ROCK_BELOW: + case BIG_ROCK_RIGHT | BIG_ROCK_BELOW: + case BIG_ROCK_BELOW | BIG_ROCK_DIAGONAL: + SetBigRockFrame(BIG_FRAME_TALL_TOP); + rocks[1]->SetBigRockFrame(BIG_FRAME_TALL_BOTTOM); + break; + case BIG_ROCK_ALL: + SetBigRockFrame(BIG_FRAME_TOP_LEFT); + rocks[0]->SetBigRockFrame(BIG_FRAME_TOP_LEFT + 1); + rocks[1]->SetBigRockFrame(BIG_FRAME_TOP_LEFT + 2); + rocks[2]->SetBigRockFrame(BIG_FRAME_TOP_LEFT + 3); + break; + default: + break; + } +} + +// The backdrop whose rocks a rock shows: the room's, or under the challenge that mixes them, a random one with rocks. +static BackdropConfig& rock_backdrop_get(GridEntity_Rock& rock) +{ + Backdrop& backdrop = g_game->room->backdrop; + BackdropConfig& config = backdrop.configs[g_game->room->backdropType]; + if (g_game->challenge != CHALLENGE_DELETE_THIS) + return config; + + RNG pick = {rock.spawnSeed, 2, 7, 25}; + RNG mixed = pick.Next() % MIXED_BACKDROP_ODDS == 0 ? RNG{rock.spawnSeed, 5, 9, 7} + : RNG{g_game->dungeonPlacementSeed, 2, 7, 25}; + BackdropConfig& random = backdrop.configs[1 + mixed.Next() % (BACKDROP_COUNT - 1)]; + return random.rocks.empty() ? config : random; +} + +// 00719f80 Loads the rock's sprite with the backdrop's rocks and picks its animation by type: a new rock stands on a +// random frame its cell's decoration seed picks, and a broken one scatters one or two bits of rubble. +void GridEntity_Rock::subclass_init() +{ + anim = "normal"; + rubbleAnim = "rubble"; + sprite.Load("gfx/grid/grid_rock.anm2", GRAPHICS_DEFER); + std::string rocks = rock_backdrop_get(*this).rocks; + for (int layer = 0; layer < (int)sprite.layerStates.size(); layer++) + sprite.ReplaceSpritesheet(layer, rocks); + sprite.LoadGraphics(); + + bool isNew = state == ROCK_STATE_NONE; + if (isNew) + { + state = ROCK_STATE_STANDING; + if (variant == ROCK_VARIANT_EVENT) + { + varData = 1; + variant = 0; + } + } + path_set(state == ROCK_STATE_STANDING ? GRID_PATH_SOLID : 0); + + bool isCracked = state == ROCK_STATE_CRACKED; + switch (type) + { + case GRID_ROCKB: + anim = "black"; + break; + case GRID_ROCKT: + anim = "tinted"; + break; + case GRID_ROCK_BOMB: + anim = "bombrock"; + fuseFrames = state == ROCK_STATE_STANDING ? BOMB_ROCK_FUSE : -1; + break; + case GRID_ROCK_ALT: + anim = "alt"; + rubbleAnim = "rubble_alt"; + break; + case GRID_ROCK_SS: + anim = isCracked ? "ss_broken" : "superspecial"; + break; + case GRID_PILLAR: + anim = "pillar"; + if (LayerState* layer = sprite.GetLayer(1)) + layer->isVisible = false; + break; + case GRID_ROCK_SPIKED: + anim = isCracked ? "spiked_retracted" : "spiked"; + rubbleAnim = isCracked ? "rubble" : "rubble_spiked"; + break; + case GRID_ROCK_ALT2: + anim = "alt2"; + rubbleAnim = "rubble_alt"; + break; + case GRID_ROCK_GOLD: + anim = "foolsgold"; + break; + default: + if (is_big(*this)) + anim = "big"; + break; + } + + if (isNew) + { + const AnimationData* data = sprite.GetAnimationData(anim); + if (!data) + KAGE_LogMessage(LOG_INFO, (uint8_t*)"[warn] GridEntityRock animation %s is NULL\n"); + RNG rng = {(gridIndex + g_game->room->GetDecorationSeed()) | 1, 5, 9, 7}; + variant = data ? (int)rng.RandomInt(data->length) : 0; + } + if (state == ROCK_STATE_BROKEN) + { + RNG rng = {spawnSeed, 5, 9, 7}; + uint32_t count = (rng.Next() & 1) + 1; + for (uint32_t i = 0; i < count; i++) + { + float y = RUBBLE_SPREAD_HALF - std::floor((float)rng.Next() * RUBBLE_UNIT * RUBBLE_SPREAD); + float x = RUBBLE_SPREAD_HALF - std::floor((float)rng.Next() * RUBBLE_UNIT * RUBBLE_SPREAD); + rubbleOffsets.push_back(vector_make(x, y)); + } + } + + UpdateAnimFrame(); + update_collision(); + previousState = state; +} + +// The glow on a rock that hides something: the Shiny Rock's pulse, every so many frames (faster with a stronger rock), +// and the Book of Secrets' while it lasts. +static void glint_update(GridEntity_Rock& rock) +{ + Room& room = *g_game->room; + float glow = 0; + if (g_game->playerManager.AnyoneHasTrinket(TRINKET_SHINY_ROCK)) + { + if ((int)g_game->deathmatchManager.state > 1) + reconstruction_missing("GridEntity_Rock::Update 00718fe0: the Shiny Rock " + "of the local player in versus"); + + int period = + g_game->playerManager.GetTrinketMultiplier(TRINKET_SHINY_ROCK) > 2 ? SHINE_PERIOD_STRONG : SHINE_PERIOD; + int phase = room.GetFrameCount() % period; + if (phase < SHINE_FRAMES) + { + if (phase == 0) + grid_sound_play(SOUND_SHINYROCK_SHIMMER); + glow = 1 - (float)std::abs(phase - SHINE_PEAK) / SHINE_PEAK; + } + } + if (TemporaryEffect* secrets = room.temporaryEffects.GetCollectibleEffect(COLLECTIBLE_BOOK_OF_SECRETS)) + glow = std::max(glow, std::min((float)secrets->cooldown / SECRETS_GLOW_FRAMES, 1.0f)); + + if (glow <= 0 && rock.sprite.color._offset[0] == 0) + return; + + float offset = glow > 0 ? glow * SHINE_OFFSET : 0; + rock.sprite.color = {{1, 1, 1, 1}, {0, 0, 0, 0}, {offset, offset, offset}}; +} + +// 00718fe0 Glints a tinted, super secret or crawlspace rock, breaks an event rock once its countdown ends, lets +// Keeper's Kin's spiders out now and then, blows a primed bomb rock once its fuse runs out, and hurts what touches a +// spiked rock until a plate or the Flat File retracts its spikes. +void GridEntity_Rock::Update() +{ + Room& room = *g_game->room; + bool isGlinting = type == GRID_ROCKT || type == GRID_ROCK_SS; + if (!isGlinting) + { + int dungeonRock = g_game->levelStateFlags & LEVEL_STATE_DUNGEON_ROCK_BROKEN ? -1 : room.dungeonRockIdx; + isGlinting = dungeonRock == gridIndex && type != GRID_ROCKB && type != GRID_PILLAR; + } + if (isGlinting && state != ROCK_STATE_BROKEN) + glint_update(*this); + sprite.Update(); + + if (state == ROCK_STATE_STANDING || state == ROCK_STATE_CRACKED) + { + if (varData == ROCK_EVENT_COUNTDOWN_END) + { + varData = 1; + uint32_t seed = Random(); + g_game->Spawn({.position = Position(), .type = ENTITY_EFFECT, .variant = EFFECT_POOF01, .seed = seed}); + Destroy(true, EntityRef()); + } + else if (varData > ROCK_EVENT_COUNTDOWN_END) + varData--; + + bool isSpiderFrame = g_game->frameCount % SPIDER_CHECK_FRAMES == 0 && Random() % SPIDER_ODDS == 0; + if (isSpiderFrame && room.GetAliveEnemiesCount() >= 1 && + g_game->playerManager.RandomCollectibleOwner(COLLECTIBLE_KEEPERS_KIN, Random(), nullptr)) + reconstruction_missing("GridEntity_Rock::Update 00718fe0: Keeper's Kin's " + "spider (Entity_Player::AddBlueSpider)"); + } + else if (state == ROCK_STATE_PRIMED && fuseFrames-- <= 0) + Destroy(false, EntityRef()); + + update_collision(); + if (state == ROCK_STATE_STANDING && type == GRID_ROCK_SPIKED) + { + RoomDescriptor* current = g_game->GetRoomByIdx(g_game->currentRoomIdx, g_game->currentDimensionIdx); + bool isRetracted = (current->flags & ROOM_DESCRIPTOR_FLAG_PRESSURE_PLATES_TRIGGERED) || + g_game->playerManager.AnyoneHasTrinket(TRINKET_FLAT_FILE); + if (!isRetracted) + reconstruction_missing("GridEntity_Rock::Update 00718fe0: a spiked rock's spikes " + "(EntityList::QueryRadius, hurt_func)"); + + state = ROCK_STATE_CRACKED; + anim = "spiked_retracted"; + rubbleAnim = "rubble"; + UpdateAnimFrame(); + } + previousState = state; +} + +// The room's floor color laid over a sprite's own (the original's Color::__mul): tints multiply, colorizes average in, +// offsets add. +static ColorMod color_multiply(ColorMod color, const ColorMod& other) +{ + for (int i = 0; i < 4; i++) + color._tint[i] *= other._tint[i]; + if (other._colorize[0] + other._colorize[1] + other._colorize[2] != 0) + { + bool isUncolored = color._colorize[0] + color._colorize[1] + color._colorize[2] == 0; + for (int i = 0; i < 4; i++) + color._colorize[i] = isUncolored ? other._colorize[i] : (color._colorize[i] + other._colorize[i]) * 0.5f; + } + for (int i = 0; i < 3; i++) + color._offset[i] += other._offset[i]; + return color; +} + +// 00719ad0 Draws a standing rock, or a broken one's rubble, each bit on the next frame of the rubble animation, in the +// floor's color over the rock's own. +// A missing rubble animation leaves the floor's color on the sprite. +void GridEntity_Rock::Render(const Vector& offset) +{ + Vector position = get_render_position(); + SpriteDraw draw = {.position = vector_make(position.x + offset.x, position.y + offset.y)}; + ColorMod saved = sprite.color; + sprite.color = color_multiply(g_game->room->floorColor, saved); + if (state == ROCK_STATE_STANDING || state == ROCK_STATE_CRACKED) + sprite.Render(draw); + else if (state == ROCK_STATE_BROKEN) + { + const AnimationData* rubble = sprite.GetAnimationData(rubbleAnim); + if (!rubble) + { + KAGE_LogMessage(LOG_INFO, (uint8_t*)"[warn] GridEntity_Rock: RubbleAnim %s is NULL\n"); + return; + } + + int frame = variant; + for (const Vector& rubbleOffset : rubbleOffsets) + { + frame = (frame + 1) % rubble->length; + if (sprite.SetAnimation(rubbleAnim) && sprite.animState.animData) + { + sprite.animState.SetFrameFloat((float)frame); + sprite.animState.isPlaying = false; + } + if (LayerState* layer = sprite.GetLayer(0)) + layer->pos = rubbleOffset; + sprite.Update(); + sprite.Render(draw); + } + } + sprite.color = saved; +} + +// 00719dd0 Draws a pillar's top layer above the entities, in the floor's color over its own. +void GridEntity_Rock::RenderTop(const Vector& offset) +{ + if (state == ROCK_STATE_BROKEN || type != GRID_PILLAR) + return; + + Vector position = get_render_position(); + SpriteDraw draw = {.position = vector_make(position.x + offset.x, position.y + offset.y)}; + ColorMod saved = sprite.color; + sprite.color = color_multiply(g_game->room->floorColor, saved); + LayerState* top = sprite.GetLayer(1); + if (top) + top->isVisible = true; + sprite.animState.RenderLayer(1, draw, sprite); + if (top) + top->isVisible = false; + sprite.color = saved; +} + +// 007197d0 Breaks the rock: a bomb rock is primed and blows, a super secret rock cracks first. Pillars and metal blocks +// stand. +bool GridEntity_Rock::Destroy(bool, const EntityRef&) +{ + reconstruction_missing("GridEntity_Rock::Destroy 007197d0"); +} + +// 0071deb0 Water clips around the rock until it breaks. +WaterClipInfo GridEntity_Rock::GetWaterClipInfo() +{ + return {state != ROCK_STATE_BROKEN ? WATER_CLIP_SOLID : WATER_CLIP_FLAT, 0}; +} + +// 00718f80 Blocks the cell while the rock stands, as a wall in a crawlspace or for a pillar. +void GridEntity_Rock::update_collision() +{ + if (state == ROCK_STATE_STANDING || state == ROCK_STATE_CRACKED) + { + bool isWall = g_game->room->roomType == ROOM_DUNGEON || type == GRID_PILLAR; + collisionClass = isWall ? COLLISION_WALL : COLLISION_SOLID; + } + else if (state == ROCK_STATE_BROKEN) + collisionClass = COLLISION_NONE; + else if (state == ROCK_STATE_PRIMED) + collisionClass = COLLISION_SOLID; +} + +// 0071a940 Shows a frame of a big rock, or a random variant of the normal rock for a negative one. +void GridEntity_Rock::SetBigRockFrame(int frame) +{ + if (frame < 0) + { + anim = "normal"; + const AnimationData* data = sprite.GetAnimationData(anim); + if (data) + { + RNG rng = {(gridIndex + g_game->room->GetDecorationSeed()) | 1, 5, 9, 7}; + variant = rng.RandomInt(data->length); + } + else + { + KAGE_LogMessage(LOG_INFO, (uint8_t*)"[warn] GridEntityRock animation %s is NULL\n"); + variant = 0; + } + } + else + { + anim = "big"; + variant = std::min(frame, BIG_ROCK_LAST_FRAME) + BIG_ROCK_VARIANT; + } + UpdateAnimFrame(); +} + +// 0071aa70 The big rock's frame, or -1 for a rock that is not big. +int GridEntity_Rock::GetBigRockFrame() +{ + return (uint32_t)variant < BIG_ROCK_VARIANT ? -1 : variant - BIG_ROCK_VARIANT; +} + +// 0071aa90 Shows the rock's frame of its animation, stopped: its variant, or its big rock frame. +void GridEntity_Rock::UpdateAnimFrame() +{ + int frame = (uint32_t)variant >= BIG_ROCK_VARIANT ? variant - BIG_ROCK_VARIANT : variant; + if (!sprite.SetAnimation(anim) || !sprite.animState.animData) + return; + + sprite.animState.SetFrameFloat((float)frame); + sprite.animState.isPlaying = false; +} + +// 0071aaf0 Updates the rocks around a broken one: big rocks fall apart and tinted neighbours show. +void GridEntity_Rock::UpdateNeighbors() +{ + reconstruction_missing("GridEntity_Rock::UpdateNeighbors 0071aaf0"); +} + +// 0071af10 Counts a broken rock toward the achievements: any but a metal block, tinted and super secret rocks again. +void GridEntity_Rock::RegisterRockDestroyed(GridEntityType type) +{ + if (type == GRID_ROCKB) + return; + + PersistentGameData& data = g_manager->persistentGameData; + data.IncreaseEventCounter(EVENT_ROCKS_DESTROYED, 1); + if (type == GRID_ROCKT) + data.IncreaseEventCounter(EVENT_TINTED_ROCKS_DESTROYED, 1); + else if (type == GRID_ROCK_SS) + data.IncreaseEventCounter(EVENT_SS_ROCKS_DESTROYED, 1); +} + +// 0071af60 Spawns the worms a rock on certain floors hides. +void GridEntity_Rock::TrySpawnWorms() +{ + reconstruction_missing("GridEntity_Rock::TrySpawnWorms 0071af60"); +} + +// 0071b100 Plays a rock breaking: the alternate rocks' own sound, flesh on the womb's floors, or crumbling. The +// backdrop only picks the alternate rock's sound. The others go by the room's. +void GridEntity_Rock::PlayBreakSound(GridEntityType type, int backdropType) +{ + int sound = SOUND_ROCK_CRUMBLE; + int roomBackdrop = g_game->room->backdropType; + if (type == GRID_ROCK_ALT || type == GRID_ROCK_ALT2) + sound = ALT_ROCK_SOUNDS[alt_rock_type_get(backdropType)]; + else if (std::find(std::begin(FLESHY_BACKDROPS), std::end(FLESHY_BACKDROPS), roomBackdrop) != + std::end(FLESHY_BACKDROPS)) + sound = SOUND_MEAT_IMPACTS; + grid_sound_play(sound); +} + +// 0071b1c0 Puts a ladder over the pit beside a broken rock in a crawlspace. +bool GridEntity_Rock::TrySpawnLadder() +{ + reconstruction_missing("GridEntity_Rock::TrySpawnLadder 0071b1c0"); +} + +// 0071b410 Spawns what a broken rock of a type drops: pickups, chests, items, spiders, troll bombs and the rest. +void GridEntity_Rock::SpawnDrops(const Vector&, GridEntityType, int, uint32_t, int, Entity*) +{ + reconstruction_missing("GridEntity_Rock::SpawnDrops 0071b410"); +} diff --git a/src/grid_entity_rock.h b/src/grid_entity_rock.h new file mode 100644 index 0000000..d7dff5b --- /dev/null +++ b/src/grid_entity_rock.h @@ -0,0 +1,48 @@ +#pragma once + +#include "grid_entity.h" +#include +#include + +// A rock standing, broken, primed to blow (a bomb rock hit by an explosion) and cracked (a super secret rock). +enum RockState : int +{ + ROCK_STATE_NONE, + ROCK_STATE_STANDING, + ROCK_STATE_BROKEN, + ROCK_STATE_PRIMED, + ROCK_STATE_CRACKED +}; + +// Destruction (0070b950) is the default. The rubble animation's getter (005cd820) is the public field. A rock of any +// kind (Lua's GridEntityRock): +// plain, tinted, bomb, super secret, spiked, gold, metal blocks and pillars. A big rock spans four cells. Broken, it +// leaves rubble and its drops. +struct GridEntity_Rock : GridEntity +{ + std::string anim; + std::string rubbleAnim; + std::vector rubbleOffsets; + int fuseFrames = 0; + int previousState = 0; + + void subclass_init() override; + void PostInit() override; + void Update() override; + void Render(const Vector& offset) override; + bool Destroy(bool isImmediate, const EntityRef& source) override; + WaterClipInfo GetWaterClipInfo() override; + + void update_collision(); + void RenderTop(const Vector& position); + void SetBigRockFrame(int frame); + int GetBigRockFrame(); + void UpdateAnimFrame(); + void UpdateNeighbors(); + static void RegisterRockDestroyed(GridEntityType type); + void TrySpawnWorms(); + static void PlayBreakSound(GridEntityType type, int backdropType); + bool TrySpawnLadder(); + static void SpawnDrops(const Vector& position, GridEntityType type, int variant, uint32_t seed, int backdropType, + Entity* source); +}; diff --git a/src/grid_entity_spikes.cpp b/src/grid_entity_spikes.cpp new file mode 100644 index 0000000..79d8380 --- /dev/null +++ b/src/grid_entity_spikes.cpp @@ -0,0 +1,43 @@ +#include "grid_entity_spikes.h" +#include "game.h" +#include "log.h" +#include "room.h" + +// The items and trinket that keep spikes down, and the variants spikes of the room's own layout have. +constexpr int COLLECTIBLE_SANGUINE_BOND = 692; +constexpr int TRINKET_FLAT_FILE = 151; +constexpr uint32_t SPIKES_LAYOUT_VARIANTS = 100; + +// 0071dfc0 Loads the spikes for the backdrop and starts their timer. +void GridEntity_Spikes::subclass_init() +{ + reconstruction_missing("GridEntity_Spikes::subclass_init 0071dfc0"); +} + +// 0071e9b0 Raises and lowers timed spikes, hurting what stands on them while up. +void GridEntity_Spikes::Update() +{ + reconstruction_missing("GridEntity_Spikes::Update 0071e9b0"); +} + +// 0071e920 Whether the spikes stay down: pressed plates and the Flat File lower them, and a devil room's spikes go with +// Sanguine Bond. Versus matches and the unnamed spikes type keep them. +bool GridEntity_Spikes::is_disabled() +{ + if ((int)g_game->deathmatchManager.state > 1 || type == GRID_SPIKES_ALT) + return false; + + RoomDescriptor* room = g_game->GetRoomByIdx(g_game->currentRoomIdx, g_game->currentDimensionIdx); + if (room->flags & ROOM_DESCRIPTOR_FLAG_PRESSURE_PLATES_TRIGGERED) + return true; + if (g_game->playerManager.AnyoneHasTrinket(TRINKET_FLAT_FILE)) + return true; + return (uint32_t)variant < SPIKES_LAYOUT_VARIANTS && g_game->room->roomType == ROOM_DEVIL && + g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_SANGUINE_BOND, LAZARUS_SHARE_CHECK); +} + +// 0071eb30 Lowers the spikes, at once or animated. +void GridEntity_Spikes::unsummon(bool) +{ + reconstruction_missing("GridEntity_Spikes::unsummon 0071eb30"); +} diff --git a/src/grid_entity_spikes.h b/src/grid_entity_spikes.h new file mode 100644 index 0000000..7c9c49e --- /dev/null +++ b/src/grid_entity_spikes.h @@ -0,0 +1,16 @@ +#pragma once + +#include "grid_entity.h" + +// Destruction (0070bdd0) is the default. +// Spikes (Lua's GridEntitySpikes), always out or going in and out on a timer, hurting what walks over them. +struct GridEntity_Spikes : GridEntity +{ + int timeout = 0; + + void subclass_init() override; + void Update() override; + + bool is_disabled(); + void unsummon(bool isInstant); +}; diff --git a/src/grid_entity_stairs.cpp b/src/grid_entity_stairs.cpp new file mode 100644 index 0000000..4c122f2 --- /dev/null +++ b/src/grid_entity_stairs.cpp @@ -0,0 +1,20 @@ +#include "grid_entity_stairs.h" +#include "log.h" + +// 0099bad0 Loads the stairs. +void GridEntity_Stairs::subclass_init() +{ + reconstruction_missing("GridEntity_Stairs::subclass_init 0099bad0"); +} + +// 0099bd50 Takes a player stepping on it out of the crawlspace. +void GridEntity_Stairs::Update() +{ + reconstruction_missing("GridEntity_Stairs::Update 0099bd50"); +} + +// 00714750 Water lies flat over the stairs. +WaterClipInfo GridEntity_Stairs::GetWaterClipInfo() +{ + return {WATER_CLIP_FLAT, 0}; +} diff --git a/src/grid_entity_stairs.h b/src/grid_entity_stairs.h new file mode 100644 index 0000000..0ecd95b --- /dev/null +++ b/src/grid_entity_stairs.h @@ -0,0 +1,11 @@ +#pragma once + +#include "grid_entity.h" + +// The stairs out of a crawlspace (Lua's GRID_STAIRS). +struct GridEntity_Stairs : GridEntity +{ + void subclass_init() override; + void Update() override; + WaterClipInfo GetWaterClipInfo() override; +}; diff --git a/src/grid_entity_statue.cpp b/src/grid_entity_statue.cpp new file mode 100644 index 0000000..efab67d --- /dev/null +++ b/src/grid_entity_statue.cpp @@ -0,0 +1,24 @@ +#include "grid_entity_statue.h" +#include "log.h" + +// 00838ae0 Spawns the statue effect that draws it. +void GridEntity_Statue::subclass_init() +{ + reconstruction_missing("GridEntity_Statue::subclass_init 00838ae0"); +} + +// 00838520 Animates the statue, solid while it stands. +void GridEntity_Statue::Update() +{ + sprite.Update(); + if (state == STATUE_STATE_STANDING) + collisionClass = COLLISION_SOLID; + else if (state == STATUE_STATE_BROKEN) + collisionClass = COLLISION_NONE; +} + +// 00838560 Breaks the statue into its angel. +bool GridEntity_Statue::Destroy(bool, const EntityRef&) +{ + reconstruction_missing("GridEntity_Statue::Destroy 00838560"); +} diff --git a/src/grid_entity_statue.h b/src/grid_entity_statue.h new file mode 100644 index 0000000..19b4dc1 --- /dev/null +++ b/src/grid_entity_statue.h @@ -0,0 +1,20 @@ +#pragma once + +#include "grid_entity.h" + +// A statue standing, and broken. +constexpr int STATUE_STATE_STANDING = 1; +constexpr int STATUE_STATE_BROKEN = 2; + +// Destruction (0070bdd0) is the default. Its render (0042cdf0) draws nothing: +// the statue effect does. An angel statue (Lua's GRID_STATUE): solid until it breaks into the angel. +struct GridEntity_Statue : GridEntity +{ + Entity* statueEffect = nullptr; + + void subclass_init() override; + void Update() override; + void Render(const Vector&) override + {} + bool Destroy(bool isImmediate, const EntityRef& source) override; +}; diff --git a/src/grid_entity_teleporter.cpp b/src/grid_entity_teleporter.cpp new file mode 100644 index 0000000..da95d54 --- /dev/null +++ b/src/grid_entity_teleporter.cpp @@ -0,0 +1,26 @@ +#include "grid_entity_teleporter.h" +#include "log.h" + +// 00838eb0 Loads the pad. +void GridEntity_Teleporter::subclass_init() +{ + reconstruction_missing("GridEntity_Teleporter::subclass_init 00838eb0"); +} + +// 00838c30 Teleports a player standing on the pad. +void GridEntity_Teleporter::Update() +{ + reconstruction_missing("GridEntity_Teleporter::Update 00838c30"); +} + +// 00711f30 Draws the sprite on its cell. +void GridEntity_Teleporter::Render(const Vector& offset) +{ + sprite_render(offset); +} + +// 00714750 Water lies flat over the pad. +WaterClipInfo GridEntity_Teleporter::GetWaterClipInfo() +{ + return {WATER_CLIP_FLAT, 0}; +} diff --git a/src/grid_entity_teleporter.h b/src/grid_entity_teleporter.h new file mode 100644 index 0000000..64f74f8 --- /dev/null +++ b/src/grid_entity_teleporter.h @@ -0,0 +1,16 @@ +#pragma once + +#include "grid_entity.h" + +// A teleporter pad switched on, and off. +constexpr int TELEPORTER_STATE_ON = 1; +constexpr int TELEPORTER_STATE_OFF = 2; + +// A teleporter pad (Lua's GRID_TELEPORTER), switched on and off by pressure plates. +struct GridEntity_Teleporter : GridEntity +{ + void subclass_init() override; + void Update() override; + void Render(const Vector& offset) override; + WaterClipInfo GetWaterClipInfo() override; +}; diff --git a/src/grid_entity_tnt.cpp b/src/grid_entity_tnt.cpp new file mode 100644 index 0000000..a71ffb8 --- /dev/null +++ b/src/grid_entity_tnt.cpp @@ -0,0 +1,33 @@ +#include "grid_entity_tnt.h" +#include "log.h" +#include "seeds.h" +#include + +// 0071ee90 Loads the barrel. +void GridEntity_TNT::subclass_init() +{ + reconstruction_missing("GridEntity_TNT::subclass_init 0071ee90"); +} + +// 0071f090 Shows the barrel's damage and explodes it when its fuse runs out. +void GridEntity_TNT::Update() +{ + reconstruction_missing("GridEntity_TNT::Update 0071f090"); +} + +// 0071f250 Damages the barrel a stage or more, one time in three a stage more. +bool GridEntity_TNT::Hurt(int damage, const EntityRef&) +{ + int stages = Random() % 3 == 0 ? std::min(damage + 1, TNT_STATE_BLOWN) : damage; + if (stages < 1 || state > TNT_STATE_READY) + return false; + + state = std::min(state + stages, (int)TNT_STATE_BLOWN); + return true; +} + +// 0071f2b0 Lights the barrel's fuse. +bool GridEntity_TNT::Destroy(bool, const EntityRef&) +{ + reconstruction_missing("GridEntity_TNT::Destroy 0071f2b0"); +} diff --git a/src/grid_entity_tnt.h b/src/grid_entity_tnt.h new file mode 100644 index 0000000..3c02f2e --- /dev/null +++ b/src/grid_entity_tnt.h @@ -0,0 +1,19 @@ +#pragma once + +#include "grid_entity.h" + +// How damaged a barrel is: up to ready to explode, then blown. +constexpr int TNT_STATE_READY = 3; +constexpr int TNT_STATE_BLOWN = 4; + +// Destruction (0070bdd0) is the default. +// A TNT barrel on the grid (Lua's GRID_TNT): hurt in stages, it explodes. +struct GridEntity_TNT : GridEntity +{ + int fuseFrames = 0; + + void subclass_init() override; + void Update() override; + bool Hurt(int damage, const EntityRef& source) override; + bool Destroy(bool isImmediate, const EntityRef& source) override; +}; diff --git a/src/grid_entity_trap_door.cpp b/src/grid_entity_trap_door.cpp new file mode 100644 index 0000000..6b7bd9d --- /dev/null +++ b/src/grid_entity_trap_door.cpp @@ -0,0 +1,20 @@ +#include "grid_entity_trap_door.h" +#include "log.h" + +// 0071f630 Loads the trapdoor for where it leads. +void GridEntity_TrapDoor::subclass_init() +{ + reconstruction_missing("GridEntity_TrapDoor::subclass_init 0071f630"); +} + +// 0071fef0 Opens once the players stand clear and takes a player falling in to the next floor. +void GridEntity_TrapDoor::Update() +{ + reconstruction_missing("GridEntity_TrapDoor::Update 0071fef0"); +} + +// 00714750 Water lies flat over the trapdoor. +WaterClipInfo GridEntity_TrapDoor::GetWaterClipInfo() +{ + return {WATER_CLIP_FLAT, 0}; +} diff --git a/src/grid_entity_trap_door.h b/src/grid_entity_trap_door.h new file mode 100644 index 0000000..192338d --- /dev/null +++ b/src/grid_entity_trap_door.h @@ -0,0 +1,14 @@ +#pragma once + +#include "grid_entity.h" + +// Destruction (0070bdd0) is the default. +// A trapdoor to the next floor (Lua's GRID_TRAPDOOR), or the heavenly light up. +struct GridEntity_TrapDoor : GridEntity +{ + int openFrames = 0; + + void subclass_init() override; + void Update() override; + WaterClipInfo GetWaterClipInfo() override; +}; diff --git a/src/grid_entity_wall.cpp b/src/grid_entity_wall.cpp new file mode 100644 index 0000000..fe30d2b --- /dev/null +++ b/src/grid_entity_wall.cpp @@ -0,0 +1,261 @@ +#include "grid_entity_wall.h" +#include "game.h" +#include "grid_entity_decoration.h" +#include "grid_entity_gravity.h" +#include "log.h" +#include "room.h" +#include "seeds.h" +#include + +constexpr int BACKDROP_DUNGEON_GIDEON = 55; +constexpr int BACKDROP_DUNGEON_ROTGUT = 56; + +// The walls inside an L-shaped room's corner: the columns either side of the middle and the rows above and below it. +constexpr int L_COLUMN_LEFT = 13; +constexpr int L_COLUMN_RIGHT = 14; +constexpr int L_ROW_TOP = 7; +constexpr int L_ROW_BOTTOM = 8; + +// The crawlspaces whose walls hold the ladder up and the gravity cells beside the exit, by subtype and variant. +constexpr int CRAWLSPACE_SUBTYPE_PLAIN_FIRST = 2; +constexpr int CRAWLSPACE_SUBTYPE_PLAIN_LAST = 3; +constexpr int CRAWLSPACE_LADDER_COLUMN = 2; +constexpr int CRAWLSPACE_GRAVITY_COLUMN = 14; +constexpr int CRAWLSPACE_GRAVITY_ROW_TOP = 3; +constexpr int CRAWLSPACE_GRAVITY_ROW_BOTTOM = 4; +constexpr int CRAWLSPACE_GRAVITY_VARIANT = 1; + +// The wall animations: the bricks of a crawlspace by what stands above them, and its decorated walls. +constexpr int BRICK_TOP_VARIANTS = 3; +constexpr int BRICK_LOW_VARIANTS = 2; +constexpr int WALL_DECORATION_1 = 1; +constexpr int WALL_DECORATION_2 = 2; + +// Puts a new grid entity on its cell in place of the one there, then initializes it. +static void grid_place(Room& room, GridEntity* entity, int variant, uint32_t seed) +{ + delete room.gridEntities[entity->gridIndex]; + room.gridEntities[entity->gridIndex] = entity; + entity->variant = variant; + entity->varData = 0; + entity->Init(seed); +} + +// Whether a cell above or below a crawlspace brick leaves it open: nothing, a decoration or gravity. +static bool is_open_cell(GridEntity* entity) +{ + return !entity || entity->type == GRID_DECORATION || entity->type == GRID_GRAVITY; +} + +// 007ee7e0 Walls a border cell unless something stands there. A crawlspace's ladder and its exit's gravity take their +// cells instead. The original writes past the grid for a cell off it, and calls a missing entity's PostInit: both are +// skipped here. +static bool make_wall(Room& room, int x, int y) +{ + int gridIndex = room.gridWidth * y + x; + if (gridIndex < 0 || gridIndex >= room.gridHeight * room.gridWidth) + { + KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"make_wall index out of bounds\n"); + return false; + } + if (room.gridEntities[gridIndex]) + return false; + + RoomConfig_Room* data = room.descriptor->data; + bool isLadderCrawlspace = room.roomType == ROOM_DUNGEON && (data->subtype < CRAWLSPACE_SUBTYPE_PLAIN_FIRST || + data->subtype > CRAWLSPACE_SUBTYPE_PLAIN_LAST); + bool isGravityCell = isLadderCrawlspace && x == CRAWLSPACE_GRAVITY_COLUMN && + data->variant == CRAWLSPACE_GRAVITY_VARIANT && + (y == CRAWLSPACE_GRAVITY_ROW_TOP || y == CRAWLSPACE_GRAVITY_ROW_BOTTOM); + if (isLadderCrawlspace && y == 0 && x == CRAWLSPACE_LADDER_COLUMN) + { + uint32_t seed = Random(); + if (room.gridPaths[gridIndex] > GRID_PATH_FREED) + return false; + + GridEntity* ladder = CreateGridEntity(GRID_DECORATION, gridIndex); + grid_place(room, ladder, DECORATION_LADDER_LOW, seed); + return false; + } + if (isGravityCell) + { + uint32_t seed = Random(); + if (room.gridPaths[gridIndex] <= GRID_PATH_FREED) + grid_place(room, CreateGridEntity(GRID_GRAVITY, gridIndex), 0, seed); + if (room.gridEntities[gridIndex]) + room.gridEntities[gridIndex]->PostInit(); + return false; + } + + GridEntity* wall = CreateGridEntity(GRID_WALL, gridIndex); + room.gridEntities[gridIndex] = wall; + wall->Init(Random()); + return true; +} + +// 0081ee20 Walls the room's border, around the corner of an L-shaped room and the corridor of a narrow one. The Beast's +// room has none. The original reads the shape of a room without a layout: none is walled here. +void Room::make_walls() +{ + RoomConfig_Room* data = descriptor->data; + if (!data || IsBeastDungeon()) + return; + + int right = gridWidth - 1; + int bottom = gridHeight - 1; + switch (data->shape) + { + case ROOMSHAPE_LBL: + for (int x = 0; x < gridWidth; x++) + { + make_wall(*this, x, 0); + make_wall(*this, x, x < L_COLUMN_LEFT ? L_ROW_BOTTOM : bottom); + } + for (int y = 0; y < bottom; y++) + { + make_wall(*this, y > L_ROW_TOP ? L_COLUMN_LEFT : 0, y); + make_wall(*this, right, y); + } + break; + case ROOMSHAPE_LBR: + for (int x = 0; x < gridWidth; x++) + { + make_wall(*this, x, 0); + make_wall(*this, x, x <= L_COLUMN_RIGHT ? bottom : L_ROW_BOTTOM); + } + for (int y = 0; y < bottom; y++) + { + make_wall(*this, 0, y); + make_wall(*this, y < L_ROW_BOTTOM ? right : L_COLUMN_RIGHT, y); + } + break; + case ROOMSHAPE_LTL: + for (int x = 0; x < gridWidth; x++) + { + make_wall(*this, x, x > L_COLUMN_LEFT ? 0 : L_ROW_TOP); + make_wall(*this, x, bottom); + } + for (int y = 0; y < bottom; y++) + { + make_wall(*this, y > L_ROW_TOP ? 0 : L_COLUMN_LEFT, y); + make_wall(*this, right, y); + } + break; + case ROOMSHAPE_LTR: + for (int x = 0; x < gridWidth; x++) + { + make_wall(*this, x, x > L_COLUMN_RIGHT ? L_ROW_TOP : 0); + make_wall(*this, x, bottom); + } + for (int y = 0; y < bottom; y++) + { + make_wall(*this, 0, y); + make_wall(*this, y < L_ROW_BOTTOM ? L_COLUMN_RIGHT : right, y); + } + break; + case ROOMSHAPE_IH: + case ROOMSHAPE_IV: + case ROOMSHAPE_IIH: + case ROOMSHAPE_IIV: + { + LRoomTileDesc tiles = GetLRoomTileDesc(); + int left = tiles.topLeftAX - 1; + int top = tiles.topLeftAY - 1; + int corridorRight = tiles.bottomRightAX + 1; + int corridorBottom = tiles.bottomRightAY + 1; + for (int x = left; x <= corridorRight; x++) + { + make_wall(*this, x, top); + make_wall(*this, x, corridorBottom); + } + for (int y = top; y <= corridorBottom; y++) + { + make_wall(*this, left, y); + make_wall(*this, corridorRight, y); + } + break; + } + default: + for (int x = 0; x < gridWidth; x++) + { + make_wall(*this, x, 0); + make_wall(*this, x, bottom); + } + for (int y = 0; y < bottom; y++) + { + make_wall(*this, 0, y); + make_wall(*this, right, y); + } + break; + } +} + +// 007210d0 Blocks the cell. A crawlspace's walls load its tiles. +void GridEntity_Wall::subclass_init() +{ + collisionClass = COLLISION_WALL; + path_set(GRID_PATH_SOLID); + + Room& room = *g_game->room; + if (room.roomType != ROOM_DUNGEON) + return; + + if (room.backdropType == BACKDROP_DUNGEON_GIDEON) + sprite.Load("gfx/grid/Tiles_Itemdungeon_Gideon.anm2", GRAPHICS_LOAD); + else if (room.backdropType == BACKDROP_DUNGEON_ROTGUT) + sprite.Load("gfx/grid/Tiles_Rotgut.anm2", GRAPHICS_LOAD); + else + sprite.Load("gfx/grid/Tiles_Itemdungeon.anm2", GRAPHICS_LOAD); +} + +// 00721310 Picks a crawlspace wall's look once the room is laid out: a decoration, or a brick as open as the cells +// above and below leave it. +// Rotgut's bricks step through their animation by column. +void GridEntity_Wall::PostInit() +{ + Room& room = *g_game->room; + if (room.roomType != ROOM_DUNGEON) + return; + + int column = gridIndex % room.gridWidth; + int row = gridIndex / room.gridWidth; + if (room.backdropType == BACKDROP_DUNGEON_ROTGUT) + { + int above = room.GetGridIndexByTile(column, row - 1); + int below = room.GetGridIndexByTile(column, row + 1); + const char* name = "MiddleBrick"; + if (is_open_cell(above < 0 ? nullptr : room.gridEntities[above])) + name = "Brick"; + else if (is_open_cell(below < 0 ? nullptr : room.gridEntities[below])) + name = "LowBrick"; + + const AnimationData* data = sprite.GetAnimationData(name); + if (!data || !sprite.SetAnimation(name) || !sprite.animState.animData) + return; + + sprite.animState.SetFrameFloat((float)(column % data->length)); + sprite.animState.isPlaying = false; + return; + } + + if (variant == WALL_DECORATION_1) + return sprite.Play("Decoration1"); + if (variant == WALL_DECORATION_2) + return sprite.Play("Decoration2"); + + Vector abovePosition = + vector_make(column * GRID_CELL_SIZE + GRID_ORIGIN_X, row * GRID_CELL_SIZE + GRID_ORIGIN_Y - GRID_CELL_SIZE); + bool isOpen = is_open_cell(room.GetGridEntity(room.GetGridIndex(abovePosition))); + char name[32]; + std::snprintf(name, sizeof(name), "%s%u", isOpen ? "Brick" : "LowBrick", + Random() % (isOpen ? BRICK_TOP_VARIANTS : BRICK_LOW_VARIANTS) + 1); + sprite.Play(name); +} + +// 00720fe0 Draws a crawlspace wall in the floor's color. +void GridEntity_Wall::Render(const Vector& offset) +{ + if (g_game->room->roomType == ROOM_DUNGEON) + sprite.color = g_game->room->floorColor; + sprite_render(offset); +} diff --git a/src/grid_entity_wall.h b/src/grid_entity_wall.h new file mode 100644 index 0000000..a466753 --- /dev/null +++ b/src/grid_entity_wall.h @@ -0,0 +1,14 @@ +#pragma once + +#include "grid_entity.h" + +// Its update (0040c200) does nothing. +// A wall on the room's border (Lua's GRID_WALL). Only a crawlspace draws its walls as bricks and ladders. +struct GridEntity_Wall : GridEntity +{ + void subclass_init() override; + void PostInit() override; + void Update() override + {} + void Render(const Vector& offset) override; +}; diff --git a/src/grid_entity_web.cpp b/src/grid_entity_web.cpp new file mode 100644 index 0000000..be5e03d --- /dev/null +++ b/src/grid_entity_web.cpp @@ -0,0 +1,35 @@ +#include "grid_entity_web.h" +#include "log.h" + +// 00721540 Loads the web. +void GridEntity_Web::subclass_init() +{ + reconstruction_missing("GridEntity_Web::subclass_init 00721540"); +} + +// 00721780 Slows the entities in the web. +void GridEntity_Web::Update() +{ + reconstruction_missing("GridEntity_Web::Update 00721780"); +} + +// 00721a10 Burns a standing web away, stopped on its first bombed frame. +bool GridEntity_Web::Destroy(bool, const EntityRef&) +{ + if (state != WEB_STATE_STANDING) + return false; + + state = WEB_STATE_BOMBED; + if (sprite.SetAnimation("Bombed") && sprite.animState.animData) + { + sprite.animState.SetFrameFloat(0); + sprite.animState.isPlaying = false; + } + return true; +} + +// 00714750 Water lies flat over the web. +WaterClipInfo GridEntity_Web::GetWaterClipInfo() +{ + return {WATER_CLIP_FLAT, 0}; +} diff --git a/src/grid_entity_web.h b/src/grid_entity_web.h new file mode 100644 index 0000000..63296c9 --- /dev/null +++ b/src/grid_entity_web.h @@ -0,0 +1,16 @@ +#pragma once + +#include "grid_entity.h" + +// A web standing, and bombed. +constexpr int WEB_STATE_STANDING = 0; +constexpr int WEB_STATE_BOMBED = 1; + +// A spider web (Lua's GRID_SPIDERWEB), which slows what walks through it until bombed. +struct GridEntity_Web : GridEntity +{ + void subclass_init() override; + void Update() override; + bool Destroy(bool isImmediate, const EntityRef& source) override; + WaterClipInfo GetWaterClipInfo() override; +}; diff --git a/src/hud.cpp b/src/hud.cpp index f797a68..75e6aa1 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -345,119 +345,6 @@ void HUD_Message::render_text_image(Font&, std::u16string_view, Vector, KColor) reconstruction_missing("HUD_Message::render_text_image 008413a0"); } -// Shows a player in a corner that does not show it yet, emptied first and redrawn. -static void corner_assign(PlayerHUD& hud, Entity_Player* player) -{ - if (player == hud.player) return; - - hud.reset(); - hud.player = player; - hud.isDirty = true; - hud.isCraftingItemDirty = true; -} - -// 00841cf0 Empties the corner: hearts, flashes, trinkets, actives, the crafting bag, and the player it showed. -void PlayerHUD::reset() -{ - hearts.fill({}); - lastHeartFlash = 0; - redHeartFlashCountdown = 0; - soulHeartFlashCountdown = 0; - goldHeartFlashCountdown = 0; - for (PlayerHUDTrinket& trinket : trinkets) trinket = {}; - for (PlayerHUDActiveItem& item : activeItems) item = {}; - craftingIcons.clear(); - isDirty = false; - isCraftingItemDirty = false; - craftingResultImage.reset(); - craftingBagImage.reset(); - player = nullptr; -} - -// Forgets the box the corner covered, as HUD::Render does before each frame. -void PlayerHUD::bounds_reset() -{ - boundsMin = vector_make(PLAYER_HUD_BOUNDS_FAR, PLAYER_HUD_BOUNDS_FAR); - boundsMax = vector_make(-PLAYER_HUD_BOUNDS_FAR, -PLAYER_HUD_BOUNDS_FAR); -} - -// 00842230 Follows the player's hearts, items, pockets and crafting bag, loading the icons they show. -void PlayerHUD::Update() -{ - reconstruction_missing("PlayerHUD::Update 00842230"); -} - -// 00841e20 Picks the animations of a heart slot from the player's health. -void PlayerHUD::UpdateHearts(PlayerHUDHeart&, int) -{ - reconstruction_missing("PlayerHUD::UpdateHearts 00841e20"); -} - -// 00840030 Sets an active slot's charge bar frame for a collectible. -void PlayerHUD::set_active_charge_frame(int) -{ - reconstruction_missing("PlayerHUD::set_active_charge_frame 00840030"); -} - -// 00843df0 Draws the heart rows and returns how far they reach. -void PlayerHUD::RenderHearts(Vector&, ANM2&, PlayerHudLayout, float, Vector) -{ - reconstruction_missing("PlayerHUD::RenderHearts 00843df0"); -} - -// 008453c0 Draws an active item with its charge bar. -void PlayerHUD::RenderActiveItem(int, Vector, PlayerHudLayout, float, float) -{ - reconstruction_missing("PlayerHUD::RenderActiveItem 008453c0"); -} - -// 00846ff0 Draws a trinket. -void PlayerHUD::RenderTrinket(int, Vector, float, bool) -{ - reconstruction_missing("PlayerHUD::RenderTrinket 00846ff0"); -} - -// 008471c0 Draws the cards, pills and pocket actives. -void PlayerHUD::RenderPocketItems(Vector, PlayerHudLayout, float, float) -{ - reconstruction_missing("PlayerHUD::RenderPocketItems 008471c0"); -} - -// 00848d20 Draws Tainted Isaac's inventory. -void PlayerHUD::render_inventory(Vector, float) -{ - reconstruction_missing("PlayerHUD::render_inventory 00848d20"); -} - -// 00849510 Draws Tainted Cain's crafting bag. -void PlayerHUD::RenderCraftingTable(Vector, float) -{ - reconstruction_missing("PlayerHUD::RenderCraftingTable 00849510"); -} - -// 0084a3e0 Draws Tainted ???'s poop spell queue. -void PlayerHUD::RenderSpellQueue(Vector, float) -{ - reconstruction_missing("PlayerHUD::RenderSpellQueue 0084a3e0"); -} - -// 0084ad40 Draws a versus health bar and returns its size. -Vector PlayerHUD::render_deathmatch_health_bar(Vector) -{ - reconstruction_missing("PlayerHUD::render_deathmatch_health_bar 0084ad40"); -} - -// 009a8500 A new corner of a HUD, not one of its eight, showing a player. -std::shared_ptr PlayerHUD::make_ref(HUD* owner, Entity_Player* shown) -{ - auto corner = std::make_shared(); - - corner->hud = owner; - corner->playerHudIndex = -1; - corner_assign(*corner, shown); - return corner; -} - // 0083abb0 Forgets both players' recent items. void HistoryHUD::clear() { @@ -1566,7 +1453,7 @@ void HUD::AssignPlayerHUDs() log_printf(LOG_INFO, "Assinging player entity %d (ControlerIndex = %d) to HUD slot %d \n", (int)i, player->controllerIndex, seat); - corner_assign(playerHUD[seat], player); + playerHUD[seat].assign(player); Entity_Player* twin = player->twin_get(); if (!twin || !twin->isExists || twin->playerType == PLAYER_THESOUL_B) continue; @@ -1575,6 +1462,6 @@ void HUD::AssignPlayerHUDs() log_printf(LOG_INFO, "Assinging player entity %d's twin (ControlerIndex = %d) to HUD slot %d \n", (int)i, twin->controllerIndex, seat); - corner_assign(playerHUD[seat + MAIN_PLAYER_HUD_COUNT], twin); + playerHUD[seat + MAIN_PLAYER_HUD_COUNT].assign(twin); } } diff --git a/src/hud.h b/src/hud.h index a179a1f..6caa1a3 100644 --- a/src/hud.h +++ b/src/hud.h @@ -5,6 +5,7 @@ #include "fx_layers.h" #include "item_info_hud.h" #include "kage_graphics.h" +#include "player_hud.h" #include "rich_text.h" #include "stat_hud.h" #include @@ -14,28 +15,11 @@ #include #include -constexpr int PLAYER_HUD_COUNT = 8; -constexpr int MAIN_PLAYER_HUD_COUNT = 4; -constexpr int PLAYER_HUD_HEART_COUNT = 24; -constexpr int PLAYER_HUD_ACTIVE_COUNT = 4; -constexpr int PLAYER_HUD_TRINKET_COUNT = 2; -constexpr int PLAYER_HUD_POCKET_COUNT = 4; constexpr int MESSAGE_STACK_COUNT = 6; constexpr int HISTORY_PLAYER_COUNT = 2; constexpr float BOSS_BAR_HIDDEN = -1; constexpr int FLASH_OFF = -1; constexpr int ONLINE_HUD_OFFLINE = 3; -constexpr float PLAYER_HUD_BOUNDS_FAR = 1e7f; - -// REPENTOGON's HUD layouts of a player, and the spot an online player's status takes. -enum PlayerHudLayout : int -{ - HUD_LAYOUT_NORMAL, - HUD_LAYOUT_JACOB_ESAU, - HUD_LAYOUT_COMPACT, - HUD_LAYOUT_JACOB_ESAU_COMPACT, - HUD_LAYOUT_NET_STATUS -}; // How much of the HUD a refresh request redraws. A full request is never downgraded by a lighter one. enum HudRefresh : int @@ -89,96 +73,6 @@ struct HUD_Message static void render_text_image(Font& textFont, std::u16string_view line, Vector at, KColor textColor); }; -// REPENTOGON's PlayerHUDHeart: the animations a heart slot shows and how. -struct PlayerHUDHeart -{ - const char* spriteAnim = ""; - const char* spriteOverlayAnim = ""; - int8_t flashType = 0; - bool isEternalHeartVisible = false; - bool isFadeHeart = false; - bool isGoldenHeartVisible = false; - bool isVisible = false; -}; - -// REPENTOGON's PlayerHUDActiveItem: the item an active slot shows, its book overlay and its charge bar flash. -struct PlayerHUDActiveItem -{ - KAGE::Graphics::ImagePtr bookImage; - KAGE::Graphics::ImagePtr itemImage; - int bookItemId = 0; - int chargeBarFlash = 0; - int id = 0; -}; - -// REPENTOGON's PlayerHUDTrinket: the trinket a slot shows. -struct PlayerHUDTrinket -{ - KAGE::Graphics::ImagePtr image; - int id = 0; - int slot = 0; -}; - -// A card, pill or pocket active slot: its sprite and what it shows. -struct PlayerHUDPocketItem -{ - ANM2 sprite; - int id = 0; - int kind = 0; -}; - -// A crafting bag pickup icon. -struct PlayerHUDIcon -{ - KAGE::Graphics::ImagePtr image; - int id = 0; -}; - -// Construction (006efc70) and destruction (006efde0) are the defaults. -// One player's corner of the HUD (REPENTOGON's PlayerHUD): hearts, actives, trinkets, pockets and the crafting bag, and -// the box the drawn parts covered this frame. -struct PlayerHUD -{ - std::array hearts{}; - std::array activeItems{}; - std::array trinkets{}; - std::array pocketItems{}; - std::vector craftingIcons; - KAGE::Graphics::ImagePtr craftingBagImage; - KAGE::Graphics::ImagePtr craftingResultImage; - KAGE::Graphics::ImagePtr deathmatchHealthBarImage; - Vector boundsMax = vector_make(-PLAYER_HUD_BOUNDS_FAR, -PLAYER_HUD_BOUNDS_FAR); - Vector boundsMin = vector_make(PLAYER_HUD_BOUNDS_FAR, PLAYER_HUD_BOUNDS_FAR); - Entity_Player* player = nullptr; - HUD* hud = nullptr; - float dropHoldFade = 0; - int16_t lastHeartFlash = 0; - int16_t playerHudIndex = 0; - int8_t goldHeartFlashCountdown = 0; - int8_t redHeartFlashCountdown = 0; - int8_t soulHeartFlashCountdown = 0; - bool isCraftingItemDirty = false; - bool isDirty = false; - - void reset(); - void bounds_reset(); - void Update(); - void UpdateHearts(PlayerHUDHeart& heart, int heartIndex); - void set_active_charge_frame(int collectibleId); - void RenderHearts(Vector& outExtent, ANM2& sprite, PlayerHudLayout layout, float heartScale, Vector at); - void RenderActiveItem(int activeSlot, Vector at, PlayerHudLayout layout, float itemScale, float alpha); - void RenderTrinket(int trinketSlot, Vector at, float trinketScale, bool isSmall); - void RenderPocketItems(Vector at, PlayerHudLayout layout, float alpha, float pocketScale); - void render_inventory(Vector at, float inventoryScale); - void RenderCraftingTable(Vector at, float tableScale); - void RenderSpellQueue(Vector at, float queueScale); - Vector render_deathmatch_health_bar(Vector at); - static std::shared_ptr make_ref(HUD* owner, Entity_Player* shown); -}; - - - - // An item of the recent items list, with its icon. struct HistoryHUDItem { diff --git a/src/item_pool.cpp b/src/item_pool.cpp index 3fad1a3..bdf9e27 100644 --- a/src/item_pool.cpp +++ b/src/item_pool.cpp @@ -364,14 +364,35 @@ void ItemPool::shuffle_pools() std::swap(pool.poolList[last], pool.poolList[twister() % (last + 1)]); } -// (007367d0) Saves the pools into a game state. GameStateItemPool is not modelled yet. -void ItemPool::StoreGameState(GameStateItemPool&) +// 007367d0 Saves the pools into a game state: each pool's item weights and Bible chance, the seeds, the removed +// collectibles, the trinkets still in the pool, the pill colors and the Genesis counts. +void ItemPool::StoreGameState(GameStateItemPool& state) { - reconstruction_missing("ItemPool::StoreGameState 007367d0"); + for (size_t i = 0; i < pools.size(); i++) + { + std::vector& weights = state.poolsItemWeights[i]; + + weights.clear(); + for (PoolItem& item : pools[i].poolList) weights.push_back(item.weight); + state.bibleUpgrades[i] = pools[i].bibleUpgrade; + } + + state.seed = seed; + state.lastPool = lastPool; + state.itemPoolRNGseed = itemPoolRNG._seed; + state.trinketPoolRNGseed = trinketPoolRNG._seed; + state.unkFloat674 = unkFloat674; + state.unkFloat678 = unkFloat678; + state.removedCollectibles = removedCollectibles; + state.trinketPoolItems.clear(); + for (TrinketPoolItem& trinket : trinketPoolItems) state.trinketPoolItems.push_back(trinket.isInPool); + state.pillEffects = pillEffects; + state.identifiedPillEffects = identifiedPillEffects; + state.remainingGenesisItems = remainingGenesisItems; } -// (00736530) Restores the pools from a game state. GameStateItemPool is not modelled yet. -void ItemPool::RestoreGameState(GameStateItemPool&) +// Not reconstructed yet: it stops the game where it is reached. +void ItemPool::RestoreGameState(const GameStateItemPool&) { reconstruction_missing("ItemPool::RestoreGameState 00736530"); } diff --git a/src/item_pool.h b/src/item_pool.h index aa0767f..42fc742 100644 --- a/src/item_pool.h +++ b/src/item_pool.h @@ -128,6 +128,26 @@ struct TrinketPoolItem bool isInPool = false; }; +// The pools as a saved run keeps them (GameStateItemPool): each pool's item weights in draw order and the Bible's +// chance, the seeds, the collectibles drawing removed, which trinkets are still in the pool, the pill colors' effects +// and the Genesis counts. +struct GameStateItemPool +{ + std::array, POOL_COUNT> poolsItemWeights; + std::array bibleUpgrades{}; + std::array pillEffects{}; + std::array identifiedPillEffects{}; + std::array remainingGenesisItems{}; + std::vector removedCollectibles; + std::vector trinketPoolItems; + float unkFloat674 = 0; + float unkFloat678 = 0; + uint32_t itemPoolRNGseed = 0; + uint32_t seed = 0; + uint32_t trinketPoolRNGseed = 0; + int lastPool = 0; +}; + // The run's item pools: the collectibles each draws from and what drawing removed, the trinket pool, which effect each // pill color has this run and which are identified. Rebirth's Lua ItemPool binds this class. class ItemPool @@ -154,7 +174,7 @@ public: void load_pools(std::string_view path, PoolsLoad load); void shuffle_pools(); void StoreGameState(GameStateItemPool& state); - void RestoreGameState(GameStateItemPool& state); + void RestoreGameState(const GameStateItemPool& state); ItemPool_Item& GetPool(ItemPoolType poolType); int GetLastPool(); diff --git a/src/level.cpp b/src/level.cpp index bb8921a..11a1ef7 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -2,6 +2,7 @@ #include "boss_pool.h" #include "entity_player.h" #include "game.h" +#include "grid_entity_door.h" #include "hud.h" #include "manager.h" #include "platform.h" @@ -9,10 +10,27 @@ #include "room_transition.h" #include "texture_cache.h" #include +#include #include #include #include +// Where GetEnterPosition puts the players: a crawlspace's ladder down and its ladder back up, the Black Market's +// stairs, and the spots of the secret shop and the two off-map rooms between it and the Black Market. +constexpr float DUNGEON_ENTRY_X = 120; +constexpr float DUNGEON_ENTRY_Y = 160; +constexpr float DUNGEON_EXIT_X = 480; +constexpr float DUNGEON_EXIT_Y = 280; +constexpr float BLACK_MARKET_EXIT_X = 560; +constexpr float SECRET_SHOP_ENTRY_X = 440; +constexpr float SECRET_SHOP_ENTRY_Y = 168; +constexpr int ROOM_OFF_MAP_14_IDX = -14; +constexpr float OFF_MAP_14_ENTRY_X = 320; +constexpr float OFF_MAP_14_ENTRY_Y = 160; +constexpr int ROOM_OFF_MAP_15_IDX = -15; +constexpr float OFF_MAP_15_ENTRY_X = 80; +constexpr float OFF_MAP_15_ENTRY_Y = 400; + constexpr uint32_t LEVEL_STAGE_BASEMENT_I = 1; constexpr uint32_t LEVEL_STAGE_CAVES_I = 3; constexpr uint32_t LEVEL_STAGE_CAVES_II = 4; @@ -45,6 +63,7 @@ constexpr int STAGE_ID_VOID = 26; constexpr uint32_t CHALLENGE_XXXXXXXXL = 21; constexpr uint32_t SPECIAL_DAILY_NO_CURSES = 18; +constexpr uint32_t SPECIAL_DAILY_DEALS = 17; constexpr uint32_t SPECIAL_DAILY_CURSED = 37; constexpr uint32_t SPECIAL_DAILY_CURSES = CURSE_OF_THE_LOST | CURSE_OF_THE_UNKNOWN | CURSE_OF_BLIND; @@ -92,8 +111,6 @@ constexpr int TRINKET_MYOSOTIS = 137; constexpr int TRINKET_DEVILS_CROWN = 146; constexpr int TREASURE_SUBTYPE_KNIFE_PIECE = 34; constexpr int LIL_PORTAL_ROOM_VARIANT = 2; -constexpr int GRID_STAIRS = 18; -constexpr int GRID_TRAPDOOR = 17; constexpr int GRID_SPAWN_PIT_FIRST = 3000; constexpr int GRID_SPAWN_PIT_END = 3010; constexpr int ROOM_INDEX_OTHER_DIMENSION = -100; @@ -217,8 +234,6 @@ constexpr int GREED_SUBTYPE = 4; constexpr int GREED_SUBTYPE_SUPER = 11; constexpr int GREED_SUBTYPE_DEVIL = 15; constexpr int RED_ROOM_DOOR_TARGET = -2; -constexpr int GRID_DOOR = 16; -constexpr int DOOR_VARIANT_HIDDEN = 7; constexpr int HUD_REFRESH_FRAMES = 2; constexpr int BACKDROP_CORPSE3 = 44; constexpr int EFFECT_VARIANT_BLOOD_SPLAT = 7; @@ -2133,12 +2148,6 @@ float Level::GetPlanetariumChance() return std::clamp(chance, PLANETARIUM_CHANCE_MIN, 1.0f); } -// A grid entity's description (type, variant, state), which classes.h still holds as bytes. -static GridEntityDesc& grid_desc_get(GridEntity& entity) -{ - return *reinterpret_cast(entity._desc); -} - // Devil's Crown's turn of an unvisited treasure room into a devil treasure room: 1 in 4 golden, 1 in 3 stronger, from // up to ten draws of a devil room with the treasure room's doors. static void devils_crown_room_roll(Level& level, RoomDescriptor& desc) @@ -2298,9 +2307,9 @@ static void doors_target(Level& level, RoomDescriptor& desc) GridEntity_Door& door = *doors[level.enterDoor]; - door._slot = level.enterDoor; + door.slot = level.enterDoor; door.SetRoomTypes(type, ROOM_DEFAULT); - door._targetRoomIdx = level.lastRoomIdx; + door.targetRoomIdx = level.lastRoomIdx; return; } for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) @@ -2310,8 +2319,8 @@ static void doors_target(Level& level, RoomDescriptor& desc) bool isRedDoor = target == RED_ROOM_DOOR_TARGET; if (!door || (!isRedDoor && (target < 0 || level.currentRoomMap[target] < 0))) continue; - door->_slot = slot; - door->_targetRoomIdx = target; + door->slot = slot; + door->targetRoomIdx = target; door->SetRoomTypes(type, isRedDoor ? ROOM_DEFAULT : level.GetRoomByIdx(target)->data->type); } } @@ -2326,18 +2335,18 @@ static void corpse_door_splats_spawn(Level& level) for (GridEntity_Door* door : room.doors) { - if (!door || std::ranges::find(CORPSE_SPLAT_ROOM_TYPES, door->_targetRoomType) == CORPSE_SPLAT_ROOM_TYPES.end()) + if (!door || std::ranges::find(CORPSE_SPLAT_ROOM_TYPES, door->targetRoomType) == CORPSE_SPLAT_ROOM_TYPES.end()) continue; - RoomDescriptor& target = *level.GetRoomByIdx(door->_targetRoomIdx); + RoomDescriptor& target = *level.GetRoomByIdx(door->targetRoomIdx); if (!(target.flags & ROOM_DESCRIPTOR_FLAG_USE_ALTERNATE_BACKDROP)) continue; RNG rng = {target.decorationSeed, 2, 15, 17}; Vector direction{}; - int gridIndex = (int)door->_gridIndex; + int gridIndex = (int)door->gridIndex; - Isaac::GetAxisAlignedUnitVectorFromDir(&direction, door->_direction); + Isaac::GetAxisAlignedUnitVectorFromDir(&direction, door->direction); Vector out = {-direction.x, -direction.y}; Vector across = {out.x * rotationCos - out.y * rotationSin, out.x * rotationSin + out.y * rotationCos}; @@ -2400,22 +2409,28 @@ void Level::load_room() reconstruction_missing("Level::load_room 0073e0a0: the mineshaft entrance's bridged pits (Room+0x746d)"); doors_target(*this, desc); if (GetRoomByIdx(currentRoomIdx)->flags & ROOM_DESCRIPTOR_FLAG_CLEAR) - reconstruction_missing("Level::load_room 0073e0a0: a cleared room's special doors (Room::TrySpawnSecretExit " - "007f7a40, TrySpawnDevilRoomDoor 007f83b0, TrySpawnBossRushDoor 007f9960, " - "TrySpawnTheVoidDoor 008204b0, TrySpawnBlueWombDoor 00820170)"); + { + if (!isGreed) + { + room->TrySpawnSecretExit(false, false); + room->TrySpawnDevilRoomDoor(false, false); + room->TrySpawnBossRushDoor(false, false); + room->TrySpawnTheVoidDoor(false); + } + room->TrySpawnBlueWombDoor(false, false, false); + } for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) { RoomShape shape = room->descriptor && room->descriptor->data ? room->descriptor->data->shape : ROOMSHAPE_1x1; int gridIndex = room_shape_get_door_grid_index(slot, room->gridWidth, room->gridHeight, shape); GridEntity* entity = gridIndex >= 0 && gridIndex < ROOM_GRID_CELLS ? room->gridEntities[gridIndex] : nullptr; - if (room->doors[slot] || !entity || grid_desc_get(*entity)._type != GRID_DOOR) continue; - if (static_cast(entity)->_direction != DOOR_NONE) continue; + if (room->doors[slot] || !entity || entity->type != GRID_DOOR) continue; + if (static_cast(entity)->direction != DIRECTION_NONE) continue; room->doors[slot] = static_cast(entity); room->RemoveDoor(slot); } - reconstruction_missing( - "Level::load_room 0073e0a0: the Member Card's shop door (Room::TrySpawnSecretShop 007f8190)"); + room->TrySpawnSecretShop(false); int roomStageType = game.challenge == CHALLENGE_RED_REDEMPTION ? GetRoomStageType(currentRoomIdx) : (int)stageType; bool isCorpse = RoomConfig::GetStageID((int)stage, roomStageType, ROOM_MODE_CURRENT) == STAGE_ID_CORPSE; @@ -2428,7 +2443,7 @@ void Level::load_room() "Game::reset_players_for_greed)"); if (!game.deathmatchManager.is_active()) game.playerManager.enter_level(); room->fxLayers.Update(PLAYER_FOLLOW_SNAP); - reconstruction_missing("Level::load_room 0073e0a0: the Red Key's door outlines (Room::UpdateRedKey 008271e0)"); + room->UpdateRedKey(); bool isHomePathBoss = game.GetChallengeParams().pathType == PATH_TYPE_HOME && @@ -2467,8 +2482,8 @@ void Level::UpdateVisibility() if (currentRoomIdx >= 0 && HasMirrorDimension()) GetRoomByIdx(currentRoomIdx, 1 - currentDimensionIdx)->displayFlags |= ROOM_DISPLAY_BOX | ROOM_DISPLAY_ICON; for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) - if (GridEntity_Door* door = room->doors[slot]; door && door->_targetRoomIdx >= 0) - reveal_room_visibility(*GetRoomByIdx(door->_targetRoomIdx), ¤t, slot); + if (GridEntity_Door* door = room->doors[slot]; door && door->targetRoomIdx >= 0) + reveal_room_visibility(*GetRoomByIdx(door->targetRoomIdx), ¤t, slot); for (MinimapConfig& config : g_game->minimap.configs) config.refresh(); if (hud.hudRefreshType == HUD_REFRESH_FULL) return; hud.hudRefreshType = HUD_REFRESH_PLAYER; @@ -2507,10 +2522,10 @@ void Level::reveal_room_visibility(RoomDescriptor& target, RoomDescriptor* fromR { GridEntity_Door& door = *room->doors[doorSlot]; - if (is_xray() && grid_desc_get(door)._variant == DOOR_VARIANT_HIDDEN) + if (is_xray() && door.variant == DOOR_HIDDEN) reconstruction_missing("Level::reveal_room_visibility 0073f620: X-Ray Vision's hidden door opening " "(Game::SpawnEx 006fe410)"); - isShown = door._isBusted; + isShown = door.isBusted; } if (!isShown) isShown = is_xray() || is_spelunker(); if (isShown) @@ -2689,10 +2704,27 @@ std::set Level::get_rooms_within_two_doors(int) reconstruction_missing("Level::get_rooms_within_two_doors 007496a0"); } -// 0074a090 Where the players enter the current room. +// 0074a090 Where the players enter the current room when no door brings them: a crawlspace's ladder (by the +// Black Market's or a room's), the secret shop's and the off-map rooms' spots, or back where a crawlspace was entered. +// Elsewhere none, the origin. Vector Level::GetEnterPosition() { - reconstruction_missing("Level::GetEnterPosition 0074a090"); + if (currentRoomIdx == ROOM_DUNGEON_IDX || currentRoomIdx == ROOM_GIDEON_DUNGEON_IDX) + { + if (lastRoomIdx >= 0) return vector_make(DUNGEON_ENTRY_X, DUNGEON_ENTRY_Y); + return vector_make(lastRoomIdx == ROOM_BLACK_MARKET_IDX ? BLACK_MARKET_EXIT_X : DUNGEON_EXIT_X, DUNGEON_EXIT_Y); + } + if (currentRoomIdx == ROOM_SECRET_SHOP_IDX) return vector_make(SECRET_SHOP_ENTRY_X, SECRET_SHOP_ENTRY_Y); + if (currentRoomIdx == ROOM_OFF_MAP_14_IDX) return vector_make(OFF_MAP_14_ENTRY_X, OFF_MAP_14_ENTRY_Y); + if (currentRoomIdx == ROOM_OFF_MAP_15_IDX) return vector_make(OFF_MAP_15_ENTRY_X, OFF_MAP_15_ENTRY_Y); + if (currentRoomIdx >= 0 && currentRoomIdx == dungeonReturnRoomIndex) + { + RoomDescriptor* last = GetRoomByIdx(lastRoomIdx); + bool isFromDungeon = last->data && last->data->type == ROOM_DUNGEON; + if (isFromDungeon || lastRoomIdx == ROOM_SECRET_SHOP_IDX || lastRoomIdx == ROOM_ANGEL_SHOP_IDX) + return dungeonReturnPosition; + } + return g_vectorZero; } // 0073d9b0 A door slot as another shape sees it. @@ -2797,10 +2829,29 @@ bool Level::ForceHorsemanBoss(uint32_t) reconstruction_missing("Level::ForceHorsemanBoss 007481d0"); } -// 00749830 Whether a deal room may spawn. +// 00749830 Whether the floor's last boss room may open a deal door: not in Red Redemption, Mausoleum II, before the +// Ascent or on the way back up; past Basement I (but for the surprise miniboss daily) and up to the Womb, Depths II +// once the Womb is unlocked (any floor in Greed); and only when the boss room has two door slots or more. bool Level::CanSpawnDevilRoom() { - reconstruction_missing("Level::CanSpawnDevilRoom 00749830"); + Game& game = *g_game; + if (game.challenge == CHALLENGE_RED_REDEMPTION) return false; + + int labyrinthStage = (int)stage_with_labyrinth(*this); + bool isAltStage = stageType == STAGETYPE_REPENTANCE || stageType == STAGETYPE_REPENTANCE_B; + bool isMausoleumTwo = !is_greed() && isAltStage && labyrinthStage == (int)LEVEL_STAGE_WOMB_II; + bool isBackwards = stage - 1 < ASCENT_LAST_STAGE && game_flag_get(LEVEL_GAME_STATE_BACKWARDS_PATH); + if (isMausoleumTwo || IsPreAscent() || isBackwards) return false; + + int dealStage = labyrinthStage + (isAltStage ? 1 : 0); + if (!is_greed()) + { + if (dealStage == (int)LEVEL_STAGE_BASEMENT_I && game.dailyChallenge._specialDailyId != SPECIAL_DAILY_DEALS) + return false; + if (dealStage != (int)LEVEL_STAGE_BASEMENT_I && dealStage > (int)LEVEL_STAGE_WOMB_II) return false; + if (dealStage == (int)LEVEL_STAGE_DEPTHS_II && !is_unlocked(ACHIEVEMENT_THE_WOMB)) return false; + } + return std::popcount(roomList[lastBossRoomListIdx].data->doors & 0xff) > 1; } // 007499a0 Picks the deal room. @@ -2845,10 +2896,28 @@ int Level::GetAbsoluteStage() reconstruction_missing("Level::GetAbsoluteStage 0074b960"); } -// 0074bae0 The kind of secret exit the floor has. +// 0074bae0 The secret exit the floor's depth calls for, an XL floor counting as its second stage and the alternate path +// as one deeper. None in Greed, nor on the alternate path's first floors. int Level::get_secret_exit_kind() { - reconstruction_missing("Level::get_secret_exit_kind 0074bae0"); + bool isLabyrinth = curses & CURSE_OF_LABYRINTH; + if (is_greed() || ((stage & 1) && IsAltPath() && !isLabyrinth)) return SECRET_EXIT_NONE; + + switch (stage + isLabyrinth + IsAltPath()) + { + case 1: + case 2: + return SECRET_EXIT_DOWNPOUR; + case 3: + case 4: + return SECRET_EXIT_MINES; + case 5: + return SECRET_EXIT_MAUSOLEUM; + case 7: + return IsAltPath() ? SECRET_EXIT_MOMS_HEART : SECRET_EXIT_NONE; + default: + return SECRET_EXIT_NONE; + } } // 0074bba0 The secret exit's room. diff --git a/src/level.h b/src/level.h index 9d59120..2a83996 100644 --- a/src/level.h +++ b/src/level.h @@ -22,6 +22,17 @@ constexpr int PORTAL_ROOM_NONE = -99999; // The xorshift a level's RNGs start on before Level::Init seeds them (shift index 35). constexpr RNG LEVEL_RNG_DEFAULT = {RNG_SEED_DEFAULT, 5, 9, 7}; +// The secret exit a floor's door leads to, also the exit room's layout subtype. Mom's Heart's leads to the Corpse +// and the Ascent. +enum SecretExitKind +{ + SECRET_EXIT_NONE, + SECRET_EXIT_DOWNPOUR, + SECRET_EXIT_MINES, + SECRET_EXIT_MAUSOLEUM, + SECRET_EXIT_MOMS_HEART +}; + // The rooms off the 13x13 map, by their negative room index (Lua's GridRooms). enum OffMapRoom : int { diff --git a/src/manager.cpp b/src/manager.cpp index 485fba7..e275591 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1413,7 +1413,7 @@ static void run_update(Manager& manager) game.Update(); } else if (manager.optionsConfig.render.isInterpolationEnabled) - reconstruction_missing("Game::interpolate_update 006fd3f0"); + game.interpolate_update(); Camera& camera = *game.room->camera; bool isRiding = game.roomTransition.mode != TRANSITION_NONE && game.roomTransition.animation == TRANSITION_MINECART; @@ -1667,7 +1667,6 @@ void seed_fart_sound_override(int* soundId) // Not reconstructed yet: each stops the game where it is reached. Manager::~Manager() { reconstruction_missing("Manager::destructor 00951160"); } -void Manager::update_ingame_input() { reconstruction_missing("Manager::update_ingame_input 006fa540"); } void Manager::render_button_sprite(int, Vector) { reconstruction_missing("Manager::render_button_sprite 0095ad30"); } void Manager::RestartGame() { reconstruction_missing("Manager::RestartGame 00958cb0"); } void Manager::apply_device_key_config(int) { reconstruction_missing("Manager::apply_device_key_config 0095b180"); } diff --git a/src/manager_input.cpp b/src/manager_input.cpp new file mode 100644 index 0000000..8023d6d --- /dev/null +++ b/src/manager_input.cpp @@ -0,0 +1,127 @@ +#include "entity_player.h" +#include "game.h" +#include "manager.h" +#include "menu_manager.h" + +constexpr int KEYBOARD_ID = 0; +// The keyboard button that asks for the render surfaces to be remade. No key sends it on this platform. +constexpr int KEY_RESIZE_REQUEST = 12; +constexpr int EVENT_EDEN_TOKENS = 21; +constexpr uint8_t RESTART_HOLD_FRAMES = 16; +constexpr float RESTART_FADE_SPEED = 1.0f / 30; +constexpr float RESTART_CANCEL_FADE_SPEED = 2.0f / 15; +constexpr float GAME_OVER_FADE_SPEED = 0.08f; +constexpr float POPUP_BUTTON_HIDDEN = 96; +// The achievement that unlocks the item info toggle, and the toggle's action past Lua's ButtonAction. +constexpr int ACHIEVEMENT_ITEM_INFO = 641; +constexpr ButtonAction ACTION_ITEM_INFO = (ButtonAction)31; + +// Whether a main player holds restart: the keyboard's player with the keyboard's restart, any other player with the +// keyboard's restart too, or pause and map held together on its own controller. The last player with a device decides. +// The original also forces the controller's restart action on (its device slot 18), which the devices here lack. +// Netplay's remote players are left out: netplay is offline. +static bool is_restart_held(PlayerManager& players) +{ + bool isHeld = false; + + for (int i = 0; i < players.count_main_players(); i++) + { + Entity_Player* player = players.get_main_player(i); + if (!player || !KAGE::Input::manager.device_find(player->controllerIndex)) continue; + + int controller = player->controllerIndex; + bool isKeyboardHeld = is_controller_action(KEYBOARD_ID, ACTION_RESTART, ACTION_PRESSED); + bool isComboHeld = is_controller_action(controller, ACTION_PAUSE, ACTION_PRESSED) && + is_controller_action(controller, ACTION_MAP, ACTION_PRESSED); + if (controller == KEYBOARD_ID) isHeld = isKeyboardHeld; + else if (isKeyboardHeld || isComboHeld) isHeld = true; + } + return isHeld; +} + +// Counts how long restart is held, fading out to a restart once held 16 frames (never in a daily, or as Eden without +// a token), and fades back if let go before the restart. +static void restart_update(Game& game) +{ + int edenTokens = g_manager->persistentGameData.eventCounters[EVENT_EDEN_TOKENS]; + Entity_Player* first = game.GetPlayer(0); + bool isEden = first && (first->playerType == PLAYER_EDEN || first->playerType == PLAYER_EDEN_B); + bool isHeld = is_restart_held(game.playerManager); + bool isRestarting = game.fadeOutTarget == FADEOUT_RESTART_HELD; + + if (!isHeld) game.restartHoldFrames = 0; + else if (!isRestarting) game.restartHoldFrames++; + + bool isReady = !(isEden && edenTokens == 0) && game.dailyChallenge._id == 0 && + game.restartHoldFrames >= RESTART_HOLD_FRAMES; + if (!isHeld && isRestarting) + { + game.fadeSpeed = RESTART_CANCEL_FADE_SPEED; + game.fadeOutTarget = FADEOUT_NONE; + } + else if (isHeld && isReady && !isRestarting) + { + game.Fadeout(RESTART_FADE_SPEED, FADEOUT_RESTART_HELD); + game.restartHoldFrames = 0; + } +} + +// On the game over screen, confirm fades out to a restart and back fades out to the run menu, both sliding the popup +// buttons away. +static void game_over_input(Game& game) +{ + Manager& manager = *g_manager; + bool isRestart = is_action(ACTION_MENU_CONFIRM, ACTION_TRIGGERED); + + if (!isRestart && !is_action(ACTION_MENU_BACK, ACTION_TRIGGERED)) return; + if (isRestart) input_poll_active_device(); + game.Fadeout(GAME_OVER_FADE_SPEED, isRestart ? FADEOUT_RESTART : FADEOUT_MENU_GAME); + for (PopupButton& button : manager.popupButtons.buttons) button.targetSlideOffset = POPUP_BUTTON_HIDDEN; +} + +// 006fa540 The run's input each frame: a request to remake the render surfaces, held restart, the console (which keeps +// the rest while open), the game over screen's answers unless a popup holds the menus, the leaderboard, then outside a +// room transition the prompt's answer or else the pause screen and the revive menu (once the run has faded in with +// nothing else up), the item info toggle (once unlocked, or in a daily or debug run) and co-op joining. During the +// versus screen, confirm skips it. +// Netplay is offline: the emote wheel, the online stats screen's votes and the players' remote input are left out. +void Manager::update_ingame_input() +{ + Manager& manager = *g_manager; + Game& game = *g_game; + RoomTransition& transition = game.roomTransition; + + std::shared_ptr keyboard = KAGE::Input::manager.device_find(KEYBOARD_ID); + if (keyboard && keyboard->is_button_triggered(KEY_RESIZE_REQUEST)) game.isWindowResizePending = true; + restart_update(game); + + game.console.Update(); + if (game.console.state != CONSOLE_CLOSED) return; + + if (!manager.popupQueue.is_blocking() && game.gameOver._state != 0) game_over_input(game); + if (game.gameOver._state != 0) return; + + game.leaderboard.update_input(); + if (game.leaderboard.displayState != LEADERBOARD_HIDDEN) return; + + bool isConfirm = is_action(ACTION_MENU_CONFIRM, ACTION_TRIGGERED); + if (transition.mode == TRANSITION_OUT && transition.bossIntroBossId != 0 && isConfirm && + transition.versusScreenANM2.animState.animData) + transition.versusScreenANM2.animState.isPlaying = false; + if (transition.mode != TRANSITION_NONE) return; + if (game.genericPrompt.IsActive()) return game.genericPrompt.handle_input(); + + bool isRunShown = game.fadeInColor._alpha <= 0 && game.stageTransition._state == 0 && !game.onlineStatsScreen.isActive; + if (isRunShown) + { + game.pauseScreen.Update(); + if (game.pauseScreen.is_pausing()) return; + game.revivePlayerMenu.Update(); + } + + bool isInfoAllowed = manager.persistentGameData.achievements[ACHIEVEMENT_ITEM_INFO] || + (manager.state == MANAGER_STATE_GAME && (game.dailyChallenge._id != 0 || game.isDebug)); + if (game.pauseScreen.state == PAUSE_HIDDEN && isInfoAllowed && is_action(ACTION_ITEM_INFO, ACTION_TRIGGERED)) + manager.optionsConfig.isItemInfoDisplayEnabled = !manager.optionsConfig.isItemInfoDisplayEnabled; + game.playerManager.handle_coop_join(); +} diff --git a/src/minimap.cpp b/src/minimap.cpp index db60fec..8473571 100644 --- a/src/minimap.cpp +++ b/src/minimap.cpp @@ -27,6 +27,11 @@ constexpr const char* SCORE_LABEL = "#MINIMAP_SCORE_LABEL"; constexpr const char* TIME_WIDEST = " 00:00:00"; constexpr const char* SCORE_WIDEST = " 000000"; +constexpr const char* ANIMATION_ROOM_OUTLINE = "RoomOutline"; +constexpr const char* ANIMATION_ROOM_CURRENT = "RoomCurrent"; +constexpr const char* ANIMATION_ROOM_VISITED = "RoomVisited"; +constexpr const char* ANIMATION_ROOM_UNVISITED = "RoomUnvisited"; +constexpr const char* ICON_LOCKED_ROOM = "IconLockedRoom"; constexpr const char* NO_PLAYERS = "PlayerManager::GetPlayer() : There are no players! \n"; // The two maps' layouts, by MinimapSize. @@ -38,7 +43,7 @@ struct MinimapLayout float margin; float gap; int cells; - int iconScale; + int iconLimit; }; constexpr MinimapLayout MINIMAP_LAYOUTS[MINIMAP_SIZE_COUNT] = {{16, 7, 6, 2, 1, 7, 1}, {32, 16, 14, 4, 1, 13, 4}}; @@ -101,6 +106,92 @@ constexpr float TEXT_DROP_INSET = 12; constexpr float TIME_Y = 30; constexpr float SCORE_Y = 46; +constexpr int CHALLENGE_APRILS_FOOL = 32; +constexpr RNG APRILS_FOOL_RNG = {0, 1, 5, 16}; +constexpr int STAGE_VOID = 12; +constexpr int DIMENSION_DEATH_CERTIFICATE = 2; +constexpr int SUBTYPE_MINESHAFT_ENTRANCE = 10; +constexpr int SUBTYPE_MIRROR_ROOM = 34; +constexpr int SUBTYPE_BOSS_AMBUSH = 1; +constexpr int MAP_GRID_STAIRS = 18; +constexpr float RED_ROOM_TINT = 75.0f / 255; +constexpr float MAP_ICON_HALF = 6; +constexpr int MAP_ICON_SLOTS = 4; + +// The doors of a Void boss room that tell which of its cells Delirium's room shows as, by the room's shape. +constexpr uint32_t VOID_DOORS_TALL_DOWN = 1 << DOOR_LEFT0 | 1 << DOOR_UP0 | 1 << DOOR_RIGHT0; +constexpr uint32_t VOID_DOORS_TALL_UP = 1 << DOOR_DOWN0 | 1 << DOOR_LEFT1 | 1 << DOOR_RIGHT1; +constexpr uint32_t VOID_DOORS_WIDE_RIGHT = 1 << DOOR_LEFT0 | 1 << DOOR_UP0 | 1 << DOOR_DOWN0; +constexpr uint32_t VOID_DOORS_WIDE_LEFT = 1 << DOOR_RIGHT0 | 1 << DOOR_UP1 | 1 << DOOR_DOWN1; +constexpr uint32_t VOID_DOORS_BIG_TOP_RIGHT = 1 << DOOR_LEFT0 | 1 << DOOR_UP0; +constexpr uint32_t VOID_DOORS_BIG_TOP_LEFT = 1 << DOOR_RIGHT0 | 1 << DOOR_UP1; +constexpr uint32_t VOID_DOORS_BIG_BOTTOM_RIGHT = 1 << DOOR_DOWN0 | 1 << DOOR_LEFT1; +constexpr uint32_t VOID_DOORS_BIG_BOTTOM_LEFT = 1 << DOOR_RIGHT1 | 1 << DOOR_DOWN1; + +// The icons a room shows on the map, by type, for the types that always show the same one. +constexpr const char* ROOM_ICONS[] = {nullptr, + nullptr, + "IconShop", + nullptr, + nullptr, + "IconBoss", + "IconMiniboss", + "IconSecretRoom", + "IconSuperSecretRoom", + "IconArcade", + "IconCurseRoom", + nullptr, + "IconLibrary", + "IconSacrificeRoom", + "IconDevilRoom", + "IconAngelRoom", + nullptr, + nullptr, + "IconIsaacsRoom", + "IconBarrenRoom", + "IconChestRoom", + "IconDiceRoom", + nullptr, + nullptr, + "IconPlanetarium", + "IconTeleporterRoom", + "IconTeleporterRoom", + nullptr, + nullptr, + "IconUltraSecretRoom"}; + +// The pickups and objects a room's map cell shows icons for, in the order they take the cell's free icon slots. +// Each is a bit of RoomIcons::shown, and the animation of minimap_icons.anm2 it shows. +struct MapIcon +{ + int bit; + const char* animation; +}; + +constexpr MapIcon MAP_ICONS[] = {{0, "IconHeart"}, {6, "IconItem"}, {10, "IconTrinket"}, {9, "IconChest"}, + {12, "IconRune"}, {5, "IconCard"}, {7, "IconPill"}, {3, "IconKey"}, + {4, "IconBomb"}, {2, "IconPoop"}, {1, "IconCoin"}, {8, "IconBattery"}, + {13, "IconBeggar"}, {11, "IconSlot"}, {14, "IconLadder"}, {15, "IconPortal"}}; +constexpr int MAP_ICON_LADDER = 14; +constexpr int MAP_ICON_COUNT = 16; + +// What refresh's passes share: the current room, the first cell drawn and the step from one cell to the next. +struct MapWindow +{ + RoomDescriptor* current = nullptr; + float stepX = 0; + float stepY = 0; + int startColumn = 0; + int startRow = 0; +}; + +// The icons a room cell shows beside its room's: which are shown, and each one's frame. +struct RoomIcons +{ + std::array frames{}; + uint32_t shown = 0; + int count = 0; +}; // How far the HUD sits in from the screen's edges, from 0 at the edge to 1. static float hud_inset() @@ -141,10 +232,345 @@ static void quad_mirror(DestinationQuad& quad) std::swap(quad._bottomLeft, quad._bottomRight); } -// 0098b5e0 Draws the floor's rooms on the map's surface and measures their bounds. +// Sets a sprite's tint, keeping its colorize and offset. +static void tint_set(ANM2& sprite, float red, float green, float blue) +{ + sprite.color._tint[0] = red; + sprite.color._tint[1] = green; + sprite.color._tint[2] = blue; + sprite.color._tint[3] = 1; +} + +// Whether a cell of the current dimension's map is in the grid and holds a room. +static bool is_room_at(int cell, int roomIndex) +{ + return cell >= 0 && cell < LEVEL_GRID_CELLS && g_game->currentRoomMap[cell] == roomIndex; +} + +// Whether a room is a big boss room of the Void, which the map shows as the one cell Delirium's doors lead to. +static bool is_void_boss(const RoomDescriptor& room) +{ + return g_game->stage == STAGE_VOID && room.data->type == ROOM_BOSS; +} + +// Whether a cell of a Void boss room shows its outline: the one cell its doors face, by its shape. +static bool is_void_outline_cell(const RoomDescriptor& room, int cell, int roomIndex) +{ + uint32_t doors = room.allowedDoors; + bool isShown = true; + + switch (room.data->shape) + { + case ROOMSHAPE_1x2: + if (doors & VOID_DOORS_TALL_DOWN) isShown = is_room_at(cell + LEVEL_GRID_WIDTH, roomIndex); + if (doors & VOID_DOORS_TALL_UP) isShown = is_room_at(cell - LEVEL_GRID_WIDTH, roomIndex); + return isShown; + case ROOMSHAPE_2x1: + if (doors & VOID_DOORS_WIDE_RIGHT) return is_room_at(cell + 1, roomIndex); + if (doors & VOID_DOORS_WIDE_LEFT) return is_room_at(cell - 1, roomIndex); + return true; + case ROOMSHAPE_2x2: + if (doors & VOID_DOORS_BIG_TOP_RIGHT) + return is_room_at(cell + 1, roomIndex) && is_room_at(cell + LEVEL_GRID_WIDTH, roomIndex); + if (doors & VOID_DOORS_BIG_TOP_LEFT) + return is_room_at(cell - 1, roomIndex) && is_room_at(cell + LEVEL_GRID_WIDTH, roomIndex); + if (doors & VOID_DOORS_BIG_BOTTOM_RIGHT) + return is_room_at(cell + 1, roomIndex) && is_room_at(cell - LEVEL_GRID_WIDTH, roomIndex); + if (doors & VOID_DOORS_BIG_BOTTOM_LEFT) + return is_room_at(cell - 1, roomIndex) && is_room_at(cell - LEVEL_GRID_WIDTH, roomIndex); + return true; + default: return true; + } +} + +// How far a Void boss room's drawing moves from its grid index to the cell its doors face. +static Vector void_boss_shift(const RoomDescriptor& room, const MapWindow& window) +{ + uint32_t doors = room.allowedDoors; + + switch (room.data->shape) + { + case ROOMSHAPE_1x2: return vector_make(0, doors & VOID_DOORS_TALL_UP ? window.stepY : 0); + case ROOMSHAPE_2x1: return vector_make(doors & VOID_DOORS_WIDE_LEFT ? window.stepX : 0, 0); + case ROOMSHAPE_2x2: + if (doors & VOID_DOORS_BIG_TOP_LEFT) return vector_make(window.stepX, 0); + if (doors & VOID_DOORS_BIG_BOTTOM_RIGHT) return vector_make(0, window.stepY); + if (doors & VOID_DOORS_BIG_BOTTOM_LEFT) return vector_make(window.stepX, window.stepY); + return vector_make(0, 0); + default: return vector_make(0, 0); + } +} + +// How many cells a room shape covers across and down, as the current room's center counts them. The L shape missing +// its top left cell counts none across. +static Vector shape_cells(int shape) +{ + switch (shape) + { + case ROOMSHAPE_1x1: + case ROOMSHAPE_IH: + case ROOMSHAPE_IV: return vector_make(1, 1); + case ROOMSHAPE_1x2: + case ROOMSHAPE_IIV: return vector_make(1, 2); + case ROOMSHAPE_2x1: + case ROOMSHAPE_IIH: return vector_make(2, 1); + case ROOMSHAPE_2x2: + case ROOMSHAPE_LTR: + case ROOMSHAPE_LBL: + case ROOMSHAPE_LBR: return vector_make(2, 2); + case ROOMSHAPE_LTL: return vector_make(0, 2); + default: + log_printf(LOG_ERROR, "invalid room shape id: %d\n", shape); + return vector_make(1, 1); + } +} + +// Whether a cell is where its room draws: its grid index, or the cell right of it for the L shape missing that one. +static bool is_room_anchor(const RoomDescriptor& room, int cell) +{ + return room.gridIndex == cell || (room.gridIndex + 1 == cell && room.data->shape == ROOMSHAPE_LTL); +} + +// Visits the window's cells in the grid, with where each draws on the surface. Pass isPadded to start a cell up and +// left of the window, for the rooms reaching into it. +template +static void cells_walk(const MinimapConfig& map, const MapWindow& window, bool isPadded, Visit visit) +{ + int firstRow = isPadded ? std::max(window.startRow - 1, 0) : window.startRow; + int firstColumn = isPadded ? std::max(window.startColumn - 1, 0) : window.startColumn; + float left = firstColumn < window.startColumn ? 0 - window.stepX : 0; + float y = firstRow < window.startRow ? 0 - window.stepY : 0; + + for (int row = firstRow; row < map.rows + window.startRow; row++, y += window.stepY) + { + float x = left; + for (int column = firstColumn; column < window.startColumn + map.columns; column++, x += window.stepX) + { + int cell = row * LEVEL_GRID_WIDTH + column; + if (cell >= 0 && cell < LEVEL_GRID_CELLS && g_game->currentRoomMap[cell] >= 0) + visit(cell, g_game->currentRoomMap[cell], vector_make(x, y)); + } + } +} + +// The icon a room shows: its type's, a visited mirror or mineshaft entrance room's, or a lock on a special room not +// visited yet. +static const char* room_icon_get(const RoomDescriptor& room) +{ + const RoomConfig_Room* data = room.data; + Game& game = *g_game; + + if (data && room.displayFlags & ROOM_DISPLAY_ICON) + { + bool isGreed = game.difficulty == DIFFICULTY_GREED || game.difficulty == DIFFICULTY_GREEDIER; + switch (data->type) + { + case ROOM_DEFAULT: + if (room.visitedCount == 0 || game.currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) break; + if (data->subtype == SUBTYPE_MIRROR_ROOM && game.HasMirrorDimension()) return "IconMirrorRoom"; + if (data->subtype == SUBTYPE_MINESHAFT_ENTRANCE && game.HasAbandonedMineshaft()) + return "IconMinecartRoom"; + break; + case ROOM_TREASURE: + if (isGreed && game.greedModeTreasureRoomIdx != (uint32_t)room.gridIndex) return "IconTreasureRoomGreed"; + return room.flags & ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE ? "IconTreasureRoomRed" : "IconTreasureRoom"; + case ROOM_CHALLENGE: return data->subtype == SUBTYPE_BOSS_AMBUSH ? "IconBossAmbushRoom" : "IconAmbushRoom"; + default: + if (data->type >= 0 && data->type < (int)std::size(ROOM_ICONS) && ROOM_ICONS[data->type]) + return ROOM_ICONS[data->type]; + } + } + + if (!data || data->type == ROOM_DEFAULT || room.visitedCount != 0 || !(room.displayFlags & ROOM_DISPLAY_LOCK)) + return nullptr; + switch (data->type) + { + case ROOM_SHOP: + case ROOM_ARCADE: + case ROOM_LIBRARY: + case ROOM_ISAACS: + case ROOM_BARREN: + case ROOM_CHEST: + case ROOM_DICE: + case ROOM_PLANETARIUM: return ICON_LOCKED_ROOM; + default: return nullptr; + } +} + +// The pickups and objects a shown room holds, from what it saved when left, and its crawlspace ladder. +static RoomIcons room_icons_find(const RoomDescriptor& room, int cell) +{ + RoomIcons icons; + if (room.displayFlags == 0) return icons; + + if (!g_game->GetRoomByIdx(cell)->savedEntities.empty()) + reconstruction_missing("MinimapConfig::refresh 0098b5e0: a room's saved pickups need EntitySaveState's fields"); + for (const GridEntityDesc& grid : room.savedGridEntities) + { + if (grid._type != MAP_GRID_STAIRS || icons.shown & 1u << MAP_ICON_LADDER) continue; + icons.shown |= 1u << MAP_ICON_LADDER; + icons.count++; + } + return icons; +} + +// Draws a room's icon and those of what it holds, spread over the cell's icon slots. +// The original lays more than four icons out as four, after logging it. +static void room_icons_draw(MinimapConfig& map, const RoomDescriptor& room, int cell, Vector at, + const MapWindow& window) +{ + const char* roomIcon = room_icon_get(room); + RoomIcons icons = room_icons_find(room, cell); + float inset = map.margin + map.gap; + Vector offset = vector_make(inset, inset); + int shape = room.data->shape; + + if (is_void_boss(room) && (shape == ROOMSHAPE_1x2 || shape == ROOMSHAPE_2x1 || shape == ROOMSHAPE_2x2)) + { + Vector shift = void_boss_shift(room, window); + at = vector_make(at.x + shift.x, at.y + shift.y); + } + else + { + if (shape == ROOMSHAPE_2x1 || shape == ROOMSHAPE_2x2) offset.x += map.cellSize.x * 0.5f; + if (shape == ROOMSHAPE_1x2 || shape == ROOMSHAPE_2x2) offset.y += map.cellSize.y * 0.5f; + } + + int count = std::min(icons.count + (roomIcon ? 1 : 0), map.iconLimit); + float left = map.cellSize.x * 0.25f + offset.x; + float right = map.cellSize.x * 0.75f + offset.x; + float middle = map.cellSize.y * 0.5f + offset.y; + std::array slots = {vector_make(map.cellSize.x * 0.5f + offset.x, middle)}; + if (count == 2) slots = {vector_make(left, middle), vector_make(right, middle)}; + else if (count > 2) + { + if (count > MAP_ICON_SLOTS) log_printf(LOG_ERROR, "currently there are no more than 4 minimap icons supported\n"); + float top = map.cellSize.y * 0.25f + offset.y; + float bottom = map.cellSize.y * 0.75f + offset.y; + slots = {vector_make(left, top), vector_make(right, top), vector_make(left, bottom), vector_make(right, bottom)}; + } + + ANM2& sprite = g_game->minimap.iconsSprite; + int slot = 0; + auto icon_draw = [&](const char* animation, int frame) { + sprite.SetFrame(animation, frame); + sprite.Render({vector_make(std::floor(at.x + slots[slot].x - MAP_ICON_HALF), + std::floor(at.y + slots[slot].y - MAP_ICON_HALF))}); + slot++; + }; + if (roomIcon) icon_draw(roomIcon, 0); + for (const MapIcon& icon : MAP_ICONS) + if (slot < count && icons.shown & 1u << icon.bit) icon_draw(icon.animation, icons.frames[icon.bit]); +} + +// 0098b5e0 Redraws the map's surface around the current room (a random room's in the April Fool's challenge), at +// most 13 cells each way: the outlines of the shown rooms (whose cells give the drawn bounds), then each room's +// shape as current, visited or not (red rooms tinted, secret rooms not shown until visited), and their icons. The +// current room gives the center the small map shows. Sprites draw without the screen shake meanwhile. +// The original reads before the room list when the current cell holds no room, and reads a room's config without a +// check. Here no room is the current one, and a room without a config draws nothing. void MinimapConfig::refresh() { - reconstruction_missing("Minimap::refresh_room_icons 0098b5e0 on a MinimapConfig, waiting on Level's takeover"); + Game& game = *g_game; + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + + DAT_00c33910 = 0; + graphics.render_target_push(surface.get(), KAGE::Graphics::TARGET_OWN_SIZE, KAGE::Graphics::PRESENT_FLUSH); + graphics.Clear(); + graphics.blendMode.SetMode(KAGE::Graphics::BLEND_NORMAL); + if (game.currentRoomIdx < 0) + { + graphics.Present(KAGE::Graphics::PRESENT_FINISH); + graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH); + DAT_00c33910 = 1; + return; + } + + int currentCell = game.currentRoomIdx; + if (game.challenge == CHALLENGE_APRILS_FOOL) + { + RNG rng = APRILS_FOOL_RNG; + if (game.room->descriptor) rng._seed = game.room->descriptor->decorationSeed; + currentCell = game.roomList[rng.RandomInt(game.nbRooms)].safeGridIndex; + } + currentCell = std::clamp(currentCell, 0, LEVEL_GRID_CELLS); + columns = std::min(columns, LEVEL_GRID_WIDTH); + rows = std::min(rows, LEVEL_GRID_WIDTH); + + MapWindow window; + int currentIndex = currentCell < LEVEL_GRID_CELLS ? game.currentRoomMap[currentCell] : -1; + window.current = currentIndex >= 0 ? &game.roomList[currentIndex] : nullptr; + window.startColumn = std::max(std::min(currentCell % LEVEL_GRID_WIDTH - columns / 2, LEVEL_GRID_WIDTH - columns), 0); + window.startRow = std::max(std::min(currentCell / LEVEL_GRID_WIDTH - rows / 2, LEVEL_GRID_WIDTH - rows), 0); + window.stepX = gap + cellSize.x; + window.stepY = gap + cellSize.y; + boundsMin = vector_make((float)surface->width, (float)surface->height); + boundsMax = vector_make(0, 0); + + float border = (margin + gap) * 2; + cells_walk(*this, window, false, [&](int cell, int roomIndex, Vector at) { + RoomDescriptor& room = game.roomList[roomIndex]; + if (!room.data || room.displayFlags == 0) return; + + bool isOutlined = !is_void_boss(room) || is_void_outline_cell(room, cell, roomIndex); + boundsMin = vector_make(std::min(boundsMin.x, at.x), std::min(boundsMin.y, at.y)); + boundsMax = vector_make(std::max(at.x + cellSize.x + border, boundsMax.x), + std::max(at.y + cellSize.y + border, boundsMax.y)); + mapSprite.SetFrame(ANIMATION_ROOM_OUTLINE, 0); + if (isOutlined) mapSprite.Render({at}); + }); + + cells_walk(*this, window, true, [&](int cell, int roomIndex, Vector at) { + RoomDescriptor& room = game.roomList[roomIndex]; + if (!room.data || !is_room_anchor(room, cell)) return; + + int shape = room.data->shape; + if (shape - 1 < 0) log_printf(LOG_ERROR, "invalid room shape id: %d\n", shape); + int frame = shape - 1; + Vector cells = shape_cells(shape); + Vector position = vector_make(shape == ROOMSHAPE_LTL ? at.x - window.stepX : at.x, at.y); + if (is_void_boss(room) && (shape == ROOMSHAPE_1x2 || shape == ROOMSHAPE_2x1 || shape == ROOMSHAPE_2x2)) + { + Vector shift = void_boss_shift(room, window); + position = vector_make(position.x + shift.x, position.y + shift.y); + frame = 0; + cells = vector_make(1, 1); + } + + bool isRed = room.flags & ROOM_DESCRIPTOR_FLAG_RED_ROOM; + if (isRed) tint_set(mapSprite, 1, RED_ROOM_TINT, RED_ROOM_TINT); + if (window.current && window.current->listIndex == room.listIndex) + { + mapSprite.SetFrame(ANIMATION_ROOM_CURRENT, frame); + mapSprite.Render({position}); + float inset = margin + gap; + center = vector_make(cells.x * cellSize.x * 0.5f + at.x + inset, cells.y * cellSize.y * 0.5f + at.y + inset); + } + else + { + int type = room.data->type; + bool isBox = room.displayFlags & ROOM_DISPLAY_BOX; + bool isSecret = type == ROOM_SECRET || type == ROOM_SUPERSECRET || type == ROOM_ULTRASECRET; + const char* animation = nullptr; + if (room.flags & ROOM_DESCRIPTOR_FLAG_CLEAR && isBox) animation = ANIMATION_ROOM_VISITED; + else if (isBox && !isSecret) animation = ANIMATION_ROOM_UNVISITED; + if (animation) + { + mapSprite.SetFrame(animation, frame); + mapSprite.Render({position}); + } + } + if (isRed) tint_set(mapSprite, 1, 1, 1); + }); + + cells_walk(*this, window, true, [&](int cell, int roomIndex, Vector at) { + RoomDescriptor& room = game.roomList[roomIndex]; + if (room.data && is_room_anchor(room, cell)) room_icons_draw(*this, room, cell, at, window); + }); + + graphics.Present(KAGE::Graphics::PRESENT_FINISH); + graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH); + DAT_00c33910 = 1; } // 0098d560 Loads both maps with their layouts and surfaces (sized to fit every cell), the item, pickup and room @@ -163,7 +589,7 @@ void Minimap::Init() map.gap = layout.gap; map.columns = layout.cells; map.rows = layout.cells; - map.iconScale = layout.iconScale; + map.iconLimit = layout.iconLimit; int gap = (int)map.gap; int margins = (int)map.margin * 2; diff --git a/src/minimap.h b/src/minimap.h index b9aad53..2df6fd5 100644 --- a/src/minimap.h +++ b/src/minimap.h @@ -23,8 +23,8 @@ enum MinimapSize : int // Copies and destruction are the defaults. // One of the two maps (MinimapConfig): its frame sheet, the surface the rooms are drawn on, the room cell size and the -// gap between cells, how many cells fit across and down, the margin around them, the room icons' size and scale, the -// point of the surface the map centers on, the drawn rooms' bounds and its alpha. +// gap between cells, how many cells fit across and down, the margin around them, the room icons' size and how many +// a cell shows, the point of the surface the map centers on, the drawn rooms' bounds and its alpha. struct MinimapConfig { ANM2 mapSprite; @@ -38,7 +38,7 @@ struct MinimapConfig float gap = 0; float margin = 0; int columns = 0; - int iconScale = 0; + int iconLimit = 0; int rows = 0; void refresh(); diff --git a/src/mod_manager.cpp b/src/mod_manager.cpp index 55e4f77..10c07e5 100644 --- a/src/mod_manager.cpp +++ b/src/mod_manager.cpp @@ -1,5 +1,6 @@ #include "mod_manager.h" #include "data.h" +#include "fx_layers.h" #include "game.h" #include "log.h" #include "lua_engine.h" @@ -13,6 +14,15 @@ #include #include +// classes.h declares the original's Lua imports, and its luaL_newstate differs from Lua's only in its return type. +#define luaL_newstate lua_newstate_auxiliary +extern "C" +{ +#include "lauxlib.h" +#include "lua.h" +} +#undef luaL_newstate + constexpr const char* CONTENT_FOLDER = "/content/"; constexpr const char* DISABLE_MARKER = "/disable.it"; constexpr const char* DLC_FOLDER_SUFFIX = "-dlc3/"; @@ -58,6 +68,13 @@ constexpr KAGE::Graphics::VertexAttribute MOD_SHADER_ATTRIBUTES[] = { {"Scale", KAGE::Graphics::VERTEX_FLOAT}}; // The wrap mode that clamps texture coordinates to the edge. constexpr int WRAP_CLAMP = 1; +// The floats of the sprite vertex before RenderData: position, color and texture coordinates. +constexpr int SHADER_RENDER_DATA_OFFSET = 9; +// ModCallbacks.MC_GET_SHADER_PARAMS, run with a shader's name for the table of its parameters. +constexpr LuaCallback MC_GET_SHADER_PARAMS = (LuaCallback)21; +constexpr int CALLBACK_PARAM_NONE = -1; +constexpr KColor SHADER_QUAD_WHITE = kcolor_rgba(1, 1, 1, 1); +constexpr KColor SHADER_QUAD_COLOR_UNSET = kcolor_rgba(-1, -1, -1, -1); // The menu sprites a mod's content folder may replace, by slot. The death sprites load with items and entities. constexpr const char* MENU_SPRITE_FILES[MOD_SPRITE_COUNT] = { @@ -371,6 +388,103 @@ void ModShader::render_target_create() renderTarget->wrap_set(WRAP_CLAMP, WRAP_CLAMP); } +// 00865490 Runs MC_GET_SHADER_PARAMS for a shader, leaving the table a mod returned on the stack. Whether it did. +// A Lua error is logged, as the game's callbacks log theirs. +static bool shader_params_push(std::string_view shaderName) +{ + if (!g_luaEngine || !lua_engine_get().enabledCallbacks[MC_GET_SHADER_PARAMS]) return false; + lua_State* state = lua_engine_get().state; + + lua_rawgeti(state, LUA_REGISTRYINDEX, lua_engine_get().runCallbackRef); + lua_pushinteger(state, MC_GET_SHADER_PARAMS); + lua_pushinteger(state, CALLBACK_PARAM_NONE); + lua_pushlstring(state, shaderName.data(), shaderName.size()); + if (lua_pcall(state, 3, 1, 0) != LUA_OK) + { + const char* error = lua_tostring(state, -1); + log_printf(LOG_INFO, "Error in \"GetShaderParams\" call: %s\n", error ? error : ""); + lua_pop(state, 1); + return false; + } + if (lua_istable(state, -1)) return true; + + lua_pop(state, 1); + return false; +} + +// The length # gives the value on top of the stack. +static int lua_length_get(lua_State* state) +{ + lua_len(state, -1); + int length = (int)lua_tonumber(state, -1); + lua_pop(state, 1); + return length; +} + +// The floats MC_GET_SHADER_PARAMS gives each parameter in name order: a number for a float, or a table of exactly +// its float count. A parameter a mod leaves out stays zero. +// The original reads a non-number table element with luaL_checknumber outside any protected call and aborts. This +// reads it as zero. +static std::vector shader_params_read(ModShader& shader) +{ + std::vector values(shader.parametersSize); + if (!shader_params_push(shader.name)) return values; + lua_State* state = lua_engine_get().state; + size_t offset = 0; + + for (auto& [parameterName, size] : shader.parameters) + { + lua_getfield(state, -1, parameterName.c_str()); + if (size == 1 && lua_type(state, -1) == LUA_TNUMBER) values[offset] = (float)lua_tonumber(state, -1); + else if (lua_istable(state, -1) && lua_length_get(state) == size) + for (int i = 0; i < size; i++) + { + lua_geti(state, -1, i + 1); + values[offset + i] = (float)lua_tonumber(state, -1); + lua_pop(state, 1); + } + lua_pop(state, 1); + offset += size; + } + lua_pop(state, 1); + return values; +} + +// Ends the frame drawn into the shader's render target, goes back to the target before it, and draws the render +// target over the screen through the shader. Each corner carries the target's size and its texture's, the point +// scale, then the parameters' floats. +// The original writes as many floats as the parameters take even when the shader's vertex is shorter (a parameter of +// unknown type, or a shader that failed to load) and draws a missing render target. This writes what fits and skips +// the draw. +void ModShader::render() +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + graphics.Present(KAGE::Graphics::PRESENT_FINISH); + graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH); + graphics.Clear(); + graphics.blendMode = KAGE::Graphics::BLEND_MODE_OPAQUE; + if (!renderTarget) return; + + if (shader && shader->isLoaded) graphics.currentShader = shader.get(); + SourceQuad whole = KAGE::Graphics::source_quad_rect({}, vector_make(1, 1)); + whole._coordinateSpace = KAGE::Graphics::COORDINATES_NORMALIZED; + KAGE::Graphics::ColorQuad screen = + KAGE::Graphics::color_quad_rect({}, vector_make(g_screenWidth, g_screenHeight), SHADER_QUAD_WHITE); + float* vertices = renderTarget->Render(whole, screen, SHADER_QUAD_COLOR_UNSET); + if (!vertices) return; + + std::vector data = {(float)renderTarget->width, (float)renderTarget->height, + (float)renderTarget->textureWidth, (float)renderTarget->textureHeight, + g_screenPointScale}; + std::vector parameterValues = shader_params_read(*this); + data.insert(data.end(), parameterValues.begin(), parameterValues.end()); + + int stride = graphics.currentShader->vertex_size_get() / (int)sizeof(float); + int count = std::clamp(stride - SHADER_RENDER_DATA_OFFSET, 0, (int)data.size()); + for (int corner = 0; corner < KAGE::Graphics::QUAD_CORNERS; corner++) + std::copy_n(data.begin(), count, vertices + corner * stride + SHADER_RENDER_DATA_OFFSET); +} + // Lets go of the shader's render target. void ModShader::render_target_release() { @@ -623,6 +737,15 @@ void ModManager::shader_render_targets_push() loaded_shaders_apply(*this, &ModShader::render_target_push); } +// 008f74c0 Draws each shader's render target of the loaded mods through its shader, the last pushed first, popping +// the targets shader_render_targets_push pushed for the frame. +void ModManager::shaders_render() +{ + for (auto mod = mods.rbegin(); mod != mods.rend(); mod++) + if ((*mod)->isLoaded) + for (auto shader = (*mod)->shaders.rbegin(); shader != (*mod)->shaders.rend(); shader++) shader->render(); +} + // 008f7dd0 Releases each shader's render target of the loaded mods. void ModManager::shader_render_targets_release() { diff --git a/src/mod_manager.h b/src/mod_manager.h index 0050692..ca0e527 100644 --- a/src/mod_manager.h +++ b/src/mod_manager.h @@ -56,6 +56,7 @@ struct ModShader void render_target_create(); void render_target_release(); void render_target_push(); + void render(); }; // Construction (008f2d80) and destruction (008f2fb0) are the defaults. @@ -138,6 +139,7 @@ struct ModManager void create_shader_render_targets(); void shader_render_targets_push(); void shader_render_targets_release(); + void shaders_render(); void unload_shaders(); static void RenderCustomCharacterMenu(int characterId, Vector& renderPos, ANM2& defaultSprite); diff --git a/src/player_hud.cpp b/src/player_hud.cpp new file mode 100644 index 0000000..51a7771 --- /dev/null +++ b/src/player_hud.cpp @@ -0,0 +1,843 @@ +#include "player_hud.h" +#include "entity_config.h" +#include "entity_player.h" +#include "game.h" +#include "hud.h" +#include "item_config.h" +#include "log.h" +#include "manager.h" +#include "menu_manager.h" +#include "render_passes.h" +#include "seeds.h" +#include +#include +#include + +constexpr const char* HEARTS_PNG = "gfx/ui/ui_hearts.png"; +constexpr const char* HEARTS_SMALL_PNG = "gfx/ui/ui_hearts_small.png"; +constexpr const char* COLOR_OFFSET_SHADER = "ColorOffset"; +constexpr const char* COLOR_OFFSET_GOLD_SHADER = "ColorOffsetGold"; +constexpr const char* ANIMATION_CURSE_HEART = "CurseHeart"; +constexpr const char* ANIMATION_GOLD_OVERLAY = "GoldHeartOverlay"; +constexpr const char* ANIMATION_WHITE_OVERLAY = "WhiteHeartOverlay"; +constexpr const char* MANTLE_WOODEN_CROSS = "HolyMantleWoodenCross"; +constexpr const char* MANTLE_BLANKET = "HolyMantleBlanket"; +constexpr const char* MANTLE_HOLY_MANTLE = "HolyMantle"; +constexpr const char* MANTLE_HOLY_CARD = "HolyMantleHolyCard"; +constexpr const char* EXTRA_LIVES_FORMAT = "x%d%s"; + +// The flash colors of HeartFlash, which add to a heart's color: red, soul, black, gold and rotten. +constexpr std::array, HEART_FLASH_COUNT> HEART_FLASH_OFFSETS = {{{0, 0, 0}, + {128 / 255.0f, 0, 0}, + {50 / 255.0f, 70 / 255.0f, 90 / 255.0f}, + {80 / 255.0f, 26 / 255.0f, 26 / 255.0f}, + {128 / 255.0f, 100 / 255.0f, 20 / 255.0f}, + {60 / 255.0f, 128 / 255.0f, 0}}}; + +constexpr float HEART_SPACING_X = 12; +constexpr float HEART_SPACING_Y = 10; +constexpr float HEART_SMALL_SPACING_X = 8; +constexpr float HEART_SMALL_SPACING_Y = 6; +constexpr int HEARTS_PER_ROW = 6; +constexpr int HEART_ALPHA_FULL = 255; +constexpr int HEART_ALPHA_DIMMED = 80; +constexpr float BYTE_TO_UNIT = 1 / 255.0f; +constexpr int FORGOTTEN_HEART_SLOTS = 6; +constexpr int GOLD_RESET_SLOT = 5; +constexpr int ROOM_INDEX_DEATHMATCH = -19; +constexpr float DEATHMATCH_BAR_SHIFT_X = -4; +constexpr float DEATHMATCH_BAR_SHIFT_Y = -6; +constexpr int ONLINE_HUD_COMPACT = 1; + +// Esau's row of the compact twin layout: how far it drops, and the line between it and Jacob's. +constexpr float ESAU_HEARTS_DROP = 34; +constexpr float ESAU_HEARTS_DROP_COMPACT = 4; +constexpr float ESAU_LINE_LEFT = 8; +constexpr float ESAU_LINE_RIGHT = 45; +constexpr float ESAU_LINE_RISE = 12; + +// The fading hearts of Tainted Magdalene: their pulse period and how far they fade. +constexpr float FADE_PULSE_FRAMES = 30; +constexpr float FADE_TINT_BASE = 0.5f; +constexpr float FADE_TINT_RANGE = 0.3f; +constexpr float FADE_OFFSET_RANGE = 0.1f; +constexpr float FADE_COLORIZE_BASE = 0.6f; +constexpr int MAGGY_FADE_START = 2; + +// The Holy Mantle shields beside the hearts: the most shown, the hearts a row may hold, and the second one's nudge. +constexpr int MANTLE_LIMIT = 5; +constexpr int MANTLE_HEART_LIMIT_MIN = 12; +constexpr int MANTLE_FORGOTTEN_SLOT = 5; +constexpr int WOODEN_CROSS_SHIELDS_MAX = 2; +constexpr uint8_t MANTLE_STACKS_MASK = 0xf; +constexpr float MANTLE_SECOND_X = 6; +constexpr float MANTLE_SECOND_RISE = 4; +constexpr float MANTLE_SECOND_ALPHA = 0.5f; +constexpr int NULL_ITEM_HOLY_CARD = 46; +constexpr int COLLECTIBLE_BLANKET = 535; +constexpr int COLLECTIBLE_GUPPYS_COLLAR = 212; + +// The extra lives text: its gap from the hearts, its rise, and the shift beside a shield or in the compact layout. +constexpr float LIVES_GAP = 10; +constexpr float LIVES_RISE = 8; +constexpr float LIVES_ROW_RISE = 6; +constexpr float LIVES_COMPACT_SHIFT = 5; +constexpr float HEART_EXTENT_PAD = 2; + +// How the HUD fades between the twins' items while the drop button is held. +constexpr float DROP_FADE_STEP = 0.25f; + +// The full heart Tainted Magdalene's health drain gives over (with Birthright, one more), and her dropping one. +constexpr int LAST_HEART_FLASH_PERIOD = 45; +constexpr int LAST_HEART_FLASH_FRAMES = 10; +constexpr int LAST_HEART_FLASH_STEPS = 9; + +// A trinket icon: its size, its frames across for Monkey Paw, its shadow, the tint of the error trinket, the clay +// colorize of a Modeling Clay copy and the golden shimmer's steps. +constexpr float TRINKET_SIZE = 32; +constexpr int MONKEY_PAW_FRAMES = 3; +constexpr int TRINKET_MONKEY_PAW = 20; +constexpr float TRINKET_SHADOW_ALPHA = 0.3f; +constexpr ColorMod TRINKET_SHADOW = {{0, 0, 0, TRINKET_SHADOW_ALPHA}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr std::array ERROR_TRINKET_TINT = {132 / 255.0f, 26 / 255.0f, 26 / 255.0f}; +constexpr std::array CLAY_COLORIZE = {0.5976471f, 0.33411765f, 0.31058824f, 1}; +constexpr int GOLD_SHIMMER_STEPS = 256; +constexpr int TRINKET_MODELING_CLAY = 166; +constexpr uint32_t ERROR_TRINKET_POOL = 189; + +// The active items whose HUD icon is not their item icon, the books Bethany and Judas show over the first slot, and +// the Necronomicon's powered icon, which needs three of the form counter it reads. +constexpr int COLLECTIBLE_NECRONOMICON = 35; +constexpr int COLLECTIBLE_BOOK_OF_BELIAL = 34; +constexpr int COLLECTIBLE_URN_OF_SOULS = 640; +constexpr int COLLECTIBLE_BAG_OF_CRAFTING = 710; +constexpr int NECRONOMICON_FORM = 15; +constexpr int NECRONOMICON_FORM_COUNT = 3; +constexpr int POCKET_ACTIVE_SLOT = 2; + +// An active item with its own HUD icon. +struct ActiveIcon +{ + int item; + const char* path; +}; + +constexpr ActiveIcon ACTIVE_ICONS[] = {{290, "gfx/characters/costumes/Costume_Rebirth_90_TheJar.png"}, + {326, "gfx/ui/hud_BreathOfLife.png"}, + {352, "gfx/ui/hud_GlassCannon.png"}, + {422, "gfx/ui/hud_GlowingHourGlass.png"}, + {434, "gfx/characters/costumes/Costume_434_JarOfFlies.png"}, + {474, "gfx/ui/hud_BrokenGlassCannon.png"}, + {479, "gfx/ui/hud_Smelter.png"}, + {483, "gfx/ui/hud_MamaMega.png"}, + {489, "gfx/characters/costumes/Costume_489_DInfinity.png"}, + {523, "gfx/characters/costumes/costume_523_movingbox.png"}, + {685, "gfx/ui/hud_JarOfWisps.png"}, + {711, "gfx/ui/hud_Flip.png"}, + {720, "gfx/ui/hud_EverythingJar.png"}}; +constexpr const char* NECRONOMICON_POWERED_PNG = "gfx/ui/hud_NecronomiconPowered.png"; +constexpr const char* URN_OF_SOULS_PNG = "gfx/ui/hud_UrnOfSouls.png"; +constexpr const char* URN_OF_SOULS_BELIAL_PNG = "gfx/ui/hud_UrnOfSouls_belial.png"; +constexpr const char* BAG_OF_CRAFTING_PNG = "gfx/ui/hud_BagOfCrafting.png"; +constexpr const char* BOOK_OF_VIRTUES_PNG = "gfx/ui/hud_BookOfVirtues.png"; +constexpr const char* BOOK_OF_BELIAL_PNG = "gfx/ui/hud_BookOfBelial.png"; +constexpr const char* BOOK_OF_VIRTUES_BELIAL_PNG = "gfx/ui/hud_BookOfVirtuesWithBelial.png"; + +constexpr int PICKUP_PILL = 70; +constexpr int PICKUP_TAROTCARD = 300; + +// Multiplies a color by another, as Color's *= does: tints multiply, offsets add and colorizes average. +static void color_multiply(ColorMod& color, const ColorMod& other) +{ + for (int i = 0; i < 4; i++) color._tint[i] = other._tint[i] * color._tint[i]; + + if (other._colorize[0] + other._colorize[1] + other._colorize[2] != 0) + { + bool isColorized = color._colorize[0] + color._colorize[1] + color._colorize[2] != 0; + for (int i = 0; i < 4; i++) + color._colorize[i] = isColorized ? (color._colorize[i] + other._colorize[i]) * 0.5f : other._colorize[i]; + } + + for (int i = 0; i < 3; i++) color._offset[i] = other._offset[i] + color._offset[i]; +} + +// A color that only tints by an alpha and adds a red offset. +static ColorMod heart_color(float alpha, float redOffset) +{ + return {{1, 1, 1, alpha}, {0, 0, 0, 0}, {redOffset, 0, 0}}; +} + +// Pulses a fading heart's color with the game's frames. +static void fade_pulse(ColorMod& color) +{ + float pulse = std::sin((float)g_game->frameCount * 3.1415927f / FADE_PULSE_FRAMES) * 0.5f + 0.5f; + float tint = pulse * FADE_TINT_RANGE + FADE_TINT_BASE; + float offset = pulse * FADE_OFFSET_RANGE; + + color_multiply(color, {{tint, tint, tint, 1}, {1, 1, 1, FADE_COLORIZE_BASE - offset}, {offset, 0, 0}}); +} + +// Whether a player is The Forgotten or The Soul, whose hearts past the first row are the other's. +static bool is_forgotten(const Entity_Player& player) +{ + return player.playerType == PLAYER_THEFORGOTTEN || player.playerType == PLAYER_THESOUL; +} + +// Whether a player is Judas or Dark Judas with Birthright, whose actives show Book of Belial. +static bool is_judas_birthright(Entity_Player& player) +{ + bool isJudas = player.playerType == PLAYER_JUDAS || player.playerType == PLAYER_BLACKJUDAS; + return isJudas && player.HasCollectible(COLLECTIBLE_BIRTHRIGHT); +} + +// The Wooden Cross shields a player has left: one per trinket multiplier (at most two) less those broken. +static int wooden_cross_shields(Entity_Player& player) +{ + int multiplier = std::min(player.GetTrinketMultiplier(TRINKET_WOODEN_CROSS), WOODEN_CROSS_SHIELDS_MAX); + return std::max(multiplier - (player.holyMantleStacks & MANTLE_STACKS_MASK), 0); +} + +// Shows a player in a corner that does not show it yet, emptied first and redrawn. +void PlayerHUD::assign(Entity_Player* shown) +{ + if (shown == player) return; + + reset(); + player = shown; + isDirty = true; + isCraftingItemDirty = true; +} + +// 00841cf0 Empties the corner: hearts, flashes, trinkets, actives, the crafting bag, and the player it showed. +void PlayerHUD::reset() +{ + hearts.fill({}); + lastHeartFlash = 0; + redHeartFlashCountdown = 0; + soulHeartFlashCountdown = 0; + goldHeartFlashCountdown = 0; + for (PlayerHUDTrinket& trinket : trinkets) trinket = {}; + for (PlayerHUDActiveItem& item : activeItems) item = {}; + inventoryIcons.clear(); + isDirty = false; + isCraftingItemDirty = false; + craftingResultImage.reset(); + craftingBagImage.reset(); + player = nullptr; +} + +// Forgets the box the corner covered, as HUD::Render does before each frame. +void PlayerHUD::bounds_reset() +{ + boundsMin = vector_make(PLAYER_HUD_BOUNDS_FAR, PLAYER_HUD_BOUNDS_FAR); + boundsMax = vector_make(-PLAYER_HUD_BOUNDS_FAR, -PLAYER_HUD_BOUNDS_FAR); +} + +// 00842230 Follows the player: its hearts (The Forgotten's first row, The Soul's second), the last heart's flash +// while one heart is left without a Holy Mantle shield, the actives, trinkets and pockets with their icons, Tainted +// Isaac's inventory and the crafting bag's result when asked, the twins' drop fade, and the heart flashes. A change +// asks the HUD to redraw the players' part. +// The crafting bag's result is not a field of Entity_Player yet. It is none while the bag is empty, as here. +void PlayerHUD::Update() +{ + Entity_Player& shown = *player; + bool isChanged = false; + + for (PlayerHUDHeart& heart : hearts) heart.isEternalHeartVisible = false; + std::span slots = hearts; + if (shown.subPlayer && is_forgotten(shown) && !shown.parent) + { + UpdateHearts(slots.first(FORGOTTEN_HEART_SLOTS), shown); + UpdateHearts(slots.subspan(FORGOTTEN_HEART_SLOTS, FORGOTTEN_HEART_SLOTS), *shown.subPlayer); + } + else UpdateHearts(slots, shown); + + lastHeartFlash = 0; + if (shown.boneHearts + shown.soulHearts + shown.eternalHearts + shown.redHearts == 1) + { + TemporaryEffects& effects = shown.temporaryEffects; + TemporaryEffect* mantle = effects.isDisabled ? nullptr : effects.GetCollectibleEffect(COLLECTIBLE_HOLY_MANTLE); + int frame = g_game->frameCount % LAST_HEART_FLASH_PERIOD; + if ((!mantle || mantle->count == 0) && frame < LAST_HEART_FLASH_FRAMES) + lastHeartFlash = (int16_t)((LAST_HEART_FLASH_STEPS - frame) * HEART_ALPHA_FULL / LAST_HEART_FLASH_STEPS); + } + + actives_update(isChanged); + trinkets_update(isChanged); + pockets_update(); + if (isDirty) inventory_update(); + + if (isCraftingItemDirty) + { + craftingResultImage.reset(); + if (std::ranges::any_of(shown.bagOfCraftingContent, [](char pickup) { return pickup != 0; })) + reconstruction_missing("PlayerHUD::Update 00842230: the crafting bag's result (Entity_Player +0x1f4c)"); + isCraftingItemDirty = false; + } + + bool isDropHeld = is_controller_action(shown.controllerIndex, ACTION_DROP, ACTION_PRESSED); + dropHoldFade = std::clamp(dropHoldFade + (isDropHeld ? DROP_FADE_STEP : -DROP_FADE_STEP), 0.0f, 1.0f); + for (int8_t* countdown : {&redHeartFlashCountdown, &soulHeartFlashCountdown, &goldHeartFlashCountdown}) + if (*countdown > 0) (*countdown)--; + if (isChanged) hud->refresh_request(HUD_REFRESH_PLAYER); +} + +// The active slots of Update: each counts its charge bar flash down, loads its item's HUD icon when the item +// changed, and the book icon the first slot shows (Book of Virtues, Judas's Book of Belial, or both) when it changed. +void PlayerHUD::actives_update(bool& isChanged) +{ + Entity_Player& shown = *player; + + for (int slot = 0; slot < PLAYER_HUD_ACTIVE_COUNT; slot++) + { + PlayerHUDActiveItem& active = activeItems[slot]; + int item = shown.activeItems[slot].item; + if (active.chargeBarFlash >= 0) + { + isChanged = true; + active.chargeBarFlash--; + } + + int book = 0; + if (slot == 0) + { + if (shown.HasCollectible(COLLECTIBLE_BOOK_OF_VIRTUES) && item != COLLECTIBLE_BOOK_OF_VIRTUES) + book = COLLECTIBLE_BOOK_OF_VIRTUES; + if (is_judas_birthright(shown) && item != COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE) + book = book == COLLECTIBLE_BOOK_OF_VIRTUES ? COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE : COLLECTIBLE_BOOK_OF_BELIAL; + } + + if (item != active.id) + { + active.id = item; + if (item < 0) reconstruction_missing("PlayerHUD::Update 00842230: a TMTRAINER active's icon"); + + ItemConfig_Item* config = g_manager->itemConfig.GetCollectible(item); + active.itemImage.reset(); + if (config) + { + std::string_view path = config->gfxFilename; + bool isNecronomiconPowered = !shown.hasCurseMistEffect && !shown.isCoopGhost && + shown.playerForms[NECRONOMICON_FORM] >= NECRONOMICON_FORM_COUNT && + shown.activeItems[slot].varData == 1; + for (const ActiveIcon& icon : ACTIVE_ICONS) + if (icon.item == item) path = icon.path; + if (item == COLLECTIBLE_NECRONOMICON && isNecronomiconPowered) path = NECRONOMICON_POWERED_PNG; + if (item == COLLECTIBLE_URN_OF_SOULS) + path = is_judas_birthright(shown) ? URN_OF_SOULS_BELIAL_PNG : URN_OF_SOULS_PNG; + if (item == COLLECTIBLE_BAG_OF_CRAFTING && slot != POCKET_ACTIVE_SLOT) path = BAG_OF_CRAFTING_PNG; + active.itemImage = Manager::LoadImage(path); + } + isChanged = true; + } + + if (book == active.bookItemId) continue; + active.bookItemId = book; + if (book == COLLECTIBLE_BOOK_OF_VIRTUES) active.bookImage = Manager::LoadImage(BOOK_OF_VIRTUES_PNG); + else if (book == COLLECTIBLE_BOOK_OF_BELIAL) active.bookImage = Manager::LoadImage(BOOK_OF_BELIAL_PNG); + else if (book == COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE) + active.bookImage = Manager::LoadImage(BOOK_OF_VIRTUES_BELIAL_PNG); + else active.bookImage.reset(); + isChanged = true; + } +} + +// The trinket slots of Update: each follows its trinket (the error trinket shows one picked by the room's spawn seed) +// and, once it shows Modeling Clay, the item the clay copies, reloading the icon and the offset of its drawn pixels +// when either changed. +void PlayerHUD::trinkets_update(bool& isChanged) +{ + Entity_Player& shown = *player; + + for (int slot = 0; slot < PLAYER_HUD_TRINKET_COUNT; slot++) + { + PlayerHUDTrinket& trinket = trinkets[slot]; + int id = (int)(shown.trinkets[slot] & TRINKET_ID_MASK); + int clayItem = trinket.id == TRINKET_MODELING_CLAY ? shown.modelingClayEffect : 0; + uint32_t seed = id == TRINKET_ERROR ? g_game->GetRoomByIdx(g_game->currentRoomIdx)->spawnSeed : 0; + if (seed != 0) + { + seed ^= seed >> 2; + seed ^= seed << 7; + id = (int)((seed >> 25 ^ seed) % ERROR_TRINKET_POOL + 1); + } + if (id == trinket.id && clayItem == trinket.clayItem) continue; + + trinket.id = id; + trinket.clayItem = clayItem; + if (id != 0 || clayItem != 0) + reconstruction_missing("PlayerHUD::Update 00842230: a trinket's icon and the offset of its drawn pixels"); + isChanged = true; + g_game->hud.mark_all_slots_dirty(HISTORY_KEEP_ICONS, HISTORY_KEEP_ITEMS); + } +} + +// The pocket slots of Update: each loads the pickup sprite of its card or pill when what it holds changed, and none +// for a pocket active or an empty slot. +void PlayerHUD::pockets_update() +{ + Entity_Player& shown = *player; + + for (int slot = 0; slot < PLAYER_HUD_POCKET_COUNT; slot++) + { + PlayerHUDPocketItem& pocket = pocketItems[slot]; + PocketItem& held = shown.pocketItems[slot]; + int subtype = 0; + if (held.type == POCKET_CARD) + { + ItemConfig_Card* card = g_manager->itemConfig.GetCard(held.id); + if (card) subtype = card->pickupSubtype; + } + else if (held.type == POCKET_PILL) subtype = held.id; + if (held.type == pocket.kind && subtype == pocket.id) continue; + + EntityConfig_Entity* config = nullptr; + if (subtype != 0 && held.type != POCKET_ACTIVE) + { + int variant = held.type == POCKET_CARD ? PICKUP_TAROTCARD : PICKUP_PILL; + config = g_manager->entityConfig.GetEntity(ENTITY_PICKUP, variant, subtype); + } + if (config) pocket.sprite.Load(config->anm2Path, GRAPHICS_LOAD); + else pocket.sprite.Reset(); + pocket.kind = held.type; + pocket.id = subtype; + } +} + +// The inventory icons of Update when the corner is redrawn: Tainted Isaac's inventory, or the Cantripped challenge's +// cards, else none. +void PlayerHUD::inventory_update() +{ + bool isCantripped = g_game->challenge == CHALLENGE_CANTRIPPED && !player->itemCards.empty(); + + if (player->playerType == PLAYER_ISAAC_B || isCantripped) + reconstruction_missing("PlayerHUD::Update 00842230: Tainted Isaac's inventory and the Cantripped cards' icons"); + inventoryIcons.clear(); + isDirty = false; +} + +// 00841e20 Fills heart slots from a player's health: the red hearts (rotten or coin ones, empty past what it has), +// then the soul and black hearts with the bone hearts among them, the eternal heart over the last filled red or bone +// heart, the broken hearts, and no heart past those. The last filled hearts are golden, as many as it has. Tainted +// Magdalene's red hearts past her first two (three with Birthright) and her soul hearts fade. +void PlayerHUD::UpdateHearts(std::span slots, Entity_Player& shown) +{ + HealthType healthType = shown.GetHealthType(); + if (healthType == HEALTH_NO_HEALTH) return; + + bool isCoin = healthType == HEALTH_COIN; + bool isMaggy = shown.playerType == PLAYER_MAGDALENE_B && (int)shown.maggyHealthDrainCooldown >= 1; + int maggyFadeStart = MAGGY_FADE_START + (shown.HasCollectible(COLLECTIBLE_BIRTHRIGHT) ? 1 : 0); + int count = (int)slots.size(); + int rotten = shown.rottenHearts; + int red = shown.redHearts - rotten * 2; + int filled = 0; + int slot = 0; + auto flash_if = [](int8_t countdown, HeartFlash flash) { return countdown > 0 ? flash : HEART_FLASH_NONE; }; + + for (; slot < (shown.maxHearts + 1) / 2 && slot < count; slot++) + { + PlayerHUDHeart& heart = slots[slot]; + heart.isVisible = true; + heart.isFadeHeart = isMaggy && slot >= maggyFadeStart; + if (red < 1 && rotten < 1) + { + heart.isGoldenHeartVisible = false; + heart.isFadeHeart = false; + heart.spriteAnim = isCoin ? "CoinEmpty" : "EmptyHeart"; + heart.flashType = HEART_FLASH_NONE; + continue; + } + + filled++; + heart.isGoldenHeartVisible = true; + if (red < 1) + { + heart.spriteAnim = "RottenHeartFull"; + heart.flashType = flash_if(redHeartFlashCountdown, HEART_FLASH_ROTTEN); + rotten--; + continue; + } + if (isCoin) heart.spriteAnim = red < 2 ? "CoinHeartHalf" : "CoinHeartFull"; + else heart.spriteAnim = red < 2 ? "RedHeartHalf" : "RedHeartFull"; + heart.flashType = flash_if(redHeartFlashCountdown, isCoin ? HEART_FLASH_GOLD : HEART_FLASH_RED); + red = std::max(red - 2, 0); + } + + int eternalSlot = std::max(slot - 1, 0); + int soul = shown.soulHearts; + int soulIndex = 0; + uint32_t boneBit = 1; + for (int i = 0; i < (shown.soulHearts + 1) / 2 + shown.boneHearts && slot < count; i++, slot++) + { + PlayerHUDHeart& heart = slots[slot]; + filled++; + heart.isFadeHeart = isMaggy; + heart.isVisible = true; + heart.isGoldenHeartVisible = true; + bool isBone = shown.boneHearts >= 1 && (uint32_t)shown.boneHeartsMask & boneBit; + boneBit = boneBit << 1 | boneBit >> 31; + if (isBone) + { + if (red >= 1) + { + heart.spriteAnim = red < 2 ? "BoneHeartHalf" : "BoneHeartFull"; + heart.flashType = flash_if(redHeartFlashCountdown, HEART_FLASH_RED); + eternalSlot = slot; + } + else if (rotten >= 1) + { + rotten--; + heart.spriteAnim = "RottenBoneHeartFull"; + heart.flashType = flash_if(redHeartFlashCountdown, HEART_FLASH_ROTTEN); + } + else + { + heart.spriteAnim = "BoneHeartEmpty"; + heart.flashType = HEART_FLASH_NONE; + } + red = std::max(red - 2, 0); + continue; + } + + bool isBlack = shown.soulHearts >= soulIndex * 2 + 1 && shown.blackHearts & 1 << (soulIndex & 31); + if (isBlack) heart.spriteAnim = soul < 2 ? "BlackHeartHalf" : "BlackHeartFull"; + else heart.spriteAnim = soul < 2 ? "BlueHeartHalf" : "BlueHeartFull"; + heart.flashType = flash_if(soulHeartFlashCountdown, isBlack ? HEART_FLASH_BLACK : HEART_FLASH_SOUL); + soul = std::max(soul - 2, 0); + soulIndex++; + } + + if (shown.eternalHearts > 0) + { + slots[eternalSlot].spriteOverlayAnim = ANIMATION_WHITE_OVERLAY; + slots[eternalSlot].isEternalHeartVisible = true; + slots[eternalSlot].flashType = HEART_FLASH_NONE; + } + + bool isFull = false; + for (int broken = 0; broken < shown.brokenHearts; broken++, slot++) + { + isFull = slot >= count; + if (isFull) break; + slots[slot].isVisible = true; + slots[slot].isGoldenHeartVisible = false; + slots[slot].spriteAnim = isCoin ? "BrokenCoinHeart" : "BrokenHeart"; + slots[slot].flashType = HEART_FLASH_NONE; + } + if (!isFull) + for (; slot < count; slot++) slots[slot].isVisible = false; + + filled -= shown.goldenHearts; + for (PlayerHUDHeart& heart : slots) + { + if (filled < 1) return; + if (!heart.isVisible || !heart.isGoldenHeartVisible) continue; + heart.isGoldenHeartVisible = false; + filled--; + } +} + +// 00840030 Sets an active slot's charge bar frame for a collectible. +void PlayerHUD::set_active_charge_frame(int) +{ + reconstruction_missing("PlayerHUD::set_active_charge_frame 00840030"); +} + +// 00843df0 Draws the hearts in rows of six from at (leftward for Esau's corner of the twin layout), last first, each +// tinted by its flash (or the last heart's flash), dimmed past The Forgotten's first row or under an instant death +// curse, Tainted Magdalene's pulsing, with the eternal heart over its heart and the golden overlays after. The Holy +// Mantle shields follow the hearts, then the extra lives count. The curse of the unknown shows one cursed heart, and a +// versus match a health bar. outExtent is how far the hearts reach. +void PlayerHUD::RenderHearts(Vector& outExtent, ANM2& sprite, PlayerHudLayout layout, float heartScale, Vector at) +{ + Game& game = *g_game; + if (game.currentRoomIdx == ROOM_INDEX_DEATHMATCH) + { + outExtent = render_deathmatch_health_bar(vector_make(at.x + DEATHMATCH_BAR_SHIFT_X, at.y + DEATHMATCH_BAR_SHIFT_Y)); + return; + } + + bool isCompact = g_manager->netplayManager.is_online() && game.deathmatchManager.state < DEATHMATCH_INTRO && + g_manager->optionsConfig.onlineHud == ONLINE_HUD_COMPACT && playerHudIndex != 0 && + playerHudIndex != MAIN_PLAYER_HUD_COUNT; + bool isFlipped = playerHudIndex >= MAIN_PLAYER_HUD_COUNT && layout == HUD_LAYOUT_JACOB_ESAU; + float spacingX = isCompact ? HEART_SMALL_SPACING_X : HEART_SPACING_X; + float spacingY = isCompact ? HEART_SMALL_SPACING_Y : HEART_SPACING_Y; + if (sprite.ReplaceSpritesheet(0, isCompact ? HEARTS_SMALL_PNG : HEARTS_PNG)) sprite.LoadGraphics(); + + if (!player || player->isCoopGhost) + { + outExtent = vector_make(spacingX * heartScale, spacingY * heartScale); + return; + } + + if (layout == HUD_LAYOUT_JACOB_ESAU_COMPACT) + { + if (playerHudIndex >= MAIN_PLAYER_HUD_COUNT) + { + at.y += ESAU_HEARTS_DROP; + if (isCompact) at.y -= ESAU_HEARTS_DROP_COMPACT; + Vector from = vector_make(at.x - ESAU_LINE_LEFT, at.y - ESAU_LINE_RISE); + Vector to = vector_make(at.x + ESAU_LINE_RIGHT, at.y - ESAU_LINE_RISE); + KColor white = kcolor_rgba(1, 1, 1, 1); + render_color_quad(&from, &to, &white, &white, 1); + } + isCompact = true; + } + + Entity_Player& shown = *player; + sprite.scale = vector_make(heartScale, heartScale); + if (game.GetCurses() & CURSE_OF_THE_UNKNOWN) + { + sprite.SetFrame(ANIMATION_CURSE_HEART, 0); + sprite.Render({at}); + sprite.scale = vector_make(1, 1); + outExtent = vector_make(spacingX * heartScale, spacingY * heartScale); + return; + } + + float stepX = isFlipped ? -spacingX : spacingX; + auto slot_position = [&](int slot) { + return vector_make((float)(slot % HEARTS_PER_ROW) * stepX * heartScale + at.x, + (float)(slot / HEARTS_PER_ROW) * spacingY * heartScale + at.y); + }; + int maxColumn = -1; + int maxRow = 0; + int fullSlots = 0; + bool isInstantDeath = shown.HasInstantDeathCurse(); + if (isFlipped) sprite.isFlipX = true; + + if (shown.GetHealthType() != HEALTH_NO_HEALTH) + { + for (int slot = PLAYER_HUD_HEART_COUNT - 1; slot >= 0; slot--) + { + PlayerHUDHeart& heart = hearts[slot]; + bool isDimmed = (slot >= FORGOTTEN_HEART_SLOTS && is_forgotten(shown)) || isInstantDeath; + int alpha = isDimmed ? HEART_ALPHA_DIMMED : HEART_ALPHA_FULL; + if (!heart.isVisible) continue; + + maxColumn = std::max(slot % HEARTS_PER_ROW, maxColumn); + maxRow = std::max(slot / HEARTS_PER_ROW, maxRow); + Vector position = slot_position(slot); + float unitAlpha = (float)alpha * BYTE_TO_UNIT; + float flashOffset = slot == 0 ? (float)lastHeartFlash * BYTE_TO_UNIT : 0; + sprite.SetFrame(heart.spriteAnim, 0); + + HeartFlash flash = heart.flashType; + if (goldHeartFlashCountdown != 0 && heart.isGoldenHeartVisible) flash = HEART_FLASH_GOLD; + if (flash != HEART_FLASH_NONE) + { + const std::array& offset = HEART_FLASH_OFFSETS[flash]; + sprite.color = {{1, 1, 1, unitAlpha}, {0, 0, 0, 0}, {offset[0], offset[1], offset[2]}}; + } + else sprite.color = heart_color(unitAlpha, flashOffset); + if (heart.isFadeHeart) fade_pulse(sprite.color); + sprite.Render({position}); + + if (heart.isEternalHeartVisible) + { + sprite.SetFrame(heart.spriteOverlayAnim, 0); + sprite.color = heart_color(unitAlpha, flashOffset); + if (heart.isFadeHeart) fade_pulse(sprite.color); + sprite.Render({position}); + } + if (fullSlots == 0 && alpha == HEART_ALPHA_FULL) fullSlots = slot + 1; + } + + sprite.SetFrame(ANIMATION_GOLD_OVERLAY, 0); + sprite.color = heart_color((float)(is_forgotten(shown) ? HEART_ALPHA_DIMMED : HEART_ALPHA_FULL) * BYTE_TO_UNIT, 0); + for (int slot = PLAYER_HUD_HEART_COUNT - 1; slot >= 0; slot--) + { + if (slot == GOLD_RESET_SLOT) sprite.color = COLOR_DEFAULT; + if (hearts[slot].isVisible && hearts[slot].isGoldenHeartVisible) sprite.Render({slot_position(slot)}); + } + } + + bool isMantleShifted = false; + TemporaryEffects& effects = shown.temporaryEffects; + TemporaryEffect* mantle = effects.isDisabled ? nullptr : effects.GetCollectibleEffect(COLLECTIBLE_HOLY_MANTLE); + if (mantle && mantle->count > 0) + { + std::array shields{}; + int shieldCount = 0; + int woodenCross = wooden_cross_shields(shown); + if (woodenCross != 0) shields[shieldCount++] = MANTLE_WOODEN_CROSS; + if (woodenCross > 1) shields[shieldCount++] = MANTLE_WOODEN_CROSS; + if (effects.HasCollectibleEffect(COLLECTIBLE_BLANKET)) shields[shieldCount++] = MANTLE_BLANKET; + if (shown.HasCollectible(COLLECTIBLE_HOLY_MANTLE) && shown.holyMantleState == 0) + shields[shieldCount++] = MANTLE_HOLY_MANTLE; + if (effects.HasNullEffect(NULL_ITEM_HOLY_CARD)) shields[shieldCount++] = MANTLE_HOLY_CARD; + for (; shieldCount < mantle->count && shieldCount < MANTLE_LIMIT; shieldCount++) + shields[shieldCount] = MANTLE_HOLY_MANTLE; + + int limit = is_forgotten(shown) ? MANTLE_FORGOTTEN_SLOT + : std::max(shown.GetHeartLimit(false) / 2, MANTLE_HEART_LIMIT_MIN) - 1; + float shift = 0; + int slot = fullSlots; + if (limit < fullSlots) + { + shift = stepX; + isMantleShifted = true; + slot = limit; + } + maxColumn = std::max(maxColumn, slot % HEARTS_PER_ROW); + Vector position = vector_make(((float)(slot % HEARTS_PER_ROW) * stepX + shift) * heartScale + at.x, + (float)(slot / HEARTS_PER_ROW) * spacingY * heartScale + at.y); + + if (mantle->count > 1 && shields[1]) + { + sprite.color._tint[3] = MANTLE_SECOND_ALPHA; + sprite.SetFrame(shields[1], 0); + float nudge = isFlipped ? -MANTLE_SECOND_X : MANTLE_SECOND_X; + sprite.Render({vector_make(nudge * heartScale + position.x, position.y + heartScale * -MANTLE_SECOND_RISE)}); + sprite.color = COLOR_DEFAULT; + } + if (shields[0]) + { + sprite.SetFrame(shields[0], 0); + sprite.Render({position}); + } + } + if (isFlipped) sprite.isFlipX = false; + + int lives = shown.GetExtraLives(); + if (lives >= 1) + { + Vector shake = game.screenShakeOffset; + float rowsY = (float)maxRow * spacingY * heartScale + at.y; + float right = at.x + (float)maxColumn * stepX * heartScale + shake.x; + char text[32]; + std::snprintf(text, sizeof(text), EXTRA_LIVES_FORMAT, lives, + shown.HasCollectible(COLLECTIBLE_GUPPYS_COLLAR) ? "?" : ""); + + Font& font = g_manager->font6_PFTempestaSevenCondensed; + float y = (-LIVES_RISE - (float)maxRow * LIVES_ROW_RISE) + rowsY + shake.y; + float direction = isFlipped ? -1 : 1; + float x = isFlipped ? (-LIVES_GAP - (float)font.GetStringWidth(text)) + right : right + LIVES_GAP; + if (isMantleShifted && !isCompact) x += direction * spacingX; + else if (isCompact) x -= direction * LIVES_COMPACT_SHIFT; + FontSettings settings; + font.DrawString(text, vector_make(x, y), vector_make(heartScale, heartScale), kcolor_rgba(1, 1, 1, 1), settings); + } + + sprite.scale = vector_make(1, 1); + outExtent = vector_make(((float)maxColumn * spacingX + spacingX) * heartScale, + ((float)maxRow * spacingY + spacingY + HEART_EXTENT_PAD) * heartScale); +} + +// 008453c0 Draws an active item with its charge bar, the book over the first slot and the item's own counters. +void PlayerHUD::RenderActiveItem(int activeSlot, Vector, PlayerHudLayout, float, float) +{ + if (!player || player->isCoopGhost || activeSlot < 0 || activeSlot >= PLAYER_HUD_ACTIVE_COUNT) return; + if (player->activeItems[activeSlot].item == 0) return; + reconstruction_missing("PlayerHUD::RenderActiveItem 008453c0: an active item's icon and charge bar"); +} + +// (0084bab0) Draws a trinket's icon at a position and size in a color: its 32 pixel frame, which for Monkey Paw is the +// one of the paw's fingers left. +void PlayerHUD::trinket_draw(const PlayerHUDTrinket& trinket, Vector at, const ColorMod& color, float trinketScale) +{ + float frameX = trinket.id == TRINKET_MONKEY_PAW ? (float)(MONKEY_PAW_FRAMES - player->monkeyPawCounter) * TRINKET_SIZE + : 0; + SourceQuad source = KAGE::Graphics::source_quad_rect(vector_make(frameX, 0), vector_make(TRINKET_SIZE, TRINKET_SIZE)); + Vector size = vector_make(trinketScale * TRINKET_SIZE, trinketScale * TRINKET_SIZE); + KAGE::Graphics::ColorQuad quad = KAGE::Graphics::color_quad_rect(at, size, kcolor_rgba(1, 1, 1, 1)); + + apply_sprite_shader_params(color, SPRITE_SHADER_COLOR_APPLY, *trinket.image); + trinket.image->Render(source, quad, kcolor_rgba(color._tint[0], color._tint[1], color._tint[2], color._tint[3])); +} + +// 00846ff0 Draws a trinket slot's icon over its shadow, shaken with the screen and, when small, centered on its drawn +// pixels: the error trinket reddened, a golden trinket shimmering in the gold shader, a Modeling Clay copy in clay. +// The original leaves the shaders it picks current. Here they are popped after. +void PlayerHUD::RenderTrinket(int trinketSlot, Vector at, float trinketScale, bool isSmall) +{ + const PlayerHUDTrinket& trinket = trinkets[trinketSlot]; + if (trinket.id == 0 || !trinket.image) return; + + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + Vector shake = g_game->screenShakeOffset; + Vector position = vector_make(at.x + shake.x, shake.y + at.y); + if (isSmall) + position = vector_make(position.x - trinketScale * trinket.offset.x, position.y - trinketScale * trinket.offset.y); + + int pushed = graphics.shader_push(COLOR_OFFSET_SHADER) ? 1 : 0; + trinket_draw(trinket, vector_make(trinketScale + trinketScale + position.x, trinketScale + trinketScale + position.y), + TRINKET_SHADOW, trinketScale); + + ColorMod color = COLOR_DEFAULT; + uint32_t held = player->trinkets[trinketSlot]; + if ((held & TRINKET_ID_MASK) == TRINKET_ERROR) + for (int i = 0; i < 3; i++) color._tint[i] = ERROR_TRINKET_TINT[i]; + if (held & TRINKET_GOLDEN_FLAG) + { + if (graphics.shader_push(COLOR_OFFSET_GOLD_SHADER)) pushed++; + color._colorize[3] = (float)(g_game->frameCount % GOLD_SHIMMER_STEPS) * (1.0f / GOLD_SHIMMER_STEPS); + } + else if (trinket.clayItem != 0) + for (int i = 0; i < 4; i++) color._colorize[i] = CLAY_COLORIZE[i]; + trinket_draw(trinket, position, color, trinketScale); + for (; pushed > 0; pushed--) graphics.shader_pop(); +} + +// 008471c0 Draws the pockets at their size and alpha: the cards, pills and pocket actives past the first, then the +// first with its name. The pocket sprites and the HUD's card sprite go back to full size after, the card sprite keeping +// the alpha. +void PlayerHUD::RenderPocketItems(Vector, PlayerHudLayout, float alpha, float pocketScale) +{ + float size = std::abs(pocketScale); + ANM2& cardsSprite = hud->cardsPillsSprite; + cardsSprite.scale = vector_make(size, size); + cardsSprite.color._tint[3] = alpha; + for (PlayerHUDPocketItem& pocket : pocketItems) + { + pocket.sprite.scale = vector_make(size, size); + pocket.sprite.color._tint[3] = alpha; + } + + for (PocketItem& held : player->pocketItems) + if (held.id != 0) reconstruction_missing("PlayerHUD::RenderPocketItems 008471c0: a card, pill or pocket active"); + + cardsSprite.scale = vector_make(1, 1); + for (PlayerHUDPocketItem& pocket : pocketItems) + { + pocket.sprite.scale = vector_make(1, 1); + pocket.sprite.color._tint[3] = 1; + } +} + +// 00848d20 Draws Tainted Isaac's inventory. +void PlayerHUD::render_inventory(Vector, float) +{ + reconstruction_missing("PlayerHUD::render_inventory 00848d20"); +} + +// 00849510 Draws Tainted Cain's crafting bag. +void PlayerHUD::RenderCraftingTable(Vector, float) +{ + reconstruction_missing("PlayerHUD::RenderCraftingTable 00849510"); +} + +// 0084a3e0 Draws Tainted ???'s poop spell queue. +void PlayerHUD::RenderSpellQueue(Vector, float) +{ + reconstruction_missing("PlayerHUD::RenderSpellQueue 0084a3e0"); +} + +// 0084ad40 Draws a versus health bar and returns its size. +Vector PlayerHUD::render_deathmatch_health_bar(Vector) +{ + reconstruction_missing("PlayerHUD::render_deathmatch_health_bar 0084ad40"); +} + +// 009a8500 A new corner of a HUD, not one of its eight, showing a player. +std::shared_ptr PlayerHUD::make_ref(HUD* owner, Entity_Player* shown) +{ + auto corner = std::make_shared(); + + corner->hud = owner; + corner->playerHudIndex = -1; + corner->assign(shown); + return corner; +} diff --git a/src/player_hud.h b/src/player_hud.h new file mode 100644 index 0000000..492f3f1 --- /dev/null +++ b/src/player_hud.h @@ -0,0 +1,136 @@ +#pragma once + +#include "anm2.h" +#include "kage_graphics.h" +#include +#include +#include +#include +#include + +constexpr int PLAYER_HUD_COUNT = 8; +constexpr int MAIN_PLAYER_HUD_COUNT = 4; +constexpr int PLAYER_HUD_HEART_COUNT = 24; +constexpr int PLAYER_HUD_ACTIVE_COUNT = 4; +constexpr int PLAYER_HUD_TRINKET_COUNT = 2; +constexpr int PLAYER_HUD_POCKET_COUNT = 4; +constexpr float PLAYER_HUD_BOUNDS_FAR = 1e7f; + +// REPENTOGON's HUD layouts of a player, and the spot an online player's status takes. +enum PlayerHudLayout : int +{ + HUD_LAYOUT_NORMAL, + HUD_LAYOUT_JACOB_ESAU, + HUD_LAYOUT_COMPACT, + HUD_LAYOUT_JACOB_ESAU_COMPACT, + HUD_LAYOUT_NET_STATUS +}; + +// The flash a heart shows while its kind of health was just gained, as an entry of the heart flash colors. +enum HeartFlash : int8_t +{ + HEART_FLASH_NONE, + HEART_FLASH_RED, + HEART_FLASH_SOUL, + HEART_FLASH_BLACK, + HEART_FLASH_GOLD, + HEART_FLASH_ROTTEN, + HEART_FLASH_COUNT +}; + +// REPENTOGON's PlayerHUDHeart: the animations a heart slot shows and how. +struct PlayerHUDHeart +{ + const char* spriteAnim = ""; + const char* spriteOverlayAnim = ""; + HeartFlash flashType = HEART_FLASH_NONE; + bool isEternalHeartVisible = false; + bool isFadeHeart = false; + bool isGoldenHeartVisible = false; + bool isVisible = false; +}; + +// REPENTOGON's PlayerHUDActiveItem: the item an active slot shows, its book overlay and its charge bar flash. +struct PlayerHUDActiveItem +{ + KAGE::Graphics::ImagePtr bookImage; + KAGE::Graphics::ImagePtr itemImage; + int bookItemId = 0; + int chargeBarFlash = 0; + int id = 0; +}; + +// REPENTOGON's PlayerHUDTrinket: the trinket a slot shows (or the item Modeling Clay copies), its icon, and how far the +// icon's drawn pixels sit from its center. +struct PlayerHUDTrinket +{ + KAGE::Graphics::ImagePtr image; + Vector offset{}; + int clayItem = 0; + int id = 0; +}; + +// A card, pill or pocket active slot: its sprite and what it shows (the pickup subtype of a card or pill). +struct PlayerHUDPocketItem +{ + ANM2 sprite; + int id = 0; + int kind = 0; +}; + +// An icon of Tainted Isaac's inventory or of the Cantripped challenge's cards. +struct PlayerHUDIcon +{ + KAGE::Graphics::ImagePtr image; + int id = 0; +}; + +// Construction (006efc70) and destruction (006efde0) are the defaults. +// One player's corner of the HUD (REPENTOGON's PlayerHUD): hearts, actives, trinkets, pockets, the inventory icons and +// the crafting bag's result, how far the drop button faded the twin's items, and the box the drawn parts covered. +struct PlayerHUD +{ + std::array hearts{}; + std::array activeItems{}; + std::array trinkets{}; + std::array pocketItems{}; + std::vector inventoryIcons; + KAGE::Graphics::ImagePtr craftingBagImage; + KAGE::Graphics::ImagePtr craftingResultImage; + KAGE::Graphics::ImagePtr deathmatchHealthBarImage; + Vector boundsMax = vector_make(-PLAYER_HUD_BOUNDS_FAR, -PLAYER_HUD_BOUNDS_FAR); + Vector boundsMin = vector_make(PLAYER_HUD_BOUNDS_FAR, PLAYER_HUD_BOUNDS_FAR); + Entity_Player* player = nullptr; + HUD* hud = nullptr; + float dropHoldFade = 0; + int16_t lastHeartFlash = 0; + int16_t playerHudIndex = 0; + int8_t goldHeartFlashCountdown = 0; + int8_t redHeartFlashCountdown = 0; + int8_t soulHeartFlashCountdown = 0; + bool isCraftingItemDirty = false; + bool isDirty = false; + + void reset(); + void bounds_reset(); + void assign(Entity_Player* shown); + void Update(); + void UpdateHearts(std::span slots, Entity_Player& shown); + void set_active_charge_frame(int collectibleId); + void RenderHearts(Vector& outExtent, ANM2& sprite, PlayerHudLayout layout, float heartScale, Vector at); + void RenderActiveItem(int activeSlot, Vector at, PlayerHudLayout layout, float itemScale, float alpha); + void RenderTrinket(int trinketSlot, Vector at, float trinketScale, bool isSmall); + void RenderPocketItems(Vector at, PlayerHudLayout layout, float alpha, float pocketScale); + void render_inventory(Vector at, float inventoryScale); + void RenderCraftingTable(Vector at, float tableScale); + void RenderSpellQueue(Vector at, float queueScale); + Vector render_deathmatch_health_bar(Vector at); + static std::shared_ptr make_ref(HUD* owner, Entity_Player* shown); + +private: + void actives_update(bool& isChanged); + void trinkets_update(bool& isChanged); + void pockets_update(); + void inventory_update(); + void trinket_draw(const PlayerHUDTrinket& trinket, Vector at, const ColorMod& color, float trinketScale); +}; diff --git a/src/player_manager.cpp b/src/player_manager.cpp index 99ff4ce..5d482b6 100644 --- a/src/player_manager.cpp +++ b/src/player_manager.cpp @@ -1,5 +1,6 @@ #include "player_manager.h" #include "entity_familiar.h" +#include "entity_npc.h" #include "entity_player.h" #include "game.h" #include "item_config.h" @@ -7,9 +8,12 @@ #include "manager.h" #include "platform.h" #include "popups.h" +#include "preload_manager.h" #include "room.h" #include "seeds.h" +#include "texture_cache.h" #include +#include constexpr int FAMILIAR_BLOOD_OATH = 203; constexpr int FAMILIAR_PASCHAL_CANDLE = 221; @@ -24,6 +28,17 @@ constexpr float PLAYER_START_X = 320; constexpr float PLAYER_START_Y = 400; constexpr int HOURGLASS_INDEX_LAST = 3; +// How far apart get_player_start_position spreads the players, and the rows past two players. +constexpr float START_SPACING = 48; +constexpr float START_ROW_OFFSET = 24; +constexpr float START_DEPTH_STEP = 0.01f; + +// How far enter_level moves the other players toward where they stood from the lead player. +constexpr float ENTER_SPREAD = 3; +constexpr float RANDOM_SCALE = 2.3283064e-10f; +constexpr float HALF_TURN = 3.14f; +constexpr const char* PLAYER_TEARS_GROUP = "player tears"; + // The babies of babies.xml the game ships (those past them are a random pick's extras) and the glitched one. constexpr int BABY_COUNT = 71; constexpr uint32_t BABY_RANDOM_PICK_MASK = 3; @@ -623,6 +638,125 @@ void PlayerManager::coop_slots_reset() } } +// 009bba30 Enters a new floor's first room: each player keeps its offset from the lead player (the room transition's, +// else the first), a random direction when it stood on it, as a step away from it once every player entered the room. +// The tears preload group loads while any player shoots tears, else it is unloaded and unused images are purged. +// Familiars move to their follow position, then they and the NPCs enter the room, and the rewind state is saved. +// The original also has NPCs enter a versus match's players, which are no NPCs. Here they are skipped. +void PlayerManager::enter_level() +{ + Entity_Player* lead = roomTransitionPlayer ? roomTransitionPlayer : g_game->GetPlayer(0); + std::vector offsets; + + for (Entity_Player* player : playerList) + { + Vector offset = vector_make(player->pos.x - lead->pos.x, player->pos.y - lead->pos.y); + if (offset.x == 0 && offset.y == 0 && player != lead) + { + float angle = (float)Random() * RANDOM_SCALE * HALF_TURN; + angle += angle; + offset = vector_make(std::cos(angle), std::sin(angle)); + } + offsets.push_back(offset); + } + + bool isTearsShot = false; + for (Entity_Player* player : playerList) + { + player->room_enter(); + if (player->HasWeaponType(WEAPON_TEARS)) isTearsShot = true; + } + if (isTearsShot) g_game->preloadManager.group_load(PLAYER_TEARS_GROUP); + else + { + auto found = g_game->preloadManager.groups.find(PLAYER_TEARS_GROUP); + if (found != g_game->preloadManager.groups.end() && found->second.isLoaded) + { + for (PreloadEntry& entry : found->second.entries) entry.image.reset(); + found->second.isLoaded = false; + } + TextureCache::Purge(); + } + + for (size_t i = 0; i < playerList.size(); i++) + { + Entity_Player& player = *playerList[i]; + Vector offset = offsets[i]; + if (&player == lead || (offset.x == 0 && offset.y == 0)) continue; + + float length = std::sqrt(offset.y * offset.y + offset.x * offset.x); + if (length > 0) offset = vector_make(ENTER_SPREAD / length * offset.x, ENTER_SPREAD / length * offset.y); + player.pos = vector_make(player.pos.x + offset.x, player.pos.y + offset.y); + } + + std::vector& entities = g_game->room->GetEntities()->updateEL; + for (Entity* entity : entities) + if (entity && entity->type == ENTITY_FAMILIAR) + reconstruction_missing("PlayerManager::enter_level 009bba30: Entity_Familiar::GetFollowTargetPosition 0063b4a0"); + for (Entity* entity : entities) + { + if (!entity) continue; + if (entity->type == ENTITY_FAMILIAR) static_cast(entity)->room_enter(); + else if (entity->type >= ENTITY_FIRST_ENEMY && entity->type < ENTITY_EFFECT) + static_cast(entity)->room_enter(); + } + g_game->save_rewind_state(-1); +} + +// 009bc690 Where a player starts in a room: at position, or the room's center when it is zero, spread 48 apart by +// player index with more than one player, in two rows past two players, each a little higher than the last. +Vector PlayerManager::get_player_start_position(Entity_Player* player, Vector position) +{ + int count = (int)g_game->playerManager.playerList.size(); + int slot = player->playerIndex; + Vector start = position.x == 0 && position.y == 0 ? Room::GetCenterPos() : position; + if (count == 1) return start; + + float rowCenter = 0.5f; + if (count != 2) + { + int rowSize = (count + 1) / 2; + if (slot < rowSize) start.y -= START_ROW_OFFSET; + else + { + start.y += START_ROW_OFFSET; + slot -= rowSize; + rowSize = count / 2; + } + rowCenter = (float)(rowSize - 1) * 0.5f; + } + return vector_make(((float)slot - rowCenter) * START_SPACING + start.x, start.y - (float)slot * START_DEPTH_STEP); +} + +// 009beba0 The players' center, cached once per frame: the average position of the room's players that are no co-op +// babies (nor Tainted Forgotten's body, unless a ghost) and of the extra players. Netplay is offline, so every +// player is local. With none, the first player's position. +Vector PlayerManager::players_center_position(CenterCache cache) +{ + unsigned int frame = g_manager->framecount; + if (cache == CENTER_CACHED && frame == centerCacheFrame) return centerCache; + + Vector sum = vector_make(0, 0); + int count = 0; + auto player_add = [&](Entity_Player& player) { + sum.x += player.pos.x; + sum.y += player.pos.y; + count++; + }; + + for (Entity_Player* player : playerList) + { + bool isBody = player->playerType == PLAYER_THEFORGOTTEN_B && !player->isCoopGhost; + if (player->variant == PLAYER_VARIANT_PLAYER && !isBody) player_add(*player); + } + for (Entity_Player* player : extraPlayers) player_add(*player); + + centerCacheFrame = frame; + if (count < 1) centerCache = g_game->GetPlayer(0)->pos; + else centerCache = vector_make(sum.x / (float)count, sum.y / (float)count); + return centerCache; +} + // 009bb960 Starts the floor for every player and familiar, and forgets the floor's rewinds. void PlayerManager::trigger_level_start() { @@ -669,7 +803,6 @@ void PlayerManager::spawn_coop_baby_for_join(int) } void PlayerManager::Update() { reconstruction_missing("PlayerManager::Update 009bb5d0"); } void PlayerManager::trigger_room_clear() { reconstruction_missing("PlayerManager::trigger_room_clear 009bb840"); } -void PlayerManager::enter_level() { reconstruction_missing("PlayerManager::enter_level 009bba30"); } void PlayerManager::trigger_coop_baby_death(Entity_Player*) { reconstruction_missing("PlayerManager::trigger_coop_baby_death 009bc120"); @@ -678,10 +811,6 @@ Vector PlayerManager::find_safe_spawn_position(Vector) { reconstruction_missing("PlayerManager::find_safe_spawn_position 009bc280"); } -Vector PlayerManager::get_player_start_position(Entity_Player*, Vector) -{ - reconstruction_missing("PlayerManager::get_player_start_position 009bc690"); -} void PlayerManager::unlock_completion_mark(int) { reconstruction_missing("PlayerManager::unlock_completion_mark 0095a7b0"); diff --git a/src/player_manager.h b/src/player_manager.h index 97aba98..2263e69 100644 --- a/src/player_manager.h +++ b/src/player_manager.h @@ -26,6 +26,13 @@ enum HealthCheck HEALTH_CHECK_ALL }; +// Whether players_center_position may return the center it already found this frame. +enum CenterCache +{ + CENTER_FRESH, + CENTER_CACHED +}; + // A seat of the co-op join carousel the HUD draws: the controller joining, its character and how far it opened. struct CoopJoinSlot { @@ -54,9 +61,11 @@ public: std::array coopSlots{}; std::array colorControllers = {-1, -1, -1, -1}; std::array randomBabies{}; + Vector centerCache{}; RNG glitchBabyRng = PLAYER_RNG_UNSEEDED; RNG rng = PLAYER_RNG_UNSEEDED; int randomBabyCount = 0; + unsigned int centerCacheFrame = UINT32_MAX; bool isColorAssignEnabled = true; PlayerManager() = default; @@ -119,6 +128,7 @@ public: void trigger_coop_baby_death(Entity_Player* deadPlayer); static Vector find_safe_spawn_position(Vector position); static Vector get_player_start_position(Entity_Player* player, Vector position); + Vector players_center_position(CenterCache cache); static void unlock_completion_mark(int completionType); static void remove_coplayer_slot(int* hudSlots, Entity_Player* player); diff --git a/src/rail_manager.cpp b/src/rail_manager.cpp new file mode 100644 index 0000000..3ca6494 --- /dev/null +++ b/src/rail_manager.cpp @@ -0,0 +1,115 @@ +#include "rail_manager.h" +#include "entity.h" +#include "game.h" +#include "grid_entity.h" +#include "log.h" +#include "room.h" + +constexpr int BACKDROP_ASHPIT = 46; + +// The row and the columns where an L room's walls step in around its missing quarter. +constexpr int L_ROW = 7; +constexpr int L_LEFT_COLUMN = 13; +constexpr int L_RIGHT_COLUMN = 14; + +// The rectangle of walls around a room's floor: the grid's edges, or a narrow room's corridor. +struct RailWalls +{ + int bottom = 0; + int columnEnd = 0; + int columnStart = 0; + int left = 0; + int right = 0; + int rowEnd = 0; + int rowStart = 0; + int top = 0; +}; + +static bool is_narrow(RoomShape shape) +{ + return shape == ROOMSHAPE_IH || shape == ROOMSHAPE_IV || shape == ROOMSHAPE_IIV || shape == ROOMSHAPE_IIH; +} + +// 009e2830 Loads the rail sprite once, takes the mineshaft's or Ashpit's rails or the usual ones, clears the rails +// and lines the room's walls with bumpers: above and below each column first, then left and right of each row, an L +// room's walls stepping in around its missing quarter. +// The backdrop it checks for Ashpit is still the last room's, as LoadBackdropGraphics comes later in Room::Init. +void RailManager::init() +{ + Room& room = *g_game->room; + + if (!sprite.isLoaded) + { + sprite.Load("gfx/grid/grid_rail.anm2", GRAPHICS_DEFER); + sprite.Play(sprite.GetDefaultAnimationName()); + } + rails.fill(RAIL_NONE); + + if (g_game->HasAbandonedMineshaft() && g_game->currentDimensionIdx == 1) + sprite.ReplaceSpritesheet(0, "gfx/grid/grid_rails_mineshaft.png"); + else if (room.backdropType == BACKDROP_ASHPIT) + sprite.ReplaceSpritesheet(0, "gfx/grid/grid_rails_ashpit.png"); + else sprite.ReplaceSpritesheet(0, "gfx/grid/grid_rails.png"); + sprite.LoadGraphics(); + + int width = room.gridWidth; + int height = room.gridHeight; + RoomShape shape = room.descriptor && room.descriptor->data ? room.descriptor->data->shape : ROOMSHAPE_NULL; + RailWalls walls = {height - 1, width, 0, 0, width - 1, height - 1, 0, 0}; + + if (is_narrow(shape)) + { + LRoomTileDesc tiles = room.GetLRoomTileDesc(); + walls = {tiles.bottomRightAY + 1, tiles.bottomRightAX + 1, tiles.topLeftAX - 1, tiles.topLeftAX - 1, + tiles.bottomRightAX + 1, tiles.bottomRightAY + 1, tiles.topLeftAY - 1, tiles.topLeftAY - 1}; + } + for (int x = walls.columnStart; x < walls.columnEnd; x++) + { + int top = walls.top; + int bottom = walls.bottom; + + if ((shape == ROOMSHAPE_LTL && x <= L_LEFT_COLUMN) || (shape == ROOMSHAPE_LTR && x > L_RIGHT_COLUMN)) top = L_ROW; + if ((shape == ROOMSHAPE_LBL && x < L_LEFT_COLUMN) || (shape == ROOMSHAPE_LBR && x > L_RIGHT_COLUMN)) + bottom = L_ROW + 1; + rails[top * width + x] = RAIL_WALL_TOP; + rails[bottom * width + x] = RAIL_WALL_BOTTOM; + } + for (int y = walls.rowStart; y < walls.rowEnd; y++) + { + int left = walls.left; + int right = walls.right; + + if ((shape == ROOMSHAPE_LTL && y <= L_ROW) || (shape == ROOMSHAPE_LBL && y > L_ROW)) left = L_LEFT_COLUMN; + if ((shape == ROOMSHAPE_LTR && y <= L_ROW) || (shape == ROOMSHAPE_LBR && y > L_ROW)) right = L_RIGHT_COLUMN; + rails[y * width + left] = RAIL_WALL_LEFT; + rails[y * width + right] = RAIL_WALL_RIGHT; + } +} + +// 009e2f20 Draws each cell's rail by its piece's frame, but under pits, offset on screen. +void RailManager::Render(Vector offset) +{ + Room& room = *g_game->room; + sprite.SetFrame("rail", 0); + + for (int i = 0; i < room.gridHeight * room.gridWidth; i++) + { + uint8_t rail = rails[i]; + GridEntity* entity = room.gridEntities[i]; + if (rail & RAIL_HIDDEN || (entity && entity->type == GRID_PIT)) continue; + + if (sprite.animState.animData) + { + uint8_t piece = rail & (rail & RAIL_MINESHAFT ? RAIL_MINESHAFT_PIECE_MASK : RAIL_PIECE_MASK); + sprite.animState.SetFrameFloat((float)piece); + } + Vector screen = render_position_get(room.GetGridPosition(i), RENDER_SNAPPED); + sprite.Render({.position = vector_make(screen.x + offset.x, screen.y + offset.y)}); + } +} + +// 009e38a0 The point of a cell's rail nearest a minecart, for its rail following. +void RailManager::get_closest_rail_point() +{ + reconstruction_missing("RailManager::get_closest_rail_point 009e38a0"); +} diff --git a/src/rail_manager.h b/src/rail_manager.h new file mode 100644 index 0000000..21adf7e --- /dev/null +++ b/src/rail_manager.h @@ -0,0 +1,39 @@ +#pragma once + +#include "anm2.h" +#include "room_descriptor.h" +#include +#include + +// A rail cell's byte (Lua's RailType): the rail's piece in the low bits, a minecart riding it either way, the +// mineshaft's pieces, and the walls' bumpers. Cells with the top bit set draw nothing. +constexpr uint8_t RAIL_NONE = 0xff; +constexpr uint8_t RAIL_PIECE_MASK = 0x0f; +constexpr uint8_t RAIL_MINESHAFT_PIECE_MASK = 0x3f; +constexpr uint8_t RAIL_CART_BACKWARD = 0x10; +constexpr uint8_t RAIL_CART_FORWARD = 0x20; +constexpr uint8_t RAIL_MINESHAFT = 0x40; +constexpr uint8_t RAIL_HIDDEN = 0x80; +constexpr uint8_t RAIL_WALL_TOP = 0xa1; +constexpr uint8_t RAIL_WALL_BOTTOM = 0x91; +constexpr uint8_t RAIL_WALL_LEFT = 0xa0; +constexpr uint8_t RAIL_WALL_RIGHT = 0x90; + +// The rail pieces a minecart can start on. +constexpr uint8_t RAIL_HORIZONTAL = 0; +constexpr uint8_t RAIL_VERTICAL = 1; +constexpr uint8_t RAIL_END_UP = 9; +constexpr uint8_t RAIL_END_DOWN = 10; + +// Construction, copies and destruction (009e27c0) are the defaults. +// The rails of a room (Room's railManager, Lua's Room:GetRail): a rail piece byte per grid cell, the walls' bumpers +// around the floor, and the sprite each piece draws from by its frame. +struct RailManager +{ + std::array rails{}; + ANM2 sprite; + + void init(); + void Render(Vector offset); + void get_closest_rail_point(); +}; diff --git a/src/room.cpp b/src/room.cpp index b69f5d3..8b87ee8 100644 --- a/src/room.cpp +++ b/src/room.cpp @@ -1,10 +1,15 @@ #include "room.h" #include "entity_pickup.h" #include "entity_player.h" +#include "entity_effect.h" +#include "entity_factory.h" +#include "entity_npc.h" #include "game.h" +#include "grid_entity_door.h" #include "log.h" #include "lua_engine.h" #include "manager.h" +#include "room_render.h" #include "seeds.h" #include "texture_cache.h" #include @@ -15,21 +20,8 @@ extern "C" #include "lua.h" } -// The grid a room's shape lays out (REPENTOGON's LRoomTileDesc table at 00c35b80): each shape's first and second -// rectangle of floor cells, top left included and bottom right excluded. Only the L shapes' rectangles differ. -struct ShapeTiles -{ - int topLeftAX; - int topLeftAY; - int bottomRightAX; - int bottomRightAY; - int topLeftBX; - int topLeftBY; - int bottomRightBX; - int bottomRightBY; -}; - -constexpr ShapeTiles SHAPE_TILES[ROOMSHAPE_ANY] = { +// REPENTOGON's LRoomTileDesc table at 00c35b80, by shape. +constexpr LRoomTileDesc SHAPE_TILES[ROOMSHAPE_ANY] = { {1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 13, 7, 1, 1, 13, 7}, {1, 3, 13, 5, 1, 3, 13, 5}, {5, 1, 9, 7, 5, 1, 9, 7}, {1, 1, 13, 14, 1, 1, 13, 14}, {5, 1, 9, 14, 5, 1, 9, 14}, {1, 1, 26, 7, 1, 1, 26, 7}, {1, 3, 26, 5, 1, 3, 26, 5}, {1, 1, 26, 14, 1, 1, 26, 14}, @@ -66,9 +58,6 @@ constexpr std::array LIGHT_BLEND = {BLEND_EQUATION_ADD, B BLEND_FACTOR_ONE_MINUS_SRC_ALPHA}; constexpr unsigned int FILTER_LINEAR = 1; -// The color the poop cloud effect gives the screen. -constexpr ColorMod POOP_FX_COLOR = {{1, 1, 1, 3}, {0.7f, 0.1f, 0.9f, 1}, {0, 0, 0}}; - // The Ascent's golden floors and walls, and the pre-items seed's grey Flooded Caves. constexpr ColorMod ASCENT_COLOR = {{1, 1, 1, 1}, {1.2f, 1.2f, 1.2f, 0.6f}, {0.0764f, -0.0216f, -0.0884f}}; constexpr ColorMod GREY_COLOR = {{1, 1, 1, 1}, {1, 1, 1, -1}, {0, 0, 0}}; @@ -110,21 +99,8 @@ constexpr int WATER_SUBTYPE_DRY = 20; constexpr int WATER_SUBTYPE_FLOODED = 11; constexpr int WATER_SUBTYPE_DUMP = 10; -// The grid entity types Init counts or avoids. -constexpr int GRID_DECORATION = 1; -constexpr int GRID_ROCK_BLOCK = 3; -constexpr int GRID_ROCK_BOMB = 5; -constexpr int GRID_PIT = 7; -constexpr int GRID_POOP = 14; -constexpr int GRID_WALL = 15; -constexpr int GRID_ROCK_SUPERSECRET = 22; - // The grid path values: what an entity walking has left, and what blocks spawning. -constexpr int GRID_PATH_DECAY_FRAMES = 3; -constexpr int GRID_PATH_PERMANENT = 3999; constexpr int GRID_PATH_RESET = 900; -constexpr int GRID_PATH_BLOCKED = 900; -constexpr int GRID_PATH_DECAY_MAX = 100; constexpr int GRID_PATH_UNIT = 1000; constexpr int GRID_PATH_PIT = 3000; constexpr int GRID_PATH_PIT_LAST = 3999; @@ -139,6 +115,7 @@ constexpr uint32_t GRID_COLLISION_WALL = 4; constexpr int STAGE_HOME = 13; // A crawlspace's subtypes: Rotgut's two phases and the Beast's arena. +constexpr int DUNGEON_GIDEON = 1; constexpr int DUNGEON_ROTGUT = 2; constexpr int DUNGEON_ROTGUT_HEART = 3; constexpr int DUNGEON_BEAST = 4; @@ -168,6 +145,188 @@ constexpr int BOSS_ULTRA_GREED = 62; constexpr int BOSS_ROTGUT = 87; constexpr int BOSS_MOM_MAUSOLEUM = 89; +// The backdrops LoadBackdropGraphics picks beyond the stage's own (backdrops.xml ids), and what picks them: rooms off +// the map, Home's rooms by subtype, the bosses and stages with their own, and the Void's random ones. +constexpr int BACKDROP_UTERO = 11; +constexpr int BACKDROP_BLUE_WOMB = 13; +constexpr int BACKDROP_SHEOL = 14; +constexpr int BACKDROP_CATHEDRAL = 15; +constexpr int BACKDROP_CHEST = 17; +constexpr int BACKDROP_LIBRARY = 19; +constexpr int BACKDROP_SHOP = 20; +constexpr int BACKDROP_ISAAC = 21; +constexpr int BACKDROP_BARREN = 22; +constexpr int BACKDROP_SECRET = 23; +constexpr int BACKDROP_DICE = 24; +constexpr int BACKDROP_ARCADE = 25; +constexpr int BACKDROP_ERROR_ROOM = 26; +constexpr int BACKDROP_BLUE_WOMB_PASS = 27; +constexpr int BACKDROP_GREED_SHOP = 28; +constexpr int BACKDROP_DUNGEON = 29; +constexpr int BACKDROP_SACRIFICE = 30; +constexpr int BACKDROP_MAUSOLEUM = 33; +constexpr int BACKDROP_DOWNPOUR_ENTRANCE = 36; +constexpr int BACKDROP_MAUSOLEUM_ENTRANCE = 38; +constexpr int BACKDROP_MAUSOLEUM_HEART = 39; +constexpr int BACKDROP_MAUSOLEUM2 = 40; +constexpr int BACKDROP_MAUSOLEUM3 = 41; +constexpr int BACKDROP_MAUSOLEUM4 = 42; +constexpr int BACKDROP_CORPSE2 = 43; +constexpr int BACKDROP_ISAACS_BEDROOM = 49; +constexpr int BACKDROP_HALLWAY = 50; +constexpr int BACKDROP_MOMS_BEDROOM = 51; +constexpr int BACKDROP_CLOSET = 52; +constexpr int BACKDROP_DOGMA = 54; +constexpr int BACKDROP_DUNGEON_GIDEON = 55; +constexpr int BACKDROP_DUNGEON_ROTGUT = 56; +constexpr int BACKDROP_DUNGEON_BEAST = 57; +constexpr int BACKDROP_DARK_CLOSET = 60; +constexpr int BACKDROP_DEATHMATCH = 61; +constexpr int BACKDROP_LIL_PORTAL = 62; +constexpr int BACKDROP_WOMB = 10; +constexpr int ROOM_DEATHMATCH_IDX = -19; +constexpr int DIMENSION_DEATH_CERTIFICATE = 2; +constexpr int DARK_CLOSET_B_SUBTYPE = 33; +constexpr int HOME_ISAACS_BEDROOM = 0; +constexpr int HOME_MOMS_BEDROOM = 2; +constexpr int HOME_LIVING_ROOM = 3; +constexpr int HOME_DOGMA = 9; +constexpr int HOME_CLOSET_LEFT = 10; +constexpr int BOSS_MAUSOLEUM_HEART = 90; +constexpr int BOSS_VISAGE = 78; +constexpr int BOSS_RAINMAKER = 77; +constexpr int STAGE_DARK_ROOM_CHEST = 11; +constexpr int STAGE_THE_VOID = 12; +constexpr int STAGE_MAUSOLEUM_II = 8; +constexpr int STAGE_ID_LAST_CHAPTER = 12; +constexpr int STAGE_ID_SHEOL = 14; +constexpr int STAGE_ID_CHEST = 17; +constexpr int STAGE_ID_ULTRA_GREED = 24; +constexpr int STAGE_ID_ULTRA_GREED_EXIT = 25; +constexpr int STAGE_ID_VOID = 26; +constexpr int STAGE_ID_FIRST_ALT = 27; +constexpr int GREED_STAGE_ULTRA_GREED = 6; +constexpr int VOID_BACKDROPS = 17; +constexpr uint32_t DELETE_THIS_STAGES = 11; +constexpr uint32_t DELETE_THIS_STAGE_TYPES = 5; + +// The Beast's arena's bounds, wider than its grid. +constexpr float BEAST_ARENA_LEFT = -49.230774f; +constexpr float BEAST_ARENA_TOP = 72.30768f; +constexpr float BEAST_ARENA_RIGHT = 689.2308f; +constexpr float BEAST_ARENA_BOTTOM = 487.69232f; + +// The deal door's chance: the base, what the items, trinkets, wisps, kills and red heart damage add, how a recent deal +// cuts it, and Goat Head's certainty. Greed's deal doors open from its eleventh wave (twelfth in Greedier). +constexpr float DEAL_CHANCE_BASE = 0.01f; +constexpr float DEAL_CHANCE_PENTAGRAM = 0.11f; +constexpr float DEAL_CHANCE_BLACK_CANDLE = 0.15f; +constexpr float DEAL_CHANCE_SECOND_PENTAGRAM = 0.05f; +constexpr float DEAL_CHANCE_BELIAL = 0.125f; +constexpr float DEAL_CHANCE_REVELATIONS = 0.175f; +constexpr float DEAL_CHANCE_BUM_KILLED = 0.35f; +constexpr float DEAL_CHANCE_UNHURT_BOSS = 0.35f; +constexpr float DEAL_CHANCE_CONTRITION_BOSS = 0.15f; +constexpr float DEAL_CHANCE_UNHURT_FLOOR = 0.99f; +constexpr float DEAL_CHANCE_CONTRITION_FLOOR = 0.4f; +constexpr float DEAL_CHANCE_SHOPKEEPER_KILLED = 0.1f; +constexpr float DEAL_CHANCE_SAUSAGE = 0.069f; +constexpr float DEAL_CHANCE_PER_WISP = 0.1f; +constexpr float DEAL_CHANCE_GOAT_HEAD = 66.6f; +constexpr float DEAL_RECENT_SCALE = 0.25f; +constexpr float DEAL_LAST_SCALE = 0.5f; +constexpr uint32_t GREED_DEAL_WAVE = 11; +constexpr int COLLECTIBLE_PENTAGRAM = 51; +constexpr int COLLECTIBLE_BOOK_OF_BELIAL = 34; +constexpr int COLLECTIBLE_BOOK_OF_REVELATIONS = 78; +constexpr int COLLECTIBLE_GOAT_HEAD = 215; +constexpr int COLLECTIBLE_BLACK_CANDLE = 260; +constexpr int COLLECTIBLE_SATANIC_BIBLE = 292; +constexpr int COLLECTIBLE_EUCHARIST = 499; +constexpr int COLLECTIBLE_ACT_OF_CONTRITION = 601; +constexpr int COLLECTIBLE_SAUSAGE = 669; +constexpr int TRINKET_NUMBER_MAGNET = 174; +constexpr int LEVEL_STATE_BUM_KILLED = 0; +constexpr int LEVEL_STATE_SHOPKEEPER_KILLED = 6; + +// The doors of a cleared boss room: what unlocks them and the stages they open on, the secret exit kinds, the deal +// door's jingles and Greed's deal door slot, Mom's parts the Boss Rush door clears, and the run flags they set. +constexpr int ACHIEVEMENT_BLUE_WOMB = 234; +constexpr int ACHIEVEMENT_THE_VOID = 320; +constexpr int ACHIEVEMENT_SECRET_EXIT = 407; +constexpr int ACHIEVEMENT_STRANGE_DOOR = 635; +constexpr int STAGE_DEPTHS_II = 6; +constexpr int COLLECTIBLE_DUALITY = 498; +constexpr int TRINKET_ROSARY_BEAD = 7; +constexpr int TRINKET_STRANGE_KEY = 175; +constexpr int SOUND_ANGEL_DOOR_APPEAR = 23; +constexpr int SOUND_DEVIL_DOOR_APPEAR = 320; +constexpr int GREED_DEAL_DOOR_SLOT = 4; +constexpr int ENTITY_MOM = 45; +constexpr float MOM_DOOR_CLEARANCE = 50; +constexpr uint64_t GAME_STATE_ANGEL_DOOR_BITS = 1ull << 0; +constexpr uint64_t GAME_STATE_DEVILROOM_SPAWNED_BITS = 1ull << 5; +constexpr uint32_t LEVEL_STATE_VOID_DOOR_DISABLED = 1u << 21; + +// The dust a door throws as it appears: how many puffs at least, how fast and far, how they spin and how long they +// last. +constexpr int EFFECT_DUST_CLOUD = 59; +constexpr int DUST_MIN = 5; +constexpr float DUST_SPEED = 5; +constexpr float DUST_RADIUS = 20; +constexpr float DUST_SPIN_RANGE = 10; +constexpr float DUST_SPIN_MIN = 2; +constexpr uint32_t DUST_TIMEOUT_RANGE = 10; +constexpr int DUST_TIMEOUT_MIN = 30; + +// The Member Card's stairs down to the secret shop (a ladder back up from it), the Red Key's door outlines and the keys +// that count as it. +constexpr int COLLECTIBLE_MEMBER_CARD = 602; +constexpr int COLLECTIBLE_VOID = 477; +constexpr int CARD_CRACKED_KEY = 78; +constexpr int CARD_SOUL_OF_CAIN = 83; +constexpr int SECRET_SHOP_COLUMN = 10; +constexpr int EFFECT_SHOP_LADDER = 156; +constexpr int EFFECT_DOOR_OUTLINE = 154; +constexpr int SOUND_SHOP_STAIRS = 916; +constexpr int STAIRS_SECRET_SHOP = 2; +constexpr float DOOR_OUTLINE_OFFSET = 15; + +// The quest doors of the alternate path's second floors: the rooms holding them and the rooms they lead to. +constexpr int MIRROR_ROOM_SUBTYPE = 34; +constexpr int MINESHAFT_ROOM_SUBTYPE = 10; +constexpr int ROOM_MIRROR_IDX = -100; +constexpr int ROOM_MINESHAFT_IDX = -101; +constexpr int ACHIEVEMENT_MEGA_SATAN = 155; + +// The effects pressure plates and rain spawn, and a minecart enemy on its rail. +constexpr int EFFECT_SPAWNER = 120; +constexpr int EFFECT_RAIN_DROP = 135; +constexpr int MINECART_ENEMY = 10; +constexpr int MINECART_VERTICAL = 4; +constexpr float MINECART_SPEED = 0.2f; + +// The rain's spots: kept off the walls, where the light is bright enough, their ellipses' radii, and how fast a +// stopped rain fades. +constexpr float RAIN_MARGIN = 20; +constexpr float RAIN_LIGHT_MIN = 0.6f; +constexpr float RAIN_RADIUS_MIN = 20; +constexpr float RAIN_RADIUS_RANGE = 60; +constexpr float RAIN_FADE = 0.02f; +constexpr float RAIN_INTENSITY_MIN = 0.01f; +constexpr float RAIN_PI = 3.14f; +constexpr float QUARTER_TURN = 1.5707964f; +constexpr float DEGREES_TO_RADIANS = 0.017453292f; + +// The screen color: how much secret rooms wash it out, pitch black rooms brighten it and the Mines' lava tints it, +// and how fast it fades. +constexpr float SECRET_WASHOUT = 0.75f; +constexpr float PITCH_BLACK_BRIGHTNESS = 0.03f; +constexpr float LAVA_TINT = 0.4f; +constexpr float LAVA_CONTRAST = 0.2f; +constexpr float LAVA_AMOUNT = 0.45f; +constexpr float COLOR_MODIFIER_RATE = 0.015f; + // The collectibles, trinkets, seeds and challenges Room checks. constexpr int COLLECTIBLE_STOP_WATCH = 232; constexpr int COLLECTIBLE_HOURGLASS = 66; @@ -178,9 +337,7 @@ constexpr int COLLECTIBLE_ISAACS_TOMB = 701; constexpr int COLLECTIBLE_SANGUINE_BOND = 692; constexpr int COLLECTIBLE_CARD_READING = 660; constexpr int COLLECTIBLE_BROKEN_SHOVEL = 550; -constexpr int COLLECTIBLE_VADE_RETRO = 653; constexpr int COLLECTIBLE_ASTRAL_PROJECTION = 677; -constexpr int NULL_EFFECT_POOP_CLOUD = 64; constexpr int TRINKET_BROKEN_GLASSES = 187; constexpr int TRINKET_WICKED_CROWN = 161; constexpr int TRINKET_HOLY_CROWN = 155; @@ -191,7 +348,6 @@ constexpr int SEED_EFFECT_NO_LAST_BOSS_DOORS = 71; constexpr int SPECIAL_DAILY_SURPRISE_MINIBOSS = 17; constexpr int CHALLENGE_SPEED = 22; constexpr int CHALLENGE_DELETE_THIS = 45; -constexpr int CHALLENGE_SEEING_DOUBLE = 40; constexpr int ACHIEVEMENT_SHOP_LEVEL_2 = 151; constexpr int ACHIEVEMENT_SHOP_LEVEL_3 = 152; constexpr int ACHIEVEMENT_SHOP_LEVEL_4 = 153; @@ -207,8 +363,6 @@ constexpr uint32_t LEVEL_STATE_MINESHAFT_ESCAPE = 1u << 22; constexpr uint32_t LEVEL_STATE_SHOVEL_QUEST_TRIGGERED = 1u << 16; constexpr uint32_t LEVEL_STATE_BROKEN_WATCH_SLOW = 1u << 24; constexpr uint32_t LEVEL_STATE_BROKEN_WATCH_FAST = 1u << 25; -constexpr uint32_t LEVEL_STATE_GREED_MONSTRO_SPAWNED = 1u << 12; -constexpr uint32_t LEVEL_STATE_LEVEL_START_TRIGGERED = 1u << 19; // Init's ambient decoration: how many spawn at most, and how the second door chance raises them. constexpr int AMBIENT_FLIES = 15; @@ -220,8 +374,7 @@ constexpr int EMBER_COUNT = 10; constexpr float EMBER_HEIGHT = 100; constexpr float TREASURE_ITEM_SPACING = 40; -// The brief jingle a boss room roars on its first frame, and the time scales the watches and effects set. -constexpr int SOUND_BOSS_ROAR = 190; +// The time scales the watches and effects set. constexpr float TIME_SCALE_SLOW = 0.7f; constexpr float TIME_SCALE_FAST = 1.43f; constexpr float TIME_SCALE_STOP_WATCH = 0.9f; @@ -229,6 +382,11 @@ constexpr float TIME_SCALE_EASE_FRAMES = 90; constexpr float TIME_SCALE_EASE_DEPTH = 0.8f; constexpr float TIME_SCALE_EASE_MIN = 0.5f; constexpr float TIME_SCALE_PER_GFUEL = 0.1f; +constexpr float TIME_SCALE_STOP_WATCH_ROOM = 0.8f; +constexpr float TIME_SCALE_MIN = 0.02f; +constexpr float SUPER_HOT_SPEED = 4.2f; +constexpr float SUPER_HOT_SCALE_MAX = 1.75f; +constexpr uint32_t SEED_EFFECT_SUPER_HOT = 77; // PlayMusic's crossfade rates: the usual one, the slow one between the Downpour and its reversed track, and the instant one. constexpr float MUSIC_CROSSFADE = 0.08f; @@ -292,19 +450,24 @@ static bool is_backwards_path() return g_game->stage >= 1 && g_game->stage <= 6 && g_game->GetStateFlag(GAME_STATE_BACKWARDS_PATH); } +static bool is_challenge_or_daily() +{ + return g_game->challenge != 0 || g_game->dailyChallenge._id != 0; +} + +// An achievement unlocked, or every one in a debug or daily run being played. +static bool is_unlocked(int achievement) +{ + if (g_manager->persistentGameData.achievements[achievement]) return true; + return g_manager->state == MANAGER_STATE_GAME && (g_game->dailyChallenge._id != 0 || g_game->isDebug); +} + static bool is_curse_active(uint32_t curse) { uint32_t curses = Seeds::GetForcedCurses() | g_game->debugCurses | g_game->curses; return (~Seeds::GetPreventedCurses() & curses & curse) != 0; } -// Whether the room has an entity of a type and variant, as the original's type query finds. -static bool entities_any(EntityList& list, int type, int variant) -{ - return std::any_of(list.updateEL.begin(), list.updateEL.end(), - [&](Entity* entity) { return entity->IsType(type, variant, -1); }); -} - static void lua_garbage_collect(); // Spawns an entity of the room with no velocity or spawner. @@ -313,17 +476,11 @@ static Entity* entity_spawn(int type, int variant, Vector position, int subType, return g_game->Spawn({.position = position, .subType = subType, .type = type, .variant = variant, .seed = seed}); } -// A grid entity's type. Grid entities stay generated this round, so none exists to ask. -static int grid_type_get(GridEntity* entity) -{ - return reinterpret_cast(entity->_desc)->_type; -} - -// 007e9400 An empty room, its backdrops read (as a mod redirects backdrops.xml) and its render surface placed for the -// screen. The original also creates the render surfaces rooms draw through (init_room_render_surfaces 007ea630, -// file globals), which waits for Render's takeover. +// 007e9400 An empty room: the surfaces rooms draw through made, its backdrops read (as a mod redirects +// backdrops.xml) and its render surface placed for the screen. Room::Room() { + room_surfaces_init(); backdrop.LoadConfig(g_manager->modManager.TryRedirectPath("backdrops.xml")); renderSurfaceTopLeft = vector_make((g_screenWidth - 338) * 0.5f - 52, (g_screenHeight - 182) * 0.5f - 52); } @@ -419,7 +576,7 @@ void Room::Init(RoomConfig_Room& config, RoomDescriptor& roomDescriptor) roomType = (RoomType)roomDescriptor.data->type; bossId = 0; secondBossId = 0; - reconstruction_missing("Room::Init 007f2800: RailManager's init 009e2830 (RailManager has no layout yet)"); + railManager.init(); beastArena.init(); if (roomType == ROOM_BOSS) boss_ids_init(); @@ -462,8 +619,8 @@ void Room::Init(RoomConfig_Room& config, RoomDescriptor& roomDescriptor) make_walls(); init_dungeon_rock(); init_decorations(config); - for (GridEntity* entity : gridEntities) - if (entity) reconstruction_missing("Room::Init 007f2800: grid entities' post-init (GridEntity stays generated)"); + for (int i = 0; i < gridHeight * gridWidth; i++) + if (gridEntities[i]) gridEntities[i]->PostInit(); attach_minecarts(); if (spawnFlags.isHeretic || spawnFlags.isRaglich) reconstruction_missing("Room::Init 007f2800: the Heretic and Raglich fireplaces"); @@ -542,10 +699,11 @@ void Room::Init(RoomConfig_Room& config, RoomDescriptor& roomDescriptor) init_colors(); if (descriptor->flags & ROOM_DESCRIPTOR_FLAG_ROTGUT_CLEARED && bossId == BOSS_ROTGUT) bossId = 0; - reconstruction_missing("Room::Init 007f2800: the room's screen color (Room::get_color_modifier, Game::SetColorModifier)"); + color_modifier_apply(); init_mineshaft_colors(); update_bounds(false); camera = std::make_unique(*this); + for (Shockwave& wave : roomShockwaves) wave.duration = wave.frame; backdrop.load_details(); TextureCache::Purge(); lua_garbage_collect(); @@ -792,7 +950,13 @@ void Room::init_saved_grid() GridEntityDesc& saved = descriptor->savedGridEntities[i]; if (saved._type == 0) continue; - reconstruction_missing("Room::Init 007f2800: restoring a saved grid entity (GridEntity stays generated)"); + delete gridEntities[i]; + gridEntities[i] = CreateGridEntity((GridEntityType)saved._type, i); + if (gridEntities[i]) + { + gridEntities[i]->desc_load(saved); + gridEntities[i]->Init(saved._spawnSeed); + } if (saved._type == GRID_PIT) descriptor->pitsCount++; else if (saved._type == GRID_POOP) descriptor->poopCount++; } @@ -810,7 +974,8 @@ void Room::init_spawns(RoomConfig_Room& config) if (spawn.entries.empty()) continue; RoomEntry& entry = *spawn.PickEntry((float)seed * 2.3283062e-10f); - if (!descriptor->restrictedGridIndexes.contains(gridIndex)) SpawnEntry(gridIndex, entry, seed); + if (!descriptor->restrictedGridIndexes.contains(gridIndex)) + room_entry_spawn(*this, entry, {.gridIndex = gridIndex, .seed = seed}); } } @@ -882,20 +1047,33 @@ void Room::init_dungeon_rock() { dungeonRockIdx = (int)rng.RandomInt(gridHeight * gridWidth); GridEntity* entity = dungeonRockIdx < ROOM_GRID_CELLS ? gridEntities[dungeonRockIdx] : nullptr; - int type = entity ? grid_type_get(entity) : 0; + int type = entity ? entity->type : GRID_NULL; - bool isUnbreakable = type == GRID_WALL || type == GRID_ROCK_BLOCK || type == GRID_ROCK_SUPERSECRET || type == GRID_ROCK_BOMB; + bool isUnbreakable = type == GRID_WALL || type == GRID_ROCKB || type == GRID_ROCK_SS || type == GRID_ROCK_BOMB; if (!entity || isUnbreakable) dungeonRockIdx = -1; } } -// Spawns a grid entity of a type on a free cell from a seed. Grid entities stay generated this round. -static void grid_spawn(int type, int gridIndex) +// 007ebca0 Puts a new grid entity of a type and variant on a cell from a seed, replacing what stood there, when +// the cell is free: no collision for trapdoors, stairs, pressure plates and teleporters, an unclaimed path for the +// others. False when it is not or the type has no grid entity. +bool Room::SpawnGridEntity(int gridIndex, GridEntityType type, int variant, uint32_t seed, int varData) { if (gridIndex < 0 || gridIndex >= ROOM_GRID_CELLS) KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"SpawnGridEntity: Grid index invalid\n"); - reconstruction_missing(type == GRID_DECORATION ? "Room::Init 007f2800: decorations (GridEntity stays generated)" - : "Room::Init 007f2800: grid entities (GridEntity stays generated)"); + if ((uint32_t)gridIndex >= ROOM_GRID_CELLS) return false; + + bool isFlat = type == GRID_TRAPDOOR || type == GRID_STAIRS || type == GRID_PRESSURE_PLATE || type == GRID_TELEPORTER; + bool isFree = isFlat ? GetGridCollision(gridIndex) == GRID_COLLISION_NONE : gridPaths[gridIndex] <= GRID_PATH_RESET; + GridEntity* entity = isFree ? CreateGridEntity(type, gridIndex) : nullptr; + if (!entity) return false; + + delete gridEntities[gridIndex]; + gridEntities[gridIndex] = entity; + entity->variant = variant; + entity->varData = varData; + entity->Init(seed); + return true; } // A first visit's decorations: random props on free cells, more in big rooms, but not in Basement I's first room; @@ -930,9 +1108,7 @@ void Room::init_decorations(RoomConfig_Room& config) int gridIndex = GetRandomTileIndex(rng.Next()); if (gridEntities[gridIndex]) continue; - Random(); - if (gridIndex >= 0 && gridIndex < ROOM_GRID_CELLS && gridPaths[gridIndex] < GRID_PATH_BLOCKED) - grid_spawn(GRID_DECORATION, gridIndex); + SpawnGridEntity(gridIndex, GRID_DECORATION, 0, Random(), 0); attempt++; } } @@ -1336,12 +1512,18 @@ Vector Room::GetClampedPosition(Vector position, float margin) return GetClampedPositionImpl(position, margin, margin, margin, margin); } +// 0081fb20 The floor cells the room's shape lays out. +LRoomTileDesc Room::GetLRoomTileDesc() +{ + return SHAPE_TILES[descriptor->data->shape]; +} + // 0081f8b0 An L-shaped room's two floor rectangles in the world, or the room's rectangle twice. LRoomAreaDesc Room::GetLRoomAreaDesc() { if (!IsLShapedRoom()) return {topLeftPos, bottomRightPos, topLeftPos, bottomRightPos}; - const ShapeTiles& tiles = SHAPE_TILES[descriptor->data->shape]; + LRoomTileDesc tiles = GetLRoomTileDesc(); float half = GRID_CELL_SIZE / 2; Vector topLeftA = GetGridPosition(GetGridIndexByTile(tiles.topLeftAX, tiles.topLeftAY)); Vector bottomRightA = GetGridPosition(GetGridIndexByTile(tiles.bottomRightAX, tiles.bottomRightAY)); @@ -1433,7 +1615,7 @@ int Room::GetRandomTileIndex(uint32_t seed) { if (IsLShapedRoom()) reconstruction_missing("Room::GetRandomTileIndex 0081ecc0: L-shaped rooms (LRoomTileDesc)"); - const ShapeTiles& tiles = SHAPE_TILES[descriptor->data->shape]; + LRoomTileDesc tiles = GetLRoomTileDesc(); RNG rng = {seed, 1, 9, 29}; int column = (int)rng.RandomInt(tiles.bottomRightAX - tiles.topLeftAX) + tiles.topLeftAX; int row = (int)rng.RandomInt(tiles.bottomRightAY - tiles.topLeftAY) + tiles.topLeftAY; @@ -1458,7 +1640,7 @@ uint32_t Room::GetGridCollision(int gridIndex) { if (IsBeastDungeon()) return GRID_COLLISION_NONE; if (gridIndex < 0) return GRID_COLLISION_WALL; - if (gridEntities[gridIndex]) return (uint32_t)gridEntities[gridIndex]->_collisionClass; + if (gridEntities[gridIndex]) return (uint32_t)gridEntities[gridIndex]->collisionClass; int path = gridPaths[gridIndex]; if (path < GRID_PATH_UNIT) return GRID_COLLISION_NONE; @@ -1870,203 +2052,1303 @@ void Room::PlayMusic() } -// The first frame's work: a boss room's roar on the first visit (but Greed's first boss before it spawns), and the -// Myosotis pickups carried from the last floor into the floor's first room. -void Room::first_frame_update() +// The stage of the floor for its deals, an alternate floor counting one deeper. +static int deal_stage_get_unclamped() { - bool isGreedBossPending = is_greed() && g_game->stage == 7 && descriptor->data->subtype == 0 && - !(g_game->levelStateFlags & LEVEL_STATE_GREED_MONSTRO_SPAWNED); - if (roomType == ROOM_BOSS && descriptor->visitedCount == 1 && !isGreedBossPending && bossId != 0) - { - int sound = SOUND_BOSS_ROAR; - seed_fart_sound_override(&sound); - g_manager->sfxManager.Play(sound); - } - if (g_game->levelStateFlags & LEVEL_STATE_LEVEL_START_TRIGGERED) return; - g_game->levelStateFlags |= LEVEL_STATE_LEVEL_START_TRIGGERED; - if (!g_game->myosotisPickups.empty()) reconstruction_missing("Room::Update 00802980: the Myosotis pickups"); + bool isAltStage = g_game->stageType == STAGETYPE_REPENTANCE || g_game->stageType == STAGETYPE_REPENTANCE_B; + return (int)g_game->stage + (isAltStage ? 1 : 0); } -// 00802980 Runs the room for a frame: its first frame's extras, timers, the grid paths fading, removed grid entities, -// the entity list and effect layers, the floor sprite and the Beast's arena, temporary effects, the clear check with -// its doors, pressure plates and door transitions, and the ambient spawns, sounds and water. -// Only the start is reconstructed. Grid entities stay generated, so any in the room stops it. -void Room::Update() +// The stage a deal door last opened on, up to Home. +static int deal_stage_get() { - isUnknown7220 = false; - if (isInitialized && g_game->frameCount - enterFrame == 1) first_frame_update(); - if (genesisTimer >= 0) - { - if (genesisTimer == 0 && g_game->currentRoomIdx == ROOM_GENESIS_IDX) - reconstruction_missing("Room::Update 00802980: Genesis's items"); - genesisTimer--; - } - isExorcistActive = g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_VADE_RETRO, LAZARUS_SHARE_CHECK) != nullptr; - if (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_ASTRAL_PROJECTION)) - g_manager->musicManager.targetPitch = time_scale_update(); - if (!temporaryEffects.isDisabled && temporaryEffects.HasNullEffect(NULL_EFFECT_POOP_CLOUD)) fxLayers.AddPoopFx(POOP_FX_COLOR); - if (descriptor->gridIndex == ROOM_LIL_PORTAL_IDX) reconstruction_missing("Room::Update 00802980: the Lil Portal room"); - - bool isEnterFrame = isInitialized && g_game->frameCount == enterFrame; - bool isHasEntities = !entityList.updateEL.empty(); - if (isEnterFrame && isHasEntities && g_game->challenge == CHALLENGE_SEEING_DOUBLE) - reconstruction_missing("Room::Update 00802980: Seeing Double's doubled enemies"); - if (isEnterFrame && g_game->playerManager.GetGFuelCount() > 3 && isHasEntities) - reconstruction_missing("Room::Update 00802980: G-Fuel's champions"); - - if (waterLerpColorCountdown > 0) waterLerpColorCountdown--; - if (!pendingGridRemovals.empty()) - { - for (int gridIndex : pendingGridRemovals) - { - if (gridIndex < 0 || gridIndex >= gridWidth * gridHeight || !gridEntities[gridIndex]) continue; - delete gridEntities[gridIndex]; - gridEntities[gridIndex] = nullptr; - } - pendingGridRemovals.clear(); - } - for (int i = 0; i < gridWidth * gridHeight; i++) - if (gridEntities[i]) reconstruction_missing("Room::Update 00802980: grid entities' updates (GridEntity stays generated)"); - if (g_game->frameCount % GRID_PATH_DECAY_FRAMES == 0) grid_paths_decay(); - - bool isKeyPieceWatch = g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_BROKEN_SHOVEL, LAZARUS_SHARE_CHECK); - Room& current = *g_game->room; - if (isKeyPieceWatch && isInitialized && g_game->frameCount - enterFrame == 4 && current.roomType == ROOM_BOSSRUSH && - !(current.descriptor->flags & ROOM_DESCRIPTOR_FLAG_CHALLENGE_DONE)) - { - if (!entities_any(entityList, ENTITY_PICKUP, PICKUP_COLLECTIBLE)) g_game->ambush.StartChallenge(); - } - if ((roomType == ROOM_CHALLENGE || roomType == ROOM_BOSSRUSH) && g_game->ambush._isActive) g_game->ambush.Update(); - if (isCardAgainstHumanity) card_against_humanity_fill(); - - int bosses = GetAliveBossesCount(); - if (bosses < 1 && lastAliveBossCount > 0) - { - if (g_manager->netplayManager.is_online()) - { - std::string frame = "[Frame " + std::to_string(g_game->frameCount) + "] "; - KAGE_LogMessage(LOG_INFO, (uint8_t*)frame.c_str()); - } - KAGE_LogMessage(LOG_INFO, (uint8_t*)"[warn] last boss died without triggering the deathspawn.\n"); - } - lastAliveBossCount = bosses; - entityList.Update(UPDATE_NORMAL); - fxLayers.Update(PLAYER_FOLLOW_EASE); - reconstruction_missing("Room::Update 00802980: from the floor sprite's animation on (the clear check, doors, " - "pressure plates and ambient spawns)"); + return std::clamp(deal_stage_get_unclamped(), 0, STAGE_HOME); } -// The grid paths an entity left fade a step every few frames, back to 900 from a permanent mark, and the cells' -// timers count down. -void Room::grid_paths_decay() -{ - for (int i = 0; i < gridWidth * gridHeight; i++) - { - int path = gridPaths[i]; - int fade = path % GRID_PATH_UNIT; - - if (path == GRID_PATH_PERMANENT) gridPaths[i] = GRID_PATH_RESET; - else if (fade < GRID_PATH_BLOCKED) gridPaths[i] = path - std::min(fade, GRID_PATH_DECAY_MAX); - if (gridTimers[i] >= 1 && gridTimers[i] <= 99) gridTimers[i] = (int16_t)std::max(gridTimers[i] - 1, 0); - } -} - -// 0081e250 How dark the room's lighting is. Not reconstructed yet. -float Room::GetLightingAlpha() -{ - reconstruction_missing("Room::GetLightingAlpha 0081e250"); -} - -// 0080f200 Draws the room: its backdrop, water, lighting and shaders, grid entities and entities by depth, and the -// overlays. Not reconstructed yet. -void Room::Render() -{ - reconstruction_missing("Room::Render 0080f200"); -} - -// 007f92b0 The chance a devil or angel room door opens after the boss. Not reconstructed yet. +// 007f92b0 The chance the floor's last boss room opens a deal door: a base chance raised by the deal items and +// trinkets, the Satanic Bible's wisps, a bum killed and a shopkeeper killed, more without red heart damage on the +// floor (or in its boss room) unless Act of Contrition forgives it, cut after a recent deal. None once disabled, +// certain with Goat Head, Eucharist, Greed's later waves and the surprise miniboss daily. float Room::GetDevilRoomChance() { - reconstruction_missing("Room::GetDevilRoomChance 007f92b0"); -} + Game& game = *g_game; + PlayerManager& players = game.playerManager; + auto is_owned = [&](int collectible) { return players.FirstCollectibleOwner(collectible, LAZARUS_SHARE_CHECK); }; + float chance = DEAL_CHANCE_BASE; -// 00800500 Plays the room's ambient loops (water, wind, fire) at the volume its contents call for. Not reconstructed -// yet. -void Room::update_ambient_sounds() + if (is_owned(COLLECTIBLE_PENTAGRAM)) chance = DEAL_CHANCE_PENTAGRAM; + if (is_owned(COLLECTIBLE_BLACK_CANDLE)) chance += DEAL_CHANCE_BLACK_CANDLE; + if (players.GetNumCollectibles(COLLECTIBLE_PENTAGRAM) > 1) chance += DEAL_CHANCE_SECOND_PENTAGRAM; + if (is_owned(COLLECTIBLE_BOOK_OF_BELIAL) || is_owned(COLLECTIBLE_BOOK_OF_BELIAL_PASSIVE)) chance += DEAL_CHANCE_BELIAL; + if (is_owned(COLLECTIBLE_BOOK_OF_REVELATIONS)) chance += DEAL_CHANCE_REVELATIONS; + if (game.levelStateFlags & 1u << LEVEL_STATE_BUM_KILLED) chance += DEAL_CHANCE_BUM_KILLED; + + bool isBossRoom = game.lastBossRoomListIdx == game.GetRoomByIdx(game.currentRoomIdx)->listIndex; + if (!isBossRoom || !game.room->isRedHeartDamaged) chance += DEAL_CHANCE_UNHURT_BOSS; + else if (is_owned(COLLECTIBLE_ACT_OF_CONTRITION)) chance += DEAL_CHANCE_CONTRITION_BOSS; + if (!(game.levelStateFlags & 1u << LEVEL_STATE_REDHEART_DAMAGED)) chance += DEAL_CHANCE_UNHURT_FLOOR; + else if (is_owned(COLLECTIBLE_ACT_OF_CONTRITION)) chance += DEAL_CHANCE_CONTRITION_FLOOR; + if (game.levelStateFlags & 1u << LEVEL_STATE_SHOPKEEPER_KILLED) chance += DEAL_CHANCE_SHOPKEEPER_KILLED; + + constexpr float NUMBER_MAGNET_CHANCES[4] = {0, 0.1f, 0.15f, 0.2f}; + constexpr float ROSARY_BEAD_CHANCES[4] = {0, 0, 0.05f, 0.1f}; + if (Entity_Player* owner = players.FirstTrinketOwner(TRINKET_NUMBER_MAGNET)) + if (int multiplier = owner->GetTrinketMultiplier(TRINKET_NUMBER_MAGNET); multiplier >= 1 && multiplier <= 3) + chance += NUMBER_MAGNET_CHANCES[multiplier]; + if (Entity_Player* owner = players.FirstTrinketOwner(TRINKET_ROSARY_BEAD)) + if (int multiplier = owner->GetTrinketMultiplier(TRINKET_ROSARY_BEAD); multiplier >= 2 && multiplier <= 3) + chance += ROSARY_BEAD_CHANCES[multiplier]; + if (is_owned(COLLECTIBLE_SAUSAGE)) chance += DEAL_CHANCE_SAUSAGE; + + int bibleWisps = (int)std::ranges::count_if(game.room->entityList.wispEL, + [](Entity* wisp) { return wisp->subtype == COLLECTIBLE_SATANIC_BIBLE; }); + chance = (float)bibleWisps * DEAL_CHANCE_PER_WISP + chance; + if (game.lastDevilRoomStage != 0) + { + int sinceDeal = deal_stage_get_unclamped() - game.lastDevilRoomStage; + if (sinceDeal == 0 || sinceDeal == 1) chance *= DEAL_RECENT_SCALE; + else if (sinceDeal == 2) chance *= DEAL_LAST_SCALE; + } + if (game.isDevilRoomDisabled) chance = 0; + if (is_owned(COLLECTIBLE_GOAT_HEAD) || temporaryEffects.HasCollectibleEffect(COLLECTIBLE_GOAT_HEAD)) + chance = DEAL_CHANCE_GOAT_HEAD; + if (game.dailyChallenge._specialDailyId == SPECIAL_DAILY_SURPRISE_MINIBOSS && + !(game.gameStateFlags & GAME_STATE_SURPRISE_MINIBOSS_SEEN)) + chance = 1; + if (is_owned(COLLECTIBLE_EUCHARIST)) chance = 1; + uint32_t greedDealWave = GREED_DEAL_WAVE + (game.difficulty == DIFFICULTY_GREEDIER ? 1 : 0); + if (is_greed()) chance = (uint32_t)game.greedModeWave < greedDealWave ? 0 : 1; + return chance; +} +static bool is_narrow_room(Room& room) { - reconstruction_missing("Room::update_ambient_sounds 00800500"); + RoomShape shape = room.descriptor->data ? room.descriptor->data->shape : ROOMSHAPE_NULL; + return shape == ROOMSHAPE_IH || shape == ROOMSHAPE_IV || shape == ROOMSHAPE_IIV || shape == ROOMSHAPE_IIH; } -// 0080ea80 Draws the room's light and shadow layer. Not reconstructed yet. -void Room::render_lighting() +static bool is_beast_arena(RoomConfig_Room* config) { - reconstruction_missing("Room::render_lighting 0080ea80"); + return config && config->type == ROOM_DUNGEON && config->stageId == STAGE_ID_HOME; } -// 007f2390 Fits the room's bounds and floor on screen to its grid. -void Room::update_bounds(bool) +// 007f2390 The room's bounds in the world, around its first and last floor cells: those of the grid or a narrow +// room's corridor, or past the columns and rows of them that are only walls and doors. The Beast's arena has fixed +// bounds wider than its grid. +void Room::update_bounds(bool isFromGridSize) { - reconstruction_missing("Room::update_bounds 007f2390"); + if (is_beast_arena(descriptor->data)) + { + topLeftPos = vector_make(BEAST_ARENA_LEFT, BEAST_ARENA_TOP); + bottomRightPos = vector_make(BEAST_ARENA_RIGHT, BEAST_ARENA_BOTTOM); + return; + } + + LRoomTileDesc grid = {1, 1, gridWidth - 2, gridHeight - 2, 1, 1, gridWidth - 2, gridHeight - 2}; + LRoomTileDesc tiles = is_narrow_room(*this) ? GetLRoomTileDesc() : grid; + int left = tiles.topLeftAX; + int top = tiles.topLeftAY; + int right = tiles.bottomRightBX; + int bottom = tiles.bottomRightBY; + + if (!isFromGridSize) + { + std::vector isRowWall(gridHeight, true); + int lastColumn = right; + int lastRow = bottom; + + for (int column = left; column <= lastColumn; column++) + { + bool isColumnWall = true; + for (int row = top; row <= lastRow; row++) + { + int gridIndex = GetGridIndexByTile(column, row); + GridEntity* entity = gridIndex >= 0 ? gridEntities[gridIndex] : nullptr; + if (entity && (entity->type == GRID_WALL || entity->type == GRID_DOOR)) continue; + + isColumnWall = false; + isRowWall[row] = false; + } + if (!isColumnWall) + { + right = lastColumn; + continue; + } + if (column == left) left++; + if (right == lastColumn) right = column - 1; + } + for (int row = top; row <= lastRow; row++) + { + if (!isRowWall[row]) + { + bottom = lastRow; + continue; + } + if (row == top) top++; + if (bottom == lastRow) bottom = row - 1; + } + } + + float half = GRID_CELL_SIZE / 2; + Vector topLeft = GetGridPosition(GetGridIndexByTile(left, top)); + Vector bottomRight = GetGridPosition(GetGridIndexByTile(right, bottom)); + topLeftPos = vector_make(topLeft.x - half, topLeft.y - half); + bottomRightPos = vector_make(bottomRight.x + half, bottomRight.y + half); } -// 007f1380 Loads the backdrop and its graphics for the room's stage, type and flags. +// The backdrops of the rooms whose type picks their own, by room type, or 0 for the stage's. +static int backdrop_by_room_type(Room& room) +{ + RoomConfig_Room& config = *room.descriptor->data; + + switch (room.roomType) + { + case ROOM_SHOP: return g_game->currentRoomIdx == ROOM_SECRET_SHOP_IDX ? BACKDROP_SECRET : BACKDROP_SHOP; + case ROOM_ERROR: return BACKDROP_ERROR_ROOM; + case ROOM_SECRET: return BACKDROP_SECRET; + case ROOM_SUPERSECRET: return config.subtype; + case ROOM_ARCADE: return BACKDROP_ARCADE; + case ROOM_CURSE: + case ROOM_CHALLENGE: + case ROOM_DEVIL: + case ROOM_BOSSRUSH: + case ROOM_BLACK_MARKET: return BACKDROP_SHEOL; + case ROOM_LIBRARY: return BACKDROP_LIBRARY; + case ROOM_SACRIFICE: return BACKDROP_SACRIFICE; + case ROOM_ANGEL: return BACKDROP_CATHEDRAL; + case ROOM_DUNGEON: + if (config.subtype == DUNGEON_GIDEON) return BACKDROP_DUNGEON_GIDEON; + if (config.subtype == DUNGEON_ROTGUT || config.subtype == DUNGEON_ROTGUT_HEART) return BACKDROP_DUNGEON_ROTGUT; + return config.subtype == DUNGEON_BEAST ? BACKDROP_DUNGEON_BEAST : BACKDROP_DUNGEON; + case ROOM_ISAACS: return BACKDROP_ISAAC; + case ROOM_BARREN: return BACKDROP_BARREN; + case ROOM_CHEST: return BACKDROP_CHEST; + case ROOM_DICE: return BACKDROP_DICE; + case ROOM_PLANETARIUM: return BACKDROP_PLANETARIUM; + case ROOM_SECRET_EXIT: + if (config.subtype == SECRET_EXIT_DOWNPOUR) return BACKDROP_DOWNPOUR_ENTRANCE; + return config.subtype == SECRET_EXIT_MAUSOLEUM ? BACKDROP_MAUSOLEUM_ENTRANCE : BACKDROP_SECRET; + case ROOM_ULTRASECRET: return BACKDROP_HALLWAY; + default: return 0; + } +} + +// Home's backdrop by its room's subtype: the bedrooms, the hallway, the closet (its red room's B side) and Dogma's. +static int backdrop_home_get(RoomDescriptor& descriptor) +{ + int subtype = descriptor.data->subtype; + + if (subtype == HOME_ISAACS_BEDROOM) return BACKDROP_ISAACS_BEDROOM; + if (subtype == HOME_MOMS_BEDROOM) return BACKDROP_MOMS_BEDROOM; + if (subtype > HOME_DOGMA) return descriptor.flags & ROOM_DESCRIPTOR_FLAG_RED_ROOM ? BACKDROP_CLOSET_B : BACKDROP_CLOSET; + if (subtype == HOME_LIVING_ROOM && descriptor.flags & ROOM_DESCRIPTOR_FLAG_SACRIFICE_DONE) return BACKDROP_DOGMA; + return subtype == HOME_DOGMA ? BACKDROP_DOGMA : BACKDROP_HALLWAY; +} + +// The backdrop of a stage's room: Delete This's random stage, the Void's random backdrop, Home's rooms, Ultra Greed's +// shop, a devil treasure room, Mom's Heart's room in the Mausoleum, and the stage's own. The stage and stage type the effect +// layers show change with Delete This and the extra boss room. +static int backdrop_by_stage(Room& room, int& fxStage, int& stageType) +{ + Game& game = *g_game; + RoomDescriptor& descriptor = *room.descriptor; + int stage = (int)game.stage; + + if (game.currentRoomIdx == ROOM_EXTRA_BOSS_IDX) + { + Level::boss_count_adjust(stage, stageType); + fxStage = stage; + } + if (game.challenge == CHALLENGE_DELETE_THIS) + { + RNG rng = {game.dungeonPlacementSeed, 2, 7, 7}; + if ((uint32_t)stage - 1 < DELETE_THIS_STAGES) + { + stage = (int)rng.RandomInt(DELETE_THIS_STAGES) + 1; + fxStage = stage; + } + stageType = (int)rng.RandomInt(DELETE_THIS_STAGE_TYPES); + if (stageType == STAGETYPE_GREEDMODE) stageType = STAGETYPE_REPENTANCE; + } + + int stageId = RoomConfig::GetStageID(stage, stageType, ROOM_MODE_CURRENT); + if (stage == STAGE_THE_VOID && descriptor.data->stageId != 0) stageId = descriptor.data->stageId; + if (stageId == STAGE_ID_VOID) + { + RNG rng = {descriptor.decorationSeed, 1, 21, 20}; + return (int)rng.RandomInt(VOID_BACKDROPS) + 1; + } + if (stageId == STAGE_ID_HOME) return backdrop_home_get(descriptor); + + int backdropId = game.roomConfig.stages[stageId].backdrop; + bool isGreedBoss = (stageId == STAGE_ID_ULTRA_GREED || stageId == STAGE_ID_ULTRA_GREED_EXIT) && + descriptor.data->type == ROOM_BOSS && descriptor.listIndex == game.lastBossRoomListIdx; + + if (isGreedBoss) backdropId = BACKDROP_GREED_SHOP; + if (room.roomType == ROOM_TREASURE && descriptor.flags & ROOM_DESCRIPTOR_FLAG_DEVIL_TREASURE) return BACKDROP_SHEOL; + if (room.roomType == ROOM_BOSS && descriptor.data->subtype == BOSS_MAUSOLEUM_HEART) return BACKDROP_WOMB; + if (backdropId == BACKDROP_MAUSOLEUM && game.IsMausoleumHeartStage()) return BACKDROP_MAUSOLEUM_HEART; + return backdropId; +} + +// The Mausoleum's and Corpse's variants: Mausoleum's boss rooms, groups and alternates, the Corpse's alternates. +static int backdrop_variant_get(Room& room, int backdropId) +{ + RoomDescriptor& descriptor = *room.descriptor; + bool isEvenSeed = (descriptor.decorationSeed & 1) == 0; + + if (backdropId == BACKDROP_MAUSOLEUM) + { + if (room.bossId == BOSS_VISAGE || room.secondBossId == BOSS_VISAGE) return BACKDROP_MAUSOLEUM4; + if (descriptor.group >= 1) return BACKDROP_MAUSOLEUM3; + return isEvenSeed ? BACKDROP_MAUSOLEUM2 : backdropId; + } + if (backdropId != BACKDROP_CORPSE) return backdropId; + if (descriptor.data->type == ROOM_BOSS) + return descriptor.data->subtype == BOSS_ROTGUT ? BACKDROP_CORPSE2 : backdropId; + if (descriptor.flags & ROOM_DESCRIPTOR_FLAG_USE_ALTERNATE_BACKDROP) return BACKDROP_CORPSE3; + return isEvenSeed && descriptor.gridIndex != g_game->startingRoomIdx ? BACKDROP_CORPSE2 : backdropId; +} + +// The backdrop of the room: Mega Satan's, the off-map rooms', the room type's or the stage's, then the abandoned +// mineshaft's and the dark closet dimension's. +static int backdrop_get(Room& room, int& fxStage, int& stageType) +{ + Game& game = *g_game; + int backdropId = 0; + + if (room.bossId == BOSS_MEGA_SATAN) backdropId = BACKDROP_MEGA_SATAN; + else if (game.currentRoomIdx == ROOM_BLUE_WOMB_IDX) backdropId = BACKDROP_BLUE_WOMB_PASS; + else if (game.currentRoomIdx == ROOM_BLUE_ROOM_IDX) backdropId = BACKDROP_BLUE_WOMB; + else if (game.currentRoomIdx == ROOM_DEATHMATCH_IDX) backdropId = BACKDROP_DEATHMATCH; + else if (game.currentRoomIdx == ROOM_LIL_PORTAL_IDX) backdropId = BACKDROP_LIL_PORTAL; + else + { + backdropId = backdrop_by_room_type(room); + bool isOwn = backdropId != 0 || room.roomType == ROOM_SUPERSECRET; + backdropId = backdrop_variant_get(room, isOwn ? backdropId : backdrop_by_stage(room, fxStage, stageType)); + } + + if (game.HasAbandonedMineshaft() && game.currentDimensionIdx == 1 && + (backdropId == BACKDROP_MINES || backdropId == BACKDROP_ASHPIT)) + return backdropId == BACKDROP_MINES ? BACKDROP_MINES_SHAFT : BACKDROP_ASHPIT_SHAFT; + if (game.currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) + return room.descriptor->data->subtype == DARK_CLOSET_B_SUBTYPE ? BACKDROP_CLOSET_B : BACKDROP_DARK_CLOSET; + return backdropId; +} + +// The stage and stage type a Void room shows the effect layers of: those of the stage its layout comes from. +static void void_fx_stage_get(int stageId, int& fxStage, int& stageType) +{ + int stage = 0; + int type = 0; + + if (is_greed()) + { + if (stageId == STAGE_ID_ULTRA_GREED) stage = GREED_STAGE_ULTRA_GREED; + else if (stageId == STAGE_ID_ULTRA_GREED_EXIT) stage = GREED_STAGE_ULTRA_GREED + 1; + else if (stageId < STAGE_ID_FIRST_ALT) + { + if (stageId > STAGE_ID_LAST_CHAPTER) return; + stage = (stageId - 1) / 3 + 1; + type = (stageId - 1) % 3; + } + else + { + stage = (stageId - STAGE_ID_FIRST_ALT) / 2 + 1; + type = (stageId - STAGE_ID_FIRST_ALT) % 2 + STAGETYPE_REPENTANCE; + } + } + else if (stageId == 0) return; + else if (stageId == STAGE_ID_HOME) stage = STAGE_HOME; + else if (stageId < STAGE_ID_FIRST_ALT) + { + if (stageId > STAGE_ID_LAST_CHAPTER) + { + if (stageId == STAGE_ID_BLUE_WOMB) stage = STAGE_BLUE_WOMB; + else if (stageId >= STAGE_ID_SHEOL && stageId <= STAGE_ID_CHEST) + { + stage = (stageId - STAGE_ID_SHEOL) / 2 + STAGE_BLUE_WOMB + 1; + type = (stageId - STAGE_ID_SHEOL) % 2; + } + else if (stageId == STAGE_ID_VOID) stage = STAGE_THE_VOID; + else return; + } + else + { + stage = (stageId - 1) / 3 * 2 + 1; + type = (stageId - 1) % 3; + } + } + else + { + stage = (stageId - STAGE_ID_FIRST_ALT) / 2 * 2 + 1; + type = (stageId - STAGE_ID_FIRST_ALT) % 2 + STAGETYPE_REPENTANCE; + } + if (stage == 0) return; + fxStage = stage; + stageType = type; +} + +// The shading image of a room's shape, the Womb's own for the shapes it has one for, or the closet's by its side. +static std::string_view shading_path_get(Room& room) +{ + RoomConfig_Room& config = *room.descriptor->data; + bool isUtero = room.backdrop.backdropId == BACKDROP_UTERO; + + if (room.backdrop.backdropId == BACKDROP_CLOSET || room.backdrop.backdropId == BACKDROP_CLOSET_B) + return config.subtype == HOME_CLOSET_LEFT ? "gfx/backdrop/shading_closet_L.png" : "gfx/backdrop/shading_closet_R.png"; + + switch (config.shape) + { + case ROOMSHAPE_IH: return "gfx/backdrop/shading_ih.png"; + case ROOMSHAPE_IV: return "gfx/backdrop/shading_iv.png"; + case ROOMSHAPE_1x2: return isUtero ? "gfx/backdrop/shading_1x2_utero.png" : "gfx/backdrop/shading_1x2.png"; + case ROOMSHAPE_IIV: return "gfx/backdrop/shading_iiv.png"; + case ROOMSHAPE_2x1: return isUtero ? "gfx/backdrop/shading_2x1_utero.png" : "gfx/backdrop/shading_2x1.png"; + case ROOMSHAPE_IIH: return "gfx/backdrop/shading_iih.png"; + case ROOMSHAPE_2x2: return isUtero ? "gfx/backdrop/shading_2x2_utero.png" : "gfx/backdrop/shading_2x2.png"; + case ROOMSHAPE_LTL: return "gfx/backdrop/shading_ltl.png"; + case ROOMSHAPE_LTR: return "gfx/backdrop/shading_ltr.png"; + case ROOMSHAPE_LBL: return "gfx/backdrop/shading_lbl.png"; + case ROOMSHAPE_LBR: return "gfx/backdrop/shading_lbr.png"; + default: return isUtero ? "gfx/backdrop/shading_utero.png" : "gfx/backdrop/shading.png"; + } +} + +// Loads the shading of a backdrop with walls and no full image, and draws it once into the shading surface. +static void shading_load(Room& room) +{ + BackdropConfig& config = room.backdrop.configs[room.backdrop.backdropId]; + + roomSurfaces.shading.reset(); + if (!config.isFullImage && config.walls > 0) roomSurfaces.shading = Manager::LoadImage(shading_path_get(room)); + if (!roomSurfaces.shading) return; + + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + graphics.render_target_push(roomSurfaces.shadingSurface.get(), KAGE::Graphics::TARGET_OWN_SIZE, + KAGE::Graphics::PRESENT_FLUSH); + graphics.Clear(); + roomSurfaces.shading->Render(vector_make(0, 0), kcolor_rgba(1, 1, 1, 1)); + graphics.Present(KAGE::Graphics::PRESENT_FINISH); + graphics.render_target_pop(KAGE::Graphics::PRESENT_FLUSH); +} + +// 007f1380 Takes the room's backdrop with its seeds, loads the effect layers of its stage (none in crawlspaces or +// Mega Satan's room), the radial glow of Mega Satan's and Ultra Greed's rooms, and the shading of its shape. +// A Void room shows the effect layers of the stage its layout comes from. void Room::LoadBackdropGraphics() { - reconstruction_missing("Room::LoadBackdropGraphics 007f1380"); + Game& game = *g_game; + int fxStage = (int)game.stage; + int stageType = game.challenge == CHALLENGE_RED_REDEMPTION ? game.GetRoomStageType(game.currentRoomIdx) + : (int)game.stageType; + int backdropId = backdrop_get(*this, fxStage, stageType); + + backdrop.seed = descriptor->decorationSeed; + backdrop.rng = {descriptor->decorationSeed, 5, 9, 7}; + backdrop.Init((uint32_t)backdropId, false); + backdropType = (int)backdrop.backdropId; + if (fxStage == STAGE_THE_VOID) void_fx_stage_get(descriptor->data->stageId, fxStage, stageType); + + bool isNoLayers = roomType == ROOM_DUNGEON || backdropId == BACKDROP_MEGA_SATAN; + if (isNoLayers) fxLayers.clear(); + else fxLayers.LoadConfig(g_manager->modManager.TryRedirectPath("fxlayers.xml"), fxStage, stageType); + + if (backdropId == BACKDROP_MEGA_SATAN || (!isNoLayers && backdropId == BACKDROP_GREED_SHOP)) + { + satanRadialSprite.Load("gfx/Effect_SatanRadial.anm2", GRAPHICS_DEFER); + if (backdropId == BACKDROP_GREED_SHOP) satanRadialSprite.ReplaceSpritesheet(0, "gfx/satan_radial_ultragreed.png"); + satanRadialSprite.LoadGraphics(); + } + shading_load(*this); } -// 007eea90 Makes the door in a slot. Doors stay generated grid entities this round. -void Room::MakeDoor(int) +// 007f9df0 Opens Mega Satan's door at the top of the Chest's or Dark Room's starting room, once his door is unlocked +// (or in a debug or daily run being played), and not in a challenge or daily that leaves Mega Satan out. Forced, it +// opens anywhere a door fits. +bool Room::TrySpawnMegaSatanRoomDoor(bool isForce) { - reconstruction_missing("Room::MakeDoor 007eea90"); + Game& game = *g_game; + bool isMegaSatan = game.GetChallengeParams().isMegaSatan; + + if (!isForce) + { + bool isStart = game.currentRoomIdx == game.startingRoomIdx && game.stage == STAGE_DARK_ROOM_CHEST && + game.currentDimensionIdx == 0; + if (!isStart || !is_unlocked(ACHIEVEMENT_MEGA_SATAN)) return false; + if (is_challenge_or_daily() && !isMegaSatan) return false; + } + KAGE_LogMessage(LOG_INFO, (uint8_t*)"Spawning Mega Satan door\n"); + if (doors[DOOR_UP0]) + { + KAGE_LogMessage(LOG_INFO, (uint8_t*)"[warn] no space for Mega Satan door\n"); + return false; + } + MakeDoor(DOOR_UP0); + doors[DOOR_UP0]->targetRoomIdx = ROOM_MEGA_SATAN_IDX; + doors[DOOR_UP0]->SetRoomTypes(descriptor->data->type, ROOM_BOSS); + return true; } -// 0081ee20 Builds the walls around the grid. Walls stay generated grid entities this round. -void Room::make_walls() -{ - reconstruction_missing("Room::make_walls 0081ee20"); -} - -// 007ed310 Spawns a layout entry on a cell. -bool Room::SpawnEntry(int, RoomEntry&, uint32_t) -{ - reconstruction_missing("Room::SpawnEntry 007ed310"); -} - -// 007eff50 Restores the entities a past visit saved. -void Room::RestoreState() -{ - reconstruction_missing("Room::RestoreState 007eff50"); -} - -// 00822d60 Holds the entities a pressure plate's output releases. -void Room::hold_trigger_output_entities() -{ - reconstruction_missing("Room::hold_trigger_output_entities 00822d60"); -} - -// 007f9df0 Opens Mega Satan's door when the room should have it. -bool Room::TrySpawnMegaSatanRoomDoor(bool) -{ - reconstruction_missing("Room::TrySpawnMegaSatanRoomDoor 007f9df0"); -} - -// 008279d0 Opens the door of a quest room (the Mausoleum's, the photo door) when the room should have it. +// 008279d0 Opens the quest door of the alternate path's second floors: the Downpour's door to the Mirror (or the +// Dross's) and the Mines' door to the abandoned mineshaft, on the first quest door slot of their special rooms. bool Room::TrySpawnSpecialQuestDoor() { - reconstruction_missing("Room::TrySpawnSpecialQuestDoor 008279d0"); + Game& game = *g_game; + if (game.stageType != STAGETYPE_REPENTANCE && game.stageType != STAGETYPE_REPENTANCE_B) return false; + + bool isLabyrinth = is_curse_active(CURSE_OF_LABYRINTH); + bool isDownpourTwo = game.stage == 2 || (game.stage == 1 && isLabyrinth); + bool isMinesTwo = game.stage == 4 || (game.stage == 3 && isLabyrinth); + RoomConfig_Room& config = *descriptor->data; + int target = 0; + + if (isDownpourTwo && config.type == ROOM_DEFAULT && config.subtype == MIRROR_ROOM_SUBTYPE) target = ROOM_MIRROR_IDX; + else if (!isDownpourTwo && isMinesTwo && config.type == ROOM_DEFAULT && + (config.subtype == MINESHAFT_ROOM_SUBTYPE || config.subtype == MINESHAFT_ROOM_SUBTYPE + 1)) + target = ROOM_MINESHAFT_IDX; + if (target == 0) return false; + + int slot = std::countr_zero(config.questDoors); + if (slot >= DOOR_SLOT_COUNT || doors[slot]) return false; + + MakeDoor(slot); + doors[slot]->targetRoomIdx = target; + doors[slot]->SetRoomTypes(config.type, config.type); + return true; } -// 00823f50 Attaches the minecarts to their rails. +// 00822d60 Holds what spawned on a pressure plate's output cells until the plate fires: each enemy (or player in a +// versus match), bomb and free pickup on a cell of an output group becomes a spawner of the group. Held enemies stay +// out of the room on later visits. +void Room::hold_trigger_output_entities() +{ + std::array cellGroups; + bool isAnyOutput = false; + + cellGroups.fill(-1); + for (int group = 0; group < OUTPUT_GROUP_COUNT; group++) + for (int gridIndex : outputGroupGridIndices[group]) + { + isAnyOutput = true; + if (cellGroups[gridIndex] < 0) cellGroups[gridIndex] = (int8_t)group; + } + if (!isAnyOutput) return; + + g_game->room->isUnknown11f5 = false; + for (size_t i = 0; i < entityList.updateEL.size(); i++) + { + Entity& entity = *entityList.updateEL[i]; + int gridIndex = entity.spawnGridIndex; + if (gridIndex < 0 || cellGroups[gridIndex] < 0) continue; + + bool isFreePickup = entity.type == ENTITY_PICKUP && static_cast(entity).price == 0; + bool isEnemy = (g_game->deathmatchManager.is_active() && entity.type == ENTITY_PLAYER) || + (entity.type >= ENTITY_FIRST_ENEMY && entity.type < ENTITY_EFFECT); + if (!isFreePickup && !isEnemy && entity.type != ENTITY_BOMB) continue; + + if (isEnemy) descriptor->restrictedGridIndexes.insert(gridIndex); + hold_entity_in_spawner(entity, cellGroups[gridIndex]); + } +} + +// 00822fd0 Replaces an entity by a spawner effect holding its type, variant and subtype for an output group, no longer +// counting it as an enemy or boss. +Entity* Room::hold_entity_in_spawner(Entity& entity, int group) +{ + EntitySpawn spawn = {.position = entity.pos, .subType = entity.type, .type = ENTITY_EFFECT, + .variant = EFFECT_SPAWNER, .seed = entity.initSeed}; + auto* spawner = static_cast(game_spawn(spawn, POOL_OVERWRITE)); + + spawner->varData[0] = (uint32_t)entity.variant; + spawner->varData[1] = (uint32_t)entity.subtype; + spawner->state = group; + if (entity.CanShutDoors() && entity.type != ENTITY_DARK_ESAU) + { + entityList.enemyCount--; + if (entity.IsBoss()) entityList.bossCount--; + } + entity.Remove(); + return spawner; +} + +// The way a cart starts along a rail piece: none for a crossing or mineshaft piece, back or forward by its cart bits. +static int rail_cart_direction(uint8_t rail) +{ + if (rail == RAIL_NONE || rail & RAIL_MINESHAFT) return 0; + if (rail & RAIL_CART_BACKWARD) return -1; + return rail & RAIL_CART_FORWARD ? 1 : 0; +} + +// Sets a minecart enemy on a rail, rolling one way, turned upright on a vertical piece. +static void minecart_snap(Entity_NPC& cart, Vector railPosition, Vector railDirection) +{ + Room& room = *g_game->room; + + cart.velocity = railDirection; + cart.pos = railPosition; + cart.targetPosition = railPosition; + + int gridIndex = room.GetGridIndex(cart.pos); + uint8_t piece = gridIndex >= 0 && gridIndex < ROOM_GRID_CELLS ? room.railManager.rails[gridIndex] : RAIL_NONE; + uint8_t shape = piece & RAIL_PIECE_MASK; + bool isVertical = piece != RAIL_NONE && (shape == RAIL_VERTICAL || shape == RAIL_END_UP || shape == RAIL_END_DOWN); + cart.i1 = isVertical ? MINECART_VERTICAL : 0; + cart.update_move_direction_anim(); + cart.v2.x = MINECART_SPEED; +} + +// 00823f50 Puts the enemies spawned next to a rail with a cart on it into minecarts on that rail, the first neighbor +// above, below, left or right that has one. A minecart enemy itself snaps onto the nearest rail and rolls along it. void Room::attach_minecarts() { - reconstruction_missing("Room::attach_minecarts 00823f50"); + constexpr int NEIGHBORS[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}}; + + for (size_t i = 0; i < entityList.updateEL.size(); i++) + { + Entity& entity = *entityList.updateEL[i]; + bool isCart = entity.type == ENTITY_MINECART && entity.variant == MINECART_ENEMY; + bool isEnemy = (g_game->deathmatchManager.is_active() && entity.type == ENTITY_PLAYER) || + (entity.type >= ENTITY_FIRST_ENEMY && entity.type < ENTITY_EFFECT); + bool isRider = !(entity.type == ENTITY_MINECART && entity.variant == 0) && !entity.minecart; + if (!isEnemy || entity.spawnGridIndex < 0 || (!isRider && !isCart)) continue; + + int column = entity.spawnGridIndex % gridWidth; + int row = entity.spawnGridIndex / gridWidth; + for (const auto& [dx, dy] : NEIGHBORS) + { + int x = column + dx; + int y = row + dy; + if (x <= 0 || y <= 0 || x >= gridWidth - 1 || y >= gridHeight - 1) continue; + + int gridIndex = GetGridIndexByTile(x, y); + if (gridIndex < 0 || gridIndex >= ROOM_GRID_CELLS || railManager.rails[gridIndex] & RAIL_HIDDEN) continue; + + uint8_t rail = railManager.rails[gridIndex]; + int direction = rail_cart_direction(rail); + if (direction == 0 && !isCart) continue; + + Vector railDirection = vector_make(0, 0); + if (direction != 0 && (rail & RAIL_PIECE_MASK) == RAIL_HORIZONTAL) railDirection.x = (float)direction; + else if (direction != 0) railDirection.y = (float)direction; + Vector railPosition = GetGridPosition(gridIndex); + + if (!isCart) + { + entity.GiveMinecart(railPosition, railDirection); + break; + } + minecart_snap(static_cast(entity), railPosition, railDirection); + break; + } + } } -// 00824350 Starts the rain of the room's backdrop. +// 007eff50 Respawns the entities a past visit saved, then forgets them. A cleared Mausoleum II secret exit loses its +// inner walls and doors. +void Room::RestoreState() +{ + if (!descriptor->savedEntities.empty()) + reconstruction_missing("Room::RestoreState 007eff50: the saved entities (EntitySaveState has no layout yet)"); + descriptor->savedEntities.clear(); + + bool isOpenedExit = descriptor->gridIndex == ROOM_SECRET_EXIT_IDX && g_game->stage == STAGE_MAUSOLEUM_II && + descriptor->flags & ROOM_DESCRIPTOR_FLAG_CLEAR; + if (!isOpenedExit) return; + + for (int y = 1; y < gridHeight - 1; y++) + for (int x = 1; x < gridWidth - 1; x++) + { + int gridIndex = GetGridIndexByTile(x, y); + GridEntity* wall = gridIndex >= 0 ? gridEntities[gridIndex] : nullptr; + if (!wall || wall->type != GRID_WALL || wall->gridIndex >= ROOM_GRID_CELLS) continue; + + GridEntity* linked = gridEntities[wall->gridIndex]; + if (!linked || linked->type == GRID_DECORATION) continue; + + gridPaths[wall->gridIndex] = GRID_PATH_RESET; + gridEntities[wall->gridIndex] = nullptr; + delete linked; + } + for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) RemoveDoor(slot); +} + +// How bright the lighting layer is at a point of the room, the light rain falls in: none without the layer. +// Reading it needs the layer image's pixels, which the renderer does not keep. +static float fx_light_get(Room& room) +{ + for (const FXLayer& layer : room.fxLayers.layers) + if (room.fxLayers.isLoaded && layer.type == FX_LAYER_LIGHTING && !layer.tiles.empty()) + reconstruction_missing("Room::init_rain 00824350: the lighting layer's pixel (FUN_00995f40)"); + return 0; +} + +// 00824350 Starts the rain of a watery Downpour, Dross or flooded Corpse room: up to four spots it falls around (four +// in the Rainmaker's room until it is cleared), placed where the lighting is bright, picked from the decoration seed, +// then ten frames of it falling. void Room::init_rain() { - reconstruction_missing("Room::init_rain 00824350"); + numRainSpawners = 0; + rainIntensity = 1; + isRainStopped = false; + + int stageId = g_game->GetStageID(); + bool isRainy = stageId == STAGE_ID_DOWNPOUR || stageId == STAGE_ID_DROSS || backdropType == BACKDROP_CORPSE3; + if (waterAmount <= 0 || !isRainy) return; + + RNG rng = {descriptor->decorationSeed, 1, 11, 6}; + int spawners = 0; + if (bossId == BOSS_RAINMAKER) spawners = descriptor->flags & ROOM_DESCRIPTOR_FLAG_CLEAR ? 0 : RAIN_SPAWNER_COUNT; + else + { + uint32_t roll = rng.Next() % 1000; + spawners = (roll < 300 ? 1 : 0) + (roll < 100 ? 1 : 0) + (roll < 40 ? 1 : 0) + (roll < 10 ? 1 : 0); + } + + for (int attempt = 0; attempt < AMBIENT_RETRIES && spawners > 0; attempt++) + { + float top = topLeftPos.y + RAIN_MARGIN; + float y = (bottomRightPos.y - RAIN_MARGIN - top) * (float)rng.Next() * 2.3283062e-10f + top; + float left = topLeftPos.x + RAIN_MARGIN; + float x = (bottomRightPos.x - RAIN_MARGIN - left) * (float)rng.Next() * 2.3283062e-10f + left; + if (fx_light_get(*this) < RAIN_LIGHT_MIN) continue; + + float angle = (float)rng.Next() * 2.3283062e-10f * 360 * DEGREES_TO_RADIANS; + float cosine = std::cos(angle); + float sine = std::sin(angle); + float radiusA = (float)rng.Next() * 2.3283062e-10f * RAIN_RADIUS_RANGE + RAIN_RADIUS_MIN; + float quarterCos = std::cos(QUARTER_TURN); + float quarterSin = std::sin(QUARTER_TURN); + float radiusB = (float)rng.Next() * 2.3283062e-10f * RAIN_RADIUS_RANGE + RAIN_RADIUS_MIN; + + RainSpawner& spawner = rainSpawners[numRainSpawners++]; + spawner.position = vector_make(x, y); + spawner.axisA = vector_make(radiusA * cosine, radiusA * sine); + spawner.axisB = vector_make(radiusB * (quarterCos * cosine - quarterSin * sine), + radiusB * (quarterSin * cosine + quarterCos * sine)); + spawners--; + } + for (int i = 0; i < AMBIENT_RETRIES; i++) update_ambient_spawns(); +} + +// 00824800 Rains drops around the rain spots, a drop at a random point of each spot's ellipse that lies in the room, +// more often the faster time runs and the harder it rains. A stopped rain fades out. +void Room::update_ambient_spawns() +{ + if (numRainSpawners <= 0 || rainIntensity <= 0) return; + + if (isRainStopped) rainIntensity = std::max(rainIntensity - RAIN_FADE, 0.0f); + if (rainIntensity < RAIN_INTENSITY_MIN) + { + rainIntensity = 0; + return; + } + + int interval = (int)(1 / (GetTimeScale(nullptr) * rainIntensity)); + if (interval != 0 && g_game->frameCount % interval >= 1) return; + + for (int i = 0; i < numRainSpawners; i++) + { + RainSpawner& spawner = rainSpawners[i]; + float angle = random_unit() * RAIN_PI; + angle += angle; + float radius = random_unit(); + float along = std::cos(angle) * radius; + float across = std::sin(angle) * radius; + Vector position = vector_make(along * spawner.axisA.x + spawner.position.x + across * spawner.axisB.x, + along * spawner.axisA.y + spawner.position.y + across * spawner.axisB.y); + + bool isInside = false; + if (IsLShapedRoom()) + { + Vector clamped = GetClampedPositionImpl(position, 0, 0, 0, 0); + isInside = clamped.x == position.x && clamped.y == position.y; + } + else + isInside = topLeftPos.x + 0 <= position.x && position.x <= bottomRightPos.x - 0 && + topLeftPos.y + 0 <= position.y && position.y <= bottomRightPos.y - 0; + if (isInside) entity_spawn(ENTITY_EFFECT, EFFECT_RAIN_DROP, position, 0, Random())->Update(); + } +} + +// 007ea3e0 How fast time runs for an entity, or for the room without one: slowed by the Stop Watch, following the +// first player's speed with the Super Hot seed, plus a tenth per G-Fuel past the first. Astral Projection's effect +// slows the room and speeds up its owner. SPEED! and the Broken Watch's fast rooms run faster. +float Room::GetTimeScale(Entity* entity) +{ + Game& game = *g_game; + bool isPlayer = entity && entity->type == ENTITY_PLAYER; + float timeScale = 1; + + if (!isPlayer) + { + if (game.playerManager.FirstCollectibleOwner(COLLECTIBLE_STOP_WATCH, LAZARUS_SHARE_CHECK)) + timeScale = TIME_SCALE_STOP_WATCH_ROOM; + if (game.seedEffects.HasSeedEffect(SEED_EFFECT_SUPER_HOT)) + { + Vector velocity = game.GetPlayer(0)->velocity; + float speed = std::sqrt(velocity.y * velocity.y + velocity.x * velocity.x) / SUPER_HOT_SPEED; + timeScale = std::min(std::max(speed, TIME_SCALE_MIN), SUPER_HOT_SCALE_MAX); + } + } + timeScale += (float)std::max(game.playerManager.GetGFuelCount() - 1, 0) * TIME_SCALE_PER_GFUEL; + + if (TemporaryEffect* astral = temporaryEffects.GetCollectibleEffect(COLLECTIBLE_ASTRAL_PROJECTION)) + { + float ease = std::clamp(((float)astral->cooldown - 0) / TIME_SCALE_EASE_FRAMES, 0.0f, 1.0f); + if (!isPlayer) timeScale = std::max((1 - ease) * timeScale, TIME_SCALE_MIN); + else if (static_cast(entity)->HasCollectible(COLLECTIBLE_ASTRAL_PROJECTION)) + timeScale *= ease + 1; + } + if (game.challenge == CHALLENGE_SPEED || game.room->brokenWatchState == BROKEN_WATCH_FAST) timeScale *= TIME_SCALE_FAST; + return timeScale; +} + +// 00823370 The screen color the room calls for: its stage's, mostly washed out in secret rooms and the abandoned +// mineshaft, a little brighter when pitch black, and darkened by the Mines' lava as it cools. +ColorModState Room::get_color_modifier() +{ + const FXParams& params = fxLayers.fxParams; + ColorModState color = {params.roomColor._red, params.roomColor._green, params.roomColor._blue, + params.roomColor._alpha, params.brightness, params.contrast}; + + bool isMineshaft = g_game->HasAbandonedMineshaft() && g_game->currentDimensionIdx == 1; + if (roomType == ROOM_SECRET || roomType == ROOM_SUPERSECRET || roomType == ROOM_ULTRASECRET || isMineshaft) + { + color._red += (1 - color._red) * SECRET_WASHOUT; + color._brightness += (0 - color._brightness) * SECRET_WASHOUT; + color._green += (1 - color._green) * SECRET_WASHOUT; + color._blue += (1 - color._blue) * SECRET_WASHOUT; + color._contrast += (1 - color._contrast) * SECRET_WASHOUT; + color._amount += (0 - color._amount) * SECRET_WASHOUT; + } + if (descriptor->flags & ROOM_DESCRIPTOR_FLAG_PITCH_BLACK) color._brightness += PITCH_BLACK_BRIGHTNESS; + if (backdropType == BACKDROP_MINES && descriptor->flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER) + { + float darken = (float)descriptor->pitsCount / (float)((gridHeight - 2) * (gridWidth - 2)) * lavaIntensity; + color._red -= darken; + color._blue += darken * LAVA_TINT; + color._green += darken * LAVA_TINT; + color._contrast += darken * LAVA_CONTRAST; + color._amount -= darken * LAVA_AMOUNT; + } + return color; +} + +// 00823540 Fades the screen to the room's color, at once while the floor generates or a saved run starts. +void Room::color_modifier_apply() +{ + bool isLerp = !g_game->isLevelGenerating && !g_game->isStartingFromState; + g_game->SetColorModifier(get_color_modifier(), isLerp, COLOR_MODIFIER_RATE); +} + +// 007067c0 Sets the screen color to fade to, at a rate of the distance per frame, or at once. +void Game::SetColorModifier(const ColorModState& color, bool isLerp, float rate) +{ + targetColorModifier = color; + isColorModifierLerped = isLerp; + if (!isLerp) + { + currentColorModifier = targetColorModifier; + return; + } + + const ColorModState& target = targetColorModifier; + const ColorModState& current = currentColorModifier; + lerpColorModifier = {std::abs(target._red - current._red) * rate, std::abs(target._green - current._green) * rate, + std::abs(target._blue - current._blue) * rate, std::abs(target._amount - current._amount) * rate, + std::abs(target._brightness - current._brightness) * rate, + std::abs(target._contrast - current._contrast) * rate}; +} + +// Which door's dust door_dust_spawn throws: the secret exit's, thrown straight out and spinning one way or the other, +// or a deal door's, thrown across and spinning at random speeds. +enum DustStyle +{ + DUST_SECRET_EXIT, + DUST_DEAL +}; + +// What door_dust_spawn throws out of a door: its style and the subtype each puff takes, or 1 for the first only. +struct DoorDust +{ + DustStyle style = DUST_SECRET_EXIT; + int subType = 0; + bool isFirstMarked = false; +}; + +// Five to eight puffs of dust thrown out of a door as it appears, spread around it and spinning away from it. +static void door_dust_spawn(Room& room, GridEntity_Door& door, const DoorDust& dust) +{ + Vector direction{}; + Isaac::GetAxisAlignedUnitVectorFromDir(&direction, door.slot & 3); + Vector out = vector_make(-direction.x, -direction.y); + Vector across = vector_make(out.x * std::cos(QUARTER_TURN) - out.y * std::sin(QUARTER_TURN), + out.x * std::sin(QUARTER_TURN) + out.y * std::cos(QUARTER_TURN)); + Vector doorPosition = room.GetGridPosition(door.gridIndex); + bool isDeal = dust.style == DUST_DEAL; + int count = (int)(Random() & 3) + DUST_MIN; + + for (int i = 0; i < count; i++) + { + uint32_t seed = Random(); + float speed = random_unit() * (isDeal ? DUST_SPEED : 1); + float side = random_unit(); + side = side + side - 1; + Vector velocity = isDeal ? vector_make(side * out.y + out.x * speed, side * -out.x + out.y * speed) + : vector_make(speed * out.x * DUST_SPEED + across.x * side, + speed * out.y * DUST_SPEED + across.y * side); + float angle = random_unit() * RAIN_PI; + angle += angle; + float radius = random_unit() * (isDeal ? DUST_RADIUS : 1); + float scale = isDeal ? 1 : DUST_RADIUS; + Vector position = vector_make(std::cos(angle) * radius * scale + doorPosition.x, + std::sin(angle) * radius * scale + doorPosition.y); + int subType = dust.isFirstMarked ? (i == 0 ? 1 : 0) : dust.subType; + + EntitySpawn spawn = {.position = position, .velocity = velocity, .subType = subType, .type = ENTITY_EFFECT, + .variant = EFFECT_DUST_CLOUD, .seed = seed}; + auto* puff = static_cast(game_spawn(spawn, POOL_OVERWRITE)); + Vector offset = vector_make(puff->pos.x - doorPosition.x, puff->pos.y - doorPosition.y); + bool isBehind = isDeal ? offset.x * out.y + offset.y * -out.x < 0 : offset.x * out.x + offset.y * out.y < 0; + float spin = random_unit() * DUST_SPIN_RANGE + DUST_SPIN_MIN; + // The secret exit's spin is only ever 1 or -1, its random speed lost in the original. + if (!isDeal) puff->rotation = spin * (float)isBehind == 0 ? 1.0f : -1.0f; + else puff->rotation = spin * (isBehind ? -1.0f : 1.0f); + puff->timeout = (int)(Random() % DUST_TIMEOUT_RANGE) + DUST_TIMEOUT_MIN; + puff->lifespan = puff->timeout; + puff->Update(); + } +} + +// The first door slot from start on, wrapping around, where the layout has a door and none stands. The original +// falls back on the last slot it tried when none fits, as here. +static int free_door_slot_get(Room& room, int start) +{ + int slot = start; + for (int i = 0; i < DOOR_SLOT_COUNT; i++) + { + slot = (start + i) & (DOOR_SLOT_COUNT - 1); + if (room.descriptor->data->doors & 1u << slot && !room.doors[slot]) break; + } + return slot; +} + +// The slot a special door opens on: back where the players came from that room, or a free slot from the decoration +// seed. +static int special_door_slot_get(Room& room, int fromRoomIdx) +{ + Game& game = *g_game; + if (game.lastRoomIdx == fromRoomIdx && game.enterDoor >= 0 && !room.doors[game.enterDoor]) return game.enterDoor; + + RNG rng = {room.descriptor->decorationSeed, 1, 11, 16}; + return free_door_slot_get(room, (int)(rng.Next() & (DOOR_SLOT_COUNT - 1))); +} + +// A door in a slot, made when there is none, leading to a room off the map. +static GridEntity_Door& special_door_make(Room& room, int slot, int targetRoomIdx) +{ + if (!room.doors[slot]) room.MakeDoor(slot); + room.doors[slot]->targetRoomIdx = targetRoomIdx; + return *room.doors[slot]; +} + +static bool is_door_to(Room& room, int targetRoomIdx) +{ + return std::ranges::any_of(room.doors, [&](GridEntity_Door* door) { return door && door->targetRoomIdx == targetRoomIdx; }); +} + +static int labyrinth_stage_get() +{ + return (int)g_game->stage + (is_curse_active(CURSE_OF_LABYRINTH) ? 1 : 0); +} + +static bool is_last_boss_room() +{ + return g_game->GetRoomByIdx(g_game->currentRoomIdx)->listIndex == g_game->lastBossRoomListIdx; +} + +// Whether the run is past the floors where the boss rooms open their doors to the path: Mom's heart killed before the +// Ascent, or on the way back up. +static bool is_path_closed(Room& room) +{ + Game& game = *g_game; + bool isMomsHeartRoom = room.roomType == ROOM_BOSS && room.descriptor->data->subtype == BOSS_MOM_MAUSOLEUM; + + return (isMomsHeartRoom && game.IsPreAscent()) || is_backwards_path(); +} + +// 007f7a40 Opens a secret exit: the strange door at the top of Depths II's starting room once it is unlocked (outside +// challenges and dailies, or on the Home path), or a door to the alternate path from the floor's last boss room, which +// a challenge on that path opens outright. Animated, dust flies out of it. +bool Room::TrySpawnSecretExit(bool isAnimate, bool isForce) +{ + Game& game = *g_game; + if (!isForce && (game.challenge == CHALLENGE_RED_REDEMPTION || is_path_closed(*this))) return false; + + ChallengeParam& params = game.GetChallengeParams(); + bool isPathUnlocked = params.pathType == PATH_TYPE_HOME || + (is_unlocked(ACHIEVEMENT_STRANGE_DOOR) && !is_challenge_or_daily()); + bool isDepthsTwo = labyrinth_stage_get() == STAGE_DEPTHS_II; + bool isAltStage = game.stageType == STAGETYPE_REPENTANCE || game.stageType == STAGETYPE_REPENTANCE_B; + + if (isPathUnlocked && isDepthsTwo && game.currentRoomIdx == game.startingRoomIdx && !isAltStage) + { + if (doors[DOOR_UP0]) return false; + MakeDoor(DOOR_UP0); + RoomDescriptor* exit = game.get_secret_exit_room(SECRET_EXIT_MAUSOLEUM); + doors[DOOR_UP0]->targetRoomIdx = ROOM_SECRET_EXIT_IDX; + doors[DOOR_UP0]->SetRoomTypes(descriptor->data->type, exit->data->type); + return true; + } + if (!isForce && !is_last_boss_room()) return false; + + ChallengeParam& challenge = game.GetChallengeParams(); + bool isAllowed = (!is_challenge_or_daily() || challenge.pathType == PATH_TYPE_REPENTANCE) && + is_unlocked(ACHIEVEMENT_SECRET_EXIT); + if (!isForce && !isAllowed) return false; + + int kind = game.get_secret_exit_kind(); + if (kind == 0 || (!isForce && kind == SECRET_EXIT_MOMS_HEART && game.IsMausoleumHeartStage())) return false; + + // Without a free slot away from the neighbours, the original takes the slot it started from, as here. + RNG rng = {descriptor->spawnSeed, 2, 9, 15}; + int start = (int)(rng.Next() & (DOOR_SLOT_COUNT - 1)); + int slot = start; + for (int i = 0; i < DOOR_SLOT_COUNT; i++, slot = (slot + 1) & (DOOR_SLOT_COUNT - 1)) + { + bool isNeighbor = descriptor->allowedDoors & 1u << slot; + if (descriptor->data->doors & 1u << slot && !doors[slot] && !isNeighbor) break; + } + + RoomDescriptor* exit = game.get_secret_exit_room(kind); + GridEntity_Door& door = special_door_make(*this, slot, ROOM_SECRET_EXIT_IDX); + door.SetRoomTypes(ROOM_DEFAULT, exit->data->type); + if (challenge.pathType == PATH_TYPE_REPENTANCE && door.variant != DOOR_UNLOCKED && + door.get_secret_exit_kind() != SECRET_EXIT_MOMS_HEART) + { + bool isKeyLocked = door.variant == DOOR_LOCKED || door.variant == DOOR_LOCKED_BARRED || + door.variant == DOOR_LOCKED_DOUBLE; + door.TryUnlock(*game.GetPlayer(0), true); + if (!isKeyLocked) + { + door.Open(); + door.TryBlowOpen(false, nullptr); + } + } + if (isAnimate) door_dust_spawn(*this, door, {.style = DUST_SECRET_EXIT}); + return true; +} + +static void deal_jingle_play(int sound) +{ + seed_fart_sound_override(&sound); + g_manager->sfxManager.Play(sound); +} + +// The slot of the deal door, from the decoration seed (the fourth in Greed): first one free whose opposite side the +// deal room has a door on, else any free one, or none. +static int deal_door_slot_get(Room& room, RoomConfig_Room& dealRoom) +{ + RNG rng = {room.descriptor->decorationSeed, 2, 5, 21}; + int start = (int)(rng.Next() & (DOOR_SLOT_COUNT - 1)); + if (is_greed()) start = GREED_DEAL_DOOR_SLOT; + + auto is_free = [&](int slot) { return room.descriptor->data->doors & 1u << slot && !room.doors[slot]; }; + for (int i = 0; i < DOOR_SLOT_COUNT; i++) + { + int slot = (i + start) & (DOOR_SLOT_COUNT - 1); + int opposite = (slot + 2) & 3; + if (is_free(slot) && dealRoom.doors & 1u << opposite) return slot; + } + for (int i = 0; i < DOOR_SLOT_COUNT; i++) + if (int slot = (start + i) & (DOOR_SLOT_COUNT - 1); is_free(slot)) return slot; + return -1; +} + +// 007f83b0 Opens the deal door of the floor's last boss room when a deal room may spawn and its chance rolls (the +// roll keeps the floor's generator as it is): Duality's two doors when the deal room is not picked yet, else the deal +// room the floor picks, on the slot the players came back through or a free one. Animated, it plays its jingle and +// throws dust. The floor's deal generator steps on after. +bool Room::TrySpawnDevilRoomDoor(bool isAnimate, bool isForce) +{ + Game& game = *g_game; + if (!isForce && (!game.CanSpawnDevilRoom() || !is_last_boss_room())) return false; + + float chance = GetDevilRoomChance(); + if (!isForce) + { + RNG roll = game.devilAngelRoomRNG; + roll._shift1 = 2; + roll._shift2 = 21; + roll._shift3 = 9; + if (chance <= (float)roll.Next() * 2.3283062e-10f && chance < 1) + { + game.isDevilRoomDisabled = true; + return false; + } + } + + // Out of the three dimensions, the original reads a blank descriptor as the deal room, as here. + RoomDescriptor blank; + bool isDimension = (uint32_t)game.currentDimensionIdx < DIMENSION_COUNT; + RoomDescriptor& devilRoom = isDimension ? game.roomList[ROOM_MAP_CELLS] : blank; + bool isDuality = game.playerManager.FirstCollectibleOwner(COLLECTIBLE_DUALITY, LAZARUS_SHARE_CHECK); + if (isDuality && !devilRoom.data) + { + RNG rng = {descriptor->decorationSeed, 2, 5, 21}; + int start = (int)rng.RandomInt(DOOR_SLOT_COUNT); + std::vector freeSlots; + for (int i = 0; i < DOOR_SLOT_COUNT; i++) + { + int slot = (start + i) & (DOOR_SLOT_COUNT - 1); + if (descriptor->data->doors & 1u << slot && !doors[slot]) freeSlots.push_back(slot); + } + if (freeSlots.size() > 1) + { + RNG::Shuffle(&rng, freeSlots.data(), freeSlots.data() + freeSlots.size()); + bool isAngelPlaced = false; + for (int i = 0; i < 2; i++) + { + int slot = freeSlots[i]; + if (!doors[slot]) MakeDoor(slot); + + bool isAngel = !isAngelPlaced && (i == 1 || game.playerManager.AnyoneHasTrinket(TRINKET_ROSARY_BEAD)); + isAngelPlaced = isAngelPlaced || isAngel; + doors[slot]->SetRoomTypes(ROOM_DEFAULT, isAngel ? ROOM_ANGEL : ROOM_DEVIL); + doors[slot]->targetRoomIdx = ROOM_DEVIL_IDX; + doors[slot]->Open(); + if (isAnimate) door_dust_spawn(*this, *doors[slot], {.style = DUST_DEAL, .isFirstMarked = true}); + } + if (isAnimate) + { + deal_jingle_play(SOUND_DEVIL_DOOR_APPEAR); + deal_jingle_play(SOUND_ANGEL_DOOR_APPEAR); + } + game.lastDevilRoomStage = deal_stage_get(); + return true; + } + } + + game.InitializeDevilAngelRoom(game.playerManager.AnyoneHasTrinket(TRINKET_ROSARY_BEAD), false); + int slot = game.enterDoor; + bool isBackDoor = game.lastRoomIdx == ROOM_DEVIL_IDX && slot >= 0 && descriptor->data->doors & 1u << slot && + !doors[slot]; + if (!isBackDoor) slot = deal_door_slot_get(*this, *devilRoom.data); + if (slot < 0) return false; + + int type = devilRoom.data->type; + if (type == ROOM_DEVIL) game.gameStateFlags |= GAME_STATE_DEVILROOM_SPAWNED_BITS; + else if (type == ROOM_ANGEL) game.gameStateFlags |= GAME_STATE_ANGEL_DOOR_BITS; + + if (!doors[slot]) MakeDoor(slot); + doors[slot]->SetRoomTypes(ROOM_DEFAULT, type); + doors[slot]->targetRoomIdx = ROOM_DEVIL_IDX; + doors[slot]->Open(); + game.lastDevilRoomStage = deal_stage_get(); + if (isAnimate) + { + deal_jingle_play(type == ROOM_DEVIL ? SOUND_DEVIL_DOOR_APPEAR : SOUND_ANGEL_DOOR_APPEAR); + door_dust_spawn(*this, *doors[slot], {.style = DUST_DEAL, .subType = type == ROOM_DEVIL ? 1 : 0}); + } + game.devilAngelRoomRNG.Next(); + return true; +} + +// 007f9960 Opens the Boss Rush door in Mom's room (Depths II) cleared within the par time, or anytime with Mom's +// Shovel, once: Mom's leftover parts by the door go away when the time did not count. +bool Room::TrySpawnBossRushDoor(bool isIgnoreTime, bool isForce) +{ + Game& game = *g_game; + bool isAllowed = game.challenge != CHALLENGE_RED_REDEMPTION && !is_path_closed(*this) && + game.currentDimensionIdx == 0 && is_last_boss_room() && !game.IsMausoleumHeartStage(); + if (!isForce && !isAllowed) return false; + if (!isForce && labyrinth_stage_get() != STAGE_DEPTHS_II) return false; + if (is_door_to(*this, ROOM_BOSSRUSH_IDX)) return false; + + if (game.playerManager.FirstCollectibleOwner(COLLECTIBLE_BROKEN_SHOVEL, LAZARUS_SHARE_CHECK)) isIgnoreTime = true; + log_printf(LOG_INFO, "Mom clear time: %d\n", game.timeCounter); + log_printf(LOG_INFO, "Par time: %d\n", game.bossRushParTime); + if (game.timeCounter > game.bossRushParTime && !isIgnoreTime && !isForce) + { + KAGE_LogMessage(LOG_INFO, (uint8_t*)"Did not meet par time, did not spawn boss rush door.\n"); + return false; + } + + KAGE_LogMessage(LOG_INFO, (uint8_t*)"Spawning boss rush door\n"); + int slot = special_door_slot_get(*this, ROOM_BOSSRUSH_IDX); + if (!doors[slot]) MakeDoor(slot); + doors[slot]->SetRoomTypes(descriptor->data->type, ROOM_BOSSRUSH); + doors[slot]->targetRoomIdx = ROOM_BOSSRUSH_IDX; + doors[slot]->Open(); + doors[slot]->SpawnDust(); + game.gameStateFlags |= 1ull << GAME_STATE_BOSSRUSH_DOOR_SPAWNED; + if (!isIgnoreTime) return true; + + Vector doorPosition = GetGridPosition(doors[slot]->gridIndex); + size_t count = entityList.updateEL.size(); + for (size_t i = 0; i < count; i++) + { + Entity& entity = *entityList.updateEL[i]; + if (entity.type != ENTITY_MOM || entity.variant != 0) continue; + + float dx = doorPosition.x - entity.pos.x; + float dy = doorPosition.y - entity.pos.y; + if (dy * dy + dx * dx < MOM_DOOR_CLEARANCE * MOM_DOOR_CLEARANCE) entity.Remove(); + } + return true; +} + +// 008204b0 Opens the Void's door at the top right of Blue Womb's boss room on a run that may go there. A run that cannot +// marks the floor so it stops asking. +bool Room::TrySpawnTheVoidDoor(bool isForce) +{ + Game& game = *g_game; + if (!isForce && game.challenge == CHALLENGE_RED_REDEMPTION) return false; + + int stage = labyrinth_stage_get(); + if (!isForce) + { + if (stage != STAGE_BLUE_WOMB || descriptor->data->type != ROOM_BOSS || game.currentRoomIdx < 0) return false; + + ChallengeParam& params = game.GetChallengeParams(); + bool isVoidUnlocked = !is_challenge_or_daily() && is_unlocked(ACHIEVEMENT_THE_VOID); + int endStage = params.endStage == STAGE_THE_VOID || isVoidUnlocked ? STAGE_THE_VOID : STAGE_DARK_ROOM_CHEST; + bool isClosed = is_greed(); + if (!isClosed && params.isPathTypeSet) + { + if (params.endStage != 0) endStage = params.endStage; + isClosed = params.pathType == PATH_TYPE_HOME; + } + if (isClosed || endStage < STAGE_THE_VOID || game.levelStateFlags & LEVEL_STATE_VOID_DOOR_DISABLED) + { + game.levelStateFlags |= LEVEL_STATE_VOID_DOOR_DISABLED; + return false; + } + } + + ChallengeParam& params = game.GetChallengeParams(); + if (!isForce && params.isPathTypeSet && stage >= params.endStage) + { + game.levelStateFlags |= LEVEL_STATE_VOID_DOOR_DISABLED; + return false; + } + GridEntity_Door& door = special_door_make(*this, DOOR_UP1, ROOM_THE_VOID_IDX); + door.SetRoomTypes(descriptor->data->type, ROOM_DEFAULT); + door.Open(); + return true; +} + +// 00820170 Opens Blue Womb's door in the boss room of Womb II (not on the alternate path), once Blue Womb is unlocked, +// for a clear within the par time, or anytime with the Strange Key or when the time is ignored. +bool Room::TrySpawnBlueWombDoor(bool isFirstTime, bool isIgnoreTime, bool isForce) +{ + Game& game = *g_game; + if (!isForce && (game.challenge == CHALLENGE_RED_REDEMPTION || !is_unlocked(ACHIEVEMENT_BLUE_WOMB))) return false; + + if (game.playerManager.AnyoneHasTrinket(TRINKET_STRANGE_KEY)) isIgnoreTime = true; + if (!isForce && !is_last_boss_room()) return false; + + int stage = labyrinth_stage_get(); + ChallengeParam& params = game.GetChallengeParams(); + bool isAltStage = game.stageType == STAGETYPE_REPENTANCE || game.stageType == STAGETYPE_REPENTANCE_B; + bool isAllowed = (!params.isPathTypeSet || stage < params.endStage) && stage == STAGE_MAUSOLEUM_II && !isAltStage; + if (!isForce && !isAllowed) return false; + if (is_door_to(*this, ROOM_BLUE_WOMB_IDX)) return false; + if (game.timeCounter > game.blueWombParTime && !isIgnoreTime && !isForce) return false; + + int slot = special_door_slot_get(*this, ROOM_BLUE_WOMB_IDX); + GridEntity_Door& door = special_door_make(*this, slot, ROOM_BLUE_WOMB_IDX); + door.SetRoomTypes(descriptor->data->type, ROOM_DEFAULT); + door.Open(); + if (isFirstTime) door.SpawnDust(); + game.gameStateFlags |= 1ull << GAME_STATE_BLUEWOMB_DOOR_SPAWNED; + return true; +} + +// 007f8190 Puts the Member Card's stairs down to the secret shop in a shop (a ladder back up in a room off the map), +// on the top right of the room, with their sound. Forced, anywhere. +bool Room::TrySpawnSecretShop(bool isForce) +{ + Game& game = *g_game; + bool isMemberCard = game.playerManager.FirstCollectibleOwner(COLLECTIBLE_MEMBER_CARD, LAZARUS_SHARE_CHECK); + if (!isForce && (roomType != ROOM_SHOP || (!isMemberCard && descriptor->gridIndex >= 0))) return false; + + bool isWide = descriptor->data->shape == ROOMSHAPE_2x1; + int gridIndex = isWide ? GetGridIndexByTile(SECRET_SHOP_COLUMN * 2, 2) : GetGridIndexByTile(SECRET_SHOP_COLUMN, 1); + if (descriptor->gridIndex < 0) + { + uint32_t seed = Random(); + entity_spawn(ENTITY_EFFECT, EFFECT_SHOP_LADDER, GetGridPosition(gridIndex), 0, seed); + return true; + } + + int sound = SOUND_SHOP_STAIRS; + seed_fart_sound_override(&sound); + g_manager->sfxManager.Play(sound); + uint32_t seed = Random(); + if (gridIndex < 0 || gridIndex >= ROOM_GRID_CELLS) + KAGE_LogMessage(LOG_ASSERT, (uint8_t*)"SpawnGridEntity: Grid index invalid\n"); + if ((uint32_t)gridIndex >= ROOM_GRID_CELLS || (int)GetGridCollision(gridIndex) >= 1) return true; + + GridEntity* stairs = CreateGridEntity(GRID_STAIRS, gridIndex); + delete gridEntities[gridIndex]; + gridEntities[gridIndex] = stairs; + stairs->variant = STAIRS_SECRET_SHOP; + stairs->varData = 0; + stairs->Init(seed); + return true; +} + +// Whether a player holds the Red Key's power: a Cracked Key or Soul of Cain in a pocket, or the Red Key inside the +// Void. +static bool is_red_key_held(Entity_Player& player) +{ + for (int slot = 0; slot < POCKET_SLOT_COUNT; slot++) + { + PocketItem& pocket = player.pocketItems[std::clamp(slot, 0, 3)]; + if (pocket.type == POCKET_CARD && (pocket.id == CARD_CRACKED_KEY || pocket.id == CARD_SOUL_OF_CAIN)) return true; + } + for (ActiveItemDesc& active : player.activeItems) + if (active.item == COLLECTIBLE_VOID) + return std::ranges::find(player.voidedCollectibles, COLLECTIBLE_RED_KEY) != player.voidedCollectibles.end(); + return false; +} + +// 008271e0 Shows the outlines of the red doors the Red Key could open, on the room's free door slots that lead +// somewhere new (not from the floor's last boss room or a room off the map), or removes them when nobody can. +void Room::UpdateRedKey() +{ + Game& game = *g_game; + bool isRedKey = std::ranges::any_of(game.playerManager.playerList, [](Entity_Player* player) { return is_red_key_held(*player); }); + if (!isRedKey && !game.playerManager.FirstCollectibleOwner(COLLECTIBLE_RED_KEY, LAZARUS_SHARE_CHECK)) + { + for (EntityPtr& outline : redDoorOutlines) + { + if (!outline) continue; + static_cast(outline)->Remove(); + outline.Set(nullptr); + } + return; + } + + constexpr float DOOR_ANGLES[4] = {-90, 0, 90, 180}; + bool isLastBossRoom = descriptor->data->type == ROOM_BOSS && descriptor->listIndex == game.lastBossRoomListIdx; + if (isLastBossRoom || descriptor->gridIndex < 0) return; + + for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) + { + bool isFree = descriptor->data->doors & 1u << slot && !doors[slot]; + if (redDoorOutlines[slot] || !isFree || !game.CanSpawnDoorOutline(descriptor->safeGridIndex, slot)) continue; + + uint32_t seed = Random(); + Entity* outline = entity_spawn(ENTITY_EFFECT, EFFECT_DOOR_OUTLINE, GetGridPosition(doorGridPositions[slot]), 0, seed); + float angle = DOOR_ANGLES[slot & 3]; + float radians = (angle + 90) * DEGREES_TO_RADIANS; + outline->sprite.rotation = angle; + outline->sprite.offset = vector_make(std::cos(radians) * DOOR_OUTLINE_OFFSET, std::sin(radians) * DOOR_OUTLINE_OFFSET); + redDoorOutlines[slot].Set(outline); + } } // 00820ac0 Turns the room's grid and pickups gold (Ultra Greedier's room). diff --git a/src/room.h b/src/room.h index 1a6aa1a..ea40d63 100644 --- a/src/room.h +++ b/src/room.h @@ -1,9 +1,12 @@ #pragma once #include "backdrop.h" +#include "beast_arena.h" #include "camera.h" #include "entity_list.h" #include "fx_layers.h" +#include "grid_entity.h" +#include "rail_manager.h" #include "room_descriptor.h" #include "temporary_effects.h" #include @@ -79,10 +82,34 @@ struct LRoomAreaDesc Vector bottomRightB{}; }; +// The grid a room's shape lays out (REPENTOGON's LRoomTileDesc): each shape's first and second rectangle of floor +// cells, both corners included. Only the L shapes' rectangles differ. +struct LRoomTileDesc +{ + int topLeftAX; + int topLeftAY; + int bottomRightAX; + int bottomRightAY; + int topLeftBX; + int topLeftBY; + int bottomRightBX; + int bottomRightBY; +}; + // The room counters for items in effect, and which of them a new room keeps (the original's table at 00b1f930). constexpr int ROOM_ITEM_COUNTER_COUNT = 16; constexpr uint32_t ROOM_ITEM_COUNTERS_KEPT = 1 << 3 | 1 << 5 | 1 << 6 | 1 << 7; +// A spot rain falls around in the Downpour and Dross: its center and the two axes of the ellipse drops fall in. +struct RainSpawner +{ + Vector position{}; + Vector axisA{}; + Vector axisB{}; +}; + +constexpr int RAIN_SPAWNER_COUNT = 4; + // What the layout's spawns say about a room before Init spawns them. struct SpawnFlags { @@ -103,7 +130,7 @@ struct SpawnFlags // The room the players are in (Level::room, Lua's Room): its layout's grid of cells, grid entities, doors and paths, // its entity list, camera, effect layers and backdrop, the water, lava, rain and lighting it shows, its shop, and the // counters and flags a visit keeps. Init fills it from a room descriptor each time the players enter one. -// Grid entities stay the generated classes this round: the room owns them by pointer. +// The room owns its grid entities by pointer, each of its type's class. // The enemy and boss counts, the damage dealt to enemies and the render mode belong to the entity list. // Members whose meaning is not known yet are named after their original offset. class Room @@ -124,8 +151,12 @@ public: Backdrop backdrop; std::unique_ptr camera; TemporaryEffects temporaryEffects{}; - BeastArena beastArena{}; + std::array redDoorOutlines; + std::array rainSpawners{}; + BeastArena beastArena; + RailManager railManager; ANM2 lightSprite; + ANM2 satanRadialSprite; ANM2 spotLightSprite; RoomDescriptor* descriptor = nullptr; Entity* deathsListTarget = nullptr; @@ -145,7 +176,6 @@ public: Vector topLeftPos{}; Vector waterCurrent{}; - float beastBlastForce = 0; float lavaIntensity = 0; float rainIntensity = 0; float waterAmount = 0; @@ -234,6 +264,7 @@ public: Vector GetClampedPosition(Vector position, float margin); Vector GetClampedPositionImpl(Vector position, float marginTop, float marginRight, float marginBottom, float marginLeft); + LRoomTileDesc GetLRoomTileDesc(); LRoomAreaDesc GetLRoomAreaDesc(); static Vector GetCenterPos(); Vector GetRandomPosition(float margin); @@ -272,6 +303,7 @@ public: BrokenWatchState GetBrokenWatchState(); void SetBrokenWatchState(BrokenWatchState state); float time_scale_update(); + float GetTimeScale(Entity* entity); int boss_music_get(); void PlayMusic(); @@ -286,13 +318,24 @@ public: void LoadBackdropGraphics(); void MakeDoor(int slot); void make_walls(); - bool SpawnEntry(int gridIndex, RoomEntry& entry, uint32_t seed); + bool SpawnGridEntity(int gridIndex, GridEntityType type, int variant, uint32_t seed, int varData); void RestoreState(); void hold_trigger_output_entities(); + Entity* hold_entity_in_spawner(Entity& entity, int group); bool TrySpawnMegaSatanRoomDoor(bool isForce); bool TrySpawnSpecialQuestDoor(); + bool TrySpawnSecretExit(bool isAnimate, bool isForce); + bool TrySpawnDevilRoomDoor(bool isAnimate, bool isForce); + bool TrySpawnBossRushDoor(bool isIgnoreTime, bool isForce); + bool TrySpawnTheVoidDoor(bool isForce); + bool TrySpawnBlueWombDoor(bool isFirstTime, bool isIgnoreTime, bool isForce); + bool TrySpawnSecretShop(bool isForce); + void UpdateRedKey(); void attach_minecarts(); void init_rain(); + void update_ambient_spawns(); + ColorModState get_color_modifier(); + void color_modifier_apply(); void TurnGold(); bool spawn_sanguine_bond_spikes(bool isRoomInit); void RemoveDoor(int slot); diff --git a/src/room_render.cpp b/src/room_render.cpp new file mode 100644 index 0000000..b728651 --- /dev/null +++ b/src/room_render.cpp @@ -0,0 +1,1158 @@ +#include "room_render.h" +#include "entity_npc.h" +#include "entity_player.h" +#include "entity_tear.h" +#include "game.h" +#include "grid_entity_door.h" +#include "grid_entity_rock.h" +#include "log.h" +#include "manager.h" +#include "rail_manager.h" +#include "render_passes.h" +#include "room.h" +#include "seeds.h" +#include +#include +#include + +// The images rooms draw from, and the texel settings init_room_render_surfaces gives some of them. +constexpr const char* ASH_MASK_PNG = "gfx/ash_mask.png"; +constexpr const char* CAUSTICS_PNG = "gfx/backdrop/caustics.png"; +constexpr const char* CLOUDS_PNG = "gfx/backdrop/8bitclouds_64_thick.png"; +constexpr const char* COLD_LAVA_PNG = "gfx/grid/lava_cold.png"; +constexpr const char* LAVA_PNG = "gfx/grid/lava.png"; +constexpr const char* PIT_MASK_PNG = "gfx/grid/grid_pit_mask.png"; +constexpr int TEXEL_KEEP = -1; +constexpr int WRAP_REPEAT = 0; +constexpr int FILTER_LINEAR = 1; +constexpr int ROOM_SURFACE_WIDTH = 780; +constexpr int ROOM_SURFACE_HEIGHT = 468; + +// The game shader Render's shadows and lighting overlay draw with (the original's shader table entry 0). +constexpr const char* COLOR_OFFSET_SHADER = "ColorOffset"; + +// A grid cell on screen: the room's floor sits two cells in from the render surface's corner. +constexpr float GRID_SCREEN_CELL = 26; +constexpr float FLOOR_MARGIN = 52; +constexpr int WALL_CELLS = 2; + +// The depths render_up_to draws entities to: the floor's entities, those under the grid entities, a grid row's (its +// world bottom, scaled) and the margin past the last row. +constexpr uint32_t DEPTH_FLOOR = 5000; +constexpr uint32_t DEPTH_GRID = 10000; +constexpr uint32_t DEPTH_AFTER_ROWS = 5000; +constexpr float DEPTH_ROW_BOTTOM = 20; +constexpr float DEPTH_ROW_SCALE = 100; +constexpr float DEPTH_ROW_BASE = 10030; + +constexpr KColor WHITE = kcolor_rgba(1, 1, 1, 1); +constexpr KColor BLACK = kcolor_rgba(0, 0, 0, 1); +constexpr KColor GREED_FLOOR_COLOR = kcolor_rgba(0.2784314f, 0.18039216f, 0.101960786f, 1); +constexpr KColor SHADOW_TINT = kcolor_rgba(1, 1, 1, 0.24f); +constexpr KColor LIGHTNING_TINT = kcolor_rgba(0.85f, 0.9f, 1, 1); +constexpr ColorMod NIGHT_LIGHT_COLOR = {{1, 1, 1, 0.2f}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod GLOW_COLOR = {{0.4f, 0.6f, 1, 0}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod BABY_GLOW_COLOR = {{1, 1, 0.9f, 1}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod FIRE_MIND_GLOW_COLOR = {{1, 0.6f, 0.4f, 0.7f}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod FLAME_GLOW_COLOR = {{1, 0.8f, 0.7f, 0.7f}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod BULLET_GLOW_COLOR = {{1, 1, 1, 0.4f}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod WILLO_GLOW_COLOR = {{0.6f, 0.4f, 0.2f, 0.7f}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod LIGHT_RED = {{1, 0, 0.03f, 1}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod LIGHT_PURPLE = {{0.9f, 0.3f, 1, 1}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod LIGHT_WARM = {{1, 0.9f, 0.8f, 1}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod LIGHT_PLATE_REWARD = {{1, 0.4f, 0.4f, 1}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod LIGHT_PLATE_CLEAR = {{1, 1, 0, 1}, {0, 0, 0, 0}, {0, 0, 0}}; +constexpr ColorMod LIGHT_PLATE = {{1, 1, 1, 0.2f}, {0, 0, 0, 0}, {0, 0, 0}}; + +// How strongly lights glow: the player's Spirit of the Night aura, the flicker of flames, the bullet glow's pulse. +constexpr float GLOW_STACK_MAX = 4; +constexpr float GLOW_ALPHA_STEP = 0.07f; +constexpr float GLOW_ALPHA = 0.2f; +constexpr float GLOW_SCALE_STEP = 0.5f; +constexpr float AURA_STACK_MAX = 5; +constexpr float AURA_ALPHA_STEP = 0.12f; +constexpr float AURA_ALPHA = 0.3f; +constexpr float AURA_SCALE = 2; +constexpr float BABY_GLOW_SCALE = 2; +constexpr float FLAME_FLICKER = 2; +constexpr float MAUSOLEUM_LIGHT = 0.65f; +constexpr float HOLOGRAM_LIGHT = 0.3f; +constexpr float DARKNESS_LIGHT_GROWTH = 0.5f; +constexpr float BULLET_PULSE_SPEED = 0.8f; +constexpr float BULLET_PULSE_RANGE = 0.20000002f; +constexpr float BULLET_PULSE_MIN = 0.1f; +constexpr float WILLO_HEIGHT = 16; +constexpr float WILLO_SCALE = 0.5f; +constexpr float PLATE_SCALE = 0.5f; +constexpr float PLATE_PRESSED_ALPHA = 0.25f; +constexpr float NIGHT_LIGHT_ANGLE = 90; +constexpr float PIXELATION_EASE_FRAMES = 15; + +// The lighting overlay: how much a lightning flash lifts it, and how much darker some rooms are. +constexpr float LIGHTNING_LIGHT = 0.2f; +constexpr float LIGHTNING_FLASH = 0.5f; +constexpr float DARK_ROOM_DARKNESS = 0.6f; +constexpr float SECRET_SHADOW = 0.33f; +constexpr float BASEMENT_SHADOW = 0.6f; +constexpr float NIGHT_LIGHT_SHADOW = 0.5f; +constexpr float GLAUCOMA_SHADOW = 0.1f; + +// The items, entities, grid states and rooms the render passes tell apart. +constexpr int COLLECTIBLE_SPIRIT_OF_THE_NIGHT = 3; +constexpr int COLLECTIBLE_GHOST_BOMBS = 192; +constexpr int COLLECTIBLE_SPIRIT_SWORD = 572; +constexpr int COLLECTIBLE_FIRE_MIND_COSTUME = 256; +constexpr int COLLECTIBLE_NIGHT_LIGHT = 425; +constexpr int COLLECTIBLE_GLAUCOMA = 460; +constexpr int COLLECTIBLE_DATAMINER = 481; +constexpr int NULL_ITEM_BRIMSTONE_FLAME = 56; +constexpr int NULL_EFFECT_SPIRIT_AURA = 74; +constexpr int PLAYER_DARK_JUDAS = 12; +constexpr int STAGE_ID_BLUE_WOMB = 13; +constexpr int BABY_SKIN_GLOW = 66; +constexpr int ENTITY_WILLO = 808; +constexpr int GRID_STATE_POOP_DESTROYED = 1000; +constexpr int PLATE_VARIANT_REWARD = 9; +constexpr int PLATE_VARIANT_ROOM_CLEAR = 3; +constexpr int DOOR_ROOM_SECRET_EXIT = 27; +constexpr int DOOR_ROOM_ANGEL = 15; +constexpr int DOOR_VARIANT_LIGHT = 8; +constexpr int DOOR_STATE_LIGHT = 4; +constexpr int ROOM_IDX_SECRET_EXIT = -10; +constexpr int ROOM_IDX_BLUE_WOMB_LIGHT = -9; +constexpr int BOSS_MOM_MAUSOLEUM = 89; +constexpr int STAGE_BASEMENT_I = 1; +constexpr int STAGE_BLUE_WOMB = 9; +constexpr int STAGE_HOME = 13; +constexpr int STAGE_ID_HOME = 35; +constexpr int STAGE_ID_CAVES = 4; +constexpr int STAGE_ID_CATACOMBS = 5; +constexpr int STAGE_ID_FLOODED = 6; +constexpr int STAGE_ID_DOWNPOUR = 27; +constexpr int STAGE_ID_DROSS = 28; +constexpr int STAGE_TYPE_WOTL = 1; +constexpr int STAGE_TYPE_AFTERBIRTH = 2; +constexpr int STAGE_TYPE_REPENTANCE = 4; +constexpr int STAGE_TYPE_REPENTANCE_B = 5; +constexpr int DIMENSION_MIRROR = 1; +constexpr int DIMENSION_DEATH_CERTIFICATE = 2; +constexpr uint32_t ROOM_DESCRIPTOR_FLAG_LIT_DOOR = 1u << 18; +constexpr uint32_t WATER_CLIP_UNDER = 1 << 1; +constexpr uint32_t DEBUG_FLAG_GRID_VALUES = 1 << 1; +constexpr uint32_t DEBUG_FLAG_ROOM_INFO = 1 << 4; +constexpr uint32_t DEBUG_FLAG_GRID_INDICES = 1 << 10; + +// The backdrops with their own render passes (Lua's BackdropType). +constexpr int BACKDROP_UTERO = 11; +constexpr int BACKDROP_MEGA_SATAN = 18; +constexpr int BACKDROP_ASHPIT = 46; +constexpr int BACKDROP_GREED_SHOP = 28; +constexpr int BACKDROP_MINES = 32; +constexpr int BACKDROP_DUNGEON_BEAST = 57; +constexpr int BACKDROP_MINES_SHAFT = 58; +constexpr int BACKDROP_ASHPIT_SHAFT = 59; + +// The tear flags and seeds that light a tear (Lua's TearFlags bits). +constexpr int TEAR_BURN_BIT = 22; +constexpr int TEAR_GLOW_BIT = 31; +constexpr int TEAR_MYSTERIOUS_LIQUID_BIT = 33; +constexpr int TEAR_LIGHT_FROM_HEAVEN_BIT = 39; +constexpr int TEAR_JACOBS_BIT = 55; +constexpr int TEAR_HORN_BIT = 56; +constexpr int TEAR_LUDOVICO_BIT = 127; +constexpr int PROJECTILE_FIRE = 2; +constexpr float PROJECTILE_LIGHT_DARKNESS = 0.5f; + +// The entities render_entity_light has a light of their own for, past the player: a familiar or bomb variant, an +// enemy type (or a variant of it), and the effects that glow. +constexpr int FAMILIAR_LIGHT_VARIANTS[] = {62, 206}; +constexpr int BOMB_LIGHT_VARIANT = 8; +constexpr int LIGHT_TYPE_EMBER_FLY = 25; +constexpr int LIGHT_TYPE_SPIDER = 85; +constexpr int LIGHT_TYPE_GLOWING = 263; +constexpr int LIGHT_TYPE_VARIANT_10 = 273; +constexpr int LIGHT_TYPE_VARIANT_1 = 817; +constexpr int LIGHT_TYPE_VARIANT_2 = 818; +constexpr int LIGHT_TYPES[] = {903, 905, 965}; +constexpr int BOSS_LIGHT_SPIDER = 51; +constexpr int EFFECT_LIGHT_VARIANTS[] = {1, 10, 22, 23, 30, 39, 51, 52, 65, 70, 71, 93, 104, + 110, 111, 112, 113, 115, 121, 126, 141, 153, 175, 177}; +constexpr int BURNING_ENEMY_TYPE = 54; +constexpr std::array FLAMING_ENEMY_TYPES = {10, 208, 226}; +constexpr int FLAMING_VARIANT = 2; + +// The Beast's arena draws in passes around the room's: under everything, over the floor, over the entities, last. +enum BeastArenaPass +{ + BEAST_PASS_BACKGROUND, + BEAST_PASS_FLOOR, + BEAST_PASS_ENTITIES, + BEAST_PASS_FOREGROUND +}; + +// render_water's passes: the caustics over the room's walls, or the water's light in the light overlay. +enum WaterPass +{ + WATER_PASS_ROOM, + WATER_PASS_LIGHT +}; + +RoomSurfaces roomSurfaces; +std::array roomShockwaves{}; + +// A render target, made unless it exists, cleared to transparent. +static void target_create(KAGE::Graphics::ImagePtr& target, const char* name, int width, int height) +{ + if (!target) target = KAGE::Graphics::manager.render_target_create({kcolor_rgba(0, 0, 0, 0), name, height, width}); +} + +// An image of the game's, made unless it exists, set to repeat or filter smoothly when asked. +static void image_create(KAGE::Graphics::ImagePtr& image, const char* path, int wrap, int filter) +{ + if (image) return; + + image = Manager::LoadImage(path); + if (wrap != TEXEL_KEEP && (image->wrapS != wrap || image->wrapT != wrap)) image->wrap_set(wrap, wrap); + if (filter != TEXEL_KEEP && (image->minFilter != filter || image->magFilter != filter)) + image->filter_set(filter, filter); +} + +// 007ea630 Makes the surfaces and images rooms draw through that do not exist yet: shadows, light (with lighting), +// caustics (with caustics), shockwaves (with shockwaves), the floor's water, the water overlay and heat wave (with the +// water overlay), dizziness, shading, pits, lava, Ashpit's dust, clouds and ash, and the mirror. +void room_surfaces_init() +{ + RenderConfig& render = g_manager->optionsConfig.render; + RoomSurfaces& surfaces = roomSurfaces; + int screenWidth = (int)g_screenWidth; + int screenHeight = (int)g_screenHeight; + int frameWidth = g_framebufferWidth; + int frameHeight = (int)DAT_00c79114; + + target_create(surfaces.shadow, "Shadow Surface", screenWidth, screenHeight); + if (render.isLightingEnabled) target_create(surfaces.lightOverlay, "Light Overlay Surface", screenWidth, screenHeight); + if (render.isCausticsEnabled) image_create(surfaces.caustics, CAUSTICS_PNG, WRAP_REPEAT, TEXEL_KEEP); + if (render.isShockwaveEnabled) target_create(surfaces.shockwave, "Shockwave Surface", frameWidth, frameHeight); + target_create(surfaces.floorWater, "Floor Water Surface", frameWidth, frameHeight); + if (render.isWaterOverlayEnabled) + target_create(surfaces.waterOverlay, "Water Overlay Surface", frameWidth, frameHeight); + target_create(surfaces.dizzy, "Dizzy Overlay Surface", frameWidth, frameHeight); + target_create(surfaces.shadingSurface, "Shading Surface (workaround)", ROOM_SURFACE_WIDTH, ROOM_SURFACE_HEIGHT); + target_create(surfaces.floorWaterV2, "Floor Water Surface (V2)", ROOM_SURFACE_WIDTH, ROOM_SURFACE_HEIGHT); + target_create(surfaces.texturedPit, "Textured Pit Surface", ROOM_SURFACE_WIDTH, ROOM_SURFACE_HEIGHT); + image_create(surfaces.pitMask, PIT_MASK_PNG, TEXEL_KEEP, TEXEL_KEEP); + image_create(surfaces.lava, LAVA_PNG, WRAP_REPEAT, TEXEL_KEEP); + image_create(surfaces.coldLava, COLD_LAVA_PNG, WRAP_REPEAT, TEXEL_KEEP); + target_create(surfaces.dust, "Dust Overlay Surface", screenWidth, screenHeight); + target_create(surfaces.dustTemp, "Dust Overlay Temp Surface", screenWidth, screenHeight); + image_create(surfaces.clouds, CLOUDS_PNG, WRAP_REPEAT, FILTER_LINEAR); + image_create(surfaces.ashMask, ASH_MASK_PNG, TEXEL_KEEP, FILTER_LINEAR); + if (render.isWaterOverlayEnabled) target_create(surfaces.heatWave, "Heat Wave Surface", frameWidth, frameHeight); + target_create(surfaces.mirror, "Mirror Surface", frameWidth, frameHeight); +} + +// 004e46d0 A color through a sprite color: tinted, colorized toward its luma, then offset. +KColor kcolor_apply(const ColorMod& color, const KColor& input) +{ + float red = color._tint[0] * input._red; + float green = color._tint[1] * input._green; + float blue = color._tint[2] * input._blue; + + if (color._colorize[3] != 0) + { + float luma = green * 0.71516f + red * 0.212671f + blue * 0.072169f; + red += (luma * color._colorize[0] - red) * color._colorize[3]; + green += (luma * color._colorize[1] - green) * color._colorize[3]; + blue += (luma * color._colorize[2] - blue) * color._colorize[3]; + } + return kcolor_rgba(red + color._offset[0], green + color._offset[1], blue + color._offset[2], + color._tint[3] * input._alpha); +} + +static bool is_curse_of_darkness() +{ + uint32_t curses = Seeds::GetForcedCurses() | g_game->debugCurses | g_game->curses; + return (~Seeds::GetPreventedCurses() & curses & CURSE_OF_DARKNESS) != 0; +} + +static Vector vector_add(Vector a, Vector b) +{ + return vector_make(a.x + b.x, a.y + b.y); +} + +static ColorMod tint_make(float red, float green, float blue, float alpha) +{ + return {{red, green, blue, alpha}, {0, 0, 0, 0}, {0, 0, 0}}; +} + +// Sets the blend mode of a sprite's first layer. +static void layer_blend_set(ANM2& sprite, KAGE::Graphics::BlendType type) +{ + KAGE::Graphics::BlendMode mode; + + mode.SetMode(type); + sprite.GetLayer(0)->blendMode = {mode.equation, mode.rgbSource, mode.rgbDest, mode.alphaSource, mode.alphaDest}; +} + +static void sprite_draw(const ANM2& sprite, Vector position) +{ + sprite.Render({.position = position}); +} + +// Draws a sprite at a world position on screen, moved by an offset. +static void sprite_draw_at(const ANM2& sprite, Vector world, Vector offset) +{ + sprite_draw(sprite, vector_add(render_position_get(world, RENDER_SNAPPED), offset)); +} + +// Draws the room's light sprite at a world position with a color and scale. +static void light_draw(Room& room, Vector world, Vector offset, const ColorMod& color, float scale) +{ + room.lightSprite.color = color; + room.lightSprite.scale = vector_make(scale, scale); + sprite_draw_at(room.lightSprite, world, offset); +} + +static KAGE::Graphics::ColorQuad screen_quad(KColor color) +{ + return KAGE::Graphics::color_quad_rect({}, vector_make(g_screenWidth, g_screenHeight), color); +} + +// Makes one of the game's shaders current when it is loaded. +static void shader_select(const char* name) +{ + if (KAGE::Graphics::Shader* shader = KAGE::Graphics::manager.shader_find(name)) + KAGE::Graphics::manager.currentShader = shader; +} + +// Draws into a surface, cleared, until surface_end. +static void surface_begin(KAGE::Graphics::ImagePtr& surface, KAGE::Graphics::TargetSize size) +{ + KAGE::Graphics::manager.render_target_push(surface.get(), size, KAGE::Graphics::PRESENT_FLUSH); + KAGE::Graphics::manager.Clear(); +} + +// Finishes a surface and goes back to the target under it. +static void surface_end() +{ + KAGE::Graphics::manager.Present(KAGE::Graphics::PRESENT_FINISH); + KAGE::Graphics::manager.render_target_pop(KAGE::Graphics::PRESENT_FLUSH); +} + +static bool is_grid_type(const GridEntity* grid, GridEntityType type) +{ + return grid && grid->type == type; +} + +// Draws the grid entities a filter picks. +template static void grids_render(Room& room, Vector offset, Filter isDrawn) +{ + for (int i = 0; i < room.gridWidth * room.gridHeight; i++) + if (room.gridEntities[i] && isDrawn(*room.gridEntities[i])) room.gridEntities[i]->Render(offset); +} + +// Pits, trapdoors, stairs and destroyed poop: the grid entities flat on the floor, drawn with the walls. +static bool is_flat_grid(const GridEntity& grid) +{ + return grid.type == GRID_PIT || grid.type == GRID_TRAPDOOR || grid.type == GRID_STAIRS || + (grid.type == GRID_POOP && grid.state == GRID_STATE_POOP_DESTROYED); +} + +// 006b7cc0 How far a minecart's rider sits from it: the cart sprite's first null, or nothing without a cart. +static Vector minecart_offset(Entity& entity) +{ + Entity* cart = entity.minecart.get(); + if (!cart || !cart->sprite.animState.animData) return {}; + + const NullFrame* frame = cart->sprite.animState.GetNullFrameById(0); + return frame ? frame->pos : Vector{}; +} + +// 0075d900 Whether an item's costume draws on a layer of the player's sprite, or on any layer for -1. +static bool is_item_costume_visible(Entity_Player& player, ItemConfig_Item* item, int layer) +{ + int first = std::max(layer, 0); + int last = layer < 0 ? COSTUME_LAYER_COUNT : layer + 1; + + for (int i = first; i < last; i++) + { + int index = player.playerCostumeMap[i].index; + if (index >= 0 && player.costumeSpriteDescs[index].item == item) return true; + } + return false; +} + +// The shared pixelation amount: full under Retro Vision, otherwise easing in and out over the game's pixelation timer. +static float pixelation_amount(Game& game) +{ + if (game.seedEffects.HasSeedEffect(SEED_RETRO_VISION)) return 1; + + int timer = game.pixelationTimer; + if (timer < 1) return 0; + if (timer > game.pixelationDuration - PIXELATION_EASE_FRAMES) + return (float)(game.pixelationDuration - timer) / PIXELATION_EASE_FRAMES; + if (timer < PIXELATION_EASE_FRAMES) return (float)timer / PIXELATION_EASE_FRAMES; + return 1; +} + +static bool is_shockwave_active() +{ + return std::any_of(roomShockwaves.begin(), roomShockwaves.end(), + [](const Shockwave& wave) { return wave.frame < wave.duration; }); +} + +// 00827bc0 Whether the room is the Mausoleum's Mom fight before the Ascent. +static bool is_pre_ascent_mom_room(Room& room) +{ + return room.roomType == ROOM_BOSS && room.descriptor->data->subtype == BOSS_MOM_MAUSOLEUM && + g_game->IsPreAscent(); +} + +// 009e31b0 Draws the rails over pits: each pit cell with a rail shows its piece's frame of the pitrail animation. +static void pit_rails_render(Room& room, Vector offset) +{ + RailManager& rails = room.railManager; + + rails.sprite.SetFrame("pitrail", 0); + for (int i = 0; i < room.gridWidth * room.gridHeight && i < ROOM_GRID_CELLS; i++) + { + uint8_t rail = rails.rails[i]; + if (rail & ~(RAIL_MINESHAFT | RAIL_MINESHAFT_PIECE_MASK) || !is_grid_type(room.gridEntities[i], GRID_PIT)) + continue; + + rails.sprite.SetFrame((float)(rail & RAIL_PIECE_MASK)); + sprite_draw_at(rails.sprite, room.GetGridPosition(i), offset); + } +} + +// 00419b50 Draws the shadows of the entities drawn this frame into the shadow surface: each visible entity alive (or +// an enemy, dead or not) without a shadow layer of its own gets the list's shadow image, sized by its shadow size. +static void shadows_render(EntityList& list, Vector offset) +{ + KAGE::Graphics::ImageBase& shadow = *list.shadowImage; + + shader_select(COLOR_OFFSET_SHADER); + apply_sprite_shader_params(COLOR_DEFAULT, SPRITE_SHADER_COLOR_APPLY, shadow); + for (Entity* entity : list.renderEL) + { + if (!entity->isVisible || (entity->isDead && !entity->to_npc_or_coop_player())) continue; + if (entity->RenderShadowLayer(offset)) continue; + + float scale = entity->shadowSize * entity->sprite.scale.x; + if (scale < 0.001f) continue; + + Vector size = vector_make(scale * (float)shadow.width, scale * (float)shadow.height); + Vector center = vector_add(render_position_get(vector_add(entity->pos, entity->shadowOffset), RENDER_SNAPPED), + vector_add(offset, g_game->screenShakeOffset)); + Vector corner = vector_make(center.x - size.x * 0.5f, center.y - size.y * 0.5f); + shadow.Render(KAGE::Graphics::color_quad_rect(corner, size, WHITE), WHITE); + } + KAGE::Graphics::manager.shader_default_set(); +} + +// The Satan radial sprite at the running shockwaves of Mega Satan's and the Greed shop's rooms, at the frame of its +// Idle animation as far through its duration as the wave is. +// The original read a missing Idle animation's length. A sprite without one is skipped. +static void shockwaves_radial_render(Room& room, Vector offset) +{ + const AnimationData* idle = room.satanRadialSprite.GetAnimationData("Idle"); + + for (const Shockwave& wave : roomShockwaves) + { + if (wave.frame >= wave.duration || !idle) continue; + if (room.backdropType != BACKDROP_MEGA_SATAN && room.backdropType != BACKDROP_GREED_SHOP) continue; + + room.satanRadialSprite.SetFrame("Idle", (int)((float)idle->length * ((float)wave.frame / (float)wave.duration))); + sprite_draw_at(room.satanRadialSprite, wave.position, offset); + } +} + +// 00817830 The floor's water caustics over the room, or their light in the light overlay. Backdrops without walls, +// and rooms without water but the flooded stages' water rooms, have none. +static void water_render(Room& room, WaterPass) +{ + int stageId = g_game->GetStageID(); + bool isFloodStage = stageId == STAGE_ID_CAVES || stageId == STAGE_ID_CATACOMBS || stageId == STAGE_ID_FLOODED || + stageId == STAGE_ID_DOWNPOUR || stageId == STAGE_ID_DROSS; + bool isFloodRoom = isFloodStage && room.descriptor->pitsCount >= 0 && + room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER; + + if (room.backdrop.configs[room.backdropType].walls == 0) return; + if (room.waterAmount <= 0 && !isFloodRoom) return; + reconstruction_missing("Room::render_water 00817830: the caustics"); +} + +// 00821950 Draws the floor through the water surface. Not reconstructed yet. +static void water_shader_render(Room&, Vector) +{ + reconstruction_missing("Room::render_water_shader 00821950"); +} + +// 00826f80 Draws the flooded Mines' water over the floor. Not reconstructed yet. +static void water_overlay_render(Room&, Vector) +{ + reconstruction_missing("Room::render_water_overlay 00826f80"); +} + +// 00825de0 Draws the Ashpit's drifting dust into the dust surface. Not reconstructed yet past the Ashpit check. +static void darkness_overlay_render(Room& room) +{ + if (room.is_ashpit_rays()) reconstruction_missing("Room::render_darkness_overlay 00825de0"); +} + +// 00826ae0 Draws a flooded Mines room's lava pits into the textured pit surface. Not reconstructed yet past its check. +static void lava_pit_mask_render(Room& room) +{ + if (room.backdropType == BACKDROP_MINES && room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER) + reconstruction_missing("Room::render_lava_pit_mask 00826ae0"); +} + +// 00820fd0 Draws the floor under the water surface into its surface. Not reconstructed yet past its check. +static void floor_water_render(Room& room) +{ + if (room.waterAmount > 0 && g_manager->optionsConfig.render.isWaterSurfaceEnabled) + reconstruction_missing("Room::render_floor_water 00820fd0"); +} + +// The floor's backing quad: the Greed shop's brown, or the floor color's change of black. +static void floor_quad_render(Room& room, Vector surfaceOffset) +{ + bool isGreedShop = room.backdropType == BACKDROP_GREED_SHOP; + KColor color = isGreedShop ? GREED_FLOOR_COLOR : kcolor_apply(room.floorColor, BLACK); + bool isBlack = color._red == BLACK._red && color._green == BLACK._green && color._blue == BLACK._blue && + color._alpha == BLACK._alpha; + if (!isGreedShop && isBlack) return; + + Vector size = vector_make((float)(room.gridWidth - WALL_CELLS) * GRID_SCREEN_CELL, + (float)(room.gridHeight - WALL_CELLS) * GRID_SCREEN_CELL); + Vector corner = vector_make(surfaceOffset.x + FLOOR_MARGIN, surfaceOffset.y + FLOOR_MARGIN); + render_color_shader_pass(KAGE::Graphics::color_quad_rect(corner, size, color)); +} + +// The floor pass: the backdrop's floor, its second surface, Hush's veins and the decorations (a crawlspace's every +// grid entity instead), then the entities on the floor. Under a water surface the floor draws through the water. +static void floor_render(Room& room, Vector surfaceOffset, bool isWaterShown) +{ + EntityList& list = room.entityList; + Vector scroll = room.renderScrollOffset; + + list.renderCursor = 0; + if (isWaterShown) + { + water_shader_render(room, surfaceOffset); + list.renderMode = RENDER_WATER_ABOVE; + list.render_up_to(DEPTH_FLOOR, scroll); + return; + } + + list.renderMode = RENDER_NORMAL; + if (room.roomType == ROOM_DUNGEON) grids_render(room, scroll, [](const GridEntity&) { return true; }); + else + { + room.backdrop.RenderFloor(surfaceOffset, room.floorColor); + if (room.backdrop.isTempSurfaceUsed) room.backdrop.render_floor_surface(surfaceOffset, room.floorColor); + room.fxLayers.veins_render(); + grids_render(room, scroll, [](const GridEntity& grid) { return grid.type == GRID_DECORATION; }); + } + list.render_up_to(DEPTH_FLOOR, scroll); + if (room.backdropType == BACKDROP_DUNGEON_BEAST) render_beast_arena_background(&room.beastArena, BEAST_PASS_FLOOR); +} + +// The walls pass: the backdrop's walls, the caustics in the blend the floor began with, and (without a water surface) +// the rails, the flat grid entities, the flooded Mines' water with their pits' rims and the rails over pits. +static void walls_render(Room& room, Vector surfaceOffset, bool isWaterShown, KAGE::Graphics::BlendMode floorBlend) +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + Vector scroll = room.renderScrollOffset; + + room.backdrop.RenderWalls(surfaceOffset, room.wallColor); + if (g_manager->optionsConfig.render.isCausticsEnabled && g_game->darknessModifier <= 0 && !is_curse_of_darkness()) + { + graphics.blend_set(KAGE::Graphics::BLEND_ADDITIVE); + water_render(room, WATER_PASS_ROOM); + graphics.blendMode = floorBlend; + } + if (isWaterShown) return; + + room.railManager.Render(scroll); + grids_render(room, scroll, is_flat_grid); + if (room.backdropType == BACKDROP_MINES && room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER) + { + water_overlay_render(room, surfaceOffset); + for (int i = 0; i < room.gridWidth * room.gridHeight; i++) + { + GridEntity* pit = room.gridEntities[i]; + if (!is_grid_type(pit, GRID_PIT)) continue; + + pit->sprite.GetLayer(0)->isVisible = false; + pit->Render(scroll); + pit->sprite.GetLayer(0)->isVisible = true; + } + } + pit_rails_render(room, scroll); +} + +// The doors, the room shape's shading and the entities' shadows, then the background effect layers. +static void doors_shading_render(Room& room, Vector surfaceOffset) +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + + if (room.roomType != ROOM_DUNGEON) + { + grids_render(room, room.renderScrollOffset, [](const GridEntity& grid) { return grid.type == GRID_DOOR; }); + if (roomSurfaces.shading) + { + graphics.blend_set(KAGE::Graphics::BLEND_NORMAL); + roomSurfaces.shading->Render(surfaceOffset, WHITE); + } + graphics.shader_push(COLOR_OFFSET_SHADER); + apply_sprite_shader_params(COLOR_DEFAULT, SPRITE_SHADER_COLOR_APPLY, *roomSurfaces.shadow); + roomSurfaces.shadow->Render(Vector{}, SHADOW_TINT); + graphics.shader_pop(); + } + room.fxLayers.background_layers_render(); +} + +// The grid entities and entities by depth: the grid entities not drawn yet (but those under a water surface), then for +// each grid row the entities above its bottom and its pillars' tops, then every entity left, and their post renders. +static void depth_render(Room& room, bool isWaterShown) +{ + EntityList& list = room.entityList; + Vector scroll = room.renderScrollOffset; + uint32_t depth = DEPTH_GRID; + + if (room.roomType != ROOM_DUNGEON) + { + grids_render(room, scroll, + [&](GridEntity& grid) + { + if (grid.type == GRID_DECORATION || grid.type == GRID_DOOR || is_flat_grid(grid)) return false; + return !isWaterShown || !(grid.GetWaterClipInfo().flags & WATER_CLIP_UNDER); + }); + for (int row = 0; row < room.gridHeight; row++) + { + float bottom = (float)row * GRID_CELL_SIZE + GRID_ORIGIN_Y + DEPTH_ROW_BOTTOM; + float rowDepth = std::floor(bottom * DEPTH_ROW_SCALE + DEPTH_ROW_BASE + 0.5f); + depth = (uint32_t)std::max(rowDepth, (float)DEPTH_GRID); + list.render_up_to(depth, scroll); + for (int column = 0; column < room.gridWidth; column++) + { + GridEntity* pillar = room.gridEntities[row * room.gridWidth + column]; + if (is_grid_type(pillar, GRID_PILLAR)) static_cast(pillar)->RenderTop(scroll); + } + } + list.render_up_to(depth + DEPTH_AFTER_ROWS, scroll); + } + if (isWaterShown) list.renderMode = RENDER_NORMAL; + list.render_up_to(UINT_MAX, scroll); + for (uint32_t i = 0; i < list.renderCursor; i++) list.renderEL[i]->PostRender(); + list.renderMode = RENDER_NULL; +} + +// The players' Night Light cones, turned with each one's body. +static void night_lights_render(Room& room) +{ + PlayerManager& players = g_game->playerManager; + + for (size_t i = 0; i < players.playerList.size(); i++) + { + Entity_Player& player = *players.GetPlayer((int)i); + if (!player.HasCollectible(COLLECTIBLE_NIGHT_LIGHT)) continue; + + room.spotLightSprite.rotation = player.bodyAngle - NIGHT_LIGHT_ANGLE; + room.spotLightSprite.color = NIGHT_LIGHT_COLOR; + layer_blend_set(room.spotLightSprite, KAGE::Graphics::BLEND_ADDITIVE); + sprite_draw_at(room.spotLightSprite, player.pos, room.renderScrollOffset); + } +} + +// The lighting overlay over the room: the light surface multiplied over it at the shadows' strength (less a lightning +// flash), and the flash itself added in the light layers. +static void lighting_overlay_render(Room& room) +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + float lightning = std::clamp(g_game->lightningIntensity, 0.0f, 1.0f); + float alpha = room.GetLightingAlpha() - lightning * LIGHTNING_LIGHT; + if (alpha <= 0) return; + + KAGE::Graphics::BlendMode saved = graphics.blendMode; + graphics.blendMode = {KAGE::Graphics::EQUATION_ADD, KAGE::Graphics::FACTOR_DST_COLOR, + KAGE::Graphics::FACTOR_ONE_MINUS_SRC_ALPHA, KAGE::Graphics::FACTOR_DST_ALPHA, + KAGE::Graphics::FACTOR_ONE_MINUS_SRC_ALPHA}; + apply_sprite_shader_params(COLOR_DEFAULT, SPRITE_SHADER_COLOR_APPLY, *roomSurfaces.lightOverlay); + roomSurfaces.lightOverlay->Render(screen_quad(WHITE), kcolor_rgba(1, 1, 1, alpha)); + if (g_game->lightningIntensity > 0) + { + float flash = std::clamp(g_game->lightningIntensity * LIGHTNING_FLASH, 0.0f, LIGHTNING_FLASH); + graphics.blend_set(KAGE::Graphics::BLEND_ADDITIVE); + room.fxLayers.lighting_layers_render( + kcolor_rgba(flash * LIGHTNING_TINT._red, flash * LIGHTNING_TINT._green, flash, flash)); + } + graphics.blendMode = saved; +} + +// The Ashpit's dust surface added over the room. +static void dust_render() +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + KAGE::Graphics::BlendMode saved = graphics.blendMode; + + graphics.blend_set(KAGE::Graphics::BLEND_ADDITIVE); + roomSurfaces.dust->Render(screen_quad(WHITE), WHITE); + graphics.blendMode = saved; +} + +// 0080bd20 The glows entities draw over the room: a player's Spirit of the Night aura, the glowing baby skin's light +// and a flickering flame for Fire Mind or the brimstone flame costume, a projectile's glow under the bullet visibility +// option, and a Willo's ember. A minecart's rider glows at the cart's null. +static void entity_glow_render(Room& room, Entity& entity, Vector offset) +{ + ANM2& light = room.lightSprite; + RNG rng = {(uint32_t)g_game->frameCount + entity.initSeed, 5, 27, 25}; + Vector base = vector_add(offset, minecart_offset(entity)); + + if (entity.type == ENTITY_PROJECTILE) + { + if (!g_manager->optionsConfig.isBulletVisibilityEnabled) return; + + float pulse = std::sin((float)g_game->frameCount * BULLET_PULSE_SPEED) * 0.5f + 0.5f; + light_draw(room, vector_add(entity.pos, entity.posOffset), base, BULLET_GLOW_COLOR, + pulse * BULLET_PULSE_RANGE + BULLET_PULSE_MIN); + return; + } + if (entity.type == ENTITY_WILLO) + { + if (!entity.isVisible) return; + + Vector ember = vector_add(render_position_get(vector_make(entity.pos.x, entity.pos.y - WILLO_HEIGHT), + RENDER_SNAPPED), base); + Vector direction{}; + light.color = WILLO_GLOW_COLOR; + RandomVector(&direction, rng.Next()); + float distance = rng.RandomFloat(); + light.scale = vector_make(WILLO_SCALE, WILLO_SCALE); + sprite_draw(light, vector_make(ember.x + distance * direction.x, ember.y + distance * direction.y)); + return; + } + if (entity.type != ENTITY_PLAYER) return; + + Entity_Player& player = static_cast(entity); + if (player.temporaryEffects.HasNullEffect(NULL_EFFECT_SPIRIT_AURA)) + { + float stacks = std::min((float)player.temporaryEffects.GetNullEffectNum(NULL_EFFECT_SPIRIT_AURA), GLOW_STACK_MAX); + ColorMod color = GLOW_COLOR; + color._tint[3] = stacks * GLOW_ALPHA_STEP + GLOW_ALPHA; + layer_blend_set(light, KAGE::Graphics::BLEND_ADDITIVE); + light_draw(room, player.pos, base, color, stacks * GLOW_SCALE_STEP + 1); + layer_blend_set(light, KAGE::Graphics::BLEND_NORMAL); + } + if (player.babySkin == BABY_SKIN_GLOW) + { + layer_blend_set(light, KAGE::Graphics::BLEND_ADDITIVE); + light_draw(room, player.pos, base, BABY_GLOW_COLOR, BABY_GLOW_SCALE); + layer_blend_set(light, KAGE::Graphics::BLEND_NORMAL); + } + + ItemConfig& items = g_manager->itemConfig; + bool isFireMind = is_item_costume_visible(player, items.GetCollectible(COLLECTIBLE_FIRE_MIND_COSTUME), 0) || + player.HasCollectible(COLLECTIBLE_FIRE_MIND); + if (!isFireMind && !is_item_costume_visible(player, items.GetNullItem(NULL_ITEM_BRIMSTONE_FLAME), 0)) return; + + Vector direction{}; + RandomVector(&direction, rng.Next()); + float distance = rng.RandomFloat() * FLAME_FLICKER; + light.color = isFireMind ? FIRE_MIND_GLOW_COLOR : FLAME_GLOW_COLOR; + light.scale = vector_make(1, 1); + Vector position = vector_add(render_position_get(player.pos, RENDER_SNAPPED), base); + sprite_draw(light, vector_make(position.x + distance * direction.x, position.y + distance * direction.y)); +} + +// 0080f200 Draws the room: the behind layers, the floor with its entities, the walls, rails and flat grid entities, +// the doors, shading and shadows, the players' glows, the grid entities and entities by depth, the players' extra +// bodies and Night Lights, the lighting overlay, the foreground and overlay layers, and the Ashpit's dust. Retro +// Vision or the game's pixelation timer pixelate the sprites meanwhile, and Dataminer garbles them. +// The effect surfaces the room draws through (the mirror world's, dizziness, shockwaves, Utero's water overlay and the +// Beast's heat wave), the water surface and the debug overlays are not reconstructed yet. +void Room::Render() +{ + KAGE::Graphics::Manager& graphics = KAGE::Graphics::manager; + Game& game = *g_game; + RenderConfig& render = g_manager->optionsConfig.render; + bool isDataminer = temporaryEffects.HasCollectibleEffect(COLLECTIBLE_DATAMINER); + bool isRepentanceStage = game.stageType == STAGE_TYPE_REPENTANCE || game.stageType == STAGE_TYPE_REPENTANCE_B; + bool isMirrorWorld = game.currentDimensionIdx == DIMENSION_MIRROR && isRepentanceStage && + (game.stage == 2 || (game.stage == 1 && game.GetCurses() & CURSE_OF_LABYRINTH)); + bool isUteroSurface = backdropType == BACKDROP_UTERO && render.isWaterOverlayEnabled; + bool isHeatWave = backdropType == BACKDROP_DUNGEON_BEAST && render.isWaterOverlayEnabled; + bool isShockwaveSurface = render.isShockwaveEnabled && is_shockwave_active(); + bool isWaterShown = waterAmount > 0 && render.isWaterSurfaceEnabled; + Vector surfaceOffset = vector_add(vector_add(renderSurfaceTopLeft, game.screenShakeOffset), renderScrollOffset); + + spriteShaderParams.pixelationAmount = pixelation_amount(game); + if (isDataminer) DAT_00c7977f = 1; + if (isMirrorWorld || game.dizzyIntensity > 0 || isShockwaveSurface || isUteroSurface || isHeatWave) + reconstruction_missing("Room::Render 0080f200: the mirror, dizzy, shockwave and water overlay surfaces"); + + if (backdropType == BACKDROP_DUNGEON_BEAST) render_beast_arena_background(&beastArena, BEAST_PASS_BACKGROUND); + graphics.blend_set(KAGE::Graphics::BLEND_NORMAL); + fxLayers.behind_layers_render(); + floor_quad_render(*this, surfaceOffset); + if (!render.isShockwaveEnabled && !IsClear()) shockwaves_radial_render(*this, renderScrollOffset); + + KAGE::Graphics::BlendMode floorBlend = graphics.blendMode; + floor_render(*this, surfaceOffset, isWaterShown); + if (roomType != ROOM_DUNGEON) walls_render(*this, surfaceOffset, isWaterShown, floorBlend); + entityList.render_up_to(DEPTH_GRID, renderScrollOffset); + if (backdropType == BACKDROP_DUNGEON_BEAST) render_beast_arena_background(&beastArena, BEAST_PASS_ENTITIES); + doors_shading_render(*this, surfaceOffset); + + lightSprite.color = COLOR_DEFAULT; + litGridIndices.clear(); + for (Entity* entity : entityList.updateEL) entity_glow_render(*this, *entity, renderScrollOffset); + depth_render(*this, isWaterShown); + for (Entity_Player* extra : game.playerManager.extraPlayers) extra->Render(renderScrollOffset); + night_lights_render(*this); + if (game.debugFlags & DEBUG_FLAG_GRID_VALUES) reconstruction_missing("Room::render_debug_grid_values 008128f0"); + if (game.debugFlags & DEBUG_FLAG_GRID_INDICES) reconstruction_missing("Room::render_debug_grid_indices 0081f130"); + + shader_select(COLOR_OFFSET_SHADER); + if (render.isLightingEnabled) lighting_overlay_render(*this); + if (backdropType == BACKDROP_DUNGEON_BEAST) render_beast_arena_background(&beastArena, BEAST_PASS_FOREGROUND); + fxLayers.Render(); + if (is_ashpit_rays()) dust_render(); + if (isDataminer) DAT_00c7977f = 0; + fxLayers.overlay_layers_render(); + + spriteShaderParams.pixelationAmount = 0; + graphics.shader_default_set(); + if (game.debugFlags & DEBUG_FLAG_ROOM_INFO) reconstruction_missing("Room::Render 0080f200: the room info text"); +} + +// Whether a tear glows: its glowing, creep, burning, horn, heaven light or Jacob's flags, a fire tear, Glowing Tears, +// a nail under G-Fuel, or a Ludovico tear in a pitch black room. +static bool is_tear_lit(Room& room, Entity& entity) +{ + Entity_Tear& tear = static_cast(entity); + Seeds& seeds = g_game->seedEffects; + bool isPitchBlack = room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_PITCH_BLACK; + + for (int bit : {TEAR_GLOW_BIT, TEAR_MYSTERIOUS_LIQUID_BIT, TEAR_BURN_BIT, TEAR_HORN_BIT, TEAR_LIGHT_FROM_HEAVEN_BIT, + TEAR_JACOBS_BIT}) + if (tear.tearFlags.test(bit)) return true; + if (tear.variant == TEAR_FIRE || seeds.HasSeedEffect(SEED_GLOWING_TEARS)) return true; + if ((tear.variant == TEAR_NAIL || tear.variant == TEAR_NAIL_BLOOD) && seeds.HasSeedEffect(SEED_G_FUEL)) return true; + return tear.tearFlags.test(TEAR_LUDOVICO_BIT) && isPitchBlack; +} + +// Whether a burning or flaming enemy glows (render_entity_light's default case). +static bool is_enemy_burning(Entity& entity) +{ + bool isFlaming = entity.variant == FLAMING_VARIANT && + std::ranges::find(FLAMING_ENEMY_TYPES, entity.type) != FLAMING_ENEMY_TYPES.end(); + return (entity.IsEnemy() && entity.flags & FLAG_BURN) || entity.type == BURNING_ENEMY_TYPE || isFlaming; +} + +// Whether render_entity_light draws a light for an entity besides a player: the kinds it has a case for (each under +// its own condition), and otherwise burning or flaming enemies. +static bool is_entity_lit(Room& room, Entity& entity) +{ + int variant = entity.variant; + bool isPitchBlack = room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_PITCH_BLACK; + + switch (entity.type) + { + case ENTITY_TEAR: return is_tear_lit(room, entity); + case ENTITY_FAMILIAR: + return entity.isVisible && std::ranges::find(FAMILIAR_LIGHT_VARIANTS, variant) != std::end(FAMILIAR_LIGHT_VARIANTS); + case ENTITY_BOMB: return variant == BOMB_LIGHT_VARIANT || entity.sprite.GetLayer("sparks"); + case ENTITY_LASER: return entity.isVisible; + case ENTITY_PROJECTILE: return variant == PROJECTILE_FIRE || room.GetLightingAlpha() > PROJECTILE_LIGHT_DARKNESS; + case ENTITY_EFFECT: + return std::ranges::find(EFFECT_LIGHT_VARIANTS, variant) != std::end(EFFECT_LIGHT_VARIANTS); + case LIGHT_TYPE_EMBER_FLY: return variant == 3 && room.backdropType == BACKDROP_ASHPIT; + case ENTITY_FIREPLACE: return entity.health > 1; + case LIGHT_TYPE_SPIDER: return room.bossId == BOSS_LIGHT_SPIDER || isPitchBlack; + case LIGHT_TYPE_GLOWING: return true; + case LIGHT_TYPE_VARIANT_10: return variant == 10; + case ENTITY_WILLO: return entity.isVisible; + case LIGHT_TYPE_VARIANT_1: return variant == 1; + case LIGHT_TYPE_VARIANT_2: return variant == 2; + } + if (entity.type > LIGHT_TYPE_VARIANT_2 && std::ranges::find(LIGHT_TYPES, entity.type) != std::end(LIGHT_TYPES)) + return true; + return is_enemy_burning(entity); +} + +// A player's light: its Spirit of the Night aura, then the light gradient (red for Dark Judas, warm under flame +// costumes, purple under the ghostly ones, white otherwise) growing with the darkness, dimmed in the Mausoleum's heart +// and for a hologram, its Night Light cone, and in Hush's room a second light pulsing faster as Hush weakens. +static void player_light_render(Room& room, Entity_Player& player, Vector offset) +{ + ANM2& light = room.lightSprite; + ItemConfig& items = g_manager->itemConfig; + Vector position = vector_add(render_position_get(vector_add(player.pos, player.posOffset), RENDER_SNAPPED), offset); + TemporaryEffect* aura = player.temporaryEffects.isDisabled + ? nullptr + : player.temporaryEffects.GetNullEffect(NULL_EFFECT_SPIRIT_AURA); + float stacks = std::min(aura ? (float)aura->count : 0.0f, AURA_STACK_MAX); + + if (player.temporaryEffects.HasNullEffect(NULL_EFFECT_SPIRIT_AURA)) + { + layer_blend_set(light, KAGE::Graphics::BLEND_ADDITIVE); + light.color = tint_make(0.4f, 0.6f, 1, stacks * AURA_ALPHA_STEP + AURA_ALPHA); + light.scale = vector_make(stacks + AURA_SCALE, stacks + AURA_SCALE); + sprite_draw(light, position); + layer_blend_set(light, KAGE::Graphics::BLEND_NORMAL); + } + + float strength = g_game->IsMausoleumHeartStage() ? MAUSOLEUM_LIGHT : 1; + if (player.IsHologram()) strength *= HOLOGRAM_LIGHT; + auto isCostume = [&](int collectible) { return is_item_costume_visible(player, items.GetCollectible(collectible), -1); }; + bool isFlame = is_item_costume_visible(player, items.GetCollectible(COLLECTIBLE_FIRE_MIND_COSTUME), 0) || + isCostume(COLLECTIBLE_FIRE_MIND) || player.IsNullItemCostumeVisible(NULL_ITEM_BRIMSTONE_FLAME, 0); + bool isGhostly = isCostume(COLLECTIBLE_SPIRIT_OF_THE_NIGHT) || isCostume(COLLECTIBLE_GHOST_BOMBS) || + isCostume(COLLECTIBLE_SPIRIT_SWORD); + if (isFlame || isGhostly) light.color = player.playerType == PLAYER_DARK_JUDAS ? LIGHT_RED : isFlame ? LIGHT_WARM : LIGHT_PURPLE; + else light.color = COLOR_DEFAULT; + light.color._tint[3] *= strength; + + float darkness = g_game->GetCurses() & CURSE_OF_DARKNESS ? 1 : g_game->darknessStrength * g_game->darknessModifier; + float scale = darkness * DARKNESS_LIGHT_GROWTH + 1; + light.scale = vector_make(scale, scale); + light.SetFrame(1.0f); + sprite_draw(light, position); + light.SetFrame(0.0f); + + if (player.HasCollectible(COLLECTIBLE_NIGHT_LIGHT)) + { + room.spotLightSprite.rotation = player.bodyAngle - NIGHT_LIGHT_ANGLE; + room.spotLightSprite.color = COLOR_DEFAULT; + layer_blend_set(room.spotLightSprite, KAGE::Graphics::BLEND_NORMAL); + sprite_draw(room.spotLightSprite, position); + } + if (g_game->GetStageID() != STAGE_ID_BLUE_WOMB || room.descriptor->data->type != ROOM_BOSS) return; + + float weakness = 0.1f; + for (Entity* entity : room.entityList.updateEL) + { + if (entity->type != ENTITY_HUSH || entity->variant != 0) continue; + + weakness = 1 - entity->health / entity->maxHitPoints; + break; + } + float pulse = std::sin((float)g_game->frameCount * (weakness * 0.18f + 0.02f)) + 3; + light.scale = vector_make(pulse, pulse); + sprite_draw(light, position); +} + +// 00806c20 Draws an entity's light into the light overlay, flickering by the frame and the entity's seed: the players' +// lights, and those of the glowing tears, familiars, bombs, lasers, projectiles, enemies and effects. A minecart's +// rider lights from the cart's null. +// Only the players' lights and the cases that draw nothing are reconstructed yet: the sprites with light layers and +// the other lit entities stop. +static void entity_light_render(Room& room, Entity& entity, Vector offset) +{ + Vector base = vector_add(offset, minecart_offset(entity)); + + DAT_00c7977e = 1; + if (entity.isVisible && entity.sprite.bitflags & (ANIM_RENDER_ENABLE_LAYER_LIGHTING | ANIM_RENDER_ENABLE_NULL_LAYER_LIGHTING)) + reconstruction_missing("Room::render_entity_light 00806c20: the sprites' light layers"); + if (entity.type == ENTITY_PLAYER) + { + if (entity.isExists) player_light_render(room, static_cast(entity), base); + } + else if (is_entity_lit(room, entity)) + reconstruction_missing("Room::render_entity_light 00806c20: the lights of entities but the players"); + + Entity_NPC* npc = entity.IsEnemy() ? dynamic_cast(&entity) : nullptr; + if (npc && npc->controllerID != -1) reconstruction_missing("Room::render_entity_light 00806c20: a controlled enemy"); + DAT_00c7977e = 0; +} + +// The light of a door: the secret exits' and the Ascent's lit doors, doors into lit rooms, the mirror world's +// mineshaft doors and angel room doors. Whether it lights before any light is drawn. +static bool is_door_lit(GridEntity_Door& door) +{ + Game& game = *g_game; + int exitKind = game.get_secret_exit_kind(); + + if (door.targetRoomType == DOOR_ROOM_SECRET_EXIT) + return exitKind == SECRET_EXIT_MINES ? door.variant == DOOR_VARIANT_LIGHT || door.state == DOOR_STATE_LIGHT + : exitKind == SECRET_EXIT_MAUSOLEUM; + if (game.currentRoomIdx == ROOM_IDX_SECRET_EXIT && exitKind == SECRET_EXIT_MOMS_HEART) + return door.variant == DOOR_VARIANT_LIGHT; + + RoomConfig_Room* config = game.room->descriptor->data; + if (config && config->stageId == STAGE_ID_HOME) return true; + if (game.GetRoomByIdx(door.targetRoomIdx)->flags & ROOM_DESCRIPTOR_FLAG_LIT_DOOR) return true; + if (door.doorFlags & DOOR_FLAG_MINESHAFT && game.currentDimensionIdx == DIMENSION_MIRROR) return true; + return door.targetRoomType == DOOR_ROOM_ANGEL && door.variant == DOOR_VARIANT_LIGHT; +} + +// 0080c810 Draws a grid entity's light into the light overlay: pressure plates (red reward plates, yellow room clear +// plates, white unpressed ones, dimmer once pressed), teleporters at their sprite's light null, and the lava pits, +// lit doors and the last boss's trapdoor in the Mausoleum's heart. +// The lava pits', doors' and trapdoor's lights are not reconstructed yet. +static void grid_light_render(Room& room, GridEntity& grid, Vector offset) +{ + Vector position = grid.Position(); + + switch (grid.type) + { + case GRID_PIT: + { + bool isFlooded = room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER; + bool isShaft = room.backdropType == BACKDROP_MINES_SHAFT || room.backdropType == BACKDROP_ASHPIT_SHAFT; + bool isFuelFlood = g_game->seedEffects.HasSeedEffect(SEED_G_FUEL) && + g_game->GetStageID() == STAGE_ID_FLOODED && room.waterAmount > 0.5f; + if (room.backdropType == BACKDROP_MINES ? isFlooded : (isShaft && isFlooded) || isFuelFlood) + reconstruction_missing("Room::render_grid_entity_light 0080c810: the lava pits"); + return; + } + case GRID_DOOR: + if (is_door_lit(static_cast(grid))) + reconstruction_missing("Room::render_grid_entity_light 0080c810: the doors' lights"); + return; + case GRID_TRAPDOOR: + if (Room::IsCurrentRoomLastBoss() && g_game->IsMausoleumHeartStage()) + reconstruction_missing("Room::render_grid_entity_light 0080c810: the trapdoor's light"); + return; + case GRID_PRESSURE_PLATE: + { + float alpha = grid.state == 0 ? 1 : PLATE_PRESSED_ALPHA; + ColorMod color = LIGHT_PLATE; + if (grid.variant == PLATE_VARIANT_REWARD) color = LIGHT_PLATE_REWARD; + else if (grid.variant == PLATE_VARIANT_ROOM_CLEAR) color = LIGHT_PLATE_CLEAR; + else if (grid.state != 0) return; + if (grid.variant == PLATE_VARIANT_REWARD || grid.variant == PLATE_VARIANT_ROOM_CLEAR) color._tint[3] = alpha; + light_draw(room, position, offset, color, PLATE_SCALE); + return; + } + case GRID_TELEPORTER: + { + if (!grid.sprite.animState.animData) return; + + const NullFrame* frame = grid.sprite.animState.GetNullFrameById(0); + if (!frame || !frame->isVisible) return; + + room.lightSprite.color = frame->color; + room.lightSprite.scale = frame->scale; + sprite_draw(room.lightSprite, vector_add(vector_add(render_position_get(position, RENDER_SNAPPED), offset), + frame->pos)); + return; + } + default: return; + } +} + +// The room's light color in the light overlay: the floor's light color darkened toward its shadow color by the +// darkness (full under the Curse of the Darkness or on Home at night, deeper in secret rooms, the mineshaft and the +// Mausoleum's Mom fight), lifted by a lightning flash. +static KColor room_light_color(Room& room, KColor shadow) +{ + Game& game = *g_game; + KColor light = room.fxLayers.fxParams.lightColor; + float darkness = is_curse_of_darkness() ? 1 : game.darknessStrength * game.darknessModifier; + bool isDarkRoom = room.roomType == ROOM_SUPERSECRET || room.roomType == ROOM_ULTRASECRET || + (game.HasAbandonedMineshaft() && game.currentDimensionIdx == DIMENSION_MIRROR) || + is_pre_ascent_mom_room(room); + + if (isDarkRoom) darkness = std::min(darkness + DARK_ROOM_DARKNESS, 1.0f); + if (game.stage == STAGE_HOME && game.stageType == STAGE_TYPE_WOTL && !room.IsSacrificeDone()) darkness = 1; + darkness = std::max(darkness - game.lightningIntensity, 0.0f); + return kcolor_rgba((shadow._red - light._red) * darkness + light._red, + (shadow._green - light._green) * darkness + light._green, + (shadow._blue - light._blue) * darkness + light._blue, light._alpha); +} + +// 0081e250 How dark the room's shadows are: the Beast's darkness, full in pitch black rooms, the floor's shadow alpha +// (lighter on Basement I, full under the Curse of the Darkness), halved by Night Light, raised by Glaucoma, toward +// the game's darkness, darker in secret rooms, the mineshaft and the death certificate's floor. Hush's room lightens +// with Hush's health. The Blue Womb's light room (-9) lightens near its center, not reconstructed yet. +float Room::GetLightingAlpha() +{ + Game& game = *g_game; + PlayerManager& players = game.playerManager; + + if (backdropType == BACKDROP_DUNGEON_BEAST) return game.darknessStrength * game.darknessModifier; + if (descriptor->flags & ROOM_DESCRIPTOR_FLAG_PITCH_BLACK) return 1; + + float alpha = 1; + if (!is_curse_of_darkness()) + { + alpha = fxLayers.fxParams.shadowAlpha; + bool isAltBasement = game.stageType == STAGE_TYPE_REPENTANCE || game.stageType == STAGE_TYPE_REPENTANCE_B || + game.stageType == STAGE_TYPE_AFTERBIRTH; + if (game.stage == STAGE_BASEMENT_I && !isAltBasement) alpha *= BASEMENT_SHADOW; + } + if (players.FirstCollectibleOwner(COLLECTIBLE_NIGHT_LIGHT, LAZARUS_SHARE_CHECK)) alpha *= NIGHT_LIGHT_SHADOW; + if (players.FirstCollectibleOwner(COLLECTIBLE_GLAUCOMA, LAZARUS_SHARE_CHECK)) + alpha = std::min(alpha + GLAUCOMA_SHADOW, 1.0f); + alpha = (game.darknessStrength - alpha) * game.darknessModifier + alpha; + + bool isMineshaft = game.HasAbandonedMineshaft() && game.currentDimensionIdx == DIMENSION_MIRROR; + bool isDark = roomType == ROOM_SUPERSECRET || roomType == ROOM_ULTRASECRET || isMineshaft || + game.currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE; + if (isDark) alpha = std::min(alpha + SECRET_SHADOW, 1.0f); + if (game.stage != STAGE_BLUE_WOMB) return alpha; + + if (descriptor->data->type == ROOM_BOSS) + { + for (Entity* entity : entityList.updateEL) + if (entity->type == ENTITY_HUSH && entity->variant == 0) + return std::max(1 - entity->health / entity->maxHitPoints, alpha); + return alpha; + } + if (game.currentRoomIdx == ROOM_IDX_BLUE_WOMB_LIGHT) + reconstruction_missing("Room::GetLightingAlpha 0081e250: the Blue Womb's light room (Game::GetNearestPlayer)"); + return alpha; +} + +// 0080ea80 Draws the room's shadow and light surfaces before the room: the entities' shadows, then (with lighting) the +// room's shadow color with the light layers in the room's light color added, the entities' and grid entities' lights, +// the light on the Mausoleum's Mom and the caustics' light. The Ashpit's dust, a flooded Mines room's pit mask and the +// floor under the water surface come after. +void Room::render_lighting() +{ + Game& game = *g_game; + RenderConfig& render = g_manager->optionsConfig.render; + bool isPitchBlack = descriptor->flags & ROOM_DESCRIPTOR_FLAG_PITCH_BLACK; + + surface_begin(roomSurfaces.shadow, KAGE::Graphics::TARGET_OWN_SIZE); + shadows_render(entityList, renderScrollOffset); + surface_end(); + + if (render.isLightingEnabled) + { + Vector offset = vector_add(renderScrollOffset, game.screenShakeOffset); + KColor shadow = isPitchBlack ? BLACK : fxLayers.fxParams.shadowColor; + + surface_begin(roomSurfaces.lightOverlay, KAGE::Graphics::TARGET_SCREEN_SIZE); + render_color_shader_pass(screen_quad(shadow)); + KAGE::Graphics::manager.blend_set(KAGE::Graphics::BLEND_ADDITIVE); + if (backdropType == BACKDROP_DUNGEON_BEAST) beastArena.render_light(); + else if (!isPitchBlack) fxLayers.lighting_layers_render(room_light_color(*this, shadow)); + + litGridIndices.clear(); + for (Entity* entity : entityList.updateEL) entity_light_render(*this, *entity, offset); + for (int i = 0; i < gridWidth * gridHeight; i++) + if (gridEntities[i]) grid_light_render(*this, *gridEntities[i], offset); + if (roomType == ROOM_BOSS && descriptor->data->subtype == BOSS_MOM_MAUSOLEUM && game.IsPreAscent()) + { + lightSprite.scale = vector_make(1, 1); + lightSprite.color = COLOR_DEFAULT; + sprite_draw_at(lightSprite, GetCenterPos(), offset); + } + if (render.isCausticsEnabled && (game.darknessModifier > 0 || !is_curse_of_darkness())) + water_render(*this, WATER_PASS_LIGHT); + surface_end(); + } + + darkness_overlay_render(*this); + if (isUnknown11f6) + { + isUnknown11f6 = false; + lava_pit_mask_render(*this); + } + floor_water_render(*this); +} diff --git a/src/room_render.h b/src/room_render.h new file mode 100644 index 0000000..580f4d2 --- /dev/null +++ b/src/room_render.h @@ -0,0 +1,53 @@ +#pragma once + +#include "anm2.h" +#include "kage_graphics.h" +#include + +constexpr int SHOCKWAVE_COUNT = 2; + +// The surfaces and images rooms draw through, file globals of the original made once for every room. +// shading is the room shape's shading image Room::LoadBackdropGraphics loads (DAT_00c797bc), drawn into shadingSurface. +struct RoomSurfaces +{ + KAGE::Graphics::ImagePtr ashMask; + KAGE::Graphics::ImagePtr caustics; + KAGE::Graphics::ImagePtr clouds; + KAGE::Graphics::ImagePtr coldLava; + KAGE::Graphics::ImagePtr dizzy; + KAGE::Graphics::ImagePtr dust; + KAGE::Graphics::ImagePtr dustTemp; + KAGE::Graphics::ImagePtr floorWater; + KAGE::Graphics::ImagePtr floorWaterV2; + KAGE::Graphics::ImagePtr heatWave; + KAGE::Graphics::ImagePtr lava; + KAGE::Graphics::ImagePtr lightOverlay; + KAGE::Graphics::ImagePtr mirror; + KAGE::Graphics::ImagePtr pitMask; + KAGE::Graphics::ImagePtr shading; + KAGE::Graphics::ImagePtr shadingSurface; + KAGE::Graphics::ImagePtr shadow; + KAGE::Graphics::ImagePtr shockwave; + KAGE::Graphics::ImagePtr texturedPit; + KAGE::Graphics::ImagePtr waterOverlay; +}; + +// A ripple through the room's picture (Game::MakeShockwave fills one): where it started, how far it spread and how +// strongly, and its frame of its duration. Room::Init ends them by setting frame to duration. +struct Shockwave +{ + Vector position{}; + float amplitude = 0; + float speed = 0; + float time = 0; + int duration = 0; + int frame = 0; +}; + +extern RoomSurfaces roomSurfaces; + +// Room's in the original (0x70c4): there is one room at a time. +extern std::array roomShockwaves; + +void room_surfaces_init(); +KColor kcolor_apply(const ColorMod& color, const KColor& input); diff --git a/src/room_transition.cpp b/src/room_transition.cpp index 25853e6..450b064 100644 --- a/src/room_transition.cpp +++ b/src/room_transition.cpp @@ -3,6 +3,7 @@ #include "entity_player.h" #include "fx_layers.h" #include "game.h" +#include "grid_entity_door.h" #include "log.h" #include "manager.h" #include "platform.h" diff --git a/src/room_update.cpp b/src/room_update.cpp new file mode 100644 index 0000000..3de2e69 --- /dev/null +++ b/src/room_update.cpp @@ -0,0 +1,846 @@ +#include "entity_npc.h" +#include "entity_player.h" +#include "game.h" +#include "grid_entity_door.h" +#include "log.h" +#include "manager.h" +#include "room.h" +#include "room_render.h" +#include "seeds.h" +#include +#include +#include + +// The grid paths an entity leaves: a permanent mark, the value it fades back to, and how fast it fades. +constexpr int GRID_PATH_DECAY_FRAMES = 3; +constexpr int GRID_PATH_PERMANENT = 3999; +constexpr int GRID_PATH_RESET = 900; +constexpr int GRID_PATH_DECAY_MAX = 100; +constexpr int GRID_PATH_UNIT = 1000; +constexpr int GRID_TIMER_MAX = 99; + +// The frames a room waits once its enemies are gone before it counts as cleared (a crawlspace's exit room longer). +constexpr int ROOM_CLEAR_DELAY = 10; +constexpr int ROOM_CLEAR_DELAY_DUNGEON_EXIT = 20; +constexpr int OUTPUT_GROUP_ROOM_CLEAR = 9; +constexpr int DUNGEON_ROTGUT = 2; +constexpr int DUNGEON_ROTGUT_HEART = 3; + +// Entering a door: how near a player stands to its cell's edge, how near to bump a locked door open, and where each +// side's door edge sits from its cell's center. Tainted Forgotten pushes doors by its speed. +constexpr float DOOR_ENTER_DISTANCE = 25; +constexpr float DOOR_UNLOCK_DISTANCE = 60; +constexpr float DOOR_EDGE = 18; +constexpr float DOOR_EDGES[][2] = {{-DOOR_EDGE, 0}, {0, -DOOR_EDGE}, {DOOR_EDGE, 0}, {0, DOOR_EDGE}}; +constexpr float DOOR_PUSH_SPEED_SQUARED = 4; +constexpr float DOOR_PUSH_FRAMES = 2; +constexpr int DOOR_SLOT_SIDES = 4; +constexpr float DUNGEON_EXIT_MARGIN = 20; + +// The weather a stage rains down: the drops' chances, and the Downpour's lightning flash and thunder. +constexpr float WEATHER_DROP_Y = -10; +constexpr uint32_t DROP_CHANCE_RARE = 30; +constexpr uint32_t DROP_CHANCE_WOMB = 6; +constexpr uint32_t DROP_CHANCE_DROSS = 20; +constexpr uint32_t LIGHTNING_FRAMES = 4; +constexpr uint32_t LIGHTNING_CHANCE = 100; +constexpr float LIGHTNING_MIN = 1.3f; +constexpr float LIGHTNING_RANGE = 0.6f; +constexpr float THUNDER_PITCH_MIN = 0.9f; +constexpr float THUNDER_PITCH_RANGE = 0.2f; +constexpr int THUNDER_DELAY = 90; + +// The walls bleeding and Flush! filling the room, and the lava's cooling under water. +constexpr int BLOOD_DROPS_MAX = 32; +constexpr float BLOOD_SPEED = 5; +constexpr float FLUSH_FILL = 0.1f; +constexpr float FLUSH_FLOOD_LOW = 0.89f; +constexpr float FLUSH_FLOOD_HIGH = 0.91f; +constexpr float LAVA_COOLING = 0.92f; +constexpr float LAVA_SOLID = 0.2f; +constexpr float LAVA_GONE = 0.001f; + +// The Mausoleum's heart keeps the room dark, and a bomb rain drops a troll bomb every few frames. +constexpr int HEART_DARK_FRAMES = 2; +constexpr int HEART_DARKNESS_TIMEOUT = 10; +constexpr int BOMB_RAIN_FRAMES = 5; + +// The Dataminer's glitch of the music: one frame in ten it bends the pitch low or high and sometimes the volume. +constexpr uint32_t DATAMINER_GLITCH_CHANCE = 10; +constexpr float DATAMINER_PITCH_LOW = 0.2f; +constexpr float DATAMINER_PITCH_LOW_RANGE = 0.1f; +constexpr float DATAMINER_PITCH_HIGH = 1.5f; +constexpr float DATAMINER_PITCH_HIGH_RANGE = 0.5f; +constexpr float DATAMINER_VOLUME_MIN = 0.3f; +constexpr float DATAMINER_VOLUME_RANGE = 0.7f; + +// The ambient loops: how far a sound source is heard, how fast a loop's volume follows its target, and the fly buzz's +// warble. +constexpr float AMBIENT_RANGE = 900; +constexpr float AMBIENT_STEP = 0.5f; +constexpr float AMBIENT_STEP_SLOW = 0.03f; +constexpr float AMBIENT_PITS = 0.1f; +constexpr float MINECART_VOLUME_MAX = 2; +constexpr float FLY_WARBLE = 0.02f; +constexpr float FLY_WARBLE_PERIODS[] = {53, 61, 23}; +constexpr int ALARM_DELAY = 10; +constexpr float ALARM_PAN_FRAMES = 60; +constexpr int MAP_WIDTH = 13; + +// The run, room and stage values Update tells apart. +constexpr ColorMod POOP_FX_COLOR = {{1, 1, 1, 3}, {0.7f, 0.1f, 0.9f, 1}, {0, 0, 0}}; +constexpr int COLLECTIBLE_FLUSH = 291; +constexpr int COLLECTIBLE_DATAMINER = 481; +constexpr int COLLECTIBLE_COUPON = 521; +constexpr int COLLECTIBLE_DEATHS_LIST = 530; +constexpr int COLLECTIBLE_BROKEN_SHOVEL = 550; +constexpr int COLLECTIBLE_VADE_RETRO = 653; +constexpr int COLLECTIBLE_ASTRAL_PROJECTION = 677; +constexpr int NULL_EFFECT_POOP_CLOUD = 64; +constexpr int PICKUP_COLLECTIBLE = 100; +constexpr int EFFECT_RAIN_DROP = 41; +constexpr int EFFECT_BLOOD_PARTICLE = 5; +constexpr int EFFECT_FALLING_EMBER = 87; +constexpr int CHALLENGE_SEEING_DOUBLE = 40; +constexpr int SOUND_BOSS_ROAR = 190; +constexpr int SOUND_THUNDER = 472; +constexpr int SOUND_ALARM = 460; +constexpr int PLAYER_THE_FORGOTTEN_B = 35; +constexpr int STAGE_HOME = 13; +constexpr int STAGE_ULTRA_GREED = 7; +constexpr int STAGE_ID_DOWNPOUR = 27; +constexpr int STAGE_ID_DROSS = 28; +constexpr int STAGE_ID_HOME = 35; +constexpr int STAGE_ID_CORPSE = 33; +constexpr int STAGE_TYPE_ORIGINAL = 0; +constexpr int STAGE_TYPE_AFTERBIRTH = 2; +constexpr int STAGE_TYPE_REPENTANCE = 4; +constexpr int STAGE_TYPE_REPENTANCE_B = 5; +constexpr int DIMENSION_DEATH_CERTIFICATE = 2; +constexpr int DIMENSION_MIRROR = 1; +constexpr int BOSS_THE_BEAST_ROOM = 91; +constexpr int ROOM_IDX_DUNGEON_BEAST = -16; +constexpr int GREED_LAST_STAGE = 5; +constexpr int GREED_LAST_STAGE_ID = 10; +constexpr uint32_t LEVEL_STATE_GREED_MONSTRO_SPAWNED = 1u << 12; +constexpr uint32_t LEVEL_STATE_MAMA_MEGA = 1u << 14; +constexpr uint32_t LEVEL_STATE_LEVEL_START_TRIGGERED = 1u << 19; +constexpr uint32_t ROOM_DESCRIPTOR_FLAG_MAMA_MEGA = 1u << 14; +constexpr int BACKDROP_DANK_DEPTHS = 9; +constexpr int BACKDROP_ERROR_ROOM = 26; +constexpr int BACKDROP_MINES = 32; +constexpr int BACKDROP_CORPSE = 34; +constexpr int BACKDROP_CORPSE2 = 43; +constexpr int BACKDROP_CORPSE3 = 44; +constexpr uint32_t RNG_SHIFT_COUPON_1 = 1; +constexpr uint32_t RNG_SHIFT_COUPON_2 = 27; + +// The entities with ambient loops of their own: enemies by type, laser and effect variants. +constexpr int SOUND_NPC_TYPES[] = {13, 14, 18, 25, 33, 61, 80, 214, 222, 249, 256, 281, 296, + 306, 808, 819, 838, 868, 886, 893, 950, 951, 965}; +constexpr int SOUND_LASER_VARIANTS[] = {6, 15}; +constexpr int SOUND_EFFECT_VARIANTS[] = {168, 171, 178, 180, 193}; + +// The ambient loops update_ambient_sounds plays, in the order it sets them, and each one's volume step and scale. +struct AmbientSound +{ + int soundId; + float step; + float scale; +}; + +enum AmbientLoop +{ + AMBIENT_FIRE, + AMBIENT_FLIES, + AMBIENT_LASER, + AMBIENT_FATTY_LASER, + AMBIENT_WATER, + AMBIENT_RAIN_LOOP, + AMBIENT_CURRENT, + AMBIENT_LAVA, + AMBIENT_PORTAL, + AMBIENT_MINECART, + AMBIENT_BALL_AND_CHAIN, + AMBIENT_BEAM, + AMBIENT_BEAST, + AMBIENT_DOGMA, + AMBIENT_DOGMA_ANGEL, + AMBIENT_STATIC, + AMBIENT_LOOP_COUNT +}; + +constexpr AmbientSound AMBIENT_SOUNDS[AMBIENT_LOOP_COUNT] = { + {269, AMBIENT_STEP, 1}, {4, AMBIENT_STEP, 1}, {279, AMBIENT_STEP, 1}, + {281, AMBIENT_STEP, 1}, {163, AMBIENT_STEP_SLOW, 1}, {473, AMBIENT_STEP_SLOW, 1}, + {476, AMBIENT_STEP_SLOW, 0.8f}, {480, AMBIENT_STEP_SLOW, 1}, {161, AMBIENT_STEP, 1}, + {505, AMBIENT_STEP, 1}, {580, AMBIENT_STEP, 1}, {535, AMBIENT_STEP, 1}, + {558, AMBIENT_STEP, 1.3f}, {553, AMBIENT_STEP, 1.5f}, {555, AMBIENT_STEP, 1.5f}, + {612, AMBIENT_STEP, 1}}; + +// The volumes the ambient loops played at last, each easing toward its new one (Room's in the original, 0x7084). +static std::array ambientVolumes{}; + +static bool is_greed() +{ + return g_game->difficulty == DIFFICULTY_GREED || g_game->difficulty == DIFFICULTY_GREEDIER; +} + +static float random_unit() +{ + return (float)Random() * 2.3283064e-10f; +} + +static Entity* entity_spawn(int type, int variant, Vector position, Vector velocity, uint32_t seed) +{ + return g_game->Spawn({.position = position, .velocity = velocity, .type = type, .variant = variant, .seed = seed}); +} + +static bool is_npc_type(int type) +{ + return (g_game->deathmatchManager.is_active() && type == ENTITY_PLAYER) || + (type >= ENTITY_FIRST_ENEMY && type <= ENTITY_LAST_ENEMY); +} + +template static bool contains(const List& list, int value) +{ + return std::find(std::begin(list), std::end(list), value) != std::end(list); +} + +// Whether the room has an entity of a type and variant, as the original's type query finds. +static bool entities_any(EntityList& list, int type, int variant) +{ + return std::any_of(list.updateEL.begin(), list.updateEL.end(), + [&](Entity* entity) { return entity->IsType(type, variant, -1); }); +} + +// The stage id the room's stage plays as: Red Redemption's room's own stage type, nothing in the death certificate's +// floor (-1). +static int room_stage_id() +{ + Game& game = *g_game; + + if (game.challenge == CHALLENGE_RED_REDEMPTION) + return RoomConfig::GetStageID((int)game.stage, game.GetRoomStageType(game.currentRoomIdx), ROOM_MODE_CURRENT); + if (game.currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) return -1; + return RoomConfig::GetStageID((int)game.stage, (int)game.stageType, ROOM_MODE_CURRENT); +} + +// The grid paths an entity left fade a step every few frames, back to 900 from a permanent mark, and the cells' +// timers count down. +void Room::grid_paths_decay() +{ + for (int i = 0; i < gridWidth * gridHeight; i++) + { + int path = gridPaths[i]; + int fade = path % GRID_PATH_UNIT; + + if (path == GRID_PATH_PERMANENT) gridPaths[i] = GRID_PATH_RESET; + else if (fade < GRID_PATH_RESET) gridPaths[i] = path - std::min(fade, GRID_PATH_DECAY_MAX); + if (gridTimers[i] >= 1 && gridTimers[i] <= GRID_TIMER_MAX) gridTimers[i] = (int16_t)std::max(gridTimers[i] - 1, 0); + } +} + +// The first frame's work: a boss room's roar on the first visit (but Greed's first boss before it spawns), and the +// Myosotis pickups carried from the last floor into the floor's first room. +void Room::first_frame_update() +{ + bool isGreedBossPending = is_greed() && g_game->stage == STAGE_ULTRA_GREED && descriptor->data->subtype == 0 && + !(g_game->levelStateFlags & LEVEL_STATE_GREED_MONSTRO_SPAWNED); + if (roomType == ROOM_BOSS && descriptor->visitedCount == 1 && !isGreedBossPending && bossId != 0) + { + int sound = SOUND_BOSS_ROAR; + seed_fart_sound_override(&sound); + g_manager->sfxManager.Play(sound); + } + if (g_game->levelStateFlags & LEVEL_STATE_LEVEL_START_TRIGGERED) return; + g_game->levelStateFlags |= LEVEL_STATE_LEVEL_START_TRIGGERED; + if (!g_game->myosotisPickups.empty()) reconstruction_missing("Room::Update 00802980: the Myosotis pickups"); +} + +// The floor sprite's animation, and the error room's floor kept on its looping Idle. +static void floor_sprite_update(Room& room) +{ + ANM2& floor = room.backdrop.floorSprite; + + floor.Update(); + if (room.backdropType != BACKDROP_ERROR_ROOM) return; + + const AnimationData* data = floor.animState.animData; + bool isIdle = data && data->name == "Idle" && (!data->isLooping || floor.animState.isPlaying); + if (isIdle || !floor.SetAnimation("Idle")) return; + + floor.animState.Rewind(); + floor.animState.isPlaying = true; +} + +// The Dataminer in the room's effects glitches the music: one frame in ten its pitch jumps low or high and, one time +// in four, its volume drops, otherwise the pitch goes back to normal. +static void dataminer_music_update(Room& room) +{ + MusicManager& music = g_manager->musicManager; + + if (room.temporaryEffects.isDisabled) return; + for (TemporaryEffect& effect : room.temporaryEffects.effects) + { + ItemType type = effect.item->type; + bool isCollectible = type == ITEM_PASSIVE || type == ITEM_ACTIVE || type == ITEM_FAMILIAR; + if (!isCollectible || effect.item->id != COLLECTIBLE_DATAMINER) continue; + + if (Random() % DATAMINER_GLITCH_CHANCE != 0) + { + music.pitch = music.targetPitch = 1; + music.channels[music.currentChannel].SetPitchAll(1); + return; + } + float pitch = Random() & 1 ? random_unit() * DATAMINER_PITCH_HIGH_RANGE + DATAMINER_PITCH_HIGH + : random_unit() * DATAMINER_PITCH_LOW_RANGE + DATAMINER_PITCH_LOW; + music.pitch = music.targetPitch = pitch; + music.channels[music.currentChannel].SetPitchAll(pitch); + float volume = (Random() & 3) == 0 ? random_unit() * DATAMINER_VOLUME_RANGE + DATAMINER_VOLUME_MIN : 1; + MusicChannel& channel = music.channels[music.currentChannel]; + channel.targetVolume = channel.volume = volume * g_manager->optionsConfig.musicVolume; + return; + } +} + +// 008020d0 Death's List: while a player holds it and the room's list is open, marks an enemy to kill next, and pays +// out once the room clears. Without it, or once done, the mark goes. +// The marking and the payout are not reconstructed yet. +static void deaths_list_update(Room& room) +{ + bool isOwned = g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_DEATHS_LIST, LAZARUS_SHARE_CHECK); + + if (isOwned && !room.isDeathsListDone) reconstruction_missing("Room::update_deaths_list 008020d0"); + room.isDeathsListDone = true; + room.deathsListTarget = nullptr; +} + +// 00823080 Fires an output group: the grid entities on its cells, its 1000.120 effects (which then die) and its +// callbacks. +// The callbacks are not reconstructed yet. +static void output_trigger(Room& room, int group) +{ + for (int gridIndex : room.outputGroupGridIndices[group]) + if (room.gridEntities[gridIndex]) room.gridEntities[gridIndex]->trigger_output(); + for (Entity* entity : room.entityList.updateEL) + { + if (entity->type != ENTITY_EFFECT || entity->variant != 120 || entity->subtype != group) continue; + + entity->isDead = true; + entity->Update(); + } + if (!room.outputGroupCallbacks[group].empty()) reconstruction_missing("Room::TriggerOutput 00823080: callbacks"); +} + +// 008068f0 Clears the room: marks and counts it, scores it, opens the exits the clear earns (the secret exit, the +// devil room's, Boss Rush, the Blue Womb, the Void), plays the clear jingle, rewards the players, and saves the +// rewind state. Not reconstructed yet. +static void room_clear_trigger(Room&) +{ + reconstruction_missing("Room::TriggerClear 008068f0"); +} + +// The clear check: while enemies or Greed's wave are left (or an ambush runs) the room holds off clearing; once the +// delay is out the doors open and the room clears, or a crawlspace's exit room sends the players back. +static void clear_update(Room& room) +{ + Game& game = *g_game; + bool isEnemyLeft = room.GetAliveEnemiesCount() > 0 || room.greedWaveTimer > 0; + bool isDungeon = room.roomType == ROOM_DUNGEON; + int dungeonKind = isDungeon ? room.descriptor->data->subtype : 0; + + if (!room.IsClear() && !game.ambush._isActive && !isEnemyLeft && room.roomClearDelay < 1) + output_trigger(room, OUTPUT_GROUP_ROOM_CLEAR); + if (game.ambush._isActive || isEnemyLeft) + { + room.roomClearDelay = isDungeon && dungeonKind == DUNGEON_ROTGUT_HEART ? ROOM_CLEAR_DELAY_DUNGEON_EXIT + : ROOM_CLEAR_DELAY; + return; + } + if (room.roomClearDelay >= 1) + { + room.roomClearDelay--; + return; + } + if (isDungeon && dungeonKind == DUNGEON_ROTGUT) return; + if (isDungeon && dungeonKind == DUNGEON_ROTGUT_HEART) + reconstruction_missing("Room::Update 00802980: Game::StartRoomTransition 006fd7c0 out of Rotgut's heart"); + + bool isBackwards = game.stage >= 1 && game.stage <= 6 && game.GetStateFlag(GAME_STATE_BACKWARDS_PATH); + if (game.stage != STAGE_HOME && !isBackwards) g_manager->musicManager.DisableLayer(0); + for (GridEntity_Door* door : room.doors) + if (door) door->Open(); + if (!(room.descriptor->flags & (ROOM_DESCRIPTOR_FLAG_CLEAR | ROOM_DESCRIPTOR_FLAG_CHALLENGE_DONE))) + room_clear_trigger(room); +} + +// 008024f0 The pressure plates, unless already triggered: the room remembers whether it has any, and once none of +// its plain plates is left unpressed (or a reward plate is pressed) the plates count as triggered and the room's +// fireplaces go out, red ones turning normal and purple ones blue. +// The fireplaces' morphs are not reconstructed yet. +static void pressure_plates_update(Room& room) +{ + if (room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_PRESSURE_PLATES_TRIGGERED) return; + + int plates = 0; + int unpressed = 0; + bool isRewardPressed = false; + for (int i = 0; i < room.gridWidth * room.gridHeight; i++) + { + GridEntity* plate = room.gridEntities[i]; + if (!plate || plate->type != GRID_PRESSURE_PLATE) continue; + + if (plate->variant == 0) + { + plates++; + if (plate->state == 0) unpressed++; + } + else if (plate->variant == 9 && plate->state != 0) isRewardPressed = true; + } + room.isTriggerPressurePlates = plates != 0; + if ((plates == 0 && !isRewardPressed) || unpressed != 0) return; + + room.descriptor->flags |= ROOM_DESCRIPTOR_FLAG_PRESSURE_PLATES_TRIGGERED; + for (Entity* entity : room.entityList.updateEL) + if (is_npc_type(entity->type) && entity->type == ENTITY_FIREPLACE && (entity->variant == 1 || entity->variant == 3)) + reconstruction_missing("Room::update_pressure_plates 008024f0: the fireplaces' morph"); +} + +// 007f01c0 Takes the players through the doors: a player standing at an open door's edge (a mirror door's closed +// edge) leaves through it, and one pushing into a locked door of a cleared room tries to unlock it. Tainted Forgotten +// pushes by its speed. A crawlspace's exits lead back up or out to its neighbours. +// Leaving a room (Game::save_rewind_state, Game::StartRoomTransition) is not reconstructed yet. +static void door_transitions_update(Room& room) +{ + Game& game = *g_game; + RoomConfig_Room* config = room.descriptor->data; + + if (game.roomTransition.mode != TRANSITION_NONE) return; + if (config && config->type == ROOM_DUNGEON && config->stageId == STAGE_ID_HOME) return; + for (size_t i = 0; i < game.playerManager.playerList.size(); i++) + { + Entity_Player& player = *game.GetPlayer((int)i); + if (player.variant != 0) continue; + + Vector position = player.pos; + for (int slot = 0; slot < DOOR_SLOT_COUNT; slot++) + { + GridEntity_Door* door = room.doors[slot]; + if (!door) continue; + + int side = slot % DOOR_SLOT_SIDES; + Vector edge = room.GetGridPosition(door->gridIndex); + edge = vector_make(edge.x + DOOR_EDGES[side][0], edge.y + DOOR_EDGES[side][1]); + float distance = std::hypot(edge.x - position.x, edge.y - position.y); + int direction = player.moveDirection; + bool isLockedKind = door->variant >= DOOR_LOCKED && door->variant <= DOOR_LOCKED_KEYFAMILIAR; + Vector velocity = player.velocity; + + if (player.playerType == PLAYER_THE_FORGOTTEN_B && + velocity.x * velocity.x + velocity.y * velocity.y > DOOR_PUSH_SPEED_SQUARED) + { + direction = std::abs(velocity.x) > std::abs(velocity.y) ? (velocity.x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT) + : (velocity.y >= 0 ? DIRECTION_DOWN : DIRECTION_UP); + if (isLockedKind) + distance = std::hypot(edge.x - (position.x + velocity.x * DOOR_PUSH_FRAMES), + edge.y - (position.y + velocity.y * DOOR_PUSH_FRAMES)); + } + + bool isOpen = door->state == DOOR_STATE_OPEN; + bool isPassable = door->doorFlags & DOOR_FLAG_MIRROR ? !isOpen : isOpen; + if (isPassable && distance < DOOR_ENTER_DISTANCE) + reconstruction_missing("Room::update_door_transitions 007f01c0: leaving through a door " + "(Game::StartRoomTransition 006fd7c0)"); + if (isLockedKind && room.IsClear() && distance < DOOR_UNLOCK_DISTANCE && direction == side) + door->TryUnlock(player, false); + } + if (room.roomType != ROOM_DUNGEON) continue; + + bool isUp = position.y < GRID_ORIGIN_Y; + bool isOut = room.bottomRightPos.x + DUNGEON_EXIT_MARGIN < position.x || position.x < 0 || + room.bottomRightPos.y + DUNGEON_EXIT_MARGIN < position.y; + if (isUp || isOut) + reconstruction_missing("Room::update_door_transitions 007f01c0: a crawlspace's exits " + "(Game::StartRoomTransition 006fd7c0)"); + } +} + +// Spawns a weather drop at a random x along the room's top, above the screen. +static void weather_drop_spawn(Room& room, int variant) +{ + uint32_t seed = Random(); + float x = (room.bottomRightPos.x - room.topLeftPos.x) * random_unit() + room.topLeftPos.x; + entity_spawn(ENTITY_EFFECT, variant, vector_make(x, WEATHER_DROP_Y), {}, seed)->Update(); +} + +// The stage's weather: rain drops in the Caves, Depths and Womb chapters' wet stage types (rarely, or often in the +// Womb's), drips in the Downpour and Dross, and embers from the Burning Basement's ceiling. Greed's floors count as +// their chapter's first stage. +static void weather_update(Room& room) +{ + Game& game = *g_game; + int stage = (int)game.stage; + int stageType = (int)game.stageType; + + if (is_greed()) + { + stage = stage < GREED_LAST_STAGE ? stage * 2 - 1 : stage == GREED_LAST_STAGE ? GREED_LAST_STAGE_ID : 0; + stageType = STAGE_TYPE_ORIGINAL; + } + bool isCaves = stage == 3 || stage == 4; + bool isWomb = stage == 7 || stage == 8; + bool isDepths = stage == 5 || stage == 6; + bool isBasement = stage == 1 || stage == 2; + bool isRareDrop = ((isCaves || isWomb) && stageType == STAGE_TYPE_ORIGINAL) || + (isDepths && stageType == STAGE_TYPE_AFTERBIRTH); + + bool isDrop = (isRareDrop && Random() % DROP_CHANCE_RARE == 0) || + (isCaves && stageType == STAGE_TYPE_AFTERBIRTH && Random() % DROP_CHANCE_WOMB == 0) || + (isWomb && stageType == STAGE_TYPE_AFTERBIRTH && (Random() & 7) == 0) || + (isBasement && stageType == STAGE_TYPE_REPENTANCE && (Random() & 3) == 0) || + (isBasement && stageType == STAGE_TYPE_REPENTANCE_B && (Random() & 3) == 0); + if (isDrop) weather_drop_spawn(room, EFFECT_RAIN_DROP); + else if (isBasement && stageType == STAGE_TYPE_AFTERBIRTH && Random() % DROP_CHANCE_DROSS == 0) + weather_drop_spawn(room, EFFECT_FALLING_EMBER); +} + +// The Downpour's lightning: one frame in four, one time in a hundred, a flash and a thunderclap. +static void lightning_update() +{ + if (room_stage_id() != STAGE_ID_DOWNPOUR) return; + if (g_game->frameCount % LIGHTNING_FRAMES != 0 || Random() % LIGHTNING_CHANCE != 0) return; + + g_game->lightningIntensity = random_unit() * LIGHTNING_RANGE + LIGHTNING_MIN; + float pitch = random_unit() * THUNDER_PITCH_RANGE + THUNDER_PITCH_MIN; + int sound = SOUND_THUNDER; + seed_fart_sound_override(&sound); + g_manager->sfxManager.Play(sound, {.volume = 1, .frameDelay = THUNDER_DELAY, .pitch = pitch}); +} + +// 00824a70 The drifting particles of the Corpse, Dross, the Beast's room, the Beast's crawlspace and the mineshaft: +// five on entering and one every 210 frames, drifting left across the room. Not reconstructed yet past its checks. +static void ambient_effects_update(Room& room) +{ + Game& game = *g_game; + int stageId = room_stage_id(); + bool isStage = game.currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE || stageId == STAGE_ID_CORPSE || + stageId == STAGE_ID_DROSS; + bool isBeastRoom = room.roomType == ROOM_BOSS && room.bossId == BOSS_THE_BEAST_ROOM; + bool isMineshaft = game.HasAbandonedMineshaft() && game.currentDimensionIdx == DIMENSION_MIRROR; + if (!isStage && !isBeastRoom && game.currentRoomIdx != ROOM_IDX_DUNGEON_BEAST && !isMineshaft && + game.currentDimensionIdx == 0) + return; + + int frames = room.GetFrameCount(); + if (frames != 0 && game.frameCount % 210 != 0) return; + reconstruction_missing("Room::update_ambient_effects 00824a70"); +} + +// 00824ee0 A water current carries the pickups, enemies and players standing in it along, and stirs ripples. +// Not reconstructed yet past its check. +static void water_current_update(Room& room) +{ + if (room.waterCurrent.x != 0 || room.waterCurrent.y != 0) + reconstruction_missing("Room::update_water_current 00824ee0"); +} + +// The walls bleeding for a while: blood particles burst from random points of the room's edge each frame, green in +// the Corpse. +static void walls_bleed_update(Room& room) +{ + if (room.bloodFromWallsDuration <= 0) return; + + float width = room.bottomRightPos.x - room.topLeftPos.x; + float height = room.bottomRightPos.y - room.topLeftPos.y; + room.bloodFromWallsDuration--; + for (int i = 0; i < std::min(room.bloodFromWallsCount, BLOOD_DROPS_MAX); i++) + { + float along = random_unit() * (height * 2 + width * 2); + Vector position = vector_make(along + room.topLeftPos.x, room.topLeftPos.y); + if (along >= width + height + width) position = vector_make(room.topLeftPos.x, along + room.topLeftPos.y - width * 2 - height); + else if (along >= width + height) position = vector_make(along + room.topLeftPos.x - width - height, room.bottomRightPos.y); + else if (along >= width) position = vector_make(room.bottomRightPos.x, along + room.topLeftPos.y - width); + + uint32_t seed = Random(); + float angle = random_unit() * 3.14f * 2; + Vector velocity = vector_make(std::cos(angle) * BLOOD_SPEED, std::sin(angle) * BLOOD_SPEED); + Entity* blood = entity_spawn(ENTITY_EFFECT, EFFECT_BLOOD_PARTICLE, position, velocity, seed); + if (room.backdropType == BACKDROP_CORPSE || room.backdropType == BACKDROP_CORPSE2 || + room.backdropType == BACKDROP_CORPSE3) + reconstruction_missing("Room::Update 00802980: the Corpse's green blood"); + blood->Update(); + } +} + +// Flush! fills the room with water, flooding it once nearly full, and water cools the lava down until it is gone. +// The pits' collisions under the changing water and lava are not reconstructed yet. +static void flood_update(Room& room) +{ + if (room.temporaryEffects.HasCollectibleEffect(COLLECTIBLE_FLUSH) && room.roomType != ROOM_DUNGEON) + { + room.waterAmount += FLUSH_FILL; + if (room.waterAmount > FLUSH_FLOOD_LOW && room.waterAmount < FLUSH_FLOOD_HIGH) + { + room.descriptor->flags |= ROOM_DESCRIPTOR_FLAG_FLOODED; + if (room.descriptor->flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER) + reconstruction_missing("Room::Update 00802980: Flush!'s pits"); + } + room.waterAmount = std::min(room.waterAmount, 1.0f); + } + if (room.waterAmount <= 0 || room.lavaIntensity <= 0) return; + + float lava = room.lavaIntensity * LAVA_COOLING; + if (lava < LAVA_SOLID && room.lavaIntensity >= LAVA_SOLID) + reconstruction_missing("Room::Update 00802980: the cooled lava's pits"); + room.lavaIntensity = lava < LAVA_GONE ? 0 : lava; + reconstruction_missing("Room::Update 00802980: the cooling lava's screen color (FUN_00823540)"); +} + +// 00801ee0 Greed mode's waves: the wave timer runs down to the next wave (the wait cut short once the room is empty), +// and Ultra Greed's room starts its fight once a player walks in. Not reconstructed yet past its checks. +static void greed_wave_update(Room& room) +{ + Game& game = *g_game; + + if (!is_greed()) return; + if (room.greedWaveTimer > 0) reconstruction_missing("Room::UpdateGreedWave 00801ee0: the wave timer"); + if (game.stage != STAGE_ULTRA_GREED || room.roomType != ROOM_BOSS) return; + if (game.levelStateFlags & LEVEL_STATE_GREED_MONSTRO_SPAWNED) return; + for (size_t i = 0; i < game.playerManager.playerList.size(); i++) + if (game.GetPlayer((int)i)->pos.y < 320) reconstruction_missing("Room::UpdateGreedWave 00801ee0: Ultra Greed"); +} + +// Coupon in a shop: once the players are in, one of the shop's items goes on sale, picked from the decoration seed. +static void coupon_update(Room& room) +{ + RoomDescriptor& descriptor = *room.descriptor; + bool isOwned = g_game->playerManager.FirstCollectibleOwner(COLLECTIBLE_COUPON, LAZARUS_SHARE_CHECK); + + if (room.roomType != ROOM_SHOP || !isOwned || !room.isInitialized || room.GetFrameCount() <= 1) return; + if (descriptor.shopItemIdx <= 0) return; + if (descriptor.shopItemIdx > descriptor.shopItemDiscountIdx && descriptor.shopItemDiscountIdx != -1) return; + + RNG rng = {descriptor.decorationSeed, RNG_SHIFT_COUPON_1, RNG_SHIFT_COUPON_2, RNG_SHIFT_COUPON_2}; + descriptor.shopItemDiscountIdx = (int16_t)rng.RandomInt((uint32_t)descriptor.shopItemIdx); +} + +// 00802980 Runs the room for a frame: its first frame's extras, Genesis's timer, the exorcism and time effects, the +// poop clouds, the removed and living grid entities and the grid paths, the Broken Shovel's and Ambush's challenges, +// the entity list and effect layers, the floor sprite and the Beast's arena, the Dataminer's music, temporary +// effects and Death's List, the clear check with its doors, pressure plates and door transitions, the weather and +// ambient spawns, the Mausoleum's darkness, the shockwaves, bleeding walls, flooding, Greed's waves, the ambient +// sounds, the shop's restock and Coupon, and the pending pickup and enemy changes. +// The extras of rarer rooms stop where marked. +void Room::Update() +{ + Game& game = *g_game; + PlayerManager& players = game.playerManager; + + isUnknown7220 = false; + if (isInitialized && game.frameCount - enterFrame == 1) first_frame_update(); + if (genesisTimer >= 0) + { + if (genesisTimer == 0 && game.currentRoomIdx == ROOM_GENESIS_IDX) + reconstruction_missing("Room::Update 00802980: Genesis's items"); + genesisTimer--; + } + isExorcistActive = players.FirstCollectibleOwner(COLLECTIBLE_VADE_RETRO, LAZARUS_SHARE_CHECK) != nullptr; + if (temporaryEffects.HasCollectibleEffect(COLLECTIBLE_ASTRAL_PROJECTION)) + g_manager->musicManager.targetPitch = time_scale_update(); + if (!temporaryEffects.isDisabled && temporaryEffects.HasNullEffect(NULL_EFFECT_POOP_CLOUD)) + fxLayers.AddPoopFx(POOP_FX_COLOR); + if (descriptor->gridIndex == ROOM_LIL_PORTAL_IDX) reconstruction_missing("Room::Update 00802980: the Lil Portal room"); + + bool isEnterFrame = isInitialized && game.frameCount == enterFrame; + bool isHasEntities = !entityList.updateEL.empty(); + if (isEnterFrame && isHasEntities && game.challenge == CHALLENGE_SEEING_DOUBLE) + reconstruction_missing("Room::Update 00802980: Seeing Double's doubled enemies"); + if (isEnterFrame && players.GetGFuelCount() > 3 && isHasEntities) + reconstruction_missing("Room::Update 00802980: G-Fuel's champions"); + + if (waterLerpColorCountdown > 0) waterLerpColorCountdown--; + for (int gridIndex : pendingGridRemovals) + { + if (gridIndex < 0 || gridIndex >= gridWidth * gridHeight || !gridEntities[gridIndex]) continue; + delete gridEntities[gridIndex]; + gridEntities[gridIndex] = nullptr; + } + pendingGridRemovals.clear(); + for (int i = 0; i < gridWidth * gridHeight; i++) + if (gridEntities[i]) gridEntities[i]->Update(); + if (game.frameCount % GRID_PATH_DECAY_FRAMES == 0) grid_paths_decay(); + + bool isShovelOwned = players.FirstCollectibleOwner(COLLECTIBLE_BROKEN_SHOVEL, LAZARUS_SHARE_CHECK); + Room& current = *game.room; + if (isShovelOwned && isInitialized && game.frameCount - enterFrame == 4 && current.roomType == ROOM_BOSSRUSH && + !(current.descriptor->flags & ROOM_DESCRIPTOR_FLAG_CHALLENGE_DONE) && + !entities_any(entityList, ENTITY_PICKUP, PICKUP_COLLECTIBLE)) + game.ambush.StartChallenge(); + if ((roomType == ROOM_CHALLENGE || roomType == ROOM_BOSSRUSH) && game.ambush._isActive) game.ambush.Update(); + if (isCardAgainstHumanity) card_against_humanity_fill(); + + int bosses = GetAliveBossesCount(); + if (bosses < 1 && lastAliveBossCount > 0) + { + if (g_manager->netplayManager.is_online()) + KAGE_LogMessage(LOG_INFO, (uint8_t*)("[Frame " + std::to_string(game.frameCount) + "] ").c_str()); + KAGE_LogMessage(LOG_INFO, (uint8_t*)"[warn] last boss died without triggering the deathspawn.\n"); + } + lastAliveBossCount = bosses; + entityList.Update(UPDATE_NORMAL); + fxLayers.Update(PLAYER_FOLLOW_EASE); + + floor_sprite_update(*this); + beastArena.update(); + if (isInitialized && game.frameCount - enterFrame == 1) game.UpdateBackwardsPathStages(); + dataminer_music_update(*this); + temporaryEffects.Update(); + deaths_list_update(*this); + clear_update(*this); + for (GridEntity_Door* door : doors) + if (door && door->state == DOOR_STATE_OPEN_DENIED) door->Open(); + pressure_plates_update(*this); + door_transitions_update(*this); + weather_update(*this); + lightning_update(); + update_ambient_spawns(); + ambient_effects_update(*this); + water_current_update(*this); + + if (game.IsMausoleumHeartStage()) + { + if (!isInitialized || game.frameCount - enterFrame < HEART_DARK_FRAMES) game.darknessModifier = 1; + game.darknessStrength = 1; + game.darknessTimeout = HEART_DARKNESS_TIMEOUT; + } + RoomConfig_Room* config = descriptor->data; + if (config && config->type == ROOM_DUNGEON && config->stageId == STAGE_ID_HOME) + reconstruction_missing("Room::Update 00802980: the Home crawlspace's cold and steam"); + for (Shockwave& wave : roomShockwaves) + { + if (wave.frame >= wave.duration) continue; + wave.frame++; + wave.time += wave.speed; + } + walls_bleed_update(*this); + flood_update(*this); + bool isMamaMega = game.levelStateFlags & LEVEL_STATE_MAMA_MEGA && !(descriptor->flags & ROOM_DESCRIPTOR_FLAG_MAMA_MEGA); + if (isMamaMega && isInitialized && game.frameCount - enterFrame == 1 && !game.IsPaused()) + reconstruction_missing("Room::MamaMegaExplosion 00820910"); + if (slowdownDuration > 0) slowdownDuration--; + greed_wave_update(*this); + update_ambient_sounds(); + + if (shopRestockTimer > 0 && --shopRestockTimer < 1) + { + shopRestockTimer = -1; + reconstruction_missing("Room::ShopRestockPartial 008158a0"); + } + coupon_update(*this); + if (unknown7230 > 0) + { + if (unknown7230 % BOMB_RAIN_FRAMES == 0) reconstruction_missing("Room::Update 00802980: the troll bomb rain"); + unknown7230--; + } + if (isPickupVisionInvalid) reconstruction_missing("Room::Update 00802980: the pickups' loot previews"); + if (isUnknown7769) reconstruction_missing("Room::Update 00802980: the split collectible pedestals"); + if (DAT_00c82674 != DAT_00c82678) reconstruction_missing("Room::Update 00802980: the enemies pending a split"); +} + +// Whether an entity plays an ambient loop: the enemies, lasers and effects with sounds of their own. +static bool is_ambient_source(Entity& entity) +{ + if (is_npc_type(entity.type)) return !entity.isDead && contains(SOUND_NPC_TYPES, entity.type); + if (entity.type == ENTITY_LASER) return contains(SOUND_LASER_VARIANTS, entity.variant); + return entity.type == ENTITY_EFFECT && contains(SOUND_EFFECT_VARIANTS, entity.variant); +} + +// How loud a source of the floor is at a distance from the players: fading out with its square at AMBIENT_RANGE. +static float ambient_falloff(Vector source, Vector center) +{ + float closeness = std::max(1 - std::hypot(source.x - center.x, source.y - center.y) / AMBIENT_RANGE, 0.0f); + return closeness * closeness; +} + +// The pits' ambient volume: each pit near the players adds its share. +static float pits_volume(Room& room, Vector center) +{ + float volume = 0; + for (int i = 0; i < room.gridWidth * room.gridHeight; i++) + if (room.gridEntities[i] && room.gridEntities[i]->type == GRID_PIT) + volume += ambient_falloff(room.GetGridPosition(i), center) * AMBIENT_PITS; + return volume; +} + +// 00800500 Plays the room's ambient loops at the volumes its sources call for near the players: fire, flies, lasers, +// the Dank Depths' and flooded Mines' pits, rain, a water current, lava, portals, minecarts and the bosses' own, each +// volume easing toward its target. Then the alarm a fast Basement I boss clear sets off, panned toward the starting +// room. +// The entities' own loops are not reconstructed yet. +void Room::update_ambient_sounds() +{ + Game& game = *g_game; + SFXManager& sfx = g_manager->sfxManager; + std::array volumes{}; + float flyPitch = 0; + Vector center = game.playerManager.players_center_position(CENTER_CACHED); + + if (!game.IsPaused() || game.roomTransition.mode != TRANSITION_NONE) + { + for (Entity* entity : entityList.updateEL) + if (is_ambient_source(*entity)) reconstruction_missing("Room::update_ambient_sounds 00800500: the entities' loops"); + + float warble = 0; + for (float period : FLY_WARBLE_PERIODS) warble += std::sin((float)game.frameCount / period); + flyPitch = warble * FLY_WARBLE + 1; + if (numRainSpawners > 0) + reconstruction_missing("Room::update_ambient_sounds 00800500: the rain (Room::init_rain's spawners)"); + if (waterCurrent.x != 0 || waterCurrent.y != 0) volumes[AMBIENT_CURRENT] = 1; + + RoomConfig_Room* config = descriptor->data; + bool isFlooded = descriptor->flags & ROOM_DESCRIPTOR_FLAG_HAS_WATER && descriptor->pitsCount > 0; + if (config && config->type == ROOM_DUNGEON && config->stageId == STAGE_ID_HOME) + { + float closeness = std::max(1 - (bottomRightPos.y - 30 - center.y) / AMBIENT_RANGE, 0.0f); + volumes[AMBIENT_LAVA] = std::min(closeness * closeness, 1.0f); + } + else if (backdropType == BACKDROP_MINES && isFlooded) + volumes[AMBIENT_LAVA] = std::min(pits_volume(*this, center) * lavaIntensity, 1.0f); + if (backdropType == BACKDROP_DANK_DEPTHS && isFlooded) + volumes[AMBIENT_WATER] = std::min(pits_volume(*this, center), 1.0f); + volumes[AMBIENT_MINECART] = std::min(volumes[AMBIENT_MINECART], MINECART_VOLUME_MAX); + } + + for (int i = 0; i < AMBIENT_LOOP_COUNT; i++) + { + const AmbientSound& sound = AMBIENT_SOUNDS[i]; + float last = ambientVolumes[i]; + float volume = std::clamp(volumes[i], last - sound.step, last + sound.step); + ambientVolumes[i] = volume; + sfx.SetAmbientSound(sound.soundId, volume * sound.scale, i == AMBIENT_FLIES ? flyPitch : 1); + } + + if (unknown72fc < 0) return; + if (++unknown72fc == ALARM_DELAY) + { + g_manager->sfxManager.Play(SOUND_ALARM); + return; + } + if (unknown72fc < ALARM_DELAY) return; + if (!sfx.IsPlaying(SOUND_ALARM)) + { + unknown72fc = -1; + return; + } + if (game.currentRoomIdx < 0) return; + + int start = game.startingRoomIdx; + int here = game.currentRoomIdx; + float rows = (float)(start / MAP_WIDTH - here / MAP_WIDTH); + float columns = (float)((here / MAP_WIDTH - start / MAP_WIDTH) * MAP_WIDTH - here + start); + float length = std::hypot(rows, columns); + if (length > 0) columns *= 1 / length; + float fade = std::clamp((float)(unknown72fc - ALARM_DELAY) / ALARM_PAN_FRAMES, 0.0f, 1.0f); + sfx.pan_adjust(SOUND_ALARM, fade * columns); +} diff --git a/src/weapon.cpp b/src/weapon.cpp new file mode 100644 index 0000000..b38e198 --- /dev/null +++ b/src/weapon.cpp @@ -0,0 +1,553 @@ +#include "weapon.h" +#include "entity_familiar.h" +#include "entity_player.h" +#include "entity_tear.h" +#include "game.h" +#include "log.h" +#include "menu_manager.h" +#include +#include + +constexpr float DEGREES_TO_RADIANS = 0.017453292f; +constexpr float EYE_DROPS_FAST_RATE = 0.5833333f; +constexpr float EYE_DROPS_SLOW_RATE = 0.41666666f; +constexpr float EYE_OFFSET_MIN = 0.3f; +constexpr float EYE_OFFSET_RANGE = 0.2f; +constexpr float EPIPHORA_SPREAD = 16; +constexpr float EPIPHORA_SPREAD_DIVISOR = 3; +constexpr int EPIPHORA_FRAMES_PER_STEP = 90; +constexpr float FIRE_BLINK_SCALE = -0.45f; +constexpr float INHERIT_SCALE = 0.6f; +constexpr float IPECAC_SPEED_MIN = 0.9f; +constexpr float IPECAC_SPEED_RANGE = 0.2f; +constexpr float PEE_SPREAD = 24; +constexpr float RANDOM_UNIT = 2.3283064e-10f; +constexpr float SHOT_ROTATION_STEP = 45; +constexpr float FULL_TURN = 360; +constexpr float SHOT_SPEED_BASE = 10; +constexpr float SHOTS_PER_SECOND = 30; +constexpr float TEAR_SPEED_SPREAD = 0.2f; +constexpr float TEAR_SPEED_MIN = 0.8f; +constexpr float CHARGE_BAR_FULL = 1; +constexpr int FIRE_BLINK_BASE = 7; +constexpr int FIRE_BLINK_MIN = 11; +constexpr int MAX_SHOTS_PER_FRAME = 8; +constexpr int NUMBER_ONE_BLINK = 16; +constexpr int SEEDED_VARIANT_NONE = -1; +constexpr int SEEDED_VARIANT_SPEEDY = 2; + +constexpr int COLLECTIBLE_EYE_DROPS = 600; +constexpr int COLLECTIBLE_EYE_OF_THE_OCCULT = 572; +constexpr int COLLECTIBLE_EPIPHORA = 368; +constexpr int COLLECTIBLE_IPECAC = 149; +constexpr int COLLECTIBLE_KIDNEY_STONE_WEAPON = 440; +constexpr int COLLECTIBLE_LEAD_PENCIL = 444; +constexpr int COLLECTIBLE_MARKED = 394; +constexpr int COLLECTIBLE_NUMBER_ONE = 6; +constexpr int COLLECTIBLE_POLYPHEMUS = 169; +constexpr int COLLECTIBLE_STAPLER = 708; +constexpr int COLLECTIBLE_ANALOG_STICK = 465; +constexpr int COLLECTIBLE_TECHNOLOGY_2 = 152; +constexpr int COLLECTIBLE_ISAACS_TEARS = 323; +constexpr int TRINKET_TORN_CARD = 157; +constexpr int BABY_SPIN = 8; +constexpr int MARKED_TARGET = 30; +constexpr int MARKED_OCCULT_TARGET = 153; +// The items that react to each tear fired: Mom's Wig, Immaculate Heart, Bird's Eye, Ghost Pepper, Eye of Greed and Lead +// Pencil. +constexpr int TEAR_TRIGGER_ITEMS[] = {217, 573, 616, 495, 450, COLLECTIBLE_LEAD_PENCIL}; + +// A random float in [0, 1), as the game turns Random() into one. +static float random_unit() { return (float)Random() * RANDOM_UNIT; } + +// A vector turned by an angle in degrees. +static Vector vector_rotate(Vector v, float degrees) +{ + float radians = degrees * DEGREES_TO_RADIANS; + float cosine = std::cos(radians); + float sine = std::sin(radians); + return vector_make(v.x * cosine - v.y * sine, v.x * sine + v.y * cosine); +} + +// A vector turned by a random angle within half a spread either side, or as it is without a spread. +static Vector vector_spread(Vector v, float spreadAngle) +{ + return spreadAngle == 0 ? v : vector_rotate(v, (random_unit() - 0.5f) * spreadAngle); +} + +static Vector vector_scale(Vector v, float scale) { return vector_make(v.x * scale, v.y * scale); } + +static bool is_zero(Vector v) { return v.x == 0 && v.y == 0; } + +// 009f9020 Makes the weapon of a type for an owner through the type's maker, written only for tears (009f9260). +WeaponPtr weapon_create(WeaponType type, Entity* owner) +{ + if (type != WEAPON_TEARS) reconstruction_missing("Isaac::CreateWeapon 009f9020 (weapons other than tears)"); + + WeaponPtr weapon(new Weapon_Tears()); + weapon->Init(type, owner); + return weapon; +} + +// 009f9050 Drops the weapon's links, then frees it. +void WeaponDelete::operator()(Weapon* weapon) const +{ + weapon->ClearReferences(); + delete weapon; +} + +// Lets the owner go: a familiar's fire cooldown restarts, a player's costumes stop their item animations. +Weapon::~Weapon() +{ + if (owner && owner->IsFamiliar()) static_cast(owner)->fireCooldown = 0; + else if (owner && owner->is_player()) owner->ToPlayer()->stop_costume_item_anims(); +} + +// 009f34d0 Resets the weapon, then gives it its type and owner. +void Weapon::Init(WeaponType type, Entity* weaponOwner) +{ + Reset(); + owner = weaponOwner; + weaponType = type; +} + +// 009f34f0 Counts the fire delay down at the owner's speed, outside interpolation frames. +void Weapon::Update(bool isInterpolated) +{ + if (isInterpolated || fireDelay <= -1) return; + fireDelay -= owner ? owner->speedMultiplier : 1; +} + +// 009f3540 What every weapon fires alongside its own shots: Technology 2's laser, which is not written yet. Without it +// a laser left over is removed. +void Weapon::Fire(const Vector&, bool, bool) +{ + Entity_Player* player = owner_player(); + if (player && player->HasCollectible(COLLECTIBLE_TECHNOLOGY_2) && weaponType != WEAPON_UMBILICAL_WHIP) + reconstruction_missing("Weapon::Fire 009f3540 (Technology 2)"); + + Entity* laser = technology2Laser; + if (laser && !laser->isDead) laser->Remove(); +} + +// 009f3480 Drops the links and restarts the fire delay, charge and aim. The original also writes two fields nothing +// reads. +void Weapon::Reset() +{ + ClearReferences(); + fireDelay = 0; + maxFireDelay = WEAPON_MAX_FIRE_DELAY_DEFAULT; + charge = 0; + numFired = 0; + direction = {}; +} + +// 009f3320 Removes Technology 2's laser and forgets it. +void Weapon::ClearReferences() +{ + Entity* laser = technology2Laser; + if (!laser) return; + + laser->Remove(); + technology2Laser = nullptr; +} + +// 009f4150 How full the charge bar is, from 0 to 1, or empty under Soy Milk or without a charge. +float Weapon::GetChargeBarAmount() +{ + if (modifiers & WEAPON_MOD_SOY_MILK) return 0; + + float maxCharge = GetMaxCharge(); + if (maxCharge <= 0 || (charge <= CHARGE_BAR_FULL && charge < maxCharge)) return 0; + return std::min(std::max(charge / maxCharge, 0.0f), CHARGE_BAR_FULL); +} + +// 009f3150 The entity the weapon fires as. The original reads the first field of the subclass, which for tears is +// Cursed Eye's charge count: plain weapons have none. +Entity* Weapon::GetMainEntity() { return nullptr; } + +// The player the weapon fires for: its owner, or the player of its owning familiar. +Entity_Player* Weapon::owner_player() +{ + if (!owner) return nullptr; + if (owner->is_player()) return owner->ToPlayer(); + return owner->IsFamiliar() ? static_cast(owner)->player : nullptr; +} + +// 009f3360 Whether shots snap to the four directions: unless the aim is fixed, or Analog Stick or Marked frees it. +bool Weapon::IsAxisAligned() +{ + Entity_Player* player = owner_player(); + return player && is_zero(fixedDirection) && !player->HasCollectible(COLLECTIBLE_ANALOG_STICK) && + !player->HasCollectible(COLLECTIBLE_MARKED); +} + +// 009f33e0 Where the weapon aims: the player's shot direction from a few frames ago, unless the aim is fixed or a +// Marked target leads it. +Vector Weapon::get_aim_direction(const Vector& defaultDirection) +{ + Entity_Player* player = owner_player(); + if (!player || (modifiers & WEAPON_MOD_FIXED_AIM)) return defaultDirection; + + bool isMarking = player->HasCollectible(COLLECTIBLE_MARKED) && player->markedTarget; + return !isMarking && is_zero(fixedDirection) ? player->delayed_shoot_direction() : defaultDirection; +} + +// 009f3bd0 Where the owner stands. +Vector Weapon::get_owner_position() { return owner ? owner->pos : Vector{}; } + +float Weapon::get_damage() { reconstruction_missing("Weapon::get_damage 009f3c80"); } +TearFlags Weapon::get_owner_tear_flags() { reconstruction_missing("Weapon::get_owner_tear_flags 009f3d00"); } +ColorMod Weapon::get_tear_color() { reconstruction_missing("Weapon::get_tear_color 009f3db0"); } +ColorMod Weapon::get_laser_color() { reconstruction_missing("Weapon::get_laser_color 009f3f60"); } + +// 009f41c0 How the owner's volley spreads, or a volley of none without a player. +Weapon_MultiShotParams Weapon::GetMultiShotParams() +{ + Entity_Player* player = owner_player(); + if (player) return player->GetMultiShotParams(weaponType); + + Weapon_MultiShotParams params; + params.numTears = 0; + return params; +} + +// 009fa1b0 The target effect Marked places, Eye of the Occult's own, or none without Marked or under Ludovico. +// A weapon without a player crashes in the original: here it places none. +int Weapon::marked_target_variant() +{ + Entity_Player* player = owner_player(); + if ((modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE) || !player || !player->HasCollectible(COLLECTIBLE_MARKED)) return 0; + return player->HasCollectible(COLLECTIBLE_EYE_OF_THE_OCCULT) ? MARKED_OCCULT_TARGET : MARKED_TARGET; +} + +// 009f57f0 The eye the owning player shoots from: -1 left, 1 right, 0 both. +int Weapon::tear_displacement() { return owner && owner->is_player() ? owner->ToPlayer()->tearDisplacement : 0; } + +// 009f5aa0 Whether shots turn with the eye, as under R U A Wizard or the spinning co-op baby. +bool Weapon::is_shot_rotated() +{ + if (!owner || !owner->is_player()) return false; + + Entity_Player& player = *owner->ToPlayer(); + return player.rUaWizardTimer > 0 || (player.variant == PLAYER_VARIANT_COOP_BABY && player.babySkin == BABY_SPIN); +} + +// 009f56c0 Keeps the owner's eyes shut for at least this long. +void Weapon::SetBlinkTime(int delay) +{ + Entity_Player* player = owner && owner->is_player() ? owner->ToPlayer() : nullptr; + if (player) player->blinkTime = std::max(player->blinkTime, delay); + else if (owner && owner->IsFamiliar()) + { + Entity_Familiar& familiar = *static_cast(owner); + familiar.headFrameDelay = std::max(familiar.headFrameDelay, delay); + } +} + +// 009f5720 Keeps the owner's head turned for at least this long. +void Weapon::SetHeadLockTime(int time) +{ + Entity_Player* player = owner && owner->is_player() ? owner->ToPlayer() : nullptr; + if (player) player->headDirectionTime = std::max(player->headDirectionTime, time); + else if (owner && owner->IsFamiliar()) + { + Entity_Familiar& familiar = *static_cast(owner); + familiar.counter = std::max(familiar.counter, time); + } +} + +// 009f5780 Turns the owner's head, playing the matching head animation for a player. +void Weapon::set_head_direction(int headDirection) +{ + Entity_Player* player = owner && owner->is_player() ? owner->ToPlayer() : nullptr; + if (player) + { + player->headDirection = (Direction)headDirection; + if (headDirection != DIRECTION_NONE) player->headAnim = PLAYER_HEAD_ANIMS[headDirection]; + } + else if (owner && owner->IsFamiliar()) static_cast(owner)->shootDirection = headDirection; +} + +// 009f5890 The share of the owner's movement its shots carry: the player's own, or for a familiar its player's +// velocity without the part against the shot. None for a fixed aim or a Marked target. A familiar without a player +// crashes in the original: here it carries none. +Vector Weapon::get_tear_movement_inheritance(const Vector& shootDirection) +{ + if (!owner || !is_zero(fixedDirection)) return {}; + if (owner->is_player()) return owner->ToPlayer()->GetTearMovementInheritance(shootDirection, INHERIT_CHECKED); + + Entity_Player* player = owner_player(); + if (!player || (player->HasCollectible(COLLECTIBLE_MARKED) && player->markedTarget)) return {}; + + Vector inherited = vector_scale(player->velocity, INHERIT_SCALE * 2); + if (is_zero(shootDirection)) return inherited; + + float length = std::sqrt(shootDirection.x * shootDirection.x + shootDirection.y * shootDirection.y); + Vector normal = length > 0 ? vector_scale(shootDirection, 1 / length) : shootDirection; + float along = inherited.x * normal.x + inherited.y * normal.y; + if (along * (normal.x * normal.x + normal.y * normal.y) < 0) + inherited = vector_make(inherited.x - normal.x * along, inherited.y - normal.y * along); + return inherited; +} + +// 009f5ad0 Fires one tear: through the owning player (a familiar's player, the familiar as its spawner), or a plain +// one from the owner. Speedy G FUEL! varies its speed. It then moves along its velocity by the position step, less the +// owner's own movement, so tears fired late in a frame start further out. +Entity_Tear* Weapon::fire_tear(const PosVel& shot, uint32_t fireFlags, float damageMultiplier, float positionStep) +{ + Entity* shooter = owner; + Entity_Tear* tear = nullptr; + + if (shooter && shooter->is_player()) + tear = shooter->ToPlayer()->FireTear(shot, fireFlags, shooter, damageMultiplier); + else if (shooter && shooter->IsFamiliar()) + { + tear = static_cast(shooter)->player->FireTear(shot, fireFlags, shooter, damageMultiplier); + tear->spawnerEntity = shooter; + } + if (!tear) + { + EntitySpawn spawn{.position = shot.position, .velocity = shot.velocity, .spawner = owner, .type = ENTITY_TEAR}; + spawn.seed = Random(); + tear = g_game->Spawn(spawn)->ToTear(); + tear->SetCollisionDamage(damageMultiplier * tear->collisionDamage); + tear->parent = owner; + tear->Update(); + } + + if (owner && owner->is_player() && owner->ToPlayer()->get_seeded_variant() == SEEDED_VARIANT_SPEEDY) + tear->velocity = vector_scale(tear->velocity, random_unit() * TEAR_SPEED_SPREAD + TEAR_SPEED_MIN); + tear->pos = vector_add(tear->pos, vector_scale(tear->velocity, positionStep)); + if (owner && (!shooter || shooter == owner)) + { + Vector ownerMotion = owner->is_player() ? vector_scale(owner->ToPlayer()->lastVelocity, 2) : owner->velocity; + tear->pos = vector_add(tear->pos, vector_scale(ownerMotion, -positionStep)); + } + return tear; +} + +// 009f7930 What firing does beyond the shot, once per tear: Isaac's Tears charges, glitched items trigger, and the +// items that fire extras or spawn things with tears (not written yet). Counts the shots fired. +void Weapon::TriggerTearEffects(const Vector&, int count) +{ + Entity_Player* player = owner_player(); + + for (int i = 0; i < count; i++) + { + if (player) + { + if (player->itemState == 0) + for (int slot = 0; slot < ACTIVE_SLOT_COUNT; slot++) + if (player->activeItems[slot].item == COLLECTIBLE_ISAACS_TEARS) + player->AddActiveCharge(count, slot, false, false, true); + if (!player->proceduralItems.empty()) + reconstruction_missing("Weapon::TriggerTearEffects 009f7930 (glitched items)"); + for (int item : TEAR_TRIGGER_ITEMS) + if (player->HasCollectible(item)) + reconstruction_missing("Weapon::TriggerTearEffects 009f7930 (items fired with tears)"); + if (player->GetTrinketMultiplier(TRINKET_TORN_CARD) > 0) + reconstruction_missing("Weapon::TriggerTearEffects 009f7930 (Torn Card)"); + } + numFired++; + } +} + +bool Weapon::is_held_item(ANM2&, std::string_view, void*) { reconstruction_missing("Weapon::is_held_item 0075a2b0"); } +void Weapon::stop_costume_item_anim(int) { reconstruction_missing("Weapon::stop_costume_item_anim 009f4ff0"); } +bool Weapon::IsItemAnimFinished(int) { reconstruction_missing("Weapon::IsItemAnimFinished 009f50f0"); } +bool Weapon::is_c_section_anim_finished() { reconstruction_missing("Weapon::is_c_section_anim_finished 009f5510"); } +Vector Weapon::GetOwnerLaserOffset(int, const Vector&) +{ + reconstruction_missing("Weapon::GetOwnerLaserOffset 009f5a30"); +} +Entity_Bomb* Weapon::fire_bomb(Weapon&, const PosVel&) { reconstruction_missing("Weapon::fire_bomb 009f5d60"); } +Entity_Laser* Weapon::fire_brimstone_with_color(const Vector&, float, uint32_t) +{ + reconstruction_missing("Weapon::fire_brimstone_with_color 009f6570"); +} +Entity_Laser* Weapon::fire_laser(const Vector&, int, const Vector&, bool, bool, float) +{ + reconstruction_missing("Weapon::fire_laser 009f6610"); +} +Entity_Knife* Weapon::fire_knife(Entity*, int, bool, float) { reconstruction_missing("Weapon::fire_knife 009f6a60"); } +Entity_Knife* Weapon::FireSword(Entity*, int, float, bool, bool, int, Entity*) +{ + reconstruction_missing("Weapon::FireSword 009f6c50"); +} + +// 00a0d870 Counts both eyes' fire delays down at the owner's speed, outside interpolation frames. +void Weapon_Tears::Update(bool isInterpolated) +{ + if (isInterpolated) return; + + float speed = owner ? owner->speedMultiplier : 1; + if (fireDelay > -1) fireDelay -= speed; + if (secondFireDelay > -1) secondFireDelay -= speed; +} + +// 00a0d850 Forgets the charges and the second eye's delay. The base's reset does not run. +void Weapon_Tears::Reset() +{ + cursedEyeCharges = 0; + chargeAtRelease = 0; + secondFireDelay = 0; +} + +// 00a0d8e0 The charge a full shot takes: twelve delays for Neptunus, two and a half for Chocolate Milk, doubled by +// Cursed Eye, none otherwise. +float Weapon_Tears::GetMaxCharge() +{ + constexpr float NEPTUNUS_CHARGE = 12; + constexpr float CHOCOLATE_MILK_CHARGE = 2.5f; + float multiplier = 1; + + if (modifiers & WEAPON_MOD_NEPTUNUS) multiplier = NEPTUNUS_CHARGE; + else + { + if (modifiers & WEAPON_MOD_CHOCOLATE_MILK) multiplier = CHOCOLATE_MILK_CHARGE; + if (modifiers & WEAPON_MOD_CURSED_EYE) multiplier += multiplier; + if (multiplier <= 1) return 0; + } + return (maxFireDelay + 1) * multiplier - 1; +} + +// The target Marked places (Weapon_Bombs::GetMarkedTargetVariant 009fa1b0, which tears share). +int Weapon_Tears::GetMarkedTargetVariant() { return marked_target_variant(); } + +// Tears ride a Tractor Beam unless Ludovico holds them (Weapon_Knife::SupportsTractorBeam 00a05060, which tears share). +bool Weapon_Tears::SupportsTractorBeam() { return !(modifiers & WEAPON_MOD_LUDOVICO_TECHNIQUE); } + +// Tears set off Kidney Stone unless Ludovico holds them (00a05060 again). +bool Weapon_Tears::CanTriggerKidneyStone() { return SupportsTractorBeam(); } + +// 00a0d950 Whether a half charged shot lets Cursed Eye teleport the player: not while Marked aims, nor under Neptunus. +bool Weapon_Tears::CanTriggerCursedEyeTeleport() +{ + if (!owner || !owner->is_player()) return false; + if (owner->ToPlayer()->markedTarget && GetMarkedTargetVariant()) return false; + return !(modifiers & WEAPON_MOD_NEPTUNUS) && charge > 0 && charge < GetMaxCharge(); +} + +// 00a0a720 Fires the tears due this frame: one volley per fire delay passed (at most eight), from each eye Eye Drops +// gives, alternating eyes, spread by the multi-shot items, with the extra backward, sideways and random shots. Shots +// fired late in a frame start further along. Cain's one eye shoots from the right, Technology 2 leaves the right eye +// to its laser. Charged shots (Chocolate Milk, Cursed Eye, Neptunus) and G FUEL! are not written yet. The player field +// getters and the volley wrapper it calls are inlined (009f5830, 009f5850, 009f5870, 009f4230). +void Weapon_Tears::Fire(const Vector& shootDirection, bool isShooting, bool isInterpolated) +{ + Weapon::Fire(shootDirection, isShooting, isInterpolated); + + Entity_Player* player = owner && owner->is_player() ? owner->ToPlayer() : nullptr; + if (!player) reconstruction_missing("Weapon_Tears::Fire 00a0a720 (familiars' tears)"); + if (modifiers & (WEAPON_MOD_CHOCOLATE_MILK | WEAPON_MOD_CURSED_EYE | WEAPON_MOD_NEPTUNUS)) + reconstruction_missing("Weapon_Tears::Fire 00a0a720 (charged shots)"); + if (player->get_seeded_variant() != SEEDED_VARIANT_NONE) + reconstruction_missing("Weapon_Tears::Fire 00a0a720 (G FUEL!)"); + + Vector aim = isShooting ? shootDirection : direction; + if (IsAxisAligned()) + aim = std::fabs(aim.x) <= std::fabs(aim.y) ? vector_make(0, aim.y < 0 ? -1 : 1) + : vector_make(aim.x < 0 ? -1 : 1, 0); + else if (float length = std::sqrt(aim.x * aim.x + aim.y * aim.y); length > 0) aim = vector_scale(aim, 1 / length); + + int eyeMode = 0; + if (player->playerType == PLAYER_CAIN || player->playerType == PLAYER_CAIN_B || + player->HasCollectible(COLLECTIBLE_LEAD_PENCIL) || player->HasCollectible(COLLECTIBLE_STAPLER)) + eyeMode = 1; + else if (player->HasCollectible(COLLECTIBLE_TECHNOLOGY_2)) eyeMode = -1; + int eyeCount = eyeMode == 0 && player->HasCollectible(COLLECTIBLE_EYE_DROPS) ? 2 : 1; + + for (int eye = 0; eye < eyeCount; eye++) + { + float& delay = eye == 0 ? fireDelay : secondFireDelay; + float eyeMaxFireDelay = maxFireDelay; + if (eyeCount == 2) + { + float rate = SHOTS_PER_SECOND / (maxFireDelay + 1); + eyeMaxFireDelay = SHOTS_PER_SECOND / (rate * (eye == 0 ? EYE_DROPS_FAST_RATE : EYE_DROPS_SLOW_RATE)) - 1; + } + + int shots = 0; + float positionStep = 0; + if (isShooting) + { + if (isInterpolated) return; + + positionStep = -1 - delay; + while (delay < 0 && shots < MAX_SHOTS_PER_FRAME) + { + shots++; + delay += eyeMaxFireDelay + 1; + } + chargeAtRelease = 0; + } + + for (; shots > 0; shots--) + { + Weapon_MultiShotParams params = GetMultiShotParams(); + Vector shotDirection = aim; + int threshold = std::max(FIRE_BLINK_MIN, FIRE_BLINK_BASE - (int)(maxFireDelay * FIRE_BLINK_SCALE)); + player->blinkTime = std::max(player->blinkTime, threshold); + TriggerTearEffects(shotDirection, 1); + + if (eyeMode != 0) player->tearDisplacement = (int8_t)eyeMode; + else player->tearDisplacement = (int8_t)(eyeCount == 2 ? (eye == 0 ? -1 : 1) : -tear_displacement()); + int eyeSide = tear_displacement(); + if (is_shot_rotated()) shotDirection = vector_rotate(shotDirection, (float)eyeSide * SHOT_ROTATION_STEP); + if (params.numTears > 1 || player->HasCollectible(COLLECTIBLE_POLYPHEMUS) || + player->HasCollectible(COLLECTIBLE_IPECAC)) + eyeSide = 0; + if (player->HasCollectible(COLLECTIBLE_NUMBER_ONE) || + player->temporaryEffects.HasCollectibleEffect(COLLECTIBLE_NUMBER_ONE) || + player->HasCollectible(COLLECTIBLE_KIDNEY_STONE_WEAPON)) + { + eyeSide = 0; + player->blinkTime = std::max(player->blinkTime, NUMBER_ONE_BLINK); + } + + Vector firePos = player->pos; + Vector base = + vector_add(vector_scale(shotDirection, SHOT_SPEED_BASE), get_tear_movement_inheritance(shotDirection)); + if (player->HasCollectible(COLLECTIBLE_IPECAC)) + base = vector_scale(base, random_unit() * IPECAC_SPEED_RANGE + IPECAC_SPEED_MIN); + + float spreadAngle = 0; + if (player->HasCollectible(COLLECTIBLE_EPIPHORA) && player->epiphoraCharge > 0) + spreadAngle = (float)(player->epiphoraCharge / EPIPHORA_FRAMES_PER_STEP) * EPIPHORA_SPREAD / + EPIPHORA_SPREAD_DIVISOR; + int pee = player->peeBurstCooldown; + int peeMax = player->maxPeeBurstCooldown; + if (pee > 0 && peeMax > 0 && pee < peeMax - 1) spreadAngle += (float)pee * PEE_SPREAD / (float)peeMax; + + float speed = player->shotSpeed; + auto extra_fire = [&](Vector velocity) { + fire_tear({firePos, vector_spread(vector_scale(velocity, speed), spreadAngle)}, TEAR_FIRE_EXTRA_SHOT, 1, + positionStep); + }; + if (params.isShootingBackwards) extra_fire(vector_make(-base.x, -base.y)); + if (params.isShootingSideways) + { + extra_fire(vector_make(-base.y, base.x)); + extra_fire(vector_make(base.y, -base.x)); + } + for (int i = 0; i < params.numRandomDirTears; i++) + extra_fire(vector_rotate(base, random_unit() * FULL_TURN)); + + if (eyeSide != 0) + { + float offset = random_unit() * EYE_OFFSET_RANGE + EYE_OFFSET_MIN; + firePos = vector_make(firePos.x - (float)eyeSide * base.y * offset, + (float)eyeSide * base.x * offset + firePos.y); + } + for (int i = 0; i < params.numTears; i++) + { + PosVel shot = Entity_Player::GetMultiShotPositionVelocity(i, weaponType, base, speed, params); + shot.position = vector_add(shot.position, firePos); + shot.velocity = vector_spread(shot.velocity, spreadAngle); + fire_tear(shot, 0, 1, positionStep); + } + positionStep -= eyeMaxFireDelay + 1; + } + } +} diff --git a/src/weapon.h b/src/weapon.h new file mode 100644 index 0000000..16acfbd --- /dev/null +++ b/src/weapon.h @@ -0,0 +1,209 @@ +#pragma once + +#include "entity.h" +#include + +constexpr float WEAPON_MAX_FIRE_DELAY_DEFAULT = 10; + +// What a player or familiar shoots (Lua's WeaponType). Slot 16 is the deathmatch's. +enum WeaponType : int +{ + WEAPON_NULL, + WEAPON_TEARS, + WEAPON_BRIMSTONE, + WEAPON_LASER, + WEAPON_KNIFE, + WEAPON_BOMBS, + WEAPON_ROCKETS, + WEAPON_MONSTROS_LUNGS, + WEAPON_LUDOVICO_TECHNIQUE, + WEAPON_TECH_X, + WEAPON_BONE, + WEAPON_NOTCHED_AXE, + WEAPON_URN_OF_SOULS, + WEAPON_SPIRIT_SWORD, + WEAPON_FETUS, + WEAPON_UMBILICAL_WHIP, + WEAPON_DEATHMATCH, + WEAPON_TYPE_COUNT +}; + +// The items that change how a weapon fires (REPENTOGON's WeaponModifier), as GetWeaponModifiers collects them. +// WEAPON_MOD_OVERRIDE marks the weapon in slot 0 that replaces the others for a while. +enum WeaponModifier : uint32_t +{ + WEAPON_MOD_CHOCOLATE_MILK = 1 << 0, + WEAPON_MOD_CURSED_EYE = 1 << 1, + WEAPON_MOD_BRIMSTONE = 1 << 2, + WEAPON_MOD_MONSTROS_LUNG = 1 << 3, + WEAPON_MOD_LUDOVICO_TECHNIQUE = 1 << 4, + WEAPON_MOD_ANTI_GRAVITY = 1 << 5, + WEAPON_MOD_TRACTOR_BEAM = 1 << 6, + WEAPON_MOD_SOY_MILK = 1 << 7, + WEAPON_MOD_NEPTUNUS = 1 << 8, + WEAPON_MOD_AZAZELS_SNEEZE = 1 << 9, + WEAPON_MOD_C_SECTION = 1 << 11, + WEAPON_MOD_FIXED_AIM = 1 << 30, + WEAPON_MOD_OVERRIDE = 1u << 31 +}; + +// How FireTear treats a shot: the extra shots of Mom's Eye, Loki's Horns and Mutant Spider drop the Tractor Beam and +// end no streak. +enum TearFireFlag : uint32_t +{ + TEAR_FIRE_NO_EVIL_EYE = 1 << 0, + TEAR_FIRE_NO_TRACTOR_BEAM = 1 << 1, + TEAR_FIRE_NO_STREAK_END = 1 << 2, + TEAR_FIRE_EXTRA_SHOT = TEAR_FIRE_NO_TRACTOR_BEAM | TEAR_FIRE_NO_STREAK_END +}; + +// Whether GetTearMovementInheritance drops the player's movement while Marked aims or the tears leave from an offset. +enum InheritMode +{ + INHERIT_CHECKED, + INHERIT_ALWAYS +}; + +// Construction (005cd690), assignment (006075a0) and copies (0065b490) are the defaults. +// What a tear is fired with (REPENTOGON's TearParams): its look, flags and damage, and how its mass, knockback, speed +// and side of the face scale. +struct TearParams +{ + TearFlags tearFlags; + ColorMod tearColor = COLOR_DEFAULT; + float knockbackMultiplier = 1.7f; + float massMultiplier = 1; + float speedMultiplier = 1; + float tearDamage = 3.5f; + float tearHeight = -23.75f; + float tearScale = 1; + int bombVariant = 0; + int tearDisplacement = 0; + int tearVariant = 0; +}; + +// How a volley spreads (Weapon_MultiShotParams): the tears per eye and eyes, their spread for each weapon, and the +// extra shots that go backwards, sideways or anywhere. +struct Weapon_MultiShotParams +{ + float multiEyeAngle = 0; + float spreadAngleKnife = 0; + float spreadAngleLaser = 0; + float spreadAngleTears = 0; + float spreadAngleTechX = 0; + int numEyesActive = 1; + short numLanesPerEye = 0; + short numRandomDirTears = 0; + short numTears = 1; + bool isCrossEyed = false; + bool isShootingBackwards = false; + bool isShootingSideways = false; +}; + +// Where one shot of a volley starts, from the shooter, and how fast it goes. +struct PosVel +{ + Vector position{}; + Vector velocity{}; +}; + +// Construction (009f3180) is the defaults. +// Destruction (009f3290, 009f3260) frees the Technology 2 laser link and stops the owner's costume item animations. +// The base of what a player or familiar shoots with (Lua's Weapon): it counts down the fire delay, charges, keeps +// the aim, and fires tears, lasers, knives and bombs for its owner. Slot 0 of a player's weapons overrides the rest. +struct Weapon +{ + EntityPtr technology2Laser; + Entity* owner = nullptr; + Vector bodyDirection{}; + Vector direction{}; + Vector fixedDirection{}; + float charge = 0; + float fireDelay = 0; + float maxFireDelay = WEAPON_MAX_FIRE_DELAY_DEFAULT; + int numFired = 0; + uint32_t modifiers = 0; + WeaponType weaponType = WEAPON_NULL; + + virtual ~Weapon(); + virtual void Init(WeaponType type, Entity* weaponOwner); + virtual void Update(bool isInterpolated); + virtual void Fire(const Vector& shootDirection, bool isShooting, bool isInterpolated); + virtual void Reset(); + virtual void ClearReferences(); + // 009f3130 Plain weapons do not charge. + virtual float GetMaxCharge() { return 0; } + virtual float GetChargeBarAmount(); + // 009f3140 Plain weapons follow nothing. + virtual Entity* GetFocusEntity() { return nullptr; } + virtual Entity* GetMainEntity(); + // Plain weapons keep nothing between rooms. + virtual void TriggerNewRoom() {} + // Plain weapons place no target. + virtual int GetMarkedTargetVariant() { return 0; } + // Plain weapons cannot ride a Tractor Beam, teleport with Cursed Eye, set off Kidney Stone or replace a throw. + virtual bool SupportsTractorBeam() { return false; } + virtual bool CanTriggerCursedEyeTeleport() { return false; } + virtual bool CanTriggerKidneyStone() { return false; } + virtual bool CanOverrideForgottenThrow() { return false; } + + Entity_Player* owner_player(); + bool IsAxisAligned(); + Vector get_aim_direction(const Vector& defaultDirection); + Vector get_owner_position(); + float get_damage(); + TearFlags get_owner_tear_flags(); + ColorMod get_tear_color(); + ColorMod get_laser_color(); + Weapon_MultiShotParams GetMultiShotParams(); + int marked_target_variant(); + int tear_displacement(); + bool is_shot_rotated(); + void SetBlinkTime(int delay); + void SetHeadLockTime(int time); + void set_head_direction(int headDirection); + Vector get_tear_movement_inheritance(const Vector& shootDirection); + Entity_Tear* fire_tear(const PosVel& shot, uint32_t fireFlags, float damageMultiplier, float positionStep); + void TriggerTearEffects(const Vector& shootDirection, int count); + + static bool is_held_item(ANM2& sprite, std::string_view animName, void* itemDesc); + void stop_costume_item_anim(int collectibleId); + bool IsItemAnimFinished(int collectibleId); + bool is_c_section_anim_finished(); + Vector GetOwnerLaserOffset(int laserOffsetId, const Vector& shootDirection); + static Entity_Bomb* fire_bomb(Weapon& weapon, const PosVel& shot); + Entity_Laser* fire_brimstone_with_color(const Vector& shootDirection, float damageMultiplier, uint32_t unknown); + Entity_Laser* fire_laser(const Vector& position, int offsetId, const Vector& shootDirection, bool isLeftEye, + bool isOneHit, float damageScale); + Entity_Knife* fire_knife(Entity* knifeParent, int knifeVariant, bool isCantOverwrite, float rotationOffset); + Entity_Knife* FireSword(Entity* swordParent, int swordVariant, float rotationOffset, bool isUnknown1, + bool isUnknown2, int unknown3, Entity* unknown4); +}; + +// Destroys a weapon as Isaac::DestoryWeapon does: its links dropped first, then freed. +struct WeaponDelete +{ + void operator()(Weapon* weapon) const; +}; + +using WeaponPtr = std::unique_ptr; + +// Destruction (009f9900) is the default. +// The weapon that fires tears (and Eye Drops' second eye, Chocolate Milk, Cursed Eye and Neptunus charge them). +struct Weapon_Tears : Weapon +{ + float chargeAtRelease = 0; + float secondFireDelay = 0; + int cursedEyeCharges = 0; + + void Update(bool isInterpolated) override; + void Fire(const Vector& shootDirection, bool isShooting, bool isInterpolated) override; + void Reset() override; + float GetMaxCharge() override; + int GetMarkedTargetVariant() override; + bool SupportsTractorBeam() override; + bool CanTriggerCursedEyeTeleport() override; + bool CanTriggerKidneyStone() override; +}; + +WeaponPtr weapon_create(WeaponType type, Entity* owner);