Fix messing with move result flags when not needed

This commit is contained in:
DizzyEggg 2019-04-02 00:14:01 +02:00
parent 743a42fec2
commit d39b5f6d26
5 changed files with 11 additions and 10 deletions

View file

@ -81,7 +81,7 @@ bool32 IsBattlerGrounded(u8 battlerId);
bool32 IsBattlerAlive(u8 battlerId);
u8 GetBattleMonMoveSlot(struct BattlePokemon *battleMon, u16 move);
u32 GetBattlerWeight(u8 battlerId);
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor);
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor, bool32 updateFlags);
u16 CalcTypeEffectivenessMultiplier(u16 move, u8 moveType, u8 battlerAtk, u8 battlerDef, bool32 recordAbilities);
u16 CalcPartyMonTypeEffectivenessMultiplier(u16 move, u16 speciesDef, u8 abilityDef);
u16 GetTypeModifier(u8 atkType, u8 defType);

View file

@ -794,7 +794,7 @@ s32 AI_CalcDamage(u16 move, u8 battlerAtk, u8 battlerDef)
gBattleStruct->dynamicMoveType = 0;
SetTypeBeforeUsingMove(move, battlerAtk);
GET_MOVE_TYPE(move, moveType);
dmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, AI_GetIfCrit(move, battlerAtk, battlerDef), FALSE);
dmg = CalculateMoveDamage(move, battlerAtk, battlerDef, moveType, 0, AI_GetIfCrit(move, battlerAtk, battlerDef), FALSE, FALSE);
RestoreBattlerData(battlerAtk);
RestoreBattlerData(battlerDef);

View file

@ -1412,7 +1412,7 @@ static void atk05_damagecalc(void)
u8 moveType;
GET_MOVE_TYPE(gCurrentMove, moveType);
gBattleMoveDamage = CalculateMoveDamage(gCurrentMove, gBattlerAttacker, gBattlerTarget, moveType, 0, gIsCriticalHit, TRUE);
gBattleMoveDamage = CalculateMoveDamage(gCurrentMove, gBattlerAttacker, gBattlerTarget, moveType, 0, gIsCriticalHit, TRUE, TRUE);
gBattlescriptCurrInstr++;
}
@ -4449,7 +4449,7 @@ static void atk49_moveend(void)
gHitMarker |= HITMARKER_NO_ATTACKSTRING;
}
if (battlerId < gBattlersCount && gBattleMons[battlerId].hp != 0)
if (IsBattlerAlive(battlerId))
{
gBattlerTarget = battlerId;
gBattleScripting.atk49_state = 0;

View file

@ -1429,7 +1429,7 @@ static void TrySetBattleSeminarShow(void)
powerOverride = 0;
if (ShouldCalculateDamage(gCurrentMove, &dmgByMove[i], &powerOverride))
{
gBattleMoveDamage = CalculateMoveDamage(gCurrentMove, gBattlerAttacker, gBattlerTarget, gBattleMoves[gCurrentMove].type, powerOverride, FALSE, FALSE);
gBattleMoveDamage = CalculateMoveDamage(gCurrentMove, gBattlerAttacker, gBattlerTarget, gBattleMoves[gCurrentMove].type, powerOverride, FALSE, FALSE, FALSE);
dmgByMove[i] = gBattleMoveDamage;
if (dmgByMove[i] == 0 && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
dmgByMove[i] = 1;

View file

@ -2212,7 +2212,7 @@ u8 AtkCanceller_UnableToUseMove(void)
{
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
gBattlerTarget = gBattlerAttacker;
gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE);
gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE, TRUE);
gProtectStructs[gBattlerAttacker].confusionSelfDmg = 1;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
}
@ -4536,7 +4536,7 @@ u8 IsMonDisobedient(void)
calc -= obedienceLevel;
if (calc < obedienceLevel)
{
gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE);
gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE, TRUE);
gBattlerTarget = gBattlerAttacker;
gBattlescriptCurrInstr = BattleScript_IgnoresAndHitsItself;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -5569,12 +5569,12 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move
return dmg;
}
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor)
s32 CalculateMoveDamage(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType, s32 fixedBasePower, bool32 isCrit, bool32 randomFactor, bool32 updateFlags)
{
s32 dmg;
u16 finalModifier, typeEffectivenessModifier;
typeEffectivenessModifier = CalcTypeEffectivenessMultiplier(move, moveType, battlerAtk, battlerDef, randomFactor);
typeEffectivenessModifier = CalcTypeEffectivenessMultiplier(move, moveType, battlerAtk, battlerDef, updateFlags);
// Don't calculate damage if the move has no effect on target.
if (typeEffectivenessModifier == UQ_4_12(0))
@ -5698,7 +5698,8 @@ u16 CalcTypeEffectivenessMultiplier(u16 move, u8 moveType, u8 battlerAtk, u8 bat
modifier = CalcTypeEffectivenessMultiplierInternal(move, gBattleMoves[move].argument, battlerAtk, battlerDef, recordAbilities, modifier);
}
UpdateMoveResultFlags(modifier);
if (recordAbilities)
UpdateMoveResultFlags(modifier);
return modifier;
}