From bc039919de088b8f8f5eba5988471032bde2dd0c Mon Sep 17 00:00:00 2001 From: bomba1749 <58524643+bomba1749@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:51:56 -0400 Subject: [PATCH] calc_ is almost done --- src/Game/AI/AI/aiAirOctaFlyUp.cpp | 61 +++++++++++++++++++++++++++---- src/Game/AI/AI/aiAirOctaFlyUp.h | 15 ++++++-- 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/src/Game/AI/AI/aiAirOctaFlyUp.cpp b/src/Game/AI/AI/aiAirOctaFlyUp.cpp index 32eec845..83bef613 100644 --- a/src/Game/AI/AI/aiAirOctaFlyUp.cpp +++ b/src/Game/AI/AI/aiAirOctaFlyUp.cpp @@ -2,7 +2,8 @@ #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" namespace uking::ai { @@ -13,11 +14,57 @@ AirOctaFlyUp::~AirOctaFlyUp() = default; bool AirOctaFlyUp::init_(sead::Heap* heap) { return ksys::act::ai::Ai::init_(heap); } +void sub_710115b070(ksys::as::ASList *this_, f32 a2, f32 a3, const sead::SafeString& a4, int a5, int a6, bool a7); +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 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" + if (!mIsEnded) { + auto currentChild = getCurrentChild(); + if (currentChild->isFinished() || currentChild->isFailed() ){ + auto ASList = getActor()->getASList(); + if (ASList){ + sub_710115b070(ASList, -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)) { + ksys::act::ActorConstDataAccess linkData; + if (ksys::act::acquireActor(&getDataMgr()->unk_00, &linkData)) { + UserData = 3; + getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &UserData, false); + } + } + } 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); + } + } + } +} + + bool AirOctaFlyUp::handleMessage_( const ksys::Message& message) { if (message.getType().value == 0x80000c8) { u32* user_data = static_cast(message.getUserData()); - auto* data_mgr = sead::DynamicCast((AirOctaDataMgr*)*mAirOctaDataMgr_a); + auto* data_mgr = getDataMgr(); if (!data_mgr) { return true; } @@ -34,20 +81,20 @@ bool AirOctaFlyUp::handleMessage_( const ksys::Message& message) { } void AirOctaFlyUp::enter_(ksys::act::ai::InlineParamPack* params) { - if (auto* data_mgr = sead::DynamicCast((AirOctaDataMgr*)*mAirOctaDataMgr_a)){ + if (auto* data_mgr = getDataMgr()){ data_mgr->unk_114 = 0; - data_mgr->sub_71002fb17c(); + data_mgr->uking::AirOctaDataMgr::sub_71002fb17c(); } - auto &mtx = getActor()->getMtx(); + auto &mtx = mActor->getMtx(); AirOctaY = mtx(1, 3); ksys::act::ai::Ai::changeChild("開始"); } void AirOctaFlyUp::leave_() { - if (auto* data_mgr = sead::DynamicCast((AirOctaDataMgr*)*mAirOctaDataMgr_a)){ + if (auto* data_mgr = getDataMgr()){ data_mgr->unk_118 = *mTargetDistance_d + data_mgr->unk_118; data_mgr->unk_114 = 0; - data_mgr->sub_71002fb17c(); + data_mgr->uking::AirOctaDataMgr::sub_71002fb17c(); } } diff --git a/src/Game/AI/AI/aiAirOctaFlyUp.h b/src/Game/AI/AI/aiAirOctaFlyUp.h index f849a0d7..ac16f8de 100644 --- a/src/Game/AI/AI/aiAirOctaFlyUp.h +++ b/src/Game/AI/AI/aiAirOctaFlyUp.h @@ -7,8 +7,8 @@ namespace uking::ai { class AirOctaFlyUp : - public ksys::act::ai::Ai { - SEAD_RTTI_OVERRIDE(AirOctaFlyUp, ksys::act::ai::Ai) + 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(); } friend uking::AirOctaDataMgr; public: explicit AirOctaFlyUp(const InitArg& arg); @@ -19,8 +19,13 @@ public: void enter_(ksys::act::ai::InlineParamPack* params) override; 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); } + // static_param at offset 0x38 const float* mFlyUpDuration_s{}; // dynamic_param at offset 0x40 @@ -33,6 +38,10 @@ protected: // void* mAirOctaDataMgr_a AirOctaDataMgr** mAirOctaDataMgr_a{}; float AirOctaY{}; + float mElapsedTime; + u32 UserData; + bool mIsEnded; + }; } // namespace uking::ai