Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player: Implement PlayerPowerGlove and PlayerSword #246

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions data/odyssey_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
63 changes: 63 additions & 0 deletions src/Player/PlayerPowerGlove.cpp
Original file line number Diff line number Diff line change
@@ -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) {}
22 changes: 22 additions & 0 deletions src/Player/PlayerPowerGlove.h
Original file line number Diff line number Diff line change
@@ -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;
};
69 changes: 69 additions & 0 deletions src/Player/PlayerSword.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
21 changes: 21 additions & 0 deletions src/Player/PlayerSword.h
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 2 additions & 0 deletions src/Util/SensorMsgFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
Loading