Add CWeapon.cpp

Former-commit-id: 831aaf2435
This commit is contained in:
Phillip Stephens 2022-10-26 22:57:38 -07:00
parent 0319fbbf47
commit 391f8389d9
13 changed files with 142 additions and 30 deletions

View File

@ -336,8 +336,8 @@ MakeDamageableTriggerActorParms__FRC16CActorParametersRC16CVisorParameters:
/* 80106804 00103764 38 21 00 80 */ addi r1, r1, 0x80
/* 80106808 00103768 4E 80 00 20 */ blr
.global sub_8010680c
sub_8010680c:
.global HotInThermal__16CActorParametersCFb
HotInThermal__16CActorParametersCFb:
/* 8010680C 0010376C 94 21 FF 80 */ stwu r1, -0x80(r1)
/* 80106810 00103770 7C 08 02 A6 */ mflr r0
/* 80106814 00103774 90 01 00 84 */ stw r0, 0x84(r1)

View File

@ -3616,7 +3616,7 @@ Render__15CGameProjectileCFRC13CStateManager:
/* 8003A600 00037560 90 E1 00 14 */ stw r7, 0x14(r1)
/* 8003A604 00037564 38 E1 00 20 */ addi r7, r1, 0x20
/* 8003A608 00037568 90 01 00 18 */ stw r0, 0x18(r1)
/* 8003A60C 0003756C 48 0C 7C 89 */ bl "__ct__7CWeaponF9TUniqueIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfoiRC10CModelData"
/* 8003A60C 0003756C 48 0C 7C 89 */ bl "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData"
/* 8003A610 00037570 38 61 00 90 */ addi r3, r1, 0x90
/* 8003A614 00037574 38 80 FF FF */ li r4, -1
/* 8003A618 00037578 48 0D C4 35 */ bl __dt__10CModelDataFv

View File

@ -664,7 +664,7 @@ lbl_8013F754:
/* 8013F7C4 0013C724 C0 02 9B 64 */ lfs f0, lbl_805AB884@sda21(r2)
/* 8013F7C8 0013C728 7F 63 DB 78 */ mr r3, r27
/* 8013F7CC 0013C72C EC 20 08 24 */ fdivs f1, f0, f1
/* 8013F7D0 0013C730 4B FC 2A 49 */ bl sub_80102218
/* 8013F7D0 0013C730 4B FC 2A 49 */ bl SetDamageFalloffSpeed__7CWeaponFf
lbl_8013F7D4:
/* 8013F7D4 0013C734 80 1B 00 E8 */ lwz r0, 0xe8(r27)
/* 8013F7D8 0013C738 C0 1C 06 2C */ lfs f0, 0x62c(r28)

View File

@ -10078,7 +10078,7 @@ __ct__11CDroneLaserF9TUniqueIdRC12CTransform4fUi:
/* 80167974 001648D4 38 61 00 78 */ addi r3, r1, 0x78
/* 80167978 001648D8 38 81 00 E0 */ addi r4, r1, 0xe0
/* 8016797C 001648DC 38 A0 00 01 */ li r5, 1
/* 80167980 001648E0 4B F9 EE 8D */ bl sub_8010680c
/* 80167980 001648E0 4B F9 EE 8D */ bl HotInThermal__16CActorParametersCFb
/* 80167984 001648E4 A0 8D A3 8C */ lhz r4, kInvalidUniqueId@sda21(r13)
/* 80167988 001648E8 38 00 00 00 */ li r0, 0
/* 8016798C 001648EC 80 AD 8D 00 */ lwz r5, lbl_805A78C0@sda21(r13)

View File

