add mirror armor

This commit is contained in:
ghoulslash 2021-10-12 18:04:34 -04:00
parent e66820e646
commit 996301d5d3
6 changed files with 86 additions and 15 deletions

View File

@ -1825,6 +1825,10 @@
various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER
.endm .endm
.macro getrandommirrorarmortarget
various BS_TARGET, VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET
.endm
@ helpful macros @ helpful macros
.macro setstatchanger stat:req, stages:req, down:req .macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7

View File

@ -2645,6 +2645,33 @@ BattleScript_StatDownPrintString::
BattleScript_StatDownEnd:: BattleScript_StatDownEnd::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_MirrorArmorReflect::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
jumpifsubstituteblocks BattleScript_AbilityNoSpecificStatLoss
BattleScript_MirrorArmorReflectStatLoss:
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_MirrorArmorReflectWontFall
jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_MirrorArmorReflectAnim
goto BattleScript_MirrorArmorReflectWontFall
BattleScript_MirrorArmorReflectAnim:
setgraphicalstatchangevalues
playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
BattleScript_MirrorArmorReflectPrintString:
printfromtable gStatDownStringIds
waitmessage B_WAIT_TIME_LONG
BattleScript_MirrorArmorReflectEnd:
return
BattleScript_MirrorArmorReflectWontFall:
copybyte gBattlerTarget, gBattlerAttacker @ STRINGID_STATSWONTDECREASE uses target
goto BattleScript_MirrorArmorReflectPrintString
BattleScript_MirrorArmorReflectStickyWeb:
call BattleScript_AbilityPopUp
getrandommirrorarmortarget
jumpifbyteequal gBattlerTarget, gBattlerAttacker, BattleScript_AbilityNoSpecificStatLossPrint
goto BattleScript_MirrorArmorReflectStatLoss
BattleScript_StatDown:: BattleScript_StatDown::
playanimation BS_EFFECT_BATTLER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 playanimation BS_EFFECT_BATTLER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
printfromtable gStatDownStringIds printfromtable gStatDownStringIds
@ -6099,6 +6126,7 @@ BattleScript_StickyWebOnSwitchIn::
copybyte gBattlerTarget, sBATTLER copybyte gBattlerTarget, sBATTLER
printstring STRINGID_STICKYWEBSWITCHIN printstring STRINGID_STICKYWEBSWITCHIN
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
jumpifability BS_TARGET, ABILITY_MIRROR_ARMOR, BattleScript_MirrorArmorReflectStickyWeb
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_StickyWebOnSwitchInEnd statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_StickyWebOnSwitchInEnd
jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_StickyWebOnSwitchInStatAnim jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_StickyWebOnSwitchInStatAnim
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY, BattleScript_StickyWebOnSwitchInEnd jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY, BattleScript_StickyWebOnSwitchInEnd
@ -7639,6 +7667,7 @@ BattleScript_GrassyTerrainHealEnd:
BattleScript_AbilityNoSpecificStatLoss:: BattleScript_AbilityNoSpecificStatLoss::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
BattleScript_AbilityNoSpecificStatLossPrint:
printstring STRINGID_PKMNSXPREVENTSYLOSS printstring STRINGID_PKMNSXPREVENTSYLOSS
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY
@ -7885,6 +7914,13 @@ BattleScript_CuteCharmActivates::
call BattleScript_TryDestinyKnotTarget call BattleScript_TryDestinyKnotTarget
return return
BattleScript_GooeyActivates::
waitstate
call BattleScript_AbilityPopUp
swapattackerwithtarget @ for defiant, mirror armor
seteffectsecondary
return
BattleScript_AbilityStatusEffect:: BattleScript_AbilityStatusEffect::
waitstate waitstate
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp

View File

@ -398,5 +398,7 @@ extern const u8 BattleScript_MysteriousAirCurrentBlowsOn[];
extern const u8 BattleScript_AttackWeakenedByStrongWinds[]; extern const u8 BattleScript_AttackWeakenedByStrongWinds[];
extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[]; extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[];
extern const u8 BattleScript_BlockedByPrimalWeatherRet[]; extern const u8 BattleScript_BlockedByPrimalWeatherRet[];
extern const u8 BattleScript_MirrorArmorReflect[];
extern const u8 BattleScript_GooeyActivates[];
#endif // GUARD_BATTLE_SCRIPTS_H #endif // GUARD_BATTLE_SCRIPTS_H

View File

@ -185,6 +185,7 @@
#define VARIOUS_REMOVE_TERRAIN 113 #define VARIOUS_REMOVE_TERRAIN 113
#define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 #define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114
#define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 #define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115
#define VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET 116
// Cmd_manipulatedamage // Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0 #define DMG_CHANGE_SIGN 0

View File

