start ground lives

This commit is contained in:
DizzyEggg
2025-05-17 14:54:56 +02:00
parent 68fa1faa6a
commit 927f9c1a0e
5 changed files with 302 additions and 551 deletions

View File

@@ -5,537 +5,11 @@
.text
thumb_func_start GroundLives_CancelBlank_1
GroundLives_CancelBlank_1:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x8
ldr r1, _080A7A70
movs r0, 0
bl Log
movs r6, 0
ldr r0, _080A7A74
ldr r4, [r0]
movs r0, 0x1
negs r0, r0
mov r8, r0
movs r1, 0xA2
lsls r1, 1
adds r5, r4, r1
mov r7, sp
_080A7A20:
movs r1, 0x2
ldrsh r0, [r4, r1]
cmp r0, r8
beq _080A7A50
ldr r0, [r5]
ldr r1, [r4, 0x14]
adds r0, r1
str r0, [sp]
ldr r0, [r5, 0x4]
ldr r1, [r4, 0x18]
adds r0, r1
str r0, [r7, 0x4]
movs r1, 0xB8
lsls r1, 1
adds r0, r4, r1
mov r1, sp
bl IsOnscreen_80A675C
lsls r0, 24
cmp r0, 0
bne _080A7A50
adds r0, r6, 0
bl GroundLives_Delete
_080A7A50:
adds r0, r6, 0x1
lsls r0, 16
asrs r6, r0, 16
movs r0, 0xF8
lsls r0, 1
adds r5, r0
adds r4, r0
cmp r6, 0x17
ble _080A7A20
add sp, 0x8
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080A7A70: .4byte gUnknown_81180D8
_080A7A74: .4byte gGroundLives
thumb_func_end GroundLives_CancelBlank_1
thumb_func_start GroundLives_CancelBlank_2
GroundLives_CancelBlank_2:
push {r4-r7,lr}
ldr r1, _080A7AC0
movs r0, 0
bl Log
movs r6, 0
ldr r0, _080A7AC4
ldr r4, [r0]
movs r7, 0x1
negs r7, r7
movs r0, 0x9F
lsls r0, 1
adds r5, r4, r0
_080A7A92:
movs r1, 0x2
ldrsh r0, [r4, r1]
cmp r0, r7
beq _080A7ACC
movs r1, 0x8E
lsls r1, 1
adds r0, r4, r1
ldr r0, [r0]
movs r1, 0x80
lsls r1, 4
ands r0, r1
cmp r0, 0
beq _080A7AC8
movs r0, 0xA2
lsls r0, 1
adds r1, r4, r0
adds r0, 0x8
adds r2, r4, r0
movs r0, 0x20
bl FindGroundEvent
b _080A7ACA
.align 2, 0
_080A7AC0: .4byte gUnknown_81180D8
_080A7AC4: .4byte gGroundLives
_080A7AC8:
ldr r0, _080A7AE4
_080A7ACA:
strh r0, [r5]
_080A7ACC:
adds r0, r6, 0x1
lsls r0, 16
asrs r6, r0, 16
movs r1, 0xF8
lsls r1, 1
adds r5, r1
adds r4, r1
cmp r6, 0x17
ble _080A7A92
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080A7AE4: .4byte 0x0000ffff
thumb_func_end GroundLives_CancelBlank_2
thumb_func_start sub_80A7AE8
sub_80A7AE8:
push {r4-r7,lr}
sub sp, 0x4
mov r1, sp
strh r0, [r1]
mov r0, sp
bl sub_80A7B94
mov r0, sp
movs r1, 0
ldrsh r2, [r0, r1]
movs r0, 0x1
negs r0, r0
cmp r2, r0
beq _080A7B34
movs r3, 0
ldr r0, _080A7B24
ldr r1, [r0]
adds r4, r2, 0
movs r2, 0x80
lsls r2, 9
adds r6, r2, 0
movs r5, 0xF8
lsls r5, 1
_080A7B16:
movs r7, 0x2
ldrsh r0, [r1, r7]
cmp r0, r4
bne _080A7B28
adds r0, r3, 0
b _080A7B38
.align 2, 0
_080A7B24: .4byte gGroundLives
_080A7B28:
adds r0, r2, 0
adds r2, r6
asrs r3, r0, 16
adds r1, r5
cmp r3, 0x17
ble _080A7B16
_080A7B34:
movs r0, 0x1
negs r0, r0
_080A7B38:
add sp, 0x4
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80A7AE8
thumb_func_start sub_80A7B40
sub_80A7B40:
push {r4-r7,lr}
lsls r0, 16
asrs r4, r0, 16
movs r3, 0
ldr r0, _080A7B70
ldr r1, [r0]
movs r6, 0x1
negs r6, r6
movs r2, 0x80
lsls r2, 9
movs r5, 0x9E
lsls r5, 1
_080A7B58:
movs r7, 0x2
ldrsh r0, [r1, r7]
cmp r0, r6
beq _080A7B74
adds r0, r1, r5
movs r7, 0
ldrsh r0, [r0, r7]
cmp r0, r4
bne _080A7B74
adds r0, r3, 0
b _080A7B8C
.align 2, 0
_080A7B70: .4byte gGroundLives
_080A7B74:
adds r0, r2, 0
movs r3, 0x80
lsls r3, 9
adds r2, r3
asrs r3, r0, 16
movs r7, 0xF8
lsls r7, 1
adds r1, r7
cmp r3, 0x17
ble _080A7B58
movs r0, 0x1
negs r0, r0
_080A7B8C:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80A7B40
thumb_func_start sub_80A7B94
sub_80A7B94:
push {r4-r7,lr}
sub sp, 0x10
adds r7, r0, 0
movs r0, 0
ldrsh r2, [r7, r0]
lsls r0, r2, 1
adds r0, r2
lsls r0, 2
ldr r1, _080A7BD4
adds r0, r1
movs r6, 0x1
negs r6, r6
movs r1, 0
ldrsh r5, [r0, r1]
cmp r5, 0x1
bne _080A7C14
adds r0, r2, 0
cmp r0, 0
bne _080A7C10
movs r0, 0
movs r1, 0x1C
bl GetScriptVarValue
adds r4, r0, 0
cmp r4, 0x1
beq _080A7BDE
cmp r4, 0x1
bgt _080A7BD8
cmp r4, 0
beq _080A7BF2
b _080A7C08
.align 2, 0
_080A7BD4: .4byte gGroundLivesTypeData_811E63C
_080A7BD8:
cmp r4, 0x2
beq _080A7BE4
b _080A7C08
_080A7BDE:
movs r0, 0x2
strh r0, [r7]
b _080A7C10
_080A7BE4:
bl GetPlayerPokemonStruct
adds r6, r0, 0
bl sub_808D3BC
cmp r0, r6
bne _080A7BF6
_080A7BF2:
strh r5, [r7]
b _080A7C10
_080A7BF6:
bl sub_808D3F8
cmp r0, r6
bne _080A7C02
strh r4, [r7]
b _080A7C10
_080A7C02:
movs r0, 0x3
strh r0, [r7]
b _080A7C10
_080A7C08:
movs r1, 0x1
negs r1, r1
adds r0, r1, 0
b _080A7DAC
_080A7C10:
movs r6, 0
b _080A7DD2
_080A7C14:
cmp r5, 0x2
bne _080A7CD2
movs r0, 0
movs r1, 0x1D
bl GetScriptVarValue
adds r4, r0, 0
movs r0, 0
movs r1, 0x1E
bl GetScriptVarValue
adds r2, r0, 0
ldrh r1, [r7]
subs r0, r1, 0x4
lsls r0, 16
lsrs r0, 16
cmp r0, 0x1
bhi _080A7C82
cmp r1, 0x4
bne _080A7C44
adds r0, r4, 0
cmp r0, 0
bne _080A7C4C
b _080A7C4A
_080A7C44:
movs r0, 0
cmp r4, 0
beq _080A7C4C
_080A7C4A:
adds r0, r2, 0
_080A7C4C:
cmp r0, 0x2
beq _080A7C7A
cmp r0, 0x2
bhi _080A7C5A
cmp r0, 0x1
beq _080A7C6E
b _080A7DA6
_080A7C5A:
cmp r0, 0x3
beq _080A7C60
b _080A7DA6
_080A7C60:
bl GetPlayerPokemonStruct
adds r4, r0, 0
bl sub_808D3BC
cmp r0, r4
bne _080A7C72
_080A7C6E:
movs r0, 0x6
b _080A7C80
_080A7C72:
bl sub_808D3F8
cmp r0, r4
bne _080A7C7E
_080A7C7A:
movs r0, 0x7
b _080A7C80
_080A7C7E:
movs r0, 0x8
_080A7C80:
strh r0, [r7]
_080A7C82:
movs r0, 0
ldrsh r5, [r7, r0]
cmp r5, 0x7
beq _080A7CB0
cmp r5, 0x7
bgt _080A7C94
cmp r5, 0x6
beq _080A7C9A
b _080A7CCA
_080A7C94:
cmp r5, 0x8
beq _080A7CC6
b _080A7CCA
_080A7C9A:
movs r6, 0x2
bl GetPlayerPokemonStruct
adds r4, r0, 0
bl sub_808D3BC
cmp r4, r0
beq _080A7CAC
b _080A7DD2
_080A7CAC:
strh r5, [r7]
b _080A7DD2
_080A7CB0:
movs r6, 0x1
bl GetPlayerPokemonStruct
adds r4, r0, 0
bl sub_808D3F8
cmp r4, r0
beq _080A7CC2
b _080A7DD2
_080A7CC2:
movs r0, 0x6
b _080A7DD0
_080A7CC6:
movs r6, 0x2
b _080A7DD2
_080A7CCA:
movs r1, 0x1
negs r1, r1
adds r0, r1, 0
b _080A7DAC
_080A7CD2:
cmp r5, 0x3
bne _080A7DB0
ldrh r1, [r7]
adds r0, r1, 0
subs r0, 0xA
lsls r0, 16
lsrs r0, 16
cmp r0, 0x3
bhi _080A7D12
adds r4, r2, 0
subs r4, 0xA
bl sub_8098F88
lsls r0, 24
cmp r0, 0
bne _080A7DD2
movs r0, 0x9
bl sub_80023E4
lsls r0, 24
cmp r0, 0
beq _080A7D06
mov r0, sp
bl sub_808D6A4
b _080A7D0C
_080A7D06:
mov r0, sp
bl sub_808D654
_080A7D0C:
cmp r4, r0
bge _080A7DA6
b _080A7D7E
_080A7D12:
adds r0, r1, 0
subs r0, 0xE
lsls r0, 16
lsrs r0, 16
cmp r0, 0xF
bhi _080A7DA6
movs r0, 0
movs r1, 0x10
bl GetScriptVarValue
lsls r0, 16
asrs r0, 16
bl sub_8002658
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0
beq _080A7DA6
movs r2, 0
ldrsh r0, [r7, r2]
adds r4, r0, 0
subs r4, 0xE
adds r0, r1, 0
mov r1, sp
movs r2, 0
movs r3, 0
bl GetFriendAreaCapacity2
mov r0, sp
movs r1, 0
ldrsh r0, [r0, r1]
cmp r4, r0
bge _080A7DA6
ldr r2, _080A7D84
ldr r0, [sp, 0x8]
adds r0, r4
movs r1, 0x58
muls r1, r0
ldr r0, [r2]
adds r4, r0, r1
movs r0, 0x9
bl sub_80023E4
lsls r0, 24
cmp r0, 0
beq _080A7D88
ldrb r1, [r4]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _080A7DA6
ldrb r0, [r4, 0x2]
cmp r0, 0
bne _080A7DA6
_080A7D7E:
movs r0, 0x1
negs r0, r0
b _080A7DD4
.align 2, 0
_080A7D84: .4byte gRecruitedPokemonRef
_080A7D88:
ldrb r1, [r4]
movs r0, 0x1
ands r0, r1
cmp r0, 0
beq _080A7DA6
ldrb r0, [r4, 0x2]
cmp r0, 0
bne _080A7DA6
movs r1, 0
ldrb r0, [r4, 0x4]
cmp r0, 0x41
bne _080A7DA2
movs r1, 0x1
_080A7DA2:
cmp r1, 0
beq _080A7D7E
_080A7DA6:
movs r2, 0x1
negs r2, r2
adds r0, r2, 0
_080A7DAC:
strh r0, [r7]
b _080A7D7E
_080A7DB0:
cmp r2, 0x23
bne _080A7DD2
bl GetPlayerPokemonStruct
adds r4, r0, 0
bl sub_808D3BC
cmp r0, r4
bne _080A7DC6
movs r0, 0x21
b _080A7DD0
_080A7DC6:
bl sub_808D3F8
cmp r0, r4
bne _080A7DD2
movs r0, 0x22
_080A7DD0:
strh r0, [r7]
_080A7DD2:
adds r0, r6, 0
_080A7DD4:
add sp, 0x10
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80A7B94
thumb_func_start sub_80A7DDC
sub_80A7DDC:

