more decomp work

This commit is contained in:
Seth Barberee
2022-11-12 15:44:26 -08:00
parent 44094d9fdd
commit 9befb0ef4e
14 changed files with 273 additions and 543 deletions

View File

@@ -4,328 +4,6 @@
.syntax unified
.text
thumb_func_start xxx_dungeon_80442D0
xxx_dungeon_80442D0:
push {r4-r7,lr}
lsls r0, 24
lsrs r7, r0, 24
bl GetLeaderEntity
adds r5, r0, 0
cmp r5, 0
beq _0804431A
bl TriggerWeatherAbilities
adds r0, r5, 0
bl GetMovementSpeed
ldr r3, _08044320
ldr r1, _08044324
ldr r1, [r1]
movs r2, 0xCC
lsls r2, 3
adds r1, r2
movs r2, 0
ldrsh r1, [r1, r2]
lsls r1, 1
movs r2, 0x32
muls r0, r2
adds r1, r0
adds r1, r3
movs r3, 0
ldrsh r0, [r1, r3]
cmp r0, 0
beq _0804431A
ldr r0, [r5, 0x70]
movs r1, 0xA4
lsls r1, 1
adds r0, r1
ldrb r0, [r0]
cmp r0, 0
beq _08044328
_0804431A:
movs r0, 0
b _0804444E
.align 2, 0
_08044320: .4byte gSpeedTurns
_08044324: .4byte gDungeonGlobalData
_08044328:
bl GetLeaderEntity
adds r5, r0, 0
cmp r5, 0
beq _0804431A
movs r0, 0
bl UseAttack
lsls r0, 24
cmp r0, 0
bne _0804435C
ldr r0, _08044388
ldr r1, [r0]
ldr r2, _0804438C
adds r0, r1, r2
ldrb r0, [r0]
cmp r0, 0
bne _08044356
ldr r3, _08044390
adds r0, r1, r3
ldrb r0, [r0]
cmp r0, 0
beq _0804435C
_08044356:
movs r0, 0xC
bl sub_803E46C
_0804435C:
ldr r0, [r5, 0x70]
adds r0, 0xF8
movs r1, 0
strb r1, [r0]
bl sub_8044B28
lsls r0, 24
lsrs r2, r0, 24
cmp r2, 0
bne _0804431A
ldr r0, _08044388
ldr r1, [r0]
adds r0, r1, 0
adds r0, 0xB8
str r5, [r0]
adds r1, 0xBC
str r2, [r1]
cmp r7, 0
beq _08044394
movs r7, 0
b _0804439A
.align 2, 0
_08044388: .4byte gDungeonGlobalData
_0804438C: .4byte 0x0000066c
_08044390: .4byte 0x00000673
_08044394:
adds r0, r5, 0
bl TickStatusHeal
_0804439A:
bl sub_8044B28
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0
bne _0804431A
adds r0, r5, 0
bl sub_8071DA4
ldr r6, _08044434
ldr r1, [r6]
movs r0, 0x1
strb r0, [r1, 0xF]
bl sub_805D8C8
ldr r0, [r6]
strb r4, [r0, 0xF]
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _0804444C
adds r0, r5, 0
bl sub_8072CF4
bl sub_8086AC0
movs r0, 0
bl sub_8043ED0
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _0804444C
ldr r2, [r5, 0x70]
ldrh r1, [r2]
movs r3, 0x80
lsls r3, 8
adds r0, r3, 0
ands r0, r1
cmp r0, 0
beq _08044400
subs r3, 0x1
adds r0, r3, 0
ands r0, r1
movs r3, 0x80
lsls r3, 7
adds r1, r3, 0
orrs r0, r1
strh r0, [r2]
_08044400:
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _0804444C
bl sub_8044454
bl sub_8044B28
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0
bne _0804444C
ldr r2, [r6]
adds r0, r2, 0
adds r0, 0xBC
ldr r1, [r0]
cmp r1, 0
beq _08044438
bl sub_805F02C
ldr r0, [r6]
adds r0, 0xBC
str r4, [r0]
movs r7, 0x1
b _08044328
.align 2, 0
_08044434: .4byte gDungeonGlobalData
_08044438:
ldr r0, [r5, 0x70]
adds r0, 0xF8
ldrb r0, [r0]
cmp r0, 0
beq _0804444C
movs r3, 0xCC
lsls r3, 3
adds r0, r2, r3
strh r1, [r0]
b _08044328
_0804444C:
movs r0, 0x1
_0804444E:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end xxx_dungeon_80442D0
thumb_func_start sub_8044454
sub_8044454:
push {r4-r6,lr}
ldr r0, _080444E8
ldr r1, [r0]
ldrb r0, [r1, 0xE]
cmp r0, 0
beq _080444E2
movs r0, 0
strb r0, [r1, 0xE]
movs r6, 0
_08044466:
ldr r0, _080444E8
ldr r0, [r0]
lsls r1, r6, 2
ldr r2, _080444EC
adds r0, r2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _080444DC
ldr r5, [r4, 0x70]
ldrh r0, [r5]
movs r2, 0x80
lsls r2, 8
adds r1, r2, 0
ands r0, r1
cmp r0, 0
beq _080444DC
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _080444E2
adds r0, r4, 0
bl TickStatusHeal
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _080444DC
adds r0, r4, 0
bl sub_8071DA4
adds r0, r4, 0
movs r1, 0
bl DecideAction
adds r0, r4, 0
bl sub_8072CF4
bl sub_8086AC0
movs r0, 0
bl sub_8043ED0
ldrh r0, [r5]
ldr r2, _080444F0
adds r1, r2, 0
ands r0, r1
movs r2, 0x80
lsls r2, 7
adds r1, r2, 0
orrs r0, r1
strh r0, [r5]
_080444DC:
adds r6, 0x1
cmp r6, 0x13
ble _08044466
_080444E2:
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_080444E8: .4byte gDungeonGlobalData
_080444EC: .4byte 0x000135cc
_080444F0: .4byte 0x00007fff
thumb_func_end sub_8044454
thumb_func_start sub_80444F4
sub_80444F4:
push {r4-r6,lr}
adds r6, r0, 0
bl GetLeaderEntity
cmp r6, r0
bne _08044566
ldr r0, _0804456C
ldr r1, [r0]
ldrb r0, [r1, 0xE]
cmp r0, 0
beq _08044566
movs r0, 0
strb r0, [r1, 0xE]
movs r5, 0
_08044510:
ldr r0, _0804456C
ldr r0, [r0]
lsls r1, r5, 2
ldr r2, _08044570
adds r0, r2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _08044560
cmp r6, r4
beq _08044560
ldr r0, [r4, 0x70]
ldrh r0, [r0]
movs r2, 0x80
lsls r2, 8
adds r1, r2, 0
ands r0, r1
cmp r0, 0
beq _08044560
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _08044566
adds r0, r4, 0
movs r1, 0
bl DecideAction
adds r0, r4, 0
bl sub_8072CF4
bl sub_8086AC0
movs r0, 0
bl sub_8043ED0
_08044560:
adds r5, 0x1
cmp r5, 0x13
ble _08044510
_08044566:
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_0804456C: .4byte gDungeonGlobalData
_08044570: .4byte 0x000135cc
thumb_func_end sub_80444F4
thumb_func_start sub_8044574
sub_8044574:
@@ -658,180 +336,4 @@ _08044818: .4byte gDungeonGlobalData
_0804481C: .4byte 0x0001357c
thumb_func_end sub_8044574
thumb_func_start sub_8044820
sub_8044820:
push {r4-r7,lr}
mov r7, r8
push {r7}
movs r7, 0
ldr r0, _08044830
mov r8, r0
b _080448FC
.align 2, 0
_08044830: .4byte gSpeedTurns
_08044834:
ldr r4, [r5, 0x70]
ldr r0, [r6]
adds r0, 0xB8
str r5, [r0]
bl TriggerWeatherAbilities
ldrh r2, [r4]
movs r1, 0x80
lsls r1, 8
adds r0, r1, 0
ands r0, r2
cmp r0, 0
bne _080448FA
movs r1, 0x80
lsls r1, 7
adds r0, r1, 0
ands r0, r2
lsls r0, 16
lsrs r1, r0, 16
cmp r1, 0
beq _0804486C
ldr r1, _08044868
adds r0, r1, 0
ands r0, r2
strh r0, [r4]
b _080448FA
.align 2, 0
_08044868: .4byte 0x0000bfff
_0804486C:
movs r2, 0xA2
lsls r2, 1
adds r0, r4, r2
strb r1, [r0]
adds r0, r5, 0
bl GetMovementSpeed
ldr r1, [r6]
movs r2, 0xCC
lsls r2, 3
adds r1, r2
movs r2, 0
ldrsh r1, [r1, r2]
lsls r1, 1
movs r2, 0x32
muls r0, r2
adds r1, r0
add r1, r8
movs r2, 0
ldrsh r0, [r1, r2]
cmp r0, 0
beq _080448FA
movs r1, 0xA4
lsls r1, 1
adds r0, r4, r1
ldrb r0, [r0]
cmp r0, 0
bne _080448FA
ldrh r1, [r4]
ldr r2, _08044984
adds r0, r2, 0
ands r1, r0
movs r0, 0
strh r1, [r4]
ldr r2, _08044988
adds r1, r4, r2
strb r0, [r1]
adds r0, r5, 0
bl TickStatusHeal
adds r0, r5, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _080448FA
adds r0, r5, 0
bl sub_8071DA4
adds r0, r5, 0
movs r1, 0
bl DecideAction
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _08044924
adds r0, r5, 0
bl sub_8072CF4
bl sub_8086AC0
movs r0, 0
bl sub_8043ED0
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _08044924
_080448FA:
adds r7, 0x1
_080448FC:
cmp r7, 0xF
bgt _08044924
ldr r6, _0804498C
ldr r0, [r6]
lsls r1, r7, 2
ldr r2, _08044990
adds r0, r2
adds r0, r1
ldr r5, [r0]
adds r0, r5, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _080448FA
bl sub_8044B28
lsls r0, 24
cmp r0, 0
beq _08044834
_08044924:
bl sub_8044B28
lsls r0, 24
cmp r0, 0
bne _0804497A
movs r7, 0
_08044930:
ldr r0, _0804498C
ldr r0, [r0]
lsls r1, r7, 2
ldr r2, _08044990
adds r0, r2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _08044974
ldr r0, [r4, 0x70]
movs r1, 0xA2
lsls r1, 1
adds r5, r0, r1
ldrb r0, [r5]
cmp r0, 0
beq _08044974
adds r0, r4, 0
bl sub_8074094
adds r0, r4, 0
bl EntityExists
lsls r0, 24
cmp r0, 0
beq _08044974
adds r0, r4, 0
bl sub_8071DA4
movs r0, 0
strb r0, [r5]
_08044974:
adds r7, 0x1
cmp r7, 0xF
ble _08044930
_0804497A:
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08044984: .4byte 0x00003fff
_08044988: .4byte 0x00000145
_0804498C: .4byte gDungeonGlobalData
_08044990: .4byte 0x0001358c
thumb_func_end sub_8044820
.align 2, 0

