Decompile some Action classes (#104)

* various action classes

* rename instanceset fns

* rename isFork -> isChangeable
This commit is contained in:
notyourav 2022-10-17 23:27:57 -07:00 committed by GitHub
parent bc6fe73df1
commit 2f62d26424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 1062 additions and 823 deletions

View File

@ -893,17 +893,17 @@ action::Escape:
action::EscapeBackTurn: action::EscapeBackTurn:
status: pending status: pending
action::EventAddGameDataIntAction: action::EventAddGameDataIntAction:
status: pending status: done
action::EventAddGameDataToRupeeAction: action::EventAddGameDataToRupeeAction:
status: pending status: done
action::EventAppearCheckPointNum: action::EventAppearCheckPointNum:
status: pending status: done
action::EventAppearFlyDistance: action::EventAppearFlyDistance:
status: pending status: done
action::EventAppearGolfCount: action::EventAppearGolfCount:
status: pending status: done
action::EventAppearRaceResult: action::EventAppearRaceResult:
status: pending status: done
action::EventAppearRupeeAction: action::EventAppearRupeeAction:
status: pending status: pending
action::EventAutoSaveAction: action::EventAutoSaveAction:
@ -973,9 +973,9 @@ action::EventFlagOFFAction:
action::EventFlagONAction: action::EventFlagONAction:
status: pending status: pending
action::EventHoverNullASPlay: action::EventHoverNullASPlay:
status: pending status: done
action::EventHoverNullASPlayBase: action::EventHoverNullASPlayBase:
status: pending status: done
action::EventIncreaseFameAction: action::EventIncreaseFameAction:
status: pending status: pending
action::EventIncreaseGameDataIntAction: action::EventIncreaseGameDataIntAction:
@ -2093,13 +2093,13 @@ action::KokkoThrown:
action::KorokFlowerAppear: action::KorokFlowerAppear:
status: pending status: pending
action::KorokFlowerVanish: action::KorokFlowerVanish:
status: pending status: done
action::KorokFlowerWait: action::KorokFlowerWait:
status: pending status: done
action::KorokTargetMove: action::KorokTargetMove:
status: pending status: done
action::KorokTargetWait: action::KorokTargetWait:
status: pending status: done
action::LandOnCeil: action::LandOnCeil:
status: pending status: pending
action::LandRagdoll: action::LandRagdoll:
@ -2421,7 +2421,7 @@ action::NPCSellHorse:
action::NPCSellItem: action::NPCSellItem:
status: pending status: pending
action::NPCStartTurnToPlayer: action::NPCStartTurnToPlayer:
status: pending status: done
action::NpcSwimMove: action::NpcSwimMove:
status: pending status: pending
action::NpcSwimNavMove: action::NpcSwimNavMove:

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit c355f876626638d265c7eb7bf90928e25e161bec Subproject commit 3077c49affa2770c5336764ca062ed50e7444b5b

@ -1 +1 @@
Subproject commit 24d64b1255378c36299f84a28297e16e37b8e569 Subproject commit 79f528be96a3d7c844847ab6371e0ae6b38c83c7

View File

@ -70,7 +70,7 @@ bool ForkAI::isFailed() const {
for (; i < num_children; ++i) { for (; i < num_children; ++i) {
auto* child = getChild(i); auto* child = getChild(i);
failed |= child->isFailed(); failed |= child->isFailed();
if (!child->isFinished() && !child->isFailed() && !child->isFlag4Set()) if (!child->isFinished() && !child->isFailed() && !child->isChangeable())
break; break;
} }
return i == num_children && failed; return i == num_children && failed;
@ -86,16 +86,16 @@ bool ForkAI::isFinished() const {
break; break;
if (child->isFinished()) if (child->isFinished())
finished = true; finished = true;
else if (!child->isFlag4Set()) else if (!child->isChangeable())
break; break;
} }
return i == num_children && finished; return i == num_children && finished;
} }
bool ForkAI::isFlag4Set() const { bool ForkAI::isChangeable() const {
const int num_children = getNumChildren(); const int num_children = getNumChildren();
for (int i = 0; i < num_children; ++i) { for (int i = 0; i < num_children; ++i) {
if (!getChild(i)->isFlag4Set()) if (!getChild(i)->isChangeable())
return false; return false;
} }
return true; return true;

View File

@ -17,7 +17,7 @@ public:
void leave_() override; void leave_() override;
bool isFailed() const override; bool isFailed() const override;
bool isFinished() const override; bool isFinished() const override;
bool isFlag4Set() const override; bool isChangeable() const override;
bool handleMessage_(const ksys::Message& message) override; bool handleMessage_(const ksys::Message& message) override;
bool handleAck_(const ksys::MessageAck& message) override; bool handleAck_(const ksys::MessageAck& message) override;
void getCurrentName(sead::BufferedSafeString* name, ActionBase* last) const override; void getCurrentName(sead::BufferedSafeString* name, ActionBase* last) const override;

View File

@ -1,4 +1,5 @@
#include "Game/AI/Action/actionEventAddGameDataIntAction.h" #include "Game/AI/Action/actionEventAddGameDataIntAction.h"
#include "KingSystem/GameData/gdtManager.h"
namespace uking::action { namespace uking::action {
@ -13,6 +14,14 @@ bool EventAddGameDataIntAction::init_(sead::Heap* heap) {
void EventAddGameDataIntAction::enter_(ksys::act::ai::InlineParamPack* params) { void EventAddGameDataIntAction::enter_(ksys::act::ai::InlineParamPack* params) {
ksys::act::ai::Action::enter_(params); ksys::act::ai::Action::enter_(params);
if (mGameDataIntSrcName_d.isEmpty() || mGameDataIntDstName_d.isEmpty()) {
setFailed();
mFlags.set(Flag::Changeable);
return;
}
mIsReady = true;
} }
void EventAddGameDataIntAction::leave_() { void EventAddGameDataIntAction::leave_() {
@ -27,6 +36,32 @@ void EventAddGameDataIntAction::loadParams_() {
void EventAddGameDataIntAction::calc_() { void EventAddGameDataIntAction::calc_() {
ksys::act::ai::Action::calc_(); ksys::act::ai::Action::calc_();
if (isFinished() || isFailed()) {
return;
}
if (!mIsReady) {
setFinished();
mFlags.set(Flag::Changeable);
return;
}
mIsReady = false;
auto* gdm = ksys::gdt::Manager::instance();
if (gdm == nullptr) {
setFailed();
mFlags.set(Flag::Changeable);
return;
}
s32 value = 0;
if (gdm->getParam().get().getS32(&value, mGameDataIntSrcName_d)) {
if (*mIsSignInversion_d) {
value = -value;
}
gdm->incrementS32(value, mGameDataIntDstName_d);
}
} }
} // namespace uking::action } // namespace uking::action

View File

@ -24,6 +24,8 @@ protected:
sead::SafeString mGameDataIntDstName_d{}; sead::SafeString mGameDataIntDstName_d{};
// dynamic_param at offset 0x38 // dynamic_param at offset 0x38
sead::SafeString mGameDataIntSrcName_d{}; sead::SafeString mGameDataIntSrcName_d{};
bool mIsReady{};
}; };
} // namespace uking::action } // namespace uking::action

View File

@ -1,4 +1,6 @@
#include "Game/AI/Action/actionEventAddGameDataToRupeeAction.h" #include "Game/AI/Action/actionEventAddGameDataToRupeeAction.h"
#include "KingSystem/GameData/gdtManager.h"
#include "KingSystem/System/UIGlue.h"
namespace uking::action { namespace uking::action {
@ -13,6 +15,19 @@ bool EventAddGameDataToRupeeAction::init_(sead::Heap* heap) {
void EventAddGameDataToRupeeAction::enter_(ksys::act::ai::InlineParamPack* params) { void EventAddGameDataToRupeeAction::enter_(ksys::act::ai::InlineParamPack* params) {
ksys::act::ai::Action::enter_(params); ksys::act::ai::Action::enter_(params);
s32 val = 0;
auto* gdm = ksys::gdt::Manager::instance();
if (!gdm->getParam().get().getS32(&val, mGameDataIntAddValueName_d)) {
ksys::ui::initRupeeCounter();
return;
}
if (*mIsSignInversion_d) {
val = -val;
}
gdm->incrementS32(val, "CurrentRupee");
ksys::ui::initRupeeCounter();
} }
void EventAddGameDataToRupeeAction::leave_() { void EventAddGameDataToRupeeAction::leave_() {
@ -26,6 +41,10 @@ void EventAddGameDataToRupeeAction::loadParams_() {
void EventAddGameDataToRupeeAction::calc_() { void EventAddGameDataToRupeeAction::calc_() {
ksys::act::ai::Action::calc_(); ksys::act::ai::Action::calc_();
if (!ksys::ui::isRupeeCounterActive()) {
setFinished();
}
} }
} // namespace uking::action } // namespace uking::action

View File

@ -1,4 +1,5 @@
#include "Game/AI/Action/actionEventAppearCheckPointNum.h" #include "Game/AI/Action/actionEventAppearCheckPointNum.h"
#include "Game/UI/uiUtils.h"
namespace uking::action { namespace uking::action {
@ -11,6 +12,11 @@ bool EventAppearCheckPointNum::init_(sead::Heap* heap) {
return ksys::act::ai::Action::init_(heap); return ksys::act::ai::Action::init_(heap);
} }
bool EventAppearCheckPointNum::oneShot_() {
ui::setShowCheckPoint(*mIconType_d, mGameDataIntTargetCounter_d);
return ksys::act::ai::Action::oneShot_();
}
void EventAppearCheckPointNum::loadParams_() { void EventAppearCheckPointNum::loadParams_() {
getDynamicParam(&mIconType_d, "IconType"); getDynamicParam(&mIconType_d, "IconType");
getDynamicParam(&mGameDataIntTargetCounter_d, "GameDataIntTargetCounter"); getDynamicParam(&mGameDataIntTargetCounter_d, "GameDataIntTargetCounter");

View File

@ -14,6 +14,8 @@ public:
void loadParams_() override; void loadParams_() override;
protected: protected:
bool oneShot_() override;
// dynamic_param at offset 0x20 // dynamic_param at offset 0x20
int* mIconType_d{}; int* mIconType_d{};
// dynamic_param at offset 0x28 // dynamic_param at offset 0x28

View File

@ -1,4 +1,5 @@
#include "Game/AI/Action/actionEventAppearFlyDistance.h" #include "Game/AI/Action/actionEventAppearFlyDistance.h"
#include "Game/UI/uiUtils.h"
namespace uking::action { namespace uking::action {
@ -10,6 +11,11 @@ bool EventAppearFlyDistance::init_(sead::Heap* heap) {
return ksys::act::ai::Action::init_(heap); return ksys::act::ai::Action::init_(heap);
} }
bool EventAppearFlyDistance::oneShot_() {
ui::setShowFlyDistance(mGameDataFloatDistance_d);
return ksys::act::ai::Action::oneShot_();
}
void EventAppearFlyDistance::loadParams_() { void EventAppearFlyDistance::loadParams_() {
getDynamicParam(&mGameDataFloatDistance_d, "GameDataFloatDistance"); getDynamicParam(&mGameDataFloatDistance_d, "GameDataFloatDistance");
} }

View File

@ -14,6 +14,8 @@ public:
void loadParams_() override; void loadParams_() override;
protected: protected:
bool oneShot_() override;
// dynamic_param at offset 0x20 // dynamic_param at offset 0x20
sead::SafeString mGameDataFloatDistance_d{}; sead::SafeString mGameDataFloatDistance_d{};
}; };

View File

@ -1,4 +1,5 @@
#include "Game/AI/Action/actionEventAppearGolfCount.h" #include "Game/AI/Action/actionEventAppearGolfCount.h"
#include "Game/UI/uiUtils.h"
namespace uking::action { namespace uking::action {
@ -10,6 +11,11 @@ bool EventAppearGolfCount::init_(sead::Heap* heap) {
return ksys::act::ai::Action::init_(heap); return ksys::act::ai::Action::init_(heap);
} }
bool EventAppearGolfCount::oneShot_() {
ui::setShowGolfCount(mGameDataIntTargetCounter_d);
return ksys::act::ai::Action::oneShot_();
}
void EventAppearGolfCount::loadParams_() { void EventAppearGolfCount::loadParams_() {
getDynamicParam(&mGameDataIntTargetCounter_d, "GameDataIntTargetCounter"); getDynamicParam(&mGameDataIntTargetCounter_d, "GameDataIntTargetCounter");
} }

View File

@ -14,6 +14,8 @@ public:
void loadParams_() override; void loadParams_() override;
protected: protected:
bool oneShot_() override;
// dynamic_param at offset 0x20 // dynamic_param at offset 0x20
sead::SafeString mGameDataIntTargetCounter_d{}; sead::SafeString mGameDataIntTargetCounter_d{};
}; };

View File

@ -1,4 +1,5 @@
#include "Game/AI/Action/actionEventAppearRaceResult.h" #include "Game/AI/Action/actionEventAppearRaceResult.h"
#include "Game/UI/uiUtils.h"
namespace uking::action { namespace uking::action {
@ -10,6 +11,11 @@ bool EventAppearRaceResult::init_(sead::Heap* heap) {
return ksys::act::ai::Action::init_(heap); return ksys::act::ai::Action::init_(heap);
} }
bool EventAppearRaceResult::oneShot_() {
ui::setShowRaceResult(*mResultType_d);
return ksys::act::ai::Action::oneShot_();
}
void EventAppearRaceResult::loadParams_() { void EventAppearRaceResult::loadParams_() {
getDynamicParam(&mResultType_d, "ResultType"); getDynamicParam(&mResultType_d, "ResultType");
} }

View File

@ -14,6 +14,8 @@ public:
void loadParams_() override; void loadParams_() override;
protected: protected:
bool oneShot_() override;
// dynamic_param at offset 0x20 // dynamic_param at offset 0x20
int* mResultType_d{}; int* mResultType_d{};
}; };

View File

@ -1,4 +1,5 @@
#include "Game/AI/Action/actionEventHoverNullASPlay.h" #include "Game/AI/Action/actionEventHoverNullASPlay.h"
#include "KingSystem/Physics/System/physInstanceSet.h"
namespace uking::action { namespace uking::action {
@ -12,9 +13,13 @@ bool EventHoverNullASPlay::init_(sead::Heap* heap) {
void EventHoverNullASPlay::enter_(ksys::act::ai::InlineParamPack* params) { void EventHoverNullASPlay::enter_(ksys::act::ai::InlineParamPack* params) {
EventHoverNullASPlayBase::enter_(params); EventHoverNullASPlayBase::enter_(params);
mCCAccessor.changeMotionType(mActor->getCharacterController(), ksys::act::MotionType::Hover);
} }
void EventHoverNullASPlay::leave_() { void EventHoverNullASPlay::leave_() {
resetAllMotion(mActor);
EventHoverNullASPlayBase::leave_(); EventHoverNullASPlayBase::leave_();
} }

View File

@ -1,7 +1,9 @@
#pragma once #pragma once
#include "Game/AI/Action/actionEventHoverNullASPlayBase.h" #include "Game/AI/Action/actionEventHoverNullASPlayBase.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/ActorSystem/actAiAction.h" #include "KingSystem/ActorSystem/actAiAction.h"
#include "KingSystem/ActorSystem/actCCAccessor.h"
namespace uking::action { namespace uking::action {
@ -18,6 +20,13 @@ public:
protected: protected:
void calc_() override; void calc_() override;
void resetAllMotion(ksys::act::Actor* actor) {
mCCAccessor.resetRigidBodyMotion(actor);
mCCAccessor.resetMotionType(actor->getCharacterController());
}
ksys::act::CCAccessor mCCAccessor;
}; };
} // namespace uking::action } // namespace uking::action

View File

@ -12,7 +12,8 @@ bool EventHoverNullASPlayBase::init_(sead::Heap* heap) {
} }
void EventHoverNullASPlayBase::enter_(ksys::act::ai::InlineParamPack* params) { void EventHoverNullASPlayBase::enter_(ksys::act::ai::InlineParamPack* params) {
ksys::act::ai::Action::enter_(params); playAS(mASName_d.cstr(), *mIsIgnoreSame_d, *mASSlot_d, *mSequenceBank_d, -1.0);
mFlags.set(ksys::act::ai::Action::Flag::Changeable);
} }
void EventHoverNullASPlayBase::leave_() { void EventHoverNullASPlayBase::leave_() {
@ -28,7 +29,9 @@ void EventHoverNullASPlayBase::loadParams_() {
} }
void EventHoverNullASPlayBase::calc_() { void EventHoverNullASPlayBase::calc_() {
ksys::act::ai::Action::calc_(); if (!isFailed() && isFinishedAS(*mASSlot_d, *mSequenceBank_d)) {
setFinished();
}
} }
} // namespace uking::action } // namespace uking::action

View File

@ -12,7 +12,7 @@ bool Fork::init_(sead::Heap* heap) {
void Fork::enter_(ksys::act::ai::InlineParamPack* params) { void Fork::enter_(ksys::act::ai::InlineParamPack* params) {
if (*mIsChangeable_s) if (*mIsChangeable_s)
mFlags.set(Flag::_4); mFlags.set(Flag::Changeable);
} }
void Fork::leave_() { void Fork::leave_() {
@ -37,7 +37,7 @@ void Fork::setEndState() {
setFailed(); setFailed();
break; break;
case 2: case 2:
mFlags.set(ksys::act::ai::ActionBase::Flag::_4); mFlags.set(ksys::act::ai::ActionBase::Flag::Changeable);
break; break;
} }
} }

View File

@ -15,7 +15,7 @@ bool GameDataAddFloat::oneShot_() {
auto* gdm = ksys::gdt::Manager::instance(); auto* gdm = ksys::gdt::Manager::instance();
if (!gdm) { if (!gdm) {
setFailed(); setFailed();
mFlags.set(Flag::_4); mFlags.set(Flag::Changeable);
return false; return false;
} }

View File

@ -15,7 +15,7 @@ bool GameDataAddInt::oneShot_() {
auto* gdm = ksys::gdt::Manager::instance(); auto* gdm = ksys::gdt::Manager::instance();
if (!gdm) { if (!gdm) {
setFailed(); setFailed();
mFlags.set(Flag::_4); mFlags.set(Flag::Changeable);
return false; return false;
} }

View File

@ -15,7 +15,7 @@ bool GameDataAddVec3::oneShot_() {
auto* gdm = ksys::gdt::Manager::instance(); auto* gdm = ksys::gdt::Manager::instance();
if (!gdm) { if (!gdm) {
setFailed(); setFailed();
mFlags.set(Flag::_4); mFlags.set(Flag::Changeable);
return false; return false;
} }

View File

@ -1,4 +1,6 @@
#include "Game/AI/Action/actionKorokFlowerAppear.h" #include "Game/AI/Action/actionKorokFlowerAppear.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
namespace uking::action { namespace uking::action {
@ -11,7 +13,18 @@ bool KorokFlowerAppear::init_(sead::Heap* heap) {
} }
void KorokFlowerAppear::enter_(ksys::act::ai::InlineParamPack* params) { void KorokFlowerAppear::enter_(ksys::act::ai::InlineParamPack* params) {
ksys::act::ai::Action::enter_(params); mActor->getActorFlags2().reset(ksys::act::Actor::ActorFlag2::_20);
auto* main_body = mActor->getMainBody();
auto* tgt_body = mActor->getTgtBody();
if (main_body != nullptr && tgt_body != nullptr) {
main_body->setContactNone();
main_body->resetFlag200();
tgt_body->setContactNone();
tgt_body->resetFlag200();
}
mFlags.set(Flag::Changeable);
setFinished();
} }
void KorokFlowerAppear::leave_() { void KorokFlowerAppear::leave_() {

View File

@ -1,4 +1,6 @@
#include "Game/AI/Action/actionKorokFlowerVanish.h" #include "Game/AI/Action/actionKorokFlowerVanish.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
namespace uking::action { namespace uking::action {
@ -11,7 +13,17 @@ bool KorokFlowerVanish::init_(sead::Heap* heap) {
} }
void KorokFlowerVanish::enter_(ksys::act::ai::InlineParamPack* params) { void KorokFlowerVanish::enter_(ksys::act::ai::InlineParamPack* params) {
ksys::act::ai::Action::enter_(params); mActor->emitBasicSigOn();
mActor->getActorFlags2().set(ksys::act::Actor::ActorFlag2::_20);
auto* main_body = mActor->getMainBody();
auto* tgt_body = mActor->getTgtBody();
if (main_body != nullptr && tgt_body != nullptr) {
main_body->setContactAll();
main_body->setFlag200();
tgt_body->setContactAll();
tgt_body->setFlag200();
}
} }
void KorokFlowerVanish::leave_() { void KorokFlowerVanish::leave_() {

View File

@ -1,4 +1,5 @@
#include "Game/AI/Action/actionKorokFlowerWait.h" #include "Game/AI/Action/actionKorokFlowerWait.h"
#include "KingSystem/ActorSystem/actActor.h"
namespace uking::action { namespace uking::action {
@ -21,7 +22,10 @@ void KorokFlowerWait::leave_() {
void KorokFlowerWait::loadParams_() {} void KorokFlowerWait::loadParams_() {}
void KorokFlowerWait::calc_() { void KorokFlowerWait::calc_() {
ksys::act::ai::Action::calc_(); if (mActor->checkBasicSig()) {
mFlags.set(Flag::Changeable);
setFinished();
}
} }
} // namespace uking::action } // namespace uking::action

View File

@ -1,4 +1,8 @@
#include "Game/AI/Action/actionKorokTargetMove.h" #include "Game/AI/Action/actionKorokTargetMove.h"
#include <math/seadMatrixCalcCommon.hpp>
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
#include "KingSystem/System/VFR.h"
namespace uking::action { namespace uking::action {
@ -26,7 +30,24 @@ void KorokTargetMove::loadParams_() {
} }
void KorokTargetMove::calc_() { void KorokTargetMove::calc_() {
ksys::act::ai::Action::calc_(); auto* actor = mActor;
auto* body = actor->getMainBody();
if (*mIsBezier_d || *mIsTargetWarp_m) {
body->setPosition(*mTargetPos_d, true);
setFinished();
return;
}
sead::Matrix34f mtx = actor->getMtx();
sead::Vector3f pos(mtx(0, 3), mtx(1, 3), mtx(2, 3));
ksys::VFR::chaseVec(&pos, *mTargetPos_d, *mSpeed_d);
body->changePosition(pos, true);
sead::Vector3f t = pos - *mTargetPos_d;
if (t.length() < *mSpeed_d) {
setFinished();
}
} }
} // namespace uking::action } // namespace uking::action

View File

@ -1,4 +1,6 @@
#include "Game/AI/Action/actionKorokTargetWait.h" #include "Game/AI/Action/actionKorokTargetWait.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
namespace uking::action { namespace uking::action {
@ -11,7 +13,7 @@ bool KorokTargetWait::init_(sead::Heap* heap) {
} }
void KorokTargetWait::enter_(ksys::act::ai::InlineParamPack* params) { void KorokTargetWait::enter_(ksys::act::ai::InlineParamPack* params) {
ksys::act::ai::Action::enter_(params); mTime = 0;
} }
void KorokTargetWait::leave_() { void KorokTargetWait::leave_() {
@ -24,7 +26,13 @@ void KorokTargetWait::loadParams_() {
} }
void KorokTargetWait::calc_() { void KorokTargetWait::calc_() {
ksys::act::ai::Action::calc_(); mActor->getMainBody()->setLinearVelocity(sead::Vector3f::zero);
if (mTime >= *mDynStopTime_d) {
mFlags.set(ksys::act::ai::Action::Flag::Changeable);
setFinished();
} else {
mTime += 1.0;
}
} }
} // namespace uking::action } // namespace uking::action

View File

@ -22,6 +22,8 @@ protected:
const float* mSpeedDecreRate_s{}; const float* mSpeedDecreRate_s{};
// dynamic_param at offset 0x28 // dynamic_param at offset 0x28
float* mDynStopTime_d{}; float* mDynStopTime_d{};
f32 mTime;
}; };
} // namespace uking::action } // namespace uking::action

View File

@ -1,4 +1,6 @@
#include "Game/AI/Action/actionNPCStartTurnToPlayer.h" #include "Game/AI/Action/actionNPCStartTurnToPlayer.h"
#include "KingSystem/ActorSystem/actActor.h"
#include "KingSystem/Utils/Thread/Message.h"
namespace uking::action { namespace uking::action {
@ -10,6 +12,14 @@ bool NPCStartTurnToPlayer::init_(sead::Heap* heap) {
return ksys::act::ai::Action::init_(heap); return ksys::act::ai::Action::init_(heap);
} }
bool NPCStartTurnToPlayer::oneShot_() {
mValue = *mTurnRange_d * 0.5f;
sendMessage(*mActor->getMesTransceiverId(), ksys::MessageType(0x8000078), &mValue);
return ksys::act::ai::Action::oneShot_();
}
void NPCStartTurnToPlayer::loadParams_() { void NPCStartTurnToPlayer::loadParams_() {
getDynamicParam(&mTurnRange_d, "TurnRange"); getDynamicParam(&mTurnRange_d, "TurnRange");
} }

View File

@ -14,8 +14,12 @@ public:
void loadParams_() override; void loadParams_() override;
protected: protected:
bool oneShot_() override;
// dynamic_param at offset 0x20 // dynamic_param at offset 0x20
float* mTurnRange_d{}; float* mTurnRange_d{};
float mValue;
}; };
} // namespace uking::action } // namespace uking::action

View File

@ -15,7 +15,7 @@ void SendMessage::enter_(ksys::act::ai::InlineParamPack* params) {
if (*mSendTiming_s == 0) if (*mSendTiming_s == 0)
doSendMessage(); doSendMessage();
mFlags.set(Flag::_4); mFlags.set(Flag::Changeable);
setFinished(); setFinished();
} }

View File

@ -34,6 +34,11 @@ int getItemGeneralLife(const char* name);
// TODO: move this to yet another translation unit (TBD but not the same one as the above) // TODO: move this to yet another translation unit (TBD but not the same one as the above)
void addItemForDebug(const sead::SafeString& name, int value); void addItemForDebug(const sead::SafeString& name, int value);
void setShowCheckPoint(s32 icon_type, const sead::SafeString& counter_name);
void setShowFlyDistance(const sead::SafeString& distance);
void setShowGolfCount(const sead::SafeString& counter_name);
void setShowRaceResult(s32 result_type);
int countCookResultsCheck(const sead::SafeString& name, s32 effect_type); int countCookResultsCheck(const sead::SafeString& name, s32 effect_type);
int countCookResultsAllOk(const sead::SafeString& name); int countCookResultsAllOk(const sead::SafeString& name);
int getItemValue(const sead::SafeString& name); int getItemValue(const sead::SafeString& name);

View File

@ -94,6 +94,7 @@ target_sources(uking PRIVATE
actBaseProcMgr.h actBaseProcMgr.h
actBaseProcUnit.cpp actBaseProcUnit.cpp
actBaseProcUnit.h actBaseProcUnit.h
actCCAccessor.h
actClusteredRenderer.cpp actClusteredRenderer.cpp
actClusteredRenderer.h actClusteredRenderer.h
actDebug.cpp actDebug.cpp

View File

@ -40,9 +40,10 @@ class UMii;
namespace phys { namespace phys {
class StaticCompoundRigidBodyGroup; class StaticCompoundRigidBodyGroup;
class Physics; class InstanceSet;
class Reaction; class Reaction;
class RigidBody; class RigidBody;
class CharacterController;
} // namespace phys } // namespace phys
namespace res { namespace res {
@ -112,6 +113,7 @@ public:
enum class ActorFlag2 { enum class ActorFlag2 {
InstEvent = 0x8, InstEvent = 0x8,
_20 = 0x20,
NoDistanceCheck = 0x80, NoDistanceCheck = 0x80,
Alive = 0x4000000, Alive = 0x4000000,
}; };
@ -140,12 +142,19 @@ public:
const sead::Vector3f& getVelocity() const { return mVelocity; } const sead::Vector3f& getVelocity() const { return mVelocity; }
const sead::Vector3f& getAngVelocity() const { return mAngVelocity; } const sead::Vector3f& getAngVelocity() const { return mAngVelocity; }
const sead::Vector3f& getScale() const { return mScale; } const sead::Vector3f& getScale() const { return mScale; }
phys::RigidBody* getMainBody() const { return mMainBody; }
phys::RigidBody* getTgtBody() const { return mTgtBody; }
const MesTransceiverId* getMesTransceiverId() const { return mMsgTransceiver.getId(); }
f32 getDeleteDistance() const { f32 getDeleteDistance() const {
return sead::Mathf::sqrt(sead::Mathf::clampMin(mDeleteDistanceSq, 0.0f)); return sead::Mathf::sqrt(sead::Mathf::clampMin(mDeleteDistanceSq, 0.0f));
} }
void setDeleteDistance(f32 distance) { mDeleteDistanceSq = sead::Mathf::square(distance); } void setDeleteDistance(f32 distance) { mDeleteDistanceSq = sead::Mathf::square(distance); }
phys::CharacterController* getCharacterController();
void clearFlag(ActorFlag flag); void clearFlag(ActorFlag flag);
bool checkFlag(ActorFlag flag) const; bool checkFlag(ActorFlag flag) const;
void setFlag(ActorFlag flag); void setFlag(ActorFlag flag);
@ -278,6 +287,7 @@ public:
void emitBasicSigOn(); void emitBasicSigOn();
void emitBasicSigOff(); void emitBasicSigOff();
bool checkBasicSig() const;
void nullsub_4649(); // Some kind of logging which has been excluded from the build? void nullsub_4649(); // Some kind of logging which has been excluded from the build?
@ -386,7 +396,7 @@ protected:
/* 0x560 */ as::ASList* mASList = nullptr; /* 0x560 */ as::ASList* mASList = nullptr;
/* 0x568 */ xlink::XLink* mXLink = nullptr; /* 0x568 */ xlink::XLink* mXLink = nullptr;
/* 0x570 */ ActorParam* mActorParam = nullptr; /* 0x570 */ ActorParam* mActorParam = nullptr;
/* 0x578 */ phys::Physics* mPhysics = nullptr; /* 0x578 */ phys::InstanceSet* mPhysics = nullptr;
/* 0x580 */ PhysicsConstraints mConstraints; /* 0x580 */ PhysicsConstraints mConstraints;
/* 0x598 */ void* _598 = nullptr; /* 0x598 */ void* _598 = nullptr;
/* 0x5a0 */ BoneControl* mBoneControl = nullptr; /* 0x5a0 */ BoneControl* mBoneControl = nullptr;

View File

@ -13,6 +13,7 @@ struct AIDefSet;
class Message; class Message;
class MessageAck; class MessageAck;
struct MesTransceiverId; struct MesTransceiverId;
struct MessageType;
} // namespace ksys } // namespace ksys
namespace ksys::res { namespace ksys::res {
@ -69,6 +70,8 @@ public:
void leave(); void leave();
bool oneShot(InlineParamPack* params); bool oneShot(InlineParamPack* params);
bool sendMessage(const MesTransceiverId& dest, const MessageType& type, void* user_data);
Action* getCurrentAction(); Action* getCurrentAction();
bool handleMessage(const Message& message); bool handleMessage(const Message& message);
bool handleAck(const MessageAck& message); bool handleAck(const MessageAck& message);
@ -78,9 +81,12 @@ public:
const char* getClassName() const; const char* getClassName() const;
const char* getName() const; const char* getName() const;
void playAS(const char* name, bool repeat, u32 slot, u32 seq_bank, f32 t);
bool isFinishedAS(u32 slot, u32 seq_bank);
virtual bool isFailed() const { return mFlags.isOn(Flag::Failed); } virtual bool isFailed() const { return mFlags.isOn(Flag::Failed); }
virtual bool isFinished() const { return mFlags.isOn(Flag::Finished); } virtual bool isFinished() const { return mFlags.isOn(Flag::Finished); }
virtual bool isFlag4Set() const { return mFlags.isOn(Flag::_4); } virtual bool isChangeable() const { return mFlags.isOn(Flag::Changeable); }
virtual bool hasPreDeleteCb() { return false; } virtual bool hasPreDeleteCb() { return false; }
virtual bool hasUpdateForPreDeleteCb() { return false; } virtual bool hasUpdateForPreDeleteCb() { return false; }
@ -123,7 +129,7 @@ protected:
enum class Flag : u8 { enum class Flag : u8 {
Finished = 1, Finished = 1,
Failed = 2, Failed = 2,
_4 = 4, Changeable = 4,
TriggerAction = 8, TriggerAction = 8,
DynamicParamChild = 0x10, DynamicParamChild = 0x10,
_20 = 0x20, _20 = 0x20,
@ -154,7 +160,7 @@ protected:
void resetFlags() { void resetFlags() {
mFlags.reset(Flag::Failed); mFlags.reset(Flag::Failed);
mFlags.reset(Flag::Finished); mFlags.reset(Flag::Finished);
mFlags.reset(Flag::_4); mFlags.reset(Flag::Changeable);
} }
res::AIProgram* getAIProg() const; res::AIProgram* getAIProg() const;

View File

@ -186,12 +186,12 @@ bool Ai::reenter(ActionBase* other, const sead::SafeString& context) {
return child->takeOver(other_child, getName()); return child->takeOver(other_child, getName());
} }
bool Ai::isFlag4Set() const { bool Ai::isChangeable() const {
auto* child = getCurrentChild(); auto* child = getCurrentChild();
if (child) if (child)
return child->isFlag4Set(); return child->isChangeable();
return mFlags.isOn(Flag::_4); return mFlags.isOn(Flag::Changeable);
} }
ActionBase* Ai::getCurrentChild() const { ActionBase* Ai::getCurrentChild() const {

View File

@ -11,7 +11,7 @@ public:
explicit Ai(const InitArg& arg); explicit Ai(const InitArg& arg);
~Ai() override; ~Ai() override;
bool isFlag4Set() const override; bool isChangeable() const override;
void calc() override; void calc() override;
ActionBase* changeChildLater(const sead::SafeString& name) override; ActionBase* changeChildLater(const sead::SafeString& name) override;
void getParams(ParamNameTypePairs* pairs, bool update_use_count) const override; void getParams(ParamNameTypePairs* pairs, bool update_use_count) const override;

View File

@ -30,7 +30,7 @@ public:
explicit RootAi(const InitArg& arg); explicit RootAi(const InitArg& arg);
~RootAi() override; ~RootAi() override;
bool isFlag4Set() const override { return true; } bool isChangeable() const override { return true; }
bool init_(sead::Heap* heap) override; bool init_(sead::Heap* heap) override;
void enter_(InlineParamPack* params) override; void enter_(InlineParamPack* params) override;
void leave_() override; void leave_() override;

View File

@ -0,0 +1,26 @@
#pragma once
namespace ksys::phys {
class CharacterController;
};
namespace ksys::act {
class Actor;
// todo: move?
enum class MotionType {
Hover = 3,
};
class CCAccessor {
public:
CCAccessor();
~CCAccessor();
void changeMotionType(phys::CharacterController* cc, MotionType motion_type);
void resetRigidBodyMotion(Actor* actor);
void resetMotionType(phys::CharacterController* cc);
};
} // namespace ksys::act

View File

@ -5,7 +5,7 @@ namespace ksys::act::ai {
DummyAction::DummyAction(const InitArg& arg) : Action(arg) {} DummyAction::DummyAction(const InitArg& arg) : Action(arg) {}
void DummyAction::enter_(InlineParamPack* params) { void DummyAction::enter_(InlineParamPack* params) {
mFlags.set(ActionBase::Flag::_4); mFlags.set(ActionBase::Flag::Changeable);
} }
void DummyAction::calc_() {} void DummyAction::calc_() {}

View File

@ -9,7 +9,7 @@ class DummyAi : public Ai {
public: public:
explicit DummyAi(const InitArg& arg); explicit DummyAi(const InitArg& arg);
bool isFlag4Set() const override { return true; } bool isChangeable() const override { return true; }
void enter_(InlineParamPack* params) override; void enter_(InlineParamPack* params) override;
protected: protected:

View File

@ -1,4 +1,6 @@
target_sources(uking PRIVATE target_sources(uking PRIVATE
CharacterController/physCharacterController.h
Cloth/physClothParam.cpp Cloth/physClothParam.cpp
Cloth/physClothParam.h Cloth/physClothParam.h
Cloth/physClothResource.cpp Cloth/physClothResource.cpp

View File

@ -0,0 +1,13 @@
#pragma once
#include "KingSystem/Physics/physDefines.h"
namespace ksys::phys {
class CharacterController {
public:
void sub_7100F5EC30();
void sub_7100F60604();
void enableCollisionMaybe_0(ContactLayer);
};
} // namespace ksys::phys

View File

@ -479,6 +479,8 @@ public:
const auto& getMotionFlags() const { return mMotionFlags; } const auto& getMotionFlags() const { return mMotionFlags; }
void resetMotionFlagDirect(const MotionFlag flag) { mMotionFlags.reset(flag); } void resetMotionFlagDirect(const MotionFlag flag) { mMotionFlags.reset(flag); }
void setMotionFlag(MotionFlag flag); void setMotionFlag(MotionFlag flag);
void setFlag200() { mFlags.set(Flag::_200); }
void resetFlag200() { mFlags.reset(Flag::_200); }
hkpRigidBody* getHkBody() const { return mHkBody; } hkpRigidBody* getHkBody() const { return mHkBody; }

View File

@ -1,4 +1,5 @@
#include "KingSystem/Physics/System/physInstanceSet.h" #include "KingSystem/Physics/System/physInstanceSet.h"
#include "KingSystem/Physics/CharacterController/physCharacterController.h"
#include "KingSystem/Physics/Ragdoll/physRagdollController.h" #include "KingSystem/Physics/Ragdoll/physRagdollController.h"
#include "KingSystem/Physics/RigidBody/physRigidBodySet.h" #include "KingSystem/Physics/RigidBody/physRigidBodySet.h"
#include "KingSystem/Physics/System/physCollisionInfo.h" #include "KingSystem/Physics/System/physCollisionInfo.h"
@ -146,16 +147,16 @@ void InstanceSet::sub_7100FBB00C(phys::RigidBody* body, phys::RigidBodyParam* pa
body->clearSensorReceiverIgnoredLayer(); body->clearSensorReceiverIgnoredLayer();
} }
void* InstanceSet::sub_7100FBBC28(const sead::SafeString& name) const { RigidBody* InstanceSet::findRigidBody(const sead::SafeString& name) const {
for (auto& rb : mRigidBodySets) { for (auto& rb : mRigidBodySets) {
void* p = rb.findBodyByHavokName(name); RigidBody* p = rb.findBodyByHavokName(name);
if (p != nullptr) if (p != nullptr)
return p; return p;
} }
return nullptr; return nullptr;
} }
s32 InstanceSet::sub_7100FBBC78(const sead::SafeString& name) const { s32 InstanceSet::findContactPointInfo(const sead::SafeString& name) const {
s32 idx = 0; s32 idx = 0;
for (auto& info : mContactPointInfo) { for (auto& info : mContactPointInfo) {
if (name == info.getName()) if (name == info.getName())
@ -165,7 +166,7 @@ s32 InstanceSet::sub_7100FBBC78(const sead::SafeString& name) const {
return -1; return -1;
} }
s32 InstanceSet::sub_7100FBBD9C(const sead::SafeString& name) const { s32 InstanceSet::findCollisionInfo(const sead::SafeString& name) const {
s32 idx = 0; s32 idx = 0;
for (auto& info : mCollisionInfo) { for (auto& info : mCollisionInfo) {
if (name == info.getName()) if (name == info.getName())

View File

@ -37,14 +37,6 @@ class RigidBodySet;
class SystemGroupHandler; class SystemGroupHandler;
class UserTag; class UserTag;
// TODO: move to a separate header
class CharacterController {
public:
void sub_7100F5EC30();
void sub_7100F60604();
void enableCollisionMaybe_0(ContactLayer);
};
class InstanceSet : public sead::hostio::Node { class InstanceSet : public sead::hostio::Node {
public: public:
enum class Flag : u32 { enum class Flag : u32 {
@ -82,9 +74,9 @@ public:
void setMtxAndScale(const sead::Matrix34f& mtx, bool a2, bool a3, f32 scale); void setMtxAndScale(const sead::Matrix34f& mtx, bool a2, bool a3, f32 scale);
void sub_7100FBB4B4(); void sub_7100FBB4B4();
void* findX(const sead::SafeString& a1, const sead::SafeString& a2) const; void* findX(const sead::SafeString& a1, const sead::SafeString& a2) const;
void* sub_7100FBBC28(const sead::SafeString& name) const; RigidBody* findRigidBody(const sead::SafeString& name) const;
s32 sub_7100FBBC78(const sead::SafeString& name) const; s32 findContactPointInfo(const sead::SafeString& name) const;
s32 sub_7100FBBD9C(const sead::SafeString& name) const; s32 findCollisionInfo(const sead::SafeString& name) const;
void sub_7100FBD284(const sead::Matrix34f& mtx); void sub_7100FBD284(const sead::Matrix34f& mtx);
void sub_7100FBC890(const sead::Matrix34f& mtx, bool a2, bool a3); void sub_7100FBC890(const sead::Matrix34f& mtx, bool a2, bool a3);
s32 sub_7100FBDA2C(const sead::SafeString& name) const; s32 sub_7100FBDA2C(const sead::SafeString& name) const;

View File

@ -5,5 +5,7 @@
namespace ksys::ui { namespace ksys::ui {
int getPorchNum(const sead::SafeString& name); int getPorchNum(const sead::SafeString& name);
void initRupeeCounter();
bool isRupeeCounterActive();
} // namespace ksys::ui } // namespace ksys::ui

View File

@ -14,7 +14,7 @@ _vtable_fn_names = [
"_ZN5uking6action{}D0Ev", "_ZN5uking6action{}D0Ev",
"_ZNK5uking6action{}8isFailedEv", "_ZNK5uking6action{}8isFailedEv",
"_ZNK5uking6action{}10isFinishedEv", "_ZNK5uking6action{}10isFinishedEv",
"_ZNK5uking6action{}10isFlag4SetEv", "_ZNK5uking6action{}12isChangeableEv",
"_ZN5uking6action{}14hasPreDeleteCbEv", "_ZN5uking6action{}14hasPreDeleteCbEv",
"_ZN5uking6action{}23hasUpdateForPreDeleteCbEv", "_ZN5uking6action{}23hasUpdateForPreDeleteCbEv",
"_ZN5uking6action{}2m9Ev", "_ZN5uking6action{}2m9Ev",

View File

@ -14,7 +14,7 @@ _vtable_fn_names = [
"_ZN5uking2ai{}D0Ev", "_ZN5uking2ai{}D0Ev",
"_ZNK5uking2ai{}8isFailedEv", "_ZNK5uking2ai{}8isFailedEv",
"_ZNK5uking2ai{}10isFinishedEv", "_ZNK5uking2ai{}10isFinishedEv",
"_ZNK5uking2ai{}10isFlag4SetEv", "_ZNK5uking2ai{}12isChangeableEv",
"_ZN5uking2ai{}14hasPreDeleteCbEv", "_ZN5uking2ai{}14hasPreDeleteCbEv",
"_ZN5uking2ai{}23hasUpdateForPreDeleteCbEv", "_ZN5uking2ai{}23hasUpdateForPreDeleteCbEv",
"_ZN5uking2ai{}2m9Ev", "_ZN5uking2ai{}2m9Ev",