Merge branch 'Chase-and-stamina-mechanic' into codex/add-chase-overworld-subsystem-for-chaser-events-eoy8ez

This commit is contained in:
MiyazakiTheFalse 2026-03-07 01:06:28 +00:00 committed by GitHub
commit 5751fb744b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 4 deletions

View File

@ -46,10 +46,9 @@ When `ChaseStamina_IsChaseActive()` is true, a chase-overworld layer drives 1..`
- Spawn point is biased behind the player when possible; each chaser then pursues every overworld frame.
- Target coordinate selection prefers the live player object-event coordinates and falls back to `gSaveBlock1Ptr->pos` when needed.
- Movement picks a primary axis toward player distance, then tries fallback directions (secondary axis, current facing, opposite facing).
- Every attempted step is validated with object collision checks; when no immediate move is legal, the chaser waits and retries.
- If a chaser remains blocked for an extended period, it is repositioned to a nearby legal tile around the player to break long-lived stuck states.
- Every attempted step is validated with object collision checks; if all checks fail the chaser turns in place toward the player instead of forcing illegal movement.
This policy keeps chasers visible and responsive while avoiding collision softlocks and prolonged stalls.
This policy keeps chasers visible and responsive while avoiding collision softlocks.
## Edge cases and invalidation handling

View File

@ -24,3 +24,7 @@ While `corpseRun.state == CR_ACTIVE`, battle permissions and payouts are resolve
When corpse-run mode is active, Safari step countdown is paused so Safari-linked encounters do not force `Times Up` during the run.
Vanilla step countdown resumes automatically as soon as corpse-run exits active state (recovery/failure/off), because the pause check is keyed directly to `CorpseRun_IsActive()`.
## Chase encounter party eligibility
Chase pressure can scale to request a double wild encounter when multiple chasers are active, but battle startup now downgrades to a single wild encounter unless `GetMonsStateToDoubles()` reports `PLAYER_HAS_TWO_USABLE_MONS`. Chase timers/chaser counts are still preserved regardless of this downgrade.

View File

@ -372,7 +372,12 @@ bool8 ChaseStamina_TryStartChaseEncounter(u32 metatileAttributes)
if (sActiveChasers >= 2)
{
if (!SweetScentWildEncounterWithCount(2))
u8 encounterCount = 2;
if (GetMonsStateToDoubles() != PLAYER_HAS_TWO_USABLE_MONS)
encounterCount = 1;
if (!SweetScentWildEncounterWithCount(encounterCount))
return FALSE;
}
else if (!SweetScentWildEncounter())

View File

@ -77,6 +77,11 @@ void CB2_EndSafariBattle(void)
{
SetMainCallback2(CB2_ReturnToField);
}
else if (gBattleOutcome == B_OUTCOME_RAN
|| gBattleOutcome == B_OUTCOME_MON_FLED)
{
SetMainCallback2(CB2_ReturnToField);
}
else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS)
{
RunScriptImmediately(SafariZone_EventScript_OutOfBallsMidBattle);
@ -107,4 +112,8 @@ void CB2_EndSafariBattle(void)
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
}
}
else
{
SetMainCallback2(CB2_ReturnToField);
}
}

View File

@ -8,6 +8,7 @@
#include "field_player_avatar.h"
#include "battle_setup.h"
#include "overworld.h"
#include "pokemon.h"
#include "metatile_behavior.h"
#include "event_scripts.h"
#include "script.h"
@ -512,6 +513,9 @@ bool8 SweetScentWildEncounterWithCount(u8 count)
if (count == 0 || count > 2)
return FALSE;
if (count >= 2 && GetMonsStateToDoubles() != PLAYER_HAS_TWO_USABLE_MONS)
count = 1;
PlayerGetDestCoords(&x, &y);
headerId = GetCurrentMapWildMonHeaderId();
if (headerId != HEADER_NONE)