mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Fix Teleport ending trainer battles (#3166)
This commit is contained in:
parent
1fb42e4497
commit
42992ca5ce
@ -1318,7 +1318,7 @@
|
||||
.2byte \holdEffect
|
||||
.4byte \jumpInstr
|
||||
.endm
|
||||
|
||||
|
||||
.macro dostockpilestatchangeswearoff, battler:req, statChangeInstr:req
|
||||
callnative BS_DoStockpileStatChangesWearOff
|
||||
.byte \battler
|
||||
@ -1354,7 +1354,7 @@
|
||||
.macro setsnow
|
||||
callnative BS_SetSnow
|
||||
.endm
|
||||
|
||||
|
||||
.macro setzeffect
|
||||
callnative BS_SetZEffect
|
||||
.endm
|
||||
@ -1364,12 +1364,6 @@
|
||||
callnative BS_TrySymbiosis
|
||||
.endm
|
||||
|
||||
@ returns TRUE or FALSE to gBattleCommunication[0]
|
||||
.macro canteleport battler:req
|
||||
callnative BS_CanTeleport
|
||||
.byte \battler
|
||||
.endm
|
||||
|
||||
@ returns B_SIDE_x to gBattleCommunication[0]
|
||||
.macro getbattlerside battler:req
|
||||
callnative BS_GetBattlerSide
|
||||
@ -2077,7 +2071,7 @@
|
||||
.macro swapsidestatuses
|
||||
various BS_ATTACKER, VARIOUS_SWAP_SIDE_STATUSES
|
||||
.endm
|
||||
|
||||
|
||||
.macro swapstats stat:req
|
||||
various BS_ATTACKER, VARIOUS_SWAP_STATS
|
||||
.byte \stat
|
||||
@ -2178,6 +2172,11 @@
|
||||
jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_NO_EFFECT, \jumpInstr
|
||||
.endm
|
||||
|
||||
.macro jumpifside battler:req, side:req, equalJumpInstr:req
|
||||
getbattlerside \battler
|
||||
jumpifbyte CMP_EQUAL, gBattleCommunication, \side, \equalJumpInstr
|
||||
.endm
|
||||
|
||||
.macro jumpifbattletype flags:req, jumpInstr:req
|
||||
jumpifword CMP_COMMON_BITS, gBattleTypeFlags, \flags, \jumpInstr
|
||||
.endm
|
||||
|
@ -5401,15 +5401,14 @@ BattleScript_EffectHurricane:
|
||||
BattleScript_EffectTeleport:
|
||||
attackcanceler
|
||||
attackstring
|
||||
ppreduce
|
||||
.if B_TELEPORT_BEHAVIOR >= GEN_7
|
||||
canteleport BS_ATTACKER
|
||||
jumpifbyte CMP_EQUAL, gBattleCommunication, TRUE, BattleScript_EffectTeleportNew
|
||||
goto BattleScript_ButItFailed
|
||||
jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_EffectBatonPass
|
||||
jumpifside BS_ATTACKER, B_SIDE_PLAYER, BattleScript_EffectBatonPass
|
||||
.else
|
||||
jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_ButItFailed
|
||||
.endif
|
||||
BattleScript_EffectTeleportTryToRunAway:
|
||||
ppreduce
|
||||
getifcantrunfrombattle BS_ATTACKER
|
||||
jumpifbyte CMP_EQUAL, gBattleCommunication, BATTLE_RUN_FORBIDDEN, BattleScript_ButItFailed
|
||||
jumpifbyte CMP_EQUAL, gBattleCommunication, BATTLE_RUN_FAILURE, BattleScript_PrintAbilityMadeIneffective
|
||||
@ -5420,29 +5419,6 @@ BattleScript_EffectTeleportTryToRunAway:
|
||||
setoutcomeonteleport BS_ATTACKER
|
||||
goto BattleScript_MoveEnd
|
||||
|
||||
BattleScript_EffectTeleportNew:
|
||||
getbattlerside BS_ATTACKER
|
||||
jumpifbyte CMP_EQUAL, gBattleCommunication, B_SIDE_OPPONENT, BattleScript_EffectTeleportTryToRunAway
|
||||
attackanimation
|
||||
waitanimation
|
||||
openpartyscreen BS_ATTACKER, BattleScript_EffectTeleportNewEnd
|
||||
switchoutabilities BS_ATTACKER
|
||||
waitstate
|
||||
switchhandleorder BS_ATTACKER, 2
|
||||
returntoball BS_ATTACKER
|
||||
getswitchedmondata BS_ATTACKER
|
||||
switchindataupdate BS_ATTACKER
|
||||
hpthresholds BS_ATTACKER
|
||||
trytoclearprimalweather
|
||||
printstring STRINGID_EMPTYSTRING3
|
||||
waitmessage 1
|
||||
printstring STRINGID_SWITCHINMON
|
||||
switchinanim BS_ATTACKER, TRUE
|
||||
waitstate
|
||||
switchineffects BS_ATTACKER
|
||||
BattleScript_EffectTeleportNewEnd:
|
||||
goto BattleScript_MoveEnd
|
||||
|
||||
BattleScript_EffectBeatUp::
|
||||
attackcanceler
|
||||
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
|
||||
@ -7897,7 +7873,7 @@ BattleScript_WishMegaEvolution::
|
||||
BattleScript_PrimalReversion::
|
||||
call BattleScript_PrimalReversionRet
|
||||
end2
|
||||
|
||||
|
||||
BattleScript_PrimalReversionRestoreAttacker::
|
||||
call BattleScript_PrimalReversionRet
|
||||
copybyte gBattlerAttacker, sSAVED_BATTLER
|
||||
@ -8944,7 +8920,7 @@ BattleScript_BadDreams_ShowPopUp:
|
||||
goto BattleScript_BadDreams_DmgAfterPopUp
|
||||
BattleScript_BadDreams_HidePopUp:
|
||||
destroyabilitypopup
|
||||
tryfaintmon BS_TARGET
|
||||
tryfaintmon BS_TARGET
|
||||
goto BattleScript_BadDreamsIncrement
|
||||
|
||||
BattleScript_TookAttack::
|
||||
|
@ -8837,33 +8837,6 @@ static void HandleScriptMegaPrimal(u32 caseId, u32 battlerId, bool32 isMega)
|
||||
}
|
||||
}
|
||||
|
||||
static bool32 CanTeleport(u8 battlerId)
|
||||
{
|
||||
struct Pokemon *party = GetBattlerParty(battlerId);
|
||||
u32 species, count, i;
|
||||
|
||||
for (i = 0; i < PARTY_SIZE; i++)
|
||||
{
|
||||
species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG);
|
||||
if (species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&party[i], MON_DATA_HP) != 0)
|
||||
count++;
|
||||
}
|
||||
|
||||
switch (GetBattlerSide(battlerId))
|
||||
{
|
||||
case B_SIDE_OPPONENT:
|
||||
if (count == 1 || gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
|
||||
return FALSE;
|
||||
break;
|
||||
case B_SIDE_PLAYER:
|
||||
if (count == 1 || (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && count <= 2))
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Return True if the order was changed, and false if the order was not changed(for example because the target would move after the attacker anyway).
|
||||
static bool32 ChangeOrderTargetAfterAttacker(void)
|
||||
{
|
||||
@ -16327,13 +16300,6 @@ void BS_GetBattlerSide(void)
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
}
|
||||
|
||||
void BS_CanTeleport(void)
|
||||
{
|
||||
NATIVE_ARGS(u8 battler);
|
||||
gBattleCommunication[0] = CanTeleport(cmd->battler);
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
}
|
||||
|
||||
void BS_TrySymbiosis(void)
|
||||
{
|
||||
NATIVE_ARGS();
|
||||
|
61
test/move_effect_teleport.c
Normal file
61
test/move_effect_teleport.c
Normal file
@ -0,0 +1,61 @@
|
||||
#include "global.h"
|
||||
#include "test_battle.h"
|
||||
|
||||
ASSUMPTIONS
|
||||
{
|
||||
ASSUME(gBattleMoves[MOVE_TELEPORT].effect == EFFECT_TELEPORT);
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Teleport fails when there is no pokemon to switch in")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
TURN { MOVE(opponent, MOVE_TELEPORT); }
|
||||
} SCENE {
|
||||
MESSAGE("But it failed!");
|
||||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Teleport fails when there no alive pokemon left")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WYNAUT) { HP(0); }
|
||||
} WHEN {
|
||||
TURN { MOVE(opponent, MOVE_TELEPORT); }
|
||||
} SCENE {
|
||||
MESSAGE("But it failed!");
|
||||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Teleport forces the pokemon to switch out")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WYNAUT);
|
||||
} WHEN {
|
||||
TURN { MOVE(opponent, MOVE_TELEPORT); SEND_OUT(opponent, 1); }
|
||||
} SCENE {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_TELEPORT, opponent);
|
||||
MESSAGE("2 sent out Wynaut!");
|
||||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Teleport does not fail if the user is trapped")
|
||||
{
|
||||
GIVEN {
|
||||
PLAYER(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
OPPONENT(SPECIES_WYNAUT);
|
||||
} WHEN {
|
||||
TURN { MOVE(player, MOVE_FIRE_SPIN); MOVE(opponent, MOVE_TELEPORT); SEND_OUT(opponent, 1); }
|
||||
} SCENE {
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_FIRE_SPIN, player);
|
||||
ANIMATION(ANIM_TYPE_MOVE, MOVE_TELEPORT, opponent);
|
||||
MESSAGE("2 sent out Wynaut!");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user