Fix Counter and Mirror Coat

This commit is contained in:
DizzyEggg 2018-07-28 10:58:47 +02:00
parent 43fc4b6933
commit ef3c39fbae
3 changed files with 10 additions and 98 deletions

View File

@ -401,7 +401,7 @@
.byte \param1
.endm
.macro typecalc2
.macro nop_4A
.byte 0x4a
.endm

View File

@ -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

View File

@ -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++;
}