Fix Mega Evolution issues related to battlers and turn order (#2810)

This commit is contained in:
Eduardo Quezada D'Ottone 2023-05-14 22:43:21 -04:00 committed by GitHub
commit c42552a107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 377 additions and 71 deletions

View File

@ -615,7 +615,7 @@ BattleScript_ShellTrapSetUp::
playanimation BS_ATTACKER, B_ANIM_SHELL_TRAP_SETUP, NULL
printstring STRINGID_PREPARESHELLTRAP
waitmessage B_WAIT_TIME_LONG
end2
end3
BattleScript_EffectShellTrap::
attackcanceler
@ -689,7 +689,7 @@ BattleScript_BeakBlastSetUp::
playanimation BS_ATTACKER, B_ANIM_BEAK_BLAST_SETUP, NULL
printstring STRINGID_HEATUPBEAK
waitmessage B_WAIT_TIME_LONG
end2
end3
BattleScript_BeakBlastBurn::
setbyte cMULTISTRING_CHOOSER, 0
@ -7893,7 +7893,7 @@ BattleScript_FocusPunchSetUp::
playanimation BS_ATTACKER, B_ANIM_FOCUS_PUNCH_SETUP
printstring STRINGID_PKMNTIGHTENINGFOCUS
waitmessage B_WAIT_TIME_LONG
end2
end3
BattleScript_MegaEvolution::
printstring STRINGID_EMPTYSTRING3
@ -7909,7 +7909,7 @@ BattleScript_MegaEvolutionAfterString:
printstring STRINGID_MEGAEVOEVOLVED
waitmessage B_WAIT_TIME_LONG
switchinabilities BS_ATTACKER
end2
end3
BattleScript_WishMegaEvolution::
printstring STRINGID_EMPTYSTRING3

View File

@ -531,7 +531,7 @@ struct BattleStruct
u8 wildVictorySong;
u8 dynamicMoveType;
u8 wrappedBy[MAX_BATTLERS_COUNT];
u8 focusPunchBattlerId;
u8 focusPunchBattlers; // as bits
u8 battlerPreventingSwitchout;
u8 moneyMultiplier:6;
u8 moneyMultiplierItem:1;
@ -650,6 +650,7 @@ struct BattleStruct
u8 attackerBeforeBounce:2;
u8 beatUpSlot:3;
bool8 hitSwitchTargetFailed:1;
bool8 effectsBeforeUsingMoveDone:1; // Mega Evo and Focus Punch/Shell Trap effects.
u8 targetsDone[MAX_BATTLERS_COUNT]; // Each battler as a bit.
u16 overwrittenAbilities[MAX_BATTLERS_COUNT]; // abilities overwritten during battle (keep separate from battle history in case of switching)
bool8 allowedToChangeFormInWeather[PARTY_SIZE][2]; // For each party member and side, used by Ice Face.

View File

@ -193,7 +193,6 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId);
bool32 IsPartnerMonFromSameTrainer(u8 battlerId);
u8 GetSplitBasedOnStats(u8 battlerId);
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast);
bool32 TestSheerForceFlag(u8 battler, u16 move);
void TryRestoreHeldItems(void);
bool32 CanStealItem(u8 battlerStealing, u8 battlerItem, u16 item);

View File

