From 560c85b32c4948f6e2187ee595e8912c231479f8 Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Tue, 11 Jun 2024 00:12:57 +0200 Subject: [PATCH] Player: Implement PlayerJudgeForceSlopeSlide (#85) --- data/odyssey_functions.csv | 8 +++---- src/Player/PlayerJudgeForceSlopeSlide.cpp | 21 ++++++++++++++++++ src/Player/PlayerJudgeForceSlopeSlide.h | 26 +++++++++++++++++++++++ src/Util/PlayerCollisionUtil.h | 1 + src/Util/PlayerUtil.h | 11 ++++++++++ 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 src/Player/PlayerJudgeForceSlopeSlide.cpp create mode 100644 src/Player/PlayerJudgeForceSlopeSlide.h create mode 100644 src/Util/PlayerUtil.h diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index c05bc957d..479f5db15 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -27846,10 +27846,10 @@ Address,Quality,Size,Name 0x000000710045963c,U,000012,_ZNK23PlayerJudgeForceRolling5judgeEv 0x0000007100459648,U,000004,_ZN23PlayerJudgeForceRolling5resetEv 0x000000710045964c,U,000004,_ZN23PlayerJudgeForceRolling6updateEv -0x0000007100459650,U,000028,_ZN26PlayerJudgeForceSlopeSlideC1EPKN2al9LiveActorEPK11PlayerConstPK19IUsePlayerCollision -0x000000710045966c,U,000008,_ZN26PlayerJudgeForceSlopeSlide5resetEv -0x0000007100459674,U,000048,_ZN26PlayerJudgeForceSlopeSlide6updateEv -0x00000071004596a4,U,000060,_ZNK26PlayerJudgeForceSlopeSlide5judgeEv +0x0000007100459650,O,000028,_ZN26PlayerJudgeForceSlopeSlideC1EPKN2al9LiveActorEPK11PlayerConstPK19IUsePlayerCollision +0x000000710045966c,O,000008,_ZN26PlayerJudgeForceSlopeSlide5resetEv +0x0000007100459674,O,000048,_ZN26PlayerJudgeForceSlopeSlide6updateEv +0x00000071004596a4,O,000060,_ZNK26PlayerJudgeForceSlopeSlide5judgeEv 0x00000071004596e0,U,000052,_ZN19PlayerJudgeGrabCeilC1EPKN2al9LiveActorEPK11PlayerConstPK19IUsePlayerCollisionPK19IPlayerModelChangerPK17PlayerCarryKeeperPK22PlayerExternalVelocity 0x0000007100459714,U,000020,_ZN19PlayerJudgeGrabCeil5resetEv 0x0000007100459728,U,001216,_ZN19PlayerJudgeGrabCeil6updateEv diff --git a/src/Player/PlayerJudgeForceSlopeSlide.cpp b/src/Player/PlayerJudgeForceSlopeSlide.cpp new file mode 100644 index 000000000..d2ec2e00f --- /dev/null +++ b/src/Player/PlayerJudgeForceSlopeSlide.cpp @@ -0,0 +1,21 @@ +#include "Player/PlayerJudgeForceSlopeSlide.h" + +#include "Util/PlayerCollisionUtil.h" +#include "Util/PlayerUtil.h" + +PlayerJudgeForceSlopeSlide::PlayerJudgeForceSlopeSlide(const al::LiveActor* player, + const PlayerConst* pConst, + const IUsePlayerCollision* collider) + : mPlayer(player), mConst(pConst), mCollider(collider) {} + +void PlayerJudgeForceSlopeSlide::reset() { + mIsForceSlide = false; +} + +void PlayerJudgeForceSlopeSlide::update() { + mIsForceSlide = rs::isOnGroundForceSlideCode(mPlayer, mCollider, mConst); +} + +bool PlayerJudgeForceSlopeSlide::judge() const { + return !rs::isPlayerHack(mPlayer) && mIsForceSlide; +} diff --git a/src/Player/PlayerJudgeForceSlopeSlide.h b/src/Player/PlayerJudgeForceSlopeSlide.h new file mode 100644 index 000000000..af302fdbd --- /dev/null +++ b/src/Player/PlayerJudgeForceSlopeSlide.h @@ -0,0 +1,26 @@ +#pragma once + +#include "Library/HostIO/HioNode.h" + +#include "Player/IJudge.h" + +namespace al { +class LiveActor; +} +class IUsePlayerCollision; +class PlayerConst; + +class PlayerJudgeForceSlopeSlide : public al::HioNode, public IJudge { +public: + PlayerJudgeForceSlopeSlide(const al::LiveActor* player, const PlayerConst* pConst, + const IUsePlayerCollision* collider); + void reset() override; + void update() override; + bool judge() const override; + +private: + const al::LiveActor* mPlayer; + const PlayerConst* mConst; + const IUsePlayerCollision* mCollider; + bool mIsForceSlide = false; +}; diff --git a/src/Util/PlayerCollisionUtil.h b/src/Util/PlayerCollisionUtil.h index 4834c7898..b1567304c 100644 --- a/src/Util/PlayerCollisionUtil.h +++ b/src/Util/PlayerCollisionUtil.h @@ -16,6 +16,7 @@ const sead::Vector3f& getCollidedWallNormal(const IUsePlayerCollision*); const sead::Vector3f& getCollidedGroundNormal(const IUsePlayerCollision*); bool isCollidedGround(const IUsePlayerCollision*); bool isCollidedGroundRunAngle(const al::LiveActor*, const IUsePlayerCollision*, const PlayerConst*); +bool isOnGroundForceSlideCode(const al::LiveActor*, const IUsePlayerCollision*, const PlayerConst*); bool isPlayerOnGround(const al::LiveActor*); bool isOnGround(const al::LiveActor*, const IUsePlayerCollision*); bool isJustLand(const IUsePlayerCollision*); diff --git a/src/Util/PlayerUtil.h b/src/Util/PlayerUtil.h new file mode 100644 index 000000000..2ba4a3eda --- /dev/null +++ b/src/Util/PlayerUtil.h @@ -0,0 +1,11 @@ +#pragma once + +namespace al { +class LiveActor; +} + +namespace rs { + +bool isPlayerHack(const al::LiveActor*); + +}