[FIX] Prevent caught Pokémon loss in NPC partner battles (#7177)

This commit is contained in:
Juanjo
2025-06-28 10:36:37 +02:00
committed by GitHub
parent 0c4b0c582e
commit 8973006273

View File

@@ -66,6 +66,8 @@
#include "constants/pokemon.h"
#include "config/battle.h"
#include "data/battle_move_effects.h"
#include "follower_npc.h"
#include "load_save.h"
// table to avoid ugly powing on gba (courtesy of doesnt)
// this returns (i^2.5)/4
@@ -16034,6 +16036,9 @@ static void Cmd_givecaughtmon(void)
{
CMD_ARGS(const u8 *passInstr);
enum GiveCaughtMonStates state = gBattleCommunication[MULTIUSE_STATE];
// Restore players party in order to handle properly the case when a wild mon is caught.
if (IsNPCFollowerWildBattle())
LoadPlayerParty();
switch (state)
{
@@ -16171,6 +16176,9 @@ static void Cmd_givecaughtmon(void)
gBattlescriptCurrInstr = cmd->nextInstr;
break;
}
// Save the player's party again to not interferes with RestorePartyAfterFollowerNPCBattle() called after battle.
if (IsNPCFollowerWildBattle())
SavePlayerParty();
}
static void Cmd_trysetcaughtmondexflags(void)