@ -2582,6 +2582,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
{ {
s32 i, byTwo, affectsUser = 0; s32 i, byTwo, affectsUser = 0;
bool32 statusChanged = FALSE; bool32 statusChanged = FALSE;
bool32 mirrorArmorReflected = (GetBattlerAbility(gBattlerTarget) == ABILITY_MIRROR_ARMOR);
u32 flags;
switch (gBattleScripting.moveEffect) // Set move effects which happen later on switch (gBattleScripting.moveEffect) // Set move effects which happen later on
{ {
@ -3012,11 +3014,18 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_SP_DEF_MINUS_1: case MOVE_EFFECT_SP_DEF_MINUS_1:
case MOVE_EFFECT_ACC_MINUS_1: case MOVE_EFFECT_ACC_MINUS_1:
case MOVE_EFFECT_EVS_MINUS_1: case MOVE_EFFECT_EVS_MINUS_1:
if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE, flags = affectsUser | certain;
gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1, if (mirrorArmorReflected && !affectsUser)
affectsUser, 0))
{ {
gBattlescriptCurrInstr++; flags |= STAT_BUFF_ALLOW_PTR;
}
if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE,
gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1,
flags, gBattlescriptCurrInstr + 1))
{
if (!mirrorArmorReflected)
gBattlescriptCurrInstr++;
} }
else else
{ {
@ -8822,6 +8831,25 @@ static void Cmd_various(void)
} }
break; break;
} }
case VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET:
i = BATTLE_OPPOSITE(gActiveBattler);
gBattlerAttacker = gBattlerTarget;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
if (IsBattlerAlive(i)
&& !(gBattleMons[i].status2 & STATUS2_SUBSTITUTE))
gBattlerAttacker = i;
else if (IsBattlerAlive(BATTLE_PARTNER(i))
&& !(gBattleMons[BATTLE_PARTNER(i)].status2 & STATUS2_SUBSTITUTE))
gBattlerAttacker = BATTLE_PARTNER(i);
}
else
{
if (IsBattlerAlive(i) && !(gBattleMons[i].status2 & STATUS2_SUBSTITUTE))
gBattlerAttacker = i;
}
SET_STATCHANGER(STAT_SPEED, 1, TRUE);
break;
} }
gBattlescriptCurrInstr += 3; gBattlescriptCurrInstr += 3;
@ -9355,8 +9383,9 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
bool32 certain = FALSE; bool32 certain = FALSE;
bool32 notProtectAffected = FALSE; bool32 notProtectAffected = FALSE;
u32 index; u32 index;
bool32 affectsUser = flags & MOVE_EFFECT_AFFECTS_USER;
if (flags & MOVE_EFFECT_AFFECTS_USER) if (affectsUser)
gActiveBattler = gBattlerAttacker; gActiveBattler = gBattlerAttacker;
else else
gActiveBattler = gBattlerTarget; gActiveBattler = gBattlerTarget;
@ -9457,8 +9486,9 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
} }
else if (GetBattlerAbility(gActiveBattler) == ABILITY_KEEN_EYE else if (!certain
&& !certain && statId == STAT_ACC) && ((GetBattlerAbility(gActiveBattler) == ABILITY_KEEN_EYE && statId == STAT_ACC)
|| (GetBattlerAbility(gActiveBattler) == ABILITY_HYPER_CUTTER && statId == STAT_ATK)))
{ {
if (flags == STAT_BUFF_ALLOW_PTR) if (flags == STAT_BUFF_ALLOW_PTR)
{ {
@ -9471,17 +9501,14 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
} }
else if (GetBattlerAbility(gActiveBattler) == ABILITY_HYPER_CUTTER else if (GetBattlerAbility(gActiveBattler) == ABILITY_MIRROR_ARMOR && !affectsUser && gBattlerAttacker != gBattlerTarget && gActiveBattler == gBattlerTarget)
&& !certain && statId == STAT_ATK)
{ {
if (flags == STAT_BUFF_ALLOW_PTR) if (flags == STAT_BUFF_ALLOW_PTR)
{ {
BattleScriptPush(BS_ptr); BattleScriptPush(BS_ptr);
gBattleScripting.battler = gActiveBattler; gBattleScripting.battler = gActiveBattler;
gBattlerAbility = gActiveBattler; gBattlerAbility = gActiveBattler;
gBattlescriptCurrInstr = BattleScript_AbilityNoSpecificStatLoss; gBattlescriptCurrInstr = BattleScript_MirrorArmorReflect;
gLastUsedAbility = GetBattlerAbility(gActiveBattler);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
} }

View File

@ -4835,15 +4835,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_TANGLING_HAIR: case ABILITY_TANGLING_HAIR:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) && (CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) || GetBattlerAbility(gBattlerAttacker) == ABILITY_MIRROR_ARMOR)
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && TARGET_TURN_DAMAGED
&& IsMoveMakingContact(move, gBattlerAttacker)) && IsMoveMakingContact(move, gBattlerAttacker))
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_SPD_MINUS_1; SET_STATCHANGER(STAT_SPEED, 1, TRUE);
gBattleScripting.moveEffect = MOVE_EFFECT_SPD_MINUS_1;
PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility); PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility);
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_AbilityStatusEffect; gBattlescriptCurrInstr = BattleScript_GooeyActivates;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
effect++; effect++;
} }