1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
#include "global.h"
#include "dungeon_pokemon_attributes.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);
bool8 sub_80716E8(struct DungeonEntity * param_1, struct DungeonEntity * param_2, u8 param_3)
{
if (param_2->entityData->protectionStatus == PROTECTION_STATUS_SAFEGUARD) {
if (param_3 != '\0') {
SetMessageArgument(gAvailablePokemonNames,param_2,0);
sub_80522F4(param_1,param_2,gUnknown_80FC2FC);
}
return TRUE;
}
return FALSE;
}
bool8 sub_8071728(struct DungeonEntity * param_1, struct DungeonEntity * param_2, u8 param_3)
{
if (param_2->entityData->protectionStatus == PROTECTION_STATUS_MIST) {
if (param_3 != '\0') {
SetMessageArgument(gAvailablePokemonNames, param_2, 0);
sub_80522F4(param_1, param_2, gUnknown_80FC31C);
}
return TRUE;
}
else {
if (HasAbility(param_2, ABILITY_CLEAR_BODY) || HasAbility(param_2, ABILITY_WHITE_SMOKE)) {
if (param_3 != '\0') {
SetMessageArgument(gAvailablePokemonNames, param_2, 0);
sub_80522F4(param_1, param_2, gUnknown_80FCEFC);
}
return TRUE;
}
}
return FALSE;
}
bool8 sub_80717A4(struct DungeonEntity *param_1, u16 moveID)
{
struct DungeonEntityData * entityData;
s32 iVar3;
entityData = param_1->entityData;
if ((entityData->sleepStatus != SLEEP_STATUS_SLEEP) && (entityData->sleepStatus != SLEEP_STATUS_NAPPING) && (entityData->sleepStatus != SLEEP_STATUS_NIGHTMARE)) {
return FALSE;
}
else
{
// Pin this register to match
register struct PokemonMove *pokeMove asm("r4");
struct PokemonMove *pokeMove2; // some reason uses another pointer to same struct
for(iVar3 = 0, pokeMove = entityData->moves, pokeMove2 = pokeMove; iVar3 < MAX_MON_MOVES; pokeMove++, pokeMove2++, iVar3++)
{
if (((pokeMove->moveFlags & MOVE_FLAG_EXISTS) != 0) && (entityData->isLeader || ((pokeMove->moveFlags & MOVE_FLAG_ENABLED) != 0)))
if((sub_805744C(param_1, pokeMove2, 1) != '\0') && (pokeMove->PP != 0))
if(pokeMove->moveID == moveID)
return TRUE;
}
return FALSE;
}
}
bool8 HasAbility(struct DungeonEntity *pokemon, u8 ability)
{
if (!EntityExists(pokemon))
{
return FALSE;
}
else
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->ability1 == ability || pokemonData->ability2 == ability)
{
return TRUE;
}
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;
}
|