diff --git a/.github/workflows/generate-builds.yml b/.github/workflows/generate-builds.yml index 6f7134282..582022dbd 100644 --- a/.github/workflows/generate-builds.yml +++ b/.github/workflows/generate-builds.yml @@ -221,6 +221,9 @@ jobs: run: | sudo apt-get update sudo apt-get install -y ninja-build + sudo apt-get remove -y cmake + wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh -O /tmp/cmake.sh + sudo sh /tmp/cmake.sh --prefix=/usr/local/ --exclude-subdir - name: Fix dubious ownership error if: ${{ vars.LINUX_RUNNER }} run: git config --global --add safe.directory '*' @@ -264,6 +267,9 @@ jobs: run: | sudo apt-get update sudo apt-get install -y ninja-build + sudo apt-get remove -y cmake + wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh -O /tmp/cmake.sh + sudo sh /tmp/cmake.sh --prefix=/usr/local/ --exclude-subdir - uses: actions/checkout@v3 with: submodules: true diff --git a/.github/workflows/test-builds-on-distros.yml b/.github/workflows/test-builds-on-distros.yml new file mode 100644 index 000000000..fd8b3c929 --- /dev/null +++ b/.github/workflows/test-builds-on-distros.yml @@ -0,0 +1,61 @@ +name: test-builds-on-distros +on: + workflow_dispatch: # by request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build: + strategy: + matrix: + image: ["archlinux:base", "opensuse/tumbleweed:latest", "ubuntu:mantic", "debian:bookworm", "fedora:39"] + cc: ["gcc", "clang"] + include: + - cxx: g++ + cc: gcc + - cxx: clang++ + cc: clang + runs-on: ${{ (vars.LINUX_RUNNER && fromJSON(vars.LINUX_RUNNER)) || 'ubuntu-latest' }} + container: + image: ${{ matrix.image }} + steps: + - name: Install dependencies (pacman) + if: ${{ matrix.image == 'archlinux:base' }} + run: | + echo arch + echo pacman -S ${{ matrix.cc }} git cmake ninja lsb-release sdl2 libpng sdl2_net boost + pacman -Syu --noconfirm + pacman -S --noconfirm ${{ matrix.cc }} git cmake ninja lsb-release sdl2 libpng sdl2_net boost + - name: Install dependencies (dnf) + if: ${{ matrix.image == 'fedora:39' }} + run: | + echo fedora + echo dnf install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} git cmake ninja-build lsb_release SDL2-devel libpng-devel boost-devel + dnf -y upgrade + dnf -y install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} git cmake ninja-build lsb_release SDL2-devel libpng-devel boost-devel + - name: Install dependencies (apt) + if: ${{ matrix.image == 'ubuntu:mantic' || matrix.image == 'debian:bookworm' }} + run: | + echo debian based + echo apt-get install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'g++') || '' }} git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libboost-dev libopengl-dev + apt-get update + apt-get -y full-upgrade + apt-get -y install ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'g++') || '' }} git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libboost-dev libopengl-dev + - name: Install dependencies (zypper) + if: ${{ matrix.image == 'opensuse/tumbleweed:latest' }} + run: | + echo openSUSE + echo zypper in ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} ${{ matrix.cc == 'clang' && 'libstdc++-devel' || '' }} git cmake ninja SDL2-devel libpng16-devel + zypper --non-interactive dup + zypper --non-interactive in ${{ matrix.cc }} ${{ (matrix.cxx == 'g++' && 'gcc-c++') || '' }} ${{ matrix.cc == 'clang' && 'libstdc++-devel' || '' }} git cmake ninja SDL2-devel libpng16-devel + - uses: actions/checkout@v3 + with: + submodules: true + - name: Build SoH + run: | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + cmake --no-warn-unused-cli -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_REMOTE_CONTROL=1 + cmake --build build-cmake --config Release -j3 + env: + CC: ${{ matrix.cc }} + CXX: ${{ matrix.cxx }} diff --git a/OTRExporter b/OTRExporter index d8f3c4dd4..e93bd2be0 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit d8f3c4dd4a46fb46c4f69cd387afadfa711606e9 +Subproject commit e93bd2be062b13106fdb29d98cf4ada4d7ad6827 diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 56ff9718f..eabc18ec8 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -84,17 +84,49 @@ cd "build/x64" ``` ## Linux -Requires `gcc >= 10, x11, curl, python3, sdl2 >= 2.0.22, libpng, glew >= 2.2, ninja, cmake, lld, pulseaudio-libs` +### Install dependencies +#### Debian/Ubuntu +```sh +# using gcc +apt-get install gcc g++ git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libboost-dev libopengl-dev -**Important: For maximum performance make sure you have ninja build tools installed!** +# or using clang +apt-get install clang git cmake ninja-build lsb-release libsdl2-dev libpng-dev libsdl2-net-dev libboost-dev libopengl-dev +``` +#### Arch +```sh +# using gcc +pacman -S gcc git cmake ninja lsb-release sdl2 libpng sdl2_net boost -_Note: If you're using Visual Studio Code, the [cpack plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) makes it very easy to just press run and debug._ +# or using clang +pacman -S clang git cmake ninja lsb-release sdl2 libpng sdl2_net boost +``` +#### Fedora +```sh +# using gcc +dnf install gcc gcc-c++ git cmake ninja-build lsb_release SDL2-devel libpng-devel boost-devel + +# or using clang +dnf install clang git cmake ninja-build lsb_release SDL2-devel libpng-devel boost-devel +``` +#### openSUSE +```sh +# using gcc +zypper in gcc gcc-c++ git cmake ninja SDL2-devel libpng16-devel boost + +# or using clang +zypper in clang libstdc++-devel git cmake ninja SDL2-devel libpng16-devel boost +``` + +### Build + +_Note: If you're using Visual Studio Code, the [CMake Tools plugin](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) makes it very easy to just press run and debug._ ```bash # Clone the repo git clone https://github.com/HarbourMasters/Shipwright.git cd Shipwright -# Clone the submodule libultraship +# Clone the submodules git submodule update --init # Copy the baserom to the OTRExporter folder cp OTRExporter diff --git a/libultraship b/libultraship index 825bd1275..a516b66ce 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 825bd1275bc26a8532f07a887db5141cd635df13 +Subproject commit a516b66ce0c89fe4e33c55b1fbfbde845d0bf129 diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt index 228303558..f653c5de5 100644 --- a/soh/CMakeLists.txt +++ b/soh/CMakeLists.txt @@ -356,7 +356,13 @@ set(SDL2-INCLUDE ${SDL2_INCLUDE_DIRS}) if (BUILD_REMOTE_CONTROL) find_package(SDL2_net) - set(SDL2-NET-INCLUDE ${SDL_NET_INCLUDE_DIRS}) + + if(NOT SDL2_net_FOUND) + message(STATUS "SDL2_net not found (it's possible the version installed is too old). Disabling BUILD_REMOTE_CONTROL.") + set(BUILD_REMOTE_CONTROL 0) + else() + set(SDL2-NET-INCLUDE ${SDL_NET_INCLUDE_DIRS}) + endif() endif() target_include_directories(${PROJECT_NAME} PRIVATE assets @@ -623,6 +629,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") -Wno-parentheses -Wno-narrowing -Wno-missing-braces + -Wno-int-conversion + -Wno-implicit-int $<$: -Werror-implicit-function-declaration -Wno-incompatible-pointer-types diff --git a/soh/SHIPOFHARKINIAN.manifest b/soh/SHIPOFHARKINIAN.manifest index 80d9f6036..6f47a937f 100644 --- a/soh/SHIPOFHARKINIAN.manifest +++ b/soh/SHIPOFHARKINIAN.manifest @@ -28,4 +28,10 @@ + + + true/pm + permonitorv2,permonitor + + diff --git a/soh/assets/custom/textures/buttons/ABtn.png b/soh/assets/custom/textures/buttons/ABtn.png index c1b06571c..031924cb9 100644 Binary files a/soh/assets/custom/textures/buttons/ABtn.png and b/soh/assets/custom/textures/buttons/ABtn.png differ diff --git a/soh/assets/custom/textures/buttons/ABtnOutline.png b/soh/assets/custom/textures/buttons/ABtnOutline.png new file mode 100644 index 000000000..b3c9d3aab Binary files /dev/null and b/soh/assets/custom/textures/buttons/ABtnOutline.png differ diff --git a/soh/assets/custom/textures/buttons/AnalogStick.png b/soh/assets/custom/textures/buttons/AnalogStick.png new file mode 100644 index 000000000..d3fec7d01 Binary files /dev/null and b/soh/assets/custom/textures/buttons/AnalogStick.png differ diff --git a/soh/assets/custom/textures/buttons/AnalogStickOutline.png b/soh/assets/custom/textures/buttons/AnalogStickOutline.png new file mode 100644 index 000000000..e4d8d7190 Binary files /dev/null and b/soh/assets/custom/textures/buttons/AnalogStickOutline.png differ diff --git a/soh/assets/custom/textures/buttons/BBtn.png b/soh/assets/custom/textures/buttons/BBtn.png index 99b1197c9..8e2fbb54b 100644 Binary files a/soh/assets/custom/textures/buttons/BBtn.png and b/soh/assets/custom/textures/buttons/BBtn.png differ diff --git a/soh/assets/custom/textures/buttons/BBtnOutline.png b/soh/assets/custom/textures/buttons/BBtnOutline.png new file mode 100644 index 000000000..fab802f3b Binary files /dev/null and b/soh/assets/custom/textures/buttons/BBtnOutline.png differ diff --git a/soh/assets/custom/textures/buttons/CDown.png b/soh/assets/custom/textures/buttons/CDown.png index 741188eaf..f30cec2b3 100644 Binary files a/soh/assets/custom/textures/buttons/CDown.png and b/soh/assets/custom/textures/buttons/CDown.png differ diff --git a/soh/assets/custom/textures/buttons/CDownOutline.png b/soh/assets/custom/textures/buttons/CDownOutline.png new file mode 100644 index 000000000..9324c282d Binary files /dev/null and b/soh/assets/custom/textures/buttons/CDownOutline.png differ diff --git a/soh/assets/custom/textures/buttons/CLeft.png b/soh/assets/custom/textures/buttons/CLeft.png index 5e26a2067..43b04412f 100644 Binary files a/soh/assets/custom/textures/buttons/CLeft.png and b/soh/assets/custom/textures/buttons/CLeft.png differ diff --git a/soh/assets/custom/textures/buttons/CLeftOutline.png b/soh/assets/custom/textures/buttons/CLeftOutline.png new file mode 100644 index 000000000..c0d48f659 Binary files /dev/null and b/soh/assets/custom/textures/buttons/CLeftOutline.png differ diff --git a/soh/assets/custom/textures/buttons/CRight.png b/soh/assets/custom/textures/buttons/CRight.png index 9e6180639..c2d1afabf 100644 Binary files a/soh/assets/custom/textures/buttons/CRight.png and b/soh/assets/custom/textures/buttons/CRight.png differ diff --git a/soh/assets/custom/textures/buttons/CRightOutline.png b/soh/assets/custom/textures/buttons/CRightOutline.png new file mode 100644 index 000000000..d450084ea Binary files /dev/null and b/soh/assets/custom/textures/buttons/CRightOutline.png differ diff --git a/soh/assets/custom/textures/buttons/CUp.png b/soh/assets/custom/textures/buttons/CUp.png index 6c0e29d2d..aca464728 100644 Binary files a/soh/assets/custom/textures/buttons/CUp.png and b/soh/assets/custom/textures/buttons/CUp.png differ diff --git a/soh/assets/custom/textures/buttons/CUpOutline.png b/soh/assets/custom/textures/buttons/CUpOutline.png new file mode 100644 index 000000000..b21cd3ae9 Binary files /dev/null and b/soh/assets/custom/textures/buttons/CUpOutline.png differ diff --git a/soh/assets/custom/textures/buttons/DPadDown.png b/soh/assets/custom/textures/buttons/DPadDown.png new file mode 100644 index 000000000..cec0af1e5 Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadDown.png differ diff --git a/soh/assets/custom/textures/buttons/DPadDownOutline.png b/soh/assets/custom/textures/buttons/DPadDownOutline.png new file mode 100644 index 000000000..e8dca39b6 Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadDownOutline.png differ diff --git a/soh/assets/custom/textures/buttons/DPadLeft.png b/soh/assets/custom/textures/buttons/DPadLeft.png new file mode 100644 index 000000000..2a4a09b79 Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadLeft.png differ diff --git a/soh/assets/custom/textures/buttons/DPadLeftOutline.png b/soh/assets/custom/textures/buttons/DPadLeftOutline.png new file mode 100644 index 000000000..ba3dbf4e8 Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadLeftOutline.png differ diff --git a/soh/assets/custom/textures/buttons/DPadRight.png b/soh/assets/custom/textures/buttons/DPadRight.png new file mode 100644 index 000000000..e7854a219 Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadRight.png differ diff --git a/soh/assets/custom/textures/buttons/DPadRightOutline.png b/soh/assets/custom/textures/buttons/DPadRightOutline.png new file mode 100644 index 000000000..f6b4764c6 Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadRightOutline.png differ diff --git a/soh/assets/custom/textures/buttons/DPadUp.png b/soh/assets/custom/textures/buttons/DPadUp.png new file mode 100644 index 000000000..8d70d96da Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadUp.png differ diff --git a/soh/assets/custom/textures/buttons/DPadUpOutline.png b/soh/assets/custom/textures/buttons/DPadUpOutline.png new file mode 100644 index 000000000..8ad2d7959 Binary files /dev/null and b/soh/assets/custom/textures/buttons/DPadUpOutline.png differ diff --git a/soh/assets/custom/textures/buttons/InputViewerBackground.png b/soh/assets/custom/textures/buttons/InputViewerBackground.png new file mode 100644 index 000000000..091d686c0 Binary files /dev/null and b/soh/assets/custom/textures/buttons/InputViewerBackground.png differ diff --git a/soh/assets/custom/textures/buttons/LBtn.png b/soh/assets/custom/textures/buttons/LBtn.png index 2e0a8f00c..351ea383a 100644 Binary files a/soh/assets/custom/textures/buttons/LBtn.png and b/soh/assets/custom/textures/buttons/LBtn.png differ diff --git a/soh/assets/custom/textures/buttons/LBtnOutline.png b/soh/assets/custom/textures/buttons/LBtnOutline.png new file mode 100644 index 000000000..10cca9c8f Binary files /dev/null and b/soh/assets/custom/textures/buttons/LBtnOutline.png differ diff --git a/soh/assets/custom/textures/buttons/RBtn.png b/soh/assets/custom/textures/buttons/RBtn.png index c255643c3..ecb96bd6c 100644 Binary files a/soh/assets/custom/textures/buttons/RBtn.png and b/soh/assets/custom/textures/buttons/RBtn.png differ diff --git a/soh/assets/custom/textures/buttons/RBtnOutline.png b/soh/assets/custom/textures/buttons/RBtnOutline.png new file mode 100644 index 000000000..afeba32eb Binary files /dev/null and b/soh/assets/custom/textures/buttons/RBtnOutline.png differ diff --git a/soh/assets/custom/textures/buttons/RightStick.png b/soh/assets/custom/textures/buttons/RightStick.png new file mode 100644 index 000000000..6b8490aaf Binary files /dev/null and b/soh/assets/custom/textures/buttons/RightStick.png differ diff --git a/soh/assets/custom/textures/buttons/RightStickOutline.png b/soh/assets/custom/textures/buttons/RightStickOutline.png new file mode 100644 index 000000000..8fbd54fcc Binary files /dev/null and b/soh/assets/custom/textures/buttons/RightStickOutline.png differ diff --git a/soh/assets/custom/textures/buttons/StartBtn.png b/soh/assets/custom/textures/buttons/StartBtn.png index c3e08dc36..ec85f2619 100644 Binary files a/soh/assets/custom/textures/buttons/StartBtn.png and b/soh/assets/custom/textures/buttons/StartBtn.png differ diff --git a/soh/assets/custom/textures/buttons/StartBtnOutline.png b/soh/assets/custom/textures/buttons/StartBtnOutline.png new file mode 100644 index 000000000..a7902edbd Binary files /dev/null and b/soh/assets/custom/textures/buttons/StartBtnOutline.png differ diff --git a/soh/assets/custom/textures/buttons/ZBtn.png b/soh/assets/custom/textures/buttons/ZBtn.png index def8d9a6d..4fee52d57 100644 Binary files a/soh/assets/custom/textures/buttons/ZBtn.png and b/soh/assets/custom/textures/buttons/ZBtn.png differ diff --git a/soh/assets/custom/textures/buttons/ZBtnOutline.png b/soh/assets/custom/textures/buttons/ZBtnOutline.png new file mode 100644 index 000000000..5832ed339 Binary files /dev/null and b/soh/assets/custom/textures/buttons/ZBtnOutline.png differ diff --git a/soh/include/functions.h b/soh/include/functions.h index cb740250e..4c97fa317 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -2468,6 +2468,10 @@ void Message_DrawText(PlayState* play, Gfx** gfxP); void Interface_CreateQuadVertexGroup(Vtx* vtxList, s32 xStart, s32 yStart, s32 width, s32 height, u8 flippedH); void Interface_RandoRestoreSwordless(void); +//Pause Warp +void PauseWarp_HandleSelection(); +void PauseWarp_Execute(); + // #endregion #ifdef __cplusplus diff --git a/soh/include/z64player.h b/soh/include/z64player.h index e5f4b826d..d03b64da5 100644 --- a/soh/include/z64player.h +++ b/soh/include/z64player.h @@ -345,7 +345,7 @@ typedef enum { #define PLAYER_LIMB_BUF_COUNT LIMB_BUF_COUNT(PLAYER_LIMB_MAX) typedef struct { - /* 0x00 */ f32 unk_00; + /* 0x00 */ f32 ceilingCheckHeight; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; /* 0x0C */ f32 unk_0C; @@ -359,7 +359,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; + /* 0x38 */ f32 wallCheckRadius; /* 0x3C */ f32 unk_3C; /* 0x40 */ f32 unk_40; /* 0x44 */ Vec3s unk_44; @@ -489,180 +489,187 @@ typedef s32 (*UpperActionFunc)(struct Player*, struct PlayState*); typedef void (*PlayerFuncA74)(struct PlayState*, struct Player*); typedef struct Player { - /* 0x0000 */ Actor actor; - /* 0x014C */ s8 currentTunic; // current tunic from `PlayerTunic` - /* 0x014D */ s8 currentSwordItemId; - /* 0x014E */ s8 currentShield; // current shield from `PlayerShield` - /* 0x014F */ s8 currentBoots; // current boots from `PlayerBoots` - /* 0x0150 */ s8 heldItemButton; // Button index for the item currently used - /* 0x0151 */ s8 heldItemAction; // Item action for the item currently used - /* 0x0152 */ u8 heldItemId; // Item id for the item currently used - /* 0x0153 */ s8 prevBoots; // previous boots from `PlayerBoots` - /* 0x0154 */ s8 itemAction; // the difference between this and heldItemAction is unclear - /* 0x0155 */ char unk_155[0x003]; - /* 0x0158 */ u8 modelGroup; - /* 0x0159 */ u8 nextModelGroup; - /* 0x015A */ s8 itemChangeType; - /* 0x015B */ u8 modelAnimType; - /* 0x015C */ u8 leftHandType; - /* 0x015D */ u8 rightHandType; - /* 0x015E */ u8 sheathType; - /* 0x015F */ u8 currentMask; // current mask equipped from `PlayerMask` - /* 0x0160 */ Gfx** rightHandDLists; - /* 0x0164 */ Gfx** leftHandDLists; - /* 0x0168 */ Gfx** sheathDLists; - /* 0x016C */ Gfx** waistDLists; - /* 0x0170 */ u8 giObjectLoading; + /* 0x0000 */ Actor actor; + /* 0x014C */ s8 currentTunic; // current tunic from `PlayerTunic` + /* 0x014D */ s8 currentSwordItemId; + /* 0x014E */ s8 currentShield; // current shield from `PlayerShield` + /* 0x014F */ s8 currentBoots; // current boots from `PlayerBoots` + /* 0x0150 */ s8 heldItemButton; // Button index for the item currently used + /* 0x0151 */ s8 heldItemAction; // Item action for the item currently used + /* 0x0152 */ u8 heldItemId; // Item id for the item currently used + /* 0x0153 */ s8 prevBoots; // previous boots from `PlayerBoots` + /* 0x0154 */ s8 itemAction; // the difference between this and heldItemAction is unclear + /* 0x0155 */ char unk_155[0x003]; + /* 0x0158 */ u8 modelGroup; + /* 0x0159 */ u8 nextModelGroup; + /* 0x015A */ s8 itemChangeType; + /* 0x015B */ u8 modelAnimType; + /* 0x015C */ u8 leftHandType; + /* 0x015D */ u8 rightHandType; + /* 0x015E */ u8 sheathType; + /* 0x015F */ u8 currentMask; // current mask equipped from `PlayerMask` + /* 0x0160 */ Gfx** rightHandDLists; + /* 0x0164 */ Gfx** leftHandDLists; + /* 0x0168 */ Gfx** sheathDLists; + /* 0x016C */ Gfx** waistDLists; + /* 0x0170 */ u8 giObjectLoading; /* 0x0174 */ DmaRequest giObjectDmaRequest; /* 0x0194 */ OSMesgQueue giObjectLoadQueue; - /* 0x01AC */ OSMesg giObjectLoadMsg; - /* 0x01B0 */ void* giObjectSegment; // also used for title card textures - /* 0x01B4 */ SkelAnime skelAnime; - /* 0x01F8 */ Vec3s jointTable[PLAYER_LIMB_BUF_COUNT]; - /* 0x0288 */ Vec3s morphTable[PLAYER_LIMB_BUF_COUNT]; - /* 0x0318 */ Vec3s blendTable[PLAYER_LIMB_BUF_COUNT]; - /* 0x03A8 */ s16 unk_3A8[2]; - /* 0x03AC */ Actor* heldActor; - /* 0x03B0 */ Vec3f leftHandPos; - /* 0x03BC */ Vec3s unk_3BC; - /* 0x03C4 */ Actor* unk_3C4; - /* 0x03C8 */ Vec3f unk_3C8; - /* 0x03D4 */ char unk_3D4[0x058]; - /* 0x042C */ s8 doorType; - /* 0x042D */ s8 doorDirection; - /* 0x042E */ s16 doorTimer; - /* 0x0430 */ Actor* doorActor; - /* 0x0434 */ s16 getItemId; // Upstream TODO: Document why this is s16 while it's s8 upstream - /* 0x0436 */ u16 getItemDirection; - /* 0x0438 */ Actor* interactRangeActor; - /* 0x043C */ s8 mountSide; - /* 0x043D */ char unk_43D[0x003]; - /* 0x0440 */ Actor* rideActor; - /* 0x0444 */ u8 csAction; - /* 0x0445 */ u8 prevCsAction; - /* 0x0446 */ u8 cueId; - /* 0x0447 */ u8 unk_447; - /* 0x0448 */ Actor* csActor; - /* 0x044C */ char unk_44C[0x004]; - /* 0x0450 */ Vec3f unk_450; - /* 0x045C */ Vec3f unk_45C; - /* 0x0468 */ char unk_468[0x002]; - /* 0x046A */ s16 doorBgCamIndex; - /* 0x046C */ s16 subCamId; - /* 0x046E */ char unk_46E[0x02A]; + /* 0x01AC */ OSMesg giObjectLoadMsg; + /* 0x01B0 */ void* giObjectSegment; // also used for title card textures + /* 0x01B4 */ SkelAnime skelAnime; + /* 0x01F8 */ Vec3s jointTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x0288 */ Vec3s morphTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x0318 */ Vec3s blendTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x03A8 */ s16 unk_3A8[2]; + /* 0x03AC */ Actor* heldActor; + /* 0x03B0 */ Vec3f leftHandPos; + /* 0x03BC */ Vec3s unk_3BC; + /* 0x03C4 */ Actor* unk_3C4; + /* 0x03C8 */ Vec3f unk_3C8; + /* 0x03D4 */ char unk_3D4[0x058]; + /* 0x042C */ s8 doorType; + /* 0x042D */ s8 doorDirection; + /* 0x042E */ s16 doorTimer; + /* 0x0430 */ Actor* doorActor; + /* 0x0434 */ s16 getItemId; // Upstream TODO: Document why this is s16 while it's s8 upstream + /* 0x0436 */ u16 getItemDirection; + /* 0x0438 */ Actor* interactRangeActor; + /* 0x043C */ s8 mountSide; + /* 0x043D */ char unk_43D[0x003]; + /* 0x0440 */ Actor* rideActor; + /* 0x0444 */ u8 csAction; + /* 0x0445 */ u8 prevCsAction; + /* 0x0446 */ u8 cueId; + /* 0x0447 */ u8 unk_447; + /* 0x0448 */ Actor* csActor; // Actor involved in a `csAction`. Typically the actor that invoked the cutscene. + /* 0x044C */ char unk_44C[0x004]; + /* 0x0450 */ Vec3f unk_450; + /* 0x045C */ Vec3f unk_45C; + /* 0x0468 */ char unk_468[0x002]; + /* 0x046A */ s16 doorBgCamIndex; + /* 0x046C */ s16 subCamId; + /* 0x046E */ char unk_46E[0x02A]; /* 0x0498 */ ColliderCylinder cylinder; /* 0x04E4 */ ColliderQuad meleeWeaponQuads[2]; /* 0x05E4 */ ColliderQuad shieldQuad; - /* 0x0664 */ Actor* unk_664; - /* 0x0668 */ char unk_668[0x004]; - /* 0x066C */ s32 unk_66C; - /* 0x0670 */ s32 meleeWeaponEffectIndex; + /* 0x0664 */ Actor* unk_664; + /* 0x0668 */ char unk_668[0x004]; + /* 0x066C */ s32 unk_66C; + /* 0x0670 */ s32 meleeWeaponEffectIndex; /* 0x0674 */ PlayerActionFunc actionFunc; /* 0x0678 */ PlayerAgeProperties* ageProperties; - /* 0x067C */ u32 stateFlags1; - /* 0x0680 */ u32 stateFlags2; - /* 0x0684 */ Actor* unk_684; - /* 0x0688 */ Actor* boomerangActor; - /* 0x068C */ Actor* naviActor; - /* 0x0690 */ s16 naviTextId; - /* 0x0692 */ u8 stateFlags3; - /* 0x0693 */ s8 exchangeItemId; - /* 0x0694 */ Actor* targetActor; - /* 0x0698 */ f32 targetActorDistance; - /* 0x069C */ char unk_69C[0x004]; - /* 0x06A0 */ f32 unk_6A0; - /* 0x06A4 */ f32 closestSecretDistSq; - /* 0x06A8 */ Actor* unk_6A8; - /* 0x06AC */ s8 unk_6AC; - /* 0x06AD */ u8 unk_6AD; - /* 0x06AE */ u16 unk_6AE; - /* 0x06B0 */ s16 unk_6B0; - /* 0x06B2 */ char unk_6B4[0x004]; - /* 0x06B6 */ s16 unk_6B6; - /* 0x06B8 */ s16 unk_6B8; - /* 0x06BA */ s16 unk_6BA; - /* 0x06BC */ s16 unk_6BC; - /* 0x06BE */ s16 unk_6BE; - /* 0x06C0 */ s16 unk_6C0; - /* 0x06C2 */ s16 unk_6C2; - /* 0x06C4 */ f32 unk_6C4; - /* 0x06C8 */ SkelAnime upperSkelAnime; - /* 0x070C */ Vec3s upperJointTable[PLAYER_LIMB_BUF_COUNT]; - /* 0x079C */ Vec3s upperMorphTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x067C */ u32 stateFlags1; + /* 0x0680 */ u32 stateFlags2; + /* 0x0684 */ Actor* unk_684; + /* 0x0688 */ Actor* boomerangActor; + /* 0x068C */ Actor* naviActor; + /* 0x0690 */ s16 naviTextId; + /* 0x0692 */ u8 stateFlags3; + /* 0x0693 */ s8 exchangeItemId; + /* 0x0694 */ Actor* targetActor; + /* 0x0698 */ f32 targetActorDistance; + /* 0x069C */ char unk_69C[0x004]; + /* 0x06A0 */ f32 unk_6A0; + /* 0x06A4 */ f32 closestSecretDistSq; + /* 0x06A8 */ Actor* unk_6A8; + /* 0x06AC */ s8 unk_6AC; + /* 0x06AD */ u8 unk_6AD; + /* 0x06AE */ u16 unk_6AE; + /* 0x06B0 */ s16 unk_6B0; + /* 0x06B2 */ char unk_6B4[0x004]; + /* 0x06B6 */ s16 unk_6B6; + /* 0x06B8 */ s16 unk_6B8; + /* 0x06BA */ s16 unk_6BA; + /* 0x06BC */ s16 unk_6BC; + /* 0x06BE */ s16 unk_6BE; + /* 0x06C0 */ s16 unk_6C0; + /* 0x06C2 */ s16 unk_6C2; + /* 0x06C4 */ f32 unk_6C4; + /* 0x06C8 */ SkelAnime upperSkelAnime; + /* 0x070C */ Vec3s upperJointTable[PLAYER_LIMB_BUF_COUNT]; + /* 0x079C */ Vec3s upperMorphTable[PLAYER_LIMB_BUF_COUNT]; /* 0x082C */ UpperActionFunc upperActionFunc; - /* 0x0830 */ f32 upperAnimBlendWeight; - /* 0x0834 */ s16 unk_834; - /* 0x0836 */ s8 unk_836; - /* 0x0837 */ u8 unk_837; - /* 0x0838 */ f32 linearVelocity; - /* 0x083C */ s16 currentYaw; - /* 0x083E */ s16 targetYaw; - /* 0x0840 */ u16 underwaterTimer; - /* 0x0842 */ s8 meleeWeaponAnimation; - /* 0x0843 */ s8 meleeWeaponState; - /* 0x0844 */ s8 unk_844; - /* 0x0845 */ u8 unk_845; - /* 0x0846 */ u8 unk_846; - /* 0x0847 */ s8 unk_847[4]; - /* 0x084B */ s8 unk_84B[4]; - /* 0x084F */ s8 unk_84F; - /* 0x0850 */ s16 unk_850; // multipurpose timer - /* 0x0854 */ f32 unk_854; - /* 0x0858 */ f32 unk_858; - /* 0x085C */ f32 unk_85C; // stick length among other things - /* 0x0860 */ s16 unk_860; // stick flame timer among other things - /* 0x0862 */ s16 unk_862; // get item draw ID + 1 - /* 0x0864 */ f32 unk_864; - /* 0x0868 */ f32 unk_868; - /* 0x086C */ f32 unk_86C; - /* 0x0870 */ f32 unk_870; - /* 0x0874 */ f32 unk_874; - /* 0x0878 */ f32 unk_878; - /* 0x087C */ s16 unk_87C; - /* 0x087E */ s16 unk_87E; - /* 0x0880 */ f32 unk_880; - /* 0x0884 */ f32 yDistToLedge; // y distance to ground above an interact wall. LEDGE_DIST_MAX if no ground is found - /* 0x0888 */ f32 distToInteractWall; // distance to the colliding wall plane - /* 0x088C */ u8 unk_88C; - /* 0x088D */ u8 unk_88D; - /* 0x088E */ u8 unk_88E; - /* 0x088F */ u8 unk_88F; - /* 0x0890 */ u8 unk_890; - /* 0x0891 */ u8 shockTimer; - /* 0x0892 */ u8 unk_892; - /* 0x0893 */ u8 hoverBootsTimer; - /* 0x0894 */ s16 fallStartHeight; // last truncated Y position before falling - /* 0x0896 */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) - /* 0x0898 */ s16 floorPitch; // angle of the floor slope in the direction of current world yaw (positive for ascending slope) - /* 0x089A */ s16 floorPitchAlt; // the calculation for this value is bugged and doesn't represent anything meaningful - /* 0x089C */ s16 unk_89C; - /* 0x089E */ u16 floorSfxOffset; - /* 0x08A0 */ u8 unk_8A0; - /* 0x08A1 */ u8 unk_8A1; - /* 0x08A2 */ s16 unk_8A2; - /* 0x08A4 */ f32 unk_8A4; - /* 0x08A8 */ f32 unk_8A8; - /* 0x08AC */ f32 pushedSpeed; // Pushing player, examples include water currents, floor conveyors, climbing sloped surfaces - /* 0x08B0 */ s16 pushedYaw; // Yaw direction of player being pushed + /* 0x0830 */ f32 upperAnimBlendWeight; + /* 0x0834 */ s16 unk_834; + /* 0x0836 */ s8 unk_836; + /* 0x0837 */ u8 unk_837; + /* 0x0838 */ f32 linearVelocity; + /* 0x083C */ s16 yaw; // General yaw value, used both for world and shape rotation. Current or target value depending on context. + /* 0x083E */ s16 zTargetYaw; // yaw relating to Z targeting/"parallel" mode + /* 0x0840 */ u16 underwaterTimer; + /* 0x0842 */ s8 meleeWeaponAnimation; + /* 0x0843 */ s8 meleeWeaponState; + /* 0x0844 */ s8 unk_844; + /* 0x0845 */ u8 unk_845; + /* 0x0846 */ u8 unk_846; + /* 0x0847 */ s8 unk_847[4]; + /* 0x084B */ s8 unk_84B[4]; + + /* 0x084F */ union { + s8 actionVar1; + } av1; // "Action Variable 1": context dependent variable that has different meanings depending on what action is currently running + + /* 0x0850 */ union { + s16 actionVar2; + } av2; // "Action Variable 2": context dependent variable that has different meanings depending on what action is currently running + + /* 0x0854 */ f32 unk_854; + /* 0x0858 */ f32 unk_858; + /* 0x085C */ f32 unk_85C; // stick length among other things + /* 0x0860 */ s16 unk_860; // stick flame timer among other things + /* 0x0862 */ s16 unk_862; // get item draw ID + 1 + /* 0x0864 */ f32 unk_864; + /* 0x0868 */ f32 unk_868; + /* 0x086C */ f32 unk_86C; + /* 0x0870 */ f32 unk_870; + /* 0x0874 */ f32 unk_874; + /* 0x0878 */ f32 unk_878; + /* 0x087C */ s16 unk_87C; + /* 0x087E */ s16 unk_87E; + /* 0x0880 */ f32 unk_880; + /* 0x0884 */ f32 yDistToLedge; // y distance to ground above an interact wall. LEDGE_DIST_MAX if no ground is found + /* 0x0888 */ f32 distToInteractWall; // xyz distance to the interact wall + /* 0x088C */ u8 ledgeClimbType; + /* 0x088D */ u8 ledgeClimbDelayTimer; + /* 0x088E */ u8 unk_88E; + /* 0x088F */ u8 unk_88F; + /* 0x0890 */ u8 unk_890; + /* 0x0891 */ u8 bodyShockTimer; + /* 0x0892 */ u8 unk_892; + /* 0x0893 */ u8 hoverBootsTimer; + /* 0x0894 */ s16 fallStartHeight; // last truncated Y position before falling + /* 0x0896 */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) + /* 0x0898 */ s16 floorPitch; // angle of the floor slope in the direction of current world yaw (positive for ascending slope) + /* 0x089A */ s16 floorPitchAlt; // the calculation for this value is bugged and doesn't represent anything meaningful + /* 0x089C */ s16 unk_89C; + /* 0x089E */ u16 floorSfxOffset; + /* 0x08A0 */ u8 unk_8A0; + /* 0x08A1 */ u8 unk_8A1; + /* 0x08A2 */ s16 unk_8A2; + /* 0x08A4 */ f32 unk_8A4; + /* 0x08A8 */ f32 unk_8A8; + /* 0x08AC */ f32 pushedSpeed; // Pushing player, examples include water currents, floor conveyors, climbing sloped surfaces + /* 0x08B0 */ s16 pushedYaw; // Yaw direction of player being pushed /* 0x08B4 */ WeaponInfo meleeWeaponInfo[3]; - /* 0x0908 */ Vec3f bodyPartsPos[PLAYER_BODYPART_MAX]; - /* 0x09E0 */ MtxF mf_9E0; - /* 0x0A20 */ MtxF shieldMf; - /* 0x0A60 */ u8 isBurning; - /* 0x0A61 */ u8 flameTimers[PLAYER_BODYPART_MAX]; // one flame per body part - /* 0x0A73 */ u8 unk_A73; + /* 0x0908 */ Vec3f bodyPartsPos[PLAYER_BODYPART_MAX]; + /* 0x09E0 */ MtxF mf_9E0; + /* 0x0A20 */ MtxF shieldMf; + /* 0x0A60 */ u8 bodyIsBurning; + /* 0x0A61 */ u8 bodyFlameTimers[PLAYER_BODYPART_MAX]; // one flame per body part + /* 0x0A73 */ u8 unk_A73; /* 0x0A74 */ PlayerFuncA74 func_A74; - /* 0x0A78 */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) - /* 0x0A79 */ u8 unk_A79; - /* 0x0A7A */ u8 unk_A7A; - /* 0x0A7B */ u8 unk_A7B; - /* 0x0A7C */ f32 unk_A7C; - /* 0x0A80 */ s16 unk_A80; - /* 0x0A82 */ u16 unk_A82; - /* 0x0A84 */ s16 unk_A84; - /* 0x0A86 */ s8 unk_A86; - /* 0x0A87 */ u8 unk_A87; - /* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position + /* 0x0A78 */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) + /* 0x0A79 */ u8 floorTypeTimer; // counts up every frame the current floor type is the same as the last frame + /* 0x0A7A */ u8 floorProperty; + /* 0x0A7B */ u8 prevFloorType; + /* 0x0A7C */ f32 prevControlStickMagnitude; + /* 0x0A80 */ s16 prevControlStickAngle; + /* 0x0A82 */ u16 prevFloorSfxOffset; + /* 0x0A84 */ s16 unk_A84; + /* 0x0A86 */ s8 unk_A86; + /* 0x0A87 */ u8 unk_A87; + /* 0x0A88 */ Vec3f unk_A88; // previous body part 0 position // #region SOH [General] // Upstream TODO: Rename these to be more obviously SoH specific /* */ PendingFlag pendingFlag; @@ -670,7 +677,7 @@ typedef struct Player { // #endregion // #region SOH [Enhancements] // Upstream TODO: Rename this to make it more obvious it is apart of an enhancement - /* */ u8 boomerangQuickRecall; // Has the player pressed the boomerang button while it's in the air still? + /* */ u8 boomerangQuickRecall; // Has the player pressed the boomerang button while it's in the air still? // #endregion u8 ivanFloating; u8 ivanDamageMultiplier; diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp new file mode 100644 index 000000000..6b25589c6 --- /dev/null +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -0,0 +1,519 @@ +#include "InputViewer.h" + +#include "public/bridge/consolevariablebridge.h" +#include "libultraship/libultra/controller.h" +#include "Context.h" +#ifndef IMGUI_DEFINE_MATH_OPERATORS +#define IMGUI_DEFINE_MATH_OPERATORS +#endif +#include +#include +#include + +#include "../../UIWidgets.hpp" + +// Text colors +static ImVec4 textColor = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); +static ImVec4 range1Color = ImVec4(1.0f, 0.7f, 0, 1.0f); +static ImVec4 range2Color = ImVec4(0, 1.0f, 0, 1.0f); + +static const char* buttonOutlineOptions[4] = { "Always Shown", "Shown Only While Not Pressed", + "Shown Only While Pressed", "Always Hidden" }; + +static const char* stickModeOptions[3] = { "Always", "While In Use", "Never" }; + +static Color_RGBA8 vec2Color(ImVec4 vec) { + Color_RGBA8 color; + color.r = vec.x * 255.0; + color.g = vec.y * 255.0; + color.b = vec.z * 255.0; + color.a = vec.w * 255.0; + return color; +} + +static ImVec4 color2Vec(Color_RGBA8 color) { + return ImVec4(color.r / 255.0, color.g / 255.0, color.b / 255.0, color.a / 255.0); +} + +InputViewer::~InputViewer() { + SPDLOG_TRACE("destruct input viewer"); +} + +void InputViewer::RenderButton(std::string btnTexture, std::string btnOutlineTexture, int state, ImVec2 size, + int outlineMode) { + const ImVec2 pos = ImGui::GetCursorPos(); + ImGui::SetNextItemAllowOverlap(); + // Render Outline based on settings + if (outlineMode == BUTTON_OUTLINE_ALWAYS_SHOWN || (outlineMode == BUTTON_OUTLINE_NOT_PRESSED && !state) || + (outlineMode == BUTTON_OUTLINE_PRESSED && state)) { + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnOutlineTexture), size, + ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + } + // Render button if pressed + if (state) { + ImGui::SetCursorPos(pos); + ImGui::SetNextItemAllowOverlap(); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName(btnTexture), size, + ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + } +} + +void InputViewer::DrawElement() { + if (CVarGetInteger("gOpenWindows.InputViewer", 0)) { + static bool sButtonTexturesLoaded = false; + if (!sButtonTexturesLoaded) { + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage( + "Input-Viewer-Background", "textures/buttons/InputViewerBackground.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn", "textures/buttons/ABtn.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn", "textures/buttons/BBtn.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn", "textures/buttons/LBtn.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn", "textures/buttons/RBtn.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn", "textures/buttons/ZBtn.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn", + "textures/buttons/StartBtn.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left", "textures/buttons/CLeft.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right", "textures/buttons/CRight.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up", "textures/buttons/CUp.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down", "textures/buttons/CDown.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick", + "textures/buttons/AnalogStick.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left", + "textures/buttons/DPadLeft.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right", + "textures/buttons/DPadRight.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up", "textures/buttons/DPadUp.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down", + "textures/buttons/DPadDown.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick", + "textures/buttons/RightStick.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("A-Btn Outline", + "textures/buttons/ABtnOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("B-Btn Outline", + "textures/buttons/BBtnOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("L-Btn Outline", + "textures/buttons/LBtnOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("R-Btn Outline", + "textures/buttons/RBtnOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Z-Btn Outline", + "textures/buttons/ZBtnOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Start-Btn Outline", + "textures/buttons/StartBtnOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Left Outline", + "textures/buttons/CLeftOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Right Outline", + "textures/buttons/CRightOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Up Outline", + "textures/buttons/CUpOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("C-Down Outline", + "textures/buttons/CDownOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Analog-Stick Outline", + "textures/buttons/AnalogStickOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Left Outline", + "textures/buttons/DPadLeftOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Right Outline", + "textures/buttons/DPadRightOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Up Outline", + "textures/buttons/DPadUpOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Dpad-Down Outline", + "textures/buttons/DPadDownOutline.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Right-Stick Outline", + "textures/buttons/RightStickOutline.png"); + sButtonTexturesLoaded = true; + } + + ImVec2 mainPos = ImGui::GetWindowPos(); + ImVec2 size = ImGui::GetContentRegionAvail(); + +#ifdef __WIIU__ + const float scale = CVarGetFloat("gInputViewer.Scale", 1.0f) * 2.0f; +#else + const float scale = CVarGetFloat("gInputViewer.Scale", 1.0f); +#endif + const int showAnalogAngles = CVarGetInteger("gInputViewer.AnalogAngles.Enabled", 0); + const int buttonOutlineMode = CVarGetInteger("gInputViewer.ButtonOutlineMode", BUTTON_OUTLINE_NOT_PRESSED); + + ImVec2 bgSize = LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureSize("Input-Viewer-Background"); + ImVec2 scaledBGSize = ImVec2(bgSize.x * scale, bgSize.y * scale); + + ImGui::SetNextWindowSize(ImVec2( + scaledBGSize.x + 20, + scaledBGSize.y + + (showAnalogAngles ? ImGui::CalcTextSize("X").y : 0) * scale * CVarGetFloat("gInputViewer.AnalogAngles.Scale", 1.0f) + 20)); + ImGui::SetNextWindowContentSize( + ImVec2(scaledBGSize.x, scaledBGSize.y + (showAnalogAngles ? 15 : 0) * scale * + CVarGetFloat("gInputViewer.AnalogAngles.Scale", 1.0f))); + ImGui::SetNextWindowPos( + ImVec2(mainPos.x + size.x - scaledBGSize.x - 30, mainPos.y + size.y - scaledBGSize.y - 30), + ImGuiCond_FirstUseEver); + + ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f)); + + OSContPad* pads = LUS::Context::GetInstance()->GetControlDeck()->GetPads(); + + ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoBackground | + ImGuiWindowFlags_NoFocusOnAppearing; + + if (!CVarGetInteger("gInputViewer.EnableDragging", 1)) { + windowFlags |= ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoMove; + } + + if (pads != nullptr && ImGui::Begin("Input Viewer", nullptr, windowFlags)) { + ImGui::SetCursorPos(ImVec2(10, 10)); + const ImVec2 aPos = ImGui::GetCursorPos(); + + if (CVarGetInteger("gInputViewer.ShowBackground", 1)) { + ImGui::SetNextItemAllowOverlap(); + // Background + ImGui::Image( + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Input-Viewer-Background"), + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + } + + // A/B + if (CVarGetInteger("gInputViewer.BBtn", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("B-Btn", "B-Btn Outline", pads[0].button & BTN_B, scaledBGSize, buttonOutlineMode); + } + if (CVarGetInteger("gInputViewer.ABtn", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("A-Btn", "A-Btn Outline", pads[0].button & BTN_A, scaledBGSize, buttonOutlineMode); + } + + // C buttons + if (CVarGetInteger("gInputViewer.CUp", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("C-Up", "C-Up Outline", pads[0].button & BTN_CUP, scaledBGSize, buttonOutlineMode); + } + if (CVarGetInteger("gInputViewer.CLeft", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("C-Left", "C-Left Outline", pads[0].button & BTN_CLEFT, scaledBGSize, buttonOutlineMode); + } + if (CVarGetInteger("gInputViewer.CRight", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("C-Right", "C-Right Outline", pads[0].button & BTN_CRIGHT, scaledBGSize, + buttonOutlineMode); + } + if (CVarGetInteger("gInputViewer.CDown", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("C-Down", "C-Down Outline", pads[0].button & BTN_CDOWN, scaledBGSize, buttonOutlineMode); + } + + // L/R/Z + if (CVarGetInteger("gInputViewer.LBtn", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("L-Btn", "L-Btn Outline", pads[0].button & BTN_L, scaledBGSize, buttonOutlineMode); + } + if (CVarGetInteger("gInputViewer.RBtn", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("R-Btn", "R-Btn Outline", pads[0].button & BTN_R, scaledBGSize, buttonOutlineMode); + } + if (CVarGetInteger("gInputViewer.ZBtn", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Z-Btn", "Z-Btn Outline", pads[0].button & BTN_Z, scaledBGSize, buttonOutlineMode); + } + + // Start + if (CVarGetInteger("gInputViewer.StartBtn", 1)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Start-Btn", "Start-Btn Outline", pads[0].button & BTN_START, scaledBGSize, + buttonOutlineMode); + } + + // Dpad + if (CVarGetInteger("gInputViewer.Dpad", 0)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Dpad-Left", "Dpad-Left Outline", pads[0].button & BTN_DLEFT, scaledBGSize, + buttonOutlineMode); + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Dpad-Right", "Dpad-Right Outline", pads[0].button & BTN_DRIGHT, scaledBGSize, + buttonOutlineMode); + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Dpad-Up", "Dpad-Up Outline", pads[0].button & BTN_DUP, scaledBGSize, buttonOutlineMode); + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + RenderButton("Dpad-Down", "Dpad-Down Outline", pads[0].button & BTN_DDOWN, scaledBGSize, + buttonOutlineMode); + } + + const bool analogStickIsInDeadzone = !pads[0].stick_x && !pads[0].stick_y; + const bool rightStickIsInDeadzone = !pads[0].right_stick_x && !pads[0].right_stick_y; + + // Analog Stick + const int analogOutlineMode = + CVarGetInteger("gInputViewer.AnalogStick.OutlineMode", STICK_MODE_ALWAYS_SHOWN); + const float maxStickDistance = CVarGetInteger("gInputViewer.AnalogStick.Movement", 12); + if (analogOutlineMode == STICK_MODE_ALWAYS_SHOWN || + (analogOutlineMode == STICK_MODE_HIDDEN_IN_DEADZONE && !analogStickIsInDeadzone)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + ImGui::Image( + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick Outline"), + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + } + const int analogStickMode = + CVarGetInteger("gInputViewer.AnalogStick.VisibilityMode", STICK_MODE_ALWAYS_SHOWN); + if (analogStickMode == STICK_MODE_ALWAYS_SHOWN || + (analogStickMode == STICK_MODE_HIDDEN_IN_DEADZONE && !analogStickIsInDeadzone)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos( + ImVec2(aPos.x + maxStickDistance * ((float)(pads[0].stick_x) / MAX_AXIS_RANGE) * scale, + aPos.y - maxStickDistance * ((float)(pads[0].stick_y) / MAX_AXIS_RANGE) * scale)); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Analog-Stick"), + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + } + + // Right Stick + const float maxRightStickDistance = CVarGetInteger("gInputViewer.RightStick.Movement", 7); + const int rightOutlineMode = + CVarGetInteger("gInputViewer.RightStick.OutlineMode", STICK_MODE_ALWAYS_HIDDEN); + if (rightOutlineMode == STICK_MODE_ALWAYS_SHOWN || + (rightOutlineMode == STICK_MODE_HIDDEN_IN_DEADZONE && !rightStickIsInDeadzone)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos(aPos); + ImGui::Image( + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick Outline"), + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + } + const int rightStickMode = + CVarGetInteger("gInputViewer.RightStick.VisibilityMode", STICK_MODE_ALWAYS_HIDDEN); + if (rightStickMode == STICK_MODE_ALWAYS_SHOWN || + (rightStickMode == STICK_MODE_HIDDEN_IN_DEADZONE && !rightStickIsInDeadzone)) { + ImGui::SetNextItemAllowOverlap(); + ImGui::SetCursorPos( + ImVec2(aPos.x + maxRightStickDistance * ((float)(pads[0].right_stick_x) / MAX_AXIS_RANGE) * scale, + aPos.y - maxRightStickDistance * ((float)(pads[0].right_stick_y) / MAX_AXIS_RANGE) * scale)); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Right-Stick"), + scaledBGSize, ImVec2(0, 0), ImVec2(1.0f, 1.0f), ImVec4(255, 255, 255, 255)); + } + + // Analog stick angle text + if (showAnalogAngles) { + ImGui::SetCursorPos(ImVec2(aPos.x + 10 + CVarGetInteger("gInputViewer.AnalogAngles.Offset", 0) * scale, + scaledBGSize.y + aPos.y + 10)); + // Scale font with input viewer scale + float oldFontScale = ImGui::GetFont()->Scale; + ImGui::GetFont()->Scale *= scale * CVarGetFloat("gInputViewer.AnalogAngles.Scale", 1.0f); + ImGui::PushFont(ImGui::GetFont()); + + // Calculate polar R coordinate from X and Y angles, squared to avoid sqrt + const float rSquared = pads[0].stick_x * pads[0].stick_x + pads[0].stick_y * pads[0].stick_y; + + // ESS range + const int range1Min = CVarGetInteger("gInputViewer.AnalogAngles.Range1.Min", 8); + const int range1Max = CVarGetInteger("gInputViewer.AnalogAngles.Range1.Max", 27); + // Walking speed range + const int range2Min = CVarGetInteger("gInputViewer.AnalogAngles.Range2.Min", 27); + const int range2Max = CVarGetInteger("gInputViewer.AnalogAngles.Range2.Max", 62); + + // Push color based on angle ranges + if (CVarGetInteger("gInputViewer.AnalogAngles.Range1.Enabled", 0) && + (rSquared >= (range1Min * range1Min)) && (rSquared < (range1Max * range1Max))) { + ImGui::PushStyleColor( + ImGuiCol_Text, + color2Vec(CVarGetColor("gInputViewer.AnalogAngles.Range1.Color", vec2Color(range1Color)))); + } else if (CVarGetInteger("gInputViewer.AnalogAngles.Range2.Enabled", 0) && + (rSquared >= (range2Min * range2Min)) && (rSquared < (range2Max * range2Max))) { + ImGui::PushStyleColor( + ImGuiCol_Text, + color2Vec(CVarGetColor("gInputViewer.AnalogAngles.Range2.Color", vec2Color(range2Color)))); + } else { + ImGui::PushStyleColor(ImGuiCol_Text, color2Vec(CVarGetColor("gInputViewer.AnalogAngles.TextColor", + vec2Color(textColor)))); + } + + // Render text + ImGui::Text("X: %-3d Y: %-3d", pads[0].stick_x, pads[0].stick_y); + // Restore original color + ImGui::PopStyleColor(); + // Restore original font scale + ImGui::GetFont()->Scale = oldFontScale; + ImGui::PopFont(); + } + + ImGui::End(); + } + + ImGui::PopStyleVar(); + ImGui::PopStyleColor(); + } +} + +InputViewerSettingsWindow::~InputViewerSettingsWindow() { + SPDLOG_TRACE("destruct input viewer settings window"); +} + +void InputViewerSettingsWindow::DrawElement() { + ImGui::SetNextWindowSize(ImVec2(450, 525), ImGuiCond_FirstUseEver); + + if (ImGui::Begin("Input Viewer Settings", &mIsVisible)) { + + // gInputViewer.Scale + UIWidgets::EnhancementSliderFloat("Input Viewer Scale: %.2f", "##Input", "gInputViewer.Scale", 0.1f, 5.0f, "", + 1.0f, false, true); + UIWidgets::Tooltip("Sets the on screen size of the input viewer"); + + // gInputViewer.EnableDragging + UIWidgets::EnhancementCheckbox("Enable Dragging", "gInputViewer.EnableDragging", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + + UIWidgets::PaddedSeparator(true, true); + + // gInputViewer.ShowBackground + UIWidgets::EnhancementCheckbox("Show Background Layer", "gInputViewer.ShowBackground", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + + UIWidgets::PaddedSeparator(true, true); + + if (ImGui::CollapsingHeader("Buttons")) { + // gInputViewer.ABtn + UIWidgets::EnhancementCheckbox("Show A-Button Layers", "gInputViewer.ABtn", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.BBtn + UIWidgets::EnhancementCheckbox("Show B-Button Layers", "gInputViewer.BBtn", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.CUp + UIWidgets::EnhancementCheckbox("Show C-Up Layers", "gInputViewer.CUp", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.CRight + UIWidgets::EnhancementCheckbox("Show C-Right Layers", "gInputViewer.CRight", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.CDown + UIWidgets::EnhancementCheckbox("Show C-Down Layers", "gInputViewer.CDown", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.CLeft + UIWidgets::EnhancementCheckbox("Show C-Left Layers", "gInputViewer.CLeft", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.LBtn + UIWidgets::EnhancementCheckbox("Show L-Button Layers", "gInputViewer.LBtn", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.RBtn + UIWidgets::EnhancementCheckbox("Show R-Button Layers", "gInputViewer.RBtn", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.ZBtn + UIWidgets::EnhancementCheckbox("Show Z-Button Layers", "gInputViewer.ZBtn", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.StartBtn + UIWidgets::EnhancementCheckbox("Show Start Button Layers", "gInputViewer.StartBtn", false, "", + UIWidgets::CheckboxGraphics::Checkmark, true); + // gInputViewer.Dpad + UIWidgets::EnhancementCheckbox("Show D-Pad Layers", "gInputViewer.Dpad", false, "", + UIWidgets::CheckboxGraphics::Checkmark, false); + + // gInputViewer.ButtonOutlineMode + UIWidgets::PaddedText("Button Outlines/Backgrounds", true, false); + UIWidgets::EnhancementCombobox("gInputViewer.ButtonOutlineMode", buttonOutlineOptions, + BUTTON_OUTLINE_NOT_PRESSED); + UIWidgets::Tooltip( + "Sets the desired visibility behavior for the button outline/background layers. Useful for " + "custom input viewers."); + + UIWidgets::PaddedSeparator(true, true); + } + + if (ImGui::CollapsingHeader("Analog Stick")) { + // gInputViewer.AnalogStick.VisibilityMode + UIWidgets::PaddedText("Analog Stick Visibility", true, false); + UIWidgets::EnhancementCombobox("gInputViewer.AnalogStick.VisibilityMode", stickModeOptions, + STICK_MODE_ALWAYS_SHOWN); + UIWidgets::Tooltip( + "Determines the conditions under which the moving layer of the analog stick texture is visible."); + + // gInputViewer.AnalogStick.OutlineMode + UIWidgets::PaddedText("Analog Stick Outline/Background Visibility", true, false); + UIWidgets::EnhancementCombobox("gInputViewer.AnalogStick.OutlineMode", stickModeOptions, + STICK_MODE_ALWAYS_SHOWN); + UIWidgets::Tooltip( + "Determines the conditions under which the analog stick outline/background texture is visible."); + + // gInputViewer.AnalogStick.Movement + UIWidgets::EnhancementSliderInt("Analog Stick Movement: %dpx", "##AnalogMovement", + "gInputViewer.AnalogStick.Movement", 0, 200, "", 12, true); + UIWidgets::Tooltip( + "Sets the distance to move the analog stick in the input viewer. Useful for custom input viewers."); + UIWidgets::PaddedSeparator(true, true); + } + + if (ImGui::CollapsingHeader("Additional (\"Right\") Stick")) { + // gInputViewer.RightStick.VisibilityMode + UIWidgets::PaddedText("Right Stick Visibility", true, false); + UIWidgets::EnhancementCombobox("gInputViewer.RightStick.VisibilityMode", stickModeOptions, + STICK_MODE_HIDDEN_IN_DEADZONE); + UIWidgets::Tooltip( + "Determines the conditions under which the moving layer of the right stick texture is visible."); + + // gInputViewer.RightStick.OutlineMode + UIWidgets::PaddedText("Right Stick Outline/Background Visibility", true, false); + UIWidgets::EnhancementCombobox("gInputViewer.RightStick.OutlineMode", stickModeOptions, + STICK_MODE_HIDDEN_IN_DEADZONE); + UIWidgets::Tooltip( + "Determines the conditions under which the right stick outline/background texture is visible."); + + // gInputViewer.RightStick.Movement + UIWidgets::EnhancementSliderInt("Right Stick Movement: %dpx", "##RightMovement", + "gInputViewer.RightStick.Movement", 0, 200, "", 7, true); + UIWidgets::Tooltip( + "Sets the distance to move the right stick in the input viewer. Useful for custom input viewers."); + UIWidgets::PaddedSeparator(true, true); + } + + if (ImGui::CollapsingHeader("Analog Angle Values")) { + // gAnalogAngles + UIWidgets::EnhancementCheckbox("Show Analog Stick Angle Values", "gInputViewer.AnalogAngles.Enabled"); + UIWidgets::Tooltip("Displays analog stick angle values in the input viewer"); + if (CVarGetInteger("gInputViewer.AnalogAngles.Enabled", 0)) { + // gInputViewer.AnalogAngles.TextColor + if (ImGui::ColorEdit4("Text Color", (float*)&textColor)) { + CVarSetColor("gInputViewer.AnalogAngles.TextColor", vec2Color(textColor)); + } + // gAnalogAngleScale + UIWidgets::EnhancementSliderFloat("Angle Text Scale: %.2f%%", "##AnalogAngleScale", + "gInputViewer.AnalogAngles.Scale", 0.1f, 5.0f, "", 1.0f, true, true); + // gInputViewer.AnalogAngles.Offset + UIWidgets::EnhancementSliderInt("Angle Text Offset: %dpx", "##AnalogAngleOffset", + "gInputViewer.AnalogAngles.Offset", 0, 400, "", 0, true); + UIWidgets::PaddedSeparator(true, true); + // gInputViewer.AnalogAngles.Range1.Enabled + UIWidgets::EnhancementCheckbox("Highlight ESS Position", "gInputViewer.AnalogAngles.Range1.Enabled"); + UIWidgets::Tooltip( + "Highlights the angle value text when the analog stick is in ESS position (on flat ground)"); + if (CVarGetInteger("gInputViewer.AnalogAngles.Range1.Enabled", 0)) { + // gInputViewer.AnalogAngles.Range1.Color + if (ImGui::ColorEdit4("ESS Color", (float*)&range1Color)) { + CVarSetColor("gInputViewer.AnalogAngles.Range1.Color", vec2Color(range1Color)); + } + } + + UIWidgets::PaddedSeparator(true, true); + // gInputViewer.AnalogAngles.Range2.Enabled + UIWidgets::EnhancementCheckbox("Highlight Walking Speed Angles", + "gInputViewer.AnalogAngles.Range2.Enabled"); + UIWidgets::Tooltip("Highlights the angle value text when the analog stick is at an angle that would " + "produce a walking speed (on flat ground)\n\n" + "Useful for 1.0 Empty Jumpslash Quick Put Away"); + if (CVarGetInteger("gInputViewer.AnalogAngles.Range2.Enabled", 0)) { + // gInputViewer.AnalogAngles.Range2.Color + if (ImGui::ColorEdit4("Walking Speed Color", (float*)&range2Color)) { + CVarSetColor("gInputViewer.AnalogAngles.Range2.Color", vec2Color(range2Color)); + } + } + } + } + + ImGui::End(); + } +} \ No newline at end of file diff --git a/soh/soh/Enhancements/controls/InputViewer.h b/soh/soh/Enhancements/controls/InputViewer.h new file mode 100644 index 000000000..646c15d9d --- /dev/null +++ b/soh/soh/Enhancements/controls/InputViewer.h @@ -0,0 +1,47 @@ +#pragma once + +#include + +typedef enum { + BUTTON_OUTLINE_ALWAYS_SHOWN, + BUTTON_OUTLINE_NOT_PRESSED, + BUTTON_OUTLINE_PRESSED, + BUTTON_OUTLINE_ALWAYS_HIDDEN +} ButtonOutlineMode; + +typedef enum { + STICK_MODE_ALWAYS_SHOWN, + STICK_MODE_HIDDEN_IN_DEADZONE, + STICK_MODE_ALWAYS_HIDDEN, +} StickMode; + +class InputViewer : public LUS::GuiWindow { +public: + using LUS::GuiWindow::GuiWindow; + + void InitElement() override {}; + void DrawElement() override; + void UpdateElement() override {}; + + InputViewer(); + ~InputViewer(); + + void Draw(); + + private: + void RenderButton(std::string btn, std::string btnOutline, int state, ImVec2 size, int outlineMode); +}; + +class InputViewerSettingsWindow : public LUS::GuiWindow { +public: + using LUS::GuiWindow::GuiWindow; + + void InitElement() override {}; + void DrawElement() override; + void UpdateElement() override {}; + + InputViewerSettingsWindow(); + ~InputViewerSettingsWindow(); + + void Draw(); +}; \ No newline at end of file diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 240bf5894..4f04bc64b 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -269,35 +269,35 @@ static std::map cosmeticOptions = { COSMETIC_OPTION("Hud_NameTagActorText", "Nametag Text", GROUP_HUD, ImVec4(255, 255, 255, 255), true, true, false), COSMETIC_OPTION("Hud_NameTagActorBackground", "Nametag Background", GROUP_HUD, ImVec4(0, 0, 0, 80), true, false, true), - COSMETIC_OPTION("Kal_ItemSelA", "Item Select Color A", GROUP_KALEIDO, ImVec4(10, 50, 80, 255), false, true, false), - COSMETIC_OPTION("Kal_ItemSelB", "Item Select Color B", GROUP_KALEIDO, ImVec4(70, 100, 130, 255), false, true, false), - COSMETIC_OPTION("Kal_ItemSelC", "Item Select Color C", GROUP_KALEIDO, ImVec4(70, 100, 130, 255), false, true, false), - COSMETIC_OPTION("Kal_ItemSelD", "Item Select Color D", GROUP_KALEIDO, ImVec4(10, 50, 80, 255), false, true, false), + COSMETIC_OPTION("Kal_ItemSelA", "Item Select Color", GROUP_KALEIDO, ImVec4(10, 50, 80, 255), false, true, false), + COSMETIC_OPTION("Kal_ItemSelB", "Item Select Color B", GROUP_KALEIDO, ImVec4(70, 100, 130, 255), false, true, true), + COSMETIC_OPTION("Kal_ItemSelC", "Item Select Color C", GROUP_KALEIDO, ImVec4(70, 100, 130, 255), false, true, true), + COSMETIC_OPTION("Kal_ItemSelD", "Item Select Color D", GROUP_KALEIDO, ImVec4(10, 50, 80, 255), false, true, true), - COSMETIC_OPTION("Kal_EquipSelA", "Equip Select Color A", GROUP_KALEIDO, ImVec4(10, 50, 40, 255), false, true, false), - COSMETIC_OPTION("Kal_EquipSelB", "Equip Select Color B", GROUP_KALEIDO, ImVec4(90, 100, 60, 255), false, true, false), - COSMETIC_OPTION("Kal_EquipSelC", "Equip Select Color C", GROUP_KALEIDO, ImVec4(90, 100, 60, 255), false, true, false), - COSMETIC_OPTION("Kal_EquipSelD", "Equip Select Color D", GROUP_KALEIDO, ImVec4(10, 50, 80, 255), false, true, false), + COSMETIC_OPTION("Kal_EquipSelA", "Equip Select Color", GROUP_KALEIDO, ImVec4(10, 50, 40, 255), false, true, false), + COSMETIC_OPTION("Kal_EquipSelB", "Equip Select Color B", GROUP_KALEIDO, ImVec4(90, 100, 60, 255), false, true, true), + COSMETIC_OPTION("Kal_EquipSelC", "Equip Select Color C", GROUP_KALEIDO, ImVec4(90, 100, 60, 255), false, true, true), + COSMETIC_OPTION("Kal_EquipSelD", "Equip Select Color D", GROUP_KALEIDO, ImVec4(10, 50, 80, 255), false, true, true), - COSMETIC_OPTION("Kal_MapSelDunA", "Map Dungeon Color A", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, false), - COSMETIC_OPTION("Kal_MapSelDunB", "Map Dungeon Color B", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, false), - COSMETIC_OPTION("Kal_MapSelDunC", "Map Dungeon Color C", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, false), - COSMETIC_OPTION("Kal_MapSelDunD", "Map Dungeon Color D", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, false), + COSMETIC_OPTION("Kal_MapSelDunA", "Map Dungeon Color", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, true), + COSMETIC_OPTION("Kal_MapSelDunB", "Map Dungeon Color B", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, true), + COSMETIC_OPTION("Kal_MapSelDunC", "Map Dungeon Color C", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, true), + COSMETIC_OPTION("Kal_MapSelDunD", "Map Dungeon Color D", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, true), - COSMETIC_OPTION("Kal_QuestStatusA", "Quest StatusColor A", GROUP_KALEIDO, ImVec4(80, 80, 50, 255), false, true, false), - COSMETIC_OPTION("Kal_QuestStatusB", "Quest StatusColor B", GROUP_KALEIDO, ImVec4(120, 120, 70, 255), false, true, false), - COSMETIC_OPTION("Kal_QuestStatusC", "Quest StatusColor C", GROUP_KALEIDO, ImVec4(120, 120, 70, 255), false, true, false), - COSMETIC_OPTION("Kal_QuestStatusD", "Quest StatusColor D", GROUP_KALEIDO, ImVec4(80, 80, 50, 255), false, true, false), + COSMETIC_OPTION("Kal_QuestStatusA", "Quest Status Color", GROUP_KALEIDO, ImVec4(80, 80, 50, 255), false, true, false), + COSMETIC_OPTION("Kal_QuestStatusB", "Quest Status Color B", GROUP_KALEIDO, ImVec4(120, 120, 70, 255), false, true, true), + COSMETIC_OPTION("Kal_QuestStatusC", "Quest Status Color C", GROUP_KALEIDO, ImVec4(120, 120, 70, 255), false, true, true), + COSMETIC_OPTION("Kal_QuestStatusD", "Quest Status Color D", GROUP_KALEIDO, ImVec4(80, 80, 50, 255), false, true, true), - COSMETIC_OPTION("Kal_MapSelectA", "Map Color A", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, false), - COSMETIC_OPTION("Kal_MapSelectB", "Map Color B", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, false), - COSMETIC_OPTION("Kal_MapSelectC", "Map Color C", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, false), - COSMETIC_OPTION("Kal_MapSelectD", "Map Color D", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, false), + COSMETIC_OPTION("Kal_MapSelectA", "Map Color", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, false), + COSMETIC_OPTION("Kal_MapSelectB", "Map Color B", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, true), + COSMETIC_OPTION("Kal_MapSelectC", "Map Color C", GROUP_KALEIDO, ImVec4(140, 60, 60, 255), false, true, true), + COSMETIC_OPTION("Kal_MapSelectD", "Map Color D", GROUP_KALEIDO, ImVec4(80, 40, 30, 255), false, true, true), - COSMETIC_OPTION("Kal_SaveA", "Save A", GROUP_KALEIDO, ImVec4(50, 50, 50, 255), false, true, false), - COSMETIC_OPTION("Kal_SaveB", "Save B", GROUP_KALEIDO, ImVec4(110, 110, 110, 255), false, true, false), - COSMETIC_OPTION("Kal_SaveC", "Save C", GROUP_KALEIDO, ImVec4(110, 110, 110, 255), false, true, false), - COSMETIC_OPTION("Kal_SaveD", "Save D", GROUP_KALEIDO, ImVec4(50, 50, 50, 255), false, true, false), + COSMETIC_OPTION("Kal_SaveA", "Save Color", GROUP_KALEIDO, ImVec4(50, 50, 50, 255), false, true, false), + COSMETIC_OPTION("Kal_SaveB", "Save Color B", GROUP_KALEIDO, ImVec4(110, 110, 110, 255), false, true, true), + COSMETIC_OPTION("Kal_SaveC", "Save Color C", GROUP_KALEIDO, ImVec4(110, 110, 110, 255), false, true, true), + COSMETIC_OPTION("Kal_SaveD", "Save Color D", GROUP_KALEIDO, ImVec4(50, 50, 50, 255), false, true, true), COSMETIC_OPTION("Kal_NamePanel", "Name Panel", GROUP_KALEIDO, ImVec4(90,100,130,255), true, true, false), @@ -1065,12 +1065,16 @@ void ApplyOrResetCustomGfxPatches(bool manualChange) { if (manualChange || CVarGetInteger(npcGoldenSkulltula.rainbowCvar, 0)) { static Color_RGBA8 defaultColor = {npcGoldenSkulltula.defaultColor.x, npcGoldenSkulltula.defaultColor.y, npcGoldenSkulltula.defaultColor.z, npcGoldenSkulltula.defaultColor.w}; Color_RGBA8 color = CVarGetColor(npcGoldenSkulltula.cvar, defaultColor); - PATCH_GFX(gGiSkulltulaTokenDL, "NPC_GoldenSkulltula1", npcGoldenSkulltula.changedCvar, 5, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); - PATCH_GFX(gGiSkulltulaTokenDL, "NPC_GoldenSkulltula2", npcGoldenSkulltula.changedCvar, 6, gsDPSetEnvColor(color.r / 2, color.g / 2, color.b / 2, 255)); - PATCH_GFX(gGiSkulltulaTokenFlameDL, "NPC_GoldenSkulltula3", npcGoldenSkulltula.changedCvar, 32, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); - PATCH_GFX(gGiSkulltulaTokenFlameDL, "NPC_GoldenSkulltula4", npcGoldenSkulltula.changedCvar, 33, gsDPSetEnvColor(color.r / 2, color.g / 2, color.b / 2, 255)); - PATCH_GFX(object_st_DL_003FB0, "NPC_GoldenSkulltula5", npcGoldenSkulltula.changedCvar, 118, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); - PATCH_GFX(object_st_DL_003FB0, "NPC_GoldenSkulltula6", npcGoldenSkulltula.changedCvar, 119, gsDPSetEnvColor(color.r / 4, color.g / 4, color.b / 4, 255)); + PATCH_GFX(gSkulltulaTokenDL, "NPC_GoldenSkulltula1", npcGoldenSkulltula.changedCvar, 5, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); + PATCH_GFX(gSkulltulaTokenDL, "NPC_GoldenSkulltula2", npcGoldenSkulltula.changedCvar, 6, gsDPSetEnvColor(color.r / 2, color.g / 2, color.b / 2, 255)); + PATCH_GFX(gSkulltulaTokenFlameDL, "NPC_GoldenSkulltula3", npcGoldenSkulltula.changedCvar, 32, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); + PATCH_GFX(gSkulltulaTokenFlameDL, "NPC_GoldenSkulltula4", npcGoldenSkulltula.changedCvar, 33, gsDPSetEnvColor(color.r / 2, color.g / 2, color.b / 2, 255)); + PATCH_GFX(gGiSkulltulaTokenDL, "NPC_GoldenSkulltula5", npcGoldenSkulltula.changedCvar, 5, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); + PATCH_GFX(gGiSkulltulaTokenDL, "NPC_GoldenSkulltula6", npcGoldenSkulltula.changedCvar, 6, gsDPSetEnvColor(color.r / 2, color.g / 2, color.b / 2, 255)); + PATCH_GFX(gGiSkulltulaTokenFlameDL, "NPC_GoldenSkulltula7", npcGoldenSkulltula.changedCvar, 32, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); + PATCH_GFX(gGiSkulltulaTokenFlameDL, "NPC_GoldenSkulltula8", npcGoldenSkulltula.changedCvar, 33, gsDPSetEnvColor(color.r / 2, color.g / 2, color.b / 2, 255)); + PATCH_GFX(object_st_DL_003FB0, "NPC_GoldenSkulltula9", npcGoldenSkulltula.changedCvar, 118, gsDPSetPrimColor(0, 0, color.r, color.g, color.b, 255)); + PATCH_GFX(object_st_DL_003FB0, "NPC_GoldenSkulltula10", npcGoldenSkulltula.changedCvar, 119, gsDPSetEnvColor(color.r / 4, color.g / 4, color.b / 4, 255)); } static CosmeticOption& npcGerudo = cosmeticOptions.at("NPC_Gerudo"); @@ -1181,6 +1185,43 @@ void DrawScaleSlider(const std::string CvarName,float DefaultValue){ //Disabled for now. feature not done and several fixes needed to be merged. //UIWidgets::EnhancementSliderFloat("Scale : %dx", InvisibleLabel.c_str(), CvarLabel.c_str(), 0.1f, 3.0f,"",DefaultValue,true); } +void Draw_Table_Dropdown(const char* Header_Title, const char* Table_ID, const char* Column_Title, const char* Slider_Title, const char* Slider_ID, int MinY, int MaxY, int MinX, int MaxX, float Default_Value) { + if (ImGui::CollapsingHeader(Header_Title)) { + if (ImGui::BeginTable(Table_ID, 1, FlagsTable)) { + ImGui::TableSetupColumn(Column_Title, FlagsCell, TablesCellsWidth); + Table_InitHeader(false); + DrawUseMarginsSlider(Slider_Title, Slider_ID); + DrawPositionsRadioBoxes(Slider_ID); + DrawPositionSlider(Slider_ID, MinY, MaxY, MinX, MaxX); + DrawScaleSlider(Slider_ID, Default_Value); + ImGui::NewLine(); + ImGui::EndTable(); + } + } +} +void C_Button_Dropdown(const char* Header_Title, const char* Table_ID, const char* Column_Title, const char* Slider_Title, const char* Slider_ID, const char* Int_Type, float Slider_Scale_Value) { + if (ImGui::CollapsingHeader(Header_Title)) { + if (ImGui::BeginTable(Table_ID, 1, FlagsTable)) { + ImGui::TableSetupColumn(Column_Title, FlagsCell, TablesCellsWidth); + Table_InitHeader(false); + DrawUseMarginsSlider(Slider_Title, Slider_ID); + DrawPositionsRadioBoxes(Slider_ID); + s16 Min_X_CU = 0; + s16 Max_X_CU = ImGui::GetWindowViewport()->Size.x/2; + if(CVarGetInteger(Int_Type,0) == 2){ + Max_X_CU = 294; + } else if(CVarGetInteger(Int_Type,0) == 3){ + Max_X_CU = ImGui::GetWindowViewport()->Size.x/2; + } else if(CVarGetInteger(Int_Type,0) == 4){ + Min_X_CU = (ImGui::GetWindowViewport()->Size.x/2)*-1; + } + DrawPositionSlider(Slider_ID, 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_CU, Max_X_CU); + DrawScaleSlider(Slider_ID, Slider_Scale_Value); + ImGui::NewLine(); + ImGui::EndTable(); + } + } +} void Draw_Placements(){ if (ImGui::BeginTable("tableMargins", 1, FlagsTable)) { ImGui::TableSetupColumn("General margins settings", FlagsCell, TablesCellsWidth); @@ -1247,126 +1288,13 @@ void Draw_Placements(){ ImGui::EndTable(); } } - if (ImGui::CollapsingHeader("B Button position")) { - if (ImGui::BeginTable("tablebbtn", 1, FlagsTable)) { - ImGui::TableSetupColumn("B Button settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("B Button", "gBBtn"); - DrawPositionsRadioBoxes("gBBtn"); - DrawPositionSlider("gBBtn", 0, ImGui::GetWindowViewport()->Size.y/4+50, -1, ImGui::GetWindowViewport()->Size.x-50); - DrawScaleSlider("gBBtn",0.95f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("A Button position")) { - if (ImGui::BeginTable("tableabtn", 1, FlagsTable)) { - ImGui::TableSetupColumn("A Button settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("A Button", "gABtn"); - DrawPositionsRadioBoxes("gABtn"); - DrawPositionSlider("gABtn", -10, ImGui::GetWindowViewport()->Size.y/4+50, -20, ImGui::GetWindowViewport()->Size.x-50); - DrawScaleSlider("gABtn",0.95f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Start Button position")) { - if (ImGui::BeginTable("tablestartbtn", 1, FlagsTable)) { - ImGui::TableSetupColumn("Start Button settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Start Button", "gStartBtn"); - DrawPositionsRadioBoxes("gStartBtn"); - DrawPositionSlider("gStartBtn", 0, ImGui::GetWindowViewport()->Size.y/2, 0, ImGui::GetWindowViewport()->Size.x/2+70); - DrawScaleSlider("gStartBtn",0.75f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("C Button Up position")) { - if (ImGui::BeginTable("tablecubtn", 1, FlagsTable)) { - ImGui::TableSetupColumn("C Button Up settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("C Button Up", "gCBtnU"); - DrawPositionsRadioBoxes("gCBtnU"); - s16 Min_X_CU = 0; - s16 Max_X_CU = ImGui::GetWindowViewport()->Size.x/2; - if(CVarGetInteger("gCBtnUPosType",0) == 2){ - Max_X_CU = 294; - } else if(CVarGetInteger("gCBtnUPosType",0) == 3){ - Max_X_CU = ImGui::GetWindowViewport()->Size.x/2; - } else if(CVarGetInteger("gCBtnUPosType",0) == 4){ - Min_X_CU = (ImGui::GetWindowViewport()->Size.x/2)*-1; - } - DrawPositionSlider("gCBtnU", 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_CU, Max_X_CU); - DrawScaleSlider("gCBtnU",0.5f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("C Button Down position")) { - if (ImGui::BeginTable("tablecdbtn", 1, FlagsTable)) { - ImGui::TableSetupColumn("C Button Down settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("C Button Down", "gCBtnD"); - DrawPositionsRadioBoxes("gCBtnD"); - s16 Min_X_CD = 0; - s16 Max_X_CD = ImGui::GetWindowViewport()->Size.x/2; - if(CVarGetInteger("gCBtnDPosType",0) == 2){ - Max_X_CD = 294; - } else if(CVarGetInteger("gCBtnDPosType",0) == 3){ - Max_X_CD = ImGui::GetWindowViewport()->Size.x/2; - } else if(CVarGetInteger("gCBtnDPosType",0) == 4){ - Min_X_CD = (ImGui::GetWindowViewport()->Size.x/2)*-1; - } - DrawPositionSlider("gCBtnD", 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_CD, Max_X_CD); - DrawScaleSlider("gCBtnD",0.87f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("C Button Left position")) { - if (ImGui::BeginTable("tableclbtn", 1, FlagsTable)) { - ImGui::TableSetupColumn("C Button Left settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("C Button Left", "gCBtnL"); - DrawPositionsRadioBoxes("gCBtnL"); - s16 Min_X_CL = 0; - s16 Max_X_CL = ImGui::GetWindowViewport()->Size.x/2; - if(CVarGetInteger("gCBtnLPosType",0) == 2){ - Max_X_CL = 294; - } else if(CVarGetInteger("gCBtnLPosType",0) == 3){ - Max_X_CL = ImGui::GetWindowViewport()->Size.x/2; - } else if(CVarGetInteger("gCBtnLPosType",0) == 4){ - Min_X_CL = (ImGui::GetWindowViewport()->Size.x/2)*-1; - } - DrawPositionSlider("gCBtnL", 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_CL, Max_X_CL); - DrawScaleSlider("gCBtnL",0.87f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("C Button Right position")) { - if (ImGui::BeginTable("tablecrnbtn", 1, FlagsTable)) { - ImGui::TableSetupColumn("C Button Right settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("C Button Right", "gCBtnR"); - DrawPositionsRadioBoxes("gCBtnR"); - s16 Min_X_CR = 0; - s16 Max_X_CR = ImGui::GetWindowViewport()->Size.x/2; - if(CVarGetInteger("gCBtnRPosType",0) == 2){ - Max_X_CR = 294; - } else if(CVarGetInteger("gCBtnRPosType",0) == 3){ - Max_X_CR = ImGui::GetWindowViewport()->Size.x/2; - } else if(CVarGetInteger("gCBtnRPosType",0) == 4){ - Min_X_CR = (ImGui::GetWindowViewport()->Size.x/2)*-1; - } - DrawPositionSlider("gCBtnR", 0, ImGui::GetWindowViewport()->Size.y/2, Min_X_CR, Max_X_CR); - DrawScaleSlider("gCBtnR",0.87f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } + Draw_Table_Dropdown("B Button position", "tablebbtn", "B Button settings", "B Button", "gBBtn", 0, ImGui::GetWindowViewport()->Size.y/4+50, -1, ImGui::GetWindowViewport()->Size.x-50, 0.95f); + Draw_Table_Dropdown("A Button position", "tableabtn", "A Button settings", "A Button", "gABtn", -10, ImGui::GetWindowViewport()->Size.y/4+50, -20, ImGui::GetWindowViewport()->Size.x-50, 0.95f); + Draw_Table_Dropdown("Start Button position", "tablestartbtn", "Start Button settings", "Start Button", "gStartBtn", 0, ImGui::GetWindowViewport()->Size.y/2, 0, ImGui::GetWindowViewport()->Size.x/2+70, 0.75f); + C_Button_Dropdown("C Button Up position", "tablecubtn", "C Button Up settings", "C Button Up", "gCBtnU", "gCBtnUPosType", 0.5f); + C_Button_Dropdown("C Button Down position", "tablecdbtn", "C Button Down settings", "C Button Down", "gCBtnD", "gCBtnDPosType", 0.87f); + C_Button_Dropdown("C Button Left position", "tableclbtn", "C Button Left settings", "C Button Left", "gCBtnL", "gCBtnLPosType", 0.87f); + C_Button_Dropdown("C Button Right position", "tablecrbtn", "C Button Right settings", "C Button Right", "gCBtnR", "gCBtnRPosType", 0.87f); if (CVarGetInteger("gDpadEquips",0) && ImGui::CollapsingHeader("DPad items position")) { if (ImGui::BeginTable("tabledpaditems", 1, FlagsTable)) { ImGui::TableSetupColumn("DPad items settings", FlagsCell, TablesCellsWidth); @@ -1386,115 +1314,15 @@ void Draw_Placements(){ ImGui::EndTable(); } } - if (ImGui::CollapsingHeader("Minimaps position")) { - if (ImGui::BeginTable("tableminimapspos", 1, FlagsTable)) { - ImGui::TableSetupColumn("minimaps settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Minimap", "gMinimap"); - DrawPositionsRadioBoxes("gMinimap", false); - DrawPositionSlider("gMinimap", (ImGui::GetWindowViewport()->Size.y/3)*-1, ImGui::GetWindowViewport()->Size.y/3, ImGui::GetWindowViewport()->Size.x*-1, ImGui::GetWindowViewport()->Size.x/2); - DrawScaleSlider("gMinimap",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Small Keys counter position")) { - if (ImGui::BeginTable("tablesmolekeys", 1, FlagsTable)) { - ImGui::TableSetupColumn("Small Keys counter settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Small Keys counter", "gSKC"); - DrawPositionsRadioBoxes("gSKC"); - DrawPositionSlider("gSKC", 0, ImGui::GetWindowViewport()->Size.y/3, -1, ImGui::GetWindowViewport()->Size.x/2); - DrawScaleSlider("gSKC",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Rupee counter position")) { - if (ImGui::BeginTable("tablerupeecount", 1, FlagsTable)) { - ImGui::TableSetupColumn("Rupee counter settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Rupee counter", "gRC"); - DrawPositionsRadioBoxes("gRC"); - DrawPositionSlider("gRC", -2, ImGui::GetWindowViewport()->Size.y/3, -3, ImGui::GetWindowViewport()->Size.x/2); - DrawScaleSlider("gRC",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Carrots position")) { - if (ImGui::BeginTable("tableCarrots", 1, FlagsTable)) { - ImGui::TableSetupColumn("Carrots settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Carrots", "gCarrots"); - DrawPositionsRadioBoxes("gCarrots"); - DrawPositionSlider("gCarrots", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+25); - DrawScaleSlider("gCarrots",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Timers position")) { - if (ImGui::BeginTable("tabletimers", 1, FlagsTable)) { - ImGui::TableSetupColumn("Timers settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Timers", "gTimers"); - DrawPositionsRadioBoxes("gTimers"); - DrawPositionSlider("gTimers", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50); - DrawScaleSlider("gTimers",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Archery Scores position")) { - if (ImGui::BeginTable("tablearchery", 1, FlagsTable)) { - ImGui::TableSetupColumn("Archery Scores settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Archery scores", "gAS"); - DrawPositionsRadioBoxes("gAS", false); - DrawPositionSlider("gAS", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50); - DrawScaleSlider("gAS",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Title cards (Maps) position")) { - if (ImGui::BeginTable("tabletcmaps", 1, FlagsTable)) { - ImGui::TableSetupColumn("Titlecard maps settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Title cards (overworld)", "gTCM"); - DrawPositionsRadioBoxes("gTCM"); - DrawPositionSlider("gTCM", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10); - DrawScaleSlider("gTCM",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("Title cards (Bosses) position")) { - if (ImGui::BeginTable("tabletcbosses", 1, FlagsTable)) { - ImGui::TableSetupColumn("Title cards (Bosses) settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("Title cards (Bosses)", "gTCB"); - DrawPositionsRadioBoxes("gTCB"); - DrawPositionSlider("gTCB", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10); - DrawScaleSlider("gTCB",1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } - if (ImGui::CollapsingHeader("In-game Gameplay Timer position")) { - if (ImGui::BeginTable("tablegameplaytimer", 1, FlagsTable)) { - ImGui::TableSetupColumn("In-game Gameplay Timer settings", FlagsCell, TablesCellsWidth); - Table_InitHeader(false); - DrawUseMarginsSlider("In-game Gameplay Timer", "gIGT"); - DrawPositionsRadioBoxes("gIGT"); - DrawPositionSlider("gIGT", 0, ImGui::GetWindowViewport()->Size.y / 2, -50, - ImGui::GetWindowViewport()->Size.x / 2 + 10); - DrawScaleSlider("gIGT", 1.0f); - ImGui::NewLine(); - ImGui::EndTable(); - } - } + Draw_Table_Dropdown("Minimaps position", "tableminimapspos", "minimaps settings", "Minimap", "gMinimap", (ImGui::GetWindowViewport()->Size.y/3)*-1, ImGui::GetWindowViewport()->Size.y/3, ImGui::GetWindowViewport()->Size.x*-1, ImGui::GetWindowViewport()->Size.x/2, 1.0f); + Draw_Table_Dropdown("Small Keys counter position", "tablesmolekeys", "Small Keys counter settings", "Small Keys counter", "gSKC", 0, ImGui::GetWindowViewport()->Size.y/3, -1, ImGui::GetWindowViewport()->Size.x/2, 1.0f); + Draw_Table_Dropdown("Rupee counter position", "tablerupeecount", "Rupee counter settings", "Rupee counter", "gRC", -2, ImGui::GetWindowViewport()->Size.y/3, -3, ImGui::GetWindowViewport()->Size.x/2, 1.0f); + Draw_Table_Dropdown("Carrots position", "tableCarrots", "Carrots settings", "Carrots", "gCarrots", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+25, 1.0f); + Draw_Table_Dropdown("Timers position", "tabletimers", "Timers settings", "Timers", "gTimers", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50, 1.0f); + Draw_Table_Dropdown("Archery Scores position", "tablearchery", "Archery Scores settings", "Archery scores", "gAS", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2-50, 1.0f); + Draw_Table_Dropdown("Title cards (Maps) position", "tabletcmaps", "Titlecard maps settings", "Title cards (overworld)", "gTCM", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10, 1.0f); + Draw_Table_Dropdown("Title cards (Bosses) position", "tabletcbosses", "Title cards (Bosses) settings", "Title cards (Bosses)", "gTCB", 0, ImGui::GetWindowViewport()->Size.y/2, -50, ImGui::GetWindowViewport()->Size.x/2+10, 1.0f); + Draw_Table_Dropdown("In-game Gameplay Timer position", "tablegameplaytimer", "In-game Gameplay Timer settings", "In-game Gameplay Timer", "gIGT", 0, ImGui::GetWindowViewport()->Size.y / 2, -50, ImGui::GetWindowViewport()->Size.x / 2 + 10, 1.0f); if (ImGui::CollapsingHeader("Enemy Health Bar position")) { if (ImGui::BeginTable("enemyhealthbar", 1, FlagsTable)) { ImGui::TableSetupColumn("Enemy Health Bar settings", FlagsCell, TablesCellsWidth); @@ -1522,7 +1350,21 @@ void Draw_Placements(){ } } } - +void Reset_Option_Single(const char* Button_Title, const char* name) { + ImGui::SameLine(); + if (ImGui::Button(Button_Title)) { + CVarClear(name); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } +} +void Reset_Option_Double(const char* Button_Title, const char* name) { + ImGui::SameLine(); + if (ImGui::Button(Button_Title)) { + CVarClear((std::string(name) + ".Value").c_str()); + CVarClear((std::string(name) + ".Changed").c_str()); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } +} void DrawSillyTab() { ImGui::BeginDisabled(CVarGetInteger("gDisableChangingSettings", 0)); if (CVarGetInteger("gLetItSnow", 0)) { @@ -1548,67 +1390,28 @@ void DrawSillyTab() { if (UIWidgets::EnhancementSliderFloat("Link Head Scale: %.2fx", "##Link_HeadScale", "gCosmetics.Link_HeadScale.Value", 0.4f, 4.0f, "", 1.0f, false)) { CVarSetInteger("gCosmetics.Link_HeadScale.Changed", 1); } - ImGui::SameLine(); - if (ImGui::Button("Reset##Link_HeadScale")) { - CVarClear("gCosmetics.Link_HeadScale.Value"); - CVarClear("gCosmetics.Link_HeadScale.Changed"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } - if (UIWidgets::EnhancementSliderFloat("Link Sword Scale: %.3fx", "##Link_SwordScale", "gCosmetics.Link_SwordScale.Value", 1.0f, 2.5f, "", 1.0f, false)) { + Reset_Option_Double("Reset##Link_HeadScale", "gCosmetics.Link_HeadScale"); + if (UIWidgets::EnhancementSliderFloat("Link Sword Scale: %f", "##Link_SwordScale", "gCosmetics.Link_SwordScale.Value", 1.0f, 2.5f, "", 1.0f, false)) { CVarSetInteger("gCosmetics.Link_SwordScale.Changed", 1); } - ImGui::SameLine(); - if (ImGui::Button("Reset##Link_SwordScale")) { - CVarClear("gCosmetics.Link_SwordScale.Value"); - CVarClear("gCosmetics.Link_SwordScale.Changed"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } - UIWidgets::EnhancementSliderFloat("Bunny Hood Length: %.0f", "##BunnyHood_EarLength", "gCosmetics.BunnyHood_EarLength", -300.0f, 1000.0f, "", 0.0f, false); - ImGui::SameLine(); - if (ImGui::Button("Reset##BunnyHood_EarLength")) { - CVarClear("gCosmetics.BunnyHood_EarLength"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } - UIWidgets::EnhancementSliderFloat("Bunny Hood Spread: %.0f", "##BunnyHood_EarSpread", "gCosmetics.BunnyHood_EarSpread", -300.0f, 500.0f, "", 0.0f, false); - ImGui::SameLine(); - if (ImGui::Button("Reset##BunnyHood_EarSpread")) { - CVarClear("gCosmetics.BunnyHood_EarSpread"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } - UIWidgets::EnhancementSliderFloat("Goron Neck Length: %.0f", "##Goron_NeckLength", "gCosmetics.Goron_NeckLength", 0.0f, 5000.0f, "", 0.0f, false); - ImGui::SameLine(); - if (ImGui::Button("Reset##Goron_NeckLength")) { - CVarClear("gCosmetics.Goron_NeckLength"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } + Reset_Option_Double("Reset##Link_SwordScale", "gCosmetics.Link_SwordScale"); + UIWidgets::EnhancementSliderFloat("Bunny Hood Length: %f", "##BunnyHood_EarLength", "gCosmetics.BunnyHood_EarLength", -300.0f, 1000.0f, "", 0.0f, false); + Reset_Option_Single("Reset##BunnyHood_EarLength", "gCosmetics.BunnyHood_EarLength"); + UIWidgets::EnhancementSliderFloat("Bunny Hood Spread: %f", "##BunnyHood_EarSpread", "gCosmetics.BunnyHood_EarSpread", -300.0f, 500.0f, "", 0.0f, false); + Reset_Option_Single("Reset##BunnyHood_EarSpread", "gCosmetics.BunnyHood_EarSpread"); + UIWidgets::EnhancementSliderFloat("Goron Neck Length: %f", "##Goron_NeckLength", "gCosmetics.Goron_NeckLength", 0.0f, 1000.0f, "", 0.0f, false); + Reset_Option_Single("Reset##Goron_NeckLength", "gCosmetics.Goron_NeckLength"); UIWidgets::EnhancementCheckbox("Unfix Goron Spin", "gUnfixGoronSpin"); - UIWidgets::EnhancementSliderFloat("Fairies Size: %.2fx", "##Fairies_Size", "gCosmetics.Fairies_Size", 0.25f, 5.0f, "", 1.0f, false); - ImGui::SameLine(); - if (ImGui::Button("Reset##Fairies_Size")) { - CVarClear("gCosmetics.Fairies_Size"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } - UIWidgets::EnhancementSliderFloat("N64 Logo Spin Speed: %.2fx", "##N64Logo_SpinSpeed", "gCosmetics.N64Logo_SpinSpeed", 0.25f, 5.0f, "", 1.0f, false); - ImGui::SameLine(); - if (ImGui::Button("Reset##N64Logo_SpinSpeed")) { - CVarClear("gCosmetics.N64Logo_SpinSpeed"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } - UIWidgets::EnhancementSliderFloat("Moon Size: %.1f %%", "##Moon_Size", "gCosmetics.Moon_Size", 0.5f, 2.0f, "", 1.0f, true); - ImGui::SameLine(); - if (ImGui::Button("Reset##Moon_Size")) { - CVarClear("gCosmetics.Moon_Size"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } - if (UIWidgets::EnhancementSliderFloat("Kak Windmill Speed: %.0f", "##Kak_Windmill_Speed", "gCosmetics.Kak_Windmill_Speed.Value", 100.0f, 6000.0f, "", 100.0f, false)) { + UIWidgets::EnhancementSliderFloat("Fairies Size: %f", "##Fairies_Size", "gCosmetics.Fairies_Size", 0.25f, 5.0f, "", 1.0f, false); + Reset_Option_Single("Reset##Fairies_Size", "gCosmetics.Fairies_Size"); + UIWidgets::EnhancementSliderFloat("N64 Logo Spin Speed: %f", "##N64Logo_SpinSpeed", "gCosmetics.N64Logo_SpinSpeed", 0.25f, 5.0f, "", 1.0f, false); + Reset_Option_Single("Reset##N64Logo_SpinSpeed", "gCosmetics.N64Logo_SpinSpeed"); + UIWidgets::EnhancementSliderFloat("Moon Size: %f", "##Moon_Size", "gCosmetics.Moon_Size", 0.5f, 2.0f, "", 1.0f, false); + Reset_Option_Single("Reset##Moon_Size", "gCosmetics.Moon_Size"); + if (UIWidgets::EnhancementSliderFloat("Kak Windmill Speed: %f", "##Kak_Windmill_Speed", "gCosmetics.Kak_Windmill_Speed.Value", 100.0f, 6000.0f, "", 100.0f, false)) { CVarSetInteger("gCosmetics.Kak_Windmill_Speed.Changed", 1); } - ImGui::SameLine(); - if (ImGui::Button("Reset##Kak_Windmill_Speed")) { - CVarClear("gCosmetics.Kak_Windmill_Speed.Value"); - CVarClear("gCosmetics.Kak_Windmill_Speed.Changed"); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - } + Reset_Option_Double("Reset##Kak_Windmill_Speed", "gCosmetics.Kak_Windmill_Speed"); ImGui::EndDisabled(); } @@ -1631,25 +1434,20 @@ void CopyMultipliedColor(CosmeticOption& cosmeticOptionSrc, CosmeticOption& cosm CVarSetInteger((cosmeticOptionTarget.changedCvar), 1); } -void RandomizeColor(CosmeticOption& cosmeticOption) { - Color_RGBA8 newColor; - newColor.r = Random(0, 255); - newColor.g = Random(0, 255); - newColor.b = Random(0, 255); - newColor.a = 255; - // For alpha supported options, retain the last set alpha instead of overwriting - if (cosmeticOption.supportsAlpha) { - newColor.a = cosmeticOption.currentColor.w * 255; +void ToggleRainbow(CosmeticOption& cosmeticOption, bool state) { + if (state) { + CVarSetInteger(cosmeticOption.rainbowCvar, 1); + CVarSetInteger(cosmeticOption.changedCvar, 1); + } else { + CVarClear(cosmeticOption.rainbowCvar); + CVarClear(cosmeticOption.changedCvar); } +} - cosmeticOption.currentColor.x = newColor.r / 255.0; - cosmeticOption.currentColor.y = newColor.g / 255.0; - cosmeticOption.currentColor.z = newColor.b / 255.0; - cosmeticOption.currentColor.w = newColor.a / 255.0; - - CVarSetColor(cosmeticOption.cvar, newColor); - CVarSetInteger((cosmeticOption.rainbowCvar), 0); - CVarSetInteger((cosmeticOption.changedCvar), 1); +void ApplySideEffects(CosmeticOption& cosmeticOption) { + if (CVarGetInteger("gCosmetics.AdvancedMode", 0)) { + return; + } // This bit is kind of experimental, not sure how I feel about it yet, but it allows for // advanced cosmetic options to be changed based on a non-advanced option. @@ -1671,9 +1469,91 @@ void RandomizeColor(CosmeticOption& cosmeticOption) { CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("SpinAttack_Level1Primary"), 2.0f); } else if (cosmeticOption.label == "Level 2 Secondary") { CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("SpinAttack_Level2Primary"), 2.0f); + } else if (cosmeticOption.label == "Item Select Color") { + if (CVarGetInteger(cosmeticOption.rainbowCvar, 0)) { + ToggleRainbow(cosmeticOptions.at("Kal_ItemSelB"), true); + ToggleRainbow(cosmeticOptions.at("Kal_ItemSelC"), true); + ToggleRainbow(cosmeticOptions.at("Kal_ItemSelD"), true); + } else { + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_ItemSelB"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_ItemSelC"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_ItemSelD"), 1.0f); + } + } else if (cosmeticOption.label == "Equip Select Color") { + if (CVarGetInteger(cosmeticOption.rainbowCvar, 0)) { + ToggleRainbow(cosmeticOptions.at("Kal_EquipSelB"), true); + ToggleRainbow(cosmeticOptions.at("Kal_EquipSelC"), true); + ToggleRainbow(cosmeticOptions.at("Kal_EquipSelD"), true); + } else { + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_EquipSelB"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_EquipSelC"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_EquipSelD"), 1.0f); + } + } else if (cosmeticOption.label == "Map Dungeon Color") { + if (CVarGetInteger(cosmeticOption.rainbowCvar, 0)) { + ToggleRainbow(cosmeticOptions.at("Kal_MapSelDunB"), true); + ToggleRainbow(cosmeticOptions.at("Kal_MapSelDunC"), true); + ToggleRainbow(cosmeticOptions.at("Kal_MapSelDunD"), true); + } else { + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_MapSelDunB"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_MapSelDunC"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_MapSelDunD"), 1.0f); + } + } else if (cosmeticOption.label == "Quest Status Color") { + if (CVarGetInteger(cosmeticOption.rainbowCvar, 0)) { + ToggleRainbow(cosmeticOptions.at("Kal_QuestStatusB"), true); + ToggleRainbow(cosmeticOptions.at("Kal_QuestStatusC"), true); + ToggleRainbow(cosmeticOptions.at("Kal_QuestStatusD"), true); + } else { + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_QuestStatusB"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_QuestStatusC"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_QuestStatusD"), 1.0f); + } + } else if (cosmeticOption.label == "Map Color") { + if (CVarGetInteger(cosmeticOption.rainbowCvar, 0)) { + ToggleRainbow(cosmeticOptions.at("Kal_MapSelectB"), true); + ToggleRainbow(cosmeticOptions.at("Kal_MapSelectC"), true); + ToggleRainbow(cosmeticOptions.at("Kal_MapSelectD"), true); + } else { + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_MapSelectB"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_MapSelectC"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_MapSelectD"), 1.0f); + } + } else if (cosmeticOption.label == "Save Color") { + if (CVarGetInteger(cosmeticOption.rainbowCvar, 0)) { + ToggleRainbow(cosmeticOptions.at("Kal_SaveB"), true); + ToggleRainbow(cosmeticOptions.at("Kal_SaveC"), true); + ToggleRainbow(cosmeticOptions.at("Kal_SaveD"), true); + } else { + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_SaveB"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_SaveC"), 2.0f); + CopyMultipliedColor(cosmeticOption, cosmeticOptions.at("Kal_SaveD"), 1.0f); + } } } +void RandomizeColor(CosmeticOption& cosmeticOption) { + Color_RGBA8 newColor; + newColor.r = Random(0, 255); + newColor.g = Random(0, 255); + newColor.b = Random(0, 255); + newColor.a = 255; + // For alpha supported options, retain the last set alpha instead of overwriting + if (cosmeticOption.supportsAlpha) { + newColor.a = cosmeticOption.currentColor.w * 255; + } + + cosmeticOption.currentColor.x = newColor.r / 255.0; + cosmeticOption.currentColor.y = newColor.g / 255.0; + cosmeticOption.currentColor.z = newColor.b / 255.0; + cosmeticOption.currentColor.w = newColor.a / 255.0; + + CVarSetColor(cosmeticOption.cvar, newColor); + CVarSetInteger((cosmeticOption.rainbowCvar), 0); + CVarSetInteger((cosmeticOption.changedCvar), 1); + ApplySideEffects(cosmeticOption); +} + void ResetColor(CosmeticOption& cosmeticOption) { Color_RGBA8 defaultColor = {cosmeticOption.defaultColor.x, cosmeticOption.defaultColor.y, cosmeticOption.defaultColor.z, cosmeticOption.defaultColor.w}; cosmeticOption.currentColor.x = defaultColor.r / 255.0; @@ -1691,7 +1571,7 @@ void ResetColor(CosmeticOption& cosmeticOption) { CVarClear((std::string(cosmeticOption.cvar) + ".A").c_str()); CVarClear((std::string(cosmeticOption.cvar) + ".Type").c_str()); - // This portion should match 1:1 the multiplied colors in `RandomizeColor()` + // This portion should match 1:1 the multiplied colors in `ApplySideEffect()` if (cosmeticOption.label == "Bow Body") { ResetColor(cosmeticOptions.at("Equipment_BowTips")); ResetColor(cosmeticOptions.at("Equipment_BowHandle")); @@ -1707,6 +1587,30 @@ void ResetColor(CosmeticOption& cosmeticOption) { ResetColor(cosmeticOptions.at("SpinAttack_Level1Primary")); } else if (cosmeticOption.label == "Level 2 Secondary") { ResetColor(cosmeticOptions.at("SpinAttack_Level2Primary")); + } else if (cosmeticOption.label == "Item Select Color") { + ResetColor(cosmeticOptions.at("Kal_ItemSelB")); + ResetColor(cosmeticOptions.at("Kal_ItemSelC")); + ResetColor(cosmeticOptions.at("Kal_ItemSelD")); + } else if (cosmeticOption.label == "Equip Select Color") { + ResetColor(cosmeticOptions.at("Kal_EquipSelB")); + ResetColor(cosmeticOptions.at("Kal_EquipSelC")); + ResetColor(cosmeticOptions.at("Kal_EquipSelD")); + } else if (cosmeticOption.label == "Map Dungeon Color") { + ResetColor(cosmeticOptions.at("Kal_MapSelDunB")); + ResetColor(cosmeticOptions.at("Kal_MapSelDunC")); + ResetColor(cosmeticOptions.at("Kal_MapSelDunD")); + } else if (cosmeticOption.label == "Quest Status Color") { + ResetColor(cosmeticOptions.at("Kal_QuestStatusB")); + ResetColor(cosmeticOptions.at("Kal_QuestStatusC")); + ResetColor(cosmeticOptions.at("Kal_QuestStatusD")); + } else if (cosmeticOption.label == "Map Color") { + ResetColor(cosmeticOptions.at("Kal_MapSelectB")); + ResetColor(cosmeticOptions.at("Kal_MapSelectC")); + ResetColor(cosmeticOptions.at("Kal_MapSelectD")); + } else if (cosmeticOption.label == "Save Color") { + ResetColor(cosmeticOptions.at("Kal_SaveB")); + ResetColor(cosmeticOptions.at("Kal_SaveC")); + ResetColor(cosmeticOptions.at("Kal_SaveD")); } } @@ -1727,6 +1631,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { CVarSetColor(cosmeticOption.cvar, color); CVarSetInteger((cosmeticOption.rainbowCvar), 0); CVarSetInteger((cosmeticOption.changedCvar), 1); + ApplySideEffects(cosmeticOption); ApplyOrResetCustomGfxPatches(); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } @@ -1744,6 +1649,7 @@ void DrawCosmeticRow(CosmeticOption& cosmeticOption) { if (ImGui::Checkbox(("Rainbow##" + cosmeticOption.label).c_str(), &isRainbow)) { CVarSetInteger((cosmeticOption.rainbowCvar), isRainbow); CVarSetInteger((cosmeticOption.changedCvar), 1); + ApplySideEffects(cosmeticOption); ApplyOrResetCustomGfxPatches(); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } @@ -1800,7 +1706,7 @@ static const char* colorSchemes[2] = { }; void CosmeticsEditorWindow::DrawElement() { - ImGui::SetNextWindowSize(ImVec2(480, 520), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowSize(ImVec2(550, 520), ImGuiCond_FirstUseEver); if (!ImGui::Begin("Cosmetics Editor", &mIsVisible)) { ImGui::End(); return; diff --git a/soh/soh/Enhancements/custom-message/CustomMessageTypes.h b/soh/soh/Enhancements/custom-message/CustomMessageTypes.h index 096517835..6abbc68fe 100644 --- a/soh/soh/Enhancements/custom-message/CustomMessageTypes.h +++ b/soh/soh/Enhancements/custom-message/CustomMessageTypes.h @@ -55,6 +55,22 @@ typedef enum { TEXT_SHOOTING_GALLERY_MAN_COME_BACK_WITH_BOW = 0x9210, TEXT_LAKE_HYLIA_WATER_SWITCH_SIGN = 0x346, // 0x3yy for cuttable sign range TEXT_LAKE_HYLIA_WATER_SWITCH_NAVI = 0x1B3, // 0x1yy for Navi msg range + TEXT_SARIAS_SONG_CHANNELING_POWER = 0x016D, + TEXT_BEAN_SALESMAN_BUY_FOR_10 = 0x405E, + TEXT_BEAN_SALESMAN_BUY_FOR_20 = 0x405F, + TEXT_BEAN_SALESMAN_BUY_FOR_30 = 0x4060, + TEXT_BEAN_SALESMAN_BUY_FOR_40 = 0x4061, + TEXT_BEAN_SALESMAN_BUY_FOR_50 = 0x4062, + TEXT_BEAN_SALESMAN_BUY_FOR_60 = 0x4063, + TEXT_BEAN_SALESMAN_BUY_FOR_70 = 0x4064, + TEXT_BEAN_SALESMAN_BUY_FOR_80 = 0x4065, + TEXT_BEAN_SALESMAN_BUY_FOR_90 = 0x4066, + TEXT_BEAN_SALESMAN_BUY_FOR_100 = 0x4067, + TEXT_BEAN_SALESMAN_OH_WELL = 0x4068, + TEXT_BEAN_SALESMAN_NOT_ENOUGH_MONEY = 0x4069, + TEXT_BEAN_SALESMAN_SET_A_BEAN_TO_C = 0x406A, + TEXT_BEAN_SALESMAN_SOLD_OUT = 0x406B, + TEXT_BEAN_SALESMAN_WANT_TO_PLANT = 0x406C, TEXT_BEGGAR_VANILLA = 0x70ED, //Please...with [C]... Please sell me something... Please...with [C]... TEXT_BANKER_GREETING = 0x9303, TEXT_BANKER_OPTIONS = 0x9304, diff --git a/soh/soh/Enhancements/debugger/MessageViewer.cpp b/soh/soh/Enhancements/debugger/MessageViewer.cpp new file mode 100644 index 000000000..51fe3c0b9 --- /dev/null +++ b/soh/soh/Enhancements/debugger/MessageViewer.cpp @@ -0,0 +1,271 @@ +#include "MessageViewer.h" + +#include +#include + +#include "../custom-message/CustomMessageManager.h" +#include "functions.h" +#include "macros.h" +#include "message_data_static.h" +#include "variables.h" +#include "soh/util.h" + +extern "C" u8 sMessageHasSetSfx; + +void MessageViewer::InitElement() { + CustomMessageManager::Instance->AddCustomMessageTable(TABLE_ID); + mTableIdBuf = static_cast(calloc(MAX_STRING_SIZE, sizeof(char))); + mTextIdBuf = static_cast(calloc(MAX_STRING_SIZE, sizeof(char))); + mCustomMessageBuf = static_cast(calloc(MAX_STRING_SIZE, sizeof(char))); +} + +void MessageViewer::DrawElement() { + ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); + if (!ImGui::Begin("Custom Message Debugger", &mIsVisible, ImGuiWindowFlags_NoFocusOnAppearing)) { + ImGui::End(); + return; + } + ImGui::Text("Table ID"); + ImGui::SameLine(); + ImGui::InputText("##TableID", mTableIdBuf, MAX_STRING_SIZE, ImGuiInputTextFlags_CallbackCharFilter, UIWidgets::TextFilters::FilterAlphaNum); + UIWidgets::InsertHelpHoverText("Leave blank for vanilla table"); + ImGui::Text("Text ID"); + ImGui::SameLine(); + switch (mTextIdBase) { + case DECIMAL: + ImGui::InputText("##TextID", mTextIdBuf, MAX_STRING_SIZE, ImGuiInputTextFlags_CharsDecimal); + UIWidgets::InsertHelpHoverText("Decimal Text ID of the message to load. Decimal digits only (0-9)."); + break; + case HEXADECIMAL: + default: + ImGui::InputText("##TextID", mTextIdBuf, MAX_STRING_SIZE, ImGuiInputTextFlags_CharsHexadecimal); + UIWidgets::InsertHelpHoverText("Hexadecimal Text ID of the message to load. Hexadecimal digits only (0-9/A-F)."); + break; + } + if (ImGui::RadioButton("Hexadecimal", &mTextIdBase, HEXADECIMAL)) { + memset(mTextIdBuf, 0, sizeof(char) * MAX_STRING_SIZE); + } + ImGui::SameLine(); + if (ImGui::RadioButton("Decimal", &mTextIdBase, DECIMAL)) { + memset(mTextIdBuf, 0, sizeof(char) * MAX_STRING_SIZE); + } + ImGui::Text("Language"); + ImGui::SameLine(); + if (ImGui::BeginCombo("##Language", mLanguages[mLanguage])) { + // ReSharper disable CppDFAUnreachableCode + for (size_t i = 0; i < mLanguages.size(); i++) { + if (strlen(mLanguages[i]) > 0) { + if (ImGui::Selectable(mLanguages[i], i == mLanguage)) { + mLanguage = i; + } + } + } + ImGui::EndCombo(); + } + UIWidgets::InsertHelpHoverText("Which language to load from the selected text ID"); + if (ImGui::Button("Display Message##ExistingMessage")) { + mDisplayExistingMessageClicked = true; + } + ImGui::Text("Custom Message"); + UIWidgets::InsertHelpHoverText("Enter a string using Custom Message Syntax to preview it in-game. " + "Any newline (\\n) characters inserted by the Enter key will be stripped " + "from the output."); + ImGui::InputTextMultiline("##CustomMessage", mCustomMessageBuf, MAX_STRING_SIZE); + if (ImGui::Button("Display Message##CustomMessage")) { + mDisplayCustomMessageClicked = true; + } + ImGui::End(); + // ReSharper restore CppDFAUnreachableCode +} + +void MessageViewer::UpdateElement() { + if (mDisplayExistingMessageClicked) { + mTableId = std::string(mTableIdBuf); + switch (mTextIdBase) { + case DECIMAL: + mTextId = std::stoi(std::string(mTextIdBuf), nullptr, 10); + break; + case HEXADECIMAL: + default: + mTextId = std::stoi(std::string(mTextIdBuf), nullptr, 16); + break; + } + DisplayExistingMessage(); + mDisplayExistingMessageClicked = false; + } + if (mDisplayCustomMessageClicked) { + mCustomMessageString = std::string(mCustomMessageBuf); + std::erase(mCustomMessageString, '\n'); + DisplayCustomMessage(); + mDisplayCustomMessageClicked = false; + } +} + +void MessageViewer::DisplayExistingMessage() const { + MessageDebug_StartTextBox(mTableId.c_str(), mTextId, mLanguage); +} + +void MessageViewer::DisplayCustomMessage() const { + MessageDebug_DisplayCustomMessage(mCustomMessageString.c_str()); +} + +extern "C" MessageTableEntry* sNesMessageEntryTablePtr; +extern "C" MessageTableEntry* sGerMessageEntryTablePtr; +extern "C" MessageTableEntry* sFraMessageEntryTablePtr; +extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; + +void FindMessage(PlayState* play, const uint16_t textId, const uint8_t language) { + const char* foundSeg; + const char* nextSeg; + MessageTableEntry* messageTableEntry = sNesMessageEntryTablePtr; + Font* font; + u16 bufferId = textId; + // Use the better owl message if better owl is enabled + if (CVarGetInteger("gBetterOwl", 0) != 0 && (bufferId == 0x2066 || bufferId == 0x607B || + bufferId == 0x10C2 || bufferId == 0x10C6 || bufferId == 0x206A)) + { + bufferId = 0x71B3; + } + + if (language == LANGUAGE_GER) + messageTableEntry = sGerMessageEntryTablePtr; + else if (language == LANGUAGE_FRA) + messageTableEntry = sFraMessageEntryTablePtr; + + // If PAL languages are not present in the OTR file, default to English + if (messageTableEntry == nullptr) + messageTableEntry = sNesMessageEntryTablePtr; + + const char* seg = messageTableEntry->segment; + + while (messageTableEntry->textId != 0xFFFF) { + font = &play->msgCtx.font; + + if (messageTableEntry->textId == bufferId) { + foundSeg = messageTableEntry->segment; + font->charTexBuf[0] = messageTableEntry->typePos; + + nextSeg = messageTableEntry->segment; + font->msgOffset = reinterpret_cast(messageTableEntry->segment); + font->msgLength = messageTableEntry->msgSize; + return; + } + messageTableEntry++; + } + + font = &play->msgCtx.font; + messageTableEntry = sNesMessageEntryTablePtr; + + foundSeg = messageTableEntry->segment; + font->charTexBuf[0] = messageTableEntry->typePos; + messageTableEntry++; + nextSeg = messageTableEntry->segment; + font->msgOffset = foundSeg - seg; + font->msgLength = nextSeg - foundSeg; +} + +static const char* msgStaticTbl[] = +{ + gDefaultMessageBackgroundTex, + gSignMessageBackgroundTex, + gNoteStaffMessageBackgroundTex, + gFadingMessageBackgroundTex, + gMessageContinueTriangleTex, + gMessageEndSquareTex, + gMessageArrowTex +}; + +void MessageDebug_StartTextBox(const char* tableId, uint16_t textId, uint8_t language) { + PlayState* play = gPlayState; + static int16_t messageStaticIndices[] = { 0, 1, 3, 2 }; + const auto player = GET_PLAYER(gPlayState); + player->actor.flags |= ACTOR_FLAG_PLAYER_TALKED_TO; + MessageContext* msgCtx = &play->msgCtx; + msgCtx->ocarinaAction = 0xFFFF; + Font* font = &msgCtx->font; + sMessageHasSetSfx = 0; + for (u32 i = 0; i < FONT_CHAR_TEX_SIZE * 120; i += FONT_CHAR_TEX_SIZE) { + if (&font->charTexBuf[i] != nullptr) { + gSPInvalidateTexCache(play->state.gfxCtx->polyOpa.p++, reinterpret_cast(&font->charTexBuf[i])); + } + } + R_TEXT_CHAR_SCALE = 75; + R_TEXT_LINE_SPACING = 12; + R_TEXT_INIT_XPOS = 65; + char* buffer = font->msgBuf; + msgCtx->textId = textId; + if (strlen(tableId) == 0) { + FindMessage(play, textId, language); + msgCtx->msgLength = static_cast(font->msgLength); + const uintptr_t src = font->msgOffset; + memcpy(font->msgBuf, reinterpret_cast(src), font->msgLength); + } else { + constexpr int maxBufferSize = sizeof(font->msgBuf); + const CustomMessage messageEntry = CustomMessageManager::Instance->RetrieveMessage(tableId, textId); + font->charTexBuf[0] = (messageEntry.GetTextBoxType() << 4) | messageEntry.GetTextBoxPosition(); + switch (language) { + case LANGUAGE_FRA: + font->msgLength = SohUtils::CopyStringToCharBuffer(buffer, messageEntry.GetFrench(), maxBufferSize); + break; + case LANGUAGE_GER: + font->msgLength = SohUtils::CopyStringToCharBuffer(buffer, messageEntry.GetGerman(), maxBufferSize); + break; + case LANGUAGE_ENG: + default: + font->msgLength = SohUtils::CopyStringToCharBuffer(buffer, messageEntry.GetEnglish(), maxBufferSize); + break; + } + msgCtx->msgLength = static_cast(font->msgLength); + } + msgCtx->textBoxProperties = font->charTexBuf[0]; + msgCtx->textBoxType = msgCtx->textBoxProperties >> 4; + msgCtx->textBoxPos = msgCtx->textBoxProperties & 0xF; + const int16_t textBoxType = msgCtx->textBoxType; + // "Text Box Type" + osSyncPrintf("吹き出し種類=%d\n", msgCtx->textBoxType); + if (textBoxType < TEXTBOX_TYPE_NONE_BOTTOM) { + const char* textureName = msgStaticTbl[messageStaticIndices[textBoxType]]; + memcpy(msgCtx->textboxSegment, textureName, strlen(textureName) + 1); + if (textBoxType == TEXTBOX_TYPE_BLACK) { + msgCtx->textboxColorRed = 0; + msgCtx->textboxColorGreen = 0; + msgCtx->textboxColorBlue = 0; + } else if (textBoxType == TEXTBOX_TYPE_WOODEN) { + msgCtx->textboxColorRed = 70; + msgCtx->textboxColorGreen = 50; + msgCtx->textboxColorBlue = 30; + } else if (textBoxType == TEXTBOX_TYPE_BLUE) { + msgCtx->textboxColorRed = 0; + msgCtx->textboxColorGreen = 10; + msgCtx->textboxColorBlue = 50; + } else { + msgCtx->textboxColorRed = 255; + msgCtx->textboxColorGreen = 0; + msgCtx->textboxColorBlue = 0; + } + if (textBoxType == TEXTBOX_TYPE_WOODEN) { + msgCtx->textboxColorAlphaTarget = 230; + } else if (textBoxType == TEXTBOX_TYPE_OCARINA) { + msgCtx->textboxColorAlphaTarget = 180; + } else { + msgCtx->textboxColorAlphaTarget = 170; + } + msgCtx->textboxColorAlphaCurrent = 0; + } + msgCtx->choiceNum = msgCtx->textUnskippable = msgCtx->textboxEndType = 0; + msgCtx->msgBufPos = msgCtx->unk_E3D0 = msgCtx->textDrawPos = 0; + msgCtx->talkActor = &player->actor; + msgCtx->msgMode = MSGMODE_TEXT_START; + msgCtx->stateTimer = 0; + msgCtx->textDelayTimer = 0; + msgCtx->ocarinaMode = OCARINA_MODE_00; +} + +void MessageDebug_DisplayCustomMessage(const char* customMessage) { + CustomMessageManager::Instance->ClearMessageTable(MessageViewer::TABLE_ID); + CustomMessageManager::Instance->CreateMessage(MessageViewer::TABLE_ID, 0, + CustomMessage(customMessage, customMessage, customMessage)); + MessageDebug_StartTextBox(MessageViewer::TABLE_ID, 0, 0); +} + + diff --git a/soh/soh/Enhancements/debugger/MessageViewer.h b/soh/soh/Enhancements/debugger/MessageViewer.h new file mode 100644 index 000000000..702693793 --- /dev/null +++ b/soh/soh/Enhancements/debugger/MessageViewer.h @@ -0,0 +1,62 @@ +#ifndef CUSTOMMESSAGEDEBUGGER_H +#define CUSTOMMESSAGEDEBUGGER_H +#include "z64.h" + +#ifdef __cplusplus +#include "GuiWindow.h" +#include +extern "C" { +#endif +/** + * \brief Pulls a message from the specified message table and kicks off the process of displaying that message + * in a text box on screen. + * \param tableId the tableId string for the table we want to pull from. Empty string for authentic/vanilla messages + * \param textId The textId corresponding to the message to display. Putting in a textId that doesn't exist will + * probably result in a crash. + * \param language The Language to display on the screen. + */ +void MessageDebug_StartTextBox(const char* tableId, uint16_t textId, uint8_t language); + +/** + * \brief + * \param customMessage A string using Custom Message Syntax. + */ +void MessageDebug_DisplayCustomMessage(const char* customMessage); +#ifdef __cplusplus +} + + +class MessageViewer : public LUS::GuiWindow { +public: + static inline const char* TABLE_ID = "MessageViewer"; + using GuiWindow::GuiWindow; + + void InitElement() override; + void DrawElement() override; + void UpdateElement() override; + + virtual ~MessageViewer() = default; + +private: + void DisplayExistingMessage() const; + void DisplayCustomMessage() const; + + static constexpr uint16_t MAX_STRING_SIZE = 1024; + static constexpr std::array mLanguages = {"English", "German", "French"}; + static constexpr int HEXADECIMAL = 0; + static constexpr int DECIMAL = 1; + char* mTableIdBuf; + std::string mTableId; + char* mTextIdBuf; + uint16_t mTextId; + int mTextIdBase = HEXADECIMAL; + size_t mLanguage = LANGUAGE_ENG; + char* mCustomMessageBuf; + std::string mCustomMessageString; + bool mDisplayExistingMessageClicked = false; + bool mDisplayCustomMessageClicked = false; +}; + + +#endif //__cplusplus +#endif //CUSTOMMESSAGEDEBUGGER_H diff --git a/soh/soh/Enhancements/enhancementTypes.h b/soh/soh/Enhancements/enhancementTypes.h index c8461bbf1..56160567a 100644 --- a/soh/soh/Enhancements/enhancementTypes.h +++ b/soh/soh/Enhancements/enhancementTypes.h @@ -78,4 +78,10 @@ typedef enum { DEKU_STICK_UNBREAKABLE_AND_ALWAYS_ON_FIRE, } DekuStickType; +typedef enum { + SWORD_TOGGLE_NONE, + SWORD_TOGGLE_CHILD, + SWORD_TOGGLE_BOTH_AGES, +} SwordToggleMode; + #endif diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor.cpp index d6641133c..dbb4782fd 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.cpp @@ -37,12 +37,19 @@ GameInteractionEffectQueryResult GameInteractor::RemoveEffect(RemovableGameInter // MARK: - Helpers -bool GameInteractor::IsSaveLoaded() { +bool GameInteractor::IsSaveLoaded(bool allowDbgSave) { Player* player; if (gPlayState != NULL) { player = GET_PLAYER(gPlayState); } - return (gPlayState == NULL || player == NULL || gSaveContext.fileNum < 0 || gSaveContext.fileNum > 2) ? false : true; + + // Checking for normal game mode prevents debug saves from reporting true on title screen + if (gPlayState == NULL || player == NULL || gSaveContext.gameMode != GAMEMODE_NORMAL) { + return false; + } + + // Valid save file or debug save + return (gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2) || (allowDbgSave && gSaveContext.fileNum == 0xFF); } bool GameInteractor::IsGameplayPaused() { diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor.h b/soh/soh/Enhancements/game-interactor/GameInteractor.h index be27e74a2..7503dbd78 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor.h @@ -163,11 +163,30 @@ public: static GameInteractionEffectQueryResult RemoveEffect(RemovableGameInteractionEffect* effect); // Game Hooks - template struct RegisteredGameHooks { inline static std::vector functions; }; - template void RegisterGameHook(typename H::fn h) { RegisteredGameHooks::functions.push_back(h); } + uint32_t nextHookId = 1; + template struct RegisteredGameHooks { inline static std::unordered_map functions; }; + template struct HooksToUnregister { inline static std::vector hooks; }; + template uint32_t RegisterGameHook(typename H::fn h) { + // Ensure hook id is unique and not 0, which is reserved for invalid hooks + if (this->nextHookId == 0 || this->nextHookId >= UINT32_MAX) this->nextHookId = 1; + while (RegisteredGameHooks::functions.find(this->nextHookId) != RegisteredGameHooks::functions.end()) { + this->nextHookId++; + } + + RegisteredGameHooks::functions[this->nextHookId] = h; + return this->nextHookId++; + } + template void UnregisterGameHook(uint32_t id) { + HooksToUnregister::hooks.push_back(id); + } + template void ExecuteHooks(Args&&... args) { - for (auto& fn : RegisteredGameHooks::functions) { - fn(std::forward(args)...); + for (auto& hookId : HooksToUnregister::hooks) { + RegisteredGameHooks::functions.erase(hookId); + } + HooksToUnregister::hooks.clear(); + for (auto& hook : RegisteredGameHooks::functions) { + hook.second(std::forward(args)...); } } @@ -221,9 +240,10 @@ public: DEFINE_HOOK(OnFileDropped, void(std::string filePath)); DEFINE_HOOK(OnAssetAltChange, void()); + DEFINE_HOOK(OnKaleidoUpdate, void()); // Helpers - static bool IsSaveLoaded(); + static bool IsSaveLoaded(bool allowDbgSave = false); static bool IsGameplayPaused(); static bool CanSpawnActor(); static bool CanAddOrTakeAmmo(int16_t amount, int16_t item); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 4bd5354a6..911c47a71 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -187,3 +187,9 @@ void GameInteractor_ExecuteOnSetGameLanguage() { void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void)) { GameInteractor::Instance->RegisterGameHook(fn); } + +//MARK: Pause Menu + +void GameInteractor_ExecuteOnKaleidoUpdate() { + GameInteractor::Instance->ExecuteHooks(); +} diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index 7b7b226fa..5c86cb39b 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -60,6 +60,9 @@ void GameInteractor_ExecuteOnSetGameLanguage(); // MARK: - System void GameInteractor_RegisterOnAssetAltChange(void (*fn)(void)); +//Mark: - Pause Menu +void GameInteractor_ExecuteOnKaleidoUpdate(); + #ifdef __cplusplus } #endif diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp index 854b7dc11..6d66d1c8b 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_RawAction.cpp @@ -111,9 +111,9 @@ void GameInteractor::RawAction::FreezePlayer() { void GameInteractor::RawAction::BurnPlayer() { Player* player = GET_PLAYER(gPlayState); for (int i = 0; i < 18; i++) { - player->flameTimers[i] = Rand_S16Offset(0, 200); + player->bodyFlameTimers[i] = Rand_S16Offset(0, 200); } - player->isBurning = true; + player->bodyIsBurning = true; func_80837C0C(gPlayState, player, 0, 0, 0, 0, 0); } diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 34e583e14..3d97d910d 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -23,6 +23,7 @@ #include "src/overlays/actors/ovl_En_Tp/z_en_tp.h" #include "src/overlays/actors/ovl_En_Firefly/z_en_firefly.h" #include "src/overlays/actors/ovl_En_Xc/z_en_xc.h" +#include "src/overlays/actors/ovl_Obj_Switch/z_obj_switch.h" #include "objects/object_link_boy/object_link_boy.h" #include "objects/object_link_child/object_link_child.h" @@ -35,6 +36,7 @@ extern "C" { #include "functions.h" #include "variables.h" #include "functions.h" +#include "src/overlays/actors/ovl_En_Door/z_en_door.h" void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction); void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName); @@ -70,7 +72,7 @@ void ReloadSceneTogglingLinkAge() { void RegisterInfiniteMoney() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gInfiniteMoney", 0) != 0) { if (gSaveContext.rupees < CUR_CAPACITY(UPG_WALLET)) { gSaveContext.rupees = CUR_CAPACITY(UPG_WALLET); @@ -81,7 +83,7 @@ void RegisterInfiniteMoney() { void RegisterInfiniteHealth() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gInfiniteHealth", 0) != 0) { if (gSaveContext.health < gSaveContext.healthCapacity) { gSaveContext.health = gSaveContext.healthCapacity; @@ -92,7 +94,7 @@ void RegisterInfiniteHealth() { void RegisterInfiniteAmmo() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gInfiniteAmmo", 0) != 0) { // Deku Sticks if (AMMO(ITEM_STICK) < CUR_CAPACITY(UPG_STICKS)) { @@ -129,7 +131,7 @@ void RegisterInfiniteAmmo() { void RegisterInfiniteMagic() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gInfiniteMagic", 0) != 0) { if (gSaveContext.isMagicAcquired && gSaveContext.magic != (gSaveContext.isDoubleMagicAcquired + 1) * 0x30) { gSaveContext.magic = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30; @@ -140,7 +142,7 @@ void RegisterInfiniteMagic() { void RegisterInfiniteNayrusLove() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gInfiniteNayru", 0) != 0) { gSaveContext.nayrusLoveTimer = 0x44B; } @@ -149,7 +151,7 @@ void RegisterInfiniteNayrusLove() { void RegisterMoonJumpOnL() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gMoonJumpOnL", 0) != 0) { Player* player = GET_PLAYER(gPlayState); @@ -164,7 +166,7 @@ void RegisterMoonJumpOnL() { void RegisterInfiniteISG() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gEzISG", 0) != 0) { Player* player = GET_PLAYER(gPlayState); @@ -176,7 +178,7 @@ void RegisterInfiniteISG() { //Permanent quick put away (QPA) glitched damage value void RegisterEzQPA() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gEzQPA", 0) != 0) { Player* player = GET_PLAYER(gPlayState); @@ -188,7 +190,7 @@ void RegisterEzQPA() { void RegisterUnrestrictedItems() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; if (CVarGetInteger("gNoRestrictItems", 0) != 0) { u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong; @@ -216,11 +218,14 @@ void RegisterFreezeTime() { /// Switches Link's age and respawns him at the last entrance he entered. void RegisterSwitchAge() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) { + static bool warped = false; + + if (!GameInteractor::IsSaveLoaded(true)) { CVarClear("gSwitchAge"); + warped = false; return; } - static bool warped = false; + static Vec3f playerPos; static int16_t playerYaw; static RoomContext* roomCtx; @@ -254,7 +259,7 @@ void RegisterSwitchAge() { void RegisterOcarinaTimeTravel() { GameInteractor::Instance->RegisterGameHook([]() { - if (!GameInteractor::IsSaveLoaded()) { + if (!GameInteractor::IsSaveLoaded(true)) { CVarClear("gTimeTravel"); return; } @@ -525,70 +530,93 @@ void RegisterDaytimeGoldSkultullas() { }); } -void RegisterHyperBosses() { - GameInteractor::Instance->RegisterGameHook([](void* refActor) { - // Run the update function a second time to make bosses move and act twice as fast. +bool IsHyperBossesActive() { + return CVarGetInteger("gHyperBosses", 0) || + (IS_BOSS_RUSH && gSaveContext.bossRushOptions[BR_OPTIONS_HYPERBOSSES] == BR_CHOICE_HYPERBOSSES_YES); +} - Player* player = GET_PLAYER(gPlayState); - Actor* actor = static_cast(refActor); +void UpdateHyperBossesState() { + static uint32_t actorUpdateHookId = 0; + if (actorUpdateHookId != 0) { + GameInteractor::Instance->UnregisterGameHook(actorUpdateHookId); + actorUpdateHookId = 0; + } - uint8_t isBossActor = - actor->id == ACTOR_BOSS_GOMA || // Gohma - actor->id == ACTOR_BOSS_DODONGO || // King Dodongo - actor->id == ACTOR_EN_BDFIRE || // King Dodongo Fire Breath - actor->id == ACTOR_BOSS_VA || // Barinade - actor->id == ACTOR_BOSS_GANONDROF || // Phantom Ganon - actor->id == ACTOR_EN_FHG_FIRE || // Phantom Ganon/Ganondorf Energy Ball/Thunder - actor->id == ACTOR_EN_FHG || // Phantom Ganon's Horse - actor->id == ACTOR_BOSS_FD || actor->id == ACTOR_BOSS_FD2 || // Volvagia (grounded/flying) - actor->id == ACTOR_EN_VB_BALL || // Volvagia Rocks - actor->id == ACTOR_BOSS_MO || // Morpha - actor->id == ACTOR_BOSS_SST || // Bongo Bongo - actor->id == ACTOR_BOSS_TW || // Twinrova - actor->id == ACTOR_BOSS_GANON || // Ganondorf - actor->id == ACTOR_BOSS_GANON2; // Ganon + if (IsHyperBossesActive()) { + actorUpdateHookId = GameInteractor::Instance->RegisterGameHook([](void* refActor) { + // Run the update function a second time to make bosses move and act twice as fast. - uint8_t hyperBossesActive = - CVarGetInteger("gHyperBosses", 0) || - (IS_BOSS_RUSH && - gSaveContext.bossRushOptions[BR_OPTIONS_HYPERBOSSES] == BR_CHOICE_HYPERBOSSES_YES); + Player* player = GET_PLAYER(gPlayState); + Actor* actor = static_cast(refActor); - // Don't apply during cutscenes because it causes weird behaviour and/or crashes on some bosses. - if (hyperBossesActive && isBossActor && !Player_InBlockingCsMode(gPlayState, player)) { - // Barinade needs to be updated in sequence to avoid unintended behaviour. - if (actor->id == ACTOR_BOSS_VA) { - // params -1 is BOSSVA_BODY - if (actor->params == -1) { - Actor* actorList = gPlayState->actorCtx.actorLists[ACTORCAT_BOSS].head; - while (actorList != NULL) { - GameInteractor::RawAction::UpdateActor(actorList); - actorList = actorList->next; + uint8_t isBossActor = + actor->id == ACTOR_BOSS_GOMA || // Gohma + actor->id == ACTOR_BOSS_DODONGO || // King Dodongo + actor->id == ACTOR_EN_BDFIRE || // King Dodongo Fire Breath + actor->id == ACTOR_BOSS_VA || // Barinade + actor->id == ACTOR_BOSS_GANONDROF || // Phantom Ganon + actor->id == ACTOR_EN_FHG_FIRE || // Phantom Ganon/Ganondorf Energy Ball/Thunder + actor->id == ACTOR_EN_FHG || // Phantom Ganon's Horse + actor->id == ACTOR_BOSS_FD || actor->id == ACTOR_BOSS_FD2 || // Volvagia (grounded/flying) + actor->id == ACTOR_EN_VB_BALL || // Volvagia Rocks + actor->id == ACTOR_BOSS_MO || // Morpha + actor->id == ACTOR_BOSS_SST || // Bongo Bongo + actor->id == ACTOR_BOSS_TW || // Twinrova + actor->id == ACTOR_BOSS_GANON || // Ganondorf + actor->id == ACTOR_BOSS_GANON2; // Ganon + + // Don't apply during cutscenes because it causes weird behaviour and/or crashes on some bosses. + if (IsHyperBossesActive() && isBossActor && !Player_InBlockingCsMode(gPlayState, player)) { + // Barinade needs to be updated in sequence to avoid unintended behaviour. + if (actor->id == ACTOR_BOSS_VA) { + // params -1 is BOSSVA_BODY + if (actor->params == -1) { + Actor* actorList = gPlayState->actorCtx.actorLists[ACTORCAT_BOSS].head; + while (actorList != NULL) { + GameInteractor::RawAction::UpdateActor(actorList); + actorList = actorList->next; + } } + } else { + GameInteractor::RawAction::UpdateActor(actor); } - } else { - GameInteractor::RawAction::UpdateActor(actor); } - } + }); + } +} + +void RegisterHyperBosses() { + UpdateHyperBossesState(); + GameInteractor::Instance->RegisterGameHook([](int16_t fileNum) { + UpdateHyperBossesState(); }); } -void RegisterHyperEnemies() { - GameInteractor::Instance->RegisterGameHook([](void* refActor) { - // Run the update function a second time to make enemies and minibosses move and act twice as fast. +void UpdateHyperEnemiesState() { + static uint32_t actorUpdateHookId = 0; + if (actorUpdateHookId != 0) { + GameInteractor::Instance->UnregisterGameHook(actorUpdateHookId); + actorUpdateHookId = 0; + } - Player* player = GET_PLAYER(gPlayState); - Actor* actor = static_cast(refActor); + if (CVarGetInteger("gHyperEnemies", 0)) { + actorUpdateHookId = GameInteractor::Instance->RegisterGameHook([](void* refActor) { + // Run the update function a second time to make enemies and minibosses move and act twice as fast. - // Some enemies are not in the ACTORCAT_ENEMY category, and some are that aren't really enemies. - bool isEnemy = actor->category == ACTORCAT_ENEMY || actor->id == ACTOR_EN_TORCH2; - bool isExcludedEnemy = actor->id == ACTOR_EN_FIRE_ROCK || actor->id == ACTOR_EN_ENCOUNT2; + Player* player = GET_PLAYER(gPlayState); + Actor* actor = static_cast(refActor); - // Don't apply during cutscenes because it causes weird behaviour and/or crashes on some cutscenes. - if (CVarGetInteger("gHyperEnemies", 0) && isEnemy && !isExcludedEnemy && - !Player_InBlockingCsMode(gPlayState, player)) { - GameInteractor::RawAction::UpdateActor(actor); - } - }); + // Some enemies are not in the ACTORCAT_ENEMY category, and some are that aren't really enemies. + bool isEnemy = actor->category == ACTORCAT_ENEMY || actor->id == ACTOR_EN_TORCH2; + bool isExcludedEnemy = actor->id == ACTOR_EN_FIRE_ROCK || actor->id == ACTOR_EN_ENCOUNT2; + + // Don't apply during cutscenes because it causes weird behaviour and/or crashes on some cutscenes. + if (CVarGetInteger("gHyperEnemies", 0) && isEnemy && !isExcludedEnemy && + !Player_InBlockingCsMode(gPlayState, player)) { + GameInteractor::RawAction::UpdateActor(actor); + } + }); + } } void RegisterBonkDamage() { @@ -1229,6 +1257,34 @@ void RegisterRandomizedEnemySizes() { }); } +void RegisterOpenAllHours() { + GameInteractor::Instance->RegisterGameHook([](void* refActor) { + Actor* actor = static_cast(refActor); + + if (CVarGetInteger("gEnhancements.OpenAllHours", 0) && (actor->id == ACTOR_EN_DOOR)) { + switch (actor->params) { + case 4753: // Night Market Bazaar + case 1678: // Night Potion Shop + case 2689: // Day Bombchu Shop + case 2703: // Night Slingshot Game + case 653: // Day Chest Game + case 6801: // Night Kak Bazaar + case 7822: // Night Kak Potion Shop + case 4751: // Night Kak Archery Game + case 3728: // Night Mask Shop + { + actor->params = (actor->params & 0xFC00) | (DOOR_SCENEEXIT << 7) | 0x3F; + EnDoor* enDoor = static_cast(refActor); + EnDoor_SetupType(enDoor, gPlayState); + break; + } + default: + break; + } + } + }); +} + void PatchToTMedallions() { // TODO: Refactor the DemoEffect_UpdateJewelAdult and DemoEffect_UpdateJewelChild from z_demo_effect // effects to take effect in there @@ -1311,6 +1367,40 @@ void RegisterToTMedallions() { }); } + +void RegisterFloorSwitchesHook() { + GameInteractor::Instance->RegisterGameHook([](void* refActor) { + Actor* actor = static_cast(refActor); + if (actor->id != ACTOR_OBJ_SWITCH || !CVarGetInteger("gEnhancements.FixFloorSwitches", 0)) { + return; + } + + ObjSwitch* switchActor = reinterpret_cast(actor); + s32 type = (switchActor->dyna.actor.params & 7); + + if (switchActor->dyna.actor.params == 0x1200 || switchActor->dyna.actor.params == 0x3A00) { + switchActor->dyna.actor.world.pos.y -= 1; + } + }); +} + +void RegisterPauseMenuHooks() { + static bool pauseWarpHooksRegistered = false; + GameInteractor::Instance->RegisterGameHook([&]() { + if (!GameInteractor::IsSaveLoaded() || !CVarGetInteger("gPauseWarp", 0)) { + pauseWarpHooksRegistered = false; + return; + } + if (!pauseWarpHooksRegistered) { + GameInteractor::Instance->RegisterGameHook([]() {PauseWarp_HandleSelection();}); + GameInteractor::Instance->RegisterGameHook([]() { + PauseWarp_Execute(); + }); + pauseWarpHooksRegistered = true; + } + }); +} + void RegisterBankUpdate() { auto handleBankUpdate = []() { if (prevTextboxCharm) { //This will be removed when TEXT_PIRATE_CHARM has been implemented. TEXT_BLUE_RUPEE is being used as a placeholder in banker.c and conflicts with this logic. @@ -1349,7 +1439,7 @@ void InitMods() { RegisterPermanentHeartLoss(); RegisterDeleteFileOnDeath(); RegisterHyperBosses(); - RegisterHyperEnemies(); + UpdateHyperEnemiesState(); RegisterBonkDamage(); RegisterMenuPathFix(); RegisterMirrorModeHandler(); @@ -1360,9 +1450,12 @@ void InitMods() { RegisterAltTrapTypes(); RegisterRandomizerSheikSpawn(); RegisterRandomizedEnemySizes(); + RegisterOpenAllHours(); RegisterToTMedallions(); NameTag_RegisterHooks(); + RegisterFloorSwitchesHook(); RegisterPatchHandHandler(); RegisterHurtContainerModeHandler(); + RegisterPauseMenuHooks(); RegisterBankUpdate(); } diff --git a/soh/soh/Enhancements/mods.h b/soh/soh/Enhancements/mods.h index 57ebedfd9..2755924f2 100644 --- a/soh/soh/Enhancements/mods.h +++ b/soh/soh/Enhancements/mods.h @@ -12,6 +12,8 @@ void UpdateMirrorModeState(int32_t sceneNum); void UpdateHurtContainerModeState(bool newState); void PatchToTMedallions(); void UpdatePermanentHeartLossState(); +void UpdateHyperEnemiesState(); +void UpdateHyperBossesState(); void InitMods(); void UpdatePatchHand(); diff --git a/soh/soh/Enhancements/pausewarp.c b/soh/soh/Enhancements/pausewarp.c new file mode 100644 index 000000000..e0fd97e24 --- /dev/null +++ b/soh/soh/Enhancements/pausewarp.c @@ -0,0 +1,92 @@ +#include "custom-message/CustomMessageTypes.h" +#include "global.h" +#include "z64.h" +#include "game-interactor/GameInteractor.h" + +static const int songMessageMap[] = { + TEXT_WARP_MINUET_OF_FOREST, + TEXT_WARP_BOLERO_OF_FIRE, + TEXT_WARP_SERENADE_OF_WATER, + TEXT_WARP_REQUIEM_OF_SPIRIT, + TEXT_WARP_NOCTURNE_OF_SHADOW, + TEXT_WARP_PRELUDE_OF_LIGHT +}; + +static const int ocarinaSongMap[] = { + OCARINA_SONG_MINUET, + OCARINA_SONG_BOLERO, + OCARINA_SONG_SERENADE, + OCARINA_SONG_REQUIEM, + OCARINA_SONG_NOCTURNE, + OCARINA_SONG_PRELUDE +}; + +static const int entranceIndexMap[] = { + ENTR_SACRED_FOREST_MEADOW_2, // Minuet + ENTR_DEATH_MOUNTAIN_CRATER_4, // Bolero + ENTR_LAKE_HYLIA_8, // Serenade + ENTR_DESERT_COLOSSUS_5, // Requiem + ENTR_GRAVEYARD_7, // Nocturne + ENTR_TEMPLE_OF_TIME_7 // Prelude +}; + +static const int songAudioMap[] = { + NA_BGM_OCA_MINUET, + NA_BGM_OCA_BOLERO, + NA_BGM_OCA_SERENADE, + NA_BGM_OCA_REQUIEM, + NA_BGM_OCA_NOCTURNE, + NA_BGM_OCA_LIGHT +}; + +static bool isWarpActive = false; + +void PauseWarp_Execute() { + if (!isWarpActive || gPlayState->msgCtx.msgMode != MSGMODE_NONE) { + return; + } + isWarpActive = false; + GET_PLAYER(gPlayState)->stateFlags1 &= ~PLAYER_STATE1_IN_CUTSCENE; + if (gPlayState->msgCtx.choiceIndex != 0) { + return; + } + if (IS_RANDO) { + Entrance_SetWarpSongEntrance(); + return; + } + gPlayState->transitionTrigger = TRANS_TRIGGER_START; + gPlayState->transitionType = TRANS_TYPE_FADE_WHITE_FAST; + for (int i = 0; i < ARRAY_COUNT(ocarinaSongMap); i++) { + if (gPlayState->msgCtx.lastPlayedSong == ocarinaSongMap[i]) { + gPlayState->nextEntranceIndex = entranceIndexMap[i]; + return; + } + } + gPlayState->transitionTrigger = TRANS_TRIGGER_OFF; +} + +void ActivateWarp(PauseContext* pauseCtx, int song) { + Audio_OcaSetInstrument(0); + Interface_SetDoAction(gPlayState, DO_ACTION_NONE); + pauseCtx->state = 0x12; + WREG(2) = -6240; + func_800F64E0(0); + pauseCtx->unk_1E4 = 0; + int idx = song - QUEST_SONG_MINUET; + gPlayState->msgCtx.lastPlayedSong = ocarinaSongMap[idx]; + Audio_SetSoundBanksMute(0x20); + Audio_PlayFanfare(songAudioMap[idx]); + Message_StartTextbox(gPlayState, songMessageMap[idx], NULL); + GET_PLAYER(gPlayState)->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; + isWarpActive = true; +} + +void PauseWarp_HandleSelection() { + if (gSaveContext.inventory.items[SLOT_OCARINA] != ITEM_NONE) { + int aButtonPressed = CHECK_BTN_ALL(gPlayState->state.input->press.button, BTN_A); + int song = gPlayState->pauseCtx.cursorPoint[PAUSE_QUEST]; + if (aButtonPressed && CHECK_QUEST_ITEM(song) && song >= QUEST_SONG_MINUET && song <= QUEST_SONG_PRELUDE) { + ActivateWarp(&gPlayState->pauseCtx, song); + } + } +} diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 8a9b963e8..3fede1e9b 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -260,6 +260,24 @@ const std::vector enhancementsCvars = { "gAddTraps.Tele", "gAddTraps.Void", "gToTMedallionsColors", + "gCuccoStayDurationMultiplier", + "gDeleteFileOnDeath", + "gEnemySizeScalesHealth", + "gEnhancements.BetterAmmoRendering", + "gEnhancements.EquimentAlwaysVisible", + "gEnhancements.FixDaruniaDanceSpeed", + "gEnhancements.OpenAllHours", + "gEnhancements.ResetNaviTimer", + "gEnhancements.ScaleAdultEquimentAsChild", + "gEnhancements.LeeverSpawnRate", + "gEnhancements.SwordToggle", + "gEnhancements.FixFloorSwitches", + "gFixZoraHintDialogue", + "gHurtContainer", + "gPauseWarp", + "gPermanentHeartLoss", + "gRemoveExplosiveLimit", + "gToggleStrength", }; const std::vector cheatCvars = { @@ -312,6 +330,7 @@ const std::vector cheatCvars = { "gSwitchAge", "gSwitchTimeline", "gNoRedeadFreeze", + "gNoKeeseGuayTarget", "gBombTimerMultiplier", "gNoFishDespawn", "gNoBugsDespawn", @@ -331,6 +350,7 @@ const std::vector cheatCvars = { "gCosmetics.Link_HeadScale.Value", "gCosmetics.Link_SwordScale.Changed", "gCosmetics.Link_SwordScale.Value", + "gEnhancements.RememberMapToggleState", }; const std::vector randomizerCvars = { @@ -525,6 +545,8 @@ const std::vector vanillaPlusPresetEntries = { PRESET_ENTRY_S32("gNaviTextFix", 1), // Extend Silver Rupee Jingle PRESET_ENTRY_S32("gSilverRupeeJingleExtend", 1), + // Fix some Floor Switches + PRESET_ENTRY_S32("gEnhancements.FixFloorSwitches", 1), // Red Ganon blood PRESET_ENTRY_S32("gRedGanonBlood", 1), @@ -596,6 +618,8 @@ const std::vector enhancedPresetEntries = { PRESET_ENTRY_S32("gSilverRupeeJingleExtend", 1), // Fix enemies not spawning on ground over water PRESET_ENTRY_S32("gEnemySpawnsOverWaterboxes", 1), + // Fix some Floor Switches + PRESET_ENTRY_S32("gEnhancements.FixFloorSwitches", 1), // Red Ganon blood PRESET_ENTRY_S32("gRedGanonBlood", 1), @@ -718,6 +742,8 @@ const std::vector randomizerPresetEntries = { PRESET_ENTRY_S32("gNaviTextFix", 1), // Extend Silver Rupee Jingle PRESET_ENTRY_S32("gSilverRupeeJingleExtend", 1), + // Fix some Floor Switches + PRESET_ENTRY_S32("gEnhancements.FixFloorSwitches", 1), // Red Ganon blood PRESET_ENTRY_S32("gRedGanonBlood", 1), diff --git a/soh/soh/Enhancements/randomizer/3drando/entrance.cpp b/soh/soh/Enhancements/randomizer/3drando/entrance.cpp index 5df67bb87..8dd8b4c63 100644 --- a/soh/soh/Enhancements/randomizer/3drando/entrance.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/entrance.cpp @@ -26,7 +26,6 @@ typedef struct { AreaKey parentRegion; AreaKey connectedRegion; int16_t index; - int16_t blueWarp; } EntranceLinkInfo; EntranceLinkInfo NO_RETURN_ENTRANCE = {EntranceType::None, NONE, NONE, -1}; @@ -40,6 +39,11 @@ using EntranceInfoPair = std::pair; using EntrancePair = std::pair; using EntrancePools = std::map>; +// Construct entrance name from parent and connected region keys +std::string EntranceNameByRegions(uint32_t parentRegion, uint32_t connectedRegion) { + return AreaTable(parentRegion)->regionName + " -> " + AreaTable(connectedRegion)->regionName; +} + //The entrance randomization algorithm used here is a direct copy of //the algorithm used in the original N64 randomizer (except now in C++ instead //of python). It may be easier to understand the algorithm by looking at the @@ -77,26 +81,22 @@ void SetAllEntrancesData(std::vector& entranceShuffleTable) { //set data Entrance* forwardEntrance = AreaTable(forwardEntry.parentRegion)->GetExit(forwardEntry.connectedRegion); forwardEntrance->SetIndex(forwardEntry.index); - forwardEntrance->SetBlueWarp(forwardEntry.blueWarp); forwardEntrance->SetType(forwardEntry.type); forwardEntrance->SetAsPrimary(); - // When decouple entrances is on, mark it for entrances except boss rooms - if (Settings::DecoupleEntrances && forwardEntry.type != EntranceType::ChildBoss && - forwardEntry.type != EntranceType::AdultBoss) { + // When decouple entrances is on, mark the forward entrance + if (Settings::DecoupleEntrances) { forwardEntrance->SetDecoupled(); } if (returnEntry.parentRegion != NONE) { Entrance* returnEntrance = AreaTable(returnEntry.parentRegion)->GetExit(returnEntry.connectedRegion); returnEntrance->SetIndex(returnEntry.index); - returnEntrance->SetBlueWarp(returnEntry.blueWarp); returnEntrance->SetType(returnEntry.type); forwardEntrance->BindTwoWay(returnEntrance); // Mark reverse entrance as decoupled - if (Settings::DecoupleEntrances && returnEntry.type != EntranceType::ChildBoss && - returnEntry.type != EntranceType::AdultBoss) { + if (Settings::DecoupleEntrances) { returnEntrance->SetDecoupled(); } } @@ -687,31 +687,31 @@ int ShuffleAllEntrances() { curNumRandomizedEntrances = 0; std::vector entranceShuffleTable = { - //Parent Region Connected Region index blue warp + //Parent Region Connected Region index {{EntranceType::Dungeon, KF_OUTSIDE_DEKU_TREE, DEKU_TREE_ENTRYWAY, 0x0000}, - {EntranceType::Dungeon, DEKU_TREE_ENTRYWAY, KF_OUTSIDE_DEKU_TREE, 0x0209, 0x0457}}, + {EntranceType::Dungeon, DEKU_TREE_ENTRYWAY, KF_OUTSIDE_DEKU_TREE, 0x0209}}, {{EntranceType::Dungeon, DEATH_MOUNTAIN_TRAIL, DODONGOS_CAVERN_ENTRYWAY, 0x0004}, - {EntranceType::Dungeon, DODONGOS_CAVERN_ENTRYWAY, DEATH_MOUNTAIN_TRAIL, 0x0242, 0x047A}}, + {EntranceType::Dungeon, DODONGOS_CAVERN_ENTRYWAY, DEATH_MOUNTAIN_TRAIL, 0x0242}}, {{EntranceType::Dungeon, ZORAS_FOUNTAIN, JABU_JABUS_BELLY_ENTRYWAY, 0x0028}, - {EntranceType::Dungeon, JABU_JABUS_BELLY_ENTRYWAY, ZORAS_FOUNTAIN, 0x0221, 0x010E}}, + {EntranceType::Dungeon, JABU_JABUS_BELLY_ENTRYWAY, ZORAS_FOUNTAIN, 0x0221}}, {{EntranceType::Dungeon, SACRED_FOREST_MEADOW, FOREST_TEMPLE_ENTRYWAY, 0x0169}, - {EntranceType::Dungeon, FOREST_TEMPLE_ENTRYWAY, SACRED_FOREST_MEADOW, 0x0215, 0x0608}}, + {EntranceType::Dungeon, FOREST_TEMPLE_ENTRYWAY, SACRED_FOREST_MEADOW, 0x0215}}, {{EntranceType::Dungeon, DMC_CENTRAL_LOCAL, FIRE_TEMPLE_ENTRYWAY, 0x0165}, - {EntranceType::Dungeon, FIRE_TEMPLE_ENTRYWAY, DMC_CENTRAL_LOCAL, 0x024A, 0x0564}}, + {EntranceType::Dungeon, FIRE_TEMPLE_ENTRYWAY, DMC_CENTRAL_LOCAL, 0x024A}}, {{EntranceType::Dungeon, LAKE_HYLIA, WATER_TEMPLE_ENTRYWAY, 0x0010}, - {EntranceType::Dungeon, WATER_TEMPLE_ENTRYWAY, LAKE_HYLIA, 0x021D, 0x060C}}, + {EntranceType::Dungeon, WATER_TEMPLE_ENTRYWAY, LAKE_HYLIA, 0x021D}}, {{EntranceType::Dungeon, DESERT_COLOSSUS, SPIRIT_TEMPLE_ENTRYWAY, 0x0082}, - {EntranceType::Dungeon, SPIRIT_TEMPLE_ENTRYWAY, DESERT_COLOSSUS_FROM_SPIRIT_ENTRYWAY, 0x01E1, 0x0610}}, + {EntranceType::Dungeon, SPIRIT_TEMPLE_ENTRYWAY, DESERT_COLOSSUS_FROM_SPIRIT_ENTRYWAY, 0x01E1}}, {{EntranceType::Dungeon, GRAVEYARD_WARP_PAD_REGION, SHADOW_TEMPLE_ENTRYWAY, 0x0037}, - {EntranceType::Dungeon, SHADOW_TEMPLE_ENTRYWAY, GRAVEYARD_WARP_PAD_REGION, 0x0205, 0x0580}}, + {EntranceType::Dungeon, SHADOW_TEMPLE_ENTRYWAY, GRAVEYARD_WARP_PAD_REGION, 0x0205}}, {{EntranceType::Dungeon, KAKARIKO_VILLAGE, BOTTOM_OF_THE_WELL_ENTRYWAY, 0x0098}, {EntranceType::Dungeon, BOTTOM_OF_THE_WELL_ENTRYWAY, KAKARIKO_VILLAGE, 0x02A6}}, {{EntranceType::Dungeon, ZORAS_FOUNTAIN, ICE_CAVERN_ENTRYWAY, 0x0088}, {EntranceType::Dungeon, ICE_CAVERN_ENTRYWAY, ZORAS_FOUNTAIN, 0x03D4}}, {{EntranceType::Dungeon, GERUDO_FORTRESS, GERUDO_TRAINING_GROUNDS_ENTRYWAY, 0x0008}, {EntranceType::Dungeon, GERUDO_TRAINING_GROUNDS_ENTRYWAY, GERUDO_FORTRESS, 0x03A8}}, - {{EntranceType::GanonDungeon, GANONS_CASTLE_LEDGE, GANONS_CASTLE_ENTRYWAY, 0x0467}, - {EntranceType::GanonDungeon, GANONS_CASTLE_ENTRYWAY, CASTLE_GROUNDS_FROM_GANONS_CASTLE, 0x023D}}, + {{EntranceType::GanonDungeon, GANONS_CASTLE_LEDGE, GANONS_CASTLE_ENTRYWAY, 0x0467}, + {EntranceType::GanonDungeon, GANONS_CASTLE_ENTRYWAY, CASTLE_GROUNDS_FROM_GANONS_CASTLE, 0x023D}}, {{EntranceType::Interior, KOKIRI_FOREST, KF_MIDOS_HOUSE, 0x0433}, {EntranceType::Interior, KF_MIDOS_HOUSE, KOKIRI_FOREST, 0x0443}}, @@ -947,21 +947,30 @@ int ShuffleAllEntrances() { {{EntranceType::WarpSong, PRELUDE_OF_LIGHT_WARP, TEMPLE_OF_TIME, 0x05F4}, NO_RETURN_ENTRANCE}, {{EntranceType::ChildBoss, DEKU_TREE_BOSS_ENTRYWAY, DEKU_TREE_BOSS_ROOM, 0x040F}, - {EntranceType::ChildBoss, DEKU_TREE_BOSS_ROOM, DEKU_TREE_BOSS_ENTRYWAY, 0x0252, 0x0457}}, + {EntranceType::ChildBoss, DEKU_TREE_BOSS_ROOM, DEKU_TREE_BOSS_ENTRYWAY, 0x0252}}, {{EntranceType::ChildBoss, DODONGOS_CAVERN_BOSS_ENTRYWAY, DODONGOS_CAVERN_BOSS_ROOM, 0x040B}, - {EntranceType::ChildBoss, DODONGOS_CAVERN_BOSS_ROOM, DODONGOS_CAVERN_BOSS_ENTRYWAY, 0x00C5, 0x047A}}, + {EntranceType::ChildBoss, DODONGOS_CAVERN_BOSS_ROOM, DODONGOS_CAVERN_BOSS_ENTRYWAY, 0x00C5}}, {{EntranceType::ChildBoss, JABU_JABUS_BELLY_BOSS_ENTRYWAY, JABU_JABUS_BELLY_BOSS_ROOM, 0x0301}, - {EntranceType::ChildBoss, JABU_JABUS_BELLY_BOSS_ROOM, JABU_JABUS_BELLY_BOSS_ENTRYWAY, 0x0407, 0x010E}}, + {EntranceType::ChildBoss, JABU_JABUS_BELLY_BOSS_ROOM, JABU_JABUS_BELLY_BOSS_ENTRYWAY, 0x0407}}, {{EntranceType::AdultBoss, FOREST_TEMPLE_BOSS_ENTRYWAY, FOREST_TEMPLE_BOSS_ROOM, 0x000C}, - {EntranceType::AdultBoss, FOREST_TEMPLE_BOSS_ROOM, FOREST_TEMPLE_BOSS_ENTRYWAY, 0x024E, 0x0608}}, + {EntranceType::AdultBoss, FOREST_TEMPLE_BOSS_ROOM, FOREST_TEMPLE_BOSS_ENTRYWAY, 0x024E}}, {{EntranceType::AdultBoss, FIRE_TEMPLE_BOSS_ENTRYWAY, FIRE_TEMPLE_BOSS_ROOM, 0x0305}, - {EntranceType::AdultBoss, FIRE_TEMPLE_BOSS_ROOM, FIRE_TEMPLE_BOSS_ENTRYWAY, 0x0175, 0x0564}}, + {EntranceType::AdultBoss, FIRE_TEMPLE_BOSS_ROOM, FIRE_TEMPLE_BOSS_ENTRYWAY, 0x0175}}, {{EntranceType::AdultBoss, WATER_TEMPLE_BOSS_ENTRYWAY, WATER_TEMPLE_BOSS_ROOM, 0x0417}, - {EntranceType::AdultBoss, WATER_TEMPLE_BOSS_ROOM, WATER_TEMPLE_BOSS_ENTRYWAY, 0x0423, 0x060C}}, + {EntranceType::AdultBoss, WATER_TEMPLE_BOSS_ROOM, WATER_TEMPLE_BOSS_ENTRYWAY, 0x0423}}, {{EntranceType::AdultBoss, SPIRIT_TEMPLE_BOSS_ENTRYWAY, SPIRIT_TEMPLE_BOSS_ROOM, 0x008D}, - {EntranceType::AdultBoss, SPIRIT_TEMPLE_BOSS_ROOM, SPIRIT_TEMPLE_BOSS_ENTRYWAY, 0x02F5, 0x0610}}, + {EntranceType::AdultBoss, SPIRIT_TEMPLE_BOSS_ROOM, SPIRIT_TEMPLE_BOSS_ENTRYWAY, 0x02F5}}, {{EntranceType::AdultBoss, SHADOW_TEMPLE_BOSS_ENTRYWAY, SHADOW_TEMPLE_BOSS_ROOM, 0x0413}, - {EntranceType::AdultBoss, SHADOW_TEMPLE_BOSS_ROOM, SHADOW_TEMPLE_BOSS_ENTRYWAY, 0x02B2, 0x0580}}, + {EntranceType::AdultBoss, SHADOW_TEMPLE_BOSS_ROOM, SHADOW_TEMPLE_BOSS_ENTRYWAY, 0x02B2}}, + + {{EntranceType::BlueWarp, DEKU_TREE_BOSS_ROOM, KF_OUTSIDE_DEKU_TREE, 0x0457}, NO_RETURN_ENTRANCE}, + {{EntranceType::BlueWarp, DODONGOS_CAVERN_BOSS_ROOM, DEATH_MOUNTAIN_TRAIL, 0x047A}, NO_RETURN_ENTRANCE}, + {{EntranceType::BlueWarp, JABU_JABUS_BELLY_BOSS_ROOM, ZORAS_FOUNTAIN, 0x010E}, NO_RETURN_ENTRANCE}, + {{EntranceType::BlueWarp, FOREST_TEMPLE_BOSS_ROOM, SACRED_FOREST_MEADOW, 0x0608}, NO_RETURN_ENTRANCE}, + {{EntranceType::BlueWarp, FIRE_TEMPLE_BOSS_ROOM, DMC_CENTRAL_LOCAL, 0x0564}, NO_RETURN_ENTRANCE}, + {{EntranceType::BlueWarp, WATER_TEMPLE_BOSS_ROOM, LAKE_HYLIA, 0x060C}, NO_RETURN_ENTRANCE}, + {{EntranceType::BlueWarp, SPIRIT_TEMPLE_BOSS_ROOM, DESERT_COLOSSUS, 0x0610}, NO_RETURN_ENTRANCE}, + {{EntranceType::BlueWarp, SHADOW_TEMPLE_BOSS_ROOM, GRAVEYARD_WARP_PAD_REGION, 0x0580}, NO_RETURN_ENTRANCE}, }; std::map priorityEntranceTable = { @@ -1011,6 +1020,11 @@ int ShuffleAllEntrances() { FilterAndEraseFromPool(entrancePools[EntranceType::Boss], [](const Entrance* entrance){return entrance->GetParentRegionKey() == DEKU_TREE_BOSS_ENTRYWAY && entrance->GetConnectedRegionKey() == DEKU_TREE_BOSS_ROOM;}); } + if (Settings::DecoupleEntrances) { + for (Entrance* entrance : entrancePools[EntranceType::Boss]) { + entrancePools[EntranceType::BossReverse].push_back(entrance->GetReverse()); + } + } } else { entrancePools[EntranceType::ChildBoss] = GetShuffleableEntrances(EntranceType::ChildBoss); entrancePools[EntranceType::AdultBoss] = GetShuffleableEntrances(EntranceType::AdultBoss); @@ -1019,6 +1033,14 @@ int ShuffleAllEntrances() { FilterAndEraseFromPool(entrancePools[EntranceType::ChildBoss], [](const Entrance* entrance){return entrance->GetParentRegionKey() == DEKU_TREE_BOSS_ENTRYWAY && entrance->GetConnectedRegionKey() == DEKU_TREE_BOSS_ROOM;}); } + if (Settings::DecoupleEntrances) { + for (Entrance* entrance : entrancePools[EntranceType::ChildBoss]) { + entrancePools[EntranceType::ChildBossReverse].push_back(entrance->GetReverse()); + } + for (Entrance* entrance : entrancePools[EntranceType::AdultBoss]) { + entrancePools[EntranceType::AdultBossReverse].push_back(entrance->GetReverse()); + } + } } } @@ -1082,10 +1104,13 @@ int ShuffleAllEntrances() { SetShuffledEntrances(oneWayEntrancePools); //combine entrance pools if mixing pools. Only continue if more than one pool is selected. - int totalMixedPools = (Settings::MixDungeons ? 1 : 0) + (Settings::MixOverworld ? 1 : 0) + (Settings::MixInteriors ? 1 : 0) + (Settings::MixGrottos ? 1 : 0); + int totalMixedPools = (Settings::MixDungeons ? 1 : 0) + (Settings::MixBosses ? 1 : 0) + + (Settings::MixOverworld ? 1 : 0) + (Settings::MixInteriors ? 1 : 0) + + (Settings::MixGrottos ? 1 : 0); if (totalMixedPools < 2) { Settings::MixedEntrancePools.SetSelectedIndex(OFF); Settings::MixDungeons.SetSelectedIndex(OFF); + Settings::MixBosses.SetSelectedIndex(OFF); Settings::MixOverworld.SetSelectedIndex(OFF); Settings::MixInteriors.SetSelectedIndex(OFF); Settings::MixGrottos.SetSelectedIndex(OFF); @@ -1099,6 +1124,12 @@ int ShuffleAllEntrances() { poolsToMix.insert(EntranceType::DungeonReverse); } } + if (Settings::MixBosses) { + poolsToMix.insert(EntranceType::Boss); + if (Settings::DecoupleEntrances) { + poolsToMix.insert(EntranceType::BossReverse); + } + } if (Settings::MixOverworld) { poolsToMix.insert(EntranceType::Overworld); } @@ -1232,6 +1263,87 @@ int ShuffleAllEntrances() { } } + // Determine blue warp targets + if (true /* Settings.BlueWarps.Is(BLUEWARPS_DUNGEON) */) { // RANDOTODO: add bluewarp shuffle + // If a boss room is inside a boss door, make the blue warp go outside the dungeon's entrance + std::map bossExits = { + { EntranceNameByRegions(DEKU_TREE_BOSS_ROOM, DEKU_TREE_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(DEKU_TREE_ENTRYWAY, KF_OUTSIDE_DEKU_TREE)) }, + { EntranceNameByRegions(DODONGOS_CAVERN_BOSS_ROOM, DODONGOS_CAVERN_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(DODONGOS_CAVERN_ENTRYWAY, DEATH_MOUNTAIN_TRAIL)) }, + { EntranceNameByRegions(JABU_JABUS_BELLY_BOSS_ROOM, JABU_JABUS_BELLY_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(JABU_JABUS_BELLY_ENTRYWAY, ZORAS_FOUNTAIN)) }, + { EntranceNameByRegions(FOREST_TEMPLE_BOSS_ROOM, FOREST_TEMPLE_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(FOREST_TEMPLE_ENTRYWAY, SACRED_FOREST_MEADOW)) }, + { EntranceNameByRegions(FIRE_TEMPLE_BOSS_ROOM, FIRE_TEMPLE_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(FIRE_TEMPLE_ENTRYWAY, DMC_CENTRAL_LOCAL)) }, + { EntranceNameByRegions(WATER_TEMPLE_BOSS_ROOM, WATER_TEMPLE_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(WATER_TEMPLE_ENTRYWAY, LAKE_HYLIA)) }, + { EntranceNameByRegions(SPIRIT_TEMPLE_BOSS_ROOM, SPIRIT_TEMPLE_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(SPIRIT_TEMPLE_ENTRYWAY, DESERT_COLOSSUS_FROM_SPIRIT_ENTRYWAY)) }, + { EntranceNameByRegions(SHADOW_TEMPLE_BOSS_ROOM, SHADOW_TEMPLE_BOSS_ENTRYWAY), + GetEntrance(EntranceNameByRegions(SHADOW_TEMPLE_ENTRYWAY, GRAVEYARD_WARP_PAD_REGION)) }, + }; + + // If a boss room is inside a dungeon entrance (or inside a dungeon which is inside a dungeon entrance), make the blue warp go to that dungeon's blue warp target + std::map dungeonExits = { + { EntranceNameByRegions(DEKU_TREE_ENTRYWAY, KF_OUTSIDE_DEKU_TREE), + GetEntrance(EntranceNameByRegions(DEKU_TREE_BOSS_ROOM, KF_OUTSIDE_DEKU_TREE)) }, + { EntranceNameByRegions(DODONGOS_CAVERN_ENTRYWAY, DEATH_MOUNTAIN_TRAIL), + GetEntrance(EntranceNameByRegions(DODONGOS_CAVERN_BOSS_ROOM, DEATH_MOUNTAIN_TRAIL)) }, + { EntranceNameByRegions(JABU_JABUS_BELLY_ENTRYWAY, ZORAS_FOUNTAIN), + GetEntrance(EntranceNameByRegions(JABU_JABUS_BELLY_BOSS_ROOM, ZORAS_FOUNTAIN)) }, + { EntranceNameByRegions(FOREST_TEMPLE_ENTRYWAY, SACRED_FOREST_MEADOW), + GetEntrance(EntranceNameByRegions(FOREST_TEMPLE_BOSS_ROOM, SACRED_FOREST_MEADOW)) }, + { EntranceNameByRegions(FIRE_TEMPLE_ENTRYWAY, DMC_CENTRAL_LOCAL), + GetEntrance(EntranceNameByRegions(FIRE_TEMPLE_BOSS_ROOM, DMC_CENTRAL_LOCAL)) }, + { EntranceNameByRegions(WATER_TEMPLE_ENTRYWAY, LAKE_HYLIA), + GetEntrance(EntranceNameByRegions(WATER_TEMPLE_BOSS_ROOM, LAKE_HYLIA)) }, + { EntranceNameByRegions(SPIRIT_TEMPLE_ENTRYWAY, DESERT_COLOSSUS_FROM_SPIRIT_ENTRYWAY), + GetEntrance(EntranceNameByRegions(SPIRIT_TEMPLE_BOSS_ROOM, DESERT_COLOSSUS)) }, + { EntranceNameByRegions(SHADOW_TEMPLE_ENTRYWAY, GRAVEYARD_WARP_PAD_REGION), + GetEntrance(EntranceNameByRegions(SHADOW_TEMPLE_BOSS_ROOM, GRAVEYARD_WARP_PAD_REGION)) }, + }; + + // Pair + std::vector bossRoomExitPairs = { + { GetEntrance(EntranceNameByRegions(DEKU_TREE_BOSS_ROOM, KF_OUTSIDE_DEKU_TREE)), + GetEntrance(EntranceNameByRegions(DEKU_TREE_BOSS_ROOM, DEKU_TREE_BOSS_ENTRYWAY)) }, + { GetEntrance(EntranceNameByRegions(DODONGOS_CAVERN_BOSS_ROOM, DEATH_MOUNTAIN_TRAIL)), + GetEntrance(EntranceNameByRegions(DODONGOS_CAVERN_BOSS_ROOM, DODONGOS_CAVERN_BOSS_ENTRYWAY)) }, + { GetEntrance(EntranceNameByRegions(JABU_JABUS_BELLY_BOSS_ROOM, ZORAS_FOUNTAIN)), + GetEntrance(EntranceNameByRegions(JABU_JABUS_BELLY_BOSS_ROOM, JABU_JABUS_BELLY_BOSS_ENTRYWAY)) }, + { GetEntrance(EntranceNameByRegions(FOREST_TEMPLE_BOSS_ROOM, SACRED_FOREST_MEADOW)), + GetEntrance(EntranceNameByRegions(FOREST_TEMPLE_BOSS_ROOM, FOREST_TEMPLE_BOSS_ENTRYWAY)) }, + { GetEntrance(EntranceNameByRegions(FIRE_TEMPLE_BOSS_ROOM, DMC_CENTRAL_LOCAL)), + GetEntrance(EntranceNameByRegions(FIRE_TEMPLE_BOSS_ROOM, FIRE_TEMPLE_BOSS_ENTRYWAY)) }, + { GetEntrance(EntranceNameByRegions(WATER_TEMPLE_BOSS_ROOM, LAKE_HYLIA)), + GetEntrance(EntranceNameByRegions(WATER_TEMPLE_BOSS_ROOM, WATER_TEMPLE_BOSS_ENTRYWAY)) }, + { GetEntrance(EntranceNameByRegions(SPIRIT_TEMPLE_BOSS_ROOM, DESERT_COLOSSUS)), + GetEntrance(EntranceNameByRegions(SPIRIT_TEMPLE_BOSS_ROOM, SPIRIT_TEMPLE_BOSS_ENTRYWAY)) }, + { GetEntrance(EntranceNameByRegions(SHADOW_TEMPLE_BOSS_ROOM, GRAVEYARD_WARP_PAD_REGION)), + GetEntrance(EntranceNameByRegions(SHADOW_TEMPLE_BOSS_ROOM, SHADOW_TEMPLE_BOSS_ENTRYWAY)) }, + }; + + for (EntrancePair pair : bossRoomExitPairs) { + Entrance* target = pair.second->GetReplacement() != nullptr ? pair.second->GetReplacement() : pair.second; + + if (!Settings::DecoupleEntrances) { + while (bossExits.find(target->GetName()) != bossExits.end()) { + Entrance* next = bossExits.at(target->GetName()); + target = next->GetReplacement() != nullptr ? next->GetReplacement() : next; + } + + if (dungeonExits.find(target->GetName()) != dungeonExits.end()) { + target = dungeonExits.at(target->GetName()); + } + } + + pair.first->Connect(target->GetOriginalConnectedRegionKey()); + pair.first->SetReplacement(target); + } + } + // Validate the world one last time to ensure all special conditions are still valid if (!ValidateWorld(nullptr)) { return ENTRANCE_SHUFFLE_FAILURE; @@ -1259,8 +1371,8 @@ void CreateEntranceOverrides() { auto message = "Setting " + entrance->to_string() + "\n"; SPDLOG_DEBUG(message); + uint8_t type = (uint8_t)entrance->GetType(); int16_t originalIndex = entrance->GetIndex(); - int16_t originalBlueWarp = entrance->GetBlueWarp(); int16_t replacementIndex = entrance->GetReplacement()->GetIndex(); int16_t destinationIndex = -1; @@ -1274,9 +1386,9 @@ void CreateEntranceOverrides() { } entranceOverrides.push_back({ + .type = type, .index = originalIndex, .destination = destinationIndex, - .blueWarp = originalBlueWarp, .override = replacementIndex, .overrideDestination = replacementDestinationIndex, }); diff --git a/soh/soh/Enhancements/randomizer/3drando/entrance.hpp b/soh/soh/Enhancements/randomizer/3drando/entrance.hpp index b6a5cb432..e99b418d8 100644 --- a/soh/soh/Enhancements/randomizer/3drando/entrance.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/entrance.hpp @@ -18,12 +18,16 @@ enum class EntranceType { OwlDrop, Spawn, WarpSong, + BlueWarp, Dungeon, GanonDungeon, DungeonReverse, Boss, + BossReverse, ChildBoss, + ChildBossReverse, AdultBoss, + AdultBossReverse, Interior, InteriorReverse, SpecialInterior, @@ -40,6 +44,7 @@ public: Entrance(uint32_t connectedRegion_, std::vector conditions_met_) : connectedRegion(connectedRegion_) { + originalConnectedRegion = connectedRegion_; conditions_met.resize(2); for (size_t i = 0; i < conditions_met_.size(); i++) { conditions_met[i] = conditions_met_[i]; @@ -134,6 +139,10 @@ public: return connectedRegion; } + uint32_t GetOriginalConnectedRegionKey() const { + return originalConnectedRegion; + } + Area* GetConnectedRegion() const { return AreaTable(connectedRegion); } @@ -198,14 +207,6 @@ public: index = newIndex; } - int16_t GetBlueWarp() const { - return blueWarp; - } - - void SetBlueWarp(int16_t newBlueWarp) { - blueWarp = newBlueWarp; - } - Entrance* GetAssumed() const { return assumed; } @@ -251,7 +252,7 @@ public: AreaTable(ROOT)->AddExit(ROOT, connectedRegion, []{return true;}); Entrance* targetEntrance = AreaTable(ROOT)->GetExit(connectedRegion); targetEntrance->SetReplacement(this); - targetEntrance->SetName(GetParentRegion()->regionName + " -> " + GetConnectedRegion()->regionName); + targetEntrance->SetName(AreaTable(ROOT)->regionName + " -> " + GetConnectedRegion()->regionName); return targetEntrance; } @@ -266,6 +267,7 @@ public: private: uint32_t parentRegion; uint32_t connectedRegion; + uint32_t originalConnectedRegion; std::vector conditions_met; //Entrance Randomizer stuff @@ -275,7 +277,6 @@ private: Entrance* assumed = nullptr; Entrance* replacement = nullptr; int16_t index = 0xFFFF; - int16_t blueWarp = 0; bool shuffled = false; bool primary = false; bool addedToPool = false; @@ -285,6 +286,7 @@ private: int ShuffleAllEntrances(); void CreateEntranceOverrides(); +std::string EntranceNameByRegions(uint32_t parentRegion, uint32_t connectedRegion); extern std::vector> playthroughEntrances; extern bool noRandomEntrances; diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index 7063a3191..7c8d027f2 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -294,7 +294,12 @@ std::vector GetAccessibleLocations(const std::vector& allowe } // Add shuffled entrances to the entrance playthrough - if (mode == SearchMode::GeneratePlaythrough && exit.IsShuffled() && !exit.IsAddedToPool() && !noRandomEntrances) { + // Include bluewarps when unshuffled but dungeon or boss shuffle is on + if (mode == SearchMode::GeneratePlaythrough && + (exit.IsShuffled() || (exit.GetType() == EntranceType::BlueWarp && + (Settings::ShuffleDungeonEntrances.IsNot(SHUFFLEDUNGEONS_OFF) || + Settings::ShuffleBossEntrances.IsNot(SHUFFLEBOSSES_OFF)))) && + !exit.IsAddedToPool() && !noRandomEntrances) { entranceSphere.push_back(&exit); exit.AddToPool(); // Don't list a two-way coupled entrance from both directions diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp index 6be67ea84..684dd16e1 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp @@ -503,3 +503,16 @@ std::vector GetShuffleableEntrances(EntranceType type, bool onlyPrima } return entrancesToShuffle; } + +// Get the specific entrance by name +Entrance* GetEntrance(const std::string name) { + for (uint32_t area : Areas::GetAllAreas()) { + for (auto& exit : AreaTable(area)->exits) { + if (exit.GetName() == name) { + return &exit; + } + } + } + + return nullptr; +} diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access.hpp b/soh/soh/Enhancements/randomizer/3drando/location_access.hpp index 60529a2f6..672a97f5c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access.hpp @@ -242,6 +242,7 @@ namespace Areas { void AreaTable_Init(); Area* AreaTable(const uint32_t areaKey); std::vector GetShuffleableEntrances(EntranceType type, bool onlyPrimary = true); +Entrance* GetEntrance(const std::string name); // Overworld void AreaTable_Init_LostWoods(); diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp index 2224df4ca..c1231b29e 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_deku_tree.cpp @@ -267,5 +267,6 @@ void AreaTable_Init_DekuTree() { { // Exits Entrance(DEKU_TREE_BOSS_ENTRYWAY, { [] { return true; } }), + Entrance(KF_OUTSIDE_DEKU_TREE, { [] { return DekuTreeClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp index 9f8effbcc..dc88b1b2c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_dodongos_cavern.cpp @@ -309,5 +309,6 @@ void AreaTable_Init_DodongosCavern() { { // Exits Entrance(DODONGOS_CAVERN_BOSS_ENTRYWAY, { [] { return true; } }), + Entrance(DEATH_MOUNTAIN_TRAIL, { [] { return DodongosCavernClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp index ff2fb885c..107028872 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_fire_temple.cpp @@ -420,5 +420,6 @@ void AreaTable_Init_FireTemple() { { // Exits Entrance(FIRE_TEMPLE_BOSS_ENTRYWAY, { [] { return false; } }), + Entrance(DMC_CENTRAL_LOCAL, { [] { return FireTempleClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp index fea9fda6f..16798906e 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_forest_temple.cpp @@ -172,7 +172,7 @@ void AreaTable_Init_ForestTemple() { Entrance(FOREST_TEMPLE_WEST_CORRIDOR, {[]{return true;}}), Entrance(FOREST_TEMPLE_NW_OUTDOORS_UPPER, {[]{return CanUse(HOVER_BOOTS) || (LogicForestOutsideBackdoor && CanJumpslash && GoronBracelet);}}), Entrance(FOREST_TEMPLE_NW_CORRIDOR_TWISTED, {[]{return IsAdult && GoronBracelet && SmallKeys(FOREST_TEMPLE, 2);}}), - Entrance(FOREST_TEMPLE_NW_CORRIDOR_STRAIGHTENED, {[]{return (CanUse(BOW) || CanUse(SLINGSHOT)) && GoronBracelet && SmallKeys(FOREST_TEMPLE, 2);}}), + Entrance(FOREST_TEMPLE_NW_CORRIDOR_STRAIGHTENED, {[]{return IsAdult && (CanUse(BOW) || CanUse(SLINGSHOT)) && GoronBracelet && SmallKeys(FOREST_TEMPLE, 2);}}), }); areaTable[FOREST_TEMPLE_NW_CORRIDOR_TWISTED] = Area("Forest Temple NW Corridor Twisted", "Forest Temple", FOREST_TEMPLE, NO_DAY_NIGHT_CYCLE, {}, {}, { @@ -433,5 +433,6 @@ void AreaTable_Init_ForestTemple() { { // Exits Entrance(FOREST_TEMPLE_BOSS_ENTRYWAY, { [] { return false; } }), + Entrance(SACRED_FOREST_MEADOW, { [] { return ForestTempleClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp index 108b69ccc..c8e38bb61 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_jabujabus_belly.cpp @@ -179,17 +179,17 @@ void AreaTable_Init_JabuJabusBelly() { //Locations LocationAccess(JABU_JABUS_BELLY_MQ_SECOND_ROOM_LOWER_CHEST, {[]{return true;}}), LocationAccess(JABU_JABUS_BELLY_MQ_SECOND_ROOM_UPPER_CHEST, {[]{return (IsAdult && (CanUse(HOVER_BOOTS) || CanUse(HOOKSHOT))) || ChildCanAccess(JABU_JABUS_BELLY_MQ_BOSS_AREA);}}), - LocationAccess(JABU_JABUS_BELLY_MQ_COMPASS_CHEST, {[]{return true;}}), - LocationAccess(JABU_JABUS_BELLY_MQ_BASEMENT_NEAR_VINES_CHEST, {[]{return true;}}), - LocationAccess(JABU_JABUS_BELLY_MQ_BASEMENT_NEAR_SWITCHES_CHEST, {[]{return true;}}), + LocationAccess(JABU_JABUS_BELLY_MQ_COMPASS_CHEST, {[]{return (IsChild || CanDive || CanUse(IRON_BOOTS) || LogicJabuAlcoveJumpDive) && (CanUse(SLINGSHOT) || CanUse(BOW) || CanUse(HOOKSHOT) || HasBombchus || (LogicJabuMQRangJump && CanUse(BOOMERANG)));}}), + LocationAccess(JABU_JABUS_BELLY_MQ_BASEMENT_NEAR_VINES_CHEST, {[]{return CanUse(SLINGSHOT);}}), + LocationAccess(JABU_JABUS_BELLY_MQ_BASEMENT_NEAR_SWITCHES_CHEST, {[]{return CanUse(SLINGSHOT);}}), LocationAccess(JABU_JABUS_BELLY_MQ_BOOMERANG_ROOM_SMALL_CHEST, {[]{return true;}}), - LocationAccess(JABU_JABUS_BELLY_MQ_BOOMERANG_CHEST, {[]{return true;}}), + LocationAccess(JABU_JABUS_BELLY_MQ_BOOMERANG_CHEST, {[]{return CanUse(KOKIRI_SWORD) || CanUse(MASTER_SWORD) || CanUse(BIGGORON_SWORD) || CanUse(MEGATON_HAMMER) || CanUse(SLINGSHOT) || CanUse(BOW) || CanUse(STICKS) || Bombs;}}), LocationAccess(JABU_JABUS_BELLY_MQ_GS_BOOMERANG_CHEST_ROOM, {[]{return CanPlay(SongOfTime) || (LogicJabuMQSoTGS && IsChild && CanUse(BOOMERANG));}}), //Trick: CanPlay(SongOfTime) || (LogicJabuMQSoTGS && IsChild && CanUse(BOOMERANG)) }, { //Exits Entrance(JABU_JABUS_BELLY_MQ_BEGINNING, {[]{return true;}}), - Entrance(JABU_JABUS_BELLY_MQ_DEPTHS, {[]{return HasExplosives && IsChild && CanUse(BOOMERANG);}}), + Entrance(JABU_JABUS_BELLY_MQ_DEPTHS, {[]{return HasExplosives && CanUse(SLINGSHOT) && CanUse(BOOMERANG);}}), }); areaTable[JABU_JABUS_BELLY_MQ_DEPTHS] = Area("Jabu Jabus Belly MQ Depths", "Jabu Jabus Belly", JABU_JABUS_BELLY, NO_DAY_NIGHT_CYCLE, {}, { @@ -209,8 +209,8 @@ void AreaTable_Init_JabuJabusBelly() { }, { //Locations LocationAccess(JABU_JABUS_BELLY_MQ_COW, {[]{return CanPlay(EponasSong);}}), - LocationAccess(JABU_JABUS_BELLY_MQ_NEAR_BOSS_CHEST, {[]{return true;}}), - LocationAccess(JABU_JABUS_BELLY_MQ_GS_NEAR_BOSS, {[]{return true;}}), + LocationAccess(JABU_JABUS_BELLY_MQ_NEAR_BOSS_CHEST, {[]{return CanUse(SLINGSHOT);}}), + LocationAccess(JABU_JABUS_BELLY_MQ_GS_NEAR_BOSS, {[]{return CanUse(BOOMERANG) || (LogicJabuNearBossRanged && CanUse(HOOKSHOT));}}), }, { //Exits Entrance(JABU_JABUS_BELLY_MQ_MAIN, {[]{return true;}}), @@ -245,5 +245,6 @@ void AreaTable_Init_JabuJabusBelly() { { // Exits Entrance(JABU_JABUS_BELLY_BOSS_ENTRYWAY, { [] { return false; } }), + Entrance(ZORAS_FOUNTAIN, { [] { return JabuJabusBellyClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp index a3dda7521..61778d563 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_shadow_temple.cpp @@ -209,5 +209,6 @@ void AreaTable_Init_ShadowTemple() { { // Exits Entrance(SHADOW_TEMPLE_BOSS_ENTRYWAY, { [] { return false; } }), + Entrance(GRAVEYARD_WARP_PAD_REGION, { [] { return ShadowTempleClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp index 2aa0c0516..f676c3c91 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_spirit_temple.cpp @@ -271,5 +271,6 @@ void AreaTable_Init_SpiritTemple() { { // Exits Entrance(SPIRIT_TEMPLE_BOSS_ENTRYWAY, { [] { return false; } }), + Entrance(DESERT_COLOSSUS, { [] { return SpiritTempleClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp index 559b6c20c..f1c86abb0 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access/locacc_water_temple.cpp @@ -331,5 +331,6 @@ void AreaTable_Init_WaterTemple() { { // Exits Entrance(WATER_TEMPLE_BOSS_ENTRYWAY, { [] { return false; } }), + Entrance(LAKE_HYLIA, { [] { return WaterTempleClear; } }), }); } diff --git a/soh/soh/Enhancements/randomizer/3drando/settings.cpp b/soh/soh/Enhancements/randomizer/3drando/settings.cpp index 684e3ec9a..5dcd5a792 100644 --- a/soh/soh/Enhancements/randomizer/3drando/settings.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/settings.cpp @@ -94,6 +94,7 @@ namespace Settings { Option ShuffleOverworldSpawns = Option::Bool("Overworld Spawns", {"Off", "On"}); Option MixedEntrancePools = Option::Bool("Mixed Entrance Pools", {"Off", "On"}); Option MixDungeons = Option::Bool("Mix Dungeons", {"Off", "On"}); + Option MixBosses = Option::Bool("Mix Bosses", {"Off", "On"}); Option MixOverworld = Option::Bool("Mix Overworld", {"Off", "On"}); Option MixInteriors = Option::Bool("Mix Interiors", {"Off", "On"}); Option MixGrottos = Option::Bool("Mix Grottos", {"Off", "On"}); @@ -135,6 +136,7 @@ namespace Settings { &ShuffleOverworldSpawns, &MixedEntrancePools, &MixDungeons, + &MixBosses, &MixOverworld, &MixInteriors, &MixGrottos, @@ -1298,6 +1300,7 @@ namespace Settings { ctx.shuffleOverworldSpawns = (ShuffleOverworldSpawns) ? 1 : 0; ctx.mixedEntrancePools = (MixedEntrancePools) ? 1 : 0; ctx.mixDungeons = (MixDungeons) ? 1 : 0; + ctx.mixBosses = (MixBosses) ? 1 : 0; ctx.mixOverworld = (MixOverworld) ? 1 : 0; ctx.mixInteriors = (MixInteriors) ? 1 : 0; ctx.mixGrottos = (MixGrottos) ? 1 : 0; @@ -1891,6 +1894,13 @@ namespace Settings { MixDungeons.SetSelectedIndex(OFF); } + if (ShuffleBossEntrances.Is(SHUFFLEBOSSES_FULL)) { + MixBosses.Unhide(); + } else { + MixBosses.Hide(); + MixBosses.SetSelectedIndex(OFF); + } + if (ShuffleOverworldEntrances) { MixOverworld.Unhide(); } else { @@ -1914,6 +1924,8 @@ namespace Settings { } else { MixDungeons.Hide(); MixDungeons.SetSelectedIndex(OFF); + MixBosses.Hide(); + MixBosses.SetSelectedIndex(OFF); MixOverworld.Hide(); MixOverworld.SetSelectedIndex(OFF); MixInteriors.Hide(); @@ -2190,6 +2202,7 @@ namespace Settings { if (!MixedEntrancePools) { MixDungeons.SetSelectedIndex(OFF); + MixBosses.SetSelectedIndex(OFF); MixOverworld.SetSelectedIndex(OFF); MixInteriors.SetSelectedIndex(OFF); MixGrottos.SetSelectedIndex(OFF); @@ -2344,6 +2357,7 @@ namespace Settings { ShuffleOverworldSpawns.SetSelectedIndex(cvarSettings[RSK_SHUFFLE_OVERWORLD_SPAWNS]); MixedEntrancePools.SetSelectedIndex(cvarSettings[RSK_MIXED_ENTRANCE_POOLS]); MixDungeons.SetSelectedIndex(cvarSettings[RSK_MIX_DUNGEON_ENTRANCES]); + MixBosses.SetSelectedIndex(cvarSettings[RSK_MIX_BOSS_ENTRANCES]); MixOverworld.SetSelectedIndex(cvarSettings[RSK_MIX_OVERWORLD_ENTRANCES]); MixInteriors.SetSelectedIndex(cvarSettings[RSK_MIX_INTERIOR_ENTRANCES]); MixGrottos.SetSelectedIndex(cvarSettings[RSK_MIX_GROTTO_ENTRANCES]); diff --git a/soh/soh/Enhancements/randomizer/3drando/settings.hpp b/soh/soh/Enhancements/randomizer/3drando/settings.hpp index 12e6443a4..17ea1f0ee 100644 --- a/soh/soh/Enhancements/randomizer/3drando/settings.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/settings.hpp @@ -397,6 +397,7 @@ typedef struct { uint8_t shuffleOverworldSpawns; uint8_t mixedEntrancePools; uint8_t mixDungeons; + uint8_t mixBosses; uint8_t mixOverworld; uint8_t mixInteriors; uint8_t mixGrottos; @@ -784,6 +785,7 @@ void UpdateSettings(std::unordered_map cvarSettin extern Option ShuffleOverworldSpawns; extern Option MixedEntrancePools; extern Option MixDungeons; + extern Option MixBosses; extern Option MixOverworld; extern Option MixInteriors; extern Option MixGrottos; diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index 0011d3a70..ce885aec5 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -307,35 +307,36 @@ static void WriteLocation( static void WriteShuffledEntrance(std::string sphereString, Entrance* entrance) { int16_t originalIndex = entrance->GetIndex(); int16_t destinationIndex = -1; - int16_t originalBlueWarp = entrance->GetBlueWarp(); - int16_t replacementBlueWarp = -1; int16_t replacementIndex = entrance->GetReplacement()->GetIndex(); int16_t replacementDestinationIndex = -1; std::string name = entrance->GetName(); std::string text = entrance->GetConnectedRegion()->regionName + " from " + entrance->GetReplacement()->GetParentRegion()->regionName; - if (entrance->GetReverse() != nullptr && !entrance->IsDecoupled()) { + // Track the reverse destination, useful for savewarp handling + if (entrance->GetReverse() != nullptr) { destinationIndex = entrance->GetReverse()->GetIndex(); - replacementDestinationIndex = entrance->GetReplacement()->GetReverse()->GetIndex(); - replacementBlueWarp = entrance->GetReplacement()->GetReverse()->GetBlueWarp(); + // When decouple is off we track the replacement's reverse destination, useful for recording visited entrances + if (!entrance->IsDecoupled()) { + replacementDestinationIndex = entrance->GetReplacement()->GetReverse()->GetIndex(); + } } json entranceJson = json::object({ + {"type", entrance->GetType()}, {"index", originalIndex}, {"destination", destinationIndex}, - {"blueWarp", originalBlueWarp}, {"override", replacementIndex}, {"overrideDestination", replacementDestinationIndex}, }); jsonData["entrances"].push_back(entranceJson); - // When decoupled entrances is off, handle saving reverse entrances with blue warps + // When decoupled entrances is off, handle saving reverse entrances if (entrance->GetReverse() != nullptr && !entrance->IsDecoupled()) { json reverseEntranceJson = json::object({ + {"type", entrance->GetReverse()->GetType()}, {"index", replacementDestinationIndex}, {"destination", replacementIndex}, - {"blueWarp", replacementBlueWarp}, {"override", destinationIndex}, {"overrideDestination", originalIndex}, }); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 984c20bb2..d642b597c 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -315,6 +315,7 @@ std::unordered_map SpoilerfileSettingNameToEn { "World Settings:Overworld Spawns", RSK_SHUFFLE_OVERWORLD_SPAWNS }, { "World Settings:Mixed Entrance Pools", RSK_MIXED_ENTRANCE_POOLS }, { "World Settings:Mix Dungeons", RSK_MIX_DUNGEON_ENTRANCES }, + { "World Settings:Mix Bosses", RSK_MIX_BOSS_ENTRANCES }, { "World Settings:Mix Overworld", RSK_MIX_OVERWORLD_ENTRANCES }, { "World Settings:Mix Interiors", RSK_MIX_INTERIOR_ENTRANCES }, { "World Settings:Mix Grottos", RSK_MIX_GROTTO_ENTRANCES }, @@ -548,13 +549,18 @@ void Randomizer::LoadMerchantMessages(const char* spoilerFileName) { "\x12\x38\x82" "Aufgeben! Ich verkaufe dir einen&%g{{item}}%w&für %r{{price}} Rubine%w!\x07\x10\xA3", "\x12\x38\x82" "J'abandonne! Tu veux bien m'acheter&un %g{{item}}%w?&Ça fera %r{{price}} Rubis%w!\x07\x10\xA3")); CustomMessageManager::Instance->CreateMessage( - Randomizer::merchantMessageTableID, TEXT_BEAN_SALESMAN, + Randomizer::merchantMessageTableID, TEXT_BEAN_SALESMAN_BUY_FOR_10, CustomMessage("I tried to be a %rmagic bean%w salesman,&but it turns out my marketing skills&weren't worth " "beans!^Anyway, want to buy my&%gmysterious item%w for 60 Rupees?\x1B&%gYes&No%w", "Möchten Sie einen geheimnisvollen&Gegenstand für 60 Rubine?\x1B&%gJa&Nein%w", "J'ai essayé d'être un vendeur de&%rharicots magiques%w, mais j'étais&mauvais au niveau du marketing et&ça " "me courait sur le haricot...^Enfin bref, ça te dirait de m'acheter un&" "%gobjet mystérieux%w pour 60 Rubis?\x1B&%gOui&Non%w")); + CustomMessageManager::Instance->CreateMessage( + Randomizer::merchantMessageTableID, TEXT_BEAN_SALESMAN_BUY_FOR_100, + CustomMessage("I never thought I'd say this, but I'm &selling the last %rMagic Bean%w. %r99%w Rupees...\x1B&%gYes&No%w", + "\x1B&%gJa&Nein%w", + "Je te vends mon dernier %rHaricot&magique%w pour %r99 Rubis%w.\x1B&%gAcheter&Ne pas acheter%w")); //Setup for merchant text boxes @@ -566,7 +572,7 @@ void Randomizer::LoadMerchantMessages(const char* spoilerFileName) { "Wie wäre es mit %g&{{item}}%w für %y200 Rubine?%w\x1B&%gJa!&Nein!%w", "Veux-tu acheter %g&{{item}}%w pour %y200 rubis?%w\x1B&%gOui&Non&w")); - //Granny Shopy + //Granny Shop //RANDOTODO: Implement obscure/ambiguous hints CustomMessageManager::Instance->CreateMessage( Randomizer::merchantMessageTableID, TEXT_GRANNYS_SHOP, @@ -899,6 +905,7 @@ void Randomizer::ParseRandomizerSettingsFile(const char* spoilerFileName) { case RSK_SHUFFLE_OVERWORLD_SPAWNS: case RSK_MIXED_ENTRANCE_POOLS: case RSK_MIX_DUNGEON_ENTRANCES: + case RSK_MIX_BOSS_ENTRANCES: case RSK_MIX_OVERWORLD_ENTRANCES: case RSK_MIX_INTERIOR_ENTRANCES: case RSK_MIX_GROTTO_ENTRANCES: @@ -1562,9 +1569,9 @@ void Randomizer::ParseEntranceDataFile(const char* spoilerFileName, bool silent) // set all the entrances to be 0 to indicate an unshuffled entrance for (auto &entranceOveride : gSaveContext.entranceOverrides) { + entranceOveride.type = 0; entranceOveride.index = 0; entranceOveride.destination = 0; - entranceOveride.blueWarp = 0; entranceOveride.override = 0; entranceOveride.overrideDestination = 0; } @@ -1579,12 +1586,12 @@ void Randomizer::ParseEntranceDataFile(const char* spoilerFileName, bool silent) json entranceJson = *it; for (auto entranceIt = entranceJson.begin(); entranceIt != entranceJson.end(); ++entranceIt) { - if (entranceIt.key() == "index") { + if (entranceIt.key() == "type") { + gSaveContext.entranceOverrides[i].type = entranceIt.value(); + } else if (entranceIt.key() == "index") { gSaveContext.entranceOverrides[i].index = entranceIt.value(); } else if (entranceIt.key() == "destination") { gSaveContext.entranceOverrides[i].destination = entranceIt.value(); - } else if (entranceIt.key() == "blueWarp") { - gSaveContext.entranceOverrides[i].blueWarp = entranceIt.value(); } else if (entranceIt.key() == "override") { gSaveContext.entranceOverrides[i].override = entranceIt.value(); } else if (entranceIt.key() == "overrideDestination") { @@ -3008,6 +3015,7 @@ void GenerateRandomizerImgui(std::string seed = "") { cvarSettings[RSK_SHUFFLE_OVERWORLD_SPAWNS] = CVarGetInteger("gRandomizeShuffleOverworldSpawns", RO_GENERIC_OFF); cvarSettings[RSK_MIXED_ENTRANCE_POOLS] = CVarGetInteger("gRandomizeMixedEntrances", RO_GENERIC_OFF); cvarSettings[RSK_MIX_DUNGEON_ENTRANCES] = CVarGetInteger("gRandomizeMixDungeons", RO_GENERIC_OFF); + cvarSettings[RSK_MIX_BOSS_ENTRANCES] = CVarGetInteger("gRandomizeMixBosses", RO_GENERIC_OFF); cvarSettings[RSK_MIX_OVERWORLD_ENTRANCES] = CVarGetInteger("gRandomizeMixOverworld", RO_GENERIC_OFF); cvarSettings[RSK_MIX_INTERIOR_ENTRANCES] = CVarGetInteger("gRandomizeMixInteriors", RO_GENERIC_OFF); cvarSettings[RSK_MIX_GROTTO_ENTRANCES] = CVarGetInteger("gRandomizeMixGrottos", RO_GENERIC_OFF); @@ -3706,7 +3714,8 @@ void RandomizerSettingsWindow::DrawElement() { // Mixed Entrance Pools UIWidgets::EnhancementCheckbox("Mixed Entrance Pools", "gRandomizeMixedEntrances"); UIWidgets::InsertHelpHoverText( - "Shuffle entrances into a mixed pool instead of separate ones.\n" + "Shuffle entrances into a mixed pool instead of separate ones. Has no affect on pools whose " + "entrances aren't shuffled, and \"Shuffle Boss Entrances\" must be set to \"Full\" to include them.\n" "\n" "For example, enabling the settings to shuffle grotto, dungeon, and overworld entrances and " "selecting grotto and dungeon entrances here will allow a dungeon to be inside a grotto or " @@ -3720,6 +3729,13 @@ void RandomizerSettingsWindow::DrawElement() { UIWidgets::EnhancementCheckbox("Mix Dungeons", "gRandomizeMixDungeons"); UIWidgets::InsertHelpHoverText("Dungeon entrances will be part of the mixed pool"); } + if (CVarGetInteger("gRandomizeShuffleBossEntrances", RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF) == + RO_BOSS_ROOM_ENTRANCE_SHUFFLE_FULL) { + UIWidgets::Spacer(0); + ImGui::SetCursorPosX(20); + UIWidgets::EnhancementCheckbox("Mix Bosses", "gRandomizeMixBosses"); + UIWidgets::InsertHelpHoverText("Boss entrances will be part of the mixed pool"); + } if (CVarGetInteger("gRandomizeShuffleOverworldEntrances", RO_GENERIC_OFF)) { UIWidgets::Spacer(0); ImGui::SetCursorPosX(20); @@ -4707,7 +4723,11 @@ void RandomizerSettingsWindow::DrawElement() { excludedLocationString += std::to_string(excludedLocationIt); excludedLocationString += ","; } - CVarSetString("gRandomizeExcludedLocations", excludedLocationString.c_str()); + if (excludedLocationString == "") { + CVarClear("gRandomizeExcludedLocations"); + } else { + CVarSetString("gRandomizeExcludedLocations", excludedLocationString.c_str()); + } LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); @@ -4893,7 +4913,7 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += std::to_string(enabledTrickIt); enabledTrickString += ","; } - CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str()); + CVarClear("gRandomizeEnabledTricks"); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } ImGui::SameLine(); @@ -5097,7 +5117,7 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += std::to_string(enabledTrickIt); enabledTrickString += ","; } - CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str()); + CVarClear("gRandomizeEnabledTricks"); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } @@ -5135,7 +5155,11 @@ void RandomizerSettingsWindow::DrawElement() { enabledTrickString += std::to_string(enabledTrickIt); enabledTrickString += ","; } - CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str()); + if (enabledTrickString == "") { + CVarClear("gRandomizeEnabledTricks"); + } else { + CVarSetString("gRandomizeEnabledTricks", enabledTrickString.c_str()); + } LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); } DrawTagChips(*rtObject.rtTags); @@ -5374,7 +5398,7 @@ CustomMessage Randomizer::GetSheikMessage(s16 scene, u16 originalTextId) { } CustomMessage Randomizer::GetSariaMessage(u16 originalTextId) { - if (originalTextId == TEXT_SARIA_SFM || (originalTextId >= TEXT_SARIAS_SONG_TEXT_START && originalTextId <= TEXT_SARIAS_SONG_TEXT_END)) { + if (originalTextId == TEXT_SARIA_SFM || (originalTextId >= TEXT_SARIAS_SONG_FACE_TO_FACE && originalTextId <= TEXT_SARIAS_SONG_CHANNELING_POWER)) { CustomMessage messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::hintMessageTableID, TEXT_SARIAS_SONG_FACE_TO_FACE); CustomMessage messageEntry2 = messageEntry; std::string code = originalTextId == TEXT_SARIA_SFM ? "" : "\x0B"; diff --git a/soh/soh/Enhancements/randomizer/randomizerTypes.h b/soh/soh/Enhancements/randomizer/randomizerTypes.h index ec0e69e81..0614795c2 100644 --- a/soh/soh/Enhancements/randomizer/randomizerTypes.h +++ b/soh/soh/Enhancements/randomizer/randomizerTypes.h @@ -1468,6 +1468,7 @@ typedef enum { RSK_SHUFFLE_OVERWORLD_SPAWNS, RSK_MIXED_ENTRANCE_POOLS, RSK_MIX_DUNGEON_ENTRANCES, + RSK_MIX_BOSS_ENTRANCES, RSK_MIX_OVERWORLD_ENTRANCES, RSK_MIX_INTERIOR_ENTRANCES, RSK_MIX_GROTTO_ENTRANCES, diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index a50a28762..81415f407 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -762,7 +762,6 @@ void InitTrackerData(bool isDebug) { } } UpdateAllOrdering(); - UpdateInventoryChecks(); } void SaveTrackerData(SaveContext* saveContext, int sectionID, bool gameSave) { diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance.c b/soh/soh/Enhancements/randomizer/randomizer_entrance.c index ee65d99e4..65606d5d9 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance.c +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance.c @@ -39,17 +39,12 @@ s16 dynamicExitList[] = { // Owl Flights : 0x492064 and 0x492080 static s16 entranceOverrideTable[ENTRANCE_TABLE_SIZE] = {0}; -// Boss scenes (normalize boss scene range to 0 on lookup) to the replaced dungeon scene it is connected to -static s16 dungeonBossSceneOverrides[SHUFFLEABLE_BOSS_COUNT] = {0}; +// Boss scenes (normalize boss scene range to 0 on lookup) mapped to save/death warp entrance +static s16 bossSceneSaveDeathWarps[SHUFFLEABLE_BOSS_COUNT] = {0}; static ActorEntry modifiedLinkActorEntry = {0}; EntranceInfo originalEntranceTable[ENTRANCE_TABLE_SIZE] = {0}; -typedef struct { - s16 blueWarp; - s16 destination; -} BlueWarpReplacement; - typedef struct { s16 entryway; s16 exit; @@ -61,40 +56,25 @@ typedef struct { } DungeonEntranceInfo; static DungeonEntranceInfo dungeons[] = { - //entryway exit, boss, reverse, bluewarp, dungeon scene, boss scene - { DEKU_TREE_ENTRANCE, ENTR_KOKIRI_FOREST_1, ENTR_DEKU_TREE_BOSS_0, ENTR_DEKU_TREE_1, ENTR_KOKIRI_FOREST_11, SCENE_DEKU_TREE, SCENE_DEKU_TREE_BOSS }, - { DODONGOS_CAVERN_ENTRANCE, ENTR_DEATH_MOUNTAIN_TRAIL_3, ENTR_DODONGOS_CAVERN_BOSS_0, ENTR_DODONGOS_CAVERN_1, ENTR_DEATH_MOUNTAIN_TRAIL_5, SCENE_DODONGOS_CAVERN, SCENE_DODONGOS_CAVERN_BOSS }, - { JABU_JABUS_BELLY_ENTRANCE, ENTR_ZORAS_FOUNTAIN_1, ENTR_JABU_JABU_BOSS_0, ENTR_JABU_JABU_1, ENTR_ZORAS_FOUNTAIN_0, SCENE_JABU_JABU, SCENE_JABU_JABU_BOSS }, - { FOREST_TEMPLE_ENTRANCE, ENTR_SACRED_FOREST_MEADOW_1, ENTR_FOREST_TEMPLE_BOSS_0, ENTR_FOREST_TEMPLE_1, ENTR_SACRED_FOREST_MEADOW_3, SCENE_FOREST_TEMPLE, SCENE_FOREST_TEMPLE_BOSS }, - { FIRE_TEMPLE_ENTRANCE, ENTR_DEATH_MOUNTAIN_CRATER_2, ENTR_FIRE_TEMPLE_BOSS_0, ENTR_FIRE_TEMPLE_1, ENTR_DEATH_MOUNTAIN_CRATER_5, SCENE_FIRE_TEMPLE, SCENE_FIRE_TEMPLE_BOSS }, - { WATER_TEMPLE_ENTRANCE, ENTR_LAKE_HYLIA_2, ENTR_WATER_TEMPLE_BOSS_0, ENTR_WATER_TEMPLE_1, ENTR_LAKE_HYLIA_9, SCENE_WATER_TEMPLE, SCENE_WATER_TEMPLE_BOSS }, - { SPIRIT_TEMPLE_ENTRANCE, ENTR_DESERT_COLOSSUS_1, ENTR_SPIRIT_TEMPLE_BOSS_0, ENTR_SPIRIT_TEMPLE_1, ENTR_DESERT_COLOSSUS_8, SCENE_SPIRIT_TEMPLE, SCENE_SPIRIT_TEMPLE_BOSS }, - { SHADOW_TEMPLE_ENTRANCE, ENTR_GRAVEYARD_1, ENTR_SHADOW_TEMPLE_BOSS_0, ENTR_SHADOW_TEMPLE_1, ENTR_GRAVEYARD_8, SCENE_SHADOW_TEMPLE, SCENE_SHADOW_TEMPLE_BOSS }, + //entryway exit, boss, reverse, bluewarp, dungeon scene, boss scene + { ENTR_DEKU_TREE_0, ENTR_KOKIRI_FOREST_1, ENTR_DEKU_TREE_BOSS_0, ENTR_DEKU_TREE_1, ENTR_KOKIRI_FOREST_11, SCENE_DEKU_TREE, SCENE_DEKU_TREE_BOSS }, + { ENTR_DODONGOS_CAVERN_0, ENTR_DEATH_MOUNTAIN_TRAIL_3, ENTR_DODONGOS_CAVERN_BOSS_0, ENTR_DODONGOS_CAVERN_1, ENTR_DEATH_MOUNTAIN_TRAIL_5, SCENE_DODONGOS_CAVERN, SCENE_DODONGOS_CAVERN_BOSS }, + { ENTR_JABU_JABU_0, ENTR_ZORAS_FOUNTAIN_1, ENTR_JABU_JABU_BOSS_0, ENTR_JABU_JABU_1, ENTR_ZORAS_FOUNTAIN_0, SCENE_JABU_JABU, SCENE_JABU_JABU_BOSS }, + { ENTR_FOREST_TEMPLE_0, ENTR_SACRED_FOREST_MEADOW_1, ENTR_FOREST_TEMPLE_BOSS_0, ENTR_FOREST_TEMPLE_1, ENTR_SACRED_FOREST_MEADOW_3, SCENE_FOREST_TEMPLE, SCENE_FOREST_TEMPLE_BOSS }, + { ENTR_FIRE_TEMPLE_0, ENTR_DEATH_MOUNTAIN_CRATER_2, ENTR_FIRE_TEMPLE_BOSS_0, ENTR_FIRE_TEMPLE_1, ENTR_DEATH_MOUNTAIN_CRATER_5, SCENE_FIRE_TEMPLE, SCENE_FIRE_TEMPLE_BOSS }, + { ENTR_WATER_TEMPLE_0, ENTR_LAKE_HYLIA_2, ENTR_WATER_TEMPLE_BOSS_0, ENTR_WATER_TEMPLE_1, ENTR_LAKE_HYLIA_9, SCENE_WATER_TEMPLE, SCENE_WATER_TEMPLE_BOSS }, + { ENTR_SPIRIT_TEMPLE_0, ENTR_DESERT_COLOSSUS_1, ENTR_SPIRIT_TEMPLE_BOSS_0, ENTR_SPIRIT_TEMPLE_1, ENTR_DESERT_COLOSSUS_8, SCENE_SPIRIT_TEMPLE, SCENE_SPIRIT_TEMPLE_BOSS }, + { ENTR_SHADOW_TEMPLE_0, ENTR_GRAVEYARD_1, ENTR_SHADOW_TEMPLE_BOSS_0, ENTR_SHADOW_TEMPLE_1, ENTR_GRAVEYARD_8, SCENE_SHADOW_TEMPLE, SCENE_SHADOW_TEMPLE_BOSS }, }; -//These variables store the new entrance indices for dungeons so that -//savewarping and game overs respawn players at the proper entrance. -//By default, these will be their vanilla values. -static s16 newDekuTreeEntrance = DEKU_TREE_ENTRANCE; -static s16 newDodongosCavernEntrance = DODONGOS_CAVERN_ENTRANCE; -static s16 newJabuJabusBellyEntrance = JABU_JABUS_BELLY_ENTRANCE; -static s16 newForestTempleEntrance = FOREST_TEMPLE_ENTRANCE; -static s16 newFireTempleEntrance = FIRE_TEMPLE_ENTRANCE; -static s16 newWaterTempleEntrance = WATER_TEMPLE_ENTRANCE; -static s16 newSpiritTempleEntrance = SPIRIT_TEMPLE_ENTRANCE; -static s16 newShadowTempleEntrance = SHADOW_TEMPLE_ENTRANCE; -static s16 newBottomOfTheWellEntrance = BOTTOM_OF_THE_WELL_ENTRANCE; -static s16 newGerudoTrainingGroundsEntrance = GERUDO_TRAINING_GROUNDS_ENTRANCE; -static s16 newIceCavernEntrance = ICE_CAVERN_ENTRANCE; - static s8 hasCopiedEntranceTable = 0; static s8 hasModifiedEntranceTable = 0; void Entrance_SetEntranceDiscovered(u16 entranceIndex, u8 isReversedEntrance); u8 Entrance_EntranceIsNull(EntranceOverride* entranceOverride) { - return entranceOverride->index == 0 && entranceOverride->destination == 0 && entranceOverride->blueWarp == 0 - && entranceOverride->override == 0 && entranceOverride->overrideDestination == 0; + return entranceOverride->index == 0 && entranceOverride->destination == 0 && entranceOverride->override == 0 && + entranceOverride->overrideDestination == 0; } static void Entrance_SeparateOGCFairyFountainExit(void) { @@ -113,6 +93,28 @@ static void Entrance_SeparateAdultSpawnAndPrelude() { } } +// Fix Adult dungeon blue warps as Child by assigning the child values for the warp pads +static void Entrance_ReplaceChildTempleWarps() { + if (Randomizer_GetSettingValue(RSK_SHUFFLE_DUNGEON_ENTRANCES) != RO_DUNGEON_ENTRANCE_SHUFFLE_OFF || + Randomizer_GetSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) != RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF) { + // Forest Temple + gEntranceTable[ENTR_SACRED_FOREST_MEADOW_3] = gEntranceTable[ENTR_SACRED_FOREST_MEADOW_2]; + gEntranceTable[ENTR_SACRED_FOREST_MEADOW_3_1] = gEntranceTable[ENTR_SACRED_FOREST_MEADOW_2_1]; + // Fire Temple + gEntranceTable[ENTR_DEATH_MOUNTAIN_CRATER_5] = gEntranceTable[ENTR_DEATH_MOUNTAIN_CRATER_4]; + gEntranceTable[ENTR_DEATH_MOUNTAIN_CRATER_5_1] = gEntranceTable[ENTR_DEATH_MOUNTAIN_CRATER_4_1]; + // Water Temple + gEntranceTable[ENTR_LAKE_HYLIA_9] = gEntranceTable[ENTR_LAKE_HYLIA_8]; + gEntranceTable[ENTR_LAKE_HYLIA_9_1] = gEntranceTable[ENTR_LAKE_HYLIA_8_1]; + // Shadow Temple + gEntranceTable[ENTR_GRAVEYARD_8] = gEntranceTable[ENTR_GRAVEYARD_7]; + gEntranceTable[ENTR_GRAVEYARD_8_1] = gEntranceTable[ENTR_GRAVEYARD_7_1]; + // Spirit Temple + gEntranceTable[ENTR_DESERT_COLOSSUS_8] = gEntranceTable[ENTR_DESERT_COLOSSUS_5]; + gEntranceTable[ENTR_DESERT_COLOSSUS_8_1] = gEntranceTable[ENTR_DESERT_COLOSSUS_5_1]; + } +} + void Entrance_CopyOriginalEntranceTable(void) { if (!hasCopiedEntranceTable) { memcpy(originalEntranceTable, gEntranceTable, sizeof(EntranceInfo) * ENTRANCE_TABLE_SIZE); @@ -130,9 +132,6 @@ void Entrance_ResetEntranceTable(void) { void Entrance_Init(void) { s32 index; - size_t blueWarpRemapIdx = 0; - BlueWarpReplacement bluewarps[SHUFFLEABLE_BOSS_COUNT] = {0}; - Entrance_CopyOriginalEntranceTable(); // Skip Child Stealth if given by settings @@ -149,6 +148,7 @@ void Entrance_Init(void) { Entrance_SeparateOGCFairyFountainExit(); Entrance_SeparateAdultSpawnAndPrelude(); + Entrance_ReplaceChildTempleWarps(); // Initialize the entrance override table with each index leading to itself. An // index referring to itself means that the entrance is not currently shuffled. @@ -156,9 +156,9 @@ void Entrance_Init(void) { entranceOverrideTable[i] = i; } - // Initialize all boss rooms connected to their vanilla dungeon + // Initialize all boss room save/death warps with their vanilla dungeon entryway for (s16 i = 1; i < SHUFFLEABLE_BOSS_COUNT; i++) { - dungeonBossSceneOverrides[i] = i; + bossSceneSaveDeathWarps[i] = dungeons[i].entryway; } // Initialize the grotto exit and load lists @@ -172,9 +172,30 @@ void Entrance_Init(void) { } s16 originalIndex = gSaveContext.entranceOverrides[i].index; - s16 blueWarpIndex = gSaveContext.entranceOverrides[i].blueWarp; + s16 originalDestination = gSaveContext.entranceOverrides[i].destination; s16 overrideIndex = gSaveContext.entranceOverrides[i].override; + int16_t bossScene = -1; + int16_t saveWarpEntrance = originalDestination; // Default save warp to the original return entrance + + // Search for boss room overrides and look for the matching save/death warp value to use + // If the boss room is in a dungeon, use the dungeons entryway as the save warp + // Otherwise use the "exit" value for the entrance that lead to the boss room + for (int j = 0; j <= SHUFFLEABLE_BOSS_COUNT; j++) { + if (overrideIndex == dungeons[j].bossDoor) { + bossScene = dungeons[j].bossScene; + } + + if (index == dungeons[j].bossDoor) { + saveWarpEntrance = dungeons[j].entryway; + } + } + + // Found a boss scene and a valid save/death warp value + if (bossScene != -1 && saveWarpEntrance != -1) { + bossSceneSaveDeathWarps[bossScene - SCENE_DEKU_TREE_BOSS] = saveWarpEntrance; + } + //Overwrite grotto related indices if (originalIndex >= ENTRANCE_RANDO_GROTTO_EXIT_START) { Grotto_SetExitOverride(originalIndex, overrideIndex); @@ -189,36 +210,6 @@ void Entrance_Init(void) { // Overwrite the indices which we want to shuffle, leaving the rest as they are entranceOverrideTable[originalIndex] = overrideIndex; - if (blueWarpIndex != 0) { - // When boss shuffle is enabled, we need to know what dungeon the boss room is connected to for - // death/save warping, and for the blue warp - if (Randomizer_GetSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) != RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF) { - s16 bossScene = -1; - s16 replacedDungeonScene = -1; - s16 replacedDungeonExit = -1; - // Search for the boss scene and replaced blue warp exits - for (s16 j = 0; j <= SHUFFLEABLE_BOSS_COUNT; j++) { - if (blueWarpIndex == dungeons[j].blueWarp) { - bossScene = dungeons[j].bossScene; - } - if (overrideIndex == dungeons[j].bossDoorReverse) { - replacedDungeonScene = dungeons[j].scene; - replacedDungeonExit = dungeons[j].exit; - } - } - - // assign the boss scene override - if (bossScene != -1 && replacedDungeonScene != -1 && replacedDungeonExit != -1) { - dungeonBossSceneOverrides[bossScene - SCENE_DEKU_TREE_BOSS] = replacedDungeonScene; - bluewarps[blueWarpRemapIdx].blueWarp = blueWarpIndex; - bluewarps[blueWarpRemapIdx].destination = replacedDungeonExit; - blueWarpRemapIdx++; - } - } else { - entranceOverrideTable[blueWarpIndex] = overrideIndex; - } - } - //Override both land and water entrances for Hyrule Field -> ZR Front and vice versa if (originalIndex == ENTR_ZORAS_RIVER_0) { //Hyrule Field -> ZR Front land entrance entranceOverrideTable[ENTR_ZORAS_RIVER_3] = overrideIndex; @@ -227,14 +218,6 @@ void Entrance_Init(void) { } } - // If we have remapped blue warps from boss shuffle, handle setting those and grabbing the override for - // the replaced dungeons exit in the event that dungeon shuffle is also turned on - for (size_t i = 0; i < ARRAY_COUNT(bluewarps); i++) { - if (bluewarps[i].blueWarp != 0 && bluewarps[i].destination != 0) { - entranceOverrideTable[bluewarps[i].blueWarp] = Entrance_GetOverride(bluewarps[i].destination); - } - } - // Stop playing background music during shuffled entrance transitions // so that we don't get duplicated or overlapping music tracks if (Randomizer_GetSettingValue(RSK_SHUFFLE_OVERWORLD_ENTRANCES)) { @@ -328,40 +311,39 @@ void Entrance_SetGameOverEntrance(void) { s16 scene = gPlayState->sceneNum; - // When in a boss room and boss shuffle is on, get the connected dungeon's original boss room entrance - // then run the normal game over overrides on it + // When in a boss room and boss shuffle is on, use the boss scene to find the death warp entrance if (Randomizer_GetSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) != RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF && scene >= SCENE_DEKU_TREE_BOSS && scene <= SCENE_SHADOW_TEMPLE_BOSS) { - // Normalize boss scene range to 0 on lookup - scene = dungeonBossSceneOverrides[scene - SCENE_DEKU_TREE_BOSS]; - gSaveContext.entranceIndex = dungeons[scene].bossDoor; + // Normalize boss scene range to 0 on lookup and handle for grotto entrances + gSaveContext.entranceIndex = Grotto_OverrideSpecialEntrance(bossSceneSaveDeathWarps[scene - SCENE_DEKU_TREE_BOSS]); + return; } //Set the current entrance depending on which entrance the player last came through switch (gSaveContext.entranceIndex) { case ENTR_DEKU_TREE_BOSS_0 : //Deku Tree Boss Room - gSaveContext.entranceIndex = newDekuTreeEntrance; + gSaveContext.entranceIndex = ENTR_DEKU_TREE_0; return; case ENTR_DODONGOS_CAVERN_BOSS_0 : //Dodongos Cavern Boss Room - gSaveContext.entranceIndex = newDodongosCavernEntrance; + gSaveContext.entranceIndex = ENTR_DODONGOS_CAVERN_0; return; case ENTR_JABU_JABU_BOSS_0 : //Jabu Jabus Belly Boss Room - gSaveContext.entranceIndex = newJabuJabusBellyEntrance; + gSaveContext.entranceIndex = ENTR_JABU_JABU_0; return; case ENTR_FOREST_TEMPLE_BOSS_0 : //Forest Temple Boss Room - gSaveContext.entranceIndex = newForestTempleEntrance; + gSaveContext.entranceIndex = ENTR_FOREST_TEMPLE_0; return; case ENTR_FIRE_TEMPLE_BOSS_0 : //Fire Temple Boss Room - gSaveContext.entranceIndex = newFireTempleEntrance; + gSaveContext.entranceIndex = ENTR_FIRE_TEMPLE_0; return; case ENTR_WATER_TEMPLE_BOSS_0 : //Water Temple Boss Room - gSaveContext.entranceIndex = newWaterTempleEntrance; + gSaveContext.entranceIndex = ENTR_WATER_TEMPLE_0; return; case ENTR_SPIRIT_TEMPLE_BOSS_0 : //Spirit Temple Boss Room - gSaveContext.entranceIndex = newSpiritTempleEntrance; + gSaveContext.entranceIndex = ENTR_SPIRIT_TEMPLE_0; return; case ENTR_SHADOW_TEMPLE_BOSS_0 : //Shadow Temple Boss Room - gSaveContext.entranceIndex = newShadowTempleEntrance; + gSaveContext.entranceIndex = ENTR_SHADOW_TEMPLE_0; return; case ENTR_GANONDORF_BOSS_0 : //Ganondorf Boss Room gSaveContext.entranceIndex = ENTR_GANONS_TOWER_0; // Inside Ganon's Castle -> Ganon's Tower Climb @@ -374,46 +356,46 @@ void Entrance_SetSavewarpEntrance(void) { s16 scene = gSaveContext.savedSceneNum; - // When in a boss room and boss shuffle is on, use the boss scene override to remap to its - // connected dungeon and use that for the final entrance + // When in a boss room and boss shuffle is on, use the boss scene to find the savewarp entrance if (Randomizer_GetSettingValue(RSK_SHUFFLE_BOSS_ENTRANCES) != RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF && scene >= SCENE_DEKU_TREE_BOSS && scene <= SCENE_SHADOW_TEMPLE_BOSS) { - // Normalize boss scene range to 0 on lookup - scene = dungeonBossSceneOverrides[scene - SCENE_DEKU_TREE_BOSS]; + // Normalize boss scene range to 0 on lookup and handle for grotto entrances + gSaveContext.entranceIndex = Grotto_OverrideSpecialEntrance(bossSceneSaveDeathWarps[scene - SCENE_DEKU_TREE_BOSS]); + return; } if (scene == SCENE_DEKU_TREE || scene == SCENE_DEKU_TREE_BOSS) { - gSaveContext.entranceIndex = newDekuTreeEntrance; + gSaveContext.entranceIndex = ENTR_DEKU_TREE_0; } else if (scene == SCENE_DODONGOS_CAVERN || scene == SCENE_DODONGOS_CAVERN_BOSS) { - gSaveContext.entranceIndex = newDodongosCavernEntrance; + gSaveContext.entranceIndex = ENTR_DODONGOS_CAVERN_0; } else if (scene == SCENE_JABU_JABU || scene == SCENE_JABU_JABU_BOSS) { - gSaveContext.entranceIndex = newJabuJabusBellyEntrance; + gSaveContext.entranceIndex = ENTR_JABU_JABU_0; } else if (scene == SCENE_FOREST_TEMPLE || scene == SCENE_FOREST_TEMPLE_BOSS) { //Forest Temple Boss Room - gSaveContext.entranceIndex = newForestTempleEntrance; + gSaveContext.entranceIndex = ENTR_FOREST_TEMPLE_0; } else if (scene == SCENE_FIRE_TEMPLE || scene == SCENE_FIRE_TEMPLE_BOSS) { //Fire Temple Boss Room - gSaveContext.entranceIndex = newFireTempleEntrance; + gSaveContext.entranceIndex = ENTR_FIRE_TEMPLE_0; } else if (scene == SCENE_WATER_TEMPLE || scene == SCENE_WATER_TEMPLE_BOSS) { //Water Temple Boss Room - gSaveContext.entranceIndex = newWaterTempleEntrance; + gSaveContext.entranceIndex = ENTR_WATER_TEMPLE_0; } else if (scene == SCENE_SPIRIT_TEMPLE || scene == SCENE_SPIRIT_TEMPLE_BOSS) { //Spirit Temple Boss Room - gSaveContext.entranceIndex = newSpiritTempleEntrance; + gSaveContext.entranceIndex = ENTR_SPIRIT_TEMPLE_0; } else if (scene == SCENE_SHADOW_TEMPLE || scene == SCENE_SHADOW_TEMPLE_BOSS) { //Shadow Temple Boss Room - gSaveContext.entranceIndex = newShadowTempleEntrance; + gSaveContext.entranceIndex = ENTR_SHADOW_TEMPLE_0; } else if (scene == SCENE_BOTTOM_OF_THE_WELL) { // BOTW - gSaveContext.entranceIndex = newBottomOfTheWellEntrance; + gSaveContext.entranceIndex = ENTR_BOTTOM_OF_THE_WELL_0; } else if (scene == SCENE_GERUDO_TRAINING_GROUND) { // GTG - gSaveContext.entranceIndex = newGerudoTrainingGroundsEntrance; + gSaveContext.entranceIndex = ENTR_GERUDO_TRAINING_GROUND_0; } else if (scene == SCENE_ICE_CAVERN) { // Ice cavern - gSaveContext.entranceIndex = newIceCavernEntrance; + gSaveContext.entranceIndex = ENTR_ICE_CAVERN_0; } else if (scene == SCENE_INSIDE_GANONS_CASTLE) { - gSaveContext.entranceIndex = GANONS_CASTLE_ENTRANCE; + gSaveContext.entranceIndex = ENTR_INSIDE_GANONS_CASTLE_0; } else if (scene == SCENE_GANONS_TOWER || scene == SCENE_INSIDE_GANONS_CASTLE_COLLAPSE || scene == SCENE_GANONS_TOWER_COLLAPSE_INTERIOR || scene == SCENE_GANON_BOSS || scene == SCENE_GANONS_TOWER_COLLAPSE_EXTERIOR) { gSaveContext.entranceIndex = ENTR_GANONS_TOWER_0; // Inside Ganon's Castle -> Ganon's Tower Climb } else if (scene == SCENE_THIEVES_HIDEOUT) { // Theives hideout gSaveContext.entranceIndex = ENTR_THIEVES_HIDEOUT_0; // Gerudo Fortress -> Thieve's Hideout spawn 0 } else if (scene == SCENE_LINKS_HOUSE) { - gSaveContext.entranceIndex = Entrance_OverrideNextIndex(LINK_HOUSE_SAVEWARP_ENTRANCE); + gSaveContext.entranceIndex = Entrance_OverrideNextIndex(ENTR_LINKS_HOUSE_0); } else if (LINK_IS_CHILD) { - gSaveContext.entranceIndex = Entrance_OverrideNextIndex(LINK_HOUSE_SAVEWARP_ENTRANCE); // Child Overworld Spawn + gSaveContext.entranceIndex = Entrance_OverrideNextIndex(ENTR_LINKS_HOUSE_0); // Child Overworld Spawn } else { gSaveContext.entranceIndex = Entrance_OverrideNextIndex(ENTR_HYRULE_FIELD_10); // Adult Overworld Spawn (Normally 0x5F4 (ENTR_TEMPLE_OF_TIME_7), but 0x282 (ENTR_HYRULE_FIELD_10) has been repurposed to differentiate from Prelude which also uses 0x5F4) } @@ -494,7 +476,7 @@ void Entrance_OverrideBlueWarp(void) { void Entrance_OverrideCutsceneEntrance(u16 cutsceneCmd) { switch (cutsceneCmd) { case 24: // Dropping a fish for Jabu Jabu - gPlayState->nextEntranceIndex = Entrance_OverrideNextIndex(newJabuJabusBellyEntrance); + gPlayState->nextEntranceIndex = Entrance_OverrideNextIndex(ENTR_JABU_JABU_0); gPlayState->transitionTrigger = TRANS_TRIGGER_START; gPlayState->transitionType = TRANS_TYPE_FADE_BLACK; // In case Jabu's mouth leads to a grotto return @@ -513,8 +495,8 @@ void Entrance_EnableFW(void) { gPlayState->sceneNum == SCENE_GANONS_TOWER_COLLAPSE_EXTERIOR || gPlayState->sceneNum == SCENE_GROTTOS || gPlayState->sceneNum == SCENE_FISHING_POND || gPlayState->sceneNum == SCENE_GANON_BOSS || gSaveContext.eventInf[0] & 0x1 || // Ingo's Minigame state - player->stateFlags1 & 0x08A02000 || // Swimming, riding horse, Down A, hanging from a ledge - player->stateFlags2 & 0x00040000 // Blank A + player->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LADDER | PLAYER_STATE1_ON_HORSE | PLAYER_STATE1_IN_WATER) || // Swimming, riding horse, Down A, hanging from a ledge + player->stateFlags2 & PLAYER_STATE2_CRAWLING // Blank A // Shielding, spinning and getting skull tokens still disable buttons automatically ) { return; diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance.h b/soh/soh/Enhancements/randomizer/randomizer_entrance.h index 10a485a94..8d8d3a678 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance.h +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance.h @@ -8,20 +8,6 @@ #define ENTRANCE_TABLE_SIZE ENTR_MAX -#define DEKU_TREE_ENTRANCE ENTR_DEKU_TREE_0 -#define DODONGOS_CAVERN_ENTRANCE ENTR_DODONGOS_CAVERN_0 -#define JABU_JABUS_BELLY_ENTRANCE ENTR_JABU_JABU_0 -#define FOREST_TEMPLE_ENTRANCE ENTR_FOREST_TEMPLE_0 -#define FIRE_TEMPLE_ENTRANCE ENTR_FIRE_TEMPLE_0 -#define WATER_TEMPLE_ENTRANCE ENTR_WATER_TEMPLE_0 -#define SPIRIT_TEMPLE_ENTRANCE ENTR_SPIRIT_TEMPLE_0 -#define SHADOW_TEMPLE_ENTRANCE ENTR_SHADOW_TEMPLE_0 -#define BOTTOM_OF_THE_WELL_ENTRANCE ENTR_BOTTOM_OF_THE_WELL_0 -#define GERUDO_TRAINING_GROUNDS_ENTRANCE ENTR_GERUDO_TRAINING_GROUND_0 -#define ICE_CAVERN_ENTRANCE ENTR_ICE_CAVERN_0 -#define GANONS_CASTLE_ENTRANCE ENTR_INSIDE_GANONS_CASTLE_0 -#define LINK_HOUSE_SAVEWARP_ENTRANCE ENTR_LINKS_HOUSE_0 - #define ENTRANCE_RANDO_GROTTO_LOAD_START 0x0700 #define ENTRANCE_RANDO_GROTTO_EXIT_START 0x0800 #define MAX_ENTRANCE_RANDO_USED_INDEX 0x0820 @@ -66,7 +52,7 @@ typedef enum { #define ENTRANCE_RANDO_GROTTO_LOAD(index) ENTRANCE_RANDO_GROTTO_LOAD_START + index #define ENTRANCE_RANDO_GROTTO_EXIT(index) ENTRANCE_RANDO_GROTTO_EXIT_START + index -#define ENTRANCE_OVERRIDES_MAX_COUNT 259 // 11 one-way entrances + 124 two-way entrances (x2) +#define ENTRANCE_OVERRIDES_MAX_COUNT 267 // 19 one-way entrances + 124 two-way entrances (x2) #define SHUFFLEABLE_BOSS_COUNT 8 #define SAVEFILE_ENTRANCES_DISCOVERED_IDX_COUNT 66 // Max entrance rando index is 0x0820, (2080 / 32 == 65) + 1 @@ -79,9 +65,9 @@ typedef enum { (((startTransType) << ENTRANCE_INFO_START_TRANS_TYPE_SHIFT) & ENTRANCE_INFO_START_TRANS_TYPE_MASK)) typedef struct { + uint16_t type; int16_t index; int16_t destination; - int16_t blueWarp; int16_t override; int16_t overrideDestination; } EntranceOverride; diff --git a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp index c4af7dd6d..13669271f 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_entrance_tracker.cpp @@ -104,6 +104,7 @@ const EntranceData entranceData[] = { { ENTR_KOKIRI_FOREST_1, ENTR_DEKU_TREE_0, SINGLE_SCENE_INFO(SCENE_DEKU_TREE), "Deku Tree", "KF", ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_TYPE_DUNGEON, ""}, { ENTR_DEKU_TREE_BOSS_0, ENTR_DEKU_TREE_1, SINGLE_SCENE_INFO(SCENE_DEKU_TREE), "Deku Tree Boss Door", "Gohma", ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_TYPE_DUNGEON, "", 1}, { ENTR_DEKU_TREE_1, ENTR_DEKU_TREE_BOSS_0, SINGLE_SCENE_INFO(SCENE_DEKU_TREE_BOSS), "Gohma", "Deku Tree Boss Door", ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_TYPE_DUNGEON, "", 1}, + { ENTR_KOKIRI_FOREST_11, -1, SINGLE_SCENE_INFO(SCENE_DEKU_TREE_BOSS), "Gohma", "Deku Tree Blue Warp", ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_TYPE_ONE_WAY, "bw", 1}, // Lost Woods { ENTR_KOKIRI_FOREST_2, ENTR_LOST_WOODS_9, SINGLE_SCENE_INFO(SCENE_LOST_WOODS), "Lost Woods Bridge", "KF", ENTRANCE_GROUP_LOST_WOODS, ENTRANCE_GROUP_KOKIRI_FOREST, ENTRANCE_TYPE_OVERWORLD, "lw"}, @@ -131,6 +132,7 @@ const EntranceData entranceData[] = { { ENTR_SACRED_FOREST_MEADOW_1, ENTR_FOREST_TEMPLE_0, SINGLE_SCENE_INFO(SCENE_FOREST_TEMPLE), "Forest Temple", "SFM", ENTRANCE_GROUP_SFM, ENTRANCE_GROUP_SFM, ENTRANCE_TYPE_DUNGEON}, { ENTR_FOREST_TEMPLE_BOSS_0, ENTR_FOREST_TEMPLE_1, SINGLE_SCENE_INFO(SCENE_FOREST_TEMPLE), "Forest Temple Boss Door", "Phantom Ganon", ENTRANCE_GROUP_SFM, ENTRANCE_GROUP_SFM, ENTRANCE_TYPE_DUNGEON, "", 1}, { ENTR_FOREST_TEMPLE_1, ENTR_FOREST_TEMPLE_BOSS_0, SINGLE_SCENE_INFO(SCENE_FOREST_TEMPLE_BOSS), "Phantom Ganon", "Forest Temple Boss Door", ENTRANCE_GROUP_SFM, ENTRANCE_GROUP_SFM, ENTRANCE_TYPE_DUNGEON, "", 1}, + { ENTR_SACRED_FOREST_MEADOW_3, -1, SINGLE_SCENE_INFO(SCENE_FOREST_TEMPLE_BOSS), "Phantom Ganon", "Forest Temple Blue Warp", ENTRANCE_GROUP_SFM, ENTRANCE_GROUP_SFM, ENTRANCE_TYPE_ONE_WAY, "bw", 1}, // Kakariko Village { ENTR_HYRULE_FIELD_1, ENTR_KAKARIKO_VILLAGE_0, SINGLE_SCENE_INFO(SCENE_KAKARIKO_VILLAGE), "Kakariko", "Hyrule Field", ENTRANCE_GROUP_KAKARIKO, ENTRANCE_GROUP_HYRULE_FIELD, ENTRANCE_TYPE_OVERWORLD, "hf"}, @@ -179,6 +181,7 @@ const EntranceData entranceData[] = { { ENTR_GRAVEYARD_1, ENTR_SHADOW_TEMPLE_0, SINGLE_SCENE_INFO(SCENE_SHADOW_TEMPLE), "Shadow Temple", "Graveyard", ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_TYPE_DUNGEON}, { ENTR_SHADOW_TEMPLE_BOSS_0, ENTR_SHADOW_TEMPLE_1, SINGLE_SCENE_INFO(SCENE_SHADOW_TEMPLE), "Shadow Temple Boss Door", "Bongo-Bongo", ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_TYPE_DUNGEON, "", 1}, { ENTR_SHADOW_TEMPLE_1, ENTR_SHADOW_TEMPLE_BOSS_0, SINGLE_SCENE_INFO(SCENE_SHADOW_TEMPLE_BOSS), "Bongo-Bongo", "Shadow Temple Boss Door", ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_TYPE_DUNGEON, "", 1}, + { ENTR_GRAVEYARD_8, -1, SINGLE_SCENE_INFO(SCENE_SHADOW_TEMPLE_BOSS), "Bongo-Bongo", "Shadow Temple Blue Warp", ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_GROUP_GRAVEYARD, ENTRANCE_TYPE_ONE_WAY, "bw", 1}, // Death Mountain Trail { ENTR_GORON_CITY_0, ENTR_DEATH_MOUNTAIN_TRAIL_1, SINGLE_SCENE_INFO(SCENE_DEATH_MOUNTAIN_TRAIL), "DMT", "Goron City", ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_GROUP_GORON_CITY, ENTRANCE_TYPE_OVERWORLD, "gc"}, @@ -194,6 +197,7 @@ const EntranceData entranceData[] = { { ENTR_DEATH_MOUNTAIN_TRAIL_3, ENTR_DODONGOS_CAVERN_0, SINGLE_SCENE_INFO(SCENE_DODONGOS_CAVERN), "Dodongo's Cavern", "DMT", ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_TYPE_DUNGEON, "dc"}, { ENTR_DODONGOS_CAVERN_BOSS_0, ENTR_DODONGOS_CAVERN_1, SINGLE_SCENE_INFO(SCENE_DODONGOS_CAVERN), "Dodongo's Cavern Boss Door", "King Dodongo", ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_TYPE_DUNGEON, "dc", 1}, { ENTR_DODONGOS_CAVERN_1, ENTR_DODONGOS_CAVERN_BOSS_0, SINGLE_SCENE_INFO(SCENE_DODONGOS_CAVERN_BOSS), "King Dodongo", "Dodongo's Cavern Boss Door", ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_TYPE_DUNGEON, "dc", 1}, + { ENTR_DEATH_MOUNTAIN_TRAIL_5, -1, SINGLE_SCENE_INFO(SCENE_DODONGOS_CAVERN_BOSS), "King Dodongo", "Dodongo's Cavern Blue Warp", ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_TYPE_ONE_WAY, "dc,bw", 1}, // Death Mountain Crater { ENTR_GORON_CITY_1, ENTR_DEATH_MOUNTAIN_CRATER_1, SINGLE_SCENE_INFO(SCENE_DEATH_MOUNTAIN_CRATER), "DMC", "Goron City", ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_GROUP_GORON_CITY, ENTRANCE_TYPE_OVERWORLD, "gc"}, @@ -208,6 +212,7 @@ const EntranceData entranceData[] = { { ENTR_DEATH_MOUNTAIN_CRATER_2, ENTR_FIRE_TEMPLE_0, SINGLE_SCENE_INFO(SCENE_FIRE_TEMPLE), "Fire Temple", "DMC", ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_TYPE_DUNGEON}, { ENTR_FIRE_TEMPLE_BOSS_0, ENTR_FIRE_TEMPLE_1, SINGLE_SCENE_INFO(SCENE_FIRE_TEMPLE), "Fire Temple Boss Door", "Volvagia", ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_TYPE_DUNGEON, "", 1}, { ENTR_FIRE_TEMPLE_1, ENTR_FIRE_TEMPLE_BOSS_0, SINGLE_SCENE_INFO(SCENE_FIRE_TEMPLE_BOSS), "Volvagia", "Fire Temple Boss Door", ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_TYPE_DUNGEON, "", 1}, + { ENTR_DEATH_MOUNTAIN_CRATER_5, -1, SINGLE_SCENE_INFO(SCENE_FIRE_TEMPLE_BOSS), "Volvagia", "Fire Temple Blue Warp", ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_GROUP_DEATH_MOUNTAIN_CRATER, ENTRANCE_TYPE_ONE_WAY, "bw", 1}, // Goron City { ENTR_DEATH_MOUNTAIN_TRAIL_1, ENTR_GORON_CITY_0, SINGLE_SCENE_INFO(SCENE_GORON_CITY), "Goron City", "DMT", ENTRANCE_GROUP_GORON_CITY, ENTRANCE_GROUP_DEATH_MOUNTAIN_TRAIL, ENTRANCE_TYPE_OVERWORLD, "gc"}, @@ -247,6 +252,7 @@ const EntranceData entranceData[] = { { ENTR_ZORAS_FOUNTAIN_1, ENTR_JABU_JABU_0, SINGLE_SCENE_INFO(SCENE_JABU_JABU), "Jabu Jabu's Belly", "ZF", ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_TYPE_DUNGEON}, { ENTR_JABU_JABU_BOSS_0, ENTR_JABU_JABU_1, SINGLE_SCENE_INFO(SCENE_JABU_JABU), "Jabu Jabu's Belly Boss Door", "Barinade", ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_TYPE_DUNGEON, "", 1}, { ENTR_JABU_JABU_1, ENTR_JABU_JABU_BOSS_0, SINGLE_SCENE_INFO(SCENE_JABU_JABU_BOSS), "Barinade", "Jabu Jabu's Belly Boss Door", ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_TYPE_DUNGEON, "", 1}, + { ENTR_ZORAS_FOUNTAIN_0, -1, SINGLE_SCENE_INFO(SCENE_JABU_JABU_BOSS), "Barinade", "Jabu Jabu's Belly Blue Warp", ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_TYPE_ONE_WAY, "bw", 1}, { ENTR_ZORAS_FOUNTAIN_3, ENTR_ICE_CAVERN_0, SINGLE_SCENE_INFO(SCENE_ICE_CAVERN), "Ice Cavern", "ZF", ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_GROUP_ZORAS_FOUNTAIN, ENTRANCE_TYPE_DUNGEON}, // Hyrule Field @@ -298,6 +304,7 @@ const EntranceData entranceData[] = { { ENTR_LAKE_HYLIA_2, ENTR_WATER_TEMPLE_0, SINGLE_SCENE_INFO(SCENE_WATER_TEMPLE), "Water Temple", "Lake Hylia", ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_TYPE_DUNGEON, "lh"}, { ENTR_WATER_TEMPLE_BOSS_0, ENTR_WATER_TEMPLE_1, SINGLE_SCENE_INFO(SCENE_WATER_TEMPLE), "Water Temple Boss Door", "Morpha", ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_TYPE_DUNGEON, "lh", 1}, { ENTR_WATER_TEMPLE_1, ENTR_WATER_TEMPLE_BOSS_0, SINGLE_SCENE_INFO(SCENE_WATER_TEMPLE_BOSS), "Morpha", "Water Temple Boss Door", ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_TYPE_DUNGEON, "lh", 1}, + { ENTR_LAKE_HYLIA_9, -1, SINGLE_SCENE_INFO(SCENE_WATER_TEMPLE_BOSS), "Morpha", "Water Temple Blue Warp", ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_GROUP_LAKE_HYLIA, ENTRANCE_TYPE_ONE_WAY, "lh,bw", 1}, // Gerudo Area { ENTR_HYRULE_FIELD_5, ENTR_GERUDO_VALLEY_0, SINGLE_SCENE_INFO(SCENE_GERUDO_VALLEY), "GV", "Hyrule Field", ENTRANCE_GROUP_GERUDO_VALLEY, ENTRANCE_GROUP_HYRULE_FIELD, ENTRANCE_TYPE_OVERWORLD, "hf"}, @@ -328,6 +335,7 @@ const EntranceData entranceData[] = { { ENTR_DESERT_COLOSSUS_1, ENTR_SPIRIT_TEMPLE_0, SINGLE_SCENE_INFO(SCENE_SPIRIT_TEMPLE), "Spirit Temple", "Desert Colossus", ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_TYPE_DUNGEON, "dc"}, { ENTR_SPIRIT_TEMPLE_BOSS_0, ENTR_SPIRIT_TEMPLE_1, SINGLE_SCENE_INFO(SCENE_SPIRIT_TEMPLE), "Spirit Temple Boss Door", "Twinrova", ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_TYPE_DUNGEON, "", 1}, { ENTR_SPIRIT_TEMPLE_1, ENTR_SPIRIT_TEMPLE_BOSS_0, SINGLE_SCENE_INFO(SCENE_SPIRIT_TEMPLE_BOSS), "Twinrova", "Spirit Temple Boss Door", ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_TYPE_DUNGEON, "", 1}, + { ENTR_DESERT_COLOSSUS_8, -1, SINGLE_SCENE_INFO(SCENE_SPIRIT_TEMPLE_BOSS), "Twinrova", "Spirit Temple Blue Warp", ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_GROUP_HAUNTED_WASTELAND, ENTRANCE_TYPE_ONE_WAY, "bw", 1}, // Market { ENTR_HYRULE_FIELD_7, ENTR_MARKET_ENTRANCE_DAY_1, {SCENE_NO_SPAWN(SCENE_MARKET_ENTRANCE_DAY), SCENE_NO_SPAWN(SCENE_MARKET_ENTRANCE_NIGHT), SCENE_NO_SPAWN(SCENE_MARKET_ENTRANCE_RUINS)}, "Market Entrance", "Hyrule Field", ENTRANCE_GROUP_MARKET, ENTRANCE_GROUP_HYRULE_FIELD, ENTRANCE_TYPE_OVERWORLD, "hf"}, @@ -797,6 +805,11 @@ void EntranceTrackerWindow::DrawElement() { continue; } + // RANDOTODO: Only show blue warps if bluewarp shuffle is on + if (original->metaTag.ends_with("bw") || override->metaTag.ends_with("bw")) { + continue; + } + bool isDiscovered = IsEntranceDiscovered(entrance.index); bool showOriginal = (!destToggle ? CVarGetInteger("gEntranceTrackerShowTo", 0) : CVarGetInteger("gEntranceTrackerShowFrom", 0)) || isDiscovered; diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index f158b4f3b..d6bccee69 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -30,6 +30,8 @@ void DrawBottle(ItemTrackerItem item); void DrawQuest(ItemTrackerItem item); void DrawSong(ItemTrackerItem item); +int itemTrackerSectionId; + bool shouldUpdateVectors = true; std::vector mainWindowItems = {}; @@ -282,11 +284,6 @@ void ItemTrackerOnFrame() { } } -void SaveNotes(uint32_t fileNum) { - CVarSetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), std::string(std::begin(itemTrackerNotes), std::end(itemTrackerNotes)).c_str()); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); -} - bool IsValidSaveFile() { bool validSave = gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2; return validSave; @@ -755,7 +752,7 @@ void DrawNotes(bool resizeable = false) { } if ((ImGui::IsItemDeactivatedAfterEdit() || (notesNeedSave && notesIdleFrames > notesMaxIdleFrames)) && IsValidSaveFile()) { notesNeedSave = false; - SaveNotes(gSaveContext.fileNum); + SaveManager::Instance->SaveSection(gSaveContext.fileNum, itemTrackerSectionId, true); } ImGui::EndGroup(); } @@ -980,6 +977,26 @@ void UpdateVectors() { shouldUpdateVectors = false; } +void ItemTrackerInitFile(bool isDebug) { + itemTrackerNotes.clear(); + itemTrackerNotes.push_back(0); +} + +void ItemTrackerSaveFile(SaveContext* saveContext, int sectionID, bool fullSave) { + SaveManager::Instance->SaveData("personalNotes", std::string(std::begin(itemTrackerNotes), std::end(itemTrackerNotes)).c_str()); +} + +void ItemTrackerLoadFile() { + std::string initialTrackerNotes = ""; + SaveManager::Instance->LoadData("personalNotes", initialTrackerNotes); + itemTrackerNotes.resize(initialTrackerNotes.length() + 1); + if (initialTrackerNotes != "") { + SohUtils::CopyStringToCharArray(itemTrackerNotes.Data, initialTrackerNotes.c_str(), itemTrackerNotes.size()); + } else { + itemTrackerNotes.push_back(0); + } +} + void ItemTrackerWindow::DrawElement() { UpdateVectors(); @@ -1249,14 +1266,9 @@ void ItemTrackerWindow::InitElement() { itemTrackerNotes.push_back(0); } - GameInteractor::Instance->RegisterGameHook([](uint32_t fileNum) { - const char* initialTrackerNotes = CVarGetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), ""); - itemTrackerNotes.resize(strlen(initialTrackerNotes) + 1); - strcpy(itemTrackerNotes.Data, initialTrackerNotes); - }); - GameInteractor::Instance->RegisterGameHook([](uint32_t fileNum) { - CVarSetString(("gItemTrackerNotes" + std::to_string(fileNum)).c_str(), ""); - LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); - }); + SaveManager::Instance->AddInitFunction(ItemTrackerInitFile); + itemTrackerSectionId = SaveManager::Instance->AddSaveFunction("itemTrackerData", 1, ItemTrackerSaveFile, true, -1); + SaveManager::Instance->AddLoadFunction("itemTrackerData", 1, ItemTrackerLoadFile); + GameInteractor::Instance->RegisterGameHook(ItemTrackerOnFrame); } diff --git a/soh/soh/Enhancements/tts/tts.cpp b/soh/soh/Enhancements/tts/tts.cpp index 1ed6eafa5..ff78fd0ab 100644 --- a/soh/soh/Enhancements/tts/tts.cpp +++ b/soh/soh/Enhancements/tts/tts.cpp @@ -168,7 +168,7 @@ void RegisterOnInterfaceUpdateHook() { prevTimer = timer; - if (!GameInteractor::IsSaveLoaded()) return; + if (!GameInteractor::IsSaveLoaded(true)) return; static int16_t lostHealth = 0; static int16_t prevHealth = 0; diff --git a/soh/soh/Extractor/Extract.cpp b/soh/soh/Extractor/Extract.cpp index d4b524474..b08783763 100644 --- a/soh/soh/Extractor/Extract.cpp +++ b/soh/soh/Extractor/Extract.cpp @@ -107,7 +107,8 @@ void Extractor::ShowSizeErrorBox() const { } void Extractor::ShowCrcErrorBox() const { - ShowErrorBox("Rom CRC invalid", "Rom CRC did not match the list of known good roms. Please find another."); + ShowErrorBox("Rom CRC invalid", "Rom CRC did not match the list of known compatible roms. Please find another.\n\n" + "Visit https://ship.equipment/ to validate your ROM and see a list of compatible versions"); } void Extractor::ShowCompressedErrorBox() const { @@ -479,7 +480,8 @@ bool Extractor::Run(std::string searchPath, RomSearchMode searchMode) { ShowCrcErrorBox(); } else { ShowErrorBox("Rom CRC invalid", - "Rom CRC did not match the list of known good roms. Trying the next one..."); + "Rom CRC did not match the list of known compatible roms. Trying the next one...\n\n" + "Visit https://ship.equipment/ to validate your ROM and see a list of compatible versions"); } continue; } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 68d3497fc..e1b3a41e2 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -92,6 +92,7 @@ GameInteractorSail* GameInteractorSail::Instance; #include // Resource Types/Factories +#include "soh/resource/type/SohResourceType.h" #include "soh/resource/type/Animation.h" #include "soh/resource/type/AudioSample.h" #include "soh/resource/type/AudioSequence.h" @@ -319,19 +320,24 @@ OTRGlobals::OTRGlobals() { SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Animation), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_PlayerAnimation), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Room), std::make_shared()); // Is room scene? maybe? - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_CollisionHeader), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Skeleton), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_SkeletonLimb), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Path), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Cutscene), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Text), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_AudioSample), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_AudioSoundFont), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_AudioSequence), std::make_shared()); - context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(static_cast(LUS::ResourceType::SOH_Background), std::make_shared()); + auto loader = context->GetResourceManager()->GetResourceLoader(); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Animation", static_cast(SOH::ResourceType::SOH_Animation), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "PlayerAnimation", static_cast(SOH::ResourceType::SOH_PlayerAnimation), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Room", static_cast(SOH::ResourceType::SOH_Room), 0); // Is room scene? maybe? + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "CollisionHeader", static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "CollisionHeader", static_cast(SOH::ResourceType::SOH_CollisionHeader), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Skeleton", static_cast(SOH::ResourceType::SOH_Skeleton), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Skeleton", static_cast(SOH::ResourceType::SOH_Skeleton), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "SkeletonLimb", static_cast(SOH::ResourceType::SOH_SkeletonLimb), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "SkeletonLimb", static_cast(SOH::ResourceType::SOH_SkeletonLimb), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Path", static_cast(SOH::ResourceType::SOH_Path), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Cutscene", static_cast(SOH::ResourceType::SOH_Cutscene), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Text", static_cast(SOH::ResourceType::SOH_Text), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_XML, "Text", static_cast(SOH::ResourceType::SOH_Text), 0); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSample", static_cast(SOH::ResourceType::SOH_AudioSample), 2); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSoundFont", static_cast(SOH::ResourceType::SOH_AudioSoundFont), 2); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "AudioSequence", static_cast(SOH::ResourceType::SOH_AudioSequence), 2); + loader->RegisterResourceFactory(std::make_shared(), RESOURCE_FORMAT_BINARY, "Background", static_cast(SOH::ResourceType::SOH_Background), 0); gSaveStateMgr = std::make_shared(); gRandomizer = std::make_shared(); @@ -534,7 +540,7 @@ extern "C" void VanillaItemTable_Init() { static GetItemEntry getItemTable[] = { GET_ITEM(ITEM_BOMBS_5, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BOMBS_5), GET_ITEM(ITEM_NUTS_5, OBJECT_GI_NUTS, GID_NUTS, 0x34, 0x0C, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_NUTS_5), - GET_ITEM(ITEM_BOMBCHU, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BOMBCHUS_10), + GET_ITEM(ITEM_BOMBCHU, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT, ITEM_CATEGORY_MAJOR, MOD_NONE, GI_BOMBCHUS_10), GET_ITEM(ITEM_BOW, OBJECT_GI_BOW, GID_BOW, 0x31, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_NONE, GI_BOW), GET_ITEM(ITEM_SLINGSHOT, OBJECT_GI_PACHINKO, GID_SLINGSHOT, 0x30, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_NONE, GI_SLINGSHOT), GET_ITEM(ITEM_BOOMERANG, OBJECT_GI_BOOMERANG, GID_BOOMERANG, 0x35, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_NONE, GI_BOOMERANG), @@ -637,8 +643,8 @@ extern "C" void VanillaItemTable_Init() { GET_ITEM(ITEM_BOMBS_20, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BOMBS_20), GET_ITEM(ITEM_BOMBS_30, OBJECT_GI_BOMB_1, GID_BOMB, 0x32, 0x59, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BOMBS_30), GET_ITEM(ITEM_SEEDS_30, OBJECT_GI_SEED, GID_SEEDS, 0xDC, 0x50, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_SEEDS_30), - GET_ITEM(ITEM_BOMBCHUS_5, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BOMBCHUS_5), - GET_ITEM(ITEM_BOMBCHUS_20, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BOMBCHUS_20), + GET_ITEM(ITEM_BOMBCHUS_5, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT, ITEM_CATEGORY_MAJOR, MOD_NONE, GI_BOMBCHUS_5), + GET_ITEM(ITEM_BOMBCHUS_20, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x33, 0x80, CHEST_ANIM_SHORT, ITEM_CATEGORY_MAJOR, MOD_NONE, GI_BOMBCHUS_20), GET_ITEM(ITEM_FISH, OBJECT_GI_FISH, GID_FISH, 0x47, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_JUNK, MOD_NONE, GI_FISH), GET_ITEM(ITEM_BUG, OBJECT_GI_INSECT, GID_BUG, 0x7A, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BUGS), GET_ITEM(ITEM_BLUE_FIRE, OBJECT_GI_FIRE, GID_BLUE_FIRE, 0x5D, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_JUNK, MOD_NONE, GI_BLUE_FIRE), @@ -1390,7 +1396,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { // Actually update the CVar now before runing the alt asset update listeners CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); gfx_texture_cache_clear(); - LUS::SkeletonPatcher::UpdateSkeletons(); + SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); } @@ -1618,7 +1624,7 @@ extern "C" uint8_t ResourceMgr_TexIsRaw(const char* texPath) { extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) { auto res = GetResourceByNameHandlingMQ(texPath); - return res->GetInitData()->Type == static_cast(LUS::ResourceType::SOH_Background); + return res->GetInitData()->Type == static_cast(SOH::ResourceType::SOH_Background); } extern "C" char* ResourceMgr_LoadJPEG(char* data, size_t dataSize) @@ -1689,7 +1695,7 @@ extern "C" Sprite* GetSeedTexture(uint8_t index) { } extern "C" char* ResourceMgr_LoadPlayerAnimByName(const char* animPath) { - auto anim = std::static_pointer_cast(GetResourceByNameHandlingMQ(animPath)); + auto anim = std::static_pointer_cast(GetResourceByNameHandlingMQ(animPath)); return (char*)&anim->limbRotData[0]; } @@ -1953,7 +1959,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel // Therefore we can take this oppurtunity to take note of the Skeleton that is created... if (skelAnime != nullptr) { auto stringPath = std::string(path); - LUS::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); + SOH::SkeletonPatcher::RegisterSkeleton(stringPath, skelAnime); } return skelHeader; @@ -1961,12 +1967,12 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel extern "C" void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime) { if (skelAnime != nullptr) - LUS::SkeletonPatcher::UnregisterSkeleton(skelAnime); + SOH::SkeletonPatcher::UnregisterSkeleton(skelAnime); } extern "C" void ResourceMgr_ClearSkeletons(SkelAnime* skelAnime) { if (skelAnime != nullptr) - LUS::SkeletonPatcher::ClearSkeletons(); + SOH::SkeletonPatcher::ClearSkeletons(); } extern "C" s32* ResourceMgr_LoadCSByName(const char* path) { @@ -2588,10 +2594,11 @@ extern "C" int CustomMessage_RetrieveIfExists(PlayState* play) { messageEntry = OTRGlobals::Instance->gRandomizer->GetGoronMessage(choice); } else if (Randomizer_GetSettingValue(RSK_FROGS_HINT) && textId == TEXT_FROGS_UNDERWATER) { messageEntry = OTRGlobals::Instance->gRandomizer->GetFrogsMessage(textId); - } else if (Randomizer_GetSettingValue(RSK_SARIA_HINT)) { - if ((gPlayState->sceneNum == SCENE_SACRED_FOREST_MEADOW && textId == TEXT_SARIA_SFM) || (textId >= TEXT_SARIAS_SONG_TEXT_START && textId <= TEXT_SARIAS_SONG_TEXT_END)) { - messageEntry = OTRGlobals::Instance->gRandomizer->GetSariaMessage(textId); - } + } else if (Randomizer_GetSettingValue(RSK_SARIA_HINT) && + (gPlayState->sceneNum == SCENE_SACRED_FOREST_MEADOW && textId == TEXT_SARIA_SFM) || (textId >= TEXT_SARIAS_SONG_FACE_TO_FACE && textId <= TEXT_SARIAS_SONG_CHANNELING_POWER)) { + messageEntry = OTRGlobals::Instance->gRandomizer->GetSariaMessage(textId); + } else if (textId == TEXT_BEAN_SALESMAN_BUY_FOR_100) { + messageEntry = CustomMessageManager::Instance->RetrieveMessage(Randomizer::merchantMessageTableID, TEXT_BEAN_SALESMAN_BUY_FOR_100); } } if (textId == TEXT_GS_NO_FREEZE || textId == TEXT_GS_FREEZE) { diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 451d34cf9..f7cd9ca46 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -184,9 +184,9 @@ void SaveManager::LoadRandomizerVersion2() { SaveManager::Instance->LoadArray("entrances", ARRAY_COUNT(gSaveContext.entranceOverrides), [&](size_t i) { SaveManager::Instance->LoadStruct("", [&]() { + SaveManager::Instance->LoadData("type", gSaveContext.entranceOverrides[i].type); SaveManager::Instance->LoadData("index", gSaveContext.entranceOverrides[i].index); SaveManager::Instance->LoadData("destination", gSaveContext.entranceOverrides[i].destination); - SaveManager::Instance->LoadData("blueWarp", gSaveContext.entranceOverrides[i].blueWarp); SaveManager::Instance->LoadData("override", gSaveContext.entranceOverrides[i].override); SaveManager::Instance->LoadData("overrideDestination", gSaveContext.entranceOverrides[i].overrideDestination); }); @@ -292,9 +292,9 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, int sectionID, bool f SaveManager::Instance->SaveArray("entrances", ARRAY_COUNT(saveContext->entranceOverrides), [&](size_t i) { SaveManager::Instance->SaveStruct("", [&]() { + SaveManager::Instance->SaveData("type", saveContext->entranceOverrides[i].type); SaveManager::Instance->SaveData("index", saveContext->entranceOverrides[i].index); SaveManager::Instance->SaveData("destination", saveContext->entranceOverrides[i].destination); - SaveManager::Instance->SaveData("blueWarp", saveContext->entranceOverrides[i].blueWarp); SaveManager::Instance->SaveData("override", saveContext->entranceOverrides[i].override); SaveManager::Instance->SaveData("overrideDestination", saveContext->entranceOverrides[i].overrideDestination); }); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 49f84068a..4cb43d3a8 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -41,6 +41,7 @@ #include "Enhancements/game-interactor/GameInteractor.h" #include "Enhancements/cosmetics/authenticGfxPatches.h" #include "Enhancements/resolution-editor/ResolutionEditor.h" +#include "Enhancements/debugger/MessageViewer.h" bool ToggleAltAssetsAtEndOfFrame = false; bool isBetaQuestEnabled = false; @@ -116,12 +117,15 @@ namespace SohGui { std::shared_ptr mInputEditorWindow; std::shared_ptr mAudioEditorWindow; + std::shared_ptr mInputViewer; + std::shared_ptr mInputViewerSettings; std::shared_ptr mCosmeticsEditorWindow; std::shared_ptr mActorViewerWindow; std::shared_ptr mColViewerWindow; std::shared_ptr mSaveEditorWindow; std::shared_ptr mDLViewerWindow; std::shared_ptr mValueViewerWindow; + std::shared_ptr mMessageViewerWindow; std::shared_ptr mGameplayStatsWindow; std::shared_ptr mCheckTrackerSettingsWindow; std::shared_ptr mCheckTrackerWindow; @@ -163,6 +167,10 @@ namespace SohGui { mAudioEditorWindow = std::make_shared("gAudioEditor.WindowOpen", "Audio Editor"); gui->AddGuiWindow(mAudioEditorWindow); + mInputViewer = std::make_shared("gOpenWindows.InputViewer", "Input Viewer"); + gui->AddGuiWindow(mInputViewer); + mInputViewerSettings = std::make_shared("gOpenWindows.InputViewerSettings", "Input Viewer Settings"); + gui->AddGuiWindow(mInputViewerSettings); mCosmeticsEditorWindow = std::make_shared("gCosmeticsEditorEnabled", "Cosmetics Editor"); gui->AddGuiWindow(mCosmeticsEditorWindow); mActorViewerWindow = std::make_shared("gActorViewerEnabled", "Actor Viewer"); @@ -175,6 +183,8 @@ namespace SohGui { gui->AddGuiWindow(mDLViewerWindow); mValueViewerWindow = std::make_shared("gValueViewer.WindowOpen", "Value Viewer"); gui->AddGuiWindow(mValueViewerWindow); + mMessageViewerWindow = std::make_shared("gMessageViewerEnabled", "Message Viewer"); + gui->AddGuiWindow(mMessageViewerWindow); mGameplayStatsWindow = std::make_shared("gGameplayStatsEnabled", "Gameplay Stats"); gui->AddGuiWindow(mGameplayStatsWindow); mCheckTrackerWindow = std::make_shared("gCheckTrackerEnabled", "Check Tracker"); @@ -204,6 +214,7 @@ namespace SohGui { mGameplayStatsWindow = nullptr; mDLViewerWindow = nullptr; mValueViewerWindow = nullptr; + mMessageViewerWindow = nullptr; mSaveEditorWindow = nullptr; mColViewerWindow = nullptr; mActorViewerWindow = nullptr; diff --git a/soh/soh/SohGui.hpp b/soh/soh/SohGui.hpp index 73a3addd4..0e1d970a8 100644 --- a/soh/soh/SohGui.hpp +++ b/soh/soh/SohGui.hpp @@ -11,6 +11,7 @@ #include #include "SohMenuBar.h" #include "Enhancements/audio/AudioEditor.h" +#include "Enhancements/controls/InputViewer.h" #include "Enhancements/cosmetics/CosmeticsEditor.h" #include "Enhancements/debugger/actorViewer.h" #include "Enhancements/debugger/colViewer.h" diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index f26aebd53..95dfc572e 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -21,6 +21,7 @@ #include "Enhancements/audio/AudioEditor.h" +#include "Enhancements/controls/InputViewer.h" #include "Enhancements/cosmetics/CosmeticsEditor.h" #include "Enhancements/debugger/actorViewer.h" #include "Enhancements/debugger/colViewer.h" @@ -28,6 +29,7 @@ #include "Enhancements/debugger/dlViewer.h" #include "Enhancements/debugger/valueViewer.h" #include "Enhancements/gameplaystatswindow.h" +#include "Enhancements/debugger/MessageViewer.h" #include "Enhancements/randomizer/randomizer_check_tracker.h" #include "Enhancements/randomizer/randomizer_entrance_tracker.h" #include "Enhancements/randomizer/randomizer_item_tracker.h" @@ -103,6 +105,7 @@ static const char* imguiScaleOptions[4] = { "Small", "Normal", "Large", "X-Large "OHKO" }; static const char* timeTravelOptions[3] = { "Disabled", "Ocarina of Time", "Any Ocarina" }; + static const char* swordToggleModes[3] = { "Disabled", "Child Toggle", "Both Ages (May lead to unintended behaviour)"}; extern "C" SaveContext gSaveContext; @@ -111,11 +114,11 @@ namespace SohGui { void DrawMenuBarIcon() { static bool gameIconLoaded = false; if (!gameIconLoaded) { - LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png"); + LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTextureFromRawImage("Game_Icon", "textures/icons/gIcon.png"); gameIconLoaded = true; } - if (LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) { + if (LUS::Context::GetInstance()->GetWindow()->GetGui()->HasTextureByName("Game_Icon")) { #ifdef __SWITCH__ ImVec2 iconSize = ImVec2(20.0f, 20.0f); float posScale = 1.0f; @@ -179,6 +182,8 @@ void DrawShipMenu() { } extern std::shared_ptr mInputEditorWindow; +extern std::shared_ptr mInputViewer; +extern std::shared_ptr mInputViewerSettings; extern std::shared_ptr mAdvancedResolutionSettingsWindow; void DrawSettingsMenu() { @@ -244,11 +249,25 @@ void DrawSettingsMenu() { #ifndef __SWITCH__ UIWidgets::EnhancementCheckbox("Menubar Controller Navigation", "gControlNav"); UIWidgets::Tooltip("Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: This will disable game inputs while the menubar is visible.\n\nD-pad to move between items, A to select, and X to grab focus on the menu bar"); + UIWidgets::PaddedSeparator(); #endif - UIWidgets::PaddedEnhancementCheckbox("Show Inputs", "gInputEnabled", true, false); - UIWidgets::Tooltip("Shows currently pressed inputs on the bottom right of the screen"); - UIWidgets::PaddedEnhancementSliderFloat("Input Scale: %.2f", "##Input", "gInputScale", 1.0f, 3.0f, "", 1.0f, false, true, true, false); - UIWidgets::Tooltip("Sets the on screen size of the displayed inputs from the Show Inputs setting"); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2 (12.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.0f, 0.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); + if (mInputViewer) { + if (ImGui::Button(GetWindowButtonText("Input Viewer", CVarGetInteger("gOpenWindows.InputViewer", 0)).c_str(), ImVec2 (-1.0f, 0.0f))) { + mInputViewer->ToggleVisibility(); + } + } + if (mInputViewerSettings) { + if (ImGui::Button(GetWindowButtonText("Input Viewer Settings", CVarGetInteger("gOpenWindows.InputViewerSettings", 0)).c_str(), ImVec2 (-1.0f, 0.0f))) { + mInputViewerSettings->ToggleVisibility(); + } + } + ImGui::PopStyleColor(1); + ImGui::PopStyleVar(3); + UIWidgets::PaddedEnhancementSliderInt("Simulated Input Lag: %d frames", "##SimulatedInputLag", "gSimulatedInputLag", 0, 6, "", 0, true, true, false); UIWidgets::Tooltip("Buffers your inputs to be executed a specified amount of frames later"); @@ -630,6 +649,8 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("The default response to Kaepora Gaebora is always that you understood what he said"); UIWidgets::PaddedEnhancementCheckbox("Exit Market at Night", "gMarketSneak", true, false); UIWidgets::Tooltip("Allows exiting Hyrule Castle Market Town to Hyrule Field at night by speaking to the guard next to the gate."); + UIWidgets::PaddedEnhancementCheckbox("Shops and Games Always Open", "gEnhancements.OpenAllHours", true, false); + UIWidgets::Tooltip("Shops and minigames are open both day and night. Requires scene reload to take effect."); UIWidgets::PaddedEnhancementCheckbox("Link as default file name", "gLinkDefaultName", true, false); UIWidgets::Tooltip("Allows you to have \"Link\" as a premade file name"); UIWidgets::PaddedEnhancementCheckbox("Quit Fishing At Door", "gQuitFishingAtDoor", true, false); @@ -644,6 +665,8 @@ void DrawEnhancementsMenu() { "- Obtained the Master Sword\n" "- Not within range of Time Block\n" "- Not within range of Ocarina playing spots"); + UIWidgets::PaddedEnhancementCheckbox("Pause Warp", "gPauseWarp", true, false); + UIWidgets::Tooltip("Selection of warp song in pause menu initiates warp. Disables song playback."); UIWidgets::PaddedEnhancementCheckbox("Skip water take breath animation", "gSkipSwimDeepEndAnim", true, false); UIWidgets::Tooltip("Skips Link's taking breath animation after coming up from water. This setting does not interfere with getting items from underwater."); UIWidgets::PaddedEnhancementCheckbox("Open Bank Account", "gBanker", true, false); @@ -942,9 +965,13 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("Bonking into trees will have a chance to drop up to 3 sticks. Must already have obtained sticks."); UIWidgets::PaddedEnhancementCheckbox("No Heart Drops", "gNoHeartDrops", true, false); UIWidgets::Tooltip("Disables heart drops, but not heart placements, like from a Deku Scrub running off\nThis simulates Hero Mode from other games in the series"); - UIWidgets::PaddedEnhancementCheckbox("Hyper Bosses", "gHyperBosses", true, false); + if (UIWidgets::PaddedEnhancementCheckbox("Hyper Bosses", "gHyperBosses", true, false)) { + UpdateHyperBossesState(); + } UIWidgets::Tooltip("All major bosses move and act twice as fast."); - UIWidgets::PaddedEnhancementCheckbox("Hyper Enemies", "gHyperEnemies", true, false); + if (UIWidgets::PaddedEnhancementCheckbox("Hyper Enemies", "gHyperEnemies", true, false)) { + UpdateHyperEnemiesState(); + } UIWidgets::Tooltip("All regular enemies and mini-bosses move and act twice as fast."); UIWidgets::PaddedEnhancementCheckbox("Always Win Goron Pot", "gGoronPot", true, false); UIWidgets::Tooltip("Always get the heart piece/purple rupee from the spinning Goron pot"); @@ -955,6 +982,8 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("All dogs can be traded in and will count as Richard."); UIWidgets::PaddedEnhancementSliderInt("Cuccos Stay Put Multiplier: %dx", "##CuccoStayDurationMultiplier", "gCuccoStayDurationMultiplier", 1, 5, "", 1, true, true, false); UIWidgets::Tooltip("Cuccos will stay in place longer after putting them down, by a multiple of the value of the slider."); + UIWidgets::PaddedEnhancementSliderInt("Leever Spawn Rate: %d seconds", "##LeeverSpawnRate", "gEnhancements.LeeverSpawnRate", 0, 10, "", 0, true, true, false); + UIWidgets::Tooltip("The time between leever groups spawning."); ImGui::EndMenu(); } @@ -971,6 +1000,8 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("Disables the voice audio when Navi calls you"); UIWidgets::PaddedEnhancementCheckbox("Disable Hot/Underwater Warning Text", "gDisableTunicWarningText", true, false); UIWidgets::Tooltip("Disables warning text when you don't have on the Goron/Zora Tunic in Hot/Underwater conditions."); + UIWidgets::PaddedEnhancementCheckbox("Remember Minimap State Between Areas", "gEnhancements.RememberMapToggleState"); + UIWidgets::Tooltip("Preserves the minimap visibility state when going between areas rather than defaulting it to \"on\" when going through loading zones."); ImGui::EndMenu(); } @@ -983,6 +1014,17 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("Allows equipping the tunic and boots to c-buttons"); UIWidgets::PaddedEnhancementCheckbox("Equipment Toggle", "gEquipmentCanBeRemoved", true, false); UIWidgets::Tooltip("Allows equipment to be removed by toggling it off on\nthe equipment subscreen."); + if (CVarGetInteger("gEquipmentCanBeRemoved", 0)) { + UIWidgets::PaddedText("Sword Toggle Options", true, false); + UIWidgets::EnhancementCombobox("gEnhancements.SwordToggle", swordToggleModes, SWORD_TOGGLE_NONE); + UIWidgets::Tooltip( + "Introduces Options for unequipping Link's sword\n\n" + "None: Only Biggoron's Sword/Giant's Knife can be toggled. Doing so will equip the Master Sword.\n\n" + "Child Toggle: This will allow for completely unequipping any sword as child link.\n\n" + "Both Ages: Any sword can be unequipped as either age. This may lead to swordless glitches as Adult.\n" + ); + } + UIWidgets::PaddedEnhancementCheckbox("Link's Cow in Both Time Periods", "gCowOfTime", true, false); UIWidgets::Tooltip("Allows the Lon Lon Ranch obstacle course reward to be shared across time periods"); UIWidgets::PaddedEnhancementCheckbox("Enable visible guard vision", "gGuardVision", true, false); @@ -1149,6 +1191,8 @@ void DrawEnhancementsMenu() { UIWidgets::Tooltip("Space between text characters (useful for HD font textures)"); UIWidgets::PaddedEnhancementCheckbox("More info in file select", "gFileSelectMoreInfo", true, false); UIWidgets::Tooltip("Shows what items you have collected in the file select screen, like in N64 randomizer"); + UIWidgets::PaddedEnhancementCheckbox("Better ammo rendering in pause menu", "gEnhancements.BetterAmmoRendering", true, false); + UIWidgets::Tooltip("Ammo counts in the pause menu will work correctly regardless of the position of items in the inventory"); ImGui::EndMenu(); } @@ -1215,6 +1259,11 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Fix Darunia dancing too fast", "gEnhancements.FixDaruniaDanceSpeed", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Fixes Darunia's dancing speed so he dances to the beat of Saria's Song, like in vanilla."); + UIWidgets::PaddedEnhancementCheckbox("Fix raised Floor Switches", "gEnhancements.FixFloorSwitches", true, false); + UIWidgets::Tooltip("Fixes the two raised floor switches, the one in Forest Temple Basement and the one at the top of Fire Temple. \n" + "This will lower them, making activating them easier"); + UIWidgets::PaddedEnhancementCheckbox("Fix Zora hint dialogue", "gFixZoraHintDialogue", true, false); + UIWidgets::Tooltip("Fixes one Zora's dialogue giving a hint about bringing Ruto's Letter to King Zora to properly occur before moving King Zora rather than after"); ImGui::EndMenu(); } @@ -1506,6 +1555,8 @@ void DrawCheatsMenu() { UIWidgets::Tooltip("This syncs the ingame time with the real world time"); UIWidgets::PaddedEnhancementCheckbox("No ReDead/Gibdo Freeze", "gNoRedeadFreeze", true, false); UIWidgets::Tooltip("Prevents ReDeads and Gibdos from being able to freeze you with their scream"); + UIWidgets::PaddedEnhancementCheckbox("Keese/Guay don't target you", "gNoKeeseGuayTarget", true, false); + UIWidgets::Tooltip("Keese and Guay no longer target you and simply ignore you as if you were wearing the skull mask"); { static int32_t betaQuestEnabled = CVarGetInteger("gEnableBetaQuest", 0); static int32_t lastBetaQuestEnabled = betaQuestEnabled; @@ -1582,6 +1633,7 @@ extern std::shared_ptr mColViewerWindow; extern std::shared_ptr mActorViewerWindow; extern std::shared_ptr mDLViewerWindow; extern std::shared_ptr mValueViewerWindow; +extern std::shared_ptr mMessageViewerWindow; void DrawDeveloperToolsMenu() { if (ImGui::BeginMenu("Developer Tools")) { @@ -1681,6 +1733,12 @@ void DrawDeveloperToolsMenu() { mValueViewerWindow->ToggleVisibility(); } } + UIWidgets::Spacer(0); + if (mMessageViewerWindow) { + if (ImGui::Button(GetWindowButtonText("Message Viewer", CVarGetInteger("gMessageViewerEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { + mMessageViewerWindow->ToggleVisibility(); + } + } ImGui::PopStyleVar(3); ImGui::PopStyleColor(1); @@ -1970,4 +2028,4 @@ void SohMenuBar::DrawElement() { ImGui::EndMenuBar(); } } -} // namespace SohGui +} // namespace SohGui diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 8de4e9e9d..4817e85fc 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -449,7 +449,7 @@ namespace UIWidgets { if (changed && !(abs(oldVal - val) < 0.000001f)) { std::stringstream ss; - ss << std::setprecision(ticks + 1) << val; + ss << std::setprecision(ticks + 1) << std::setiosflags(std::ios_base::fixed) << val; val = std::stof(ss.str()); CVarSetFloat(cvarName, val); LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); diff --git a/soh/soh/resource/importer/AnimationFactory.cpp b/soh/soh/resource/importer/AnimationFactory.cpp index c2aaf3067..8e1aca9b7 100644 --- a/soh/soh/resource/importer/AnimationFactory.cpp +++ b/soh/soh/resource/importer/AnimationFactory.cpp @@ -2,32 +2,14 @@ #include "soh/resource/type/Animation.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -AnimationFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Animation with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAnimationV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr animation = std::static_pointer_cast(resource); - - ResourceVersionFactory::ParseFileBinary(reader, animation); + auto animation = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); AnimationType animType = (AnimationType)reader->ReadUInt32(); animation->type = animType; @@ -100,5 +82,7 @@ void LUS::AnimationFactoryV0::ParseFileBinary(std::shared_ptr read } else if (animType == AnimationType::Legacy) { SPDLOG_DEBUG("BEYTAH ANIMATION?!"); } + + return animation; } -} // namespace LUS +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/importer/AnimationFactory.h b/soh/soh/resource/importer/AnimationFactory.h index dee2026f9..36dfceaae 100644 --- a/soh/soh/resource/importer/AnimationFactory.h +++ b/soh/soh/resource/importer/AnimationFactory.h @@ -1,17 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AnimationFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryAnimationV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AnimationFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSampleFactory.cpp b/soh/soh/resource/importer/AudioSampleFactory.cpp index 9d1477a51..b45e698e5 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.cpp +++ b/soh/soh/resource/importer/AudioSampleFactory.cpp @@ -2,33 +2,14 @@ #include "soh/resource/type/AudioSample.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -AudioSampleFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 2: - factory = std::make_shared(); - break; +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAudioSampleV2::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; } - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load AudioSample with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr audioSample = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSample); + auto audioSample = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); audioSample->sample.codec = reader->ReadUByte(); audioSample->sample.medium = reader->ReadUByte(); @@ -65,9 +46,10 @@ void LUS::AudioSampleFactoryV0::ParseFileBinary(std::shared_ptr re } audioSample->book.book = audioSample->bookData.data(); audioSample->sample.book = &audioSample->book; -} -} // namespace LUS + return audioSample; +} +} // namespace SOH /* in ResourceMgr_LoadAudioSample we used to have diff --git a/soh/soh/resource/importer/AudioSampleFactory.h b/soh/soh/resource/importer/AudioSampleFactory.h index 6e9ddc17c..2680ccdc2 100644 --- a/soh/soh/resource/importer/AudioSampleFactory.h +++ b/soh/soh/resource/importer/AudioSampleFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AudioSampleFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryAudioSampleV2 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AudioSampleFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSequenceFactory.cpp b/soh/soh/resource/importer/AudioSequenceFactory.cpp index a4862cb19..ba2a36697 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.cpp +++ b/soh/soh/resource/importer/AudioSequenceFactory.cpp @@ -2,33 +2,14 @@ #include "soh/resource/type/AudioSequence.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -AudioSequenceFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 2: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load AudioSequence with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAudioSequenceV2::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr audioSequence = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSequence); + auto audioSequence = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); audioSequence->sequence.seqDataSize = reader->ReadInt32(); audioSequence->sequenceData.reserve(audioSequence->sequence.seqDataSize); @@ -48,5 +29,7 @@ void LUS::AudioSequenceFactoryV0::ParseFileBinary(std::shared_ptr for (uint32_t i = 0; i < audioSequence->sequence.numFonts; i++) { audioSequence->sequence.fonts[i] = reader->ReadUByte(); } + + return audioSequence; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSequenceFactory.h b/soh/soh/resource/importer/AudioSequenceFactory.h index 12b3809aa..fb4391d61 100644 --- a/soh/soh/resource/importer/AudioSequenceFactory.h +++ b/soh/soh/resource/importer/AudioSequenceFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AudioSequenceFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryAudioSequenceV2 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AudioSequenceFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.cpp b/soh/soh/resource/importer/AudioSoundFontFactory.cpp index 5a94cb5f8..6d7efc58c 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.cpp +++ b/soh/soh/resource/importer/AudioSoundFontFactory.cpp @@ -3,33 +3,14 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr -AudioSoundFontFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 2: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load AudioSoundFont with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryAudioSoundFontV2::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr audioSoundFont = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, audioSoundFont); + auto audioSoundFont = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); audioSoundFont->soundFont.fntIndex = reader->ReadInt32(); audioSoundFont->medium = reader->ReadInt8(); @@ -186,5 +167,7 @@ void LUS::AudioSoundFontFactoryV0::ParseFileBinary(std::shared_ptr audioSoundFont->soundEffects.push_back(soundEffect); } audioSoundFont->soundFont.soundEffects = audioSoundFont->soundEffects.data(); + + return audioSoundFont; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/AudioSoundFontFactory.h b/soh/soh/resource/importer/AudioSoundFontFactory.h index 7dd5bc0d5..a63533db9 100644 --- a/soh/soh/resource/importer/AudioSoundFontFactory.h +++ b/soh/soh/resource/importer/AudioSoundFontFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class AudioSoundFontFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryAudioSoundFontV2 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class AudioSoundFontFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/BackgroundFactory.cpp b/soh/soh/resource/importer/BackgroundFactory.cpp index 5b09ce70f..07c47cbe9 100644 --- a/soh/soh/resource/importer/BackgroundFactory.cpp +++ b/soh/soh/resource/importer/BackgroundFactory.cpp @@ -2,31 +2,14 @@ #include "soh/resource/type/Background.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -BackgroundFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Background with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryBackgroundV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void BackgroundFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { - std::shared_ptr background = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, background); + auto background = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t dataSize = reader->ReadUInt32(); @@ -35,5 +18,7 @@ void BackgroundFactoryV0::ParseFileBinary(std::shared_ptr reader, for (uint32_t i = 0; i < dataSize; i++) { background->Data.push_back(reader->ReadUByte()); } + + return background; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/BackgroundFactory.h b/soh/soh/resource/importer/BackgroundFactory.h index 9767fdf8b..787ee509c 100644 --- a/soh/soh/resource/importer/BackgroundFactory.h +++ b/soh/soh/resource/importer/BackgroundFactory.h @@ -1,17 +1,11 @@ #pragma once #include "resource/Resource.h" -#include "resource/ResourceFactory.h" +#include "resource/ResourceFactoryBinary.h" -namespace LUS { -class BackgroundFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryBackgroundV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class BackgroundFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.cpp b/soh/soh/resource/importer/CollisionHeaderFactory.cpp index 9300efdf0..c5372f249 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/CollisionHeaderFactory.cpp @@ -2,54 +2,14 @@ #include "soh/resource/type/CollisionHeader.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -CollisionHeaderFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryCollisionHeaderV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -CollisionHeaderFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Collision Header with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileXML(reader, resource); - - return resource; -} - -void LUS::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr collisionHeader = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, collisionHeader); + auto collisionHeader = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); collisionHeader->collisionHeaderData.minBounds.x = reader->ReadInt16(); collisionHeader->collisionHeaderData.minBounds.y = reader->ReadInt16(); @@ -159,10 +119,19 @@ void LUS::CollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptrwaterBoxes.push_back(waterBox); } collisionHeader->collisionHeaderData.waterBoxes = collisionHeader->waterBoxes.data(); + + return collisionHeader; } -void LUS::CollisionHeaderFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) { - std::shared_ptr collisionHeader = std::static_pointer_cast(resource); +std::shared_ptr ResourceFactoryXMLCollisionHeaderV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto collisionHeader = std::make_shared(file->InitData); + + auto reader = std::get>(file->Reader)->FirstChildElement(); + auto child = reader->FirstChildElement(); collisionHeader->collisionHeaderData.minBounds.x = reader->IntAttribute("MinBoundsX"); collisionHeader->collisionHeaderData.minBounds.y = reader->IntAttribute("MinBoundsY"); @@ -178,8 +147,6 @@ void LUS::CollisionHeaderFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, s zero.z = 0; collisionHeader->camPosDataZero = zero; - auto child = reader->FirstChildElement(); - while (child != nullptr) { std::string childName = child->Name(); if (childName == "Vertex") { @@ -274,5 +241,7 @@ void LUS::CollisionHeaderFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, s collisionHeader->collisionHeaderData.cameraDataList = collisionHeader->camData.data(); collisionHeader->collisionHeaderData.cameraDataListLen = collisionHeader->camDataCount; collisionHeader->collisionHeaderData.waterBoxes = collisionHeader->waterBoxes.data(); + + return collisionHeader; } -} \ No newline at end of file +} // namespace SOH diff --git a/soh/soh/resource/importer/CollisionHeaderFactory.h b/soh/soh/resource/importer/CollisionHeaderFactory.h index e0276b38f..abd878909 100644 --- a/soh/soh/resource/importer/CollisionHeaderFactory.h +++ b/soh/soh/resource/importer/CollisionHeaderFactory.h @@ -1,20 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class CollisionHeaderFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryCollisionHeaderV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class CollisionHeaderFactoryV0 : public ResourceVersionFactory { +class ResourceFactoryXMLCollisionHeaderV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/CutsceneFactory.cpp b/soh/soh/resource/importer/CutsceneFactory.cpp index 27c747a6e..28f5e642b 100644 --- a/soh/soh/resource/importer/CutsceneFactory.cpp +++ b/soh/soh/resource/importer/CutsceneFactory.cpp @@ -2,36 +2,14 @@ #include "soh/resource/type/Cutscene.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -CutsceneFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Cutscene with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -static inline uint32_t read_CMD_BBBB(std::shared_ptr reader) { +static inline uint32_t read_CMD_BBBB(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); return v; } -static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { +static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); @@ -46,7 +24,7 @@ static inline uint32_t read_CMD_BBH(std::shared_ptr reader) { return v; } -static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { +static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); @@ -61,7 +39,7 @@ static inline uint32_t read_CMD_HBB(std::shared_ptr reader) { return v; } -static inline uint32_t read_CMD_HH(std::shared_ptr reader) { +static inline uint32_t read_CMD_HH(std::shared_ptr reader) { uint32_t v; reader->Read((char*)&v, sizeof(uint32_t)); @@ -79,11 +57,14 @@ static inline uint32_t read_CMD_HH(std::shared_ptr reader) { return v; } -void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr cutscene = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, cutscene); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryCutsceneV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto cutscene = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); cutscene->commands.reserve(numEntries); @@ -459,7 +440,7 @@ void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reade case 0xFFFFFFFF: // CS_END { cutscene->commands.push_back(reader->ReadUInt32()); - return; + return cutscene; } default: SPDLOG_TRACE("CutsceneV0: Unknown command {}\n", commandId); @@ -467,5 +448,7 @@ void LUS::CutsceneFactoryV0::ParseFileBinary(std::shared_ptr reade break; } } + + return cutscene; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/CutsceneFactory.h b/soh/soh/resource/importer/CutsceneFactory.h index a5813f6fe..8194615af 100644 --- a/soh/soh/resource/importer/CutsceneFactory.h +++ b/soh/soh/resource/importer/CutsceneFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class CutsceneFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryCutsceneV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class CutsceneFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/PathFactory.cpp b/soh/soh/resource/importer/PathFactory.cpp index bb4f87eb6..07fc86f40 100644 --- a/soh/soh/resource/importer/PathFactory.cpp +++ b/soh/soh/resource/importer/PathFactory.cpp @@ -2,32 +2,14 @@ #include "soh/resource/type/Path.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -PathFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; +namespace SOH { +std::shared_ptr ResourceFactoryBinaryPathV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; } - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Path with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr path = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, path); + auto path = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); path->numPaths = reader->ReadUInt32(); path->paths.reserve(path->numPaths); @@ -52,5 +34,7 @@ void LUS::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, path->pathData.push_back(pathDataEntry); } + + return path; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/PathFactory.h b/soh/soh/resource/importer/PathFactory.h index 3a8c0d595..aa8ae747c 100644 --- a/soh/soh/resource/importer/PathFactory.h +++ b/soh/soh/resource/importer/PathFactory.h @@ -1,19 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class PathFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryPathV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class PathFactoryV0 : public ResourceVersionFactory -{ - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.cpp b/soh/soh/resource/importer/PlayerAnimationFactory.cpp index ae9457669..4c25d5e80 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.cpp +++ b/soh/soh/resource/importer/PlayerAnimationFactory.cpp @@ -2,34 +2,14 @@ #include "soh/resource/type/PlayerAnimation.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -PlayerAnimationFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; +namespace SOH { +std::shared_ptr ResourceFactoryBinaryPlayerAnimationV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; } - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load PlayerAnimation with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr playerAnimation = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, playerAnimation); + auto playerAnimation = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t numEntries = reader->ReadUInt32(); playerAnimation->limbRotData.reserve(numEntries); @@ -37,5 +17,7 @@ void LUS::PlayerAnimationFactoryV0::ParseFileBinary(std::shared_ptrlimbRotData.push_back(reader->ReadInt16()); } -} -} // namespace LUS + + return playerAnimation; +}; +} // namespace SOH diff --git a/soh/soh/resource/importer/PlayerAnimationFactory.h b/soh/soh/resource/importer/PlayerAnimationFactory.h index b4981f7c6..8b459a38b 100644 --- a/soh/soh/resource/importer/PlayerAnimationFactory.h +++ b/soh/soh/resource/importer/PlayerAnimationFactory.h @@ -1,17 +1,11 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class PlayerAnimationFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinaryPlayerAnimationV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; - -class PlayerAnimationFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/SceneFactory.cpp b/soh/soh/resource/importer/SceneFactory.cpp index b71f78a2c..679d574cb 100644 --- a/soh/soh/resource/importer/SceneFactory.cpp +++ b/soh/soh/resource/importer/SceneFactory.cpp @@ -1,4 +1,5 @@ #include "spdlog/spdlog.h" +#include "soh/resource/type/SohResourceType.h" #include "soh/resource/importer/SceneFactory.h" #include "soh/resource/type/Scene.h" #include "soh/resource/type/scenecommand/SceneCommand.h" @@ -28,67 +29,36 @@ #include "soh/resource/importer/scenecommand/SetLightListFactory.h" #include "soh/resource/importer/scenecommand/SetMeshFactory.h" -namespace LUS { - -std::shared_ptr -SceneFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - if (SceneFactory::sceneCommandFactories.empty()) { - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightingSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetWind] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetExitList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTimeSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxModifier] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEchoSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSoundSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSkyboxSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomBehavior] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCsCamera] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCameraSettings] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetRoomList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCollisionHeader] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetEntranceList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetSpecialObjects] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetObjectList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetStartPositionList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetActorList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetTransitionActorList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::EndMarker] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetAlternateHeaders] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetPathways] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetCutscenes] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetLightList] = std::make_shared(); - SceneFactory::sceneCommandFactories[LUS::SceneCommandID::SetMesh] = std::make_shared(); - } - - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Scene with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; +namespace SOH { +ResourceFactoryBinarySceneV0::ResourceFactoryBinarySceneV0() { + sceneCommandFactories[SceneCommandID::SetLightingSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetWind] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetExitList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetTimeSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSkyboxModifier] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetEchoSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSoundSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSkyboxSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetRoomBehavior] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCsCamera] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCameraSettings] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetRoomList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCollisionHeader] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetEntranceList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetSpecialObjects] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetObjectList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetStartPositionList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetActorList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetTransitionActorList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::EndMarker] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetAlternateHeaders] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetPathways] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetCutscenes] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetLightList] = std::make_shared(); + sceneCommandFactories[SceneCommandID::SetMesh] = std::make_shared(); } -void SceneFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr scene = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, scene); - - ParseSceneCommands(scene, reader); -} - -void SceneFactoryV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { +void ResourceFactoryBinarySceneV0::ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader) { uint32_t commandCount = reader->ReadUInt32(); scene->commands.reserve(commandCount); @@ -97,19 +67,19 @@ void SceneFactoryV0::ParseSceneCommands(std::shared_ptr scene, std::share } } -std::shared_ptr SceneFactoryV0::ParseSceneCommand(std::shared_ptr scene, - std::shared_ptr reader, uint32_t index) { +std::shared_ptr ResourceFactoryBinarySceneV0::ParseSceneCommand(std::shared_ptr scene, + std::shared_ptr reader, uint32_t index) { SceneCommandID cmdID = (SceneCommandID)reader->ReadInt32(); - reader->Seek(-sizeof(int32_t), SeekOffsetType::Current); + reader->Seek(-sizeof(int32_t), LUS::SeekOffsetType::Current); std::shared_ptr result = nullptr; - std::shared_ptr commandFactory = SceneFactory::sceneCommandFactories[cmdID]; + auto commandFactory = ResourceFactoryBinarySceneV0::sceneCommandFactories[cmdID]; if (commandFactory != nullptr) { - auto initData = std::make_shared(); + auto initData = std::make_shared(); initData->Id = scene->GetInitData()->Id; - initData->Type = static_cast(ResourceType::SOH_SceneCommand); + initData->Type = static_cast(SOH::ResourceType::SOH_SceneCommand); initData->Path = scene->GetInitData()->Path + "/SceneCommand" + std::to_string(index); initData->ResourceVersion = scene->GetInitData()->ResourceVersion; result = std::static_pointer_cast(commandFactory->ReadResource(initData, reader)); @@ -123,4 +93,16 @@ std::shared_ptr SceneFactoryV0::ParseSceneCommand(std::shared_ptr return result; } -} // namespace LUS +std::shared_ptr ResourceFactoryBinarySceneV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto scene = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); + + ParseSceneCommands(scene, reader); + + return scene; +}; +} // namespace SOH diff --git a/soh/soh/resource/importer/SceneFactory.h b/soh/soh/resource/importer/SceneFactory.h index 59fe08ddf..5dfed2739 100644 --- a/soh/soh/resource/importer/SceneFactory.h +++ b/soh/soh/resource/importer/SceneFactory.h @@ -4,26 +4,22 @@ #include "soh/resource/type/scenecommand/SceneCommand.h" #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" -namespace LUS { -class SceneFactory : public ResourceFactory { +namespace SOH { +class ResourceFactoryBinarySceneV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + ResourceFactoryBinarySceneV0(); + + std::shared_ptr ReadResource(std::shared_ptr file) override; + void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); // Doing something very similar to what we do on the ResourceLoader. // Eventually, scene commands should be moved up to the ResourceLoader as well. // They can not right now because the exporter does not give them a proper resource type enum value, // and the exporter does not export the commands with a proper OTR header. - static inline std::unordered_map> sceneCommandFactories; -}; - -class SceneFactoryV0 : public ResourceVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseSceneCommands(std::shared_ptr scene, std::shared_ptr reader); + static inline std::unordered_map> sceneCommandFactories; protected: - std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); + std::shared_ptr ParseSceneCommand(std::shared_ptr scene, std::shared_ptr reader, uint32_t index); }; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonFactory.cpp b/soh/soh/resource/importer/SkeletonFactory.cpp index 2ce651dee..fedfda400 100644 --- a/soh/soh/resource/importer/SkeletonFactory.cpp +++ b/soh/soh/resource/importer/SkeletonFactory.cpp @@ -3,54 +3,14 @@ #include #include -namespace LUS { -std::shared_ptr -SkeletonFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -SkeletonFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinarySkeletonV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileXML(reader, resource); - - return resource; -} - -void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr skeleton = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, skeleton); + auto skeleton = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); skeleton->type = (SkeletonType)reader->ReadInt8(); skeleton->limbType = (LimbType)reader->ReadInt8(); @@ -66,17 +26,17 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, skeleton->limbTable.push_back(limbPath); } - if (skeleton->type == LUS::SkeletonType::Curve) { + if (skeleton->type == SkeletonType::Curve) { skeleton->skeletonData.skelCurveLimbList.limbCount = skeleton->limbCount; skeleton->curveLimbArray.reserve(skeleton->skeletonData.skelCurveLimbList.limbCount); - } else if (skeleton->type == LUS::SkeletonType::Flex) { + } else if (skeleton->type == SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.dListCount = skeleton->dListCount; } - if (skeleton->type == LUS::SkeletonType::Normal) { + if (skeleton->type == SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.limbCount = skeleton->limbCount; skeleton->standardLimbArray.reserve(skeleton->skeletonData.skeletonHeader.limbCount); - } else if (skeleton->type == LUS::SkeletonType::Flex) { + } else if (skeleton->type == SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.limbCount = skeleton->limbCount; skeleton->standardLimbArray.reserve(skeleton->skeletonData.flexSkeletonHeader.sh.limbCount); } @@ -87,21 +47,29 @@ void SkeletonFactoryV0::ParseFileBinary(std::shared_ptr reader, skeleton->skeletonHeaderSegments.push_back(limb ? limb->GetRawPointer() : nullptr); } - if (skeleton->type == LUS::SkeletonType::Normal) { + if (skeleton->type == SkeletonType::Normal) { skeleton->skeletonData.skeletonHeader.segment = (void**)skeleton->skeletonHeaderSegments.data(); - } else if (skeleton->type == LUS::SkeletonType::Flex) { + } else if (skeleton->type == SkeletonType::Flex) { skeleton->skeletonData.flexSkeletonHeader.sh.segment = (void**)skeleton->skeletonHeaderSegments.data(); - } else if (skeleton->type == LUS::SkeletonType::Curve) { + } else if (skeleton->type == SkeletonType::Curve) { skeleton->skeletonData.skelCurveLimbList.limbs = (SkelCurveLimb**)skeleton->skeletonHeaderSegments.data(); } else { SPDLOG_ERROR("unknown skeleton type {}", (uint32_t)skeleton->type); } skeleton->skeletonData.skeletonHeader.skeletonType = (uint8_t)skeleton->type; + + return skeleton; } -void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) -{ - std::shared_ptr skel = std::static_pointer_cast(resource); + +std::shared_ptr ResourceFactoryXMLSkeletonV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto skel = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader)->FirstChildElement(); + auto child = reader->FirstChildElement(); skel->type = SkeletonType::Flex; // Default to Flex for legacy reasons if (reader->FindAttribute("Type")) { @@ -137,8 +105,6 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p skel->limbCount = reader->IntAttribute("LimbCount"); skel->dListCount = reader->IntAttribute("DisplayListCount"); - auto child = reader->FirstChildElement(); - while (child != nullptr) { std::string childName = child->Name(); @@ -157,6 +123,7 @@ void SkeletonFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_p skel->skeletonData.flexSkeletonHeader.sh.segment = (void**)skel->skeletonHeaderSegments.data(); skel->skeletonData.flexSkeletonHeader.dListCount = skel->dListCount; skel->skeletonData.skeletonHeader.skeletonType = (uint8_t)skel->type; -} -} // namespace LUS + return skel; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonFactory.h b/soh/soh/resource/importer/SkeletonFactory.h index d64449393..5de02175f 100644 --- a/soh/soh/resource/importer/SkeletonFactory.h +++ b/soh/soh/resource/importer/SkeletonFactory.h @@ -1,23 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class SkeletonFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinarySkeletonV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class SkeletonFactoryV0 : public ResourceVersionFactory -{ +class ResourceFactoryXMLSkeletonV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS - +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.cpp b/soh/soh/resource/importer/SkeletonLimbFactory.cpp index 7ca8ae1cc..15ba92281 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.cpp +++ b/soh/soh/resource/importer/SkeletonLimbFactory.cpp @@ -3,54 +3,14 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr -SkeletonLimbFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -SkeletonLimbFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Skeleton Limb with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinarySkeletonLimbV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileXML(reader, resource); - - return resource; -} - -void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr skeletonLimb = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, skeletonLimb); + auto skeletonLimb = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); skeletonLimb->limbType = (LimbType)reader->ReadInt8(); skeletonLimb->skinSegmentType = (ZLimbSkinType)reader->ReadInt8(); @@ -124,7 +84,7 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->childIndex = reader->ReadUByte(); skeletonLimb->siblingIndex = reader->ReadUByte(); - if (skeletonLimb->limbType == LUS::LimbType::LOD) { + if (skeletonLimb->limbType == LimbType::LOD) { skeletonLimb->limbData.lodLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.lodLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.lodLimb.jointPos.z = skeletonLimb->transZ; @@ -144,7 +104,7 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r } else { skeletonLimb->limbData.lodLimb.dLists[1] = nullptr; } - } else if (skeletonLimb->limbType == LUS::LimbType::Standard) { + } else if (skeletonLimb->limbType == LimbType::Standard) { skeletonLimb->limbData.standardLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.standardLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.standardLimb.jointPos.z = skeletonLimb->transZ; @@ -156,7 +116,7 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->dListPtr = "__OTR__" + skeletonLimb->dListPtr; skeletonLimb->limbData.standardLimb.dList = (Gfx*)skeletonLimb->dListPtr.c_str(); } - } else if (skeletonLimb->limbType == LUS::LimbType::Curve) { + } else if (skeletonLimb->limbType == LimbType::Curve) { skeletonLimb->limbData.skelCurveLimb.firstChildIdx = skeletonLimb->childIndex; skeletonLimb->limbData.skelCurveLimb.nextLimbIdx = skeletonLimb->siblingIndex; skeletonLimb->limbData.skelCurveLimb.dList[0] = nullptr; @@ -171,31 +131,31 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->dList2Ptr = "__OTR__" + skeletonLimb->dList2Ptr; skeletonLimb->limbData.skelCurveLimb.dList[1] = (Gfx*)skeletonLimb->dList2Ptr.c_str(); } - } else if (skeletonLimb->limbType == LUS::LimbType::Skin) { + } else if (skeletonLimb->limbType == LimbType::Skin) { skeletonLimb->limbData.skinLimb.jointPos.x = skeletonLimb->transX; skeletonLimb->limbData.skinLimb.jointPos.y = skeletonLimb->transY; skeletonLimb->limbData.skinLimb.jointPos.z = skeletonLimb->transZ; skeletonLimb->limbData.skinLimb.child = skeletonLimb->childIndex; skeletonLimb->limbData.skinLimb.sibling = skeletonLimb->siblingIndex; - if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) { + if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_DList) { skeletonLimb->limbData.skinLimb.segmentType = static_cast(skeletonLimb->skinSegmentType); - } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) { + } else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_4) { skeletonLimb->limbData.skinLimb.segmentType = 4; - } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_5) { + } else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_5) { skeletonLimb->limbData.skinLimb.segmentType = 5; } else { skeletonLimb->limbData.skinLimb.segmentType = 0; } - if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_DList) { + if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_DList) { if (skeletonLimb->skinDList != "") { skeletonLimb->skinDList = "__OTR__" + skeletonLimb->skinDList; skeletonLimb->limbData.skinLimb.segment = (Gfx*)skeletonLimb->skinDList.c_str(); } else { skeletonLimb->limbData.skinLimb.segment = nullptr; } - } else if (skeletonLimb->skinSegmentType == LUS::ZLimbSkinType::SkinType_4) { + } else if (skeletonLimb->skinSegmentType == ZLimbSkinType::SkinType_4) { skeletonLimb->skinAnimLimbData.totalVtxCount = skeletonLimb->skinVtxCnt; skeletonLimb->skinAnimLimbData.limbModifCount = skeletonLimb->skinLimbModifCount; skeletonLimb->skinAnimLimbData.limbModifications = skeletonLimb->skinLimbModifArray.data(); @@ -220,10 +180,17 @@ void LUS::SkeletonLimbFactoryV0::ParseFileBinary(std::shared_ptr r skeletonLimb->limbData.skinLimb.segment = &skeletonLimb->skinAnimLimbData; } } + + return skeletonLimb; } -void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) -{ - std::shared_ptr skelLimb = std::static_pointer_cast(resource); + +std::shared_ptr ResourceFactoryXMLSkeletonLimbV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto skelLimb = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader)->FirstChildElement(); std::string limbType = reader->Attribute("Type"); @@ -275,6 +242,7 @@ void SkeletonLimbFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shar limbData.lodLimb.sibling = skelLimb->siblingIndex; // skelLimb->dList2Ptr = reader->Attribute("DisplayList2"); -} -} // namespace LUS + return skelLimb; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/SkeletonLimbFactory.h b/soh/soh/resource/importer/SkeletonLimbFactory.h index 8480a0126..125dde2b8 100644 --- a/soh/soh/resource/importer/SkeletonLimbFactory.h +++ b/soh/soh/resource/importer/SkeletonLimbFactory.h @@ -1,23 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class SkeletonLimbFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinarySkeletonLimbV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class SkeletonLimbFactoryV0 : public ResourceVersionFactory -{ +class ResourceFactoryXMLSkeletonLimbV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS - +} // namespace SOH diff --git a/soh/soh/resource/importer/TextFactory.cpp b/soh/soh/resource/importer/TextFactory.cpp index 314dd135c..89d229f80 100644 --- a/soh/soh/resource/importer/TextFactory.cpp +++ b/soh/soh/resource/importer/TextFactory.cpp @@ -2,74 +2,38 @@ #include "soh/resource/type/Text.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -TextFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - default: - // VERSION NOT SUPPORTED - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -std::shared_ptr -TextFactory::ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load Text with version {}", resource->GetInitData()->ResourceVersion); +namespace SOH { +std::shared_ptr ResourceFactoryBinaryTextV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { return nullptr; } - factory->ParseFileXML(reader, resource); - - return resource; -} - -void LUS::TextFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr text = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, text); + auto text = std::make_shared(file->InitData); + auto reader = std::get>(file->Reader); uint32_t msgCount = reader->ReadUInt32(); text->messages.reserve(msgCount); for (uint32_t i = 0; i < msgCount; i++) { - MessageEntry entry; - entry.id = reader->ReadUInt16(); - entry.textboxType = reader->ReadUByte(); - entry.textboxYPos = reader->ReadUByte(); - entry.msg = reader->ReadString(); + MessageEntry entry; + entry.id = reader->ReadUInt16(); + entry.textboxType = reader->ReadUByte(); + entry.textboxYPos = reader->ReadUByte(); + entry.msg = reader->ReadString(); - text->messages.push_back(entry); + text->messages.push_back(entry); } -} -void TextFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) { - std::shared_ptr txt = std::static_pointer_cast(resource); - auto child = reader->FirstChildElement(); + return text; +} + +std::shared_ptr ResourceFactoryXMLTextV0::ReadResource(std::shared_ptr file) { + if (!FileHasValidFormatAndReader(file)) { + return nullptr; + } + + auto txt = std::make_shared(file->InitData); + auto child = std::get>(file->Reader)->FirstChildElement()->FirstChildElement(); while (child != nullptr) { std::string childName = child->Name(); @@ -88,6 +52,7 @@ void TextFactoryV0::ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptrNextSiblingElement(); } -} -} // namespace LUS + return txt; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/TextFactory.h b/soh/soh/resource/importer/TextFactory.h index 7a6ae2841..cb466204b 100644 --- a/soh/soh/resource/importer/TextFactory.h +++ b/soh/soh/resource/importer/TextFactory.h @@ -1,23 +1,17 @@ #pragma once #include "Resource.h" -#include "ResourceFactory.h" +#include "ResourceFactoryBinary.h" +#include "ResourceFactoryXML.h" -namespace LUS { -class TextFactory : public ResourceFactory -{ +namespace SOH { +class ResourceFactoryBinaryTextV0 : public LUS::ResourceFactoryBinary { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; - std::shared_ptr - ReadResourceXML(std::shared_ptr initData, tinyxml2::XMLElement *reader) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -class TextFactoryV0 : public ResourceVersionFactory -{ +class ResourceFactoryXMLTextV0 : public LUS::ResourceFactoryXML { public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; - void ParseFileXML(tinyxml2::XMLElement* reader, std::shared_ptr resource) override; + std::shared_ptr ReadResource(std::shared_ptr file) override; }; -}; // namespace LUS - +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp index 4134e259a..ffcf17410 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.cpp @@ -2,37 +2,13 @@ #include "soh/resource/type/scenecommand/EndMarker.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -EndMarkerFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load EndMarker with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::EndMarkerFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr endMarker = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, endMarker); +namespace SOH { +std::shared_ptr +EndMarkerFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto endMarker = std::make_shared(initData); ReadCommandId(endMarker, reader); - - // This has no data. -} -} // namespace LUS + return endMarker; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h index 8cd83b4f6..486aaa2fb 100644 --- a/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h +++ b/soh/soh/resource/importer/scenecommand/EndMarkerFactory.h @@ -2,15 +2,9 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class EndMarkerFactory : public SceneCommandFactory { +namespace SOH { +class EndMarkerFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class EndMarkerFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp index 9ad0ba2d3..9ab5d1611 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.cpp @@ -2,9 +2,8 @@ #include "soh/resource/type/scenecommand/SceneCommand.h" #include "spdlog/spdlog.h" -namespace LUS { -void SceneCommandVersionFactory::ReadCommandId(std::shared_ptr command, std::shared_ptr reader) { +namespace SOH { +void SceneCommandFactoryBinaryV0::ReadCommandId(std::shared_ptr command, std::shared_ptr reader) { command->cmdId = (SceneCommandID)reader->ReadInt32(); } -} - \ No newline at end of file +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h index d9a23818a..4cebc4a64 100644 --- a/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h +++ b/soh/soh/resource/importer/scenecommand/SceneCommandFactory.h @@ -5,11 +5,12 @@ #include "ResourceFactory.h" #include "soh/resource/type/scenecommand/SceneCommand.h" -namespace LUS { -class SceneCommandFactory : public ResourceFactory {}; +namespace SOH { +class SceneCommandFactoryBinaryV0 { + public: + virtual std::shared_ptr ReadResource(std::shared_ptr initData, std::shared_ptr reader) = 0; -class SceneCommandVersionFactory : public ResourceVersionFactory { -protected: - void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); + protected: + void ReadCommandId(std::shared_ptr command, std::shared_ptr reader); }; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp index 0451eb4c3..86deea193 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.cpp @@ -2,52 +2,30 @@ #include "soh/resource/type/scenecommand/SetActorList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetActorListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetActorList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setActorList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setActorList); +namespace SOH { +std::shared_ptr +SetActorListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setActorList = std::make_shared(initData); ReadCommandId(setActorList, reader); setActorList->numActors = reader->ReadUInt32(); setActorList->actorList.reserve(setActorList->numActors); for (uint32_t i = 0; i < setActorList->numActors; i++) { - ActorEntry entry; + ActorEntry entry; - entry.id = reader->ReadUInt16(); - entry.pos.x = reader->ReadInt16(); - entry.pos.y = reader->ReadInt16(); - entry.pos.z = reader->ReadInt16(); - entry.rot.x = reader->ReadInt16(); - entry.rot.y = reader->ReadInt16(); - entry.rot.z = reader->ReadInt16(); - entry.params = reader->ReadUInt16(); + entry.id = reader->ReadUInt16(); + entry.pos.x = reader->ReadInt16(); + entry.pos.y = reader->ReadInt16(); + entry.pos.z = reader->ReadInt16(); + entry.rot.x = reader->ReadInt16(); + entry.rot.y = reader->ReadInt16(); + entry.rot.z = reader->ReadInt16(); + entry.params = reader->ReadUInt16(); setActorList->actorList.push_back(entry); } -} -} // namespace LUS + return setActorList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h index 1f4c213bb..49a269cfe 100644 --- a/soh/soh/resource/importer/scenecommand/SetActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetActorListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetActorListFactory : public SceneCommandFactory { +namespace SOH { +class SetActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetActorListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp index 5258d970b..833d0af8c 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.cpp @@ -3,47 +3,24 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetAlternateHeaders with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetAlternateHeadersFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setAlternateHeaders = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setAlternateHeaders); +namespace SOH { +std::shared_ptr SetAlternateHeadersFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setAlternateHeaders = std::make_shared(initData); ReadCommandId(setAlternateHeaders, reader); setAlternateHeaders->numHeaders = reader->ReadUInt32(); setAlternateHeaders->headers.reserve(setAlternateHeaders->numHeaders); for (uint32_t i = 0; i < setAlternateHeaders->numHeaders; i++) { - auto headerName = reader->ReadString(); - if (!headerName.empty()) { - setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); - } else { - setAlternateHeaders->headers.push_back(nullptr); - } + auto headerName = reader->ReadString(); + if (!headerName.empty()) { + setAlternateHeaders->headers.push_back(std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(headerName.c_str()))); + } else { + setAlternateHeaders->headers.push_back(nullptr); + } } -} -} // namespace LUS + return setAlternateHeaders; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h index a534c4392..2bc430c0b 100644 --- a/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetAlternateHeadersFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetAlternateHeadersFactory : public SceneCommandFactory { +namespace SOH { +class SetAlternateHeadersFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetAlternateHeadersFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp index 14b332d2a..7e2911a17 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.cpp @@ -2,38 +2,16 @@ #include "soh/resource/type/scenecommand/SetCameraSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetCameraSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCameraSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setCameraSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCameraSettings); +namespace SOH { +std::shared_ptr SetCameraSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setCameraSettings = std::make_shared(initData); ReadCommandId(setCameraSettings, reader); setCameraSettings->settings.cameraMovement = reader->ReadInt8(); setCameraSettings->settings.worldMapArea = reader->ReadInt32(); -} -} // namespace LUS + return setCameraSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h index ec4dc9e42..2f1db272f 100644 --- a/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCameraSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCameraSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetCameraSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCameraSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp index e1c113ba3..bb83dc57b 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.cpp @@ -3,37 +3,16 @@ #include "libultraship/libultraship.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetCollisionHeader with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCollisionHeaderFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setCollisionHeader = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCollisionHeader); +namespace SOH { +std::shared_ptr SetCollisionHeaderFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setCollisionHeader = std::make_shared(initData); ReadCommandId(setCollisionHeader, reader); setCollisionHeader->fileName = reader->ReadString(); setCollisionHeader->collisionHeader = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCollisionHeader->fileName.c_str())); -} -} // namespace LUS + return setCollisionHeader; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h index 96c6ff0a1..b80ee34b4 100644 --- a/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCollisionHeaderFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCollisionHeaderFactory : public SceneCommandFactory { +namespace SOH { +class SetCollisionHeaderFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCollisionHeaderFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp index d24e3b2c3..84c277989 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetCsCamera.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetCsCameraFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetCsCamera with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setCsCamera = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCsCamera); +namespace SOH { +std::shared_ptr +SetCsCameraFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setCsCamera = std::make_shared(initData); ReadCommandId(setCsCamera, reader); @@ -35,6 +13,7 @@ void LUS::SetCsCameraFactoryV0::ParseFileBinary(std::shared_ptr re reader->ReadInt32(); // segOffset // OTRTODO: FINISH! -} -} // namespace LUS + return setCsCamera; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h index ec74ed58e..08dc8e3c3 100644 --- a/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCsCameraFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCsCameraFactory : public SceneCommandFactory { +namespace SOH { +class SetCsCameraFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCsCameraFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp index db9392e7d..30f72d168 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.cpp @@ -3,38 +3,16 @@ #include #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetCutscenesFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetCutscenes with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetCutscenesFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setCutscenes = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setCutscenes); +namespace SOH { +std::shared_ptr +SetCutscenesFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setCutscenes = std::make_shared(initData); ReadCommandId(setCutscenes, reader); setCutscenes->fileName = reader->ReadString(); setCutscenes->cutscene = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(setCutscenes->fileName.c_str())); -} -} // namespace LUS + return setCutscenes; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h index 7963036ba..bbbe38c98 100644 --- a/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetCutscenesFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetCutscenesFactory : public SceneCommandFactory { +namespace SOH { +class SetCutscenesFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetCutscenesFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp index 530bcb8af..e9c3381cb 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.cpp @@ -2,37 +2,15 @@ #include "soh/resource/type/scenecommand/SetEchoSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetEchoSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetEchoSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setEchoSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setEchoSettings); +namespace SOH { +std::shared_ptr +SetEchoSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setEchoSettings = std::make_shared(initData); ReadCommandId(setEchoSettings, reader); setEchoSettings->settings.echo = reader->ReadInt8(); -} -} // namespace LUS + return setEchoSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h index 90bf3222f..99bda6eae 100644 --- a/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEchoSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetEchoSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetEchoSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetEchoSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp index 0fd841278..766bb82da 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetEntranceList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetEntranceListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetEntranceListList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setEntranceList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setEntranceList); +namespace SOH { +std::shared_ptr +SetEntranceListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setEntranceList = std::make_shared(initData); ReadCommandId(setEntranceList, reader); @@ -41,6 +19,7 @@ void LUS::SetEntranceListFactoryV0::ParseFileBinary(std::shared_ptrentrances.push_back(entranceEntry); } -} -} // namespace LUS + return setEntranceList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h index ce20db4f7..35b7fba62 100644 --- a/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetEntranceListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetEntranceListFactory : public SceneCommandFactory { +namespace SOH { +class SetEntranceListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetEntranceListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp index 04ed0c56b..5fef9d096 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetExitList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetExitListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared( initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetExitList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setExitList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setExitList); +namespace SOH { +std::shared_ptr +SetExitListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setExitList = std::make_shared( initData); ReadCommandId(setExitList, reader); @@ -36,6 +14,7 @@ void LUS::SetExitListFactoryV0::ParseFileBinary(std::shared_ptr re for (uint32_t i = 0; i < setExitList->numExits; i++) { setExitList->exits.push_back(reader->ReadUInt16()); } -} -} // namespace LUS + return setExitList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h index 351ebe7ca..d82e8f04a 100644 --- a/soh/soh/resource/importer/scenecommand/SetExitListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetExitListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetExitListFactory : public SceneCommandFactory { +namespace SOH { +class SetExitListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetExitListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp index 2d2a9afe4..2d05631cd 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.cpp @@ -2,34 +2,10 @@ #include "soh/resource/type/scenecommand/SetLightList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetLightListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetLightList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setLightList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setLightList); +namespace SOH { +std::shared_ptr +SetLightListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setLightList = std::make_shared(initData); ReadCommandId(setLightList, reader); @@ -40,7 +16,7 @@ void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr r light.type = reader->ReadUByte(); - light.params.point.x = reader->ReadInt16(); + light.params.point.x = reader->ReadInt16(); light.params.point.y = reader->ReadInt16(); light.params.point.z = reader->ReadInt16(); @@ -49,10 +25,11 @@ void LUS::SetLightListFactoryV0::ParseFileBinary(std::shared_ptr r light.params.point.color[2] = reader->ReadUByte(); // b light.params.point.drawGlow = reader->ReadUByte(); - light.params.point.radius = reader->ReadInt16(); + light.params.point.radius = reader->ReadInt16(); setLightList->lightList.push_back(light); } -} -} // namespace LUS + return setLightList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h index 24292a289..1c4a6e9dc 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetLightListFactory : public SceneCommandFactory { +namespace SOH { +class SetLightListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetLightListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp index 3fdedd0e4..d0a7b89d5 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.cpp @@ -2,33 +2,10 @@ #include "soh/resource/type/scenecommand/SetLightingSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetLightingSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setLightingSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setLightingSettings); +namespace SOH { +std::shared_ptr SetLightingSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setLightingSettings = std::make_shared(initData); ReadCommandId(setLightingSettings, reader); @@ -65,6 +42,7 @@ void LUS::SetLightingSettingsFactoryV0::ParseFileBinary(std::shared_ptrReadUInt16(); setLightingSettings->settings.push_back(lightSettings); } -} -} // namespace LUS + return setLightingSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h index 78a624ca6..df25600e2 100644 --- a/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetLightingSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetLightingSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetLightingSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetLightingSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp index 1398641a7..8c17ecc07 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.cpp @@ -3,34 +3,10 @@ #include "spdlog/spdlog.h" #include "libultraship/libultraship.h" -namespace LUS { -std::shared_ptr -SetMeshFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetMesh with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setMesh = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setMesh); +namespace SOH { +std::shared_ptr +SetMeshFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setMesh = std::make_shared(initData); ReadCommandId(setMesh, reader); @@ -143,10 +119,10 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reader std::string meshOpa = reader->ReadString(); std::string meshXlu = reader->ReadString(); - auto opaRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()); - auto xluRes = LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()); - dlist.opa = meshOpa != "" ? (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr) : 0; - dlist.xlu = meshXlu != "" ? (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr) : 0; + auto opaRes = meshOpa != "" ? LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshOpa.c_str()) : nullptr; + auto xluRes = meshXlu != "" ? LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(meshXlu.c_str()) : nullptr; + dlist.opa = (Gfx*)(opaRes ? opaRes->GetRawPointer() : nullptr); + dlist.xlu = (Gfx*)(xluRes ? xluRes->GetRawPointer() : nullptr); setMesh->dlists2.push_back(dlist); } else { @@ -164,6 +140,7 @@ void LUS::SetMeshFactoryV0::ParseFileBinary(std::shared_ptr reader } else { SPDLOG_ERROR("Tried to load mesh in SetMesh scene header with type that doesn't exist: {}", setMesh->meshHeader.base.type); } -} -} // namespace LUS + return setMesh; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h index 8ca086d43..a912bdd37 100644 --- a/soh/soh/resource/importer/scenecommand/SetMeshFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetMeshFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetMeshFactory : public SceneCommandFactory { +namespace SOH { +class SetMeshFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetMeshFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp index 27082f6e7..b84befb3b 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.cpp @@ -2,33 +2,10 @@ #include "soh/resource/type/scenecommand/SetObjectList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetObjectListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetObjectList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setObjectList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setObjectList); +namespace SOH { +std::shared_ptr +SetObjectListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setObjectList = std::make_shared(initData); ReadCommandId(setObjectList, reader); @@ -37,6 +14,7 @@ void LUS::SetObjectListFactoryV0::ParseFileBinary(std::shared_ptr for (uint32_t i = 0; i < setObjectList->numObjects; i++) { setObjectList->objects.push_back(reader->ReadUInt16()); } -} -} // namespace LUS + return setObjectList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h index 65725bfb2..4c2f002c0 100644 --- a/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetObjectListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetObjectListFactory : public SceneCommandFactory { +namespace SOH { +class SetObjectListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetObjectListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp index 1f40ab69d..61534ba48 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp @@ -3,32 +3,10 @@ #include "spdlog/spdlog.h" #include -namespace LUS { -std::shared_ptr -SetPathwaysFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetPathways with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setPathways = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setPathways); +namespace SOH { +std::shared_ptr +SetPathwaysFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setPathways = std::make_shared(initData); ReadCommandId(setPathways, reader); @@ -39,6 +17,7 @@ void LUS::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr re auto path = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResourceProcess(pathFileName.c_str())); setPathways->paths.push_back(path->GetPointer()); } -} -} // namespace LUS + return setPathways; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h index fc9b2c62d..c622c820d 100644 --- a/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetPathwaysFactory : public SceneCommandFactory { +namespace SOH { +class SetPathwaysFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetPathwaysFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp index 409e3d410..e4601e59c 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.cpp @@ -2,37 +2,16 @@ #include "soh/resource/type/scenecommand/SetRoomBehavior.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetRoomBehaviorFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetRoomBehavior with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetRoomBehaviorFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setRoomBehavior = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setRoomBehavior); +namespace SOH { +std::shared_ptr +SetRoomBehaviorFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setRoomBehavior = std::make_shared(initData); ReadCommandId(setRoomBehavior, reader); setRoomBehavior->roomBehavior.gameplayFlags = reader->ReadInt8(); setRoomBehavior->roomBehavior.gameplayFlags2 = reader->ReadInt32(); -} -} // namespace LUS + return setRoomBehavior; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h index ef5a77bd4..70a53ba1e 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomBehaviorFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetRoomBehaviorFactory : public SceneCommandFactory { +namespace SOH { +class SetRoomBehaviorFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetRoomBehaviorFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp index 136b410a0..7726877a1 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.cpp @@ -2,49 +2,27 @@ #include "soh/resource/type/scenecommand/SetRoomList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetRoomListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetRoomList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetRoomListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setRoomList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setRoomList); +namespace SOH { +std::shared_ptr +SetRoomListFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setRoomList = std::make_shared(initData); ReadCommandId(setRoomList, reader); setRoomList->numRooms = reader->ReadInt32(); setRoomList->rooms.reserve(setRoomList->numRooms); for (uint32_t i = 0; i < setRoomList->numRooms; i++) { - RomFile room; + RomFile room; - setRoomList->fileNames.push_back(reader->ReadString()); + setRoomList->fileNames.push_back(reader->ReadString()); - room.fileName = (char*)setRoomList->fileNames.back().c_str(); - room.vromStart = reader->ReadInt32(); - room.vromEnd = reader->ReadInt32(); + room.fileName = (char*)setRoomList->fileNames.back().c_str(); + room.vromStart = reader->ReadInt32(); + room.vromEnd = reader->ReadInt32(); setRoomList->rooms.push_back(room); } -} -} // namespace LUS + return setRoomList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h index 1ba5e5c1f..6bf9eaa5c 100644 --- a/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetRoomListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetRoomListFactory : public SceneCommandFactory { +namespace SOH { +class SetRoomListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetRoomListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp index b68d2e56d..291ae578c 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.cpp @@ -2,37 +2,16 @@ #include "soh/resource/type/scenecommand/SetSkyboxModifier.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetSkyboxModifier with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetSkyboxModifierFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSkyboxModifier = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSkyboxModifier); +namespace SOH { +std::shared_ptr SetSkyboxModifierFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSkyboxModifier = std::make_shared(initData); ReadCommandId(setSkyboxModifier, reader); setSkyboxModifier->modifier.skyboxDisabled = reader->ReadInt8(); setSkyboxModifier->modifier.sunMoonDisabled = reader->ReadInt8(); -} -} // namespace LUS + return setSkyboxModifier; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h index 9556b6699..d467cc73d 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxModifierFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSkyboxModifierFactory : public SceneCommandFactory { +namespace SOH { +class SetSkyboxModifierFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSkyboxModifierFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp index 3b793c80e..f3e726b07 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetSkyboxSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetSkyboxSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSkyboxSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSkyboxSettings); +namespace SOH { +std::shared_ptr SetSkyboxSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSkyboxSettings = std::make_shared(initData); ReadCommandId(setSkyboxSettings, reader); @@ -35,6 +13,7 @@ void SetSkyboxSettingsFactoryV0::ParseFileBinary(std::shared_ptr r setSkyboxSettings->settings.skyboxId = reader->ReadInt8(); setSkyboxSettings->settings.weather = reader->ReadInt8(); setSkyboxSettings->settings.indoors = reader->ReadInt8(); -} -} // namespace LUS + return setSkyboxSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h index 7c2da4bb1..581e56122 100644 --- a/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSkyboxSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSkyboxSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetSkyboxSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSkyboxSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp index 1817af81d..f85178e22 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.cpp @@ -2,38 +2,17 @@ #include "soh/resource/type/scenecommand/SetSoundSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetSoundSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetSoundSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSoundSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSoundSettings); +namespace SOH { +std::shared_ptr SetSoundSettingsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSoundSettings = std::make_shared(initData); ReadCommandId(setSoundSettings, reader); setSoundSettings->settings.reverb = reader->ReadInt8(); setSoundSettings->settings.natureAmbienceId = reader->ReadInt8(); setSoundSettings->settings.seqId = reader->ReadInt8(); -} -} // namespace LUS + return setSoundSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h index 7195b0fb6..e1c4efb03 100644 --- a/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSoundSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSoundSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetSoundSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSoundSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp index 5f818f1d4..b7fd21aa4 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.cpp @@ -2,37 +2,16 @@ #include "soh/resource/type/scenecommand/SetSpecialObjects.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr){ - SPDLOG_ERROR("Failed to load SetSpecialObjects with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetSpecialObjectsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setSpecialObjects = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setSpecialObjects); +namespace SOH { +std::shared_ptr SetSpecialObjectsFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setSpecialObjects = std::make_shared(initData); ReadCommandId(setSpecialObjects, reader); setSpecialObjects->specialObjects.elfMessage = reader->ReadInt8(); setSpecialObjects->specialObjects.globalObject = reader->ReadInt16(); -} -} // namespace LUS + return setSpecialObjects; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h index 3e3fc77d0..503cfb61f 100644 --- a/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetSpecialObjectsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetSpecialObjectsFactory : public SceneCommandFactory { +namespace SOH { +class SetSpecialObjectsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetSpecialObjectsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp index bafb0b153..3165b4361 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.cpp @@ -2,54 +2,30 @@ #include "soh/resource/type/scenecommand/SetStartPositionList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) - { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) - { - SPDLOG_ERROR("Failed to load SetStartPositionList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetStartPositionListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) -{ - std::shared_ptr setStartPositionList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setStartPositionList); +namespace SOH { +std::shared_ptr SetStartPositionListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setStartPositionList = std::make_shared(initData); ReadCommandId(setStartPositionList, reader); setStartPositionList->numStartPositions = reader->ReadUInt32(); setStartPositionList->startPositions.reserve(setStartPositionList->numStartPositions); for (uint32_t i = 0; i < setStartPositionList->numStartPositions; i++) { - ActorEntry entry; + ActorEntry entry; - entry.id = reader->ReadUInt16(); - entry.pos.x = reader->ReadInt16(); - entry.pos.y = reader->ReadInt16(); - entry.pos.z = reader->ReadInt16(); - entry.rot.x = reader->ReadInt16(); - entry.rot.y = reader->ReadInt16(); - entry.rot.z = reader->ReadInt16(); - entry.params = reader->ReadUInt16(); + entry.id = reader->ReadUInt16(); + entry.pos.x = reader->ReadInt16(); + entry.pos.y = reader->ReadInt16(); + entry.pos.z = reader->ReadInt16(); + entry.rot.x = reader->ReadInt16(); + entry.rot.y = reader->ReadInt16(); + entry.rot.z = reader->ReadInt16(); + entry.params = reader->ReadUInt16(); setStartPositionList->startPositions.push_back(entry); } -} -} // namespace LUS + return setStartPositionList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h index d2bbcb6a6..b07901f05 100644 --- a/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetStartPositionListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetStartPositionListFactory : public SceneCommandFactory { +namespace SOH { +class SetStartPositionListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetStartPositionListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp index ab2ac12f0..d83b24583 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.cpp @@ -2,38 +2,17 @@ #include "soh/resource/type/scenecommand/SetTimeSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetTimeSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetTimeSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetTimeSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setTimeSettings = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setTimeSettings); +namespace SOH { +std::shared_ptr +SetTimeSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setTimeSettings = std::make_shared(initData); ReadCommandId(setTimeSettings, reader); setTimeSettings->settings.hour = reader->ReadInt8(); setTimeSettings->settings.minute = reader->ReadInt8(); setTimeSettings->settings.timeIncrement = reader->ReadInt8(); -} -} // namespace LUS + return setTimeSettings; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h index b7ee1083c..d1336f788 100644 --- a/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTimeSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetTimeSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetTimeSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetTimeSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp index 575151bab..c751ad611 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.cpp @@ -2,33 +2,11 @@ #include "soh/resource/type/scenecommand/SetTransitionActorList.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr initData, - std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetTransitionActorList with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setTransitionActorList = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setTransitionActorList); - +namespace SOH { +std::shared_ptr SetTransitionActorListFactory::ReadResource(std::shared_ptr initData, + std::shared_ptr reader) { + auto setTransitionActorList = std::make_shared(initData); + ReadCommandId(setTransitionActorList, reader); setTransitionActorList->numTransitionActors = reader->ReadUInt32(); @@ -49,6 +27,7 @@ void LUS::SetTransitionActorListFactoryV0::ParseFileBinary(std::shared_ptrtransitionActorList.push_back(entry); } -} -} // namespace LUS + return setTransitionActorList; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h index 25343ced8..c8fb65f9a 100644 --- a/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetTransitionActorListFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetTransitionActorListFactory : public SceneCommandFactory { +namespace SOH { +class SetTransitionActorListFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetTransitionActorListFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp index 995045014..3208004ce 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.cpp @@ -2,32 +2,10 @@ #include "soh/resource/type/scenecommand/SetWindSettings.h" #include "spdlog/spdlog.h" -namespace LUS { -std::shared_ptr -SetWindSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { - auto resource = std::make_shared(initData); - std::shared_ptr factory = nullptr; - - switch (resource->GetInitData()->ResourceVersion) { - case 0: - factory = std::make_shared(); - break; - } - - if (factory == nullptr) { - SPDLOG_ERROR("Failed to load SetWindSettings with version {}", resource->GetInitData()->ResourceVersion); - return nullptr; - } - - factory->ParseFileBinary(reader, resource); - - return resource; -} - -void LUS::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptr reader, - std::shared_ptr resource) { - std::shared_ptr setWind = std::static_pointer_cast(resource); - ResourceVersionFactory::ParseFileBinary(reader, setWind); +namespace SOH { +std::shared_ptr +SetWindSettingsFactory::ReadResource(std::shared_ptr initData, std::shared_ptr reader) { + auto setWind = std::make_shared(initData); ReadCommandId(setWind, reader); @@ -35,6 +13,7 @@ void LUS::SetWindSettingsFactoryV0::ParseFileBinary(std::shared_ptrsettings.windVertical = reader->ReadInt8(); setWind->settings.windSouth = reader->ReadInt8(); setWind->settings.windSpeed = reader->ReadUByte(); -} -} // namespace LUS + return setWind; +} +} // namespace SOH diff --git a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h index 0a783bb9f..6cc9fbc1b 100644 --- a/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h +++ b/soh/soh/resource/importer/scenecommand/SetWindSettingsFactory.h @@ -2,15 +2,10 @@ #include "soh/resource/importer/scenecommand/SceneCommandFactory.h" -namespace LUS { -class SetWindSettingsFactory : public SceneCommandFactory { +namespace SOH { +class SetWindSettingsFactory : public SceneCommandFactoryBinaryV0 { public: - std::shared_ptr - ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; + std::shared_ptr + ReadResource(std::shared_ptr initData, std::shared_ptr reader) override; }; - -class SetWindSettingsFactoryV0 : public SceneCommandVersionFactory { - public: - void ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) override; -}; -}; // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Animation.cpp b/soh/soh/resource/type/Animation.cpp index 46327c732..d11d05394 100644 --- a/soh/soh/resource/type/Animation.cpp +++ b/soh/soh/resource/type/Animation.cpp @@ -1,6 +1,6 @@ #include "Animation.h" -namespace LUS { +namespace SOH { AnimationData* Animation::GetPointer() { return &animationData; } @@ -18,4 +18,4 @@ size_t Animation::GetPointerSize() { return 0; } } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/Animation.h b/soh/soh/resource/type/Animation.h index 3d6b810bf..abd319d97 100644 --- a/soh/soh/resource/type/Animation.h +++ b/soh/soh/resource/type/Animation.h @@ -3,85 +3,85 @@ #include "Resource.h" #include -namespace LUS { - enum class AnimationType { - Normal = 0, - Link = 1, - Curve = 2, - Legacy = 3, - }; +namespace SOH { +enum class AnimationType { + Normal = 0, + Link = 1, + Curve = 2, + Legacy = 3, +}; - struct RotationIndex { - uint16_t x, y, z; +struct RotationIndex { + uint16_t x, y, z; - RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) { - } - }; + RotationIndex(uint16_t nX, uint16_t nY, uint16_t nZ) : x(nX), y(nY), z(nZ) { + } +}; - typedef struct { - /* 0x0000 */ u16 unk_00; // appears to be flags - /* 0x0002 */ s16 unk_02; - /* 0x0004 */ s16 unk_04; - /* 0x0006 */ s16 unk_06; - /* 0x0008 */ f32 unk_08; - } TransformData; // size = 0xC +typedef struct { + /* 0x0000 */ u16 unk_00; // appears to be flags + /* 0x0002 */ s16 unk_02; + /* 0x0004 */ s16 unk_04; + /* 0x0006 */ s16 unk_06; + /* 0x0008 */ f32 unk_08; +} TransformData; // size = 0xC - typedef struct { - /* 0x0000 */ u8* refIndex; - /* 0x0004 */ TransformData* transformData; - /* 0x0008 */ s16* copyValues; - /* 0x000C */ s16 unk_0C; - /* 0x000E */ s16 unk_0E; - } TransformUpdateIndex; // size = 0x10 +typedef struct { + /* 0x0000 */ u8* refIndex; + /* 0x0004 */ TransformData* transformData; + /* 0x0008 */ s16* copyValues; + /* 0x000C */ s16 unk_0C; + /* 0x000E */ s16 unk_0E; +} TransformUpdateIndex; // size = 0x10 - typedef struct { - /* 0x00 */ s16 frameCount; - } AnimationHeaderCommon; +typedef struct { + /* 0x00 */ s16 frameCount; +} AnimationHeaderCommon; - // Index into the frame data table. - typedef struct { - /* 0x00 */ u16 x; - /* 0x02 */ u16 y; - /* 0x04 */ u16 z; - } JointIndex; // size = 0x06 +// Index into the frame data table. +typedef struct { + /* 0x00 */ u16 x; + /* 0x02 */ u16 y; + /* 0x04 */ u16 z; +} JointIndex; // size = 0x06 - typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ s16* frameData; // "tbl" - /* 0x08 */ JointIndex* jointIndices; // "ref_tbl" - /* 0x0C */ u16 staticIndexMax; - } AnimationHeader; // size = 0x10 +typedef struct { + /* 0x00 */ AnimationHeaderCommon common; + /* 0x04 */ s16* frameData; // "tbl" + /* 0x08 */ JointIndex* jointIndices; // "ref_tbl" + /* 0x0C */ u16 staticIndexMax; +} AnimationHeader; // size = 0x10 - typedef struct { - /* 0x00 */ AnimationHeaderCommon common; - /* 0x04 */ void* segment; - } LinkAnimationHeader; // size = 0x8 +typedef struct { + /* 0x00 */ AnimationHeaderCommon common; + /* 0x04 */ void* segment; +} LinkAnimationHeader; // size = 0x8 - union AnimationData { - AnimationHeader animationHeader; - LinkAnimationHeader linkAnimationHeader; - TransformUpdateIndex transformUpdateIndex; - }; +union AnimationData { +AnimationHeader animationHeader; +LinkAnimationHeader linkAnimationHeader; +TransformUpdateIndex transformUpdateIndex; +}; - class Animation : public Resource { - public: - using Resource::Resource; +class Animation : public LUS::Resource { +public: + using Resource::Resource; - Animation() : Resource(std::shared_ptr()) {} + Animation() : Resource(std::shared_ptr()) {} - AnimationData* GetPointer(); - size_t GetPointerSize(); + AnimationData* GetPointer(); + size_t GetPointerSize(); - AnimationType type; - AnimationData animationData; + AnimationType type; + AnimationData animationData; - // NORMAL - std::vector rotationValues; - std::vector rotationIndices; + // NORMAL + std::vector rotationValues; + std::vector rotationIndices; - // CURVE - std::vector refIndexArr; - std::vector transformDataArr; - std::vector copyValuesArr; - }; -}; // namespace LUS \ No newline at end of file + // CURVE + std::vector refIndexArr; + std::vector transformDataArr; + std::vector copyValuesArr; +}; +}; // namespace LUS diff --git a/soh/soh/resource/type/AudioSample.cpp b/soh/soh/resource/type/AudioSample.cpp index 951aae6c1..288765822 100644 --- a/soh/soh/resource/type/AudioSample.cpp +++ b/soh/soh/resource/type/AudioSample.cpp @@ -1,6 +1,6 @@ #include "AudioSample.h" -namespace LUS { +namespace SOH { Sample* AudioSample::GetPointer() { return &sample; } @@ -8,4 +8,4 @@ Sample* AudioSample::GetPointer() { size_t AudioSample::GetPointerSize() { return sizeof(Sample); } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/AudioSample.h b/soh/soh/resource/type/AudioSample.h index eda8aa456..4d6929c59 100644 --- a/soh/soh/resource/type/AudioSample.h +++ b/soh/soh/resource/type/AudioSample.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ uintptr_t start; /* 0x04 */ uintptr_t end; @@ -39,11 +39,11 @@ namespace LUS { s32 sampleRate; // For wav samples only... } Sample; // size = 0x10 - class AudioSample : public Resource { + class AudioSample : public LUS::Resource { public: using Resource::Resource; - AudioSample() : Resource(std::shared_ptr()) {} + AudioSample() : Resource(std::shared_ptr()) {} Sample* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSequence.cpp b/soh/soh/resource/type/AudioSequence.cpp index c09514a67..41029d47d 100644 --- a/soh/soh/resource/type/AudioSequence.cpp +++ b/soh/soh/resource/type/AudioSequence.cpp @@ -1,6 +1,6 @@ #include "AudioSequence.h" -namespace LUS { +namespace SOH { Sequence* AudioSequence::GetPointer() { return &sequence; @@ -9,4 +9,4 @@ Sequence* AudioSequence::GetPointer() { size_t AudioSequence::GetPointerSize() { return sizeof(Sequence); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/AudioSequence.h b/soh/soh/resource/type/AudioSequence.h index 2b2bb8be9..457db6243 100644 --- a/soh/soh/resource/type/AudioSequence.h +++ b/soh/soh/resource/type/AudioSequence.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { typedef struct { char* seqData; @@ -17,11 +17,11 @@ typedef struct { uint8_t fonts[16]; } Sequence; -class AudioSequence : public Resource { +class AudioSequence : public LUS::Resource { public: using Resource::Resource; - AudioSequence() : Resource(std::shared_ptr()) {} + AudioSequence() : Resource(std::shared_ptr()) {} Sequence* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/AudioSoundFont.cpp b/soh/soh/resource/type/AudioSoundFont.cpp index 43ac40abf..12218cb64 100644 --- a/soh/soh/resource/type/AudioSoundFont.cpp +++ b/soh/soh/resource/type/AudioSoundFont.cpp @@ -1,6 +1,6 @@ #include "AudioSoundFont.h" -namespace LUS { +namespace SOH { SoundFont* AudioSoundFont::GetPointer() { return &soundFont; } @@ -8,4 +8,4 @@ SoundFont* AudioSoundFont::GetPointer() { size_t AudioSoundFont::GetPointerSize() { return sizeof(SoundFont); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/AudioSoundFont.h b/soh/soh/resource/type/AudioSoundFont.h index c47218090..11b899d3e 100644 --- a/soh/soh/resource/type/AudioSoundFont.h +++ b/soh/soh/resource/type/AudioSoundFont.h @@ -6,7 +6,7 @@ #include "soh/resource/type/AudioSample.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x0 */ s16 delay; @@ -52,11 +52,11 @@ typedef struct { s32 fntIndex; } SoundFont; // size = 0x14 -class AudioSoundFont : public Resource { +class AudioSoundFont : public LUS::Resource { public: using Resource::Resource; - AudioSoundFont() : Resource(std::shared_ptr()) {} + AudioSoundFont() : Resource(std::shared_ptr()) {} SoundFont* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Background.cpp b/soh/soh/resource/type/Background.cpp index bc1047b5c..5465b1ad9 100644 --- a/soh/soh/resource/type/Background.cpp +++ b/soh/soh/resource/type/Background.cpp @@ -1,6 +1,6 @@ #include "Background.h" -namespace LUS { +namespace SOH { uint8_t* Background::GetPointer() { return Data.data(); } @@ -8,4 +8,4 @@ uint8_t* Background::GetPointer() { size_t Background::GetPointerSize() { return Data.size() * sizeof(uint8_t); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Background.h b/soh/soh/resource/type/Background.h index 7f22658e0..9edc4b0d6 100644 --- a/soh/soh/resource/type/Background.h +++ b/soh/soh/resource/type/Background.h @@ -2,12 +2,12 @@ #include "resource/Resource.h" -namespace LUS { -class Background : public Resource { +namespace SOH { +class Background : public LUS::Resource { public: using Resource::Resource; - Background() : Resource(std::shared_ptr()) {} + Background() : Resource(std::shared_ptr()) {} uint8_t* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/CollisionHeader.cpp b/soh/soh/resource/type/CollisionHeader.cpp index 5625d2b59..dbfd737ee 100644 --- a/soh/soh/resource/type/CollisionHeader.cpp +++ b/soh/soh/resource/type/CollisionHeader.cpp @@ -1,6 +1,6 @@ #include "CollisionHeader.h" -namespace LUS { +namespace SOH { CollisionHeaderData* CollisionHeader::GetPointer() { return &collisionHeaderData; } @@ -8,4 +8,4 @@ CollisionHeaderData* CollisionHeader::GetPointer() { size_t CollisionHeader::GetPointerSize() { return sizeof(collisionHeaderData); } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/CollisionHeader.h b/soh/soh/resource/type/CollisionHeader.h index e401aa7f5..e2ddf3f7a 100644 --- a/soh/soh/resource/type/CollisionHeader.h +++ b/soh/soh/resource/type/CollisionHeader.h @@ -6,7 +6,7 @@ #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u16 type; @@ -67,11 +67,11 @@ typedef struct { size_t cameraDataListLen; // OTRTODO: Added to allow for bounds checking the cameraDataList. } CollisionHeaderData; // original name: BGDataInfo -class CollisionHeader : public Resource { +class CollisionHeader : public LUS::Resource { public: using Resource::Resource; - CollisionHeader() : Resource(std::shared_ptr()) {} + CollisionHeader() : Resource(std::shared_ptr()) {} CollisionHeaderData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Cutscene.cpp b/soh/soh/resource/type/Cutscene.cpp index c7e98062a..60440ceb2 100644 --- a/soh/soh/resource/type/Cutscene.cpp +++ b/soh/soh/resource/type/Cutscene.cpp @@ -1,7 +1,7 @@ #include "Cutscene.h" #include -namespace LUS { +namespace SOH { uint32_t* Cutscene::GetPointer() { return commands.data(); } @@ -9,4 +9,4 @@ uint32_t* Cutscene::GetPointer() { size_t Cutscene::GetPointerSize() { return commands.size() * sizeof(uint32_t); } -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/Cutscene.h b/soh/soh/resource/type/Cutscene.h index 5bd268e61..3ca8b3d50 100644 --- a/soh/soh/resource/type/Cutscene.h +++ b/soh/soh/resource/type/Cutscene.h @@ -7,7 +7,7 @@ #include "Vec3f.h" #include "Color3b.h" -namespace LUS { +namespace SOH { enum class CutsceneCommands { Cmd00 = 0x0000, @@ -44,11 +44,11 @@ enum class CutsceneCommands { Error = 0xFEAF, }; -class Cutscene : public Resource { +class Cutscene : public LUS::Resource { public: using Resource::Resource; - Cutscene() : Resource(std::shared_ptr()) {} + Cutscene() : Resource(std::shared_ptr()) {} uint32_t* GetPointer(); size_t GetPointerSize(); @@ -57,7 +57,7 @@ class Cutscene : public Resource { uint32_t endFrame; std::vector commands; }; -} // namespace LUS +} // namespace SOH ///////////// diff --git a/soh/soh/resource/type/Path.cpp b/soh/soh/resource/type/Path.cpp index 535db4e7d..072c65fd0 100644 --- a/soh/soh/resource/type/Path.cpp +++ b/soh/soh/resource/type/Path.cpp @@ -1,6 +1,6 @@ #include "Path.h" -namespace LUS { +namespace SOH { PathData* Path::GetPointer() { return pathData.data(); } @@ -8,4 +8,4 @@ PathData* Path::GetPointer() { size_t Path::GetPointerSize() { return pathData.size() * sizeof(PathData); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Path.h b/soh/soh/resource/type/Path.h index 5dd16dec9..c4078bed3 100644 --- a/soh/soh/resource/type/Path.h +++ b/soh/soh/resource/type/Path.h @@ -6,18 +6,18 @@ #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 count; // number of points in the path /* 0x04 */ Vec3s* points; // Segment Address to the array of points } PathData; // size = 0x8 -class Path : public Resource { +class Path : public LUS::Resource { public: using Resource::Resource; - Path() : Resource(std::shared_ptr()) {} + Path() : Resource(std::shared_ptr()) {} PathData* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/PlayerAnimation.cpp b/soh/soh/resource/type/PlayerAnimation.cpp index 55925f49c..189460e4d 100644 --- a/soh/soh/resource/type/PlayerAnimation.cpp +++ b/soh/soh/resource/type/PlayerAnimation.cpp @@ -1,7 +1,7 @@ #include "PlayerAnimation.h" #include -namespace LUS { +namespace SOH { int16_t* PlayerAnimation::GetPointer() { return limbRotData.data(); } @@ -9,4 +9,4 @@ int16_t* PlayerAnimation::GetPointer() { size_t PlayerAnimation::GetPointerSize() { return limbRotData.size() * sizeof(int16_t); } -} // namespace LUS \ No newline at end of file +} // namespace SOH diff --git a/soh/soh/resource/type/PlayerAnimation.h b/soh/soh/resource/type/PlayerAnimation.h index 4eb51b139..d8c47a5f6 100644 --- a/soh/soh/resource/type/PlayerAnimation.h +++ b/soh/soh/resource/type/PlayerAnimation.h @@ -7,17 +7,16 @@ #include "Vec3f.h" #include "Color3b.h" -namespace LUS { - -class PlayerAnimation : public Resource { +namespace SOH { +class PlayerAnimation : public LUS::Resource { public: using Resource::Resource; - PlayerAnimation() : Resource(std::shared_ptr()) {} + PlayerAnimation() : Resource(std::shared_ptr()) {} int16_t* GetPointer(); size_t GetPointerSize(); std::vector limbRotData; }; -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/Scene.cpp b/soh/soh/resource/type/Scene.cpp index bfe219e54..15829c40e 100644 --- a/soh/soh/resource/type/Scene.cpp +++ b/soh/soh/resource/type/Scene.cpp @@ -1,6 +1,6 @@ #include "Scene.h" -namespace LUS { +namespace SOH { void* Scene::GetPointer() { // Scene is a special type that requries C++ processing. As such, we return nothing. return nullptr; @@ -9,4 +9,4 @@ void* Scene::GetPointer() { size_t Scene::GetPointerSize() { return 0; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Scene.h b/soh/soh/resource/type/Scene.h index f726da359..79ff69392 100644 --- a/soh/soh/resource/type/Scene.h +++ b/soh/soh/resource/type/Scene.h @@ -7,13 +7,13 @@ #include "scenecommand/SceneCommand.h" #include -namespace LUS { +namespace SOH { -class Scene : public Resource { +class Scene : public LUS::Resource { public: using Resource::Resource; - Scene() : Resource(std::shared_ptr()) {} + Scene() : Resource(std::shared_ptr()) {} void* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 13798d3c5..39c28f533 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -3,7 +3,7 @@ #include "soh/OTRGlobals.h" #include "libultraship/libultraship.h" -namespace LUS { +namespace SOH { SkeletonData* Skeleton::GetPointer() { return &skeletonData; } @@ -79,4 +79,4 @@ void SkeletonPatcher::UpdateSkeletons() { } } } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Skeleton.h b/soh/soh/resource/type/Skeleton.h index 490614a44..81aa90c68 100644 --- a/soh/soh/resource/type/Skeleton.h +++ b/soh/soh/resource/type/Skeleton.h @@ -5,7 +5,7 @@ #include "SkeletonLimb.h" #include -namespace LUS { +namespace SOH { enum class SkeletonType { Normal, @@ -50,11 +50,11 @@ union SkeletonData { SkelCurveLimbList skelCurveLimbList; }; -class Skeleton : public Resource { +class Skeleton : public LUS::Resource { public: using Resource::Resource; - Skeleton() : Resource(std::shared_ptr()) {} + Skeleton() : Resource(std::shared_ptr()) {} SkeletonData* GetPointer(); size_t GetPointerSize(); @@ -91,4 +91,4 @@ class SkeletonPatcher { }; -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/SkeletonLimb.cpp b/soh/soh/resource/type/SkeletonLimb.cpp index 8e5a8ef6d..eb599e641 100644 --- a/soh/soh/resource/type/SkeletonLimb.cpp +++ b/soh/soh/resource/type/SkeletonLimb.cpp @@ -1,6 +1,6 @@ #include "SkeletonLimb.h" -namespace LUS { +namespace SOH { SkeletonLimbData* SkeletonLimb::GetPointer() { return &limbData; } @@ -21,4 +21,4 @@ size_t SkeletonLimb::GetPointerSize() { return 0; } } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/SkeletonLimb.h b/soh/soh/resource/type/SkeletonLimb.h index 2110b3484..bae04092c 100644 --- a/soh/soh/resource/type/SkeletonLimb.h +++ b/soh/soh/resource/type/SkeletonLimb.h @@ -4,7 +4,7 @@ #include "libultraship/libultra.h" #include "z64math.h" -namespace LUS { +namespace SOH { enum class LimbType { Invalid, Standard, @@ -97,11 +97,11 @@ union SkeletonLimbData { SkinLimb skinLimb; }; -class SkeletonLimb : public Resource { +class SkeletonLimb : public LUS::Resource { public: using Resource::Resource; - SkeletonLimb() : Resource(std::shared_ptr()) {} + SkeletonLimb() : Resource(std::shared_ptr()) {} SkeletonLimbData* GetPointer(); size_t GetPointerSize(); @@ -131,4 +131,4 @@ public: std::vector> skinLimbModifVertexArrays; std::vector> skinLimbModifTransformationArrays; }; -} // namespace LUS \ No newline at end of file +} // namespace SOH \ No newline at end of file diff --git a/soh/soh/resource/type/SohResourceType.h b/soh/soh/resource/type/SohResourceType.h new file mode 100644 index 000000000..fdf39031e --- /dev/null +++ b/soh/soh/resource/type/SohResourceType.h @@ -0,0 +1,21 @@ +#pragma once + +namespace SOH { +enum class ResourceType { + SOH_Animation = 0x4F414E4D, // OANM + SOH_PlayerAnimation = 0x4F50414D, // OPAM + SOH_Room = 0x4F524F4D, // OROM + SOH_CollisionHeader = 0x4F434F4C, // OCOL + SOH_Skeleton = 0x4F534B4C, // OSKL + SOH_SkeletonLimb = 0x4F534C42, // OSLB + SOH_Path = 0x4F505448, // OPTH + SOH_Cutscene = 0x4F435654, // OCUT + SOH_Text = 0x4F545854, // OTXT + SOH_Audio = 0x4F415544, // OAUD + SOH_AudioSample = 0x4F534D50, // OSMP + SOH_AudioSoundFont = 0x4F534654, // OSFT + SOH_AudioSequence = 0x4F534551, // OSEQ + SOH_Background = 0x4F424749, // OBGI + SOH_SceneCommand = 0x4F52434D, // ORCM +}; +} // namespace SOH diff --git a/soh/soh/resource/type/Text.cpp b/soh/soh/resource/type/Text.cpp index eee289f8a..4678dbbad 100644 --- a/soh/soh/resource/type/Text.cpp +++ b/soh/soh/resource/type/Text.cpp @@ -1,6 +1,6 @@ #include "Text.h" -namespace LUS { +namespace SOH { MessageEntry* Text::GetPointer() { return messages.data(); } @@ -8,4 +8,4 @@ MessageEntry* Text::GetPointer() { size_t Text::GetPointerSize() { return messages.size() * sizeof(MessageEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/Text.h b/soh/soh/resource/type/Text.h index db0cb36a0..03cf7340b 100644 --- a/soh/soh/resource/type/Text.h +++ b/soh/soh/resource/type/Text.h @@ -5,7 +5,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { // TODO: we've moved away from using classes for this stuff class MessageEntry { @@ -16,11 +16,11 @@ public: std::string msg; }; -class Text : public Resource { +class Text : public LUS::Resource { public: using Resource::Resource; - Text() : Resource(std::shared_ptr()) {} + Text() : Resource(std::shared_ptr()) {} MessageEntry* GetPointer(); size_t GetPointerSize(); diff --git a/soh/soh/resource/type/scenecommand/EndMarker.cpp b/soh/soh/resource/type/scenecommand/EndMarker.cpp index 9d12c1518..ba8898187 100644 --- a/soh/soh/resource/type/scenecommand/EndMarker.cpp +++ b/soh/soh/resource/type/scenecommand/EndMarker.cpp @@ -1,6 +1,6 @@ #include "EndMarker.h" -namespace LUS { +namespace SOH { Marker* EndMarker::GetPointer() { return &endMarker; } @@ -8,4 +8,4 @@ Marker* EndMarker::GetPointer() { size_t EndMarker::GetPointerSize() { return sizeof(Marker); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/EndMarker.h b/soh/soh/resource/type/scenecommand/EndMarker.h index 9f981f1f9..4f45051c2 100644 --- a/soh/soh/resource/type/scenecommand/EndMarker.h +++ b/soh/soh/resource/type/scenecommand/EndMarker.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { } Marker; diff --git a/soh/soh/resource/type/scenecommand/RomFile.h b/soh/soh/resource/type/scenecommand/RomFile.h index ebdc3dc3b..19a5545e7 100644 --- a/soh/soh/resource/type/scenecommand/RomFile.h +++ b/soh/soh/resource/type/scenecommand/RomFile.h @@ -2,7 +2,7 @@ #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ uintptr_t vromStart; /* 0x04 */ uintptr_t vromEnd; diff --git a/soh/soh/resource/type/scenecommand/SceneCommand.h b/soh/soh/resource/type/scenecommand/SceneCommand.h index 6fb845568..5eb44ae9d 100644 --- a/soh/soh/resource/type/scenecommand/SceneCommand.h +++ b/soh/soh/resource/type/scenecommand/SceneCommand.h @@ -6,7 +6,7 @@ #include "Resource.h" #include -namespace LUS { +namespace SOH { enum class SceneCommandID : uint8_t { SetStartPositionList = 0x00, @@ -47,10 +47,10 @@ enum class SceneCommandID : uint8_t { Error = 0xFF }; -class ISceneCommand : public IResource { +class ISceneCommand : public LUS::IResource { public: using IResource::IResource; - ISceneCommand() : IResource(std::shared_ptr()) {} + ISceneCommand() : IResource(std::shared_ptr()) {} SceneCommandID cmdId; }; diff --git a/soh/soh/resource/type/scenecommand/SetActorList.cpp b/soh/soh/resource/type/scenecommand/SetActorList.cpp index d37ebb148..5bb62e764 100644 --- a/soh/soh/resource/type/scenecommand/SetActorList.cpp +++ b/soh/soh/resource/type/scenecommand/SetActorList.cpp @@ -1,6 +1,6 @@ #include "SetActorList.h" -namespace LUS { +namespace SOH { ActorEntry* SetActorList::GetPointer() { return actorList.data(); } @@ -8,4 +8,4 @@ ActorEntry* SetActorList::GetPointer() { size_t SetActorList::GetPointerSize() { return actorList.size() * sizeof(ActorEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetActorList.h b/soh/soh/resource/type/scenecommand/SetActorList.h index 117175d7d..0eb53c585 100644 --- a/soh/soh/resource/type/scenecommand/SetActorList.h +++ b/soh/soh/resource/type/scenecommand/SetActorList.h @@ -9,7 +9,7 @@ // #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ s16 id; /* 0x02 */ Vec3s pos; diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp index 15b3c97d4..911fef455 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.cpp @@ -1,6 +1,6 @@ #include "SetAlternateHeaders.h" -namespace LUS { +namespace SOH { void* SetAlternateHeaders::GetPointer() { // Like Scene, SetAlternateHeader is a special type that is only acted upon in C++. return nullptr; @@ -9,4 +9,4 @@ void* SetAlternateHeaders::GetPointer() { size_t SetAlternateHeaders::GetPointerSize() { return 0; } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h index dc7272369..fdddee3f8 100644 --- a/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h +++ b/soh/soh/resource/type/scenecommand/SetAlternateHeaders.h @@ -11,7 +11,7 @@ #include -namespace LUS { +namespace SOH { class SetAlternateHeaders : public SceneCommand { public: diff --git a/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp b/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp index e1d2967e7..5c41f1c8f 100644 --- a/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetCameraSettings.cpp @@ -1,6 +1,6 @@ #include "SetCameraSettings.h" -namespace LUS { +namespace SOH { CameraSettings* SetCameraSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ CameraSettings* SetCameraSettings::GetPointer() { size_t SetCameraSettings::GetPointerSize() { return sizeof(CameraSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCameraSettings.h b/soh/soh/resource/type/scenecommand/SetCameraSettings.h index adbde2e02..1d8062f9a 100644 --- a/soh/soh/resource/type/scenecommand/SetCameraSettings.h +++ b/soh/soh/resource/type/scenecommand/SetCameraSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t cameraMovement; int32_t worldMapArea; diff --git a/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp b/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp index db8cdcb32..a1c22b9ea 100644 --- a/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp +++ b/soh/soh/resource/type/scenecommand/SetCollisionHeader.cpp @@ -1,6 +1,6 @@ #include "SetCollisionHeader.h" -namespace LUS { +namespace SOH { CollisionHeaderData* SetCollisionHeader::GetPointer() { if (collisionHeader == nullptr) { return nullptr; @@ -14,4 +14,4 @@ size_t SetCollisionHeader::GetPointerSize() { } return collisionHeader->GetPointerSize(); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h index 79573fe74..e2f63d089 100644 --- a/soh/soh/resource/type/scenecommand/SetCollisionHeader.h +++ b/soh/soh/resource/type/scenecommand/SetCollisionHeader.h @@ -9,7 +9,7 @@ #include "soh/resource/type/CollisionHeader.h" // #include -namespace LUS { +namespace SOH { class SetCollisionHeader : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetCsCamera.cpp b/soh/soh/resource/type/scenecommand/SetCsCamera.cpp index d3eafb803..762ee1e65 100644 --- a/soh/soh/resource/type/scenecommand/SetCsCamera.cpp +++ b/soh/soh/resource/type/scenecommand/SetCsCamera.cpp @@ -1,6 +1,6 @@ #include "SetCsCamera.h" -namespace LUS { +namespace SOH { CsCamera* SetCsCamera::GetPointer() { return &csCamera; } @@ -8,4 +8,4 @@ CsCamera* SetCsCamera::GetPointer() { size_t SetCsCamera::GetPointerSize() { return sizeof(CsCamera); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCsCamera.h b/soh/soh/resource/type/scenecommand/SetCsCamera.h index db0e3d682..c44d9f935 100644 --- a/soh/soh/resource/type/scenecommand/SetCsCamera.h +++ b/soh/soh/resource/type/scenecommand/SetCsCamera.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { } CsCamera; diff --git a/soh/soh/resource/type/scenecommand/SetCutscenes.cpp b/soh/soh/resource/type/scenecommand/SetCutscenes.cpp index 42d1326d5..6643eda47 100644 --- a/soh/soh/resource/type/scenecommand/SetCutscenes.cpp +++ b/soh/soh/resource/type/scenecommand/SetCutscenes.cpp @@ -1,6 +1,6 @@ #include "SetCutscenes.h" -namespace LUS { +namespace SOH { uint32_t* SetCutscenes::GetPointer() { if (cutscene == nullptr) { return nullptr; @@ -14,4 +14,4 @@ size_t SetCutscenes::GetPointerSize() { } return cutscene->GetPointerSize(); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetCutscenes.h b/soh/soh/resource/type/scenecommand/SetCutscenes.h index 482553934..be74770c0 100644 --- a/soh/soh/resource/type/scenecommand/SetCutscenes.h +++ b/soh/soh/resource/type/scenecommand/SetCutscenes.h @@ -9,7 +9,7 @@ #include "soh/resource/type/Cutscene.h" // #include -namespace LUS { +namespace SOH { class SetCutscenes : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp b/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp index 47cfa85ad..d4b2b1e15 100644 --- a/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetEchoSettings.cpp @@ -1,6 +1,6 @@ #include "SetEchoSettings.h" -namespace LUS { +namespace SOH { EchoSettings* SetEchoSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ EchoSettings* SetEchoSettings::GetPointer() { size_t SetEchoSettings::GetPointerSize() { return sizeof(EchoSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetEchoSettings.h b/soh/soh/resource/type/scenecommand/SetEchoSettings.h index ea2f664d4..30f54d1b3 100644 --- a/soh/soh/resource/type/scenecommand/SetEchoSettings.h +++ b/soh/soh/resource/type/scenecommand/SetEchoSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t echo; } EchoSettings; diff --git a/soh/soh/resource/type/scenecommand/SetEntranceList.cpp b/soh/soh/resource/type/scenecommand/SetEntranceList.cpp index d33ac189b..e82711da2 100644 --- a/soh/soh/resource/type/scenecommand/SetEntranceList.cpp +++ b/soh/soh/resource/type/scenecommand/SetEntranceList.cpp @@ -1,6 +1,6 @@ #include "SetEntranceList.h" -namespace LUS { +namespace SOH { EntranceEntry* SetEntranceList::GetPointer() { return entrances.data(); } @@ -8,4 +8,4 @@ EntranceEntry* SetEntranceList::GetPointer() { size_t SetEntranceList::GetPointerSize() { return entrances.size() * sizeof(EntranceEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetEntranceList.h b/soh/soh/resource/type/scenecommand/SetEntranceList.h index d31dda78c..7c41b4b04 100644 --- a/soh/soh/resource/type/scenecommand/SetEntranceList.h +++ b/soh/soh/resource/type/scenecommand/SetEntranceList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 spawn; /* 0x01 */ u8 room; diff --git a/soh/soh/resource/type/scenecommand/SetExitList.cpp b/soh/soh/resource/type/scenecommand/SetExitList.cpp index 99966cdb4..3de483b0e 100644 --- a/soh/soh/resource/type/scenecommand/SetExitList.cpp +++ b/soh/soh/resource/type/scenecommand/SetExitList.cpp @@ -1,6 +1,6 @@ #include "SetExitList.h" -namespace LUS { +namespace SOH { uint16_t* SetExitList::GetPointer() { return exits.data(); } @@ -8,4 +8,4 @@ uint16_t* SetExitList::GetPointer() { size_t SetExitList::GetPointerSize() { return exits.size() * sizeof(int16_t); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetExitList.h b/soh/soh/resource/type/scenecommand/SetExitList.h index c6f0b3f42..f97f11d1e 100644 --- a/soh/soh/resource/type/scenecommand/SetExitList.h +++ b/soh/soh/resource/type/scenecommand/SetExitList.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { class SetExitList : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetLightList.cpp b/soh/soh/resource/type/scenecommand/SetLightList.cpp index c59f75c20..459e957cb 100644 --- a/soh/soh/resource/type/scenecommand/SetLightList.cpp +++ b/soh/soh/resource/type/scenecommand/SetLightList.cpp @@ -1,6 +1,6 @@ #include "SetLightList.h" -namespace LUS { +namespace SOH { LightInfo* SetLightList::GetPointer() { return lightList.data(); } @@ -8,4 +8,4 @@ LightInfo* SetLightList::GetPointer() { size_t SetLightList::GetPointerSize() { return lightList.size() * sizeof(LightInfo); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetLightList.h b/soh/soh/resource/type/scenecommand/SetLightList.h index bbc5aad3d..c3ede1f16 100644 --- a/soh/soh/resource/type/scenecommand/SetLightList.h +++ b/soh/soh/resource/type/scenecommand/SetLightList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x0 */ s16 x; /* 0x2 */ s16 y; diff --git a/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp b/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp index 69127f19c..042062512 100644 --- a/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetLightingSettings.cpp @@ -1,6 +1,6 @@ #include "SetLightingSettings.h" -namespace LUS { +namespace SOH { EnvLightSettings* SetLightingSettings::GetPointer() { return settings.data(); } @@ -8,4 +8,4 @@ EnvLightSettings* SetLightingSettings::GetPointer() { size_t SetLightingSettings::GetPointerSize() { return settings.size() * sizeof(EnvLightSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetLightingSettings.h b/soh/soh/resource/type/scenecommand/SetLightingSettings.h index ca894fec3..b8f08d834 100644 --- a/soh/soh/resource/type/scenecommand/SetLightingSettings.h +++ b/soh/soh/resource/type/scenecommand/SetLightingSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 ambientColor[3]; /* 0x03 */ s8 light1Dir[3]; diff --git a/soh/soh/resource/type/scenecommand/SetMesh.cpp b/soh/soh/resource/type/scenecommand/SetMesh.cpp index 5ecd2cbfa..1e2cd396c 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.cpp +++ b/soh/soh/resource/type/scenecommand/SetMesh.cpp @@ -1,6 +1,6 @@ #include "SetMesh.h" -namespace LUS { +namespace SOH { MeshHeader* SetMesh::GetPointer() { return &meshHeader; } @@ -8,4 +8,4 @@ MeshHeader* SetMesh::GetPointer() { size_t SetMesh::GetPointerSize() { return sizeof(MeshHeader); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetMesh.h b/soh/soh/resource/type/scenecommand/SetMesh.h index a3a6c9731..33ab24202 100644 --- a/soh/soh/resource/type/scenecommand/SetMesh.h +++ b/soh/soh/resource/type/scenecommand/SetMesh.h @@ -8,7 +8,7 @@ #include "libultraship/libultra.h" #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { /* 0x00 */ u8 type; } PolygonBase; diff --git a/soh/soh/resource/type/scenecommand/SetObjectList.cpp b/soh/soh/resource/type/scenecommand/SetObjectList.cpp index 921166675..04aeb27d0 100644 --- a/soh/soh/resource/type/scenecommand/SetObjectList.cpp +++ b/soh/soh/resource/type/scenecommand/SetObjectList.cpp @@ -1,6 +1,6 @@ #include "SetObjectList.h" -namespace LUS { +namespace SOH { int16_t* SetObjectList::GetPointer() { return objects.data(); } @@ -8,4 +8,4 @@ int16_t* SetObjectList::GetPointer() { size_t SetObjectList::GetPointerSize() { return objects.size() * sizeof(int16_t); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetObjectList.h b/soh/soh/resource/type/scenecommand/SetObjectList.h index c6f786636..e843d4db0 100644 --- a/soh/soh/resource/type/scenecommand/SetObjectList.h +++ b/soh/soh/resource/type/scenecommand/SetObjectList.h @@ -8,7 +8,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { class SetObjectList : public SceneCommand { public: using SceneCommand::SceneCommand; diff --git a/soh/soh/resource/type/scenecommand/SetPathways.cpp b/soh/soh/resource/type/scenecommand/SetPathways.cpp index b69108ea6..fe1d7c5d8 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.cpp +++ b/soh/soh/resource/type/scenecommand/SetPathways.cpp @@ -1,6 +1,6 @@ #include "SetPathways.h" -namespace LUS { +namespace SOH { PathData** SetPathways::GetPointer() { return paths.data(); } @@ -8,4 +8,4 @@ PathData** SetPathways::GetPointer() { size_t SetPathways::GetPointerSize() { return paths.size() * sizeof(PathData*); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetPathways.h b/soh/soh/resource/type/scenecommand/SetPathways.h index 5846c382f..cf875cf5e 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.h +++ b/soh/soh/resource/type/scenecommand/SetPathways.h @@ -8,7 +8,7 @@ // #include #include "soh/resource/type/Path.h" -namespace LUS { +namespace SOH { class SetPathways : public SceneCommand { public: diff --git a/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp b/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp index deababc87..11bb4e95f 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp +++ b/soh/soh/resource/type/scenecommand/SetRoomBehavior.cpp @@ -1,6 +1,6 @@ #include "SetRoomBehavior.h" -namespace LUS { +namespace SOH { RoomBehavior* SetRoomBehavior::GetPointer() { return &roomBehavior; } @@ -8,4 +8,4 @@ RoomBehavior* SetRoomBehavior::GetPointer() { size_t SetRoomBehavior::GetPointerSize() { return sizeof(RoomBehavior); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h index c2a28176e..c05e96a66 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomBehavior.h +++ b/soh/soh/resource/type/scenecommand/SetRoomBehavior.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t gameplayFlags; int32_t gameplayFlags2; diff --git a/soh/soh/resource/type/scenecommand/SetRoomList.cpp b/soh/soh/resource/type/scenecommand/SetRoomList.cpp index cf8c1d61a..c81d3645e 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomList.cpp +++ b/soh/soh/resource/type/scenecommand/SetRoomList.cpp @@ -1,6 +1,6 @@ #include "SetRoomList.h" -namespace LUS { +namespace SOH { RomFile* SetRoomList::GetPointer() { return rooms.data(); } @@ -8,4 +8,4 @@ RomFile* SetRoomList::GetPointer() { size_t SetRoomList::GetPointerSize() { return rooms.size() * sizeof(RomFile); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetRoomList.h b/soh/soh/resource/type/scenecommand/SetRoomList.h index 66d83dc9c..09ba46f22 100644 --- a/soh/soh/resource/type/scenecommand/SetRoomList.h +++ b/soh/soh/resource/type/scenecommand/SetRoomList.h @@ -10,7 +10,7 @@ #include -namespace LUS { +namespace SOH { // typedef struct { // /* 0x00 */ uintptr_t vromStart; // /* 0x04 */ uintptr_t vromEnd; diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp index 9926ec01a..122d93d77 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp +++ b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.cpp @@ -1,6 +1,6 @@ #include "SetSkyboxModifier.h" -namespace LUS { +namespace SOH { SkyboxModifier* SetSkyboxModifier::GetPointer() { return &modifier; } @@ -8,4 +8,4 @@ SkyboxModifier* SetSkyboxModifier::GetPointer() { size_t SetSkyboxModifier::GetPointerSize() { return sizeof(SkyboxModifier); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h index 6a54879e6..a60adfcaf 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxModifier.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t skyboxDisabled; uint8_t sunMoonDisabled; diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp index 7f12d4fa3..527f0462c 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.cpp @@ -1,6 +1,6 @@ #include "SetSkyboxSettings.h" -namespace LUS { +namespace SOH { SkyboxSettings* SetSkyboxSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ SkyboxSettings* SetSkyboxSettings::GetPointer() { size_t SetSkyboxSettings::GetPointerSize() { return sizeof(SetSkyboxSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h index a2a9593b0..f256e103e 100644 --- a/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSkyboxSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t unk; uint8_t skyboxId; diff --git a/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp b/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp index f6f1941d1..c136d34db 100644 --- a/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetSoundSettings.cpp @@ -1,6 +1,6 @@ #include "SetSoundSettings.h" -namespace LUS { +namespace SOH { SoundSettings* SetSoundSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ SoundSettings* SetSoundSettings::GetPointer() { size_t SetSoundSettings::GetPointerSize() { return sizeof(SoundSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSoundSettings.h b/soh/soh/resource/type/scenecommand/SetSoundSettings.h index c4ee4668d..b72c2b74d 100644 --- a/soh/soh/resource/type/scenecommand/SetSoundSettings.h +++ b/soh/soh/resource/type/scenecommand/SetSoundSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t seqId; uint8_t natureAmbienceId; diff --git a/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp b/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp index 3887107da..304ab514c 100644 --- a/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp +++ b/soh/soh/resource/type/scenecommand/SetSpecialObjects.cpp @@ -1,6 +1,6 @@ #include "SetSpecialObjects.h" -namespace LUS { +namespace SOH { SpecialObjects* SetSpecialObjects::GetPointer() { return &specialObjects; } @@ -8,4 +8,4 @@ SpecialObjects* SetSpecialObjects::GetPointer() { size_t SetSpecialObjects::GetPointerSize() { return sizeof(SpecialObjects); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h index 78cfcd425..2a8906461 100644 --- a/soh/soh/resource/type/scenecommand/SetSpecialObjects.h +++ b/soh/soh/resource/type/scenecommand/SetSpecialObjects.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t elfMessage; int16_t globalObject; diff --git a/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp b/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp index 89fb40049..5fa17b2a0 100644 --- a/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp +++ b/soh/soh/resource/type/scenecommand/SetStartPositionList.cpp @@ -1,6 +1,6 @@ #include "SetStartPositionList.h" -namespace LUS { +namespace SOH { ActorEntry* SetStartPositionList::GetPointer() { return startPositions.data(); } @@ -8,4 +8,4 @@ ActorEntry* SetStartPositionList::GetPointer() { size_t SetStartPositionList::GetPointerSize() { return startPositions.size() * sizeof(ActorEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetStartPositionList.h b/soh/soh/resource/type/scenecommand/SetStartPositionList.h index 1c5d4242f..28d2d0d31 100644 --- a/soh/soh/resource/type/scenecommand/SetStartPositionList.h +++ b/soh/soh/resource/type/scenecommand/SetStartPositionList.h @@ -9,7 +9,7 @@ #include "soh/resource/type/scenecommand/SetActorList.h" // #include -namespace LUS { +namespace SOH { // typedef struct { // /* 0x00 */ s16 id; // /* 0x02 */ Vec3s pos; diff --git a/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp b/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp index 9a10fb022..c9380a0a0 100644 --- a/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetTimeSettings.cpp @@ -1,6 +1,6 @@ #include "SetTimeSettings.h" -namespace LUS { +namespace SOH { TimeSettings* SetTimeSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ TimeSettings* SetTimeSettings::GetPointer() { size_t SetTimeSettings::GetPointerSize() { return sizeof(TimeSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetTimeSettings.h b/soh/soh/resource/type/scenecommand/SetTimeSettings.h index 637398652..cd47e33dc 100644 --- a/soh/soh/resource/type/scenecommand/SetTimeSettings.h +++ b/soh/soh/resource/type/scenecommand/SetTimeSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { uint8_t hour; uint8_t minute; diff --git a/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp b/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp index 86387e682..c944e99f2 100644 --- a/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp +++ b/soh/soh/resource/type/scenecommand/SetTransitionActorList.cpp @@ -1,6 +1,6 @@ #include "SetTransitionActorList.h" -namespace LUS { +namespace SOH { TransitionActorEntry* SetTransitionActorList::GetPointer() { return transitionActorList.data(); } @@ -8,4 +8,4 @@ TransitionActorEntry* SetTransitionActorList::GetPointer() { size_t SetTransitionActorList::GetPointerSize() { return transitionActorList.size() * sizeof(TransitionActorEntry); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h index bb6fc2ac6..389526b0d 100644 --- a/soh/soh/resource/type/scenecommand/SetTransitionActorList.h +++ b/soh/soh/resource/type/scenecommand/SetTransitionActorList.h @@ -9,7 +9,7 @@ // #include #include "z64math.h" -namespace LUS { +namespace SOH { typedef struct { struct { s8 room; // Room to switch to diff --git a/soh/soh/resource/type/scenecommand/SetWindSettings.cpp b/soh/soh/resource/type/scenecommand/SetWindSettings.cpp index 3aa9ce7a6..64bc8ecc8 100644 --- a/soh/soh/resource/type/scenecommand/SetWindSettings.cpp +++ b/soh/soh/resource/type/scenecommand/SetWindSettings.cpp @@ -1,6 +1,6 @@ #include "SetWindSettings.h" -namespace LUS { +namespace SOH { WindSettings* SetWindSettings::GetPointer() { return &settings; } @@ -8,4 +8,4 @@ WindSettings* SetWindSettings::GetPointer() { size_t SetWindSettings::GetPointerSize() { return sizeof(WindSettings); } -} // namespace LUS +} // namespace SOH diff --git a/soh/soh/resource/type/scenecommand/SetWindSettings.h b/soh/soh/resource/type/scenecommand/SetWindSettings.h index e79b445ae..f3f9da968 100644 --- a/soh/soh/resource/type/scenecommand/SetWindSettings.h +++ b/soh/soh/resource/type/scenecommand/SetWindSettings.h @@ -7,7 +7,7 @@ #include "SceneCommand.h" #include -namespace LUS { +namespace SOH { typedef struct { int8_t windWest; int8_t windVertical; diff --git a/soh/soh/util.cpp b/soh/soh/util.cpp index 856432cbb..ceadb8b0e 100644 --- a/soh/soh/util.cpp +++ b/soh/soh/util.cpp @@ -336,3 +336,16 @@ std::string SohUtils::Sanitize(std::string stringValue) { return stringValue; } + +size_t SohUtils::CopyStringToCharBuffer(char* buffer, const std::string& source, const size_t maxBufferSize) { + if (!source.empty()) { + // Prevent potential horrible overflow due to implicit conversion of maxBufferSize to an unsigned. Prevents negatives. + memset(buffer, 0, std::max(0, maxBufferSize)); + // Gaurentee that this value will be greater than 0, regardless of passed variables. + const size_t copiedCharLen = std::min(std::max(0, maxBufferSize - 1), source.length()); + memcpy(buffer, source.c_str(), copiedCharLen); + return copiedCharLen; + } + + return 0; +} diff --git a/soh/soh/util.h b/soh/soh/util.h index db5af8636..827355862 100644 --- a/soh/soh/util.h +++ b/soh/soh/util.h @@ -14,4 +14,8 @@ namespace SohUtils { void CopyStringToCharArray(char* destination, std::string source, size_t size); std::string Sanitize(std::string stringValue); + + // Copies a string into a char buffer up to maxBufferSize characters. This does NOT insert a null terminator + // on the end, as this is used for in-game messages which are not null-terminated. + size_t CopyStringToCharBuffer(char* buffer, const std::string& source, size_t maxBufferSize); } // namespace SohUtils diff --git a/soh/soh/z_message_OTR.cpp b/soh/soh/z_message_OTR.cpp index 7ec7ab53b..326b4bf1f 100644 --- a/soh/soh/z_message_OTR.cpp +++ b/soh/soh/z_message_OTR.cpp @@ -15,7 +15,7 @@ extern "C" MessageTableEntry* sFraMessageEntryTablePtr; extern "C" MessageTableEntry* sStaffMessageEntryTablePtr; //extern "C" MessageTableEntry* _message_0xFFFC_nes; -static void SetMessageEntry(MessageTableEntry& entry, const LUS::MessageEntry& msgEntry) { +static void SetMessageEntry(MessageTableEntry& entry, const SOH::MessageEntry& msgEntry) { entry.textId = msgEntry.id; entry.typePos = (msgEntry.textboxType << 4) | msgEntry.textboxYPos; entry.segment = msgEntry.msg.c_str(); @@ -26,7 +26,7 @@ static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEnt auto lst = *LUS::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->ListFiles(folderPath).get(); for (auto& tPath : lst) { - auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(tPath)); + auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(tPath)); for (size_t j = 0; j < file->messages.size(); ++j) { // Check if same text ID exists already @@ -43,7 +43,7 @@ static void OTRMessage_LoadCustom(const std::string& folderPath, MessageTableEnt } MessageTableEntry* OTRMessage_LoadTable(const std::string& filePath, bool isNES) { - auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); + auto file = std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource(filePath)); if (file == nullptr) return nullptr; @@ -120,7 +120,7 @@ extern "C" void OTRMessage_Init() if (sStaffMessageEntryTablePtr == NULL) { auto file2 = - std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource( + std::static_pointer_cast(LUS::Context::GetInstance()->GetResourceManager()->LoadResource( "text/staff_message_data_static/staff_message_data_static")); // OTRTODO: Should not be malloc'ing here. It's fine for now since we check that the message table is already null. sStaffMessageEntryTablePtr = (MessageTableEntry*)malloc(sizeof(MessageTableEntry) * file2->messages.size()); diff --git a/soh/soh/z_play_otr.cpp b/soh/soh/z_play_otr.cpp index 828380ea7..522a24eb8 100644 --- a/soh/soh/z_play_otr.cpp +++ b/soh/soh/z_play_otr.cpp @@ -10,7 +10,7 @@ extern "C" void Play_InitScene(PlayState * play, s32 spawn); extern "C" void Play_InitEnvironment(PlayState * play, s16 skyboxId); void OTRPlay_InitScene(PlayState* play, s32 spawn); -s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene); +s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); //LUS::OTRResource* OTRPlay_LoadFile(PlayState* play, RomFile* file) { LUS::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName) @@ -75,7 +75,7 @@ void OTRPlay_InitScene(PlayState* play, s32 spawn) { func_80096FD4(play, &play->roomCtx.curRoom); YREG(15) = 0; gSaveContext.worldMapArea = 0; - OTRScene_ExecuteCommands(play, (LUS::Scene*)play->sceneSegment); + OTRScene_ExecuteCommands(play, (SOH::Scene*)play->sceneSegment); Play_InitEnvironment(play, play->skyboxId); // Unpause the timer for Boss Rush when the scene loaded isn't the Chamber of Sages. if (IS_BOSS_RUSH && play->sceneNum != SCENE_CHAMBER_OF_THE_SAGES) { diff --git a/soh/soh/z_scene_otr.cpp b/soh/soh/z_scene_otr.cpp index 8bfb13308..aed069698 100644 --- a/soh/soh/z_scene_otr.cpp +++ b/soh/soh/z_scene_otr.cpp @@ -37,7 +37,7 @@ extern LUS::IResource* OTRPlay_LoadFile(PlayState* play, const char* fileName); extern "C" s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId); extern "C" RomFile sNaviMsgFiles[]; -s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene); +s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene); std::shared_ptr ResourceMgr_LoadFile(const char* path) { std::string Path = path; @@ -53,9 +53,9 @@ std::shared_ptr ResourceMgr_LoadFile(const char* path) { // Forward Declaration of function declared in OTRGlobals.cpp std::shared_ptr GetResourceByNameHandlingMQ(const char* path); -bool Scene_CommandSpawnList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetStartPositionList* cmdStartPos = std::static_pointer_cast(cmd); - LUS::SetStartPositionList* cmdStartPos = (LUS::SetStartPositionList*)cmd; +bool Scene_CommandSpawnList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetStartPositionList* cmdStartPos = std::static_pointer_cast(cmd); + SOH::SetStartPositionList* cmdStartPos = (SOH::SetStartPositionList*)cmd; ActorEntry* entries = (ActorEntry*)cmdStartPos->GetRawPointer(); play->linkActorEntry = &entries[play->setupEntranceList[play->curSpawn].spawn]; @@ -67,9 +67,9 @@ bool Scene_CommandSpawnList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandActorList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetActorList* cmdActor = std::static_pointer_cast(cmd); - LUS::SetActorList* cmdActor = (LUS::SetActorList*)cmd; +bool Scene_CommandActorList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetActorList* cmdActor = std::static_pointer_cast(cmd); + SOH::SetActorList* cmdActor = (SOH::SetActorList*)cmd; play->numSetupActors = cmdActor->numActors; play->setupActorList = (ActorEntry*)cmdActor->GetRawPointer(); @@ -77,24 +77,24 @@ bool Scene_CommandActorList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandUnused2(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandUnused2(PlayState* play, SOH::ISceneCommand* cmd) { // OTRTODO: Do we need to implement this? // play->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); return false; } -bool Scene_CommandCollisionHeader(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetCollisionHeader* cmdCol = std::static_pointer_cast(cmd); - LUS::SetCollisionHeader* cmdCol = (LUS::SetCollisionHeader*)cmd; +bool Scene_CommandCollisionHeader(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetCollisionHeader* cmdCol = std::static_pointer_cast(cmd); + SOH::SetCollisionHeader* cmdCol = (SOH::SetCollisionHeader*)cmd; BgCheck_Allocate(&play->colCtx, play, (CollisionHeader*)cmdCol->GetRawPointer()); return false; } -bool Scene_CommandRoomList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetRoomList* cmdRoomList = std::static_pointer_cast(cmd); - LUS::SetRoomList* cmdRoomList = (LUS::SetRoomList*)cmd; +bool Scene_CommandRoomList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetRoomList* cmdRoomList = std::static_pointer_cast(cmd); + SOH::SetRoomList* cmdRoomList = (SOH::SetRoomList*)cmd; play->numRooms = cmdRoomList->numRooms; play->roomList = (RomFile*)cmdRoomList->GetRawPointer(); @@ -102,17 +102,17 @@ bool Scene_CommandRoomList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandEntranceList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetEntranceList* otrEntrance = std::static_pointer_cast(cmd); - LUS::SetEntranceList* otrEntrance = (LUS::SetEntranceList*)cmd; +bool Scene_CommandEntranceList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetEntranceList* otrEntrance = std::static_pointer_cast(cmd); + SOH::SetEntranceList* otrEntrance = (SOH::SetEntranceList*)cmd; play->setupEntranceList = (EntranceEntry*)otrEntrance->GetRawPointer(); return false; } -bool Scene_CommandSpecialFiles(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSpecialObjects* specialCmd = std::static_pointer_cast(cmd); - LUS::SetSpecialObjects* specialCmd = (LUS::SetSpecialObjects*)cmd; +bool Scene_CommandSpecialFiles(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSpecialObjects* specialCmd = std::static_pointer_cast(cmd); + SOH::SetSpecialObjects* specialCmd = (SOH::SetSpecialObjects*)cmd; if (specialCmd->specialObjects.globalObject != 0) { play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, specialCmd->specialObjects.globalObject); @@ -127,9 +127,9 @@ bool Scene_CommandSpecialFiles(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandRoomBehavior(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetRoomBehavior* cmdRoom = std::static_pointer_cast(cmd); - LUS::SetRoomBehavior* cmdRoom = (LUS::SetRoomBehavior*)cmd; +bool Scene_CommandRoomBehavior(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetRoomBehavior* cmdRoom = std::static_pointer_cast(cmd); + SOH::SetRoomBehavior* cmdRoom = (SOH::SetRoomBehavior*)cmd; play->roomCtx.curRoom.behaviorType1 = cmdRoom->roomBehavior.gameplayFlags; play->roomCtx.curRoom.behaviorType2 = cmdRoom->roomBehavior.gameplayFlags2 & 0xFF; @@ -139,9 +139,9 @@ bool Scene_CommandRoomBehavior(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandMeshHeader(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetMesh* otrMesh = static_pointer_cast(cmd); - LUS::SetMesh* otrMesh = (LUS::SetMesh*)cmd; +bool Scene_CommandMeshHeader(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetMesh* otrMesh = static_pointer_cast(cmd); + SOH::SetMesh* otrMesh = (SOH::SetMesh*)cmd; play->roomCtx.curRoom.meshHeader = (MeshHeader*)otrMesh->GetRawPointer(); return false; @@ -156,9 +156,9 @@ bool OTRfunc_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) { return false; } -bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetObjectList* cmdObj = static_pointer_cast(cmd); - LUS::SetObjectList* cmdObj = (LUS::SetObjectList*)cmd; +bool Scene_CommandObjectList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetObjectList* cmdObj = static_pointer_cast(cmd); + SOH::SetObjectList* cmdObj = (SOH::SetObjectList*)cmd; s32 i; s32 j; @@ -178,7 +178,7 @@ bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) { // Loop until a mismatch in the object lists // Then clear all object ids past that in the context object list and kill actors for those objects for (i = play->objectCtx.unk_09, k = 0; i < play->objectCtx.num; i++, k++) { - if (play->objectCtx.status[i].id != cmdObj->objects[k]) { + if (i >= cmdObj->objects.size() || play->objectCtx.status[i].id != cmdObj->objects[k]) { for (j = i; j < play->objectCtx.num; j++) { play->objectCtx.status[j].id = OBJECT_INVALID; } @@ -199,9 +199,9 @@ bool Scene_CommandObjectList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandLightList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetLightList* cmdLight = static_pointer_cast(cmd); - LUS::SetLightList* cmdLight = (LUS::SetLightList*)cmd; +bool Scene_CommandLightList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetLightList* cmdLight = static_pointer_cast(cmd); + SOH::SetLightList* cmdLight = (SOH::SetLightList*)cmd; for (size_t i = 0; i < cmdLight->lightList.size(); i++) { LightContext_InsertLight(play, &play->lightCtx, (LightInfo*)&cmdLight->lightList[i]); @@ -210,17 +210,17 @@ bool Scene_CommandLightList(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandPathList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetPathways* cmdPath = static_pointer_cast(cmd); - LUS::SetPathways* cmdPath = (LUS::SetPathways*)cmd; +bool Scene_CommandPathList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetPathways* cmdPath = static_pointer_cast(cmd); + SOH::SetPathways* cmdPath = (SOH::SetPathways*)cmd; play->setupPathList = (Path*)(cmdPath->GetPointer()[0]); return false; } -bool Scene_CommandTransitionActorList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetTransitionActorList* cmdActor = static_pointer_cast(cmd); - LUS::SetTransitionActorList* cmdActor = (LUS::SetTransitionActorList*)cmd; +bool Scene_CommandTransitionActorList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetTransitionActorList* cmdActor = static_pointer_cast(cmd); + SOH::SetTransitionActorList* cmdActor = (SOH::SetTransitionActorList*)cmd; play->transiActorCtx.numActors = cmdActor->numTransitionActors; play->transiActorCtx.list = (TransitionActorEntry*)cmdActor->GetRawPointer(); @@ -232,16 +232,16 @@ bool Scene_CommandTransitionActorList(PlayState* play, LUS::ISceneCommand* cmd) // transiActorCtx->numActors = 0; //} -bool Scene_CommandLightSettingsList(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandLightSettingsList(PlayState* play, SOH::ISceneCommand* cmd) { play->envCtx.lightSettingsList = (EnvLightSettings*)cmd->GetRawPointer(); return false; } // Scene Command 0x11: Skybox Settings -bool Scene_CommandSkyboxSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSkyboxSettings* cmdSky = static_pointer_cast(cmd); - LUS::SetSkyboxSettings* cmdSky = (LUS::SetSkyboxSettings*)cmd; +bool Scene_CommandSkyboxSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSkyboxSettings* cmdSky = static_pointer_cast(cmd); + SOH::SetSkyboxSettings* cmdSky = (SOH::SetSkyboxSettings*)cmd; play->skyboxId = cmdSky->settings.skyboxId; play->envCtx.unk_17 = play->envCtx.unk_18 = cmdSky->settings.weather; @@ -250,9 +250,9 @@ bool Scene_CommandSkyboxSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandSkyboxDisables(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSkyboxModifier* cmdSky = static_pointer_cast(cmd); - LUS::SetSkyboxModifier* cmdSky = (LUS::SetSkyboxModifier*)cmd; +bool Scene_CommandSkyboxDisables(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSkyboxModifier* cmdSky = static_pointer_cast(cmd); + SOH::SetSkyboxModifier* cmdSky = (SOH::SetSkyboxModifier*)cmd; play->envCtx.sunMoonDisabled = cmdSky->modifier.sunMoonDisabled; play->envCtx.skyboxDisabled = cmdSky->modifier.skyboxDisabled; @@ -260,9 +260,9 @@ bool Scene_CommandSkyboxDisables(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandTimeSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetTimeSettings* cmdTime = static_pointer_cast(cmd); - LUS::SetTimeSettings* cmdTime = (LUS::SetTimeSettings*)cmd; +bool Scene_CommandTimeSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetTimeSettings* cmdTime = static_pointer_cast(cmd); + SOH::SetTimeSettings* cmdTime = (SOH::SetTimeSettings*)cmd; if ((cmdTime->settings.hour != 0xFF) && (cmdTime->settings.minute != 0xFF)) { gSaveContext.skyboxTime = gSaveContext.dayTime = @@ -300,9 +300,9 @@ bool Scene_CommandTimeSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandWindSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetWind* cmdWind = std::static_pointer_cast(cmd); - LUS::SetWindSettings* cmdWind = (LUS::SetWindSettings*)cmd; +bool Scene_CommandWindSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetWind* cmdWind = std::static_pointer_cast(cmd); + SOH::SetWindSettings* cmdWind = (SOH::SetWindSettings*)cmd; play->envCtx.windDirection.x = cmdWind->settings.windWest; play->envCtx.windDirection.y = cmdWind->settings.windVertical; @@ -313,19 +313,19 @@ bool Scene_CommandWindSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandExitList(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandExitList(PlayState* play, SOH::ISceneCommand* cmd) { play->setupExitList = (s16*)cmd->GetRawPointer(); return false; } -bool Scene_CommandUndefined9(PlayState* play, LUS::ISceneCommand* cmd) { +bool Scene_CommandUndefined9(PlayState* play, SOH::ISceneCommand* cmd) { return false; } -bool Scene_CommandSoundSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetSoundSettings* cmdSnd = static_pointer_cast(cmd); - LUS::SetSoundSettings* cmdSnd = (LUS::SetSoundSettings*)cmd; +bool Scene_CommandSoundSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetSoundSettings* cmdSnd = static_pointer_cast(cmd); + SOH::SetSoundSettings* cmdSnd = (SOH::SetSoundSettings*)cmd; play->sequenceCtx.seqId = cmdSnd->settings.seqId; play->sequenceCtx.natureAmbienceId = cmdSnd->settings.natureAmbienceId; @@ -337,18 +337,18 @@ bool Scene_CommandSoundSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool Scene_CommandEchoSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetEchoSettings* cmdEcho = static_pointer_cast(cmd); - LUS::SetEchoSettings* cmdEcho = (LUS::SetEchoSettings*)cmd; +bool Scene_CommandEchoSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetEchoSettings* cmdEcho = static_pointer_cast(cmd); + SOH::SetEchoSettings* cmdEcho = (SOH::SetEchoSettings*)cmd; play->roomCtx.curRoom.echo = cmdEcho->settings.echo; return false; } -bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetAlternateHeaders* cmdHeaders = static_pointer_cast(cmd); - LUS::SetAlternateHeaders* cmdHeaders = (LUS::SetAlternateHeaders*)cmd; +bool Scene_CommandAlternateHeaderList(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetAlternateHeaders* cmdHeaders = static_pointer_cast(cmd); + SOH::SetAlternateHeaders* cmdHeaders = (SOH::SetAlternateHeaders*)cmd; // s32 pad; // SceneCmd* altHeader; @@ -358,8 +358,8 @@ bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) // osSyncPrintf("\n[ZU]sceneset counter=[%X]", ((void)0, gSaveContext.sceneSetupIndex)); if (gSaveContext.sceneSetupIndex != 0) { - LUS::Scene* desiredHeader = - std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1]).get(); + SOH::Scene* desiredHeader = + std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 1]).get(); if (desiredHeader != nullptr) { OTRScene_ExecuteCommands(play, desiredHeader); @@ -369,8 +369,8 @@ bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) osSyncPrintf("\nげぼはっ! 指定されたデータがないでええっす!"); if (gSaveContext.sceneSetupIndex == 3) { - LUS::Scene* desiredHeader = - std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 2]).get(); + SOH::Scene* desiredHeader = + std::static_pointer_cast(cmdHeaders->headers[gSaveContext.sceneSetupIndex - 2]).get(); // "Using adult day data there!" osSyncPrintf("\nそこで、大人の昼データを使用するでええっす!!"); @@ -385,9 +385,9 @@ bool Scene_CommandAlternateHeaderList(PlayState* play, LUS::ISceneCommand* cmd) return false; } -bool Scene_CommandCutsceneData(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetCutscenes* cmdCS = std::static_pointer_cast(cmd); - LUS::SetCutscenes* cmdCS = (LUS::SetCutscenes*)cmd; +bool Scene_CommandCutsceneData(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetCutscenes* cmdCS = std::static_pointer_cast(cmd); + SOH::SetCutscenes* cmdCS = (SOH::SetCutscenes*)cmd; play->csCtx.segment = cmdCS->cutscene->commands.data(); @@ -396,9 +396,9 @@ bool Scene_CommandCutsceneData(PlayState* play, LUS::ISceneCommand* cmd) { } // Camera & World Map Area -bool Scene_CommandMiscSettings(PlayState* play, LUS::ISceneCommand* cmd) { - // LUS::SetCameraSettings* cmdCam = std::static_pointer_cast(cmd); - LUS::SetCameraSettings* cmdCam = (LUS::SetCameraSettings*)cmd; +bool Scene_CommandMiscSettings(PlayState* play, SOH::ISceneCommand* cmd) { + // SOH::SetCameraSettings* cmdCam = std::static_pointer_cast(cmd); + SOH::SetCameraSettings* cmdCam = (SOH::SetCameraSettings*)cmd; YREG(15) = cmdCam->settings.cameraMovement; gSaveContext.worldMapArea = cmdCam->settings.worldMapArea; @@ -420,7 +420,7 @@ bool Scene_CommandMiscSettings(PlayState* play, LUS::ISceneCommand* cmd) { return false; } -bool (*sceneCommands[])(PlayState*, LUS::ISceneCommand*) = { +bool (*sceneCommands[])(PlayState*, SOH::ISceneCommand*) = { Scene_CommandSpawnList, // SCENE_CMD_ID_SPAWN_LIST Scene_CommandActorList, // SCENE_CMD_ID_ACTOR_LIST Scene_CommandUnused2, // SCENE_CMD_ID_UNUSED_2 @@ -449,8 +449,8 @@ bool (*sceneCommands[])(PlayState*, LUS::ISceneCommand*) = { Scene_CommandMiscSettings, // SCENE_CMD_ID_MISC_SETTINGS }; -s32 OTRScene_ExecuteCommands(PlayState* play, LUS::Scene* scene) { - LUS::SceneCommandID cmdCode; +s32 OTRScene_ExecuteCommands(PlayState* play, SOH::Scene* scene) { + SOH::SceneCommandID cmdCode; for (int i = 0; i < scene->commands.size(); i++) { auto sceneCmd = scene->commands[i]; @@ -487,7 +487,7 @@ extern "C" s32 OTRfunc_800973FC(PlayState* play, RoomContext* roomCtx) { roomCtx->curRoom.segment = roomCtx->unk_34; gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); - OTRScene_ExecuteCommands(play, (LUS::Scene*)roomCtx->roomToLoad); + OTRScene_ExecuteCommands(play, (SOH::Scene*)roomCtx->roomToLoad); Player_SetBootData(play, GET_PLAYER(play)); Actor_SpawnTransitionActors(play, &play->actorCtx); @@ -523,7 +523,7 @@ extern "C" s32 OTRfunc_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomN //&roomCtx->loadQueue, NULL, __FILE__, __LINE__); auto roomData = - std::static_pointer_cast(GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName)); + std::static_pointer_cast(GetResourceByNameHandlingMQ(play->roomList[roomNum].fileName)); roomCtx->status = 1; roomCtx->roomToLoad = roomData.get(); diff --git a/soh/src/code/code_800430A0.c b/soh/src/code/code_800430A0.c index abaf88405..379f4a3e6 100644 --- a/soh/src/code/code_800430A0.c +++ b/soh/src/code/code_800430A0.c @@ -48,7 +48,7 @@ void func_800432A0(CollisionContext* colCtx, s32 bgId, Actor* actor) { s16 rot = colCtx->dyna.bgActors[bgId].curTransform.rot.y - colCtx->dyna.bgActors[bgId].prevTransform.rot.y; if (actor->id == ACTOR_PLAYER) { - ((Player*)actor)->currentYaw += rot; + ((Player*)actor)->yaw += rot; } actor->shape.rot.y += rot; diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 089ed475a..a8924398b 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -486,7 +486,7 @@ void func_8002C124(TargetContext* targetCtx, PlayState* play) { func_8002BE64(targetCtx, targetCtx->unk_4C, spBC.x, spBC.y, spBC.z); - if ((!(player->stateFlags1 & 0x40)) || (actor != player->unk_664)) { + if ((!(player->stateFlags1 & PLAYER_STATE1_TEXT_ON_SCREEN)) || (actor != player->unk_664)) { OVERLAY_DISP = Gfx_SetupDL(OVERLAY_DISP, 0x39); for (spB0 = 0, spAC = targetCtx->unk_4C; spB0 < spB8; spB0++, spAC = (spAC + 1) % 3) { @@ -1376,7 +1376,7 @@ f32 Actor_HeightDiff(Actor* actorA, Actor* actorB) { } f32 Player_GetHeight(Player* player) { - f32 offset = (player->stateFlags1 & 0x800000) ? 32.0f : 0.0f; + f32 offset = (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) ? 32.0f : 0.0f; if (LINK_IS_ADULT) { return offset + 68.0f; @@ -1386,9 +1386,9 @@ f32 Player_GetHeight(Player* player) { } f32 func_8002DCE4(Player* player) { - if (player->stateFlags1 & 0x800000) { + if (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) { return 8.0f; - } else if (player->stateFlags1 & 0x8000000) { + } else if (player->stateFlags1 & PLAYER_STATE1_IN_WATER) { return (R_RUN_SPEED_LIMIT / 100.0f) * 0.6f; } else { return R_RUN_SPEED_LIMIT / 100.0f; @@ -1396,7 +1396,7 @@ f32 func_8002DCE4(Player* player) { } s32 func_8002DD6C(Player* player) { - return player->stateFlags1 & 0x8; + return player->stateFlags1 & PLAYER_STATE1_ITEM_IN_HAND; } s32 func_8002DD78(Player* player) { @@ -1406,19 +1406,19 @@ s32 func_8002DD78(Player* player) { s32 func_8002DDA8(PlayState* play) { Player* player = GET_PLAYER(play); - return (player->stateFlags1 & 0x800) || func_8002DD78(player); + return (player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) || func_8002DD78(player); } s32 func_8002DDE4(PlayState* play) { Player* player = GET_PLAYER(play); - return player->stateFlags2 & 0x8; + return player->stateFlags2 & PLAYER_STATE2_FOOTSTEP; } s32 func_8002DDF4(PlayState* play) { Player* player = GET_PLAYER(play); - return player->stateFlags2 & 0x1000; + return player->stateFlags2 & PLAYER_STATE2_STATIONARY_LADDER; } void func_8002DE04(PlayState* play, Actor* actorA, Actor* actorB) { @@ -1440,12 +1440,12 @@ void func_8002DE74(PlayState* play, Player* player) { void Actor_MountHorse(PlayState* play, Player* player, Actor* horse) { player->rideActor = horse; - player->stateFlags1 |= 0x800000; + player->stateFlags1 |= PLAYER_STATE1_ON_HORSE; horse->child = &player->actor; } s32 func_8002DEEC(Player* player) { - return (player->stateFlags1 & 0x20000080) || (player->csAction != 0); + return (player->stateFlags1 & (PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_CUTSCENE)) || (player->csAction != 0); } void func_8002DF18(PlayState* play, Player* player) { @@ -2005,10 +2005,13 @@ u32 Actor_HasParent(Actor* actor, PlayState* play) { s32 GiveItemEntryWithoutActor(PlayState* play, GetItemEntry getItemEntry) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_DEAD | PLAYER_STATE1_CHARGING_SPIN_ATTACK | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | + PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_FIRST_PERSON | PLAYER_STATE1_CLIMBING_LADDER)) && + Player_GetExplosiveHeld(player) < 0) { if (((player->heldActor != NULL) && ((getItemEntry.getItemId > GI_NONE) && (getItemEntry.getItemId < GI_MAX)) || (IS_RANDO && (getItemEntry.getItemId > RG_NONE) && (getItemEntry.getItemId < RG_MAX))) || - (!(player->stateFlags1 & 0x20000800))) { + (!(player->stateFlags1 & (PLAYER_STATE1_ITEM_OVER_HEAD | PLAYER_STATE1_IN_CUTSCENE)))) { if ((getItemEntry.getItemId != GI_NONE)) { player->getItemEntry = getItemEntry; player->getItemId = getItemEntry.getItemId; @@ -2041,11 +2044,14 @@ s32 GiveItemEntryWithoutActor(PlayState* play, GetItemEntry getItemEntry) { s32 GiveItemEntryFromActor(Actor* actor, PlayState* play, GetItemEntry getItemEntry, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_DEAD | PLAYER_STATE1_CHARGING_SPIN_ATTACK | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | + PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_FIRST_PERSON | PLAYER_STATE1_CLIMBING_LADDER)) && + Player_GetExplosiveHeld(player) < 0) { if ((((player->heldActor != NULL) || (actor == player->targetActor)) && ((!IS_RANDO && ((getItemEntry.getItemId > GI_NONE) && (getItemEntry.getItemId < GI_MAX))) || (IS_RANDO && ((getItemEntry.getItemId > RG_NONE) && (getItemEntry.getItemId < RG_MAX))))) || - (!(player->stateFlags1 & 0x20000800))) { + (!(player->stateFlags1 & (PLAYER_STATE1_ITEM_OVER_HEAD | PLAYER_STATE1_IN_CUTSCENE)))) { if ((actor->xzDistToPlayer < xzRange) && (fabsf(actor->yDistToPlayer) < yRange)) { s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; s32 absYawDiff = ABS(yawDiff); @@ -2083,10 +2089,13 @@ void GiveItemEntryFromActorWithFixedRange(Actor* actor, PlayState* play, GetItem s32 func_8002F434(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_DEAD | PLAYER_STATE1_CHARGING_SPIN_ATTACK | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | + PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_FIRST_PERSON | PLAYER_STATE1_CLIMBING_LADDER)) && + Player_GetExplosiveHeld(player) < 0) { if ((((player->heldActor != NULL) || (actor == player->targetActor)) && ((!IS_RANDO && ((getItemId > GI_NONE) && (getItemId < GI_MAX))) || (IS_RANDO && ((getItemId > RG_NONE) && (getItemId < RG_MAX))))) || - (!(player->stateFlags1 & 0x20000800))) { + (!(player->stateFlags1 & (PLAYER_STATE1_ITEM_OVER_HEAD | PLAYER_STATE1_IN_CUTSCENE)))) { if ((actor->xzDistToPlayer < xzRange) && (fabsf(actor->yDistToPlayer) < yRange)) { s16 yawDiff = actor->yawTowardsPlayer - player->actor.shape.rot.y; s32 absYawDiff = ABS(yawDiff); @@ -2156,7 +2165,9 @@ s32 Actor_IsMounted(PlayState* play, Actor* horse) { u32 Actor_SetRideActor(PlayState* play, Actor* horse, s32 mountSide) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x003C7880)) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_DEAD | PLAYER_STATE1_ITEM_OVER_HEAD | PLAYER_STATE1_CHARGING_SPIN_ATTACK | PLAYER_STATE1_HANGING_OFF_LEDGE | + PLAYER_STATE1_CLIMBING_LEDGE | PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_FIRST_PERSON | PLAYER_STATE1_CLIMBING_LADDER))) { player->rideActor = horse; player->mountSide = mountSide; return true; @@ -2501,8 +2512,18 @@ void func_800304DC(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEnt } u32 D_80116068[ACTORCAT_MAX] = { - 0x100000C0, 0x100000C0, 0x00000000, 0x100004C0, 0x00000080, 0x300000C0, - 0x10000080, 0x00000000, 0x300000C0, 0x100004C0, 0x00000000, 0x100000C0, + PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS, + PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS, + 0, + PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_GETTING_ITEM | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS, + PLAYER_STATE1_DEAD, + PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE, + PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS, + 0, + PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE, + PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_GETTING_ITEM | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS, + 0, + PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS, }; void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { @@ -2543,11 +2564,11 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { sp80 = &D_80116068[0]; - if (player->stateFlags2 & 0x8000000) { + if (player->stateFlags2 & PLAYER_STATE2_OCARINA_PLAYING) { unkFlag = ACTOR_FLAG_NO_FREEZE_OCARINA; } - if ((player->stateFlags1 & 0x40) && ((player->actor.textId & 0xFF00) != 0x600)) { + if ((player->stateFlags1 & PLAYER_STATE1_TEXT_ON_SCREEN) && ((player->actor.textId & 0xFF00) != 0x600)) { sp74 = player->targetActor; } @@ -3891,7 +3912,7 @@ s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 s32 Actor_IsTargeted(PlayState* play, Actor* actor) { Player* player = GET_PLAYER(play); - if ((player->stateFlags1 & 0x10) && actor->isTargeted) { + if ((player->stateFlags1 & PLAYER_STATE1_ENEMY_TARGET) && actor->isTargeted) { return true; } else { return false; @@ -3904,7 +3925,7 @@ s32 Actor_IsTargeted(PlayState* play, Actor* actor) { s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor) { Player* player = GET_PLAYER(play); - if ((player->stateFlags1 & 0x10) && !actor->isTargeted) { + if ((player->stateFlags1 & PLAYER_STATE1_ENEMY_TARGET) && !actor->isTargeted) { return true; } else { return false; diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index ec3981397..90634ea31 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -522,7 +522,7 @@ s32 Camera_GetWaterBoxDataIdx(Camera* camera, f32* waterY) { return -1; } - if (!(camera->player->stateFlags1 & 0x8000000)) { + if (!(camera->player->stateFlags1 & PLAYER_STATE1_IN_WATER)) { // player is not swimming *waterY = BGCHECK_Y_MIN; return -1; @@ -1031,7 +1031,7 @@ s32 Camera_CalcAtForParallel(Camera* camera, VecSph* arg1, f32 yOffset, f32* arg } if (camera->playerGroundY == camera->playerPosRot.pos.y || camera->player->actor.gravity > -0.1f || - camera->player->stateFlags1 & 0x200000) { + camera->player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) { *arg3 = Camera_LERPCeilF(playerPosRot->pos.y, *arg3, PCT(OREG(43)), 0.1f); phi_f20 = playerPosRot->pos.y - *arg3; posOffsetTarget.y -= phi_f20; @@ -1134,7 +1134,7 @@ s32 Camera_CalcAtForLockOn(Camera* camera, VecSph* eyeAtDir, Vec3f* targetPos, f tmpPos0.z = tmpPos0.z + lookFromOffset.z; if (camera->playerGroundY == camera->playerPosRot.pos.y || camera->player->actor.gravity > -0.1f || - camera->player->stateFlags1 & 0x200000) { + camera->player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) { *yPosOffset = Camera_LERPCeilF(playerPosRot->pos.y, *yPosOffset, PCT(OREG(43)), 0.1f); yPosDelta = playerPosRot->pos.y - *yPosOffset; tmpPos0.y -= yPosDelta; @@ -1679,7 +1679,9 @@ s32 Camera_Normal1(Camera* camera) { if (anim->startSwingTimer <= 0) { // idle camera re-center - if (CVarGetInteger("gA11yDisableIdleCam", 0)) return; + if (CVarGetInteger("gA11yDisableIdleCam", 0)) { + return 1; + } eyeAdjustment.pitch = atEyeNextGeo.pitch; eyeAdjustment.yaw = Camera_LERPCeilS(anim->swingYawTarget, atEyeNextGeo.yaw, 1.0f / camera->yawUpdateRateInv, 0xA); @@ -2203,7 +2205,7 @@ s32 Camera_Parallel1(Camera* camera) { } if (camera->playerGroundY == camera->playerPosRot.pos.y || camera->player->actor.gravity > -0.1f || - camera->player->stateFlags1 & 0x200000) { + camera->player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) { anim->yTarget = playerPosRot->pos.y; sp6A = 0; } else { @@ -2907,7 +2909,7 @@ s32 Camera_Battle1(Camera* camera) { sp78 = batt1->swingPitchFinal; fov = batt1->fov; - if (camera->player->stateFlags1 & 0x1000) { + if (camera->player->stateFlags1 & PLAYER_STATE1_CHARGING_SPIN_ATTACK) { // charging sword. anim->unk_10 = Camera_LERPCeilF(PCT(OREG(12)) * 0.5f, anim->unk_10, PCT(OREG(25)), 0.1f); camera->xzOffsetUpdateRate = Camera_LERPCeilF(0.2f, camera->xzOffsetUpdateRate, PCT(OREG(25)), 0.1f); @@ -2978,7 +2980,7 @@ s32 Camera_Battle1(Camera* camera) { } if (camera->playerGroundY == camera->playerPosRot.pos.y || camera->player->actor.gravity > -0.1f || - camera->player->stateFlags1 & 0x200000) { + camera->player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) { isOffGround = false; anim->yPosOffset = playerPosRot->pos.y; } else { @@ -3303,7 +3305,7 @@ s32 Camera_KeepOn1(Camera* camera) { anim->unk_0C = NULL; cont: if (camera->playerGroundY == camera->playerPosRot.pos.y || camera->player->actor.gravity > -0.1f || - camera->player->stateFlags1 & 0x200000) { + camera->player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) { anim->unk_08 = playerPosRot->pos.y; sp80 = 0; } else { @@ -3724,7 +3726,7 @@ s32 Camera_KeepOn4(Camera* camera) { keep4->unk_04 = playerHeight * 1.6f * yNormal; keep4->unk_08 = -2.0f; keep4->unk_0C = 120.0f; - keep4->unk_10 = player->stateFlags1 & 0x8000000 ? 0.0f : 20.0f; + keep4->unk_10 = player->stateFlags1 & PLAYER_STATE1_IN_WATER ? 0.0f : 20.0f; keep4->unk_1C = 0x3212; keep4->unk_1E = 0x1E; keep4->unk_18 = 50.0f; @@ -4982,7 +4984,7 @@ s32 Camera_Unique0(Camera* camera) { camera->animState++; } - if (player->stateFlags1 & 0x20000000) { + if (player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) { anim->initalPos = playerPosRot->pos; } @@ -4990,7 +4992,7 @@ s32 Camera_Unique0(Camera* camera) { if (anim->animTimer > 0) { anim->animTimer--; anim->initalPos = playerPosRot->pos; - } else if ((!(player->stateFlags1 & 0x20000000)) && + } else if ((!(player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE)) && ((OLib_Vec3fDistXZ(&playerPosRot->pos, &anim->initalPos) >= 10.0f) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || @@ -5018,7 +5020,7 @@ s32 Camera_Unique0(Camera* camera) { anim->initalPos = playerPosRot->pos; } - if ((!(player->stateFlags1 & 0x20000000)) && + if ((!(player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE)) && ((0.001f < camera->xzSpeed) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_A) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_B) || CHECK_BTN_ALL(D_8015BD7C->state.input[0].press.button, BTN_CLEFT) || @@ -5235,7 +5237,7 @@ s32 Camera_Unique9(Camera* camera) { D_8011D3AC = anim->curKeyFrame->unk_01 & 0xF; } else if ((anim->curKeyFrame->unk_01 & 0xF0) == 0xC0) { Camera_UpdateInterface(0xF000 | ((anim->curKeyFrame->unk_01 & 0xF) << 8)); - } else if (camera->player->stateFlags1 & 0x8000000 && player->currentBoots != PLAYER_BOOTS_IRON) { + } else if (camera->player->stateFlags1 & PLAYER_STATE1_IN_WATER && player->currentBoots != PLAYER_BOOTS_IRON) { func_8002DF38(camera->play, camera->target, 8); osSyncPrintf("camera: demo: player demo set WAIT\n"); } else { @@ -5610,7 +5612,7 @@ s32 Camera_Unique9(Camera* camera) { // Set the player's position camera->player->actor.world.pos.x = anim->playerPos.x; camera->player->actor.world.pos.z = anim->playerPos.z; - if (camera->player->stateFlags1 & 0x8000000 && player->currentBoots != PLAYER_BOOTS_IRON) { + if (camera->player->stateFlags1 & PLAYER_STATE1_IN_WATER && player->currentBoots != PLAYER_BOOTS_IRON) { camera->player->actor.world.pos.y = anim->playerPos.y; } } else { @@ -6171,16 +6173,16 @@ s32 Camera_Demo5(Camera* camera) { sDemo5PrevSfxFrame = camera->play->state.frames; - if (camera->player->stateFlags1 & 0x8000000 && (player->currentBoots != PLAYER_BOOTS_IRON)) { + if (camera->player->stateFlags1 & PLAYER_STATE1_IN_WATER && (player->currentBoots != PLAYER_BOOTS_IRON)) { // swimming, and not iron boots - player->stateFlags1 |= 0x20000000; + player->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; // env frozen player->actor.freezeTimer = camera->timer; } else { sp4A = playerhead.rot.y - playerTargetGeo.yaw; if (camera->target->category == ACTORCAT_PLAYER) { pad = camera->play->state.frames - sDemo5PrevAction12Frame; - if (player->stateFlags1 & 0x800) { + if (player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) { // holding object over head. func_8002DF54(camera->play, camera->target, 8); } else if (ABS(pad) > 3000) { @@ -7240,7 +7242,7 @@ s32 Camera_UpdateWater(Camera* camera) { } if (camera->unk_14C & 0x200) { - if (player->stateFlags2 & 0x800) { + if (player->stateFlags2 & PLAYER_STATE2_DIVING) { Camera_ChangeSettingFlags(camera, CAM_SET_PIVOT_WATER_SURFACE, 6); camera->unk_14C |= (s16)0x8000; } else if (camera->unk_14C & (s16)0x8000) { @@ -7730,7 +7732,7 @@ void Camera_Finish(Camera* camera) { if ((camera->parentCamIdx == MAIN_CAM) && (camera->csId != 0)) { player->actor.freezeTimer = 0; - player->stateFlags1 &= ~0x20000000; + player->stateFlags1 &= ~PLAYER_STATE1_IN_CUTSCENE; if (player->csAction != 0) { func_8002DF54(camera->play, &player->actor, 7); diff --git a/soh/src/code/z_construct.c b/soh/src/code/z_construct.c index b95902cc5..c8a340492 100644 --- a/soh/src/code/z_construct.c +++ b/soh/src/code/z_construct.c @@ -430,7 +430,9 @@ void Regs_InitDataImpl(void) { WREG(28) = 0; R_OW_MINIMAP_X = 238; R_OW_MINIMAP_Y = 164; - R_MINIMAP_DISABLED = CVarGetInteger("gMinimalUI", 0); + if (!CVarGetInteger("gEnhancements.RememberMapToggleState", 0)) { + R_MINIMAP_DISABLED = CVarGetInteger("gMinimalUI", 0); + } WREG(32) = 122; WREG(33) = 60; WREG(35) = 0; diff --git a/soh/src/code/z_eff_blure.c b/soh/src/code/z_eff_blure.c index 91ac43766..e770a9096 100644 --- a/soh/src/code/z_eff_blure.c +++ b/soh/src/code/z_eff_blure.c @@ -203,13 +203,17 @@ s32 EffectBlure_Update(void* thisx) { EffectBlure* this = (EffectBlure*)thisx; s32 i; Color_RGBA8 color; - u8 changed = 0; + static u8 changed = 0; + u8 reset = 0; switch (this->trailType) { //there HAS to be a better way to do this. case 2: if (CVarGetInteger("gCosmetics.Trails_Boomerang.Changed", 0)) { color = CVarGetColor("gCosmetics.Trails_Boomerang.Value", (Color_RGBA8){ 255, 255, 100, 255 }); changed = 1; + } else if (changed) { + color = (Color_RGBA8){ 255, 255, 100, 255 }; + reset = 1; } break; case 3: @@ -227,36 +231,65 @@ s32 EffectBlure_Update(void* thisx) { this->p2StartColor.b = color.b * 0.8f; this->p1EndColor.b = color.b * 0.6f; this->p2EndColor.b = color.b * 0.4f; + } else if (changed) { + color = (Color_RGBA8){ 250, 0, 0, 255 }; + this->p1StartColor.r = color.r; + this->p2StartColor.r = color.r * 0.8f; + this->p1EndColor.r = color.r * 0.6f; + this->p2EndColor.r = color.r * 0.4f; + this->p1StartColor.g = color.g; + this->p2StartColor.g = color.g * 0.8f; + this->p1EndColor.g = color.g * 0.6f; + this->p2EndColor.g = color.g * 0.4f; + this->p1StartColor.b = color.b; + this->p2StartColor.b = color.b * 0.8f; + this->p1EndColor.b = color.b * 0.6f; + this->p2EndColor.b = color.b * 0.4f; } break; case 4: if (CVarGetInteger("gCosmetics.Trails_KokiriSword.Changed", 0)) { color = CVarGetColor("gCosmetics.Trails_KokiriSword.Value", (Color_RGBA8){ 255, 255, 255, 255 }); changed = 1; + } else if (changed) { + color = (Color_RGBA8){ 255, 255, 255, 255 }; + reset = 1; } break; case 5: if (CVarGetInteger("gCosmetics.Trails_MasterSword.Changed", 0)) { color = CVarGetColor("gCosmetics.Trails_MasterSword.Value", (Color_RGBA8){ 255, 255, 255, 255 }); changed = 1; + } else if (changed) { + color = (Color_RGBA8){ 255, 255, 255, 255 }; + reset = 1; } break; case 6: if (CVarGetInteger("gCosmetics.Trails_BiggoronSword.Changed", 0)) { color = CVarGetColor("gCosmetics.Trails_BiggoronSword.Value", (Color_RGBA8){ 255, 255, 255, 255 }); changed = 1; + } else if (changed) { + color = (Color_RGBA8){ 255, 255, 255, 255 }; + reset = 1; } break; case 7: if (CVarGetInteger("gCosmetics.Trails_Stick.Changed", 0)) { color = CVarGetColor("gCosmetics.Trails_Stick.Value", (Color_RGBA8){ 255, 255, 255, 255 }); changed = 1; + } else if (changed) { + color = (Color_RGBA8){ 255, 255, 255, 255 }; + reset = 1; } break; case 8: if (CVarGetInteger("gCosmetics.Trails_Hammer.Changed", 0)) { color = CVarGetColor("gCosmetics.Trails_Hammer.Value", (Color_RGBA8){ 255, 255, 255, 255 }); changed = 1; + } else if (changed) { + color = (Color_RGBA8){ 255, 255, 255, 255 }; + reset = 1; } break; default: // don't do anything @@ -278,6 +311,9 @@ s32 EffectBlure_Update(void* thisx) { this->p1EndColor.b = color.b; this->p2EndColor.b = color.b; } + if (reset) { + changed = 0; + } // Don't override boomerang and bombchu trail durations if (this->trailType != 2 && this->trailType != 3) { diff --git a/soh/src/code/z_kaleido_scope_call.c b/soh/src/code/z_kaleido_scope_call.c index dd7e3fdd9..82922acd0 100644 --- a/soh/src/code/z_kaleido_scope_call.c +++ b/soh/src/code/z_kaleido_scope_call.c @@ -1,5 +1,6 @@ #include "global.h" #include "vt.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" void (*sKaleidoScopeUpdateFunc)(PlayState* play); void (*sKaleidoScopeDrawFunc)(PlayState* play); @@ -56,6 +57,8 @@ void KaleidoScopeCall_Update(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; PauseContext* pauseCtx = &play->pauseCtx; + GameInteractor_ExecuteOnKaleidoUpdate(); + if (!gSaveContext.sohStats.gameComplete && (!IS_BOSS_RUSH || !gSaveContext.isBossRushPaused)) { gSaveContext.sohStats.pauseTimer++; diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 4c661aad7..234972ff6 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -453,19 +453,20 @@ void Message_SetTextColor(MessageContext* msgCtx, u16 colorParameter) { } void Message_DrawTextboxIcon(PlayState* play, Gfx** p, s16 x, s16 y) { - static Color_RGB8 sIconPrimColors[2] = { + // SoH [Cosmetics] The following Color_RGB8 were originally static + Color_RGB8 sIconPrimColors[2] = { { 0, 80, 200 }, { 50, 130, 255 }, }; - static Color_RGB8 sIconEnvColors[2] = { + Color_RGB8 sIconEnvColors[2] = { { 0, 0, 0 }, { 0, 130, 255 }, }; if (CVarGetInteger("gCosmetics.Hud_AButton.Changed", 0)) { Color_RGB8 color = CVarGetColor24("gCosmetics.Hud_AButton.Value", (Color_RGB8){ 50, 130, 255 }); - sIconPrimColors[0].r = (color.r / 255) * 95; - sIconPrimColors[0].g = (color.g / 255) * 95; - sIconPrimColors[0].b = (color.b / 255) * 95; + sIconPrimColors[0].r = color.r - 50; + sIconPrimColors[0].g = color.g - 50; + sIconPrimColors[0].b = color.b - 50; sIconPrimColors[1] = color; sIconEnvColors[1] = color; } else if (CVarGetInteger("gCosmetics.DefaultColorScheme", COLORSCHEME_N64) == COLORSCHEME_GAMECUBE) { @@ -2006,19 +2007,21 @@ void Message_DrawMain(PlayState* play, Gfx** p) { static void* sOcarinaNoteTextures[] = { gOcarinaBtnIconATex, gOcarinaBtnIconCDownTex, gOcarinaBtnIconCRightTex, gOcarinaBtnIconCLeftTex, gOcarinaBtnIconCUpTex, }; - static Color_RGB8 sOcarinaNoteAPrimColors[2] = { + + // SoH [Cosmetics] The following Color_RGB8 were originally static + Color_RGB8 sOcarinaNoteAPrimColors[2] = { { 80, 150, 255 }, { 100, 200, 255 }, }; - static Color_RGB8 sOcarinaNoteAEnvColors[2] = { + Color_RGB8 sOcarinaNoteAEnvColors[2] = { { 10, 10, 10 }, { 50, 50, 255 }, }; if (CVarGetInteger("gCosmetics.Hud_AButton.Changed", 0)) { Color_RGB8 color = CVarGetColor24("gCosmetics.Hud_AButton.Value", (Color_RGB8){ 100, 200, 255 }); - sOcarinaNoteAPrimColors[0].r = (color.r / 255) * 95; - sOcarinaNoteAPrimColors[0].g = (color.g / 255) * 95; - sOcarinaNoteAPrimColors[0].b = (color.b / 255) * 95; + sOcarinaNoteAPrimColors[0].r = (color.r / 255.0f) * 95; + sOcarinaNoteAPrimColors[0].g = (color.g / 255.0f) * 95; + sOcarinaNoteAPrimColors[0].b = (color.b / 255.0f) * 95; sOcarinaNoteAPrimColors[1] = color; sOcarinaNoteAEnvColors[1] = color; } else if (CVarGetInteger("gCosmetics.DefaultColorScheme", COLORSCHEME_N64) == COLORSCHEME_GAMECUBE) { @@ -2027,11 +2030,11 @@ void Message_DrawMain(PlayState* play, Gfx** p) { sOcarinaNoteAEnvColors[1] = (Color_RGB8){ 50, 255, 50 }; } - static Color_RGB8 sOcarinaNoteCPrimColors[2] = { + Color_RGB8 sOcarinaNoteCPrimColors[2] = { { 255, 255, 50 }, { 255, 255, 180 }, }; - static Color_RGB8 sOcarinaNoteCEnvColors[2] = { + Color_RGB8 sOcarinaNoteCEnvColors[2] = { { 10, 10, 10 }, { 110, 110, 50 }, }; @@ -2039,16 +2042,16 @@ void Message_DrawMain(PlayState* play, Gfx** p) { Color_RGB8 color = CVarGetColor24("gCosmetics.Hud_CButtons.Value", (Color_RGB8){ 100, 200, 255 }); sOcarinaNoteCPrimColors[0] = color; sOcarinaNoteCPrimColors[1] = color; - sOcarinaNoteCEnvColors[1].r = (color.r / 255) * 95; - sOcarinaNoteCEnvColors[1].g = (color.g / 255) * 95; - sOcarinaNoteCEnvColors[1].b = (color.b / 255) * 95; + sOcarinaNoteCEnvColors[1].r = (color.r / 255.0f) * 95; + sOcarinaNoteCEnvColors[1].g = (color.g / 255.0f) * 95; + sOcarinaNoteCEnvColors[1].b = (color.b / 255.0f) * 95; } - static Color_RGB8 sOcarinaNoteCUpPrimColors[2] = { + Color_RGB8 sOcarinaNoteCUpPrimColors[2] = { { 255, 255, 50 }, { 255, 255, 180 }, }; - static Color_RGB8 sOcarinaNoteCUpEnvColors[2] = { + Color_RGB8 sOcarinaNoteCUpEnvColors[2] = { { 10, 10, 10 }, { 110, 110, 50 }, }; @@ -2056,16 +2059,16 @@ void Message_DrawMain(PlayState* play, Gfx** p) { Color_RGB8 color = CVarGetColor24("gCosmetics.Hud_CUpButton.Value", (Color_RGB8){ 100, 200, 255 }); sOcarinaNoteCUpPrimColors[0] = color; sOcarinaNoteCUpPrimColors[1] = color; - sOcarinaNoteCUpEnvColors[1].r = (color.r / 255) * 95; - sOcarinaNoteCUpEnvColors[1].g = (color.g / 255) * 95; - sOcarinaNoteCUpEnvColors[1].b = (color.b / 255) * 95; + sOcarinaNoteCUpEnvColors[1].r = (color.r / 255.0f) * 95; + sOcarinaNoteCUpEnvColors[1].g = (color.g / 255.0f) * 95; + sOcarinaNoteCUpEnvColors[1].b = (color.b / 255.0f) * 95; } - static Color_RGB8 sOcarinaNoteCDownPrimColors[2] = { + Color_RGB8 sOcarinaNoteCDownPrimColors[2] = { { 255, 255, 50 }, { 255, 255, 180 }, }; - static Color_RGB8 sOcarinaNoteCDownEnvColors[2] = { + Color_RGB8 sOcarinaNoteCDownEnvColors[2] = { { 10, 10, 10 }, { 110, 110, 50 }, }; @@ -2073,16 +2076,16 @@ void Message_DrawMain(PlayState* play, Gfx** p) { Color_RGB8 color = CVarGetColor24("gCosmetics.Hud_CDownButton.Value", (Color_RGB8){ 100, 200, 255 }); sOcarinaNoteCDownPrimColors[0] = color; sOcarinaNoteCDownPrimColors[1] = color; - sOcarinaNoteCDownEnvColors[1].r = (color.r / 255) * 95; - sOcarinaNoteCDownEnvColors[1].g = (color.g / 255) * 95; - sOcarinaNoteCDownEnvColors[1].b = (color.b / 255) * 95; + sOcarinaNoteCDownEnvColors[1].r = (color.r / 255.0f) * 95; + sOcarinaNoteCDownEnvColors[1].g = (color.g / 255.0f) * 95; + sOcarinaNoteCDownEnvColors[1].b = (color.b / 255.0f) * 95; } - static Color_RGB8 sOcarinaNoteCLeftPrimColors[2] = { + Color_RGB8 sOcarinaNoteCLeftPrimColors[2] = { { 255, 255, 50 }, { 255, 255, 180 }, }; - static Color_RGB8 sOcarinaNoteCLeftEnvColors[2] = { + Color_RGB8 sOcarinaNoteCLeftEnvColors[2] = { { 10, 10, 10 }, { 110, 110, 50 }, }; @@ -2090,16 +2093,16 @@ void Message_DrawMain(PlayState* play, Gfx** p) { Color_RGB8 color = CVarGetColor24("gCosmetics.Hud_CLeftButton.Value", (Color_RGB8){ 100, 200, 255 }); sOcarinaNoteCLeftPrimColors[0] = color; sOcarinaNoteCLeftPrimColors[1] = color; - sOcarinaNoteCLeftEnvColors[1].r = (color.r / 255) * 95; - sOcarinaNoteCLeftEnvColors[1].g = (color.g / 255) * 95; - sOcarinaNoteCLeftEnvColors[1].b = (color.b / 255) * 95; + sOcarinaNoteCLeftEnvColors[1].r = (color.r / 255.0f) * 95; + sOcarinaNoteCLeftEnvColors[1].g = (color.g / 255.0f) * 95; + sOcarinaNoteCLeftEnvColors[1].b = (color.b / 255.0f) * 95; } - static Color_RGB8 sOcarinaNoteCRightPrimColors[2] = { + Color_RGB8 sOcarinaNoteCRightPrimColors[2] = { { 255, 255, 50 }, { 255, 255, 180 }, }; - static Color_RGB8 sOcarinaNoteCRightEnvColors[2] = { + Color_RGB8 sOcarinaNoteCRightEnvColors[2] = { { 10, 10, 10 }, { 110, 110, 50 }, }; @@ -2107,9 +2110,9 @@ void Message_DrawMain(PlayState* play, Gfx** p) { Color_RGB8 color = CVarGetColor24("gCosmetics.Hud_CRightButton.Value", (Color_RGB8){ 100, 200, 255 }); sOcarinaNoteCRightPrimColors[0] = color; sOcarinaNoteCRightPrimColors[1] = color; - sOcarinaNoteCRightEnvColors[1].r = (color.r / 255) * 95; - sOcarinaNoteCRightEnvColors[1].g = (color.g / 255) * 95; - sOcarinaNoteCRightEnvColors[1].b = (color.b / 255) * 95; + sOcarinaNoteCRightEnvColors[1].r = (color.r / 255.0f) * 95; + sOcarinaNoteCRightEnvColors[1].g = (color.g / 255.0f) * 95; + sOcarinaNoteCRightEnvColors[1].b = (color.b / 255.0f) * 95; } static s16 sOcarinaNoteFlashTimer = 12; diff --git a/soh/src/code/z_onepointdemo.c b/soh/src/code/z_onepointdemo.c index 9489eefcd..2ece7c2f1 100644 --- a/soh/src/code/z_onepointdemo.c +++ b/soh/src/code/z_onepointdemo.c @@ -634,7 +634,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0; csCam->fov = 75.0f; - player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = spD0.yaw + 0x7FFF; + player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = spD0.yaw + 0x7FFF; func_8002DF54(play, NULL, 8); break; case 3240: @@ -674,7 +674,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor Quake_SetCountdown(i, D_80120698 - 20); break; case 3390: - player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = -0x3FD9; + player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = -0x3FD9; csInfo->keyFrames = D_80121DB4; csInfo->keyFrameCnt = 9; @@ -697,7 +697,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor D_80121F1C[0].eyeTargetInit = play->view.eye; D_80121F1C[0].fovTargetInit = play->view.fovy; Actor_GetFocus(&spA0, actor); - player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = spA0.rot.y; + player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = spA0.rot.y; csInfo->keyFrames = D_80121F1C; csInfo->keyFrameCnt = 4; @@ -788,7 +788,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor func_8002DF54(play, NULL, 8); func_800C0808(play, camIdx, player, CAM_SET_CS_C); - player->stateFlags1 |= 0x20000000; + player->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; player->actor.freezeTimer = 90; i = Quake_Add(csCam, 1); @@ -817,7 +817,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor csInfo->keyFrameCnt = 2; } - player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = 0x3FFC; + player->actor.shape.rot.y = player->actor.world.rot.y = player->yaw = 0x3FFC; func_800C0808(play, camIdx, player, CAM_SET_CS_C); func_8002DF54(play, NULL, 8); break; @@ -990,7 +990,7 @@ s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor if (func_800C0CB8(play)) { D_801231B4[0].eyeTargetInit.z = D_801231B4[1].eyeTargetInit.z = !LINK_IS_ADULT ? 100.0f : 120.0f; - if (player->stateFlags1 & 0x08000000) { + if (player->stateFlags1 & PLAYER_STATE1_IN_WATER) { D_801231B4[2].atTargetInit.z = 0.0f; } Actor_GetWorldPosShapeRot(&spA0, &player->actor); diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 2159d0cb3..a37841b5d 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -3841,7 +3841,7 @@ void Interface_DrawEnemyHealthBar(TargetContext* targetCtx, PlayState* play) { Interface_CreateQuadVertexGroup(&sEnemyHealthVtx[12], -floorf(halfBarWidth) + endTexWidth, (-texHeight / 2) + 3, healthBarFill, 7, 0); - if (((!(player->stateFlags1 & 0x40)) || (actor != player->unk_664)) && targetCtx->unk_44 < 500.0f) { + if (((!(player->stateFlags1 & PLAYER_STATE1_TEXT_ON_SCREEN)) || (actor != player->unk_664)) && targetCtx->unk_44 < 500.0f) { f32 slideInOffsetY = 0; // Slide in the health bar from edge of the screen (mimic the Z-Target triangles fly in) @@ -4320,7 +4320,7 @@ void Interface_DrawItemButtons(PlayState* play) { if ((gSaveContext.unk_13EA == 1) || (gSaveContext.unk_13EA == 2) || (gSaveContext.unk_13EA == 5)) { temp = 0; - } else if ((player->stateFlags1 & 0x00200000) || (Player_GetEnvironmentalHazard(play) == 4) || + } else if ((player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) || (Player_GetEnvironmentalHazard(play) == 4) || (player->stateFlags2 & PLAYER_STATE2_CRAWLING)) { temp = 70; } else { @@ -5393,7 +5393,7 @@ void Interface_Draw(PlayState* play) { Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[0]], 0); } - if ((player->stateFlags1 & 0x00800000) || (play->shootingGalleryStatus > 1) || + if ((player->stateFlags1 & PLAYER_STATE1_ON_HORSE) || (play->shootingGalleryStatus > 1) || ((play->sceneNum == SCENE_BOMBCHU_BOWLING_ALLEY) && Flags_GetSwitch(play, 0x38))) { if (!fullUi) { @@ -5858,7 +5858,7 @@ void Interface_Draw(PlayState* play) { if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (msgCtx->msgMode == MSGMODE_NONE) && - !(player->stateFlags2 & 0x01000000) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + !(player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (gSaveContext.minigameState != 1) && (play->shootingGalleryStatus <= 1) && !((play->sceneNum == SCENE_BOMBCHU_BOWLING_ALLEY) && Flags_GetSwitch(play, 0x38))) { @@ -6550,7 +6550,7 @@ void Interface_Update(PlayState* play) { HealthMeter_Update(play); if ((gSaveContext.timer1State >= 3) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && - (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & 0x01000000) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) {} if (gSaveContext.rupeeAccumulator != 0) { diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 3edaaca5b..532b01eba 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -526,7 +526,7 @@ void Player_SetBootData(PlayState* play, Player* this) { currentBoots = PLAYER_BOOTS_KOKIRI_CHILD; } } else if (currentBoots == PLAYER_BOOTS_IRON) { - if (this->stateFlags1 & 0x8000000) { + if (this->stateFlags1 & PLAYER_STATE1_IN_WATER) { currentBoots = PLAYER_BOOTS_IRON_UNDERWATER; } REG(27) = 500; @@ -564,8 +564,8 @@ uint8_t Player_IsCustomLinkModel() { } s32 Player_InBlockingCsMode(PlayState* play, Player* this) { - return (this->stateFlags1 & 0x20000080) || (this->csAction != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) || - (this->stateFlags1 & 1) || (this->stateFlags3 & 0x80) || + return (this->stateFlags1 & (PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_CUTSCENE)) || (this->csAction != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) || + (this->stateFlags1 & PLAYER_STATE1_LOADING) || (this->stateFlags3 & PLAYER_STATE3_HOOKSHOT_TRAVELLING) || ((gSaveContext.magicState != MAGIC_STATE_IDLE) && (Player_ActionToMagicSpell(this, this->itemAction) >= 0)); } @@ -576,7 +576,7 @@ s32 Player_InCsMode(PlayState* play) { } s32 func_8008E9C4(Player* this) { - return (this->stateFlags1 & 0x10); + return (this->stateFlags1 & PLAYER_STATE1_ENEMY_TARGET); } s32 Player_IsChildWithHylianShield(Player* this) { @@ -595,7 +595,7 @@ s32 Player_ActionToModelGroup(Player* this, s32 actionParam) { } void Player_SetModelsForHoldingShield(Player* this) { - if ((this->stateFlags1 & 0x400000) && + if ((this->stateFlags1 & PLAYER_STATE1_SHIELDING) && ((this->itemAction < 0) || (this->itemAction == this->heldItemAction))) { if ((CVarGetInteger("gShieldTwoHanded", 0) && (this->heldItemAction != PLAYER_IA_DEKU_STICK) || !Player_HoldsTwoHandedWeapon(this)) && !Player_IsChildWithHylianShield(this)) { @@ -737,15 +737,15 @@ void Player_UpdateBottleHeld(PlayState* play, Player* this, s32 item, s32 action void func_8008EDF0(Player* this) { this->unk_664 = NULL; - this->stateFlags2 &= ~0x2000; + this->stateFlags2 &= ~PLAYER_STATE2_SWITCH_TARGETING; } void func_8008EE08(Player* this) { - if ((this->actor.bgCheckFlags & 1) || (this->stateFlags1 & 0x8A00000) || - (!(this->stateFlags1 & 0xC0000) && ((this->actor.world.pos.y - this->actor.floorHeight) < 100.0f))) { - this->stateFlags1 &= ~0x400F8000; - } else if (!(this->stateFlags1 & 0x2C0000)) { - this->stateFlags1 |= 0x80000; + if ((this->actor.bgCheckFlags & 1) || (this->stateFlags1 & (PLAYER_STATE1_CLIMBING_LADDER | PLAYER_STATE1_ON_HORSE | PLAYER_STATE1_IN_WATER)) || + (!(this->stateFlags1 & (PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL)) && ((this->actor.world.pos.y - this->actor.floorHeight) < 100.0f))) { + this->stateFlags1 &= ~(PLAYER_STATE1_TARGETING | PLAYER_STATE1_TARGET_LOCKED | PLAYER_STATE1_TARGET_NOTHING | PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_30); + } else if (!(this->stateFlags1 & (PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_CLIMBING_LADDER))) { + this->stateFlags1 |= PLAYER_STATE1_FREEFALL; } func_8008EDF0(this); @@ -757,7 +757,7 @@ void func_8008EEAC(PlayState* play, Actor* actor) { func_8008EE08(this); this->unk_664 = actor; this->unk_684 = actor; - this->stateFlags1 |= 0x10000; + this->stateFlags1 |= PLAYER_STATE1_TARGET_LOCKED; Camera_SetParam(Play_GetCamera(play, 0), 8, actor); Camera_ChangeMode(Play_GetCamera(play, 0), 2); } @@ -765,7 +765,7 @@ void func_8008EEAC(PlayState* play, Actor* actor) { s32 func_8008EF30(PlayState* play) { Player* this = GET_PLAYER(play); - return (this->stateFlags1 & 0x800000); + return (this->stateFlags1 & PLAYER_STATE1_ON_HORSE); } s32 func_8008EF44(PlayState* play, s32 ammo) { @@ -942,7 +942,7 @@ s32 Player_GetEnvironmentalHazard(PlayState* play) { } else if ((this->underwaterTimer > 80) && ((this->currentBoots == PLAYER_BOOTS_IRON) || (this->underwaterTimer >= 300))) { // Deep underwater var = ((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & 1)) ? 1 : 3; - } else if (this->stateFlags1 & 0x8000000) { // Swimming + } else if (this->stateFlags1 & PLAYER_STATE1_IN_WATER) { // Swimming var = 2; } else { return 0; @@ -1171,7 +1171,7 @@ void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* p s16 temp2; s32 temp3; - if ((this->actor.scale.y >= 0.0f) && !(this->stateFlags1 & 0x80) && + if ((this->actor.scale.y >= 0.0f) && !(this->stateFlags1 & PLAYER_STATE1_DEAD) && (Player_ActionToMagicSpell(this, this->itemAction) < 0)) { s32 pad; @@ -1367,10 +1367,10 @@ s32 Player_OverrideLimbDrawGameplayDefault(PlayState* play, s32 limbIndex, Gfx** if ((sLeftHandType == PLAYER_MODELTYPE_LH_BGS) && (gSaveContext.swordHealth <= 0.0f)) { dLists += 4; - } else if ((sLeftHandType == PLAYER_MODELTYPE_LH_BOOMERANG) && (this->stateFlags1 & 0x2000000)) { + } else if ((sLeftHandType == PLAYER_MODELTYPE_LH_BOOMERANG) && (this->stateFlags1 & PLAYER_STATE1_THREW_BOOMERANG)) { dLists = &gPlayerLeftHandOpenDLs[gSaveContext.linkAge]; - sLeftHandType = 0; - } else if ((this->leftHandType == PLAYER_MODELTYPE_LH_OPEN) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { + sLeftHandType = PLAYER_MODELTYPE_LH_OPEN; + } else if ((this->leftHandType == PLAYER_MODELTYPE_LH_OPEN) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER)) { dLists = &gPlayerLeftHandClosedDLs[gSaveContext.linkAge]; sLeftHandType = PLAYER_MODELTYPE_LH_CLOSED; } @@ -1381,7 +1381,7 @@ s32 Player_OverrideLimbDrawGameplayDefault(PlayState* play, s32 limbIndex, Gfx** if (sRightHandType == PLAYER_MODELTYPE_RH_SHIELD) { dLists += this->currentShield * 4; - } else if ((this->rightHandType == PLAYER_MODELTYPE_RH_OPEN) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & 0x8000000)) { + } else if ((this->rightHandType == PLAYER_MODELTYPE_RH_OPEN) && (this->actor.speedXZ > 2.0f) && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER)) { dLists = &sPlayerRightHandClosedDLs[gSaveContext.linkAge]; sRightHandType = PLAYER_MODELTYPE_RH_CLOSED; } @@ -1510,7 +1510,7 @@ void Player_UpdateShieldCollider(PlayState* play, Player* this, ColliderQuad* co COLTYPE_METAL, }; - if (this->stateFlags1 & 0x400000) { + if (this->stateFlags1 & PLAYER_STATE1_SHIELDING) { Vec3f quadDest[4]; this->shieldQuad.base.colType = shieldColTypes[this->currentShield]; @@ -1544,12 +1544,12 @@ void func_800906D4(PlayState* play, Player* this, Vec3f* newTipPos) { Matrix_MultVec3f(&D_801260A4[2], &newBasePos[2]); if (func_80090480(play, NULL, &this->meleeWeaponInfo[0], &newTipPos[0], &newBasePos[0]) && - !(this->stateFlags1 & 0x400000)) { + !(this->stateFlags1 & PLAYER_STATE1_SHIELDING)) { EffectBlure_AddVertex(Effect_GetByIndex(this->meleeWeaponEffectIndex), &this->meleeWeaponInfo[0].tip, &this->meleeWeaponInfo[0].base); } - if ((this->meleeWeaponState > 0) && ((this->meleeWeaponAnimation < 0x18) || (this->stateFlags2 & 0x20000))) { + if ((this->meleeWeaponState > 0) && ((this->meleeWeaponAnimation < 0x18) || (this->stateFlags2 & PLAYER_STATE2_SPIN_ATTACKING))) { func_80090480(play, &this->meleeWeaponQuads[0], &this->meleeWeaponInfo[1], &newTipPos[1], &newBasePos[1]); func_80090480(play, &this->meleeWeaponQuads[1], &this->meleeWeaponInfo[2], &newTipPos[2], &newBasePos[2]); } @@ -1818,13 +1818,13 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve if (this->actor.scale.y >= 0.0f) { if (!Player_HoldsHookshot(this) && ((hookedActor = this->heldActor) != NULL)) { - if (this->stateFlags1 & 0x200) { + if (this->stateFlags1 & PLAYER_STATE1_READY_TO_FIRE) { Matrix_MultVec3f(&sLeftHandArrowVec3, &hookedActor->world.pos); Matrix_RotateZYX(0x69E8, -0x5708, 0x458E, MTXMODE_APPLY); Matrix_Get(&sp14C); Matrix_MtxFToYXZRotS(&sp14C, &hookedActor->world.rot, 0); hookedActor->shape.rot = hookedActor->world.rot; - } else if (this->stateFlags1 & 0x800) { + } else if (this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) { Vec3s spB8; Matrix_Get(&sp14C); @@ -1858,7 +1858,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve Matrix_Push(); Matrix_Translate(stringData->pos.x, stringData->pos.y, stringData->pos.z, MTXMODE_APPLY); - if ((this->stateFlags1 & 0x200) && (this->unk_860 >= 0) && (this->unk_834 <= 10)) { + if ((this->stateFlags1 & PLAYER_STATE1_READY_TO_FIRE) && (this->unk_860 >= 0) && (this->unk_834 <= 10)) { Vec3f sp90; f32 distXYZ; @@ -1938,7 +1938,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Ve } if ((this->unk_862 != 0) || ((func_8002DD6C(this) == 0) && (heldActor != NULL))) { - if (!(this->stateFlags1 & 0x400) && (this->unk_862 != 0) && (this->exchangeItemId != EXCH_ITEM_NONE)) { + if (!(this->stateFlags1 & PLAYER_STATE1_GETTING_ITEM) && (this->unk_862 != 0) && (this->exchangeItemId != EXCH_ITEM_NONE)) { Math_Vec3f_Copy(&sGetItemRefPos, &this->leftHandPos); } else { sGetItemRefPos.x = (this->bodyPartsPos[15].x + this->leftHandPos.x) * 0.5f; diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index 772978f09..e92925c6a 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -575,6 +575,13 @@ u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { frontRoom = gSaveContext.respawnFlag > 0 ? ((void)0, gSaveContext.respawn[gSaveContext.respawnFlag - 1].roomIndex) : play->setupEntranceList[play->curSpawn].room; + + // In ER, override roomNum to load based on scene and spawn during scene init + if (IS_RANDO && gSaveContext.respawnFlag <= 0 && + Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES)) { + frontRoom = Entrance_OverrideSpawnSceneRoom(play->sceneNum, play->curSpawn, frontRoom); + } + func_8009728C(play, roomCtx, frontRoom); return maxRoomSize; @@ -583,12 +590,6 @@ u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { size_t size; - // In ER, override roomNum to load based on scene and spawn - if (IS_RANDO && gSaveContext.respawnFlag <= 0 && - Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES)) { - roomNum = Entrance_OverrideSpawnSceneRoom(play->sceneNum, play->curSpawn, roomNum); - } - return OTRfunc_8009728C(play, roomCtx, roomNum); if (roomCtx->status == 0) { diff --git a/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 93ff272f4..0c7435da4 100644 --- a/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/soh/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -122,7 +122,7 @@ s32 ArmsHook_CheckForCancel(ArmsHook* this) { if (Player_HoldsHookshot(player)) { if ((player->itemAction != player->heldItemAction) || (player->actor.flags & ACTOR_FLAG_PLAYER_TALKED_TO) || - ((player->stateFlags1 & 0x4000080))) { + ((player->stateFlags1 & (PLAYER_STATE1_DEAD | PLAYER_STATE1_DAMAGED)))) { this->timer = 0; ArmsHook_DetachHookFromActor(this); Math_Vec3f_Copy(&this->actor.world.pos, &player->unk_3C8); diff --git a/soh/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.c b/soh/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.c index e10eb04be..ae8f9cd05 100644 --- a/soh/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.c +++ b/soh/src/overlays/actors/ovl_Bg_Gnd_Iceblock/z_bg_gnd_iceblock.c @@ -237,7 +237,7 @@ void BgGndIceblock_Idle(BgGndIceblock* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; if (this->dyna.unk_150 > 0.0f) { BgGndIceblock_SetNextPosition(this); if (Actor_WorldDistXZToPoint(&this->dyna.actor, &this->targetPos) > 1.0f) { @@ -254,7 +254,7 @@ void BgGndIceblock_Reset(BgGndIceblock* this, PlayState* play) { Actor* thisx = &this->dyna.actor; if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y, 1.0f)) { diff --git a/soh/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c b/soh/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c index 3745db003..2379b0a58 100644 --- a/soh/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c +++ b/soh/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c @@ -61,7 +61,7 @@ void func_8087B758(BgHaka* this, Player* player) { func_8002DBD0(&this->dyna.actor, &sp1C, &player->actor.world.pos); if (fabsf(sp1C.x) < 34.6f && sp1C.z > -112.8f && sp1C.z < -36.0f) { - player->stateFlags2 |= 0x200; + player->stateFlags2 |= PLAYER_STATE2_SPAWN_DUST; } } @@ -71,7 +71,7 @@ void func_8087B7E8(BgHaka* this, PlayState* play) { if (this->dyna.unk_150 != 0.0f) { if (play->sceneNum == SCENE_GRAVEYARD && !LINK_IS_ADULT && IS_DAY && !CVarGetInteger("gDayGravePull", 0)) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; if (!Play_InCsMode(play)) { Message_StartTextbox(play, 0x5073, NULL); this->dyna.actor.params = 100; @@ -80,7 +80,7 @@ void func_8087B7E8(BgHaka* this, PlayState* play) { } else if (0.0f < this->dyna.unk_150 || (play->sceneNum == SCENE_LAKE_HYLIA && !LINK_IS_ADULT && !Flags_GetSwitch(play, 0x23))) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } else { this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y + 0x8000; this->actionFunc = func_8087B938; @@ -112,7 +112,7 @@ void func_8087B938(BgHaka* this, PlayState* play) { } actor = actor->next; } - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; if (this->dyna.actor.params == 1) { func_80078884(NA_SE_SY_CORRECT_CHIME); @@ -146,7 +146,7 @@ void func_8087BAAC(BgHaka* this, PlayState* play) { if (this->dyna.unk_150 != 0.0f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } } @@ -159,7 +159,7 @@ void func_8087BAE4(BgHaka* this, PlayState* play) { } if (this->dyna.unk_150 != 0.0f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } if (this->dyna.actor.params == 0) { this->actionFunc = func_8087B7E8; diff --git a/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c b/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c index de2235b2e..c61c93a46 100644 --- a/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c +++ b/soh/src/overlays/actors/ovl_Bg_Haka_Gate/z_bg_haka_gate.c @@ -153,7 +153,7 @@ void BgHakaGate_StatueInactive(BgHakaGate* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } @@ -172,7 +172,7 @@ void BgHakaGate_StatueIdle(BgHakaGate* this, PlayState* play) { this->vTurnDirection = linkDirection * forceDirection; this->actionFunc = BgHakaGate_StatueTurn; } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; if (this->vTimer != 0) { this->vTimer--; @@ -197,7 +197,7 @@ void BgHakaGate_StatueTurn(BgHakaGate* this, PlayState* play) { turnFinished = Math_StepToS(&this->vTurnAngleDeg10, 600, this->vTurnRateDeg10); turnAngle = this->vTurnAngleDeg10 * this->vTurnDirection; this->dyna.actor.shape.rot.y = (this->vRotYDeg10 + turnAngle) * 0.1f * (0x10000 / 360.0f); - if ((player->stateFlags2 & 0x10) && (sStatueDistToPlayer > 0.0f)) { + if ((player->stateFlags2 & PLAYER_STATE2_MOVING_DYNAPOLY) && (sStatueDistToPlayer > 0.0f)) { player->actor.world.pos.x = this->dyna.actor.home.pos.x + (Math_SinS(this->dyna.actor.shape.rot.y - this->vInitTurnAngle) * sStatueDistToPlayer); @@ -209,7 +209,7 @@ void BgHakaGate_StatueTurn(BgHakaGate* this, PlayState* play) { } sStatueRotY = this->dyna.actor.shape.rot.y; if (turnFinished) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->vRotYDeg10 = (this->vRotYDeg10 + turnAngle) % 3600; this->vTurnRateDeg10 = CVarGetInteger("gFasterBlockPush", 0) * 2; this->vTurnAngleDeg10 = 0; diff --git a/soh/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c b/soh/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c index 846cc1f72..22b8c989a 100644 --- a/soh/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c +++ b/soh/src/overlays/actors/ovl_Bg_Haka_Sgami/z_bg_haka_sgami.c @@ -290,7 +290,7 @@ void BgHakaSgami_Update(Actor* thisx, PlayState* play) { BgHakaSgami* this = (BgHakaSgami*)thisx; Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x300000C0) || (this->actionFunc == BgHakaSgami_SetupSpin)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE)) || (this->actionFunc == BgHakaSgami_SetupSpin)) { this->actionFunc(this, play); } } diff --git a/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c b/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c index 8b1d99cb9..36cfb0a27 100644 --- a/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c +++ b/soh/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c @@ -151,7 +151,7 @@ void func_8088B268(BgHidanRock* this, PlayState* play) { this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.unk_158) * D_8088BFC0) + this->dyna.actor.home.pos.z; if (temp_v1) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x; this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z; @@ -162,7 +162,7 @@ void func_8088B268(BgHidanRock* this, PlayState* play) { func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG); } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; if (this->timer != 0) { this->timer--; @@ -180,7 +180,7 @@ void func_8088B268(BgHidanRock* this, PlayState* play) { this->dyna.actor.world.pos.z = D_8088BF60.z; this->dyna.actor.speedXZ = 0.0f; D_8088BFC0 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->actionFunc = func_8088B79C; } @@ -300,7 +300,7 @@ void func_8088B990(BgHidanRock* this, PlayState* play) { this->timer++; if (this->dyna.unk_150 != 0.0f) { this->dyna.actor.speedXZ = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } if ((this->type == 0 && (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 1820.0f, diff --git a/soh/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c b/soh/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c index ce1732e07..03615e480 100644 --- a/soh/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c +++ b/soh/src/overlays/actors/ovl_Bg_Hidan_Sima/z_bg_hidan_sima.c @@ -118,7 +118,7 @@ void func_8088E518(BgHidanSima* this, PlayState* play) { Player* player = GET_PLAYER(play); Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 3.4f); - if (func_8004356C(&this->dyna) && !(player->stateFlags1 & 0x6000)) { + if (func_8004356C(&this->dyna) && !(player->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE))) { this->timer = 20; this->dyna.actor.world.rot.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x4000; if (this->dyna.actor.home.pos.y <= this->dyna.actor.world.pos.y) { diff --git a/soh/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.c b/soh/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.c index 039b77807..1cd91d468 100644 --- a/soh/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.c +++ b/soh/src/overlays/actors/ovl_Bg_Ice_Objects/z_bg_ice_objects.c @@ -138,7 +138,7 @@ void BgIceObjects_Idle(BgIceObjects* this, PlayState* play) { Actor* thisx = &this->dyna.actor; if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; if ((this->dyna.unk_150 > 0.0f) && !Player_InCsMode(play)) { BgIceObjects_SetNextTarget(this, play); if (Actor_WorldDistXZToPoint(thisx, &this->targetPos) > 1.0f) { @@ -203,7 +203,7 @@ void BgIceObjects_Reset(BgIceObjects* this, PlayState* play) { Actor* thisx = &this->dyna.actor; if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } if (Math_StepToF(&thisx->world.pos.y, thisx->home.pos.y, 1.0f)) { @@ -218,7 +218,7 @@ void BgIceObjects_Stuck(BgIceObjects* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.c b/soh/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.c index ff695140d..848931456 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Block/z_bg_jya_block.c @@ -59,7 +59,7 @@ void BgJyaBlock_Update(Actor* thisx, PlayState* play) { BgJyaBlock* this = (BgJyaBlock*)thisx; Player* player = GET_PLAYER(play); - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c b/soh/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c index 000895dc5..30164bf2e 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Goroiwa/z_bg_jya_goroiwa.c @@ -201,7 +201,7 @@ void BgJyaGoroiwa_Update(Actor* thisx, PlayState* play) { s32 bgId; Vec3f pos; - if (!(player->stateFlags1 & 0x300000C0)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE))) { this->actionFunc(this, play); BgJyaGoroiwa_UpdateRotation(this); pos.x = this->actor.world.pos.x; diff --git a/soh/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c b/soh/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c index b8ee9c331..1b0f52ae8 100644 --- a/soh/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c +++ b/soh/src/overlays/actors/ovl_Bg_Jya_Zurerukabe/z_bg_jya_zurerukabe.c @@ -78,7 +78,7 @@ void BgJyaZurerukabe_InitDynaPoly(BgJyaZurerukabe* this, PlayState* play, Collis void func_8089B4C8(BgJyaZurerukabe* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((player->stateFlags1 == 0x200000) && (player->actor.wallPoly != NULL)) { + if ((player->stateFlags1 == PLAYER_STATE1_CLIMBING_LADDER) && (player->actor.wallPoly != NULL)) { s32 i; for (i = 0; i < ARRAY_COUNT(D_8089BA18); i++) { diff --git a/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c b/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c index 645d5cc56..8392e7224 100644 --- a/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c +++ b/soh/src/overlays/actors/ovl_Bg_Mori_Kaitenkabe/z_bg_mori_kaitenkabe.c @@ -112,7 +112,7 @@ void BgMoriKaitenkabe_Wait(BgMoriKaitenkabe* this, PlayState* play) { } if (fabsf(this->dyna.unk_150) > 0.001f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } } @@ -145,7 +145,7 @@ void BgMoriKaitenkabe_Rotate(BgMoriKaitenkabe* this, PlayState* play) { } if (fabsf(this->dyna.unk_150) > 0.001f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } Math_Vec3f_Copy(&player->actor.world.pos, &this->lockedPlayerPos); } diff --git a/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c b/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c index ae699abb6..a2fca0db7 100644 --- a/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c +++ b/soh/src/overlays/actors/ovl_Bg_Po_Event/z_bg_po_event.c @@ -348,7 +348,7 @@ void BgPoEvent_BlockIdle(BgPoEvent* this, PlayState* play) { } } else { if ((gSaveContext.timer1Value == 0) && (sBgPoEventBlocksAtRest == 5)) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; sBgPoEventPuzzleState = 0x10; sBgPoEventBlocksAtRest = 0; } @@ -367,11 +367,11 @@ void BgPoEvent_BlockIdle(BgPoEvent* this, PlayState* play) { this->direction = (this->dyna.unk_150 >= 0.0f) ? 1.0f : -1.0f; this->actionFunc = BgPoEvent_BlockPush; } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; DECR(this->direction); } @@ -394,7 +394,7 @@ void BgPoEvent_BlockPush(BgPoEvent* this, PlayState* play) { this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.unk_158) * displacement) + this->dyna.actor.home.pos.x; this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.unk_158) * displacement) + this->dyna.actor.home.pos.z; if (blockStop) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; if ((this->dyna.unk_150 > 0.0f) && (func_800435D8(play, &this->dyna, 0x1E, 0x32, -0x14) == 0)) { Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); } @@ -419,7 +419,7 @@ void BgPoEvent_BlockReset(BgPoEvent* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } if (Math_StepToF(&this->dyna.actor.world.pos.y, 493.0f, 1.0f) && @@ -439,7 +439,7 @@ void BgPoEvent_BlockSolved(BgPoEvent* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->dyna.unk_150 != 0.0f) { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } if (Math_StepToF(&this->dyna.actor.world.pos.y, 369.0f, 2.0f)) { sBgPoEventPuzzleState = 0x20; diff --git a/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c b/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c index 019c71cd0..4385c4341 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot15_Rrbox/z_bg_spot15_rrbox.c @@ -239,11 +239,11 @@ void func_808B40AC(BgSpot15Rrbox* this, PlayState* play) { this->unk_17C = this->dyna.unk_150; func_808B4178(this, play); } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } @@ -275,7 +275,7 @@ void func_808B4194(BgSpot15Rrbox* this, PlayState* play) { if (!func_808B3F58(this, play)) { actor->home.pos.x = actor->world.pos.x; actor->home.pos.z = actor->world.pos.z; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; this->unk_178 = 0.0f; this->unk_174 = 0.0f; @@ -290,7 +290,7 @@ void func_808B4194(BgSpot15Rrbox* this, PlayState* play) { } actor->home.pos.x = actor->world.pos.x; actor->home.pos.z = actor->world.pos.z; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; this->unk_178 = 0.0f; this->unk_174 = 0.0f; @@ -316,7 +316,7 @@ void func_808B43D0(BgSpot15Rrbox* this, PlayState* play) { if (fabsf(this->dyna.unk_150) > 0.001f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } Actor_MoveForward(actor); @@ -347,7 +347,7 @@ void func_808B44B8(BgSpot15Rrbox* this, PlayState* play) { void func_808B44CC(BgSpot15Rrbox* this, PlayState* play) { Player* player = GET_PLAYER(play); - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } diff --git a/soh/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c b/soh/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c index 5509765c3..4bc551eae 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot16_Bombstone/z_bg_spot16_bombstone.c @@ -413,7 +413,7 @@ void func_808B57E0(BgSpot16Bombstone* this, PlayState* play) { OnePointCutscene_Init(play, 4180, sTimer, NULL, MAIN_CAM); } } - } else if (player->stateFlags1 & 0x800) { + } else if (player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) { playerHeldActor = player->heldActor; if (playerHeldActor != NULL && playerHeldActor->category == ACTORCAT_EXPLOSIVE && playerHeldActor->id == ACTOR_EN_BOMBF) { diff --git a/soh/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c b/soh/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c index e24e39902..bcff47d6b 100644 --- a/soh/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c +++ b/soh/src/overlays/actors/ovl_Bg_Spot18_Obj/z_bg_spot18_obj.c @@ -213,7 +213,7 @@ void func_808B8E20(BgSpot18Obj* this, PlayState* play) { if (fabsf(this->dyna.unk_150) > 0.001f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } } @@ -256,7 +256,7 @@ void func_808B8F08(BgSpot18Obj* this, PlayState* play) { this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.x; this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.actor.world.rot.y) * 80.0f) + this->dyna.actor.home.pos.z; this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; Flags_SetSwitch(play, (this->dyna.actor.params >> 8) & 0x3F); func_80078884(NA_SE_SY_CORRECT_CHIME); Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); diff --git a/soh/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c b/soh/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c index 444de05e3..f62f09128 100644 --- a/soh/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c +++ b/soh/src/overlays/actors/ovl_Bg_Sst_Floor/z_bg_sst_floor.c @@ -81,7 +81,7 @@ void BgSstFloor_Update(BgSstFloor* thisx, PlayState* play) { this->dyna.actor.params = BONGOFLOOR_REST; this->drumPhase = 28; - if (func_8004356C(&this->dyna) && !(player->stateFlags1 & 0x6000)) { + if (func_8004356C(&this->dyna) && !(player->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE))) { distFromRim = 600.0f - this->dyna.actor.xzDistToPlayer; if (distFromRim > 0.0f) { if (distFromRim > 350.0f) { diff --git a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index e74f3c0e4..0d33533ae 100644 --- a/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/soh/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -1480,11 +1480,11 @@ void BossFd_UpdateEffects(BossFd* this, PlayState* play) { if ((this->timers[3] == 0) && (sqrtf(SQ(diff.x) + SQ(diff.y) + SQ(diff.z)) < 20.0f)) { this->timers[3] = 50; func_8002F6D4(play, NULL, 5.0f, effect->kbAngle, 0.0f, 0x30); - if (player->isBurning == false) { - for (i2 = 0; i2 < ARRAY_COUNT(player->flameTimers); i2++) { - player->flameTimers[i2] = Rand_S16Offset(0, 200); + if (player->bodyIsBurning == false) { + for (i2 = 0; i2 < ARRAY_COUNT(player->bodyFlameTimers); i2++) { + player->bodyFlameTimers[i2] = Rand_S16Offset(0, 200); } - player->isBurning = true; + player->bodyIsBurning = true; } } if (effect->timer2 == 0) { diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c index ebc244d74..97551ca46 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon/z_boss_ganon.c @@ -2276,10 +2276,10 @@ void BossGanon_Wait(BossGanon* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((this->unk_1C2 == 0) && !(player->actor.world.pos.y < 0.0f)) { - if (!(player->stateFlags1 & 0x2000) && (fabsf(player->actor.world.pos.x) < 110.0f) && + if (!(player->stateFlags1 & PLAYER_STATE1_HANGING_OFF_LEDGE) && (fabsf(player->actor.world.pos.x) < 110.0f) && (fabsf(player->actor.world.pos.z) < 110.0f)) { BossGanon_SetupPoundFloor(this, play); - } else if ((this->timers[0] == 0) && !(player->stateFlags1 & 0x2000)) { + } else if ((this->timers[0] == 0) && !(player->stateFlags1 & PLAYER_STATE1_HANGING_OFF_LEDGE)) { this->timers[0] = (s16)Rand_ZeroFloat(30.0f) + 30; if ((s8)this->actor.colChkInfo.health >= 20) { diff --git a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c index 5ec12f093..ba4a4fbc6 100644 --- a/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c +++ b/soh/src/overlays/actors/ovl_Boss_Ganon2/z_boss_ganon2.c @@ -1918,11 +1918,11 @@ void func_80902348(BossGanon2* this, PlayState* play) { temp_f12 = -200.0f - player->actor.world.pos.z; if (sqrtf(SQ(temp_f2) + SQ(temp_f12)) > 784.0f) { - for (j = 0; j < ARRAY_COUNT(player->flameTimers); j++) { - player->flameTimers[j] = Rand_S16Offset(0, 200); + for (j = 0; j < ARRAY_COUNT(player->bodyFlameTimers); j++) { + player->bodyFlameTimers[j] = Rand_S16Offset(0, 200); } - player->isBurning = true; + player->bodyIsBurning = true; func_8002F6D4(play, &this->actor, 10.0f, Math_Atan2S(temp_f12, temp_f2), 0.0f, 0x10); sBossGanon2Zelda->unk_3C8 = 8; } diff --git a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index 78534e851..74684df71 100644 --- a/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/soh/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -775,7 +775,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { } } if (this->work[MO_TENT_ACTION_STATE] == MO_TENT_GRAB) { - player->unk_850 = 0xA; + player->av2.actionVar2 = 0xA; player->actor.speedXZ = player->actor.velocity.y = 0; Math_ApproachF(&player->actor.world.pos.x, this->grabPosRot.pos.x, 0.5f, 20.0f); Math_ApproachF(&player->actor.world.pos.y, this->grabPosRot.pos.y, 0.5f, 20.0f); @@ -833,7 +833,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { Math_ApproachS(&this->tentRot[indS1].z, tempf2, 1.0f / this->tentMaxAngle, this->tentSpeed); } } - player->unk_850 = 0xA; + player->av2.actionVar2 = 0xA; player->actor.world.pos.x = this->grabPosRot.pos.x; player->actor.world.pos.y = this->grabPosRot.pos.y; player->actor.world.pos.z = this->grabPosRot.pos.z; @@ -852,7 +852,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { this->work[MO_TENT_ACTION_STATE] = MO_TENT_RETREAT; this->work[MO_TENT_INVINC_TIMER] = 50; if (&this->actor == player->actor.parent) { - player->unk_850 = 0x65; + player->av2.actionVar2 = 0x65; player->actor.parent = NULL; player->csAction = 0; if (this->timers[0] == 0) { @@ -882,7 +882,7 @@ void BossMo_Tentacle(BossMo* this, PlayState* play) { case MO_TENT_CUT: func_80078914(&this->tentTipPos, NA_SE_EV_WATER_WALL - SFX_FLAG); if (&this->actor == player->actor.parent) { - player->unk_850 = 0x65; + player->av2.actionVar2 = 0x65; player->actor.parent = NULL; player->csAction = 0; } @@ -1804,7 +1804,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, PlayState* play) { sMorphaTent2->tent2KillTimer = 1; } if (player->actor.parent != NULL) { - player->unk_850 = 0x65; + player->av2.actionVar2 = 0x65; player->actor.parent = NULL; player->csAction = 0; } @@ -1823,7 +1823,7 @@ void BossMo_CoreCollisionCheck(BossMo* this, PlayState* play) { sMorphaTent1->timers[0] = 40; sMorphaTent1->actor.flags &= ~ACTOR_FLAG_TARGETABLE; if (player->actor.parent == &sMorphaTent1->actor) { - player->unk_850 = 0x65; + player->av2.actionVar2 = 0x65; player->actor.parent = NULL; player->csAction = 0; } diff --git a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c index f7a48f873..b9f5c6f2c 100644 --- a/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c +++ b/soh/src/overlays/actors/ovl_Boss_Sst/z_boss_sst.c @@ -384,10 +384,10 @@ void BossSst_HeadSetupIntro(BossSst* this, PlayState* play) { player->actor.world.pos.z = sRoomCenter.z; player->linearVelocity = player->actor.velocity.y = 0.0f; player->actor.shape.rot.y = -0x8000; - player->targetYaw = -0x8000; - player->currentYaw = -0x8000; + player->zTargetYaw = -0x8000; + player->yaw = -0x8000; player->fallStartHeight = 0; - player->stateFlags1 |= 0x20; + player->stateFlags1 |= PLAYER_STATE1_INPUT_DISABLED; func_80064520(play, &play->csCtx); func_8002DF54(play, &this->actor, 8); @@ -421,7 +421,7 @@ void BossSst_HeadIntro(BossSst* this, PlayState* play) { if (this->timer == 0) { sHands[RIGHT]->actor.flags |= ACTOR_FLAG_TARGETABLE; sHands[LEFT]->actor.flags |= ACTOR_FLAG_TARGETABLE; - player->stateFlags1 &= ~0x20; + player->stateFlags1 &= ~PLAYER_STATE1_INPUT_DISABLED; func_80064534(play, &play->csCtx); func_8002DF54(play, &this->actor, 7); sCameraAt.y += 30.0f; @@ -443,8 +443,8 @@ void BossSst_HeadIntro(BossSst* this, PlayState* play) { player->actor.world.pos.z = sRoomCenter.z; player->linearVelocity = 0; player->actor.shape.rot.y = -0x8000; - player->targetYaw = -0x8000; - player->currentYaw = -0x8000; + player->zTargetYaw = -0x8000; + player->yaw = -0x8000; } Math_Vec3f_Copy(&sCameraAt, &player->actor.world.pos); @@ -667,7 +667,7 @@ void BossSst_HeadNeutral(BossSst* this, PlayState* play) { } if (this->timer == 0) { - if ((GET_PLAYER(play)->actor.world.pos.y > -50.0f) && !(GET_PLAYER(play)->stateFlags1 & 0x6080)) { + if ((GET_PLAYER(play)->actor.world.pos.y > -50.0f) && !(GET_PLAYER(play)->stateFlags1 & (PLAYER_STATE1_DEAD | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE))) { sHands[Rand_ZeroOne() <= 0.5f]->ready = true; BossSst_HeadSetupWait(this); } else { @@ -1252,7 +1252,7 @@ void BossSst_HandWait(BossSst* this, PlayState* play) { this->timer--; } - if ((this->timer == 0) && (player->actor.world.pos.y > -50.0f) && !(player->stateFlags1 & 0x6080)) { + if ((this->timer == 0) && (player->actor.world.pos.y > -50.0f) && !(player->stateFlags1 & (PLAYER_STATE1_DEAD | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE))) { BossSst_HandSelectAttack(this); } } else if (sHead->actionFunc == BossSst_HeadNeutral) { @@ -1735,7 +1735,7 @@ void BossSst_HandClap(BossSst* this, PlayState* play) { if (this->ready) { this->timer = 30; this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); - if (!(player->stateFlags2 & 0x80)) { + if (!(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { dropFlag = true; } } else { @@ -1757,7 +1757,7 @@ void BossSst_HandClap(BossSst* this, PlayState* play) { } if (player->actor.parent == &this->actor) { - player->unk_850 = 0; + player->av2.actionVar2 = 0; player->actor.world.pos = this->actor.world.pos; } } @@ -1824,7 +1824,7 @@ void BossSst_HandGrab(BossSst* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { this->colliderJntSph.base.atFlags &= ~(AT_ON | AT_HIT); this->actor.speedXZ = 0.0f; - if (player->stateFlags2 & 0x80) { + if (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) { if (Rand_ZeroOne() < 0.5f) { BossSst_HandSetupCrush(this); } else { @@ -1851,8 +1851,8 @@ void BossSst_HandGrab(BossSst* this, PlayState* play) { this->actor.world.pos.x += this->actor.speedXZ * Math_SinS(this->actor.world.rot.y); this->actor.world.pos.z += this->actor.speedXZ * Math_CosS(this->actor.world.rot.y); - if (player->stateFlags2 & 0x80) { - player->unk_850 = 0; + if (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) { + player->av2.actionVar2 = 0; player->actor.world.pos = this->actor.world.pos; player->actor.shape.rot.y = this->actor.shape.rot.y; } @@ -1872,7 +1872,7 @@ void BossSst_HandCrush(BossSst* this, PlayState* play) { this->timer--; } - if (!(player->stateFlags2 & 0x80)) { + if (!(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { BossSst_HandReleasePlayer(this, play, true); BossSst_HandSetupEndCrush(this); } else { @@ -1945,8 +1945,8 @@ void BossSst_HandSwing(BossSst* this, PlayState* play) { Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 0x800); } - if (player->stateFlags2 & 0x80) { - player->unk_850 = 0; + if (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) { + player->av2.actionVar2 = 0; Math_Vec3f_Copy(&player->actor.world.pos, &this->actor.world.pos); player->actor.shape.rot.x = this->actor.shape.rot.x; player->actor.shape.rot.z = (this->vParity * -0x4000) + this->actor.shape.rot.z; @@ -1958,7 +1958,7 @@ void BossSst_HandSwing(BossSst* this, PlayState* play) { } if ((this->timer == 4) && (this->amplitude == 0) && SkelAnime_Update(&this->skelAnime) && - (player->stateFlags2 & 0x80)) { + (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { BossSst_HandReleasePlayer(this, play, false); player->actor.world.pos.x += 70.0f * Math_SinS(this->actor.shape.rot.y); player->actor.world.pos.z += 70.0f * Math_CosS(this->actor.shape.rot.y); @@ -2429,7 +2429,7 @@ void BossSst_HandReleasePlayer(BossSst* this, PlayState* play, s32 dropPlayer) { if (player->actor.parent == &this->actor) { player->actor.parent = NULL; - player->unk_850 = 100; + player->av2.actionVar2 = 100; this->colliderJntSph.base.ocFlags1 |= OC1_ON; OTHER_HAND(this)->colliderJntSph.base.ocFlags1 |= OC1_ON; if (dropPlayer) { diff --git a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 5360eef02..9d0a68c38 100644 --- a/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/soh/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -777,12 +777,12 @@ s32 BossTw_BeamHitPlayerCheck(BossTw* this, PlayState* play) { if (sFreezeState == 0) { sFreezeState = 1; } - } else if (!player->isBurning) { - for (i = 0; i < ARRAY_COUNT(player->flameTimers); i++) { - player->flameTimers[i] = Rand_S16Offset(0, 200); + } else if (!player->bodyIsBurning) { + for (i = 0; i < ARRAY_COUNT(player->bodyFlameTimers); i++) { + player->bodyFlameTimers[i] = Rand_S16Offset(0, 200); } - player->isBurning = true; + player->bodyIsBurning = true; Player_PlaySfx(&player->actor, player->ageProperties->unk_92 + NA_SE_VO_LI_DEMO_DAMAGE); } } @@ -803,7 +803,7 @@ s32 BossTw_CheckBeamReflection(BossTw* this, PlayState* play) { Vec3f vec; Player* player = GET_PLAYER(play); - if (player->stateFlags1 & 0x400000 && + if (player->stateFlags1 & PLAYER_STATE1_SHIELDING && (s16)(player->actor.shape.rot.y - this->actor.shape.rot.y + 0x8000) < 0x2000 && (s16)(player->actor.shape.rot.y - this->actor.shape.rot.y + 0x8000) > -0x2000) { // player is shielding and facing angles are less than 45 degrees in either direction @@ -945,7 +945,7 @@ void BossTw_ShootBeam(BossTw* this, PlayState* play) { if (this->timers[1] != 0) { Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, this->rotateSpeed); - if ((player->stateFlags1 & 0x400000) && + if ((player->stateFlags1 & PLAYER_STATE1_SHIELDING) && ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) < 0x2000) && ((s16)((player->actor.shape.rot.y - this->actor.shape.rot.y) + 0x8000) > -0x2000)) { Math_ApproachF(&this->targetPos.x, player->bodyPartsPos[15].x, 1.0f, 400.0f); @@ -3154,7 +3154,7 @@ void BossTw_TwinrovaUpdate(Actor* thisx, PlayState* play2) { } } - if (player->isBurning && sShieldIceCharge != 0) { + if (player->bodyIsBurning && sShieldIceCharge != 0) { sShieldIceCharge = 4; } } @@ -4039,15 +4039,15 @@ void BossTw_BlastFire(BossTw* this, PlayState* play) { yDiff = sKoumePtr->groundBlastPos2.y - player->actor.world.pos.y; zDiff = sKoumePtr->groundBlastPos2.z - player->actor.world.pos.z; - if (!player->isBurning && (player->actor.bgCheckFlags & 1) && (fabsf(yDiff) < 10.0f) && + if (!player->bodyIsBurning && (player->actor.bgCheckFlags & 1) && (fabsf(yDiff) < 10.0f) && (sqrtf(SQ(xDiff) + SQ(zDiff)) < (sKoumePtr->workf[UNK_F13] * 4550.0f))) { s16 j; for (j = 0; j < 18; j++) { - player->flameTimers[j] = Rand_S16Offset(0, 200); + player->bodyFlameTimers[j] = Rand_S16Offset(0, 200); } - player->isBurning = 1; + player->bodyIsBurning = 1; if (this->work[BURN_TMR] == 0) { Player_PlaySfx(&player->actor, player->ageProperties->unk_92 + NA_SE_VO_LI_DEMO_DAMAGE); @@ -4799,7 +4799,7 @@ void BossTw_UpdateEffects(PlayState* play) { if (eff->workf[EFF_SCALE] == 0.0f) { eff->type = TWEFF_NONE; if (eff->target == NULL) { - player->stateFlags2 &= ~0x8000; + player->stateFlags2 &= ~PLAYER_STATE2_PAUSE_MOST_UPDATING; sFreezeState = 0; } } @@ -4815,9 +4815,9 @@ void BossTw_UpdateEffects(PlayState* play) { if (eff->workf[EFF_ROLL] >= 0.8f) { eff->workf[EFF_ROLL] -= 0.8f; - player->stateFlags2 |= 0x8000; + player->stateFlags2 |= PLAYER_STATE2_PAUSE_MOST_UPDATING; } else { - player->stateFlags2 &= ~0x8000; + player->stateFlags2 &= ~PLAYER_STATE2_PAUSE_MOST_UPDATING; } if ((sKotakePtr->workf[UNK_F11] > 10.0f) && (sKotakePtr->workf[UNK_F11] < 200.0f)) { diff --git a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index ee62b141e..4891b0330 100644 --- a/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/soh/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -1441,14 +1441,14 @@ void BossVa_BodyPhase4(BossVa* this, PlayState* play) { } else { Math_SmoothStepToS(&this->vaBodySpinRate, 0, 1, 0x96, 0); if (this->timer > 0) { - if ((player->stateFlags1 & 0x4000000) && (this->timer > 35)) { + if ((player->stateFlags1 & PLAYER_STATE1_DAMAGED) && (this->timer > 35)) { this->timer = 35; } Math_SmoothStepToF(&this->actor.shape.yOffset, -480.0f, 1.0f, 30.0f, 0.0f); this->colliderBody.info.bumper.dmgFlags = 0xFC00712; this->timer--; } else { - if ((player->stateFlags1 & 0x4000000) && (this->timer < -60)) { + if ((player->stateFlags1 & PLAYER_STATE1_DAMAGED) && (this->timer < -60)) { this->timer = -59; } if ((play->gameplayFrames % 4) == 0) { @@ -2024,7 +2024,7 @@ void BossVa_ZapperAttack(BossVa* this, PlayState* play) { sp98 = Math_Vec3f_Yaw(&sp7C, &this->armTip); tmp17 = sp98 - this->actor.shape.rot.y; - if ((sp8E >= ABS(tmp17) || this->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & 0x04000000)) { + if ((sp8E >= ABS(tmp17) || this->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & PLAYER_STATE1_DAMAGED)) { if (!this->burst) { sp94 = sp98 - this->actor.shape.rot.y; @@ -2086,7 +2086,7 @@ void BossVa_ZapperAttack(BossVa* this, PlayState* play) { this->timer2 = 0; } - if ((this->timer2 < 0) && (player->stateFlags1 & 0x4000000)) { + if ((this->timer2 < 0) && (player->stateFlags1 & PLAYER_STATE1_DAMAGED)) { BossVa_Spark(play, this, 1, 30, 0.0f, 0.0f, SPARK_LINK, 0.0f, true); } } @@ -2287,7 +2287,7 @@ void BossVa_ZapperEnraged(BossVa* this, PlayState* play) { sp6C = Math_Vec3f_Yaw(&sp54, &this->armTip); tmp16 = sp6C - this->actor.shape.rot.y; - if ((ABS(tmp16) <= 0x4650 || this->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & 0x04000000)) { + if ((ABS(tmp16) <= 0x4650 || this->burst) && !(sBodyState & 0x80) && !(player->stateFlags1 & PLAYER_STATE1_DAMAGED)) { if (!this->burst) { sp68 = sp6C - this->actor.shape.rot.y; @@ -2344,7 +2344,7 @@ void BossVa_ZapperEnraged(BossVa* this, PlayState* play) { this->timer2 = 0; } - if ((this->timer2 < 0) && (player->stateFlags1 & 0x4000000)) { + if ((this->timer2 < 0) && (player->stateFlags1 & PLAYER_STATE1_DAMAGED)) { BossVa_Spark(play, this, 1, 30, 0.0f, 0, SPARK_LINK, 0.0f, true); } } diff --git a/soh/src/overlays/actors/ovl_Door_Ana/z_door_ana.c b/soh/src/overlays/actors/ovl_Door_Ana/z_door_ana.c index f3c601fa1..22c850111 100644 --- a/soh/src/overlays/actors/ovl_Door_Ana/z_door_ana.c +++ b/soh/src/overlays/actors/ovl_Door_Ana/z_door_ana.c @@ -134,8 +134,8 @@ void DoorAna_WaitOpen(DoorAna* this, PlayState* play) { player = GET_PLAYER(play); if (Math_StepToF(&this->actor.scale.x, 0.01f, 0.001f)) { - if ((this->actor.targetMode != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (player->stateFlags1 & 0x80000000) && - (player->unk_84F == 0)) { + if ((this->actor.targetMode != 0) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (player->stateFlags1 & PLAYER_STATE1_FLOOR_DISABLED) && + (player->av1.actionVar1 == 0)) { destinationIdx = ((this->actor.params >> 0xC) & 7) - 1; Play_SetupRespawnPoint(play, RESPAWN_MODE_RETURN, 0x4FF); gSaveContext.respawn[RESPAWN_MODE_RETURN].pos.y = this->actor.world.pos.y; @@ -153,10 +153,10 @@ void DoorAna_WaitOpen(DoorAna* this, PlayState* play) { DoorAna_SetupAction(this, DoorAna_GrabPlayer); } else { - if (!Player_InCsMode(play) && !(player->stateFlags1 & 0x8800000) && + if (!Player_InCsMode(play) && !(player->stateFlags1 & (PLAYER_STATE1_ON_HORSE | PLAYER_STATE1_IN_WATER)) && this->actor.xzDistToPlayer <= 15.0f && -50.0f <= this->actor.yDistToPlayer && this->actor.yDistToPlayer <= 15.0f) { - player->stateFlags1 |= 0x80000000; + player->stateFlags1 |= PLAYER_STATE1_FLOOR_DISABLED; this->actor.targetMode = 1; } else { this->actor.targetMode = 0; diff --git a/soh/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/soh/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index 290e809f6..c61822f67 100644 --- a/soh/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/soh/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -553,7 +553,7 @@ void func_80997220(DoorShutter* this, PlayState* play) { } this->unk_164 = 0; this->dyna.actor.velocity.y = 0.0f; - if (DoorShutter_SetupDoor(this, play) && !(player->stateFlags1 & 0x800)) { + if (DoorShutter_SetupDoor(this, play) && !(player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD)) { DoorShutter_SetupAction(this, func_80997568); func_8002DF54(play, NULL, 2); } @@ -637,7 +637,7 @@ void DoorShutter_Update(Actor* thisx, PlayState* play) { DoorShutter* this = (DoorShutter*)thisx; Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x100004C0) || (this->actionFunc == DoorShutter_SetupType)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_GETTING_ITEM | PLAYER_STATE1_IN_ITEM_CS)) || (this->actionFunc == DoorShutter_SetupType)) { this->actionFunc(this, play); } } diff --git a/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 56a761c84..a81ed473a 100644 --- a/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/soh/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -180,7 +180,7 @@ void EffDust_UpdateFunc_8099DFC0(EffDust* this, PlayState* play) { s32 i; s32 j; - if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & 0x1000)) { + if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & PLAYER_STATE1_CHARGING_SPIN_ATTACK)) { if (this->life != 0) { this->life -= 1; } else { diff --git a/soh/src/overlays/actors/ovl_En_Am/z_en_am.c b/soh/src/overlays/actors/ovl_En_Am/z_en_am.c index c5ca6686a..8347c631a 100644 --- a/soh/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/soh/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -694,7 +694,7 @@ void EnAm_Statue(EnAm* this, PlayState* play) { ((this->hurtCollider.base.ocFlags1 & OC1_HIT) && (ABS(moveDir) <= 0x2000))) { this->unk_258 = 0; - player->stateFlags2 &= ~0x151; + player->stateFlags2 &= ~(PLAYER_STATE2_DO_ACTION_GRAB | PLAYER_STATE2_MOVING_DYNAPOLY | PLAYER_STATE2_DISABLE_ROTATION_ALWAYS | PLAYER_STATE2_GRABBING_DYNAPOLY); player->actor.speedXZ = 0.0f; this->dyna.unk_150 = this->dyna.unk_154 = 0.0f; } diff --git a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c index 9686965d5..04b09aca8 100644 --- a/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c +++ b/soh/src/overlays/actors/ovl_En_Ba/z_en_ba.c @@ -188,7 +188,7 @@ void EnBa_Idle(EnBa* this, PlayState* play) { } this->unk_2A8[13].x = this->unk_2A8[12].x; this->unk_2A8[13].y = this->unk_2A8[12].y; - if (!(player->stateFlags1 & 0x4000000) && (this->actor.xzDistToPlayer <= 175.0f) && + if (!(player->stateFlags1 & PLAYER_STATE1_DAMAGED) && (this->actor.xzDistToPlayer <= 175.0f) && (this->actor.world.pos.y == this->actor.home.pos.y + 100.0f)) { EnBa_SetupSwingAtPlayer(this); } @@ -294,7 +294,7 @@ void EnBa_SwingAtPlayer(EnBa* this, PlayState* play) { Matrix_MultVec3f(&D_809B8080, &this->unk_158[i + 1]); } this->unk_31A--; - } else if ((this->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & 0x4000000)) { + } else if ((this->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & PLAYER_STATE1_DAMAGED)) { EnBa_SetupIdle(this); } else { EnBa_SetupSwingAtPlayer(this); @@ -313,7 +313,7 @@ void EnBa_SwingAtPlayer(EnBa* this, PlayState* play) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); return; } - if ((this->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & 0x4000000)) { + if ((this->actor.xzDistToPlayer > 175.0f) || (player->stateFlags1 & PLAYER_STATE1_DAMAGED)) { EnBa_SetupIdle(this); } else { EnBa_SetupSwingAtPlayer(this); diff --git a/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c b/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c index a3d6c923d..ab0b82d65 100644 --- a/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c +++ b/soh/src/overlays/actors/ovl_En_Bdfire/z_en_bdfire.c @@ -174,13 +174,13 @@ void func_809BC598(EnBdfire* this, PlayState* play) { Actor_Kill(&this->actor); return; } - } else if (!player->isBurning) { + } else if (!player->bodyIsBurning) { distToBurn = (this->actor.scale.x * 130.0f) / 4.2000003f; if (this->actor.xyzDistToPlayerSq < SQ(distToBurn)) { for (i = 0; i < 18; i++) { - player->flameTimers[i] = Rand_S16Offset(0, 200); + player->bodyFlameTimers[i] = Rand_S16Offset(0, 200); } - player->isBurning = true; + player->bodyIsBurning = true; func_8002F6D4(play, &this->actor, 20.0f, this->actor.world.rot.y, 0.0f, 8); osSyncPrintf("POWER\n"); } diff --git a/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c b/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c index fafb55ca5..816dcf091 100644 --- a/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c +++ b/soh/src/overlays/actors/ovl_En_Blkobj/z_en_blkobj.c @@ -84,7 +84,7 @@ void EnBlkobj_Wait(EnBlkobj* this, PlayState* play) { if (this->dyna.actor.xzDistToPlayer < 120.0f) { EnBlkobj_SetupAction(this, EnBlkobj_SpawnDarkLink); } - player->stateFlags2 |= 0x04000000; + player->stateFlags2 |= PLAYER_STATE2_REFLECTION; } void EnBlkobj_SpawnDarkLink(EnBlkobj* this, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 40adc1a6f..7fee4b178 100644 --- a/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/soh/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -238,11 +238,11 @@ void EnBom_Explode(EnBom* this, PlayState* play) { if (this->timer == 0) { player = GET_PLAYER(play); - if ((player->stateFlags1 & 0x800) && (player->heldActor == &this->actor)) { + if ((player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) && (player->heldActor == &this->actor)) { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_ITEM_OVER_HEAD; } Actor_Kill(&this->actor); diff --git a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c index a6d3afda5..5c18c52fa 100644 --- a/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c +++ b/soh/src/overlays/actors/ovl_En_Bom_Bowl_Pit/z_en_bom_bowl_pit.c @@ -200,14 +200,14 @@ void EnBomBowlPit_GivePrize(EnBomBowlPit* this, PlayState* play) { } } - player->stateFlags1 &= ~0x20000000; + player->stateFlags1 &= ~PLAYER_STATE1_IN_CUTSCENE; this->actor.parent = NULL; if (!IS_RANDO || this->getItemEntry.getItemId == GI_NONE) { func_8002F434(&this->actor, play, this->getItemId, 2000.0f, 1000.0f); } else { GiveItemEntryFromActor(&this->actor, play, this->getItemEntry, 2000.0f, 1000.0f); } - player->stateFlags1 |= 0x20000000; + player->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; this->actionFunc = EnBomBowlPit_WaitTillPrizeGiven; } diff --git a/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index 13b02c79c..2eecc1fb3 100644 --- a/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/soh/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -164,7 +164,7 @@ void EnBombf_GrowBomb(EnBombf* this, PlayState* play) { player->heldActor = NULL; player->interactRangeActor = NULL; this->actor.parent = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_ITEM_OVER_HEAD; } } else if (this->bombCollider.base.acFlags & AC_HIT) { this->bombCollider.base.acFlags &= ~AC_HIT; @@ -200,7 +200,7 @@ void EnBombf_GrowBomb(EnBombf* this, PlayState* play) { player->heldActor = NULL; player->interactRangeActor = NULL; this->actor.parent = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_ITEM_OVER_HEAD; this->actor.world.pos = this->actor.home.pos; } } @@ -218,7 +218,7 @@ void EnBombf_GrowBomb(EnBombf* this, PlayState* play) { player->heldActor = NULL; player->interactRangeActor = NULL; this->actor.parent = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_ITEM_OVER_HEAD; this->actor.world.pos = this->actor.home.pos; } } @@ -302,11 +302,11 @@ void EnBombf_Explode(EnBombf* this, PlayState* play) { if (this->timer == 0) { player = GET_PLAYER(play); - if ((player->stateFlags1 & 0x800) && (player->heldActor == &this->actor)) { + if ((player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) && (player->heldActor == &this->actor)) { player->actor.child = NULL; player->heldActor = NULL; player->interactRangeActor = NULL; - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_ITEM_OVER_HEAD; } Actor_Kill(&this->actor); diff --git a/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c index dedb53d5b..d5e082933 100644 --- a/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/soh/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -243,7 +243,7 @@ void EnBoom_Update(Actor* thisx, PlayState* play) { EnBoom* this = (EnBoom*)thisx; Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x20000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE)) { this->actionFunc(this, play); Actor_SetFocus(&this->actor, 0.0f); this->activeTimer = this->activeTimer + 1; diff --git a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c index a4d86ff61..dfd8fae27 100644 --- a/soh/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/soh/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -320,8 +320,8 @@ void func_809C9700(EnBox* this, PlayState* play) { this->unk_1FB = ENBOX_STATE_0; } else { if (this->unk_1FB == ENBOX_STATE_0) { - if (!(player->stateFlags2 & 0x1000000)) { - player->stateFlags2 |= 0x800000; + if (!(player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR)) { + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; return; } this->unk_1FB = ENBOX_STATE_1; @@ -646,9 +646,17 @@ void EnBox_UpdateSizeAndTexture(EnBox* this, PlayState* play) { if (!isVanilla) { getItemCategory = this->getItemEntry.getItemCategory; - // If they don't have bombchu's yet consider the bombchu item major - if (this->getItemEntry.gid == GID_BOMBCHU && INV_CONTENT(ITEM_BOMBCHU) != ITEM_BOMBCHU) { - getItemCategory = ITEM_CATEGORY_MAJOR; + // If they have bombchus, don't consider the bombchu item major + if ( + INV_CONTENT(ITEM_BOMBCHU) == ITEM_BOMBCHU && + ((this->getItemEntry.modIndex == MOD_RANDOMIZER && this->getItemEntry.getItemId == RG_PROGRESSIVE_BOMBCHUS) || + (this->getItemEntry.modIndex == MOD_NONE && ( + this->getItemEntry.getItemId == GI_BOMBCHUS_5 || + this->getItemEntry.getItemId == GI_BOMBCHUS_10 || + this->getItemEntry.getItemId == GI_BOMBCHUS_20 + ))) + ) { + getItemCategory = ITEM_CATEGORY_JUNK; // If it's a bottle and they already have one, consider the item lesser } else if ( (this->getItemEntry.modIndex == MOD_RANDOMIZER && this->getItemEntry.getItemId >= RG_BOTTLE_WITH_RED_POTION && this->getItemEntry.getItemId <= RG_BOTTLE_WITH_BIG_POE) || diff --git a/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c b/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c index a57594a0f..2a6fdb4fd 100644 --- a/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c +++ b/soh/src/overlays/actors/ovl_En_Bw/z_en_bw.c @@ -359,7 +359,7 @@ void func_809CEA24(EnBw* this, PlayState* play) { Math_SmoothStepToS(&this->actor.world.rot.y, this->unk_236 + this->unk_238, 1, this->actor.speedXZ * 1000.0f, 0); } - if ((this->unk_224 == 0) || (ABS(this->actor.yDistToPlayer) > 60.0f) || (player2->stateFlags1 & 0x6000)) { + if ((this->unk_224 == 0) || (ABS(this->actor.yDistToPlayer) > 60.0f) || (player2->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE))) { this->unk_221 = 3; this->unk_224 = 150; this->unk_250 = 0.0f; diff --git a/soh/src/overlays/actors/ovl_En_Crow/z_en_crow.c b/soh/src/overlays/actors/ovl_En_Crow/z_en_crow.c index 24650142d..ea0432f27 100644 --- a/soh/src/overlays/actors/ovl_En_Crow/z_en_crow.c +++ b/soh/src/overlays/actors/ovl_En_Crow/z_en_crow.c @@ -281,8 +281,9 @@ void EnCrow_FlyIdle(EnCrow* this, PlayState* play) { if (this->timer != 0) { this->timer--; } - if ((this->timer == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & 0x00800000) && - (this->actor.yDistToWater < -40.0f) && (Player_GetMask(play) != PLAYER_MASK_SKULL)) { + if ((this->timer == 0) && (this->actor.xzDistToPlayer < 300.0f) && !(player->stateFlags1 & PLAYER_STATE1_ON_HORSE) && + (this->actor.yDistToWater < -40.0f) && (Player_GetMask(play) != PLAYER_MASK_SKULL) && + !CVarGetInteger("gNoKeeseGuayTarget", 0)) { EnCrow_SetupDiveAttack(this); } } @@ -319,7 +320,8 @@ void EnCrow_DiveAttack(EnCrow* this, PlayState* play) { if ((this->timer == 0) || (Player_GetMask(play) == PLAYER_MASK_SKULL) || (this->collider.base.atFlags & AT_HIT) || (this->actor.bgCheckFlags & 9) || - (player->stateFlags1 & 0x00800000) || (this->actor.yDistToWater > -40.0f)) { + (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) || (this->actor.yDistToWater > -40.0f) || + CVarGetInteger("gNoKeeseGuayTarget", 0)) { if (this->collider.base.atFlags & AT_HIT) { this->collider.base.atFlags &= ~AT_HIT; Audio_PlayActorSound2(&this->actor, NA_SE_EN_KAICHO_ATTACK); diff --git a/soh/src/overlays/actors/ovl_En_Dha/z_en_dha.c b/soh/src/overlays/actors/ovl_En_Dha/z_en_dha.c index 4f58b1937..da6f43388 100644 --- a/soh/src/overlays/actors/ovl_En_Dha/z_en_dha.c +++ b/soh/src/overlays/actors/ovl_En_Dha/z_en_dha.c @@ -230,7 +230,7 @@ void EnDha_Wait(EnDha* this, PlayState* play) { this->timer += 0x1194; this->limbAngleY = Math_SinS(this->timer) * 1820.0f; - if (!(player->stateFlags2 & 0x80)) { + if (!(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { this->unk_1CC = 0; EnDha_SetupTakeDamage(this); return; @@ -245,10 +245,10 @@ void EnDha_Wait(EnDha* this, PlayState* play) { this->handAngle.y -= this->actor.shape.rot.y + this->limbAngleY; this->handAngle.x -= this->actor.shape.rot.x + this->limbAngleX[0] + this->limbAngleX[1]; } else { - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && (&this->actor == player->actor.parent)) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; } if (this->actor.home.rot.z != 0) { @@ -285,10 +285,10 @@ void EnDha_Wait(EnDha* this, PlayState* play) { this->limbAngleX[1] *= -2; } } else { - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && (&this->actor == player->actor.parent)) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; } this->actor.home.rot.z = 1; @@ -306,10 +306,10 @@ void EnDha_SetupTakeDamage(EnDha* this) { void EnDha_TakeDamage(EnDha* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && (&this->actor == player->actor.parent)) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; } Math_SmoothStepToS(&this->limbAngleX[1], 0, 1, 2000, 0); @@ -344,10 +344,10 @@ void EnDha_Die(EnDha* this, PlayState* play) { Vec3f vec; Player* player = GET_PLAYER(play); - if ((player->stateFlags2 & 0x80) && (&this->actor == player->actor.parent)) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && (&this->actor == player->actor.parent)) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; } Math_SmoothStepToS(&this->limbAngleX[1], 0, 1, 0x7D0, 0); diff --git a/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c b/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c index 0dd33a8ac..cf73c6a94 100644 --- a/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c +++ b/soh/src/overlays/actors/ovl_En_Dns/z_en_dns.c @@ -460,7 +460,7 @@ void func_809EFF50(EnDns* this, PlayState* play) { void func_809EFF98(EnDns* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (player->stateFlags1 & 0x400) { + if (player->stateFlags1 & PLAYER_STATE1_GETTING_ITEM) { if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) { this->dnsItemEntry->setRupeesAndFlags(this); this->dropCollectible = 1; diff --git a/soh/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c b/soh/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c index 9ce27f4c1..2864544c5 100644 --- a/soh/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c +++ b/soh/src/overlays/actors/ovl_En_Dnt_Jiji/z_en_dnt_jiji.c @@ -123,7 +123,7 @@ void EnDntJiji_Wait(EnDntJiji* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if ((this->timer == 1) && (this->actor.xzDistToPlayer < 150.0f) && !Play_InCsMode(play) && - !(player->stateFlags1 & 0x800)) { + !(player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD)) { OnePointCutscene_Init(play, 2230, -99, &this->actor, MAIN_CAM); this->timer = 0; func_8002DF54(play, NULL, 8); diff --git a/soh/src/overlays/actors/ovl_En_Door/z_en_door.c b/soh/src/overlays/actors/ovl_En_Door/z_en_door.c index 329462c06..2a571e34e 100644 --- a/soh/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/soh/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -198,7 +198,7 @@ void EnDoor_Idle(EnDoor* this, PlayState* play) { if (this->playerIsOpening != 0) { this->actionFunc = EnDoor_Open; Animation_PlayOnceSetSpeed(&this->skelAnime, D_809FCECC[this->animStyle], - (player->stateFlags1 & 0x8000000) ? 0.75f : 1.5f); + (player->stateFlags1 & PLAYER_STATE1_IN_WATER) ? 0.75f : 1.5f); if (this->lockTimer != 0) { gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]--; Flags_SetSwitch(play, this->actor.params & 0x3F); diff --git a/soh/src/overlays/actors/ovl_En_Door/z_en_door.h b/soh/src/overlays/actors/ovl_En_Door/z_en_door.h index 5cb5a7f1c..7389ac99a 100644 --- a/soh/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/soh/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -57,4 +57,6 @@ typedef struct EnDoor { /* 0x01D4 */ EnDoorActionFunc actionFunc; } EnDoor; // size = 0x01D8 +void EnDoor_SetupType(EnDoor* enDoor, PlayState* play); + #endif diff --git a/soh/src/overlays/actors/ovl_En_Du/z_en_du.c b/soh/src/overlays/actors/ovl_En_Du/z_en_du.c index db13ecc54..19af8a4c5 100644 --- a/soh/src/overlays/actors/ovl_En_Du/z_en_du.c +++ b/soh/src/overlays/actors/ovl_En_Du/z_en_du.c @@ -353,9 +353,9 @@ void func_809FE3B4(EnDu* this, PlayState* play) { void func_809FE3C0(EnDu* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { func_8010BD88(play, OCARINA_ACTION_CHECK_SARIA); - player->stateFlags2 |= 0x2000000; + player->stateFlags2 |= PLAYER_STATE2_PLAY_FOR_ACTOR; player->unk_6A8 = &this->actor; EnDu_SetupAction(this, func_809FE4A4); return; @@ -365,7 +365,7 @@ void func_809FE3C0(EnDu* this, PlayState* play) { this->interactInfo.talkState = NPC_TALK_STATE_IDLE; } if (this->actor.xzDistToPlayer < 116.0f + this->collider.dim.radius) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } @@ -393,14 +393,14 @@ void func_809FE4A4(EnDu* this, PlayState* play) { EnDu_SetupAction(this, func_809FE890); play->msgCtx.ocarinaMode = OCARINA_MODE_04; } else { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } void func_809FE638(EnDu* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (!(player->stateFlags1 & 0x20000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE)) { OnePointCutscene_Init(play, 3330, -99, &this->actor, MAIN_CAM); player->actor.shape.rot.y = player->actor.world.rot.y = this->actor.world.rot.y + 0x7FFF; Audio_PlayFanfare(NA_BGM_APPEAR); diff --git a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 2191daeab..f996fe6c1 100644 --- a/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/soh/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1097,13 +1097,13 @@ void func_80A0461C(EnElf* this, PlayState* play) { } else { arrowPointedActor = play->actorCtx.targetCtx.arrowPointedActor; - if ((player->stateFlags1 & 0x400) || ((YREG(15) & 0x10) && func_800BC56C(play, 2))) { + if ((player->stateFlags1 & PLAYER_STATE1_GETTING_ITEM) || ((YREG(15) & 0x10) && func_800BC56C(play, 2))) { temp = 12; this->unk_2C0 = 100; } else if (arrowPointedActor == NULL || arrowPointedActor->category == ACTORCAT_NPC) { if (arrowPointedActor != NULL) { this->unk_2C0 = 100; - player->stateFlags2 |= 0x100000; + player->stateFlags2 |= PLAYER_STATE2_NAVI_OUT; temp = 0; } else { switch (this->unk_2A8) { @@ -1124,7 +1124,7 @@ void func_80A0461C(EnElf* this, PlayState* play) { this->unk_2AE--; temp = 7; } else { - player->stateFlags2 |= 0x100000; + player->stateFlags2 |= PLAYER_STATE2_NAVI_OUT; temp = 0; } } else { @@ -1154,7 +1154,7 @@ void func_80A0461C(EnElf* this, PlayState* play) { switch (temp) { case 0: - if (!(player->stateFlags2 & 0x100000)) { + if (!(player->stateFlags2 & PLAYER_STATE2_NAVI_OUT)) { temp = 7; if (this->unk_2C7 == 0) { Audio_PlayActorSound2(&this->actor, NA_SE_EV_NAVY_VANISH); @@ -1162,7 +1162,7 @@ void func_80A0461C(EnElf* this, PlayState* play) { } break; case 8: - if (player->stateFlags2 & 0x100000) { + if (player->stateFlags2 & PLAYER_STATE2_NAVI_OUT) { func_80A0299C(this, 0x32); this->unk_2C0 = 42; temp = 11; @@ -1172,10 +1172,10 @@ void func_80A0461C(EnElf* this, PlayState* play) { } break; case 7: - player->stateFlags2 &= ~0x100000; + player->stateFlags2 &= ~PLAYER_STATE2_NAVI_OUT; break; default: - player->stateFlags2 |= 0x100000; + player->stateFlags2 |= PLAYER_STATE2_NAVI_OUT; break; } } @@ -1514,7 +1514,7 @@ void EnElf_Draw(Actor* thisx, PlayState* play) { Player* player = GET_PLAYER(play); if ((this->unk_2A8 != 8) && !(this->fairyFlags & 8)) { - if (!(player->stateFlags1 & 0x100000) || (kREG(90) < this->actor.projectedPos.z)) { + if (!(player->stateFlags1 & PLAYER_STATE1_FIRST_PERSON) || (kREG(90) < this->actor.projectedPos.z)) { dListHead = Graph_Alloc(play->state.gfxCtx, sizeof(Gfx) * 4); OPEN_DISPS(play->state.gfxCtx); diff --git a/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 48877526a..146f0deaa 100644 --- a/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/soh/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -169,6 +169,10 @@ void EnEncount1_SpawnLeevers(EnEncount1* this, PlayState* play) { break; } } + int32_t modifiedSpawnRate = CVarGetInteger("gEnhancements.LeeverSpawnRate", 0); + if (modifiedSpawnRate) { + this->timer = 20 * modifiedSpawnRate; + } } } } @@ -249,7 +253,7 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, PlayState* play) { (CVarGetInteger("gRandomizedEnemies", 0) && enemyCount < 15)) { if (play->sceneNum == SCENE_HYRULE_FIELD) { if ((player->floorSfxOffset == 0) || (player->actor.floorBgId != BGCHECK_SCENE) || - !(player->actor.bgCheckFlags & 1) || (player->stateFlags1 & 0x08000000)) { + !(player->actor.bgCheckFlags & 1) || (player->stateFlags1 & PLAYER_STATE1_IN_WATER)) { this->fieldSpawnTimer = 60; break; diff --git a/soh/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c b/soh/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c index fbdfbc7f7..aa52d53ae 100644 --- a/soh/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c +++ b/soh/src/overlays/actors/ovl_En_Fire_Rock/z_en_fire_rock.c @@ -362,7 +362,7 @@ void EnFireRock_Update(Actor* thisx, PlayState* play) { if (this->collider.base.atFlags & 2) { this->collider.base.atFlags &= ~2; if (this->collider.base.at == playerActor) { - if (!(player->stateFlags1 & 0x04000000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_DAMAGED)) { func_8002F758(play, thisx, 2.0f, -player->actor.world.rot.y, 3.0f, 4); } return; diff --git a/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c b/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c index bf7b79b7f..f37bc73db 100644 --- a/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c +++ b/soh/src/overlays/actors/ovl_En_Firefly/z_en_firefly.c @@ -415,7 +415,8 @@ void EnFirefly_FlyIdle(EnFirefly* this, PlayState* play) { Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300); } if ((this->timer == 0) && (this->actor.xzDistToPlayer < 200.0f) && - (Player_GetMask(play) != PLAYER_MASK_SKULL)) { + (Player_GetMask(play) != PLAYER_MASK_SKULL) && + !CVarGetInteger("gNoKeeseGuayTarget", 0)) { EnFirefly_SetupDiveAttack(this); } } @@ -493,7 +494,8 @@ void EnFirefly_DiveAttack(EnFirefly* this, PlayState* play) { } Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100); } - if ((this->timer == 0) || (Player_GetMask(play) == PLAYER_MASK_SKULL)) { + if ((this->timer == 0) || (Player_GetMask(play) == PLAYER_MASK_SKULL) || + CVarGetInteger("gNoKeeseGuayTarget", 0)) { EnFirefly_SetupFlyAway(this); } } diff --git a/soh/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c b/soh/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c index 59136cee2..1a906e5b7 100644 --- a/soh/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c +++ b/soh/src/overlays/actors/ovl_En_Floormas/z_en_floormas.c @@ -797,7 +797,7 @@ void EnFloormas_GrabLink(EnFloormas* this, PlayState* play) { this->actor.world.pos.z = Math_CosS(this->actor.shape.rot.y) * (xzDelta * 0.1f) + player->actor.world.pos.z; // let go - if (!(player->stateFlags2 & 0x80) || (player->invincibilityTimer < 0)) { + if (!(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) || (player->invincibilityTimer < 0)) { parent = (EnFloormas*)this->actor.parent; child = (EnFloormas*)this->actor.child; diff --git a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c index 11a7eb026..36c9c2818 100644 --- a/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/soh/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -606,7 +606,7 @@ s32 EnFr_SetupJumpingUp(EnFr* this, s32 frogIndex) { void EnFr_Idle(EnFr* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (player->stateFlags2 & 0x2000000) { + if (player->stateFlags2 & PLAYER_STATE2_PLAY_FOR_ACTOR) { if (play->msgCtx.ocarinaMode == OCARINA_MODE_04) { play->msgCtx.ocarinaMode = OCARINA_MODE_00; } @@ -616,7 +616,7 @@ void EnFr_Idle(EnFr* this, PlayState* play) { player->actor.world.pos.x = this->actor.world.pos.x; // x = 990.0f player->actor.world.pos.y = this->actor.world.pos.y; // y = 205.0f player->actor.world.pos.z = this->actor.world.pos.z; // z = -1220.0f - player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; + player->yaw = player->actor.world.rot.y = player->actor.shape.rot.y = this->actor.world.rot.y; this->reward = GI_NONE; this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; this->actionFunc = EnFr_Activate; diff --git a/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c b/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c index 278fb18e2..67ad97c96 100644 --- a/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c +++ b/soh/src/overlays/actors/ovl_En_Fu/z_en_fu.c @@ -208,17 +208,17 @@ void func_80A1DBD4(EnFu* this, PlayState* play) { play->msgCtx.ocarinaMode = OCARINA_MODE_00; Flags_SetEventChkInf(EVENTCHKINF_PLAYED_SONG_OF_STORMS_IN_WINDMILL); } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_02) { - player->stateFlags2 &= ~0x1000000; + player->stateFlags2 &= ~PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR; this->actionFunc = EnFu_WaitAdult; } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } void EnFu_WaitForPlayback(EnFu* this, PlayState* play) { Player* player = GET_PLAYER(play); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; // if dialog state is 7, player has played back the song if (Message_GetState(&play->msgCtx) == TEXT_STATE_SONG_DEMO_DONE) { func_8010BD58(play, OCARINA_ACTION_PLAYBACK_STORMS); @@ -229,7 +229,7 @@ void EnFu_WaitForPlayback(EnFu* this, PlayState* play) { void EnFu_TeachSong(EnFu* this, PlayState* play) { Player* player = GET_PLAYER(play); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; // if dialog state is 2, start song demonstration if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->behaviorFlags &= ~FU_WAIT; @@ -246,7 +246,7 @@ void EnFu_WaitAdult(EnFu* this, PlayState* play) { yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; if ((Flags_GetEventChkInf(EVENTCHKINF_LEARNED_SONG_OF_STORMS))) { func_80A1D94C(this, play, 0x508E, func_80A1DBA0); - } else if (player->stateFlags2 & 0x1000000) { + } else if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { this->actor.textId = 0x5035; Message_StartTextbox(play, this->actor.textId, NULL); this->actionFunc = IS_RANDO ? func_80A1DBD4 : EnFu_TeachSong; @@ -257,7 +257,7 @@ void EnFu_WaitAdult(EnFu* this, PlayState* play) { if (this->actor.xzDistToPlayer < 100.0f) { this->actor.textId = 0x5034; func_8002F2CC(&this->actor, play, 100.0f); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } } diff --git a/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c b/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index 1ad8f4867..92a768205 100644 --- a/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/soh/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -661,7 +661,7 @@ void EnGe1_BeginGame_Archery(EnGe1* this, PlayState* play) { gSaveContext.eventInf[0] |= 0x100; Flags_SetEventChkInf(EVENTCHKINF_PLAYED_HORSEBACK_ARCHERY); - if (!(player->stateFlags1 & 0x800000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_ON_HORSE)) { func_8002DF54(play, &this->actor, 1); } else { horse = Actor_FindNearby(play, &player->actor, ACTOR_EN_HORSE, ACTORCAT_BG, 1200.0f); @@ -741,7 +741,7 @@ void EnGe1_Wait_Archery(EnGe1* this, PlayState* play) { Player* player = GET_PLAYER(play); u16 textId; - if (!(player->stateFlags1 & 0x800000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_ON_HORSE)) { EnGe1_SetTalkAction(this, play, 0x603F, 100.0f, EnGe1_TalkNoHorse_Archery); } else { if (Flags_GetEventChkInf(EVENTCHKINF_PLAYED_HORSEBACK_ARCHERY)) { diff --git a/soh/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c b/soh/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c index c61ac7de1..432116b2d 100644 --- a/soh/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c +++ b/soh/src/overlays/actors/ovl_En_Goroiwa/z_en_goroiwa.c @@ -725,7 +725,7 @@ void EnGoroiwa_Update(Actor* thisx, PlayState* play) { s32 pad; s32 sp30; - if (!(player->stateFlags1 & 0x300000C0)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE))) { if (this->collisionDisabledTimer > 0) { this->collisionDisabledTimer--; } diff --git a/soh/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/soh/src/overlays/actors/ovl_En_Gs/z_en_gs.c index e2a4cdaa0..159774406 100644 --- a/soh/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/soh/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -144,8 +144,8 @@ void func_80A4E470(EnGs* this, PlayState* play) { if (this->actor.xzDistToPlayer <= 100.0f) { bREG(15) = 1; if (this->unk_19D == 0) { - player->stateFlags2 |= 0x800000; - if (player->stateFlags2 & 0x1000000) { + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { func_8010BD58(play, OCARINA_ACTION_FREE_PLAY); this->unk_19D |= 1; } @@ -168,7 +168,7 @@ void func_80A4E470(EnGs* this, PlayState* play) { this->unk_19D = 0; Flags_SetSwitch(play, (this->actor.params >> 8) & 0x3F); } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } } diff --git a/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c index d8192be6c..f653b6ff9 100644 --- a/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/soh/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -724,7 +724,7 @@ void EnHorse_ResetRace(EnHorse* this, PlayState* play) { s32 EnHorse_PlayerCanMove(EnHorse* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((player->stateFlags1 & 1) || func_8002DD78(GET_PLAYER(play)) == 1 || (player->stateFlags1 & 0x100000) || + if ((player->stateFlags1 & PLAYER_STATE1_LOADING) || func_8002DD78(GET_PLAYER(play)) == 1 || (player->stateFlags1 & PLAYER_STATE1_FIRST_PERSON) || ((this->stateFlags & ENHORSE_FLAG_19) && !this->inRace) || this->action == ENHORSE_ACT_HBA || player->actor.flags & ACTOR_FLAG_PLAYER_TALKED_TO || play->csCtx.state != 0) { return false; @@ -3533,7 +3533,7 @@ void EnHorse_Update(Actor* thisx, PlayState* play2) { CollisionCheck_SetAT(play, &play->colChkCtx, &this->cyl1.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->cyl1.base); CollisionCheck_SetOC(play, &play->colChkCtx, &this->cyl2.base); - if ((player->stateFlags1 & 1) && player->rideActor != NULL) { + if ((player->stateFlags1 & PLAYER_STATE1_LOADING) && player->rideActor != NULL) { if (play->sceneNum != SCENE_LON_LON_RANCH || (play->sceneNum == SCENE_LON_LON_RANCH && (thisx->world.pos.z < -2400.0f))) { EnHorse_UpdateConveyors(this, play); diff --git a/soh/src/overlays/actors/ovl_En_In/z_en_in.c b/soh/src/overlays/actors/ovl_En_In/z_en_in.c index dd8b52fcc..1d0866e6d 100644 --- a/soh/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/soh/src/overlays/actors/ovl_En_In/z_en_in.c @@ -145,7 +145,7 @@ u16 func_80A79010(PlayState* play) { } switch (gSaveContext.eventInf[0] & 0xF) { case 1: - if (!(player->stateFlags1 & 0x800000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_ON_HORSE)) { return 0x2036; } else if (Flags_GetEventChkInf(EVENTCHKINF_RENTED_HORSE_FROM_INGO)) { if (Flags_GetInfTable(INFTABLE_A2)) { @@ -657,7 +657,7 @@ void func_80A7A568(EnIn* this, PlayState* play) { s32 phi_a2; s32 transitionType; - if (!Flags_GetEventChkInf(EVENTCHKINF_RENTED_HORSE_FROM_INGO) && (player->stateFlags1 & 0x800000)) { + if (!Flags_GetEventChkInf(EVENTCHKINF_RENTED_HORSE_FROM_INGO) && (player->stateFlags1 & PLAYER_STATE1_ON_HORSE)) { Flags_SetInfTable(INFTABLE_AB); } if (gSaveContext.timer1State == 10) { diff --git a/soh/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/soh/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 8c3104e9b..cf2f4499b 100644 --- a/soh/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/soh/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -213,18 +213,18 @@ void func_80A8F75C(EnKakasi* this, PlayState* play) { if (absyawTowardsPlayer < 0x4300) { if (!this->unk_194) { - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { this->camId = OnePointCutscene_Init(play, 2260, -99, &this->actor, MAIN_CAM); func_8010BD58(play, OCARINA_ACTION_SCARECROW_LONG_RECORDING); this->unk_19A = 0; this->unk_1B8 = 0.0; - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; this->actionFunc = func_80A8F8D0; return; } if (this->actor.xzDistToPlayer < 80.0f) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } func_8002F2CC(&this->actor, play, 100.0f); @@ -253,7 +253,7 @@ void func_80A8F8D0(EnKakasi* this, PlayState* play) { } } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { func_80A8F320(this, play, 0); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } diff --git a/soh/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c b/soh/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c index bc2fb7632..37b6236a5 100644 --- a/soh/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c +++ b/soh/src/overlays/actors/ovl_En_Kakasi3/z_en_kakasi3.c @@ -232,33 +232,33 @@ void func_80A91348(EnKakasi3* this, PlayState* play) { if (absAngleTowardsLink < 0x4300) { if (!this->unk_194) { - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { this->camId = OnePointCutscene_Init(play, 2260, -99, &this->actor, MAIN_CAM); play->msgCtx.msgMode = MSGMODE_PAUSED; this->dialogState = TEXT_STATE_EVENT; this->unk_1B8 = 0.0f; Message_StartTextbox(play, 0x40A4, NULL); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; this->actionFunc = func_80A915B8; return; } if (this->actor.xzDistToPlayer < 80.0f) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } else if (gSaveContext.scarecrowSpawnSongSet && !this->unk_195) { - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { this->camId = OnePointCutscene_Init(play, 2260, -99, &this->actor, MAIN_CAM); play->msgCtx.msgMode = MSGMODE_PAUSED; this->dialogState = TEXT_STATE_EVENT; this->unk_1B8 = 0.0f; Message_StartTextbox(play, 0x40A8, NULL); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; this->actionFunc = func_80A9187C; return; } if (this->actor.xzDistToPlayer < 80.0f) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } func_8002F2CC(&this->actor, play, 100.0f); @@ -303,7 +303,7 @@ void func_80A91620(EnKakasi3* this, PlayState* play) { if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { func_80A90EBC(this, play, 0); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } @@ -377,7 +377,7 @@ void func_80A918E4(EnKakasi3* this, PlayState* play) { if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { func_80A90EBC(this, play, 0); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } diff --git a/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index 6f8624518..00cfb3555 100644 --- a/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -84,7 +84,7 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) { Actor_SetScale(&this->actor, 0.1f); this->unk_1CA = 0; - if (player->stateFlags2 & 0x20000) { + if (player->stateFlags2 & PLAYER_STATE2_SPIN_ATTACKING) { if (!gSaveContext.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || (((this->actor.params & 0xFF00) >> 8) && !(Magic_RequestChange(play, (this->actor.params & 0xFF00) >> 8, MAGIC_CONSUME_NOW)))) { @@ -96,7 +96,7 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) { return; } - player->stateFlags2 &= ~0x20000; + player->stateFlags2 &= ~PLAYER_STATE2_SPIN_ATTACKING; this->unk_1CA = 1; this->collider.info.toucher.dmgFlags = D_80AA044C[this->unk_1C7]; this->unk_1C6 = 1; @@ -131,7 +131,7 @@ void func_80A9F314(PlayState* play, f32 arg1) { void func_80A9F350(EnMThunder* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (player->stateFlags2 & 0x20000) { + if (player->stateFlags2 & PLAYER_STATE2_SPIN_ATTACKING) { if (player->meleeWeaponAnimation >= 0x18) { Audio_PlaySoundGeneral(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -143,7 +143,7 @@ void func_80A9F350(EnMThunder* this, PlayState* play) { return; } - if (!(player->stateFlags1 & 0x1000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_CHARGING_SPIN_ATTACK)) { Actor_Kill(&this->actor); } } @@ -176,7 +176,7 @@ void func_80A9F408(EnMThunder* this, PlayState* play) { func_800AA000(0.0f, (s32)(player->unk_858 * 150.0f) & 0xFF, 2, (s32)(player->unk_858 * 150.0f) & 0xFF); } - if (player->stateFlags2 & 0x20000) { + if (player->stateFlags2 & PLAYER_STATE2_SPIN_ATTACKING) { if ((child != NULL) && (child->update != NULL)) { child->parent = NULL; } @@ -191,7 +191,7 @@ void func_80A9F408(EnMThunder* this, PlayState* play) { Actor_Kill(&this->actor); return; } else { - player->stateFlags2 &= ~0x20000; + player->stateFlags2 &= ~PLAYER_STATE2_SPIN_ATTACKING; if ((this->actor.params & 0xFF00) >> 8) { gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } @@ -214,7 +214,7 @@ void func_80A9F408(EnMThunder* this, PlayState* play) { } } - if (!(player->stateFlags1 & 0x1000)) { + if (!(player->stateFlags1 & PLAYER_STATE1_CHARGING_SPIN_ATTACK)) { if (this->actor.child != NULL) { this->actor.child->parent = NULL; } diff --git a/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c b/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c index 8a11eb668..606bca3b8 100644 --- a/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c +++ b/soh/src/overlays/actors/ovl_En_Ma1/z_en_ma1.c @@ -420,8 +420,8 @@ void func_80AA0F44(EnMa1* this, PlayState* play) { if (Flags_GetEventChkInf(EVENTCHKINF_INVITED_TO_SING_WITH_CHILD_MALON)) { // When the player pulls out the Ocarina while close to Malon - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { + player->stateFlags2 |= PLAYER_STATE2_PLAY_FOR_ACTOR; player->unk_6A8 = &this->actor; this->actor.textId = 0x2061; Message_StartTextbox(play, this->actor.textId, NULL); @@ -432,7 +432,7 @@ void func_80AA0F44(EnMa1* this, PlayState* play) { } else if (this->actor.xzDistToPlayer < 30.0f + (f32)this->collider.dim.radius) { // somehow flags that the player is close to malon so that pulling out the Ocarina // triggers the code above this. - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } // If rando'ed, a textbox is closing, it's malon's 'my mom wrote this song' text, AND we do have an ocarina // in our inventory. This allows us to grant the check when talking to malon with the ocarina in our inventory. @@ -444,7 +444,7 @@ void func_80AA0F44(EnMa1* this, PlayState* play) { } void func_80AA106C(EnMa1* this, PlayState* play) { - GET_PLAYER(play)->stateFlags2 |= 0x800000; + GET_PLAYER(play)->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; if (this->interactInfo.talkState == NPC_TALK_STATE_ACTION) { Audio_OcaSetInstrument(2); func_8010BD58(play, OCARINA_ACTION_TEACH_EPONA); @@ -454,7 +454,7 @@ void func_80AA106C(EnMa1* this, PlayState* play) { } void func_80AA10EC(EnMa1* this, PlayState* play) { - GET_PLAYER(play)->stateFlags2 |= 0x800000; + GET_PLAYER(play)->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; if (Message_GetState(&play->msgCtx) == TEXT_STATE_SONG_DEMO_DONE) { func_8010BD58(play, OCARINA_ACTION_PLAYBACK_EPONA); this->actionFunc = func_80AA1150; @@ -481,7 +481,7 @@ void EnMa1_EndTeachSong(EnMa1* this, PlayState* play) { } void func_80AA1150(EnMa1* this, PlayState* play) { - GET_PLAYER(play)->stateFlags2 |= 0x800000; + GET_PLAYER(play)->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; // When rando'ed, trigger the "song learned" Ocarina mode. if (IS_RANDO && (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING)) { diff --git a/soh/src/overlays/actors/ovl_En_Ma2/z_en_ma2.c b/soh/src/overlays/actors/ovl_En_Ma2/z_en_ma2.c index dc50b0e0e..1519e57c7 100644 --- a/soh/src/overlays/actors/ovl_En_Ma2/z_en_ma2.c +++ b/soh/src/overlays/actors/ovl_En_Ma2/z_en_ma2.c @@ -265,13 +265,13 @@ void func_80AA2018(EnMa2* this, PlayState* play) { void func_80AA204C(EnMa2* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { player->unk_6A8 = &this->actor; - player->stateFlags2 |= 0x2000000; + player->stateFlags2 |= PLAYER_STATE2_PLAY_FOR_ACTOR; func_8010BD58(play, OCARINA_ACTION_CHECK_EPONA); this->actionFunc = func_80AA20E4; } else if (this->actor.xzDistToPlayer < 30.0f + (f32)this->collider.dim.radius) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } @@ -288,7 +288,7 @@ void func_80AA20E4(EnMa2* this, PlayState* play) { this->actionFunc = func_80AA21C8; play->msgCtx.ocarinaMode = OCARINA_MODE_04; } else { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } @@ -296,7 +296,7 @@ void func_80AA21C8(EnMa2* this, PlayState* play) { Player* player = GET_PLAYER(play); if (DECR(this->unk_208)) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } else { if (this->interactInfo.talkState == NPC_TALK_STATE_IDLE) { this->actor.flags |= ACTOR_FLAG_WILL_TALK; diff --git a/soh/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c b/soh/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c index 5280f583e..63c4f4da6 100644 --- a/soh/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c +++ b/soh/src/overlays/actors/ovl_En_Ma3/z_en_ma3.c @@ -98,7 +98,7 @@ u16 func_80AA2AA0(PlayState* play, Actor* thisx) { return 0x2004; } } - if ((!(player->stateFlags1 & 0x800000)) && + if ((!(player->stateFlags1 & PLAYER_STATE1_ON_HORSE)) && (Actor_FindNearby(play, thisx, ACTOR_EN_HORSE, 1, 1200.0f) == NULL)) { return 0x2001; } diff --git a/soh/src/overlays/actors/ovl_En_Mb/z_en_mb.c b/soh/src/overlays/actors/ovl_En_Mb/z_en_mb.c index 59bee3ee5..43f6a6665 100644 --- a/soh/src/overlays/actors/ovl_En_Mb/z_en_mb.c +++ b/soh/src/overlays/actors/ovl_En_Mb/z_en_mb.c @@ -612,10 +612,10 @@ void EnMb_SetupStunned(EnMb* this) { void EnMb_Stunned(EnMb* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && player->actor.parent == &this->actor) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); this->attack = ENMB_ATTACK_NONE; } @@ -737,10 +737,10 @@ void EnMb_SpearPatrolEndCharge(EnMb* this, PlayState* play) { s16 relYawFromPlayer; s16 yawPlayerToWaypoint; - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && player->actor.parent == &this->actor) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); } @@ -939,7 +939,7 @@ void EnMb_SpearPatrolPrepareAndCharge(EnMb* this, PlayState* play) { if (this->attackCollider.base.atFlags & AT_HIT) { if (this->attackCollider.base.at == &player->actor) { - if (!endCharge && !(player->stateFlags2 & 0x80)) { + if (!endCharge && !(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { if (player->invincibilityTimer < 0) { if (player->invincibilityTimer < -39) { player->invincibilityTimer = 0; @@ -961,24 +961,24 @@ void EnMb_SpearPatrolPrepareAndCharge(EnMb* this, PlayState* play) { } } - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && player->actor.parent == &this->actor) { player->actor.world.pos.x = this->actor.world.pos.x + Math_CosS(this->actor.shape.rot.y) * 10.0f + Math_SinS(this->actor.shape.rot.y) * 89.0f; hasHitPlayer = true; player->actor.world.pos.z = this->actor.world.pos.z + Math_SinS(this->actor.shape.rot.y) * 10.0f + Math_CosS(this->actor.shape.rot.y) * 89.0f; - player->unk_850 = 0; + player->av2.actionVar2 = 0; player->actor.speedXZ = 0.0f; player->actor.velocity.y = 0.0f; } if (endCharge) { - if (hasHitPlayer || (player->stateFlags2 & 0x80)) { + if (hasHitPlayer || (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { this->attackCollider.base.atFlags &= ~AT_HIT; - if (player->stateFlags2 & 0x80) { - player->stateFlags2 &= ~0x80; + if (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); } } @@ -1008,7 +1008,7 @@ void EnMb_SpearPatrolImmediateCharge(EnMb* this, PlayState* play) { if (this->attackCollider.base.atFlags & AT_HIT) { if (this->attackCollider.base.at == &player->actor) { - if (!endCharge && !(player->stateFlags2 & 0x80)) { + if (!endCharge && !(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { if (player->invincibilityTimer < 0) { if (player->invincibilityTimer <= -40) { player->invincibilityTimer = 0; @@ -1030,24 +1030,24 @@ void EnMb_SpearPatrolImmediateCharge(EnMb* this, PlayState* play) { } } - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && player->actor.parent == &this->actor) { player->actor.world.pos.x = this->actor.world.pos.x + Math_CosS(this->actor.shape.rot.y) * 10.0f + Math_SinS(this->actor.shape.rot.y) * 89.0f; hasHitPlayer = true; player->actor.world.pos.z = this->actor.world.pos.z + Math_SinS(this->actor.shape.rot.y) * 10.0f + Math_CosS(this->actor.shape.rot.y) * 89.0f; - player->unk_850 = 0; + player->av2.actionVar2 = 0; player->actor.speedXZ = 0.0f; player->actor.velocity.y = 0.0f; } if (endCharge) { - if (hasHitPlayer || (player->stateFlags2 & 0x80)) { + if (hasHitPlayer || (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { this->attackCollider.base.atFlags &= ~AT_HIT; - if (player->stateFlags2 & 0x80) { - player->stateFlags2 &= ~0x80; + if (player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); } this->attack = ENMB_ATTACK_NONE; @@ -1274,7 +1274,7 @@ void EnMb_ClubWaitPlayerNear(EnMb* this, PlayState* play) { SkelAnime_Update(&this->skelAnime); if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) < this->playerDetectionRange && - !(player->stateFlags1 & 0x4000000) && ABS(relYawFromPlayer) < 0x3E80) { + !(player->stateFlags1 & PLAYER_STATE1_DAMAGED) && ABS(relYawFromPlayer) < 0x3E80) { // Add a height check to the Moblin's Club attack when Enemy Randomizer is on. // Without the height check, the Moblin will attack (and play the sound effect) a lot even though // the Moblin is very far away from the player in vertical rooms (like the first room in Deku Tree). @@ -1339,10 +1339,10 @@ void EnMb_SpearDead(EnMb* this, PlayState* play) { Math_SmoothStepToF(&this->actor.speedXZ, 0.0f, 1.0f, 0.5f, 0.0f); - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && player->actor.parent == &this->actor) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; func_8002F71C(play, &this->actor, 4.0f, this->actor.world.rot.y, 4.0f); this->attack = ENMB_ATTACK_NONE; } @@ -1422,10 +1422,10 @@ void EnMb_CheckColliding(EnMb* this, PlayState* play) { this->hitbox.base.acFlags &= ~AC_HIT; if (this->actor.colChkInfo.damageEffect != ENMB_DMGEFF_IGNORE && this->actor.colChkInfo.damageEffect != ENMB_DMGEFF_FREEZE) { - if ((player->stateFlags2 & 0x80) && player->actor.parent == &this->actor) { - player->stateFlags2 &= ~0x80; + if ((player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && player->actor.parent == &this->actor) { + player->stateFlags2 &= ~PLAYER_STATE2_GRABBED_BY_ENEMY; player->actor.parent = NULL; - player->unk_850 = 200; + player->av2.actionVar2 = 200; func_8002F71C(play, &this->actor, 6.0f, this->actor.world.rot.y, 6.0f); } this->damageEffect = this->actor.colChkInfo.damageEffect; diff --git a/soh/src/overlays/actors/ovl_En_Md/z_en_md.c b/soh/src/overlays/actors/ovl_En_Md/z_en_md.c index 14d9cbb7b..9181b452b 100644 --- a/soh/src/overlays/actors/ovl_En_Md/z_en_md.c +++ b/soh/src/overlays/actors/ovl_En_Md/z_en_md.c @@ -774,8 +774,8 @@ void func_80AAB948(EnMd* this, PlayState* play) { } if ((this->interactInfo.talkState == NPC_TALK_STATE_IDLE) && (play->sceneNum == SCENE_LOST_WOODS)) { - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { + player->stateFlags2 |= PLAYER_STATE2_PLAY_FOR_ACTOR; player->unk_6A8 = &this->actor; func_8010BD58(play, OCARINA_ACTION_CHECK_SARIA); this->actionFunc = func_80AABC10; @@ -783,7 +783,7 @@ void func_80AAB948(EnMd* this, PlayState* play) { } if (this->actor.xzDistToPlayer < (30.0f + this->collider.dim.radius)) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } } @@ -802,7 +802,7 @@ void func_80AABC10(EnMd* this, PlayState* play) { this->actionFunc = func_80AAB948; play->msgCtx.ocarinaMode = OCARINA_MODE_04; } else { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } diff --git a/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c b/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c index e5501858c..989b90c96 100644 --- a/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c +++ b/soh/src/overlays/actors/ovl_En_Mk/z_en_mk.c @@ -342,13 +342,13 @@ void EnMk_Update(Actor* thisx, PlayState* play) { player = GET_PLAYER(play); if (this->flags & 8) { - if (!(player->stateFlags2 & 0x400)) { + if (!(player->stateFlags2 & PLAYER_STATE2_UNDERWATER)) { this->flags &= ~8; } } else { if (player->currentBoots == PLAYER_BOOTS_IRON) { this->flags |= 8; - } else if (player->stateFlags2 & 0x400) { + } else if (player->stateFlags2 & PLAYER_STATE2_UNDERWATER) { swimFlag = player->actor.yDistToWater; if (swimFlag > 0) { diff --git a/soh/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/soh/src/overlays/actors/ovl_En_Ms/z_en_ms.c index b1d453f00..f89644847 100644 --- a/soh/src/overlays/actors/ovl_En_Ms/z_en_ms.c +++ b/soh/src/overlays/actors/ovl_En_Ms/z_en_ms.c @@ -18,6 +18,7 @@ void EnMs_SetOfferText(EnMs* this, PlayState* play); void EnMs_Wait(EnMs* this, PlayState* play); void EnMs_Talk(EnMs* this, PlayState* play); void EnMs_Sell(EnMs* this, PlayState* play); +void EnMs_Sell_Rando(EnMs* this, PlayState* play); void EnMs_TalkAfterPurchase(EnMs* this, PlayState* play); const ActorInit En_Ms_InitVars = { @@ -49,6 +50,10 @@ static s16 sPrices[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, }; +static s16 sRandoPrices[] = { + 10, 20, 30, 40, 50, 60, 70, 80, 90, 99, +}; + static u16 sOfferTextIDs[] = { 0x405E, 0x405F, 0x4060, 0x4061, 0x4062, 0x4063, 0x4064, 0x4065, 0x4066, 0x4067, }; @@ -127,21 +132,30 @@ void EnMs_Talk(EnMs* this, PlayState* play) { } else if (Message_ShouldAdvance(play)) { switch (play->msgCtx.choiceIndex) { case 0: // yes - if (gSaveContext.rupees < - ((IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) - ? 60 - : sPrices[BEANS_BOUGHT])) { - Message_ContinueTextbox(play, 0x4069); // not enough rupees text + //Randomizer Mechanic: Magic bean salesman + if (IS_RANDO){ + if (gSaveContext.rupees < ((Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) ? 60 : sRandoPrices[BEANS_BOUGHT])) { + Message_ContinueTextbox(play, 0x4069); // TEXT_BEAN_SALESMAN_NOT_ENOUGH_MONEY + return; + } + if (Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)){ + GiveItemEntryFromActor(&this->actor, play, + Randomizer_GetItemFromKnownCheck(RC_ZR_MAGIC_BEAN_SALESMAN, GI_BEAN), 90.0f, 10.0f); + } else { + func_8002F434(&this->actor, play, GI_BEAN, 90.0f, 10.0f); + } + this->actionFunc = EnMs_Sell_Rando; + return; + } else { // vanilla code + if(gSaveContext.rupees < sPrices[BEANS_BOUGHT]){ + Message_ContinueTextbox(play, 0x4069); // TEXT_BEAN_SALESMAN_NOT_ENOUGH_MONEY + return; + } + func_8002F434(&this->actor, play, GI_BEAN, 90.0f, 10.0f); + this->actionFunc = EnMs_Sell; return; } - if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) { - GiveItemEntryFromActor(&this->actor, play, - Randomizer_GetItemFromKnownCheck(RC_ZR_MAGIC_BEAN_SALESMAN, GI_BEAN), 90.0f, 10.0f); - } else { - func_8002F434(&this->actor, play, GI_BEAN, 90.0f, 10.0f); - } - this->actionFunc = EnMs_Sell; - return; + //Randomizer Mechanic end case 1: // no Message_ContinueTextbox(play, 0x4068); default: @@ -150,14 +164,13 @@ void EnMs_Talk(EnMs* this, PlayState* play) { } } -void EnMs_Sell(EnMs* this, PlayState* play) { +void EnMs_Sell_Rando(EnMs* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { - Rupees_ChangeBy((IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) ? -60 : -sPrices[BEANS_BOUGHT]); + Rupees_ChangeBy((Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) ? -60 : -sRandoPrices[BEANS_BOUGHT]); this->actor.parent = NULL; - this->actionFunc = - (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) ? EnMs_Wait : EnMs_TalkAfterPurchase; + this->actionFunc = (Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) ? EnMs_Wait : EnMs_TalkAfterPurchase; } else { - if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) { + if (Randomizer_GetSettingValue(RSK_SHUFFLE_MAGIC_BEANS)) { GetItemEntry itemEntry = Randomizer_GetItemFromKnownCheck(RC_ZR_MAGIC_BEAN_SALESMAN, GI_BEAN); gSaveContext.pendingSale = itemEntry.itemId; gSaveContext.pendingSaleMod = itemEntry.modIndex; @@ -172,6 +185,16 @@ void EnMs_Sell(EnMs* this, PlayState* play) { } } +void EnMs_Sell(EnMs* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + Rupees_ChangeBy(-sPrices[BEANS_BOUGHT]); + this->actor.parent = NULL; + this->actionFunc = EnMs_TalkAfterPurchase; + } else { + func_8002F434(&this->actor, play, GI_BEAN, 90.0f, 10.0f); + } +} + void EnMs_TalkAfterPurchase(EnMs* this, PlayState* play) { // if dialog state is 6 and player responded to textbox if ((Message_GetState(&play->msgCtx)) == TEXT_STATE_DONE && Message_ShouldAdvance(play)) { diff --git a/soh/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c b/soh/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c index d2500afaf..2add8c4a9 100644 --- a/soh/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c +++ b/soh/src/overlays/actors/ovl_En_Nutsball/z_en_nutsball.c @@ -156,7 +156,7 @@ void EnNutsball_Update(Actor* thisx, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; - if (!(player->stateFlags1 & 0x300000C0) || (this->actionFunc == func_80ABBB34)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE)) || (this->actionFunc == func_80ABBB34)) { this->actionFunc(this, play); Actor_MoveForward(&this->actor); diff --git a/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c b/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c index 74afaacff..8cb491da4 100644 --- a/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c +++ b/soh/src/overlays/actors/ovl_En_Okarina_Tag/z_en_okarina_tag.c @@ -115,18 +115,18 @@ void func_80ABEF2C(EnOkarinaTag* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; } else { if ((this->ocarinaSong != 6) || (gSaveContext.scarecrowSpawnSongSet)) { - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { // "North! ! ! ! !" osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ 北!!!!! ☆☆☆☆☆ %f\n" VT_RST, this->actor.xzDistToPlayer); } if ((this->actor.xzDistToPlayer < (90.0f + this->interactRange)) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { - if (player->stateFlags2 & 0x2000000) { + if (player->stateFlags2 & PLAYER_STATE2_PLAY_FOR_ACTOR) { ocarinaSong = this->ocarinaSong; if (ocarinaSong == 6) { ocarinaSong = 0xA; } - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; func_8010BD58(play, ocarinaSong + OCARINA_ACTION_CHECK_SARIA); this->actionFunc = func_80ABF0CC; } else if ((this->actor.xzDistToPlayer < (50.0f + this->interactRange) && @@ -180,7 +180,7 @@ void func_80ABF0CC(EnOkarinaTag* this, PlayState* play) { play->msgCtx.ocarinaMode = OCARINA_MODE_04; this->actionFunc = func_80ABEF2C; } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } } @@ -196,7 +196,7 @@ void func_80ABF28C(EnOkarinaTag* this, PlayState* play) { ((this->type != 6) || !Flags_GetEventChkInf(EVENTCHKINF_DESTROYED_ROYAL_FAMILY_TOMB)) && (this->actor.xzDistToPlayer < (90.0f + this->interactRange)) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 80.0f)) { - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { switch (this->type) { case 1: func_8010BD58(play, OCARINA_ACTION_CHECK_LULLABY); @@ -217,12 +217,12 @@ void func_80ABF28C(EnOkarinaTag* this, PlayState* play) { Actor_Kill(&this->actor); break; } - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; this->actionFunc = func_80ABF4C8; } else if ((this->actor.xzDistToPlayer < (50.0f + this->interactRange)) && (fabsf(player->actor.world.pos.y - this->actor.world.pos.y) < 40.0f)) { this->unk_15A = 0; - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } } @@ -296,7 +296,7 @@ void func_80ABF4C8(EnOkarinaTag* this, PlayState* play) { } } if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } } diff --git a/soh/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c b/soh/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c index 017d1e9ae..9533e8309 100644 --- a/soh/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c +++ b/soh/src/overlays/actors/ovl_En_Okuta/z_en_okuta.c @@ -629,7 +629,7 @@ void EnOkuta_Update(Actor* thisx, PlayState* play2) { Vec3f sp38; s32 sp34; - if (!(player->stateFlags1 & 0x300000C0)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE))) { if (this->actor.params == 0) { EnOkuta_ColliderCheck(this, play); if (!WaterBox_GetSurfaceImpl(play, &play->colCtx, this->actor.world.pos.x, diff --git a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index b0d03430a..34ef24e40 100644 --- a/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -678,7 +678,7 @@ void EnOssan_EndInteraction(PlayState* play, EnOssan* this) { Actor_ProcessTalkRequest(&this->actor, play); play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; play->msgCtx.stateTimer = 4; - player->stateFlags2 &= ~0x20000000; + player->stateFlags2 &= ~PLAYER_STATE2_DISABLE_DRAW; func_800BC490(play, 1); Interface_ChangeAlpha(50); this->drawCursor = 0; @@ -762,7 +762,7 @@ void EnOssan_State_Idle(EnOssan* this, PlayState* play, Player* player) { if (Actor_ProcessTalkRequest(&this->actor, play)) { // "Start conversation!!" osSyncPrintf(VT_FGCOL(YELLOW) "★★★ 会話開始!! ★★★" VT_RST "\n"); - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_DISABLE_DRAW; func_800BC590(play); EnOssan_SetStateStartShopping(play, this, false); } else if (this->actor.xzDistToPlayer < 100.0f) { @@ -1403,7 +1403,7 @@ void EnOssan_GiveItemWithFanfare(PlayState* play, EnOssan* this) { } play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; play->msgCtx.stateTimer = 4; - player->stateFlags2 &= ~0x20000000; + player->stateFlags2 &= ~PLAYER_STATE2_DISABLE_DRAW; func_800BC490(play, 1); Interface_ChangeAlpha(50); this->drawCursor = 0; @@ -1811,7 +1811,7 @@ void EnOssan_State_ContinueShoppingPrompt(EnOssan* this, PlayState* play, Player case 0: osSyncPrintf(VT_FGCOL(YELLOW) "★★★ 続けるよ!! ★★★" VT_RST "\n"); player->actor.shape.rot.y += 0x8000; - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_DISABLE_DRAW; func_800BC490(play, 2); Message_StartTextbox(play, this->actor.textId, &this->actor); EnOssan_SetStateStartShopping(play, this, true); @@ -1830,7 +1830,7 @@ void EnOssan_State_ContinueShoppingPrompt(EnOssan* this, PlayState* play, Player selectedItem = this->shelfSlots[this->cursorIndex]; selectedItem->updateStockedItemFunc(play, selectedItem); player->actor.shape.rot.y += 0x8000; - player->stateFlags2 |= 0x20000000; + player->stateFlags2 |= PLAYER_STATE2_DISABLE_DRAW; func_800BC490(play, 2); Message_StartTextbox(play, this->actor.textId, &this->actor); EnOssan_SetStateStartShopping(play, this, true); diff --git a/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c b/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c index c11feb327..3f109863c 100644 --- a/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c +++ b/soh/src/overlays/actors/ovl_En_Po_Field/z_en_po_field.c @@ -386,7 +386,7 @@ void EnPoField_CorrectYPos(EnPoField* this, PlayState* play) { f32 EnPoField_SetFleeSpeed(EnPoField* this, PlayState* play) { Player* player = GET_PLAYER(play); - f32 speed = ((player->stateFlags1 & 0x800000) && player->rideActor != NULL) ? player->rideActor->speedXZ : 12.0f; + f32 speed = ((player->stateFlags1 & PLAYER_STATE1_ON_HORSE) && player->rideActor != NULL) ? player->rideActor->speedXZ : 12.0f; if (this->actor.xzDistToPlayer < 300.0f) { this->actor.speedXZ = speed * 1.5f + 2.0f; @@ -414,13 +414,13 @@ void EnPoField_WaitForSpawn(EnPoField* this, PlayState* play) { if (fabsf(sEnPoFieldSpawnPositions[i].x - player->actor.world.pos.x) < 150.0f && fabsf(sEnPoFieldSpawnPositions[i].z - player->actor.world.pos.z) < 150.0f) { if (Flags_GetSwitch(play, sEnPoFieldSpawnSwitchFlags[i])) { - if (player->stateFlags1 & 0x800000) { // Player riding Epona + if (player->stateFlags1 & PLAYER_STATE1_ON_HORSE) { // Player riding Epona return; } else { this->actor.params = EN_PO_FIELD_SMALL; spawnDist = 300.0f; } - } else if (player->stateFlags1 & 0x800000 || Rand_ZeroOne() < 0.4f) { + } else if (player->stateFlags1 & PLAYER_STATE1_ON_HORSE || Rand_ZeroOne() < 0.4f) { this->actor.params = EN_PO_FIELD_BIG; this->spawnFlagIndex = i; spawnDist = 480.0f; diff --git a/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c b/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c index 6f36bea36..4514439c1 100644 --- a/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c +++ b/soh/src/overlays/actors/ovl_En_Rd/z_en_rd.c @@ -333,9 +333,12 @@ void func_80AE2C1C(EnRd* this, PlayState* play) { } if ((ABS(sp32) < 0x1554) && (Actor_WorldDistXYZToActor(&this->actor, &player->actor) <= 150.0f)) { - if (!(player->stateFlags1 & 0x2C6080) && !(player->stateFlags2 & 0x80)) { + if (!(player->stateFlags1 & + (PLAYER_STATE1_DEAD | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | + PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_CLIMBING_LADDER)) && + !(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { if (this->unk_306 == 0) { - if (!(this->unk_312 & 0x80) && !CVarGetInteger("gNoRedeadFreeze", 0)) { + if (!(this->unk_312 & PLAYER_STATE2_GRABBED_BY_ENEMY) && !CVarGetInteger("gNoRedeadFreeze", 0)) { player->actor.freezeTimer = 40; func_8008EEAC(play, &this->actor); GET_PLAYER(play)->unk_684 = &this->actor; @@ -405,7 +408,10 @@ void func_80AE2FD0(EnRd* this, PlayState* play) { this->actor.world.rot.y = this->actor.shape.rot.y; SkelAnime_Update(&this->skelAnime); - if (!(player->stateFlags1 & 0x2C6080) && !(player->stateFlags2 & 0x80) && + if (!(player->stateFlags1 & + (PLAYER_STATE1_DEAD | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | + PLAYER_STATE1_JUMPING | PLAYER_STATE1_FREEFALL | PLAYER_STATE1_CLIMBING_LADDER)) && + !(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && (Actor_WorldDistXYZToPoint(&player->actor, &this->actor.home.pos) < 150.0f)) { this->actor.targetMode = 0; func_80AE2B90(this, play); diff --git a/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c index a3265d724..f999f3486 100644 --- a/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/soh/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -499,7 +499,7 @@ void EnRr_CollisionCheck(EnRr* this, PlayState* play) { } } if ((this->ocTimer == 0) && (this->actor.colorFilterTimer == 0) && (player->invincibilityTimer == 0) && - !(player->stateFlags2 & 0x80) && + !(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY) && ((this->collider1.base.ocFlags1 & OC1_HIT) || (this->collider2.base.ocFlags1 & OC1_HIT))) { this->collider1.base.ocFlags1 &= ~OC1_HIT; this->collider2.base.ocFlags1 &= ~OC1_HIT; @@ -627,7 +627,7 @@ void EnRr_GrabPlayer(EnRr* this, PlayState* play) { Audio_PlayActorSound2(&this->actor, NA_SE_EN_LIKE_EAT); } this->ocTimer = 8; - if ((this->grabTimer == 0) || !(player->stateFlags2 & 0x80)) { + if ((this->grabTimer == 0) || !(player->stateFlags2 & PLAYER_STATE2_GRABBED_BY_ENEMY)) { EnRr_SetupReleasePlayer(this, play); } else { Math_ApproachF(&player->actor.world.pos.x, this->mouthPos.x, 1.0f, 30.0f); diff --git a/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index 97a3c0091..1ca46ddae 100644 --- a/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/soh/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -866,7 +866,8 @@ void func_80AEC780(EnRu1* this, PlayState* play) { s32 pad; Player* player = GET_PLAYER(play); - if ((func_80AEC5FC(this, play)) && (!Play_InCsMode(play)) && (!(player->stateFlags1 & 0x206000)) && + if ((func_80AEC5FC(this, play)) && (!Play_InCsMode(play)) && + (!(player->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | PLAYER_STATE1_CLIMBING_LADDER))) && (player->actor.bgCheckFlags & 1)) { play->csCtx.segment = &D_80AF0880; @@ -1652,7 +1653,7 @@ void func_80AEE7C4(EnRu1* this, PlayState* play) { } player = GET_PLAYER(play); - if (player->stateFlags2 & 0x10000000) { + if (player->stateFlags2 & PLAYER_STATE2_IDLING) { this->unk_370 += 1.0f; if (this->action != 32) { if (*unk_370 > 30.0f) { diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 49e88f903..943a2fbb0 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -16,6 +16,7 @@ void EnSi_Init(Actor* thisx, PlayState* play); void EnSi_Destroy(Actor* thisx, PlayState* play); void EnSi_Update(Actor* thisx, PlayState* play); void EnSi_Draw(Actor* thisx, PlayState* play); +void EnSi_Reset(); s32 func_80AFB748(EnSi* this, PlayState* play); void func_80AFB768(EnSi* this, PlayState* play); @@ -61,7 +62,7 @@ const ActorInit En_Si_InitVars = { (ActorFunc)EnSi_Destroy, (ActorFunc)EnSi_Update, (ActorFunc)EnSi_Draw, - NULL, + (ActorResetFunc)EnSi_Reset, }; void EnSi_Init(Actor* thisx, PlayState* play) { @@ -190,7 +191,7 @@ void func_80AFB950(EnSi* this, PlayState* play) { player->actor.freezeTimer = 0; func_8083C148(GET_PLAYER(play), play); func_80078884(NA_SE_SY_CAMERA_ZOOM_UP); - player->currentYaw = player->actor.shape.rot.y; + player->yaw = player->actor.shape.rot.y; } } } @@ -224,6 +225,11 @@ void EnSi_Draw(Actor* thisx, PlayState* play) { } } +void EnSi_Reset() { + textId = 0xB4; + giveItemId = ITEM_SKULL_TOKEN; +} + void Randomizer_UpdateSkullReward(EnSi* this, PlayState* play) { Player* player = GET_PLAYER(play); diff --git a/soh/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c b/soh/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c index 81138e23c..e577a3d45 100644 --- a/soh/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c +++ b/soh/src/overlays/actors/ovl_En_Siofuki/z_en_siofuki.c @@ -170,7 +170,7 @@ void func_80AFBE8C(EnSiofuki* this, PlayState* play) { } else { if (this->applySpeed) { player->linearVelocity = this->appliedSpeed + player->linearVelocity; - player->currentYaw = this->appliedYaw; + player->yaw = this->appliedYaw; } this->targetAppliedSpeed = 0.0f; diff --git a/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c b/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c index 207d9612b..67c695872 100644 --- a/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c +++ b/soh/src/overlays/actors/ovl_En_Skj/z_en_skj.c @@ -722,7 +722,7 @@ void EnSkj_SariasSongKidIdle(EnSkj* this, PlayState* play) { Player* player = GET_PLAYER(play); if (EnSkj_RangeCheck(player, sSmallStumpSkullKid.skullkid)) { EnSkj_SetupWaitInRange(this); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; player->unk_6A8 = &sSmallStumpSkullKid.skullkid->actor; } } @@ -906,8 +906,8 @@ void EnSkj_WaitInRange(EnSkj* this, PlayState* play) { // When link pulls out the Ocarina center him on the stump // Link was probably supposed to be pointed towards skull kid as well - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { + player->stateFlags2 |= PLAYER_STATE2_PLAY_FOR_ACTOR; player->unk_6A8 = &sSmallStumpSkullKid.skullkid->actor; player->actor.world.pos.x = sSmallStumpSkullKid.skullkid->actor.world.pos.x; player->actor.world.pos.y = sSmallStumpSkullKid.skullkid->actor.world.pos.y; @@ -928,7 +928,7 @@ void EnSkj_WaitInRange(EnSkj* this, PlayState* play) { } else if (!EnSkj_RangeCheck(player, sSmallStumpSkullKid.skullkid)) { EnSkj_SetupResetFight(this); } else { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; if (Flags_GetItemGetInf(ITEMGETINF_16)) { if (Flags_GetItemGetInf(ITEMGETINF_39)) { this->textId = Text_GetFaceReaction(play, 0x15); @@ -989,10 +989,10 @@ void EnSkj_WaitForSong(EnSkj* this, PlayState* play) { play->msgCtx.ocarinaMode = OCARINA_MODE_05; } } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_02) { - player->stateFlags2 &= ~0x1000000; + player->stateFlags2 &= ~PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR; Actor_Kill(&this->actor); } else if (play->msgCtx.ocarinaMode == OCARINA_MODE_01) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } else { if (play->msgCtx.ocarinaMode >= OCARINA_MODE_05) { gSaveContext.sunsSongState = 0; @@ -1214,7 +1214,7 @@ void EnSkj_SariasSongWaitForTextClear(EnSkj* this, PlayState* play) { if (state == TEXT_STATE_DONE && Message_ShouldAdvance(play)) { EnSkj_SetupWaitInRange(this); - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; player->unk_6A8 = (Actor*)sSmallStumpSkullKid.skullkid; } } @@ -1367,7 +1367,7 @@ void EnSkj_SariasSongShortStumpUpdate(Actor* thisx, PlayState* play) { void EnSkj_TurnPlayer(EnSkj* this, Player* player) { Math_SmoothStepToS(&player->actor.shape.rot.y, this->actor.world.rot.y, 5, 2000, 0); player->actor.world.rot.y = player->actor.shape.rot.y; - player->currentYaw = player->actor.shape.rot.y; + player->yaw = player->actor.shape.rot.y; } void EnSkj_SetupWaitForOcarina(EnSkj* this, PlayState* play) { @@ -1377,8 +1377,8 @@ void EnSkj_SetupWaitForOcarina(EnSkj* this, PlayState* play) { sOcarinaMinigameSkullKids[SKULL_KID_LEFT].skullkid->playerInRange = true; sOcarinaMinigameSkullKids[SKULL_KID_RIGHT].skullkid->playerInRange = true; - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { + player->stateFlags2 |= PLAYER_STATE2_PLAY_FOR_ACTOR; func_800F5BF0(NATURE_ID_KOKIRI_REGION); EnSkj_TurnPlayer(this, player); player->unk_6A8 = &this->actor; @@ -1393,15 +1393,15 @@ void EnSkj_SetupWaitForOcarina(EnSkj* this, PlayState* play) { void EnSkj_WaitForOcarina(EnSkj* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (player->stateFlags2 & 0x1000000) { - player->stateFlags2 |= 0x2000000; + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { + player->stateFlags2 |= PLAYER_STATE2_PLAY_FOR_ACTOR; func_800F5BF0(NATURE_ID_KOKIRI_REGION); EnSkj_TurnPlayer(this, player); player->unk_6A8 = &this->actor; Message_StartTextbox(play, 0x10BE, &this->actor); this->actionFunc = EnSkj_StartOcarinaMinigame; } else if (EnSkj_RangeCheck(player, this)) { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } @@ -1535,7 +1535,7 @@ void EnSkj_WaitForOfferResponse(EnSkj* this, PlayState* play) { switch (play->msgCtx.choiceIndex) { case 0: // yes player = GET_PLAYER(play); - player->stateFlags3 |= 0x20; // makes player take ocarina out right away after closing box + player->stateFlags3 |= PLAYER_STATE3_FORCE_PULL_OCARINA; // makes player take ocarina out right away after closing box this->actionFunc = EnSkj_SetupWaitForOcarina; break; case 1: // no diff --git a/soh/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/soh/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 9d061ee47..34db1a005 100644 --- a/soh/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/soh/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -103,7 +103,7 @@ void EnStream_SuckPlayer(EnStream* this, PlayState* play) { if (yDistWithOffset > 0.0f) { Math_SmoothStepToF(&player->actor.velocity.y, -3.0f, 0.7f, yDistWithOffset, 0.0f); if (posDifference.y < -70.0f) { - player->stateFlags2 |= 0x80000000; + player->stateFlags2 |= PLAYER_STATE2_FORCED_VOID_OUT; } } } else { diff --git a/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 0a6825c0e..f62f8b998 100644 --- a/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/soh/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -718,7 +718,7 @@ s32 func_80B0DEA8(EnSw* this, PlayState* play, s32 arg2) { s32 sp54; Vec3f sp48; - if (!(player->stateFlags1 & 0x200000) && arg2) { + if (!(player->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER) && arg2) { return false; } else if (func_8002DDF4(play) && arg2) { return false; diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c b/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c index 05b76cb0e..f0d9d3897 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c +++ b/soh/src/overlays/actors/ovl_En_Syateki_Itm/z_en_syateki_itm.c @@ -107,7 +107,7 @@ void EnSyatekiItm_Idle(EnSyatekiItm* this, PlayState* play) { player->actor.world.pos.x = -12.0f; player->actor.world.pos.y = 20.0f; player->actor.world.pos.z = 182.0f; - player->currentYaw = player->actor.world.rot.y = player->actor.shape.rot.y = 0x7F03; + player->yaw = player->actor.world.rot.y = player->actor.shape.rot.y = 0x7F03; player->actor.world.rot.x = player->actor.shape.rot.x = player->actor.world.rot.z = player->actor.shape.rot.z = 0; s32 ammunition = 15; diff --git a/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c b/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c index 0eb3e9095..267a26c90 100644 --- a/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c +++ b/soh/src/overlays/actors/ovl_En_Ta/z_en_ta.c @@ -579,7 +579,7 @@ s32 func_80B150AC(EnTa* this, PlayState* play, s32 idx) { Player* player = GET_PLAYER(play); Actor* interactRangeActor; - if (player->stateFlags1 & 0x800) { + if (player->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) { interactRangeActor = player->interactRangeActor; if (interactRangeActor != NULL && interactRangeActor->id == ACTOR_EN_NIW && interactRangeActor == &this->superCuccos[idx]->actor) { @@ -613,7 +613,7 @@ void func_80B15100(EnTa* this, PlayState* play) { if (player->heldActor == &this->superCuccos[unk_2CA]->actor) { player->heldActor = NULL; } - player->stateFlags1 &= ~0x800; + player->stateFlags1 &= ~PLAYER_STATE1_ITEM_OVER_HEAD; this->superCuccos[unk_2CA] = NULL; } this->unk_2E0 |= 1; diff --git a/soh/src/overlays/actors/ovl_En_Test/z_en_test.c b/soh/src/overlays/actors/ovl_En_Test/z_en_test.c index 46e9edc9e..1f4be6670 100644 --- a/soh/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/soh/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -407,7 +407,7 @@ void EnTest_ChooseAction(EnTest* this, PlayState* play) { } else { if (this->actor.xzDistToPlayer < 110.0f) { if (Rand_ZeroOne() > 0.2f) { - if (player->stateFlags1 & 0x10) { + if (player->stateFlags1 & PLAYER_STATE1_ENEMY_TARGET) { if (this->actor.isTargeted) { EnTest_SetupSlashDown(this); } else { @@ -693,7 +693,7 @@ void EnTest_WalkAndBlock(EnTest* this, PlayState* play) { if (this->actor.xzDistToPlayer < 110.0f) { if (Rand_ZeroOne() > 0.2f) { - if (player->stateFlags1 & 0x10) { + if (player->stateFlags1 & PLAYER_STATE1_ENEMY_TARGET) { if (this->actor.isTargeted) { EnTest_SetupSlashDown(this); } else { @@ -978,7 +978,7 @@ void EnTest_SlashDownEnd(EnTest* this, PlayState* play) { if ((ABS(yawDiff) > 0x3E80) && (this->actor.params != STALFOS_TYPE_CEILING)) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; EnTest_SetupJumpBack(this); - } else if (player->stateFlags1 & 0x10) { + } else if (player->stateFlags1 & PLAYER_STATE1_ENEMY_TARGET) { if (this->actor.isTargeted) { EnTest_SetupSlashDown(this); } else if ((play->gameplayFrames % 2) != 0) { diff --git a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index bfc99a5b8..f919bb39a 100644 --- a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -356,7 +356,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { } else if (sSwordJumpState != 0) { sStickTilt = 0.0f; - player->stateFlags3 |= 4; + player->stateFlags3 |= PLAYER_STATE3_PAUSE_ACTION_FUNC; Math_SmoothStepToF(&this->actor.world.pos.x, (Math_SinS(player->actor.shape.rot.y - 0x3E8) * 45.0f) + player->actor.world.pos.x, @@ -369,7 +369,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { if (((u32)sSwordJumpTimer == 0) || ((player->invincibilityTimer > 0) && (this->meleeWeaponState == 0))) { this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer; input->cur.button = BTN_A; - player->stateFlags3 &= ~4; + player->stateFlags3 &= ~PLAYER_STATE3_PAUSE_ACTION_FUNC; sStickTilt = 127.0f; player->skelAnime.curFrame = 3.0f; sStickAngle = this->actor.yawTowardsPlayer + 0x8000; @@ -404,7 +404,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { sStickTilt = 0.0f; sSwordJumpState = 1; - player->stateFlags3 |= 4; + player->stateFlags3 |= PLAYER_STATE3_PAUSE_ACTION_FUNC; this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; sSwordJumpTimer = 27; player->meleeWeaponState = 0; @@ -452,7 +452,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { sStickAngle = thisx->yawTowardsPlayer; sp50 = 0.0f; if ((90.0f >= this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 70.0f) && - (ABS(sp5A) >= 0x7800) && (this->actor.isTargeted || !(player->stateFlags1 & 0x00400000))) { + (ABS(sp5A) >= 0x7800) && (this->actor.isTargeted || !(player->stateFlags1 & PLAYER_STATE1_SHIELDING))) { EnTorch2_SwingSword(play, input, this); } else if (((this->actor.xzDistToPlayer <= 70.0f) || ((this->actor.xzDistToPlayer <= 80.0f + sp50) && (player->meleeWeaponState != 0))) && @@ -523,7 +523,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { this->meleeWeaponState = 0; input->cur.stick_x = input->cur.stick_y = 0; if ((this->invincibilityTimer > 0) && (this->actor.world.pos.y < (this->actor.floorHeight - 160.0f))) { - this->stateFlags3 &= ~1; + this->stateFlags3 &= ~PLAYER_STATE3_IGNORE_CEILING_FLOOR_WATER; this->actor.flags |= ACTOR_FLAG_TARGETABLE; this->invincibilityTimer = 0; this->actor.velocity.y = 0.0f; @@ -608,7 +608,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { sDeathFlag = false; } if ((this->invincibilityTimer == 0) && (this->actor.colChkInfo.health != 0) && - (this->cylinder.base.acFlags & AC_HIT) && !(this->stateFlags1 & 0x04000000) && + (this->cylinder.base.acFlags & AC_HIT) && !(this->stateFlags1 & PLAYER_STATE1_SHIELDING) && !(this->meleeWeaponQuads[0].base.atFlags & AT_HIT) && !(this->meleeWeaponQuads[1].base.atFlags & AT_HIT)) { if (!Actor_ApplyDamage(&this->actor)) { @@ -623,7 +623,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { sActionState = ENTORCH2_DEATH; Enemy_StartFinishingBlow(play, &this->actor); Item_DropCollectibleRandom(play, &this->actor, &thisx->world.pos, 0xC0); - this->stateFlags3 &= ~4; + this->stateFlags3 &= ~PLAYER_STATE3_PAUSE_ACTION_FUNC; } else { func_800F5ACC(NA_BGM_MINI_BOSS); if (this->actor.colChkInfo.damageEffect == 1) { @@ -640,8 +640,8 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { this->unk_8A4 = 8.0f; this->unk_8A2 = this->actor.yawTowardsPlayer + 0x8000; Actor_SetDropFlag(&this->actor, &this->cylinder.info, 1); - this->stateFlags3 &= ~4; - this->stateFlags3 |= 1; + this->stateFlags3 &= ~PLAYER_STATE3_PAUSE_ACTION_FUNC; + this->stateFlags3 |= PLAYER_STATE3_IGNORE_CEILING_FLOOR_WATER; sActionState = ENTORCH2_DAMAGE; if (sAlpha == 255) { Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, 0xC); @@ -657,10 +657,10 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { // Handles being frozen by a deku nut if ((this->actor.colorFilterTimer == 0) || (this->actor.colorFilterParams & 0x4000)) { - this->stateFlags3 &= ~4; + this->stateFlags3 &= ~PLAYER_STATE3_PAUSE_ACTION_FUNC; } else { - this->stateFlags3 |= 4; - this->stateFlags1 &= ~0x04000000; + this->stateFlags3 |= PLAYER_STATE3_PAUSE_ACTION_FUNC; + this->stateFlags1 &= ~PLAYER_STATE1_SHIELDING; this->invincibilityTimer = 0; input->press.stick_x = input->press.stick_y = 0; /*! @bug diff --git a/soh/src/overlays/actors/ovl_En_Tp/z_en_tp.c b/soh/src/overlays/actors/ovl_En_Tp/z_en_tp.c index 82c22529d..30ff3c37f 100644 --- a/soh/src/overlays/actors/ovl_En_Tp/z_en_tp.c +++ b/soh/src/overlays/actors/ovl_En_Tp/z_en_tp.c @@ -657,7 +657,7 @@ void EnTp_Update(Actor* thisx, PlayState* play) { Player* player = GET_PLAYER(play); s16 yawToWall; - if (player->stateFlags1 & 0x4000000) { // Shielding + if (player->stateFlags1 & PLAYER_STATE1_SHIELDING) { // Shielding this->damageEffect = TAILPASARAN_DMGEFF_NONE; } diff --git a/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c b/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c index 69c33f5f5..2f90ad1a0 100644 --- a/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c +++ b/soh/src/overlays/actors/ovl_En_Wallmas/z_en_wallmas.c @@ -313,11 +313,11 @@ void EnWallmas_WaitToDrop(EnWallmas* this, PlayState* play) { } if (this->actor.params == WMT_SHADOWTAG) { - if ((player->stateFlags1 & 0x100000) || (player->stateFlags1 & 0x8000000) || !(player->actor.bgCheckFlags & 1)) { + if ((player->stateFlags1 & PLAYER_STATE1_FIRST_PERSON) || (player->stateFlags1 & PLAYER_STATE1_IN_WATER) || !(player->actor.bgCheckFlags & 1)) { Audio_StopSfxById(NA_SE_EN_FALL_AIM); this->timer = 0x82; } - } else if ((player->stateFlags1 & 0x100000) || (player->stateFlags1 & 0x8000000) || !(player->actor.bgCheckFlags & 1) || + } else if ((player->stateFlags1 & PLAYER_STATE1_FIRST_PERSON) || (player->stateFlags1 & PLAYER_STATE1_IN_WATER) || !(player->actor.bgCheckFlags & 1) || ((this->actor.params == 1) && (320.0f < Math_Vec3f_DistXZ(&this->actor.home.pos, playerPos)))) { Audio_StopSfxById(NA_SE_EN_FALL_AIM); this->timer = 0x82; @@ -339,7 +339,7 @@ void EnWallmas_WaitToDrop(EnWallmas* this, PlayState* play) { void EnWallmas_Drop(EnWallmas* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (!Player_InCsMode(play) && !(player->stateFlags2 & 0x10) && (player->invincibilityTimer >= 0) && + if (!Player_InCsMode(play) && !(player->stateFlags2 & PLAYER_STATE2_MOVING_DYNAPOLY) && (player->invincibilityTimer >= 0) && (this->actor.xzDistToPlayer < 30.0f) && (this->actor.yDistToPlayer < -5.0f) && (-(f32)(player->cylinder.dim.height + 10) < this->actor.yDistToPlayer)) { EnWallmas_SetupTakePlayer(this, play); diff --git a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c index 83f799877..f0cdc2249 100644 --- a/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/soh/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -392,7 +392,7 @@ s32 EnXc_SerenadeCS(EnXc* this, PlayState* play) { if (((CHECK_OWNED_EQUIP(EQUIP_TYPE_BOOTS, EQUIP_INV_BOOTS_IRON) && !IS_RANDO) || (Flags_GetTreasure(play, 2) && IS_RANDO)) && - !Flags_GetEventChkInf(EVENTCHKINF_LEARNED_SERENADE_OF_WATER) && !(stateFlags & 0x20000000) && + !Flags_GetEventChkInf(EVENTCHKINF_LEARNED_SERENADE_OF_WATER) && !(stateFlags & PLAYER_STATE1_IN_CUTSCENE) && !Play_InCsMode(play)) { if (!IS_RANDO) { Cutscene_SetSegment(play, &gIceCavernSerenadeCs); diff --git a/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c b/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c index 9aa8204dd..98180605e 100644 --- a/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c +++ b/soh/src/overlays/actors/ovl_En_Zf/z_en_zf.c @@ -532,7 +532,7 @@ s32 EnZf_CanAttack(PlayState* play, EnZf* this) { Player* player = GET_PLAYER(play); if (this->actor.params >= ENZF_TYPE_LIZALFOS_MINIBOSS_A) { // miniboss - if (player->stateFlags1 & 0x6000) { // Hanging or climbing + if (player->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE)) { // Hanging or climbing return false; } else { return true; @@ -1208,7 +1208,7 @@ void EnZf_Slash(EnZf* this, PlayState* play) { if (yawDiff > 16000) { this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80B483E4(this, play); - } else if (player->stateFlags1 & 0x6010) { + } else if (player->stateFlags1 & (PLAYER_STATE1_ENEMY_TARGET | PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE)) { if (this->actor.isTargeted) { EnZf_SetupSlash(this); } else { diff --git a/soh/src/overlays/actors/ovl_En_Zo/z_en_zo.c b/soh/src/overlays/actors/ovl_En_Zo/z_en_zo.c index 561ebf81b..f5275618b 100644 --- a/soh/src/overlays/actors/ovl_En_Zo/z_en_zo.c +++ b/soh/src/overlays/actors/ovl_En_Zo/z_en_zo.c @@ -361,7 +361,7 @@ void EnZo_SpawnSplashes(EnZo* this) { } } -u16 func_80B61024(PlayState* play, Actor* thisx) { +u16 EnZo_GetTextId(PlayState* play, Actor* thisx) { u16 textId; textId = Text_GetFaceReaction(play, 29); @@ -427,7 +427,9 @@ u16 func_80B61024(PlayState* play, Actor* thisx) { return 0x402D; } - if (Flags_GetEventChkInf(EVENTCHKINF_KING_ZORA_MOVED)) { + if (Flags_GetEventChkInf(EVENTCHKINF_KING_ZORA_MOVED) || + (CVarGetInteger("gFixZoraHintDialogue", 0) && + Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_RUTOS_LETTER))) { return 0x4010; } if (Flags_GetEventChkInf(EVENTCHKINF_SPOKE_TO_A_ZORA)) { @@ -520,7 +522,7 @@ void EnZo_Dialog(EnZo* this, PlayState* play) { } Npc_TrackPoint(&this->actor, &this->interactInfo, 11, this->trackingMode); if (this->canSpeak == true) { - Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->dialogRadius, func_80B61024, + Npc_UpdateTalking(play, &this->actor, &this->interactInfo.talkState, this->dialogRadius, EnZo_GetTextId, func_80B61298); } } diff --git a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c index 727a20730..9a31ceb50 100644 --- a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -2233,7 +2233,7 @@ void Fishing_UpdateLure(Fishing* this, PlayState* play) { Math_ApproachF(&D_80B7E144, 195.0f, 1.0f, 1.0f); - if (player->stateFlags1 & 0x8000000) { + if (player->stateFlags1 & PLAYER_STATE1_IN_WATER) { D_80B7E0B4 = 0; player->unk_860 = 0; } diff --git a/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 27b4c17cd..09ce9dff6 100644 --- a/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/soh/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -486,11 +486,11 @@ void ObjOshihiki_OnScene(ObjOshihiki* this, PlayState* play) { this->direction = this->dyna.unk_150; ObjOshihiki_SetupPush(this, play); } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } @@ -527,11 +527,11 @@ void ObjOshihiki_OnActor(ObjOshihiki* this, PlayState* play) { this->direction = this->dyna.unk_150; ObjOshihiki_SetupPush(this, play); } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } else { - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; } } else { @@ -579,7 +579,7 @@ void ObjOshihiki_Push(ObjOshihiki* this, PlayState* play) { if (!ObjOshihiki_CheckFloor(this, play)) { thisx->home.pos.x = thisx->world.pos.x; thisx->home.pos.z = thisx->world.pos.z; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; this->pushDist = 0.0f; this->pushSpeed = 0.0f; @@ -592,7 +592,7 @@ void ObjOshihiki_Push(ObjOshihiki* this, PlayState* play) { thisx->home.pos.x = thisx->world.pos.x; thisx->home.pos.z = thisx->world.pos.z; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; this->dyna.unk_150 = 0.0f; this->pushDist = 0.0f; this->pushSpeed = 0.0f; @@ -620,7 +620,7 @@ void ObjOshihiki_Fall(ObjOshihiki* this, PlayState* play) { this->stateFlags |= PUSHBLOCK_FALL; if (fabsf(this->dyna.unk_150) > 0.001f) { this->dyna.unk_150 = 0.0f; - player->stateFlags2 &= ~0x10; + player->stateFlags2 &= ~PLAYER_STATE2_MOVING_DYNAPOLY; } Actor_MoveForward(&this->dyna.actor); if (ObjOshihiki_CheckGround(this, play)) { diff --git a/soh/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c b/soh/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c index ed210ce0b..b0c7b44fc 100644 --- a/soh/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c +++ b/soh/src/overlays/actors/ovl_Obj_Timeblock/z_obj_timeblock.c @@ -171,11 +171,11 @@ s32 ObjTimeblock_WaitForOcarina(ObjTimeblock* this, PlayState* play) { Player* player = GET_PLAYER(play); if (ObjTimeblock_PlayerIsInRange(this, play)) { - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { func_8010BD58(play, OCARINA_ACTION_FREE_PLAY); this->songObserverFunc = ObjTimeblock_WaitForSong; } else { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } return false; diff --git a/soh/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c b/soh/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c index 73e592e3e..b67660963 100644 --- a/soh/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c +++ b/soh/src/overlays/actors/ovl_Obj_Warp2block/z_obj_warp2block.c @@ -159,11 +159,11 @@ s32 func_80BA2218(ObjWarp2block* this, PlayState* play) { Player* player = GET_PLAYER(play); if (func_80BA1ECC(this, play)) { - if (player->stateFlags2 & 0x1000000) { + if (player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR) { func_8010BD58(play, OCARINA_ACTION_FREE_PLAY); this->func_168 = func_80BA228C; } else { - player->stateFlags2 |= 0x800000; + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; } } diff --git a/soh/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c b/soh/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c index 0c280171f..a0552a027 100644 --- a/soh/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c +++ b/soh/src/overlays/actors/ovl_Shot_Sun/z_shot_sun.c @@ -128,8 +128,8 @@ void func_80BADF0C(ShotSun* this, PlayState* play) { this->unk_1A4 = 0; } else { if (this->unk_1A4 == 0) { - if (!(player->stateFlags2 & 0x1000000)) { - player->stateFlags2 |= 0x800000; + if (!(player->stateFlags2 & PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR)) { + player->stateFlags2 |= PLAYER_STATE2_NEAR_OCARINA_ACTOR; return; } else { this->unk_1A4 = 1; diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index fb5faab39..d1c224088 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -65,9 +65,9 @@ typedef struct { typedef struct { /* 0x00 */ s8 damage; - /* 0x01 */ u8 unk_01; - /* 0x02 */ u8 unk_02; - /* 0x03 */ u8 unk_03; + /* 0x01 */ u8 rumbleStrength; + /* 0x02 */ u8 rumbleDuration; + /* 0x03 */ u8 rumbleDecreaseRate; /* 0x04 */ u16 sfxId; } FallImpactInfo; // size = 0x06 @@ -76,9 +76,28 @@ typedef struct { /* 0x0C */ s16 yaw; } SpecialRespawnInfo; // size = 0x10 +typedef enum { + /* 1 */ ANIMSFX_TYPE_1 = 1, + /* 2 */ ANIMSFX_TYPE_2, + /* 3 */ ANIMSFX_TYPE_3, + /* 4 */ ANIMSFX_TYPE_4, + /* 5 */ ANIMSFX_TYPE_5, + /* 6 */ ANIMSFX_TYPE_6, + /* 7 */ ANIMSFX_TYPE_7, + /* 8 */ ANIMSFX_TYPE_8, + /* 9 */ ANIMSFX_TYPE_9 +} AnimSfxType; + +#define ANIMSFX_SHIFT_TYPE(type) ((type) << 11) + +#define ANIMSFX_DATA(type, frame) ((ANIMSFX_SHIFT_TYPE(type) | ((frame)&0x7FF))) + +#define ANIMSFX_GET_TYPE(data) ((data)&0x7800) +#define ANIMSFX_GET_FRAME(data) ((data)&0x7FF) + typedef struct { /* 0x00 */ u16 sfxId; - /* 0x02 */ s16 field; + /* 0x02 */ s16 data; } AnimSfxEntry; // size = 0x04 typedef struct { @@ -120,24 +139,26 @@ typedef struct { }; } struct_80854B18; // size = 0x08 -void func_80833770(PlayState* play, Player* this); -void func_80833790(PlayState* play, Player* this); -void func_8083379C(PlayState* play, Player* this); -void func_8083377C(PlayState* play, Player* this); -void func_808337D4(PlayState* play, Player* this); -void func_80833910(PlayState* play, Player* this); -void func_80833984(PlayState* play, Player* this); void Player_InitItemAction(PlayState* play, Player* this, s8 itemAction); -s32 func_8083485C(Player* this, PlayState* play); -s32 func_808349DC(Player* this, PlayState* play); + +void Player_InitDefaultIA(PlayState* play, Player* this); +void Player_InitHammerIA(PlayState* play, Player* this); +void Player_InitBowOrSlingshotIA(PlayState* play, Player* this); +void Player_InitDekuStickIA(PlayState* play, Player* this); +void Player_InitExplosiveIA(PlayState* play, Player* this); +void Player_InitHookshotIA(PlayState* play, Player* this); +void Player_InitBoomerangIA(PlayState* play, Player* this); + s32 Player_UpperAction_ChangeHeldItem(Player* this, PlayState* play); +s32 func_8083485C(Player* this, PlayState* play); +s32 Player_UpperAction_Sword(Player* this, PlayState* play); s32 func_80834B5C(Player* this, PlayState* play); s32 func_80834C74(Player* this, PlayState* play); s32 func_8083501C(Player* this, PlayState* play); s32 func_808351D4(Player* this, PlayState* play); // Arrow nocked s32 func_808353D8(Player* this, PlayState* play); // Aiming in first person s32 func_80835588(Player* this, PlayState* play); -s32 func_808356E8(Player* this, PlayState* play); +s32 Player_UpperAction_CarryActor(Player* this, PlayState* play); s32 func_80835800(Player* this, PlayState* play); s32 func_80835884(Player* this, PlayState* play); // Start aiming boomerang s32 func_808358F0(Player* this, PlayState* play); // Aim boomerang @@ -145,65 +166,14 @@ s32 func_808359FC(Player* this, PlayState* play); // Throw boomerang s32 spawn_boomerang_ivan(EnPartner* this, PlayState* play); // Throw boomerang Ivan s32 func_80835B60(Player* this, PlayState* play); // Boomerang active s32 func_80835C08(Player* this, PlayState* play); + void Player_UseItem(PlayState* play, Player* this, s32 item); void func_80839F90(Player* this, PlayState* play); -s32 func_80838A14(Player* this, PlayState* play); -s32 func_80839800(Player* this, PlayState* play); -s32 func_8083B040(Player* this, PlayState* play); -s32 func_8083B998(Player* this, PlayState* play); -s32 func_8083B644(Player* this, PlayState* play); -s32 func_8083BDBC(Player* this, PlayState* play); -s32 func_8083C1DC(Player* this, PlayState* play); -s32 func_8083C2B0(Player* this, PlayState* play); -s32 func_8083C544(Player* this, PlayState* play); s32 func_8083C61C(PlayState* play, Player* this); void func_8083CA20(PlayState* play, Player* this); void func_8083CA54(PlayState* play, Player* this); void func_8083CA9C(PlayState* play, Player* this); -s32 func_8083E0FC(Player* this, PlayState* play); void Player_SetPendingFlag(Player* this, PlayState* play); -s32 func_8083E5A8(Player* this, PlayState* play); -s32 func_8083EB44(Player* this, PlayState* play); -s32 func_8083F7BC(Player* this, PlayState* play); -void func_80840450(Player* this, PlayState* play); -void func_808407CC(Player* this, PlayState* play); -void func_80840BC8(Player* this, PlayState* play); -void func_80840DE4(Player* this, PlayState* play); -void func_808414F8(Player* this, PlayState* play); -void func_8084170C(Player* this, PlayState* play); -void func_808417FC(Player* this, PlayState* play); -void func_8084193C(Player* this, PlayState* play); -void func_80841BA8(Player* this, PlayState* play); -void func_80842180(Player* this, PlayState* play); -void func_8084227C(Player* this, PlayState* play); -void func_8084279C(Player* this, PlayState* play); -void func_808423EC(Player* this, PlayState* play); -void func_8084251C(Player* this, PlayState* play); -void func_80843188(Player* this, PlayState* play); -void func_808435C4(Player* this, PlayState* play); -void func_8084370C(Player* this, PlayState* play); -void func_8084377C(Player* this, PlayState* play); -void func_80843954(Player* this, PlayState* play); -void func_80843A38(Player* this, PlayState* play); -void func_80843CEC(Player* this, PlayState* play); -void func_8084411C(Player* this, PlayState* play); -void func_80844708(Player* this, PlayState* play); -void func_80844A44(Player* this, PlayState* play); -void func_80844AF4(Player* this, PlayState* play); -void func_80844E68(Player* this, PlayState* play); -void func_80845000(Player* this, PlayState* play); -void func_80845308(Player* this, PlayState* play); -void func_80845668(Player* this, PlayState* play); -void func_808458D0(Player* this, PlayState* play); -void func_80845CA4(Player* this, PlayState* play); -void func_80845EF8(Player* this, PlayState* play); -void func_80846050(Player* this, PlayState* play); -void func_80846120(Player* this, PlayState* play); -void func_80846260(Player* this, PlayState* play); -void func_80846358(Player* this, PlayState* play); -void func_80846408(Player* this, PlayState* play); -void func_808464B0(Player* this, PlayState* play); -void func_80846578(Player* this, PlayState* play); void func_80846648(PlayState* play, Player* this); void func_80846660(PlayState* play, Player* this); void func_808467D4(PlayState* play, Player* this); @@ -212,59 +182,10 @@ void func_808468E8(PlayState* play, Player* this); void func_80846978(PlayState* play, Player* this); void func_808469BC(PlayState* play, Player* this); void func_80846A68(PlayState* play, Player* this); -void func_8084B1D8(Player* this, PlayState* play); -void func_8084B530(Player* this, PlayState* play); -void func_8084B78C(Player* this, PlayState* play); -void func_8084B898(Player* this, PlayState* play); -void func_8084B9E4(Player* this, PlayState* play); -void func_8084BBE4(Player* this, PlayState* play); -void func_8084BDFC(Player* this, PlayState* play); -void func_8084BF1C(Player* this, PlayState* play); void Player_UpdateCommon(Player* this, PlayState* play, Input* input); -void func_8084C5F8(Player* this, PlayState* play); -void func_8084C760(Player* this, PlayState* play); -void func_8084C81C(Player* this, PlayState* play); -void func_8084CC98(Player* this, PlayState* play); -void func_8084D3E4(Player* this, PlayState* play); -void func_8084D610(Player* this, PlayState* play); -void func_8084D7C4(Player* this, PlayState* play); -void func_8084D84C(Player* this, PlayState* play); -void func_8084DAB4(Player* this, PlayState* play); -void func_8084DC48(Player* this, PlayState* play); -void func_8084E1EC(Player* this, PlayState* play); -void func_8084E30C(Player* this, PlayState* play); -void func_8084E368(Player* this, PlayState* play); -void func_8084E3C4(Player* this, PlayState* play); -void func_8084E604(Player* this, PlayState* play); -void func_8084E6D4(Player* this, PlayState* play); -void func_8084E9AC(Player* this, PlayState* play); -void func_8084EAC0(Player* this, PlayState* play); -void func_8084ECA4(Player* this, PlayState* play); -void func_8084EED8(Player* this, PlayState* play); -void func_8084EFC0(Player* this, PlayState* play); -void func_8084F104(Player* this, PlayState* play); -void func_8084F390(Player* this, PlayState* play); -void func_8084F608(Player* this, PlayState* play); -void func_8084F698(Player* this, PlayState* play); -void func_8084F710(Player* this, PlayState* play); -void func_8084F88C(Player* this, PlayState* play); -void func_8084F9A0(Player* this, PlayState* play); -void func_8084F9C0(Player* this, PlayState* play); -void func_8084FA54(Player* this, PlayState* play); -void func_8084FB10(Player* this, PlayState* play); -void func_8084FBF4(Player* this, PlayState* play); s32 func_8084FCAC(Player* this, PlayState* play); void func_8084FF7C(Player* this); void Player_UpdateBunnyEars(Player* this); -s32 func_80850224(Player* this, PlayState* play); -void func_808502D0(Player* this, PlayState* play); -void func_808505DC(Player* this, PlayState* play); -void func_8085063C(Player* this, PlayState* play); -void func_8085076C(Player* this, PlayState* play); -void func_808507F4(Player* this, PlayState* play); -void func_80850AEC(Player* this, PlayState* play); -void func_80850C68(Player* this, PlayState* play); -void func_80850E84(Player* this, PlayState* play); void func_80851008(PlayState* play, Player* this, void* anim); void func_80851030(PlayState* play, Player* this, void* anim); void func_80851050(PlayState* play, Player* this, void* anim); @@ -339,8 +260,7 @@ void func_808528C8(PlayState* play, Player* this, CsCmdActorAction* arg2); void func_80852944(PlayState* play, Player* this, CsCmdActorAction* arg2); void func_808529D0(PlayState* play, Player* this, CsCmdActorAction* arg2); void func_80852C50(PlayState* play, Player* this, CsCmdActorAction* arg2); -void func_80852E14(Player* this, PlayState* play); -s32 Player_IsDroppingFish(PlayState* play); +int Player_IsDroppingFish(PlayState* play); s32 Player_StartFishing(PlayState* play); s32 func_80852F38(PlayState* play, Player* this); s32 Player_TryCsAction(PlayState* play, Actor* actor, s32 csAction); @@ -349,6 +269,95 @@ s32 Player_InflictDamage(PlayState* play, s32 damage); s32 Player_InflictDamageModified(PlayState* play, s32 damage, u8 modified); void Player_StartTalking(PlayState* play, Actor* actor); +void Player_Action_80840450(Player* this, PlayState* play); +void Player_Action_808407CC(Player* this, PlayState* play); +void Player_Action_80840BC8(Player* this, PlayState* play); +void Player_Action_80840DE4(Player* this, PlayState* play); +void Player_Action_808414F8(Player* this, PlayState* play); +void Player_Action_8084170C(Player* this, PlayState* play); +void Player_Action_808417FC(Player* this, PlayState* play); +void Player_Action_8084193C(Player* this, PlayState* play); +void Player_Action_80841BA8(Player* this, PlayState* play); +void Player_Action_80842180(Player* this, PlayState* play); +void Player_Action_8084227C(Player* this, PlayState* play); +void Player_Action_8084279C(Player* this, PlayState* play); +void Player_Action_808423EC(Player* this, PlayState* play); +void Player_Action_8084251C(Player* this, PlayState* play); +void Player_Action_80843188(Player* this, PlayState* play); +void Player_Action_808435C4(Player* this, PlayState* play); +void Player_Action_8084370C(Player* this, PlayState* play); +void Player_Action_8084377C(Player* this, PlayState* play); +void Player_Action_80843954(Player* this, PlayState* play); +void Player_Action_80843A38(Player* this, PlayState* play); +void Player_Action_80843CEC(Player* this, PlayState* play); +void Player_Action_8084411C(Player* this, PlayState* play); +void Player_Action_80844708(Player* this, PlayState* play); +void Player_Action_80844A44(Player* this, PlayState* play); +void Player_Action_80844AF4(Player* this, PlayState* play); +void Player_Action_80844E68(Player* this, PlayState* play); +void Player_Action_80845000(Player* this, PlayState* play); +void Player_Action_80845308(Player* this, PlayState* play); +void Player_Action_80845668(Player* this, PlayState* play); +void Player_Action_808458D0(Player* this, PlayState* play); +void Player_Action_80845CA4(Player* this, PlayState* play); +void Player_Action_80845EF8(Player* this, PlayState* play); +void Player_Action_80846050(Player* this, PlayState* play); +void Player_Action_80846120(Player* this, PlayState* play); +void Player_Action_80846260(Player* this, PlayState* play); +void Player_Action_80846358(Player* this, PlayState* play); +void Player_Action_80846408(Player* this, PlayState* play); +void Player_Action_808464B0(Player* this, PlayState* play); +void Player_Action_80846578(Player* this, PlayState* play); +void Player_Action_8084B1D8(Player* this, PlayState* play); +void Player_Action_8084B530(Player* this, PlayState* play); +void Player_Action_8084B78C(Player* this, PlayState* play); +void Player_Action_8084B898(Player* this, PlayState* play); +void Player_Action_8084B9E4(Player* this, PlayState* play); +void Player_Action_8084BBE4(Player* this, PlayState* play); +void Player_Action_8084BDFC(Player* this, PlayState* play); +void Player_Action_8084BF1C(Player* this, PlayState* play); +void Player_Action_8084C5F8(Player* this, PlayState* play); +void Player_Action_8084C760(Player* this, PlayState* play); +void Player_Action_8084C81C(Player* this, PlayState* play); +void Player_Action_8084CC98(Player* this, PlayState* play); +void Player_Action_8084D3E4(Player* this, PlayState* play); +void Player_Action_8084D610(Player* this, PlayState* play); +void Player_Action_8084D7C4(Player* this, PlayState* play); +void Player_Action_8084D84C(Player* this, PlayState* play); +void Player_Action_8084DAB4(Player* this, PlayState* play); +void Player_Action_8084DC48(Player* this, PlayState* play); +void Player_Action_8084E1EC(Player* this, PlayState* play); +void Player_Action_8084E30C(Player* this, PlayState* play); +void Player_Action_8084E368(Player* this, PlayState* play); +void Player_Action_8084E3C4(Player* this, PlayState* play); +void Player_Action_8084E604(Player* this, PlayState* play); +void Player_Action_8084E6D4(Player* this, PlayState* play); +void Player_Action_8084E9AC(Player* this, PlayState* play); +void Player_Action_8084EAC0(Player* this, PlayState* play); +void Player_Action_8084ECA4(Player* this, PlayState* play); +void Player_Action_8084EED8(Player* this, PlayState* play); +void Player_Action_8084EFC0(Player* this, PlayState* play); +void Player_Action_8084F104(Player* this, PlayState* play); +void Player_Action_8084F390(Player* this, PlayState* play); +void Player_Action_8084F608(Player* this, PlayState* play); +void Player_Action_8084F698(Player* this, PlayState* play); +void Player_Action_8084F710(Player* this, PlayState* play); +void Player_Action_8084F88C(Player* this, PlayState* play); +void Player_Action_8084F9A0(Player* this, PlayState* play); +void Player_Action_8084F9C0(Player* this, PlayState* play); +void Player_Action_8084FA54(Player* this, PlayState* play); +void Player_Action_8084FB10(Player* this, PlayState* play); +void Player_Action_8084FBF4(Player* this, PlayState* play); +void Player_Action_808502D0(Player* this, PlayState* play); +void Player_Action_808505DC(Player* this, PlayState* play); +void Player_Action_8085063C(Player* this, PlayState* play); +void Player_Action_8085076C(Player* this, PlayState* play); +void Player_Action_808507F4(Player* this, PlayState* play); +void Player_Action_80850AEC(Player* this, PlayState* play); +void Player_Action_80850C68(Player* this, PlayState* play); +void Player_Action_80850E84(Player* this, PlayState* play); +void Player_Action_CsAction(Player* this, PlayState* play); + // .bss part 1 static s32 D_80858AA0; static s32 D_80858AA4; @@ -384,108 +393,108 @@ static u8 sUpperBodyLimbCopyMap[PLAYER_LIMB_MAX] = { static PlayerAgeProperties sAgeProperties[] = { { - 56.0f, - 90.0f, - 1.0f, - 111.0f, - 70.0f, - 79.4f, - 59.0f, - 41.0f, - 19.0f, - 36.0f, - 44.8f, - 56.0f, - 68.0f, - 70.0f, - 18.0f, - 15.0f, - 70.0f, - { 9, 4671, 359 }, + 56.0f, // ceilingCheckHeight + 90.0f, // unk_04 + 1.0f, // unk_08 + 111.0f, // unk_0C + 70.0f, // unk_10 + 79.4f, // unk_14 + 59.0f, // unk_18 + 41.0f, // unk_1C + 19.0f, // unk_20 + 36.0f, // unk_24 + 44.8f, // unk_28 + 56.0f, // unk_2C + 68.0f, // unk_30 + 70.0f, // unk_34 + 18.0f, // wallCheckRadius + 15.0f, // unk_3C + 70.0f, // unk_40 + { 9, 4671, 359 }, // unk_44 { { 8, 4694, 380 }, { 9, 6122, 359 }, { 8, 4694, 380 }, { 9, 6122, 359 }, - }, + }, // unk_4A { { 9, 6122, 359 }, { 9, 7693, 380 }, { 9, 6122, 359 }, { 9, 7693, 380 }, - }, + }, // unk_62 { { 8, 4694, 380 }, { 9, 6122, 359 }, - }, + }, // unk_7A { { -1592, 4694, 380 }, { -1591, 6122, 359 }, - }, - 0, - 0x80, - &gPlayerAnim_link_demo_Tbox_open, - &gPlayerAnim_link_demo_back_to_past, - &gPlayerAnim_link_demo_return_to_past, - &gPlayerAnim_link_normal_climb_startA, - &gPlayerAnim_link_normal_climb_startB, + }, // unk_86 + 0, // unk_92 + 0x80, // unk_94 + &gPlayerAnim_link_demo_Tbox_open, // unk_98 + &gPlayerAnim_link_demo_back_to_past, // unk_9C + &gPlayerAnim_link_demo_return_to_past, // unk_A0 + &gPlayerAnim_link_normal_climb_startA, // unk_A4 + &gPlayerAnim_link_normal_climb_startB, // unk_A8 { &gPlayerAnim_link_normal_climb_upL, &gPlayerAnim_link_normal_climb_upR, &gPlayerAnim_link_normal_Fclimb_upL, - &gPlayerAnim_link_normal_Fclimb_upR }, - { &gPlayerAnim_link_normal_Fclimb_sideL, &gPlayerAnim_link_normal_Fclimb_sideR }, - { &gPlayerAnim_link_normal_climb_endAL, &gPlayerAnim_link_normal_climb_endAR }, - { &gPlayerAnim_link_normal_climb_endBR, &gPlayerAnim_link_normal_climb_endBL }, + &gPlayerAnim_link_normal_Fclimb_upR }, // unk_AC + { &gPlayerAnim_link_normal_Fclimb_sideL, &gPlayerAnim_link_normal_Fclimb_sideR }, // unk_BC + { &gPlayerAnim_link_normal_climb_endAL, &gPlayerAnim_link_normal_climb_endAR }, // unk_C4 + { &gPlayerAnim_link_normal_climb_endBR, &gPlayerAnim_link_normal_climb_endBL }, // unk_CC }, { - 40.0f, - 60.0f, - 11.0f / 17.0f, - 71.0f, - 50.0f, - 47.0f, - 39.0f, - 27.0f, - 19.0f, - 22.0f, - 29.6f, - 32.0f, - 48.0f, - 70.0f * (11.0f / 17.0f), - 14.0f, - 12.0f, - 55.0f, - { -24, 3565, 876 }, + 40.0f, // ceilingCheckHeight + 60.0f, // unk_04 + 11.0f / 17.0f, // unk_08 + 71.0f, // unk_0C + 50.0f, // unk_10 + 47.0f, // unk_14 + 39.0f, // unk_18 + 27.0f, // unk_1C + 19.0f, // unk_20 + 22.0f, // unk_24 + 29.6f, // unk_28 + 32.0f, // unk_2C + 48.0f, // unk_30 + 70.0f * (11.0f / 17.0f), // unk_34 + 14.0f, // wallCheckRadius + 12.0f, // unk_3C + 55.0f, // unk_40 + { -24, 3565, 876 }, // unk_44 { { -24, 3474, 862 }, { -24, 4977, 937 }, { 8, 4694, 380 }, { 9, 6122, 359 }, - }, + }, // unk_4A { { -24, 4977, 937 }, { -24, 6495, 937 }, { 9, 6122, 359 }, { 9, 7693, 380 }, - }, + }, // unk_62 { { 8, 4694, 380 }, { 9, 6122, 359 }, - }, + }, // unk_7A { { -1592, 4694, 380 }, { -1591, 6122, 359 }, - }, - 0x20, - 0, - &gPlayerAnim_clink_demo_Tbox_open, - &gPlayerAnim_clink_demo_goto_future, - &gPlayerAnim_clink_demo_return_to_future, - &gPlayerAnim_clink_normal_climb_startA, - &gPlayerAnim_clink_normal_climb_startB, + }, // unk_86 + 0x20, // unk_92 + 0, // unk_94 + &gPlayerAnim_clink_demo_Tbox_open, // unk_98 + &gPlayerAnim_clink_demo_goto_future, // unk_9C + &gPlayerAnim_clink_demo_return_to_future, // unk_A0 + &gPlayerAnim_clink_normal_climb_startA, // unk_A4 + &gPlayerAnim_clink_normal_climb_startB, // unk_A8 { &gPlayerAnim_clink_normal_climb_upL, &gPlayerAnim_clink_normal_climb_upR, &gPlayerAnim_link_normal_Fclimb_upL, - &gPlayerAnim_link_normal_Fclimb_upR }, - { &gPlayerAnim_link_normal_Fclimb_sideL, &gPlayerAnim_link_normal_Fclimb_sideR }, - { &gPlayerAnim_clink_normal_climb_endAL, &gPlayerAnim_clink_normal_climb_endAR }, - { &gPlayerAnim_clink_normal_climb_endBR, &gPlayerAnim_clink_normal_climb_endBL }, + &gPlayerAnim_link_normal_Fclimb_upR }, // unk_AC + { &gPlayerAnim_link_normal_Fclimb_sideL, &gPlayerAnim_link_normal_Fclimb_sideR }, // unk_BC + { &gPlayerAnim_clink_normal_climb_endAL, &gPlayerAnim_clink_normal_climb_endAR }, // unk_C4 + { &gPlayerAnim_clink_normal_climb_endBR, &gPlayerAnim_clink_normal_climb_endBL }, // unk_CC }, }; @@ -499,7 +508,7 @@ static f32 D_808535E8 = 1.0f; static f32 D_808535EC = 1.0f; static u32 sTouchedWallFlags = 0; static u32 sConveyorSpeed = 0; -static s16 sIsFloorConveyor = 0; +static s16 sIsFloorConveyor = false; static s16 sConveyorYaw = 0; static f32 sYDistToFloor = 0.0f; static s32 sPrevFloorProperty = 0; @@ -955,50 +964,53 @@ static LinkAnimationHeader* D_80853D7C[][2] = { }; static AnimSfxEntry D_80853DEC[] = { - { NA_SE_VO_LI_SNEEZE, -0x2008 }, + { NA_SE_VO_LI_SNEEZE, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 8) }, }; static AnimSfxEntry D_80853DF0[] = { - { NA_SE_VO_LI_SWEAT, -0x2012 }, + { NA_SE_VO_LI_SWEAT, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 18) }, }; static AnimSfxEntry D_80853DF4[] = { - { NA_SE_VO_LI_BREATH_REST, -0x200D }, + { NA_SE_VO_LI_BREATH_REST, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 13) }, }; static AnimSfxEntry D_80853DF8[] = { - { NA_SE_VO_LI_BREATH_REST, -0x200A }, + { NA_SE_VO_LI_BREATH_REST, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 10) }, }; static AnimSfxEntry D_80853DFC[] = { - { NA_SE_PL_CALM_HIT, 0x82C }, { NA_SE_PL_CALM_HIT, 0x830 }, { NA_SE_PL_CALM_HIT, 0x834 }, - { NA_SE_PL_CALM_HIT, 0x838 }, { NA_SE_PL_CALM_HIT, -0x83C }, + { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 44) }, { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 48) }, + { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 52) }, { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 56) }, + { NA_SE_PL_CALM_HIT, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 60) }, }; static AnimSfxEntry D_80853E10[] = { - { 0, 0x4019 }, { 0, 0x401E }, { 0, 0x402C }, { 0, 0x4030 }, { 0, 0x4034 }, { 0, -0x4038 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 25) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 30) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 44) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 48) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 52) }, { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_8, 56) }, }; static AnimSfxEntry D_80853E28[] = { - { NA_SE_IT_SHIELD_POSTURE, 0x810 }, - { NA_SE_IT_SHIELD_POSTURE, 0x814 }, - { NA_SE_IT_SHIELD_POSTURE, -0x846 }, + { NA_SE_IT_SHIELD_POSTURE, ANIMSFX_DATA(ANIMSFX_TYPE_1, 16) }, + { NA_SE_IT_SHIELD_POSTURE, ANIMSFX_DATA(ANIMSFX_TYPE_1, 20) }, + { NA_SE_IT_SHIELD_POSTURE, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 70) }, }; static AnimSfxEntry D_80853E34[] = { - { NA_SE_IT_HAMMER_SWING, 0x80A }, - { NA_SE_VO_LI_AUTO_JUMP, 0x200A }, - { NA_SE_IT_SWORD_SWING, 0x816 }, - { NA_SE_VO_LI_SWORD_N, -0x2016 }, + { NA_SE_IT_HAMMER_SWING, ANIMSFX_DATA(ANIMSFX_TYPE_1, 10) }, + { NA_SE_VO_LI_AUTO_JUMP, ANIMSFX_DATA(ANIMSFX_TYPE_4, 10) }, + { NA_SE_IT_SWORD_SWING, ANIMSFX_DATA(ANIMSFX_TYPE_1, 22) }, + { NA_SE_VO_LI_SWORD_N, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 22) }, }; static AnimSfxEntry D_80853E44[] = { - { NA_SE_IT_SWORD_SWING, 0x827 }, - { NA_SE_VO_LI_SWORD_N, -0x2027 }, + { NA_SE_IT_SWORD_SWING, ANIMSFX_DATA(ANIMSFX_TYPE_1, 39) }, + { NA_SE_VO_LI_SWORD_N, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 39) }, }; static AnimSfxEntry D_80853E4C[] = { - { NA_SE_VO_LI_RELAX, -0x2014 }, + { NA_SE_VO_LI_RELAX, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 20) }, }; static AnimSfxEntry* D_80853E50[] = { @@ -1081,143 +1093,143 @@ u8 gWalkSpeedToggle1; u8 gWalkSpeedToggle2; static s32 (*sItemActionUpdateFuncs[])(Player* this, PlayState* play) = { - func_8083485C, // PLAYER_IA_NONE - func_8083485C, // PLAYER_IA_SWORD_CS - func_8083485C, // PLAYER_IA_FISHING_POLE - func_808349DC, // PLAYER_IA_SWORD_MASTER - func_808349DC, // PLAYER_IA_SWORD_KOKIRI - func_808349DC, // PLAYER_IA_SWORD_BIGGORON - func_8083485C, // PLAYER_IA_DEKU_STICK - func_8083485C, // PLAYER_IA_HAMMER - func_8083501C, // PLAYER_IA_BOW - func_8083501C, // PLAYER_IA_BOW_FIRE - func_8083501C, // PLAYER_IA_BOW_ICE - func_8083501C, // PLAYER_IA_BOW_LIGHT - func_8083501C, // PLAYER_IA_BOW_0C - func_8083501C, // PLAYER_IA_BOW_0D - func_8083501C, // PLAYER_IA_BOW_0E - func_8083501C, // PLAYER_IA_SLINGSHOT - func_8083501C, // PLAYER_IA_HOOKSHOT - func_8083501C, // PLAYER_IA_LONGSHOT - func_808356E8, // PLAYER_IA_BOMB - func_808356E8, // PLAYER_IA_BOMBCHU - func_80835800, // PLAYER_IA_BOOMERANG - func_8083485C, // PLAYER_IA_MAGIC_SPELL_15 - func_8083485C, // PLAYER_IA_MAGIC_SPELL_16 - func_8083485C, // PLAYER_IA_MAGIC_SPELL_17 - func_8083485C, // PLAYER_IA_FARORES_WIND - func_8083485C, // PLAYER_IA_NAYRUS_LOVE - func_8083485C, // PLAYER_IA_DINS_FIRE - func_8083485C, // PLAYER_IA_DEKU_NUT - func_8083485C, // PLAYER_IA_OCARINA_FAIRY - func_8083485C, // PLAYER_IA_OCARINA_OF_TIME - func_8083485C, // PLAYER_IA_BOTTLE - func_8083485C, // PLAYER_IA_BOTTLE_FISH - func_8083485C, // PLAYER_IA_BOTTLE_FIRE - func_8083485C, // PLAYER_IA_BOTTLE_BUG - func_8083485C, // PLAYER_IA_BOTTLE_POE - func_8083485C, // PLAYER_IA_BOTTLE_BIG_POE - func_8083485C, // PLAYER_IA_BOTTLE_RUTOS_LETTER - func_8083485C, // PLAYER_IA_BOTTLE_POTION_RED - func_8083485C, // PLAYER_IA_BOTTLE_POTION_BLUE - func_8083485C, // PLAYER_IA_BOTTLE_POTION_GREEN - func_8083485C, // PLAYER_IA_BOTTLE_MILK_FULL - func_8083485C, // PLAYER_IA_BOTTLE_MILK_HALF - func_8083485C, // PLAYER_IA_BOTTLE_FAIRY - func_8083485C, // PLAYER_IA_ZELDAS_LETTER - func_8083485C, // PLAYER_IA_WEIRD_EGG - func_8083485C, // PLAYER_IA_CHICKEN - func_8083485C, // PLAYER_IA_MAGIC_BEAN - func_8083485C, // PLAYER_IA_POCKET_EGG - func_8083485C, // PLAYER_IA_POCKET_CUCCO - func_8083485C, // PLAYER_IA_COJIRO - func_8083485C, // PLAYER_IA_ODD_MUSHROOM - func_8083485C, // PLAYER_IA_ODD_POTION - func_8083485C, // PLAYER_IA_POACHERS_SAW - func_8083485C, // PLAYER_IA_BROKEN_GORONS_SWORD - func_8083485C, // PLAYER_IA_PRESCRIPTION - func_8083485C, // PLAYER_IA_FROG - func_8083485C, // PLAYER_IA_EYEDROPS - func_8083485C, // PLAYER_IA_CLAIM_CHECK - func_8083485C, // PLAYER_IA_MASK_KEATON - func_8083485C, // PLAYER_IA_MASK_SKULL - func_8083485C, // PLAYER_IA_MASK_SPOOKY - func_8083485C, // PLAYER_IA_MASK_BUNNY_HOOD - func_8083485C, // PLAYER_IA_MASK_GORON - func_8083485C, // PLAYER_IA_MASK_ZORA - func_8083485C, // PLAYER_IA_MASK_GERUDO - func_8083485C, // PLAYER_IA_MASK_TRUTH - func_8083485C, // PLAYER_IA_LENS_OF_TRUTH + func_8083485C, // PLAYER_IA_NONE + func_8083485C, // PLAYER_IA_SWORD_CS + func_8083485C, // PLAYER_IA_FISHING_POLE + Player_UpperAction_Sword, // PLAYER_IA_SWORD_MASTER + Player_UpperAction_Sword, // PLAYER_IA_SWORD_KOKIRI + Player_UpperAction_Sword, // PLAYER_IA_SWORD_BIGGORON + func_8083485C, // PLAYER_IA_DEKU_STICK + func_8083485C, // PLAYER_IA_HAMMER + func_8083501C, // PLAYER_IA_BOW + func_8083501C, // PLAYER_IA_BOW_FIRE + func_8083501C, // PLAYER_IA_BOW_ICE + func_8083501C, // PLAYER_IA_BOW_LIGHT + func_8083501C, // PLAYER_IA_BOW_0C + func_8083501C, // PLAYER_IA_BOW_0D + func_8083501C, // PLAYER_IA_BOW_0E + func_8083501C, // PLAYER_IA_SLINGSHOT + func_8083501C, // PLAYER_IA_HOOKSHOT + func_8083501C, // PLAYER_IA_LONGSHOT + Player_UpperAction_CarryActor, // PLAYER_IA_BOMB + Player_UpperAction_CarryActor, // PLAYER_IA_BOMBCHU + func_80835800, // PLAYER_IA_BOOMERANG + func_8083485C, // PLAYER_IA_MAGIC_SPELL_15 + func_8083485C, // PLAYER_IA_MAGIC_SPELL_16 + func_8083485C, // PLAYER_IA_MAGIC_SPELL_17 + func_8083485C, // PLAYER_IA_FARORES_WIND + func_8083485C, // PLAYER_IA_NAYRUS_LOVE + func_8083485C, // PLAYER_IA_DINS_FIRE + func_8083485C, // PLAYER_IA_DEKU_NUT + func_8083485C, // PLAYER_IA_OCARINA_FAIRY + func_8083485C, // PLAYER_IA_OCARINA_OF_TIME + func_8083485C, // PLAYER_IA_BOTTLE + func_8083485C, // PLAYER_IA_BOTTLE_FISH + func_8083485C, // PLAYER_IA_BOTTLE_FIRE + func_8083485C, // PLAYER_IA_BOTTLE_BUG + func_8083485C, // PLAYER_IA_BOTTLE_POE + func_8083485C, // PLAYER_IA_BOTTLE_BIG_POE + func_8083485C, // PLAYER_IA_BOTTLE_RUTOS_LETTER + func_8083485C, // PLAYER_IA_BOTTLE_POTION_RED + func_8083485C, // PLAYER_IA_BOTTLE_POTION_BLUE + func_8083485C, // PLAYER_IA_BOTTLE_POTION_GREEN + func_8083485C, // PLAYER_IA_BOTTLE_MILK_FULL + func_8083485C, // PLAYER_IA_BOTTLE_MILK_HALF + func_8083485C, // PLAYER_IA_BOTTLE_FAIRY + func_8083485C, // PLAYER_IA_ZELDAS_LETTER + func_8083485C, // PLAYER_IA_WEIRD_EGG + func_8083485C, // PLAYER_IA_CHICKEN + func_8083485C, // PLAYER_IA_MAGIC_BEAN + func_8083485C, // PLAYER_IA_POCKET_EGG + func_8083485C, // PLAYER_IA_POCKET_CUCCO + func_8083485C, // PLAYER_IA_COJIRO + func_8083485C, // PLAYER_IA_ODD_MUSHROOM + func_8083485C, // PLAYER_IA_ODD_POTION + func_8083485C, // PLAYER_IA_POACHERS_SAW + func_8083485C, // PLAYER_IA_BROKEN_GORONS_SWORD + func_8083485C, // PLAYER_IA_PRESCRIPTION + func_8083485C, // PLAYER_IA_FROG + func_8083485C, // PLAYER_IA_EYEDROPS + func_8083485C, // PLAYER_IA_CLAIM_CHECK + func_8083485C, // PLAYER_IA_MASK_KEATON + func_8083485C, // PLAYER_IA_MASK_SKULL + func_8083485C, // PLAYER_IA_MASK_SPOOKY + func_8083485C, // PLAYER_IA_MASK_BUNNY_HOOD + func_8083485C, // PLAYER_IA_MASK_GORON + func_8083485C, // PLAYER_IA_MASK_ZORA + func_8083485C, // PLAYER_IA_MASK_GERUDO + func_8083485C, // PLAYER_IA_MASK_TRUTH + func_8083485C, // PLAYER_IA_LENS_OF_TRUTH }; static void (*sItemActionInitFuncs[])(PlayState* play, Player* this) = { - func_80833770, // PLAYER_IA_NONE - func_80833770, // PLAYER_IA_SWORD_CS - func_80833770, // PLAYER_IA_FISHING_POLE - func_80833770, // PLAYER_IA_SWORD_MASTER - func_80833770, // PLAYER_IA_SWORD_KOKIRI - func_80833770, // PLAYER_IA_SWORD_BIGGORON - func_8083377C, // PLAYER_IA_DEKU_STICK - func_80833790, // PLAYER_IA_HAMMER - func_8083379C, // PLAYER_IA_BOW - func_8083379C, // PLAYER_IA_BOW_FIRE - func_8083379C, // PLAYER_IA_BOW_ICE - func_8083379C, // PLAYER_IA_BOW_LIGHT - func_8083379C, // PLAYER_IA_BOW_0C - func_8083379C, // PLAYER_IA_BOW_0D - func_8083379C, // PLAYER_IA_BOW_0E - func_8083379C, // PLAYER_IA_SLINGSHOT - func_80833910, // PLAYER_IA_HOOKSHOT - func_80833910, // PLAYER_IA_LONGSHOT - func_808337D4, // PLAYER_IA_BOMB - func_808337D4, // PLAYER_IA_BOMBCHU - func_80833984, // PLAYER_IA_BOOMERANG - func_80833770, // PLAYER_IA_MAGIC_SPELL_15 - func_80833770, // PLAYER_IA_MAGIC_SPELL_16 - func_80833770, // PLAYER_IA_MAGIC_SPELL_17 - func_80833770, // PLAYER_IA_FARORES_WIND - func_80833770, // PLAYER_IA_NAYRUS_LOVE - func_80833770, // PLAYER_IA_DINS_FIRE - func_80833770, // PLAYER_IA_DEKU_NUT - func_80833770, // PLAYER_IA_OCARINA_FAIRY - func_80833770, // PLAYER_IA_OCARINA_OF_TIME - func_80833770, // PLAYER_IA_BOTTLE - func_80833770, // PLAYER_IA_BOTTLE_FISH - func_80833770, // PLAYER_IA_BOTTLE_FIRE - func_80833770, // PLAYER_IA_BOTTLE_BUG - func_80833770, // PLAYER_IA_BOTTLE_POE - func_80833770, // PLAYER_IA_BOTTLE_BIG_POE - func_80833770, // PLAYER_IA_BOTTLE_RUTOS_LETTER - func_80833770, // PLAYER_IA_BOTTLE_POTION_RED - func_80833770, // PLAYER_IA_BOTTLE_POTION_BLUE - func_80833770, // PLAYER_IA_BOTTLE_POTION_GREEN - func_80833770, // PLAYER_IA_BOTTLE_MILK_FULL - func_80833770, // PLAYER_IA_BOTTLE_MILK_HALF - func_80833770, // PLAYER_IA_BOTTLE_FAIRY - func_80833770, // PLAYER_IA_ZELDAS_LETTER - func_80833770, // PLAYER_IA_WEIRD_EGG - func_80833770, // PLAYER_IA_CHICKEN - func_80833770, // PLAYER_IA_MAGIC_BEAN - func_80833770, // PLAYER_IA_POCKET_EGG - func_80833770, // PLAYER_IA_POCKET_CUCCO - func_80833770, // PLAYER_IA_COJIRO - func_80833770, // PLAYER_IA_ODD_MUSHROOM - func_80833770, // PLAYER_IA_ODD_POTION - func_80833770, // PLAYER_IA_POACHERS_SAW - func_80833770, // PLAYER_IA_BROKEN_GORONS_SWORD - func_80833770, // PLAYER_IA_PRESCRIPTION - func_80833770, // PLAYER_IA_FROG - func_80833770, // PLAYER_IA_EYEDROPS - func_80833770, // PLAYER_IA_CLAIM_CHECK - func_80833770, // PLAYER_IA_MASK_KEATON - func_80833770, // PLAYER_IA_MASK_SKULL - func_80833770, // PLAYER_IA_MASK_SPOOKY - func_80833770, // PLAYER_IA_MASK_BUNNY_HOOD - func_80833770, // PLAYER_IA_MASK_GORON - func_80833770, // PLAYER_IA_MASK_ZORA - func_80833770, // PLAYER_IA_MASK_GERUDO - func_80833770, // PLAYER_IA_MASK_TRUTH - func_80833770, // PLAYER_IA_LENS_OF_TRUTH + Player_InitDefaultIA, // PLAYER_IA_NONE + Player_InitDefaultIA, // PLAYER_IA_SWORD_CS + Player_InitDefaultIA, // PLAYER_IA_FISHING_POLE + Player_InitDefaultIA, // PLAYER_IA_SWORD_MASTER + Player_InitDefaultIA, // PLAYER_IA_SWORD_KOKIRI + Player_InitDefaultIA, // PLAYER_IA_SWORD_BIGGORON + Player_InitDekuStickIA, // PLAYER_IA_DEKU_STICK + Player_InitHammerIA, // PLAYER_IA_HAMMER + Player_InitBowOrSlingshotIA, // PLAYER_IA_BOW + Player_InitBowOrSlingshotIA, // PLAYER_IA_BOW_FIRE + Player_InitBowOrSlingshotIA, // PLAYER_IA_BOW_ICE + Player_InitBowOrSlingshotIA, // PLAYER_IA_BOW_LIGHT + Player_InitBowOrSlingshotIA, // PLAYER_IA_BOW_0C + Player_InitBowOrSlingshotIA, // PLAYER_IA_BOW_0D + Player_InitBowOrSlingshotIA, // PLAYER_IA_BOW_0E + Player_InitBowOrSlingshotIA, // PLAYER_IA_SLINGSHOT + Player_InitHookshotIA, // PLAYER_IA_HOOKSHOT + Player_InitHookshotIA, // PLAYER_IA_LONGSHOT + Player_InitExplosiveIA, // PLAYER_IA_BOMB + Player_InitExplosiveIA, // PLAYER_IA_BOMBCHU + Player_InitBoomerangIA, // PLAYER_IA_BOOMERANG + Player_InitDefaultIA, // PLAYER_IA_MAGIC_SPELL_15 + Player_InitDefaultIA, // PLAYER_IA_MAGIC_SPELL_16 + Player_InitDefaultIA, // PLAYER_IA_MAGIC_SPELL_17 + Player_InitDefaultIA, // PLAYER_IA_FARORES_WIND + Player_InitDefaultIA, // PLAYER_IA_NAYRUS_LOVE + Player_InitDefaultIA, // PLAYER_IA_DINS_FIRE + Player_InitDefaultIA, // PLAYER_IA_DEKU_NUT + Player_InitDefaultIA, // PLAYER_IA_OCARINA_FAIRY + Player_InitDefaultIA, // PLAYER_IA_OCARINA_OF_TIME + Player_InitDefaultIA, // PLAYER_IA_BOTTLE + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_FISH + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_FIRE + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_BUG + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_POE + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_BIG_POE + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_RUTOS_LETTER + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_POTION_RED + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_POTION_BLUE + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_POTION_GREEN + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_MILK_FULL + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_MILK_HALF + Player_InitDefaultIA, // PLAYER_IA_BOTTLE_FAIRY + Player_InitDefaultIA, // PLAYER_IA_ZELDAS_LETTER + Player_InitDefaultIA, // PLAYER_IA_WEIRD_EGG + Player_InitDefaultIA, // PLAYER_IA_CHICKEN + Player_InitDefaultIA, // PLAYER_IA_MAGIC_BEAN + Player_InitDefaultIA, // PLAYER_IA_POCKET_EGG + Player_InitDefaultIA, // PLAYER_IA_POCKET_CUCCO + Player_InitDefaultIA, // PLAYER_IA_COJIRO + Player_InitDefaultIA, // PLAYER_IA_ODD_MUSHROOM + Player_InitDefaultIA, // PLAYER_IA_ODD_POTION + Player_InitDefaultIA, // PLAYER_IA_POACHERS_SAW + Player_InitDefaultIA, // PLAYER_IA_BROKEN_GORONS_SWORD + Player_InitDefaultIA, // PLAYER_IA_PRESCRIPTION + Player_InitDefaultIA, // PLAYER_IA_FROG + Player_InitDefaultIA, // PLAYER_IA_EYEDROPS + Player_InitDefaultIA, // PLAYER_IA_CLAIM_CHECK + Player_InitDefaultIA, // PLAYER_IA_MASK_KEATON + Player_InitDefaultIA, // PLAYER_IA_MASK_SKULL + Player_InitDefaultIA, // PLAYER_IA_MASK_SPOOKY + Player_InitDefaultIA, // PLAYER_IA_MASK_BUNNY_HOOD + Player_InitDefaultIA, // PLAYER_IA_MASK_GORON + Player_InitDefaultIA, // PLAYER_IA_MASK_ZORA + Player_InitDefaultIA, // PLAYER_IA_MASK_GERUDO + Player_InitDefaultIA, // PLAYER_IA_MASK_TRUTH + Player_InitDefaultIA, // PLAYER_IA_LENS_OF_TRUTH }; typedef enum { @@ -1555,15 +1567,15 @@ void func_80832564(PlayState* play, Player* this) { } s32 func_80832594(Player* this, s32 arg1, s32 arg2) { - s16 controlStickAngleDiff = this->unk_A80 - sControlStickAngle; + s16 controlStickAngleDiff = this->prevControlStickAngle - sControlStickAngle; - this->unk_850 += arg1 + (s16)(ABS(controlStickAngleDiff) * fabsf(sControlStickMagnitude) * 2.5415802156203426e-06f); + this->av2.actionVar2 += arg1 + (s16)(ABS(controlStickAngleDiff) * fabsf(sControlStickMagnitude) * 2.5415802156203426e-06f); if (CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B)) { - this->unk_850 += 5; + this->av2.actionVar2 += 5; } - return this->unk_850 > arg2; + return this->av2.actionVar2 > arg2; } void func_80832630(PlayState* play) { @@ -1676,31 +1688,33 @@ void Player_ProcessAnimSfxList(Player* this, AnimSfxEntry* entry) { s32 pad; do { - s32 absData = ABS(entry->field); - s32 type = absData & 0x7800; - if (LinkAnimation_OnFrame(&this->skelAnime, fabsf(absData & 0x7FF))) { - if (type == 0x800) { + s32 absData = ABS(entry->data); + s32 type = ANIMSFX_GET_TYPE(absData); + + if (LinkAnimation_OnFrame(&this->skelAnime, fabsf(ANIMSFX_GET_FRAME(absData)))) { + if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_1)) { Player_PlaySfx(this, entry->sfxId); - } else if (type == 0x1000) { + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_2)) { func_80832770(this, entry->sfxId); - } else if (type == 0x1800) { + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_3)) { func_808327C4(this, entry->sfxId); - } else if (type == 0x2000) { + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_4)) { func_80832698(this, entry->sfxId); - } else if (type == 0x2800) { + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_5)) { func_808328A0(this); - } else if (type == 0x3000) { + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_6)) { func_808327F8(this, 6.0f); - } else if (type == 0x3800) { + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_7)) { func_80832854(this); - } else if (type == 0x4000) { + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_8)) { func_808327F8(this, 0.0f); - } else if (type == 0x4800) { - func_800F4010(&this->actor.projectedPos, this->ageProperties->unk_94 + NA_SE_PL_WALK_LADDER, 0.0f); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_9)) { + func_800F4010(&this->actor.projectedPos, + NA_SE_PL_WALK_LADDER + this->ageProperties->unk_94, 0.0f); } } - cont = (entry->field >= 0); // stop processing if `data` is negative + cont = (entry->data >= 0); // stop processing if `data` is negative entry++; } while (cont); } @@ -1812,7 +1826,8 @@ void Player_AnimReplaceApplyFlags(PlayState* play, Player* this, s32 flags) { AnimationContext_DisableQueue(play); } -void Player_AnimReplacePlayOnceSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { +void Player_AnimReplacePlayOnceSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, + f32 playbackSpeed) { LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, playbackSpeed); Player_AnimReplaceApplyFlags(play, this, flags); } @@ -1829,7 +1844,8 @@ void Player_AnimReplaceNormalPlayOnceAdjusted(PlayState* play, Player* this, Lin Player_AnimReplacePlayOnceAdjusted(play, this, anim, 0x1C); } -void Player_AnimReplacePlayLoopSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, f32 playbackSpeed) { +void Player_AnimReplacePlayLoopSetSpeed(PlayState* play, Player* this, LinkAnimationHeader* anim, s32 flags, + f32 playbackSpeed) { LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, playbackSpeed); Player_AnimReplaceApplyFlags(play, this, flags); } @@ -1850,8 +1866,8 @@ void Player_ProcessControlStick(PlayState* play, Player* this) { s8 phi_v1; s8 phi_v0; - this->unk_A7C = sControlStickMagnitude; - this->unk_A80 = sControlStickAngle; + this->prevControlStickMagnitude = sControlStickMagnitude; + this->prevControlStickAngle = sControlStickAngle; func_80077D10(&sControlStickMagnitude, &sControlStickAngle, sControlInput); @@ -1875,7 +1891,7 @@ void func_8083328C(PlayState* play, Player* this, LinkAnimationHeader* linkAnim) LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, linkAnim, D_808535E8); } -s32 func_808332B8(Player* this) { +int func_808332B8(Player* this) { return (this->stateFlags1 & PLAYER_STATE1_IN_WATER) && (this->currentBoots != PLAYER_BOOTS_IRON); } @@ -1931,7 +1947,7 @@ LinkAnimationHeader* func_80833438(Player* this) { } } -s32 func_808334B4(Player* this) { +int func_808334B4(Player* this) { return func_808332E4(this) && (this->unk_834 != 0); } @@ -1975,8 +1991,8 @@ LinkAnimationHeader* func_808335F4(Player* this) { } } -void Player_SetUpperActionFunc(Player* this, UpperActionFunc arg1) { - this->upperActionFunc = arg1; +void Player_SetUpperActionFunc(Player* this, UpperActionFunc upperActionFunc) { + this->upperActionFunc = upperActionFunc; this->unk_836 = 0; this->upperAnimBlendWeight = 0.0f; func_808326F0(this); @@ -2019,17 +2035,17 @@ s8 Player_ItemToItemAction(s32 item) { } } -void func_80833770(PlayState* play, Player* this) { +void Player_InitDefaultIA(PlayState* play, Player* this) { } -void func_8083377C(PlayState* play, Player* this) { +void Player_InitDekuStickIA(PlayState* play, Player* this) { this->unk_85C = 1.0f; } -void func_80833790(PlayState* play, Player* this) { +void Player_InitHammerIA(PlayState* play, Player* this) { } -void func_8083379C(PlayState* play, Player* this) { +void Player_InitBowOrSlingshotIA(PlayState* play, Player* this) { this->stateFlags1 |= PLAYER_STATE1_ITEM_IN_HAND; if (this->heldItemAction != PLAYER_IA_SLINGSHOT) { @@ -2039,7 +2055,7 @@ void func_8083379C(PlayState* play, Player* this) { } } -void func_808337D4(PlayState* play, Player* this) { +void Player_InitExplosiveIA(PlayState* play, Player* this) { s32 explosiveType; ExplosiveInfo* explosiveInfo; Actor* spawnedActor; @@ -2052,9 +2068,9 @@ void func_808337D4(PlayState* play, Player* this) { explosiveType = Player_GetExplosiveHeld(this); explosiveInfo = &sExplosiveInfos[explosiveType]; - spawnedActor = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, explosiveInfo->actorId, - this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, - this->actor.shape.rot.y, 0, 0); + spawnedActor = + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, explosiveInfo->actorId, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); if (spawnedActor != NULL) { if ((explosiveType != 0) && (play->bombchuBowlingStatus != 0)) { if (!CVarGetInteger("gInfiniteAmmo", 0)) { @@ -2076,7 +2092,7 @@ void func_808337D4(PlayState* play, Player* this) { } } -void func_80833910(PlayState* play, Player* this) { +void Player_InitHookshotIA(PlayState* play, Player* this) { this->stateFlags1 |= PLAYER_STATE1_ITEM_IN_HAND; this->unk_860 = -3; @@ -2085,7 +2101,7 @@ void func_80833910(PlayState* play, Player* this) { this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); } -void func_80833984(PlayState* play, Player* this) { +void Player_InitBoomerangIA(PlayState* play, Player* this) { this->stateFlags1 |= PLAYER_STATE1_BOOMERANG_IN_HAND; } @@ -2109,7 +2125,8 @@ void func_80833A20(Player* this, s32 newMeleeWeaponState) { u16 voiceSfx; if (this->meleeWeaponState == 0) { - if ((this->heldItemAction == PLAYER_IA_SWORD_BIGGORON) && (gSaveContext.swordHealth > 0.0f)) { + if ((this->heldItemAction == PLAYER_IA_SWORD_BIGGORON) && + (gSaveContext.swordHealth > 0.0f)) { itemSfx = NA_SE_IT_HAMMER_SWING; } else { itemSfx = NA_SE_IT_SWORD_SWING; @@ -2160,18 +2177,18 @@ s32 func_80833B54(Player* this) { if (this->stateFlags1 & PLAYER_STATE1_ENEMY_TARGET) { this->stateFlags1 &= ~PLAYER_STATE1_ENEMY_TARGET; if (this->linearVelocity == 0.0f) { - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } } return 0; } -s32 func_80833BCC(Player* this) { +int func_80833BCC(Player* this) { return func_8008E9C4(this) || func_80833B2C(this); } -s32 func_80833C04(Player* this) { +int func_80833C04(Player* this) { return func_80833B54(this) || func_80833B2C(this); } @@ -2251,13 +2268,15 @@ void Player_ProcessItemButtons(Player* this, PlayState* play) { } } else { maskItemAction = this->currentMask - 1 + PLAYER_IA_MASK_KEATON; + bool hasOnDpad = false; if (CVarGetInteger("gDpadEquips", 0) != 0) { for (int buttonIndex = 0; buttonIndex < 4; buttonIndex++) { hasOnDpad |= Player_ItemIsItemAction(DPAD_ITEM(buttonIndex), maskItemAction); } } - if (!Player_ItemIsItemAction(C_BTN_ITEM(0), maskItemAction) && !Player_ItemIsItemAction(C_BTN_ITEM(1), maskItemAction) && + if (!Player_ItemIsItemAction(C_BTN_ITEM(0), maskItemAction) && + !Player_ItemIsItemAction(C_BTN_ITEM(1), maskItemAction) && !Player_ItemIsItemAction(C_BTN_ITEM(2), maskItemAction) && !hasOnDpad) { this->currentMask = PLAYER_MASK_NONE; } @@ -2544,7 +2563,11 @@ s32 func_8083499C(Player* this, PlayState* play) { return 1; } -s32 func_808349DC(Player* this, PlayState* play) { +/** + * The actual sword weapon is not handled here. See `Player_ActionChange_7` for melee weapon usage. + * This upper body action allows for shielding or changing held items while a sword is in hand. + */ +s32 Player_UpperAction_Sword(Player* this, PlayState* play) { if (func_80834758(play, this) || func_8083499C(this, play)) { return 1; } else { @@ -2555,8 +2578,8 @@ s32 func_808349DC(Player* this, PlayState* play) { s32 Player_UpperAction_ChangeHeldItem(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->upperSkelAnime) || ((Player_ItemToItemAction(this->heldItemId) == this->heldItemAction) && - (sUseHeldItem = (sUseHeldItem || - ((this->modelAnimType != PLAYER_ANIMTYPE_3) && (play->shootingGalleryStatus == 0)))))) { + (sUseHeldItem = + (sUseHeldItem || ((this->modelAnimType != PLAYER_ANIMTYPE_3) && (play->shootingGalleryStatus == 0)))))) { Player_SetUpperActionFunc(this, sItemActionUpdateFuncs[this->heldItemAction]); this->unk_834 = 0; this->unk_6AC = 0; @@ -2609,7 +2632,8 @@ s32 func_80834C74(Player* this, PlayState* play) { if (sUseHeldItem || LinkAnimation_Update(play, &this->upperSkelAnime)) { Player_SetUpperActionFunc(this, sItemActionUpdateFuncs[this->heldItemAction]); - LinkAnimation_PlayLoop(play, &this->upperSkelAnime, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType)); + LinkAnimation_PlayLoop(play, &this->upperSkelAnime, + GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType)); this->unk_6AC = 0; this->upperActionFunc(this, play); return 0; @@ -2647,22 +2671,24 @@ s32 func_80834D2C(Player* this, PlayState* play) { return 1; } -s32 func_80834E44(PlayState* play) { +int func_80834E44(PlayState* play) { return (play->shootingGalleryStatus > 0) && CHECK_BTN_ALL(sControlInput->press.button, BTN_B); } -s32 func_80834E7C(PlayState* play) { +int func_80834E7C(PlayState* play) { u16 buttonsToCheck = BTN_A | BTN_B | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; if (CVarGetInteger("gDpadEquips", 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } return (play->shootingGalleryStatus != 0) && - ((play->shootingGalleryStatus < 0) || CHECK_BTN_ANY(sControlInput->cur.button, buttonsToCheck)); + ((play->shootingGalleryStatus < 0) || + CHECK_BTN_ANY(sControlInput->cur.button, buttonsToCheck)); } s32 func_80834EB8(Player* this, PlayState* play) { if ((this->unk_6AD == 0) || (this->unk_6AD == 2)) { - if (func_80833BCC(this) || (Camera_CheckValidMode(Play_GetCamera(play, 0), 7) == 0)) { + if (func_80833BCC(this) || + (Camera_CheckValidMode(Play_GetCamera(play, 0), 7) == 0)) { return 1; } this->unk_6AD = 2; @@ -2859,10 +2885,10 @@ void func_808355DC(Player* this) { this->stateFlags1 |= PLAYER_STATE1_TARGET_NOTHING; if (!(this->skelAnime.moveFlags & 0x80) && (this->actor.bgCheckFlags & 0x200) && (sShapeYawToTouchedWall < 0x2000)) { - this->currentYaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; + this->yaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; } - this->targetYaw = this->actor.shape.rot.y; + this->zTargetYaw = this->actor.shape.rot.y; } s32 func_80835644(PlayState* play, Player* this, Actor* arg2) { @@ -2877,12 +2903,12 @@ s32 func_80835644(PlayState* play, Player* this, Actor* arg2) { void func_80835688(Player* this, PlayState* play) { if (!func_80835644(play, this, this->heldActor)) { - Player_SetUpperActionFunc(this, func_808356E8); + Player_SetUpperActionFunc(this, Player_UpperAction_CarryActor); LinkAnimation_PlayLoop(play, &this->upperSkelAnime, &gPlayerAnim_link_normal_carryB_wait); } } -s32 func_808356E8(Player* this, PlayState* play) { +s32 Player_UpperAction_CarryActor(Player* this, PlayState* play) { Actor* heldActor = this->heldActor; if (heldActor == NULL) { @@ -2974,8 +3000,8 @@ s32 func_808359FC(Player* this, PlayState* play) { f32 posZ = (Math_CosS(this->actor.shape.rot.y) * 10.0f) + this->actor.world.pos.z; s32 yaw = (this->unk_664 != NULL) ? this->actor.shape.rot.y + 14000 : this->actor.shape.rot.y; EnBoom* boomerang = - (EnBoom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOOM, posX, this->actor.world.pos.y + 30.0f, - posZ, this->actor.focus.rot.x, yaw, 0, 0, true); + (EnBoom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOOM, posX, this->actor.world.pos.y + 30.0f, posZ, + this->actor.focus.rot.x, yaw, 0, 0, true); this->boomerangActor = &boomerang->actor; if (boomerang != NULL) { @@ -3024,7 +3050,7 @@ s32 func_80835B60(Player* this, PlayState* play) { Player_SetUpperActionFunc(this, func_80835C08); LinkAnimation_PlayOnce(play, &this->upperSkelAnime, &gPlayerAnim_link_boom_catch); func_808357E8(this, gPlayerLeftHandBoomerangDLs); - Player_PlaySfx(&this->actor, NA_SE_PL_CATCH_BOOMERANG); + Player_PlaySfx(this, NA_SE_PL_CATCH_BOOMERANG); func_80832698(this, NA_SE_VO_LI_SWORD_N); return 1; } @@ -3049,21 +3075,20 @@ s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFun return 0; } - if (func_8084E3C4 == this->actionFunc) { + if (Player_Action_8084E3C4 == this->actionFunc) { Audio_OcaSetInstrument(0); this->stateFlags2 &= ~(PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR | PLAYER_STATE2_PLAY_FOR_ACTOR); - } else if (func_808507F4 == this->actionFunc) { + } else if (Player_Action_808507F4 == this->actionFunc) { func_80832340(play, this); } this->actionFunc = actionFunc; - if ((this->itemAction != this->heldItemAction) && - (!(flags & 1) || !(this->stateFlags1 & PLAYER_STATE1_SHIELDING))) { + if ((this->itemAction != this->heldItemAction) && (!(flags & 1) || !(this->stateFlags1 & PLAYER_STATE1_SHIELDING))) { func_8008EC70(this); } - if (!(flags & 1) && (!(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD))) { + if (!(flags & 1) && !(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD)) { func_80834644(play, this); this->stateFlags1 &= ~PLAYER_STATE1_SHIELDING; } @@ -3075,8 +3100,8 @@ s32 Player_SetupAction(PlayState* play, Player* this, PlayerActionFunc actionFun this->stateFlags2 &= ~(PLAYER_STATE2_HOPPING | PLAYER_STATE2_OCARINA_PLAYING | PLAYER_STATE2_IDLING); this->stateFlags3 &= ~(PLAYER_STATE3_MIDAIR | PLAYER_STATE3_FINISHED_ATTACKING | PLAYER_STATE3_HOOKSHOT_TRAVELLING); - this->unk_84F = 0; - this->unk_850 = 0; + this->av1.actionVar1 = 0; + this->av2.actionVar2 = 0; this->unk_6AC = 0; @@ -3118,7 +3143,7 @@ void func_80835E44(PlayState* play, s16 camSetting) { void func_80835EA4(PlayState* play, s32 arg1) { func_80835E44(play, CAM_SET_TURN_AROUND); - Camera_SetCameraData(Play_GetCamera(play, 0), 4, 0, 0, arg1, 0, 0); + Camera_SetCameraData(Play_GetCamera(play, 0), 4, NULL, NULL, arg1, 0, 0); } void Player_DestroyHookshot(Player* this) { @@ -3143,8 +3168,7 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) { if (((this->heldItemAction == this->itemAction) && (!(this->stateFlags1 & PLAYER_STATE1_SHIELDING) || (Player_ActionToMeleeWeapon(itemAction) != 0) || (itemAction == PLAYER_IA_NONE))) || - ((this->itemAction < 0) && - ((Player_ActionToMeleeWeapon(itemAction) != 0) || (itemAction == PLAYER_IA_NONE)))) { + ((this->itemAction < 0) && ((Player_ActionToMeleeWeapon(itemAction) != 0) || (itemAction == PLAYER_IA_NONE)))) { if ((itemAction == PLAYER_IA_NONE) || !(this->stateFlags1 & PLAYER_STATE1_IN_WATER) || ((this->actor.bgCheckFlags & 1) && @@ -3156,11 +3180,11 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) { (temp = Player_ActionToExplosive(this, itemAction), ((temp >= 0) && ((AMMO(sExplosiveInfos[temp].itemId) == 0) || (play->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].length >= 3 && !CVarGetInteger("gRemoveExplosiveLimit", 0))))))) { + // Prevent some items from being used if player is out of ammo. + // Also prevent explosives from being used if there are 3 or more active (outside of bombchu bowling) func_80078884(NA_SE_SY_ERROR); - return; - } - - if (itemAction == PLAYER_IA_LENS_OF_TRUTH) { + } else if (itemAction == PLAYER_IA_LENS_OF_TRUTH) { + // Handle Lens of Truth if (Magic_RequestChange(play, 0, MAGIC_CONSUME_LENS)) { if (play->actorCtx.lensActive) { Actor_DisableLens(play); @@ -3171,20 +3195,15 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) { } else { func_80078884(NA_SE_SY_ERROR); } - return; - } - - if (itemAction == PLAYER_IA_DEKU_NUT) { + } else if (itemAction == PLAYER_IA_DEKU_NUT) { + // Handle Deku Nuts if (AMMO(ITEM_NUT) != 0) { func_8083C61C(play, this); } else { func_80078884(NA_SE_SY_ERROR); } - return; - } - - temp = Player_ActionToMagicSpell(this, itemAction); - if (temp >= 0) { + } else if ((temp = Player_ActionToMagicSpell(this, itemAction)) >= 0) { + // Handle magic spells if (((itemAction == PLAYER_IA_FARORES_WIND) && (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 0)) || ((gSaveContext.magicCapacity != 0) && (gSaveContext.magicState == MAGIC_STATE_IDLE) && (gSaveContext.magic >= sMagicSpellCosts[temp]))) { @@ -3193,35 +3212,31 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) { } else { func_80078884(NA_SE_SY_ERROR); } - return; - } - - if (itemAction >= PLAYER_IA_MASK_KEATON) { + } else if (itemAction >= PLAYER_IA_MASK_KEATON) { + // Handle wearable masks if (this->currentMask != PLAYER_MASK_NONE) { this->currentMask = PLAYER_MASK_NONE; } else { this->currentMask = itemAction - PLAYER_IA_MASK_KEATON + 1; } + sMaskMemory = this->currentMask; func_808328EC(this, NA_SE_PL_CHANGE_ARMS); - return; - } - - if (((itemAction >= PLAYER_IA_OCARINA_FAIRY) && (itemAction <= PLAYER_IA_OCARINA_OF_TIME)) || + } else if (((itemAction >= PLAYER_IA_OCARINA_FAIRY) && (itemAction <= PLAYER_IA_OCARINA_OF_TIME)) || (itemAction >= PLAYER_IA_BOTTLE_FISH)) { + // Handle "cutscene items" if (!func_8008E9C4(this) || ((itemAction >= PLAYER_IA_BOTTLE_POTION_RED) && (itemAction <= PLAYER_IA_BOTTLE_FAIRY))) { func_8002D53C(play, &play->actorCtx.titleCtx); this->unk_6AD = 4; this->itemAction = itemAction; } - return; - } - - if ((itemAction != this->heldItemAction) || - ((this->heldActor == 0) && (Player_ActionToExplosive(this, itemAction) >= 0))) { + } else if ((itemAction != this->heldItemAction) || + ((this->heldActor == NULL) && (Player_ActionToExplosive(this, itemAction) >= 0))) { + // Handle using a new held item this->nextModelGroup = Player_ActionToModelGroup(this, itemAction); nextAnimType = gPlayerModelTypes[this->nextModelGroup][PLAYER_MODELGROUPENTRY_ANIM]; + if ((this->heldItemAction >= 0) && (Player_ActionToMagicSpell(this, itemAction) < 0) && (item != this->heldItemId) && (sItemChangeTypes[gPlayerModelTypes[this->modelGroup][PLAYER_MODELGROUPENTRY_ANIM]][nextAnimType] != @@ -3229,6 +3244,7 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) { (!CVarGetInteger("gSeparateArrows", 0) || itemAction < PLAYER_IA_BOW || itemAction > PLAYER_IA_BOW_0E || this->heldItemAction < PLAYER_IA_BOW || this->heldItemAction > PLAYER_IA_BOW_0E)) { + // Start the held item change process this->heldItemId = item; this->stateFlags1 |= PLAYER_STATE1_START_PUTAWAY; } else { @@ -3237,10 +3253,10 @@ void Player_UseItem(PlayState* play, Player* this, s32 item) { Player_DetachHeldActor(play, this); Player_InitItemActionWithAnim(play, this, itemAction); } - return; + } else { + // Handle using the held item already in hand + sUseHeldItem = sHeldItemButtonIsHeldDown = true; } - - sUseHeldItem = sHeldItemButtonIsHeldDown = true; } } } @@ -3250,7 +3266,7 @@ void func_80836448(PlayState* play, Player* this, LinkAnimationHeader* anim) { func_80832564(play, this); - Player_SetupAction(play, this, cond ? func_8084E368 : func_80843CEC, 0); + Player_SetupAction(play, this, cond ? Player_Action_8084E368 : Player_Action_80843CEC, 0); this->stateFlags1 |= PLAYER_STATE1_DEAD; @@ -3267,7 +3283,7 @@ void func_80836448(PlayState* play, Player* this, LinkAnimationHeader* anim) { if (Inventory_ConsumeFairy(play)) { play->gameOverCtx.state = GAMEOVER_REVIVE_START; - this->unk_84F = 1; + this->av1.actionVar1 = 1; } else { play->gameOverCtx.state = GAMEOVER_DEATH_START; func_800F6AB0(0); @@ -3282,7 +3298,7 @@ void func_80836448(PlayState* play, Player* this, LinkAnimationHeader* anim) { } s32 Player_CanUpdateItems(Player* this) { - return (!(func_808458D0 == this->actionFunc) || + return (!(Player_Action_808458D0 == this->actionFunc) || ((this->stateFlags1 & PLAYER_STATE1_START_PUTAWAY) && ((this->heldItemId == ITEM_LAST_USED) || (this->heldItemId == ITEM_NONE)))) && (!(Player_UpperAction_ChangeHeldItem == this->upperActionFunc) || @@ -3291,12 +3307,12 @@ s32 Player_CanUpdateItems(Player* this) { s32 Player_UpdateUpperBody(Player* this, PlayState* play) { if (!(this->stateFlags1 & PLAYER_STATE1_ON_HORSE) && (this->actor.parent != NULL) && Player_HoldsHookshot(this)) { - Player_SetupAction(play, this, func_80850AEC, 1); + Player_SetupAction(play, this, Player_Action_80850AEC, 1); this->stateFlags3 |= PLAYER_STATE3_HOOKSHOT_TRAVELLING; Player_AnimPlayOnce(play, this, &gPlayerAnim_link_hook_fly_start); Player_AnimReplaceApplyFlags(play, this, 0x9B); func_80832224(this); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; this->actor.bgCheckFlags &= ~1; this->hoverBootsTimer = 0; this->unk_6AE |= 0x43; @@ -3306,7 +3322,7 @@ s32 Player_UpdateUpperBody(Player* this, PlayState* play) { if (Player_CanUpdateItems(this)) { Player_UpdateItems(this, play); - if (func_8084E604 == this->actionFunc) { + if (Player_Action_8084E604 == this->actionFunc) { return 1; } } @@ -3336,7 +3352,7 @@ s32 Player_UpdateUpperBody(Player* this, PlayState* play) { s32 func_80836898(PlayState* play, Player* this, PlayerFuncA74 func) { this->func_A74 = func; - Player_SetupAction(play, this, func_808458D0, 0); + Player_SetupAction(play, this, Player_Action_808458D0, 0); this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; return func_80832528(play, this); } @@ -3351,10 +3367,10 @@ void func_808368EC(Player* this, PlayState* play) { Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_664->focus.pos), 4000); } else if ((this->stateFlags1 & PLAYER_STATE1_TARGET_NOTHING) && !(this->stateFlags2 & (PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET | PLAYER_STATE2_DISABLE_ROTATION_ALWAYS))) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 4000); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->zTargetYaw, 4000); } } else if (!(this->stateFlags2 & PLAYER_STATE2_DISABLE_ROTATION_ALWAYS)) { - Math_ScaledStepToS(&this->actor.shape.rot.y, this->currentYaw, 2000); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->yaw, 2000); } this->unk_87C = this->actor.shape.rot.y - previousYaw; @@ -3508,26 +3524,52 @@ void func_80836BEC(Player* this, PlayState* play) { } } +/** + * These defines exist to simplify the variable used to toggle the different speed modes. + * While the `speedMode` variable is a float and can contain a non-boolean value, + * `Player_CalcSpeedAndYawFromControlStick` never actually uses the value for anything. + * It simply checks if the value is non-zero to toggle the "curved" mode. + * In practice, 0.0f or 0.018f are the only values passed to this function. + * + * It's clear that this value was intended to mean something in the curved mode calculation at + * some point in development, but was either never implemented or removed. + * + * To see the difference between linear and curved mode, with interactive toggles for + * speed cap and floor pitch, see the following desmos graph: https://www.desmos.com/calculator/hri7dcws4c + */ + +// Linear mode is a straight line, increasing target speed at a steady rate relative to the control stick magnitude +#define SPEED_MODE_LINEAR 0.0f + +// Curved mode drops any input below 20 units of magnitude, resulting in zero for target speed. +// Beyond 20 units, a gradual curve slowly moves up until around the 40 unit mark +// when target speed ramps up very quickly. +#define SPEED_MODE_CURVED 0.018f + /** * Calculates target speed and yaw based on input from the control stick. * See `Player_GetMovementSpeedAndYaw` for detailed argument descriptions. * * @return true if the control stick has any magnitude, false otherwise. */ -s32 Player_CalcSpeedAndYawFromControlStick(PlayState* play, Player* this, f32* outSpeedTarget, s16* outYawTarget, f32 speedMode) { +s32 Player_CalcSpeedAndYawFromControlStick(PlayState* play, Player* this, f32* outSpeedTarget, s16* outYawTarget, + f32 speedMode) { f32 temp; f32 sinFloorPitch; f32 floorPitchInfluence; f32 speedCap; - if ((this->unk_6AD != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) || (this->stateFlags1 & PLAYER_STATE1_LOADING)) { + if ((this->unk_6AD != 0) || (play->transitionTrigger == TRANS_TRIGGER_START) || + (this->stateFlags1 & PLAYER_STATE1_LOADING)) { *outSpeedTarget = 0.0f; *outYawTarget = this->actor.shape.rot.y; } else { *outSpeedTarget = sControlStickMagnitude; *outYawTarget = sControlStickAngle; - if (speedMode != 0.0f) { + // The value of `speedMode` is never actually used. It only toggles this condition. + // See the definition of `SPEED_MODE_LINEAR` and `SPEED_MODE_CURVED` for more information. + if (speedMode != SPEED_MODE_LINEAR) { *outSpeedTarget -= 20.0f; if (*outSpeedTarget < 0.0f) { // If control stick magnitude is below 20, return zero speed. @@ -3537,7 +3579,7 @@ s32 Player_CalcSpeedAndYawFromControlStick(PlayState* play, Player* this, f32* o // it happens to give a desirable curve for grounded movement speed relative // to control stick magnitude. temp = 1.0f - Math_CosS(*outSpeedTarget * 450.0f); - *outSpeedTarget = ((temp * temp) * 30.0f) + 7.0f; + *outSpeedTarget = (SQ(temp) * 30.0f) + 7.0f; } } else { // Speed increases linearly relative to control stick magnitude @@ -3550,10 +3592,8 @@ s32 Player_CalcSpeedAndYawFromControlStick(PlayState* play, Player* this, f32* o floorPitchInfluence = CLAMP(sinFloorPitch, 0.0f, 0.6f); if (this->unk_6C4 != 0.0f) { - speedCap = speedCap - (this->unk_6C4 * 0.008f); - if (speedCap < 2.0f) { - speedCap = 2.0f; - } + speedCap -= (this->unk_6C4 * 0.008f); + speedCap = CLAMP_MIN(speedCap, 2.0f); } *outSpeedTarget = (*outSpeedTarget * 0.14f) - (8.0f * floorPitchInfluence * floorPitchInfluence); @@ -3583,7 +3623,8 @@ s32 func_8083721C(Player* this) { * * @return true if the control stick has any magnitude, false otherwise. */ -s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYawTarget, f32 speedMode, PlayState* play) { +s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYawTarget, f32 speedMode, + PlayState* play) { if (!Player_CalcSpeedAndYawFromControlStick(play, this, outSpeedTarget, outYawTarget, speedMode)) { *outYawTarget = this->actor.shape.rot.y; @@ -3593,7 +3634,7 @@ s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYaw return false; } } else if (func_80833B2C(this)) { - *outYawTarget = this->targetYaw; + *outYawTarget = this->zTargetYaw; } return false; @@ -3603,21 +3644,115 @@ s32 Player_GetMovementSpeedAndYaw(Player* this, f32* outSpeedTarget, s16* outYaw } } -static s8 D_808543E0[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; -static s8 D_808543E8[] = { 13, 1, 2, 5, 3, 4, 9, 10, 11, 7, 8, -6 }; -static s8 D_808543F4[] = { 13, 1, 2, 3, 4, 9, 10, 11, 8, 7, -6 }; -static s8 D_80854400[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; -static s8 D_80854408[] = { 13, 2, 4, 9, 10, 11, 12, 8, -7 }; -static s8 D_80854414[] = { -7 }; -static s8 D_80854418[] = { 0, 11, 1, 2, 3, 5, 4, 9, 8, 7, -6 }; -static s8 D_80854424[] = { 0, 11, 1, 2, 3, 12, 5, 4, 9, 8, 7, -6 }; -static s8 D_80854430[] = { 13, 1, 2, 3, 12, 5, 4, 9, 10, 11, 8, 7, -6 }; -static s8 D_80854440[] = { 10, 8, -7 }; -static s8 D_80854444[] = { 0, 12, 5, -4 }; +typedef enum { + /* 0 */ PLAYER_ACTION_CHG_0, + /* 1 */ PLAYER_ACTION_CHG_1, + /* 2 */ PLAYER_ACTION_CHG_2, + /* 3 */ PLAYER_ACTION_CHG_3, + /* 4 */ PLAYER_ACTION_CHG_4, + /* 5 */ PLAYER_ACTION_CHG_5, + /* 6 */ PLAYER_ACTION_CHG_6, + /* 7 */ PLAYER_ACTION_CHG_7, + /* 8 */ PLAYER_ACTION_CHG_8, + /* 9 */ PLAYER_ACTION_CHG_9, + /* 10 */ PLAYER_ACTION_CHG_10, + /* 11 */ PLAYER_ACTION_CHG_11, + /* 12 */ PLAYER_ACTION_CHG_12, + /* 13 */ PLAYER_ACTION_CHG_13 +} ActionChangeIndex; -static s32 (*D_80854448[])(Player* this, PlayState* play) = { - func_8083B998, func_80839800, func_8083E5A8, func_8083E0FC, func_8083B644, func_8083F7BC, func_8083C1DC, - func_80850224, func_8083C544, func_8083EB44, func_8083BDBC, func_8083C2B0, func_80838A14, func_8083B040, +static s8 sActionChangeList1[] = { + PLAYER_ACTION_CHG_13, PLAYER_ACTION_CHG_2, PLAYER_ACTION_CHG_4, PLAYER_ACTION_CHG_9, + PLAYER_ACTION_CHG_10, PLAYER_ACTION_CHG_11, PLAYER_ACTION_CHG_8, -PLAYER_ACTION_CHG_7, +}; + +static s8 sActionChangeList2[] = { + PLAYER_ACTION_CHG_13, PLAYER_ACTION_CHG_1, PLAYER_ACTION_CHG_2, PLAYER_ACTION_CHG_5, + PLAYER_ACTION_CHG_3, PLAYER_ACTION_CHG_4, PLAYER_ACTION_CHG_9, PLAYER_ACTION_CHG_10, + PLAYER_ACTION_CHG_11, PLAYER_ACTION_CHG_7, PLAYER_ACTION_CHG_8, -PLAYER_ACTION_CHG_6, +}; + +static s8 sActionChangeList3[] = { + PLAYER_ACTION_CHG_13, PLAYER_ACTION_CHG_1, PLAYER_ACTION_CHG_2, PLAYER_ACTION_CHG_3, + PLAYER_ACTION_CHG_4, PLAYER_ACTION_CHG_9, PLAYER_ACTION_CHG_10, PLAYER_ACTION_CHG_11, + PLAYER_ACTION_CHG_8, PLAYER_ACTION_CHG_7, -PLAYER_ACTION_CHG_6, +}; + +static s8 sActionChangeList4[] = { + PLAYER_ACTION_CHG_13, PLAYER_ACTION_CHG_2, PLAYER_ACTION_CHG_4, PLAYER_ACTION_CHG_9, + PLAYER_ACTION_CHG_10, PLAYER_ACTION_CHG_11, PLAYER_ACTION_CHG_8, -PLAYER_ACTION_CHG_7, +}; + +static s8 sActionChangeList5[] = { + PLAYER_ACTION_CHG_13, PLAYER_ACTION_CHG_2, PLAYER_ACTION_CHG_4, PLAYER_ACTION_CHG_9, PLAYER_ACTION_CHG_10, + PLAYER_ACTION_CHG_11, PLAYER_ACTION_CHG_12, PLAYER_ACTION_CHG_8, -PLAYER_ACTION_CHG_7, +}; + +static s8 sActionChangeList6[] = { + -PLAYER_ACTION_CHG_7, +}; + +static s8 sActionChangeList7[] = { + PLAYER_ACTION_CHG_0, PLAYER_ACTION_CHG_11, PLAYER_ACTION_CHG_1, PLAYER_ACTION_CHG_2, + PLAYER_ACTION_CHG_3, PLAYER_ACTION_CHG_5, PLAYER_ACTION_CHG_4, PLAYER_ACTION_CHG_9, + PLAYER_ACTION_CHG_8, PLAYER_ACTION_CHG_7, -PLAYER_ACTION_CHG_6, +}; + +static s8 sActionChangeList8[] = { + PLAYER_ACTION_CHG_0, PLAYER_ACTION_CHG_11, PLAYER_ACTION_CHG_1, PLAYER_ACTION_CHG_2, + PLAYER_ACTION_CHG_3, PLAYER_ACTION_CHG_12, PLAYER_ACTION_CHG_5, PLAYER_ACTION_CHG_4, + PLAYER_ACTION_CHG_9, PLAYER_ACTION_CHG_8, PLAYER_ACTION_CHG_7, -PLAYER_ACTION_CHG_6, +}; + +static s8 sActionChangeList9[] = { + PLAYER_ACTION_CHG_13, PLAYER_ACTION_CHG_1, PLAYER_ACTION_CHG_2, PLAYER_ACTION_CHG_3, PLAYER_ACTION_CHG_12, + PLAYER_ACTION_CHG_5, PLAYER_ACTION_CHG_4, PLAYER_ACTION_CHG_9, PLAYER_ACTION_CHG_10, PLAYER_ACTION_CHG_11, + PLAYER_ACTION_CHG_8, PLAYER_ACTION_CHG_7, -PLAYER_ACTION_CHG_6, +}; + +static s8 sActionChangeList10[] = { + PLAYER_ACTION_CHG_10, + PLAYER_ACTION_CHG_8, + -PLAYER_ACTION_CHG_7, +}; + +static s8 sActionChangeList11[] = { + PLAYER_ACTION_CHG_0, + PLAYER_ACTION_CHG_12, + PLAYER_ACTION_CHG_5, + -PLAYER_ACTION_CHG_4, +}; + +s32 Player_ActionChange_0(Player* this, PlayState* play); +s32 Player_ActionChange_1(Player* this, PlayState* play); +s32 Player_ActionChange_2(Player* this, PlayState* play); +s32 Player_ActionChange_3(Player* this, PlayState* play); +s32 Player_ActionChange_4(Player* this, PlayState* play); +s32 Player_ActionChange_5(Player* this, PlayState* play); +s32 Player_ActionChange_6(Player* this, PlayState* play); +s32 Player_ActionChange_7(Player* this, PlayState* play); +s32 Player_ActionChange_8(Player* this, PlayState* play); +s32 Player_ActionChange_9(Player* this, PlayState* play); +s32 Player_ActionChange_10(Player* this, PlayState* play); +s32 Player_ActionChange_11(Player* this, PlayState* play); +s32 Player_ActionChange_12(Player* this, PlayState* play); +s32 Player_ActionChange_13(Player* this, PlayState* play); + +static s32 (*sActionChangeFuncs[])(Player* this, PlayState* play) = { + /* PLAYER_ACTION_CHG_0 */ Player_ActionChange_0, + /* PLAYER_ACTION_CHG_1 */ Player_ActionChange_1, + /* PLAYER_ACTION_CHG_2 */ Player_ActionChange_2, + /* PLAYER_ACTION_CHG_3 */ Player_ActionChange_3, + /* PLAYER_ACTION_CHG_4 */ Player_ActionChange_4, + /* PLAYER_ACTION_CHG_5 */ Player_ActionChange_5, + /* PLAYER_ACTION_CHG_6 */ Player_ActionChange_6, + /* PLAYER_ACTION_CHG_7 */ Player_ActionChange_7, + /* PLAYER_ACTION_CHG_8 */ Player_ActionChange_8, + /* PLAYER_ACTION_CHG_9 */ Player_ActionChange_9, + /* PLAYER_ACTION_CHG_10 */ Player_ActionChange_10, + /* PLAYER_ACTION_CHG_11 */ Player_ActionChange_11, + /* PLAYER_ACTION_CHG_12 */ Player_ActionChange_12, + /* PLAYER_ACTION_CHG_13 */ Player_ActionChange_13, }; /** @@ -3640,9 +3775,10 @@ s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeLi s32 i; if (!(this->stateFlags1 & (PLAYER_STATE1_LOADING | PLAYER_STATE1_DEAD | PLAYER_STATE1_IN_CUTSCENE))) { - if (updateUpperBody != 0) { + if (updateUpperBody) { D_808535E0 = Player_UpdateUpperBody(this, play); - if (func_8084E604 == this->actionFunc) { + + if (Player_Action_8084E604 == this->actionFunc) { return true; } } @@ -3652,15 +3788,18 @@ s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeLi return true; } - if (!(this->stateFlags1 & PLAYER_STATE1_START_PUTAWAY) && (Player_UpperAction_ChangeHeldItem != this->upperActionFunc)) { + if (!(this->stateFlags1 & PLAYER_STATE1_START_PUTAWAY) && + (Player_UpperAction_ChangeHeldItem != this->upperActionFunc)) { + // Process all entries in the Action Change List with a positive index while (*actionChangeList >= 0) { - if (D_80854448[*actionChangeList](this, play)) { + if (sActionChangeFuncs[*actionChangeList](this, play)) { return true; } actionChangeList++; } - if (D_80854448[-(*actionChangeList)](this, play)) { + // Try the last entry in the list. Negate the index to make it positive again. + if (sActionChangeFuncs[-(*actionChangeList)](this, play)) { return true; } } @@ -3670,15 +3809,15 @@ s32 Player_TryActionChangeList(PlayState* play, Player* this, s8* actionChangeLi } s32 func_808374A0(PlayState* play, Player* this, SkelAnime* skelAnime, f32 arg3) { - f32 sp24; - s16 sp22; + f32 speedTarget; + s16 yawTarget; if ((skelAnime->endFrame - arg3) <= skelAnime->curFrame) { - if (Player_TryActionChangeList(play, this, D_80854418, 1)) { + if (Player_TryActionChangeList(play, this, sActionChangeList7, true)) { return 0; } - if (Player_GetMovementSpeedAndYaw(this, &sp24, &sp22, 0.018f, play)) { + if (Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_CURVED, play)) { return 1; } } @@ -3755,7 +3894,7 @@ void func_80837704(PlayState* play, Player* this) { } void func_808377DC(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_80844E68, 1); + Player_SetupAction(play, this, Player_Action_80844E68, 1); func_80837704(play, this); } @@ -3833,7 +3972,7 @@ void func_80837948(PlayState* play, Player* this, s32 arg2) { u32 dmgFlags; s32 temp; - Player_SetupAction(play, this, func_808502D0, 0); + Player_SetupAction(play, this, Player_Action_808502D0, 0); this->unk_844 = 8; if (!((arg2 >= PLAYER_MWA_FLIPSLASH_FINISH) && (arg2 <= PLAYER_MWA_JUMPSLASH_FINISH))) { func_80832318(this); @@ -3855,7 +3994,7 @@ void func_80837948(PlayState* play, Player* this, s32 arg2) { Player_AnimReplaceApplyFlags(play, this, 0x209); } - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; if (Player_HoldsBrokenKnife(this)) { temp = 1; @@ -3915,9 +4054,9 @@ void func_80837B60(Player* this) { } void func_80837B9C(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_8084411C, 0); + Player_SetupAction(play, this, Player_Action_8084411C, 0); Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); - this->unk_850 = 1; + this->av2.actionVar2 = 1; if (this->unk_6AD != 3) { this->unk_6AD = 0; } @@ -3952,7 +4091,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, func_80837AE0(this, arg6); if (arg2 == 3) { - Player_SetupAction(play, this, func_8084FB10, 0); + Player_SetupAction(play, this, Player_Action_8084FB10, 0); anim = &gPlayerAnim_link_normal_ice_down; @@ -3962,18 +4101,18 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, Player_PlaySfx(this, NA_SE_PL_FREEZE_S); func_80832698(this, NA_SE_VO_LI_FREEZE); } else if (arg2 == 4) { - Player_SetupAction(play, this, func_8084FBF4, 0); + Player_SetupAction(play, this, Player_Action_8084FBF4, 0); Player_RequestRumble(this, 255, 80, 150, 0); Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_link_normal_electric_shock); func_80832224(this); - this->unk_850 = 20; + this->av2.actionVar2 = 20; } else { arg5 -= this->actor.shape.rot.y; if (this->stateFlags1 & PLAYER_STATE1_IN_WATER) { - Player_SetupAction(play, this, func_8084E30C, 0); + Player_SetupAction(play, this, Player_Action_8084E30C, 0); Player_RequestRumble(this, 180, 20, 50, 0); this->linearVelocity = 4.0f; @@ -3984,7 +4123,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, func_80832698(this, NA_SE_VO_LI_DAMAGE_S); } else if ((arg2 == 1) || (arg2 == 2) || !(this->actor.bgCheckFlags & 1) || (this->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | PLAYER_STATE1_CLIMBING_LADDER))) { - Player_SetupAction(play, this, func_8084377C, 0); + Player_SetupAction(play, this, Player_Action_8084377C, 0); this->stateFlags3 |= PLAYER_STATE3_MIDAIR; @@ -3992,7 +4131,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, func_80832224(this); if (arg2 == 2) { - this->unk_850 = 4; + this->av2.actionVar2 = 4; this->actor.speedXZ = 3.0f; this->linearVelocity = 3.0f; @@ -4030,7 +4169,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, sp28 = D_808544B0; - Player_SetupAction(play, this, func_8084370C, 0); + Player_SetupAction(play, this, Player_Action_8084370C, 0); func_80833C3C(this); if (this->actor.colChkInfo.damage < 5) { @@ -4055,7 +4194,7 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, } this->actor.shape.rot.y += arg5; - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; this->actor.world.rot.y = this->actor.shape.rot.y; if (ABS(arg5) > 0x4000) { this->actor.shape.rot.y += 0x8000; @@ -4087,8 +4226,8 @@ s32 func_8083816C(s32 arg0) { void func_8083819C(Player* this, PlayState* play) { if (this->currentShield == PLAYER_SHIELD_DEKU && (CVarGetInteger("gFireproofDekuShield", 0) == 0)) { - Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_SHIELD, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, true); + Actor_Spawn(&play->actorCtx, play, ACTOR_ITEM_SHIELD, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 1, true); Inventory_DeleteEquipment(play, EQUIP_TYPE_SHIELD); Message_StartTextbox(play, 0x305F, NULL); } @@ -4098,10 +4237,10 @@ void func_8083821C(Player* this) { s32 i; // clang-format off - for (i = 0; i < PLAYER_BODYPART_MAX; i++) { this->flameTimers[i] = Rand_S16Offset(0, 200); } + for (i = 0; i < PLAYER_BODYPART_MAX; i++) { this->bodyFlameTimers[i] = Rand_S16Offset(0, 200); } // clang-format on - this->isBurning = true; + this->bodyIsBurning = true; } void func_80838280(Player* this) { @@ -4168,7 +4307,7 @@ s32 func_808382DC(Player* this, PlayState* play) { func_80838280(this); if (this->unk_8A1 == 3) { - this->shockTimer = 40; + this->bodyShockTimer = 40; } this->actor.colChkInfo.damage += this->unk_8A0; @@ -4188,13 +4327,13 @@ s32 func_808382DC(Player* this, PlayState* play) { if (!Player_IsChildWithHylianShield(this)) { if (this->invincibilityTimer >= 0) { LinkAnimationHeader* anim; - s32 sp54 = func_80843188 == this->actionFunc; + s32 sp54 = Player_Action_80843188 == this->actionFunc; if (!func_808332B8(this)) { - Player_SetupAction(play, this, func_808435C4, 0); + Player_SetupAction(play, this, Player_Action_808435C4, 0); } - if (!(this->unk_84F = sp54)) { + if (!(this->av1.actionVar1 = sp54)) { Player_SetUpperActionFunc(this, func_80834BD4); if (this->unk_870 < 0.5f) { @@ -4217,7 +4356,7 @@ s32 func_808382DC(Player* this, PlayState* play) { if (!(this->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | PLAYER_STATE1_CLIMBING_LADDER))) { this->linearVelocity = -18.0f; - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } } @@ -4239,7 +4378,7 @@ s32 func_808382DC(Player* this, PlayState* play) { s32 sp4C; if (ac->flags & ACTOR_FLAG_PLAY_HIT_SFX) { - Player_PlaySfx(&this->actor, NA_SE_PL_BODY_HIT); + Player_PlaySfx(this, NA_SE_PL_BODY_HIT); } if (this->stateFlags1 & PLAYER_STATE1_IN_WATER) { @@ -4266,10 +4405,10 @@ s32 func_808382DC(Player* this, PlayState* play) { SurfaceType_IsWallDamage(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) || ((sp48 >= 0) && SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) && - (this->unk_A79 >= D_808544F4[sp48])) || + (this->floorTypeTimer >= D_808544F4[sp48])) || ((sp48 >= 0) && ((this->currentTunic != PLAYER_TUNIC_GORON && CVarGetInteger("gSuperTunic", 0) == 0) || - (this->unk_A79 >= D_808544F4[sp48])))) { - this->unk_A79 = 0; + (this->floorTypeTimer >= D_808544F4[sp48])))) { + this->floorTypeTimer = 0; this->actor.colChkInfo.damage = 4; func_80837C0C(play, this, 0, 4.0f, 5.0f, this->actor.shape.rot.y, 20); } else { @@ -4283,7 +4422,7 @@ s32 func_808382DC(Player* this, PlayState* play) { } void func_80838940(Player* this, LinkAnimationHeader* anim, f32 arg2, PlayState* play, u16 sfxId) { - Player_SetupAction(play, this, func_8084411C, 1); + Player_SetupAction(play, this, Player_Action_8084411C, 1); if (anim != NULL) { Player_AnimPlayOnceAdjusted(play, this, anim); @@ -4303,7 +4442,7 @@ void func_808389E8(Player* this, LinkAnimationHeader* anim, f32 arg2, PlayState* func_80838940(this, anim, arg2, play, NA_SE_VO_LI_SWORD_N); } -s32 func_80838A14(Player* this, PlayState* play) { +s32 Player_ActionChange_12(Player* this, PlayState* play) { s32 sp3C; LinkAnimationHeader* anim; f32 sp34; @@ -4312,16 +4451,16 @@ s32 func_80838A14(Player* this, PlayState* play) { f32 wallPolyNormalZ; f32 sp24; - if (!(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) && (this->unk_88C >= 2) && + if (!(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) && (this->ledgeClimbType >= 2) && (!(this->stateFlags1 & PLAYER_STATE1_IN_WATER) || (this->ageProperties->unk_14 > this->yDistToLedge))) { sp3C = 0; if (func_808332B8(this)) { if (this->actor.yDistToWater < 50.0f) { - if ((this->unk_88C < 2) || (this->yDistToLedge > this->ageProperties->unk_10)) { + if ((this->ledgeClimbType < 2) || (this->yDistToLedge > this->ageProperties->unk_10)) { return 0; } - } else if ((this->currentBoots != PLAYER_BOOTS_IRON) || (this->unk_88C > 2)) { + } else if ((this->currentBoots != PLAYER_BOOTS_IRON) || (this->ledgeClimbType > 2)) { return 0; } } else if (!(this->actor.bgCheckFlags & 1) || @@ -4330,18 +4469,18 @@ s32 func_80838A14(Player* this, PlayState* play) { } if ((this->actor.wallBgId != BGCHECK_SCENE) && (sTouchedWallFlags & 0x40)) { - if (this->unk_88D >= 6) { + if (this->ledgeClimbDelayTimer >= 6) { this->stateFlags2 |= PLAYER_STATE2_DO_ACTION_CLIMB; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { sp3C = 1; } } - } else if ((this->unk_88D >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + } else if ((this->ledgeClimbDelayTimer >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { sp3C = 1; } if (sp3C != 0) { - Player_SetupAction(play, this, func_80845668, 0); + Player_SetupAction(play, this, Player_Action_80845668, 0); this->stateFlags1 |= PLAYER_STATE1_JUMPING; @@ -4383,11 +4522,11 @@ s32 func_80838A14(Player* this, PlayState* play) { LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 1.3f); AnimationContext_DisableQueue(play); - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; + this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; return 1; } - } else if ((this->actor.bgCheckFlags & 1) && (this->unk_88C == 1) && (this->unk_88D >= 3)) { + } else if ((this->actor.bgCheckFlags & 1) && (this->ledgeClimbType == 1) && (this->ledgeClimbDelayTimer >= 3)) { temp = (this->yDistToLedge * 0.08f) + 5.5f; func_808389E8(this, &gPlayerAnim_link_normal_jump, temp, play); this->linearVelocity = 2.5f; @@ -4399,11 +4538,11 @@ s32 func_80838A14(Player* this, PlayState* play) { } void func_80838E70(PlayState* play, Player* this, f32 arg2, s16 arg3) { - Player_SetupAction(play, this, func_80845CA4, 0); + Player_SetupAction(play, this, Player_Action_80845CA4, 0); func_80832440(play, this); - this->unk_84F = 1; - this->unk_850 = 1; + this->av1.actionVar1 = 1; + this->av2.actionVar2 = 1; this->unk_450.x = (Math_SinS(arg3) * arg2) + this->actor.world.pos.x; this->unk_450.z = (Math_CosS(arg3) * arg2) + this->actor.world.pos.z; @@ -4412,12 +4551,12 @@ void func_80838E70(PlayState* play, Player* this, f32 arg2, s16 arg3) { } void func_80838F18(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084D610, 0); + Player_SetupAction(play, this, Player_Action_8084D610, 0); Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait); } void func_80838F5C(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084F88C, 0); + Player_SetupAction(play, this, Player_Action_8084F88C, 0); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE | PLAYER_STATE1_FLOOR_DISABLED; @@ -4490,19 +4629,19 @@ u8 sReturnEntranceGroupIndices[] = { }; s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) { - s32 sp3C; + s32 exitIndex; s32 temp; s32 sp34; - f32 linearVel; + f32 speedXZ; s32 yaw; if (this->actor.category == ACTORCAT_PLAYER) { - sp3C = 0; + exitIndex = 0; if (!(this->stateFlags1 & PLAYER_STATE1_DEAD) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (this->csAction == 0) && !(this->stateFlags1 & PLAYER_STATE1_LOADING) && - (((poly != NULL) && (sp3C = SurfaceType_GetSceneExitIndex(&play->colCtx, poly, bgId), sp3C != 0)) || - (func_8083816C(sFloorType) && (this->unk_A7A == 12)))) { + (((poly != NULL) && (exitIndex = SurfaceType_GetSceneExitIndex(&play->colCtx, poly, bgId), exitIndex != 0)) || + (func_8083816C(sFloorType) && (this->floorProperty == 12)))) { sp34 = this->unk_A84 - (s32)this->actor.world.pos.y; @@ -4511,11 +4650,11 @@ s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* pol return 0; } - if (sp3C == 0) { + if (exitIndex == 0) { Play_TriggerVoidOut(play); Scene_SetTransitionForNextEntrance(play); } else { - play->nextEntranceIndex = play->setupExitList[sp3C - 1]; + play->nextEntranceIndex = play->setupExitList[exitIndex - 1]; // Main override for entrance rando and entrance skips if (IS_RANDO) { @@ -4538,7 +4677,9 @@ s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* pol Scene_SetTransitionForNextEntrance(play); } else { - if (SurfaceType_GetSlope(&play->colCtx, poly, bgId) == 2) { + // In Entrance rando, if our respawnFlag is set for a grotto return, we don't want the void out to happen + if (SurfaceType_GetSlope(&play->colCtx, poly, bgId) == 2 && + (!IS_RANDO || (Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES) && gSaveContext.respawnFlag != 2))) { gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = play->nextEntranceIndex; Play_TriggerVoidOut(play); gSaveContext.respawnFlag = -2; @@ -4560,17 +4701,17 @@ s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* pol gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = NATURE_ID_DISABLED; } else { - linearVel = this->linearVelocity; + speedXZ = this->linearVelocity; - if (linearVel < 0.0f) { + if (speedXZ < 0.0f) { this->actor.world.rot.y += 0x8000; - linearVel = -linearVel; + speedXZ = -speedXZ; } - if (linearVel > R_RUN_SPEED_LIMIT / 100.0f) { + if (speedXZ > R_RUN_SPEED_LIMIT / 100.0f) { gSaveContext.entranceSpeed = R_RUN_SPEED_LIMIT / 100.0f; } else { - gSaveContext.entranceSpeed = linearVel; + gSaveContext.entranceSpeed = speedXZ; } if (sConveyorSpeed != 0) { @@ -4595,13 +4736,13 @@ s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* pol if (play->transitionTrigger == TRANS_TRIGGER_OFF) { if ((this->actor.world.pos.y < -4000.0f) || - (((this->unk_A7A == 5) || (this->unk_A7A == 12)) && + (((this->floorProperty == 5) || (this->floorProperty == 12)) && ((sYDistToFloor < 100.0f) || (this->fallDistance > 400.0f) || ((play->sceneNum != SCENE_SHADOW_TEMPLE) && (this->fallDistance > 200.0f)))) || ((play->sceneNum == SCENE_GANONS_TOWER_COLLAPSE_EXTERIOR) && (this->fallDistance > 320.0f))) { if (this->actor.bgCheckFlags & 1) { - if (this->unk_A7A == 5) { + if (this->floorProperty == 5) { Play_TriggerRespawn(play); } else { Play_TriggerVoidOut(play); @@ -4610,11 +4751,11 @@ s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* pol func_80078884(NA_SE_OC_ABYSS); } else { func_80838F5C(play, this); - this->unk_850 = 9999; - if (this->unk_A7A == 5) { - this->unk_84F = -1; + this->av2.actionVar2 = 9999; + if (this->floorProperty == 5) { + this->av1.actionVar1 = -1; } else { - this->unk_84F = 1; + this->av1.actionVar1 = 1; } } } @@ -4669,7 +4810,8 @@ f32 func_8083973C(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3) { * Point B of the line is at player's world position offset by the entire `offset` vector. * Point A and B are always at the same height, meaning this is a horizontal line test. */ -s32 Player_PosVsWallLineTest(PlayState* play, Player* this, Vec3f* offset, CollisionPoly** wallPoly, s32* bgId, Vec3f* posResult) { +s32 Player_PosVsWallLineTest(PlayState* play, Player* this, Vec3f* offset, CollisionPoly** wallPoly, s32* bgId, + Vec3f* posResult) { Vec3f posA; Vec3f posB; @@ -4682,7 +4824,7 @@ s32 Player_PosVsWallLineTest(PlayState* play, Player* this, Vec3f* offset, Colli return BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, posResult, wallPoly, true, false, false, true, bgId); } -s32 func_80839800(Player* this, PlayState* play) { +s32 Player_ActionChange_1(Player* this, PlayState* play) { DoorShutter* doorShutter; EnDoor* door; // Can also be DoorKiller* s32 doorDirection; @@ -4694,14 +4836,14 @@ s32 func_80839800(Player* this, PlayState* play) { s32 frontRoom; Actor* attachedActor; LinkAnimationHeader* sp5C; - CollisionPoly* sp58; - Vec3f sp4C; + CollisionPoly* groundPoly; + Vec3f checkPos; if ((this->doorType != PLAYER_DOORTYPE_NONE) && (!(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) || ((this->heldActor != NULL) && (this->heldActor->id == ACTOR_EN_RU1)))) { // Disable doors in Boss Rush so the player can't leave the boss rooms backwards. - if ((CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (func_8084F9A0 == this->actionFunc)) && !IS_BOSS_RUSH) { + if ((CHECK_BTN_ALL(sControlInput->press.button, BTN_A) || (Player_Action_8084F9A0 == this->actionFunc)) && !IS_BOSS_RUSH) { doorActor = this->doorActor; if (this->doorType <= PLAYER_DOORTYPE_AJAR) { @@ -4717,11 +4859,11 @@ s32 func_80839800(Player* this, PlayState* play) { if (this->doorType == PLAYER_DOORTYPE_SLIDING) { doorShutter = (DoorShutter*)doorActor; - this->currentYaw = doorShutter->dyna.actor.home.rot.y; + this->yaw = doorShutter->dyna.actor.home.rot.y; if (doorDirection > 0) { - this->currentYaw -= 0x8000; + this->yaw -= 0x8000; } - this->actor.shape.rot.y = this->currentYaw; + this->actor.shape.rot.y = this->yaw; if (this->linearVelocity <= 0.0f) { this->linearVelocity = 0.1f; @@ -4729,7 +4871,7 @@ s32 func_80839800(Player* this, PlayState* play) { func_80838E70(play, this, 50.0f, this->actor.shape.rot.y); - this->unk_84F = 0; + this->av1.actionVar1 = 0; this->unk_447 = this->doorType; this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; @@ -4742,7 +4884,7 @@ s32 func_80839800(Player* this, PlayState* play) { func_80832224(this); if (this->doorTimer != 0) { - this->unk_850 = 0; + this->av2.actionVar2 = 0; Player_AnimChangeOnceMorph(play, this, func_80833338(this)); this->skelAnime.endFrame = 0.0f; } else { @@ -4775,7 +4917,7 @@ s32 func_80839800(Player* this, PlayState* play) { sp5C = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_doorB, this->modelAnimType); } - Player_SetupAction(play, this, func_80845EF8, 0); + Player_SetupAction(play, this, Player_Action_80845EF8, 0); func_80832528(play, this); if (doorDirection < 0) { @@ -4784,7 +4926,7 @@ s32 func_80839800(Player* this, PlayState* play) { this->actor.shape.rot.y = doorActor->shape.rot.y - 0x8000; } - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; sp6C = (doorDirection * 22.0f); this->actor.world.pos.x = doorActor->world.pos.x + sp6C * sp74; @@ -4810,13 +4952,14 @@ s32 func_80839800(Player* this, PlayState* play) { Actor_DisableLens(play); if (((doorActor->params >> 7) & 7) == 3) { - sp4C.x = doorActor->world.pos.x - (sp6C * sp74); - sp4C.y = doorActor->world.pos.y + 10.0f; - sp4C.z = doorActor->world.pos.z - (sp6C * sp78); + checkPos.x = doorActor->world.pos.x - (sp6C * sp74); + checkPos.y = doorActor->world.pos.y + 10.0f; + checkPos.z = doorActor->world.pos.z - (sp6C * sp78); - BgCheck_EntityRaycastFloor1(&play->colCtx, &sp58, &sp4C); + BgCheck_EntityRaycastFloor1(&play->colCtx, &groundPoly, &checkPos); - if (Player_HandleExitsAndVoids(play, this, sp58, BGCHECK_SCENE)) { + //! @bug groundPoly's bgId is not guaranteed to be BGCHECK_SCENE + if (Player_HandleExitsAndVoids(play, this, groundPoly, BGCHECK_SCENE)) { gSaveContext.entranceSpeed = 2.0f; gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN; } @@ -4856,7 +4999,7 @@ s32 func_80839800(Player* this, PlayState* play) { void func_80839E88(Player* this, PlayState* play) { LinkAnimationHeader* anim; - Player_SetupAction(play, this, func_80840450, 1); + Player_SetupAction(play, this, Player_Action_80840450, 1); if (this->unk_870 < 0.5f) { anim = func_808334E4(this); @@ -4868,13 +5011,13 @@ void func_80839E88(Player* this, PlayState* play) { this->unk_874 = this->unk_870; Player_AnimPlayLoop(play, this, anim); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } void func_80839F30(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_808407CC, 1); + Player_SetupAction(play, this, Player_Action_808407CC, 1); Player_AnimChangeOnceMorph(play, this, func_80833338(this)); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } void func_80839F90(Player* this, PlayState* play) { @@ -4891,11 +5034,11 @@ void func_80839FFC(Player* this, PlayState* play) { PlayerActionFunc actionFunc; if (func_8008E9C4(this)) { - actionFunc = func_80840450; + actionFunc = Player_Action_80840450; } else if (func_80833B2C(this)) { - actionFunc = func_808407CC; + actionFunc = Player_Action_808407CC; } else { - actionFunc = func_80840BC8; + actionFunc = Player_Action_80840BC8; } Player_SetupAction(play, this, actionFunc, 1); @@ -4904,7 +5047,7 @@ void func_80839FFC(Player* this, PlayState* play) { void func_8083A060(Player* this, PlayState* play) { func_80839FFC(this, play); if (func_8008E9C4(this)) { - this->unk_850 = 1; + this->av2.actionVar2 = 1; } } @@ -4924,30 +5067,30 @@ void func_8083A0F4(PlayState* play, Player* this) { if (interactActorId == ACTOR_BG_TOKI_SWD) { this->interactRangeActor->parent = &this->actor; - Player_SetupAction(play, this, func_8084F608, 0); + Player_SetupAction(play, this, Player_Action_8084F608, 0); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; sMaskMemory = PLAYER_MASK_NONE; } else { LinkAnimationHeader* anim; if (interactActorId == ACTOR_BG_HEAVY_BLOCK) { - Player_SetupAction(play, this, func_80846120, 0); + Player_SetupAction(play, this, Player_Action_80846120, 0); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; anim = &gPlayerAnim_link_normal_heavy_carry; } else if ((interactActorId == ACTOR_EN_ISHI) && ((interactRangeActor->params & 0xF) == 1)) { - Player_SetupAction(play, this, func_80846260, 0); + Player_SetupAction(play, this, Player_Action_80846260, 0); anim = &gPlayerAnim_link_silver_carry; } else if (((interactActorId == ACTOR_EN_BOMBF) || (interactActorId == ACTOR_EN_KUSA)) && (Player_GetStrength() <= PLAYER_STR_NONE)) { - Player_SetupAction(play, this, func_80846408, 0); + Player_SetupAction(play, this, Player_Action_80846408, 0); this->actor.world.pos.x = (Math_SinS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.x; this->actor.world.pos.z = (Math_CosS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.z; - this->currentYaw = this->actor.shape.rot.y = interactRangeActor->yawTowardsPlayer + 0x8000; + this->yaw = this->actor.shape.rot.y = interactRangeActor->yawTowardsPlayer + 0x8000; anim = &gPlayerAnim_link_normal_nocarry_free; } else { - Player_SetupAction(play, this, func_80846050, 0); + Player_SetupAction(play, this, Player_Action_80846050, 0); anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_carryB, this->modelAnimType); } @@ -4966,7 +5109,7 @@ void func_8083A0F4(PlayState* play, Player* this) { } void func_8083A2F8(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084B530, 0); + func_80835DAC(play, this, Player_Action_8084B530, 0); this->stateFlags1 |= PLAYER_STATE1_TEXT_ON_SCREEN | PLAYER_STATE1_IN_CUTSCENE; @@ -4977,37 +5120,37 @@ void func_8083A2F8(PlayState* play, Player* this) { } void func_8083A360(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084CC98, 0); + func_80835DAC(play, this, Player_Action_8084CC98, 0); } void func_8083A388(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084B78C, 0); + Player_SetupAction(play, this, Player_Action_8084B78C, 0); } void func_8083A3B0(PlayState* play, Player* this) { - s32 sp1C = this->unk_850; - s32 sp18 = this->unk_84F; + s32 sp1C = this->av2.actionVar2; + s32 sp18 = this->av1.actionVar1; - func_80835DAC(play, this, func_8084BF1C, 0); + func_80835DAC(play, this, Player_Action_8084BF1C, 0); this->actor.velocity.y = 0.0f; - this->unk_850 = sp1C; - this->unk_84F = sp18; + this->av2.actionVar2 = sp1C; + this->av1.actionVar1 = sp18; } void func_8083A40C(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084C760, 0); + func_80835DAC(play, this, Player_Action_8084C760, 0); } void func_8083A434(PlayState* play, Player* this) { - func_80835DAC(play, this, func_8084E6D4, 0); + func_80835DAC(play, this, Player_Action_8084E6D4, 0); this->stateFlags1 |= PLAYER_STATE1_GETTING_ITEM | PLAYER_STATE1_IN_CUTSCENE; if (this->getItemId == GI_HEART_CONTAINER_2) { - this->unk_850 = 20; + this->av2.actionVar2 = 20; } else if (this->getItemId >= 0 || (this->getItemEntry.objectId != OBJECT_INVALID && this->getItemEntry.getItemId >= 0)) { - this->unk_850 = 1; + this->av2.actionVar2 = 1; } else { this->getItemId = -this->getItemId; this->getItemEntry.getItemId = -this->getItemEntry.getItemId; @@ -5019,7 +5162,7 @@ s32 func_8083A4A8(Player* this, PlayState* play) { LinkAnimationHeader* anim; f32 temp; - yawDiff = this->currentYaw - this->actor.shape.rot.y; + yawDiff = this->yaw - this->actor.shape.rot.y; if ((ABS(yawDiff) < 0x1000) && (this->linearVelocity > 4.0f)) { anim = &gPlayerAnim_link_normal_run_jump; @@ -5034,7 +5177,7 @@ s32 func_8083A4A8(Player* this, PlayState* play) { } func_80838940(this, anim, temp, play, NA_SE_VO_LI_AUTO_JUMP); - this->unk_850 = 1; + this->av2.actionVar2 = 1; return 1; } @@ -5043,13 +5186,13 @@ void func_8083A5C4(PlayState* play, Player* this, CollisionPoly* arg2, f32 arg3, f32 nx = COLPOLY_GET_NORMAL(arg2->normal.x); f32 nz = COLPOLY_GET_NORMAL(arg2->normal.z); - Player_SetupAction(play, this, func_8084BBE4, 0); + Player_SetupAction(play, this, Player_Action_8084BBE4, 0); func_80832564(play, this); Player_AnimPlayOnce(play, this, anim); this->actor.world.pos.x -= (arg3 + 1.0f) * nx; this->actor.world.pos.z -= (arg3 + 1.0f) * nz; - this->actor.shape.rot.y = this->currentYaw = Math_Atan2S(nz, nx); + this->actor.shape.rot.y = this->yaw = Math_Atan2S(nz, nx); func_80832224(this); Player_SkelAnimeResetPrevTranslRot(this); @@ -5102,20 +5245,20 @@ s32 func_8083A6AC(Player* this, PlayState* play) { if (sp50) { func_80836898(play, this, func_8083A3B0); - this->currentYaw += 0x8000; - this->actor.shape.rot.y = this->currentYaw; + this->yaw += 0x8000; + this->actor.shape.rot.y = this->yaw; this->stateFlags1 |= PLAYER_STATE1_CLIMBING_LADDER; Player_AnimReplaceApplyFlags(play, this, 0x9F); - this->unk_850 = -1; - this->unk_84F = sp50; + this->av2.actionVar2 = -1; + this->av1.actionVar1 = sp50; } else { this->stateFlags1 |= PLAYER_STATE1_HANGING_OFF_LEDGE; this->stateFlags1 &= ~PLAYER_STATE1_TARGET_NOTHING; } - Player_PlaySfx(&this->actor, NA_SE_PL_SLIPDOWN); + Player_PlaySfx(this, NA_SE_PL_SLIPDOWN); func_80832698(this, NA_SE_VO_LI_HANG); return 1; } @@ -5125,7 +5268,7 @@ s32 func_8083A6AC(Player* this, PlayState* play) { } void func_8083A9B8(Player* this, LinkAnimationHeader* anim, PlayState* play) { - Player_SetupAction(play, this, func_8084BDFC, 0); + Player_SetupAction(play, this, Player_Action_8084BDFC, 0); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 1.3f); } @@ -5151,7 +5294,7 @@ void func_8083AA10(Player* this, PlayState* play) { } if (!(this->stateFlags3 & PLAYER_STATE3_MIDAIR) && !(this->skelAnime.moveFlags & 0x80) && - (func_8084411C != this->actionFunc) && (func_80844A44 != this->actionFunc)) { + (Player_Action_8084411C != this->actionFunc) && (Player_Action_80844A44 != this->actionFunc)) { if ((sPrevFloorProperty == 7) || (this->meleeWeaponState != 0)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); @@ -5165,12 +5308,12 @@ void func_8083AA10(Player* this, PlayState* play) { return; } - sp5C = (s16)(this->currentYaw - this->actor.shape.rot.y); + sp5C = (s16)(this->yaw - this->actor.shape.rot.y); - Player_SetupAction(play, this, func_8084411C, 1); + Player_SetupAction(play, this, Player_Action_8084411C, 1); func_80832440(play, this); - this->floorSfxOffset = this->unk_A82; + this->floorSfxOffset = this->prevFloorSfxOffset; if ((this->actor.bgCheckFlags & 4) && !(this->stateFlags1 & PLAYER_STATE1_IN_WATER) && (sPrevFloorProperty != 6) && (sPrevFloorProperty != 9) && (sYDistToFloor > 20.0f) && (this->meleeWeaponState == 0) && (ABS(sp5C) < 0x2000) && @@ -5184,7 +5327,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (WaterBox_GetSurface1(play, &play->colCtx, sp44.x, sp44.z, &sp3C, &sp50) && ((sp3C - sp40) > 50.0f)) { func_808389E8(this, &gPlayerAnim_link_normal_run_jump_water_fall, 6.0f, play); - Player_SetupAction(play, this, func_80844A44, 0); + Player_SetupAction(play, this, Player_Action_80844A44, 0); return; } } @@ -5236,7 +5379,7 @@ s32 Player_StartCsAction(PlayState* play, Player* this) { // unk_6AD will get set to 3 in `Player_UpdateCommon` if `this->csAction` is non-zero // (with a special case for `PLAYER_CSACTION_7`) if (this->unk_6AD == 3) { - Player_SetupAction(play, this, func_80852E14, 0); + Player_SetupAction(play, this, Player_Action_CsAction, 0); if (this->doorBgCamIndex != 0) { this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; } @@ -5267,9 +5410,9 @@ void func_8083AE40(Player* this, s16 objectId) { } void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { - func_80835DE4(play, this, func_808507F4, 0); + func_80835DE4(play, this, Player_Action_808507F4, 0); - this->unk_84F = magicSpell - 3; + this->av1.actionVar1 = magicSpell - 3; //! @bug `MAGIC_CONSUME_WAIT_PREVIEW` is not guaranteed to succeed. //! Ideally, the return value of `Magic_RequestChange` should be checked before allowing the process of @@ -5317,7 +5460,7 @@ static LinkAnimationHeader* D_80854548[] = { &gPlayerAnim_link_normal_take_out, }; -s32 func_8083B040(Player* this, PlayState* play) { +s32 Player_ActionChange_13(Player* this, PlayState* play) { s32 sp2C; s32 sp28; GetItemEntry giEntry; @@ -5333,7 +5476,7 @@ s32 func_8083B040(Player* this, PlayState* play) { if ((sp2C != 3) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { func_8083AF44(play, this, sp2C); } else { - Player_SetupAction(play, this, func_8085063C, 1); + Player_SetupAction(play, this, Player_Action_8085063C, 1); this->stateFlags1 |= PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE; Player_AnimPlayOnce(play, this, func_80833338(this)); func_80835EA4(play, 4); @@ -5353,7 +5496,7 @@ s32 func_8083B040(Player* this, PlayState* play) { (this->exchangeItemId == EXCH_ITEM_BLUE_FIRE))))))) { if ((play->actorCtx.titleCtx.delayTimer == 0) && (play->actorCtx.titleCtx.alpha == 0)) { - func_80835DE4(play, this, func_8084F104, 0); + func_80835DE4(play, this, Player_Action_8084F104, 0); if (sp2C >= 0) { if (this->getItemEntry.objectId == OBJECT_INVALID) { @@ -5383,19 +5526,19 @@ s32 func_8083B040(Player* this, PlayState* play) { ((this->exchangeItemId != EXCH_ITEM_BEAN) || (this->itemAction == PLAYER_IA_MAGIC_BEAN))) { if (this->exchangeItemId == EXCH_ITEM_BEAN) { Inventory_ChangeAmmo(ITEM_BEAN, -1); - func_80835DE4(play, this, func_8084279C, 0); + func_80835DE4(play, this, Player_Action_8084279C, 0); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; - this->unk_850 = 0x50; - this->unk_84F = -1; + this->av2.actionVar2 = 0x50; + this->av1.actionVar1 = -1; } targetActor->flags |= ACTOR_FLAG_PLAYER_TALKED_TO; this->unk_664 = this->targetActor; } else if (sp2C == EXCH_ITEM_LETTER_RUTO) { - this->unk_84F = 1; + this->av1.actionVar1 = 1; this->actor.textId = 0x4005; func_80835EA4(play, 1); } else { - this->unk_84F = 2; + this->av1.actionVar1 = 2; this->actor.textId = 0xCF; func_80835EA4(play, 4); } @@ -5403,10 +5546,10 @@ s32 func_8083B040(Player* this, PlayState* play) { this->actor.flags |= ACTOR_FLAG_PLAYER_TALKED_TO; this->exchangeItemId = sp2C; - if (this->unk_84F < 0) { + if (this->av1.actionVar1 < 0) { Player_AnimChangeOnceMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_check, this->modelAnimType)); } else { - Player_AnimPlayOnce(play, this, D_80854548[this->unk_84F]); + Player_AnimPlayOnce(play, this, D_80854548[this->av1.actionVar1]); } func_80832224(this); @@ -5417,20 +5560,20 @@ s32 func_8083B040(Player* this, PlayState* play) { sp2C = Player_ActionToBottle(this, this->itemAction); if (sp2C >= 0) { if (sp2C == 0xC) { - func_80835DE4(play, this, func_8084EED8, 0); + func_80835DE4(play, this, Player_Action_8084EED8, 0); Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_bottle_bug_out); func_80835EA4(play, 3); } else if ((sp2C > 0) && (sp2C < 4)) { - func_80835DE4(play, this, func_8084EFC0, 0); + func_80835DE4(play, this, Player_Action_8084EFC0, 0); Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_bottle_fish_out); func_80835EA4(play, (sp2C == 1) ? 1 : 5); } else { - func_80835DE4(play, this, func_8084EAC0, 0); + func_80835DE4(play, this, Player_Action_8084EAC0, 0); Player_AnimChangeOnceMorphAdjusted(play, this, &gPlayerAnim_link_bottle_drink_demo_start); func_80835EA4(play, 2); } } else { - func_80835DE4(play, this, func_8084E3C4, 0); + func_80835DE4(play, this, Player_Action_8084E3C4, 0); Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_normal_okarina_start); this->stateFlags2 |= PLAYER_STATE2_OCARINA_PLAYING; func_80835EA4(play, (this->unk_6A8 != NULL) ? 0x5B : 0x5A); @@ -5441,8 +5584,8 @@ s32 func_8083B040(Player* this, PlayState* play) { } } else if (func_8083AD4C(play, this)) { if (!(this->stateFlags1 & PLAYER_STATE1_ON_HORSE)) { - Player_SetupAction(play, this, func_8084B1D8, 1); - this->unk_850 = 13; + Player_SetupAction(play, this, Player_Action_8084B1D8, 1); + this->av2.actionVar2 = 13; func_8083B010(this); } this->stateFlags1 |= PLAYER_STATE1_FIRST_PERSON; @@ -5465,14 +5608,15 @@ s32 func_8083B040(Player* this, PlayState* play) { return 0; } -s32 func_8083B644(Player* this, PlayState* play) { +s32 Player_ActionChange_4(Player* this, PlayState* play) { Actor* sp34 = this->targetActor; Actor* sp30 = this->unk_664; Actor* sp2C = NULL; s32 sp28 = 0; s32 sp24; - sp24 = (sp30 != NULL) && (CHECK_FLAG_ALL(sp30->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_NAVI_HAS_INFO) || (sp30->naviEnemyId != 0xFF)); + sp24 = (sp30 != NULL) && + (CHECK_FLAG_ALL(sp30->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_NAVI_HAS_INFO) || (sp30->naviEnemyId != 0xFF)); if (sp24 || (this->naviTextId != 0)) { sp28 = (this->naviTextId < 0) && ((ABS(this->naviTextId) & 0xFF00) != 0x200); @@ -5509,8 +5653,7 @@ s32 func_8083B644(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_NAVI_ALERT; } - if (!CHECK_BTN_ALL(sControlInput->press.button, CVarGetInteger("gNaviOnL", 0) ? BTN_L : BTN_CUP) && - !sp28) { + if (!CHECK_BTN_ALL(sControlInput->press.button, CVarGetInteger("gNaviOnL", 0) ? BTN_L : BTN_CUP) && !sp28) { return 0; } @@ -5518,11 +5661,7 @@ s32 func_8083B644(Player* this, PlayState* play) { this->targetActor = NULL; if (sp28 || !sp24) { - if (this->naviTextId >= 0) { - sp2C->textId = this->naviTextId; - } else { - sp2C->textId = -this->naviTextId; - } + sp2C->textId = ABS(this->naviTextId); } else { if (sp2C->naviEnemyId != 0xFF) { sp2C->textId = sp2C->naviEnemyId + 0x600; @@ -5554,18 +5693,18 @@ s32 func_8083B8F4(Player* this, PlayState* play) { return 0; } -s32 func_8083B998(Player* this, PlayState* play) { +s32 Player_ActionChange_0(Player* this, PlayState* play) { if (this->unk_6AD != 0) { - func_8083B040(this, play); + Player_ActionChange_13(this, play); return 1; } - if ((this->unk_664 != NULL) && - (CHECK_FLAG_ALL(this->unk_664->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_NAVI_HAS_INFO) || (this->unk_664->naviEnemyId != 0xFF))) { + if ((this->unk_664 != NULL) && (CHECK_FLAG_ALL(this->unk_664->flags, ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_NAVI_HAS_INFO) || + (this->unk_664->naviEnemyId != 0xFF))) { this->stateFlags2 |= PLAYER_STATE2_NAVI_ALERT; - } else if ((this->naviTextId == 0 || CVarGetInteger("gNaviOnL", 0)) && !func_8008E9C4(this) && - CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && (YREG(15) != 0x10) && (YREG(15) != 0x20) && - !func_8083B8F4(this, play)) { + } else if ((this->naviTextId == 0 || CVarGetInteger("gNaviOnL", 0)) && !func_8008E9C4(this) && CHECK_BTN_ALL(sControlInput->press.button, BTN_CUP) && + (YREG(15) != 0x10) && + (YREG(15) != 0x20) && !func_8083B8F4(this, play)) { func_80078884(NA_SE_SY_ERROR); } @@ -5574,11 +5713,11 @@ s32 func_8083B998(Player* this, PlayState* play) { void func_8083BA90(PlayState* play, Player* this, s32 arg2, f32 xzVelocity, f32 yVelocity) { func_80837948(play, this, arg2); - Player_SetupAction(play, this, func_80844AF4, 0); + Player_SetupAction(play, this, Player_Action_80844AF4, 0); this->stateFlags3 |= PLAYER_STATE3_MIDAIR; - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; this->linearVelocity = xzVelocity; this->actor.velocity.y = yVelocity; @@ -5610,8 +5749,9 @@ s32 func_8083BBA0(Player* this, PlayState* play) { } void func_8083BC04(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80844708, 0); - LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_landing_roll, this->modelAnimType), + Player_SetupAction(play, this, Player_Action_80844708, 0); + LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, + GET_PLAYER_ANIM(PLAYER_ANIMGROUP_landing_roll, this->modelAnimType), 1.25f * D_808535E8); gSaveContext.sohStats.count[COUNT_ROLLS]++; } @@ -5630,18 +5770,18 @@ void func_8083BCD0(Player* this, PlayState* play, s32 arg2) { if (arg2) {} - this->unk_850 = 1; - this->unk_84F = arg2; + this->av2.actionVar2 = 1; + this->av1.actionVar1 = arg2; - this->currentYaw = this->actor.shape.rot.y + (arg2 << 0xE); + this->yaw = this->actor.shape.rot.y + (arg2 << 0xE); this->linearVelocity = !(arg2 & 1) ? 6.0f : 8.5f; this->stateFlags2 |= PLAYER_STATE2_HOPPING; - Player_PlaySfx(&this->actor, ((arg2 << 0xE) == 0x8000) ? NA_SE_PL_ROLL : NA_SE_PL_SKIP); + Player_PlaySfx(this, ((arg2 << 0xE) == 0x8000) ? NA_SE_PL_ROLL : NA_SE_PL_SKIP); } -s32 func_8083BDBC(Player* this, PlayState* play) { +s32 Player_ActionChange_10(Player* this, PlayState* play) { s32 sp2C; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && @@ -5658,7 +5798,7 @@ s32 func_8083BDBC(Player* this, PlayState* play) { func_8083BC04(this, play); } } else { - if (Player_GetMeleeWeaponHeld(this) && Player_CanUpdateItems(this)) { + if ((Player_GetMeleeWeaponHeld(this) != 0) && Player_CanUpdateItems(this)) { func_8083BA90(play, this, PLAYER_MWA_JUMPSLASH_START, 5.0f, 5.0f); } else { func_8083BC04(this, play); @@ -5709,7 +5849,7 @@ void func_8083BF50(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, 4.0f * sp30); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } void func_8083C0B8(Player* this, PlayState* play) { @@ -5718,9 +5858,9 @@ void func_8083C0B8(Player* this, PlayState* play) { } void func_8083C0E8(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80840BC8, 1); + Player_SetupAction(play, this, Player_Action_80840BC8, 1); Player_AnimPlayOnce(play, this, func_80833338(this)); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } void func_8083C148(Player* this, PlayState* play) { @@ -5739,7 +5879,7 @@ void func_8083C148(Player* this, PlayState* play) { this->stateFlags1 &= ~(PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | PLAYER_STATE1_FIRST_PERSON); } -s32 func_8083C1DC(Player* this, PlayState* play) { +s32 Player_ActionChange_6(Player* this, PlayState* play) { if (!func_80833B54(this) && (D_808535E0 == 0) && !(this->stateFlags1 & PLAYER_STATE1_ON_HORSE) && CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { if (func_8083BC7C(this, play)) { @@ -5755,7 +5895,7 @@ s32 func_8083C1DC(Player* this, PlayState* play) { return 0; } -s32 func_8083C2B0(Player* this, PlayState* play) { +s32 Player_ActionChange_11(Player* this, PlayState* play) { LinkAnimationHeader* anim; f32 frame; @@ -5766,7 +5906,7 @@ s32 func_8083C2B0(Player* this, PlayState* play) { func_80832318(this); Player_DetachHeldActor(play, this); - if (Player_SetupAction(play, this, func_80843188, 0)) { + if (Player_SetupAction(play, this, Player_Action_80843188, 0)) { this->stateFlags1 |= PLAYER_STATE1_SHIELDING; if (!Player_IsChildWithHylianShield(this)) { @@ -5793,7 +5933,7 @@ s32 func_8083C2B0(Player* this, PlayState* play) { Player_AnimReplaceApplyFlags(play, this, 4); } - Player_PlaySfx(&this->actor, NA_SE_IT_SHIELD_POSTURE); + Player_PlaySfx(this, NA_SE_IT_SHIELD_POSTURE); } return 1; @@ -5803,12 +5943,12 @@ s32 func_8083C2B0(Player* this, PlayState* play) { } s32 func_8083C484(Player* this, f32* arg1, s16* arg2) { - s16 yaw = this->currentYaw - *arg2; + s16 yaw = this->yaw - *arg2; if (ABS(yaw) > 0x6000) { if (func_8083721C(this)) { *arg1 = 0.0f; - *arg2 = this->currentYaw; + *arg2 = this->yaw; } else { return 1; } @@ -5823,7 +5963,7 @@ void func_8083C50C(Player* this) { } } -s32 func_8083C544(Player* this, PlayState* play) { +s32 Player_ActionChange_8(Player* this, PlayState* play) { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { if (!(this->stateFlags1 & PLAYER_STATE1_SHIELDING) && (Player_GetMeleeWeaponHeld(this) != 0) && (this->unk_844 == 1) && (this->heldItemAction != PLAYER_IA_DEKU_STICK)) { @@ -5842,7 +5982,7 @@ s32 func_8083C544(Player* this, PlayState* play) { s32 func_8083C61C(PlayState* play, Player* this) { if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (this->actor.bgCheckFlags & 1) && (AMMO(ITEM_NUT) != 0)) { - Player_SetupAction(play, this, func_8084E604, 0); + Player_SetupAction(play, this, Player_Action_8084E604, 0); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_light_bom); this->unk_6AD = 0; return 1; @@ -5861,15 +6001,15 @@ s32 func_8083C6B8(PlayState* play, Player* this) { if (sUseHeldItem) { if (Player_GetBottleHeld(this) >= 0) { - Player_SetupAction(play, this, func_8084ECA4, 0); + Player_SetupAction(play, this, Player_Action_8084ECA4, 0); if (this->actor.yDistToWater > 12.0f) { - this->unk_850 = 1; + this->av2.actionVar2 = 1; } - Player_AnimPlayOnceAdjusted(play, this, D_80854554[this->unk_850].unk_00); + Player_AnimPlayOnceAdjusted(play, this, D_80854554[this->av2.actionVar2].unk_00); - Player_PlaySfx(&this->actor, NA_SE_IT_SWORD_SWING); + Player_PlaySfx(this, NA_SE_IT_SWORD_SWING); func_80832698(this, NA_SE_VO_LI_AUTO_JUMP); return 1; } @@ -5886,7 +6026,7 @@ s32 func_8083C6B8(PlayState* play, Player* this) { return 0; } - Player_SetupAction(play, this, func_80850C68, 0); + Player_SetupAction(play, this, Player_Action_80850C68, 0); this->unk_860 = 1; Player_ZeroSpeedXZ(this); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_fishing_throw); @@ -5903,9 +6043,9 @@ void func_8083C858(Player* this, PlayState* play) { PlayerActionFunc actionFunc; if (func_80833BCC(this)) { - actionFunc = func_8084227C; + actionFunc = Player_Action_8084227C; } else { - actionFunc = func_80842180; + actionFunc = Player_Action_80842180; } Player_SetupAction(play, this, actionFunc, 1); @@ -5916,7 +6056,7 @@ void func_8083C858(Player* this, PlayState* play) { } void func_8083C8DC(Player* this, PlayState* play, s16 arg2) { - this->actor.shape.rot.y = this->currentYaw = arg2; + this->actor.shape.rot.y = this->yaw = arg2; func_8083C858(this, play); } @@ -5929,10 +6069,10 @@ s32 func_8083C910(PlayState* play, Player* this, f32 arg2) { &sp2C) != 0) { sp28 -= this->actor.world.pos.y; if (this->ageProperties->unk_24 <= sp28) { - Player_SetupAction(play, this, func_8084D7C4, 0); + Player_SetupAction(play, this, Player_Action_8084D7C4, 0); Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); this->stateFlags1 |= PLAYER_STATE1_IN_WATER | PLAYER_STATE1_IN_CUTSCENE; - this->unk_850 = 20; + this->av2.actionVar2 = 20; this->linearVelocity = 2.0f; Player_SetBootData(play, this); return 0; @@ -5946,7 +6086,7 @@ s32 func_8083C910(PlayState* play, Player* this, f32 arg2) { void func_8083CA20(PlayState* play, Player* this) { if (func_8083C910(play, this, 180.0f)) { - this->unk_850 = -20; + this->av2.actionVar2 = -20; } } @@ -5954,7 +6094,7 @@ void func_8083CA54(PlayState* play, Player* this) { this->linearVelocity = 2.0f; gSaveContext.entranceSpeed = 2.0f; if (func_8083C910(play, this, 120.0f)) { - this->unk_850 = -15; + this->av2.actionVar2 = -15; } } @@ -5966,47 +6106,47 @@ void func_8083CA9C(PlayState* play, Player* this) { this->linearVelocity = gSaveContext.entranceSpeed; if (func_8083C910(play, this, 800.0f)) { - this->unk_850 = -80 / this->linearVelocity; - if (this->unk_850 < -20) { - this->unk_850 = -20; + this->av2.actionVar2 = -80 / this->linearVelocity; + if (this->av2.actionVar2 < -20) { + this->av2.actionVar2 = -20; } } } void func_8083CB2C(Player* this, s16 yaw, PlayState* play) { - Player_SetupAction(play, this, func_808414F8, 1); + Player_SetupAction(play, this, Player_Action_808414F8, 1); LinkAnimation_CopyJointToMorph(play, &this->skelAnime); this->unk_864 = this->unk_868 = 0.0f; - this->currentYaw = yaw; + this->yaw = yaw; } void func_8083CB94(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80840DE4, 1); + Player_SetupAction(play, this, Player_Action_80840DE4, 1); Player_AnimChangeLoopMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_walk, this->modelAnimType)); } void func_8083CBF0(Player* this, s16 yaw, PlayState* play) { - Player_SetupAction(play, this, func_808423EC, 1); + Player_SetupAction(play, this, Player_Action_808423EC, 1); LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_anchor_back_walk, 2.2f, 0.0f, Animation_GetLastFrame(&gPlayerAnim_link_anchor_back_walk), ANIMMODE_ONCE, -6.0f); this->linearVelocity = 8.0f; - this->currentYaw = yaw; + this->yaw = yaw; } void func_8083CC9C(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_8084193C, 1); + Player_SetupAction(play, this, Player_Action_8084193C, 1); Player_AnimChangeLoopMorph(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_side_walkR, this->modelAnimType)); this->unk_868 = 0.0f; } void func_8083CD00(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_8084251C, 1); + Player_SetupAction(play, this, Player_Action_8084251C, 1); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, &gPlayerAnim_link_anchor_back_brake, 2.0f); } void func_8083CD54(PlayState* play, Player* this, s16 yaw) { - this->currentYaw = yaw; - Player_SetupAction(play, this, func_80841BA8, 1); + this->yaw = yaw; + Player_SetupAction(play, this, Player_Action_80841BA8, 1); this->unk_87E = 1200; this->unk_87E *= D_808535E8; LinkAnimation_Change(play, &this->skelAnime, D_80853914[PLAYER_ANIMGROUP_45_turn][this->modelAnimType], 1.0f, 0.0f, @@ -6016,7 +6156,7 @@ void func_8083CD54(PlayState* play, Player* this, s16 yaw) { void func_8083CE0C(Player* this, PlayState* play) { LinkAnimationHeader* anim; - Player_SetupAction(play, this, func_80840BC8, 1); + Player_SetupAction(play, this, Player_Action_80840BC8, 1); if (this->unk_870 < 0.5f) { anim = D_80853914[PLAYER_ANIMGROUP_waitR2wait][this->modelAnimType]; @@ -6025,13 +6165,13 @@ void func_8083CE0C(Player* this, PlayState* play) { } Player_AnimPlayOnce(play, this, anim); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } void func_8083CEAC(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80840450, 1); + Player_SetupAction(play, this, Player_Action_80840450, 1); Player_AnimChangeOnceMorph(play, this, D_80853914[PLAYER_ANIMGROUP_wait2waitR][this->modelAnimType]); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } void func_8083CF10(Player* this, PlayState* play) { @@ -6080,7 +6220,7 @@ void func_8083D0A8(PlayState* play, Player* this, f32 arg2) { func_80832340(play, this); if (func_8083CFA8(play, this, arg2, 500)) { - Player_PlaySfx(&this->actor, NA_SE_EV_JUMP_OUT_WATER); + Player_PlaySfx(this, NA_SE_EV_JUMP_OUT_WATER); } Player_SetBootData(play, this); @@ -6091,7 +6231,7 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { if ((arg2 == NULL) || (CHECK_BTN_ALL(arg2->press.button, BTN_A) && (ABS(this->unk_6C2) < 12000) && (this->currentBoots != PLAYER_BOOTS_IRON))) { - Player_SetupAction(play, this, func_8084DC48, 0); + Player_SetupAction(play, this, Player_Action_8084DC48, 0); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_swimer_swim_deep_start); this->unk_6C2 = 0; @@ -6100,7 +6240,7 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { if (arg2 != NULL) { this->stateFlags2 |= PLAYER_STATE2_DIVING; - Player_PlaySfx(&this->actor, NA_SE_PL_DIVE_BUBBLE); + Player_PlaySfx(this, NA_SE_PL_DIVE_BUBBLE); } return 1; @@ -6114,13 +6254,13 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { this->stateFlags2 &= ~PLAYER_STATE2_UNDERWATER; if (arg2 != NULL) { - Player_SetupAction(play, this, func_8084E1EC, 1); + Player_SetupAction(play, this, Player_Action_8084E1EC, 1); if (this->stateFlags1 & PLAYER_STATE1_GETTING_ITEM) { this->stateFlags1 |= PLAYER_STATE1_GETTING_ITEM | PLAYER_STATE1_ITEM_OVER_HEAD | PLAYER_STATE1_IN_CUTSCENE; } - this->unk_850 = 2; + this->av2.actionVar2 = 2; } func_80832340(play, this); @@ -6136,7 +6276,7 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { } if (func_8083CFA8(play, this, this->actor.velocity.y, 500)) { - Player_PlaySfx(&this->actor, NA_SE_PL_FACE_UP); + Player_PlaySfx(this, NA_SE_PL_FACE_UP); } return 1; @@ -6150,7 +6290,7 @@ s32 func_8083D12C(PlayState* play, Player* this, Input* arg2) { void func_8083D330(PlayState* play, Player* this) { Player_AnimPlayLoop(play, this, &gPlayerAnim_link_swimer_swim); this->unk_6C2 = 16000; - this->unk_850 = 1; + this->av2.actionVar2 = 1; } void func_8083D36C(PlayState* play, Player* this) { @@ -6160,12 +6300,12 @@ void func_8083D36C(PlayState* play, Player* this) { if ((this->currentBoots != PLAYER_BOOTS_IRON) && (this->stateFlags2 & PLAYER_STATE2_UNDERWATER)) { this->stateFlags2 &= ~PLAYER_STATE2_UNDERWATER; func_8083D12C(play, this, 0); - this->unk_84F = 1; - } else if (func_80844A44 == this->actionFunc) { - Player_SetupAction(play, this, func_8084DC48, 0); + this->av1.actionVar1 = 1; + } else if (Player_Action_80844A44 == this->actionFunc) { + Player_SetupAction(play, this, Player_Action_8084DC48, 0); func_8083D330(play, this); } else { - Player_SetupAction(play, this, func_8084D610, 1); + Player_SetupAction(play, this, Player_Action_8084D610, 1); Player_AnimChangeOnceMorph(play, this, (this->actor.bgCheckFlags & 1) ? &gPlayerAnim_link_swimer_wait2swim_wait : &gPlayerAnim_link_swimer_land2swim_wait); @@ -6174,7 +6314,7 @@ void func_8083D36C(PlayState* play, Player* this) { if (!(this->stateFlags1 & PLAYER_STATE1_IN_WATER) || (this->actor.yDistToWater < this->ageProperties->unk_2C)) { if (func_8083CFA8(play, this, this->actor.velocity.y, 500)) { - Player_PlaySfx(&this->actor, NA_SE_EV_DIVE_INTO_WATER); + Player_PlaySfx(this, NA_SE_EV_DIVE_INTO_WATER); if (this->fallDistance > 800.0f) { func_80832698(this, NA_SE_VO_LI_CLIMB_END); @@ -6201,14 +6341,14 @@ void func_8083D53C(PlayState* play, Player* this) { } } - if ((func_80845668 != this->actionFunc) && (func_8084BDFC != this->actionFunc)) { + if ((Player_Action_80845668 != this->actionFunc) && (Player_Action_8084BDFC != this->actionFunc)) { if (this->ageProperties->unk_2C < this->actor.yDistToWater) { if (!(this->stateFlags1 & PLAYER_STATE1_IN_WATER) || (!((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & 1)) && - (func_8084E30C != this->actionFunc) && (func_8084E368 != this->actionFunc) && - (func_8084D610 != this->actionFunc) && (func_8084D84C != this->actionFunc) && - (func_8084DAB4 != this->actionFunc) && (func_8084DC48 != this->actionFunc) && - (func_8084E1EC != this->actionFunc) && (func_8084D7C4 != this->actionFunc))) { + (Player_Action_8084E30C != this->actionFunc) && (Player_Action_8084E368 != this->actionFunc) && + (Player_Action_8084D610 != this->actionFunc) && (Player_Action_8084D84C != this->actionFunc) && + (Player_Action_8084DAB4 != this->actionFunc) && (Player_Action_8084DC48 != this->actionFunc) && + (Player_Action_8084E1EC != this->actionFunc) && (Player_Action_8084D7C4 != this->actionFunc))) { func_8083D36C(play, this); return; } @@ -6374,7 +6514,7 @@ void func_8083DDC8(Player* this, PlayState* play) { if (!func_8002DD78(this) && !func_808334B4(this) && (this->linearVelocity > 5.0f)) { temp1 = this->linearVelocity * 200.0f; - temp2 = (s16)(this->currentYaw - this->actor.shape.rot.y) * this->linearVelocity * 0.1f; + temp2 = (s16)(this->yaw - this->actor.shape.rot.y) * this->linearVelocity * 0.1f; temp1 = CLAMP(temp1, -4000, 4000); temp2 = CLAMP(-temp2, -4000, 4000); Math_ScaledStepToS(&this->unk_6BC, temp1, 900); @@ -6389,11 +6529,11 @@ void func_8083DDC8(Player* this, PlayState* play) { void func_8083DF68(Player* this, f32 arg1, s16 arg2) { Math_AsymStepToF(&this->linearVelocity, arg1, REG(19) / 100.0f, 1.5f); - Math_ScaledStepToS(&this->currentYaw, arg2, REG(27)); + Math_ScaledStepToS(&this->yaw, arg2, REG(27)); } void func_8083DFE0(Player* this, f32* arg1, s16* arg2) { - s16 yawDiff = this->currentYaw - *arg2; + s16 yawDiff = this->yaw - *arg2; if (this->meleeWeaponState == 0) { float maxSpeed = R_RUN_SPEED_LIMIT / 100.0f; @@ -6432,11 +6572,11 @@ void func_8083DFE0(Player* this, f32* arg1, s16* arg2) { if (ABS(yawDiff) > 0x6000) { if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = *arg2; + this->yaw = *arg2; } } else { Math_AsymStepToF(&this->linearVelocity, *arg1, 0.05f, 0.1f); - Math_ScaledStepToS(&this->currentYaw, *arg2, 200); + Math_ScaledStepToS(&this->yaw, *arg2, 200); } } @@ -6445,7 +6585,7 @@ static struct_80854578 D_80854578[] = { { &gPlayerAnim_link_uma_right_up, -34.16f, 7.91f }, }; -s32 func_8083E0FC(Player* this, PlayState* play) { +s32 Player_ActionChange_3(Player* this, PlayState* play) { EnHorse* rideActor = (EnHorse*)this->rideActor; f32 unk_04; f32 unk_08; @@ -6476,7 +6616,7 @@ s32 func_8083E0FC(Player* this, PlayState* play) { rideActor->actor.world.pos.z + rideActor->riderPos.z + ((unk_08 * sp38) - (unk_04 * sp34)); this->unk_878 = rideActor->actor.world.pos.y - this->actor.world.pos.y; - this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; Actor_MountHorse(play, this, &rideActor->actor); Player_AnimPlayOnce(play, this, D_80854578[temp].anim); @@ -6511,7 +6651,7 @@ s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly) f32 slopeSlowdownSpeedStep; s16 velYawToDownwardSlope; - if (!Player_InBlockingCsMode(play, this) && (func_8084F390 != this->actionFunc) && + if (!Player_InBlockingCsMode(play, this) && (Player_Action_8084F390 != this->actionFunc) && (SurfaceType_GetSlope(&play->colCtx, floorPoly, this->actor.floorBgId) == 1)) { playerVelYaw = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); Player_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw); @@ -6531,14 +6671,14 @@ s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly) Math_StepToF(&this->pushedSpeed, slopeSlowdownSpeed, slopeSlowdownSpeedStep); } else { // moving downward on the slope, causing player to slip - Player_SetupAction(play, this, func_8084F390, 0); + Player_SetupAction(play, this, Player_Action_8084F390, 0); func_80832564(play, this); if (sFloorShapePitch >= 0) { - this->unk_84F = 1; + this->av1.actionVar1 = 1; } - Player_AnimChangeLoopMorph(play, this, sSlopeSlipAnims[this->unk_84F]); + Player_AnimChangeLoopMorph(play, this, sSlopeSlipAnims[this->av1.actionVar1]); this->linearVelocity = sqrtf(SQ(this->actor.velocity.x) + SQ(this->actor.velocity.z)); - this->currentYaw = playerVelYaw; + this->yaw = playerVelYaw; return true; } } @@ -6605,13 +6745,15 @@ void Player_SetPendingFlag(Player* this, PlayState* play) { this->pendingFlag.flagID = 0; } -s32 func_8083E5A8(Player* this, PlayState* play) { +s32 Player_ActionChange_2(Player* this, PlayState* play) { Actor* interactedActor; if(gSaveContext.pendingIceTrapCount) { gSaveContext.pendingIceTrapCount--; GameInteractor_ExecuteOnItemReceiveHooks(ItemTable_RetrieveEntry(MOD_RANDOMIZER, RG_ICE_TRAP)); - if (CVarGetInteger("gAddTraps.enabled", 0)) return; + if (CVarGetInteger("gAddTraps.enabled", 0)) { + return 1; + } this->stateFlags1 &= ~(PLAYER_STATE1_GETTING_ITEM | PLAYER_STATE1_ITEM_OVER_HEAD); this->actor.colChkInfo.damage = 0; func_80837C0C(play, this, 3, 0.0f, 0.0f, 0, 20); @@ -6721,7 +6863,7 @@ s32 func_8083E5A8(Player* this, PlayState* play) { chest->dyna.actor.world.pos.x - (Math_SinS(chest->dyna.actor.shape.rot.y) * 29.4343f); this->actor.world.pos.z = chest->dyna.actor.world.pos.z - (Math_CosS(chest->dyna.actor.shape.rot.y) * 29.4343f); - this->currentYaw = this->actor.shape.rot.y = chest->dyna.actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y = chest->dyna.actor.shape.rot.y; func_80832224(this); if ((giEntry.itemId != ITEM_NONE) && (giEntry.gi >= 0) && @@ -6775,7 +6917,7 @@ s32 func_8083E5A8(Player* this, PlayState* play) { } void func_8083EA94(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80846578, 1); + Player_SetupAction(play, this, Player_Action_80846578, 1); Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_throw, this->modelAnimType)); } @@ -6788,7 +6930,7 @@ s32 func_8083EAF0(Player* this, Actor* actor) { return 1; } -s32 func_8083EB44(Player* this, PlayState* play) { +s32 Player_ActionChange_9(Player* this, PlayState* play) { u16 buttonsToCheck = BTN_A | BTN_B | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN; if (CVarGetInteger("gDpadEquips", 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; @@ -6797,7 +6939,7 @@ s32 func_8083EB44(Player* this, PlayState* play) { CHECK_BTN_ANY(sControlInput->press.button, buttonsToCheck)) { if (!func_80835644(play, this, this->heldActor)) { if (!func_8083EAF0(this, this->heldActor)) { - Player_SetupAction(play, this, func_808464B0, 1); + Player_SetupAction(play, this, Player_Action_808464B0, 1); Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_put, this->modelAnimType)); } else { func_8083EA94(this, play); @@ -6882,24 +7024,24 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 wallFlags) { this->stateFlags1 &= ~PLAYER_STATE1_IN_WATER; if ((sp8C != 0) || (wallFlags & 2)) { - if ((this->unk_84F = sp8C) != 0) { + if ((this->av1.actionVar1 = sp8C) != 0) { if (this->actor.bgCheckFlags & 1) { anim = &gPlayerAnim_link_normal_Fclimb_startA; } else { anim = &gPlayerAnim_link_normal_Fclimb_hold2upL; } - sp34 = (this->ageProperties->unk_38 - 1.0f) - sp34; + sp34 = (this->ageProperties->wallCheckRadius - 1.0f) - sp34; } else { anim = this->ageProperties->unk_A4; sp34 = sp34 - 1.0f; } - this->unk_850 = -2; + this->av2.actionVar2 = -2; this->actor.world.pos.y += phi_f20; - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; + this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; } else { anim = this->ageProperties->unk_A8; - this->unk_850 = -4; - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw; + this->av2.actionVar2 = -4; + this->actor.shape.rot.y = this->yaw = this->actor.wallYaw; } this->actor.world.pos.x = (sp34 * wallPolyNormalX) + sp80; @@ -6919,7 +7061,7 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 wallFlags) { } void func_8083F070(Player* this, LinkAnimationHeader* anim, PlayState* play) { - func_80835DAC(play, this, func_8084C5F8, 0); + func_80835DAC(play, this, Player_Action_8084C5F8, 0); LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, (4.0f / 3.0f)); } @@ -6981,7 +7123,7 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall func_80836898(play, this, func_8083A40C); this->stateFlags2 |= PLAYER_STATE2_CRAWLING; - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; + this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; this->actor.world.pos.x = xVertex1 + (distToInteractWall * wallPolyNormX); this->actor.world.pos.z = zVertex1 + (distToInteractWall * wallPolyNormZ); func_80832224(this); @@ -7042,7 +7184,7 @@ s32 func_8083F360(PlayState* play, Player* this, f32 arg1, f32 arg2, f32 arg3, f temp = Math_Atan2S(-temp2, -temp1); Math_ScaledStepToS(&this->actor.shape.rot.y, temp, 800); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; this->actor.world.pos.x = sp54.x - (Math_SinS(this->actor.shape.rot.y) * arg2); this->actor.world.pos.z = sp54.z - (Math_CosS(this->actor.shape.rot.y) * arg2); @@ -7055,7 +7197,7 @@ s32 func_8083F360(PlayState* play, Player* this, f32 arg1, f32 arg2, f32 arg3, f } s32 func_8083F524(PlayState* play, Player* this) { - return func_8083F360(play, this, 26.0f, this->ageProperties->unk_38 + 5.0f, 30.0f, 0.0f); + return func_8083F360(play, this, 26.0f, this->ageProperties->wallCheckRadius + 5.0f, 30.0f, 0.0f); } /** @@ -7075,7 +7217,7 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { } if (ABS(temp) > 0x4000) { - Player_SetupAction(play, this, func_8084C81C, 0); + Player_SetupAction(play, this, Player_Action_8084C81C, 0); if (this->linearVelocity > 0.0f) { this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; @@ -7114,7 +7256,7 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { } } - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; Player_ZeroSpeedXZ(this); return 1; @@ -7126,16 +7268,16 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { void func_8083F72C(Player* this, LinkAnimationHeader* anim, PlayState* play) { if (!func_80836898(play, this, func_8083A388)) { - Player_SetupAction(play, this, func_8084B78C, 0); + Player_SetupAction(play, this, Player_Action_8084B78C, 0); } Player_AnimPlayOnce(play, this, anim); func_80832224(this); - this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; + this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; } -s32 func_8083F7BC(Player* this, PlayState* play) { +s32 Player_ActionChange_5(Player* this, PlayState* play) { DynaPolyActor* wallPolyActor; if (!(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) && (this->actor.bgCheckFlags & 0x200) && (sShapeYawToTouchedWall < 0x3000)) { @@ -7165,7 +7307,7 @@ s32 func_8083F7BC(Player* this, PlayState* play) { this->interactRangeActor = &wallPolyActor->actor; this->getItemId = GI_NONE; this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; - this->currentYaw = this->actor.wallYaw + 0x8000; + this->yaw = this->actor.wallYaw + 0x8000; func_80832224(this); return 1; @@ -7211,13 +7353,13 @@ s32 func_8083F9D0(PlayState* play, Player* this) { } void func_8083FAB8(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_8084B898, 0); + Player_SetupAction(play, this, Player_Action_8084B898, 0); this->stateFlags2 |= PLAYER_STATE2_MOVING_DYNAPOLY; Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_push_start); } void func_8083FB14(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_8084B9E4, 0); + Player_SetupAction(play, this, Player_Action_8084B9E4, 0); this->stateFlags2 |= PLAYER_STATE2_MOVING_DYNAPOLY; Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_pull_start, this->modelAnimType)); } @@ -7260,7 +7402,7 @@ s32 func_8083FC68(Player* this, f32 arg1, s16 arg2) { } s32 func_8083FD78(Player* this, f32* arg1, s16* arg2, PlayState* play) { - s16 sp2E = *arg2 - this->targetYaw; + s16 sp2E = *arg2 - this->zTargetYaw; u16 sp2C = ABS(sp2E); if ((func_8002DD78(this) || func_808334B4(this)) && (this->unk_664 == NULL)) { @@ -7425,9 +7567,9 @@ void func_8084029C(Player* this, f32 arg1) { } } -void func_80840450(Player* this, PlayState* play) { - f32 sp44; - s16 sp42; +void Player_Action_80840450(Player* this, PlayState* play) { + f32 speedTarget; + s16 yawTarget; s32 temp1; u32 temp2; s16 temp3; @@ -7441,11 +7583,11 @@ void func_80840450(Player* this, PlayState* play) { } } - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80832DBC(this); Player_AnimPlayLoop(play, this, func_808334E4(this)); - this->unk_850 = 0; + this->av2.actionVar2 = 0; this->stateFlags3 &= ~PLAYER_STATE3_FINISHED_ATTACKING; } func_80833C3C(this); @@ -7455,33 +7597,33 @@ void func_80840450(Player* this, PlayState* play) { func_8083721C(this); - if (!Player_TryActionChangeList(play, this, D_808543E0, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList1, true)) { if (!func_80833B54(this) && (!func_80833B2C(this) || (func_80834B5C != this->upperActionFunc))) { func_8083CF10(this, play); return; } - Player_GetMovementSpeedAndYaw(this, &sp44, &sp42, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); - temp1 = func_8083FC68(this, sp44, sp42); + temp1 = func_8083FC68(this, speedTarget, yawTarget); if (temp1 > 0) { - func_8083C8DC(this, play, sp42); + func_8083C8DC(this, play, yawTarget); return; } if (temp1 < 0) { - func_8083CBF0(this, sp42, play); + func_8083CBF0(this, yawTarget, play); return; } - if (sp44 > 4.0f) { + if (speedTarget > 4.0f) { func_8083CC9C(this, play); return; } func_8084029C(this, (this->linearVelocity * 0.3f) + 1.0f); - func_80840138(this, sp44, sp42); + func_80840138(this, speedTarget, yawTarget); temp2 = this->unk_868; if ((temp2 < 6) || ((temp2 - 0xE) < 6)) { @@ -7489,27 +7631,27 @@ void func_80840450(Player* this, PlayState* play) { return; } - temp3 = sp42 - this->currentYaw; + temp3 = yawTarget - this->yaw; temp4 = ABS(temp3); if (temp4 > 0x4000) { if (Math_StepToF(&this->linearVelocity, 0.0f, 1.5f)) { - this->currentYaw = sp42; + this->yaw = yawTarget; } return; } - Math_AsymStepToF(&this->linearVelocity, sp44 * 0.3f, 2.0f, 1.5f); + Math_AsymStepToF(&this->linearVelocity, speedTarget * 0.3f, 2.0f, 1.5f); if (!(this->stateFlags3 & PLAYER_STATE3_FINISHED_ATTACKING)) { - Math_ScaledStepToS(&this->currentYaw, sp42, temp4 * 0.1f); + Math_ScaledStepToS(&this->yaw, yawTarget, temp4 * 0.1f); } } } -void func_808407CC(Player* this, PlayState* play) { - f32 sp3C; - s16 sp3A; +void Player_Action_808407CC(Player* this, PlayState* play) { + f32 speedTarget; + s16 yawTarget; s32 temp1; s16 temp2; s32 temp3; @@ -7521,15 +7663,15 @@ void func_808407CC(Player* this, PlayState* play) { func_8083721C(this); - if (!Player_TryActionChangeList(play, this, D_808543E8, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList2, true)) { if (func_80833B54(this)) { func_8083CEAC(this, play); return; } if (!func_80833B2C(this)) { - func_80835DAC(play, this, func_80840BC8, 1); - this->currentYaw = this->actor.shape.rot.y; + func_80835DAC(play, this, Player_Action_80840BC8, 1); + this->yaw = this->actor.shape.rot.y; return; } @@ -7538,35 +7680,35 @@ void func_808407CC(Player* this, PlayState* play) { return; } - Player_GetMovementSpeedAndYaw(this, &sp3C, &sp3A, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); - temp1 = func_8083FD78(this, &sp3C, &sp3A, play); + temp1 = func_8083FD78(this, &speedTarget, &yawTarget, play); if (temp1 > 0) { - func_8083C8DC(this, play, sp3A); + func_8083C8DC(this, play, yawTarget); return; } if (temp1 < 0) { - func_8083CB2C(this, sp3A, play); + func_8083CB2C(this, yawTarget, play); return; } - if (sp3C > 4.9f) { + if (speedTarget > 4.9f) { func_8083CC9C(this, play); func_80833C3C(this); return; } - if (sp3C != 0.0f) { + if (speedTarget != 0.0f) { func_8083CB94(this, play); return; } - temp2 = sp3A - this->actor.shape.rot.y; + temp2 = yawTarget - this->actor.shape.rot.y; temp3 = ABS(temp2); if (temp3 > 800) { - func_8083CD54(play, this, sp3A); + func_8083CD54(play, this, yawTarget); } } } @@ -7619,11 +7761,11 @@ void func_808409CC(PlayState* play, Player* this) { Animation_GetLastFrame(anim), ANIMMODE_ONCE, -6.0f); } -void func_80840BC8(Player* this, PlayState* play) { +void Player_Action_80840BC8(Player* this, PlayState* play) { s32 sp44; s32 sp40; - f32 sp3C; - s16 sp3A; + f32 speedTarget; + s16 yawTarget; s16 temp; sp44 = func_80833350(this); @@ -7634,11 +7776,11 @@ void func_80840BC8(Player* this, PlayState* play) { } if (sp40 != 0) { - if (this->unk_850 != 0) { - if (DECR(this->unk_850) == 0) { + if (this->av2.actionVar2 != 0) { + if (DECR(this->av2.actionVar2) == 0) { this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; } - this->skelAnime.jointTable[0].y = (this->skelAnime.jointTable[0].y + ((this->unk_850 & 1) * 0x50)) - 0x28; + this->skelAnime.jointTable[0].y = (this->skelAnime.jointTable[0].y + ((this->av2.actionVar2 & 1) * 0x50)) - 0x28; } else { func_80832DBC(this); func_808409CC(play, this); @@ -7647,8 +7789,8 @@ void func_80840BC8(Player* this, PlayState* play) { func_8083721C(this); - if (this->unk_850 == 0) { - if (!Player_TryActionChangeList(play, this, D_80854418, 1)) { + if (this->av2.actionVar2 == 0) { + if (!Player_TryActionChangeList(play, this, sActionChangeList7, true)) { if (func_80833B54(this)) { func_8083CEAC(this, play); return; @@ -7659,21 +7801,21 @@ void func_80840BC8(Player* this, PlayState* play) { return; } - Player_GetMovementSpeedAndYaw(this, &sp3C, &sp3A, 0.018f, play); + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_CURVED, play); - if (sp3C != 0.0f) { - func_8083C8DC(this, play, sp3A); + if (speedTarget != 0.0f) { + func_8083C8DC(this, play, yawTarget); return; } - temp = sp3A - this->actor.shape.rot.y; + temp = yawTarget - this->actor.shape.rot.y; if (ABS(temp) > 800) { - func_8083CD54(play, this, sp3A); + func_8083CD54(play, this, yawTarget); return; } - Math_ScaledStepToS(&this->actor.shape.rot.y, sp3A, 1200); - this->currentYaw = this->actor.shape.rot.y; + Math_ScaledStepToS(&this->actor.shape.rot.y, yawTarget, 1200); + this->yaw = this->actor.shape.rot.y; if (func_80833338(this) == this->skelAnime.animation) { func_8083DC54(this, play); } @@ -7681,11 +7823,11 @@ void func_80840BC8(Player* this, PlayState* play) { } } -void func_80840DE4(Player* this, PlayState* play) { +void Player_Action_80840DE4(Player* this, PlayState* play) { f32 frames; f32 coeff; - f32 sp44; - s16 sp42; + f32 speedTarget; + s16 yawTarget; s32 temp1; s16 temp2; s32 temp3; @@ -7707,7 +7849,7 @@ void func_80840DE4(Player* this, PlayState* play) { this->skelAnime.animLength = frames; this->skelAnime.endFrame = frames - 1.0f; - if ((s16)(this->currentYaw - this->actor.shape.rot.y) >= 0) { + if ((s16)(this->yaw - this->actor.shape.rot.y) >= 0) { direction = 1; } else { direction = -1; @@ -7721,7 +7863,7 @@ void func_80840DE4(Player* this, PlayState* play) { func_808327F8(this, this->linearVelocity); } - if (!Player_TryActionChangeList(play, this, D_808543F4, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList3, true)) { if (func_80833B54(this)) { func_8083CEAC(this, play); return; @@ -7732,42 +7874,42 @@ void func_80840DE4(Player* this, PlayState* play) { return; } - Player_GetMovementSpeedAndYaw(this, &sp44, &sp42, 0.0f, play); - temp1 = func_8083FD78(this, &sp44, &sp42, play); + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); + temp1 = func_8083FD78(this, &speedTarget, &yawTarget, play); if (temp1 > 0) { - func_8083C8DC(this, play, sp42); + func_8083C8DC(this, play, yawTarget); return; } if (temp1 < 0) { - func_8083CB2C(this, sp42, play); + func_8083CB2C(this, yawTarget, play); return; } - if (sp44 > 4.9f) { + if (speedTarget > 4.9f) { func_8083CC9C(this, play); func_80833C3C(this); return; } - if ((sp44 == 0.0f) && (this->linearVelocity == 0.0f)) { + if ((speedTarget == 0.0f) && (this->linearVelocity == 0.0f)) { func_80839F30(this, play); return; } - temp2 = sp42 - this->currentYaw; + temp2 = yawTarget - this->yaw; temp3 = ABS(temp2); if (temp3 > 0x4000) { if (Math_StepToF(&this->linearVelocity, 0.0f, 1.5f)) { - this->currentYaw = sp42; + this->yaw = yawTarget; } return; } - Math_AsymStepToF(&this->linearVelocity, sp44 * 0.4f, 1.5f, 1.5f); - Math_ScaledStepToS(&this->currentYaw, sp42, temp3 * 0.1f); + Math_AsymStepToF(&this->linearVelocity, speedTarget * 0.4f, 1.5f, 1.5f); + Math_ScaledStepToS(&this->yaw, yawTarget, temp3 * 0.1f); } } @@ -7813,7 +7955,7 @@ void func_80841138(Player* this, PlayState* play) { } void func_8084140C(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_8084170C, 1); + Player_SetupAction(play, this, Player_Action_8084170C, 1); Player_AnimChangeOnceMorph(play, this, &gPlayerAnim_link_normal_back_brake); } @@ -7826,7 +7968,7 @@ s32 func_80841458(Player* this, f32* arg1, s16* arg2, PlayState* play) { if (*arg1 != 0.0f) { if (func_8083721C(this)) { *arg1 = 0.0f; - *arg2 = this->currentYaw; + *arg2 = this->yaw; } else { return 1; } @@ -7835,40 +7977,40 @@ s32 func_80841458(Player* this, f32* arg1, s16* arg2, PlayState* play) { return 0; } -void func_808414F8(Player* this, PlayState* play) { - f32 sp34; - s16 sp32; +void Player_Action_808414F8(Player* this, PlayState* play) { + f32 speedTarget; + s16 yawTarget; s32 sp2C; s16 sp2A; func_80841138(this, play); - if (!Player_TryActionChangeList(play, this, D_80854400, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList4, true)) { if (!func_80833C04(this)) { - func_8083C8DC(this, play, this->currentYaw); + func_8083C8DC(this, play, this->yaw); return; } - Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.0f, play); - sp2C = func_8083FD78(this, &sp34, &sp32, play); + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); + sp2C = func_8083FD78(this, &speedTarget, &yawTarget, play); if (sp2C >= 0) { - if (!func_80841458(this, &sp34, &sp32, play)) { + if (!func_80841458(this, &speedTarget, &yawTarget, play)) { if (sp2C != 0) { func_8083C858(this, play); - } else if (sp34 > 4.9f) { + } else if (speedTarget > 4.9f) { func_8083CC9C(this, play); } else { func_8083CB94(this, play); } } } else { - sp2A = sp32 - this->currentYaw; + sp2A = yawTarget - this->yaw; - Math_AsymStepToF(&this->linearVelocity, sp34 * 1.5f, 1.5f, 2.0f); - Math_ScaledStepToS(&this->currentYaw, sp32, sp2A * 0.1f); + Math_AsymStepToF(&this->linearVelocity, speedTarget * 1.5f, 1.5f, 2.0f); + Math_ScaledStepToS(&this->yaw, yawTarget, sp2A * 0.1f); - if ((sp34 == 0.0f) && (this->linearVelocity == 0.0f)) { + if ((speedTarget == 0.0f) && (this->linearVelocity == 0.0f)) { func_80839F30(this, play); } } @@ -7876,39 +8018,39 @@ void func_808414F8(Player* this, PlayState* play) { } void func_808416C0(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_808417FC, 1); + Player_SetupAction(play, this, Player_Action_808417FC, 1); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_back_brake_end); } -void func_8084170C(Player* this, PlayState* play) { +void Player_Action_8084170C(Player* this, PlayState* play) { s32 sp34; - f32 sp30; - s16 sp2E; + f32 speedTarget; + s16 yawTarget; sp34 = LinkAnimation_Update(play, &this->skelAnime); func_8083721C(this); - if (!Player_TryActionChangeList(play, this, D_80854400, 1)) { - Player_GetMovementSpeedAndYaw(this, &sp30, &sp2E, 0.0f, play); + if (!Player_TryActionChangeList(play, this, sActionChangeList4, true)) { + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); if (this->linearVelocity == 0.0f) { - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; - if (func_8083FD78(this, &sp30, &sp2E, play) > 0) { + if (func_8083FD78(this, &speedTarget, &yawTarget, play) > 0) { func_8083C858(this, play); - } else if ((sp30 != 0.0f) || (sp34 != 0)) { + } else if ((speedTarget != 0.0f) || (sp34 != 0)) { func_808416C0(this, play); } } } } -void func_808417FC(Player* this, PlayState* play) { +void Player_Action_808417FC(Player* this, PlayState* play) { s32 sp1C; sp1C = LinkAnimation_Update(play, &this->skelAnime); - if (!Player_TryActionChangeList(play, this, D_80854400, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList4, true)) { if (sp1C != 0) { func_80839F30(this, play); } @@ -7929,27 +8071,27 @@ void func_80841860(PlayState* play, Player* this) { LinkAnimation_BlendToJoint(play, &this->skelAnime, sp34, frame, sp38, frame, this->unk_870, this->blendTable); } -void func_8084193C(Player* this, PlayState* play) { - f32 sp3C; - s16 sp3A; +void Player_Action_8084193C(Player* this, PlayState* play) { + f32 speedTarget; + s16 yawTarget; s32 temp1; s16 temp2; s32 temp3; func_80841860(play, this); - if (!Player_TryActionChangeList(play, this, D_80854408, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList5, true)) { if (!func_80833C04(this)) { func_8083C858(this, play); return; } - Player_GetMovementSpeedAndYaw(this, &sp3C, &sp3A, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); if (func_80833B2C(this)) { - temp1 = func_8083FD78(this, &sp3C, &sp3A, play); + temp1 = func_8083FD78(this, &speedTarget, &yawTarget, play); } else { - temp1 = func_8083FC68(this, sp3C, sp3A); + temp1 = func_8083FC68(this, speedTarget, yawTarget); } if (temp1 > 0) { @@ -7959,14 +8101,14 @@ void func_8084193C(Player* this, PlayState* play) { if (temp1 < 0) { if (func_80833B2C(this)) { - func_8083CB2C(this, sp3A, play); + func_8083CB2C(this, yawTarget, play); } else { - func_8083CBF0(this, sp3A, play); + func_8083CBF0(this, yawTarget, play); } return; } - if ((this->linearVelocity < 3.6f) && (sp3C < 4.0f)) { + if ((this->linearVelocity < 3.6f) && (speedTarget < 4.0f)) { if (!func_8008E9C4(this) && func_80833B2C(this)) { func_8083CB94(this, play); } else { @@ -7975,25 +8117,25 @@ void func_8084193C(Player* this, PlayState* play) { return; } - func_80840138(this, sp3C, sp3A); + func_80840138(this, speedTarget, yawTarget); - temp2 = sp3A - this->currentYaw; + temp2 = yawTarget - this->yaw; temp3 = ABS(temp2); if (temp3 > 0x4000) { if (Math_StepToF(&this->linearVelocity, 0.0f, 3.0f) != 0) { - this->currentYaw = sp3A; + this->yaw = yawTarget; } return; } - sp3C *= 0.9f; - Math_AsymStepToF(&this->linearVelocity, sp3C, 2.0f, 3.0f); - Math_ScaledStepToS(&this->currentYaw, sp3A, temp3 * 0.1f); + speedTarget *= 0.9f; + Math_AsymStepToF(&this->linearVelocity, speedTarget, 2.0f, 3.0f); + Math_ScaledStepToS(&this->yaw, yawTarget, temp3 * 0.1f); } } -void func_80841BA8(Player* this, PlayState* play) { +void Player_Action_80841BA8(Player* this, PlayState* play) { f32 sp34; s16 sp32; @@ -8006,9 +8148,9 @@ void func_80841BA8(Player* this, PlayState* play) { this->skelAnime.morphTable, sUpperBodyLimbCopyMap); } - Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.018f, play); + Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, SPEED_MODE_CURVED, play); - if (!Player_TryActionChangeList(play, this, D_80854414, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList6, true)) { if (sp34 != 0.0f) { this->actor.shape.rot.y = sp32; func_8083C858(this, play); @@ -8016,7 +8158,7 @@ void func_80841BA8(Player* this, PlayState* play) { func_8083C0E8(this, play); } - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } } @@ -8118,20 +8260,20 @@ void func_80841EE4(Player* this, PlayState* play) { } } -void func_80842180(Player* this, PlayState* play) { +void Player_Action_80842180(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; func_80841EE4(this, play); - if (!Player_TryActionChangeList(play, this, D_80854424, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList8, true)) { if (func_80833C04(this)) { func_8083C858(this, play); return; } - Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, 0.018f, play); + Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, SPEED_MODE_CURVED, play); if (!func_8083C484(this, &sp2C, &sp2A)) { int32_t giSpeedModifier = GameInteractor_RunSpeedModifier(); @@ -8173,20 +8315,20 @@ void func_80842180(Player* this, PlayState* play) { } } -void func_8084227C(Player* this, PlayState* play) { +void Player_Action_8084227C(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; func_80841EE4(this, play); - if (!Player_TryActionChangeList(play, this, D_80854430, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList9, true)) { if (!func_80833C04(this)) { func_8083C858(this, play); return; } - Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, SPEED_MODE_LINEAR, play); if (!func_8083C484(this, &sp2C, &sp2A)) { if ((func_80833B2C(this) && (sp2C != 0.0f) && (func_8083FD78(this, &sp2C, &sp2A, play) <= 0)) || @@ -8205,20 +8347,20 @@ void func_8084227C(Player* this, PlayState* play) { } } -void func_808423EC(Player* this, PlayState* play) { +void Player_Action_808423EC(Player* this, PlayState* play) { s32 sp34; f32 sp30; s16 sp2E; sp34 = LinkAnimation_Update(play, &this->skelAnime); - if (!Player_TryActionChangeList(play, this, D_80854408, 1)) { + if (!Player_TryActionChangeList(play, this, sActionChangeList5, true)) { if (!func_80833C04(this)) { func_8083C858(this, play); return; } - Player_GetMovementSpeedAndYaw(this, &sp30, &sp2E, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp30, &sp2E, SPEED_MODE_LINEAR, play); if ((this->skelAnime.morphWeight == 0.0f) && (this->skelAnime.curFrame > 5.0f)) { func_8083721C(this); @@ -8235,27 +8377,27 @@ void func_808423EC(Player* this, PlayState* play) { } } -void func_8084251C(Player* this, PlayState* play) { +void Player_Action_8084251C(Player* this, PlayState* play) { s32 sp34; - f32 sp30; - s16 sp2E; + f32 speedTarget; + s16 yawTarget; sp34 = LinkAnimation_Update(play, &this->skelAnime); func_8083721C(this); - if (!Player_TryActionChangeList(play, this, D_80854440, 1)) { - Player_GetMovementSpeedAndYaw(this, &sp30, &sp2E, 0.0f, play); + if (!Player_TryActionChangeList(play, this, sActionChangeList10, true)) { + Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_LINEAR, play); if (this->linearVelocity == 0.0f) { - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; - if (func_8083FC68(this, sp30, sp2E) > 0) { + if (func_8083FC68(this, speedTarget, yawTarget) > 0) { func_8083C858(this, play); return; } - if ((sp30 != 0.0f) || (sp34 != 0)) { + if ((speedTarget != 0.0f) || (sp34 != 0)) { func_80839F90(this, play); } } @@ -8287,11 +8429,11 @@ s32 func_8084269C(PlayState* play, Player* this) { return 0; } -void func_8084279C(Player* this, PlayState* play) { +void Player_Action_8084279C(Player* this, PlayState* play) { func_80832CB0(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_check_wait, this->modelAnimType)); - if (DECR(this->unk_850) == 0) { - if (!func_8083B040(this, play)) { + if (DECR(this->av2.actionVar2) == 0) { + if (!Player_ActionChange_13(this, play)) { func_8083A098(this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_check_end, this->modelAnimType), play); } @@ -8316,9 +8458,9 @@ s32 func_808428D8(Player* this, PlayState* play) { } Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_defense_kiru); - this->unk_84F = 1; + this->av1.actionVar1 = 1; this->meleeWeaponAnimation = PLAYER_MWA_STAB_1H; - this->currentYaw = this->actor.shape.rot.y + this->unk_6BE; + this->yaw = this->actor.shape.rot.y + this->unk_6BE; if (!CVarGetInteger("gCrouchStabHammerFix", 0)) { return 1; @@ -8343,22 +8485,22 @@ s32 func_808428D8(Player* this, PlayState* play) { } s32 func_80842964(Player* this, PlayState* play) { - return func_8083B040(this, play) || func_8083B644(this, play) || func_8083E5A8(this, play); + return Player_ActionChange_13(this, play) || Player_ActionChange_4(this, play) || Player_ActionChange_2(this, play); } void Player_RequestQuake(PlayState* play, s32 speed, s32 y, s32 countdown) { - s32 quakeIdx = Quake_Add(Play_GetCamera(play, 0), 3); + s32 quakeIndex = Quake_Add(Play_GetCamera(play, 0), 3); - Quake_SetSpeed(quakeIdx, speed); - Quake_SetQuakeValues(quakeIdx, y, 0, 0, 0); - Quake_SetCountdown(quakeIdx, countdown); + Quake_SetSpeed(quakeIndex, speed); + Quake_SetQuakeValues(quakeIndex, y, 0, 0, 0); + Quake_SetCountdown(quakeIndex, countdown); } void func_80842A28(PlayState* play, Player* this) { Player_RequestQuake(play, 27767, 7, 20); play->actorCtx.unk_02 = 4; Player_RequestRumble(this, 255, 20, 150, 0); - Player_PlaySfx(&this->actor, NA_SE_IT_HAMMER_HIT); + Player_PlaySfx(this, NA_SE_IT_HAMMER_HIT); } void func_80842A88(PlayState* play, Player* this) { @@ -8375,7 +8517,7 @@ s32 func_80842AC4(PlayState* play, Player* this) { this->actor.shape.rot.y + 0x8000); this->unk_85C = 0.5f; func_80842A88(play, this); - Player_PlaySfx(&this->actor, NA_SE_IT_WOODSTICK_BROKEN); + Player_PlaySfx(this, NA_SE_IT_WOODSTICK_BROKEN); } return 1; @@ -8391,7 +8533,7 @@ s32 func_80842B7C(PlayState* play, Player* this) { EffectSsStick_Spawn(play, &this->bodyPartsPos[PLAYER_BODYPART_R_HAND], this->actor.shape.rot.y + 0x8000); func_800849EC(play); - Player_PlaySfx(&this->actor, NA_SE_IT_MAJIN_SWORD_BROKEN); + Player_PlaySfx(this, NA_SE_IT_MAJIN_SWORD_BROKEN); } } @@ -8417,9 +8559,9 @@ void func_80842D20(PlayState* play, Player* this) { s32 pad; s32 sp28; - if (func_80843188 != this->actionFunc) { + if (Player_Action_80843188 != this->actionFunc) { func_80832440(play, this); - Player_SetupAction(play, this, func_808505DC, 0); + Player_SetupAction(play, this, Player_Action_808505DC, 0); if (func_8008E9C4(this)) { sp28 = 2; @@ -8480,9 +8622,9 @@ s32 func_80842DF4(PlayState* play, Player* this) { } else { CollisionCheck_SpawnShieldParticles(play, &sp5C); if (sp48 == 0xB) { - Player_PlaySfx(&this->actor, NA_SE_IT_WALL_HIT_SOFT); + Player_PlaySfx(this, NA_SE_IT_WALL_HIT_SOFT); } else { - Player_PlaySfx(&this->actor, NA_SE_IT_WALL_HIT_HARD); + Player_PlaySfx(this, NA_SE_IT_WALL_HIT_HARD); } } @@ -8525,7 +8667,7 @@ s32 func_80842DF4(PlayState* play, Player* this) { return 0; } -void func_80843188(Player* this, PlayState* play) { +void Player_Action_80843188(Player* this, PlayState* play) { f32 sp54; f32 sp50; s16 sp4E; @@ -8539,8 +8681,8 @@ void func_80843188(Player* this, PlayState* play) { if (!Player_IsChildWithHylianShield(this)) { Player_AnimPlayLoop(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_defense_wait, this->modelAnimType)); } - this->unk_850 = 1; - this->unk_84F = 0; + this->av2.actionVar2 = 1; + this->av1.actionVar1 = 0; } if (!Player_IsChildWithHylianShield(this)) { @@ -8551,7 +8693,7 @@ void func_80843188(Player* this, PlayState* play) { func_8083721C(this); - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { sp54 = sControlInput->rel.stick_y * 100 * (CVarGetInteger("gInvertShieldAimingYAxis", 1) ? 1 : -1); sp50 = sControlInput->rel.stick_x * (CVarGetInteger("gMirroredWorld", 0) ? 120 : -120) * (CVarGetInteger("gInvertShieldAimingXAxis", 0) ? -1 : 1); sp4E = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play)); @@ -8579,17 +8721,17 @@ void func_80843188(Player* this, PlayState* play) { this->unk_6BC = this->actor.focus.rot.x; Math_ScaledStepToS(&this->unk_6BE, sp4A, sp46); - if (this->unk_84F != 0) { + if (this->av1.actionVar1 != 0) { if (!func_80842DF4(play, this)) { if (this->skelAnime.curFrame < 2.0f) { func_80833A20(this, 1); } } else { - this->unk_850 = 1; - this->unk_84F = 0; + this->av2.actionVar2 = 1; + this->av1.actionVar1 = 0; } } else if (!func_80842964(this, play)) { - if (func_8083C2B0(this, play)) { + if (Player_ActionChange_11(this, play)) { func_808428D8(this, play); } else { this->stateFlags1 &= ~PLAYER_STATE1_SHIELDING; @@ -8608,7 +8750,7 @@ void func_80843188(Player* this, PlayState* play) { func_8083A098(this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_defense_end, this->modelAnimType), play); } - Player_PlaySfx(&this->actor, NA_SE_IT_SHIELD_REMOVE); + Player_PlaySfx(this, NA_SE_IT_SHIELD_REMOVE); return; } } else { @@ -8622,22 +8764,22 @@ void func_80843188(Player* this, PlayState* play) { this->unk_6AE |= 0xC1; } -void func_808435C4(Player* this, PlayState* play) { +void Player_Action_808435C4(Player* this, PlayState* play) { s32 temp; LinkAnimationHeader* anim; f32 frames; func_8083721C(this); - if (this->unk_84F == 0) { + if (this->av1.actionVar1 == 0) { D_808535E0 = Player_UpdateUpperBody(this, play); if ((func_80834B5C == this->upperActionFunc) || (func_808374A0(play, this, &this->upperSkelAnime, 4.0f) > 0)) { - Player_SetupAction(play, this, func_80840450, 1); + Player_SetupAction(play, this, Player_Action_80840450, 1); } } else { temp = func_808374A0(play, this, &this->skelAnime, 4.0f); if ((temp != 0) && ((temp > 0) || LinkAnimation_Update(play, &this->skelAnime))) { - Player_SetupAction(play, this, func_80843188, 1); + Player_SetupAction(play, this, Player_Action_80843188, 1); this->stateFlags1 |= PLAYER_STATE1_SHIELDING; Player_SetModelsForHoldingShield(this); anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_defense, this->modelAnimType); @@ -8647,7 +8789,7 @@ void func_808435C4(Player* this, PlayState* play) { } } -void func_8084370C(Player* this, PlayState* play) { +void Player_Action_8084370C(Player* this, PlayState* play) { s32 sp1C; func_8083721C(this); @@ -8658,15 +8800,15 @@ void func_8084370C(Player* this, PlayState* play) { } } -void func_8084377C(Player* this, PlayState* play) { +void Player_Action_8084377C(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET | PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; func_808382BC(this); - if (!(this->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) && (this->unk_850 == 0) && (this->unk_8A1 != 0)) { + if (!(this->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) && (this->av2.actionVar2 == 0) && (this->unk_8A1 != 0)) { s16 temp = this->actor.shape.rot.y - this->unk_8A2; - this->currentYaw = this->actor.shape.rot.y = this->unk_8A2; + this->yaw = this->actor.shape.rot.y = this->unk_8A2; this->linearVelocity = this->unk_8A4; if (ABS(temp) > 0x4000) { @@ -8680,22 +8822,22 @@ void func_8084377C(Player* this, PlayState* play) { } if (LinkAnimation_Update(play, &this->skelAnime) && (this->actor.bgCheckFlags & 1)) { - if (this->unk_850 != 0) { - this->unk_850--; - if (this->unk_850 == 0) { + if (this->av2.actionVar2 != 0) { + this->av2.actionVar2--; + if (this->av2.actionVar2 == 0) { func_80853080(this, play); } } else if ((this->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) || (!(this->cylinder.base.acFlags & AC_HIT) && (this->unk_8A1 == 0))) { if (this->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) { - this->unk_850++; + this->av2.actionVar2++; } else { - Player_SetupAction(play, this, func_80843954, 0); + Player_SetupAction(play, this, Player_Action_80843954, 0); this->stateFlags1 |= PLAYER_STATE1_DAMAGED; } Player_AnimPlayOnce(play, this, - (this->currentYaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_downB + (this->yaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_downB : &gPlayerAnim_link_normal_back_downB); func_80832698(this, NA_SE_VO_LI_FREEZE); } @@ -8706,7 +8848,7 @@ void func_8084377C(Player* this, PlayState* play) { } } -void func_80843954(Player* this, PlayState* play) { +void Player_Action_80843954(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET | PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; func_808382BC(this); @@ -8714,25 +8856,25 @@ void func_80843954(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime) && (this->linearVelocity == 0.0f)) { if (this->stateFlags1 & PLAYER_STATE1_IN_CUTSCENE) { - this->unk_850++; + this->av2.actionVar2++; } else { - Player_SetupAction(play, this, func_80843A38, 0); + Player_SetupAction(play, this, Player_Action_80843A38, 0); this->stateFlags1 |= PLAYER_STATE1_DAMAGED; } Player_AnimPlayOnceAdjusted(play, this, - (this->currentYaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_down_wake + (this->yaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_down_wake : &gPlayerAnim_link_normal_back_down_wake); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } } static AnimSfxEntry D_808545DC[] = { - { 0, 0x4014 }, - { 0, -0x401E }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 20) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_8, 30) }, }; -void func_80843A38(Player* this, PlayState* play) { +void Player_Action_80843A38(Player* this, PlayState* play) { s32 sp24; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; @@ -8753,10 +8895,10 @@ void func_80843A38(Player* this, PlayState* play) { static Vec3f D_808545E4 = { 0.0f, 0.0f, 5.0f }; void func_80843AE8(PlayState* play, Player* this) { - if (this->unk_850 != 0) { - if (this->unk_850 > 0) { - this->unk_850--; - if (this->unk_850 == 0) { + if (this->av2.actionVar2 != 0) { + if (this->av2.actionVar2 > 0) { + this->av2.actionVar2--; + if (this->av2.actionVar2 == 0) { if (this->stateFlags1 & PLAYER_STATE1_IN_WATER) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_swimer_swim_wait, 1.0f, 0.0f, Animation_GetLastFrame(&gPlayerAnim_link_swimer_swim_wait), ANIMMODE_ONCE, @@ -8775,7 +8917,7 @@ void func_80843AE8(PlayState* play, Player* this) { } else { gSaveContext.healthAccumulator = 0x140; } - this->unk_850 = -1; + this->av2.actionVar2 = -1; } } else if (gSaveContext.healthAccumulator == 0) { this->stateFlags1 &= ~PLAYER_STATE1_DEAD; @@ -8788,10 +8930,10 @@ void func_80843AE8(PlayState* play, Player* this) { func_80837AFC(this, -20); func_800F47FC(); } - } else if (this->unk_84F != 0) { - this->unk_850 = 60; + } else if (this->av1.actionVar1 != 0) { + this->av2.actionVar2 = 60; Player_SpawnFairy(play, this, &this->actor.world.pos, &D_808545E4, FAIRY_REVIVE_DEATH); - Player_PlaySfx(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Player_PlaySfx(this, NA_SE_EV_FIATY_HEAL - SFX_FLAG); OnePointCutscene_Init(play, 9908, 125, &this->actor, MAIN_CAM); } else if (play->gameOverCtx.state == GAMEOVER_DEATH_WAIT_GROUND) { play->gameOverCtx.state = GAMEOVER_DEATH_DELAY_MENU; @@ -8800,13 +8942,13 @@ void func_80843AE8(PlayState* play, Player* this) { } static AnimSfxEntry D_808545F0[] = { - { NA_SE_PL_BOUND, 0x103C }, - { 0, 0x408C }, - { 0, 0x40A4 }, - { 0, -0x40AA }, + { NA_SE_PL_BOUND, ANIMSFX_DATA(ANIMSFX_TYPE_2, 60) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 140) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 164) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_8, 170) }, }; -void func_80843CEC(Player* this, PlayState* play) { +void Player_Action_80843CEC(Player* this, PlayState* play) { if (this->currentTunic != PLAYER_TUNIC_GORON && CVarGetInteger("gSuperTunic", 0) == 0) { if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) || (sFloorType == 9) || ((func_80838144(sFloorType) >= 0) && @@ -8878,8 +9020,8 @@ s32 func_80843E64(PlayState* play, Player* this) { func_80837AE0(this, 40); Player_RequestQuake(play, 32967, 2, 30); - Player_RequestRumble(this, impactInfo->unk_01, impactInfo->unk_02, impactInfo->unk_03, 0); - Player_PlaySfx(&this->actor, NA_SE_PL_BODY_HIT); + Player_RequestRumble(this, impactInfo->rumbleStrength, impactInfo->rumbleDuration, impactInfo->rumbleDecreaseRate, 0); + Player_PlaySfx(this, NA_SE_PL_BODY_HIT); func_80832698(this, impactInfo->sfxId); return impactIndex + 1; @@ -8912,12 +9054,12 @@ void func_8084409C(PlayState* play, Player* this, f32 speedXZ, f32 velocityY) { heldActor->speedXZ = speedXZ; heldActor->velocity.y = velocityY; func_80834644(play, this); - Player_PlaySfx(&this->actor, NA_SE_PL_THROW); + Player_PlaySfx(this, NA_SE_PL_THROW); func_80832698(this, NA_SE_VO_LI_SWORD_N); } } -void func_8084411C(Player* this, PlayState* play) { +void Player_Action_8084411C(Player* this, PlayState* play) { f32 sp4C; s16 sp4A; @@ -8927,7 +9069,7 @@ void func_8084411C(Player* this, PlayState* play) { this->actor.gravity = -1.2f; } - Player_GetMovementSpeedAndYaw(this, &sp4C, &sp4A, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp4C, &sp4A, SPEED_MODE_LINEAR, play); if (!(this->actor.bgCheckFlags & 1)) { if (this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) { @@ -8951,10 +9093,10 @@ void func_8084411C(Player* this, PlayState* play) { Player_UpdateUpperBody(this, play); - if (((this->stateFlags2 & PLAYER_STATE2_HOPPING) && (this->unk_84F == 2)) || !func_8083BBA0(this, play)) { + if (((this->stateFlags2 & PLAYER_STATE2_HOPPING) && (this->av1.actionVar1 == 2)) || !func_8083BBA0(this, play)) { if (this->actor.velocity.y < 0.0f) { - if (this->unk_850 >= 0) { - if ((this->actor.bgCheckFlags & 8) || (this->unk_850 == 0) || (this->fallDistance > 0)) { + if (this->av2.actionVar2 >= 0) { + if ((this->actor.bgCheckFlags & 8) || (this->av2.actionVar2 == 0) || (this->fallDistance > 0)) { if ((sYDistToFloor > 800.0f) || (this->stateFlags1 & PLAYER_STATE1_HOOKSHOT_FALLING)) { func_80843E14(this, NA_SE_VO_LI_FALL_S); this->stateFlags1 &= ~PLAYER_STATE1_HOOKSHOT_FALLING; @@ -8962,11 +9104,11 @@ void func_8084411C(Player* this, PlayState* play) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_normal_landing, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 8.0f); - this->unk_850 = -1; + this->av2.actionVar2 = -1; } } else { - if ((this->unk_850 == -1) && (this->fallDistance > 120.0f) && (sYDistToFloor > 280.0f)) { - this->unk_850 = -2; + if ((this->av2.actionVar2 == -1) && (this->fallDistance > 120.0f) && (sYDistToFloor > 280.0f)) { + this->av2.actionVar2 = -2; func_80843E14(this, NA_SE_VO_LI_FALL_L); } @@ -8975,7 +9117,7 @@ void func_8084411C(Player* this, PlayState* play) { !(this->stateFlags1 & (PLAYER_STATE1_ITEM_OVER_HEAD | PLAYER_STATE1_IN_WATER)) && (this->linearVelocity > 0.0f)) { if ((this->yDistToLedge >= 150.0f) && (this->unk_84B[this->unk_846] == 0)) { func_8083EC18(this, play, sTouchedWallFlags); - } else if ((this->unk_88C >= 2) && (this->yDistToLedge < 150.0f) && + } else if ((this->ledgeClimbType >= 2) && (this->yDistToLedge < 150.0f) && (((this->actor.world.pos.y - this->actor.floorHeight) + this->yDistToLedge) > (70.0f * this->ageProperties->unk_08))) { AnimationContext_DisableQueue(play); @@ -8987,7 +9129,7 @@ void func_8084411C(Player* this, PlayState* play) { this->actor.world.pos.y += this->yDistToLedge; func_8083A5C4(play, this, this->actor.wallPoly, this->distToInteractWall, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_hold, this->modelAnimType)); - this->actor.shape.rot.y = this->currentYaw += 0x8000; + this->actor.shape.rot.y = this->yaw += 0x8000; this->stateFlags1 |= PLAYER_STATE1_HANGING_OFF_LEDGE; } } @@ -9000,9 +9142,9 @@ void func_8084411C(Player* this, PlayState* play) { if (this->stateFlags2 & PLAYER_STATE2_HOPPING) { if (func_8008E9C4(this)) { - anim = D_80853D4C[this->unk_84F][2]; + anim = D_80853D4C[this->av1.actionVar1][2]; } else { - anim = D_80853D4C[this->unk_84F][1]; + anim = D_80853D4C[this->av1.actionVar1][1]; } } else if (this->skelAnime.animation == &gPlayerAnim_link_normal_run_jump) { anim = &gPlayerAnim_link_normal_run_jump_end; @@ -9023,9 +9165,9 @@ void func_8084411C(Player* this, PlayState* play) { func_8083A098(this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_landing, this->modelAnimType), play); this->skelAnime.endFrame = 8.0f; if (sp3C == 1) { - this->unk_850 = 10; + this->av2.actionVar2 = 10; } else { - this->unk_850 = 20; + this->av2.actionVar2 = 20; } } else if (sp3C == 0) { func_8083A098(this, anim, play); @@ -9034,13 +9176,13 @@ void func_8084411C(Player* this, PlayState* play) { } static AnimSfxEntry D_8085460C[] = { - { NA_SE_VO_LI_SWORD_N, 0x2001 }, - { NA_SE_PL_WALK_GROUND, 0x1806 }, - { NA_SE_PL_ROLL, 0x806 }, - { 0, -0x2812 }, + { NA_SE_VO_LI_SWORD_N, ANIMSFX_DATA(ANIMSFX_TYPE_4, 1) }, + { NA_SE_PL_WALK_GROUND, ANIMSFX_DATA(ANIMSFX_TYPE_3, 6) }, + { NA_SE_PL_ROLL, ANIMSFX_DATA(ANIMSFX_TYPE_1, 6) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_5, 18) }, }; -void func_80844708(Player* this, PlayState* play) { +void Player_Action_80844708(Player* this, PlayState* play) { Actor* cylinderOc; s32 temp; s32 sp44; @@ -9059,7 +9201,7 @@ void func_80844708(Player* this, PlayState* play) { } if (func_80842964(this, play) == 0) { - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { Math_StepToF(&this->linearVelocity, 0.0f, 2.0f); temp = func_808374A0(play, this, &this->skelAnime, 5.0f); @@ -9089,22 +9231,22 @@ void func_80844708(Player* this, PlayState* play) { this->linearVelocity = -this->linearVelocity; Player_RequestQuake(play, 33267, 3, 12); Player_RequestRumble(this, 255, 20, 150, 0); - Player_PlaySfx(&this->actor, NA_SE_PL_BODY_HIT); + Player_PlaySfx(this, NA_SE_PL_BODY_HIT); func_80832698(this, NA_SE_VO_LI_CLIMB_END); - this->unk_850 = 1; + this->av2.actionVar2 = 1; gSaveContext.sohStats.count[COUNT_BONKS]++; GameInteractor_ExecuteOnPlayerBonk(); return; } } - if ((this->skelAnime.curFrame < 15.0f) || !func_80850224(this, play)) { + if ((this->skelAnime.curFrame < 15.0f) || !Player_ActionChange_7(this, play)) { if (this->skelAnime.curFrame >= 20.0f) { func_8083A060(this, play); return; } - Player_GetMovementSpeedAndYaw(this, &sp38, &sp36, 0.018f, play); + Player_GetMovementSpeedAndYaw(this, &sp38, &sp36, SPEED_MODE_CURVED, play); sp38 *= 1.5f; if ((sp38 < 3.0f) || (this->unk_84B[this->unk_846] != 0)) { @@ -9123,7 +9265,7 @@ void func_80844708(Player* this, PlayState* play) { } } -void func_80844A44(Player* this, PlayState* play) { +void Player_Action_80844A44(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -9138,7 +9280,7 @@ void func_80844A44(Player* this, PlayState* play) { } } -void func_80844AF4(Player* this, PlayState* play) { +void Player_Action_80844AF4(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; @@ -9151,8 +9293,8 @@ void func_80844AF4(Player* this, PlayState* play) { func_8084285C(this, 6.0f, 7.0f, 99.0f); if (!(this->actor.bgCheckFlags & 1)) { - Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, 0.0f, play); - func_8083DFE0(this, &sp2C, &this->currentYaw); + Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, SPEED_MODE_LINEAR, play); + func_8083DFE0(this, &sp2C, &this->yaw); return; } @@ -9194,32 +9336,32 @@ s32 func_80844BE4(Player* this, PlayState* play) { } void func_80844CF8(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80845000, 1); + Player_SetupAction(play, this, Player_Action_80845000, 1); } void func_80844D30(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80845308, 1); + Player_SetupAction(play, this, Player_Action_80845308, 1); } void func_80844D68(Player* this, PlayState* play) { func_80839FFC(this, play); func_80832318(this); Player_AnimChangeOnceMorph(play, this, D_80854368[Player_HoldsTwoHandedWeapon(this)]); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } void func_80844DC8(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80844E68, 1); + Player_SetupAction(play, this, Player_Action_80844E68, 1); this->unk_868 = 0.0f; Player_AnimPlayLoop(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } void func_80844E3C(Player* this) { Math_StepToF(&this->unk_858, 1.0f, 0.02f); } -void func_80844E68(Player* this, PlayState* play) { +void Player_Action_80844E68(Player* this, PlayState* play) { f32 sp34; s16 sp32; s32 temp; @@ -9231,23 +9373,23 @@ void func_80844E68(Player* this, PlayState* play) { func_808355DC(this); this->stateFlags1 &= ~PLAYER_STATE1_TARGET_NOTHING; Player_AnimPlayLoop(play, this, D_80854360[Player_HoldsTwoHandedWeapon(this)]); - this->unk_850 = -1; + this->av2.actionVar2 = -1; } func_8083721C(this); - if (!func_80842964(this, play) && (this->unk_850 != 0)) { + if (!func_80842964(this, play) && (this->av2.actionVar2 != 0)) { func_80844E3C(this); - if (this->unk_850 < 0) { + if (this->av2.actionVar2 < 0) { if (this->unk_858 >= 0.1f) { this->unk_845 = 0; - this->unk_850 = 1; + this->av2.actionVar2 = 1; } else if (!CHECK_BTN_ALL(sControlInput->cur.button, BTN_B)) { func_80844D68(this, play); } } else if (!func_80844BE4(this, play)) { - Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, SPEED_MODE_LINEAR, play); temp = func_80840058(this, &sp34, &sp32, play); if (temp > 0) { @@ -9259,7 +9401,7 @@ void func_80844E68(Player* this, PlayState* play) { } } -void func_80845000(Player* this, PlayState* play) { +void Player_Action_80845000(Player* this, PlayState* play) { s16 temp1; s32 temp2; f32 sp5C; @@ -9270,7 +9412,7 @@ void func_80845000(Player* this, PlayState* play) { s16 temp5; s32 sp44; - temp1 = this->currentYaw - this->actor.shape.rot.y; + temp1 = this->yaw - this->actor.shape.rot.y; temp2 = ABS(temp1); sp5C = fabsf(this->linearVelocity); @@ -9294,7 +9436,7 @@ void func_80845000(Player* this, PlayState* play) { if (!func_80842964(this, play) && !func_80844BE4(this, play)) { func_80844E3C(this); - Player_GetMovementSpeedAndYaw(this, &sp54, &sp52, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp54, &sp52, SPEED_MODE_LINEAR, play); temp4 = func_80840058(this, &sp54, &sp52, play); @@ -9305,21 +9447,21 @@ void func_80845000(Player* this, PlayState* play) { if (temp4 == 0) { sp54 = 0.0f; - sp52 = this->currentYaw; + sp52 = this->yaw; } - temp5 = sp52 - this->currentYaw; + temp5 = sp52 - this->yaw; sp44 = ABS(temp5); if (sp44 > 0x4000) { if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = sp52; + this->yaw = sp52; } return; } Math_AsymStepToF(&this->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); - Math_ScaledStepToS(&this->currentYaw, sp52, sp44 * 0.1f); + Math_ScaledStepToS(&this->yaw, sp52, sp44 * 0.1f); if ((sp54 == 0.0f) && (this->linearVelocity == 0.0f)) { func_80844DC8(this, play); @@ -9327,7 +9469,7 @@ void func_80845000(Player* this, PlayState* play) { } } -void func_80845308(Player* this, PlayState* play) { +void Player_Action_80845308(Player* this, PlayState* play) { f32 sp5C; f32 sp58; f32 sp54; @@ -9362,7 +9504,7 @@ void func_80845308(Player* this, PlayState* play) { if (!func_80842964(this, play) && !func_80844BE4(this, play)) { func_80844E3C(this); - Player_GetMovementSpeedAndYaw(this, &sp54, &sp52, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp54, &sp52, SPEED_MODE_LINEAR, play); temp4 = func_80840058(this, &sp54, &sp52, play); @@ -9373,21 +9515,21 @@ void func_80845308(Player* this, PlayState* play) { if (temp4 == 0) { sp54 = 0.0f; - sp52 = this->currentYaw; + sp52 = this->yaw; } - temp5 = sp52 - this->currentYaw; + temp5 = sp52 - this->yaw; sp44 = ABS(temp5); if (sp44 > 0x4000) { if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = sp52; + this->yaw = sp52; } return; } Math_AsymStepToF(&this->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); - Math_ScaledStepToS(&this->currentYaw, sp52, sp44 * 0.1f); + Math_ScaledStepToS(&this->yaw, sp52, sp44 * 0.1f); if ((sp54 == 0.0f) && (this->linearVelocity == 0.0f) && (sp5C == 0.0f)) { func_80844DC8(this, play); @@ -9395,7 +9537,7 @@ void func_80845308(Player* this, PlayState* play) { } } -void func_80845668(Player* this, PlayState* play) { +void Player_Action_80845668(Player* this, PlayState* play) { s32 sp3C; f32 temp1; s32 temp2; @@ -9425,7 +9567,7 @@ void func_80845668(Player* this, PlayState* play) { } func_80838940(this, NULL, temp1, play, NA_SE_VO_LI_AUTO_JUMP); - this->unk_850 = -1; + this->av2.actionVar2 = -1; return; } } else { @@ -9461,16 +9603,16 @@ void func_80845668(Player* this, PlayState* play) { } if ((this->skelAnime.animation == &gPlayerAnim_link_normal_100step_up) || (this->skelAnime.curFrame > 5.0f)) { - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { func_80832854(this); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } Math_StepToF(&this->actor.shape.yOffset, 0.0f, 150.0f); } } } -void func_808458D0(Player* this, PlayState* play) { +void Player_Action_808458D0(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET | PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; LinkAnimation_Update(play, &this->skelAnime); @@ -9547,26 +9689,26 @@ s32 func_80845C68(PlayState* play, s32 arg1) { return arg1; } -void func_80845CA4(Player* this, PlayState* play) { +void Player_Action_80845CA4(Player* this, PlayState* play) { f32 sp3C; s32 temp; f32 sp34; s32 sp30; s32 pad; - if (!func_8083B040(this, play)) { - if (this->unk_850 == 0) { + if (!Player_ActionChange_13(this, play)) { + if (this->av2.actionVar2 == 0) { LinkAnimation_Update(play, &this->skelAnime); if (DECR(this->doorTimer) == 0) { this->linearVelocity = 0.1f; - this->unk_850 = 1; + this->av2.actionVar2 = 1; } - } else if (this->unk_84F == 0) { + } else if (this->av1.actionVar1 == 0) { sp3C = 5.0f * D_808535E8; if (func_80845BA0(play, this, &sp3C, -1) < 30) { - this->unk_84F = 1; + this->av1.actionVar1 = 1; this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; this->unk_450.x = this->unk_45C.x; @@ -9583,8 +9725,8 @@ void func_80845CA4(Player* this, PlayState* play) { this->unk_450.x = (Math_SinS(sConveyorYaw) * 400.0f) + this->actor.world.pos.x; this->unk_450.z = (Math_CosS(sConveyorYaw) * 400.0f) + this->actor.world.pos.z; } - } else if (this->unk_850 < 0) { - this->unk_850++; + } else if (this->av2.actionVar2 < 0) { + this->av2.actionVar2++; sp34 = gSaveContext.entranceSpeed; sp30 = -1; @@ -9592,13 +9734,13 @@ void func_80845CA4(Player* this, PlayState* play) { temp = func_80845BA0(play, this, &sp34, sp30); - if ((this->unk_850 == 0) || + if ((this->av2.actionVar2 == 0) || ((temp == 0) && (this->linearVelocity == 0.0f) && (Play_GetCamera(play, 0)->unk_14C & 0x10))) { func_8005B1A4(Play_GetCamera(play, 0)); func_80845C68(play, gSaveContext.respawn[RESPAWN_MODE_DOWN].data); - if (!func_8083B644(this, play)) { + if (!Player_ActionChange_4(this, play)) { func_8083CF5C(this, play); } } @@ -9610,7 +9752,7 @@ void func_80845CA4(Player* this, PlayState* play) { } } -void func_80845EF8(Player* this, PlayState* play) { +void Player_Action_80845EF8(Player* this, PlayState* play) { s32 sp2C; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; @@ -9619,9 +9761,9 @@ void func_80845EF8(Player* this, PlayState* play) { Player_UpdateUpperBody(this, play); if (sp2C) { - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (DECR(this->doorTimer) == 0) { - this->unk_850 = 1; + this->av2.actionVar2 = 1; this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; } } else { @@ -9640,7 +9782,7 @@ void func_80845EF8(Player* this, PlayState* play) { } } -void func_80846050(Player* this, PlayState* play) { +void Player_Action_80846050(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -9666,13 +9808,13 @@ void func_80846050(Player* this, PlayState* play) { } static AnimSfxEntry D_8085461C[] = { - { NA_SE_VO_LI_SWORD_L, 0x2031 }, - { NA_SE_VO_LI_SWORD_N, -0x20E6 }, + { NA_SE_VO_LI_SWORD_L, ANIMSFX_DATA(ANIMSFX_TYPE_4, 49) }, + { NA_SE_VO_LI_SWORD_N, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 230) }, }; -void func_80846120(Player* this, PlayState* play) { - if (LinkAnimation_Update(play, &this->skelAnime) && (this->unk_850++ > 20)) { - if (!func_8083B040(this, play)) { +void Player_Action_80846120(Player* this, PlayState* play) { + if (LinkAnimation_Update(play, &this->skelAnime) && (this->av2.actionVar2++ > 20)) { + if (!Player_ActionChange_13(this, play)) { func_8083A098(this, &gPlayerAnim_link_normal_heavy_carry_end, play); } return; @@ -9706,12 +9848,12 @@ void func_80846120(Player* this, PlayState* play) { Player_ProcessAnimSfxList(this, D_8085461C); } -void func_80846260(Player* this, PlayState* play) { +void Player_Action_80846260(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimPlayLoop(play, this, &gPlayerAnim_link_silver_wait); - this->unk_850 = 1; + this->av2.actionVar2 = 1; return; } @@ -9719,7 +9861,7 @@ void func_80846260(Player* this, PlayState* play) { if (CVarGetInteger("gDpadEquips", 0) != 0) { buttonsToCheck |= BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT; } - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 27.0f)) { Actor* interactRangeActor = this->interactRangeActor; @@ -9735,12 +9877,12 @@ void func_80846260(Player* this, PlayState* play) { } } else if (CHECK_BTN_ANY(sControlInput->press.button, buttonsToCheck)) { - Player_SetupAction(play, this, func_80846358, 1); + Player_SetupAction(play, this, Player_Action_80846358, 1); Player_AnimPlayOnce(play, this, &gPlayerAnim_link_silver_throw); } } -void func_80846358(Player* this, PlayState* play) { +void Player_Action_80846358(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80839F90(this, play); return; @@ -9753,21 +9895,21 @@ void func_80846358(Player* this, PlayState* play) { heldActor->speedXZ = 10.0f; heldActor->velocity.y = 20.0f; func_80834644(play, this); - Player_PlaySfx(&this->actor, NA_SE_PL_THROW); + Player_PlaySfx(this, NA_SE_PL_THROW); func_80832698(this, NA_SE_VO_LI_SWORD_N); } } -void func_80846408(Player* this, PlayState* play) { +void Player_Action_80846408(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_nocarry_free_wait); - this->unk_850 = 15; + this->av2.actionVar2 = 15; return; } - if (this->unk_850 != 0) { - this->unk_850--; - if (this->unk_850 == 0) { + if (this->av2.actionVar2 != 0) { + this->av2.actionVar2--; + if (this->av2.actionVar2 == 0) { func_8083A098(this, &gPlayerAnim_link_normal_nocarry_free_end, play); this->stateFlags1 &= ~PLAYER_STATE1_ITEM_OVER_HEAD; func_80832698(this, NA_SE_VO_LI_DAMAGE_S); @@ -9775,7 +9917,7 @@ void func_80846408(Player* this, PlayState* play) { } } -void func_808464B0(Player* this, PlayState* play) { +void Player_Action_808464B0(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -9797,14 +9939,14 @@ void func_808464B0(Player* this, PlayState* play) { } } -void func_80846578(Player* this, PlayState* play) { +void Player_Action_80846578(Player* this, PlayState* play) { f32 sp34; s16 sp32; func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime) || - ((this->skelAnime.curFrame >= 8.0f) && Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.018f, play))) { + ((this->skelAnime.curFrame >= 8.0f) && Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, SPEED_MODE_CURVED, play))) { func_80839F90(this, play); return; } @@ -9883,9 +10025,9 @@ void func_80846648(PlayState* play, Player* this) { } void func_80846660(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084F710, 0); + Player_SetupAction(play, this, Player_Action_8084F710, 0); if ((play->sceneNum == SCENE_LAKE_HYLIA) && (gSaveContext.sceneSetupIndex >= 4)) { - this->unk_84F = 1; + this->av1.actionVar1 = 1; } this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_okarina_warp_goal, 2.0f / 3.0f, 0.0f, 24.0f, @@ -9909,34 +10051,34 @@ void func_80846720(PlayState* play, Player* this, s32 arg2) { func_80834644(play, this); if (arg2 != 0) { - Player_PlaySfx(&this->actor, NA_SE_IT_SWORD_PICKOUT); + Player_PlaySfx(this, NA_SE_IT_SWORD_PICKOUT); } } static Vec3f D_808546F4 = { -1.0f, 69.0f, 20.0f }; void func_808467D4(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084E9AC, 0); + Player_SetupAction(play, this, Player_Action_8084E9AC, 0); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; Math_Vec3f_Copy(&this->actor.world.pos, &D_808546F4); - this->currentYaw = this->actor.shape.rot.y = -0x8000; + this->yaw = this->actor.shape.rot.y = -0x8000; LinkAnimation_Change(play, &this->skelAnime, this->ageProperties->unk_A0, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); Player_AnimReplaceApplyFlags(play, this, 0x28F); if (LINK_IS_ADULT) { func_80846720(play, this, 0); } - this->unk_850 = 20; + this->av2.actionVar2 = 20; } void func_808468A8(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084F9A0, 0); + Player_SetupAction(play, this, Player_Action_8084F9A0, 0); Player_AnimReplaceApplyFlags(play, this, 0x9B); } void func_808468E8(PlayState* play, Player* this) { func_808389E8(this, &gPlayerAnim_link_normal_jump, 12.0f, play); - Player_SetupAction(play, this, func_8084F9C0, 0); + Player_SetupAction(play, this, Player_Action_8084F9C0, 0); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; this->fallStartHeight = this->actor.world.pos.y; OnePointCutscene_Init(play, 5110, 40, &this->actor, MAIN_CAM); @@ -9947,7 +10089,7 @@ void func_80846978(PlayState* play, Player* this) { } void func_808469BC(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084F698, 0); + Player_SetupAction(play, this, Player_Action_8084F698, 0); this->actor.draw = NULL; this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; } @@ -9961,7 +10103,7 @@ Actor* func_80846A00(PlayState* play, Player* this, s32 arg2) { void func_80846A68(PlayState* play, Player* this) { this->actor.draw = NULL; - Player_SetupAction(play, this, func_8085076C, 0); + Player_SetupAction(play, this, Player_Action_8085076C, 0); this->stateFlags1 |= PLAYER_STATE1_IN_CUTSCENE; } @@ -9981,7 +10123,7 @@ void Player_InitCommon(Player* this, PlayState* play, FlexSkeletonHeader* skelHe this->ageProperties = &sAgeProperties[gSaveContext.linkAge]; Actor_ProcessInitChain(&this->actor, sInitChain); this->meleeWeaponEffectIndex = TOTAL_EFFECT_COUNT; - this->currentYaw = this->actor.world.rot.y; + this->yaw = this->actor.world.rot.y; func_80834644(play, this); SkelAnime_InitLink(play, &this->skelAnime, skelHeader, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_wait, this->modelAnimType), 9, @@ -10075,7 +10217,7 @@ void Player_Init(Actor* thisx, PlayState* play2) { Math_Vec3f_Copy(&thisx->home.pos, &thisx->world.pos); Math_Vec3f_Copy(&thisx->prevPos, &thisx->world.pos); this->fallStartHeight = thisx->world.pos.y; - this->currentYaw = thisx->shape.rot.y = gSaveContext.respawn[sp4C].yaw; + this->yaw = thisx->shape.rot.y = gSaveContext.respawn[sp4C].yaw; thisx->params = gSaveContext.respawn[sp4C].playerParams; } @@ -10220,7 +10362,7 @@ void func_808473D4(PlayState* play, Player* this) { if (this->unk_860 == 2) { doAction = DO_ACTION_REEL; } - } else if ((func_8084E3C4 != this->actionFunc) && !(this->stateFlags2 & PLAYER_STATE2_CRAWLING)) { + } else if ((Player_Action_8084E3C4 != this->actionFunc) && !(this->stateFlags2 & PLAYER_STATE2_CRAWLING)) { if ((this->doorType != PLAYER_DOORTYPE_NONE) && (!(this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) || ((heldActor != NULL) && (heldActor->id == ACTOR_EN_RU1)))) { @@ -10242,7 +10384,7 @@ void func_808473D4(PlayState* play, Player* this) { (!(this->stateFlags1 & PLAYER_STATE1_ON_HORSE) && (this->rideActor != NULL))) { doAction = DO_ACTION_CLIMB; } else if ((this->stateFlags1 & PLAYER_STATE1_ON_HORSE) && !EN_HORSE_CHECK_4((EnHorse*)this->rideActor) && - (func_8084D3E4 != this->actionFunc)) { + (Player_Action_8084D3E4 != this->actionFunc)) { if ((this->stateFlags2 & PLAYER_STATE2_SPEAK_OR_CHECK) && (this->targetActor != NULL)) { if (this->targetActor->category == ACTORCAT_NPC) { doAction = DO_ACTION_SPEAK; @@ -10393,16 +10535,16 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { f32 ceilingCheckHeight; u32 flags; - sPrevFloorProperty = this->unk_A7A; + sPrevFloorProperty = this->floorProperty; if (this->stateFlags2 & PLAYER_STATE2_CRAWLING) { spB0 = 10.0f; spAC = 15.0f; ceilingCheckHeight = 30.0f; } else { - spB0 = this->ageProperties->unk_38; + spB0 = this->ageProperties->wallCheckRadius; spAC = 26.0f; - ceilingCheckHeight = this->ageProperties->unk_00; + ceilingCheckHeight = this->ageProperties->ceilingCheckHeight; } if (this->stateFlags1 & (PLAYER_STATE1_IN_CUTSCENE | PLAYER_STATE1_FLOOR_DISABLED)) { @@ -10412,7 +10554,7 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { } else if ((this->stateFlags1 & PLAYER_STATE1_LOADING) && ((this->unk_A84 - (s32)this->actor.world.pos.y) >= 100)) { flags = 0x39; } else if (!(this->stateFlags1 & PLAYER_STATE1_LOADING) && - ((func_80845EF8 == this->actionFunc) || (func_80845CA4 == this->actionFunc))) { + ((Player_Action_80845EF8 == this->actionFunc) || (Player_Action_80845CA4 == this->actionFunc))) { this->actor.bgCheckFlags &= ~0x208; flags = 0x3C; } else { @@ -10443,8 +10585,8 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { floorPoly = this->actor.floorPoly; if (floorPoly != NULL) { - this->unk_A7A = func_80041EA4(&play->colCtx, floorPoly, this->actor.floorBgId); - this->unk_A82 = this->floorSfxOffset; + this->floorProperty = func_80041EA4(&play->colCtx, floorPoly, this->actor.floorBgId); + this->prevFloorSfxOffset = this->floorSfxOffset; if (this->actor.bgCheckFlags & 0x20) { if (this->actor.yDistToWater < 20.0f) { @@ -10495,7 +10637,7 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { s32 pad; sInteractWallCheckOffset.y = 18.0f; - sInteractWallCheckOffset.z = this->ageProperties->unk_38 + 10.0f; + sInteractWallCheckOffset.z = this->ageProperties->wallCheckRadius + 10.0f; if (!(this->stateFlags2 & PLAYER_STATE2_CRAWLING) && Player_PosVsWallLineTest(play, this, &sInteractWallCheckOffset, &wallPoly, &wallBgId, &sInteractWallCheckResult)) { @@ -10563,7 +10705,7 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { sShapeYawToTouchedWall = ABS(yawDiff); - yawDiff = this->currentYaw - (s16)(this->actor.wallYaw + 0x8000); + yawDiff = this->yaw - (s16)(this->actor.wallYaw + 0x8000); sWorldYawToTouchedWall = ABS(yawDiff); @@ -10637,17 +10779,17 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { } } else { this->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; - this->unk_88D = 0; + this->ledgeClimbDelayTimer = 0; this->yDistToLedge = 0.0f; } - if (nextLedgeClimbType == this->unk_88C) { - if ((this->linearVelocity != 0.0f) && (this->unk_88D < 100)) { - this->unk_88D++; + if (nextLedgeClimbType == this->ledgeClimbType) { + if ((this->linearVelocity != 0.0f) && (this->ledgeClimbDelayTimer < 100)) { + this->ledgeClimbDelayTimer++; } } else { - this->unk_88C = nextLedgeClimbType; - this->unk_88D = 0; + this->ledgeClimbType = nextLedgeClimbType; + this->ledgeClimbDelayTimer = 0; } if (this->actor.bgCheckFlags & 1) { @@ -10670,8 +10812,8 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { sp54 = 1.0f / COLPOLY_GET_NORMAL(floorPoly->normal.y); sp50 = COLPOLY_GET_NORMAL(floorPoly->normal.z); - sp4C = Math_SinS(this->currentYaw); - sp44 = Math_CosS(this->currentYaw); + sp4C = Math_SinS(this->yaw); + sp44 = Math_CosS(this->yaw); this->floorPitch = Math_Atan2S(1.0f, (-(sp58 * sp4C) - (sp50 * sp44)) * sp54); this->floorPitchAlt = Math_Atan2S(1.0f, (-(sp58 * sp44) - (sp50 * sp4C)) * sp54); @@ -10687,11 +10829,11 @@ void Player_ProcessSceneCollision(PlayState* play, Player* this) { Player_UpdateHoverBoots(this); } - if (this->unk_A7B == sFloorType) { - this->unk_A79++; + if (this->prevFloorType == sFloorType) { + this->floorTypeTimer++; } else { - this->unk_A7B = sFloorType; - this->unk_A79 = 0; + this->prevFloorType = sFloorType; + this->floorTypeTimer = 0; } } @@ -10710,7 +10852,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { if ((this->actor.parent != NULL) && (this->stateFlags3 & PLAYER_STATE3_HOOKSHOT_TRAVELLING)) { camMode = CAM_MODE_HOOKSHOT; Camera_SetParam(Play_GetCamera(play, 0), 8, this->actor.parent); - } else if (func_8084377C == this->actionFunc) { + } else if (Player_Action_8084377C == this->actionFunc) { camMode = CAM_MODE_STILL; } else if (this->stateFlags2 & PLAYER_STATE2_GRABBING_DYNAPOLY) { camMode = CAM_MODE_PUSHPULL; @@ -10747,7 +10889,7 @@ void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { camMode = CAM_MODE_TARGET; } } else if (this->stateFlags1 & (PLAYER_STATE1_JUMPING | PLAYER_STATE1_CLIMBING_LADDER)) { - if ((func_80845668 == this->actionFunc) || (this->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER)) { + if ((Player_Action_80845668 == this->actionFunc) || (this->stateFlags1 & PLAYER_STATE1_CLIMBING_LADDER)) { camMode = CAM_MODE_CLIMB; } else { camMode = CAM_MODE_JUMP; @@ -10822,16 +10964,16 @@ void func_80848A04(PlayState* play, Player* this) { 0, 8); } -void func_80848B44(PlayState* play, Player* this) { +void Player_UpdateBodyShock(PlayState* play, Player* this) { Vec3f shockPos; Vec3f* randBodyPart; s32 shockScale; - this->shockTimer--; - this->unk_892 += this->shockTimer; + this->bodyShockTimer--; + this->unk_892 += this->bodyShockTimer; if (this->unk_892 > 20) { - shockScale = this->shockTimer * 2; + shockScale = this->bodyShockTimer * 2; this->unk_892 -= 20; if (shockScale > 40) { @@ -10848,7 +10990,7 @@ void func_80848B44(PlayState* play, Player* this) { } } -void func_80848C74(PlayState* play, Player* this) { +void Player_UpdateBodyBurn(PlayState* play, Player* this) { s32 spawnedFlame; u8* timerPtr; s32 timerStep; @@ -10866,7 +11008,7 @@ void func_80848C74(PlayState* play, Player* this) { } spawnedFlame = false; - timerPtr = this->flameTimers; + timerPtr = this->bodyFlameTimers; if (this->stateFlags2 & PLAYER_STATE2_FOOTSTEP) { sp58 = 100; @@ -10899,7 +11041,7 @@ void func_80848C74(PlayState* play, Player* this) { } if (spawnedFlame) { - Player_PlaySfx(&this->actor, NA_SE_EV_TORCH - SFX_FLAG); + Player_PlaySfx(this, NA_SE_EV_TORCH - SFX_FLAG); if (play->sceneNum == SCENE_SPIRIT_TEMPLE_BOSS) { dmgCooldown = 0; @@ -10911,7 +11053,7 @@ void func_80848C74(PlayState* play, Player* this) { Player_InflictDamage(play, -1); } } else { - this->isBurning = false; + this->bodyIsBurning = false; } } @@ -11120,12 +11262,12 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->unk_860++; } - if (this->shockTimer != 0) { - func_80848B44(play, this); + if (this->bodyShockTimer != 0) { + Player_UpdateBodyShock(play, this); } - if (this->isBurning) { - func_80848C74(play, this); + if (this->bodyIsBurning) { + Player_UpdateBodyBurn(play, this); } if ((this->stateFlags3 & PLAYER_STATE3_RESTORE_NAYRUS_LOVE) && (gSaveContext.nayrusLoveTimer != 0) && (gSaveContext.magicState == MAGIC_STATE_IDLE)) { @@ -11171,7 +11313,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->stateFlags1 |= PLAYER_STATE1_ON_HORSE; Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_1); Player_AnimReplaceApplyFlags(play, this, 0x9B); - this->unk_850 = 99; + this->av2.actionVar2 = 99; } if (this->unk_844 == 0) { @@ -11200,7 +11342,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { ((this->currentBoots == PLAYER_BOOTS_HOVER || GameInteractor_GetSlipperyFloorActive()) && !(this->stateFlags1 & (PLAYER_STATE1_IN_WATER | PLAYER_STATE1_IN_CUTSCENE)))) { f32 sp70 = this->linearVelocity; - s16 sp6E = this->currentYaw; + s16 sp6E = this->yaw; s16 yawDiff = this->actor.world.rot.y - sp6E; s32 pad; @@ -11210,7 +11352,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } if (Math_StepToF(&this->actor.speedXZ, sp70, 0.35f) && (sp70 == 0.0f)) { - this->actor.world.rot.y = this->currentYaw; + this->actor.world.rot.y = this->yaw; } if (this->linearVelocity != 0.0f) { @@ -11227,14 +11369,14 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } } else { this->actor.speedXZ = this->linearVelocity; - this->actor.world.rot.y = this->currentYaw; + this->actor.world.rot.y = this->yaw; } func_8002D868(&this->actor); if ((this->pushedSpeed != 0.0f) && !Player_InCsMode(play) && !(this->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | PLAYER_STATE1_CLIMBING_LADDER)) && - (func_80845668 != this->actionFunc) && (func_808507F4 != this->actionFunc)) { + (Player_Action_80845668 != this->actionFunc) && (Player_Action_808507F4 != this->actionFunc)) { this->actor.velocity.x += this->pushedSpeed * Math_SinS(this->pushedYaw); this->actor.velocity.z += this->pushedSpeed * Math_CosS(this->pushedYaw); } @@ -11243,7 +11385,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Player_ProcessSceneCollision(play, this); } else { sFloorType = 0; - this->unk_A7A = 0; + this->floorProperty = 0; if (!(this->stateFlags1 & PLAYER_STATE1_LOADING) && (this->stateFlags1 & PLAYER_STATE1_ON_HORSE)) { EnHorse* rideActor = (EnHorse*)this->rideActor; @@ -11304,7 +11446,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } else if ((this->actor.bgCheckFlags & 1) || (this->stateFlags1 & PLAYER_STATE1_IN_WATER)) { func_80836448(play, this, func_808332B8(this) ? &gPlayerAnim_link_swimer_swim_down - : (this->shockTimer != 0) ? &gPlayerAnim_link_normal_electric_shock_end + : (this->bodyShockTimer != 0) ? &gPlayerAnim_link_normal_electric_shock_end : &gPlayerAnim_link_derth_rebirth); } } else { @@ -11337,7 +11479,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { if ((this->csAction != 7) || !(this->stateFlags1 & (PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE | PLAYER_STATE1_CLIMBING_LADDER | PLAYER_STATE1_DAMAGED))) { this->unk_6AD = 3; - } else if (func_80852E14 != this->actionFunc) { + } else if (Player_Action_CsAction != this->actionFunc) { func_80852944(play, this, NULL); } } else { @@ -11811,7 +11953,7 @@ void Player_Draw(Actor* thisx, PlayState* play2) { } if (this->stateFlags2 & PLAYER_STATE2_FROZEN) { - f32 scale = (this->unk_84F >> 1) * 22.0f; + f32 scale = (this->av1.actionVar1 >> 1) * 22.0f; gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (0 - play->gameplayFrames) % 128, 32, 32, 1, @@ -11996,7 +12138,7 @@ void func_8084AEEC(Player* this, f32* arg1, f32 arg2, s16 arg3) { } Math_AsymStepToF(arg1, arg2 * 0.8f * swimMod, temp1, (fabsf(*arg1) * 0.02f) + 0.05f); - Math_ScaledStepToS(&this->currentYaw, arg3, 1600); + Math_ScaledStepToS(&this->yaw, arg3, 1600); // #endregion } else { @@ -12015,7 +12157,7 @@ void func_8084AEEC(Player* this, f32* arg1, f32 arg2, s16 arg3) { } Math_AsymStepToF(arg1, arg2 * 0.8f, temp1, (fabsf(*arg1) * 0.02f) + 0.05f); - Math_ScaledStepToS(&this->currentYaw, arg3, 1600); + Math_ScaledStepToS(&this->yaw, arg3, 1600); } } @@ -12041,7 +12183,7 @@ void SurfaceWithoutSwimMod(Player* this, f32* arg1, f32 arg2, s16 arg3) { } Math_AsymStepToF(arg1, arg2 * 0.8f, temp1, (fabsf(*arg1) * 0.02f) + 0.05f); - Math_ScaledStepToS(&this->currentYaw, arg3, 1600); + Math_ScaledStepToS(&this->yaw, arg3, 1600); } // #endregion @@ -12113,7 +12255,7 @@ void func_8084B158(PlayState* play, Player* this, Input* input, f32 arg3) { LinkAnimation_Update(play, &this->skelAnime); } -void func_8084B1D8(Player* this, PlayState* play) { +void Player_Action_8084B1D8(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_IN_WATER) { func_8084B000(this); func_8084AEEC(this, &this->linearVelocity, 0, this->actor.shape.rot.y); @@ -12136,7 +12278,7 @@ void func_8084B1D8(Player* this, PlayState* play) { ((this->unk_6AD == 1) && CHECK_BTN_ANY(sControlInput->press.button, buttonsToCheck)))) { func_8083C148(this, play); func_80078884(NA_SE_SY_CAMERA_ZOOM_UP); - } else if ((DECR(this->unk_850) == 0) || (this->unk_6AD != 2)) { + } else if ((DECR(this->av2.actionVar2) == 0) || (this->unk_6AD != 2)) { if (func_8008F128(this)) { this->unk_6AE |= 0x43; } else { @@ -12144,13 +12286,13 @@ void func_8084B1D8(Player* this, PlayState* play) { } } - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } s32 func_8084B3CC(PlayState* play, Player* this) { if (play->shootingGalleryStatus != 0) { func_80832564(play, this); - Player_SetupAction(play, this, func_8084FA54, 0); + Player_SetupAction(play, this, Player_Action_8084FA54, 0); if (!func_8002DD6C(this) || Player_HoldsHookshot(this)) { s32 projectileItemToUse = ITEM_BOW; @@ -12181,14 +12323,14 @@ s32 func_8084B4D4(PlayState* play, Player* this) { this->stateFlags3 &= ~PLAYER_STATE3_FORCE_PULL_OCARINA; func_8084B498(this); this->unk_6AD = 4; - func_8083B040(this, play); + Player_ActionChange_13(this, play); return 1; } return 0; } -void func_8084B530(Player* this, PlayState* play) { +void Player_Action_8084B530(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; Player_UpdateUpperBody(this, play); @@ -12202,11 +12344,11 @@ void func_8084B530(Player* this, PlayState* play) { func_8005B1A4(Play_GetCamera(play, 0)); if (!func_8084B4D4(play, this) && !func_8084B3CC(play, this) && !Player_StartCsAction(play, this)) { - if ((this->targetActor != this->interactRangeActor) || !func_8083E5A8(this, play)) { + if ((this->targetActor != this->interactRangeActor) || !Player_ActionChange_2(this, play)) { if (this->stateFlags1 & PLAYER_STATE1_ON_HORSE) { - s32 sp24 = this->unk_850; + s32 sp24 = this->av2.actionVar2; func_8083A360(play, this); - this->unk_850 = sp24; + this->av2.actionVar2 = sp24; } else if (func_808332B8(this)) { func_80838F18(play, this); } else { @@ -12220,9 +12362,9 @@ void func_8084B530(Player* this, PlayState* play) { } if (this->stateFlags1 & PLAYER_STATE1_ON_HORSE) { - func_8084CC98(this, play); + Player_Action_8084CC98(this, play); } else if (func_808332B8(this)) { - func_8084D610(this, play); + Player_Action_8084D610(this, play); } else if (!func_8008E9C4(this) && LinkAnimation_Update(play, &this->skelAnime)) { if (this->skelAnime.moveFlags != 0) { func_80832DBC(this); @@ -12238,11 +12380,11 @@ void func_8084B530(Player* this, PlayState* play) { } if (this->unk_664 != NULL) { - this->currentYaw = this->actor.shape.rot.y = func_8083DB98(this, 0); + this->yaw = this->actor.shape.rot.y = func_8083DB98(this, 0); } } -void func_8084B78C(Player* this, PlayState* play) { +void Player_Action_8084B78C(Player* this, PlayState* play) { f32 sp34; s16 sp32; s32 temp; @@ -12252,7 +12394,7 @@ void func_8084B78C(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { if (!func_8083F9D0(play, this)) { - Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, SPEED_MODE_LINEAR, play); temp = func_8083FFB8(this, &sp34, &sp32); if (temp > 0) { func_8083FAB8(this, play); @@ -12274,11 +12416,11 @@ void func_8084B840(PlayState* play, Player* this, f32 arg2) { } static AnimSfxEntry D_80854870[] = { - { NA_SE_PL_SLIP, 0x1003 }, - { NA_SE_PL_SLIP, -0x1015 }, + { NA_SE_PL_SLIP, ANIMSFX_DATA(ANIMSFX_TYPE_2, 3) }, + { NA_SE_PL_SLIP, -ANIMSFX_DATA(ANIMSFX_TYPE_2, 21) }, }; -void func_8084B898(Player* this, PlayState* play) { +void Player_Action_8084B898(Player* this, PlayState* play) { f32 sp34; s16 sp32; s32 temp; @@ -12286,8 +12428,8 @@ void func_8084B898(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DO_ACTION_GRAB | PLAYER_STATE2_DISABLE_ROTATION_ALWAYS | PLAYER_STATE2_GRABBING_DYNAPOLY; if (func_80832CB0(play, this, &gPlayerAnim_link_normal_pushing)) { - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + this->av2.actionVar2 = 1; + } else if (this->av2.actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 11.0f)) { func_80832698(this, NA_SE_VO_LI_PUSH); } @@ -12297,7 +12439,7 @@ void func_8084B898(Player* this, PlayState* play) { func_8083F524(play, this); if (!func_8083F9D0(play, this)) { - Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, SPEED_MODE_LINEAR, play); temp = func_8083FFB8(this, &sp34, &sp32); if (temp < 0) { func_8083FB14(this, play); @@ -12315,13 +12457,13 @@ void func_8084B898(Player* this, PlayState* play) { } static AnimSfxEntry D_80854878[] = { - { NA_SE_PL_SLIP, 0x1004 }, - { NA_SE_PL_SLIP, -0x1018 }, + { NA_SE_PL_SLIP, ANIMSFX_DATA(ANIMSFX_TYPE_2, 4) }, + { NA_SE_PL_SLIP, -ANIMSFX_DATA(ANIMSFX_TYPE_2, 24) }, }; static Vec3f D_80854880 = { 0.0f, 26.0f, -40.0f }; -void func_8084B9E4(Player* this, PlayState* play) { +void Player_Action_8084B9E4(Player* this, PlayState* play) { LinkAnimationHeader* anim; f32 sp70; s16 sp6E; @@ -12337,9 +12479,9 @@ void func_8084B9E4(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DO_ACTION_GRAB | PLAYER_STATE2_DISABLE_ROTATION_ALWAYS | PLAYER_STATE2_GRABBING_DYNAPOLY; if (func_80832CB0(play, this, anim)) { - this->unk_850 = 1; + this->av2.actionVar2 = 1; } else { - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 11.0f)) { func_80832698(this, NA_SE_VO_LI_PUSH); } @@ -12351,7 +12493,7 @@ void func_8084B9E4(Player* this, PlayState* play) { func_8083F524(play, this); if (!func_8083F9D0(play, this)) { - Player_GetMovementSpeedAndYaw(this, &sp70, &sp6E, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp70, &sp6E, SPEED_MODE_LINEAR, play); temp1 = func_8083FFB8(this, &sp70, &sp6E); if (temp1 > 0) { func_8083FAB8(this, play); @@ -12378,7 +12520,7 @@ void func_8084B9E4(Player* this, PlayState* play) { } } -void func_8084BBE4(Player* this, PlayState* play) { +void Player_Action_8084BBE4(Player* this, PlayState* play) { f32 sp3C; s16 sp3A; LinkAnimationHeader* anim; @@ -12388,9 +12530,9 @@ void func_8084BBE4(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { // clang-format off - anim = (this->unk_84F > 0) ? &gPlayerAnim_link_normal_fall_wait : GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_wait, this->modelAnimType); Player_AnimPlayLoop(play, this, anim); + anim = (this->av1.actionVar1 > 0) ? &gPlayerAnim_link_normal_fall_wait : GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_wait, this->modelAnimType); Player_AnimPlayLoop(play, this, anim); // clang-format on - } else if (this->unk_84F == 0) { + } else if (this->av1.actionVar1 == 0) { if (this->skelAnime.animation == &gPlayerAnim_link_normal_fall) { temp = 11.0f; } else { @@ -12400,19 +12542,19 @@ void func_8084BBE4(Player* this, PlayState* play) { if (LinkAnimation_OnFrame(&this->skelAnime, temp)) { func_80832770(this, NA_SE_PL_WALK_GROUND); if (this->skelAnime.animation == &gPlayerAnim_link_normal_fall) { - this->unk_84F = 1; + this->av1.actionVar1 = 1; } else { - this->unk_84F = -1; + this->av1.actionVar1 = -1; } } } - Math_ScaledStepToS(&this->actor.shape.rot.y, this->currentYaw, 0x800); + Math_ScaledStepToS(&this->actor.shape.rot.y, this->yaw, 0x800); - if (this->unk_84F != 0) { - Player_GetMovementSpeedAndYaw(this, &sp3C, &sp3A, 0.0f, play); + if (this->av1.actionVar1 != 0) { + Player_GetMovementSpeedAndYaw(this, &sp3C, &sp3A, SPEED_MODE_LINEAR, play); if (this->unk_847[this->unk_846] >= 0) { - if (this->unk_84F > 0) { + if (this->av1.actionVar1 > 0) { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_fall_up, this->modelAnimType); } else { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_up, this->modelAnimType); @@ -12423,7 +12565,7 @@ void func_8084BBE4(Player* this, PlayState* play) { if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) || (this->actor.shape.feetFloorFlags != 0)) { func_80837B60(this); - if (this->unk_84F < 0) { + if (this->av1.actionVar1 < 0) { this->linearVelocity = -0.8f; } else { this->linearVelocity = 0.8f; @@ -12434,7 +12576,7 @@ void func_8084BBE4(Player* this, PlayState* play) { } } -void func_8084BDFC(Player* this, PlayState* play) { +void Player_Action_8084BDFC(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -12447,16 +12589,16 @@ void func_8084BDFC(Player* this, PlayState* play) { func_808328A0(this); } else if (LinkAnimation_OnFrame(&this->skelAnime, this->skelAnime.endFrame - 34.0f)) { this->stateFlags1 &= ~(PLAYER_STATE1_HANGING_OFF_LEDGE | PLAYER_STATE1_CLIMBING_LEDGE); - Player_PlaySfx(&this->actor, NA_SE_PL_CLIMB_CLIFF); + Player_PlaySfx(this, NA_SE_PL_CLIMB_CLIFF); func_80832698(this, NA_SE_VO_LI_CLIMB_END); } } void func_8084BEE4(Player* this) { - Player_PlaySfx(&this->actor, (this->unk_84F != 0) ? NA_SE_PL_WALK_WALL : NA_SE_PL_WALK_LADDER); + Player_PlaySfx(this, (this->av1.actionVar1 != 0) ? NA_SE_PL_WALK_WALL : NA_SE_PL_WALK_LADDER); } -void func_8084BF1C(Player* this, PlayState* play) { +void Player_Action_8084BF1C(Player* this, PlayState* play) { static Vec3f D_8085488C = { 0.0f, 0.0f, 26.0f }; s32 sp84; s32 sp80; @@ -12475,7 +12617,7 @@ void func_8084BF1C(Player* this, PlayState* play) { this->fallStartHeight = this->actor.world.pos.y; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; - if ((this->unk_84F != 0) && (ABS(sp84) < ABS(sp80))) { + if ((this->av1.actionVar1 != 0) && (ABS(sp84) < ABS(sp80))) { phi_f0 = ABS(sp80) * 0.0325f; sp84 = 0; } else { @@ -12497,7 +12639,7 @@ void func_8084BF1C(Player* this, PlayState* play) { this->skelAnime.playSpeed = phi_f2 * phi_f0 + phi_f2 * CVarGetInteger("gClimbSpeed", 0); - if (this->unk_850 >= 0) { + if (this->av2.actionVar2 >= 0) { if ((this->actor.wallPoly != NULL) && (this->actor.wallBgId != BGCHECK_SCENE)) { DynaPolyActor* wallPolyActor = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); if (wallPolyActor != NULL) { @@ -12506,36 +12648,36 @@ void func_8084BF1C(Player* this, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 6.0f, this->ageProperties->unk_00, 7); + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 6.0f, this->ageProperties->ceilingCheckHeight, 7); func_8083F360(play, this, 26.0f, this->ageProperties->unk_3C, 50.0f, -20.0f); } - if ((this->unk_850 < 0) || !func_8083FBC0(this, play)) { + if ((this->av2.actionVar2 < 0) || !func_8083FBC0(this, play)) { if (LinkAnimation_Update(play, &this->skelAnime) != 0) { - if (this->unk_850 < 0) { - this->unk_850 = ABS(this->unk_850) & 1; + if (this->av2.actionVar2 < 0) { + this->av2.actionVar2 = ABS(this->av2.actionVar2) & 1; return; } if (sp84 != 0) { - sp68 = this->unk_84F + this->unk_850; + sp68 = this->av1.actionVar1 + this->av2.actionVar2; if (sp84 > 0) { D_8085488C.y = this->ageProperties->unk_40; temp_f0 = func_8083973C(play, this, &D_8085488C, &sp5C); if (this->actor.world.pos.y < temp_f0) { - if (this->unk_84F != 0) { + if (this->av1.actionVar1 != 0) { this->actor.world.pos.y = temp_f0; this->stateFlags1 &= ~PLAYER_STATE1_CLIMBING_LADDER; func_8083A5C4(play, this, this->actor.wallPoly, this->ageProperties->unk_3C, &gPlayerAnim_link_normal_jump_climb_up_free); - this->currentYaw += 0x8000; - this->actor.shape.rot.y = this->currentYaw; + this->yaw += 0x8000; + this->actor.shape.rot.y = this->yaw; func_8083A9B8(this, &gPlayerAnim_link_normal_jump_climb_up_free, play); this->stateFlags1 |= PLAYER_STATE1_CLIMBING_LEDGE; } else { - func_8083F070(this, this->ageProperties->unk_CC[this->unk_850], play); + func_8083F070(this, this->ageProperties->unk_CC[this->av2.actionVar2], play); } } else { this->skelAnime.prevTransl = this->ageProperties->unk_4A[sp68]; @@ -12543,14 +12685,14 @@ void func_8084BF1C(Player* this, PlayState* play) { } } else { if ((this->actor.world.pos.y - this->actor.floorHeight) < 15.0f) { - if (this->unk_84F != 0) { + if (this->av1.actionVar1 != 0) { func_8083FB7C(this, play); } else { - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { this->skelAnime.prevTransl = this->ageProperties->unk_44; } - func_8083F070(this, this->ageProperties->unk_C4[this->unk_850], play); - this->unk_850 = 1; + func_8083F070(this, this->ageProperties->unk_C4[this->av2.actionVar2], play); + this->av2.actionVar2 = 1; } } else { sp68 ^= 1; @@ -12560,16 +12702,16 @@ void func_8084BF1C(Player* this, PlayState* play) { 0.0f, ANIMMODE_ONCE, 0.0f); } } - this->unk_850 ^= 1; + this->av2.actionVar2 ^= 1; } else { - if ((this->unk_84F != 0) && (sp80 != 0)) { - anim2 = this->ageProperties->unk_BC[this->unk_850]; + if ((this->av1.actionVar1 != 0) && (sp80 != 0)) { + anim2 = this->ageProperties->unk_BC[this->av2.actionVar2]; if (CVarGetInteger("gMirroredWorld", 0) ? (sp80 < 0) : (sp80 > 0)) { - this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->unk_850]; + this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->av2.actionVar2]; Player_AnimPlayOnce(play, this, anim2); } else { - this->skelAnime.prevTransl = this->ageProperties->unk_86[this->unk_850]; + this->skelAnime.prevTransl = this->ageProperties->unk_86[this->av2.actionVar2]; LinkAnimation_Change(play, &this->skelAnime, anim2, -1.0f, Animation_GetLastFrame(anim2), 0.0f, ANIMMODE_ONCE, 0.0f); } @@ -12582,10 +12724,10 @@ void func_8084BF1C(Player* this, PlayState* play) { } } - if (this->unk_850 < 0) { - if (((this->unk_850 == -2) && + if (this->av2.actionVar2 < 0) { + if (((this->av2.actionVar2 == -2) && (LinkAnimation_OnFrame(&this->skelAnime, 14.0f) || LinkAnimation_OnFrame(&this->skelAnime, 29.0f))) || - ((this->unk_850 == -4) && + ((this->av2.actionVar2 == -4) && (LinkAnimation_OnFrame(&this->skelAnime, 22.0f) || LinkAnimation_OnFrame(&this->skelAnime, 35.0f) || LinkAnimation_OnFrame(&this->skelAnime, 49.0f) || LinkAnimation_OnFrame(&this->skelAnime, 55.0f)))) { func_8084BEE4(this); @@ -12602,12 +12744,12 @@ static f32 D_80854898[] = { 10.0f, 20.0f }; static f32 D_808548A0[] = { 40.0f, 50.0f }; static AnimSfxEntry D_808548A8[] = { - { NA_SE_PL_WALK_LADDER, 0x80A }, - { NA_SE_PL_WALK_LADDER, 0x814 }, - { NA_SE_PL_WALK_LADDER, -0x81E }, + { NA_SE_PL_WALK_LADDER, ANIMSFX_DATA(ANIMSFX_TYPE_1, 10) }, + { NA_SE_PL_WALK_LADDER, ANIMSFX_DATA(ANIMSFX_TYPE_1, 20) }, + { NA_SE_PL_WALK_LADDER, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 30) }, }; -void func_8084C5F8(Player* this, PlayState* play) { +void Player_Action_8084C5F8(Player* this, PlayState* play) { s32 temp; f32* sp38; CollisionPoly* sp34; @@ -12631,7 +12773,7 @@ void func_8084C5F8(Player* this, PlayState* play) { sp38 = D_80854898; - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { Player_ProcessAnimSfxList(this, D_808548A8); sp38 = D_808548A0; } @@ -12648,11 +12790,14 @@ void func_8084C5F8(Player* this, PlayState* play) { } static AnimSfxEntry D_808548B4[] = { - { 0, 0x3028 }, { 0, 0x3030 }, { 0, 0x3038 }, { 0, 0x3040 }, { 0, 0x3048 }, - { 0, 0x3050 }, { 0, 0x3058 }, { 0, 0x3060 }, { 0, -0x3068 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 40) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 48) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 56) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 64) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 72) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 80) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 88) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 96) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_6, 104) }, }; -void func_8084C760(Player* this, PlayState* play) { +void Player_Action_8084C760(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -12680,11 +12825,14 @@ void func_8084C760(Player* this, PlayState* play) { } static AnimSfxEntry D_808548D8[] = { - { 0, 0x300A }, { 0, 0x3012 }, { 0, 0x301A }, { 0, 0x3022 }, { 0, 0x3034 }, - { 0, 0x303C }, { 0, 0x3044 }, { 0, 0x304C }, { 0, -0x3054 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 10) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 18) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 26) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 34) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 52) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 60) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 68) }, { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 76) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_6, 84) }, }; -void func_8084C81C(Player* this, PlayState* play) { +void Player_Action_8084C81C(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -12735,8 +12883,8 @@ s32 func_8084C9BC(Player* this, PlayState* play) { s32 sp38; f32 sp34; - if (this->unk_850 < 0) { - this->unk_850 = 99; + if (this->av2.actionVar2 < 0) { + this->av2.actionVar2 = 99; } else { sp38 = (this->mountSide < 0) ? 0 : 1; if (!func_8084C89C(play, this, sp38, &sp34)) { @@ -12755,7 +12903,7 @@ s32 func_8084C9BC(Player* this, PlayState* play) { if (EN_HORSE_CHECK_1(rideActor) || (EN_HORSE_CHECK_4(rideActor) && CHECK_BTN_ALL(sControlInput->press.button, BTN_A))) { rideActor->actor.child = NULL; - func_80835DAC(play, this, func_8084D3E4, 0); + func_80835DAC(play, this, Player_Action_8084D3E4, 0); this->unk_878 = sp34 - rideActor->actor.world.pos.y; Player_AnimPlayOnce(play, this, (this->mountSide < 0) ? &gPlayerAnim_link_uma_left_down @@ -12826,12 +12974,13 @@ static u8 D_80854998[2][2] = { static Vec3s D_8085499C = { -69, 7146, -266 }; static AnimSfxEntry D_808549A4[] = { - { NA_SE_PL_CALM_HIT, 0x830 }, { NA_SE_PL_CALM_HIT, 0x83A }, { NA_SE_PL_CALM_HIT, 0x844 }, - { NA_SE_PL_CALM_PAT, 0x85C }, { NA_SE_PL_CALM_PAT, 0x86E }, { NA_SE_PL_CALM_PAT, 0x87E }, - { NA_SE_PL_CALM_PAT, 0x884 }, { NA_SE_PL_CALM_PAT, -0x888 }, + { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 48) }, { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 58) }, + { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 68) }, { NA_SE_PL_CALM_PAT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 92) }, + { NA_SE_PL_CALM_PAT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 110) }, { NA_SE_PL_CALM_PAT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 126) }, + { NA_SE_PL_CALM_PAT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 132) }, { NA_SE_PL_CALM_PAT, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 136) }, }; -void func_8084CC98(Player* this, PlayState* play) { +void Player_Action_8084CC98(Player* this, PlayState* play) { EnHorse* rideActor = (EnHorse*)this->rideActor; u8* arr; @@ -12839,23 +12988,23 @@ void func_8084CC98(Player* this, PlayState* play) { func_8084CBF4(this, 1.0f, 10.0f); - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (LinkAnimation_Update(play, &this->skelAnime)) { this->skelAnime.animation = &gPlayerAnim_link_uma_wait_1; - this->unk_850 = 99; + this->av2.actionVar2 = 99; return; } arr = D_80854998[(this->mountSide < 0) ? 0 : 1]; if (LinkAnimation_OnFrame(&this->skelAnime, arr[0])) { - Player_PlaySfx(&this->actor, NA_SE_PL_CLIMB_CLIFF); + Player_PlaySfx(this, NA_SE_PL_CLIMB_CLIFF); return; } if (LinkAnimation_OnFrame(&this->skelAnime, arr[1])) { func_8002DE74(play, this); - Player_PlaySfx(&this->actor, NA_SE_PL_SIT_ON_HORSE); + Player_PlaySfx(this, NA_SE_PL_SIT_ON_HORSE); return; } @@ -12865,12 +13014,12 @@ void func_8084CC98(Player* this, PlayState* play) { func_8002DE74(play, this); this->skelAnime.prevTransl = D_8085499C; - if ((rideActor->animationIdx != this->unk_850) && ((rideActor->animationIdx >= 2) || (this->unk_850 >= 2))) { - if ((this->unk_850 = rideActor->animationIdx) < 2) { + if ((rideActor->animationIdx != this->av2.actionVar2) && ((rideActor->animationIdx >= 2) || (this->av2.actionVar2 >= 2))) { + if ((this->av2.actionVar2 = rideActor->animationIdx) < 2) { f32 rand = Rand_ZeroOne(); s32 temp = 0; - this->unk_850 = 1; + this->av2.actionVar2 = 1; if (rand < 0.1f) { temp = 2; @@ -12879,20 +13028,20 @@ void func_8084CC98(Player* this, PlayState* play) { } Player_AnimPlayOnce(play, this, D_8085498C[temp]); } else { - this->skelAnime.animation = D_80854944[this->unk_850 - 2]; + this->skelAnime.animation = D_80854944[this->av2.actionVar2 - 2]; Animation_SetMorph(play, &this->skelAnime, 8.0f); - if (this->unk_850 < 4) { + if (this->av2.actionVar2 < 4) { func_80834644(play, this); - this->unk_84F = 0; + this->av1.actionVar1 = 0; } } } - if (this->unk_850 == 1) { + if (this->av2.actionVar2 == 1) { if ((D_808535E0 != 0) || func_8083224C(play)) { Player_AnimPlayOnce(play, this, &gPlayerAnim_link_uma_wait_3); } else if (LinkAnimation_Update(play, &this->skelAnime)) { - this->unk_850 = 99; + this->av2.actionVar2 = 99; } else if (this->skelAnime.animation == &gPlayerAnim_link_uma_wait_1) { Player_ProcessAnimSfxList(this, D_808549A4); } @@ -12909,11 +13058,11 @@ void func_8084CC98(Player* this, PlayState* play) { this->csAction = 0; } this->unk_6AD = 0; - this->unk_84F = 0; - } else if ((this->unk_850 < 2) || (this->unk_850 >= 4)) { + this->av1.actionVar1 = 0; + } else if ((this->av2.actionVar2 < 2) || (this->av2.actionVar2 >= 4)) { D_808535E0 = Player_UpdateUpperBody(this, play); if (D_808535E0 != 0) { - this->unk_84F = 0; + this->av1.actionVar1 = 0; } } @@ -12921,21 +13070,21 @@ void func_8084CC98(Player* this, PlayState* play) { this->actor.world.pos.y = (rideActor->actor.world.pos.y + rideActor->riderPos.y) - 27.0f; this->actor.world.pos.z = rideActor->actor.world.pos.z + rideActor->riderPos.z; - this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; if ((this->csAction != 0) || - (!func_8083224C(play) && ((rideActor->actor.speedXZ != 0.0f) || !func_8083B644(this, play)) && - !func_8083C1DC(this, play))) { + (!func_8083224C(play) && ((rideActor->actor.speedXZ != 0.0f) || !Player_ActionChange_4(this, play)) && + !Player_ActionChange_6(this, play))) { if (D_808535E0 == 0) { - if (this->unk_84F != 0) { + if (this->av1.actionVar1 != 0) { if (LinkAnimation_Update(play, &this->upperSkelAnime)) { rideActor->stateFlags &= ~ENHORSE_FLAG_8; - this->unk_84F = 0; + this->av1.actionVar1 = 0; } if (this->upperSkelAnime.animation == &gPlayerAnim_link_uma_stop_muti) { if (LinkAnimation_OnFrame(&this->upperSkelAnime, 23.0f)) { - Player_PlaySfx(&this->actor, NA_SE_IT_LASH); + Player_PlaySfx(this, NA_SE_IT_LASH); func_80832698(this, NA_SE_VO_LI_LASH); } @@ -12943,7 +13092,7 @@ void func_8084CC98(Player* this, PlayState* play) { this->upperSkelAnime.jointTable); } else { if (LinkAnimation_OnFrame(&this->upperSkelAnime, 10.0f)) { - Player_PlaySfx(&this->actor, NA_SE_IT_LASH); + Player_PlaySfx(this, NA_SE_IT_LASH); func_80832698(this, NA_SE_VO_LI_LASH); } @@ -12956,14 +13105,14 @@ void func_8084CC98(Player* this, PlayState* play) { if (EN_HORSE_CHECK_3(rideActor)) { anim = &gPlayerAnim_link_uma_stop_muti; } else if (EN_HORSE_CHECK_2(rideActor)) { - if ((this->unk_850 >= 2) && (this->unk_850 != 99)) { - anim = D_80854968[this->unk_850 - 2]; + if ((this->av2.actionVar2 >= 2) && (this->av2.actionVar2 != 99)) { + anim = D_80854968[this->av2.actionVar2 - 2]; } } if (anim != NULL) { LinkAnimation_PlayOnce(play, &this->upperSkelAnime, anim); - this->unk_84F = 1; + this->av1.actionVar1 = 1; } } } @@ -12981,7 +13130,7 @@ void func_8084CC98(Player* this, PlayState* play) { return; } - if ((this->csAction != 0) || (!func_8084C9BC(this, play) && !func_8083B040(this, play))) { + if ((this->csAction != 0) || (!func_8084C9BC(this, play) && !Player_ActionChange_13(this, play))) { if (this->unk_664 != NULL) { if (func_8002DD78(this) != 0) { this->unk_6BE = func_8083DB98(this, 1) - this->actor.shape.rot.y; @@ -13004,12 +13153,12 @@ void func_8084CC98(Player* this, PlayState* play) { } static AnimSfxEntry D_808549C4[] = { - { 0, 0x2800 }, - { NA_SE_PL_GET_OFF_HORSE, 0x80A }, - { NA_SE_PL_SLIPDOWN, -0x819 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_5, 0) }, + { NA_SE_PL_GET_OFF_HORSE, ANIMSFX_DATA(ANIMSFX_TYPE_1, 10) }, + { NA_SE_PL_SLIPDOWN, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 25) }, }; -void func_8084D3E4(Player* this, PlayState* play) { +void Player_Action_8084D3E4(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_ALWAYS; func_8084CBF4(this, 1.0f, 10.0f); @@ -13031,16 +13180,16 @@ void func_8084D3E4(Player* this, PlayState* play) { Camera_ChangeSetting(Play_GetCamera(play, 0), CAM_SET_NORMAL0); if (this->mountSide < 0) { - D_808549C4[0].field = 0x2828; + D_808549C4[0].data = ANIMSFX_DATA(ANIMSFX_TYPE_5, 40); } else { - D_808549C4[0].field = 0x281D; + D_808549C4[0].data = ANIMSFX_DATA(ANIMSFX_TYPE_5, 29); } Player_ProcessAnimSfxList(this, D_808549C4); } } static AnimSfxEntry D_808549D0[] = { - { NA_SE_PL_SWIM, -0x800 }, + { NA_SE_PL_SWIM, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 0) }, }; void func_8084D530(Player* this, f32* arg1, f32 arg2, s16 arg3) { @@ -13049,24 +13198,24 @@ void func_8084D530(Player* this, f32* arg1, f32 arg2, s16 arg3) { } void func_8084D574(PlayState* play, Player* this, s16 arg2) { - Player_SetupAction(play, this, func_8084D84C, 0); - this->actor.shape.rot.y = this->currentYaw = arg2; + Player_SetupAction(play, this, Player_Action_8084D84C, 0); + this->actor.shape.rot.y = this->yaw = arg2; Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); } void func_8084D5CC(PlayState* play, Player* this) { - Player_SetupAction(play, this, func_8084DAB4, 0); + Player_SetupAction(play, this, Player_Action_8084DAB4, 0); Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); } -void func_8084D610(Player* this, PlayState* play) { +void Player_Action_8084D610(Player* this, PlayState* play) { f32 sp34; s16 sp32; func_80832CB0(play, this, &gPlayerAnim_link_swimer_swim_wait); func_8084B000(this); - if (!func_8083224C(play) && !Player_TryActionChangeList(play, this, D_80854444, 1) && + if (!func_8083224C(play) && !Player_TryActionChangeList(play, this, sActionChangeList11, true) && !func_8083D12C(play, this, sControlInput)) { if (this->unk_6AD != 1) { this->unk_6AD = 0; @@ -13081,7 +13230,7 @@ void func_8084D610(Player* this, PlayState* play) { func_808328A0(this); } } else { - Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, SPEED_MODE_LINEAR, play); if (sp34 != 0.0f) { s16 temp = this->actor.shape.rot.y - sp32; @@ -13102,20 +13251,20 @@ void func_8084D610(Player* this, PlayState* play) { } } -void func_8084D7C4(Player* this, PlayState* play) { - if (!func_8083B040(this, play)) { +void Player_Action_8084D7C4(Player* this, PlayState* play) { + if (!Player_ActionChange_13(this, play)) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; func_8084B158(play, this, NULL, this->linearVelocity); func_8084B000(this); - if (DECR(this->unk_850) == 0) { + if (DECR(this->av2.actionVar2) == 0) { func_80838F18(play, this); } } } -void func_8084D84C(Player* this, PlayState* play) { +void Player_Action_8084D84C(Player* this, PlayState* play) { f32 sp34; s16 sp32; s16 temp; @@ -13125,8 +13274,8 @@ void func_8084D84C(Player* this, PlayState* play) { func_8084B158(play, this, sControlInput, this->linearVelocity); func_8084B000(this); - if (!Player_TryActionChangeList(play, this, D_80854444, 1) && !func_8083D12C(play, this, sControlInput)) { - Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, 0.0f, play); + if (!Player_TryActionChangeList(play, this, sActionChangeList11, true) && !func_8083D12C(play, this, sControlInput)) { + Player_GetMovementSpeedAndYaw(this, &sp34, &sp32, SPEED_MODE_LINEAR, play); temp = this->actor.shape.rot.y - sp32; if ((sp34 == 0.0f) || (ABS(temp) > 0x6000) || (this->currentBoots == PLAYER_BOOTS_IRON)) { @@ -13144,16 +13293,16 @@ s32 func_8084D980(PlayState* play, Player* this, f32* arg2, s16* arg3) { s16 temp1; s32 temp2; - temp1 = this->currentYaw - *arg3; + temp1 = this->yaw - *arg3; if (ABS(temp1) > 0x6000) { anim = &gPlayerAnim_link_swimer_swim_wait; if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { - this->currentYaw = *arg3; + this->yaw = *arg3; } else { *arg2 = 0.0f; - *arg3 = this->currentYaw; + *arg3 = this->yaw; } } else { temp2 = func_8083FD78(this, arg2, arg3, play); @@ -13177,15 +13326,15 @@ s32 func_8084D980(PlayState* play, Player* this, f32* arg2, s16* arg3) { return 0; } -void func_8084DAB4(Player* this, PlayState* play) { +void Player_Action_8084DAB4(Player* this, PlayState* play) { f32 sp2C; s16 sp2A; func_8084B158(play, this, sControlInput, this->linearVelocity); func_8084B000(this); - if (!Player_TryActionChangeList(play, this, D_80854444, 1) && !func_8083D12C(play, this, sControlInput)) { - Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, 0.0f, play); + if (!Player_TryActionChangeList(play, this, sActionChangeList11, true) && !func_8083D12C(play, this, sControlInput)) { + Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, SPEED_MODE_LINEAR, play); if (sp2C == 0.0f) { func_80838F18(play, this); @@ -13203,33 +13352,33 @@ void func_8084DBC4(PlayState* play, Player* this, f32 arg2) { f32 sp2C; s16 sp2A; - Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, 0.0f, play); + Player_GetMovementSpeedAndYaw(this, &sp2C, &sp2A, SPEED_MODE_LINEAR, play); func_8084AEEC(this, &this->linearVelocity, sp2C * 0.5f, sp2A); // Original implementation of func_8084AEEC (SurfaceWithoutSwimMod) to prevent velocity increases via swim mod which push Link into the air // #region SOH [Enhancement] if (CVarGetInteger("gEnableWalkModify", 0)) { - SurfaceWithoutSwimMod(this, &this->actor.velocity.y, arg2, this->currentYaw); + SurfaceWithoutSwimMod(this, &this->actor.velocity.y, arg2, this->yaw); // #endregion } else { - func_8084AEEC(this, &this->actor.velocity.y, arg2, this->currentYaw); + func_8084AEEC(this, &this->actor.velocity.y, arg2, this->yaw); } } -void func_8084DC48(Player* this, PlayState* play) { +void Player_Action_8084DC48(Player* this, PlayState* play) { f32 sp2C; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; this->actor.gravity = 0.0f; Player_UpdateUpperBody(this, play); - if (!func_8083B040(this, play)) { + if (!Player_ActionChange_13(this, play)) { if (this->currentBoots == PLAYER_BOOTS_IRON) { func_80838F18(play, this); return; } - if (this->unk_84F == 0) { - if (this->unk_850 == 0) { + if (this->av1.actionVar1 == 0) { + if (this->av2.actionVar2 == 0) { if (LinkAnimation_Update(play, &this->skelAnime) || ((this->skelAnime.curFrame >= 22.0f) && !CHECK_BTN_ALL(sControlInput->cur.button, BTN_A))) { func_8083D330(play, this); @@ -13244,24 +13393,24 @@ void func_8084DC48(Player* this, PlayState* play) { func_8084B158(play, this, sControlInput, this->actor.velocity.y); this->unk_6C2 = 16000; - if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) && !func_8083E5A8(this, play) && + if (CHECK_BTN_ALL(sControlInput->cur.button, BTN_A) && !Player_ActionChange_2(this, play) && !(this->actor.bgCheckFlags & 1) && (this->actor.yDistToWater < D_80854784[CUR_UPG_VALUE(UPG_SCALE)])) { func_8084DBC4(play, this, -2.0f); } else { - this->unk_84F++; + this->av1.actionVar1++; Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait); } - } else if (this->unk_84F == 1) { + } else if (this->av1.actionVar1 == 1) { LinkAnimation_Update(play, &this->skelAnime); func_8084B000(this); if (this->unk_6C2 < 10000) { - this->unk_84F++; - this->unk_850 = this->actor.yDistToWater; + this->av1.actionVar1++; + this->av2.actionVar2 = this->actor.yDistToWater; Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim); } } else if (!func_8083D12C(play, this, sControlInput)) { - sp2C = (this->unk_850 * 0.018f) + 4.0f; + sp2C = (this->av2.actionVar2 * 0.018f) + 4.0f; if (this->stateFlags1 & PLAYER_STATE1_ITEM_OVER_HEAD) { sControlInput = NULL; @@ -13291,7 +13440,7 @@ void func_8084DFAC(PlayState* play, Player* this) { func_8084DF6C(play, this); func_808322FC(this); func_8083C0E8(this, play); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } s32 func_8084DFF4(PlayState* play, Player* this) { @@ -13305,13 +13454,13 @@ s32 func_8084DFF4(PlayState* play, Player* this) { return 1; } - if (this->unk_84F == 0) { + if (this->av1.actionVar1 == 0) { if (this->getItemEntry.objectId == OBJECT_INVALID || (this->getItemId != this->getItemEntry.getItemId)) { giEntry = ItemTable_Retrieve(this->getItemId); } else { giEntry = this->getItemEntry; } - this->unk_84F = 1; + this->av1.actionVar1 = 1; equipItem = giEntry.itemId; equipNow = CVarGetInteger("gAskToEquip", 0) && giEntry.modIndex == MOD_NONE && equipItem >= ITEM_SWORD_KOKIRI && equipItem <= ITEM_TUNIC_ZORA && @@ -13422,7 +13571,7 @@ s32 func_8084DFF4(PlayState* play, Player* this) { return 0; } -void func_8084E1EC(Player* this, PlayState* play) { +void Player_Action_8084E1EC(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -13445,7 +13594,7 @@ void func_8084E1EC(Player* this, PlayState* play) { func_8084AEEC(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); } -void func_8084E30C(Player* this, PlayState* play) { +void Player_Action_8084E30C(Player* this, PlayState* play) { func_8084B000(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -13455,7 +13604,7 @@ void func_8084E30C(Player* this, PlayState* play) { func_8084AEEC(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); } -void func_8084E368(Player* this, PlayState* play) { +void Player_Action_8084E368(Player* this, PlayState* play) { func_8084B000(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -13474,10 +13623,10 @@ static s16 sWarpSongEntrances[] = { ENTR_TEMPLE_OF_TIME_7, }; -void func_8084E3C4(Player* this, PlayState* play) { +void Player_Action_8084E3C4(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_link_normal_okarina_swing); - this->unk_850 = 1; + this->av2.actionVar2 = 1; if (this->stateFlags2 & (PLAYER_STATE2_NEAR_OCARINA_ACTOR | PLAYER_STATE2_PLAY_FOR_ACTOR)) { this->stateFlags2 |= PLAYER_STATE2_ATTEMPT_PLAY_FOR_ACTOR; } else { @@ -13486,7 +13635,7 @@ void func_8084E3C4(Player* this, PlayState* play) { return; } - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { return; } @@ -13499,7 +13648,7 @@ void func_8084E3C4(Player* this, PlayState* play) { this->targetActor = this->naviActor; this->naviActor->textId = -this->naviTextId; Player_StartTalking(play, this->targetActor); - } else if (!func_8083B040(this, play)) { + } else if (!Player_ActionChange_13(this, play)) { func_8083A098(this, &gPlayerAnim_link_normal_okarina_end, play); } @@ -13528,7 +13677,7 @@ void func_8084E3C4(Player* this, PlayState* play) { } } -void func_8084E604(Player* this, PlayState* play) { +void Player_Action_8084E604(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_8083A098(this, &gPlayerAnim_link_normal_light_bom_end, play); } else if (LinkAnimation_OnFrame(&this->skelAnime, 3.0f)) { @@ -13543,22 +13692,22 @@ void func_8084E604(Player* this, PlayState* play) { } static AnimSfxEntry D_808549E0[] = { - { 0, 0x3857 }, - { NA_SE_VO_LI_CLIMB_END, 0x2057 }, - { NA_SE_VO_LI_AUTO_JUMP, 0x2045 }, - { 0, -0x287B }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_7, 87) }, + { NA_SE_VO_LI_CLIMB_END, ANIMSFX_DATA(ANIMSFX_TYPE_4, 87) }, + { NA_SE_VO_LI_AUTO_JUMP, ANIMSFX_DATA(ANIMSFX_TYPE_4, 69) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_5, 123) }, }; -void func_8084E6D4(Player* this, PlayState* play) { +void Player_Action_8084E6D4(Player* this, PlayState* play) { s32 cond; if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 != 0) { - if (this->unk_850 >= 2) { - this->unk_850--; + if (this->av2.actionVar2 != 0) { + if (this->av2.actionVar2 >= 2) { + this->av2.actionVar2--; } - if (func_8084DFF4(play, this) && (this->unk_850 == 1)) { + if (func_8084DFF4(play, this) && (this->av2.actionVar2 == 1)) { cond = ((this->targetActor != NULL) && (this->exchangeItemId < 0)) || (this->stateFlags3 & PLAYER_STATE3_FORCE_PULL_OCARINA); @@ -13603,11 +13752,11 @@ void func_8084E6D4(Player* this, PlayState* play) { Player_AnimPlayOnceAdjusted(play, this, &gPlayerAnim_link_demo_get_itemA); } - this->unk_850 = 2; + this->av2.actionVar2 = 2; func_80835EA4(play, 9); } } else { - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (!LINK_IS_ADULT) { Player_ProcessAnimSfxList(this, D_808549E0); } @@ -13625,7 +13774,7 @@ void func_8084E6D4(Player* this, PlayState* play) { } static AnimSfxEntry D_808549F0[] = { - { NA_SE_IT_MASTER_SWORD_SWING, -0x83C }, + { NA_SE_IT_MASTER_SWORD_SWING, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 60) }, }; void func_8084E988(Player* this) { @@ -13633,15 +13782,15 @@ void func_8084E988(Player* this) { } static AnimSfxEntry D_808549F4[] = { - { NA_SE_VO_LI_AUTO_JUMP, 0x2005 }, - { 0, -0x280F }, + { NA_SE_VO_LI_AUTO_JUMP, ANIMSFX_DATA(ANIMSFX_TYPE_4, 5) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_5, 15) }, }; -void func_8084E9AC(Player* this, PlayState* play) { +void Player_Action_8084E9AC(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F == 0) { - if (DECR(this->unk_850) == 0) { - this->unk_84F = 1; + if (this->av1.actionVar1 == 0) { + if (DECR(this->av2.actionVar2) == 0) { + this->av1.actionVar1 = 1; this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; } } else { @@ -13665,9 +13814,9 @@ static u8 D_808549FC[] = { 0x01, 0x03, 0x02, 0x04, 0x04, }; -void func_8084EAC0(Player* this, PlayState* play) { +void Player_Action_8084EAC0(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (this->itemAction == PLAYER_IA_BOTTLE_POE) { s32 rand = Rand_S16Offset(-1, 3); @@ -13773,20 +13922,20 @@ void func_8084EAC0(Player* this, PlayState* play) { } Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_link_bottle_drink_demo_wait); - this->unk_850 = 1; + this->av2.actionVar2 = 1; return; } func_8083C0E8(this, play); func_8005B1A4(Play_GetCamera(play, 0)); - } else if (this->unk_850 == 1) { + } else if (this->av2.actionVar2 == 1) { if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { Player_AnimChangeOnceMorphAdjusted(play, this, &gPlayerAnim_link_bottle_drink_demo_end); - this->unk_850 = 2; + this->av2.actionVar2 = 2; Player_UpdateBottleHeld(play, this, ITEM_BOTTLE, PLAYER_IA_BOTTLE); } func_80832698(this, NA_SE_VO_LI_DRINK - SFX_FLAG); - } else if ((this->unk_850 == 2) && LinkAnimation_OnFrame(&this->skelAnime, 29.0f)) { + } else if ((this->av2.actionVar2 == 2) && LinkAnimation_OnFrame(&this->skelAnime, 29.0f)) { func_80832698(this, NA_SE_VO_LI_BREATH_DRINK); } } @@ -13798,41 +13947,41 @@ static BottleCatchInfo D_80854A04[] = { { ACTOR_EN_INSECT, ITEM_BUG, 0x21, 0x7A }, }; -void func_8084ECA4(Player* this, PlayState* play) { +void Player_Action_8084ECA4(Player* this, PlayState* play) { struct_80854554* sp24; BottleCatchInfo* catchInfo; s32 temp; s32 i; - sp24 = &D_80854554[this->unk_850]; + sp24 = &D_80854554[this->av2.actionVar2]; func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F != 0) { - if (this->unk_850 == 0) { + if (this->av1.actionVar1 != 0) { + if (this->av2.actionVar2 == 0) { if (CVarGetInteger("gFastDrops", 0)) { - this->unk_84F = 0; + this->av1.actionVar1 = 0; } else { - Message_StartTextbox(play, D_80854A04[this->unk_84F - 1].textId, &this->actor); + Message_StartTextbox(play, D_80854A04[this->av1.actionVar1 - 1].textId, &this->actor); } Audio_PlayFanfare(NA_BGM_ITEM_GET | 0x900); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { - this->unk_84F = 0; + this->av1.actionVar1 = 0; func_8005B1A4(Play_GetCamera(play, 0)); } } else { func_8083C0E8(this, play); } } else { - if (this->unk_84F == 0) { + if (this->av1.actionVar1 == 0) { temp = this->skelAnime.curFrame - sp24->unk_08; if (temp >= 0) { if (sp24->unk_09 >= temp) { - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { if (temp == 0) { - Player_PlaySfx(&this->actor, NA_SE_IT_SCOOP_UP_WATER); + Player_PlaySfx(this, NA_SE_IT_SCOOP_UP_WATER); } } @@ -13845,8 +13994,8 @@ void func_8084ECA4(Player* this, PlayState* play) { } if (i < 4) { - this->unk_84F = i + 1; - this->unk_850 = 0; + this->av1.actionVar1 = i + 1; + this->av2.actionVar2 = 0; this->interactRangeActor->parent = &this->actor; Player_UpdateBottleHeld(play, this, catchInfo->itemId, ABS(catchInfo->itemAction)); if (!CVarGetInteger("gFastDrops", 0)) { @@ -13871,7 +14020,7 @@ void func_8084ECA4(Player* this, PlayState* play) { static Vec3f D_80854A1C = { 0.0f, 0.0f, 5.0f }; -void func_8084EED8(Player* this, PlayState* play) { +void Player_Action_8084EED8(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_8083C0E8(this, play); func_8005B1A4(Play_GetCamera(play, 0)); @@ -13881,8 +14030,8 @@ void func_8084EED8(Player* this, PlayState* play) { if (LinkAnimation_OnFrame(&this->skelAnime, 37.0f)) { Player_SpawnFairy(play, this, &this->leftHandPos, &D_80854A1C, FAIRY_REVIVE_BOTTLE); Player_UpdateBottleHeld(play, this, ITEM_BOTTLE, PLAYER_IA_BOTTLE); - Player_PlaySfx(&this->actor, NA_SE_EV_BOTTLE_CAP_OPEN); - Player_PlaySfx(&this->actor, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + Player_PlaySfx(this, NA_SE_EV_BOTTLE_CAP_OPEN); + Player_PlaySfx(this, NA_SE_EV_FIATY_HEAL - SFX_FLAG); } else if (LinkAnimation_OnFrame(&this->skelAnime, 47.0f)) { if (CVarGetInteger("gFairyEffect", 0)) { if (CVarGetInteger("gFairyPercentRestore", 0)) { @@ -13904,11 +14053,11 @@ static BottleDropInfo D_80854A28[] = { }; static AnimSfxEntry D_80854A34[] = { - { NA_SE_VO_LI_AUTO_JUMP, 0x2026 }, - { NA_SE_EV_BOTTLE_CAP_OPEN, -0x828 }, + { NA_SE_VO_LI_AUTO_JUMP, ANIMSFX_DATA(ANIMSFX_TYPE_4, 38) }, + { NA_SE_EV_BOTTLE_CAP_OPEN, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 40) }, }; -void func_8084EFC0(Player* this, PlayState* play) { +void Player_Action_8084EFC0(Player* this, PlayState* play) { func_8083721C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { @@ -13933,14 +14082,14 @@ void func_8084EFC0(Player* this, PlayState* play) { } static AnimSfxEntry D_80854A3C[] = { - { NA_SE_PL_PUT_OUT_ITEM, -0x81E }, + { NA_SE_PL_PUT_OUT_ITEM, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 30) }, }; -void func_8084F104(Player* this, PlayState* play) { +void Player_Action_8084F104(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 < 0) { + if (this->av2.actionVar2 < 0) { func_8083C0E8(this, play); } else if (this->exchangeItemId == EXCH_ITEM_NONE) { Actor* targetActor = this->targetActor; @@ -13962,21 +14111,21 @@ void func_8084F104(Player* this, PlayState* play) { } } - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { Message_StartTextbox(play, this->actor.textId, &this->actor); if ((this->itemAction == PLAYER_IA_CHICKEN) || (this->itemAction == PLAYER_IA_POCKET_CUCCO)) { - Player_PlaySfx(&this->actor, NA_SE_EV_CHICKEN_CRY_M); + Player_PlaySfx(this, NA_SE_EV_CHICKEN_CRY_M); } - this->unk_850 = 1; + this->av2.actionVar2 = 1; } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { this->actor.flags &= ~ACTOR_FLAG_PLAYER_TALKED_TO; this->unk_862 = 0; - if (this->unk_84F == 1) { + if (this->av1.actionVar1 == 1) { Player_AnimPlayOnce(play, this, &gPlayerAnim_link_bottle_read_end); - this->unk_850 = -1; + this->av2.actionVar2 = -1; } else { func_8083C0E8(this, play); } @@ -13984,12 +14133,12 @@ void func_8084F104(Player* this, PlayState* play) { func_8005B1A4(Play_GetCamera(play, 0)); } } - } else if (this->unk_850 >= 0) { + } else if (this->av2.actionVar2 >= 0) { Player_ProcessAnimSfxList(this, D_80854A3C); } - if ((this->unk_84F == 0) && (this->unk_664 != NULL)) { - this->currentYaw = this->actor.shape.rot.y = func_8083DB98(this, 0); + if ((this->av1.actionVar1 == 0) && (this->unk_664 != NULL)) { + this->yaw = this->actor.shape.rot.y = func_8083DB98(this, 0); } } @@ -14006,7 +14155,7 @@ void func_8084F308(Player* this, PlayState* play) { } } -void func_8084F390(Player* this, PlayState* play) { +void Player_Action_8084F390(Player* this, PlayState* play) { CollisionPoly* floorPoly; f32 sp50; f32 sp4C; @@ -14020,7 +14169,7 @@ void func_8084F390(Player* this, PlayState* play) { func_8084269C(play, this); func_800F4138(&this->actor.projectedPos, NA_SE_PL_SLIP_LEVEL - SFX_FLAG, this->actor.speedXZ); - if (func_8083B040(this, play) == 0) { + if (Player_ActionChange_13(this, play) == 0) { floorPoly = this->actor.floorPoly; if (floorPoly == NULL) { @@ -14031,7 +14180,7 @@ void func_8084F390(Player* this, PlayState* play) { Player_GetSlopeDirection(floorPoly, &sp38, &sp46); sp44 = sp46; - if (this->unk_84F != 0) { + if (this->av1.actionVar1 != 0) { sp44 = sp46 + 0x8000; } @@ -14055,7 +14204,7 @@ void func_8084F390(Player* this, PlayState* play) { if (Math_AsymStepToF(&this->linearVelocity, sp50, sp4C, sp48) && (sp50 == 0)) { LinkAnimationHeader* anim; - if (this->unk_84F == 0) { + if (this->av1.actionVar1 == 0) { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_down_slope_slip_end, this->modelAnimType); } else { anim = GET_PLAYER_ANIM(PLAYER_ANIMGROUP_up_slope_slip_end, this->modelAnimType); @@ -14063,38 +14212,38 @@ void func_8084F390(Player* this, PlayState* play) { func_8083A098(this, anim, play); } - Math_SmoothStepToS(&this->currentYaw, sp46, 10, 4000, 800); + Math_SmoothStepToS(&this->yaw, sp46, 10, 4000, 800); Math_ScaledStepToS(&this->actor.shape.rot.y, sp44, 2000); } } -void func_8084F608(Player* this, PlayState* play) { - if ((DECR(this->unk_850) == 0) && Player_StartCsAction(play, this)) { +void Player_Action_8084F608(Player* this, PlayState* play) { + if ((DECR(this->av2.actionVar2) == 0) && Player_StartCsAction(play, this)) { func_80852280(play, this, NULL); - Player_SetupAction(play, this, func_80852E14, 0); - func_80852E14(this, play); + Player_SetupAction(play, this, Player_Action_CsAction, 0); + Player_Action_CsAction(this, play); } } -void func_8084F698(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_8084F608, 0); - this->unk_850 = 40; +void Player_Action_8084F698(Player* this, PlayState* play) { + Player_SetupAction(play, this, Player_Action_8084F608, 0); + this->av2.actionVar2 = 40; Actor_Spawn(&play->actorCtx, play, ACTOR_DEMO_KANKYO, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0x10, true); } -void func_8084F710(Player* this, PlayState* play) { +void Player_Action_8084F710(Player* this, PlayState* play) { s32 pad; - if ((this->unk_84F != 0) && (play->csCtx.frames < 0x131)) { + if ((this->av1.actionVar1 != 0) && (play->csCtx.frames < 0x131)) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; } else if (sYDistToFloor < 150.0f) { if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (this->actor.bgCheckFlags & 1) { this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; func_808328A0(this); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } } else { if ((play->sceneNum == SCENE_KOKIRI_FOREST) && Player_StartCsAction(play, this)) { @@ -14117,16 +14266,16 @@ void func_8084F710(Player* this, PlayState* play) { } } -void func_8084F88C(Player* this, PlayState* play) { +void Player_Action_8084F88C(Player* this, PlayState* play) { LinkAnimation_Update(play, &this->skelAnime); - if ((this->unk_850++ > 8) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { + if ((this->av2.actionVar2++ > 8) && (play->transitionTrigger == TRANS_TRIGGER_OFF)) { - if (this->unk_84F != 0) { + if (this->av1.actionVar1 != 0) { if (play->sceneNum == SCENE_ICE_CAVERN) { Play_TriggerRespawn(play); play->nextEntranceIndex = ENTR_ICE_CAVERN_0; - } else if (this->unk_84F < 0) { + } else if (this->av1.actionVar1 < 0) { Play_TriggerRespawn(play); // In ER, handle DMT and other special void outs to respawn from last entrance from grotto if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES)) { @@ -14149,11 +14298,11 @@ void func_8084F88C(Player* this, PlayState* play) { } } -void func_8084F9A0(Player* this, PlayState* play) { - func_80839800(this, play); +void Player_Action_8084F9A0(Player* this, PlayState* play) { + Player_ActionChange_1(this, play); } -void func_8084F9C0(Player* this, PlayState* play) { +void Player_Action_8084F9C0(Player* this, PlayState* play) { this->actor.gravity = -1.0f; LinkAnimation_Update(play, &this->skelAnime); @@ -14165,7 +14314,7 @@ void func_8084F9C0(Player* this, PlayState* play) { } } -void func_8084FA54(Player* this, PlayState* play) { +void Player_Action_8084FA54(Player* this, PlayState* play) { this->unk_6AD = 2; func_8083AD4C(play, this); @@ -14183,16 +14332,16 @@ void func_8084FA54(Player* this, PlayState* play) { } } -void func_8084FB10(Player* this, PlayState* play) { - if (this->unk_84F >= 0) { - if (this->unk_84F < 6) { - this->unk_84F++; +void Player_Action_8084FB10(Player* this, PlayState* play) { + if (this->av1.actionVar1 >= 0) { + if (this->av1.actionVar1 < 6) { + this->av1.actionVar1++; } if (func_80832594(this, 1, 100)) { - this->unk_84F = -1; + this->av1.actionVar1 = -1; EffectSsIcePiece_SpawnBurst(play, &this->actor.world.pos, this->actor.scale.x); - Player_PlaySfx(&this->actor, NA_SE_PL_ICE_BROKEN); + Player_PlaySfx(this, NA_SE_PL_ICE_BROKEN); } else { this->stateFlags2 |= PLAYER_STATE2_FROZEN; } @@ -14208,17 +14357,17 @@ void func_8084FB10(Player* this, PlayState* play) { } } -void func_8084FBF4(Player* this, PlayState* play) { +void Player_Action_8084FBF4(Player* this, PlayState* play) { LinkAnimation_Update(play, &this->skelAnime); func_808382BC(this); - if (((this->unk_850 % 25) != 0) || func_80837B18(play, this, -1)) { - if (DECR(this->unk_850) == 0) { + if (((this->av2.actionVar2 % 25) != 0) || func_80837B18(play, this, -1)) { + if (DECR(this->av2.actionVar2) == 0) { func_80839F90(this, play); } } - this->shockTimer = 40; + this->bodyShockTimer = 40; func_8002F8F0(&this->actor, NA_SE_VO_LI_TAKEN_AWAY - SFX_FLAG + this->ageProperties->unk_92); } @@ -14353,7 +14502,7 @@ void Player_UpdateBunnyEars(Player* this) { } } -s32 func_80850224(Player* this, PlayState* play) { +s32 Player_ActionChange_7(Player* this, PlayState* play) { if (func_8083C6B8(play, this) == 0) { if (func_8083BB20(this) != 0) { s32 sp24 = func_80837818(this); @@ -14375,7 +14524,7 @@ s32 func_80850224(Player* this, PlayState* play) { static Vec3f D_80854A40 = { 0.0f, 40.0f, 45.0f }; -void func_808502D0(Player* this, PlayState* play) { +void Player_Action_808502D0(Player* this, PlayState* play) { struct_80854190* sp44 = &D_80854190[this->meleeWeaponAnimation]; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; @@ -14397,7 +14546,7 @@ void func_808502D0(Player* this, PlayState* play) { func_8083C50C(this); if (LinkAnimation_Update(play, &this->skelAnime)) { - if (!func_80850224(this, play)) { + if (!Player_ActionChange_7(this, play)) { u8 sp43 = this->skelAnime.moveFlags; LinkAnimationHeader* sp3C; @@ -14444,7 +14593,7 @@ void func_808502D0(Player* this, PlayState* play) { } } -void func_808505DC(Player* this, PlayState* play) { +void Player_Action_808505DC(Player* this, PlayState* play) { LinkAnimation_Update(play, &this->skelAnime); func_8083721C(this); @@ -14453,15 +14602,15 @@ void func_808505DC(Player* this, PlayState* play) { } } -void func_8085063C(Player* this, PlayState* play) { +void Player_Action_8085063C(Player* this, PlayState* play) { this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; LinkAnimation_Update(play, &this->skelAnime); Player_UpdateUpperBody(this, play); - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { Message_StartTextbox(play, 0x3B, &this->actor); - this->unk_850 = 1; + this->av2.actionVar2 = 1; return; } @@ -14488,17 +14637,17 @@ void func_8085063C(Player* this, PlayState* play) { } } -void func_8085076C(Player* this, PlayState* play) { +void Player_Action_8085076C(Player* this, PlayState* play) { s32 respawnData = gSaveContext.respawn[RESPAWN_MODE_TOP].data; - if (this->unk_850 > 20) { + if (this->av2.actionVar2 > 20) { this->actor.draw = Player_Draw; this->actor.world.pos.y += 60.0f; func_80837B9C(this, play); return; } - if (this->unk_850++ == 20) { + if (this->av2.actionVar2++ == 20) { gSaveContext.respawn[RESPAWN_MODE_TOP].data = respawnData + 1; func_80078914(&gSaveContext.respawn[RESPAWN_MODE_TOP].pos, NA_SE_PL_MAGIC_WIND_WARP); } @@ -14525,61 +14674,61 @@ static LinkAnimationHeader* D_80854A70[] = { static u8 D_80854A7C[] = { 70, 10, 10 }; static AnimSfxEntry D_80854A80[] = { - { NA_SE_PL_SKIP, 0x814 }, - { NA_SE_VO_LI_SWORD_N, 0x2014 }, - { 0, -0x301A }, + { NA_SE_PL_SKIP, ANIMSFX_DATA(ANIMSFX_TYPE_1, 20) }, + { NA_SE_VO_LI_SWORD_N, ANIMSFX_DATA(ANIMSFX_TYPE_4, 20) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_6, 26) }, }; static AnimSfxEntry D_80854A8C[][2] = { { - { 0, 0x4014 }, - { NA_SE_VO_LI_MAGIC_FROL, -0x201E }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 20) }, + { NA_SE_VO_LI_MAGIC_FROL, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 30) }, }, { - { 0, 0x4014 }, - { NA_SE_VO_LI_MAGIC_NALE, -0x202C }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 20) }, + { NA_SE_VO_LI_MAGIC_NALE, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 44) }, }, { - { NA_SE_VO_LI_MAGIC_ATTACK, 0x2014 }, - { NA_SE_IT_SWORD_SWING_HARD, -0x814 }, + { NA_SE_VO_LI_MAGIC_ATTACK, ANIMSFX_DATA(ANIMSFX_TYPE_4, 20) }, + { NA_SE_IT_SWORD_SWING_HARD, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 20) }, }, }; -void func_808507F4(Player* this, PlayState* play) { +void Player_Action_808507F4(Player* this, PlayState* play) { u8 isFastFarores = CVarGetInteger("gFastFarores", 0) && this->itemAction == PLAYER_IA_FARORES_WIND; if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F < 0) { + if (this->av1.actionVar1 < 0) { if ((this->itemAction == PLAYER_IA_NAYRUS_LOVE) || isFastFarores || (gSaveContext.magicState == MAGIC_STATE_IDLE)) { func_80839FFC(this, play); func_8005B1A4(Play_GetCamera(play, 0)); } } else { - if (this->unk_850 == 0) { - LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A58[this->unk_84F], 0.83f * (isFastFarores ? 2 : 1)); + if (this->av2.actionVar2 == 0) { + LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A58[this->av1.actionVar1], 0.83f * (isFastFarores ? 2 : 1)); - if (func_80846A00(play, this, this->unk_84F) != NULL) { + if (func_80846A00(play, this, this->av1.actionVar1) != NULL) { this->stateFlags1 |= PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE; - if ((this->unk_84F != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { + if ((this->av1.actionVar1 != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } } else { Magic_Reset(play); } } else { - LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, D_80854A64[this->unk_84F], 0.83f * (isFastFarores ? 2 : 1)); + LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, D_80854A64[this->av1.actionVar1], 0.83f * (isFastFarores ? 2 : 1)); - if (this->unk_84F == 0) { - this->unk_850 = -10; + if (this->av1.actionVar1 == 0) { + this->av2.actionVar2 = -10; } } - this->unk_850++; + this->av2.actionVar2++; } } else { - if (this->unk_850 < 0) { - this->unk_850++; + if (this->av2.actionVar2 < 0) { + this->av2.actionVar2++; - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { gSaveContext.respawn[RESPAWN_MODE_TOP].data = 1; Play_SetupRespawnPoint(play, RESPAWN_MODE_TOP, 0x6FF); gSaveContext.fw.set = 1; @@ -14592,20 +14741,20 @@ void func_808507F4(Player* this, PlayState* play) { gSaveContext.fw.roomIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].roomIndex; gSaveContext.fw.tempSwchFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags; gSaveContext.fw.tempCollectFlags = gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags; - this->unk_850 = 2; + this->av2.actionVar2 = 2; } - } else if (this->unk_84F >= 0) { - if (this->unk_850 == 0) { + } else if (this->av1.actionVar1 >= 0) { + if (this->av2.actionVar2 == 0) { Player_ProcessAnimSfxList(this, D_80854A80); - } else if (this->unk_850 == 1) { - Player_ProcessAnimSfxList(this, D_80854A8C[this->unk_84F]); - if ((this->unk_84F == 2) && LinkAnimation_OnFrame(&this->skelAnime, 30.0f)) { + } else if (this->av2.actionVar2 == 1) { + Player_ProcessAnimSfxList(this, D_80854A8C[this->av1.actionVar1]); + if ((this->av1.actionVar1 == 2) && LinkAnimation_OnFrame(&this->skelAnime, 30.0f)) { this->stateFlags1 &= ~(PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE); } - } else if ((isFastFarores ? 10 : D_80854A7C[this->unk_84F]) < this->unk_850++) { - LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A70[this->unk_84F], 0.83f * (isFastFarores ? 2 : 1)); - this->currentYaw = this->actor.shape.rot.y; - this->unk_84F = -1; + } else if ((isFastFarores ? 10 : D_80854A7C[this->av1.actionVar1]) < this->av2.actionVar2++) { + LinkAnimation_PlayOnceSetSpeed(play, &this->skelAnime, D_80854A70[this->av1.actionVar1], 0.83f * (isFastFarores ? 2 : 1)); + this->yaw = this->actor.shape.rot.y; + this->av1.actionVar1 = -1; } } } @@ -14613,7 +14762,7 @@ void func_808507F4(Player* this, PlayState* play) { func_8083721C(this); } -void func_80850AEC(Player* this, PlayState* play) { +void Player_Action_80850AEC(Player* this, PlayState* play) { f32 temp; this->stateFlags2 |= PLAYER_STATE2_DISABLE_ROTATION_Z_TARGET; @@ -14651,8 +14800,8 @@ void func_80850AEC(Player* this, PlayState* play) { } } -void func_80850C68(Player* this, PlayState* play) { - if ((this->unk_850 != 0) && ((this->unk_858 != 0.0f) || (this->unk_85C != 0.0f))) { +void Player_Action_80850C68(Player* this, PlayState* play) { + if ((this->av2.actionVar2 != 0) && ((this->unk_858 != 0.0f) || (this->unk_85C != 0.0f))) { f32 updateScale = R_UPDATE_RATE * 0.5f; this->skelAnime.curFrame += this->skelAnime.playSpeed * updateScale; @@ -14672,7 +14821,7 @@ void func_80850C68(Player* this, PlayState* play) { } else if (LinkAnimation_Update(play, &this->skelAnime)) { this->unk_860 = 2; Player_AnimPlayLoop(play, this, &gPlayerAnim_link_fishing_wait); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } func_8083721C(this); @@ -14680,12 +14829,12 @@ void func_80850C68(Player* this, PlayState* play) { if (this->unk_860 == 0) { func_80853080(this, play); } else if (this->unk_860 == 3) { - Player_SetupAction(play, this, func_80850E84, 0); + Player_SetupAction(play, this, Player_Action_80850E84, 0); Player_AnimChangeOnceMorph(play, this, &gPlayerAnim_link_fishing_fish_catch); } } -void func_80850E84(Player* this, PlayState* play) { +void Player_Action_80850E84(Player* this, PlayState* play) { if (LinkAnimation_Update(play, &this->skelAnime) && (this->unk_860 == 0)) { func_8083A098(this, &gPlayerAnim_link_fishing_fish_catch_end, play); } @@ -14698,18 +14847,22 @@ static void (*D_80854AA4[])(PlayState*, Player*, void*) = { }; static AnimSfxEntry D_80854AF0[] = { - { 0, 0x2822 }, - { NA_SE_PL_CALM_HIT, 0x82D }, - { NA_SE_PL_CALM_HIT, 0x833 }, - { NA_SE_PL_CALM_HIT, -0x840 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_5, 34) }, + { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 45) }, + { NA_SE_PL_CALM_HIT, ANIMSFX_DATA(ANIMSFX_TYPE_1, 51) }, + { NA_SE_PL_CALM_HIT, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 64) }, }; static AnimSfxEntry D_80854B00[] = { - { NA_SE_VO_LI_SURPRISE, 0x2003 }, { 0, 0x300F }, { 0, 0x3018 }, { 0, 0x301E }, { NA_SE_VO_LI_FALL_L, -0x201F }, + { NA_SE_VO_LI_SURPRISE, ANIMSFX_DATA(ANIMSFX_TYPE_4, 3) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 15) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 24) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 30) }, + { NA_SE_VO_LI_FALL_L, -ANIMSFX_DATA(ANIMSFX_TYPE_4, 31) }, }; static AnimSfxEntry D_80854B14[] = { - { 0, -0x300A }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_6, 10) }, }; static struct_80854B18 D_80854B18[] = { @@ -15004,7 +15157,7 @@ void func_808511D4(PlayState* play, Player* this, void* anim) { void func_808511FC(PlayState* play, Player* this, void* anim) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimChangeLoopMorphAdjustedZeroRootYawSpeed(play, this, anim); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } } @@ -15018,7 +15171,7 @@ void func_80851248(PlayState* play, Player* this, void* anim) { void func_80851294(PlayState* play, Player* this, void* anim) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimReplaceNormalPlayLoopAdjusted(play, this, anim); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } } @@ -15050,19 +15203,19 @@ void func_80851368(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_808513BC(PlayState* play, Player* this, CsCmdActorAction* arg2) { this->actor.gravity = 0.0f; - if (this->unk_84F == 0) { + if (this->av1.actionVar1 == 0) { if (func_8083D12C(play, this, NULL)) { - this->unk_84F = 1; + this->av1.actionVar1 = 1; } else { func_8084B158(play, this, NULL, fabsf(this->actor.velocity.y)); Math_ScaledStepToS(&this->unk_6C2, -10000, 800); - func_8084AEEC(this, &this->actor.velocity.y, 4.0f, this->currentYaw); + func_8084AEEC(this, &this->actor.velocity.y, 4.0f, this->yaw); } return; } if (LinkAnimation_Update(play, &this->skelAnime)) { - if (this->unk_84F == 1) { + if (this->av1.actionVar1 == 1) { Player_AnimChangeLoopSlowMorph(play, this, &gPlayerAnim_link_swimer_swim_wait); } else { Player_AnimPlayLoop(play, this, &gPlayerAnim_link_swimer_swim_wait); @@ -15089,7 +15242,7 @@ void func_808514C0(PlayState* play, Player* this, CsCmdActorAction* arg2) { } if ((this->interactRangeActor != NULL) && (this->interactRangeActor->textId == 0xFFFF)) { - func_8083E5A8(this, play); + Player_ActionChange_2(this, play); } } @@ -15139,8 +15292,8 @@ void func_80851688(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_80855188[] = { - { 0, 0x302A }, - { 0, -0x3030 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 42) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_6, 48) }, }; void func_80851750(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15151,7 +15304,7 @@ void func_80851750(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_80851788(PlayState* play, Player* this, CsCmdActorAction* arg2) { this->stateFlags1 &= ~PLAYER_STATE1_THREW_BOOMERANG; - this->currentYaw = this->actor.shape.rot.y = this->actor.world.rot.y = + this->yaw = this->actor.shape.rot.y = this->actor.world.rot.y = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_450); if (this->linearVelocity <= 0.0f) { @@ -15167,7 +15320,7 @@ void func_80851828(PlayState* play, Player* this, CsCmdActorAction* arg2) { func_80845BA0(play, this, &sp1C, 10); if (play->sceneNum == SCENE_JABU_JABU_BOSS) { - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { return; } @@ -15178,8 +15331,8 @@ void func_80851828(PlayState* play, Player* this, CsCmdActorAction* arg2) { } } - this->unk_850++; - if (this->unk_850 > 20) { + this->av2.actionVar2++; + if (this->av2.actionVar2 > 20) { this->csAction = 0xB; } } @@ -15191,10 +15344,10 @@ void func_808518DC(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_8085190C(PlayState* play, Player* this, CsCmdActorAction* arg2) { func_80851314(this); - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimPlayLoop(play, this, func_808334E4(this)); - this->unk_850 = 0; + this->av2.actionVar2 = 0; } func_80833C3C(this); @@ -15232,8 +15385,8 @@ static struct_808551A4 D_808551A4[] = { }; static AnimSfxEntry D_808551AC[] = { - { 0, 0x401D }, - { 0, -0x4027 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 29) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_8, 39) }, }; void func_80851A50(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15254,7 +15407,7 @@ void func_80851A50(PlayState* play, Player* this, CsCmdActorAction* arg2) { } this->leftHandDLists = &dLists[gSaveContext.linkAge]; - Player_PlaySfx(&this->actor, sp2C->unk_00); + Player_PlaySfx(this, sp2C->unk_00); if (!LINK_IS_ADULT) { func_80832698(this, sp2C->unk_02); } @@ -15273,16 +15426,16 @@ void func_80851B90(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551B4[] = { - { 0, -0x281E }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_5, 30) }, }; void func_80851BE8(PlayState* play, Player* this, CsCmdActorAction* arg2) { LinkAnimation_Update(play, &this->skelAnime); - this->unk_850++; + this->av2.actionVar2++; - if (this->unk_850 >= 180) { - if (this->unk_850 == 180) { + if (this->av2.actionVar2 >= 180) { + if (this->av2.actionVar2 == 180) { LinkAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_okarina_warp_goal, (2.0f / 3.0f), 10.0f, Animation_GetLastFrame(&gPlayerAnim_link_okarina_warp_goal), ANIMMODE_ONCE, -8.0f); } @@ -15291,12 +15444,12 @@ void func_80851BE8(PlayState* play, Player* this, CsCmdActorAction* arg2) { } void func_80851CA4(PlayState* play, Player* this, CsCmdActorAction* arg2) { - if (LinkAnimation_Update(play, &this->skelAnime) && (this->unk_850 == 0) && (this->actor.bgCheckFlags & 1)) { + if (LinkAnimation_Update(play, &this->skelAnime) && (this->av2.actionVar2 == 0) && (this->actor.bgCheckFlags & 1)) { Player_AnimPlayOnce(play, this, &gPlayerAnim_link_normal_back_downB); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } - if (this->unk_850 != 0) { + if (this->av2.actionVar2 != 0) { func_8083721C(this); } } @@ -15308,7 +15461,7 @@ void func_80851D2C(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551B8[] = { - { NA_SE_IT_SWORD_PICKOUT, -0x80C }, + { NA_SE_IT_SWORD_PICKOUT, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 12) }, }; void func_80851D80(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15349,8 +15502,8 @@ void func_80851ECC(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_80851F14(PlayState* play, Player* this, LinkAnimationHeader* anim, AnimSfxEntry* arg3) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimPlayLoopAdjusted(play, this, anim); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + this->av2.actionVar2 = 1; + } else if (this->av2.actionVar2 == 0) { Player_ProcessAnimSfxList(this, arg3); } } @@ -15361,16 +15514,16 @@ void func_80851F84(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551BC[] = { - { NA_SE_VO_LI_RELAX, 0x2023 }, - { NA_SE_PL_SLIPDOWN, 0x8EC }, - { NA_SE_PL_SLIPDOWN, -0x900 }, + { NA_SE_VO_LI_RELAX, ANIMSFX_DATA(ANIMSFX_TYPE_4, 35) }, + { NA_SE_PL_SLIPDOWN, ANIMSFX_DATA(ANIMSFX_TYPE_1, 236) }, + { NA_SE_PL_SLIPDOWN, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 256) }, }; void func_80851FB0(PlayState* play, Player* this, CsCmdActorAction* arg2) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimReplacePlayLoop(play, this, &gPlayerAnim_clink_op3_wait3, 0x9C); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + this->av2.actionVar2 = 1; + } else if (this->av2.actionVar2 == 0) { Player_ProcessAnimSfxList(this, D_808551BC); if (LinkAnimation_OnFrame(&this->skelAnime, 240.0f)) { this->actor.shape.shadowDraw = ActorShadow_DrawFeet; @@ -15379,10 +15532,10 @@ void func_80851FB0(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551C8[] = { - { NA_SE_PL_LAND_LADDER, 0x843 }, - { 0, 0x4854 }, - { 0, 0x485A }, - { 0, -0x4860 }, + { NA_SE_PL_LAND_LADDER, ANIMSFX_DATA(ANIMSFX_TYPE_1, 67) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_9, 84) }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_9, 90) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_9, 96) }, }; void func_80852048(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15410,8 +15563,8 @@ void func_808520BC(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551D8[] = { - { NA_SE_PL_BOUND, 0x1014 }, - { NA_SE_PL_BOUND, -0x101E }, + { NA_SE_PL_BOUND, ANIMSFX_DATA(ANIMSFX_TYPE_2, 20) }, + { NA_SE_PL_BOUND, -ANIMSFX_DATA(ANIMSFX_TYPE_2, 30) }, }; void func_80852174(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15447,8 +15600,8 @@ void func_80852280(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_80852298(PlayState* play, Player* this, CsCmdActorAction* arg2) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimReplaceNormalPlayLoopAdjusted(play, this, &gPlayerAnim_clink_demo_koutai_wait); - this->unk_850 = 1; - } else if (this->unk_850 == 0) { + this->av2.actionVar2 = 1; + } else if (this->av2.actionVar2 == 0) { if (LinkAnimation_OnFrame(&this->skelAnime, 10.0f)) { func_80846720(play, this, 1); } @@ -15456,8 +15609,8 @@ void func_80852298(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551E0[] = { - { 0, 0x300A }, - { 0, -0x3018 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 10) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_6, 24) }, }; void func_80852328(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15465,8 +15618,8 @@ void func_80852328(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551E8[] = { - { 0, 0x400F }, - { 0, -0x4023 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_8, 15) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_8, 35) }, }; void func_80852358(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15476,10 +15629,10 @@ void func_80852358(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_80852388(PlayState* play, Player* this, CsCmdActorAction* arg2) { if (LinkAnimation_Update(play, &this->skelAnime)) { Player_AnimPlayLoopAdjusted(play, this, &gPlayerAnim_demo_link_twait); - this->unk_850 = 1; + this->av2.actionVar2 = 1; } - if ((this->unk_850 != 0) && (play->csCtx.frames >= 900)) { + if ((this->av2.actionVar2 != 0) && (play->csCtx.frames >= 900)) { this->rightHandType = PLAYER_MODELTYPE_LH_OPEN; } else { this->rightHandType = PLAYER_MODELTYPE_RH_FF; @@ -15488,14 +15641,14 @@ void func_80852388(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_80852414(PlayState* play, Player* this, LinkAnimationHeader* anim, AnimSfxEntry* arg3) { func_80851294(play, this, anim); - if (this->unk_850 == 0) { + if (this->av2.actionVar2 == 0) { Player_ProcessAnimSfxList(this, arg3); } } static AnimSfxEntry D_808551F0[] = { - { 0, 0x300F }, - { 0, -0x3021 }, + { 0, ANIMSFX_DATA(ANIMSFX_TYPE_6, 15) }, + { 0, -ANIMSFX_DATA(ANIMSFX_TYPE_6, 33) }, }; void func_80852450(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15503,7 +15656,7 @@ void func_80852450(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static AnimSfxEntry D_808551F8[] = { - { NA_SE_PL_KNOCK, -0x84E }, + { NA_SE_PL_KNOCK, -ANIMSFX_DATA(ANIMSFX_TYPE_1, 78) }, }; void func_80852480(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15517,11 +15670,11 @@ void func_808524B0(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_808524D0(PlayState* play, Player* this, CsCmdActorAction* arg2) { sControlInput->press.button |= BTN_B; - func_80844E68(this, play); + Player_Action_80844E68(this, play); } void func_80852514(PlayState* play, Player* this, CsCmdActorAction* arg2) { - func_80844E68(this, play); + Player_Action_80844E68(this, play); } void func_80852544(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15540,13 +15693,13 @@ void func_80852564(PlayState* play, Player* this, CsCmdActorAction* arg2) { } static void (*D_808551FC[])(Player* this, PlayState* play) = { - func_8084377C, - func_80843954, - func_80843A38, + Player_Action_8084377C, + Player_Action_80843954, + Player_Action_80843A38, }; void func_808525C0(PlayState* play, Player* this, CsCmdActorAction* arg2) { - D_808551FC[this->unk_850](this, play); + D_808551FC[this->av2.actionVar2](this, play); } void func_80852608(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15618,7 +15771,7 @@ void func_808526EC(PlayState* play, Player* this, CsCmdActorAction* arg2) { void func_8085283C(PlayState* play, Player* this, CsCmdActorAction* arg2) { if (LinkAnimation_Update(play, &this->skelAnime)) { func_80852944(play, this, arg2); - } else if (this->unk_850 == 0) { + } else if (this->av2.actionVar2 == 0) { Item_Give(play, ITEM_SWORD_MASTER); func_80846720(play, this, 0); } else { @@ -15642,8 +15795,8 @@ void func_80852944(PlayState* play, Player* this, CsCmdActorAction* arg2) { func_80832340(play, this); } else { func_8083C148(this, play); - if (!func_8083B644(this, play)) { - func_8083E5A8(this, play); + if (!Player_ActionChange_4(this, play)) { + Player_ActionChange_2(this, play); } } @@ -15658,7 +15811,7 @@ void func_808529D0(PlayState* play, Player* this, CsCmdActorAction* arg2) { this->actor.world.pos.y -= 1.0f; } this->actor.world.pos.z = arg2->startPos.z; - this->currentYaw = this->actor.shape.rot.y = arg2->rot.y; + this->yaw = this->actor.shape.rot.y = arg2->rot.y; } void func_80852A54(PlayState* play, Player* this, CsCmdActorAction* arg2) { @@ -15729,8 +15882,8 @@ void func_80852C50(PlayState* play, Player* this, CsCmdActorAction* arg2) { func_80852C0C(play, this, ABS(sp24)); func_80852B4C(play, this, linkCsAction, &D_80854B18[ABS(sp24)]); - this->unk_850 = 0; - this->unk_84F = 0; + this->av2.actionVar2 = 0; + this->av1.actionVar1 = 0; this->cueId = linkCsAction->action; } @@ -15742,7 +15895,7 @@ void func_80852C50(PlayState* play, Player* this, CsCmdActorAction* arg2) { } } -void func_80852E14(Player* this, PlayState* play) { +void Player_Action_CsAction(Player* this, PlayState* play) { if (this->csAction != this->prevCsAction) { D_80858AA0 = this->skelAnime.moveFlags; @@ -15756,10 +15909,10 @@ void func_80852E14(Player* this, PlayState* play) { func_80852B4C(play, this, NULL, &D_80854E50[this->csAction]); } -s32 Player_IsDroppingFish(PlayState* play) { +int Player_IsDroppingFish(PlayState* play) { Player* this = GET_PLAYER(play); - return (func_8084EFC0 == this->actionFunc) && (this->itemAction == PLAYER_IA_BOTTLE_FISH); + return (Player_Action_8084EFC0 == this->actionFunc) && (this->itemAction == PLAYER_IA_BOTTLE_FISH); } s32 Player_StartFishing(PlayState* play) { @@ -15798,20 +15951,20 @@ s32 Player_TryCsAction(PlayState* play, Actor* actor, s32 csAction) { if (!Player_InBlockingCsMode(play, this)) { func_80832564(play, this); - Player_SetupAction(play, this, func_80852E14, 0); + Player_SetupAction(play, this, Player_Action_CsAction, 0); this->csAction = csAction; this->csActor = actor; func_80832224(this); - return 1; + return true; } - return 0; + return false; } void func_80853080(Player* this, PlayState* play) { - Player_SetupAction(play, this, func_80840BC8, 1); + Player_SetupAction(play, this, Player_Action_80840BC8, 1); Player_AnimChangeOnceMorph(play, this, func_80833338(this)); - this->currentYaw = this->actor.shape.rot.y; + this->yaw = this->actor.shape.rot.y; } s32 Player_InflictDamage(PlayState* play, s32 damage) { @@ -15855,12 +16008,12 @@ void Player_StartTalking(PlayState* play, Actor* actor) { } if (this->stateFlags1 & PLAYER_STATE1_ON_HORSE) { - s32 sp24 = this->unk_850; + s32 sp24 = this->av2.actionVar2; func_80832528(play, this); func_8083A2F8(play, this); - this->unk_850 = sp24; + this->av2.actionVar2 = sp24; } else { if (func_808332B8(this)) { func_80836898(play, this, func_8083A2F8); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index def71a66b..cf4344027 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -2,6 +2,7 @@ #include "textures/icon_item_static/icon_item_static.h" #include "textures/parameter_static/parameter_static.h" #include "soh/Enhancements/cosmetics/cosmeticsTypes.h" +#include "soh/Enhancements/enhancementTypes.h" static u8 sChildUpgrades[] = { UPG_BULLET_BAG, UPG_BOMB_BAG, UPG_STRENGTH, UPG_SCALE }; static u8 sAdultUpgrades[] = { UPG_QUIVER, UPG_BOMB_BAG, UPG_STRENGTH, UPG_SCALE }; @@ -562,20 +563,32 @@ void KaleidoScope_DrawEquipment(PlayState* play) { if (CHECK_AGE_REQ_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP])) { if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + // #Region SoH [Enhancements] // Allow Link to remove his equipment from the equipment subscreen by toggling on/off // Shields will be un-equipped entirely, and tunics/boots will revert to Kokiri Tunic/Kokiri Boots // Only BGS/Giant's Knife is affected, and it will revert to Master Sword. // If we have the feature toggled on if (CVarGetInteger("gEquipmentCanBeRemoved", 0)) { - - // If we're on the "swords" section of the equipment screen AND we're on a currently-equipped BGS/Giant's Knife - if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == 3 - && CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_BIGGORON && CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)){ // And we have the Master Sword - Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_MASTER); // "Unequip" it by equipping Master Sword - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - gSaveContext.infTable[29] = 0; - goto RESUME_EQUIPMENT_SWORD; // Skip to here so we don't re-equip it + + if (CVarGetInteger("gEnhancements.SwordToggle", SWORD_TOGGLE_NONE) == SWORD_TOGGLE_BOTH_AGES || + (CVarGetInteger("gEnhancements.SwordToggle", SWORD_TOGGLE_NONE) == SWORD_TOGGLE_CHILD) && LINK_IS_CHILD) { + // If we're on the "swords" section of the equipment screen AND we're on a currently-equipped sword + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD)) { + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_NONE); + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + Flags_SetInfTable(INFTABLE_SWORDLESS); + goto RESUME_EQUIPMENT_SWORD; // Skip to here so we don't re-equip it + } + } else { + // If we're on the "swords" section of the equipment screen AND we're on a currently-equipped BGS/Giant's Knife + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == 3 + && CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_BIGGORON && CHECK_OWNED_EQUIP(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_MASTER)){ // And we have the Master Sword + Inventory_ChangeEquipment(EQUIP_TYPE_SWORD, EQUIP_VALUE_SWORD_MASTER); // "Unequip" it by equipping Master Sword + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + Flags_UnsetInfTable(INFTABLE_SWORDLESS); + goto RESUME_EQUIPMENT_SWORD; // Skip to here so we don't re-equip it + } } // If we're on the "shields" section of the equipment screen AND we're on a currently-equipped shield diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index b04f07b38..18cfdc065 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -19,8 +19,23 @@ static s16 sAmmoVtxOffset[] = { 0, 2, 4, 6, 99, 99, 8, 99, 10, 99, 99, 99, 99, 99, 12, }; +static s16 sAllAmmoVtxOffset[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46 +}; + extern const char* _gAmmoDigit0Tex[]; +s8 ItemInSlotUsesAmmo(s16 slot) { + s16 item = gSaveContext.inventory.items[slot]; + return item == ITEM_STICK || + item == ITEM_NUT || + item == ITEM_BOMB || + item == ITEM_BOW || + item == ITEM_SLINGSHOT || + item == ITEM_BOMBCHU || + item == ITEM_BEAN; +} + void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, s16 item, int slot) { s16 ammo; s16 i; @@ -55,7 +70,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gDPPipeSync(POLY_KAL_DISP++); if (i != 0) { - gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[slot] + 31) * 4], 4, 0); + gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[((CVarGetInteger("gEnhancements.BetterAmmoRendering", 0) ? sAllAmmoVtxOffset[slot] : sAmmoVtxOffset[slot]) + 31) * 4], 4, 0); gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[i]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, @@ -64,7 +79,7 @@ void KaleidoScope_DrawAmmoCount(PauseContext* pauseCtx, GraphicsContext* gfxCtx, gSP1Quadrangle(POLY_KAL_DISP++, 0, 2, 3, 1, 0); } - gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[(sAmmoVtxOffset[slot] + 32) * 4], 4, 0); + gSPVertex(POLY_KAL_DISP++, &pauseCtx->itemVtx[((CVarGetInteger("gEnhancements.BetterAmmoRendering", 0) ? sAllAmmoVtxOffset[slot] : sAmmoVtxOffset[slot]) + 32) * 4], 4, 0); gDPLoadTextureBlock(POLY_KAL_DISP++, ((u8*)_gAmmoDigit0Tex[ammo]), G_IM_FMT_IA, G_IM_SIZ_8b, 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, @@ -764,8 +779,10 @@ void KaleidoScope_DrawItemSelect(PlayState* play) { gDPSetCombineLERP(POLY_KAL_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - for (i = 0; i < 15; i++) { - if ((gAmmoItems[i] != ITEM_NONE) && (gSaveContext.inventory.items[i] != ITEM_NONE)) { + u8 gBetterAmmoRendering = CVarGetInteger("gEnhancements.BetterAmmoRendering", 0); + + for (i = 0; i < (gBetterAmmoRendering ? 24 : 15); i++) { + if ((gBetterAmmoRendering ? ItemInSlotUsesAmmo(i) : gAmmoItems[i] != ITEM_NONE) && (gSaveContext.inventory.items[i] != ITEM_NONE)) { KaleidoScope_DrawAmmoCount(pauseCtx, play->state.gfxCtx, gSaveContext.inventory.items[i], i); } } diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 5f8da1b70..059a845c3 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -2703,6 +2703,8 @@ s16 func_80823A0C(PlayState* play, Vtx* vtx, s16 pageIndex, s16 arg3) { static s16 D_8082B11C[] = { 0, 4, 8, 12, 24, 32, 56 }; +static s16 D_8082B11C_all[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 96 }; + static s16 D_8082B12C[] = { -114, 12, 44, 76 }; static u8 D_8082B134[] = { 1, 5, 9, 13 }; @@ -2825,7 +2827,7 @@ void KaleidoScope_InitVertices(PlayState* play, GraphicsContext* gfxCtx) { pauseCtx->cursorVtx[19].v.tc[1] = 0x400; // 24 items, 7 "item selected" backgrounds, 14 ammo digits (2 each for 7 items) -- then 4 vertices for each - pauseCtx->itemVtx = Graph_Alloc(gfxCtx, (24 + 7 + 14) * 4 * sizeof(Vtx)); + pauseCtx->itemVtx = Graph_Alloc(gfxCtx, (24 + 7 + 2 * (CVarGetInteger("gEnhancements.BetterAmmoRendering", 0) ? ARRAY_COUNT(D_8082B11C_all) : ARRAY_COUNT(D_8082B11C))) * 4 * sizeof(Vtx)); for (phi_t4 = 0, phi_t2 = 0, phi_t5 = 58; phi_t4 < 4; phi_t4++, phi_t5 -= 32) { for (phi_t1 = -96, phi_t3 = 0; phi_t3 < 6; phi_t3++, phi_t2 += 4, phi_t1 += 32) { @@ -2915,8 +2917,10 @@ void KaleidoScope_InitVertices(PlayState* play, GraphicsContext* gfxCtx) { } } - for (phi_t3 = 0; phi_t3 < 7; phi_t3++) { - phi_t4 = D_8082B11C[phi_t3]; + u8 gBetterAmmoRendering = CVarGetInteger("gEnhancements.BetterAmmoRendering", 0); + + for (phi_t3 = 0; phi_t3 < (gBetterAmmoRendering ? ARRAY_COUNT(D_8082B11C_all) : ARRAY_COUNT(D_8082B11C)); phi_t3++) { + phi_t4 = gBetterAmmoRendering ? D_8082B11C_all[phi_t3] : D_8082B11C[phi_t3]; pauseCtx->itemVtx[phi_t2 + 0].v.ob[0] = pauseCtx->itemVtx[phi_t2 + 2].v.ob[0] = pauseCtx->itemVtx[phi_t4].v.ob[0];