Player: Implement PlayerPowerGlove and PlayerSword (#246)

Co-authored-by: LynxDev2 <128722393+LynxDev2@users.noreply.github.com>
This commit is contained in:
GRAnimated 2026-02-15 15:19:17 -05:00 committed by GitHub
parent 03ab3f345f
commit f4643f9ff1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 193 additions and 15 deletions

View file

@ -125170,35 +125170,35 @@ Player/PlayerPowerGlove.o:
- offset: 0x45f0b8
size: 140
label: _ZN16PlayerPowerGloveC2Ev
status: NotDecompiled
status: Matching
- offset: 0x45f144
size: 144
label: _ZN16PlayerPowerGloveC1Ev
status: NotDecompiled
status: Matching
- offset: 0x45f1d4
size: 196
label: _ZN16PlayerPowerGlove12initPartsMtxEPN2al9LiveActorERKNS0_13ActorInitInfoEPKN4sead8Matrix34IfEE
status: NotDecompiled
status: Matching
- offset: 0x45f298
size: 312
label: _ZN16PlayerPowerGlove14makeActorAliveEv
status: NotDecompiled
status: Matching
- offset: 0x45f3d0
size: 300
label: _ZN16PlayerPowerGlove10updatePoseEv
status: NotDecompiled
status: Matching
- offset: 0x45f4fc
size: 356
label: _ZN16PlayerPowerGlove7controlEv
status: NotDecompiled
status: Matching
- offset: 0x45f660
size: 12
label: _ZN16PlayerPowerGlove12attackSensorEPN2al9HitSensorES2_
status: NotDecompiled
status: Matching
- offset: 0x45f66c
size: 4
label: _ZN16PlayerPowerGlove4initERKN2al13ActorInitInfoE
status: NotDecompiled
status: Matching
lazy: true
Player/PlayerPuppet.o:
'.text':
@ -129355,31 +129355,31 @@ Player/PlayerSword.o:
- offset: 0x49244c
size: 132
label: _ZN11PlayerSwordC2EPKc
status: NotDecompiled
status: Matching
- offset: 0x4924d0
size: 144
label: _ZN11PlayerSwordC1EPKc
status: NotDecompiled
status: Matching
- offset: 0x492560
size: 260
label: _ZN11PlayerSword12initPartsMtxEPN2al9LiveActorERKNS0_13ActorInitInfoEPKN4sead8Matrix34IfEEPKc
status: NotDecompiled
status: Matching
- offset: 0x492664
size: 312
label: _ZN11PlayerSword14makeActorAliveEv
status: NotDecompiled
status: Matching
- offset: 0x49279c
size: 300
label: _ZN11PlayerSword10updatePoseEv
status: NotDecompiled
status: Matching
- offset: 0x4928c8
size: 356
label: _ZN11PlayerSword7controlEv
status: NotDecompiled
status: Matching
- offset: 0x492a2c
size: 12
label: _ZN11PlayerSword12attackSensorEPN2al9HitSensorES2_
status: NotDecompiled
status: Matching
Player/PlayerTrigger.o:
'.text':
- offset: 0x492a38

View file

@ -0,0 +1,64 @@
#include "Player/PlayerPowerGlove.h"
#include "Library/LiveActor/ActorClippingFunction.h"
#include "Library/LiveActor/ActorInitInfo.h"
#include "Library/LiveActor/ActorInitUtil.h"
#include "Library/LiveActor/ActorModelFunction.h"
#include "Library/LiveActor/ActorPoseUtil.h"
#include "Library/LiveActor/ActorSensorFunction.h"
#include "Library/LiveActor/ActorSensorUtil.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* player, const al::ActorInitInfo& info,
const sead::Matrix34f* playerBaseMtx) {
mPlayer = player;
mPlayerBodySensor = al::getHitSensor(player, "Body");
mPlayerBaseMtx = playerBaseMtx;
al::initChildActorWithArchiveNameNoPlacementInfo(this, info, "PowerGrove", nullptr);
al::setHitSensorMtxPtr(this, "Attack", player->getBaseMtx());
al::invalidateClipping(this);
al::invalidateHitSensors(this);
makeActorAlive();
}
void PlayerPowerGlove::makeActorAlive() {
updatePose();
al::LiveActor::makeActorAlive();
mIsInvisible = false;
}
void PlayerPowerGlove::updatePose() {
sead::Matrix34f t;
sead::Matrix34f tt;
t.makeR({sead::Mathf::piHalf(), 0.0f, 0.0f});
tt.makeR({0.0f, 0.0f, 0.0f});
sead::Matrix34f newPoseMtx = *mPlayerBaseMtx;
al::normalize(&newPoseMtx);
newPoseMtx *= (t * tt);
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) {}

View file

@ -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* player, const al::ActorInitInfo& info,
const sead::Matrix34f* playerBaseMtx);
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;
};

View file

@ -0,0 +1,71 @@
#include "Player/PlayerSword.h"
#include "Library/LiveActor/ActorClippingFunction.h"
#include "Library/LiveActor/ActorInitInfo.h"
#include "Library/LiveActor/ActorInitUtil.h"
#include "Library/LiveActor/ActorModelFunction.h"
#include "Library/LiveActor/ActorPoseUtil.h"
#include "Library/LiveActor/ActorSensorFunction.h"
#include "Library/LiveActor/ActorSensorUtil.h"
#include "Library/Math/MathUtil.h"
#include "Library/Obj/PartsFunction.h"
#include "Library/Placement/PlacementFunction.h"
#include "Util/SensorMsgFunction.h"
// BUG: second entry should have been `PowerGlove`. Unused, so does not matter
static const char* sWeaponTypes[] = {"Sword", "PowerGrove"};
PlayerSword::PlayerSword(const char* name) : al::LiveActor(name) {}
void PlayerSword::initPartsMtx(al::LiveActor* player, const al::ActorInitInfo& info,
const sead::Matrix34f* playerBaseMtx, const char* name) {
mPlayer = player;
mPlayerBodySensor = al::getHitSensor(player, "Body");
mPlayerBaseMtx = playerBaseMtx;
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", player->getBaseMtx());
al::invalidateClipping(this);
al::invalidateHitSensors(this);
makeActorAlive();
}
void PlayerSword::makeActorAlive() {
updatePose();
al::LiveActor::makeActorAlive();
mIsInvisible = false;
}
void PlayerSword::updatePose() {
sead::Matrix34f t;
sead::Matrix34f tt;
t.makeR({sead::Mathf::piHalf(), 0.0f, 0.0f});
tt.makeR({0.0f, 0.0f, 0.0f});
sead::Matrix34f newPoseMtx = *mPlayerBaseMtx;
al::normalize(&newPoseMtx);
newPoseMtx *= (t * tt);
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
src/Player/PlayerSword.h Normal file
View file

@ -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* player, const al::ActorInitInfo& info,
const sead::Matrix34f* playerBaseMtx, 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;
};