@ -4623,7 +4623,7 @@ lbl_801D2090:
/* 801D2254 001CF1B4 7D C5 73 78 */ mr r5, r14
/* 801D2258 001CF1B8 38 61 00 EC */ addi r3, r1, 0xec
/* 801D225C 001CF1BC 38 81 01 54 */ addi r4, r1, 0x154
/* 801D2260 001CF1C0 4B F3 45 AD */ bl sub_8010680c
/* 801D2260 001CF1C0 4B F3 45 AD */ bl HotInThermal__16CActorParametersCFb
/* 801D2264 001CF1C4 A0 8D A3 8C */ lhz r4, kInvalidUniqueId@sda21(r13)
/* 801D2268 001CF1C8 38 00 00 00 */ li r0, 0
/* 801D226C 001CF1CC 80 AD 91 8C */ lwz r5, lbl_805A7D4C@sda21(r13)

View File

@ -498,7 +498,7 @@ lbl_8018F18C:
/* 8018F20C 0018C16C 38 61 00 30 */ addi r3, r1, 0x30
/* 8018F210 0018C170 38 81 00 98 */ addi r4, r1, 0x98
/* 8018F214 0018C174 38 A0 00 01 */ li r5, 1
/* 8018F218 0018C178 4B F7 75 F5 */ bl sub_8010680c
/* 8018F218 0018C178 4B F7 75 F5 */ bl HotInThermal__16CActorParametersCFb
/* 8018F21C 0018C17C A0 8D A3 8C */ lhz r4, kInvalidUniqueId@sda21(r13)
/* 8018F220 0018C180 38 00 00 00 */ li r0, 0
/* 8018F224 0018C184 80 AD 8E F0 */ lwz r5, lbl_805A7AB0@sda21(r13)

View File

@ -1783,7 +1783,7 @@ lbl_8008F11C:
/* 8008F1FC 0008C15C 7E E5 BB 78 */ mr r5, r23
/* 8008F200 0008C160 38 61 01 58 */ addi r3, r1, 0x158
/* 8008F204 0008C164 38 81 01 C0 */ addi r4, r1, 0x1c0
/* 8008F208 0008C168 48 07 76 05 */ bl sub_8010680c
/* 8008F208 0008C168 48 07 76 05 */ bl HotInThermal__16CActorParametersCFb
/* 8008F20C 0008C16C A0 8D A3 8C */ lhz r4, kInvalidUniqueId@sda21(r13)
/* 8008F210 0008C170 38 00 00 00 */ li r0, 0
/* 8008F214 0008C174 80 AD 85 50 */ lwz r5, lbl_805A7110@sda21(r13)

View File

@ -1123,7 +1123,7 @@ lbl_80090788:
/* 80090938 0008D898 93 A1 00 10 */ stw r29, 0x10(r1)
/* 8009093C 0008D89C 91 61 00 14 */ stw r11, 0x14(r1)
/* 80090940 0008D8A0 90 01 00 18 */ stw r0, 0x18(r1)
/* 80090944 0008D8A4 48 07 19 51 */ bl "__ct__7CWeaponF9TUniqueIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfoiRC10CModelData"
/* 80090944 0008D8A4 48 07 19 51 */ bl "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData"
/* 80090948 0008D8A8 38 61 00 90 */ addi r3, r1, 0x90
/* 8009094C 0008D8AC 38 80 FF FF */ li r4, -1
/* 80090950 0008D8B0 48 08 60 FD */ bl __dt__10CModelDataFv

View File

@ -554,7 +554,7 @@ lbl_8014DE38:
/* 8014DFD8 0014AF38 93 41 00 10 */ stw r26, 0x10(r1)
/* 8014DFDC 0014AF3C 91 61 00 14 */ stw r11, 0x14(r1)
/* 8014DFE0 0014AF40 90 01 00 18 */ stw r0, 0x18(r1)
/* 8014DFE4 0014AF44 4B FB 42 B1 */ bl "__ct__7CWeaponF9TUniqueIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfoiRC10CModelData"
/* 8014DFE4 0014AF44 4B FB 42 B1 */ bl "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData"
/* 8014DFE8 0014AF48 38 61 00 78 */ addi r3, r1, 0x78
/* 8014DFEC 0014AF4C 38 80 FF FF */ li r4, -1
/* 8014DFF0 0014AF50 4B FC 8A 5D */ bl __dt__10CModelDataFv

View File