@ -4917,9 +4917,6 @@ static void SetActionsAndBattlersTurnOrder(void)
turnOrderId++;
}
}
gBattleMainFunc = CheckMegaEvolutionBeforeTurn;
gBattleStruct->mega.battlerId = 0;
return;
}
else
{
@ -4965,8 +4962,8 @@ static void SetActionsAndBattlersTurnOrder(void)
}
}
}
gBattleMainFunc = CheckMegaEvolutionBeforeTurn;
gBattleStruct->mega.battlerId = 0;
gBattleMainFunc = CheckQuickClaw_CustapBerryActivation;
gBattleStruct->quickClawBattlerId = 0;
}
static void TurnValuesCleanUp(bool8 var0)
@ -5015,49 +5012,98 @@ void SpecialStatusesClear(void)
memset(&gSpecialStatuses, 0, sizeof(gSpecialStatuses));
}
static void CheckMegaEvolutionBeforeTurn(void)
static void PopulateArrayWithBattlers(u8 *battlers)
{
if (!(gHitMarker & HITMARKER_RUN))
{
while (gBattleStruct->mega.battlerId < gBattlersCount)
{
gActiveBattler = gBattlerAttacker = gBattleStruct->mega.battlerId;
gBattleStruct->mega.battlerId++;
if (gBattleStruct->mega.toEvolve & gBitTable[gActiveBattler]
&& !(gProtectStructs[gActiveBattler].noValidMoves))
{
struct Pokemon *party = GetBattlerParty(gActiveBattler);
struct Pokemon *mon = &party[gBattlerPartyIndexes[gActiveBattler]];
u32 i;
for (i = 0; i < gBattlersCount; i++)
battlers[i] = i;
}
static bool32 TryDoMegaEvosBeforeMoves(void)
{
if (!(gHitMarker & HITMARKER_RUN) && gBattleStruct->mega.toEvolve)
{
u32 i;
struct Pokemon *party;
struct Pokemon *mon;
u8 megaOrder[MAX_BATTLERS_COUNT];
PopulateArrayWithBattlers(megaOrder);
SortBattlersBySpeed(megaOrder, FALSE);
for (i = 0; i < gBattlersCount; i++)
{
if (gBattleStruct->mega.toEvolve & gBitTable[megaOrder[i]]
&& !(gProtectStructs[megaOrder[i]].noValidMoves))
{
gActiveBattler = gBattlerAttacker = megaOrder[i];
gBattleStruct->mega.toEvolve &= ~(gBitTable[gActiveBattler]);
gLastUsedItem = gBattleMons[gActiveBattler].item;
party = GetBattlerParty(gActiveBattler);
mon = &party[gBattlerPartyIndexes[gActiveBattler]];
if (GetBattleFormChangeTargetSpecies(gActiveBattler, FORM_CHANGE_BATTLE_MEGA_EVOLUTION_MOVE) != SPECIES_NONE)
BattleScriptExecute(BattleScript_WishMegaEvolution);
else
BattleScriptExecute(BattleScript_MegaEvolution);
return;
return TRUE;
}
}
}
#if B_MEGA_EVO_TURN_ORDER <= GEN_6
gBattleMainFunc = CheckChosenMoveForEffectsBeforeTurnStarts;
gBattleStruct->focusPunchBattlerId = 0;
#else
gBattleMainFunc = TryChangeTurnOrder; // This will just do nothing if no mon has mega evolved
#if B_MEGA_EVO_TURN_ORDER >= GEN_7
TryChangeTurnOrder(); // This will just do nothing if no mon has mega evolved.
#endif
return FALSE;
}
static bool32 TryDoMoveEffectsBeforeMoves(void)
{
if (!(gHitMarker & HITMARKER_RUN))
{
u32 i;
struct Pokemon *mon;
u8 battlers[MAX_BATTLERS_COUNT];
PopulateArrayWithBattlers(battlers);
SortBattlersBySpeed(battlers, FALSE);
for (i = 0; i < gBattlersCount; i++)
{
if (!(gBattleStruct->focusPunchBattlers & gBitTable[battlers[i]])
&& !(gBattleMons[battlers[i]].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[battlers[i]].truantCounter)
&& !(gProtectStructs[battlers[i]].noValidMoves))
{
gBattleStruct->focusPunchBattlers |= gBitTable[battlers[i]];
gActiveBattler = gBattlerAttacker = battlers[i];
switch (gChosenMoveByBattler[gActiveBattler])
{
case MOVE_FOCUS_PUNCH:
BattleScriptExecute(BattleScript_FocusPunchSetUp);
return TRUE;
case MOVE_BEAK_BLAST:
BattleScriptExecute(BattleScript_BeakBlastSetUp);
return TRUE;
case MOVE_SHELL_TRAP:
BattleScriptExecute(BattleScript_ShellTrapSetUp);
return TRUE;
}
}
}
}
return FALSE;
}
// In gen7, priority and speed are recalculated during the turn in which a pokemon mega evolves
static void TryChangeTurnOrder(void)
{
s32 i, j;
u32 i, j;
for (i = 0; i < gBattlersCount - 1; i++)
{
for (j = i + 1; j < gBattlersCount; j++)
{
u8 battler1 = gBattlerByTurnOrder[i];
u8 battler2 = gBattlerByTurnOrder[j];
u32 battler1 = gBattlerByTurnOrder[i];
u32 battler2 = gBattlerByTurnOrder[j];
if (gActionsByTurnOrder[i] == B_ACTION_USE_MOVE
&& gActionsByTurnOrder[j] == B_ACTION_USE_MOVE)
{
@ -5066,42 +5112,6 @@ static void TryChangeTurnOrder(void)
}
}
}
gBattleMainFunc = CheckChosenMoveForEffectsBeforeTurnStarts;
gBattleStruct->focusPunchBattlerId = 0;
}
static void CheckChosenMoveForEffectsBeforeTurnStarts(void)
{
u32 i;
if (!(gHitMarker & HITMARKER_RUN))
{
while (gBattleStruct->focusPunchBattlerId < gBattlersCount)
{
gActiveBattler = gBattlerAttacker = gBattleStruct->focusPunchBattlerId;
gBattleStruct->focusPunchBattlerId++;
if (!(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)
&& !(gDisableStructs[gBattlerAttacker].truantCounter)
&& !(gProtectStructs[gActiveBattler].noValidMoves))
{
switch (gChosenMoveByBattler[gActiveBattler])
{
case MOVE_FOCUS_PUNCH:
BattleScriptExecute(BattleScript_FocusPunchSetUp);
return;
case MOVE_BEAK_BLAST:
BattleScriptExecute(BattleScript_BeakBlastSetUp);
return;
case MOVE_SHELL_TRAP:
BattleScriptExecute(BattleScript_ShellTrapSetUp);
return;
}
}
}
}
gBattleMainFunc = CheckQuickClaw_CustapBerryActivation;
gBattleStruct->quickClawBattlerId = 0;
}
static void CheckQuickClaw_CustapBerryActivation(void)
@ -5156,6 +5166,8 @@ static void CheckQuickClaw_CustapBerryActivation(void)
gCurrentTurnActionNumber = 0;
gCurrentActionFuncId = gActionsByTurnOrder[0];
gBattleStruct->dynamicMoveType = 0;
gBattleStruct->effectsBeforeUsingMoveDone = FALSE;
gBattleStruct->focusPunchBattlers = 0;
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
gBattleStruct->ateBoost[i] = FALSE;
@ -5174,6 +5186,16 @@ static void RunTurnActionsFunctions(void)
if (gBattleOutcome != 0)
gCurrentActionFuncId = B_ACTION_FINISHED;
// Mega Evolve / Focus Punch-like moves after switching, items, running, but before using a move.
if (gCurrentActionFuncId == B_ACTION_USE_MOVE && !gBattleStruct->effectsBeforeUsingMoveDone)
{
if (TryDoMegaEvosBeforeMoves())
return;
else if (TryDoMoveEffectsBeforeMoves())
return;
gBattleStruct->effectsBeforeUsingMoveDone = TRUE;
}
*(&gBattleStruct->savedTurnActionNumber) = gCurrentTurnActionNumber;
sTurnActionsFuncsTable[gCurrentActionFuncId]();

View File

@ -3074,7 +3074,11 @@ static const u8 *BattleStringGetPlayerName(u8 *text, u8 battlerId)
toCpy = gSaveBlock2Ptr->playerName;
break;
case B_POSITION_PLAYER_RIGHT:
if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_MULTI))
if ((gBattleTypeFlags & BATTLE_TYPE_RECORDED) && !(gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)))
{
toCpy = gLinkPlayers[0].name;
}
else if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && gBattleTypeFlags & (BATTLE_TYPE_RECORDED | BATTLE_TYPE_MULTI))
{
toCpy = gLinkPlayers[2].name;
}

