diff options
author | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-02-13 23:13:47 -0500 |
---|---|---|
committer | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-02-13 23:15:33 -0500 |
commit | 2a2a0805b481b8425b4d1047d868fb1159993e6c (patch) | |
tree | aacd438bd14b32c816c54a564785fd9716e70fae /src/dungeon_pokemon_attributes.c | |
parent | 3bbb6035e746cdb83b128b1d6153436756cb3be0 (diff) |
Decomped HasType()
Diffstat (limited to 'src/dungeon_pokemon_attributes.c')
-rw-r--r-- | src/dungeon_pokemon_attributes.c | 171 |
1 files changed, 169 insertions, 2 deletions
diff --git a/src/dungeon_pokemon_attributes.c b/src/dungeon_pokemon_attributes.c index 9f01c2b..bd3a1f6 100644 --- a/src/dungeon_pokemon_attributes.c +++ b/src/dungeon_pokemon_attributes.c @@ -1,15 +1,27 @@ #include "global.h" #include "dungeon_pokemon_attributes.h" -#include "dungeon_util.h" #include "constants/ability.h" +#include "constants/dungeon.h" +#include "constants/iq_skill.h" +#include "constants/move_id.h" #include "constants/status.h" +#include "constants/tactic.h" +#include "constants/type.h" +#include "dungeon_global_data.h" +#include "dungeon_items.h" +#include "dungeon_util.h" +#include "dungeon_visibility.h" +#include "moves.h" +#include "pokemon.h" +#include "pokemon_3.h" + +const s16 gItemMasterMinWildLevel[] = {16}; extern u8 gAvailablePokemonNames[]; extern u32 gUnknown_80FC31C; extern u32 gUnknown_80FCEFC; extern u32 gUnknown_80FC2FC; - extern bool8 sub_805744C(struct DungeonEntity *, struct PokemonMove *, u32); extern void SetMessageArgument(char[], struct DungeonEntity*, u32); extern void sub_80522F4(struct DungeonEntity *r1, struct DungeonEntity *r2, u32); @@ -90,3 +102,158 @@ bool8 HasAbility(struct DungeonEntity *pokemon, u8 ability) return FALSE; } } + +bool8 HasType(struct DungeonEntity *pokemon, u8 type) +{ + struct DungeonEntityData *pokemonData = pokemonData = pokemon->entityData; + if (type == TYPE_NONE) + { + return FALSE; + } + if (pokemonData->type1 == type) + { + return TRUE; + } + if (pokemonData->type2 == type) + { + return TRUE; + } + return FALSE; +} + +bool8 CanSeeInvisible(struct DungeonEntity *pokemon) +{ + struct DungeonEntityData *pokemonData = pokemon->entityData; + if (pokemonData->eyesightStatus != EYESIGHT_STATUS_EYEDROPS) + { + if (!HasItem(pokemon, ITEM_ID_GOGGLE_SPECS)) + return FALSE; + else + return TRUE; + } + else + return TRUE; +} + +bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic) +{ + struct DungeonEntityData *pokemonData = pokemon->entityData; + if (pokemonData->isLeader) + { + bool8 isGoTheOtherWay = tactic == TACTIC_GO_THE_OTHER_WAY; + return isGoTheOtherWay; + } + return pokemonData->tactic == tactic; +} + +bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill) +{ + return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill); +} + +bool8 HasIQSkillPair(struct DungeonEntity *pokemon, u8 IQSkill1, u8 IQSkill2) +{ + return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill1 | 1 << IQSkill2); +} + +void LoadIQSkills(struct DungeonEntity *pokemon) +{ + u8 *iVar2; + s32 IQSkill; + struct DungeonEntityData *pokemonData; + + pokemonData = pokemon->entityData; + if (pokemonData->isEnemy) { + iVar2 = pokemonData->IQSkillsEnabled; + SetIQSkill(iVar2, IQ_SKILL_STATUS_CHECKER); + SetIQSkill(iVar2, IQ_SKILL_PP_CHECKER); + SetIQSkill(iVar2, IQ_SKILL_ITEM_CATCHER); + if (pokemonData->isBoss) + SetIQSkill(iVar2, IQ_SKILL_SELF_CURER); + if (pokemonData->level >= *gItemMasterMinWildLevel) + SetIQSkill(iVar2, IQ_SKILL_ITEM_MASTER); + pokemonData->tactic = TACTIC_GO_AFTER_FOES; + } + else { + pokemonData->IQSkillsEnabled[0] = 0; + pokemonData->IQSkillsEnabled[1] = 0; + pokemonData->IQSkillsEnabled[2] = 0; + for(IQSkill = IQ_SKILL_TYPE_ADVANTAGE_MASTER; IQSkill < NUM_IQ_SKILLS; IQSkill++) + { + if (HasIQForSkill(pokemonData->IQ,IQSkill) && + IsIQSkillSet(pokemonData->IQSkillsSelected, 1 << IQSkill)) + { + SetIQSkill(pokemonData->IQSkillsEnabled,IQSkill); + } + } + } +} + +bool8 CanSeeTeammate(struct DungeonEntity * pokemon) +{ + struct DungeonEntity *teamMember; + s32 memberIdx; + + if (pokemon->entityData->isEnemy) { + return FALSE; + } + else + { + for(memberIdx = 0; memberIdx < MAX_TEAM_MEMBERS; memberIdx++) + { + teamMember = gDungeonGlobalData->teamPokemon[memberIdx]; + if (EntityExists(pokemon) && (pokemon != teamMember) && (CanSee(pokemon,teamMember))) + { + return TRUE; + } + } + return FALSE; + } +} + +u8 GetMoveTypeForPokemon(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove) +{ + if (pokeMove->moveID == MOVE_HIDDEN_POWER) + return pokemon->entityData->hiddenPowerType; + else + return GetMoveType(pokeMove); +} + +s32 CalculateMovePower(struct DungeonEntity *pokemon, struct PokemonMove *pokeMove) +{ + if(pokeMove->moveID == MOVE_HIDDEN_POWER) + return (pokemon->entityData->hiddenPowerPower + pokeMove->powerBoost); + else + return (GetMovePower(pokeMove) + pokeMove->powerBoost); +} + +bool8 ToolboxEnabled(struct DungeonEntityData *pokemon) +{ + if(!IsToolboxEnabled(pokemon->entityID)) + return FALSE; + return TRUE; +} + +static inline bool8 sub_8071A8C_sub(struct DungeonEntityData *pokemonData) +{ + if(pokemonData->joinLocation == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON || + pokemonData->joinLocation == DUNGEON_RESCUE_TEAM_BASE) + return TRUE; + else + return FALSE; +} + +bool8 sub_8071A8C(struct DungeonEntity *pokemon) +{ + struct DungeonEntityData *pokemonData; + if(EntityExists(pokemon)) + { + pokemonData = pokemon->entityData; + if(pokemonData->clientType != CLIENT_TYPE_CLIENT) + { + if(!sub_8071A8C_sub(pokemonData)) + return TRUE; + } + } + return FALSE; +} |