@ -3,8 +3,8 @@
.section .data
.balign 8
.global lbl_803DFEF0
lbl_803DFEF0:
.global __vt__7CWeapon
__vt__7CWeapon:
# ROM: 0x3DCEF0
.4byte 0
.4byte 0
@ -123,30 +123,23 @@ FluidFXThink__7CWeaponFQ26CActor11EFluidStateR12CScriptWaterR13CStateManager:
/* 80101F54 000FEEB4 7C 03 00 2E */ lwzx r0, r3, r0
/* 80101F58 000FEEB8 7C 09 03 A6 */ mtctr r0
/* 80101F5C 000FEEBC 4E 80 04 20 */ bctr
.global lbl_80101F60
lbl_80101F60:
/* 80101F60 000FEEC0 C3 E2 93 EC */ lfs f31, lbl_805AB10C@sda21(r2)
/* 80101F64 000FEEC4 48 00 00 2C */ b lbl_80101F90
.global lbl_80101F68
lbl_80101F68:
/* 80101F68 000FEEC8 C3 E2 93 F0 */ lfs f31, lbl_805AB110@sda21(r2)
/* 80101F6C 000FEECC 48 00 00 24 */ b lbl_80101F90
.global lbl_80101F70
lbl_80101F70:
/* 80101F70 000FEED0 C3 E2 93 EC */ lfs f31, lbl_805AB10C@sda21(r2)
/* 80101F74 000FEED4 48 00 00 1C */ b lbl_80101F90
.global lbl_80101F78
lbl_80101F78:
/* 80101F78 000FEED8 48 00 00 18 */ b lbl_80101F90
.global lbl_80101F7C
lbl_80101F7C:
/* 80101F7C 000FEEDC C3 E2 93 F4 */ lfs f31, lbl_805AB114@sda21(r2)
/* 80101F80 000FEEE0 48 00 00 10 */ b lbl_80101F90
.global lbl_80101F84
lbl_80101F84:
/* 80101F84 000FEEE4 C3 E2 93 EC */ lfs f31, lbl_805AB10C@sda21(r2)
/* 80101F88 000FEEE8 48 00 00 08 */ b lbl_80101F90
.global lbl_80101F8C
lbl_80101F8C:
/* 80101F8C 000FEEEC 3B 60 00 00 */ li r27, 0
lbl_80101F90:
@ -326,8 +319,8 @@ lbl_801021E8:
/* 80102210 000FF170 38 21 00 40 */ addi r1, r1, 0x40
/* 80102214 000FF174 4E 80 00 20 */ blr
.global sub_80102218
sub_80102218:
.global SetDamageFalloffSpeed__7CWeaponFf
SetDamageFalloffSpeed__7CWeaponFf:
/* 80102218 000FF178 C0 02 93 E8 */ lfs f0, lbl_805AB108@sda21(r2)
/* 8010221C 000FF17C FC 01 00 40 */ fcmpo cr0, f1, f0
/* 80102220 000FF180 4C 81 00 20 */ blelr
@ -346,9 +339,9 @@ __dt__7CWeaponFv:
/* 80102248 000FF1A8 93 C1 00 08 */ stw r30, 8(r1)
/* 8010224C 000FF1AC 7C 7E 1B 79 */ or. r30, r3, r3
/* 80102250 000FF1B0 41 82 00 28 */ beq lbl_80102278
/* 80102254 000FF1B4 3C A0 80 3E */ lis r5, lbl_803DFEF0@ha
/* 80102254 000FF1B4 3C A0 80 3E */ lis r5, __vt__7CWeapon@ha
/* 80102258 000FF1B8 38 80 00 00 */ li r4, 0
/* 8010225C 000FF1BC 38 05 FE F0 */ addi r0, r5, lbl_803DFEF0@l
/* 8010225C 000FF1BC 38 05 FE F0 */ addi r0, r5, __vt__7CWeapon@l
/* 80102260 000FF1C0 90 1E 00 00 */ stw r0, 0(r30)
/* 80102264 000FF1C4 4B F5 34 8D */ bl __dt__6CActorFv
/* 80102268 000FF1C8 7F E0 07 35 */ extsh. r0, r31
@ -364,8 +357,8 @@ lbl_80102278:
/* 8010228C 000FF1EC 38 21 00 10 */ addi r1, r1, 0x10
/* 80102290 000FF1F0 4E 80 00 20 */ blr
.global "__ct__7CWeaponF9TUniqueIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfoiRC10CModelData"
"__ct__7CWeaponF9TUniqueIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfoiRC10CModelData":
.global "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData"
"__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData":
/* 80102294 000FF1F4 94 21 FE B0 */ stwu r1, -0x150(r1)
/* 80102298 000FF1F8 7C 08 02 A6 */ mflr r0
/* 8010229C 000FF1FC 3D 60 80 57 */ lis r11, NullConnectionList__7CEntity@ha
@ -397,7 +390,7 @@ lbl_80102278:
/* 80102304 000FF264 38 61 00 48 */ addi r3, r1, 0x48
/* 80102308 000FF268 38 81 00 B0 */ addi r4, r1, 0xb0
/* 8010230C 000FF26C 38 A0 00 01 */ li r5, 1
/* 80102310 000FF270 48 00 44 FD */ bl sub_8010680c
/* 80102310 000FF270 48 00 44 FD */ bl HotInThermal__16CActorParametersCFb
/* 80102314 000FF274 A0 6D A3 8C */ lhz r3, kInvalidUniqueId@sda21(r13)
/* 80102318 000FF278 38 81 00 48 */ addi r4, r1, 0x48
/* 8010231C 000FF27C A0 F4 00 00 */ lhz r7, 0(r20)
@ -440,9 +433,9 @@ lbl_8010239C:
/* 801023A8 000FF308 41 82 00 08 */ beq lbl_801023B0
/* 801023AC 000FF30C 48 21 35 85 */ bl Free__7CMemoryFPCv
lbl_801023B0:
/* 801023B0 000FF310 3C 60 80 3E */ lis r3, lbl_803DFEF0@ha
/* 801023B0 000FF310 3C 60 80 3E */ lis r3, __vt__7CWeapon@ha
/* 801023B4 000FF314 C0 02 93 E8 */ lfs f0, lbl_805AB108@sda21(r2)
/* 801023B8 000FF318 38 03 FE F0 */ addi r0, r3, lbl_803DFEF0@l
/* 801023B8 000FF318 38 03 FE F0 */ addi r0, r3, __vt__7CWeapon@l
/* 801023BC 000FF31C 7F 23 CB 78 */ mr r3, r25
/* 801023C0 000FF320 90 19 00 00 */ stw r0, 0(r25)
/* 801023C4 000FF324 93 F9 00 E8 */ stw r31, 0xe8(r25)