View File

@@ -3,7 +3,7 @@
#include "dungeon_entity.h"
void DecideAction(struct DungeonEntity *pokemon);
void DecideAction(struct DungeonEntity *pokemon, u32 unused);
u8 sub_8075BF4(struct DungeonEntity * pokemon, s32 param_2);
#endif

View File

@@ -1,7 +1,9 @@
#ifndef GUARD_DUNGEON_ENGINE_H
#define GUARD_DUNGEON_ENGINE_H
bool8 IsBossBattle();
bool8 IsFixedDungeon();
bool8 IsBossBattle(void);
bool8 IsFixedDungeon(void);
bool8 sub_8044210(void);
void RunDungeon(bool8 param_1);
#endif

View File

@@ -166,7 +166,7 @@ struct DungeonEntityData
/* 0xF5 */ bool8 exposedStatus;
/* 0xF6 */ bool8 isColorChanged;
/* 0xF7 */ bool8 isBoss;
/* 0xF8 */ u8 unkF8;
/* 0xF8 */ bool8 movementSpeedChanged; // Toggled when pokemon is movement speed is sped up
/* 0xF9 */ u8 unkF9;
/* 0xFA */ u8 terrifiedTurnsLeft; // Doubles as a bool for whether the Pokémon is terrified.
u8 unkFB;
@@ -301,6 +301,7 @@ enum MovementFlag
{
MOVEMENT_FLAG_SWAPPED_PLACES = 1 << 5,
MOVEMENT_FLAG_MOVING = 1 << 9,
MOVEMENT_FLAG_UNK_14 = 1 << 14,
MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED = 1 << 15 // Set if the Pokémon is petrified and the leader cures them by swapping places.
};

