Merge branch 'battle_engine' of https://github.com/rh-hideout/pokeemerald-expansion into mimicry

This commit is contained in:
LOuroboros 2021-11-04 12:25:26 -03:00
commit 22f7e81bef
10 changed files with 259 additions and 209 deletions

View File

@ -2598,6 +2598,18 @@ BattleScript_AromaVeilProtects:
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_PastelVeilProtectsRet::
pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp
printstring STRINGID_PASTELVEILPROTECTED
waitmessage B_WAIT_TIME_LONG
return
BattleScript_PastelVeilProtects:
call BattleScript_PastelVeilProtectsRet
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
goto BattleScript_MoveEnd
BattleScript_LeafGuardProtectsRet:: BattleScript_LeafGuardProtectsRet::
pause B_WAIT_TIME_SHORT pause B_WAIT_TIME_SHORT
call BattleScript_AbilityPopUp call BattleScript_AbilityPopUp
@ -3098,6 +3110,7 @@ BattleScript_EffectToxic::
ppreduce ppreduce
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifability BS_TARGET_SIDE, ABILITY_PASTEL_VEIL, BattleScript_PastelVeilProtects
jumpifflowerveil BattleScript_FlowerVeilProtects jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
@ -3125,6 +3138,7 @@ BattleScript_AlreadyPoisoned::
BattleScript_ImmunityProtected:: BattleScript_ImmunityProtected::
copybyte gEffectBattler, gBattlerTarget copybyte gEffectBattler, gBattlerTarget
call BattleScript_AbilityPopUp
setbyte cMULTISTRING_CHOOSER, B_MSG_ABILITY_PREVENTS_MOVE_STATUS setbyte cMULTISTRING_CHOOSER, B_MSG_ABILITY_PREVENTS_MOVE_STATUS
call BattleScript_PSNPrevention call BattleScript_PSNPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -3453,6 +3467,7 @@ BattleScript_EffectPoison::
ppreduce ppreduce
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects jumpifability BS_TARGET, ABILITY_COMATOSE, BattleScript_LeafGuardProtects
jumpifability BS_TARGET_SIDE, ABILITY_PASTEL_VEIL, BattleScript_PastelVeilProtects
jumpifflowerveil BattleScript_FlowerVeilProtects jumpifflowerveil BattleScript_FlowerVeilProtects
jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects jumpifleafguardprotected BS_TARGET, BattleScript_LeafGuardProtects
jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects
@ -9001,3 +9016,27 @@ BattleScript_DarkTypePreventsPrankster::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT orhalfword gMoveResultFlags, MOVE_RESULT_NO_EFFECT
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_PastelVeilActivates::
setbyte gBattleCommunication, 0
setbyte gBattleCommunication + 1, 0
BattleScript_PastelVeil_TryCurePoison:
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_PastelVeilCurePoison
goto BattleScript_PastelVeilLoopIncrement
BattleScript_PastelVeilCurePoison:
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication + 1, 0x0, BattleScript_PastelVeilCurePoisonNoPopUp
call BattleScript_AbilityPopUp
setbyte gBattleCommunication + 1, 1
BattleScript_PastelVeilCurePoisonNoPopUp: @ Only show Pastel Veil pop up once if it cures two mons
printfromtable gSwitchInAbilityStringIds
waitmessage B_WAIT_TIME_LONG
curestatus BS_TARGET
updatestatusicon BS_TARGET
BattleScript_PastelVeilLoopIncrement:
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, 0x0, BattleScript_PastelVeilEnd
addbyte gBattleCommunication, 1
jumpifnoally BS_TARGET, BattleScript_PastelVeilEnd
setallytonexttarget BattleScript_PastelVeil_TryCurePoison
goto BattleScript_PastelVeilEnd
BattleScript_PastelVeilEnd:
end3

View File

@ -145,8 +145,8 @@ struct ProtectStruct
u32 powderSelfDmg:1; u32 powderSelfDmg:1;
u32 usedThroatChopPreventedMove:1; u32 usedThroatChopPreventedMove:1;
u32 statRaised:1; u32 statRaised:1;
u32 micle:1; u32 usedMicleBerry:1;
u32 custap:1; // also quick claw u32 usedCustapBerry:1; // also quick claw
u32 touchedProtectLike:1; u32 touchedProtectLike:1;
u32 disableEjectPack:1; u32 disableEjectPack:1;
u32 statFell:1; u32 statFell:1;

View File

@ -406,6 +406,7 @@ extern const u8 BattleScript_SelectingNotAllowedMoveGorillaTactics[];
extern const u8 BattleScript_WanderingSpiritActivates[]; extern const u8 BattleScript_WanderingSpiritActivates[];
extern const u8 BattleScript_MirrorArmorReflect[]; extern const u8 BattleScript_MirrorArmorReflect[];
extern const u8 BattleScript_GooeyActivates[]; extern const u8 BattleScript_GooeyActivates[];
extern const u8 BattleScript_PastelVeilActivates[];
extern const u8 BattleScript_MimicryActivatesEnd3[]; extern const u8 BattleScript_MimicryActivatesEnd3[];
extern const u8 BattleScript_ApplyMimicry[]; extern const u8 BattleScript_ApplyMimicry[];

View File

@ -171,7 +171,7 @@ bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability); bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
bool32 CanSleep(u8 battlerId); bool32 CanSleep(u8 battlerId);
bool32 CanBePoisoned(u8 battlerId); bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget);
bool32 CanBeBurned(u8 battlerId); bool32 CanBeBurned(u8 battlerId);
bool32 CanBeParalyzed(u8 battlerId); bool32 CanBeParalyzed(u8 battlerId);
bool32 CanBeFrozen(u8 battlerId); bool32 CanBeFrozen(u8 battlerId);

View File

@ -599,9 +599,11 @@
#define STRINGID_BROKETHROUGHPROTECTION 596 #define STRINGID_BROKETHROUGHPROTECTION 596
#define STRINGID_ABILITYALLOWSONLYMOVE 597 #define STRINGID_ABILITYALLOWSONLYMOVE 597
#define STRINGID_SWAPPEDABILITIES 598 #define STRINGID_SWAPPEDABILITIES 598
#define STRINGID_BATTLERTYPECHANGEDTO 599 #define STRINGID_PASTELVEILPROTECTED 599
#define STRINGID_PASTELVEILENTERS 600
#define STRINGID_BATTLERTYPECHANGEDTO 601
#define BATTLESTRINGS_COUNT 600 #define BATTLESTRINGS_COUNT 602
// The below IDs are all indexes into battle message tables, // The below IDs are all indexes into battle message tables,
// used to determine which of a set of messages to print. // used to determine which of a set of messages to print.
@ -836,6 +838,7 @@
#define B_MSG_SWITCHIN_SCREENCLEANER 12 #define B_MSG_SWITCHIN_SCREENCLEANER 12
#define B_MSG_SWITCHIN_ASONE 13 #define B_MSG_SWITCHIN_ASONE 13
#define B_MSG_SWITCHIN_CURIOUS_MEDICINE 14 #define B_MSG_SWITCHIN_CURIOUS_MEDICINE 14
#define B_MSG_SWITCHIN_PASTEL_VEIL 15
// gMentalHerbCureStringIds // gMentalHerbCureStringIds
#define B_MSG_MENTALHERBCURE_INFATUATION 0 #define B_MSG_MENTALHERBCURE_INFATUATION 0

View File

