From a6ee5c2836e9d5355043bd9debdc23449475652d Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Thu, 10 Nov 2022 01:45:24 +0200 Subject: [PATCH] Add CPowerBomb Former-commit-id: 70e69ea33bad0a9b90db6fcd0a5ade9463f82c77 --- asm/MetroidPrime/CGameProjectile.s | 2 +- asm/MetroidPrime/Weapons/CBomb.s | 2 +- asm/MetroidPrime/Weapons/CPowerBomb.s | 22 ++-- asm/MetroidPrime/Weapons/CWeapon.s | 4 +- configure.py | 2 +- include/Collision/CCollidableAABox.hpp | 2 +- include/Kyoto/Audio/CSfxManager.hpp | 4 +- include/MetroidPrime/CStateManager.hpp | 7 + include/MetroidPrime/Enemies/CAi.hpp | 7 +- .../MetroidPrime/Enemies/EListenNoiseType.hpp | 10 ++ include/MetroidPrime/Player/CPlayer.hpp | 2 + include/MetroidPrime/Player/CPlayerState.hpp | 1 + include/MetroidPrime/Weapons/CPowerBomb.hpp | 22 +++- include/MetroidPrime/Weapons/CWeapon.hpp | 6 +- src/MetroidPrime/Weapons/CPowerBomb.cpp | 123 ++++++++++++++++++ src/MetroidPrime/Weapons/CWeapon.cpp | 2 +- 16 files changed, 187 insertions(+), 31 deletions(-) create mode 100644 include/MetroidPrime/Enemies/EListenNoiseType.hpp create mode 100644 src/MetroidPrime/Weapons/CPowerBomb.cpp diff --git a/asm/MetroidPrime/CGameProjectile.s b/asm/MetroidPrime/CGameProjectile.s index 96312bfb..9caff5ee 100644 --- a/asm/MetroidPrime/CGameProjectile.s +++ b/asm/MetroidPrime/CGameProjectile.s @@ -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__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" +/* 8003A60C 0003756C 48 0C 7C 89 */ bl "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" /* 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 diff --git a/asm/MetroidPrime/Weapons/CBomb.s b/asm/MetroidPrime/Weapons/CBomb.s index b8f3884b..07b65830 100644 --- a/asm/MetroidPrime/Weapons/CBomb.s +++ b/asm/MetroidPrime/Weapons/CBomb.s @@ -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__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" +/* 80090944 0008D8A4 48 07 19 51 */ bl "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" /* 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 diff --git a/asm/MetroidPrime/Weapons/CPowerBomb.s b/asm/MetroidPrime/Weapons/CPowerBomb.s index 3bd6f8c1..e0e101e5 100644 --- a/asm/MetroidPrime/Weapons/CPowerBomb.s +++ b/asm/MetroidPrime/Weapons/CPowerBomb.s @@ -20,7 +20,7 @@ lbl_803E2808: .4byte SetActive__6CActorFUc .4byte PreRender__6CActorFR13CStateManagerRC14CFrustumPlanes .4byte AddToRenderer__10CPowerBombCFRC14CFrustumPlanesRC13CStateManager - .4byte nullsub_228 + .4byte Render__10CPowerBombCFRC13CStateManager .4byte CanRenderUnsorted__6CActorCFRC13CStateManager .4byte CalculateRenderBounds__6CActorFv .4byte HealthInfo__6CActorFR13CStateManager @@ -82,8 +82,8 @@ lbl_805A77F0: .balign 8 # CPowerBomb -.global lbl_805A8FA8 -lbl_805A8FA8: +.global kFadeColor__10CPowerBomb +kFadeColor__10CPowerBomb: .skip 0x8 .section .text, "ax" @@ -243,7 +243,7 @@ Think__10CPowerBombFfR13CStateManager: /* 8014DB74 0014AAD4 38 7F 0C 90 */ addi r3, r31, 0xc90 /* 8014DB78 0014AAD8 38 80 00 03 */ li r4, 3 /* 8014DB7C 0014AADC 38 A0 00 00 */ li r5, 0 -/* 8014DB80 0014AAE0 38 CD A3 E8 */ addi r6, r13, lbl_805A8FA8@sda21 +/* 8014DB80 0014AAE0 38 CD A3 E8 */ addi r6, r13, kFadeColor__10CPowerBomb@sda21 /* 8014DB84 0014AAE4 38 E0 FF FF */ li r7, -1 /* 8014DB88 0014AAE8 4B F9 F8 19 */ bl SetFilter__17CCameraFilterPassFQ217CCameraFilterPass11EFilterTypeQ217CCameraFilterPass12EFilterShapefRC6CColorUi /* 8014DB8C 0014AAEC 88 1E 01 58 */ lbz r0, 0x158(r30) @@ -323,7 +323,7 @@ lbl_8014DC64: /* 8014DCA0 0014AC00 D0 01 00 18 */ stfs f0, 0x18(r1) /* 8014DCA4 0014AC04 D0 21 00 1C */ stfs f1, 0x1c(r1) /* 8014DCA8 0014AC08 D0 41 00 20 */ stfs f2, 0x20(r1) -/* 8014DCAC 0014AC0C 48 00 00 AD */ bl sub_8014dd58 +/* 8014DCAC 0014AC0C 48 00 00 AD */ bl ApplyDynamicDamage__10CPowerBombFRC9CVector3fR13CStateManager /* 8014DCB0 0014AC10 C0 3E 01 64 */ lfs f1, 0x164(r30) /* 8014DCB4 0014AC14 C0 1E 01 60 */ lfs f0, 0x160(r30) /* 8014DCB8 0014AC18 EC 01 07 FA */ fmadds f0, f1, f31, f0 @@ -348,8 +348,8 @@ lbl_8014DCE4: /* 8014DCFC 0014AC5C 38 21 00 40 */ addi r1, r1, 0x40 /* 8014DD00 0014AC60 4E 80 00 20 */ blr -.global nullsub_228 -nullsub_228: +.global Render__10CPowerBombCFRC13CStateManager +Render__10CPowerBombCFRC13CStateManager: /* 8014DD04 0014AC64 4E 80 00 20 */ blr .global AddToRenderer__10CPowerBombCFRC14CFrustumPlanesRC13CStateManager @@ -381,8 +381,8 @@ Touch__10CPowerBombFR6CActorR13CStateManager: /* 8014DD50 0014ACB0 54 00 CF FF */ rlwinm. r0, r0, 0x19, 0x1f, 0x1f /* 8014DD54 0014ACB4 4E 80 00 20 */ blr -.global sub_8014dd58 -sub_8014dd58: +.global ApplyDynamicDamage__10CPowerBombFRC9CVector3fR13CStateManager +ApplyDynamicDamage__10CPowerBombFRC9CVector3fR13CStateManager: /* 8014DD58 0014ACB8 94 21 FF D0 */ stwu r1, -0x30(r1) /* 8014DD5C 0014ACBC 7C 08 02 A6 */ mflr r0 /* 8014DD60 0014ACC0 7C 86 23 78 */ mr r6, r4 @@ -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__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" +/* 8014DFE4 0014AF44 4B FB 42 B1 */ bl "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" /* 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 @@ -629,7 +629,7 @@ lbl_8014E0A8: .global __sinit_CPowerBomb_cpp __sinit_CPowerBomb_cpp: /* 8014E0F8 0014B058 38 00 FF 7F */ li r0, -129 -/* 8014E0FC 0014B05C 90 0D A3 E8 */ stw r0, lbl_805A8FA8@sda21(r13) +/* 8014E0FC 0014B05C 90 0D A3 E8 */ stw r0, kFadeColor__10CPowerBomb@sda21(r13) /* 8014E100 0014B060 4E 80 00 20 */ blr .section .sdata2, "a" diff --git a/asm/MetroidPrime/Weapons/CWeapon.s b/asm/MetroidPrime/Weapons/CWeapon.s index 2865545a..abf52567 100644 --- a/asm/MetroidPrime/Weapons/CWeapon.s +++ b/asm/MetroidPrime/Weapons/CWeapon.s @@ -357,8 +357,8 @@ lbl_80102278: /* 8010228C 000FF1EC 38 21 00 10 */ addi r1, r1, 0x10 /* 80102290 000FF1F0 4E 80 00 20 */ blr -.global "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" -"__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>R12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData": +.global "__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData" +"__ct__7CWeaponF9TUniqueId7TAreaIdb9TUniqueId11EWeaponTypeRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC12CTransform4fRC15CMaterialFilterRC13CMaterialListRC11CDamageInfo17EProjectileAttribRC10CModelData": /* 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 diff --git a/configure.py b/configure.py index 5e187ea5..3346d6f7 100755 --- a/configure.py +++ b/configure.py @@ -214,7 +214,7 @@ LIBS = [ "MetroidPrime/Enemies/CPuddleToadGamma", ["MetroidPrime/ScriptObjects/CScriptDistanceFog", False], ["MetroidPrime/BodyState/CBSProjectileAttack", True], - "MetroidPrime/Weapons/CPowerBomb", + ["MetroidPrime/Weapons/CPowerBomb", False], ["MetroidPrime/Enemies/CMetaree", False], ["MetroidPrime/ScriptObjects/CScriptDockAreaChange", False], ["MetroidPrime/ScriptObjects/CScriptSpecialFunction", False], diff --git a/include/Collision/CCollidableAABox.hpp b/include/Collision/CCollidableAABox.hpp index e795401b..8d743846 100644 --- a/include/Collision/CCollidableAABox.hpp +++ b/include/Collision/CCollidableAABox.hpp @@ -17,7 +17,7 @@ public: CAABox CalculateLocalAABox() const override; FourCC GetPrimType() const override; ~CCollidableAABox() override{}; - CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const; + CRayCastResult CastRayInternal(const CInternalRayCastStructure&) const override; private: CAABox x10_aabb; diff --git a/include/Kyoto/Audio/CSfxManager.hpp b/include/Kyoto/Audio/CSfxManager.hpp index 920424ca..55b5c14a 100644 --- a/include/Kyoto/Audio/CSfxManager.hpp +++ b/include/Kyoto/Audio/CSfxManager.hpp @@ -94,8 +94,8 @@ public: static void PitchBend(CSfxHandle handle, int pitch); - static CSfxHandle SfxStart(ushort id, uchar vol, uchar pan, bool useAcoustics, short prio, - bool looped, int areaId); + static CSfxHandle SfxStart(ushort id, short vol, short pan, bool useAcoustics, short prio = kMaxPriority, + bool looped = false, int areaId = kAllAreas); static bool IsPlaying(const CSfxHandle& handle); static void SetChannel(ESfxChannels); diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index d86ef68a..9d2fd5a6 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -17,6 +17,7 @@ #include "MetroidPrime/Cameras/CCameraFilterPass.hpp" #include "MetroidPrime/TGameTypes.hpp" #include "MetroidPrime/Weapons/WeaponTypes.hpp" +#include "MetroidPrime/Enemies/EListenNoiseType.hpp" #include "rstl/auto_ptr.hpp" #include "rstl/list.hpp" @@ -194,11 +195,17 @@ public: const CDamageInfo& info, const CMaterialFilter& filter, const CVector3f& knockbackVec); + void InformListeners(const CVector3f&, EListenNoiseType); + // void ShowPausedHUDMemo(CAssetId strg, float time); void QueueMessage(int frameCount, CAssetId msg, float f1); int GetHUDMessageFrameCount() const { return xf80_hudMessageFrameCount; } + // Weapon + void RemoveWeaponId(TUniqueId, EWeaponType); + void AddWeaponId(TUniqueId, EWeaponType); + // State transitions void DeferStateTransition(EStateManagerTransition t); void EnterMapScreen() { DeferStateTransition(kSMT_MapScreen); } diff --git a/include/MetroidPrime/Enemies/CAi.hpp b/include/MetroidPrime/Enemies/CAi.hpp index 5d1d961c..044df876 100644 --- a/include/MetroidPrime/Enemies/CAi.hpp +++ b/include/MetroidPrime/Enemies/CAi.hpp @@ -6,12 +6,7 @@ #include "MetroidPrime/CPhysicsActor.hpp" #include "MetroidPrime/Enemies/CAiFuncMap.hpp" #include "MetroidPrime/Enemies/CKnockBackController.hpp" - -enum EListenNoiseType { - kLNT_PlayerFire, - kLNT_BombExplode, - kLNT_ProjectileExplode, -}; +#include "MetroidPrime/Enemies/EListenNoiseType.hpp" class CTeamAiRole; class CAiFuncMap; diff --git a/include/MetroidPrime/Enemies/EListenNoiseType.hpp b/include/MetroidPrime/Enemies/EListenNoiseType.hpp new file mode 100644 index 00000000..48ae27dc --- /dev/null +++ b/include/MetroidPrime/Enemies/EListenNoiseType.hpp @@ -0,0 +1,10 @@ +#ifndef _ELISTENNOISETYPE +#define _ELISTENNOISETYPE + +enum EListenNoiseType { + kLNT_PlayerFire, + kLNT_BombExplode, + kLNT_ProjectileExplode, +}; + +#endif // _ELISTENNOISETYPE diff --git a/include/MetroidPrime/Player/CPlayer.hpp b/include/MetroidPrime/Player/CPlayer.hpp index 9d0f1b8f..b8a26504 100644 --- a/include/MetroidPrime/Player/CPlayer.hpp +++ b/include/MetroidPrime/Player/CPlayer.hpp @@ -195,6 +195,8 @@ public: void AddOrbitDisableSource(CStateManager& mgr, TUniqueId addId); void RemoveOrbitDisableSource(TUniqueId uid); + void ApplySubmergedPitchBend(CSfxHandle& sfx); + CPlayerGun* PlayerGun() { return x490_gun.get(); } const CPlayerGun* GetPlayerGun() const { return x490_gun.get(); } diff --git a/include/MetroidPrime/Player/CPlayerState.hpp b/include/MetroidPrime/Player/CPlayerState.hpp index d24e05ae..9e503b63 100644 --- a/include/MetroidPrime/Player/CPlayerState.hpp +++ b/include/MetroidPrime/Player/CPlayerState.hpp @@ -123,6 +123,7 @@ public: void UpdateVisorTransition(float dt); void StartTransitionToVisor(EPlayerVisor visor); void ResetVisor(); + bool IsPlayerAlive() const { return x0_24_alive; } bool ItemEnabled(EItemType type) const; void DisableItem(EItemType type); diff --git a/include/MetroidPrime/Weapons/CPowerBomb.hpp b/include/MetroidPrime/Weapons/CPowerBomb.hpp index c36732d6..bbe05394 100644 --- a/include/MetroidPrime/Weapons/CPowerBomb.hpp +++ b/include/MetroidPrime/Weapons/CPowerBomb.hpp @@ -5,9 +5,28 @@ #include "MetroidPrime/Weapons/CWeapon.hpp" +class CGenDescription; class CElementGen; class CPowerBomb : public CWeapon { +public: + CPowerBomb(TToken< CGenDescription > particle, TUniqueId uid, TAreaId aid, + TUniqueId playerId, const CTransform4f& xf, const CDamageInfo& dInfo); + ~CPowerBomb(); + + void Accept(IVisitor& visitor) override; + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; + void Think(float, CStateManager&) override; + void AddToRenderer(const CFrustumPlanes&, const CStateManager&) const override; + void Render(const CStateManager&) const override; + rstl::optional_object GetTouchBounds() const override; + void Touch(CActor&, CStateManager&) override; + + float GetCurTime() const { return x15c_curTime; } + void ApplyDynamicDamage(const CVector3f&, CStateManager&); + +private: + static CColor kFadeColor; bool x158_24_canStartFilter : 1; bool x158_25_filterEnabled : 1; float x15c_curTime; @@ -15,9 +34,6 @@ class CPowerBomb : public CWeapon { float x164_radiusIncrement; rstl::single_ptr< CElementGen > x168_particle; float x16c_radius; - -public: - float GetCurTime() const { return x15c_curTime; } }; #endif // _CPOWERBOMB diff --git a/include/MetroidPrime/Weapons/CWeapon.hpp b/include/MetroidPrime/Weapons/CWeapon.hpp index b7eaf92a..01341ec1 100644 --- a/include/MetroidPrime/Weapons/CWeapon.hpp +++ b/include/MetroidPrime/Weapons/CWeapon.hpp @@ -10,7 +10,7 @@ class CWeapon : public CActor { public: CWeapon(TUniqueId uid, TAreaId areaId, bool active, TUniqueId owner, EWeaponType type, - const rstl::string& name, CTransform4f& xf, const CMaterialFilter& filter, + const rstl::string& name, const CTransform4f& xf, const CMaterialFilter& filter, const CMaterialList& mList, const CDamageInfo& dInfo, EProjectileAttrib attribs, const CModelData& mData); @@ -29,8 +29,10 @@ public: EProjectileAttrib GetAttribField() const { return xe8_projectileAttribs; } TUniqueId GetOwnerId() const { return xec_ownerId; } + EWeaponType GetWeaponType() const { return xf0_weaponType; } + CDamageInfo& OrigDamageInfo() { return x110_origDamageInfo; } -private: +protected: EProjectileAttrib xe8_projectileAttribs; TUniqueId xec_ownerId; EWeaponType xf0_weaponType; diff --git a/src/MetroidPrime/Weapons/CPowerBomb.cpp b/src/MetroidPrime/Weapons/CPowerBomb.cpp new file mode 100644 index 00000000..e4f91bd8 --- /dev/null +++ b/src/MetroidPrime/Weapons/CPowerBomb.cpp @@ -0,0 +1,123 @@ +#include "MetroidPrime/Weapons/CPowerBomb.hpp" + +#include "MetroidPrime/CStateManager.hpp" +#include "MetroidPrime/Cameras/CCameraFilterPass.hpp" +#include "MetroidPrime/Player/CPlayer.hpp" +#include "MetroidPrime/Player/CPlayerState.hpp" +#include "MetroidPrime/SFX/Weapons.h" + +#include "Kyoto/Audio/CSfxManager.hpp" +#include "Kyoto/Particles/CElementGen.hpp" +#include "MetaRender/CCubeRenderer.hpp" + +CColor CPowerBomb::kFadeColor(0xffffff7f); + +CPowerBomb::CPowerBomb(TToken< CGenDescription > particle, TUniqueId uid, TAreaId aid, + TUniqueId playerId, const CTransform4f& xf, const CDamageInfo& dInfo) +: CWeapon(uid, aid, true, playerId, kWT_PowerBomb, rstl::string_l("PowerBomb"), xf, + CMaterialFilter::MakeIncludeExclude(CMaterialList(kMT_Solid, kMT_Immovable, kMT_Trigger), + CMaterialList(kMT_Projectile, kMT_PowerBomb)), + CMaterialList(kMT_Projectile, kMT_PowerBomb), dInfo, kPA_PowerBombs, + CModelData::CModelDataNull()) + +, x158_24_canStartFilter(true) +, x158_25_filterEnabled(false) +, x15c_curTime(0.f) +, x160_curRadius(0.f) +, x164_radiusIncrement(dInfo.GetRadius() / 2.5f) +, x168_particle(new CElementGen(particle)) +, x16c_radius(dInfo.GetRadius()) { + x168_particle->SetGlobalTranslation(xf.GetTranslation()); +} + +CPowerBomb::~CPowerBomb() {} + +void CPowerBomb::ApplyDynamicDamage(const CVector3f& pos, CStateManager& mgr) { + mgr.ApplyDamageToWorld(GetOwnerId(), *this, pos, x12c_curDamageInfo, CMaterialFilter(xf8_filter)); +} + +void CPowerBomb::Touch(CActor&, CStateManager&) { + if (x158_24_canStartFilter) { + return; + } +} + +rstl::optional_object< CAABox > CPowerBomb::GetTouchBounds() const { + return rstl::optional_object_null(); +} + +void CPowerBomb::AddToRenderer(const CFrustumPlanes&, const CStateManager&) const { + gpRender->AddParticleGen(*x168_particle); +} + +void CPowerBomb::Render(const CStateManager&) const {} + +void CPowerBomb::Think(float dt, CStateManager& mgr) { + CWeapon::Think(dt, mgr); + + if (x158_24_canStartFilter) { + if (x15c_curTime > 1.f && x158_25_filterEnabled != true) { + mgr.CameraFilterPass(CStateManager::kCFS_Six) + .SetFilter(CCameraFilterPass::kFT_Add, CCameraFilterPass::kFS_Fullscreen, 1.5f, + kFadeColor, kInvalidAssetId); + x158_25_filterEnabled = true; + } + + if (x15c_curTime > 2.5f) + x158_24_canStartFilter = false; + } else { + if (x15c_curTime > 3.75f && x158_25_filterEnabled) { + mgr.CameraFilterPass(CStateManager::kCFS_Six).DisableFilter(.5f); + x158_25_filterEnabled = false; + } + + if (x15c_curTime > 7.f) { + if (x168_particle->IsSystemDeletable()) + mgr.FreeScriptObject(GetUniqueId()); + } + + if (x15c_curTime > 30.f) { + mgr.FreeScriptObject(GetUniqueId()); + return; + } + } + + if (x15c_curTime > 1.f && x15c_curTime < 4.f) { + x110_origDamageInfo.SetRadius(x160_curRadius); + ApplyDynamicDamage(GetTranslation(), mgr); + x160_curRadius += x164_radiusIncrement * dt; + } + + x168_particle->Update(dt); + x15c_curTime += dt; +} + +void CPowerBomb::Accept(IVisitor& visitor) { visitor.Visit(*this); } + +void CPowerBomb::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { + switch (msg) { + case kSM_Registered: + mgr.AddWeaponId(GetOwnerId(), GetWeaponType()); + OrigDamageInfo().SetRadius(0.f); + + if (mgr.GetPlayerState()->IsPlayerAlive()) { + CSfxManager::AddEmitter(SFXsfx0710, GetTranslation(), CVector3f::Zero(), true, false); + mgr.InformListeners(GetTranslation(), kLNT_BombExplode); + } else { + CSfxHandle handle = CSfxManager::SfxStart(SFXsfx073F, 0x7f, 0x40, false); + mgr.Player()->ApplySubmergedPitchBend(handle); + } + break; + + case kSM_Deleted: + if (x15c_curTime <= 7.0f) { + mgr.CameraFilterPass(CStateManager::kCFS_Six).DisableFilter(0.f); + } + mgr.RemoveWeaponId(GetOwnerId(), GetWeaponType()); + break; + + default: + break; + } + CActor::AcceptScriptMsg(msg, uid, mgr); +} diff --git a/src/MetroidPrime/Weapons/CWeapon.cpp b/src/MetroidPrime/Weapons/CWeapon.cpp index 6aa96f3f..0c81cb98 100644 --- a/src/MetroidPrime/Weapons/CWeapon.cpp +++ b/src/MetroidPrime/Weapons/CWeapon.cpp @@ -8,7 +8,7 @@ #include CWeapon::CWeapon(TUniqueId uid, TAreaId areaId, bool active, TUniqueId owner, EWeaponType type, - const rstl::string& name, CTransform4f& xf, const CMaterialFilter& filter, + const rstl::string& name, const 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,