Decomped GetLeaderEntity()

This commit is contained in:
AnonymousRandomPerson 2022-10-16 22:00:14 -04:00
parent d93c95ac80
commit b1e02bd9ef
13 changed files with 1486 additions and 1491 deletions

File diff suppressed because it is too large Load Diff

1437
asm/code_8083654.s Normal file

File diff suppressed because it is too large Load Diff

6
include/dungeon_leader.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef GUARD_DUNGEON_LEADER_H
#define GUARD_DUNGEON_LEADER_H
struct DungeonEntity* GetLeaderEntity();
#endif

View File

@ -5,6 +5,6 @@
bool8 HasNegativeStatus(struct DungeonEntity *pokemon);
bool8 IsSleeping(struct DungeonEntity *pokemon);
bool8 HasQuarterHPOrLess(struct DungeonEntity* pokemon);
bool8 HasQuarterHPOrLess(struct DungeonEntity *pokemon);
#endif

View File

@ -3,6 +3,6 @@
#include "dungeon_entity.h"
u8 GetWeather(struct DungeonEntity* pokemon);
u8 GetWeather(struct DungeonEntity *pokemon);
#endif

View File

@ -264,6 +264,8 @@ SECTIONS {
src/code_8083288.o(.text);
src/dungeon_range.o(.text);
asm/code_808333C.o(.text);
src/dungeon_leader.o(.text);
asm/code_8083654.o(.text);
src/dungeon_random.o(.text);
src/code_808417C.o(.text);
asm/code_808417C.o(.text);

View File

@ -15,6 +15,7 @@
#include "dungeon_ai_movement.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_global_data.h"
#include "dungeon_leader.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
@ -41,7 +42,6 @@ extern void sub_807AB38(struct DungeonEntity *, u32);
extern void sub_8041888(u32);
extern u8 sub_803F428(s16 *);
extern void sub_803E708(u32, u32);
extern struct DungeonEntity *GetLeaderEntity();
extern u8 sub_8075CFC(struct DungeonEntity *, struct DungeonEntity *, u32, u32);
extern void sub_8041AF4(struct DungeonEntity *);
extern void sub_80522F4(struct DungeonEntity *r1, struct DungeonEntity *r2, u8 *);
@ -300,7 +300,7 @@ u8 sub_8075BF4(struct DungeonEntity * pokemon, s32 sleepTurns)
{
struct DungeonEntityData *entityData;
u32 uVar4;
uVar4 = 0;
if (!EntityExists(pokemon)){
return uVar4;
@ -331,7 +331,7 @@ void sub_8075C58(struct DungeonEntity * pokemon, struct DungeonEntity * target,
{
u8 sleepStatus;
u8 cVar2;
if (sub_8075CFC(pokemon,target,1,param_4) == '\0') {
sleepStatus = target->entityData->sleepStatus;

View File

@ -280,7 +280,7 @@ void FindStraightThrowableTargets(struct DungeonEntity *pokemon, s32 thrownAIFla
}
for (i = 0; i < DUNGEON_MAX_POKEMON; i++)
{
struct DungeonEntity* targetPokemon = gDungeonGlobalData->allPokemon[i];
struct DungeonEntity *targetPokemon = gDungeonGlobalData->allPokemon[i];
if (EntityExists(targetPokemon) && pokemon != targetPokemon)
{
s32 targetingFlags;
@ -317,7 +317,7 @@ void FindRockItemTargets(struct DungeonEntity *pokemon, struct ItemSlot *item, s
gNumPotentialTargets = 0;
for (i = 0; i < DUNGEON_MAX_POKEMON; i++)
{
struct DungeonEntity* targetPokemon = gDungeonGlobalData->allPokemon[i];
struct DungeonEntity *targetPokemon = gDungeonGlobalData->allPokemon[i];
if (EntityExists(targetPokemon) && pokemon != targetPokemon &&
CanSee(pokemon, targetPokemon) && CanTarget(pokemon, targetPokemon, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
{

View File

@ -4,11 +4,10 @@
#include "constants/status.h"
#include "constants/targeting.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_leader.h"
#include "dungeon_visibility.h"
#include "pokemon_3.h"
extern struct DungeonEntity* GetLeaderEntity();
bool8 TargetLeader(struct DungeonEntity *pokemon)
{
if (pokemon->entityData->isEnemy)

View File

@ -2,8 +2,9 @@
#include "dungeon_items.h"
#include "dungeon_capabilities.h"
#include "dungeon_random.h"
#include "dungeon_global_data.h"
#include "dungeon_leader.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "team_inventory.h"
#include "pokemon.h"
@ -18,7 +19,6 @@ extern u8 *gUnknown_8105434[];
extern u8 sub_8046D70(void);
extern s32 sub_8052B8C(u32, u8 *, u32);
extern struct DungeonEntity *GetLeaderEntity(void);
extern void sub_80861A8(void);
extern void PrintFieldMessage(u32, u8 *, u32);
extern void sub_803E708(u32, u32);
@ -103,7 +103,7 @@ void MusicBoxCreation(void)
struct DungeonEntity *entity;
s32 indexes[3];
createMusicBox = FALSE;
do {
musicBoxOnce = FALSE;

27
src/dungeon_leader.c Normal file
View File

@ -0,0 +1,27 @@
#include "global.h"
#include "dungeon_leader.h"
#include "dungeon_global_data.h"
#include "dungeon_util.h"
extern struct DungeonEntity *gLeaderPokemon;
struct DungeonEntity* GetLeaderEntity()
{
struct DungeonEntity *leader = gLeaderPokemon;
if (leader == NULL)
{
s32 i = 0;
do
{
struct DungeonEntity *currentPokemon = gDungeonGlobalData->teamPokemon[i];
if (EntityExists(currentPokemon) && currentPokemon->entityData->isLeader)
{
gLeaderPokemon = currentPokemon;
return currentPokemon;
}
} while (++i < MAX_TEAM_MEMBERS);
return NULL;
}
return leader;
}

View File

@ -171,7 +171,7 @@ bool8 IsSleeping(struct DungeonEntity *pokemon)
return TRUE;
}
bool8 HasQuarterHPOrLess(struct DungeonEntity* pokemon)
bool8 HasQuarterHPOrLess(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
struct DungeonEntityData *pokemonData2 = pokemon->entityData;

View File

@ -11,7 +11,7 @@ extern void TriggerWeatherAbilities(void);
extern void sub_807EAA0(u32, u32);
void sub_807E5E4(u8);
u8 GetWeather(struct DungeonEntity* pokemon)
u8 GetWeather(struct DungeonEntity *pokemon)
{
if (pokemon != NULL && HasItem(pokemon, ITEM_ID_WEATHER_BAND))
{