summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dungeon_ai_items.c1
-rw-r--r--src/dungeon_pokemon_attributes_1.c124
-rw-r--r--src/dungeon_random.c5
-rw-r--r--src/dungeon_random_1.c9
-rw-r--r--src/moves.c2
5 files changed, 136 insertions, 5 deletions
diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c
index fc10e85..4afc928 100644
--- a/src/dungeon_ai_items.c
+++ b/src/dungeon_ai_items.c
@@ -33,7 +33,6 @@ enum ItemTargetFlag
extern s32 CalculateFacingDir(struct Position*, struct Position*);
extern u32 EvaluateItem(struct DungeonEntity*, struct ItemSlot*, u8);
-extern bool8 ToolboxEnabled(struct DungeonEntityData*);
extern void sub_8077274(struct DungeonEntity *, struct DungeonEntity *);
extern void TargetThrownItem(struct DungeonEntity*, struct DungeonEntity*, struct ItemSlot*, u8, bool8);
diff --git a/src/dungeon_pokemon_attributes_1.c b/src/dungeon_pokemon_attributes_1.c
index 02e9af0..d3b8cab 100644
--- a/src/dungeon_pokemon_attributes_1.c
+++ b/src/dungeon_pokemon_attributes_1.c
@@ -1,12 +1,28 @@
#include "global.h"
+#include "dungeon_global_data.h"
#include "dungeon_pokemon_attributes_1.h"
+#include "dungeon_util.h"
+#include "pokemon.h"
+#include "constants/dungeon.h"
+#include "constants/iq_skill.h"
+#include "constants/move_id.h"
#include "constants/status.h"
#include "constants/tactic.h"
-extern bool8 IsIQSkillSet(u8 *, u32);
+extern s16 gItemMasterMinWildLevel;
+
extern u8 HasItem(struct DungeonEntity *, u32);
+extern bool8 IsIQSkillSet(u8 *, u32);
+extern void SetIQSkill(u8 *param_1, u32 skillIndex);
+extern bool8 HasIQForSkill(s32 pokeIQ, u8 IQSkillIndex);
+
+extern bool8 CanSee(struct DungeonEntity *, struct DungeonEntity *);
+
+extern u8 GetMoveType(struct PokemonMove *move);
+extern s32 GetMovePower(struct PokemonMove *move);
+
bool8 CanSeeInvisible(struct DungeonEntity *pokemon)
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
@@ -32,12 +48,114 @@ bool8 HasTactic(struct DungeonEntity *pokemon, u8 tactic)
return pokemonData->tactic == tactic;
}
-bool8 HasIQSkill(struct DungeonEntity* pokemon, u8 IQSkill)
+bool8 HasIQSkill(struct DungeonEntity *pokemon, u8 IQSkill)
{
return IsIQSkillSet(pokemon->entityData->IQSkillsEnabled, 1 << IQSkill);
}
-bool8 HasIQSkillPair(struct DungeonEntity* pokemon, u8 IQSkill1, u8 IQSkill2)
+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 GetMoveType_2(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;
+}
diff --git a/src/dungeon_random.c b/src/dungeon_random.c
index 86b1c79..6f180d3 100644
--- a/src/dungeon_random.c
+++ b/src/dungeon_random.c
@@ -3,6 +3,11 @@
extern u32 gDungeonRngState;
+void SetDungeonRNG(u32 value)
+{
+ gDungeonRngState = (value | 1);
+}
+
s32 DungeonRandom(void)
{
gDungeonRngState = 1566083941 * gDungeonRngState + 1;
diff --git a/src/dungeon_random_1.c b/src/dungeon_random_1.c
index a6941f3..418a51c 100644
--- a/src/dungeon_random_1.c
+++ b/src/dungeon_random_1.c
@@ -11,3 +11,12 @@ bool8 RollPercentChance(s32 percentChance)
}
return FALSE;
}
+
+bool8 RollPercentChance_2(s32 percentChance)
+{
+ if (DungeonRandomCapped(100) < percentChance)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/src/moves.c b/src/moves.c
index 0f59f0b..e5998db 100644
--- a/src/moves.c
+++ b/src/moves.c
@@ -246,7 +246,7 @@ u8 GetMoveHitCount(struct PokemonMove *move)
return gMovesData[move->moveID].hitCount;
}
-s16 GetMovePower(struct PokemonMove *move)
+s32 GetMovePower(struct PokemonMove *move)
{
return gMovesData[move->moveID].power;
}