Fix no_effect script command overwriting trainer data in trainer script (#7978)
This commit is contained in:
parent
90c3a8cb2c
commit
ddddca68e9
@ -429,7 +429,7 @@ bool8 CheckForTrainersWantingBattle(void)
|
|||||||
|
|
||||||
static u8 CheckTrainer(u8 objectEventId)
|
static u8 CheckTrainer(u8 objectEventId)
|
||||||
{
|
{
|
||||||
const u8 *scriptPtr, *trainerBattlePtr;
|
const u8 *trainerBattlePtr;
|
||||||
u8 numTrainers = 1;
|
u8 numTrainers = 1;
|
||||||
|
|
||||||
u8 approachDistance = GetTrainerApproachDistance(&gObjectEvents[objectEventId]);
|
u8 approachDistance = GetTrainerApproachDistance(&gObjectEvents[objectEventId]);
|
||||||
@ -438,13 +438,13 @@ static u8 CheckTrainer(u8 objectEventId)
|
|||||||
|
|
||||||
if (InTrainerHill() == TRUE)
|
if (InTrainerHill() == TRUE)
|
||||||
{
|
{
|
||||||
trainerBattlePtr = scriptPtr = GetTrainerHillTrainerScript();
|
trainerBattlePtr = GetTrainerHillTrainerScript();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
trainerBattlePtr = scriptPtr = GetObjectEventScriptPointerByObjectEventId(objectEventId);
|
trainerBattlePtr = GetObjectEventScriptPointerByObjectEventId(objectEventId);
|
||||||
struct ScriptContext ctx;
|
struct ScriptContext ctx;
|
||||||
if (RunScriptImmediatelyUntilEffect(SCREFF_V1 | SCREFF_SAVE | SCREFF_HARDWARE | SCREFF_TRAINERBATTLE, scriptPtr, &ctx))
|
if (RunScriptImmediatelyUntilEffect(SCREFF_V1 | SCREFF_SAVE | SCREFF_HARDWARE | SCREFF_TRAINERBATTLE, trainerBattlePtr, &ctx))
|
||||||
{
|
{
|
||||||
if (*ctx.scriptPtr == 0x5c) // trainerbattle
|
if (*ctx.scriptPtr == 0x5c) // trainerbattle
|
||||||
trainerBattlePtr = ctx.scriptPtr;
|
trainerBattlePtr = ctx.scriptPtr;
|
||||||
@ -492,7 +492,7 @@ static u8 CheckTrainer(u8 objectEventId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gApproachingTrainers[gNoOfApproachingTrainers].objectEventId = objectEventId;
|
gApproachingTrainers[gNoOfApproachingTrainers].objectEventId = objectEventId;
|
||||||
gApproachingTrainers[gNoOfApproachingTrainers].trainerScriptPtr = scriptPtr;
|
gApproachingTrainers[gNoOfApproachingTrainers].trainerScriptPtr = trainerBattlePtr;
|
||||||
gApproachingTrainers[gNoOfApproachingTrainers].radius = approachDistance;
|
gApproachingTrainers[gNoOfApproachingTrainers].radius = approachDistance;
|
||||||
InitTrainerApproachTask(&gObjectEvents[objectEventId], approachDistance - 1);
|
InitTrainerApproachTask(&gObjectEvents[objectEventId], approachDistance - 1);
|
||||||
gNoOfApproachingTrainers++;
|
gNoOfApproachingTrainers++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user