Skip to content

Commit

Permalink
most of AirOctaFlyUp is done, some of AirOctaDataMgr is done (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
bomba1749 authored Mar 18, 2024
1 parent 72a0a82 commit f62a726
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 25 deletions.
26 changes: 13 additions & 13 deletions data/uking_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20236,7 +20236,7 @@ Address,Quality,Size,Name
0x00000071002fae08,O,000288,_ZNK5uking2ai19AirOctaBurnReaction27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x00000071002faf28,O,000092,_ZNK5uking2ai19AirOctaBurnReaction18getRuntimeTypeInfoEv
0x00000071002faf84,U,000504,
0x00000071002fb17c,U,000044,
0x00000071002fb17c,O,000044,_ZN5uking14AirOctaDataMgr23changeOctasYheightMaybeEv
0x00000071002fb1a8,U,000048,
0x00000071002fb1d8,U,000340,
0x00000071002fb32c,U,000020,
Expand All @@ -20245,24 +20245,24 @@ Address,Quality,Size,Name
0x00000071002fb388,O,000004,_ZN5uking2ai12AirOctaFlyUpD1Ev
0x00000071002fb38c,O,000036,_ZN5uking2ai12AirOctaFlyUpD0Ev
0x00000071002fb3b0,O,000008,_ZN5uking2ai12AirOctaFlyUp5init_EPN4sead4HeapE
0x00000071002fb3b8,U,000176,_ZN5uking2ai12AirOctaFlyUp6enter_EPN4ksys3act2ai15InlineParamPackE
0x00000071002fb468,U,001116,_ZN5uking2ai12AirOctaFlyUp5calc_Ev
0x00000071002fb8c4,U,000176,_ZN5uking2ai12AirOctaFlyUp6leave_Ev
0x00000071002fb974,O,000164,_ZN5uking2ai12AirOctaFlyUp11loadParams_Ev
0x00000071002fba18,U,000284,_ZN5uking2ai12AirOctaFlyUp14handleMessage_ERKN4ksys7MessageE
0x00000071002fbb34,O,000288,_ZNK5uking2ai12AirOctaFlyUp27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x00000071002fbc54,O,000092,_ZNK5uking2ai12AirOctaFlyUp18getRuntimeTypeInfoEv
0x00000071002fb3b8,O,000176,_ZN5uking2ai12AirOctaFlyUp6enter_EPN4ksys3act2ai15InlineParamPackE
0x00000071002fb468,M,001116,_ZN5uking2ai12AirOctaFlyUp5calc_Ev
0x00000071002fb8c4,O,000176,_ZN5uking2ai12AirOctaFlyUp6leave_Ev
0x00000071002fb974,M,000164,_ZN5uking2ai12AirOctaFlyUp11loadParams_Ev
0x00000071002fba18,O,000284,_ZN5uking2ai12AirOctaFlyUp14handleMessage_ERKN4ksys7MessageE
0x00000071002fbb34,U,000288,
0x00000071002fbc54,U,000092,
0x00000071002fbcb0,U,000052,AI_AI_AirOctaReaction::ctor
0x00000071002fbce4,O,000004,_ZN5uking2ai15AirOctaReactionD1Ev
0x00000071002fbce8,O,000036,_ZN5uking2ai15AirOctaReactionD0Ev
0x00000071002fbd0c,O,000008,_ZN5uking2ai15AirOctaReaction5init_EPN4sead4HeapE
0x00000071002fbd14,U,000044,_ZN5uking2ai15AirOctaReaction6enter_EPN4ksys3act2ai15InlineParamPackE
0x00000071002fbd40,U,000004,_ZN5uking2ai15AirOctaReaction5calc_Ev
0x00000071002fbd44,O,000004,_ZN5uking2ai15AirOctaReaction6leave_Ev
0x00000071002fbd48,U,000084,_ZN5uking2ai15AirOctaReaction11loadParams_Ev
0x00000071002fbd9c,U,000132,uking::ai::AirOctaReaction::m34
0x00000071002fbe20,U,000008,uking::ai::AirOctaReaction::m35
0x00000071002fbe28,U,000316,uking::ai::AirOctaReaction::m42
0x00000071002fbd48,M,000084,_ZN5uking2ai15AirOctaReaction11loadParams_Ev
0x00000071002fbd9c,U,000132,_ZN5uking2ai15AirOctaReaction3m34Emj
0x00000071002fbe20,U,000008,_ZN5uking2ai15AirOctaReaction3m35EmjcPN4ksys3act2ai15InlineParamPackE
0x00000071002fbe28,U,000316,_ZN5uking2ai15AirOctaReaction3m42EPN4ksys3act2ai15InlineParamPackE
0x00000071002fbf64,O,000008,_ZNK5uking2ai15AirOctaReaction27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x00000071002fbf6c,O,000092,_ZNK5uking2ai15AirOctaReaction18getRuntimeTypeInfoEv
0x00000071002fbfc8,U,000008,uking::ai::EnemyDefaultReaction::m36
Expand Down Expand Up @@ -45194,7 +45194,7 @@ Address,Quality,Size,Name
0x00000071006dfe4c,O,000500,_ZN5uking3dmg17DamageManagerBase11applyDamageERi
0x00000071006e0040,O,000204,_ZN5uking3dmg17DamageManagerBase21handleDamageForPlayerEPjS2_S2_S2_S2_
0x00000071006e010c,O,000072,_ZN5uking3dmg17DamageManagerBase9addDamageEliiiiii
0x00000071006e0154,U,000004,DamageMgrBase::isSlowTime
0x00000071006e0154,U,000004,_ZN5uking3dmg17DamageManagerBase10isSlowTimeEv
0x00000071006e0158,U,000324,DamageMgrBase::m29
0x00000071006e029c,U,002296,DamageMgrBase::m30
0x00000071006e0b94,O,000056,_ZN5uking3dmg17DamageManagerBase9getDamageEv
Expand Down
8 changes: 8 additions & 0 deletions src/Game/AI/AI/AirOcta/AirOctaDataMgr.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "Game/AI/AI/AirOcta/AirOctaDataMgr.h"
namespace uking {

void AirOctaDataMgr::changeOctasYheightMaybe() {
float result = vec_EC.y + unk_110 + unk_114 + unk_118 + unk_11c;
vec_F8.y = result;
}
} // namespace uking
42 changes: 42 additions & 0 deletions src/Game/AI/AI/AirOcta/AirOctaDataMgr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#include <container/seadObjArray.h>
#include <prim/seadRuntimeTypeInfo.h>
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/ActorSystem/actAiClassDef.h"

namespace uking {
class AirOctaDataMgr {
SEAD_RTTI_BASE(AirOctaDataMgr)
public:
ksys::act::BaseProcLink& getProc() { return mBaseProcLink; }
void changeOctasYheightMaybe();

struct MessageData {
u32 unk_00;
u64 unk_08;
};

/* 0x08 */ ksys::act::BaseProcLink mBaseProcLink;
/* 0x18 */ ksys::act::BaseProcLink mBaseProcLink2;
/* 0x28 */ void* unk_28{};
/* 0x30 */ u32 unk_30{};
/* 0x34 */ sead::Vector3f unk_34{sead::Vector3f::zero};
/* 0x40 */ void* unk_40{};
/* 0x48 */ u32 unk_48{};
/* 0x4C */ sead::Vector3f unk_4C{sead::Vector3f::zero};
/* 0x58 */ sead::FixedObjArray<MessageData, 4> obj_arr;
/* 0xD8 */ u16 unk_D8{};
/* 0xDA */ bool unk_DA{};
/* 0xDC */ u32 unk_DC;
/* 0xE0 */ sead::Vector3f vec_E0{sead::Vector3f::zero};
/* 0xEC */ sead::Vector3f vec_EC{sead::Vector3f::zero};
/* 0xF8 */ sead::Vector3f vec_F8{sead::Vector3f::zero};
/*0x104 */ sead::Vector3f vec_104{sead::Vector3f::zero};
/*0x110 */ float unk_110;
/*0x114 */ float unk_114;
/*0x118 */ float unk_118;
/*0x11c */ float unk_11c;
/*0x120 */ u32 mFlags;
};
} // namespace uking
2 changes: 2 additions & 0 deletions src/Game/AI/AI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,8 @@ target_sources(uking PRIVATE
aiRideHorseAI.h
aiRitoHeroSoulGiftRoot.cpp
aiRitoHeroSoulGiftRoot.h
AirOcta/AirOctaDataMgr.cpp
AirOcta/AirOctaDataMgr.h
aiRodEnemyFindPlayer.cpp
aiRodEnemyFindPlayer.h
aiRodRoot.cpp
Expand Down
93 changes: 90 additions & 3 deletions src/Game/AI/AI/aiAirOctaFlyUp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#include "Game/AI/AI/aiAirOctaFlyUp.h"
#include "Game/AI/AI/AirOcta/AirOctaDataMgr.h"
#include "Game/AI/AI/aiAirOctaRoot.h"
#include "KingSystem/ActorSystem/AS/ASList.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/ActorSystem/actActorConstDataAccess.h"
#include "KingSystem/ActorSystem/actAiAi.h"
#include "KingSystem/ActorSystem/actBaseProcLink.h"
#include "KingSystem/System/VFR.h"
#include "KingSystem/Utils/Thread/Message.h"

namespace uking::ai {

Expand All @@ -9,15 +18,93 @@ AirOctaFlyUp::~AirOctaFlyUp() = default;
bool AirOctaFlyUp::init_(sead::Heap* heap) {
return ksys::act::ai::Ai::init_(heap);
}
// NON_MATCHING: stack for the sendMessage() message, type that y is casted to
void AirOctaFlyUp::calc_() {
auto* data_mgr = getDataMgr();
if (!data_mgr) {
return;
}
auto dt = ksys::VFR::instance()->getDeltaTime();
mElapsedTime += dt;
auto fly_up_turning_pts =
(sead::Mathf::min(1.0f, mElapsedTime / *mFlyUpDuration_s) * 2.f) - 1.f;
auto fly_up_multiplier = fly_up_turning_pts < 1.f ?
sead::Mathf::exp((fly_up_turning_pts * 2.f) - 1.f * 10.f) :
2.f - sead::Mathf::exp((fly_up_turning_pts * 2.f) - 1.f * -10.f);
data_mgr->unk_114 = fly_up_multiplier * 0.5f * *mTargetDistance_d;
data_mgr->changeOctasYheightMaybe();
auto y = getActor()->getMtx().m[1][3];
if (isCurrentChild("終了")) { // "End"
if (!mIsEnded) {
auto currentChild = getCurrentChild();
if (currentChild->isFinished() || currentChild->isFailed()) {
auto as_list = getActor()->getASList();
if (as_list) {
as_list->startAnimationMaybe(-1.f, -1.f, "Wait", 0, 0, true);
}
mIsEnded = true;
} else if (!mIsEnded) {
return;
}
}
if ((fly_up_multiplier * 0.5f >= 1.f && y >= getDataMgr()->vec_F8.y) ||
mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) {
ksys::act::ActorConstDataAccess linkData;
if (ksys::act::acquireActor(&getDataMgr()->mBaseProcLink, &linkData)) {
mUserData = 3;
getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &mUserData,
false);
}
}
} else if (y - AirOctaY >= *mTargetDistance_d * 0.9f ||
mElapsedTime >= (*mFlyUpDuration_s * 3.0f)) {
ksys::act::ActorConstDataAccess linkData;
if (ksys::act::acquireActor(&getDataMgr()->mBaseProcLink, &linkData)) {
mUserData = 2;
getActor()->sendMessage(*linkData.getMessageTransceiverId(), 0x80000C8, &mUserData,
false);
}
}
}

bool AirOctaFlyUp::handleMessage_(const ksys::Message& message) {
if (message.getType().value != 0x80000c8) {
return false;
}
u32* user_data = static_cast<u32*>(message.getUserData());
auto* data_mgr = getDataMgr();
if (!data_mgr) {
return true;
}
if (user_data == nullptr) {
return true;
}
if (*user_data == 3) {
Ai::changeChild("終了"); // Ended
} else if (*user_data == 4) {
ActionBase::setFinished();
}
return true;
}

void AirOctaFlyUp::enter_(ksys::act::ai::InlineParamPack* params) {
ksys::act::ai::Ai::enter_(params);
if (auto* data_mgr = getDataMgr()) {
data_mgr->unk_114 = 0;
data_mgr->changeOctasYheightMaybe();
}
auto& mtx = mActor->getMtx();
AirOctaY = mtx(1, 3);
ksys::act::ai::Ai::changeChild("開始");
}

void AirOctaFlyUp::leave_() {
ksys::act::ai::Ai::leave_();
if (auto* data_mgr = getDataMgr()) {
data_mgr->unk_118 += *mTargetDistance_d;
data_mgr->unk_114 = 0;
data_mgr->changeOctasYheightMaybe();
}
}

// NON_MATCHING: addresses that variables are loaded from
void AirOctaFlyUp::loadParams_() {
getStaticParam(&mFlyUpDuration_s, "FlyUpDuration");
getDynamicParam(&mTargetDistance_d, "TargetDistance");
Expand Down
28 changes: 23 additions & 5 deletions src/Game/AI/AI/aiAirOctaFlyUp.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
#pragma once

#include "Game/AI/AI/AirOcta/AirOctaDataMgr.h"
#include "KingSystem/ActorSystem/actAiAi.h"

namespace uking::ai {

namespace uking {
class AirOctaDataMgr;
namespace ai {
class AirOctaFlyUp : public ksys::act::ai::Ai {
SEAD_RTTI_OVERRIDE(AirOctaFlyUp, ksys::act::ai::Ai)
friend uking::AirOctaDataMgr;

public:
explicit AirOctaFlyUp(const InitArg& arg);
~AirOctaFlyUp() override;

bool handleMessage_(const ksys::Message& message) override;
bool init_(sead::Heap* heap) override;
void enter_(ksys::act::ai::InlineParamPack* params) override;
void leave_() override;
void loadParams_() override;
void calc_() override;

protected:
AirOctaDataMgr* getDataMgr() const {
return sead::DynamicCast<AirOctaDataMgr>(*mAirOctaDataMgr_a);
}
// static_param at offset 0x38
const float* mFlyUpDuration_s{};
// dynamic_param at offset 0x40
float* mTargetDistance_d{};
// aitree_variable at offset 0x48
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 mUserData;
bool mIsEnded;
};

} // namespace uking::ai
} // namespace ai
} // namespace uking
1 change: 1 addition & 0 deletions src/KingSystem/ActorSystem/AS/ASList.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

13 changes: 13 additions & 0 deletions src/KingSystem/ActorSystem/AS/ASList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once
#include "KingSystem/ActorSystem/actActor.h"
namespace ksys::as {
class ASList {
public:
void startAnimationMaybe(f32 a2, f32 a3, const sead::SafeString& animation, int a5, int a6,
bool a7);
bool goLimpFromHeadShotMaybe(u32 a1, const sead::SafeString& a2, u32 a3); // x_8
s64 x_2(u32 a1, int a2, bool m, u32 a4);
u8 sub_710115D3B8();
};

} // namespace ksys::as
4 changes: 4 additions & 0 deletions src/KingSystem/ActorSystem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
target_sources(uking PRIVATE
AS/ASList.h
AS/ASList.cpp

Attention/actAttention.cpp
Attention/actAttention.h

Expand All @@ -9,6 +12,7 @@ target_sources(uking PRIVATE
Awareness/actAwarenessInstance.cpp
Awareness/actAwarenessInstance.h


LOD/actLodState.cpp
LOD/actLodState.h

Expand Down
13 changes: 10 additions & 3 deletions src/KingSystem/ActorSystem/actActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ namespace gsys {
class Model;
} // namespace gsys

namespace uking::dmg {
class DamageManagerBase;
} // namespace uking::dmg

namespace ksys {

namespace as {
Expand Down Expand Up @@ -137,6 +141,7 @@ class Actor : public BaseProc, public ActorMessageTransceiver::IHandler {
const ActorParam* getParam() const { return mActorParam; }
map::Object* getMapObject() const { return mMapObject; }
const map::MubinIter& getMapObjIter() const { return mMapObjIter; }
as::ASList* getASList() const { return mASList; }

const sead::Matrix34f& getMtx() const { return mMtx; }
const sead::Vector3f& getVelocity() const { return mVelocity; }
Expand All @@ -146,6 +151,8 @@ class Actor : public BaseProc, public ActorMessageTransceiver::IHandler {
phys::RigidBody* getTgtBody() const { return mTgtBody; }

const MesTransceiverId* getMesTransceiverId() const { return mMsgTransceiver.getId(); }
void sendMessage(const MesTransceiverId& dest, const MessageType& type, void* user_data,
bool ack);

f32 getDeleteDistance() const {
return sead::Mathf::sqrt(sead::Mathf::clampMin(mDeleteDistanceSq, 0.0f));
Expand Down Expand Up @@ -229,11 +236,11 @@ class Actor : public BaseProc, public ActorMessageTransceiver::IHandler {
virtual void m90();
virtual void m91();
virtual void m92();
virtual void m93();
virtual void m93(int a1, float a2);
virtual void m94();
virtual void m95();
virtual void m96();
virtual void getChemicalStuff();
virtual Chemical* getChemicalStuff();
virtual void getWeapons();
virtual void getArmors();
virtual void m100();
Expand Down Expand Up @@ -263,7 +270,7 @@ class Actor : public BaseProc, public ActorMessageTransceiver::IHandler {
virtual void onPlacementObjReset();
virtual void getAtk();
virtual void m126();
virtual void getDamageMgr();
virtual uking::dmg::DamageManagerBase* getDamageMgr();
virtual void m128();
virtual void m129();
virtual void getPlayerRideInfo();
Expand Down
4 changes: 3 additions & 1 deletion src/KingSystem/ActorSystem/actActorLinkConstDataAccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <prim/seadSafeString.h>

namespace ksys {

struct MesTransceiverId;
namespace act {

class BaseProc;
Expand Down Expand Up @@ -36,6 +36,8 @@ class ActorLinkConstDataAccess {

bool hasProc() const { return mProc != nullptr; }

const MesTransceiverId* getMessageTransceiverId() const;

protected:
friend class ActorConstDataAccess;
friend class BaseProc;
Expand Down

0 comments on commit f62a726

Please sign in to comment.