Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roamer's frostbite status carries over between battles #4822

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,15 @@ struct Roamer
/*0x08*/ u16 species;
/*0x0A*/ u16 hp;
/*0x0C*/ u8 level;
/*0x0D*/ u8 status;
/*0x0D*/ u8 statusA;
/*0x0E*/ u8 cool;
/*0x0F*/ u8 beauty;
/*0x10*/ u8 cute;
/*0x11*/ u8 smart;
/*0x12*/ u8 tough;
/*0x13*/ bool8 active;
/*0x14*/ u8 filler[0x8];
/*0x14*/ u8 statusB; // Stores frostbite
/*0x14*/ u8 filler[0x7];
};

struct RamScriptData
Expand Down
17 changes: 7 additions & 10 deletions src/roamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ static void CreateInitialRoamerMon(bool16 createLatios)

CreateMon(&gEnemyParty[0], ROAMER->species, 40, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0);
ROAMER->level = 40;
ROAMER->status = 0;
ROAMER->statusA = 0;
ROAMER->statusB = 0;
ROAMER->active = TRUE;
ROAMER->ivs = GetMonData(&gEnemyParty[0], MON_DATA_IVS);
ROAMER->personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY);
Expand Down Expand Up @@ -193,18 +194,11 @@ bool8 IsRoamerAt(u8 mapGroup, u8 mapNum)

void CreateRoamerMonInstance(void)
{
u32 status;
u32 status = ROAMER->statusA + (ROAMER->statusB << 8);
struct Pokemon *mon = &gEnemyParty[0];
ZeroEnemyPartyMons();
CreateMonWithIVsPersonality(mon, ROAMER->species, ROAMER->level, ROAMER->ivs, ROAMER->personality);
// The roamer's status field is u8, but SetMonData expects status to be u32, so will set the roamer's status
// using the status field and the following 3 bytes (cool, beauty, and cute).
#ifdef BUGFIX
status = ROAMER->status;
SetMonData(mon, MON_DATA_STATUS, &status);
#else
SetMonData(mon, MON_DATA_STATUS, &ROAMER->status);
#endif
SetMonData(mon, MON_DATA_HP, &ROAMER->hp);
SetMonData(mon, MON_DATA_COOL, &ROAMER->cool);
SetMonData(mon, MON_DATA_BEAUTY, &ROAMER->beauty);
Expand All @@ -228,8 +222,11 @@ bool8 TryStartRoamerEncounter(void)

void UpdateRoamerHPStatus(struct Pokemon *mon)
{
u32 status = GetMonData(mon, MON_DATA_STATUS);

ROAMER->hp = GetMonData(mon, MON_DATA_HP);
ROAMER->status = GetMonData(mon, MON_DATA_STATUS);
ROAMER->statusA = status;
ROAMER->statusB = status >> 8;

RoamerMoveToOtherLocationSet();
}
Expand Down
Loading