Skip to content

Commit

Permalink
Remove EWRAM gHpDealt (not needed anymore) (#5925)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexOn1ine authored Jan 2, 2025
1 parent 94fba81 commit ec1876b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,6 @@ extern u8 gChosenMovePos;
extern u16 gCurrentMove;
extern u16 gChosenMove;
extern u16 gCalledMove;
extern s32 gHpDealt;
extern s32 gBideDmg[MAX_BATTLERS_COUNT];
extern u16 gLastUsedItem;
extern u16 gLastUsedAbility;
Expand Down
3 changes: 1 addition & 2 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ EWRAM_DATA u8 gChosenMovePos = 0;
EWRAM_DATA u16 gCurrentMove = 0;
EWRAM_DATA u16 gChosenMove = 0;
EWRAM_DATA u16 gCalledMove = 0;
EWRAM_DATA s32 gHpDealt = 0;
EWRAM_DATA s32 gBideDmg[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u16 gLastUsedItem = 0;
EWRAM_DATA u16 gLastUsedAbility = 0;
Expand Down Expand Up @@ -3384,7 +3383,7 @@ const u8* FaintClearSetData(u32 battler)
gBattleStruct->lastTakenMoveFrom[battler][1] = 0;
gBattleStruct->lastTakenMoveFrom[battler][2] = 0;
gBattleStruct->lastTakenMoveFrom[battler][3] = 0;

if (gBattleStruct->pursuitTarget & (1u << battler))
{
gBattleStruct->pursuitTarget = 0;
Expand Down
20 changes: 9 additions & 11 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -2583,13 +2583,12 @@ static void Cmd_datahpupdate(void)
if (gSpecialStatuses[battler].shellBellDmg == 0)
gSpecialStatuses[battler].shellBellDmg = gBattleStruct->moveDamage[battler];
gDisableStructs[battler].substituteHP -= gBattleStruct->moveDamage[battler];
gHpDealt = gBattleStruct->moveDamage[battler];
}
else
{
if (gSpecialStatuses[battler].shellBellDmg == 0)
gSpecialStatuses[battler].shellBellDmg = gDisableStructs[battler].substituteHP;
gHpDealt = gDisableStructs[battler].substituteHP;
gBattleStruct->moveDamage[battler] = gDisableStructs[battler].substituteHP;
gDisableStructs[battler].substituteHP = 0;
}
// check substitute fading
Expand Down Expand Up @@ -2647,17 +2646,16 @@ static void Cmd_datahpupdate(void)
if (gBattleMons[battler].hp > gBattleStruct->moveDamage[battler])
{
gBattleMons[battler].hp -= gBattleStruct->moveDamage[battler];
gHpDealt = gBattleStruct->moveDamage[battler];
}
else
{
gHpDealt = gBattleMons[battler].hp;
gBattleStruct->moveDamage[battler] = gBattleMons[battler].hp;
gBattleMons[battler].hp = 0;
}

// Record damage for Shell Bell
if (gSpecialStatuses[battler].shellBellDmg == 0 && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE))
gSpecialStatuses[battler].shellBellDmg = gHpDealt;
gSpecialStatuses[battler].shellBellDmg = gBattleStruct->moveDamage[battler];

u32 effect = GetMoveEffect(gCurrentMove);

Expand All @@ -2666,8 +2664,8 @@ static void Cmd_datahpupdate(void)
// to help determine if a fire move should defrost the target.
if (IsBattleMovePhysical(gCurrentMove) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE) && effect != EFFECT_PAIN_SPLIT)
{
gProtectStructs[battler].physicalDmg = gHpDealt;
gSpecialStatuses[battler].physicalDmg = gHpDealt;
gProtectStructs[battler].physicalDmg = gBattleStruct->moveDamage[battler];
gSpecialStatuses[battler].physicalDmg = gBattleStruct->moveDamage[battler];
if (cmd->battler == BS_TARGET)
{
gProtectStructs[battler].physicalBattlerId = gBattlerAttacker;
Expand All @@ -2682,8 +2680,8 @@ static void Cmd_datahpupdate(void)
else if (!IsBattleMovePhysical(gCurrentMove) && !(gHitMarker & HITMARKER_PASSIVE_DAMAGE) && effect != EFFECT_PAIN_SPLIT)
{
// Record special damage/attacker for Mirror Coat
gProtectStructs[battler].specialDmg = gHpDealt;
gSpecialStatuses[battler].specialDmg = gHpDealt;
gProtectStructs[battler].specialDmg = gBattleStruct->moveDamage[battler];
gSpecialStatuses[battler].specialDmg = gBattleStruct->moveDamage[battler];
if (cmd->battler == BS_TARGET)
{
gProtectStructs[battler].specialBattlerId = gBattlerAttacker;
Expand Down Expand Up @@ -5951,7 +5949,7 @@ static void Cmd_moveend(void)
switch (gBattleScripting.moveendState)
{
case MOVEEND_SUM_DAMAGE: // Sum and store damage dealt for multi strike recoil
gBattleScripting.savedDmg += gHpDealt;
gBattleScripting.savedDmg += gBattleStruct->moveDamage[gBattlerTarget];
gBattleScripting.moveendState++;
break;
case MOVEEND_PROTECT_LIKE_EFFECT:
Expand Down Expand Up @@ -11944,7 +11942,7 @@ static void Cmd_setdrainedhp(void)
{
CMD_ARGS();

gBattleStruct->moveDamage[gBattlerAttacker] = (gHpDealt * GetMoveAbsorbPercentage(gCurrentMove) / 100);
gBattleStruct->moveDamage[gBattlerAttacker] = (gBattleStruct->moveDamage[gBattlerTarget] * GetMoveAbsorbPercentage(gCurrentMove) / 100);

if (gBattleStruct->moveDamage[gBattlerAttacker] == 0)
gBattleStruct->moveDamage[gBattlerAttacker] = 1;
Expand Down

0 comments on commit ec1876b

Please sign in to comment.