Decompile roamer

This commit is contained in:
PikalaxALT
2019-04-11 19:21:10 -04:00
parent 915694e8a7
commit c85f726224
5 changed files with 241 additions and 538 deletions
-531
View File
@@ -1,531 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start ClearRoamerData
ClearRoamerData: @ 8141C54
push {lr}
ldr r0, _08141C84 @ =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, _08141C88 @ =0x000030d0
adds r0, r1
movs r1, 0
movs r2, 0x1C
bl memset
ldr r1, _08141C8C @ =sRoamerLocation
movs r0, 0
strb r0, [r1]
strb r0, [r1, 0x1]
movs r1, 0
movs r2, 0
ldr r0, _08141C90 @ =sLocationHistory
_08141C74:
strb r2, [r0]
strb r2, [r0, 0x1]
adds r0, 0x2
adds r1, 0x1
cmp r1, 0x2
bls _08141C74
pop {r0}
bx r0
.align 2, 0
_08141C84: .4byte gSaveBlock1Ptr
_08141C88: .4byte 0x000030d0
_08141C8C: .4byte sRoamerLocation
_08141C90: .4byte sLocationHistory
thumb_func_end ClearRoamerData
thumb_func_start CreateInitialRoamerMon
CreateInitialRoamerMon: @ 8141C94
push {r4-r7,lr}
sub sp, 0x10
ldr r7, _08141CB0 @ =gEnemyParty
bl ScrSpecial_GetStarter
lsls r0, 16
lsrs r0, 16
cmp r0, 0x1 @ SPECIES_BULBASAUR
beq _08141CB4
cmp r0, 0x4 @ SPECIES_CHARMANDER
beq _08141CB8
movs r6, 0xF3 @ SPECIES_RAIKOU
b _08141CBA
.align 2, 0
_08141CB0: .4byte gEnemyParty
_08141CB4:
movs r6, 0xF4 @ SPECIES_ENTEI
b _08141CBA
_08141CB8:
movs r6, 0xF5 @ SPECIES_SUICUNE
_08141CBA:
movs r0, 0
str r0, [sp]
str r0, [sp, 0x4]
str r0, [sp, 0x8]
str r0, [sp, 0xC]
adds r0, r7, 0
adds r1, r6, 0
movs r2, 0x32
movs r3, 0x20
bl CreateMon
ldr r5, _08141D8C @ =gSaveBlock1Ptr
ldr r1, [r5]
ldr r4, _08141D90 @ =0x000030d0
adds r1, r4
movs r2, 0
strh r6, [r1, 0x8]
movs r0, 0x32
strb r0, [r1, 0xC]
ldr r0, [r5]
adds r0, r4
strb r2, [r0, 0xD]
ldr r0, [r5]
adds r0, r4
movs r1, 0x1
strb r1, [r0, 0x13]
adds r0, r7, 0
movs r1, 0x42
bl GetMonData
ldr r1, [r5]
adds r1, r4
str r0, [r1]
adds r0, r7, 0
movs r1, 0
bl GetMonData
ldr r1, [r5]
adds r1, r4
str r0, [r1, 0x4]
adds r0, r7, 0
movs r1, 0x3A
bl GetMonData
ldr r1, [r5]
adds r1, r4
strh r0, [r1, 0xA]
adds r0, r7, 0
movs r1, 0x16
bl GetMonData
ldr r1, [r5]
adds r1, r4
strb r0, [r1, 0xE]
adds r0, r7, 0
movs r1, 0x17
bl GetMonData
ldr r1, [r5]
adds r1, r4
strb r0, [r1, 0xF]
adds r0, r7, 0
movs r1, 0x18
bl GetMonData
ldr r1, [r5]
adds r1, r4
strb r0, [r1, 0x10]
adds r0, r7, 0
movs r1, 0x21
bl GetMonData
ldr r1, [r5]
adds r1, r4
strb r0, [r1, 0x11]
adds r0, r7, 0
movs r1, 0x2F
bl GetMonData
ldr r1, [r5]
adds r1, r4
strb r0, [r1, 0x12]
ldr r5, _08141D94 @ =sRoamerLocation
movs r0, 0x3
strb r0, [r5]
bl Random
ldr r4, _08141D98 @ =sRoamerLocations
lsls r0, 16
lsrs r0, 16
movs r1, 0x19
bl __umodsi3
lsls r0, 16
lsrs r0, 16
lsls r1, r0, 3
subs r1, r0
adds r1, r4
ldrb r0, [r1]
strb r0, [r5, 0x1]
add sp, 0x10
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08141D8C: .4byte gSaveBlock1Ptr
_08141D90: .4byte 0x000030d0
_08141D94: .4byte sRoamerLocation
_08141D98: .4byte sRoamerLocations
thumb_func_end CreateInitialRoamerMon
thumb_func_start InitRoamer
InitRoamer: @ 8141D9C
push {lr}
bl ClearRoamerData
bl CreateInitialRoamerMon
pop {r0}
bx r0
thumb_func_end InitRoamer
thumb_func_start UpdateLocationHistoryForRoamer
UpdateLocationHistoryForRoamer: @ 8141DAC
ldr r0, _08141DCC @ =sLocationHistory
ldrb r1, [r0, 0x2]
strb r1, [r0, 0x4]
ldrb r1, [r0, 0x3]
strb r1, [r0, 0x5]
ldrb r1, [r0]
strb r1, [r0, 0x2]
ldrb r1, [r0, 0x1]
strb r1, [r0, 0x3]
ldr r1, _08141DD0 @ =gSaveBlock1Ptr
ldr r2, [r1]
ldrb r1, [r2, 0x4]
strb r1, [r0]
ldrb r1, [r2, 0x5]
strb r1, [r0, 0x1]
bx lr
.align 2, 0
_08141DCC: .4byte sLocationHistory
_08141DD0: .4byte gSaveBlock1Ptr
thumb_func_end UpdateLocationHistoryForRoamer
thumb_func_start RoamerMoveToOtherLocationSet
RoamerMoveToOtherLocationSet: @ 8141DD4
push {r4,r5,lr}
ldr r0, _08141E18 @ =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, _08141E1C @ =0x000030d0
adds r0, r1
ldrb r0, [r0, 0x13]
cmp r0, 0
beq _08141E10
ldr r1, _08141E20 @ =sRoamerLocation
movs r0, 0x3
strb r0, [r1]
ldr r5, _08141E24 @ =sRoamerLocations
adds r4, r1, 0
_08141DEE:
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0x19
bl __umodsi3
lsls r0, 16
lsrs r0, 16
lsls r1, r0, 3
subs r1, r0
adds r1, r5
ldrb r1, [r1]
ldrb r0, [r4, 0x1]
cmp r0, r1
beq _08141DEE
strb r1, [r4, 0x1]
_08141E10:
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_08141E18: .4byte gSaveBlock1Ptr
_08141E1C: .4byte 0x000030d0
_08141E20: .4byte sRoamerLocation
_08141E24: .4byte sRoamerLocations
thumb_func_end RoamerMoveToOtherLocationSet
thumb_func_start RoamerMove
RoamerMove: @ 8141E28
push {r4-r7,lr}
movs r4, 0
bl Random
lsls r0, 16
movs r1, 0xF0
lsls r1, 12
ands r1, r0
cmp r1, 0
bne _08141E42
bl RoamerMoveToOtherLocationSet
b _08141EB2
_08141E42:
ldr r0, _08141E94 @ =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, _08141E98 @ =0x000030d0
adds r0, r1
ldrb r0, [r0, 0x13]
cmp r0, 0
beq _08141EB2
ldr r7, _08141E9C @ =sRoamerLocation
_08141E52:
ldr r3, _08141EA0 @ =sRoamerLocations
lsls r0, r4, 3
subs r2, r0, r4
adds r1, r2, r3
ldrb r0, [r7, 0x1]
ldrb r1, [r1]
cmp r0, r1
bne _08141EA8
adds r6, r3, 0
adds r5, r2, 0x1
ldr r4, _08141EA4 @ =sLocationHistory
_08141E68:
bl Random
lsls r0, 16
lsrs r0, 16
movs r1, 0x6
bl __umodsi3
lsls r0, 16
lsrs r0, 16
adds r0, r5
adds r0, r6
ldrb r1, [r0]
ldrb r0, [r4, 0x4]
cmp r0, 0x3
bne _08141E8C
ldrb r0, [r4, 0x5]
cmp r0, r1
beq _08141E68
_08141E8C:
cmp r1, 0xFF
beq _08141E68
strb r1, [r7, 0x1]
b _08141EB2
.align 2, 0
_08141E94: .4byte gSaveBlock1Ptr
_08141E98: .4byte 0x000030d0
_08141E9C: .4byte sRoamerLocation
_08141EA0: .4byte sRoamerLocations
_08141EA4: .4byte sLocationHistory
_08141EA8:
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0x18
bls _08141E52
_08141EB2:
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end RoamerMove
thumb_func_start IsRoamerAt
IsRoamerAt: @ 8141EB8
push {lr}
lsls r0, 24
lsrs r2, r0, 24
lsls r1, 24
lsrs r1, 24
ldr r0, _08141EE4 @ =gSaveBlock1Ptr
ldr r0, [r0]
ldr r3, _08141EE8 @ =0x000030d0
adds r0, r3
ldrb r0, [r0, 0x13]
cmp r0, 0
beq _08141EF0
ldr r0, _08141EEC @ =sRoamerLocation
ldrb r3, [r0]
cmp r2, r3
bne _08141EF0
ldrb r0, [r0, 0x1]
cmp r1, r0
bne _08141EF0
movs r0, 0x1
b _08141EF2
.align 2, 0
_08141EE4: .4byte gSaveBlock1Ptr
_08141EE8: .4byte 0x000030d0
_08141EEC: .4byte sRoamerLocation
_08141EF0:
movs r0, 0
_08141EF2:
pop {r1}
bx r1
thumb_func_end IsRoamerAt
thumb_func_start CreateRoamerMonInstance
CreateRoamerMonInstance: @ 8141EF8
push {r4,r5,lr}
sub sp, 0x4
ldr r5, _08141F84 @ =gEnemyParty
bl ZeroEnemyPartyMons
ldr r4, _08141F88 @ =gSaveBlock1Ptr
ldr r0, [r4]
ldr r1, _08141F8C @ =0x000030d0
adds r0, r1
ldrh r1, [r0, 0x8]
ldrb r2, [r0, 0xC]
ldr r3, [r0]
ldr r0, [r0, 0x4]
str r0, [sp]
adds r0, r5, 0
bl CreateMonWithIVsPersonality
ldr r2, [r4]
ldr r0, _08141F90 @ =0x000030dd
adds r2, r0
adds r0, r5, 0
movs r1, 0x37
bl SetMonData
ldr r2, [r4]
ldr r1, _08141F94 @ =0x000030da
adds r2, r1
adds r0, r5, 0
movs r1, 0x39
bl SetMonData
ldr r2, [r4]
ldr r0, _08141F98 @ =0x000030de
adds r2, r0
adds r0, r5, 0
movs r1, 0x16
bl SetMonData
ldr r2, [r4]
ldr r1, _08141F9C @ =0x000030df
adds r2, r1
adds r0, r5, 0
movs r1, 0x17
bl SetMonData
ldr r2, [r4]
ldr r0, _08141FA0 @ =0x000030e0
adds r2, r0
adds r0, r5, 0
movs r1, 0x18
bl SetMonData
ldr r2, [r4]
ldr r1, _08141FA4 @ =0x000030e1
adds r2, r1
adds r0, r5, 0
movs r1, 0x21
bl SetMonData
ldr r2, [r4]
ldr r0, _08141FA8 @ =0x000030e2
adds r2, r0
adds r0, r5, 0
movs r1, 0x2F
bl SetMonData
add sp, 0x4
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_08141F84: .4byte gEnemyParty
_08141F88: .4byte gSaveBlock1Ptr
_08141F8C: .4byte 0x000030d0
_08141F90: .4byte 0x000030dd
_08141F94: .4byte 0x000030da
_08141F98: .4byte 0x000030de
_08141F9C: .4byte 0x000030df
_08141FA0: .4byte 0x000030e0
_08141FA4: .4byte 0x000030e1
_08141FA8: .4byte 0x000030e2
thumb_func_end CreateRoamerMonInstance
thumb_func_start TryStartRoamerEncounter
TryStartRoamerEncounter: @ 8141FAC
push {lr}
ldr r0, _08141FDC @ =gSaveBlock1Ptr
ldr r1, [r0]
ldrb r0, [r1, 0x4]
ldrb r1, [r1, 0x5]
bl IsRoamerAt
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _08141FE0
bl Random
lsls r0, 16
movs r1, 0xC0
lsls r1, 10
ands r1, r0
cmp r1, 0
bne _08141FE0
bl CreateRoamerMonInstance
movs r0, 0x1
b _08141FE2
.align 2, 0
_08141FDC: .4byte gSaveBlock1Ptr
_08141FE0:
movs r0, 0
_08141FE2:
pop {r1}
bx r1
thumb_func_end TryStartRoamerEncounter
thumb_func_start UpdateRoamerHPStatus
UpdateRoamerHPStatus: @ 8141FE8
push {r4-r6,lr}
adds r6, r0, 0
movs r1, 0x39
bl GetMonData
ldr r5, _08142014 @ =gSaveBlock1Ptr
ldr r1, [r5]
ldr r4, _08142018 @ =0x000030d0
adds r1, r4
strh r0, [r1, 0xA]
adds r0, r6, 0
movs r1, 0x37
bl GetMonData
ldr r1, [r5]
adds r1, r4
strb r0, [r1, 0xD]
bl RoamerMoveToOtherLocationSet
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_08142014: .4byte gSaveBlock1Ptr
_08142018: .4byte 0x000030d0
thumb_func_end UpdateRoamerHPStatus
thumb_func_start SetRoamerInactive
SetRoamerInactive: @ 814201C
ldr r0, _0814202C @ =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, _08142030 @ =0x000030d0
adds r0, r1
movs r1, 0
strb r1, [r0, 0x13]
bx lr
.align 2, 0
_0814202C: .4byte gSaveBlock1Ptr
_08142030: .4byte 0x000030d0
thumb_func_end SetRoamerInactive
thumb_func_start GetRoamerLocation
GetRoamerLocation: @ 8142034
ldr r3, _08142040 @ =sRoamerLocation
ldrb r2, [r3]
strb r2, [r0]
ldrb r0, [r3, 0x1]
strb r0, [r1]
bx lr
.align 2, 0
_08142040: .4byte sRoamerLocation
thumb_func_end GetRoamerLocation
thumb_func_start GetRoamerLocationMapSectionId
GetRoamerLocationMapSectionId: @ 8142044
push {lr}
ldr r0, _08142064 @ =gSaveBlock1Ptr
ldr r0, [r0]
ldr r1, _08142068 @ =0x000030d0
adds r0, r1
ldrb r0, [r0, 0x13]
cmp r0, 0
beq _08142070
ldr r1, _0814206C @ =sRoamerLocation
ldrb r0, [r1]
ldrb r1, [r1, 0x1]
bl get_mapheader_by_bank_and_number
ldrb r0, [r0, 0x14]
b _08142072
.align 2, 0
_08142064: .4byte gSaveBlock1Ptr
_08142068: .4byte 0x000030d0
_0814206C: .4byte sRoamerLocation
_08142070:
movs r0, 0xC5
_08142072:
pop {r1}
bx r1
thumb_func_end GetRoamerLocationMapSectionId
.align 2, 0 @ Don't pad with nop.
-5
View File
@@ -1,5 +0,0 @@
.section .rodata
.align 2
sRoamerLocations:: @ 8466C58
.incbin "baserom.gba", 0x466C58, 0xB8
+1
View File
@@ -6,5 +6,6 @@
u8 GetLeadMonIndex(void);
u8 CountDigits(u16 number);
void TV_PrintIntToStringVar(u8, int);
u16 ScrSpecial_GetStarter(void);
#endif // GUARD_FIELD_SPECIALS_H
+2 -2
View File
@@ -240,7 +240,7 @@ SECTIONS {
asm/itemfinder.o(.text);
asm/buy_menu_helpers.o(.text);
asm/slot_machine.o(.text);
asm/roamer.o(.text);
src/roamer.o(.text);
asm/mystery_gift_menu.o(.text);
asm/link_rfu_4.o(.text);
src/mevent.o(.text);
@@ -395,7 +395,7 @@ SECTIONS {
data/itemfinder.o(.rodata);
data/buy_menu_helpers.o(.rodata);
data/slot_machine.o(.rodata);
data/roamer.o(.rodata);
src/roamer.o(.rodata);
data/mystery_gift_menu.o(.rodata);
data/link_rfu_4.o(.rodata);
src/mevent.o(.rodata);
+238
View File
@@ -0,0 +1,238 @@
#include "global.h"
#include "roamer.h"
#include "random.h"
#include "overworld.h"
#include "field_specials.h"
#include "constants/species.h"
EWRAM_DATA u8 sLocationHistory[3][2] = {};
EWRAM_DATA u8 sRoamerLocation[2] = {};
#define saveRoamer (*(&gSaveBlock1Ptr->roamer))
enum
{
MAP_GRP = 0, // map group
MAP_NUM = 1, // map number
};
const u8 sRoamerLocations[][7] = {
{0x13, 0x14, 0x27, 0x29, 0xff, 0xff, 0xff},
{0x14, 0x13, 0x15, 0x29, 0xff, 0xff, 0xff},
{0x15, 0x14, 0x16, 0xff, 0xff, 0xff, 0xff},
{0x16, 0x15, 0x17, 0x1b, 0x2b, 0xff, 0xff},
{0x17, 0x16, 0x18, 0x19, 0x1a, 0x1b, 0x2b},
{0x18, 0x17, 0x19, 0x1a, 0x1d, 0xff, 0xff},
{0x19, 0x17, 0x18, 0x1a, 0x22, 0xff, 0xff},
{0x1a, 0x17, 0x18, 0x19, 0x1c, 0x1e, 0xff},
{0x1b, 0x16, 0x17, 0x1c, 0x2b, 0xff, 0xff},
{0x1c, 0x1a, 0x1b, 0x1e, 0xff, 0xff, 0xff},
{0x1d, 0x18, 0x1e, 0xff, 0xff, 0xff, 0xff},
{0x1e, 0x1c, 0x1d, 0x1f, 0xff, 0xff, 0xff},
{0x1f, 0x1e, 0x20, 0xff, 0xff, 0xff, 0xff},
{0x20, 0x1f, 0x21, 0xff, 0xff, 0xff, 0xff},
{0x21, 0x20, 0x24, 0x25, 0xff, 0xff, 0xff},
{0x22, 0x19, 0x23, 0xff, 0xff, 0xff, 0xff},
{0x23, 0x22, 0x24, 0xff, 0xff, 0xff, 0xff},
{0x24, 0x21, 0x23, 0x25, 0xff, 0xff, 0xff},
{0x25, 0x21, 0x24, 0x26, 0xff, 0xff, 0xff},
{0x26, 0x25, 0x27, 0xff, 0xff, 0xff, 0xff},
{0x27, 0x13, 0x26, 0xff, 0xff, 0xff, 0xff},
{0x29, 0x13, 0x14, 0x2a, 0xff, 0xff, 0xff},
{0x2a, 0x29, 0x14, 0xff, 0xff, 0xff, 0xff},
{0x2b, 0x16, 0x17, 0x1b, 0xff, 0xff, 0xff},
{0x2c, 0x2b, 0x1b, 0xff, 0xff, 0xff, 0xff},
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
};
void ClearRoamerData(void)
{
u32 i;
gSaveBlock1Ptr->roamer = (struct Roamer){};
sRoamerLocation[MAP_GRP] = 0;
sRoamerLocation[MAP_NUM] = 0;
for (i = 0; i < 3; i++)
{
sLocationHistory[i][MAP_GRP] = 0;
sLocationHistory[i][MAP_NUM] = 0;
}
}
#define GetRoamerSpecies() ({\
u16 a;\
switch (ScrSpecial_GetStarter())\
{\
default:\
a = SPECIES_RAIKOU;\
break;\
case SPECIES_BULBASAUR:\
a = SPECIES_ENTEI;\
break;\
case SPECIES_CHARMANDER:\
a = SPECIES_SUICUNE;\
break;\
}\
a;\
})
void CreateInitialRoamerMon(void)
{
struct Pokemon * tmpMon = &gEnemyParty[0];
u16 roamerMon;
CreateMon(tmpMon, (roamerMon = GetRoamerSpecies()), 50, 0x20, 0, 0, 0, 0);
saveRoamer.species = roamerMon;
saveRoamer.level = 50;
saveRoamer.status = 0;
saveRoamer.active = TRUE;
saveRoamer.ivs = GetMonData(tmpMon, MON_DATA_IVS);
saveRoamer.personality = GetMonData(tmpMon, MON_DATA_PERSONALITY);
saveRoamer.hp = GetMonData(tmpMon, MON_DATA_MAX_HP);
saveRoamer.cool = GetMonData(tmpMon, MON_DATA_COOL);
saveRoamer.beauty = GetMonData(tmpMon, MON_DATA_BEAUTY);
saveRoamer.cute = GetMonData(tmpMon, MON_DATA_CUTE);
saveRoamer.smart = GetMonData(tmpMon, MON_DATA_SMART);
saveRoamer.tough = GetMonData(tmpMon, MON_DATA_TOUGH);
sRoamerLocation[MAP_GRP] = 3;
sRoamerLocation[MAP_NUM] = sRoamerLocations[Random() % (ARRAY_COUNT(sRoamerLocations) - 1)][0];
}
void InitRoamer(void)
{
ClearRoamerData();
CreateInitialRoamerMon();
}
void UpdateLocationHistoryForRoamer(void)
{
sLocationHistory[2][MAP_GRP] = sLocationHistory[1][MAP_GRP];
sLocationHistory[2][MAP_NUM] = sLocationHistory[1][MAP_NUM];
sLocationHistory[1][MAP_GRP] = sLocationHistory[0][MAP_GRP];
sLocationHistory[1][MAP_NUM] = sLocationHistory[0][MAP_NUM];
sLocationHistory[0][MAP_GRP] = gSaveBlock1Ptr->location.mapGroup;
sLocationHistory[0][MAP_NUM] = gSaveBlock1Ptr->location.mapNum;
}
void RoamerMoveToOtherLocationSet(void)
{
u8 mapNum = 0;
struct Roamer *roamer = &saveRoamer;
if (!roamer->active)
return;
sRoamerLocation[MAP_GRP] = 3;
while (1)
{
mapNum = sRoamerLocations[Random() % (ARRAY_COUNT(sRoamerLocations) - 1)][0];
if (sRoamerLocation[MAP_NUM] != mapNum)
{
sRoamerLocation[MAP_NUM] = mapNum;
return;
}
}
}
void RoamerMove(void)
{
u8 locSet = 0;
if ((Random() % 16) == 0)
{
RoamerMoveToOtherLocationSet();
}
else
{
struct Roamer *roamer = &saveRoamer;
if (!roamer->active)
return;
while (locSet < (ARRAY_COUNT(sRoamerLocations) - 1))
{
if (sRoamerLocation[MAP_NUM] == sRoamerLocations[locSet][0])
{
u8 mapNum;
while (1)
{
mapNum = sRoamerLocations[locSet][(Random() % 6) + 1];
if (!(sLocationHistory[2][MAP_GRP] == 3 && sLocationHistory[2][MAP_NUM] == mapNum) && mapNum != 0xFF)
break;
}
sRoamerLocation[MAP_NUM] = mapNum;
return;
}
locSet++;
}
}
}
bool8 IsRoamerAt(u8 mapGroup, u8 mapNum)
{
struct Roamer *roamer = &saveRoamer;
if (roamer->active && mapGroup == sRoamerLocation[MAP_GRP] && mapNum == sRoamerLocation[MAP_NUM])
return TRUE;
else
return FALSE;
}
void CreateRoamerMonInstance(void)
{
struct Pokemon *mon;
struct Roamer *roamer;
mon = &gEnemyParty[0];
ZeroEnemyPartyMons();
roamer = &saveRoamer;
CreateMonWithIVsPersonality(mon, roamer->species, roamer->level, roamer->ivs, roamer->personality);
SetMonData(mon, MON_DATA_STATUS, &gSaveBlock1Ptr->roamer.status);
SetMonData(mon, MON_DATA_HP, &gSaveBlock1Ptr->roamer.hp);
SetMonData(mon, MON_DATA_COOL, &gSaveBlock1Ptr->roamer.cool);
SetMonData(mon, MON_DATA_BEAUTY, &gSaveBlock1Ptr->roamer.beauty);
SetMonData(mon, MON_DATA_CUTE, &gSaveBlock1Ptr->roamer.cute);
SetMonData(mon, MON_DATA_SMART, &gSaveBlock1Ptr->roamer.smart);
SetMonData(mon, MON_DATA_TOUGH, &gSaveBlock1Ptr->roamer.tough);
}
bool8 TryStartRoamerEncounter(void)
{
if (IsRoamerAt(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum) == TRUE && (Random() % 4) == 0)
{
CreateRoamerMonInstance();
return TRUE;
}
else
{
return FALSE;
}
}
void UpdateRoamerHPStatus(struct Pokemon *mon)
{
saveRoamer.hp = GetMonData(mon, MON_DATA_HP);
saveRoamer.status = GetMonData(mon, MON_DATA_STATUS);
RoamerMoveToOtherLocationSet();
}
void SetRoamerInactive(void)
{
struct Roamer *roamer = &saveRoamer;
roamer->active = FALSE;
}
void GetRoamerLocation(u8 *mapGroup, u8 *mapNum)
{
*mapGroup = sRoamerLocation[MAP_GRP];
*mapNum = sRoamerLocation[MAP_NUM];
}
u16 GetRoamerLocationMapSectionId(void)
{
struct Roamer *roamer = &saveRoamer;
if (!saveRoamer.active)
return 0xC5;
return get_mapheader_by_bank_and_number(sRoamerLocation[MAP_GRP], sRoamerLocation[MAP_NUM])->regionMapSectionId;
}