diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index 83246de4c..0228342d8 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -28142,14 +28142,14 @@ Address,Quality,Size,Name 0x000000710045f000,U,000084,_ZN19PlayerPlayRecordMtxC2Ev 0x000000710045f054,U,000032,_ZN19PlayerPlayRecordMtx11startRecordERKN4sead8Matrix34IfEE 0x000000710045f074,U,000068,_ZN19PlayerPlayRecordMtx13recordViewMtxERKN4sead8Matrix34IfEE -0x000000710045f0b8,U,000140,_ZN16PlayerPowerGloveC2Ev -0x000000710045f144,U,000144,_ZN16PlayerPowerGloveC1Ev -0x000000710045f1d4,U,000196,_ZN16PlayerPowerGlove12initPartsMtxEPN2al9LiveActorERKNS0_13ActorInitInfoEPKN4sead8Matrix34IfEE -0x000000710045f298,U,000312,_ZN16PlayerPowerGlove14makeActorAliveEv -0x000000710045f3d0,U,000300,_ZN16PlayerPowerGlove10updatePoseEv -0x000000710045f4fc,U,000356,_ZN16PlayerPowerGlove7controlEv -0x000000710045f660,U,000012,_ZN16PlayerPowerGlove12attackSensorEPN2al9HitSensorES2_ -0x000000710045f66c,U,000004,_ZN16PlayerPowerGlove4initERKN2al13ActorInitInfoE +0x000000710045f0b8,O,000140,_ZN16PlayerPowerGloveC2Ev +0x000000710045f144,O,000144,_ZN16PlayerPowerGloveC1Ev +0x000000710045f1d4,O,000196,_ZN16PlayerPowerGlove12initPartsMtxEPN2al9LiveActorERKNS0_13ActorInitInfoEPKN4sead8Matrix34IfEE +0x000000710045f298,O,000312,_ZN16PlayerPowerGlove14makeActorAliveEv +0x000000710045f3d0,O,000300,_ZN16PlayerPowerGlove10updatePoseEv +0x000000710045f4fc,O,000356,_ZN16PlayerPowerGlove7controlEv +0x000000710045f660,O,000012,_ZN16PlayerPowerGlove12attackSensorEPN2al9HitSensorES2_ +0x000000710045f66c,O,000004,_ZN16PlayerPowerGlove4initERKN2al13ActorInitInfoE 0x000000710045f670,U,000164,_ZN12PlayerPuppetC2EPN2al9LiveActorEP7HackCapP14PlayerAnimatorP19IUsePlayerCollisionP20ActorDimensionKeeperP19IPlayerModelChangerP20WorldEndBorderKeeperP21PlayerCounterForceRunP18PlayerDamageKeeperP12PlayerEffectPK11PlayerInputPK11PlayerConst 0x000000710045f714,U,000040,_ZN12PlayerPuppet5startEPN2al9HitSensorES2_ 0x000000710045f73c,U,000048,_ZN12PlayerPuppet3endEv @@ -29077,13 +29077,13 @@ Address,Quality,Size,Name 0x00000071004923d8,U,000100,_ZNK12_GLOBAL__N_127PlayerStateWallCatchNrvWait7executeEPN2al11NerveKeeperE 0x000000710049243c,U,000008,_ZNK12_GLOBAL__N_131PlayerStateWallCatchNrvMoveLeft7executeEPN2al11NerveKeeperE 0x0000007100492444,U,000008,_ZNK12_GLOBAL__N_132PlayerStateWallCatchNrvMoveRight7executeEPN2al11NerveKeeperE -0x000000710049244c,U,000132,_ZN11PlayerSwordC2EPKc -0x00000071004924d0,U,000144,_ZN11PlayerSwordC1EPKc -0x0000007100492560,U,000260,_ZN11PlayerSword12initPartsMtxEPN2al9LiveActorERKNS0_13ActorInitInfoEPKN4sead8Matrix34IfEEPKc -0x0000007100492664,U,000312,_ZN11PlayerSword14makeActorAliveEv -0x000000710049279c,U,000300,_ZN11PlayerSword10updatePoseEv -0x00000071004928c8,U,000356,_ZN11PlayerSword7controlEv -0x0000007100492a2c,U,000012,_ZN11PlayerSword12attackSensorEPN2al9HitSensorES2_ +0x000000710049244c,O,000132,_ZN11PlayerSwordC2EPKc +0x00000071004924d0,O,000144,_ZN11PlayerSwordC1EPKc +0x0000007100492560,O,000260,_ZN11PlayerSword12initPartsMtxEPN2al9LiveActorERKNS0_13ActorInitInfoEPKN4sead8Matrix34IfEEPKc +0x0000007100492664,O,000312,_ZN11PlayerSword14makeActorAliveEv +0x000000710049279c,O,000300,_ZN11PlayerSword10updatePoseEv +0x00000071004928c8,O,000356,_ZN11PlayerSword7controlEv +0x0000007100492a2c,O,000012,_ZN11PlayerSword12attackSensorEPN2al9HitSensorES2_ 0x0000007100492a38,O,000016,_ZN13PlayerTriggerC2Ev 0x0000007100492a48,O,000024,_ZN13PlayerTrigger3setENS_17ECollisionTriggerE 0x0000007100492a60,O,000024,_ZN13PlayerTrigger3setENS_20EAttackSensorTriggerE diff --git a/src/Player/PlayerPowerGlove.cpp b/src/Player/PlayerPowerGlove.cpp new file mode 100644 index 000000000..8880ae407 --- /dev/null +++ b/src/Player/PlayerPowerGlove.cpp @@ -0,0 +1,63 @@ +#include "Player/PlayerPowerGlove.h" + +#include "Library/LiveActor/ActorClippingFunction.h" +#include "Library/LiveActor/ActorInitInfo.h" +#include "Library/LiveActor/ActorModelFunction.h" +#include "Library/LiveActor/ActorPoseKeeper.h" +#include "Library/LiveActor/ActorSensorFunction.h" +#include "Library/Math/MathUtil.h" +#include "Library/Obj/PartsFunction.h" +#include "Library/Placement/PlacementFunction.h" + +#include "Util/SensorMsgFunction.h" + +PlayerPowerGlove::PlayerPowerGlove() : al::LiveActor("パワーグローブ") {} + +void PlayerPowerGlove::initPartsMtx(al::LiveActor* other, const al::ActorInitInfo& info, + const sead::Matrix34f* mtx) { + mPlayer = other; + mPlayerBodySensor = al::getHitSensor(other, "Body"); + mPlayerBaseMtx = mtx; + + al::initChildActorWithArchiveNameNoPlacementInfo(this, info, "PowerGrove", nullptr); + + al::setHitSensorMtxPtr(this, "Attack", other->getBaseMtx()); + al::invalidateClipping(this); + al::invalidateHitSensors(this); + makeActorAlive(); +} + +void PlayerPowerGlove::makeActorAlive() { + updatePose(); + al::LiveActor::makeActorAlive(); + mIsInvisible = false; +} + +void PlayerPowerGlove::updatePose() { + // These are created but not used + sead::Matrix34f t; + sead::Matrix34f tt; + t.makeR(sead::Vector3f(sead::Mathf::piHalf(), 0, 0)); + tt.makeR(sead::Vector3f(0, 0, 0)); + + sead::Matrix34f newPoseMtx = *mPlayerBaseMtx; + al::normalize(&newPoseMtx); + + newPoseMtx.setMul(newPoseMtx, {0, 0, 1.0f, 0, 0, -0.001f, 0.7f, 0, 1.0f, 0.001f, 0.3f, 0}); + + return al::updatePoseMtx(this, &newPoseMtx); +} + +void PlayerPowerGlove::control() { + if (al::updateSyncHostVisible(&mIsInvisible, this, mPlayer, false)) { + al::showModelIfHide(this); + updatePose(); + } else + al::hideModelIfShow(this); +} + +void PlayerPowerGlove::attackSensor(al::HitSensor* self, al::HitSensor* other) { + rs::sendMsgCapAttack(other, mPlayerBodySensor); +} + +void PlayerPowerGlove::init(const al::ActorInitInfo& info) {} diff --git a/src/Player/PlayerPowerGlove.h b/src/Player/PlayerPowerGlove.h new file mode 100644 index 000000000..a00791eed --- /dev/null +++ b/src/Player/PlayerPowerGlove.h @@ -0,0 +1,22 @@ +#pragma once + +#include "Library/LiveActor/LiveActor.h" + +class PlayerPowerGlove : public al::LiveActor { +public: + PlayerPowerGlove(); + + void init(const al::ActorInitInfo& info) override; + void initPartsMtx(al::LiveActor* other, const al::ActorInitInfo& info, + const sead::Matrix34f* mtx); + void makeActorAlive() override; + void updatePose(); + void control() override; + void attackSensor(al::HitSensor* self, al::HitSensor* other) override; + +private: + al::LiveActor* mPlayer = nullptr; + al::HitSensor* mPlayerBodySensor = nullptr; + const sead::Matrix34f* mPlayerBaseMtx = nullptr; + bool mIsInvisible = false; +}; diff --git a/src/Player/PlayerSword.cpp b/src/Player/PlayerSword.cpp new file mode 100644 index 000000000..382a56d06 --- /dev/null +++ b/src/Player/PlayerSword.cpp @@ -0,0 +1,69 @@ +#include "Player/PlayerSword.h" + +#include "Library/LiveActor/ActorClippingFunction.h" +#include "Library/LiveActor/ActorInitInfo.h" +#include "Library/LiveActor/ActorModelFunction.h" +#include "Library/LiveActor/ActorPoseKeeper.h" +#include "Library/LiveActor/ActorSensorFunction.h" +#include "Library/Math/MathUtil.h" +#include "Library/Obj/PartsFunction.h" +#include "Library/Placement/PlacementFunction.h" + +#include "Util/SensorMsgFunction.h" + +static const char* sWeaponTypes[] = {"Sword", "PowerGrove"}; + +PlayerSword::PlayerSword(const char* name) : al::LiveActor(name) {} + +void PlayerSword::initPartsMtx(al::LiveActor* other, const al::ActorInitInfo& info, + const sead::Matrix34f* mtx, const char* name) { + mPlayer = other; + mPlayerBodySensor = al::getHitSensor(other, "Body"); + mPlayerBaseMtx = mtx; + + if (name) + al::initChildActorWithArchiveNameNoPlacementInfo(this, info, name, nullptr); + else { + s32 type = 0; + al::tryGetArg(&type, info, "WeaponType"); + al::initChildActorWithArchiveNameNoPlacementInfo(this, info, sWeaponTypes[type], nullptr); + } + + al::setHitSensorMtxPtr(this, "Attack", other->getBaseMtx()); + al::invalidateClipping(this); + al::invalidateHitSensors(this); + makeActorAlive(); +} + +void PlayerSword::makeActorAlive() { + updatePose(); + al::LiveActor::makeActorAlive(); + mIsInvisible = false; +} + +void PlayerSword::updatePose() { + // These are created but not used + sead::Matrix34f t; + sead::Matrix34f tt; + t.makeR(sead::Vector3f(sead::Mathf::piHalf(), 0, 0)); + tt.makeR(sead::Vector3f(0, 0, 0)); + + sead::Matrix34f newPoseMtx = *mPlayerBaseMtx; + al::normalize(&newPoseMtx); + + newPoseMtx.setMul(newPoseMtx, {0, 0, 1.0f, 0, 0, -0.001f, 0.7f, 0, 1.0f, 0.001f, 0.3f, 0}); + + return al::updatePoseMtx(this, &newPoseMtx); +} + +void PlayerSword::control() { + if (al::updateSyncHostVisible(&mIsInvisible, this, mPlayer, false)) { + al::showModelIfHide(this); + updatePose(); + } else + al::hideModelIfShow(this); +} + +void PlayerSword::attackSensor(al::HitSensor* self, al::HitSensor* other) { + rs::sendMsgPlayerSwordAttack(other, mPlayerBodySensor); +} diff --git a/src/Player/PlayerSword.h b/src/Player/PlayerSword.h new file mode 100644 index 000000000..a9d392244 --- /dev/null +++ b/src/Player/PlayerSword.h @@ -0,0 +1,21 @@ +#pragma once + +#include "Library/LiveActor/LiveActor.h" + +class PlayerSword : public al::LiveActor { +public: + PlayerSword(const char* name); + + void initPartsMtx(al::LiveActor* other, const al::ActorInitInfo& info, + const sead::Matrix34f* mtx, const char* name); + void makeActorAlive() override; + void updatePose(); + void control() override; + void attackSensor(al::HitSensor* self, al::HitSensor* other) override; + +private: + al::LiveActor* mPlayer = nullptr; + al::HitSensor* mPlayerBodySensor = nullptr; + const sead::Matrix34f* mPlayerBaseMtx = nullptr; + bool mIsInvisible = false; +}; diff --git a/src/Util/SensorMsgFunction.h b/src/Util/SensorMsgFunction.h index 74288471a..47d8a9813 100644 --- a/src/Util/SensorMsgFunction.h +++ b/src/Util/SensorMsgFunction.h @@ -16,6 +16,8 @@ bool sendMsgNoticePlayerDamage(al::HitSensor* source, al::HitSensor* target); bool sendMsgTouchFireDrum2D(al::HitSensor* source, al::HitSensor* target); bool sendMsgItemAmiiboKoopa(al::HitSensor* source, al::HitSensor* target); bool sendMsgPushToPlayer(al::HitSensor* source, al::HitSensor* target); +bool sendMsgPlayerSwordAttack(al::HitSensor* source, al::HitSensor* target); +bool sendMsgCapAttack(al::HitSensor* source, al::HitSensor* target); bool isMsgCapTouchWall(const al::SensorMsg*); bool isMsgCapHipDrop(const al::SensorMsg*);