View File

@ -5562,6 +5562,9 @@ static void Cmd_moveend(void)
{
gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE;
gBattleMons[gBattlerAttacker].status1 = STATUS1_BURN;
gActiveBattler = gBattlerAttacker;
BtlController_EmitSetMonData(BUFFER_A, REQUEST_STATUS_BATTLE, 0, sizeof(gBattleMons[gActiveBattler].status1), &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler);
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BeakBlastBurn;
effect = 1;

View File

@ -1598,7 +1598,8 @@ void BattleScriptPushCursor(void)
void BattleScriptPop(void)
{
gBattlescriptCurrInstr = gBattleResources->battleScriptsStack->ptr[--gBattleResources->battleScriptsStack->size];
if (gBattleResources->battleScriptsStack->size != 0)
gBattlescriptCurrInstr = gBattleResources->battleScriptsStack->ptr[--gBattleResources->battleScriptsStack->size];
}
static bool32 IsGravityPreventingMove(u32 move)
@ -10647,7 +10648,7 @@ bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability)
void SortBattlersBySpeed(u8 *battlers, bool8 slowToFast)
{
int i, j, currSpeed, currBattler;
u16 speeds[4] = {0};
u16 speeds[MAX_BATTLERS_COUNT] = {0};
for (i = 0; i < gBattlersCount; i++)
speeds[i] = GetBattlerTotalSpeedStat(battlers[i]);

View File

@ -17,6 +17,44 @@ SINGLE_BATTLE_TEST("Venusaur can Mega Evolve holding Venusaurite")
}
}
DOUBLE_BATTLE_TEST("Mega Evolution's order is determined by Speed - opponent faster")
{
GIVEN {
PLAYER(SPECIES_VENUSAUR) { Item(ITEM_VENUSAURITE); Speed(1); }
PLAYER(SPECIES_WOBBUFFET) { Speed(3);}
OPPONENT(SPECIES_GARDEVOIR) { Item(ITEM_GARDEVOIRITE); Speed(3);}
OPPONENT(SPECIES_WOBBUFFET) { Speed(4);}
} WHEN {
TURN { MOVE(opponentLeft, MOVE_CELEBRATE, megaEvolve: TRUE); MOVE(playerLeft, MOVE_CELEBRATE, megaEvolve: TRUE); }
} SCENE {
MESSAGE("Foe Gardevoir's Gardevoirite is reacting to 's Mega Ring!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, opponentLeft);
MESSAGE("Foe Gardevoir has Mega Evolved into Mega Gardevoir!");
MESSAGE("Venusaur's Venusaurite is reacting to 1's Mega Ring!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, playerLeft);
MESSAGE("Venusaur has Mega Evolved into Mega Venusaur!");
}
}
DOUBLE_BATTLE_TEST("Mega Evolution's order is determined by Speed - player faster")
{
GIVEN {
PLAYER(SPECIES_VENUSAUR) { Item(ITEM_VENUSAURITE); Speed(5); }
PLAYER(SPECIES_WOBBUFFET) { Speed(3);}
OPPONENT(SPECIES_GARDEVOIR) { Item(ITEM_GARDEVOIRITE); Speed(2);}
OPPONENT(SPECIES_WOBBUFFET) { Speed(4);}
} WHEN {
TURN { MOVE(opponentLeft, MOVE_CELEBRATE, megaEvolve: TRUE); MOVE(playerLeft, MOVE_CELEBRATE, megaEvolve: TRUE); }
} SCENE {
MESSAGE("Venusaur's Venusaurite is reacting to 1's Mega Ring!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, playerLeft);
MESSAGE("Venusaur has Mega Evolved into Mega Venusaur!");
MESSAGE("Foe Gardevoir's Gardevoirite is reacting to 's Mega Ring!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, opponentLeft);
MESSAGE("Foe Gardevoir has Mega Evolved into Mega Gardevoir!");
}
}
SINGLE_BATTLE_TEST("Rayquaza can Mega Evolve knowing Dragon Ascent")
{
GIVEN {
@ -66,3 +104,52 @@ SINGLE_BATTLE_TEST("Abilities replaced by Mega Evolution do not affect turn orde
ASSUME(player->speed == 45);
}
}
DOUBLE_BATTLE_TEST("Mega Evolution happens after switching, but before Focus Punch-like Moves")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_FOCUS_PUNCH].effect == EFFECT_FOCUS_PUNCH);
PLAYER(SPECIES_WOBBUFFET);
PLAYER(SPECIES_VENUSAUR) { Item(ITEM_VENUSAURITE);}
OPPONENT(SPECIES_WYNAUT);
OPPONENT(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { SWITCH(opponentRight, 2); MOVE(playerRight, MOVE_FOCUS_PUNCH, megaEvolve: TRUE, target:opponentLeft); MOVE(playerLeft, MOVE_FOCUS_PUNCH, target:opponentLeft); }
TURN {};
} SCENE {
MESSAGE("2 withdrew Wobbuffet!");
MESSAGE("2 sent out Wobbuffet!");
MESSAGE("Venusaur's Venusaurite is reacting to 1's Mega Ring!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, playerRight);
MESSAGE("Venusaur has Mega Evolved into Mega Venusaur!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerRight);
MESSAGE("Venusaur is tightening its focus!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerLeft);
MESSAGE("Wobbuffet is tightening its focus!");
}
}
SINGLE_BATTLE_TEST("Regular Mega Evolution and Fervent Wish Mega Evolution can happen on the same turn")
{
GIVEN {
PLAYER(SPECIES_RAYQUAZA) { Moves(MOVE_DRAGON_ASCENT, MOVE_CELEBRATE); Speed(3);}
OPPONENT(SPECIES_GARDEVOIR) { Item(ITEM_GARDEVOIRITE); Speed(2);}
} WHEN {
TURN { MOVE(player, MOVE_CELEBRATE, megaEvolve: TRUE); MOVE(opponent, MOVE_CELEBRATE, megaEvolve: TRUE); }
} SCENE {
MESSAGE("1's fervent wish has reached Rayquaza!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, player);
MESSAGE("Rayquaza has Mega Evolved into Mega Rayquaza!");
MESSAGE("Foe Gardevoir's Gardevoirite is reacting to 's Mega Ring!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_MEGA_EVOLUTION, opponent);
MESSAGE("Foe Gardevoir has Mega Evolved into Mega Gardevoir!");
} THEN {
EXPECT_EQ(player->species, SPECIES_RAYQUAZA_MEGA);
EXPECT_EQ(opponent->species, SPECIES_GARDEVOIR_MEGA);
}
}

View File

@ -0,0 +1,113 @@
#include "global.h"
#include "test_battle.h"
ASSUMPTIONS
{
ASSUME(gBattleMoves[MOVE_BEAK_BLAST].effect == EFFECT_BEAK_BLAST);
}
DOUBLE_BATTLE_TEST("Beak Blast's charging message is shown before other moves are used")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_BEAK_BLAST].priority < 0);
PLAYER(SPECIES_WYNAUT) {Speed(10); }
PLAYER(SPECIES_WOBBUFFET) {Speed(5); }
OPPONENT(SPECIES_WOBBUFFET) {Speed(2); }
OPPONENT(SPECIES_WOBBUFFET) {Speed(3); }
} WHEN {
TURN { MOVE(playerLeft, MOVE_BEAK_BLAST, target:opponentLeft); }
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_BEAK_BLAST_SETUP, playerLeft);
MESSAGE("Wynaut started heating up its beak!");
MESSAGE("Wobbuffet used Celebrate!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, playerRight);
MESSAGE("Foe Wobbuffet used Celebrate!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponentRight);
MESSAGE("Foe Wobbuffet used Celebrate!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, opponentLeft);
MESSAGE("Wynaut used Beak Blast!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_BEAK_BLAST, playerLeft);
HP_BAR(opponentLeft);
}
}
DOUBLE_BATTLE_TEST("Beak Blast burns all who make contact with the pokemon")
{
GIVEN {
ASSUME(gBattleMoves[MOVE_BEAK_BLAST].priority < 0);
ASSUME(gBattleMoves[MOVE_TACKLE].flags & FLAG_MAKES_CONTACT);
PLAYER(SPECIES_WYNAUT) {Speed(10); }
PLAYER(SPECIES_WOBBUFFET) {Speed(5); }
OPPONENT(SPECIES_WOBBUFFET) {Speed(3); }
OPPONENT(SPECIES_WOBBUFFET) {Speed(2); }
} WHEN {
TURN { MOVE(opponentLeft, MOVE_TACKLE, target:playerLeft); MOVE(opponentRight, MOVE_TACKLE, target:playerLeft); MOVE(playerLeft, MOVE_BEAK_BLAST, target:opponentLeft); }
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_BEAK_BLAST_SETUP, playerLeft);
MESSAGE("Wynaut started heating up its beak!");
MESSAGE("Wobbuffet used Celebrate!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_CELEBRATE, playerRight);
MESSAGE("Foe Wobbuffet used Tackle!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentLeft);
HP_BAR(playerLeft);
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponentLeft);
MESSAGE("Foe Wobbuffet was burned!");
STATUS_ICON(opponentLeft, burn: TRUE);
MESSAGE("Foe Wobbuffet used Tackle!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_TACKLE, opponentRight);
HP_BAR(playerLeft);
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponentRight);
MESSAGE("Foe Wobbuffet was burned!");
STATUS_ICON(opponentRight, burn: TRUE);
MESSAGE("Wynaut used Beak Blast!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_BEAK_BLAST, playerLeft);
HP_BAR(opponentLeft);
}
}
SINGLE_BATTLE_TEST("Beak Blast burns only when contact moves are used")
{
u32 move;
bool32 burn;
PARAMETRIZE { move = MOVE_TACKLE; burn = TRUE; }
PARAMETRIZE { move = MOVE_WATER_GUN; burn = FALSE; }
PARAMETRIZE { move = MOVE_LEER; burn = FALSE; }
GIVEN {
ASSUME(gBattleMoves[MOVE_TACKLE].flags & FLAG_MAKES_CONTACT);
ASSUME(!(gBattleMoves[MOVE_WATER_GUN].flags & FLAG_MAKES_CONTACT));
ASSUME(!(gBattleMoves[MOVE_LEER].flags & FLAG_MAKES_CONTACT));
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_BEAK_BLAST); MOVE(opponent, move); }
TURN {}
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_BEAK_BLAST_SETUP, player);
MESSAGE("Wobbuffet started heating up its beak!");
ANIMATION(ANIM_TYPE_MOVE, move, opponent);
if (burn) {
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponent);
MESSAGE("Foe Wobbuffet was burned!");
STATUS_ICON(opponent, burn: TRUE);
}
else {
NONE_OF {
ANIMATION(ANIM_TYPE_STATUS, B_ANIM_STATUS_BRN, opponent);
MESSAGE("Foe Wobbuffet was burned!");
STATUS_ICON(opponent, burn: TRUE);
}
}
MESSAGE("Wobbuffet used Beak Blast!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_BEAK_BLAST, player);
HP_BAR(opponent);
}
}

View File

@ -0,0 +1,76 @@
#include "global.h"
#include "test_battle.h"
ASSUMPTIONS
{
ASSUME(gBattleMoves[MOVE_FOCUS_PUNCH].effect == EFFECT_FOCUS_PUNCH);
}
SINGLE_BATTLE_TEST("Focus Punch activates only if not damaged")
{
u32 move;
bool32 activate;
PARAMETRIZE { move = MOVE_TACKLE; activate = FALSE; }
PARAMETRIZE { move = MOVE_WATER_GUN; activate = FALSE; }
PARAMETRIZE { move = MOVE_LEER; activate = TRUE; }
GIVEN {
PLAYER(SPECIES_WOBBUFFET);
OPPONENT(SPECIES_WOBBUFFET);
} WHEN {
TURN { MOVE(player, MOVE_FOCUS_PUNCH); MOVE(opponent, move); }
} SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, player);
MESSAGE("Wobbuffet is tightening its focus!");
ANIMATION(ANIM_TYPE_MOVE, move, opponent);
if (activate) {
MESSAGE("Wobbuffet used Focus Punch!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, player);
HP_BAR(opponent);
} else {
MESSAGE("Wobbuffet lost its focus and couldn't move!");
NONE_OF {
MESSAGE("Wobbuffet used Focus Punch!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, player);
HP_BAR(opponent);
}
}
}
}
DOUBLE_BATTLE_TEST("Focus Punch activation is based on Speed")
{
GIVEN {
PLAYER(SPECIES_WOBBUFFET) {Speed(2) ;}
PLAYER(SPECIES_WYNAUT) {Speed(3) ;}
OPPONENT(SPECIES_WOBBUFFET) {Speed(1) ;}
OPPONENT(SPECIES_WYNAUT) {Speed(5) ;}
} WHEN {
TURN { MOVE(opponentRight, MOVE_FOCUS_PUNCH, target:playerLeft); MOVE(playerRight, MOVE_FOCUS_PUNCH, target:opponentLeft); MOVE(playerLeft, MOVE_FOCUS_PUNCH, target:opponentLeft); MOVE(opponentLeft, MOVE_FOCUS_PUNCH, target:playerLeft); }
}
SCENE {
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, opponentRight);
MESSAGE("Foe Wynaut is tightening its focus!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerRight);
MESSAGE("Wynaut is tightening its focus!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, playerLeft);
MESSAGE("Wobbuffet is tightening its focus!");
ANIMATION(ANIM_TYPE_GENERAL, B_ANIM_FOCUS_PUNCH_SETUP, opponentLeft);
MESSAGE("Foe Wobbuffet is tightening its focus!");
MESSAGE("Foe Wynaut used Focus Punch!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, opponentRight);
HP_BAR(playerLeft);
MESSAGE("Wynaut used Focus Punch!");
ANIMATION(ANIM_TYPE_MOVE, MOVE_FOCUS_PUNCH, playerRight);
HP_BAR(opponentLeft);
MESSAGE("Wobbuffet lost its focus and couldn't move!");
MESSAGE("Foe Wobbuffet lost its focus and couldn't move!");
}
}