View File

@@ -33,12 +33,16 @@ struct DungeonGlobalData
u8 unk8;
u8 fill9[0xC - 0x9];
u8 unkC;
u8 unkD[0xF - 0xD];
u8 unkD;
u8 unkE;
/* 0xF */ bool8 inputAllowed; // Whether the game is currently accepting input. Set to false while action animations play.
u8 unk10;
u8 unk11;
s16 unk12;
u8 fill14[0x16D - 0x14];
u8 fill14[0xB8 - 0x14];
struct DungeonEntity *unkB8;
u32 unkBC;
u8 fillC0[0x16D - 0xC0];
u8 unk16D;
u8 fill16E[0x179 - 0x16E];
/* 0x179 */ bool8 pokemonExposed; // True if a Pokémon on the floor has the Exposed status.
@@ -57,12 +61,13 @@ struct DungeonGlobalData
/* 0x666 */ u16 turnsLeft; // Turns remaining before getting swept out of the dungeon.
u8 fill668[0x66A - 0x668];
u16 unk66A;
u8 fill66C[0x66E - 0x66C];
u8 unk66C;
u8 unk66D;
/* 0x66E */ u8 unk66E;
u8 fill66F[0x671 - 0x66F];
/* 0x671 */ bool8 monsterHouseActive;
/* 0x672 */ u8 unk672;
u8 fill673[0x674 - 0x673];
u8 unk673;
u8 unk674;
u8 unk675;
/* 0x676 */ bool8 itemHoldersIdentified;
@@ -96,7 +101,7 @@ struct DungeonGlobalData
/* 0xE26F */ u8 startingWeather[8]; // The weather at the start of the floor. If the weather changes, then expires, revert back to the starting weather.
/* 0xE277 */ u8 mudSportTurnsLeft;
/* 0xE278 */ u8 waterSportTurnsLeft;
/* 0xE279 */ u8 negateWeatherEffects; // Air Lock and Cloud Nine toggle this to disable weather effects
/* 0xE279 */ bool8 negateWeatherEffects; // Air Lock and Cloud Nine toggle this to disable weather effects
u8 fillE27A[0xE8C0 - 0xE27A];
/* 0xE8C0 */ struct MapTile* mapTilePointers[DUNGEON_MAX_SIZE_Y][DUNGEON_MAX_SIZE_X];
u8 fill104C0[0x104C4 - 0x104C0];