@ -2616,7 +2616,7 @@ bool32 AI_CanPutToSleep(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move,
bool32 AI_CanBePoisoned(u8 battler, u16 ability) bool32 AI_CanBePoisoned(u8 battler, u16 ability)
{ {
if (ability == ABILITY_IMMUNITY if (ability == ABILITY_IMMUNITY
|| ability == ABILITY_PASTEL_VEIL || IsAbilityOnSide(battler, ABILITY_PASTEL_VEIL)
|| gBattleMons[battler].status1 & STATUS1_ANY || gBattleMons[battler].status1 & STATUS1_ANY
|| IsAbilityStatusProtected(battler) || IsAbilityStatusProtected(battler)
|| gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SAFEGUARD) || gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SAFEGUARD)

View File

@ -3084,35 +3084,35 @@ void FaintClearSetData(void)
memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct)); memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct));
gProtectStructs[gActiveBattler].protected = 0; gProtectStructs[gActiveBattler].protected = FALSE;
gProtectStructs[gActiveBattler].spikyShielded = 0; gProtectStructs[gActiveBattler].spikyShielded = FALSE;
gProtectStructs[gActiveBattler].kingsShielded = 0; gProtectStructs[gActiveBattler].kingsShielded = FALSE;
gProtectStructs[gActiveBattler].banefulBunkered = 0; gProtectStructs[gActiveBattler].banefulBunkered = FALSE;
gProtectStructs[gActiveBattler].obstructed = 0; gProtectStructs[gActiveBattler].obstructed = FALSE;
gProtectStructs[gActiveBattler].endured = 0; gProtectStructs[gActiveBattler].endured = FALSE;
gProtectStructs[gActiveBattler].noValidMoves = 0; gProtectStructs[gActiveBattler].noValidMoves = FALSE;
gProtectStructs[gActiveBattler].helpingHand = 0; gProtectStructs[gActiveBattler].helpingHand = FALSE;
gProtectStructs[gActiveBattler].bounceMove = 0; gProtectStructs[gActiveBattler].bounceMove = FALSE;
gProtectStructs[gActiveBattler].stealMove = 0; gProtectStructs[gActiveBattler].stealMove = FALSE;
gProtectStructs[gActiveBattler].prlzImmobility = 0; gProtectStructs[gActiveBattler].prlzImmobility = FALSE;
gProtectStructs[gActiveBattler].confusionSelfDmg = 0; gProtectStructs[gActiveBattler].confusionSelfDmg = FALSE;
gProtectStructs[gActiveBattler].targetAffected = 0; gProtectStructs[gActiveBattler].targetAffected = FALSE;
gProtectStructs[gActiveBattler].chargingTurn = 0; gProtectStructs[gActiveBattler].chargingTurn = FALSE;
gProtectStructs[gActiveBattler].fleeFlag = 0; gProtectStructs[gActiveBattler].fleeFlag = 0;
gProtectStructs[gActiveBattler].usedImprisonedMove = 0; gProtectStructs[gActiveBattler].usedImprisonedMove = FALSE;
gProtectStructs[gActiveBattler].loveImmobility = 0; gProtectStructs[gActiveBattler].loveImmobility = FALSE;
gProtectStructs[gActiveBattler].usedDisabledMove = 0; gProtectStructs[gActiveBattler].usedDisabledMove = FALSE;
gProtectStructs[gActiveBattler].usedTauntedMove = 0; gProtectStructs[gActiveBattler].usedTauntedMove = FALSE;
gProtectStructs[gActiveBattler].flag2Unknown = 0; gProtectStructs[gActiveBattler].flag2Unknown = FALSE;
gProtectStructs[gActiveBattler].flinchImmobility = 0; gProtectStructs[gActiveBattler].flinchImmobility = FALSE;
gProtectStructs[gActiveBattler].notFirstStrike = 0; gProtectStructs[gActiveBattler].notFirstStrike = FALSE;
gProtectStructs[gActiveBattler].usedHealBlockedMove = 0; gProtectStructs[gActiveBattler].usedHealBlockedMove = FALSE;
gProtectStructs[gActiveBattler].usesBouncedMove = 0; gProtectStructs[gActiveBattler].usesBouncedMove = FALSE;
gProtectStructs[gActiveBattler].usedGravityPreventedMove = 0; gProtectStructs[gActiveBattler].usedGravityPreventedMove = FALSE;
gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = 0; gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = FALSE;
gProtectStructs[gActiveBattler].statRaised = 0; gProtectStructs[gActiveBattler].statRaised = FALSE;
gProtectStructs[gActiveBattler].statFell = 0; gProtectStructs[gActiveBattler].statFell = FALSE;
gProtectStructs[gActiveBattler].pranksterElevated = 0; gProtectStructs[gActiveBattler].pranksterElevated = FALSE;
gDisableStructs[gActiveBattler].isFirstTurn = 2; gDisableStructs[gActiveBattler].isFirstTurn = 2;
@ -4426,7 +4426,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
|| (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE)
&& holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY
&& HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item)))) && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))))
gProtectStructs[battler1].custap = TRUE; gProtectStructs[battler1].usedCustapBerry = TRUE;
// Battler 2 // Battler 2
speedBattler2 = GetBattlerTotalSpeedStat(battler2); speedBattler2 = GetBattlerTotalSpeedStat(battler2);
@ -4440,7 +4440,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
|| (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE)
&& holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY
&& HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item)))) && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))))
gProtectStructs[battler2].custap = TRUE; gProtectStructs[battler2].usedCustapBerry = TRUE;
if (!ignoreChosenMoves) if (!ignoreChosenMoves)
{ {
@ -4460,9 +4460,9 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)
strikesFirst = 0; strikesFirst = 0;
else if (!gProtectStructs[battler1].quickDraw && gProtectStructs[battler2].quickDraw) else if (!gProtectStructs[battler1].quickDraw && gProtectStructs[battler2].quickDraw)
strikesFirst = 1; strikesFirst = 1;
else if (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap) else if (gProtectStructs[battler1].usedCustapBerry && !gProtectStructs[battler2].usedCustapBerry)
strikesFirst = 0; strikesFirst = 0;
else if (gProtectStructs[battler2].custap && !gProtectStructs[battler1].custap) else if (gProtectStructs[battler2].usedCustapBerry && !gProtectStructs[battler1].usedCustapBerry)
strikesFirst = 1; strikesFirst = 1;
else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL)
strikesFirst = 1; strikesFirst = 1;
@ -4623,10 +4623,10 @@ static void TurnValuesCleanUp(bool8 var0)
{ {
if (var0) if (var0)
{ {
gProtectStructs[gActiveBattler].protected = 0; gProtectStructs[gActiveBattler].protected = FALSE;
gProtectStructs[gActiveBattler].spikyShielded = 0; gProtectStructs[gActiveBattler].spikyShielded = FALSE;
gProtectStructs[gActiveBattler].kingsShielded = 0; gProtectStructs[gActiveBattler].kingsShielded = FALSE;
gProtectStructs[gActiveBattler].banefulBunkered = 0; gProtectStructs[gActiveBattler].banefulBunkered = FALSE;
} }
else else
{ {
@ -4721,14 +4721,14 @@ static void CheckQuickClaw_CustapBerryActivation(void)
gBattleStruct->quickClawBattlerId++; gBattleStruct->quickClawBattlerId++;
if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE
&& gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here
&& (gProtectStructs[gActiveBattler].custap || gProtectStructs[gActiveBattler].quickDraw) && (gProtectStructs[gActiveBattler].usedCustapBerry || gProtectStructs[gActiveBattler].quickDraw)
&& !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gDisableStructs[gBattlerAttacker].truantCounter)
&& !(gProtectStructs[gActiveBattler].noValidMoves)) && !(gProtectStructs[gActiveBattler].noValidMoves))
{ {
if (gProtectStructs[gActiveBattler].custap) if (gProtectStructs[gActiveBattler].usedCustapBerry)
{ {
gProtectStructs[gActiveBattler].custap = FALSE; gProtectStructs[gActiveBattler].usedCustapBerry = FALSE;
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem); PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem);
if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY)
@ -5138,7 +5138,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
gBattleStruct->dynamicMoveType = 0; gBattleStruct->dynamicMoveType = 0;
gBattleStruct->ateBoost[battlerAtk] = 0; gBattleStruct->ateBoost[battlerAtk] = 0;
gSpecialStatuses[battlerAtk].gemBoost = 0; gSpecialStatuses[battlerAtk].gemBoost = FALSE;
if (gBattleMoves[move].effect == EFFECT_WEATHER_BALL) if (gBattleMoves[move].effect == EFFECT_WEATHER_BALL)
{ {
@ -5236,7 +5236,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
&& moveType == ItemId_GetSecondaryId(gBattleMons[battlerAtk].item)) && moveType == ItemId_GetSecondaryId(gBattleMons[battlerAtk].item))
{ {
gSpecialStatuses[battlerAtk].gemParam = GetBattlerHoldEffectParam(battlerAtk); gSpecialStatuses[battlerAtk].gemParam = GetBattlerHoldEffectParam(battlerAtk);
gSpecialStatuses[battlerAtk].gemBoost = 1; gSpecialStatuses[battlerAtk].gemBoost = TRUE;
} }
} }

View File

