mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
GetBattlerHoldEffect usage optimizations (#3330)
* GetBattlerHoldEffect optimizations * Type fix
This commit is contained in:
parent
8bf8c9e7a7
commit
f564d4492b
@ -11431,8 +11431,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
{
|
||||
bool32 certain = FALSE;
|
||||
bool32 notProtectAffected = FALSE;
|
||||
u32 index, battler;
|
||||
u16 battlerAbility;
|
||||
u32 index, battler, battlerAbility, battlerHoldEffect;
|
||||
bool32 affectsUser = (flags & MOVE_EFFECT_AFFECTS_USER);
|
||||
bool32 mirrorArmored = (flags & STAT_CHANGE_MIRROR_ARMOR);
|
||||
|
||||
@ -11442,6 +11441,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
battler = gBattlerTarget;
|
||||
|
||||
battlerAbility = GetBattlerAbility(battler);
|
||||
battlerHoldEffect = GetBattlerHoldEffect(battler, TRUE);
|
||||
|
||||
gSpecialStatuses[battler].changedStatsBattlerId = gBattlerAttacker;
|
||||
|
||||
@ -11500,13 +11500,13 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
gBattlescriptCurrInstr = BattleScript_ButItFailed;
|
||||
return STAT_CHANGE_DIDNT_WORK;
|
||||
}
|
||||
else if ((GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_CLEAR_AMULET
|
||||
else if ((battlerHoldEffect == HOLD_EFFECT_CLEAR_AMULET
|
||||
|| battlerAbility == ABILITY_CLEAR_BODY
|
||||
|| battlerAbility == ABILITY_FULL_METAL_BODY
|
||||
|| battlerAbility == ABILITY_WHITE_SMOKE)
|
||||
&& (!affectsUser || mirrorArmored) && !certain && gCurrentMove != MOVE_CURSE)
|
||||
{
|
||||
if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_CLEAR_AMULET)
|
||||
if (battlerHoldEffect == HOLD_EFFECT_CLEAR_AMULET)
|
||||
{
|
||||
RecordItemEffectBattle(battler, HOLD_EFFECT_CLEAR_AMULET);
|
||||
}
|
||||
@ -11521,7 +11521,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
{
|
||||
BattleScriptPush(BS_ptr);
|
||||
gBattleScripting.battler = battler;
|
||||
if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_CLEAR_AMULET)
|
||||
if (battlerHoldEffect == HOLD_EFFECT_CLEAR_AMULET)
|
||||
{
|
||||
gBattlescriptCurrInstr = BattleScript_ItemNoStatLoss;
|
||||
}
|
||||
@ -11591,7 +11591,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
|
||||
RecordAbilityBattle(battler, ABILITY_SHIELD_DUST);
|
||||
return STAT_CHANGE_DIDNT_WORK;
|
||||
}
|
||||
else if (flags == 0 && GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_COVERT_CLOAK)
|
||||
else if (flags == 0 && battlerHoldEffect == HOLD_EFFECT_COVERT_CLOAK)
|
||||
{
|
||||
RecordItemEffectBattle(battler, HOLD_EFFECT_COVERT_CLOAK);
|
||||
return STAT_CHANGE_DIDNT_WORK;
|
||||
|
@ -8288,7 +8288,9 @@ bool32 IsBattlerProtected(u8 battler, u16 move)
|
||||
// Only called directly when calculating damage type effectiveness
|
||||
static bool32 IsBattlerGrounded2(u8 battler, bool32 considerInverse)
|
||||
{
|
||||
if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_IRON_BALL)
|
||||
u32 holdEffect = GetBattlerHoldEffect(battler, TRUE);
|
||||
|
||||
if (holdEffect == HOLD_EFFECT_IRON_BALL)
|
||||
return TRUE;
|
||||
if (gFieldStatuses & STATUS_FIELD_GRAVITY)
|
||||
return TRUE;
|
||||
@ -8302,7 +8304,7 @@ static bool32 IsBattlerGrounded2(u8 battler, bool32 considerInverse)
|
||||
return FALSE;
|
||||
if (gStatuses3[battler] & STATUS3_MAGNET_RISE)
|
||||
return FALSE;
|
||||
if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_AIR_BALLOON)
|
||||
if (holdEffect == HOLD_EFFECT_AIR_BALLOON)
|
||||
return FALSE;
|
||||
if (GetBattlerAbility(battler) == ABILITY_LEVITATE)
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user