diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index 42852e024..8ae96e6ac 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -6622,14 +6622,14 @@ Address,Quality,Size,Name 0x0000007100101338,U,000072,_ZNK12_GLOBAL__N_125FireBrosFireBallNrvAttach7executeEPN2al11NerveKeeperE 0x0000007100101380,U,000020,_ZN15FlyerStateParamC2Ev 0x0000007100101394,U,000012,_ZN15FlyerStateParamC2Eff -0x00000071001013a0,U,000288,_ZN21FlyerStateWanderParamC2EiiiPKcPKN2al14ActorParamMoveE -0x00000071001014c0,U,000092,_ZN16FlyerStateWanderC1EPN2al9LiveActorEPK21FlyerStateWanderParam -0x000000710010151c,U,000016,_ZN16FlyerStateWander6appearEv -0x000000710010152c,U,000204,_ZN16FlyerStateWander9exeWanderEv -0x00000071001015f8,U,000124,_ZN16FlyerStateWander7exeWaitEv -0x0000007100101674,U,000036,_ZN16FlyerStateWanderD0Ev -0x0000007100101698,U,000008,_ZNK12_GLOBAL__N_125FlyerStateWanderNrvWander7executeEPN2al11NerveKeeperE -0x00000071001016a0,U,000128,_ZNK12_GLOBAL__N_123FlyerStateWanderNrvWait7executeEPN2al11NerveKeeperE +0x00000071001013a0,O,000288,_ZN21FlyerStateWanderParamC2EiiiPKcPKN2al14ActorParamMoveE +0x00000071001014c0,O,000092,_ZN16FlyerStateWanderC1EPN2al9LiveActorEPK21FlyerStateWanderParam +0x000000710010151c,O,000016,_ZN16FlyerStateWander6appearEv +0x000000710010152c,O,000204,_ZN16FlyerStateWander9exeWanderEv +0x00000071001015f8,O,000124,_ZN16FlyerStateWander7exeWaitEv +0x0000007100101674,O,000036,_ZN16FlyerStateWanderD0Ev +0x0000007100101698,O,000008,_ZNK12_GLOBAL__N_125FlyerStateWanderNrvWander7executeEPN2al11NerveKeeperE +0x00000071001016a0,O,000128,_ZNK12_GLOBAL__N_123FlyerStateWanderNrvWait7executeEPN2al11NerveKeeperE 0x0000007100101720,U,000316,_ZN7GabuZouC2EPKc 0x000000710010185c,U,000328,_ZN7GabuZouC1EPKc 0x00000071001019a4,U,000808,_ZN7GabuZou4initERKN2al13ActorInitInfoE diff --git a/lib/al/Library/LiveActor/ActorMovementFunction.h b/lib/al/Library/LiveActor/ActorMovementFunction.h index 0f75ce68b..943b2939c 100644 --- a/lib/al/Library/LiveActor/ActorMovementFunction.h +++ b/lib/al/Library/LiveActor/ActorMovementFunction.h @@ -8,7 +8,7 @@ namespace al { class LiveActor; class HitSensor; -class ActorParamMove; +struct ActorParamMove; void resetPosition(LiveActor* actor); void resetPosition(LiveActor* actor, const sead::Vector3f& trans); diff --git a/lib/al/Library/LiveActor/ActorParamMove.h b/lib/al/Library/LiveActor/ActorParamMove.h new file mode 100644 index 000000000..3af91eccf --- /dev/null +++ b/lib/al/Library/LiveActor/ActorParamMove.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace al { +struct ActorParamMove { +public: + f32 _0; + f32 _4; + f32 _8; + f32 _c; +}; +} // namespace al diff --git a/src/Enemy/FlyerStateWander.cpp b/src/Enemy/FlyerStateWander.cpp new file mode 100644 index 000000000..67b5b3274 --- /dev/null +++ b/src/Enemy/FlyerStateWander.cpp @@ -0,0 +1,59 @@ +#include "Enemy/FlyerStateWander.h" + +#include "Library/LiveActor/ActorActionFunction.h" +#include "Library/LiveActor/ActorMovementFunction.h" +#include "Library/LiveActor/ActorParamMove.h" +#include "Library/LiveActor/ActorPoseKeeper.h" +#include "Library/Math/MathRandomUtil.h" +#include "Library/Nerve/NerveSetupUtil.h" + +namespace { +NERVE_IMPL(FlyerStateWander, Wander) +NERVE_IMPL(FlyerStateWander, Wait) + +NERVES_MAKE_NOSTRUCT(FlyerStateWander, Wander, Wait) +} // namespace + +FlyerStateWanderParam::FlyerStateWanderParam(s32 ukn, s32 wanderTime, s32 waitTime, + const char* actionName, + const al::ActorParamMove* actorParamMove) + : _0(ukn), mWanderTime(wanderTime), mWaitTime(waitTime), mActionName(actionName), + mActorParamMove(actorParamMove) {} + +FlyerStateWander::FlyerStateWander(al::LiveActor* actor, const FlyerStateWanderParam* param) + : al::ActorStateBase("飛行型うろつき状態", actor), mFlyerStateWanderParam(param) { + initNerve(&Wander, 0); +} + +void FlyerStateWander::appear() { + setDead(false); + al::setNerve(this, &Wander); +} + +void FlyerStateWander::exeWander() { + if (al::isFirstStep(this)) { + mStartTrans.set(al::getTrans(mActor)); + al::startAction(mActor, mFlyerStateWanderParam->getActionName()); + mNerveTime = mFlyerStateWanderParam->getWanderTime() + + mFlyerStateWanderParam->get_0() * al::getRandom(3); + } + + const al::ActorParamMove* actorParamMove = mFlyerStateWanderParam->getActorParamMove(); + al::flyAndTurnToTarget(mActor, mStartTrans, actorParamMove->_0, actorParamMove->_4, + actorParamMove->_8, actorParamMove->_c); + + if (al::isGreaterEqualStep(this, mNerveTime)) + al::setNerve(this, &Wait); +} + +void FlyerStateWander::exeWait() { + if (al::isFirstStep(this)) { + mNerveTime = mFlyerStateWanderParam->getWaitTime() + + mFlyerStateWanderParam->get_0() * al::getRandom(3); + } + + al::setVelocityZero(mActor); + + if (al::isGreaterEqualStep(this, mNerveTime)) + al::setNerve(this, &Wander); +} diff --git a/src/Enemy/FlyerStateWander.h b/src/Enemy/FlyerStateWander.h new file mode 100644 index 000000000..3e7401e91 --- /dev/null +++ b/src/Enemy/FlyerStateWander.h @@ -0,0 +1,52 @@ +#pragma once + +#include +#include + +#include "Library/Nerve/NerveStateBase.h" + +namespace al { +struct ActorParamMove; +} + +class FlyerStateWanderParam { +public: + FlyerStateWanderParam(s32, s32 wanderTime, s32 waitTime, const char* actionName, + const al::ActorParamMove* actorParamMove); + + s32 get_0() const { return _0; } + + s32 getWanderTime() const { return mWanderTime; } + + s32 getWaitTime() const { return mWaitTime; } + + const char* getActionName() const { return mActionName.cstr(); } + + const al::ActorParamMove* getActorParamMove() const { return mActorParamMove; } + +private: + s32 _0; + s32 mWanderTime; + s32 mWaitTime; + sead::FixedSafeString<32> mActionName; + const al::ActorParamMove* mActorParamMove; +}; + +static_assert(sizeof(FlyerStateWanderParam) == 0x50); + +class FlyerStateWander : public al::ActorStateBase { +public: + FlyerStateWander(al::LiveActor* actor, const FlyerStateWanderParam* param); + + void appear() override; + + void exeWander(); + void exeWait(); + +private: + s32 mNerveTime = 0; + sead::Vector3f mStartTrans = {0.0f, 0.0f, 0.0f}; + const FlyerStateWanderParam* mFlyerStateWanderParam; +}; + +static_assert(sizeof(FlyerStateWander) == 0x38);