8
include/ground_event.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef GUARD_GROUND_EVENT_H
#define GUARD_GROUND_EVENT_H
#include "structs/str_position.h"
s16 FindGroundEvent(u32 flags, PixelPos *arg1, PixelPos *arg2);
#endif // GUARD_GROUND_EVENT_H

View File

@@ -66,6 +66,7 @@ typedef struct unkStruct_3001B7C
void GroundSprite_Reset(s32);
void GroundSprite_ExtendPaletteAdd(struct UnkGroundSpriteStruct *ptr, u16);
void GroundSprite_ExtendPaletteDelete(struct UnkGroundSpriteStruct *ptr);
bool8 IsOnscreen_80A675C(struct UnkGroundSpriteStruct *ptr, PixelPos *pixPosArg);
void sub_80A67CC(struct UnkGroundSpriteStruct *ptr, struct UnkGroundSpriteSubStructx48 *a1, s32 a2);
void sub_80A68A0(struct UnkGroundSpriteStruct *ptr);
void sub_80A6EFC(struct UnkGroundSpriteStruct *ptr, s32 a1_, s32 a2_);

View File

@@ -1,5 +1,6 @@
#include "global.h"
#include "globaldata.h"
#include "ground_event.h"
#include "ground_script.h"
#include "debug.h"
#include "memory.h"
@@ -230,17 +231,17 @@ bool8 sub_80ADC64(s32 id, ScriptInfoSmall *dst)
}
}
s16 FindGroundEvent(u32 flags, s32 *arg1, s32 *arg2)
s16 FindGroundEvent(u32 flags, PixelPos *arg1, PixelPos *arg2)
{
s32 i;
GroundEvent *ptr = &gGroundEvents[0];
for (i = 0; i < 0x20; i = (s16)(i + 1), ptr++) {
if (ptr->unk2 != -1
&& (ptr->unk8 & flags)
&& ptr->unkC < arg2[0]
&& ptr->unk14 > arg1[0]
&& ptr->unk10 < arg2[1]
&& ptr->unk18 > arg1[1])
&& ptr->unkC < arg2->x
&& ptr->unk14 > arg1->x
&& ptr->unk10 < arg2->y
&& ptr->unk18 > arg1->y)
{
return i;
}
@@ -249,19 +250,19 @@ s16 FindGroundEvent(u32 flags, s32 *arg1, s32 *arg2)
return -1;
}
UNUSED static s16 UnusedFindGroundEvent(u32 flags, s32 *arg1, s32 *arg2)
UNUSED static s16 UnusedFindGroundEvent(u32 flags, PixelPos *arg1, PixelPos *arg2)
{
s32 i;
GroundEvent *ptr = &gGroundEvents[0];
for (i = 0; i < 0x20; i = (s16)(i + 1), ptr++) {
if (ptr->unk2 != -1 && (ptr->unk8 & flags)) {
struct TestStruct r = {0};
r.unk0 = (ptr->unkC + ptr->unk14) / 2;
r.unk4 = (ptr->unk10 + ptr->unk18) / 2;
if (r.unk0 < arg2[0]
&& r.unk0 > arg1[0]
&& r.unk4 < arg2[1]
&& r.unk4 > arg1[1])
PixelPos resultPos = {0};
resultPos.x = (ptr->unkC + ptr->unk14) / 2;
resultPos.y = (ptr->unk10 + ptr->unk18) / 2;
if (resultPos.x < arg2->x
&& resultPos.x > arg1->x
&& resultPos.y < arg2->y
&& resultPos.y > arg1->y)
{
return i;
}

View File

@@ -1,6 +1,13 @@
#include "global.h"
#include "ground_script.h"
#include "ground_sprite.h"
#include "ground_event.h"
#include "ground_lives.h"
#include "ground_main.h"
#include "memory.h"
#include "event_flag.h"
#include "pokemon.h"
#include "friend_area.h"
struct GroundLivesMeta_Sub1
{
@@ -28,12 +35,25 @@ struct unkStruct_3001B84_sub
s16 unk2;
s16 unk4;
s8 unk6;
u8 unk8[0x1F0 - 0x8];
u8 fill8[0x14 - 0x8];
PixelPos unk14;
u8 fill1C[0x11C-0x1C];
u32 unk11C;
u8 fill120[0x13C - 0x120];
s16 unk13C;
s16 unk13E;
u8 fill140[4];
PixelPos unk144;
PixelPos unk14C;
u8 fill14C[0x170-0x154];
struct UnkGroundSpriteStruct unk170;
};
#define UNK_3001B84_ARR_COUNT 0x18
struct unkStruct_3001B84
{
struct unkStruct_3001B84_sub array[0x18];
struct unkStruct_3001B84_sub array[UNK_3001B84_ARR_COUNT];
};
IWRAM_INIT struct unkStruct_3001B84 *gGroundLives = NULL;
@@ -54,7 +74,7 @@ void AllocGroundLives(void)
gGroundLivesMeta = MemoryAlloc(sizeof(struct unkStruct_3001B80),6);
gGroundLives = MemoryAlloc(sizeof(struct unkStruct_3001B84),6);
for(index = 0, ptr = &gGroundLives->array[index]; index < 0x18; index = (s16)(index + 1), ptr++)
for(index = 0, ptr = &gGroundLives->array[index]; index < UNK_3001B84_ARR_COUNT; index = (s16)(index + 1), ptr++)
{
ptr->unk2 = -1;
}
@@ -63,26 +83,25 @@ void AllocGroundLives(void)
DeleteGroundLives();
}
void DeleteGroundLives(void)
{
int index;
struct unkStruct_3001B84_sub *iVar4;
struct GroundLivesMeta_Sub1 *ptr;
iVar4 = &gGroundLives->array[0];
for(index = 0; index < 0x18; index = (s16)(index + 1), iVar4++)
for(index = 0; index < UNK_3001B84_ARR_COUNT; index = (s16)(index + 1), iVar4++)
{
if (iVar4->unk2 != -1) {
GroundLives_Delete(index);
}
}
gGroundLivesMeta->unk24 = -1;
gGroundLivesMeta->unk24 = -1;
gGroundLivesMeta->unk28 = -1;
for(index = 0; index < 3; ptr++, index++)
{
ptr = &gGroundLivesMeta->unk0[index];
@@ -90,7 +109,7 @@ void DeleteGroundLives(void)
ptr->unk0 = 0;
ptr->unk4 = 0;
}
for(index = 0; index < 0x40; ptr++, index++)
{
@@ -155,10 +174,258 @@ void GroundLives_Cancel(s32 scriptID, s32 sector)
index = 0;
ptr = &gGroundLives->array[0];
for(; index < 0x18; index = (s16)(index + 1), ptr++)
for(; index < UNK_3001B84_ARR_COUNT; index = (s16)(index + 1), ptr++)
{
if((ptr->unk2 != -1) && (ptr->unk4 == scriptID_s32))
if(sector_s32 < 0 || ptr->unk6 == sector_s32)
GroundLives_Delete(index);
}
}
extern const char gUnknown_81180D8[];
void GroundLives_CancelBlank_1(void)
{
s32 i;
struct unkStruct_3001B84_sub *ptr;
Log(0, gUnknown_81180D8);
for (i = 0, ptr = &gGroundLives->array[0]; i < UNK_3001B84_ARR_COUNT; i = (s16)(i + 1), ptr++) {
if (ptr->unk2 != -1) {
PixelPos pixelPos;
pixelPos.x = ptr->unk144.x + ptr->unk14.x;
pixelPos.y = ptr->unk144.y + ptr->unk14.y;
if (!IsOnscreen_80A675C(&ptr->unk170, &pixelPos)) {
GroundLives_Delete(i);
}
}
}
}
void GroundLives_CancelBlank_2(void)
{
s32 i;
struct unkStruct_3001B84_sub *ptr;
Log(0, gUnknown_81180D8);
for (i = 0, ptr = &gGroundLives->array[0]; i < UNK_3001B84_ARR_COUNT; i = (s16)(i + 1), ptr++) {
if (ptr->unk2 != -1) {
if (ptr->unk11C & 0x800) {
ptr->unk13E = FindGroundEvent(0x20, &ptr->unk144, &ptr->unk14C);
}
else {
ptr->unk13E = -1;
}
}
}
}
s32 sub_80A7B94(s16 *a0);
s16 sub_80A7AE8(s16 a0)
{
s32 i;
struct unkStruct_3001B84_sub *ptr;
s16 sp = a0;
sub_80A7B94(&sp);
if (sp != -1) {
for (i = 0, ptr = &gGroundLives->array[0]; i < UNK_3001B84_ARR_COUNT; i = (s16)(i + 1), ptr++) {
if (ptr->unk2 == sp) {
return i;
}
}
}
return -1;
}
UNUSED static s16 sub_80A7B40(s32 a0_)
{
s32 i;
struct unkStruct_3001B84_sub *ptr;
s32 a0 = (s16) a0_;
for (i = 0, ptr = &gGroundLives->array[0]; i < UNK_3001B84_ARR_COUNT; i = (s16)(i + 1), ptr++) {
if (ptr->unk2 != -1 && ptr->unk13C == a0) {
return i;
}
}
return -1;
}
struct GroundLiveTypeData
{
s16 unk0;
u8 fill2[4];
const char *unk4;
};
extern const struct GroundLiveTypeData gGroundLivesTypeData_811E63C[];
extern s32 sub_808D6A4(s32 *ptr);
extern s32 sub_808D654(s32 *ptr);
s32 sub_80A7B94(s16 *a0)
{
s32 id = *a0;
const struct GroundLiveTypeData *dataPtr = &gGroundLivesTypeData_811E63C[id];
s32 ret = -1;
if (dataPtr->unk0 == 1) {
if (*a0 == 0) {
switch (GetScriptVarValue(NULL, PLAYER_KIND)) {
case 0:
*a0 = 1;
break;
case 1:
*a0 = 2;
break;
case 2: {
PokemonStruct1 *playerMonStruct = GetPlayerPokemonStruct();
if (sub_808D3BC() == playerMonStruct) {
*a0 = 1;
}
else if (sub_808D3F8() == playerMonStruct) {
*a0 = 2;
}
else {
*a0 = 3;
}
break;
default:
*a0 = -1;
return -1;
}
}
}
ret = 0;
}
else if (dataPtr->unk0 == 2) {
u32 partner;
s32 partner1 = GetScriptVarValue(NULL, PARTNER1_KIND);
s32 partner2 = GetScriptVarValue(NULL, PARTNER2_KIND);
if (*a0 == 4 || *a0 == 5) {
if (*a0 == 4) {
partner = partner1;
if (partner == 0) {
partner = partner2;
}
}
else {
partner = 0;
if (partner1 != 0) {
partner = partner2;
}
}
switch (partner) {
case 1:
*a0 = 6;
break;
case 2:
*a0 = 7;
break;
case 3: {
PokemonStruct1 *playerMonStruct = GetPlayerPokemonStruct();
if (sub_808D3BC() == playerMonStruct) {
*a0 = 6;
}
else if (sub_808D3F8() == playerMonStruct) {
*a0 = 7;
}
else {
*a0 = 8;
}
break;
default:
*a0 = -1;
return -1;
}
}
}
switch (*a0) {
case 6:
ret = 2;
if (GetPlayerPokemonStruct() == sub_808D3BC()) {
*a0 = 6;
}
break;
case 7:
ret = 1;
if (GetPlayerPokemonStruct() == sub_808D3F8()) {
*a0 = 6;
}
break;
case 8:
ret = 2;
break;
default:
*a0 = -1;
return -1;
}
}
else if (dataPtr->unk0 == 3) {
if (*a0 >= 10 && *a0 <= 13) {
s32 val;
s32 sp[4];
s32 id = *a0 - 10;
if (sub_8098F88()) {
return -1;
}
if (sub_80023E4(9)) {
val = sub_808D6A4(sp);
}
else {
val = sub_808D654(sp);
}
if (id < val) {
return -1;
}
}
else if (*a0 >= 14 && *a0 <= 29) {
FriendAreaCapacity fAreaCapacity;
u8 map = sub_8002658(GetScriptVarValue(NULL, GROUND_MAP));
if (map != 0) {
s32 id = *a0 - 14;
GetFriendAreaCapacity2(map, &fAreaCapacity, FALSE, FALSE);
if (id < fAreaCapacity.maxPokemon) {
PokemonStruct1 *monStrPtr = &gRecruitedPokemonRef->pokemon[fAreaCapacity.unk8 + id];
if (sub_80023E4(9)) {
if (PokemonFlag1(monStrPtr) && !monStrPtr->isTeamLeader) {
return -1;
}
}
else {
if (PokemonFlag1(monStrPtr) && !monStrPtr->isTeamLeader && !IsMonPartner(monStrPtr)) {
return -1;
}
}
}
}
}
*a0 = -1;
return -1;
}
else if (id == 0x23) {
PokemonStruct1 *playerMonStruct = GetPlayerPokemonStruct();
if (sub_808D3BC() == playerMonStruct) {
*a0 = 0x21;
}
else if (sub_808D3F8() == playerMonStruct) {
*a0 = 0x22;
}
}
return ret;
}
//