diff --git a/asm/code_8080CF0.s b/asm/code_8080CF0.s index a5ef3afb7..3074a9eab 100644 --- a/asm/code_8080CF0.s +++ b/asm/code_8080CF0.s @@ -5,599 +5,6 @@ .text - thumb_func_start sub_8081454 -sub_8081454: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r7, r0, 0 - ldr r1, _08081600 - bl sub_808300C - ldr r4, _08081604 - ldr r0, [r4] - ldr r1, _08081608 - adds r0, r1 - ldrb r1, [r0] - adds r0, r7, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r2, _0808160C - adds r0, r2 - ldrb r1, [r0] - adds r0, r7, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081610 - adds r0, r1 - ldrb r1, [r0] - adds r0, r7, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r2, _08081614 - adds r0, r2 - ldrb r1, [r0] - adds r0, r7, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081618 - adds r0, r1 - ldrb r1, [r0] - adds r0, r7, 0 - bl sub_8083060 - ldr r0, [r4] - ldr r2, _0808161C - adds r0, r2 - ldrb r1, [r0] - adds r0, r7, 0 - bl sub_8083060 - ldr r0, [r4] - ldr r1, _08081620 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r7, 0 - bl sub_8083048 - ldr r0, [r4] - ldr r1, _08081624 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r7, 0 - bl sub_8083048 - ldr r0, [r4] - ldr r1, _08081628 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r7, 0 - bl sub_8083048 - ldr r0, [r4] - ldr r1, _0808162C - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r7, 0 - bl sub_8083048 - ldr r0, [r4] - ldr r1, _08081630 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r7, 0 - bl sub_8083048 - movs r1, 0 - mov r9, r4 -_08081510: - lsls r0, r1, 2 - adds r2, r1, 0x1 - mov r8, r2 - adds r0, r1 - lsls r0, 2 - adds r0, r1 - lsls r0, 6 - ldr r1, _08081634 - adds r6, r0, r1 - movs r5, 0 - movs r4, 0x37 -_08081526: - mov r2, r9 - ldr r1, [r2] - adds r1, r6 - adds r1, r5 - adds r0, r7, 0 - bl sub_8081B60 - adds r5, 0x18 - subs r4, 0x1 - cmp r4, 0 - bge _08081526 - mov r1, r8 - cmp r1, 0x1F - ble _08081510 - ldr r4, _08081604 - ldr r1, [r4] - ldr r0, _08081638 - adds r1, r0 - adds r0, r7, 0 - bl SavePosition - ldr r1, [r4] - ldr r2, _0808163C - adds r1, r2 - adds r0, r7, 0 - bl SavePosition - ldr r6, _08081640 - movs r5, 0x7 -_08081560: - ldr r1, [r4] - adds r1, r6 - adds r0, r7, 0 - bl SavePosition - adds r6, 0x4 - subs r5, 0x1 - cmp r5, 0 - bge _08081560 - ldr r4, _08081604 - ldr r1, [r4] - ldr r0, _08081644 - adds r1, r0 - adds r0, r7, 0 - bl sub_80830F8 - ldr r1, [r4] - ldr r2, _08081648 - adds r1, r2 - adds r0, r7, 0 - bl sub_80830F8 - ldr r1, [r4] - ldr r0, _0808164C - adds r1, r0 - adds r0, r7, 0 - bl sub_808312C - movs r1, 0 - mov r10, r4 -_0808159C: - movs r4, 0 - adds r2, r1, 0x1 - mov r8, r2 - lsls r0, r1, 1 - lsls r2, r1, 3 - mov r9, r2 - adds r0, r1 - lsls r0, 6 - ldr r1, _08081650 - adds r6, r0, r1 - movs r5, 0 -_080815B2: - mov r2, r10 - ldr r1, [r2] - adds r1, r6 - adds r1, r5 - adds r0, r7, 0 - bl sub_8081B60 - mov r1, r10 - ldr r0, [r1] - mov r2, r9 - adds r1, r4, r2 - ldr r2, _08081654 - adds r0, r2 - adds r0, r1 - ldrb r1, [r0] - adds r0, r7, 0 - bl sub_8083060 - adds r5, 0x18 - adds r4, 0x1 - cmp r4, 0x7 - ble _080815B2 - mov r1, r8 - cmp r1, 0x7 - ble _0808159C - ldr r0, _08081604 - ldr r1, [r0] - ldr r0, _08081658 - adds r1, r0 - adds r0, r7, 0 - bl sub_8081B94 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08081600: .4byte gUnknown_81071E0 -_08081604: .4byte gDungeon -_08081608: .4byte 0x00003a08 -_0808160C: .4byte 0x00003a09 -_08081610: .4byte 0x00003a0a -_08081614: .4byte 0x00003a0b -_08081618: .4byte 0x00003a0c -_0808161C: .4byte 0x00003a0d -_08081620: .4byte 0x00003a0e -_08081624: .4byte 0x00003a10 -_08081628: .4byte 0x00003a12 -_0808162C: .4byte 0x00003a14 -_08081630: .4byte 0x00003a16 -_08081634: .4byte 0x00003a18 -_08081638: .4byte 0x0000e218 -_0808163C: .4byte 0x0000e21c -_08081640: .4byte 0x0000e220 -_08081644: .4byte 0x0000e240 -_08081648: .4byte 0x0000e250 -_0808164C: .4byte 0x0000e260 -_08081650: .4byte 0x0000e27c -_08081654: .4byte 0x0000e87c -_08081658: .4byte 0x0000e264 - thumb_func_end sub_8081454 - - thumb_func_start sub_808165C -sub_808165C: - push {r4,r5,lr} - adds r5, r0, 0 - ldr r1, _08081708 - bl sub_808300C - ldr r4, _0808170C - ldr r0, [r4] - ldr r1, _08081710 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_8083060 - ldr r0, [r4] - ldr r1, _08081714 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_8083060 - ldr r0, [r4] - ldr r1, _08081718 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _0808171C - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081720 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081724 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081728 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _0808172C - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081730 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081734 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - ldr r0, [r4] - ldr r1, _08081738 - adds r0, r1 - ldrb r1, [r0] - adds r0, r5, 0 - bl sub_80830B4 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08081708: .4byte gUnknown_81071E0 -_0808170C: .4byte gDungeon -_08081710: .4byte 0x00018208 -_08081714: .4byte 0x00018209 -_08081718: .4byte 0x0001820a -_0808171C: .4byte 0x0001820b -_08081720: .4byte 0x0001820c -_08081724: .4byte 0x0001820d -_08081728: .4byte 0x0001820e -_0808172C: .4byte 0x0001820f -_08081730: .4byte 0x00018210 -_08081734: .4byte 0x00018211 -_08081738: .4byte 0x00018213 - thumb_func_end sub_808165C - - thumb_func_start sub_808173C -sub_808173C: - push {r4,r5,lr} - adds r5, r0, 0 - ldr r4, _08081778 - ldr r0, [r4] - ldr r1, _0808177C - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r5, 0 - bl sub_8083048 - ldr r0, [r4] - ldr r1, _08081780 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r5, 0 - bl sub_8083048 - ldr r0, [r4] - ldr r1, _08081784 - adds r0, r1 - movs r2, 0 - ldrsh r1, [r0, r2] - adds r0, r5, 0 - bl sub_8083048 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_08081778: .4byte gDungeon -_0808177C: .4byte 0x0001ced6 -_08081780: .4byte 0x0001ced8 -_08081784: .4byte 0x0001ceda - thumb_func_end sub_808173C - - thumb_func_start sub_8081788 -sub_8081788: - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - movs r2, 0x1 - bl sub_8082FA8 - adds r1, r5, 0x1 - adds r0, r4, 0 - movs r2, 0x1 - bl sub_8082FA8 - adds r5, 0x2 - adds r0, r4, 0 - adds r1, r5, 0 - movs r2, 0x1 - bl sub_8082FA8 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8081788 - - thumb_func_start sub_80817B0 -sub_80817B0: - push {lr} - sub sp, 0x4 - mov r2, sp - strb r1, [r2] - mov r1, sp - movs r2, 0x1 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_80817B0 - - thumb_func_start sub_80817C8 -sub_80817C8: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - adds r1, r4, 0x2 - movs r2, 0x1 - bl sub_8082FA8 - adds r1, r4, 0 - adds r1, 0x14 - adds r0, r5, 0 - movs r2, 0x1 - bl sub_8082FA8 - adds r4, 0x16 - adds r0, r5, 0 - adds r1, r4, 0 - movs r2, 0x1 - bl sub_8082FA8 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80817C8 - - thumb_func_start sub_80817F4 -sub_80817F4: - push {lr} - sub sp, 0x4 - mov r2, sp - strh r1, [r2] - mov r1, sp - movs r2, 0x2 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_80817F4 - - thumb_func_start sub_808180C -sub_808180C: - push {lr} - sub sp, 0x4 - mov r2, sp - strb r1, [r2] - mov r1, sp - movs r2, 0x1 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_808180C - - thumb_func_start sub_8081824 -sub_8081824: - push {lr} - sub sp, 0x4 - mov r2, sp - strb r1, [r2] - mov r1, sp - movs r2, 0x1 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_8081824 - - thumb_func_start sub_808183C -sub_808183C: - push {lr} - sub sp, 0x4 - mov r2, sp - strb r1, [r2] - mov r1, sp - movs r2, 0x1 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_808183C - - thumb_func_start sub_8081854 -sub_8081854: - push {lr} - sub sp, 0x4 - mov r2, sp - strb r1, [r2] - mov r1, sp - movs r2, 0x1 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_8081854 - - thumb_func_start sub_808186C -sub_808186C: - push {lr} - sub sp, 0x4 - str r1, [sp] - mov r1, sp - movs r2, 0x4 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_808186C - - thumb_func_start sub_8081880 -sub_8081880: - push {lr} - sub sp, 0x4 - mov r2, sp - strb r1, [r2] - mov r1, sp - movs r2, 0x1 - bl sub_8082FA8 - add sp, 0x4 - pop {r0} - bx r0 - thumb_func_end sub_8081880 - - thumb_func_start sub_8081898 -sub_8081898: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r0, 0 - ldrsh r1, [r4, r0] - adds r0, r5, 0 - bl sub_8083048 - ldrb r1, [r4, 0x2] - adds r0, r5, 0 - bl sub_808180C - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8081898 - - thumb_func_start sub_80818B8 -sub_80818B8: - push {lr} - lsls r1, 24 - lsrs r1, 24 - bl sub_8083060 - pop {r0} - bx r0 - thumb_func_end sub_80818B8 - - thumb_func_start sub_80818C8 -sub_80818C8: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - ldrb r1, [r4] - bl sub_8083060 - ldrb r1, [r4, 0x1] - adds r0, r5, 0 - bl sub_8083060 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80818C8 - - thumb_func_start sub_80818E4 -sub_80818E4: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r2, 0x1 - bl sub_8082FA8 - ldrb r1, [r4, 0x1] - adds r0, r5, 0 - bl sub_80830B4 - ldrb r1, [r4, 0x2] - adds r0, r5, 0 - bl sub_80830B4 - ldrb r1, [r4, 0x3] - adds r0, r5, 0 - bl sub_80830B4 - ldrh r1, [r4, 0x4] - adds r0, r5, 0 - bl sub_8083030 - adds r4, 0x10 - adds r0, r5, 0 - adds r1, r4, 0 - bl SavePosition - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80818E4 - - thumb_func_start sub_8081920 -sub_8081920: - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - movs r2, 0x1 - bl sub_8082FA8 - ldrb r1, [r4, 0x1] - adds r0, r5, 0 - bl sub_8083060 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_8081920 - thumb_func_start sub_808193C sub_808193C: push {r4,r5,lr} @@ -2762,6 +2169,8 @@ _08082BB8: .4byte gDungeon _08082BBC: .4byte 0x000135cc thumb_func_end sub_8082B40 +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + thumb_func_start sub_8082BC0 sub_8082BC0: push {lr} diff --git a/include/structs/dungeon_entity.h b/include/structs/dungeon_entity.h index 406cc9c3b..a5c288002 100644 --- a/include/structs/dungeon_entity.h +++ b/include/structs/dungeon_entity.h @@ -41,6 +41,40 @@ typedef struct ActionContainer /* 0x14 */ Position itemTargetPosition; } ActionContainer; +typedef struct HiddenPower +{ + /* 0x0 */ s16 hiddenPowerBasePower; + /* 0x2 */ u8 hiddenPowerType; +} HiddenPower; + +typedef struct JoinedAt +{ + /* 0x0 */ u8 joinedAt; + /* 0x1 */ u8 unk1; +} JoinedAt; + + +typedef struct AITarget +{ + /* 0x0 */ u8 aiObjective; + /* 0x1 */ bool8 aiNotNextToTarget; + /* 0x2 */ bool8 aiTargetingEnemy; + /* 0x3 */ bool8 aiTurningAround; + /* 0x4 */ u16 aiTargetSpawnGenID; + /* 0x8 */ struct Entity *aiTarget; + /* 0xC */ u8 fillC[4]; + /* 0x10 */ Position aiTargetPos; + +} AITarget; + + +typedef struct Sleep +{ + /* 0x0 */ u8 sleep; + /* 0x1 */ u8 sleepTurns; +} Sleep; + + // size: 0x208 typedef struct EntityInfo { @@ -82,24 +116,15 @@ typedef struct EntityInfo /* 0x2C */ s32 offensiveMultipliers[2]; // Index 0 is Defense. Index 1 is Special Defense. /* 0x34 */ s32 defensiveMultipliers[2]; - /* 0x3C */ s16 hiddenPowerBasePower; - /* 0x3E */ u8 hiddenPowerType; - u8 fill3F; - /* 0x40 */ u8 joinedAt; // Uses the dungeon index in dungeon.h. + /* 0x3C */ HiddenPower hiddenPower; + /* 0x40 */ JoinedAt joinedAt; // Uses the dungeon index in dungeon.h. /* 0x44 */ ActionContainer action; /* 0x5C */ u8 types[2]; /* 0x5E */ u8 abilities[2]; /* 0x60 */ Item heldItem; u8 fill64[0x68 - 0x64]; /* 0x68 */ Position prevPos[NUM_PREV_POS]; - /* 0x78 */ u8 aiObjective; - /* 0x79 */ bool8 aiNotNextToTarget; - /* 0x7A */ bool8 aiTargetingEnemy; - /* 0x7B */ bool8 aiTurningAround; - /* 0x7C */ u16 aiTargetSpawnGenID; - /* 0x80 */ struct Entity *aiTarget; - u8 fill84[0x88 - 0x84]; - /* 0x88 */ Position aiTargetPos; + /* 0x78 */ AITarget aiTarget; // Bitwise flags corresponding to selected IQ skills. /* 0x8C */ u8 IQSkillMenuFlags[4]; // IQ skills selected in the IQ skills menu. /* 0x90 */ u8 IQSkillFlags[4]; @@ -112,9 +137,7 @@ typedef struct EntityInfo u8 fillA5[0xA8 - 0xA5]; // Statuses are split into groups based on which ones can't overlap. // See status.h for which statuses are in each group. - /* 0xA8 */ u8 sleep; - /* 0xA9 */ u8 sleepTurns; - u8 fillAA[0xAC - 0xAA]; + /* 0xA8 */ Sleep sleep; /* 0xAC */ u8 nonVolatileStatus; /* 0xAD */ u8 nonVolatileStatusTurns; /* 0xAE */ u8 nonVolatileStatusDamageCountdown; diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index 1cf1889c4..beb041540 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -150,22 +150,25 @@ typedef struct Dungeon /* 0x3904 */ s16 unk3904; u8 fill3906[0x3A08 - 0x3906]; /* 0x3A08 */ u8 unk3A08; - u8 fill3A09[0x3A0C - 0x3A09]; + /* 0x3A09 */ u8 unk3A09; + /* 0x3A0A */ u8 unk3A0A; + /* 0x3A0B */ u8 unk3A0B; u8 unk3A0C; /* 0x3A0D */ u8 unk3A0D; /* 0x3A0E */ s16 tileset; - /* 0x3A10 */ u16 unk3A10; - u8 fill3A10[0x3A14 - 0x3A12]; + /* 0x3A10 */ s16 unk3A10; + /* 0x3A12 */ s16 unk3A12; /* 0x3A14 */ s16 bossBattleIndex; + /* 0x3A16 */ s16 unk3A16; /* 0x3A18 */ Tile tiles[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X]; - u8 fillE218[0xE21C - 0xE218]; - u16 unkE21C; - u16 unkE21E; - Position unkE220[4]; - u8 unkE230[0xE23C - 0xE230]; - s16 unkE23C; // x coord of some kind - s16 unkE23E; // y coord of some kind - u8 fillE240[0xE264 - 0xE240]; + Position unkE218; + Position unkE21C; + Position unkE220[8]; + u32 unkE240; + u8 fillE244[0xE250 - 0xE244]; + u32 unkE250; + u8 fillE254[0xE260 - 0xE254]; + u32 unkE260; /* 0xE264 */ u8 weather; // Uses the weather constants in weather.h. u8 unkE265; // Uses the weather constants in weather.h /* 0xE266 */ u8 weatherDamageCounter; // Timer for applying sandstorm/hail damage periodically. @@ -181,7 +184,8 @@ typedef struct Dungeon /* 0xE279 */ bool8 nullifyWeather; // Air Lock and Cloud Nine toggle this to disable weather effects u8 fillE27A[0xE27C - 0xE27A]; /* 0xE27C */ Tile unkE27C[8][8]; - /* 0xE87C */ u8 fillE87C[68]; + /* 0xE87C */ u8 unkE87C[8][8]; + u32 fillE8BC; /* 0xE8C0 */ Tile *tilePointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X]; u8 unk104C0; /* 0x104C4 */ RoomData roomData[MAX_ROOM_COUNT]; @@ -233,7 +237,10 @@ typedef struct Dungeon u8 unk1820E; u8 unk1820F; /* 0x18210 */ bool8 hallucinating; // Displays Substitute and flower sprites when the player has the Cross-Eyed status. - u8 fill18211[0x18217 - 0x18211]; + u8 unk18211; + u8 unk18212; + u8 unk18213; + u8 fill18214[3]; u8 unk18217; u8 fill18218[0x1821A - 0x18218]; u8 unk1821A; diff --git a/src/code_8041AD0.c b/src/code_8041AD0.c index fa42b5005..bbab3a130 100644 --- a/src/code_8041AD0.c +++ b/src/code_8041AD0.c @@ -204,13 +204,13 @@ void EntityUpdateStatusSprites(Entity *entity) if (entityInfo->id == 0xb9) { // NOTE: clean this up sometime - temp = entityInfo->sleepTurns; + temp = entityInfo->sleep.sleepTurns; flag = 0x7f; temp ^= flag; flag = (temp) != 0; } if (flag) { - spriteStatus = gStatusSpriteMasks_SleepStatus[entityInfo->sleep]; + spriteStatus = gStatusSpriteMasks_SleepStatus[entityInfo->sleep.sleep]; } spriteStatus = spriteStatus | gStatusSpriteMasks_NonVolatileStatus[entityInfo->nonVolatileStatus] | diff --git a/src/code_8048480.c b/src/code_8048480.c index 0b3504657..c2f3adf0b 100644 --- a/src/code_8048480.c +++ b/src/code_8048480.c @@ -746,10 +746,10 @@ void sub_80487CC(Entity *pokemon, Entity * target, u32 param_3, u32 param_4) static inline bool8 JoinLocationCannotUseItems_1(EntityInfo *pokemonInfo) { - if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) return TRUE; - if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) return TRUE; return FALSE; @@ -830,11 +830,11 @@ void nullsub_94(Entity *pokemon, Entity *target, u8 r2) static inline bool8 JoinLocationCannotUseItems_2(EntityInfo *pokemonInfo) { - if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) { return TRUE; } - if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) { return TRUE; } @@ -895,11 +895,11 @@ bool8 sub_8048950(Entity *param_1,Item *item) static inline bool8 JoinLocationCannotUseItems_3(EntityInfo *pokemonInfo) { - if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) { return TRUE; } - if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) { return TRUE; } @@ -972,11 +972,11 @@ bool8 sub_8048A68(Entity *param_1,Item *item) static inline bool8 JoinLocationCannotUseItems_4(EntityInfo *pokemonInfo) { - if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) { return TRUE; } - if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) { return TRUE; } diff --git a/src/code_8057824_1.c b/src/code_8057824_1.c index c4f24ecb7..fa2c3ffb4 100644 --- a/src/code_8057824_1.c +++ b/src/code_8057824_1.c @@ -3815,7 +3815,8 @@ void CreateJirachiWishWarpTile(void) { struct Tile *tile; - tile = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E); + tile = GetTileSafe(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + //tile = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E); tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); tile->terrainType |= TERRAIN_TYPE_IMPASSABLE_WALL; tile->terrainType &= ~TERRAIN_TYPE_STAIRS; @@ -3829,7 +3830,8 @@ void EnableJirachiWishWarpTile(void) { struct Tile *tile; - tile = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E); + tile = GetTileSafe(gDungeon->unkE220[7].x, gDungeon->unkE220[7].y); + //tile = GetTileSafe(gDungeon->unkE23C, gDungeon->unkE23E); tile->terrainType &= ~(TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); tile->terrainType |= TERRAIN_TYPE_NORMAL; tile->terrainType &= ~TERRAIN_TYPE_IMPASSABLE_WALL; diff --git a/src/code_806CD90.c b/src/code_806CD90.c index d6a479ab4..f7c934cd4 100644 --- a/src/code_806CD90.c +++ b/src/code_806CD90.c @@ -151,10 +151,10 @@ u8 sub_806CEBC(Entity *entity) // NOTE: copy needed to match entityInfo1 = entity->info; entityInfo2 = entity->info; - sleep = entityInfo1->sleep; + sleep = entityInfo1->sleep.sleep; if (sleep == STATUS_SLEEP || sleep == STATUS_NAPPING || sleep == STATUS_NIGHTMARE) { - if (entityInfo2->apparentID != MONSTER_SUDOWOODO || entityInfo2->sleepTurns != 0x7F) + if (entityInfo2->apparentID != MONSTER_SUDOWOODO || entityInfo2->sleep.sleepTurns != 0x7F) return 5; else return 7; diff --git a/src/code_80718D8.c b/src/code_80718D8.c index a5028c42d..1ec5cae06 100644 --- a/src/code_80718D8.c +++ b/src/code_80718D8.c @@ -132,11 +132,11 @@ void sub_8071B48(void) static inline bool8 JoinLocationCannotUseItems(EntityInfo *pokemonInfo) { - if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) { return TRUE; } - if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) { return TRUE; } diff --git a/src/code_8077274_1.c b/src/code_8077274_1.c index 632880449..3776602a4 100644 --- a/src/code_8077274_1.c +++ b/src/code_8077274_1.c @@ -1175,7 +1175,7 @@ void SendSleepEndMessage(Entity * pokemon, Entity * target, bool8 param_3, bool8 } entityInfo = target->info; SetMessageArgument(gAvailablePokemonNames,target,0); - switch(entityInfo->sleep) { + switch(entityInfo->sleep.sleep) { case STATUS_NONE: case 6: break; @@ -1197,19 +1197,19 @@ void SendSleepEndMessage(Entity * pokemon, Entity * target, bool8 param_3, bool8 isAsleep = TRUE; sub_80522F4(pokemon,target,*gUnknown_80FA710); HealTargetHP(pokemon,target,gUnknown_80F4F7A, 0, FALSE); - entityInfo->sleep = 0; + entityInfo->sleep.sleep = 0; sub_8079F20(pokemon,target,1,1); break; case STATUS_YAWNING: if (param_3) { - entityInfo->sleep = STATUS_NONE; + entityInfo->sleep.sleep = STATUS_NONE; sub_8075C58(pokemon,target,CalculateStatusTurns(target, gUnknown_80F4F2C, TRUE) + 1, TRUE); return; } sub_80522F4(pokemon,target,*gUnknown_80FA734); break; } - entityInfo->sleep = STATUS_NONE; + entityInfo->sleep.sleep = STATUS_NONE; EntityUpdateStatusSprites(target); if (isAsleep) { sub_806CE68(target,8); @@ -1585,7 +1585,7 @@ void SendMuzzledEndMessage(Entity * pokemon, Entity * target) flag = TRUE; } - if (entityInfo->sleep == 1 && entityInfo->sleepTurns == 0x7f) { + if (entityInfo->sleep.sleep == 1 && entityInfo->sleep.sleepTurns == 0x7f) { SendSleepEndMessage(pokemon,target,0,1); flag = TRUE; } @@ -1636,8 +1636,8 @@ void WakeUpPokemon(Entity * pokemon) EntityInfo *entityInfo; entityInfo = pokemon->info; - entityInfo->sleep = STATUS_NONE; - entityInfo->sleepTurns = 0; + entityInfo->sleep.sleep = STATUS_NONE; + entityInfo->sleep.sleepTurns = 0; sub_806A898(pokemon, 1, 1); EntityUpdateStatusSprites(pokemon); } @@ -1676,8 +1676,8 @@ void sub_807AA30(void) { wildEntity = gDungeon->wildPokemon[wildIndex]; if (EntityExists(wildEntity) && - (entityInfo = wildEntity->info, entityInfo->sleep == STATUS_SLEEP) && - (entityInfo->sleepTurns == 0x7F)) { + (entityInfo = wildEntity->info, entityInfo->sleep.sleep == STATUS_SLEEP) && + (entityInfo->sleep.sleepTurns == 0x7F)) { adjacentCheck = FALSE; forceWakeup = FALSE; room = GetEntityRoom(wildEntity); diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c index 4af9f49bc..26965d032 100644 --- a/src/dungeon_ai.c +++ b/src/dungeon_ai.c @@ -178,7 +178,7 @@ void RunMonsterAI(Entity *pokemon, u32 unused) { return; } - pokemonInfo->aiNotNextToTarget = FALSE; + pokemonInfo->aiTarget.aiNotNextToTarget = FALSE; pokemonInfo->aiNextToTarget = FALSE; pokemonInfo->waiting = FALSE; } diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c index 86910e1a3..f19f01da7 100644 --- a/src/dungeon_ai_item_weight.c +++ b/src/dungeon_ai_item_weight.c @@ -316,9 +316,9 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags) itemWeight = 40; break; case ITEM_SLEEP_SEED: - if (pokemonInfo->sleep != STATUS_SLEEP && - pokemonInfo->sleep != STATUS_NAPPING && - pokemonInfo->sleep != STATUS_NIGHTMARE) + if (pokemonInfo->sleep.sleep != STATUS_SLEEP && + pokemonInfo->sleep.sleep != STATUS_NAPPING && + pokemonInfo->sleep.sleep != STATUS_NIGHTMARE) { if (CanTargetAdjacentPokemon(targetPokemon)) { @@ -335,7 +335,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags) } break; case ITEM_CHESTO_BERRY: - if (pokemonInfo->sleep != STATUS_SLEEPLESS) + if (pokemonInfo->sleep.sleep != STATUS_SLEEPLESS) { itemWeight = 5; } diff --git a/src/dungeon_ai_movement.c b/src/dungeon_ai_movement.c index 8b10caed5..37e4113bd 100644 --- a/src/dungeon_ai_movement.c +++ b/src/dungeon_ai_movement.c @@ -46,9 +46,9 @@ const s32 gFaceDirectionIncrements[] = {0, 1, -1, 2, -2, 3, -3, 4, 0, -1, 1, -2, void MoveIfPossible(Entity *pokemon, bool8 showRunAwayEffect) { EntityInfo *pokemonInfo = pokemon->info; - pokemonInfo->aiNotNextToTarget = FALSE; - pokemonInfo->aiTargetingEnemy = FALSE; - pokemonInfo->aiTurningAround = FALSE; + pokemonInfo->aiTarget.aiNotNextToTarget = FALSE; + pokemonInfo->aiTarget.aiTargetingEnemy = FALSE; + pokemonInfo->aiTarget.aiTurningAround = FALSE; if (HasTactic(pokemon, TACTIC_BE_PATIENT)) { u32 maxHPStat = pokemonInfo->maxHPStat; @@ -229,11 +229,11 @@ bool8 ChooseTargetPosition(Entity *pokemon) } if (targetIndex > -1) { - pokemonInfo->aiObjective = AI_CHASE_TARGET; - pokemonInfo->aiTargetPos = possibleTargets[targetIndex]->pos; - pokemonInfo->aiTarget = possibleTargets[targetIndex]; - pokemonInfo->aiTargetSpawnGenID = pokemonInfo->aiTarget->spawnGenID; - pokemonInfo->aiTargetingEnemy = TRUE; + pokemonInfo->aiTarget.aiObjective = AI_CHASE_TARGET; + pokemonInfo->aiTarget.aiTargetPos = possibleTargets[targetIndex]->pos; + pokemonInfo->aiTarget.aiTarget = possibleTargets[targetIndex]; + pokemonInfo->aiTarget.aiTargetSpawnGenID = pokemonInfo->aiTarget.aiTarget->spawnGenID; + pokemonInfo->aiTarget.aiTargetingEnemy = TRUE; pokemonInfo->moveRandomly = FALSE; if (HasTactic(pokemon, TACTIC_KEEP_YOUR_DISTANCE) && !CanSeeTeammate(pokemon)) { @@ -251,7 +251,7 @@ bool8 ChooseTargetPosition(Entity *pokemon) } if (distanceY < 2) { - pokemonInfo->aiTurningAround = TRUE; + pokemonInfo->aiTarget.aiTurningAround = TRUE; } } } @@ -267,10 +267,10 @@ bool8 ChooseTargetPosition(Entity *pokemon) Entity *leader = GetLeaderIfVisible(pokemon); if (EntityExists(leader)) { - pokemonInfo->aiObjective = AI_CHASE_TARGET; - pokemonInfo->aiTargetPos = leader->pos; - pokemonInfo->aiTarget = leader; - pokemonInfo->aiTargetSpawnGenID = leader->spawnGenID; + pokemonInfo->aiTarget.aiObjective = AI_CHASE_TARGET; + pokemonInfo->aiTarget.aiTargetPos = leader->pos; + pokemonInfo->aiTarget.aiTarget = leader; + pokemonInfo->aiTarget.aiTargetSpawnGenID = leader->spawnGenID; pokemonInfo->moveRandomly = FALSE; return TRUE; } @@ -313,31 +313,31 @@ bool8 ChooseTargetPosition(Entity *pokemon) Entity *object = GetTileSafe(x, y)->object; if (object && GetEntityType(object) == ENTITY_ITEM) { - pokemonInfo->aiObjective = AI_TAKE_ITEM; - pokemonInfo->aiTargetPos.x = x; - pokemonInfo->aiTargetPos.y = y; - pokemonInfo->aiTarget = NULL; - pokemonInfo->aiTargetSpawnGenID = 0; + pokemonInfo->aiTarget.aiObjective = AI_TAKE_ITEM; + pokemonInfo->aiTarget.aiTargetPos.x = x; + pokemonInfo->aiTarget.aiTargetPos.y = y; + pokemonInfo->aiTarget.aiTarget = NULL; + pokemonInfo->aiTarget.aiTargetSpawnGenID = 0; pokemonInfo->moveRandomly = FALSE; return TRUE; } } } } - if ((u8) (pokemonInfo->aiObjective - 1) <= 1) + if ((u8) (pokemonInfo->aiTarget.aiObjective - 1) <= 1) { - if (pokemonInfo->aiTarget) + if (pokemonInfo->aiTarget.aiTarget) { - if (pokemonInfo->aiTarget->spawnGenID == pokemonInfo->aiTargetSpawnGenID) + if (pokemonInfo->aiTarget.aiTarget->spawnGenID == pokemonInfo->aiTarget.aiTargetSpawnGenID) { - EntityInfo *targetData = pokemonInfo->aiTarget->info; + EntityInfo *targetData = pokemonInfo->aiTarget.aiTarget->info; s32 i; for (i = 0; i < NUM_PREV_POS; i++) { if (CanTargetPosition(pokemon, &targetData->prevPos[i])) { - pokemonInfo->aiObjective = AI_CHASE_REMEMBERED_TARGET; - pokemonInfo->aiTargetPos = targetData->prevPos[i]; + pokemonInfo->aiTarget.aiObjective = AI_CHASE_REMEMBERED_TARGET; + pokemonInfo->aiTarget.aiTargetPos = targetData->prevPos[i]; pokemonInfo->moveRandomly = FALSE; return TRUE; } @@ -345,9 +345,9 @@ bool8 ChooseTargetPosition(Entity *pokemon) } else { - pokemonInfo->aiObjective = AI_STAND_STILL; - pokemonInfo->aiTarget = NULL; - pokemonInfo->aiTargetSpawnGenID = 0; + pokemonInfo->aiTarget.aiObjective = AI_STAND_STILL; + pokemonInfo->aiTarget.aiTarget = NULL; + pokemonInfo->aiTarget.aiTargetSpawnGenID = 0; } } } @@ -363,20 +363,20 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) s32 i; struct CanMoveInDirectionInfo canMoveInDirectionInfo[6]; bool8 pokemonInFront; - pokemonInfo->targetPos = pokemonInfo->aiTargetPos; - if (pokemon->pos.x == pokemonInfo->aiTargetPos.x && - pokemon->pos.y == pokemonInfo->aiTargetPos.y) + pokemonInfo->targetPos = pokemonInfo->aiTarget.aiTargetPos; + if (pokemon->pos.x == pokemonInfo->aiTarget.aiTargetPos.x && + pokemon->pos.y == pokemonInfo->aiTarget.aiTargetPos.y) { SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); return; } - direction = GetDirectionTowardsPosition(&pokemon->pos, &pokemonInfo->aiTargetPos); - if (ShouldAvoidFirstHit(pokemon, pokemonInfo->aiTargetingEnemy)) + direction = GetDirectionTowardsPosition(&pokemon->pos, &pokemonInfo->aiTarget.aiTargetPos); + if (ShouldAvoidFirstHit(pokemon, pokemonInfo->aiTarget.aiTargetingEnemy)) { - if (pokemonInfo->aiObjective == AI_CHASE_TARGET && - IsTargetTwoTilesAway(&pokemon->pos, &pokemonInfo->aiTargetPos)) + if (pokemonInfo->aiTarget.aiObjective == AI_CHASE_TARGET && + IsTargetTwoTilesAway(&pokemon->pos, &pokemonInfo->aiTarget.aiTargetPos)) { - s32 distance = GetDistance(&pokemon->pos, &pokemonInfo->aiTargetPos); + s32 distance = GetDistance(&pokemon->pos, &pokemonInfo->aiTarget.aiTargetPos); if (distance == 2) { SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); @@ -389,7 +389,7 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) } } } - else if (pokemonInfo->aiTurningAround) + else if (pokemonInfo->aiTarget.aiTurningAround) { direction += 4; direction &= DIRECTION_MASK; @@ -404,31 +404,31 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) { if (!pokemonInfo->isNotTeamMember && !pokemonInfo->recalculateFollow) { - pokemonInfo->aiNotNextToTarget = TRUE; + pokemonInfo->aiTarget.aiNotNextToTarget = TRUE; pokemonInfo->aiNextToTarget = TRUE; SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); pokemonInfo->waiting = TRUE; return; } - if (pokemon->pos.x + gAdjacentTileOffsets[direction].x == pokemonInfo->aiTargetPos.x && - pokemon->pos.y + gAdjacentTileOffsets[direction].y == pokemonInfo->aiTargetPos.y) + if (pokemon->pos.x + gAdjacentTileOffsets[direction].x == pokemonInfo->aiTarget.aiTargetPos.x && + pokemon->pos.y + gAdjacentTileOffsets[direction].y == pokemonInfo->aiTarget.aiTargetPos.y) { SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); pokemonInfo->waiting = TRUE; return; } - pokemonInfo->aiNotNextToTarget = TRUE; + pokemonInfo->aiTarget.aiNotNextToTarget = TRUE; } canMoveInDirectionInfo[TURN_LEFT_45].tryTurn = canMoveInDirectionInfo[TURN_RIGHT_45].tryTurn = canMoveInDirectionInfo[TURN_LEFT_90].tryTurn = canMoveInDirectionInfo[TURN_RIGHT_90].tryTurn = canMoveInDirectionInfo[TURN_LEFT_135].tryTurn = TRUE; if (!pokemonInfo->isNotTeamMember && (direction & 1) != 0) { - s32 targetDistanceX = pokemon->pos.x - pokemonInfo->aiTargetPos.x; + s32 targetDistanceX = pokemon->pos.x - pokemonInfo->aiTarget.aiTargetPos.x; s32 targetDistanceY; if (targetDistanceX < 0) { targetDistanceX = -targetDistanceX; } - targetDistanceY = pokemon->pos.y - pokemonInfo->aiTargetPos.y; + targetDistanceY = pokemon->pos.y - pokemonInfo->aiTarget.aiTargetPos.y; if (targetDistanceY < 0) { targetDistanceY = -targetDistanceY; @@ -460,7 +460,7 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) } } turnLimit = TURN_LEFT_90; - if (ShouldMonsterRunAwayAndShowEffect(pokemon, showRunAwayEffect) || pokemonInfo->aiTurningAround) + if (ShouldMonsterRunAwayAndShowEffect(pokemon, showRunAwayEffect) || pokemonInfo->aiTarget.aiTurningAround) { turnLimit = TURN_LEFT_135; } @@ -484,17 +484,17 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) } if (canMoveInDirectionInfo[i].pokemonInFront) { - pokemonInfo->aiNotNextToTarget = TRUE; + pokemonInfo->aiTarget.aiNotNextToTarget = TRUE; } } SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); pokemonInfo->waiting = TRUE; if (pokemonInfo->isTeamLeader) { - pokemonInfo->aiNotNextToTarget = FALSE; + pokemonInfo->aiTarget.aiNotNextToTarget = FALSE; pokemonInfo->aiNextToTarget = FALSE; } - else if (pokemonInfo->aiNotNextToTarget) + else if (pokemonInfo->aiTarget.aiNotNextToTarget) { pokemonInfo->aiNextToTarget = TRUE; } @@ -544,7 +544,7 @@ bool8 AvoidEnemies(Entity *pokemon) closestTargetDistance = distance; closestTarget = target; closestTargetRoom = GetEntityRoom(target); - pokemonInfo->aiTargetPos = closestTarget->pos; + pokemonInfo->aiTarget.aiTargetPos = closestTarget->pos; pokemonInfo->targetPos = closestTarget->pos; } } @@ -575,15 +575,15 @@ bool8 AvoidEnemies(Entity *pokemon) if (targetDir == NUM_DIRECTIONS) { targetDir = DungeonRandInt(NUM_DIRECTIONS); - pokemonInfo->aiObjective = AI_STAND_STILL; - pokemonInfo->aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[targetDir].x; - pokemonInfo->aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[targetDir].y; + pokemonInfo->aiTarget.aiObjective = AI_STAND_STILL; + pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[targetDir].x; + pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[targetDir].y; return TRUE; } else { - pokemonInfo->aiObjective = AI_RUN_AWAY; - pokemonInfo->aiTargetPos = aiTargetPos; + pokemonInfo->aiTarget.aiObjective = AI_RUN_AWAY; + pokemonInfo->aiTarget.aiTargetPos = aiTargetPos; return TRUE; } } @@ -681,16 +681,16 @@ bool8 AvoidEnemies(Entity *pokemon) } if (furthestTargetToExitDistance >= 0) { - pokemonInfo->aiObjective = AI_RUN_AWAY; - pokemonInfo->aiTargetPos.x = naturalJunctionList[furthestTargetExitIndex].x; - pokemonInfo->aiTargetPos.y = naturalJunctionList[furthestTargetExitIndex].y; + pokemonInfo->aiTarget.aiObjective = AI_RUN_AWAY; + pokemonInfo->aiTarget.aiTargetPos.x = naturalJunctionList[furthestTargetExitIndex].x; + pokemonInfo->aiTarget.aiTargetPos.y = naturalJunctionList[furthestTargetExitIndex].y; return TRUE; } } } - pokemonInfo->aiObjective = AI_RUN_AWAY; - pokemonInfo->aiTargetPos.x = pokemon->pos.x - (closestTarget->pos.x - pokemon->pos.x); - pokemonInfo->aiTargetPos.y = pokemon->pos.y - (closestTarget->pos.y - pokemon->pos.y); + pokemonInfo->aiTarget.aiObjective = AI_RUN_AWAY; + pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x - (closestTarget->pos.x - pokemon->pos.x); + pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y - (closestTarget->pos.y - pokemon->pos.y); return TRUE; } else @@ -1108,8 +1108,8 @@ void sub_807BB78(Entity *pokemon) EntityInfo *entityInfo; entityInfo = pokemon->info; - entityInfo->aiObjective = 0; - entityInfo->aiTargetPos = pokemon->pos; - entityInfo->aiTarget = 0; - entityInfo->aiTargetSpawnGenID = 0; + entityInfo->aiTarget.aiObjective = 0; + entityInfo->aiTarget.aiTargetPos = pokemon->pos; + entityInfo->aiTarget.aiTarget = 0; + entityInfo->aiTarget.aiTargetSpawnGenID = 0; } diff --git a/src/dungeon_ai_targeting.c b/src/dungeon_ai_targeting.c index 6c450e6ec..780ee977a 100644 --- a/src/dungeon_ai_targeting.c +++ b/src/dungeon_ai_targeting.c @@ -528,11 +528,11 @@ u8 CanTarget(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool static inline bool8 JoinLocationCannotUseItems_1(EntityInfo *pokemonInfo) { - if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) { return TRUE; } - if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) { return TRUE; } diff --git a/src/dungeon_capabilities.c b/src/dungeon_capabilities.c index 51bbb62bc..222ad149b 100644 --- a/src/dungeon_capabilities.c +++ b/src/dungeon_capabilities.c @@ -22,9 +22,9 @@ bool8 CannotMove(Entity *pokemon, bool8 checkBlinker) EntityInfo *pokemonInfo = pokemon->info; if ((checkBlinker && pokemonInfo->eyesightStatus == STATUS_BLINKER) - || pokemonInfo->sleep == STATUS_SLEEP - || pokemonInfo->sleep == STATUS_NAPPING - || pokemonInfo->sleep == STATUS_NIGHTMARE + || pokemonInfo->sleep.sleep == STATUS_SLEEP + || pokemonInfo->sleep.sleep == STATUS_NAPPING + || pokemonInfo->sleep.sleep == STATUS_NIGHTMARE || pokemonInfo->volatileStatus == STATUS_PAUSED || pokemonInfo->volatileStatus == STATUS_INFATUATED || pokemonInfo->immobilizeStatus == STATUS_PETRIFIED) @@ -41,8 +41,8 @@ bool8 sub_8070BC0(Entity* entity) EntityInfo *entityInfo = entity->info; if (IsCharging(entity, FALSE) - || entityInfo->sleep == STATUS_YAWNING - || entityInfo->sleep == STATUS_NIGHTMARE + || entityInfo->sleep.sleep == STATUS_YAWNING + || entityInfo->sleep.sleep == STATUS_NIGHTMARE || ShouldMonsterRunAway(entity) || entityInfo->muzzled == TRUE || entityInfo->immobilizeStatus == STATUS_PETRIFIED @@ -51,10 +51,10 @@ bool8 sub_8070BC0(Entity* entity) if (entityInfo->volatileStatus == STATUS_CONFUSED) return FALSE; - if (entityInfo->sleep == STATUS_SLEEP) + if (entityInfo->sleep.sleep == STATUS_SLEEP) return FALSE; if (entityInfo->transformStatus == STATUS_INVISIBLE - || entityInfo->sleep == STATUS_NAPPING) + || entityInfo->sleep.sleep == STATUS_NAPPING) return FALSE; if (entityInfo->volatileStatus == STATUS_CRINGE) return FALSE; @@ -76,9 +76,9 @@ bool8 sub_8070BC0(Entity* entity) static inline bool8 JoinLocationCannotUseItems(EntityInfo *pokemonInfo) { - if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON) return TRUE; - if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if (pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) return TRUE; return FALSE; } @@ -104,8 +104,8 @@ bool8 HasStatusThatPreventsActing(Entity *pokemon) { EntityInfo *pokemonInfo = pokemon->info; - if ((pokemonInfo->sleep != STATUS_SLEEPLESS - && pokemonInfo->sleep != STATUS_NONE) + if ((pokemonInfo->sleep.sleep != STATUS_SLEEPLESS + && pokemonInfo->sleep.sleep != STATUS_NONE) || pokemonInfo->immobilizeStatus == STATUS_FROZEN || pokemonInfo->immobilizeStatus == STATUS_PETRIFIED) return TRUE; @@ -121,9 +121,9 @@ bool8 CannotAttack(Entity *pokemon, bool8 skipSleep) EntityInfo *pokemonInfo = pokemon->info; if ((skipSleep || - pokemonInfo->sleep == STATUS_SLEEPLESS || - pokemonInfo->sleep == STATUS_YAWNING || - pokemonInfo->sleep == STATUS_NONE) && + pokemonInfo->sleep.sleep == STATUS_SLEEPLESS || + pokemonInfo->sleep.sleep == STATUS_YAWNING || + pokemonInfo->sleep.sleep == STATUS_NONE) && pokemonInfo->immobilizeStatus != STATUS_FROZEN && pokemonInfo->immobilizeStatus != STATUS_WRAP && pokemonInfo->immobilizeStatus != STATUS_WRAPPED && @@ -167,4 +167,4 @@ bool8 CanMoveInDirection(Entity *pokemon, u32 direction) return FALSE; return TRUE; -} \ No newline at end of file +} diff --git a/src/dungeon_pokemon_attributes.c b/src/dungeon_pokemon_attributes.c index 7b105e043..08bf39530 100644 --- a/src/dungeon_pokemon_attributes.c +++ b/src/dungeon_pokemon_attributes.c @@ -65,7 +65,7 @@ bool8 sub_80717A4(Entity *pokemon, u16 moveID) s32 index; entityInfo = pokemon->info; - if ((entityInfo->sleep != STATUS_SLEEP) && (entityInfo->sleep != STATUS_NAPPING) && (entityInfo->sleep != STATUS_NIGHTMARE)) { + if ((entityInfo->sleep.sleep != STATUS_SLEEP) && (entityInfo->sleep.sleep != STATUS_NAPPING) && (entityInfo->sleep.sleep != STATUS_NIGHTMARE)) { return FALSE; } else @@ -218,7 +218,7 @@ bool8 CanSeeTeammate(Entity * pokemon) u8 GetMoveTypeForMonster(Entity *pokemon, Move *pokeMove) { if (pokeMove->id == MOVE_HIDDEN_POWER) - return pokemon->info->hiddenPowerType; + return pokemon->info->hiddenPower.hiddenPowerType; else return GetMoveType(pokeMove); } @@ -226,7 +226,7 @@ u8 GetMoveTypeForMonster(Entity *pokemon, Move *pokeMove) s32 GetMovePower(Entity *pokemon, Move *pokeMove) { if(pokeMove->id == MOVE_HIDDEN_POWER) - return (pokemon->info->hiddenPowerBasePower + pokeMove->ginseng); + return (pokemon->info->hiddenPower.hiddenPowerBasePower + pokeMove->ginseng); else return (GetMoveBasePower(pokeMove) + pokeMove->ginseng); } @@ -240,8 +240,8 @@ bool8 ToolboxEnabled(EntityInfo *pokemon) static inline bool8 sub_8071A8C_sub(EntityInfo *pokemonInfo) { - if(pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON || - pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE) + if(pokemonInfo->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON || + pokemonInfo->joinedAt.joinedAt == DUNGEON_RESCUE_TEAM_BASE) return TRUE; else return FALSE; diff --git a/src/dungeon_util_1.c b/src/dungeon_util_1.c index 37723b2f1..451e2dd76 100644 --- a/src/dungeon_util_1.c +++ b/src/dungeon_util_1.c @@ -38,7 +38,7 @@ Entity *GetPartnerEntity(void) for(counter = 0; counter < MAX_TEAM_MEMBERS; counter++) { entity = gDungeon->teamPokemon[counter]; - if(EntityExists(entity) && entity->info->joinedAt == DUNGEON_JOIN_LOCATION_PARTNER) + if(EntityExists(entity) && entity->info->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_PARTNER) { return entity; } @@ -85,7 +85,7 @@ void sub_80854D4(void) for(index = 0; index < MAX_TEAM_MEMBERS; index++) { entity3 = stack1[index]; - if(entity3 != NULL && entity3->info->joinedAt == DUNGEON_JOIN_LOCATION_PARTNER) + if(entity3 != NULL && entity3->info->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_PARTNER) { stack1[index] = NULL; stack2[counter] = entity3; @@ -126,7 +126,7 @@ void sub_80855E4(DungeonCallback func) { entity = gDungeon->teamPokemon[index]; if (EntityExists(entity)) { - if (entity->info->joinedAt == DUNGEON_JOIN_LOCATION_PARTNER) { + if (entity->info->joinedAt.joinedAt == DUNGEON_JOIN_LOCATION_PARTNER) { flag = TRUE; } func(entity); @@ -145,7 +145,7 @@ void sub_808563C(DungeonCallback func) for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) { entity = gDungeon->wildPokemon[index]; - if ((EntityExists(entity)) && (entity->info->joinedAt != 0x41)) { + if ((EntityExists(entity)) && (entity->info->joinedAt.joinedAt != 0x41)) { func(entity); } } diff --git a/src/move_actions.c b/src/move_actions.c index d63d7e3e4..1e382fb0e 100644 --- a/src/move_actions.c +++ b/src/move_actions.c @@ -3202,7 +3202,7 @@ bool8 sub_805AD34(Entity *pokemon, Entity *target, Move *move, u32 param_4) static inline bool8 sub_805AD54_sub(Entity *entity) { - if ((entity->info->joinedAt == 0x4A) || (entity->info->joinedAt == 0x47)) { + if ((entity->info->joinedAt.joinedAt == 0x4A) || (entity->info->joinedAt.joinedAt == 0x47)) { return TRUE; } else { diff --git a/src/move_checks.c b/src/move_checks.c index 3b6476f27..4ba6bfc82 100644 --- a/src/move_checks.c +++ b/src/move_checks.c @@ -564,7 +564,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_YAWN: - if (targetData->sleep == STATUS_YAWNING) + if (targetData->sleep.sleep == STATUS_YAWNING) { return FALSE; } @@ -574,7 +574,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_NIGHTMARE: - if (targetData->sleep == STATUS_NIGHTMARE) + if (targetData->sleep.sleep == STATUS_NIGHTMARE) { return FALSE; } @@ -741,7 +741,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) break; } case MOVE_UPROAR: - if (targetData->sleep == STATUS_SLEEPLESS) + if (targetData->sleep.sleep == STATUS_SLEEPLESS) { return FALSE; } diff --git a/src/move_effects_target.c b/src/move_effects_target.c index 52f158e82..ac0273395 100644 --- a/src/move_effects_target.c +++ b/src/move_effects_target.c @@ -178,18 +178,18 @@ u8 sub_8075BF4(Entity * pokemon, s32 sleepTurns) { entityInfo = pokemon->info; - if(entityInfo->sleep != STATUS_NIGHTMARE && entityInfo->sleep != STATUS_SLEEP) + if(entityInfo->sleep.sleep != STATUS_NIGHTMARE && entityInfo->sleep.sleep != STATUS_SLEEP) { - entityInfo->sleep = STATUS_SLEEP; + entityInfo->sleep.sleep = STATUS_SLEEP; if ((sleepTurns != 0x7f) && HasAbility(pokemon, ABILITY_EARLY_BIRD) && (sleepTurns = sleepTurns / 2, sleepTurns < 1)) { sleepTurns = 1; } - entityInfo->sleepTurns = sleepTurns; + entityInfo->sleep.sleepTurns = sleepTurns; } - else if(entityInfo->sleep == STATUS_SLEEP) + else if(entityInfo->sleep.sleep == STATUS_SLEEP) uVar4 = 1; - else if(entityInfo->sleep == STATUS_NIGHTMARE) + else if(entityInfo->sleep.sleep == STATUS_NIGHTMARE) uVar4 = 2; EntityUpdateStatusSprites(pokemon); } @@ -203,7 +203,7 @@ void sub_8075C58(Entity * pokemon, Entity * target, s32 turns, u8 displayMessage if (!CannotSleep(pokemon,target,1,displayMessage)) { - sleep = target->info->sleep; + sleep = target->info->sleep.sleep; if (sleep == STATUS_SLEEPLESS) { if (displayMessage) sub_80522F4(pokemon,target,*gUnknown_80FB380); @@ -269,19 +269,19 @@ void NightmareStatusTarget(Entity * pokemon, Entity * target, s32 turns) hasNightmare = FALSE; if (!CannotSleep(pokemon, target, 1, TRUE)) { entityInfo = target->info; - if (entityInfo->sleep != STATUS_SLEEPLESS) { + if (entityInfo->sleep.sleep != STATUS_SLEEPLESS) { sub_8041EC8(target); - if (entityInfo->sleep != STATUS_NIGHTMARE) { - entityInfo->sleepTurns = turns; - if ((HasAbility(target, ABILITY_EARLY_BIRD)) && (entityInfo->sleepTurns >>= 1, entityInfo->sleepTurns == 0)) { - entityInfo->sleepTurns = 1; + if (entityInfo->sleep.sleep != STATUS_NIGHTMARE) { + entityInfo->sleep.sleepTurns = turns; + if ((HasAbility(target, ABILITY_EARLY_BIRD)) && (entityInfo->sleep.sleepTurns >>= 1, entityInfo->sleep.sleepTurns == 0)) { + entityInfo->sleep.sleepTurns = 1; } } else { hasNightmare = TRUE; } - entityInfo->sleep = STATUS_NIGHTMARE; + entityInfo->sleep.sleep = STATUS_NIGHTMARE; sub_806CE68(target,8); if (hasNightmare) { sub_80522F4(pokemon,target,*gUnknown_80FB3CC); @@ -306,19 +306,19 @@ void NappingStatusTarget(Entity * pokemon, Entity * target, s32 turns) isSleeping = FALSE; if (!CannotSleep(pokemon, target, 0, TRUE)) { entityInfo = target->info; - if (entityInfo->sleep != STATUS_SLEEPLESS) { + if (entityInfo->sleep.sleep != STATUS_SLEEPLESS) { sub_8041ED8(target); - if (entityInfo->sleep == STATUS_NONE || entityInfo->sleep == STATUS_YAWNING) { - entityInfo->sleepTurns = turns; - if ((HasAbility(target, ABILITY_EARLY_BIRD)) && (entityInfo->sleepTurns >>= 1, entityInfo->sleepTurns == 0)) { - entityInfo->sleepTurns = 1; + if (entityInfo->sleep.sleep == STATUS_NONE || entityInfo->sleep.sleep == STATUS_YAWNING) { + entityInfo->sleep.sleepTurns = turns; + if ((HasAbility(target, ABILITY_EARLY_BIRD)) && (entityInfo->sleep.sleepTurns >>= 1, entityInfo->sleep.sleepTurns == 0)) { + entityInfo->sleep.sleepTurns = 1; } } else { isSleeping = TRUE; } - entityInfo->sleep = STATUS_NAPPING; + entityInfo->sleep.sleep = STATUS_NAPPING; sub_806CE68(target, 8); if (isSleeping) { sub_80522F4(pokemon,target,*gUnknown_80FB360); @@ -343,21 +343,21 @@ void YawnedStatusTarget(Entity * pokemon, Entity * target, s32 turns) return; } entityInfo = target->info; - if (entityInfo->sleep == STATUS_NONE) { - entityInfo->sleep = STATUS_YAWNING; - entityInfo->sleepTurns = turns; + if (entityInfo->sleep.sleep == STATUS_NONE) { + entityInfo->sleep.sleep = STATUS_YAWNING; + entityInfo->sleep.sleepTurns = turns; nullsub_91(target); sub_806CE68(target, 8); sub_80522F4(pokemon,target,*gUnknown_80FB3E0); } - else if (((entityInfo->sleep == STATUS_SLEEP) || (entityInfo->sleep == STATUS_NIGHTMARE)) || (entityInfo->sleep == STATUS_NAPPING)) { + else if (((entityInfo->sleep.sleep == STATUS_SLEEP) || (entityInfo->sleep.sleep == STATUS_NIGHTMARE)) || (entityInfo->sleep.sleep == STATUS_NAPPING)) { sub_80522F4(pokemon,target,*gUnknown_80FB418); } - else if (entityInfo->sleep == STATUS_SLEEPLESS) { + else if (entityInfo->sleep.sleep == STATUS_SLEEPLESS) { sub_80522F4(pokemon,target,*gUnknown_80FB3F8); } else { - if (entityInfo->sleep == STATUS_YAWNING) + if (entityInfo->sleep.sleep == STATUS_YAWNING) sub_80522F4(pokemon,target,*gUnknown_80FB414); else sub_80522F4(pokemon,target,*gUnknown_80FB3E0); @@ -376,15 +376,15 @@ void SleeplessStatusTarget(Entity * pokemon, Entity * target) } entityInfo = target->info; - if ((entityInfo->sleep == STATUS_SLEEP) || (entityInfo->sleep == STATUS_NAPPING) || (entityInfo->sleep == STATUS_NIGHTMARE)) { + if ((entityInfo->sleep.sleep == STATUS_SLEEP) || (entityInfo->sleep.sleep == STATUS_NAPPING) || (entityInfo->sleep.sleep == STATUS_NIGHTMARE)) { isAsleep = TRUE; } SetMessageArgument(gAvailablePokemonNames, target, 0); - if (entityInfo->sleep != STATUS_SLEEPLESS) + if (entityInfo->sleep.sleep != STATUS_SLEEPLESS) { - entityInfo->sleep = STATUS_SLEEPLESS; - entityInfo->sleepTurns = CalculateStatusTurns(target, gUnknown_80F4E7C, FALSE) + 1; + entityInfo->sleep.sleep = STATUS_SLEEPLESS; + entityInfo->sleep.sleepTurns = CalculateStatusTurns(target, gUnknown_80F4E7C, FALSE) + 1; entityInfo->unk165 = 0xFF; entityInfo->unk164 = 0xFF; sub_8041EE8(target); @@ -977,11 +977,11 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target) entity = gDungeon->teamPokemon[index]; if (EntityExists(entity)) { entityInfo = entity->info; - if ((entityInfo->aiObjective == AI_CHASE_TARGET) && (entityInfo->aiTarget == target)) { - entityInfo->aiObjective = AI_STAND_STILL; - entityInfo->aiTarget = NULL; - entityInfo->aiTargetSpawnGenID = 0; - entityInfo->aiTargetingEnemy = FALSE; + if ((entityInfo->aiTarget.aiObjective == AI_CHASE_TARGET) && (entityInfo->aiTarget.aiTarget == target)) { + entityInfo->aiTarget.aiObjective = AI_STAND_STILL; + entityInfo->aiTarget.aiTarget = NULL; + entityInfo->aiTarget.aiTargetSpawnGenID = 0; + entityInfo->aiTarget.aiTargetingEnemy = FALSE; } } } diff --git a/src/status.c b/src/status.c index 18a392561..3c714052a 100644 --- a/src/status.c +++ b/src/status.c @@ -1017,9 +1017,9 @@ void sub_80783C4(Entity * pokemon, Entity * target, u8 param_3) entity2 = gDungeon->allPokemon[index]; if (EntityExists(entity2)) { entityInfo = entity2->info; - entityInfo->aiObjective = AI_STAND_STILL; - entityInfo->aiTarget = NULL; - entityInfo->aiTargetSpawnGenID = 0; + entityInfo->aiTarget.aiObjective = AI_STAND_STILL; + entityInfo->aiTarget.aiTarget = NULL; + entityInfo->aiTarget.aiTargetSpawnGenID = 0; if (!entityInfo->isTeamLeader) { action = entityInfo->action; MoveIfPossible(entity2, TRUE); diff --git a/src/status_actions.c b/src/status_actions.c index 468c15308..4a5dde90f 100644 --- a/src/status_actions.c +++ b/src/status_actions.c @@ -83,7 +83,7 @@ extern void sub_8075C58(Entity *, Entity *, s32, s32); extern void sub_806F324(Entity *, s32, u32, u32); extern bool8 sub_805755C(Entity* pokemon,u16 moveID); extern void sub_80783C4(Entity *, Entity *, u32); -extern void sub_807CD9C(Entity *, Entity *, u8 direction); +extern void sub_807CD9C(Entity *, Entity *, u32 direction); // NOTE: Override pokemon.c types for these two funcs diff --git a/src/status_checks.c b/src/status_checks.c index a4779cfb2..314e5a8e7 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -31,7 +31,7 @@ bool8 HasStatusAffectingActions(Entity *pokemon) EntityInfo *pokemonInfo = pokemon->info; SetMessageArgument(gAvailablePokemonNames, pokemon, 0); SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); - switch (pokemonInfo->sleep) + switch (pokemonInfo->sleep.sleep) { case STATUS_NIGHTMARE: case STATUS_SLEEP: @@ -121,7 +121,7 @@ bool8 sub_80701A4(Entity *pokemon) flag = FALSE; SetMessageArgument(gAvailablePokemonNames, pokemon, 0); SetMonsterActionFields(&pokemonInfo->action, ACTION_PASS_TURN); - switch(pokemonInfo->sleep) + switch(pokemonInfo->sleep.sleep) { case STATUS_SLEEP: case STATUS_NIGHTMARE: diff --git a/src/status_checks_1.c b/src/status_checks_1.c index efa6d8ffd..aa964b04e 100644 --- a/src/status_checks_1.c +++ b/src/status_checks_1.c @@ -72,7 +72,7 @@ void SetMessageArgument_2(u8 *buffer, EntityInfo *param_2, s32 colorNum) else { if (param_2->isNotTeamMember) { - if ((param_2->joinedAt == 0x4A) || (param_2->clientType == CLIENT_TYPE_CLIENT)) { + if ((param_2->joinedAt.joinedAt == 0x4A) || (param_2->clientType == CLIENT_TYPE_CLIENT)) { CopyYellowMonsterNametoBuffer(buffer, param_2->apparentID); } else @@ -130,9 +130,9 @@ bool8 HasNegativeStatus(Entity *pokemon) { EntityInfo *pokemonInfo = pokemon->info; s32 i; - if (pokemonInfo->sleep == STATUS_SLEEP || - pokemonInfo->sleep == STATUS_NIGHTMARE || - pokemonInfo->sleep == STATUS_YAWNING || + if (pokemonInfo->sleep.sleep == STATUS_SLEEP || + pokemonInfo->sleep.sleep == STATUS_NIGHTMARE || + pokemonInfo->sleep.sleep == STATUS_YAWNING || pokemonInfo->nonVolatileStatus != STATUS_NONE || (pokemonInfo->immobilizeStatus != STATUS_INGRAIN && pokemonInfo->immobilizeStatus != STATUS_NONE) || pokemonInfo->volatileStatus != STATUS_NONE || @@ -168,9 +168,9 @@ bool8 HasNegativeStatus(Entity *pokemon) bool8 IsSleeping(Entity *pokemon) { - if (pokemon->info->sleep != STATUS_SLEEP && - pokemon->info->sleep != STATUS_NAPPING && - pokemon->info->sleep != STATUS_NIGHTMARE) + if (pokemon->info->sleep.sleep != STATUS_SLEEP && + pokemon->info->sleep.sleep != STATUS_NAPPING && + pokemon->info->sleep.sleep != STATUS_NIGHTMARE) { return FALSE; } diff --git a/src/trap_1.c b/src/trap_1.c index 8e6283da9..dcc94b695 100644 --- a/src/trap_1.c +++ b/src/trap_1.c @@ -12,39 +12,43 @@ extern u8 gUnknown_81071D4[]; extern void sub_8082FA8(void *, void *, u32); +void sub_8081B60(void *, Tile *); +void sub_80830F8(void * , u32*); +void sub_808312C(void *, u32 *); +void sub_8081B94(void *, u8 *); void sub_8083078(void *, u32); void sub_80830B4(void *, u8); void sub_8083030(void *, u16); void sub_8080E0C(unkStruct_8094924 *, Entity *); void sub_808300C(void *, u8 *); -void sub_8081788(void *, Item *); +void sub_8081788(unkStruct_8094924 *param_1, Item *param_2); void sub_8080B90(unkStruct_8094924 *param_1); void SaveItemData(unkStruct_8094924 *param_1); void sub_8081454(unkStruct_8094924 *param_1); void sub_808165C(unkStruct_8094924 *param_1); -void sub_808173C(unkStruct_8094924 *param_1); +void SaveDungeonMusic(unkStruct_8094924 *param_1); void SaveTrapData(unkStruct_8094924 *param_1); void sub_8080CF0(unkStruct_8094924 *param_1); void nullsub_98(unkStruct_8094924 *param_1); void sub_8082F9C(unkStruct_8094924 *param_1, u32, u32); void sub_8049ED4(void); void sub_8083060(void *, u32); -void sub_80817F4(void *, u32); +void sub_80817F4(unkStruct_8094924 *param_1, u32 param_2); void sub_80830A0(void *, u32); -void sub_808180C(void *, u32); +void sub_808180C(unkStruct_8094924 *param_1, u32 param_2); void sub_8083048(void *, u32); -void sub_80818C8(void *, bool8 *); -void sub_80817C8(void *, void *); +void sub_80818C8(unkStruct_8094924 *param_1, JoinedAt *param_2); +void sub_80817C8(unkStruct_8094924 *param_1, ActionContainer *param_2); void sub_8081B34(void *, void *); void sub_8081B08(void *, Move *); -void sub_8081824(void *, u32); -void sub_80817B0(void *, u32); +void sub_8081824(unkStruct_8094924 *param_1, u32 param_2); +void sub_80817B0(unkStruct_8094924 *param_1, u32 param_2); void SavePosition(void*, Position *); -void sub_80818E4(void *, u8 *); +void sub_80818E4(unkStruct_8094924 *param_1, AITarget* param_2); void sub_8081B54(void *, u8 *); -void sub_808186C(void *, s32); -void sub_8081854(void *, s32); -void sub_808183C(void *, s32); +void sub_808186C(unkStruct_8094924 *param_1, s32 param_2); +void sub_8081854(unkStruct_8094924 *param_1, s32 param_2); +void sub_808183C(unkStruct_8094924 *param_1, s32 param_2); void sub_8081AB8(void *, bool8 *); void sub_8081A9C(void *, u8*); void sub_8081A80(void *, u8*); @@ -54,14 +58,14 @@ void sub_8081A24(void *, u8*); void sub_8081994(void *, u8*); void sub_8081968(void *, u8*); void sub_808193C(void *, u8*); -void sub_8081920(void *, u8*); -void sub_8081880(void *, u8); -void sub_8081898(void *, s16 *); +void sub_8081920(unkStruct_8094924 *param_1, Sleep* param_2); +void sub_8081880(unkStruct_8094924 *param_1, u8 param_2); +void SaveHiddenPower(unkStruct_8094924 *param_1, HiddenPower *param_2); void sub_80819B0(void *, u8 *); void sub_80819D4(void *, u8 *); void sub_80819F0(void *, u8 *); void SaveSpeedCounters(void *, u8 *, u32); -void sub_80818B8(void *, u32); +void sub_80818B8(unkStruct_8094924 *param_1, u8 param_2); void sub_803E708(u32, u32); void sub_80421C0(Entity *, u32); void sub_804687C(Entity *, Position *, Position *, Item *, u32); @@ -116,7 +120,7 @@ void sub_8080B30(u32 param_1,u32 param_2) sub_8080B90(&uStack_14); sub_8081454(&uStack_14); sub_808165C(&uStack_14); - sub_808173C(&uStack_14); + SaveDungeonMusic(&uStack_14); SaveItemData(&uStack_14); SaveTrapData(&uStack_14); sub_8080CF0(&uStack_14); @@ -228,16 +232,16 @@ void sub_8080E0C(unkStruct_8094924 *param_1,Entity *param_2) EntityInfo info2; u32 uStack_ac; u32 uStack_a8; - s16 *psStack_a4; + HiddenPower *psStack_a4; u8 *temp1; u8 *temp2; - u8 *temp3; + AITarget *temp3; u8 *puStack_a0; u32 *puStack_9c; u32 *puStack_98; u32 *puStack_94; u8 *puStack_90; - u8 *puStack_8c; + Sleep *puStack_8c; u8 *puStack_88; u8 *puStack_84; u8 *puStack_80; @@ -323,11 +327,11 @@ void sub_8080E0C(unkStruct_8094924 *param_1,Entity *param_2) sub_8081824(param_1,info->abilities[1]); sub_8081788(param_1,&info->heldItem); sub_80817B0(param_1,info->fill64[0]); - temp3 = &info->aiObjective; + temp3 = &info->aiTarget; temp2 = info->IQSkillMenuFlags; temp1 = info->IQSkillFlags; puStack_a0 = &info->tactic; - psStack_a4 = &info->hiddenPowerBasePower; + psStack_a4 = &info->hiddenPower; puStack_9c = &info->unk98; puStack_98 = &info->unk9C; puStack_94 = &info->unkA0; @@ -371,7 +375,7 @@ void sub_8080E0C(unkStruct_8094924 *param_1,Entity *param_2) sub_8081B54(param_1,temp2); sub_8081B54(param_1,temp1); sub_8081880(param_1,*puStack_a0); - sub_8081898(param_1,psStack_a4); + SaveHiddenPower(param_1,psStack_a4); sub_8083078(param_1,*puStack_9c); sub_8083078(param_1,*puStack_98); sub_8083078(param_1,*puStack_94); @@ -442,3 +446,179 @@ void sub_8080E0C(unkStruct_8094924 *param_1,Entity *param_2) sub_8083078(param_1,info->expGainedInTurn); sub_80818B8(param_1,*puStack_90); } + +void sub_8081454(unkStruct_8094924 *param_1) +{ + int iVar1; + int iVar2; + int iVar4; + + sub_808300C(param_1,gUnknown_81071E0); + sub_80830B4(param_1, gDungeon->unk3A08); + sub_80830B4(param_1, gDungeon->unk3A09); + sub_80830B4(param_1, gDungeon->unk3A0A); + sub_80830B4(param_1, gDungeon->unk3A0B); + sub_8083060(param_1, gDungeon->unk3A0C); + sub_8083060(param_1, gDungeon->unk3A0D); + sub_8083048(param_1, gDungeon->tileset); + sub_8083048(param_1,gDungeon->unk3A10); + sub_8083048(param_1, gDungeon->unk3A12); + sub_8083048(param_1, gDungeon->bossBattleIndex); + sub_8083048(param_1, gDungeon->unk3A16); + for(iVar1 = 0; iVar1 < DUNGEON_MAX_SIZE_Y; iVar1++) + { + + for(iVar2 = 0; iVar2 < DUNGEON_MAX_SIZE_X; iVar2++) + { + sub_8081B60(param_1,&gDungeon->tiles[iVar1][iVar2]); + } + } + + + SavePosition(param_1,&gDungeon->unkE218); + SavePosition(param_1,&gDungeon->unkE21C); + + + + for(iVar4 = 0; iVar4 < 8; iVar4++) + { + SavePosition(param_1,&gDungeon->unkE220[iVar4]); + } + sub_80830F8(param_1,&gDungeon->unkE240); + sub_80830F8(param_1,&gDungeon->unkE250); + sub_808312C(param_1,&gDungeon->unkE260); + + for(iVar1 = 0; iVar1 < 8; iVar1++) + { + for(iVar2 = 0; iVar2 < 8; iVar2++) + { + sub_8081B60(param_1, &gDungeon->unkE27C[iVar1][iVar2]); + sub_8083060(param_1, gDungeon->unkE87C[iVar1][iVar2]); + } + } + sub_8081B94(param_1,&gDungeon->weather); +} + +void sub_808165C(unkStruct_8094924 *param_1) +{ + + sub_808300C(param_1,gUnknown_81071E0); + sub_8083060(param_1, gDungeon->unk18208); + sub_8083060(param_1, gDungeon->visibilityRange); + sub_80830B4(param_1, gDungeon->blinded); + sub_80830B4(param_1, gDungeon->unk1820B); + sub_80830B4(param_1, gDungeon->unk1820C); + sub_80830B4(param_1, gDungeon->unk1820D); + sub_80830B4(param_1, gDungeon->unk1820E); + sub_80830B4(param_1, gDungeon->unk1820F); + sub_80830B4(param_1, gDungeon->hallucinating); + sub_80830B4(param_1, gDungeon->unk18211); + sub_80830B4(param_1, gDungeon->unk18213); +} + +// NOTE: forcing this s16 for now - Seth +void SaveDungeonMusic(unkStruct_8094924 *param_1) +{ + sub_8083048(param_1, (s16)gDungeon->musPlayer.songIndex); + sub_8083048(param_1, (s16)gDungeon->musPlayer.pastSongIndex); + sub_8083048(param_1, (s16)gDungeon->musPlayer.queuedSongIndex); +} + +void sub_8081788(unkStruct_8094924 *param_1, Item *param_2) +{ + sub_8082FA8(param_1, ¶m_2->flags, 1); + sub_8082FA8(param_1, ¶m_2->quantity, 1); + sub_8082FA8(param_1, ¶m_2->id, 1); +} + +void sub_80817B0(unkStruct_8094924 *param_1, u32 param_2) +{ + u8 stack; + stack = param_2; + sub_8082FA8(param_1, &stack, 1); +} + +void sub_80817C8(unkStruct_8094924 *param_1, ActionContainer *param_2) +{ + sub_8082FA8(param_1, ¶m_2->direction, 1); + sub_8082FA8(param_1, ¶m_2->itemTargetPosition.x, 1); + sub_8082FA8(param_1, ¶m_2->itemTargetPosition.y, 1); +} + +void sub_80817F4(unkStruct_8094924 *param_1, u32 param_2) +{ + u16 stack; + stack = param_2; + sub_8082FA8(param_1, &stack, 2); +} + +void sub_808180C(unkStruct_8094924 *param_1, u32 param_2) +{ + u8 stack; + stack = param_2; + sub_8082FA8(param_1, &stack, 1); +} + +void sub_8081824(unkStruct_8094924 *param_1, u32 param_2) +{ + u8 stack; + stack = param_2; + sub_8082FA8(param_1, &stack, 1); +} + +void sub_808183C(unkStruct_8094924 *param_1, s32 param_2) +{ + u8 stack; + stack = param_2; + sub_8082FA8(param_1, &stack, 1); +} + +void sub_8081854(unkStruct_8094924 *param_1, s32 param_2) +{ + u8 stack; + stack = param_2; + sub_8082FA8(param_1, &stack, 1); +} + +void sub_808186C(unkStruct_8094924 *param_1, s32 param_2) +{ + sub_8082FA8(param_1, ¶m_2, 4); +} + +void sub_8081880(unkStruct_8094924 *param_1, u8 param_2) +{ + sub_8082FA8(param_1, ¶m_2, 1); +} + +void SaveHiddenPower(unkStruct_8094924 *param_1, HiddenPower *param_2) +{ + sub_8083048(param_1, param_2->hiddenPowerBasePower); + sub_808180C(param_1, param_2->hiddenPowerType); +} + +void sub_80818B8(unkStruct_8094924 *param_1, u8 param_2) +{ + sub_8083060(param_1, param_2); +} + +void sub_80818C8(unkStruct_8094924 *param_1, JoinedAt *param_2) +{ + sub_8083060(param_1, param_2->joinedAt); + sub_8083060(param_1, param_2->unk1); +} + +void sub_80818E4(unkStruct_8094924 *param_1, AITarget* param_2) +{ + sub_8082FA8(param_1, ¶m_2->aiObjective, 1); + sub_80830B4(param_1, param_2->aiNotNextToTarget); + sub_80830B4(param_1, param_2->aiTargetingEnemy); + sub_80830B4(param_1, param_2->aiTurningAround); + sub_8083030(param_1, param_2->aiTargetSpawnGenID); + SavePosition(param_1, ¶m_2->aiTargetPos); +} + +void sub_8081920(unkStruct_8094924 *param_1, Sleep* param_2) +{ + sub_8082FA8(param_1, ¶m_2->sleep, 1); + sub_8083060(param_1, param_2->sleepTurns); +}