From ef3c39fbae7da92cd181e09c1422b58366254462 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 28 Jul 2018 10:58:47 +0200 Subject: [PATCH] Fix Counter and Mirror Coat --- asm/macros/battle_script.inc | 2 +- data/battle_scripts_1.s | 10 ++-- src/battle_script_commands.c | 96 ++---------------------------------- 3 files changed, 10 insertions(+), 98 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 659b3de64..27e052c33 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -401,7 +401,7 @@ .byte \param1 .endm - .macro typecalc2 + .macro nop_4A .byte 0x4a .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b6008134c..11650c811 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1650,7 +1650,8 @@ BattleScript_EffectCounter:: accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce - typecalc2 + typecalc + bichalfword gMoveResultFlags, MOVE_RESULT_NOT_VERY_EFFECTIVE | MOVE_RESULT_SUPER_EFFECTIVE adjustdamage goto BattleScript_HitFromAtkAnimation @@ -2028,7 +2029,7 @@ BattleScript_EffectRollout:: BattleScript_RolloutCheckAccuracy:: accuracycheck BattleScript_RolloutHit, ACC_CURR_MOVE BattleScript_RolloutHit:: - typecalc2 + typecalc handlerollout goto BattleScript_HitFromCritCalc @@ -2223,7 +2224,8 @@ BattleScript_EffectMirrorCoat:: accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce - typecalc2 + typecalc + bichalfword gMoveResultFlags, MOVE_RESULT_NOT_VERY_EFFECTIVE | MOVE_RESULT_SUPER_EFFECTIVE adjustdamage goto BattleScript_HitFromAtkAnimation @@ -2826,7 +2828,7 @@ BattleScript_BrickBreakAnim:: printstring STRINGID_THEWALLSHATTERED waitmessage 0x40 BattleScript_BrickBreakDoHit:: - typecalc2 + typecalc effectivenesssound hitanimation BS_TARGET waitstate diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b1b75c6e3..77ddd61f3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -166,7 +166,7 @@ static void atk46_playanimation2(void); static void atk47_setgraphicalstatchangevalues(void); static void atk48_playstatchangeanimation(void); static void atk49_moveend(void); -static void atk4A_typecalc2(void); +static void atk4A_nop(void); static void atk4B_returnatktoball(void); static void atk4C_getswitchedmondata(void); static void atk4D_switchindataupdate(void); @@ -424,7 +424,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk47_setgraphicalstatchangevalues, atk48_playstatchangeanimation, atk49_moveend, - atk4A_typecalc2, + atk4A_nop, atk4B_returnatktoball, atk4C_getswitchedmondata, atk4D_switchindataupdate, @@ -4341,98 +4341,8 @@ static void atk49_moveend(void) gBattlescriptCurrInstr += 3; } -static void atk4A_typecalc2(void) +static void atk4A_nop(void) { - u8 flags = 0; - s32 i = 0; - u8 moveType = gBattleMoves[gCurrentMove].type; - - if (gBattleMons[gBattlerTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) - { - gLastUsedAbility = gBattleMons[gBattlerTarget].ability; - gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); - gLastLandedMoves[gBattlerTarget] = 0; - gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); - } - else - { - while (TYPE_EFFECT_ATK_TYPE(i) != TYPE_ENDTABLE) - { - if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) - { - if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT) - { - break; - } - else - { - i += 3; - continue; - } - } - - if (TYPE_EFFECT_ATK_TYPE(i) == moveType) - { - // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1) - { - if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) - { - gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; - break; - } - if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) - { - flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; - } - if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) - { - flags |= MOVE_RESULT_SUPER_EFFECTIVE; - } - } - // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2) - { - if (gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 - && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) - { - gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; - break; - } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 - && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 - && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) - { - flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; - } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 - && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 - && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) - { - flags |= MOVE_RESULT_SUPER_EFFECTIVE; - } - } - } - i += 3; - } - } - - if (gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD - && !(flags & MOVE_RESULT_NO_EFFECT) - && AttacksThisTurn(gBattlerAttacker, gCurrentMove) == 2 - && (!(flags & MOVE_RESULT_SUPER_EFFECTIVE) || ((flags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE))) - && gBattleMoves[gCurrentMove].power) - { - gLastUsedAbility = ABILITY_WONDER_GUARD; - gMoveResultFlags |= MOVE_RESULT_MISSED; - gLastLandedMoves[gBattlerTarget] = 0; - gBattleCommunication[6] = 3; - RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); - } - if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) - gProtectStructs[gBattlerAttacker].targetNotAffected = 1; - gBattlescriptCurrInstr++; }