diff --git a/data/status_ai.yml b/data/status_ai.yml index bfc41f7b..e33d5f6b 100644 --- a/data/status_ai.yml +++ b/data/status_ai.yml @@ -1,5 +1,5 @@ ai::ActorWaterDepthSelect: - status: pending + status: done ai::AddBasicLinkOn: status: pending ai::AddCarried: diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 763b05d9..9a041f9a 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -20062,15 +20062,15 @@ Address,Quality,Size,Name 0x00000071002f6180,O,000004,_ZN5uking2ai21ActorWaterDepthSelectD1Ev 0x00000071002f6184,O,000036,_ZN5uking2ai21ActorWaterDepthSelectD0Ev 0x00000071002f61a8,O,000008,_ZN5uking2ai21ActorWaterDepthSelect5init_EPN4sead4HeapE -0x00000071002f61b0,U,000084,_ZN5uking2ai21ActorWaterDepthSelect6enter_EPN4ksys3act2ai15InlineParamPackE -0x00000071002f6204,U,000324,_ZN5uking2ai21ActorWaterDepthSelect5calc_Ev +0x00000071002f61b0,O,000084,_ZN5uking2ai21ActorWaterDepthSelect6enter_EPN4ksys3act2ai15InlineParamPackE +0x00000071002f6204,O,000324,_ZN5uking2ai21ActorWaterDepthSelect5calc_Ev 0x00000071002f6348,O,000004,_ZN5uking2ai21ActorWaterDepthSelect6leave_Ev 0x00000071002f634c,O,000128,_ZN5uking2ai21ActorWaterDepthSelect11loadParams_Ev 0x00000071002f63cc,O,000288,_ZNK5uking2ai21ActorWaterDepthSelect27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE 0x00000071002f64ec,O,000092,_ZNK5uking2ai21ActorWaterDepthSelect18getRuntimeTypeInfoEv -0x00000071002f6548,U,000036,_ZNK5uking2ai21ActorWaterDepthSelect8isFailedEv -0x00000071002f656c,U,000036,_ZNK5uking2ai21ActorWaterDepthSelect10isFinishedEv -0x00000071002f6590,U,000036,_ZNK5uking2ai21ActorWaterDepthSelect12isChangeableEv +0x00000071002f6548,O,000036,_ZNK5uking2ai21ActorWaterDepthSelect8isFailedEv +0x00000071002f656c,O,000036,_ZNK5uking2ai21ActorWaterDepthSelect10isFinishedEv +0x00000071002f6590,O,000036,_ZNK5uking2ai21ActorWaterDepthSelect12isChangeableEv 0x00000071002f65b4,O,000008,_ZNK4ksys3act2ai2Ai14getNumChildrenEv 0x00000071002f65bc,O,000008,_ZNK4ksys3act2ai2Ai7getTypeEv 0x00000071002f65c4,O,000008,_ZN4ksys3act2ai2Ai9postLeaveEv diff --git a/src/Game/AI/AI/aiActorWaterDepthSelect.cpp b/src/Game/AI/AI/aiActorWaterDepthSelect.cpp index ddbb21e1..2bc93767 100644 --- a/src/Game/AI/AI/aiActorWaterDepthSelect.cpp +++ b/src/Game/AI/AI/aiActorWaterDepthSelect.cpp @@ -1,4 +1,5 @@ #include "Game/AI/AI/aiActorWaterDepthSelect.h" +#include "KingSystem/ActorSystem/actActor.h" namespace uking::ai { @@ -6,12 +7,48 @@ ActorWaterDepthSelect::ActorWaterDepthSelect(const InitArg& arg) : ksys::act::ai ActorWaterDepthSelect::~ActorWaterDepthSelect() = default; +bool ActorWaterDepthSelect::isChangeable() const { + return getCurrentChild()->isChangeable(); +} + +bool ActorWaterDepthSelect::isFailed() const { + return getCurrentChild()->isFailed(); +} + +bool ActorWaterDepthSelect::isFinished() const { + return getCurrentChild()->isFinished(); +} + bool ActorWaterDepthSelect::init_(sead::Heap* heap) { - return ksys::act::ai::Ai::init_(heap); + return true; } void ActorWaterDepthSelect::enter_(ksys::act::ai::InlineParamPack* params) { - ksys::act::ai::Ai::enter_(params); + if (isDeep() && isUnderwater()) { + changeChild("深瀬", params); + } else { + changeChild("浅瀬", params); + } +} + +void ActorWaterDepthSelect::calc_() { + if (*mOnEnterOnly_s) + return; + + auto is_deep = isDeep() && isUnderwater(); + if (*mForceDeepChange_s && is_deep) { + if (!isCurrentChild("深瀬")) { + changeChild("深瀬"); + return; + } + } + + if (getCurrentChild()->isChangeable()) { + if (is_deep && !isCurrentChild("深瀬")) + changeChild("深瀬"); + else if (!is_deep && !isCurrentChild("浅瀬")) + changeChild("浅瀬"); + } } void ActorWaterDepthSelect::leave_() { @@ -24,4 +61,13 @@ void ActorWaterDepthSelect::loadParams_() { getStaticParam(&mForceDeepChange_s, "ForceDeepChange"); } +bool ActorWaterDepthSelect::isDeep() const { + return 0.0 < *mDeepDepth_s && mActor->get68f().load(); +} + +bool ActorWaterDepthSelect::isUnderwater() const { + float y_w = mActor->getMtx().m[1][3]; + return mActor->get6f0() - y_w > *mDeepDepth_s; +} + } // namespace uking::ai diff --git a/src/Game/AI/AI/aiActorWaterDepthSelect.h b/src/Game/AI/AI/aiActorWaterDepthSelect.h index 01df54ec..894d7ed0 100644 --- a/src/Game/AI/AI/aiActorWaterDepthSelect.h +++ b/src/Game/AI/AI/aiActorWaterDepthSelect.h @@ -10,11 +10,18 @@ public: explicit ActorWaterDepthSelect(const InitArg& arg); ~ActorWaterDepthSelect() override; + bool isFailed() const override; + bool isChangeable() const override; + bool isFinished() const override; bool init_(sead::Heap* heap) override; void enter_(ksys::act::ai::InlineParamPack* params) override; + void calc_() override; void leave_() override; void loadParams_() override; + bool isDeep() const; + bool isUnderwater() const; + protected: // static_param at offset 0x38 const float* mDeepDepth_s{}; diff --git a/src/KingSystem/ActorSystem/actActor.h b/src/KingSystem/ActorSystem/actActor.h index 7a3d2093..ce14c73a 100644 --- a/src/KingSystem/ActorSystem/actActor.h +++ b/src/KingSystem/ActorSystem/actActor.h @@ -285,6 +285,9 @@ public: virtual void m146(); virtual void m147(); + sead::Atomic& get68f() { return _68f; } + float get6f0() const { return _6f0; } + void emitBasicSigOn(); void emitBasicSigOff(); bool checkBasicSig() const;