diff --git a/src/Game/AI/AI/aiAirOctaFlyUp.cpp b/src/Game/AI/AI/aiAirOctaFlyUp.cpp index 8a31c577..beb5282c 100644 --- a/src/Game/AI/AI/aiAirOctaFlyUp.cpp +++ b/src/Game/AI/AI/aiAirOctaFlyUp.cpp @@ -1,10 +1,9 @@ #include "Game/AI/AI/aiAirOctaFlyUp.h" -#include "Game/DLC/aocHardModeManager.h" -#include "KingSystem/Utils/Thread/Message.h" #include "Game/AirOctaDataMgrTemp.h" -#include "KingSystem/System/VFRValue.h" -#include "KingSystem/System/VFR.h" +#include "Game/DLC/aocHardModeManager.h" #include "KingSystem/ActorSystem/AS/ASList.h" +#include "KingSystem/System/VFR.h" +#include "KingSystem/Utils/Thread/Message.h" namespace uking::ai { AirOctaFlyUp::AirOctaFlyUp(const InitArg& arg) : ksys::act::ai::Ai(arg) {} @@ -14,54 +13,56 @@ AirOctaFlyUp::~AirOctaFlyUp() = default; bool AirOctaFlyUp::init_(sead::Heap* heap) { return ksys::act::ai::Ai::init_(heap); } - -void AirOctaFlyUp::calc_(){ +// NON_MATCHING: one add should be a sub, and one str should be a stur +void AirOctaFlyUp::calc_() { if (auto* data_mgr = getDataMgr()) { // I added VFR::getDeltaFrame and changed VFR::getDeltaTime to refer to mDeltaTimes array. auto deltaTime = ksys::VFR::instance()->getDeltaTime(); mElapsedTime += deltaTime; - auto v11 = sead::Mathf::min( 1.0f, mElapsedTime / *mFlyUpDuration_s); + auto v11 = sead::Mathf::min(1.0f, mElapsedTime / *mFlyUpDuration_s); auto v12 = v11 * 2.f; auto v13 = (v11 * 2.f) - 1.f; auto v14 = v12 < 1.f ? sead::Mathf::exp(v13 * 10.f) : 2.f - sead::Mathf::exp(v13 * -10.f); auto v15 = v14 * 0.5f; data_mgr->unk_114 = v15 * *mTargetDistance_d; data_mgr->sub_71002fb17c(); - u32 y_ = *(u32*)&(getActor()->getMtx().m[1][3]); - if (isCurrentChild("終了")) { // "End" + u32 y = *(u32*)&(getActor()->getMtx().m[1][3]); + if (isCurrentChild("終了")) { // "End" if (!mIsEnded) { auto currentChild = getCurrentChild(); - if (currentChild->isFinished() || currentChild->isFailed() ){ + if (currentChild->isFinished() || currentChild->isFailed()) { auto ASList = getActor()->getASList(); - if (ASList){ - ASList->sub_710115b070( -1.f, -1.f, "Wait", 0, 0, true); + if (ASList) { + ASList->sub_710115b070(-1.f, -1.f, "Wait", 0, 0, true); } mIsEnded = true; } else if (!mIsEnded) { return; } - } + } - if ((v15 >= 1.f && *(float*)&y_ >= getDataMgr()->unk_fc.y) || mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) { + if ((v15 >= 1.f && *(float*)&y >= getDataMgr()->unk_fc.y) || + mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) { ksys::act::ActorConstDataAccess linkData; - if (ksys::act::acquireActor(&getDataMgr()->unk_00, &linkData)) { - UserData = 3; - getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &UserData, false); + if (ksys::act::acquireActor(&getDataMgr()->mBaseProcLink, &linkData)) { + mUserData = 3; + getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, + &mUserData, false); } } - } else if (*(float*)&y_ - AirOctaY >= *mTargetDistance_d * 0.9f || mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) { + } else if (*(float*)&y - AirOctaY >= *mTargetDistance_d * 0.9f || + mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) { ksys::act::ActorConstDataAccess linkData; - if (ksys::act::acquireActor(&getDataMgr()->unk_00, &linkData)) { - UserData = 2; - getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &UserData, false); + if (ksys::act::acquireActor(&getDataMgr()->mBaseProcLink, &linkData)) { + mUserData = 2; + getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &mUserData, + false); } } } } - - -bool AirOctaFlyUp::handleMessage_( const ksys::Message& message) { +bool AirOctaFlyUp::handleMessage_(const ksys::Message& message) { if (message.getType().value == 0x80000c8) { u32* user_data = static_cast(message.getUserData()); auto* data_mgr = getDataMgr(); @@ -70,7 +71,7 @@ bool AirOctaFlyUp::handleMessage_( const ksys::Message& message) { } if (user_data != nullptr) { if (*user_data == 3) { - Ai::changeChild( "終了"); //END IN JAPANESE + Ai::changeChild("終了"); // END IN JAPANESE } else if (*user_data == 4) { ActionBase::setFinished(); } @@ -81,20 +82,20 @@ bool AirOctaFlyUp::handleMessage_( const ksys::Message& message) { } void AirOctaFlyUp::enter_(ksys::act::ai::InlineParamPack* params) { - if (auto* data_mgr = getDataMgr()){ - data_mgr->unk_114 = 0; - data_mgr->uking::AirOctaDataMgr::sub_71002fb17c(); + if (auto* data_mgr = getDataMgr()) { + data_mgr->unk_114 = 0; + data_mgr->uking::AirOctaDataMgr::sub_71002fb17c(); } - auto &mtx = mActor->getMtx(); + auto& mtx = mActor->getMtx(); AirOctaY = mtx(1, 3); ksys::act::ai::Ai::changeChild("開始"); } void AirOctaFlyUp::leave_() { - if (auto* data_mgr = getDataMgr()){ - data_mgr->unk_118 = *mTargetDistance_d + data_mgr->unk_118; - data_mgr->unk_114 = 0; - data_mgr->uking::AirOctaDataMgr::sub_71002fb17c(); + if (auto* data_mgr = getDataMgr()) { + data_mgr->unk_118 = *mTargetDistance_d + data_mgr->unk_118; + data_mgr->unk_114 = 0; + data_mgr->uking::AirOctaDataMgr::sub_71002fb17c(); } } @@ -105,4 +106,3 @@ void AirOctaFlyUp::loadParams_() { } } // namespace uking::ai - diff --git a/src/Game/AI/AI/aiAirOctaFlyUp.h b/src/Game/AI/AI/aiAirOctaFlyUp.h index c1f675d7..694b3e8e 100644 --- a/src/Game/AI/AI/aiAirOctaFlyUp.h +++ b/src/Game/AI/AI/aiAirOctaFlyUp.h @@ -1,15 +1,15 @@ #pragma once +#include "Game/AI/AI/aiAirOctaRoot.h" +#include "Game/AirOctaDataMgrTemp.h" +#include "KingSystem/ActorSystem/actActor.h" #include "KingSystem/ActorSystem/actAiAi.h" #include "KingSystem/ActorSystem/actBaseProcLink.h" -#include "KingSystem/ActorSystem/actActor.h" -#include "Game/AirOctaDataMgrTemp.h" namespace uking::ai { -class AirOctaFlyUp : - public ksys::act::ai::Ai { - public: static const sead::RuntimeTypeInfo::Interface* getRuntimeTypeInfoStatic() { static const sead::RuntimeTypeInfo::Derive typeInfo; return &typeInfo; } static bool checkDerivedRuntimeTypeInfoStatic( const sead::RuntimeTypeInfo::Interface* typeInfo) { const sead::RuntimeTypeInfo::Interface* clsTypeInfo = AirOctaFlyUp::getRuntimeTypeInfoStatic(); if (typeInfo == clsTypeInfo) return true; return ksys::act::ai::Ai::checkDerivedRuntimeTypeInfoStatic(typeInfo); } bool checkDerivedRuntimeTypeInfo(const sead::RuntimeTypeInfo::Interface* typeInfo) const override { return checkDerivedRuntimeTypeInfoStatic(typeInfo); } const sead::RuntimeTypeInfo::Interface* getRuntimeTypeInfo() const override { return getRuntimeTypeInfoStatic(); } +class AirOctaFlyUp : public ksys::act::ai::Ai { friend uking::AirOctaDataMgr; + public: explicit AirOctaFlyUp(const InitArg& arg); ~AirOctaFlyUp() override; @@ -20,27 +20,26 @@ public: void leave_() override; void loadParams_() override; void calc_() override; - //probably somewhere else, but it has to exist somewhere to get calc_ working - //void sub_710115b070(ksys::as::ASList *this_, f32 a2, f32 a3, const sead::SafeString& a4, int a5, int a6, bool a7); + protected: - // Added - uking::AirOctaDataMgr *getDataMgr() { return sead::DynamicCast(*mAirOctaDataMgr_a); } + uking::AirOctaDataMgr* getDataMgr() { + return sead::DynamicCast(*mAirOctaDataMgr_a); + } // static_param at offset 0x38 const float* mFlyUpDuration_s{}; // dynamic_param at offset 0x40 float* mTargetDistance_d{}; // aitree_variable at offset 0x48 - // for whatever reason, removing void* mAirOctaDataMgr_a; and replacing it with - // AirOctaDataMgr** mAirOctaDataMgr_a{}; will make loadParams_ be not matching with a difference of 0 and make - // handleMessage_ go from a difference of 5 to matching. ¯\_(ツ)_/¯ going from nonmatching to matching and - // making another function go from matching to not really unmatching is still net progress - // void* mAirOctaDataMgr_a + // for whatever reason, removing void* mAirOctaDataMgr_a; and replacing it with + // AirOctaDataMgr** mAirOctaDataMgr_a{}; will make loadParams_ be not matching with a difference + // of 0 and make handleMessage_ go from a difference of 5 to matching. ¯\_(ツ)_/¯ going from + // nonmatching to matching and making another function go from matching to not really unmatching + // is still net progress void* mAirOctaDataMgr_a AirOctaDataMgr** mAirOctaDataMgr_a{}; float AirOctaY{}; float mElapsedTime; - u32 UserData; + u32 mUserData; bool mIsEnded; - }; } // namespace uking::ai