View File

@@ -3,6 +3,7 @@
#include "dungeon_entity.h"
s32 GetMovementSpeed(struct DungeonEntity *pokemon);
bool8 HasNegativeStatus(struct DungeonEntity *pokemon);
bool8 IsSleeping(struct DungeonEntity *pokemon);
bool8 HasQuarterHPOrLess(struct DungeonEntity *pokemon);

View File

@@ -15,7 +15,7 @@ void sub_8045BF8(u8 *, struct ItemSlot *);
void sub_8045ACC(void)
{
struct DungeonEntity *uVar2;
struct DungeonEntity *entity;
s32 index;
s32 pokeCount;
@@ -23,18 +23,18 @@ void sub_8045ACC(void)
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
uVar2 = gDungeonGlobalData->teamPokemon[index];
if (EntityExists(uVar2)) {
gDungeonGlobalData->allPokemon[pokeCount] = uVar2;
entity = gDungeonGlobalData->teamPokemon[index];
if (EntityExists(entity)) {
gDungeonGlobalData->allPokemon[pokeCount] = entity;
pokeCount++;
}
}
for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++)
{
uVar2 = gDungeonGlobalData->wildPokemon[index];
if (EntityExists(uVar2)) {
gDungeonGlobalData->allPokemon[pokeCount] = uVar2;
entity = gDungeonGlobalData->wildPokemon[index];
if (EntityExists(entity)) {
gDungeonGlobalData->allPokemon[pokeCount] = entity;
pokeCount++;
}
}
@@ -43,32 +43,32 @@ void sub_8045ACC(void)
}
}
s32 GetTeamMemberEntityIndex(struct DungeonEntity *entity)
s32 GetTeamMemberEntityIndex(struct DungeonEntity *pokemon)
{
struct DungeonEntity *uVar2;
struct DungeonEntity *entity;
s32 index;
for(index = 0; index < MAX_TEAM_MEMBERS; index++)
{
uVar2 = gDungeonGlobalData->teamPokemon[index];
if (entity == uVar2)
entity = gDungeonGlobalData->teamPokemon[index];
if (pokemon == entity)
return index;
}
return -1;
}
void SetMessageArgument(char *buffer, struct DungeonEntity *entity, u32 param_3)
void SetMessageArgument(char *buffer, struct DungeonEntity *pokemon, u32 param_3)
{
switch(GetEntityType(entity))
switch(GetEntityType(pokemon))
{
case ENTITY_POKEMON:
SetMessageArgument_2(buffer, entity->entityData, param_3);
SetMessageArgument_2(buffer, pokemon->entityData, param_3);
break;
case ENTITY_ITEM:
sub_8045BF8(buffer, GetItemData_1(entity));
sub_8045BF8(buffer, GetItemData_1(pokemon));
break;
case ENTITY_TRAP:
GetTrapName(buffer, *((u8 *)GetTrapData_1(entity)));
GetTrapName(buffer, *((u8 *)GetTrapData_1(pokemon)));
break;
default:
strcpy(buffer, *gUnknown_80FE6F4);

View File

@@ -170,7 +170,6 @@ extern void sub_80522F4(struct DungeonEntity *pokemon, struct DungeonEntity *r1,
extern void DungeonEntityUpdateStatusSprites(struct DungeonEntity *);
extern void sub_8042A74(struct DungeonEntity *r0);
extern void sub_8076CB4(u32);
extern s32 GetMovementSpeed(struct DungeonEntity *);
extern void sub_807EC28(u32);
extern s32 sub_8069F54(struct DungeonEntity *param_1, s16 param_2);
extern u32 sub_80687D0(s16);

View File

@@ -1,10 +1,10 @@
#include "global.h"
#include "dungeon_global_data.h"
void sub_807FC3C(struct Position *param_1, u32 param_2, u32 param_3)
void sub_807FC3C(struct Position *pos, u32 param_2, u32 param_3)
{
gDungeonGlobalData->unk13574 = param_1->x;
gDungeonGlobalData->unk13576 = param_1->y;
gDungeonGlobalData->unk13574 = pos->x;
gDungeonGlobalData->unk13576 = pos->y;
gDungeonGlobalData->unk13578 = param_2;
gDungeonGlobalData->unk13579 = param_3;
gDungeonGlobalData->unk13570 = 1;

View File

@@ -3,6 +3,7 @@
#include "constants/ability.h"
#include "constants/dungeon_action.h"
#include "dungeon_ai.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "dungeon_leader.h"
@@ -10,6 +11,7 @@
#include "dungeon_pokemon_attributes.h"
#include "pokemon.h"
#include "item.h"
#include "status_checks_1.h"
extern u8 *gUnknown_80F91EC[];
extern u8 *gUnknown_80F7C50[];
@@ -32,6 +34,73 @@ extern void sub_8043ED0(u32);
extern void sub_807EAA0(u32, u32);
extern void UseAttack(u32);
extern void sub_8071B48(void);
extern void TriggerWeatherAbilities(void);
extern void sub_8074094(struct DungeonEntity *);
extern void sub_8071DA4(struct DungeonEntity *);
extern u8 sub_8072CF4(struct DungeonEntity *);
extern void TickStatusHeal(struct DungeonEntity *);
void sub_8044820(void)
{
s32 movSpeed;
struct DungeonEntityData *entityData;
struct DungeonEntityData *entityData2;
struct DungeonEntity * entity;
struct DungeonEntity * entity2;
s32 index;
for (index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++) {
entity = gDungeonGlobalData->wildPokemon[index];
if (EntityExists(entity)) {
if (sub_8044B28()) break;
entityData = entity->entityData;
gDungeonGlobalData->unkB8 = entity;
TriggerWeatherAbilities();
if ((entityData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED) == 0) {
if ((u16)(entityData->flags & MOVEMENT_FLAG_UNK_14) != 0) {
entityData->flags &= ~(MOVEMENT_FLAG_UNK_14);
}
else
{
entityData->movingIntoTarget = FALSE;
movSpeed = GetMovementSpeed(entity);
if (gSpeedTurns[movSpeed][gDungeonGlobalData->speedTurnCounter] != 0) {
if (!entityData->attacking) {
entityData->flags &= ~(MOVEMENT_FLAG_UNK_14 | MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED);
entityData->recalculateFollow = FALSE;
TickStatusHeal(entity);
if (EntityExists(entity)) {
sub_8071DA4(entity);
DecideAction(entity, 0);
if (sub_8044B28()) break;
sub_8072CF4(entity);
sub_8086AC0();
sub_8043ED0(0);
if (sub_8044B28()) break;
}
}
}
}
}
}
}
if (sub_8044B28() == 0) {
for(index = 0; index < DUNGEON_MAX_WILD_POKEMON; index++)
{
entity2 = gDungeonGlobalData->wildPokemon[index];
if ((EntityExists(entity2)) && (entityData2 = entity2->entityData, entityData2->movingIntoTarget))
{
sub_8074094(entity2);
if (EntityExists(entity2)) {
sub_8071DA4(entity2);
entityData2->movingIntoTarget = FALSE;
}
}
}
}
}
void CheckElectricAbilities(void)
{
struct DungeonEntityData * entityData;
@@ -65,14 +134,14 @@ void CheckElectricAbilities(void)
isNotEnemy = TRUE;
}
if (HasAbility(entity, ABILITY_LIGHTNINGROD)) { // ABILITY_LIGHTNINGROD
if (HasAbility(entity, ABILITY_LIGHTNINGROD)) {
gDungeonGlobalData->lightningRodPokemon = entity;
gDungeonGlobalData->unk17B38 = entityData2->unk98;
}
if (HasAbility(entity, ABILITY_MINUS)) { // ABILITY_MINUS
if (HasAbility(entity, ABILITY_MINUS)) {
gDungeonGlobalData->hasMinus[isNotEnemy] = TRUE;
}
if (HasAbility(entity, ABILITY_PLUS)) { // ABILITY_PLUS
if (HasAbility(entity, ABILITY_PLUS)) {
gDungeonGlobalData->hasPlus[isNotEnemy] = TRUE;
}
}

View File

@@ -162,7 +162,7 @@ void sub_8075900(struct DungeonEntity *pokemon, u8 r1)
}
}
void DecideAction(struct DungeonEntity *pokemon)
void DecideAction(struct DungeonEntity *pokemon, u32 unused)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED)

View File

@@ -1,15 +1,35 @@
#include "global.h"
#include "dungeon_entity.h"
#include "dungeon_engine.h"
#include "constants/dungeon.h"
#include "dungeon_global_data.h"
#include "dungeon_ai.h"
#include "dungeon_leader.h"
#include "dungeon_util.h"
#include "status_checks_1.h"
extern s16 gSpeedTurns[2][25];
extern bool8 sub_8044B28(void);
extern bool8 xxx_dungeon_80442D0(u8);
extern void CheckElectricAbilities(void);
extern void sub_807E378(void);
extern void sub_8044574(void);
extern void sub_8044820(void);
extern void sub_8044AB4(void);
extern u8 UseAttack(u32);
extern u8 sub_8072CF4(struct DungeonEntity *);
extern void TickStatusHeal(struct DungeonEntity *);
extern void sub_8086AC0(void);
extern void sub_8043ED0(u32);
extern void sub_8071DA4(struct DungeonEntity *);
extern void TriggerWeatherAbilities(void);
extern void sub_805D8C8(void);
extern void sub_805F02C(void);
extern void sub_803E46C(u32);
static void sub_8044454(void);
static bool8 xxx_dungeon_80442D0(bool8);
bool8 IsBossBattle()
{
@@ -37,7 +57,7 @@ bool8 sub_8044210(void)
return FALSE;
}
void RunDungeon(u8 param_1)
void RunDungeon(bool8 param_1)
{
bool8 cVar2;
@@ -69,3 +89,134 @@ void RunDungeon(u8 param_1)
}
}
}
static bool8 xxx_dungeon_80442D0(bool8 param_1)
{
struct DungeonEntityData *entityData;
struct DungeonEntity *entity;
s32 movSpeed;
entity = GetLeaderEntity();
if (entity == NULL) {
return FALSE;
}
else
{
TriggerWeatherAbilities();
movSpeed = GetMovementSpeed(entity);
if (gSpeedTurns[movSpeed][gDungeonGlobalData->speedTurnCounter] == 0) {
return FALSE;
}
else
{
if (entity->entityData->attacking) {
return FALSE;
}
else
{
while (1) {
if(entity = GetLeaderEntity(), entity == NULL)
{
return FALSE;
}
else
{
if ((UseAttack(0) == 0) &&
((gDungeonGlobalData->unk66C != 0 ||
(gDungeonGlobalData->unk673 != 0)))) {
sub_803E46C(0xc);
}
entity->entityData->movementSpeedChanged = FALSE;
if (sub_8044B28()) return FALSE;
gDungeonGlobalData->unkB8 = entity;
gDungeonGlobalData->unkBC = 0;
if (param_1) {
param_1 = FALSE;
}
else {
TickStatusHeal(entity);
}
if (sub_8044B28()) return FALSE;
sub_8071DA4(entity);
gDungeonGlobalData->inputAllowed = TRUE;
sub_805D8C8();
gDungeonGlobalData->inputAllowed = FALSE;
if (sub_8044B28()) break;
sub_8072CF4(entity);
sub_8086AC0();
sub_8043ED0(0);
if (sub_8044B28()) break;
entityData = entity->entityData;
if ((entityData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED)) {
entity->entityData->flags = (entityData->flags & ~(MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED)) | MOVEMENT_FLAG_UNK_14;
}
if (sub_8044B28() ) break;
sub_8044454();
if (sub_8044B28()) break;
if (gDungeonGlobalData->unkBC != 0) {
sub_805F02C();
gDungeonGlobalData->unkBC = 0;
param_1 = TRUE;
}
else {
if (!entity->entityData->movementSpeedChanged) break;
gDungeonGlobalData->speedTurnCounter = 0;
}
}
}
}
}
}
return TRUE;
}
static void sub_8044454(void)
{
struct DungeonEntity *entity;
struct DungeonEntityData *entityData;
s32 index;
if (gDungeonGlobalData->unkE) {
gDungeonGlobalData->unkE = 0;
for(index = 0; index < DUNGEON_MAX_POKEMON; index++)
{
entity = gDungeonGlobalData->allPokemon[index];
if ((EntityExists(entity)) && (entityData = entity->entityData, (entityData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED))) {
if (sub_8044B28()) break;
TickStatusHeal(entity);
if (EntityExists(entity)) {
sub_8071DA4(entity);
DecideAction(entity, 0);
sub_8072CF4(entity);
sub_8086AC0();
sub_8043ED0(0);
entityData->flags = (entityData->flags & ~(MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED)) | MOVEMENT_FLAG_UNK_14;
}
}
}
}
}
void sub_80444F4(struct DungeonEntity *pokemon)
{
struct DungeonEntity *entity;
struct DungeonEntityData *entityData;
s32 index;
if (pokemon == GetLeaderEntity() && gDungeonGlobalData->unkE) {
gDungeonGlobalData->unkE = 0;
for(index = 0; index < DUNGEON_MAX_POKEMON; index++)
{
entity = gDungeonGlobalData->allPokemon[index];
if ((EntityExists(entity)) && (pokemon != entity) && (entityData = entity->entityData, (entityData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED))) {
if (sub_8044B28()) break;
DecideAction(entity, 0);
sub_8072CF4(entity);
sub_8086AC0();
sub_8043ED0(0);
}
}
}
}

View File

@@ -13,6 +13,7 @@
#include "code_808417C.h"
#include "code_8077274_1.h"
#include "map.h"
#include "status_checks_1.h"
extern u8 gAvailablePokemonNames[];
extern u8 gUnknown_202DE58[];
@@ -148,7 +149,6 @@ extern void sub_8041BE8(struct DungeonEntity *);
extern void sub_8041CCC(struct DungeonEntity *);
extern void sub_8041CB8(struct DungeonEntity *r0);
extern void sub_8041C1C(struct DungeonEntity *r0);
extern s32 GetMovementSpeed(struct DungeonEntity *);
extern void sub_8042060(struct DungeonEntity *, s32);
extern bool8 sub_8071728(struct DungeonEntity * param_1, struct DungeonEntity * param_2, u8 param_3);
extern void sub_8041FB4(struct DungeonEntity *r0, u32 r1);
@@ -439,7 +439,7 @@ void sub_8077780(struct DungeonEntity * pokemon, struct DungeonEntity * target,
SetMessageArgument(gAvailablePokemonNames,target,0);
if (entityData->nonVolatileStatus != NON_VOLATILE_STATUS_PARALYZED) {
entityData->nonVolatileStatus = NON_VOLATILE_STATUS_PARALYZED;
entityData->nonVolatileStatusTurnsLeft = CalculateStatusTurns(target,gUnknown_80F4E50,1) + 1;
entityData->nonVolatileStatusTurnsLeft = CalculateStatusTurns(target,gUnknown_80F4E50,TRUE) + 1;
entityData->nonVolatileStatusDamageTimer = 0;
entityData->fillAF = 0;
bVar6 = FALSE;
@@ -485,7 +485,7 @@ void sub_8077910(struct DungeonEntity * pokemon, struct DungeonEntity * target,
return;
}
if (turns == 0) {
turns = CalculateStatusTurns(target,gUnknown_80F4E40,0) + 1;
turns = CalculateStatusTurns(target,gUnknown_80F4E40,FALSE) + 1;
}
entityData = target->entityData;
SetMessageArgument(gAvailablePokemonNames,target,0);
@@ -511,7 +511,7 @@ void sub_8077910(struct DungeonEntity * pokemon, struct DungeonEntity * target,
{
sub_8041CB8(target);
sub_80522F4(pokemon,target,gUnknown_80FA124[movSpeed_1]);
entityData->unkF8 = 1;
entityData->movementSpeedChanged = TRUE;
entityData->attacking = FALSE;
}
}
@@ -545,7 +545,7 @@ void sub_80779F0(struct DungeonEntity * pokemon, struct DungeonEntity * target,
for(index = 0; index < NUM_SPEED_TURN_COUNTERS; index++)
{
if (entityData->slowTurnsLeft[index]== 0) {
entityData->slowTurnsLeft[index] = CalculateStatusTurns(target,gUnknown_80F4E48,1) + 1;
entityData->slowTurnsLeft[index] = CalculateStatusTurns(target,gUnknown_80F4E48,TRUE) + 1;
break;
}
}
@@ -593,7 +593,7 @@ void sub_8077AE4(struct DungeonEntity * pokemon, struct DungeonEntity * target,
entityData = target->entityData;
if (entityData->volatileStatus != VOLATILE_STATUS_CONFUSED) {
entityData->volatileStatus = VOLATILE_STATUS_CONFUSED;
entityData->volatileStatusTurnsLeft = CalculateStatusTurns(target,gUnknown_80F4E4C,1) + 1;
entityData->volatileStatusTurnsLeft = CalculateStatusTurns(target,gUnknown_80F4E4C,TRUE) + 1;
sub_80522F4(pokemon,target,*gUnknown_80FB25C);
}
else {
@@ -613,7 +613,7 @@ void sub_8077BB4(struct DungeonEntity * pokemon, struct DungeonEntity * target,
SetMessageArgument(gAvailablePokemonNames,target,0);
if (entityData->volatileStatus != VOLATILE_STATUS_COWERING) {
entityData->volatileStatus = VOLATILE_STATUS_COWERING;
entityData->volatileStatusTurnsLeft = CalculateStatusTurns(target,gUnknown_80F4ECC,1) + 1;
entityData->volatileStatusTurnsLeft = CalculateStatusTurns(target,gUnknown_80F4ECC,TRUE) + 1;
sub_8041BF8(target);
sub_80522F4(pokemon,target,*gUnknown_80FB940);
}
@@ -1130,7 +1130,7 @@ void sub_80787E4(struct DungeonEntity * pokemon, struct DungeonEntity * target)
if ((EntityExists(target))) {
entityData = target->entityData;
SetMessageArgument(gAvailablePokemonNames,target,0);
if (entityData->stockpileCount < 3) {
if (entityData->stockpileCount < MAX_STOCKPILE_COUNT) {
entityData->stockpileCount++;
sub_804178C(1);
sub_8041D5C(target);
@@ -1178,7 +1178,7 @@ void PerishSongTarget(struct DungeonEntity * pokemon, struct DungeonEntity * tar
entityData = target->entityData;
SetMessageArgument(gAvailablePokemonNames,target,0);
if (entityData->perishSongTimer == 0) {
entityData->perishSongTimer = CalculateStatusTurns(target,gUnknown_80F4EEC,0) + 1;
entityData->perishSongTimer = CalculateStatusTurns(target,gUnknown_80F4EEC,FALSE) + 1;
sub_80522F4(pokemon,target,*gUnknown_80FBB04);
}
else {

View File

@@ -105,7 +105,7 @@ bool8 sub_80706A4(struct DungeonEntity *pokemon, struct Position *pos)
return TRUE;
}
u32 GetMovementSpeed(struct DungeonEntity *pokemon)
s32 GetMovementSpeed(struct DungeonEntity *pokemon)
{
s32 index;
s32 speed;