Add battle flag that prevents running from wild Pokémon (#5502)
* Add No Running Battle Flag Adds a flag that if set prevents the player from being able to run from wild battles. * Formatting battle_util.c Co-authored-by: Bassoonian <iasperbassoonian@gmail.com> * Adjust for pre-Gen 8 Teleport Addresses the edge case with Teleport when used with under Gen 8 mechanics. --------- Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
This commit is contained in:
parent
464c90a862
commit
2db1f071fa
5 changed files with 17 additions and 1 deletions
|
@ -187,6 +187,7 @@
|
|||
#define B_SMART_WILD_AI_FLAG 0 // If not 0, you can set this flag in a script to enable smart wild pokemon
|
||||
#define B_FLAG_NO_BAG_USE 0 // If this flag is set, the ability to use the bag in battle is disabled.
|
||||
#define B_FLAG_NO_CATCHING 0 // If this flag is set, the ability to catch wild Pokémon is disabled.
|
||||
#define B_FLAG_NO_RUNNING 0 // If this flag is set, the ability to escape from wild battles is disabled. Also makes Roar/Whirlwind and Teleport (under Gen8) fail.
|
||||
#define B_FLAG_AI_VS_AI_BATTLE 0 // If this flag is set, the player's mons will be controlled by the ai next battles.
|
||||
#define B_FLAG_DYNAMAX_BATTLE 0 // If this flag is set, the ability to Dynamax in battle is enabled for all trainers.
|
||||
#define B_FLAG_TERA_ORB_CHARGED 0 // If this flag is set, the Tera Orb is charged. It is automatically set upon healing and cleared upon Terastallizing once configured.
|
||||
|
|
|
@ -4073,6 +4073,12 @@ u8 IsRunningFromBattleImpossible(u32 battler)
|
|||
{
|
||||
u32 holdEffect, i;
|
||||
|
||||
if (FlagGet(B_FLAG_NO_RUNNING))
|
||||
{
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_ESCAPE;
|
||||
return BATTLE_RUN_FORBIDDEN;
|
||||
}
|
||||
|
||||
if (gBattleMons[battler].item == ITEM_ENIGMA_BERRY_E_READER)
|
||||
holdEffect = gEnigmaBerries[battler].holdEffect;
|
||||
else
|
||||
|
@ -4430,8 +4436,9 @@ static void HandleTurnActionSelectionState(void)
|
|||
BattleScriptExecute(BattleScript_PrintCantRunFromTrainer);
|
||||
gBattleCommunication[battler] = STATE_BEFORE_ACTION_CHOSEN;
|
||||
}
|
||||
else if (IsRunningFromBattleImpossible(battler) != BATTLE_RUN_SUCCESS
|
||||
else if ((IsRunningFromBattleImpossible(battler) != BATTLE_RUN_SUCCESS
|
||||
&& gBattleResources->bufferB[battler][1] == B_ACTION_RUN)
|
||||
|| (FlagGet(B_FLAG_NO_RUNNING) == TRUE && gBattleResources->bufferB[battler][1] == B_ACTION_RUN))
|
||||
{
|
||||
gSelectionBattleScripts[battler] = BattleScript_PrintCantEscapeFromBattle;
|
||||
gBattleCommunication[battler] = STATE_SELECTION_SCRIPT;
|
||||
|
|
|
@ -9076,6 +9076,7 @@ static void Cmd_various(void)
|
|||
{
|
||||
// Roar will fail in a double wild battle when used by the player against one of the two alive wild mons.
|
||||
// Also when an opposing wild mon uses it againt its partner.
|
||||
// Also when B_FLAG_NO_RUNNING is enabled.
|
||||
case VARIOUS_JUMP_IF_ROAR_FAILS:
|
||||
{
|
||||
VARIOUS_ARGS(const u8 *jumpInstr);
|
||||
|
@ -9088,6 +9089,8 @@ static void Cmd_various(void)
|
|||
&& GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT
|
||||
&& GetBattlerSide(gBattlerTarget) == B_SIDE_OPPONENT)
|
||||
gBattlescriptCurrInstr = cmd->jumpInstr;
|
||||
else if (FlagGet(B_FLAG_NO_RUNNING))
|
||||
gBattlescriptCurrInstr = cmd->jumpInstr;
|
||||
else
|
||||
gBattlescriptCurrInstr = cmd->nextInstr;
|
||||
return;
|
||||
|
|
|
@ -450,6 +450,10 @@ bool32 TryRunFromBattle(u32 battler)
|
|||
u8 pyramidMultiplier;
|
||||
u8 speedVar;
|
||||
|
||||
// If this flag is set, running will never be successful under any circumstances.
|
||||
if (FlagGet(B_FLAG_NO_RUNNING))
|
||||
return effect;
|
||||
|
||||
if (gBattleMons[battler].item == ITEM_ENIGMA_BERRY_E_READER)
|
||||
holdEffect = gEnigmaBerries[battler].holdEffect;
|
||||
else
|
||||
|
|
|
@ -423,6 +423,7 @@ void Overworld_ResetBattleFlagsAndVars(void)
|
|||
FlagClear(B_SMART_WILD_AI_FLAG);
|
||||
FlagClear(B_FLAG_NO_BAG_USE);
|
||||
FlagClear(B_FLAG_NO_CATCHING);
|
||||
FlagClear(B_FLAG_NO_RUNNING);
|
||||
FlagClear(B_FLAG_DYNAMAX_BATTLE);
|
||||
FlagClear(B_FLAG_SKY_BATTLE);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue