blob: b2e3b2ebb8506dcb34860d6f0b37174e5649a850 (
plain)
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
|
#include "global.h"
#include "dungeon_ai.h"
#include "constants/ability.h"
#include "constants/tactic.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
extern void CheckRunAwayVisualFlag(struct DungeonEntity *, bool8 showRunAwayEffect);
bool8 ShouldAvoidFirstHit(struct DungeonEntity *pokemon, bool8 forceAvoid)
{
if (!HasTactic(pokemon, TACTIC_AVOID_THE_FIRST_HIT))
return FALSE;
if (!forceAvoid)
return FALSE;
return TRUE;
}
bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon)
{
if (!EntityExists(pokemon))
{
return FALSE;
}
else
{
struct DungeonEntityData *pokemonData = pokemon->entityData;
if (pokemonData->terrifiedTurnsLeft != 0)
{
return TRUE;
}
if (pokemonData->isLeader)
{
return FALSE;
}
if (HasAbility(pokemon, ABILITY_RUN_AWAY))
{
bool8 runAwayActive = pokemonData->HP < pokemonData->maxHP / 2;
if (runAwayActive)
{
return TRUE;
}
}
if (HasTactic(pokemon, TACTIC_GET_AWAY) ||
(HasTactic(pokemon, TACTIC_AVOID_TROUBLE) && pokemonData->HP <= pokemonData->maxHP / 2))
{
return TRUE;
}
return FALSE;
}
}
bool8 ShouldAvoidEnemiesAndShowEffect(struct DungeonEntity *pokemon, bool8 showRunAwayEffect)
{
if (ShouldAvoidEnemies(pokemon))
{
CheckRunAwayVisualFlag(pokemon, showRunAwayEffect);
return TRUE;
}
return FALSE;
}
|