View File

@ -118,6 +118,11 @@ public:
float GetFadeOutTime() const { return x60_fadeOutTime; }
static CActorParameters None();
CActorParameters HotInThermal(bool hot) const;/* {
CActorParameters ret = *this;
ret.x58_25_thermalHeat = hot;
return ret;
}*/
private:
CLightParameters x0_lightParams;

View File

@ -9,7 +9,10 @@
class CWeapon : public CActor {
public:
// TODO
CWeapon(TUniqueId uid, TAreaId areaId, bool active, TUniqueId owner, EWeaponType type,
const rstl::string& name, CTransform4f& xf, const CMaterialFilter& filter,
const CMaterialList& mList, const CDamageInfo& dInfo, EProjectileAttrib attribs,
const CModelData& mData);
// CEntity
~CWeapon() override;
@ -23,7 +26,7 @@ public:
void FluidFXThink(EFluidState, CScriptWater&, CStateManager&) override;
EProjectileAttrib GetAttribField() const { return xe8_projectileAttribs; }
void SetDamageFalloffSpeed(float d);
private:
EProjectileAttrib xe8_projectileAttribs;
TUniqueId xec_ownerId;

View File

@ -0,0 +1,111 @@
#include "MetroidPrime/Weapons/CWeapon.hpp"
#include "MetroidPrime/CActorParameters.hpp"
#include "MetroidPrime/ScriptObjects/CScriptWater.hpp"
#include <rstl/math.hpp>
CWeapon::CWeapon(TUniqueId uid, TAreaId areaId, bool active, TUniqueId owner, EWeaponType type,
const rstl::string& name, CTransform4f& xf, const CMaterialFilter& filter,
const CMaterialList& mList, const CDamageInfo& dInfo, EProjectileAttrib attribs,
const CModelData& mData)
: CActor(uid, active, name, CEntityInfo(areaId, CEntity::NullConnectionList), xf, mData, mList,
CActorParameters::None().HotInThermal(true), kInvalidUniqueId)
, xe8_projectileAttribs(attribs)
, xec_ownerId(owner)
, xf0_weaponType(type)
, xf8_filter(filter)
, x110_origDamageInfo(dInfo)
, x12c_curDamageInfo(dInfo)
, x148_curTime(0.f)
, x14c_damageFalloffSpeed(0.f)
, x150_damageDuration(0.f)
, x154_interferenceDuration(0.f) {}
CWeapon::~CWeapon() {}
void CWeapon::SetDamageFalloffSpeed(float speed) {
if (speed > 0.f) {
x14c_damageFalloffSpeed = 1.f / speed;
}
}
void CWeapon::Think(float dt, CStateManager& mgr) {
x148_curTime += dt;
if ((xe8_projectileAttribs & kPA_DamageFalloff) == kPA_DamageFalloff) {
float damMul = CMath::Max(0.f, 1.f - x148_curTime * x14c_damageFalloffSpeed);
x12c_curDamageInfo = CDamageInfo(
x110_origDamageInfo.GetWeaponMode(), damMul * x110_origDamageInfo.GetDamage(),
damMul * x110_origDamageInfo.GetRadius(), damMul * x110_origDamageInfo.GetKnockBackPower());
} else {
x12c_curDamageInfo = x110_origDamageInfo;
}
CEntity::Think(dt, mgr);
}
void CWeapon::FluidFXThink(EFluidState state, CScriptWater& water, CStateManager& mgr) {
bool doRipple = true;
float mag = 0.f;
switch (xf0_weaponType) {
case kWT_Power:
mag = 0.1f;
break;
case kWT_Ice:
mag = 0.3f;
break;
case kWT_Wave:
mag = 0.1f;
break;
case kWT_Plasma:
break;
case kWT_Missile:
mag = 0.5f;
break;
case kWT_Phazon:
mag = 0.1f;
break;
default:
doRipple = false;
break;
}
if ((xe8_projectileAttribs & kPA_ComboShot) != 0 && state != kFS_InFluid) {
mag += 0.5f;
}
if ((xe8_projectileAttribs & kPA_Charged) != 0) {
mag += 0.25f;
}
if (mag > 1.f) {
mag = 1.f;
}
#if 0
if (doRipple) {
CVector3f pos = GetTranslation();
pos.SetZ(float(water.GetTriggerBoundsWR().GetMax().GetZ()));
if (True(xe8_projectileAttribs & EProjectileAttrib::ComboShot)) {
if (!water.CanRippleAtPoint(pos))
doRipple = false;
} else if (state == EFluidState::InFluid) {
doRipple = false;
}
if (doRipple) {
water.GetFluidPlane().AddRipple(mag, x8_uid, pos, water, mgr);
mgr.GetFluidPlaneManager()->CreateSplash(x8_uid, mgr, water, pos, mag,
state == EFluidState::EnteredFluid ||
state == EFluidState::LeftFluid);
}
}
#endif
}
void CWeapon::Render(const CStateManager& mgr) const {}
EWeaponCollisionResponseTypes CWeapon::GetCollisionResponseType(const CVector3f& pos,
const CVector3f& dir,
const CWeaponMode& wMode,
int) const {
return kWCR_Projectile;
}