@ -725,11 +725,15 @@ static const u8 sText_ButHoopaCantUseIt[] = _("But Hoopa can't use it\nthe way i
static const u8 sText_BrokeThroughProtection[] = _("It broke through the\n{B_DEF_NAME_WITH_PREFIX}'s protection!"); static const u8 sText_BrokeThroughProtection[] = _("It broke through the\n{B_DEF_NAME_WITH_PREFIX}'s protection!");
static const u8 sText_AbilityAllowsOnlyMove[] = _("{B_ATK_ABILITY} allows the\nuse of only {B_CURRENT_MOVE}!\p"); static const u8 sText_AbilityAllowsOnlyMove[] = _("{B_ATK_ABILITY} allows the\nuse of only {B_CURRENT_MOVE}!\p");
static const u8 sText_SwappedAbilities[] = _("{B_DEF_NAME_WITH_PREFIX} swapped Abilities\nwith its target!"); static const u8 sText_SwappedAbilities[] = _("{B_DEF_NAME_WITH_PREFIX} swapped Abilities\nwith its target!");
static const u8 sText_PastelVeilProtected[] = _("{B_DEF_NAME_WITH_PREFIX} is protected\nby a pastel veil!");
static const u8 sText_PastelVeilEnters[] = _("{B_DEF_NAME_WITH_PREFIX} was cured\nof its poisoning!");
static const u8 sText_BattlerTypeChangedTo[] = _("{B_BUFF1}'s type\nchanged to {B_BUFF2}!"); static const u8 sText_BattlerTypeChangedTo[] = _("{B_BUFF1}'s type\nchanged to {B_BUFF2}!");
const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
{ {
[STRINGID_BATTLERTYPECHANGEDTO - 12] = sText_BattlerTypeChangedTo, [STRINGID_BATTLERTYPECHANGEDTO - 12] = sText_BattlerTypeChangedTo,
[STRINGID_PASTELVEILENTERS - 12] = sText_PastelVeilEnters,
[STRINGID_PASTELVEILPROTECTED -12] = sText_PastelVeilProtected,
[STRINGID_SWAPPEDABILITIES - 12] = sText_SwappedAbilities, [STRINGID_SWAPPEDABILITIES - 12] = sText_SwappedAbilities,
[STRINGID_ABILITYALLOWSONLYMOVE - 12] = sText_AbilityAllowsOnlyMove, [STRINGID_ABILITYALLOWSONLYMOVE - 12] = sText_AbilityAllowsOnlyMove,
[STRINGID_BROKETHROUGHPROTECTION - 12] = sText_BrokeThroughProtection, [STRINGID_BROKETHROUGHPROTECTION - 12] = sText_BrokeThroughProtection,
@ -1377,6 +1381,7 @@ const u16 gSwitchInAbilityStringIds[] =
[B_MSG_SWITCHIN_SCREENCLEANER] = STRINGID_SCREENCLEANERENTERS, [B_MSG_SWITCHIN_SCREENCLEANER] = STRINGID_SCREENCLEANERENTERS,
[B_MSG_SWITCHIN_ASONE] = STRINGID_ASONEENTERS, [B_MSG_SWITCHIN_ASONE] = STRINGID_ASONEENTERS,
[B_MSG_SWITCHIN_CURIOUS_MEDICINE] = STRINGID_CURIOUSMEDICINEENTERS, [B_MSG_SWITCHIN_CURIOUS_MEDICINE] = STRINGID_CURIOUSMEDICINEENTERS,
[B_MSG_SWITCHIN_PASTEL_VEIL] = STRINGID_PASTELVEILENTERS,
}; };
const u16 gMissStringIds[] = const u16 gMissStringIds[] =

View File

@ -1437,8 +1437,8 @@ static void Cmd_attackcanceler(void)
&& !gProtectStructs[gBattlerAttacker].usesBouncedMove) && !gProtectStructs[gBattlerAttacker].usesBouncedMove)
{ {
PressurePPLose(gBattlerAttacker, gBattlerTarget, MOVE_MAGIC_COAT); PressurePPLose(gBattlerAttacker, gBattlerTarget, MOVE_MAGIC_COAT);
gProtectStructs[gBattlerTarget].bounceMove = 0; gProtectStructs[gBattlerTarget].bounceMove = FALSE;
gProtectStructs[gBattlerTarget].usesBouncedMove = 1; gProtectStructs[gBattlerTarget].usesBouncedMove = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
if (BlocksPrankster(gCurrentMove, gBattlerTarget, gBattlerAttacker, TRUE)) if (BlocksPrankster(gCurrentMove, gBattlerTarget, gBattlerAttacker, TRUE))
{ {
@ -1458,7 +1458,7 @@ static void Cmd_attackcanceler(void)
&& !gProtectStructs[gBattlerAttacker].usesBouncedMove) && !gProtectStructs[gBattlerAttacker].usesBouncedMove)
{ {
RecordAbilityBattle(gBattlerTarget, ABILITY_MAGIC_BOUNCE); RecordAbilityBattle(gBattlerTarget, ABILITY_MAGIC_BOUNCE);
gProtectStructs[gBattlerTarget].usesBouncedMove = 1; gProtectStructs[gBattlerTarget].usesBouncedMove = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; gBattlescriptCurrInstr = BattleScript_MagicCoatBounce;
@ -1470,7 +1470,7 @@ static void Cmd_attackcanceler(void)
if ((gProtectStructs[gBattlerByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) if ((gProtectStructs[gBattlerByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED)
{ {
PressurePPLose(gBattlerAttacker, gBattlerByTurnOrder[i], MOVE_SNATCH); PressurePPLose(gBattlerAttacker, gBattlerByTurnOrder[i], MOVE_SNATCH);
gProtectStructs[gBattlerByTurnOrder[i]].stealMove = 0; gProtectStructs[gBattlerByTurnOrder[i]].stealMove = FALSE;
gBattleScripting.battler = gBattlerByTurnOrder[i]; gBattleScripting.battler = gBattlerByTurnOrder[i];
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SnatchedMove; gBattlescriptCurrInstr = BattleScript_SnatchedMove;
@ -1480,7 +1480,7 @@ static void Cmd_attackcanceler(void)
if (gSpecialStatuses[gBattlerTarget].lightningRodRedirected) if (gSpecialStatuses[gBattlerTarget].lightningRodRedirected)
{ {
gSpecialStatuses[gBattlerTarget].lightningRodRedirected = 0; gSpecialStatuses[gBattlerTarget].lightningRodRedirected = FALSE;
gLastUsedAbility = ABILITY_LIGHTNING_ROD; gLastUsedAbility = ABILITY_LIGHTNING_ROD;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_TookAttack; gBattlescriptCurrInstr = BattleScript_TookAttack;
@ -1488,7 +1488,7 @@ static void Cmd_attackcanceler(void)
} }
else if (gSpecialStatuses[gBattlerTarget].stormDrainRedirected) else if (gSpecialStatuses[gBattlerTarget].stormDrainRedirected)
{ {
gSpecialStatuses[gBattlerTarget].stormDrainRedirected = 0; gSpecialStatuses[gBattlerTarget].stormDrainRedirected = FALSE;
gLastUsedAbility = ABILITY_STORM_DRAIN; gLastUsedAbility = ABILITY_STORM_DRAIN;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_TookAttack; gBattlescriptCurrInstr = BattleScript_TookAttack;
@ -1500,7 +1500,7 @@ static void Cmd_attackcanceler(void)
&& gBattleMoves[gCurrentMove].effect != EFFECT_SUCKER_PUNCH) && gBattleMoves[gCurrentMove].effect != EFFECT_SUCKER_PUNCH)
{ {
if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT) if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT)
gProtectStructs[gBattlerAttacker].touchedProtectLike = 1; gProtectStructs[gBattlerAttacker].touchedProtectLike = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gMoveResultFlags |= MOVE_RESULT_MISSED; gMoveResultFlags |= MOVE_RESULT_MISSED;
gLastLandedMoves[gBattlerTarget] = 0; gLastLandedMoves[gBattlerTarget] = 0;
@ -1683,9 +1683,9 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move)
else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)); else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef));
calc = (calc * (100 + atkParam)) / 100; calc = (calc * (100 + atkParam)) / 100;
if (gProtectStructs[battlerAtk].micle) if (gProtectStructs[battlerAtk].usedMicleBerry)
{ {
gProtectStructs[battlerAtk].micle = FALSE; gProtectStructs[battlerAtk].usedMicleBerry = FALSE;
if (atkAbility == ABILITY_RIPEN) if (atkAbility == ABILITY_RIPEN)
calc = (calc * 140) / 100; // ripen gives 40% acc boost calc = (calc * 140) / 100; // ripen gives 40% acc boost
else else
@ -1790,7 +1790,7 @@ static void Cmd_ppreduce(void)
if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos]) if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos])
{ {
gProtectStructs[gBattlerAttacker].notFirstStrike = 1; gProtectStructs[gBattlerAttacker].notFirstStrike = TRUE;
// For item Metronome, echoed voice // For item Metronome, echoed voice
if (gCurrentMove == gLastResultingMoves[gBattlerAttacker] if (gCurrentMove == gLastResultingMoves[gBattlerAttacker]
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
@ -1937,17 +1937,17 @@ static void Cmd_adjustdamage(void)
if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param) if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param)
{ {
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
gSpecialStatuses[gBattlerTarget].focusBanded = 1; gSpecialStatuses[gBattlerTarget].focusBanded = TRUE;
} }
else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget))
{ {
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
gSpecialStatuses[gBattlerTarget].focusSashed = 1; gSpecialStatuses[gBattlerTarget].focusSashed = TRUE;
} }
else if (GetBattlerAbility(gBattlerTarget) == ABILITY_STURDY && BATTLER_MAX_HP(gBattlerTarget)) else if (GetBattlerAbility(gBattlerTarget) == ABILITY_STURDY && BATTLER_MAX_HP(gBattlerTarget))
{ {
RecordAbilityBattle(gBattlerTarget, ABILITY_STURDY); RecordAbilityBattle(gBattlerTarget, ABILITY_STURDY);
gSpecialStatuses[gBattlerTarget].sturdied = 1; gSpecialStatuses[gBattlerTarget].sturdied = TRUE;
} }
if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE
@ -2027,7 +2027,7 @@ static void Cmd_multihitresultmessage(void)
if (gMoveResultFlags & MOVE_RESULT_STURDIED) if (gMoveResultFlags & MOVE_RESULT_STURDIED)
{ {
gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON); gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON);
gSpecialStatuses[gBattlerTarget].sturdied = 0; // Delete this line to make Sturdy last for the duration of the whole move turn. gSpecialStatuses[gBattlerTarget].sturdied = FALSE; // Delete this line to make Sturdy last for the duration of the whole move turn.
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SturdiedMsg; gBattlescriptCurrInstr = BattleScript_SturdiedMsg;
return; return;
@ -2037,8 +2037,8 @@ static void Cmd_multihitresultmessage(void)
gLastUsedItem = gBattleMons[gBattlerTarget].item; gLastUsedItem = gBattleMons[gBattlerTarget].item;
gPotentialItemEffectBattler = gBattlerTarget; gPotentialItemEffectBattler = gBattlerTarget;
gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON); gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON);
gSpecialStatuses[gBattlerTarget].focusBanded = 0; // Delete this line to make Focus Band last for the duration of the whole move turn. gSpecialStatuses[gBattlerTarget].focusBanded = FALSE; // Delete this line to make Focus Band last for the duration of the whole move turn.
gSpecialStatuses[gBattlerTarget].focusSashed = 0; // Delete this line to make Focus Sash last for the duration of the whole move turn. gSpecialStatuses[gBattlerTarget].focusSashed = FALSE; // Delete this line to make Focus Sash last for the duration of the whole move turn.
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_HangedOnMsg; gBattlescriptCurrInstr = BattleScript_HangedOnMsg;
return; return;
@ -2050,7 +2050,7 @@ static void Cmd_multihitresultmessage(void)
if (gSpecialStatuses[gBattlerTarget].berryReduced if (gSpecialStatuses[gBattlerTarget].berryReduced
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{ {
gSpecialStatuses[gBattlerTarget].berryReduced = 0; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString; gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
} }
@ -2402,7 +2402,7 @@ static void Cmd_resultmessage(void)
else if (gMoveResultFlags & MOVE_RESULT_STURDIED) else if (gMoveResultFlags & MOVE_RESULT_STURDIED)
{ {
gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON);
gSpecialStatuses[gBattlerTarget].sturdied = 0; gSpecialStatuses[gBattlerTarget].sturdied = FALSE;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SturdiedMsg; gBattlescriptCurrInstr = BattleScript_SturdiedMsg;
return; return;
@ -2444,7 +2444,7 @@ static void Cmd_resultmessage(void)
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{ {
gLastUsedItem = gBattleMons[gBattlerTarget].item; gLastUsedItem = gBattleMons[gBattlerTarget].item;
gSpecialStatuses[gBattlerTarget].berryReduced = 0; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString; gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString;
} }
@ -2686,15 +2686,13 @@ void SetMoveEffect(bool32 primary, u32 certain)
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUS_HAD_NO_EFFECT; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUS_HAD_NO_EFFECT;
RESET_RETURN RESET_RETURN
} }
if (!CanPoisonType(gBattleScripting.battler, gEffectBattler)) if (!CanBePoisoned(gBattleScripting.battler, gEffectBattler))
break;
if (!CanBePoisoned(gEffectBattler))
break; break;
statusChanged = TRUE; statusChanged = TRUE;
break; break;
case STATUS1_BURN: case STATUS1_BURN:
if (gCurrentMove == MOVE_BURNING_JEALOUSY && gProtectStructs[gEffectBattler].statRaised == 0) if (gCurrentMove == MOVE_BURNING_JEALOUSY && !gProtectStructs[gEffectBattler].statRaised)
break; break;
if ((GetBattlerAbility(gEffectBattler) == ABILITY_WATER_VEIL || GetBattlerAbility(gEffectBattler) == ABILITY_WATER_BUBBLE) if ((GetBattlerAbility(gEffectBattler) == ABILITY_WATER_VEIL || GetBattlerAbility(gEffectBattler) == ABILITY_WATER_BUBBLE)
@ -2813,11 +2811,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
if (gBattleMons[gEffectBattler].status1) if (gBattleMons[gEffectBattler].status1)
break; break;
if (CanPoisonType(gBattleScripting.battler, gEffectBattler)) if (CanBePoisoned(gBattleScripting.battler, gEffectBattler))
{ {
if (!CanBePoisoned(gEffectBattler))
break;
// It's redundant, because at this point we know the status1 value is 0. // It's redundant, because at this point we know the status1 value is 0.
gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON); gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON);
gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON); gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON);
@ -2959,7 +2954,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_CHARGING: case MOVE_EFFECT_CHARGING:
gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS; gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS;
gLockedMoves[gEffectBattler] = gCurrentMove; gLockedMoves[gEffectBattler] = gCurrentMove;
gProtectStructs[gEffectBattler].chargingTurn = 1; gProtectStructs[gEffectBattler].chargingTurn = TRUE;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
break; break;
case MOVE_EFFECT_WRAP: case MOVE_EFFECT_WRAP:
@ -3293,15 +3288,15 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_FEINT: case MOVE_EFFECT_FEINT:
if (IS_BATTLER_PROTECTED(gBattlerTarget)) if (IS_BATTLER_PROTECTED(gBattlerTarget))
{ {
gProtectStructs[gBattlerTarget].protected = 0; gProtectStructs[gBattlerTarget].protected = FALSE;
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD);
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_QUICK_GUARD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_QUICK_GUARD);
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_CRAFTY_SHIELD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_CRAFTY_SHIELD);
gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_MAT_BLOCK); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_MAT_BLOCK);
gProtectStructs[gBattlerTarget].spikyShielded = 0; gProtectStructs[gBattlerTarget].spikyShielded = FALSE;
gProtectStructs[gBattlerTarget].kingsShielded = 0; gProtectStructs[gBattlerTarget].kingsShielded = FALSE;
gProtectStructs[gBattlerTarget].banefulBunkered = 0; gProtectStructs[gBattlerTarget].banefulBunkered = FALSE;
gProtectStructs[gBattlerTarget].obstructed = 0; gProtectStructs[gBattlerTarget].obstructed = FALSE;
if (gCurrentMove == MOVE_FEINT) if (gCurrentMove == MOVE_FEINT)
{ {
BattleScriptPush(gBattlescriptCurrInstr + 1); BattleScriptPush(gBattlescriptCurrInstr + 1);
@ -4854,7 +4849,7 @@ static void Cmd_moveend(void)
{ {
if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
{ {
gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8;
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1; gBattleMoveDamage = 1;
@ -4865,7 +4860,7 @@ static void Cmd_moveend(void)
} }
else if (gProtectStructs[gBattlerTarget].kingsShielded) else if (gProtectStructs[gBattlerTarget].kingsShielded)
{ {
gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE;
i = gBattlerAttacker; i = gBattlerAttacker;
gBattlerAttacker = gBattlerTarget; gBattlerAttacker = gBattlerTarget;
gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable
@ -4876,7 +4871,7 @@ static void Cmd_moveend(void)
} }
else if (gProtectStructs[gBattlerTarget].banefulBunkered) else if (gProtectStructs[gBattlerTarget].banefulBunkered)
{ {
gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE;
gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER; gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER); PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER);
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -5036,7 +5031,7 @@ static void Cmd_moveend(void)
BtlController_EmitSpriteInvisibility(0, FALSE); BtlController_EmitSpriteInvisibility(0, FALSE);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE);
gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = 1; gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = TRUE;
gBattleScripting.moveendState++; gBattleScripting.moveendState++;
return; return;
} }
@ -5142,7 +5137,7 @@ static void Cmd_moveend(void)
// Set a flag if move hits either target (for throat spray that can't check damage) // Set a flag if move hits either target (for throat spray that can't check damage)
if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
gProtectStructs[gBattlerAttacker].targetAffected = 1; gProtectStructs[gBattlerAttacker].targetAffected = TRUE;
if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE)
&& gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattleTypeFlags & BATTLE_TYPE_DOUBLE
@ -5340,7 +5335,7 @@ static void Cmd_moveend(void)
{ {
gBattleScripting.savedBattler = gBattlerTarget | 0x4; gBattleScripting.savedBattler = gBattlerTarget | 0x4;
gBattleScripting.savedBattler |= (gBattlerAttacker << 4); gBattleScripting.savedBattler |= (gBattlerAttacker << 4);
gSpecialStatuses[gBattlerAttacker].dancerUsedMove = 1; gSpecialStatuses[gBattlerAttacker].dancerUsedMove = TRUE;
} }
for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++) for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++)
{ {
@ -5388,13 +5383,13 @@ static void Cmd_moveend(void)
*(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3;
if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget) if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget)
*(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3; *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3;
gProtectStructs[gBattlerAttacker].usesBouncedMove = 0; gProtectStructs[gBattlerAttacker].usesBouncedMove = FALSE;
gProtectStructs[gBattlerAttacker].targetAffected = 0; gProtectStructs[gBattlerAttacker].targetAffected = FALSE;
gBattleStruct->ateBoost[gBattlerAttacker] = 0; gBattleStruct->ateBoost[gBattlerAttacker] = 0;
gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST); gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST);
gSpecialStatuses[gBattlerAttacker].gemBoost = 0; gSpecialStatuses[gBattlerAttacker].gemBoost = FALSE;
gSpecialStatuses[gBattlerAttacker].damagedMons = 0; gSpecialStatuses[gBattlerAttacker].damagedMons = 0;
gSpecialStatuses[gBattlerTarget].berryReduced = 0; gSpecialStatuses[gBattlerTarget].berryReduced = FALSE;
gBattleScripting.moveEffect = 0; gBattleScripting.moveEffect = 0;
gBattleScripting.moveendState++; gBattleScripting.moveendState++;
break; break;
@ -7270,9 +7265,8 @@ static void HandleTerrainMove(u32 moveEffect)
bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget) bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget)
{ {
return (GetBattlerAbility(battlerAttacker) == ABILITY_CORROSION return ((GetBattlerAbility(battlerAttacker) == ABILITY_CORROSION && gBattleMoves[gCurrentMove].split == SPLIT_STATUS)
|| !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
|| IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
} }
bool32 CanParalyzeType(u8 battlerAttacker, u8 battlerTarget) bool32 CanParalyzeType(u8 battlerAttacker, u8 battlerTarget)
@ -7666,9 +7660,9 @@ static void Cmd_various(void)
gBattleCommunication[0] = FALSE; gBattleCommunication[0] = FALSE;
break; break;
case VARIOUS_RESET_INTIMIDATE_TRACE_BITS: case VARIOUS_RESET_INTIMIDATE_TRACE_BITS:
gSpecialStatuses[gActiveBattler].intimidatedMon = 0; gSpecialStatuses[gActiveBattler].intimidatedMon = FALSE;
gSpecialStatuses[gActiveBattler].traced = 0; gSpecialStatuses[gActiveBattler].traced = FALSE;
gSpecialStatuses[gActiveBattler].switchInAbilityDone = 0; gSpecialStatuses[gActiveBattler].switchInAbilityDone = FALSE;
break; break;
case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP: case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP:
if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId || gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId) if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId || gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId)
@ -9062,32 +9056,32 @@ static void Cmd_setprotectlike(void)
{ {
if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE) if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE)
{ {
gProtectStructs[gBattlerAttacker].endured = 1; gProtectStructs[gBattlerAttacker].endured = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BRACED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BRACED_ITSELF;
} }
else if (gCurrentMove == MOVE_DETECT || gCurrentMove == MOVE_PROTECT) else if (gCurrentMove == MOVE_DETECT || gCurrentMove == MOVE_PROTECT)
{ {
gProtectStructs[gBattlerAttacker].protected = 1; gProtectStructs[gBattlerAttacker].protected = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_SPIKY_SHIELD) else if (gCurrentMove == MOVE_SPIKY_SHIELD)
{ {
gProtectStructs[gBattlerAttacker].spikyShielded = 1; gProtectStructs[gBattlerAttacker].spikyShielded = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_KINGS_SHIELD) else if (gCurrentMove == MOVE_KINGS_SHIELD)
{ {
gProtectStructs[gBattlerAttacker].kingsShielded = 1; gProtectStructs[gBattlerAttacker].kingsShielded = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_BANEFUL_BUNKER) else if (gCurrentMove == MOVE_BANEFUL_BUNKER)
{ {
gProtectStructs[gBattlerAttacker].banefulBunkered = 1; gProtectStructs[gBattlerAttacker].banefulBunkered = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF;
} }
else if (gCurrentMove == MOVE_OBSTRUCT) else if (gCurrentMove == MOVE_OBSTRUCT)
{ {
gProtectStructs[gBattlerAttacker].obstructed = 1; gProtectStructs[gBattlerAttacker].obstructed = TRUE;
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
} }
@ -9252,7 +9246,7 @@ static void Cmd_trymirrormove(void)
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
} }
} }
@ -9621,7 +9615,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
BattleScriptPush(BS_ptr); BattleScriptPush(BS_ptr);
gBattleScripting.battler = gActiveBattler; gBattleScripting.battler = gActiveBattler;
gBattlescriptCurrInstr = BattleScript_MistProtected; gBattlescriptCurrInstr = BattleScript_MistProtected;
gSpecialStatuses[gActiveBattler].statLowered = 1; gSpecialStatuses[gActiveBattler].statLowered = TRUE;
} }
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
@ -9651,7 +9645,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss; gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss;
gLastUsedAbility = GetBattlerAbility(gActiveBattler); gLastUsedAbility = GetBattlerAbility(gActiveBattler);
RecordAbilityBattle(gActiveBattler, gLastUsedAbility); RecordAbilityBattle(gActiveBattler, gLastUsedAbility);
gSpecialStatuses[gActiveBattler].statLowered = 1; gSpecialStatuses[gActiveBattler].statLowered = TRUE;
} }
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
@ -9671,7 +9665,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
gBattlerAbility = index - 1; gBattlerAbility = index - 1;
gBattlescriptCurrInstr = BattleScript_FlowerVeilProtectsRet; gBattlescriptCurrInstr = BattleScript_FlowerVeilProtectsRet;
gLastUsedAbility = ABILITY_FLOWER_VEIL; gLastUsedAbility = ABILITY_FLOWER_VEIL;
gSpecialStatuses[gActiveBattler].statLowered = 1; gSpecialStatuses[gActiveBattler].statLowered = TRUE;
} }
} }
return STAT_CHANGE_DIDNT_WORK; return STAT_CHANGE_DIDNT_WORK;
@ -9745,7 +9739,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
} }
else else
{ {
gProtectStructs[gActiveBattler].statFell = 1; // Eject pack, lash out gProtectStructs[gActiveBattler].statFell = TRUE; // Eject pack, lash out
gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); // B_MSG_ATTACKER_STAT_FELL or B_MSG_DEFENDER_STAT_FELL gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); // B_MSG_ATTACKER_STAT_FELL or B_MSG_DEFENDER_STAT_FELL
} }
} }
@ -9788,7 +9782,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr
else else
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler);
gProtectStructs[gActiveBattler].statRaised = 1; gProtectStructs[gActiveBattler].statRaised = TRUE;
} }
} }
@ -10243,12 +10237,12 @@ static void Cmd_tryKO(void)
if (holdEffect == HOLD_EFFECT_FOCUS_BAND if (holdEffect == HOLD_EFFECT_FOCUS_BAND
&& (Random() % 100) < GetBattlerHoldEffectParam(gBattlerTarget)) && (Random() % 100) < GetBattlerHoldEffectParam(gBattlerTarget))
{ {
gSpecialStatuses[gBattlerTarget].focusBanded = 1; gSpecialStatuses[gBattlerTarget].focusBanded = TRUE;
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
} }
else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget))
{ {
gSpecialStatuses[gBattlerTarget].focusSashed = 1; gSpecialStatuses[gBattlerTarget].focusSashed = TRUE;
RecordItemEffectBattle(gBattlerTarget, holdEffect); RecordItemEffectBattle(gBattlerTarget, holdEffect);
} }
@ -10662,7 +10656,7 @@ static void Cmd_counterdamagecalculator(void)
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
} }
@ -10687,7 +10681,7 @@ static void Cmd_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the phy
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
} }
@ -11177,7 +11171,7 @@ static void Cmd_trysetspikes(void)
if (gSideTimers[targetSide].spikesAmount == 3) if (gSideTimers[targetSide].spikesAmount == 3)
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
else else
@ -11872,7 +11866,7 @@ static void Cmd_trysethelpinghand(void)
&& !gProtectStructs[gBattlerAttacker].helpingHand && !gProtectStructs[gBattlerAttacker].helpingHand
&& !gProtectStructs[gBattlerTarget].helpingHand) && !gProtectStructs[gBattlerTarget].helpingHand)
{ {
gProtectStructs[gBattlerTarget].helpingHand = 1; gProtectStructs[gBattlerTarget].helpingHand = TRUE;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
else else
@ -12292,28 +12286,28 @@ static void Cmd_assistattackselect(void)
static void Cmd_trysetmagiccoat(void) static void Cmd_trysetmagiccoat(void)
{ {
gBattlerTarget = gBattlerAttacker; gBattlerTarget = gBattlerAttacker;
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
else else
{ {
gProtectStructs[gBattlerAttacker].bounceMove = 1; gProtectStructs[gBattlerAttacker].bounceMove = TRUE;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
} }
static void Cmd_trysetsnatch(void) // snatch static void Cmd_trysetsnatch(void) // snatch
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
else else
{ {
gProtectStructs[gBattlerAttacker].stealMove = 1; gProtectStructs[gBattlerAttacker].stealMove = TRUE;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
} }
@ -13303,7 +13297,7 @@ static void Cmd_metalburstdamagecalculator(void)
} }
else else
{ {
gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE;
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
} }

View File

@ -256,7 +256,7 @@ void HandleAction_UseMove(void)
// choose move // choose move
if (gProtectStructs[gBattlerAttacker].noValidMoves) if (gProtectStructs[gBattlerAttacker].noValidMoves)
{ {
gProtectStructs[gBattlerAttacker].noValidMoves = 0; gProtectStructs[gBattlerAttacker].noValidMoves = FALSE;
gCurrentMove = gChosenMove = MOVE_STRUGGLE; gCurrentMove = gChosenMove = MOVE_STRUGGLE;
gHitMarker |= HITMARKER_NO_PPDEDUCT; gHitMarker |= HITMARKER_NO_PPDEDUCT;
*(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); *(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0);
@ -388,9 +388,9 @@ void HandleAction_UseMove(void)
gActiveBattler = gBattlerByTurnOrder[var]; gActiveBattler = gBattlerByTurnOrder[var];
RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability);
if (gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD) if (gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD)
gSpecialStatuses[gActiveBattler].lightningRodRedirected = 1; gSpecialStatuses[gActiveBattler].lightningRodRedirected = TRUE;
else if (gBattleMons[gActiveBattler].ability == ABILITY_STORM_DRAIN) else if (gBattleMons[gActiveBattler].ability == ABILITY_STORM_DRAIN)
gSpecialStatuses[gActiveBattler].stormDrainRedirected = 1; gSpecialStatuses[gActiveBattler].stormDrainRedirected = TRUE;
gBattlerTarget = gActiveBattler; gBattlerTarget = gActiveBattler;
} }
} }
@ -1618,7 +1618,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1633,7 +1633,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1648,7 +1648,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1663,7 +1663,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1678,7 +1678,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1693,7 +1693,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravityInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravityInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1708,7 +1708,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1723,7 +1723,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace; gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace;
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1754,7 +1754,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1768,7 +1768,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1796,7 +1796,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
{ {
if (gBattleTypeFlags & BATTLE_TYPE_PALACE) if (gBattleTypeFlags & BATTLE_TYPE_PALACE)
{ {
gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE;
} }
else else
{ {
@ -1859,12 +1859,12 @@ bool8 AreAllMovesUnusable(void)
if (unusable == 0xF) // All moves are unusable. if (unusable == 0xF) // All moves are unusable.
{ {
gProtectStructs[gActiveBattler].noValidMoves = 1; gProtectStructs[gActiveBattler].noValidMoves = TRUE;
gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft; gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft;
} }
else else
{ {
gProtectStructs[gActiveBattler].noValidMoves = 0; gProtectStructs[gActiveBattler].noValidMoves = FALSE;
} }
return (unusable == 0xF); return (unusable == 0xF);
@ -3325,7 +3325,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_FLINCH: // flinch case CANCELLER_FLINCH: // flinch
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FLINCHED) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FLINCHED)
{ {
gProtectStructs[gBattlerAttacker].flinchImmobility = 1; gProtectStructs[gBattlerAttacker].flinchImmobility = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched; gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -3336,7 +3336,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_DISABLED: // disabled move case CANCELLER_DISABLED: // disabled move
if (gDisableStructs[gBattlerAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattlerAttacker].disabledMove != 0) if (gDisableStructs[gBattlerAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattlerAttacker].disabledMove != 0)
{ {
gProtectStructs[gBattlerAttacker].usedDisabledMove = 1; gProtectStructs[gBattlerAttacker].usedDisabledMove = TRUE;
gBattleScripting.battler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled; gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled;
@ -3348,7 +3348,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_HEAL_BLOCKED: case CANCELLER_HEAL_BLOCKED:
if (gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK && IsHealBlockPreventingMove(gBattlerAttacker, gCurrentMove)) if (gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK && IsHealBlockPreventingMove(gBattlerAttacker, gCurrentMove))
{ {
gProtectStructs[gBattlerAttacker].usedHealBlockedMove = 1; gProtectStructs[gBattlerAttacker].usedHealBlockedMove = TRUE;
gBattleScripting.battler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedHealBlockPrevents; gBattlescriptCurrInstr = BattleScript_MoveUsedHealBlockPrevents;
@ -3360,7 +3360,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_GRAVITY: case CANCELLER_GRAVITY:
if (gFieldStatuses & STATUS_FIELD_GRAVITY && IsGravityPreventingMove(gCurrentMove)) if (gFieldStatuses & STATUS_FIELD_GRAVITY && IsGravityPreventingMove(gCurrentMove))
{ {
gProtectStructs[gBattlerAttacker].usedGravityPreventedMove = 1; gProtectStructs[gBattlerAttacker].usedGravityPreventedMove = TRUE;
gBattleScripting.battler = gBattlerAttacker; gBattleScripting.battler = gBattlerAttacker;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedGravityPrevents; gBattlescriptCurrInstr = BattleScript_MoveUsedGravityPrevents;
@ -3372,7 +3372,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_TAUNTED: // taunt case CANCELLER_TAUNTED: // taunt
if (gDisableStructs[gBattlerAttacker].tauntTimer && gBattleMoves[gCurrentMove].power == 0) if (gDisableStructs[gBattlerAttacker].tauntTimer && gBattleMoves[gCurrentMove].power == 0)
{ {
gProtectStructs[gBattlerAttacker].usedTauntedMove = 1; gProtectStructs[gBattlerAttacker].usedTauntedMove = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted; gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -3383,7 +3383,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_IMPRISONED: // imprisoned case CANCELLER_IMPRISONED: // imprisoned
if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove)) if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove))
{ {
gProtectStructs[gBattlerAttacker].usedImprisonedMove = 1; gProtectStructs[gBattlerAttacker].usedImprisonedMove = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned; gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -3402,7 +3402,7 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleCommunication[MULTISTRING_CHOOSER] = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = TRUE;
gBattlerTarget = gBattlerAttacker; gBattlerTarget = gBattlerAttacker;
gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE, TRUE); gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE, TRUE);
gProtectStructs[gBattlerAttacker].confusionSelfDmg = 1; gProtectStructs[gBattlerAttacker].confusionSelfDmg = TRUE;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
} }
else else
@ -3424,7 +3424,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_PARALYSED: // paralysis case CANCELLER_PARALYSED: // paralysis
if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0)
{ {
gProtectStructs[gBattlerAttacker].prlzImmobility = 1; gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE;
// This is removed in Emerald for some reason // This is removed in Emerald for some reason
//CancelMultiTurnMoves(gBattlerAttacker); //CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed;
@ -3445,7 +3445,7 @@ u8 AtkCanceller_UnableToUseMove(void)
{ {
BattleScriptPush(BattleScript_MoveUsedIsInLoveCantAttack); BattleScriptPush(BattleScript_MoveUsedIsInLoveCantAttack);
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
gProtectStructs[gBattlerAttacker].loveImmobility = 1; gProtectStructs[gBattlerAttacker].loveImmobility = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
} }
gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove; gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove;
@ -3525,7 +3525,7 @@ u8 AtkCanceller_UnableToUseMove(void)
GET_MOVE_TYPE(gCurrentMove, moveType); GET_MOVE_TYPE(gCurrentMove, moveType);
if (moveType == TYPE_FIRE) if (moveType == TYPE_FIRE)
{ {
gProtectStructs[gBattlerAttacker].powderSelfDmg = 1; gProtectStructs[gBattlerAttacker].powderSelfDmg = TRUE;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4;
gBattlescriptCurrInstr = BattleScript_MoveUsedPowder; gBattlescriptCurrInstr = BattleScript_MoveUsedPowder;
effect = 1; effect = 1;
@ -3536,7 +3536,7 @@ u8 AtkCanceller_UnableToUseMove(void)
case CANCELLER_THROAT_CHOP: case CANCELLER_THROAT_CHOP:
if (gDisableStructs[gBattlerAttacker].throatChopTimer && gBattleMoves[gCurrentMove].flags & FLAG_SOUND) if (gDisableStructs[gBattlerAttacker].throatChopTimer && gBattleMoves[gCurrentMove].flags & FLAG_SOUND)
{ {
gProtectStructs[gBattlerAttacker].usedThroatChopPreventedMove = 1; gProtectStructs[gBattlerAttacker].usedThroatChopPreventedMove = TRUE;
CancelMultiTurnMoves(gBattlerAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsThroatChopPrevented; gBattlescriptCurrInstr = BattleScript_MoveUsedIsThroatChopPrevented;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
@ -4071,7 +4071,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_MOLDBREAKER; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_MOLDBREAKER;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4080,7 +4080,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TERAVOLT; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TERAVOLT;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4089,7 +4089,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TURBOBLAZE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TURBOBLAZE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4099,7 +4099,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
{ {
gDisableStructs[battler].slowStartTimer = 5; gDisableStructs[battler].slowStartTimer = 5;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SLOWSTART; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SLOWSTART;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4108,7 +4108,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_UNNERVE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_UNNERVE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4118,7 +4118,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ASONE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ASONE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_ActivateAsOne); BattleScriptPushCursorAndCallback(BattleScript_ActivateAsOne);
effect++; effect++;
} }
@ -4130,11 +4130,21 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
u32 i; u32 i;
gEffectBattler = BATTLE_PARTNER(battler); gEffectBattler = BATTLE_PARTNER(battler);
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_CURIOUS_MEDICINE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_CURIOUS_MEDICINE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
break; break;
case ABILITY_PASTEL_VEIL:
if (!gSpecialStatuses[battler].switchInAbilityDone)
{
gBattlerTarget = battler;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_PASTEL_VEIL;
BattleScriptPushCursorAndCallback(BattleScript_PastelVeilActivates);
effect++;
gSpecialStatuses[battler].switchInAbilityDone = 1;
}
break;
case ABILITY_ANTICIPATION: case ABILITY_ANTICIPATION:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
@ -4160,7 +4170,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (effect) if (effect)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ANTICIPATION; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ANTICIPATION;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
} }
} }
@ -4168,7 +4178,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_FRISK: case ABILITY_FRISK:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_FriskActivates); // Try activate BattleScriptPushCursorAndCallback(BattleScript_FriskActivates); // Try activate
effect++; effect++;
} }
@ -4178,7 +4188,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
{ {
ForewarnChooseMove(battler); ForewarnChooseMove(battler);
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FOREWARN; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FOREWARN;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4208,7 +4218,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
else else
statId = STAT_SPATK; statId = STAT_SPATK;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
if (CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN)) if (CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN))
{ {
@ -4225,7 +4235,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_PRESSURE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_PRESSURE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4234,7 +4244,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_DARKAURA; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_DARKAURA;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4243,7 +4253,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FAIRYAURA; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FAIRYAURA;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4252,7 +4262,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_AURABREAK; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_AURABREAK;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4261,7 +4271,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_COMATOSE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_COMATOSE;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4270,7 +4280,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!gSpecialStatuses[battler].switchInAbilityDone && TryRemoveScreens(battler)) if (!gSpecialStatuses[battler].switchInAbilityDone && TryRemoveScreens(battler))
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SCREENCLEANER; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SCREENCLEANER;
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
effect++; effect++;
} }
@ -4359,7 +4369,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gSpecialStatuses[battler].intimidatedMon)) if (!(gSpecialStatuses[battler].intimidatedMon))
{ {
gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_INTIMIDATED; gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_INTIMIDATED;
gSpecialStatuses[battler].intimidatedMon = 1; gSpecialStatuses[battler].intimidatedMon = TRUE;
} }
break; break;
case ABILITY_FORECAST: case ABILITY_FORECAST:
@ -4375,14 +4385,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gSpecialStatuses[battler].traced)) if (!(gSpecialStatuses[battler].traced))
{ {
gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_TRACED; gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_TRACED;
gSpecialStatuses[battler].traced = 1; gSpecialStatuses[battler].traced = TRUE;
} }
break; break;
case ABILITY_CLOUD_NINE: case ABILITY_CLOUD_NINE:
case ABILITY_AIR_LOCK: case ABILITY_AIR_LOCK:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
BattleScriptPushCursorAndCallback(BattleScript_AnnounceAirLockCloudNine); BattleScriptPushCursorAndCallback(BattleScript_AnnounceAirLockCloudNine);
effect++; effect++;
} }
@ -4400,7 +4410,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_INTREPID_SWORD: case ABILITY_INTREPID_SWORD:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
SET_STATCHANGER(STAT_ATK, 1, FALSE); SET_STATCHANGER(STAT_ATK, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn); BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
effect++; effect++;
@ -4409,7 +4419,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
case ABILITY_DAUNTLESS_SHIELD: case ABILITY_DAUNTLESS_SHIELD:
if (!gSpecialStatuses[battler].switchInAbilityDone) if (!gSpecialStatuses[battler].switchInAbilityDone)
{ {
gSpecialStatuses[battler].switchInAbilityDone = 1; gSpecialStatuses[battler].switchInAbilityDone = TRUE;
SET_STATCHANGER(STAT_DEF, 1, FALSE); SET_STATCHANGER(STAT_DEF, 1, FALSE);
BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn); BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn);
effect++; effect++;
@ -4862,7 +4872,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
|| CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN))) // Don't activate if defense cannot be lowered || CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN))) // Don't activate if defense cannot be lowered
{ {
if (gBattleMoves[gCurrentMove].effect == EFFECT_HIT_ESCAPE && CanBattlerSwitch(gBattlerAttacker)) if (gBattleMoves[gCurrentMove].effect == EFFECT_HIT_ESCAPE && CanBattlerSwitch(gBattlerAttacker))
gProtectStructs[battler].disableEjectPack = 1; // Set flag for target gProtectStructs[battler].disableEjectPack = TRUE; // Set flag for target
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WeakArmorActivates; gBattlescriptCurrInstr = BattleScript_WeakArmorActivates;
@ -5076,7 +5086,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& gBattleMons[gBattlerAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && TARGET_TURN_DAMAGED
&& CanBePoisoned(gBattlerAttacker) && CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
@ -5263,8 +5273,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerTarget].hp != 0 && gBattleMons[gBattlerTarget].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& CanBePoisoned(gBattlerTarget) && CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& TARGET_TURN_DAMAGED // Need to actually hit the target
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_POISON; gBattleScripting.moveEffect = MOVE_EFFECT_POISON;
@ -5311,7 +5322,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& gBattlerAttacker != battler) && gBattlerAttacker != battler)
{ {
// Set bit and save Dancer mon's original target // Set bit and save Dancer mon's original target
gSpecialStatuses[battler].dancerUsedMove = 1; gSpecialStatuses[battler].dancerUsedMove = TRUE;
gSpecialStatuses[battler].dancerOriginalTarget = *(gBattleStruct->moveTarget + battler) | 0x4; gSpecialStatuses[battler].dancerOriginalTarget = *(gBattleStruct->moveTarget + battler) | 0x4;
gBattleStruct->atkCancellerTracker = 0; gBattleStruct->atkCancellerTracker = 0;
gBattlerAttacker = gBattlerAbility = battler; gBattlerAttacker = gBattlerAbility = battler;
@ -5704,18 +5715,19 @@ bool32 CanSleep(u8 battlerId)
return TRUE; return TRUE;
} }
bool32 CanBePoisoned(u8 battlerId) bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget)
{ {
u16 ability = GetBattlerAbility(battlerId); u16 ability = GetBattlerAbility(battlerTarget);
if (IS_BATTLER_OF_TYPE(battlerId, TYPE_POISON)
|| IS_BATTLER_OF_TYPE(battlerId, TYPE_STEEL) if (!(CanPoisonType(battlerAttacker, battlerTarget))
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_SAFEGUARD || gSideStatuses[GetBattlerSide(battlerTarget)] & SIDE_STATUS_SAFEGUARD
|| gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerTarget].status1 & STATUS1_ANY
|| ability == ABILITY_IMMUNITY || ability == ABILITY_IMMUNITY
|| ability == ABILITY_COMATOSE || ability == ABILITY_COMATOSE
|| gBattleMons[battlerId].status1 & STATUS1_ANY || IsAbilityOnSide(battlerTarget, ABILITY_PASTEL_VEIL)
|| IsAbilityStatusProtected(battlerId) || gBattleMons[battlerTarget].status1 & STATUS1_ANY
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN)) || IsAbilityStatusProtected(battlerTarget)
|| IsBattlerTerrainAffected(battlerTarget, STATUS_FIELD_MISTY_TERRAIN))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -5918,7 +5930,7 @@ static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2)
{ {
if (HasEnoughHpToEatBerry(battlerId, 4, itemId)) if (HasEnoughHpToEatBerry(battlerId, 4, itemId))
{ {
gProtectStructs[battlerId].micle = TRUE; // battler's next attack has increased accuracy gProtectStructs[battlerId].usedMicleBerry = TRUE; // battler's next attack has increased accuracy
if (end2) if (end2)
{ {
@ -6320,7 +6332,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (effect) if (effect)
{ {
gSpecialStatuses[battlerId].switchInItemDone = 1; gSpecialStatuses[battlerId].switchInItemDone = TRUE;
gActiveBattler = gBattlerAttacker = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId; gActiveBattler = gBattlerAttacker = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId;
switch (effect) switch (effect)
{ {
@ -7176,7 +7188,7 @@ u32 GetMoveTarget(u16 move, u8 setTarget)
{ {
targetBattler ^= BIT_FLANK; targetBattler ^= BIT_FLANK;
RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability); RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability);
gSpecialStatuses[targetBattler].lightningRodRedirected = 1; gSpecialStatuses[targetBattler].lightningRodRedirected = TRUE;
} }
else if (gBattleMoves[move].type == TYPE_WATER else if (gBattleMoves[move].type == TYPE_WATER
&& IsAbilityOnOpposingSide(gBattlerAttacker, ABILITY_STORM_DRAIN) && IsAbilityOnOpposingSide(gBattlerAttacker, ABILITY_STORM_DRAIN)
@ -7184,7 +7196,7 @@ u32 GetMoveTarget(u16 move, u8 setTarget)
{ {
targetBattler ^= BIT_FLANK; targetBattler ^= BIT_FLANK;
RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability); RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability);
gSpecialStatuses[targetBattler].stormDrainRedirected = 1; gSpecialStatuses[targetBattler].stormDrainRedirected = TRUE;
} }
} }
break; break;
@ -7711,7 +7723,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef)
basePower *= 2; basePower *= 2;
break; break;
case EFFECT_ASSURANCE: case EFFECT_ASSURANCE:
if (gProtectStructs[battlerDef].physicalDmg != 0 || gProtectStructs[battlerDef].specialDmg != 0 || gProtectStructs[battlerDef].confusionSelfDmg != 0) if (gProtectStructs[battlerDef].physicalDmg != 0 || gProtectStructs[battlerDef].specialDmg != 0 || gProtectStructs[battlerDef].confusionSelfDmg)
basePower *= 2; basePower *= 2;
break; break;
case EFFECT_TRUMP_CARD: case EFFECT_TRUMP_CARD:
@ -8612,7 +8624,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move
else else
MulModifier(&finalModifier, UQ_4_12(0.5)); MulModifier(&finalModifier, UQ_4_12(0.5));
if (updateFlags) if (updateFlags)
gSpecialStatuses[battlerDef].berryReduced = 1; gSpecialStatuses[battlerDef].berryReduced = TRUE;
} }
break; break;
} }
@ -9017,33 +9029,29 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut)
{ {
u32 i, currSpecies; u32 i, currSpecies;
struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; struct Pokemon *party = (side == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty;
static const u16 species[][2] = // changed form id, default form id static const u16 species[][3] =
{ {
{SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU}, // Changed Form ID Default Form ID Should change on switch
{SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND}, {SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU, FALSE},
{SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH}, {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND, FALSE},
{SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN}, {SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH, TRUE},
{SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED}, {SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN, TRUE},
{SPECIES_MINIOR_METEOR_BLUE, SPECIES_MINIOR_CORE_BLUE}, {SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED, TRUE},
{SPECIES_MINIOR_METEOR_GREEN, SPECIES_MINIOR_CORE_GREEN}, {SPECIES_MINIOR_METEOR_BLUE, SPECIES_MINIOR_CORE_BLUE, TRUE},
{SPECIES_MINIOR_METEOR_INDIGO, SPECIES_MINIOR_CORE_INDIGO}, {SPECIES_MINIOR_METEOR_GREEN, SPECIES_MINIOR_CORE_GREEN, TRUE},
{SPECIES_MINIOR_METEOR_ORANGE, SPECIES_MINIOR_CORE_ORANGE}, {SPECIES_MINIOR_METEOR_INDIGO, SPECIES_MINIOR_CORE_INDIGO, TRUE},
{SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET}, {SPECIES_MINIOR_METEOR_ORANGE, SPECIES_MINIOR_CORE_ORANGE, TRUE},
{SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW}, {SPECIES_MINIOR_METEOR_VIOLET, SPECIES_MINIOR_CORE_VIOLET, TRUE},
{SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI}, {SPECIES_MINIOR_METEOR_YELLOW, SPECIES_MINIOR_CORE_YELLOW, TRUE},
{SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT}, {SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI, TRUE},
{SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT}, {SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT, TRUE},
{SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT, TRUE},
}; };
if (isSwitchingOut) // Don't revert Mimikyu Busted or Ash-Greninja when switching out
i = 2;
else
i = 0;
currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL); currSpecies = GetMonData(&party[monId], MON_DATA_SPECIES, NULL);
for (; i < ARRAY_COUNT(species); i++) for (i = 0; i < ARRAY_COUNT(species); i++)
{ {
if (currSpecies == species[i][0]) if (currSpecies == species[i][0] && (!isSwitchingOut || species[i][2] == TRUE))
{ {
SetMonData(&party[monId], MON_DATA_SPECIES, &species[i][1]); SetMonData(&party[monId], MON_DATA_SPECIES, &species[i][1]);
CalculateMonStats(&party[monId]); CalculateMonStats(&party[monId]);