Minor renaming for CStateManager::ApplyLocalDamage

This commit is contained in:
Henrique Gemignani Passos Lima
2026-07-04 13:30:02 +03:00
parent 7c58bd096f
commit 67858cc318
7 changed files with 146 additions and 28 deletions
+6 -6
View File
@@ -313,7 +313,7 @@ fn_8000BE98__7CPlayerCFv = .text:0x8000BE98; // type:function size:0x84
fn_8000BF1C = .text:0x8000BF1C; // type:function size:0x58 align:4
fn_8000BF74 = .text:0x8000BF74; // type:function size:0x8
fn_8000BF7C = .text:0x8000BF7C; // type:function size:0x18
fn_8000BF94 = .text:0x8000BF94; // type:function size:0x18
GetTweakPlayer__7CPlayerCFv = .text:0x8000BF94; // type:function size:0x18
fn_8000BFAC = .text:0x8000BFAC; // type:function size:0x178 align:4
fn_8000C124 = .text:0x8000C124; // type:function size:0x500 align:4
fn_8000C624 = .text:0x8000C624; // type:function size:0x870
@@ -1156,7 +1156,7 @@ fn_8003D408 = .text:0x8003D408; // type:function size:0x74
fn_8003D47C = .text:0x8003D47C; // type:function size:0x210
fn_8003D68C = .text:0x8003D68C; // type:function size:0x130
fn_8003D7BC = .text:0x8003D7BC; // type:function size:0x7C
fn_8003D838 = .text:0x8003D838; // type:function size:0x550
ApplyLocalDamage__13CStateManagerFRC9CVector3fRC9CVector3fR6CActorfRC9TUniqueIdRC9TUniqueIdRC11CDamageInfoi = .text:0x8003D838; // type:function size:0x550
fn_8003DD88 = .text:0x8003DD88; // type:function size:0x198
fn_8003DF20 = .text:0x8003DF20; // type:function size:0x234
fn_8003E154 = .text:0x8003E154; // type:function size:0x108
@@ -5338,7 +5338,7 @@ fn_801423A8 = .text:0x801423A8; // type:function size:0xBC
GetGameMode__10CGameStateFv = .text:0x80142464; // type:function size:0x8 scope:global
fn_8014246C = .text:0x8014246C; // type:function size:0x8
fn_80142474 = .text:0x80142474; // type:function size:0x24 align:4
fn_80142498 = .text:0x80142498; // type:function size:0x24
GetHardModeDamageMultiplier__10CGameStateCFv = .text:0x80142498; // type:function size:0x24
SetIsDarkWorld__10CGameStateFb = .text:0x801424BC; // type:function size:0x10 scope:global align:4
fn_801424CC = .text:0x801424CC; // type:function size:0x10 align:4
fn_801424DC = .text:0x801424DC; // type:function size:0x10
@@ -9333,9 +9333,9 @@ fn_80217B30 = .text:0x80217B30; // type:function size:0x80
fn_80217BB0 = .text:0x80217BB0; // type:function size:0x80
fn_80217C30 = .text:0x80217C30; // type:function size:0x80 align:4
fn_80217CB0 = .text:0x80217CB0; // type:function size:0x80
fn_80217D30 = .text:0x80217D30; // type:function size:0xC
fn_80217D3C = .text:0x80217D3C; // type:function size:0xC
fn_80217D48 = .text:0x80217D48; // type:function size:0xC
GetLightSuitDamageReduction__12CTweakPlayerFv = .text:0x80217D30; // type:function size:0xC
GetDarkSuitDamageReduction__12CTweakPlayerFv = .text:0x80217D3C; // type:function size:0xC
GetVariaSuitDamageReduction__12CTweakPlayerFv = .text:0x80217D48; // type:function size:0xC
fn_80217D54 = .text:0x80217D54; // type:function size:0xC
fn_80217D60 = .text:0x80217D60; // type:function size:0xC
fn_80217D6C = .text:0x80217D6C; // type:function size:0xC align:4
+4
View File
@@ -39,6 +39,7 @@ class CStateManagerContainer;
class CSortedListManager;
class CWeaponMgr;
class CFluidPlaneManager;
class CDamageInfo;
class CAABox;
struct MapWorldInfoAreas {};
@@ -120,6 +121,9 @@ public:
void UpdateActorInSortedLists(CActor*);
bool ApplyLocalDamage(const CVector3f& pos, const CVector3f& dir, CActor& damagee, float damage, const TUniqueId& uid1, const TUniqueId& uid2, const CDamageInfo& info, int);
void fn_8003dd88(CActor&, TUniqueId, const CDamageInfo& info, bool, int);
void fn_8003BF84(CEntity*);
void fn_800412EC(TUniqueId);
bool fn_80036F10() const; // Maybe_CheckIsMultiplayer
@@ -27,6 +27,8 @@ public:
u32 GetCardSerialA() const { return cardSerialA; }
u32 GetCardSerialB() const { return cardSerialB; }
float GetHardModeDamageMultiplier() const;
bool GetHardModeEnabled() const;
private:
char pad1[0x80];
+9 -1
View File
@@ -13,6 +13,7 @@ class CMorphBall;
class CPlayerState;
class CCameraManager;
class CPlayerGun;
class CTweakPlayer;
namespace NPlayer {
enum EPlayerMovementState {
@@ -112,8 +113,13 @@ public:
EPlayerMorphBallState GetMorphballTransitionState() const { return m_morphBallState; }
EPlayerMorphBallState GetSpawnedMorphballState() const { return m_spawnedMorphBallState; }
int Get_x12f8() const { return x12f8_unk; }
float fn_8000BE98() const;
void fn_80019E40(CStateManager&, int);
void fn_8000d3ac(const CVector3f&, CStateManager&);
bool fn_8000d40c(const CVector3f&, CStateManager&);
CTweakPlayer* GetTweakPlayer() const;
void Teleport(const CTransform4f& xf, CStateManager& mgr, bool resetBallCam);
void SetSpawnedMorphBallState(EPlayerMorphBallState state, CStateManager& mgr);
@@ -238,7 +244,9 @@ private:
CVector3f m_lookDir; // 0xfd0
char m_pad_3[0x198]; // 0xFDC
CMorphBall* m_morphBall; // 0x1174
char m_pad_4[0x19C]; // 0x1178
char m_pad_4[0x180]; // 0x1178
int x12f8_unk; // 0x12f8
char m_pad_5[0x18]; // 0x12fc
CPlayerState* m_playerState; // 0x1314
CCameraManager* m_cameraManager; // 0x1318
};
@@ -5,6 +5,9 @@ class CTweakPlayer {
public:
float GetLeftAnalogMax();
float GetRightAnalogMax();
float GetVariaSuitDamageReduction();
float GetDarkSuitDamageReduction();
float GetLightSuitDamageReduction();
};
extern CTweakPlayer* gpTweakPlayerA;
+17 -21
View File
@@ -6,21 +6,27 @@
enum EWeaponType {
kWT_None = -1,
kWT_Power = 0,
kWT_Ice = 1,
kWT_Wave = 2,
kWT_Plasma = 3,
kWT_Dark = 1,
kWT_Light = 2,
kWT_Annihilator = 3,
kWT_Bomb = 4,
kWT_PowerBomb = 5,
kWT_Missile = 6,
kWT_BoostBall = 7,
kWT_Phazon = 8,
kWT_AI = 9,
kWT_PoisonWater = 10,
kWT_Lava = 11,
kWT_Heat = 12,
kWT_Unused1 = 13,
kWT_OrangePhazon = 14,
kWT_Max = 15
kWT_CannonBall = 8,
kWT_ScrewAttack = 9,
kWT_Phazon = 10,
kWT_AI = 11,
kWT_PoisonWater1 = 12,
kWT_PoisonWater2 = 13,
kWT_Lava = 14,
kWT_Heat = 15,
kWT_Unused1 = 16,
kWT_AreaDark = 17,
kWT_AreaLight = 18,
kWT_UnknownSource = 19,
kWT_SafeZone = 20,
kWT_Max = 21
};
class CWeaponMode {
@@ -44,16 +50,6 @@ public:
bool IsCharged() const { return x4_24_charged; }
bool IsComboed() const { return x4_25_comboed; }
bool IsInstantKill() const { return x4_26_instantKill; }
static CWeaponMode Invalid() { return CWeaponMode(kWT_None); }
static CWeaponMode Phazon() { return CWeaponMode(kWT_Phazon); }
static CWeaponMode Plasma() { return CWeaponMode(kWT_Plasma); }
static CWeaponMode Wave() { return CWeaponMode(kWT_Wave); }
static CWeaponMode BoostBall() { return CWeaponMode(kWT_BoostBall); }
static CWeaponMode Ice() { return CWeaponMode(kWT_Ice); }
static CWeaponMode Power() { return CWeaponMode(kWT_Power); }
static CWeaponMode Bomb() { return CWeaponMode(kWT_Bomb); }
static CWeaponMode PowerBomb() { return CWeaponMode(kWT_PowerBomb); }
};
#endif // _WEAPONTYPES
+105
View File
@@ -1,11 +1,18 @@
#include "MetroidPrime/CStateManager.hpp"
#include "MetroidPrime/CActor.hpp"
#include "MetroidPrime/CEntity.hpp"
#include "MetroidPrime/Player/CPlayer.hpp"
#include "MetroidPrime/Player/CPlayerState.hpp"
#include "MetroidPrime/CHealthInfo.hpp"
#include "MetroidPrime/CCameraManager.hpp"
#include "MetroidPrime/CSaveGameScreen.hpp"
#include "MetroidPrime/CWorld.hpp"
#include "MetroidPrime/Player/CGameMode.hpp"
#include "MetroidPrime/Player/CGameState.hpp"
#include "MetroidPrime/TCastTo.hpp"
#include "MetroidPrime/CDamageInfo.hpp"
#include "MetroidPrime/Tweaks/CTweakPlayer.hpp"
#include "Kyoto/Basics/RAssertDolphin.hpp"
@@ -62,6 +69,104 @@ void CStateManager::SetIsDarkWorld(bool b) {
gpGameState->SetIsDarkWorld(m_isDarkWorld);
}
bool CStateManager::ApplyLocalDamage(const CVector3f& pos, const CVector3f& dir, CActor& damagee, float damage, const TUniqueId& uid1, const TUniqueId& uid2, const CDamageInfo& damageInfo, int unkParam) {
CHealthInfo* healthInfo = damagee.HealthInfo(*this);
if (!healthInfo || damage < 0.0f) {
return false;
}
float hp = healthInfo->GetHP();
if (hp <= 0.0f) {
fn_8003dd88(damagee, uid1, damageInfo, false, unkParam);
return true;
}
CPlayer* player = TCastToPtr< CPlayer* >(damagee);
if (player && player->Get_x12f8() != 0) {
if (player->Get_x12f8() != 3) {
return false;
}
player->fn_8000d3ac(pos, *this);
if (!player->fn_8000d40c(dir, *this)) {
return false;
}
}
TUniqueId playerId = player ? player->GetUniqueId() : kInvalidUniqueId;
if (player) {
int playerIndex = MaskUIdNumPlayers(playerId);
CPlayerState& playerState = *PlayerState(playerIndex);
if (GetCameraManager(playerIndex)->IsInCinematicCamera()) {
return false;
}
if (gpGameState->GetHardModeEnabled()) {
switch ((EWeaponType) damageInfo.GetWeaponMode1()) {
case kWT_Power:
case kWT_Dark:
case kWT_Light:
case kWT_Annihilator:
case kWT_Bomb:
case kWT_PowerBomb:
case kWT_Missile:
case kWT_BoostBall:
case kWT_CannonBall:
case kWT_ScrewAttack:
case kWT_AI:
case kWT_PoisonWater1:
case kWT_PoisonWater2:
case kWT_Lava:
case kWT_Heat:
case kWT_Unused1:
case kWT_AreaDark:
damage *= gpGameState->GetHardModeDamageMultiplier();
break;
}
}
float damageReduction = 0.0f;
if (playerState.HasPowerUp(CPlayerState::kIT_VariaSuit)) {
damageReduction = player->GetTweakPlayer()->GetVariaSuitDamageReduction();
}
if (playerState.HasPowerUp(CPlayerState::kIT_DarkSuit)) {
float reduction = player->GetTweakPlayer()->GetDarkSuitDamageReduction();
if (reduction > damageReduction) {
damageReduction = reduction;
}
}
if (playerState.HasPowerUp(CPlayerState::kIT_LightSuit)) {
float reduction = player->GetTweakPlayer()->GetLightSuitDamageReduction();
if (reduction > damageReduction) {
damageReduction = reduction;
}
}
if (playerState.GetItemAmount(CPlayerState::kIT_AbsorbAttack, true) != 0) {
float reduction = 1.5f;
if (reduction > damageReduction) {
damageReduction = reduction;
}
}
if (playerState.GetItemAmount(CPlayerState::kIT_LightShield, true) != 0) {
// TODO: flag
float reduction = 0.75f;
if (reduction > damageReduction) {
damageReduction = reduction;
}
}
if (playerState.GetItemAmount(CPlayerState::kIT_DarkShield, true) != 0) {
// TODO: flag
float reduction = 0.75f;
if (reduction > damageReduction) {
damageReduction = reduction;
}
}
hp = playerState.CalculateHealth();
damage = -(damageReduction * damage - damage);
}
}
void CStateManager::fn_8003BF84(CEntity* ent) {
// Clear Graveyard?
if (m_graveyard.empty()) {