From 8498bd6e942cf870d8138b30baa0e553d1ca0174 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 1 Nov 2022 01:46:20 +0200 Subject: [PATCH] Match and link CScriptBeam Former-commit-id: b19380ffb4f599a0b8fc2095dc5991a085ca12b5 --- asm/MetroidPrime/Enemies/CEyeBall.s | 2 +- asm/MetroidPrime/Enemies/CMetroidPrimeExo.s | 2 +- asm/MetroidPrime/Enemies/CNewIntroBoss.s | 6 +- asm/MetroidPrime/Enemies/CRidley.s | 2 +- asm/MetroidPrime/ScriptLoader.s | 2 +- asm/MetroidPrime/ScriptObjects/CScriptBeam.s | 18 ++-- asm/MetroidPrime/Weapons/CPlasmaProjectile.s | 4 +- configure.py | 2 +- .../ScriptObjects/CScriptBeam.hpp | 26 +++++ include/MetroidPrime/Weapons/CBeamInfo.hpp | 37 +++++++ .../Weapons/CPlasmaProjectile.hpp | 98 +++++++++++++++++++ include/rstl/string.hpp | 2 + obj_files.mk | 2 +- .../ScriptObjects/CScriptBeam.cpp | 68 +++++++++++++ 14 files changed, 251 insertions(+), 20 deletions(-) create mode 100644 include/MetroidPrime/ScriptObjects/CScriptBeam.hpp create mode 100644 include/MetroidPrime/Weapons/CBeamInfo.hpp create mode 100644 include/MetroidPrime/Weapons/CPlasmaProjectile.hpp create mode 100644 src/MetroidPrime/ScriptObjects/CScriptBeam.cpp diff --git a/asm/MetroidPrime/Enemies/CEyeBall.s b/asm/MetroidPrime/Enemies/CEyeBall.s index b59ebcd8..c4b5de0c 100644 --- a/asm/MetroidPrime/Enemies/CEyeBall.s +++ b/asm/MetroidPrime/Enemies/CEyeBall.s @@ -1368,7 +1368,7 @@ CreateBeam__8CEyeballFR13CStateManager: /* 8022566C 002225CC 38 C0 00 09 */ li r6, 9 /* 80225670 002225D0 39 20 00 21 */ li r9, 0x21 /* 80225674 002225D4 90 01 00 1C */ stw r0, 0x1c(r1) -/* 80225678 002225D8 4B F5 35 B1 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" +/* 80225678 002225D8 4B F5 35 B1 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" /* 8022567C 002225DC 7C 7F 1B 78 */ mr r31, r3 lbl_80225680: /* 80225680 002225E0 7F 80 07 75 */ extsb. r0, r28 diff --git a/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s b/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s index 7b45a370..cdc48a43 100644 --- a/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s +++ b/asm/MetroidPrime/Enemies/CMetroidPrimeExo.s @@ -8349,7 +8349,7 @@ lbl_80277D38: /* 80277DB4 00274D14 39 20 00 21 */ li r9, 0x21 /* 80277DB8 00274D18 90 01 00 18 */ stw r0, 0x18(r1) /* 80277DBC 00274D1C 93 E1 00 1C */ stw r31, 0x1c(r1) -/* 80277DC0 00274D20 4B F0 0E 69 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" +/* 80277DC0 00274D20 4B F0 0E 69 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" /* 80277DC4 00274D24 7C 7D 1B 78 */ mr r29, r3 lbl_80277DC8: /* 80277DC8 00274D28 7F 80 07 75 */ extsb. r0, r28 diff --git a/asm/MetroidPrime/Enemies/CNewIntroBoss.s b/asm/MetroidPrime/Enemies/CNewIntroBoss.s index b59425d6..ea145333 100644 --- a/asm/MetroidPrime/Enemies/CNewIntroBoss.s +++ b/asm/MetroidPrime/Enemies/CNewIntroBoss.s @@ -673,7 +673,7 @@ lbl_8018A148: /* 8018A450 001873B0 38 C0 00 09 */ li r6, 9 /* 8018A454 001873B4 39 20 00 21 */ li r9, 0x21 /* 8018A458 001873B8 90 01 00 1C */ stw r0, 0x1c(r1) -/* 8018A45C 001873BC 4B FE E7 CD */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" +/* 8018A45C 001873BC 4B FE E7 CD */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" /* 8018A460 001873C0 7C 7B 1B 78 */ mr r27, r3 lbl_8018A464: /* 8018A464 001873C4 7E E0 07 75 */ extsb. r0, r23 @@ -737,7 +737,7 @@ lbl_8018A478: /* 8018A548 001874A8 38 C0 00 09 */ li r6, 9 /* 8018A54C 001874AC 39 20 00 21 */ li r9, 0x21 /* 8018A550 001874B0 90 01 00 1C */ stw r0, 0x1c(r1) -/* 8018A554 001874B4 4B FE E6 D5 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" +/* 8018A554 001874B4 4B FE E6 D5 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" /* 8018A558 001874B8 7C 7B 1B 78 */ mr r27, r3 lbl_8018A55C: /* 8018A55C 001874BC 7E E0 07 75 */ extsb. r0, r23 @@ -818,7 +818,7 @@ lbl_8018A570: /* 8018A684 001875E4 38 C0 00 09 */ li r6, 9 /* 8018A688 001875E8 39 20 00 21 */ li r9, 0x21 /* 8018A68C 001875EC 90 01 00 1C */ stw r0, 0x1c(r1) -/* 8018A690 001875F0 4B FE E5 99 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" +/* 8018A690 001875F0 4B FE E5 99 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" /* 8018A694 001875F4 7C 7B 1B 78 */ mr r27, r3 lbl_8018A698: /* 8018A698 001875F8 7E E0 07 75 */ extsb. r0, r23 diff --git a/asm/MetroidPrime/Enemies/CRidley.s b/asm/MetroidPrime/Enemies/CRidley.s index 284c1396..9390b64e 100644 --- a/asm/MetroidPrime/Enemies/CRidley.s +++ b/asm/MetroidPrime/Enemies/CRidley.s @@ -5707,7 +5707,7 @@ sub_80256db4: /* 80256EC4 00253E24 38 C0 00 09 */ li r6, 9 /* 80256EC8 00253E28 39 20 00 21 */ li r9, 0x21 /* 80256ECC 00253E2C 90 01 00 1C */ stw r0, 0x1c(r1) -/* 80256ED0 00253E30 4B F2 1D 59 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" +/* 80256ED0 00253E30 4B F2 1D 59 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" /* 80256ED4 00253E34 7C 7F 1B 78 */ mr r31, r3 lbl_80256ED8: /* 80256ED8 00253E38 7F 80 07 75 */ extsb. r0, r28 diff --git a/asm/MetroidPrime/ScriptLoader.s b/asm/MetroidPrime/ScriptLoader.s index 23f6bb52..56746b88 100644 --- a/asm/MetroidPrime/ScriptLoader.s +++ b/asm/MetroidPrime/ScriptLoader.s @@ -1409,7 +1409,7 @@ lbl_800C6444: /* 800C64F4 000C3454 39 21 00 18 */ addi r9, r1, 0x18 /* 800C64F8 000C3458 39 41 00 8C */ addi r10, r1, 0x8c /* 800C64FC 000C345C 3B 20 00 01 */ li r25, 1 -/* 800C6500 000C3460 48 1B 64 81 */ bl "__ct__11CScriptBeamF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC34TLockedToken<18CWeaponDescription>RC9CBeamInfoRC11CDamageInfo" +/* 800C6500 000C3460 48 1B 64 81 */ bl "__ct__11CScriptBeamF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC28TToken<18CWeaponDescription>RC9CBeamInfoRC11CDamageInfo" /* 800C6504 000C3464 7C 7F 1B 78 */ mr r31, r3 lbl_800C6508: /* 800C6508 000C3468 7F 20 07 75 */ extsb. r0, r25 diff --git a/asm/MetroidPrime/ScriptObjects/CScriptBeam.s b/asm/MetroidPrime/ScriptObjects/CScriptBeam.s index 1f3675e0..d080971e 100644 --- a/asm/MetroidPrime/ScriptObjects/CScriptBeam.s +++ b/asm/MetroidPrime/ScriptObjects/CScriptBeam.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803EB180 -lbl_803EB180: +.global __vt__11CScriptBeam +__vt__11CScriptBeam: # ROM: 0x3E8180 .4byte 0 .4byte 0 @@ -48,9 +48,9 @@ __dt__11CScriptBeamFv: /* 8027C5E0 00279540 93 C1 00 08 */ stw r30, 8(r1) /* 8027C5E4 00279544 7C 7E 1B 79 */ or. r30, r3, r3 /* 8027C5E8 00279548 41 82 00 48 */ beq lbl_8027C630 -/* 8027C5EC 0027954C 3C 60 80 3F */ lis r3, lbl_803EB180@ha +/* 8027C5EC 0027954C 3C 60 80 3F */ lis r3, __vt__11CScriptBeam@ha /* 8027C5F0 00279550 34 1E 00 E8 */ addic. r0, r30, 0xe8 -/* 8027C5F4 00279554 38 03 B1 80 */ addi r0, r3, lbl_803EB180@l +/* 8027C5F4 00279554 38 03 B1 80 */ addi r0, r3, __vt__11CScriptBeam@l /* 8027C5F8 00279558 90 1E 00 00 */ stw r0, 0(r30) /* 8027C5FC 0027955C 41 82 00 18 */ beq lbl_8027C614 /* 8027C600 00279560 34 1E 00 E8 */ addic. r0, r30, 0xe8 @@ -222,7 +222,7 @@ lbl_8027C764: /* 8027C85C 002797BC 91 21 00 18 */ stw r9, 0x18(r1) /* 8027C860 002797C0 39 20 00 23 */ li r9, 0x23 /* 8027C864 002797C4 90 01 00 1C */ stw r0, 0x1c(r1) -/* 8027C868 002797C8 4B EF C3 C1 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" +/* 8027C868 002797C8 4B EF C3 C1 */ bl "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" /* 8027C86C 002797CC 7C 7F 1B 78 */ mr r31, r3 lbl_8027C870: /* 8027C870 002797D0 7F C3 F3 78 */ mr r3, r30 @@ -299,8 +299,8 @@ lbl_8027C950: /* 8027C978 002798D8 38 21 00 B0 */ addi r1, r1, 0xb0 /* 8027C97C 002798DC 4E 80 00 20 */ blr -.global "__ct__11CScriptBeamF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC34TLockedToken<18CWeaponDescription>RC9CBeamInfoRC11CDamageInfo" -"__ct__11CScriptBeamF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC34TLockedToken<18CWeaponDescription>RC9CBeamInfoRC11CDamageInfo": +.global "__ct__11CScriptBeamF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC28TToken<18CWeaponDescription>RC9CBeamInfoRC11CDamageInfo" +"__ct__11CScriptBeamF9TUniqueIdRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fbRC28TToken<18CWeaponDescription>RC9CBeamInfoRC11CDamageInfo": /* 8027C980 002798E0 94 21 FF 00 */ stwu r1, -0x100(r1) /* 8027C984 002798E4 7C 08 02 A6 */ mflr r0 /* 8027C988 002798E8 90 01 01 04 */ stw r0, 0x104(r1) @@ -344,9 +344,9 @@ lbl_8027C950: /* 8027CA20 00279980 38 61 00 88 */ addi r3, r1, 0x88 /* 8027CA24 00279984 38 80 FF FF */ li r4, -1 /* 8027CA28 00279988 4B E9 A0 25 */ bl __dt__10CModelDataFv -/* 8027CA2C 0027998C 3C 60 80 3F */ lis r3, lbl_803EB180@ha +/* 8027CA2C 0027998C 3C 60 80 3F */ lis r3, __vt__11CScriptBeam@ha /* 8027CA30 00279990 3A FD 00 E8 */ addi r23, r29, 0xe8 -/* 8027CA34 00279994 38 03 B1 80 */ addi r0, r3, lbl_803EB180@l +/* 8027CA34 00279994 38 03 B1 80 */ addi r0, r3, __vt__11CScriptBeam@l /* 8027CA38 00279998 7F 84 E3 78 */ mr r4, r28 /* 8027CA3C 0027999C 90 1D 00 00 */ stw r0, 0(r29) /* 8027CA40 002799A0 7E E3 BB 78 */ mr r3, r23 diff --git a/asm/MetroidPrime/Weapons/CPlasmaProjectile.s b/asm/MetroidPrime/Weapons/CPlasmaProjectile.s index b2d5777c..fc97f310 100644 --- a/asm/MetroidPrime/Weapons/CPlasmaProjectile.s +++ b/asm/MetroidPrime/Weapons/CPlasmaProjectile.s @@ -2355,8 +2355,8 @@ Accept__17CPlasmaProjectileFR8IVisitor: /* 80178C20 00175B80 38 21 00 10 */ addi r1, r1, 0x10 /* 80178C24 00175B84 4E 80 00 20 */ blr -.global "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi" -"__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId9TUniqueIdbUi": +.global "__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib" +"__ct__17CPlasmaProjectileFRC28TToken<18CWeaponDescription>RCQ24rstl66basic_string,Q24rstl17rmemory_allocator>11EWeaponTypeRC9CBeamInfoRC12CTransform4f14EMaterialTypesRC11CDamageInfo9TUniqueId7TAreaId9TUniqueIdRCQ217CPlasmaProjectile21PlayerEffectResourcesb17EProjectileAttrib": /* 80178C28 00175B88 94 21 FE C0 */ stwu r1, -0x140(r1) /* 80178C2C 00175B8C 7C 08 02 A6 */ mflr r0 /* 80178C30 00175B90 90 01 01 44 */ stw r0, 0x144(r1) diff --git a/configure.py b/configure.py index ed763e18..47af3ef9 100755 --- a/configure.py +++ b/configure.py @@ -369,7 +369,7 @@ LIBS = [ "MetroidPrime/CFluidPlaneRender", "MetroidPrime/Enemies/CBurrower", "MetroidPrime/Enemies/CMetroidPrimeExo", - "MetroidPrime/ScriptObjects/CScriptBeam", + ["MetroidPrime/ScriptObjects/CScriptBeam", True], "MetroidPrime/Enemies/CMetroidPrimeEssence", "MetroidPrime/Enemies/CMetroidPrimeRelay", "MetroidPrime/Player/CPlayerDynamics", diff --git a/include/MetroidPrime/ScriptObjects/CScriptBeam.hpp b/include/MetroidPrime/ScriptObjects/CScriptBeam.hpp new file mode 100644 index 00000000..4a53b317 --- /dev/null +++ b/include/MetroidPrime/ScriptObjects/CScriptBeam.hpp @@ -0,0 +1,26 @@ +#ifndef _CSCRIPTBEAM +#define _CSCRIPTBEAM + +#include "MetroidPrime/CActor.hpp" + +#include "MetroidPrime/CDamageInfo.hpp" +#include "MetroidPrime/Weapons/CBeamInfo.hpp" + +class CWeaponDescription; +class CScriptBeam : public CActor { + TLockedToken< CWeaponDescription > xe8_weaponDescription; + CBeamInfo xf4_beamInfo; + CDamageInfo x138_damageInfo; + TUniqueId x154_projectileId; + +public: + CScriptBeam(TUniqueId, const rstl::string&, const CEntityInfo&, const CTransform4f&, bool, + const TToken< CWeaponDescription >&, const CBeamInfo&, const CDamageInfo&); + ~CScriptBeam(); + + void Accept(IVisitor& visitor) override; + void Think(float, CStateManager&) override; + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; +}; + +#endif // _CSCRIPTBEAM diff --git a/include/MetroidPrime/Weapons/CBeamInfo.hpp b/include/MetroidPrime/Weapons/CBeamInfo.hpp new file mode 100644 index 00000000..14b5d553 --- /dev/null +++ b/include/MetroidPrime/Weapons/CBeamInfo.hpp @@ -0,0 +1,37 @@ +#ifndef _CBEAMINFO +#define _CBEAMINFO + +#include "MetroidPrime/TGameTypes.hpp" + +#include "Kyoto/SObjectTag.hpp" +#include "Kyoto/Graphics/CColor.hpp" + +class CBeamInfo { + +private: + uint x0_; + /* + * 0x1: motion blur + * 0x2: pulse effect + * 0x4: one shot + * 0x8: phazon damage + */ + int x4_beamAttributes; + CAssetId x8_contactFxId; + CAssetId xc_pulseFxId; + CAssetId x10_textureId; + CAssetId x14_glowTextureId; + int x18_length; + float x1c_radius; + float x20_expansionSpeed; + float x24_lifeTime; + float x28_pulseSpeed; + float x2c_shutdownTime; + float x30_contactFxScale; + float x34_pulseFxScale; + float x38_travelSpeed; + CColor x3c_innerColor; + CColor x40_outerColor; +}; + +#endif // _CBEAMINFO diff --git a/include/MetroidPrime/Weapons/CPlasmaProjectile.hpp b/include/MetroidPrime/Weapons/CPlasmaProjectile.hpp new file mode 100644 index 00000000..b851d164 --- /dev/null +++ b/include/MetroidPrime/Weapons/CPlasmaProjectile.hpp @@ -0,0 +1,98 @@ +#ifndef _CPLASMAPROJECTILE +#define _CPLASMAPROJECTILE + +#include "MetroidPrime/Weapons/CBeamProjectile.hpp" + +class CElectricDescription; + +class CPlasmaProjectile : public CBeamProjectile { +public: + enum EExpansionState { kES_Inactive, kES_Attack, kES_Sustain, kES_Release, kES_Done }; + + struct PlayerEffectResources { + int count; + CAssetId data[8]; + + PlayerEffectResources(CAssetId a = kInvalidAssetId, CAssetId b = kInvalidAssetId, + CAssetId c = kInvalidAssetId, CAssetId d = kInvalidAssetId, + CAssetId e = kInvalidAssetId, CAssetId f = kInvalidAssetId, + CAssetId g = kInvalidAssetId, CAssetId h = kInvalidAssetId) + : count(8) + { + data[0] = a; + data[1] = b; + data[2] = c; + data[3] = d; + data[4] = e; + data[5] = f; + data[6] = g; + data[7] = h; + } + }; + + CPlasmaProjectile(const TToken< CWeaponDescription >& wDesc, const rstl::string& name, + EWeaponType wType, const CBeamInfo& bInfo, const CTransform4f& xf, + EMaterialTypes matType, const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, + TUniqueId owner, + + const PlayerEffectResources& res, bool growingBeam, EProjectileAttrib attribs); + + void Accept(IVisitor& visitor) override; + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; + void ResetBeam(CStateManager& mgr, bool fullReset) override; + void UpdateFx(const CTransform4f& xf, float dt, CStateManager& mgr) override; + void Fire(const CTransform4f& xf, CStateManager& mgr, bool b) override; + void Touch(CActor& other, CStateManager& mgr) override; + bool CanRenderUnsorted(const CStateManager& mgr) const override; + void AddToRenderer(const CFrustumPlanes& frustum, CStateManager& mgr) override; + void Render(CStateManager& mgr) override; + CColor GetInnerColor() const { return x490_innerColor; } + CColor GetOuterColor() const { return x494_outerColor; } + bool IsFiring() const { return x548_26_firing; } + +private: + rstl::vector< TUniqueId > x468_lights; + int x478_beamAttributes; + float x47c_lifeTime; + float x480_pulseSpeed; + float x484_shutdownTime; + float x488_expansionSpeed; + float x48c_; + CColor x490_innerColor; + CColor x494_outerColor; + CDamageInfo x498_phazonDamage; + EExpansionState x4b4_expansionState; + float x4b8_beamWidth; + float x4bc_lifeTimer; + float x4c0_expansionT; + float x4c4_expansion; + float x4c8_beamAngle; + float x4cc_energyPulseStartY; + float x4d0_shutdownTimer; + float x4d4_contactPulseTimer; + float x4d8_energyPulseTimer; + float x4dc_playerEffectPulseTimer; + float x4e0_playerDamageDuration; + float x4e4_playerDamageTimer; + TLockedToken< CTexture > x4e8_texture; + TLockedToken< CTexture > x4f4_glowTexture; + TCachedToken< CGenDescription > x500_contactFxDesc; + TCachedToken< CGenDescription > x50c_pulseFxDesc; + rstl::single_ptr< CElementGen > x518_contactGen; + rstl::single_ptr< CElementGen > x51c_pulseGen; + rstl::single_ptr< CElementGen > x520_weaponGen; + CAssetId x524_freezeSteamTxtr; + CAssetId x528_freezeIceTxtr; + rstl::optional_object< TToken< CElectricDescription > > x52c_visorElectric; + rstl::optional_object< TToken< CGenDescription > > x538_visorParticle; + u16 x544_freezeSfx; + u16 x546_electricSfx; + bool x548_24_ : 1; + bool x548_25_enableEnergyPulse : 1; + bool x548_26_firing : 1; + bool x548_27_texturesLoaded : 1; + bool x548_28_drawOwnerFirst : 1; + bool x548_29_activePlayerPhazon : 1; +}; + +#endif // _CPLASMAPROJECTILE diff --git a/include/rstl/string.hpp b/include/rstl/string.hpp index 4109cc80..831f3546 100644 --- a/include/rstl/string.hpp +++ b/include/rstl/string.hpp @@ -127,6 +127,8 @@ string string_l(const char* data); // return string(string::literal_t(), data); // } +string operator+(const string&, const string&); + CHECK_SIZEOF(string, 0x10) } // namespace rstl diff --git a/obj_files.mk b/obj_files.mk index b4707a54..a91830d1 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -334,7 +334,7 @@ METROIDPRIME :=\ $(BUILD_DIR)/asm/MetroidPrime/CFluidPlaneRender.o\ $(BUILD_DIR)/asm/MetroidPrime/Enemies/CBurrower.o\ $(BUILD_DIR)/asm/MetroidPrime/Enemies/CMetroidPrimeExo.o\ - $(BUILD_DIR)/asm/MetroidPrime/ScriptObjects/CScriptBeam.o\ + $(BUILD_DIR)/src/MetroidPrime/ScriptObjects/CScriptBeam.o\ $(BUILD_DIR)/asm/MetroidPrime/Enemies/CMetroidPrimeEssence.o\ $(BUILD_DIR)/asm/MetroidPrime/Enemies/CMetroidPrimeRelay.o\ $(BUILD_DIR)/asm/MetroidPrime/Player/CPlayerDynamics.o\ diff --git a/src/MetroidPrime/ScriptObjects/CScriptBeam.cpp b/src/MetroidPrime/ScriptObjects/CScriptBeam.cpp new file mode 100644 index 00000000..60384700 --- /dev/null +++ b/src/MetroidPrime/ScriptObjects/CScriptBeam.cpp @@ -0,0 +1,68 @@ +#include "MetroidPrime/ScriptObjects/CScriptBeam.hpp" + +#include "MetroidPrime/CActorParameters.hpp" +#include "MetroidPrime/Weapons/CPlasmaProjectile.hpp" + +CScriptBeam::CScriptBeam(TUniqueId uid, const rstl::string& name, const CEntityInfo& info, + const CTransform4f& xf, bool active, + const TToken< CWeaponDescription >& weaponDesc, const CBeamInfo& bInfo, + const CDamageInfo& dInfo) +: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), + CActorParameters::None(), kInvalidUniqueId) +, xe8_weaponDescription(weaponDesc) +, xf4_beamInfo(bInfo) +, x138_damageInfo(dInfo) +, x154_projectileId(kInvalidUniqueId) {} + + +void CScriptBeam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& mgr) { + switch (msg) { + + case kSM_Registered: { + x154_projectileId = mgr.AllocateUniqueId(); + mgr.AddObject(new CPlasmaProjectile( + xe8_weaponDescription, GetDebugName() + rstl::string_l("-Projectile"), + x138_damageInfo.GetWeaponMode().GetType(), xf4_beamInfo, x34_transform, kMT_Projectile, + x138_damageInfo, x154_projectileId, GetCurrentAreaId(), GetUniqueId(), + CPlasmaProjectile::PlayerEffectResources(), false, + kPA_KeepInCinematic // TODO: wrong attrib definition? + )); + } break; + + case kSM_Deleted: + mgr.FreeScriptObject(x154_projectileId); + break; + + case kSM_Increment: + if (CPlasmaProjectile* proj = + static_cast< CPlasmaProjectile* >(mgr.ObjectById(x154_projectileId))) { + proj->ResetBeam(mgr, true); + proj->Fire(GetTransform(), mgr, false); + } + break; + case kSM_Decrement: + if (CPlasmaProjectile* proj = + static_cast< CPlasmaProjectile* >(mgr.ObjectById(x154_projectileId))) { + if (proj->GetActive()) { + proj->ResetBeam(mgr, false); + } + } + break; + } + CActor::AcceptScriptMsg(msg, objId, mgr); +} + +void CScriptBeam::Accept(IVisitor& visitor) { visitor.Visit(*this); } + +void CScriptBeam::Think(float dt, CStateManager& mgr) { + if (CPlasmaProjectile* proj = + static_cast< CPlasmaProjectile* >(mgr.ObjectById(x154_projectileId))) { + if (proj->GetActive()) { + proj->UpdateFx(x34_transform, dt, mgr); + } + } else { + x154_projectileId = kInvalidUniqueId; + } +} + +CScriptBeam::~CScriptBeam() {}