summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/charge_move.c43
-rw-r--r--src/code_80848F0.c18
-rw-r--r--src/dungeon_ai.c42
-rw-r--r--src/dungeon_capabilities.c25
-rw-r--r--src/dungeon_capabilities_1.c56
-rw-r--r--src/dungeon_movement.c2
-rw-r--r--src/dungeon_pokemon_attributes.c21
-rw-r--r--src/dungeon_pokemon_attributes_1.c15
-rw-r--r--src/dungeon_util_1.c50
-rw-r--r--src/post_office_guide.c20
-rw-r--r--src/wonder_mail_2.c10
11 files changed, 277 insertions, 25 deletions
diff --git a/src/charge_move.c b/src/charge_move.c
new file mode 100644
index 0000000..c17db2b
--- /dev/null
+++ b/src/charge_move.c
@@ -0,0 +1,43 @@
+#include "global.h"
+#include "charge_move.h"
+
+#include "constants/status.h"
+#include "dungeon_util.h"
+
+extern u32 gMultiTurnChargingStatuses[];
+
+bool8 IsCharging(struct DungeonEntity *pokemon, bool8 checkCharge)
+{
+ if (!EntityExists(pokemon))
+ {
+ return FALSE;
+ }
+ else
+ {
+ struct DungeonEntityData *pokemonData = pokemon->entityData;
+ int i = 0;
+ u8 *chargingStatusPointer = &pokemonData->chargingStatus;
+ u8 *chargingStatusPointer2;
+ u8 chargeStatus = CHARGING_STATUS_CHARGE;
+ for (; i < 100; i++)
+ {
+ u8 currentStatus = gMultiTurnChargingStatuses[i];
+ u8 chargingStatus;
+ if (currentStatus == CHARGING_STATUS_NONE)
+ {
+ return FALSE;
+ }
+ chargingStatus = *chargingStatusPointer;
+ chargingStatusPointer2 = &pokemonData->chargingStatus;
+ if (chargingStatus == currentStatus)
+ {
+ return TRUE;
+ }
+ }
+ if (checkCharge && *chargingStatusPointer2 == chargeStatus)
+ {
+ return TRUE;
+ }
+ return FALSE;
+ }
+}
diff --git a/src/code_80848F0.c b/src/code_80848F0.c
index f82c4af..365411a 100644
--- a/src/code_80848F0.c
+++ b/src/code_80848F0.c
@@ -3,11 +3,11 @@
extern struct DungeonGlobalData *gDungeonGlobalData;
-extern void SkarmonyPreFightDialogue();
-extern void SkarmonyReFightDialogue();
+extern void SkarmoryPreFightDialogue();
+extern void SkarmoryReFightDialogue();
extern void sub_8086E40();
-extern void TeamMeaniePreFightDialogue();
-extern void TeamMeanieReFightDialogue();
+extern void TeamMeaniesPreFightDialogue();
+extern void TeamMeaniesReFightDialogue();
extern void sub_8087130();
extern void ZapdosPreFightDialogue();
extern void ZapdosReFightDialogue();
@@ -97,24 +97,24 @@ extern void sub_808B0B0(u8);
void DisplayPreFightDialogue(void)
{
-
+
switch(gDungeonGlobalData->unk3A0D) {
case 0:
break;
case 1:
- SkarmonyPreFightDialogue();
+ SkarmoryPreFightDialogue();
break;
case 2:
- SkarmonyReFightDialogue();
+ SkarmoryReFightDialogue();
break;
case 3:
sub_8086E40();
break;
case 4:
- TeamMeaniePreFightDialogue();
+ TeamMeaniesPreFightDialogue();
break;
case 5:
- TeamMeanieReFightDialogue();
+ TeamMeaniesReFightDialogue();
break;
case 6:
sub_8087130();
diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c
new file mode 100644
index 0000000..6253a64
--- /dev/null
+++ b/src/dungeon_ai.c
@@ -0,0 +1,42 @@
+#include "global.h"
+#include "dungeon_ai.h"
+
+#include "constants/ability.h"
+#include "constants/tactic.h"
+#include "dungeon_pokemon_attributes.h"
+#include "dungeon_pokemon_attributes_1.h"
+#include "dungeon_util.h"
+
+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;
+ }
+}
diff --git a/src/dungeon_capabilities.c b/src/dungeon_capabilities.c
new file mode 100644
index 0000000..7a62149
--- /dev/null
+++ b/src/dungeon_capabilities.c
@@ -0,0 +1,25 @@
+#include "global.h"
+#include "dungeon_capabilities.h"
+
+#include "constants/status.h"
+
+bool8 CannotMove(struct DungeonEntity *pokemon, bool8 checkBlinker)
+{
+ struct DungeonEntityData *pokemonData = pokemon->entityData;
+ if ((checkBlinker && pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER)
+ || pokemonData->sleepStatus == SLEEP_STATUS_SLEEP
+ || pokemonData->sleepStatus == SLEEP_STATUS_NAPPING
+ || pokemonData->sleepStatus == SLEEP_STATUS_NIGHTMARE
+ || pokemonData->volatileStatus == VOLATILE_STATUS_PAUSED
+ || pokemonData->volatileStatus == VOLATILE_STATUS_INFATUATED
+ || pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED)
+ {
+ return TRUE;
+ }
+ if (pokemonData->terrifiedTurnsLeft != 0)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
diff --git a/src/dungeon_capabilities_1.c b/src/dungeon_capabilities_1.c
new file mode 100644
index 0000000..956c6e1
--- /dev/null
+++ b/src/dungeon_capabilities_1.c
@@ -0,0 +1,56 @@
+#include "global.h"
+#include "dungeon_capabilities_1.h"
+
+#include "constants/dungeon.h"
+#include "constants/status.h"
+#include "charge_move.h"
+#include "dungeon_ai.h"
+#include "dungeon_capabilities.h"
+
+static inline bool8 JoinLocationCannotUseItems(struct DungeonEntityData *pokemonData)
+{
+ if (pokemonData->joinLocation == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
+ {
+ return TRUE;
+ }
+ if (pokemonData->joinLocation == DUNGEON_RESCUE_TEAM_BASE)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+bool8 CannotUseItems(struct DungeonEntity *pokemon)
+{
+ struct DungeonEntityData *pokemonData = pokemon->entityData;
+ if (pokemonData->clientType == CLIENT_TYPE_CLIENT
+ || JoinLocationCannotUseItems(pokemonData)
+ || (!pokemonData->isLeader && ShouldAvoidEnemies(pokemon))
+ || CannotMove(pokemon, FALSE)
+ || CannotAct(pokemon))
+ {
+ return TRUE;
+ }
+ if (IsCharging(pokemon, FALSE))
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+bool8 CannotAct(struct DungeonEntity *pokemon)
+{
+ struct DungeonEntityData *pokemonData = pokemon->entityData;
+ if ((pokemonData->sleepStatus != SLEEP_STATUS_SLEEPLESS
+ && pokemonData->sleepStatus != SLEEP_STATUS_NONE)
+ || pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_FROZEN
+ || pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED)
+ {
+ return TRUE;
+ }
+ if (pokemonData->chargingStatus == CHARGING_STATUS_BIDE)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/src/dungeon_movement.c b/src/dungeon_movement.c
index b17e232..6a55c90 100644
--- a/src/dungeon_movement.c
+++ b/src/dungeon_movement.c
@@ -5,6 +5,7 @@
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "dungeon_global_data.h"
+#include "dungeon_capabilities_1.h"
#include "map.h"
extern char gAvailablePokemonNames[];
@@ -13,7 +14,6 @@ extern struct DungeonGlobalData *gDungeonGlobalData;
extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity*);
extern bool8 IsMovingClient(struct DungeonEntity*);
-extern bool8 CannotUseItems(struct DungeonEntity*);
extern void SetMessageArgument(char[], struct DungeonEntity*, u32);
extern void SendMessage(struct DungeonEntity*, char*);
extern void DecideUseItem(struct DungeonEntity*);
diff --git a/src/dungeon_pokemon_attributes.c b/src/dungeon_pokemon_attributes.c
new file mode 100644
index 0000000..a9aa6c2
--- /dev/null
+++ b/src/dungeon_pokemon_attributes.c
@@ -0,0 +1,21 @@
+#include "global.h"
+#include "dungeon_pokemon_attributes.h"
+
+#include "dungeon_util.h"
+
+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;
+ }
+}
diff --git a/src/dungeon_pokemon_attributes_1.c b/src/dungeon_pokemon_attributes_1.c
new file mode 100644
index 0000000..b0a670a
--- /dev/null
+++ b/src/dungeon_pokemon_attributes_1.c
@@ -0,0 +1,15 @@
+#include "global.h"
+#include "dungeon_pokemon_attributes_1.h"
+
+#include "constants/tactic.h"
+
+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;
+}
diff --git a/src/dungeon_util_1.c b/src/dungeon_util_1.c
new file mode 100644
index 0000000..97af7fb
--- /dev/null
+++ b/src/dungeon_util_1.c
@@ -0,0 +1,50 @@
+#include "global.h"
+#include "dungeon_util_1.h"
+
+bool8 IsMovingClient(struct DungeonEntity *pokemon)
+{
+ struct DungeonEntityData *pokemonData = pokemon->entityData;
+ switch (pokemonData->clientType)
+ {
+ case CLIENT_TYPE_CLIENT:
+ case CLIENT_TYPE_DONT_MOVE:
+ case 0x5:
+ case 0x6:
+ case 0x7:
+ case 0x8:
+ case 0x9:
+ case 0xD:
+ case 0xE:
+ case 0xF:
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x13:
+ case 0x14:
+ case 0x15:
+ case 0x16:
+ case 0x17:
+ case 0x18:
+ case 0x19:
+ case 0x1A:
+ case 0x1B:
+ case 0x1C:
+ case 0x1D:
+ case 0x1E:
+ case 0x1F:
+ case 0x20:
+ case 0x21:
+ case 0x22:
+ case 0x23:
+ case 0x24:
+ return TRUE;
+ case CLIENT_TYPE_NONE:
+ case 0x2:
+ case 0x4:
+ case 0xA:
+ case 0xB:
+ case 0xC:
+ default:
+ return FALSE;
+ }
+}
diff --git a/src/post_office_guide.c b/src/post_office_guide.c
index 9c96472..388955c 100644
--- a/src/post_office_guide.c
+++ b/src/post_office_guide.c
@@ -77,9 +77,9 @@ enum PostOfficeStates
enum PostOfficeMenuActions
{
- POST_OFFICE,
- BULLETIN_BOARD,
- DELIVERY,
+ POST_OFFICE,
+ BULLETIN_BOARD,
+ DELIVERY,
FRIEND_RESCUE,
CANCEL,
EXIT,
@@ -168,7 +168,7 @@ ALIGNED(4) const char GettingHelp_Text[] = _("Getting Help");
ALIGNED(4) const u8 wonder_mail_fill[] = _("pksdir0");
-const struct UnkTextStruct2 gUnknown_80E1EFC =
+const struct UnkTextStruct2 gUnknown_80E1EFC =
{
0, 0, 0, 0,
3, 0, 0, 0,
@@ -180,7 +180,7 @@ const struct UnkTextStruct2 gUnknown_80E1EFC =
const u8 gUnkData_80E1F14[] = {1, 0, 8, 0};
-const struct UnkTextStruct2 gUnknown_80E1F18 =
+const struct UnkTextStruct2 gUnknown_80E1F18 =
{
0, 0, 0, 0,
6, 0, 0, 0,
@@ -221,7 +221,7 @@ u32 CreateHelperPelipperMenu(s16 speciesID)
char *monName;
struct OpenedFile *faceFile;
int species_32;
-
+
species_32 = speciesID;
ResetUnusedInputStruct();
sub_800641C(0,1,1);
@@ -249,7 +249,7 @@ u32 CreateHelperPelipperMenu(s16 speciesID)
}
-u32 HelperPelliperCallback(void)
+u32 HelperPelipperCallback(void)
{
switch(gPostOfficeHelper->state) {
case IM_GUIDE_START_MENU:
@@ -304,7 +304,7 @@ void UpdateHelperPelipperText(void)
faceFile = NULL;
if(gPostOfficeHelper->faceFile != NULL)
faceFile = &gPostOfficeHelper->faceFile;
-
+
switch(gPostOfficeHelper->state)
{
case DISPLAY_GET_HELP_MENU:
@@ -535,7 +535,7 @@ void ReturnToGetHelpMenu(void)
u32 sub_80319A4(u8 param_1,u8 param_2,int param_3)
{
-
+
gUnknown_203B330 = MemoryAlloc(sizeof(struct unkStruct_203B330),8);
gUnknown_203B330->unkC = param_1;
gUnknown_203B330->unkD = param_2;
@@ -582,7 +582,7 @@ void sub_8031A3C(void)
void sub_8031A84(void)
{
s32 iVar1;
-
+
sub_8006518(gUnknown_203B330->unk18);
gUnknown_203B330->unk18[gUnknown_203B330->unk10] = gUnknown_80E1F18;
if (gUnknown_203B330->unkC == 2) {
diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c
index fda000b..73d25be 100644
--- a/src/wonder_mail_2.c
+++ b/src/wonder_mail_2.c
@@ -170,7 +170,7 @@ ALIGNED(4) const char gUnknown_80DF9F8[] = _(
"Here is your reward from the Pokémon\n"
"Rescue Organization!");
-ALIGNED(4) const char gUnknown_80DFAA8[] =
+ALIGNED(4) const char gUnknown_80DFAA8[] =
" I hope you will keep on\n"
"rescuing your friends in\n"
"dire straits.#P"
@@ -192,7 +192,7 @@ u32 sub_802B2D4(void)
{
s32 iVar1;
struct OpenedFile *faceFile;
-
+
ResetUnusedInputStruct();
sub_800641C(0,1,1);
gUnknown_203B2C8 = MemoryAlloc(sizeof(struct unkStruct_203B2C8),8);
@@ -272,7 +272,7 @@ void sub_802B3E0(void)
}
// Print and expand placeholders?
ExpandPlaceholdersBuffer(gUnknown_203B2C8->teamName,gUnknown_80DF9F8,teamNameBuffer);
- // Display to screen with Peliper face
+ // Display to screen with Pelipper face
sub_80141B4(gUnknown_203B2C8->teamName, 0, &gUnknown_203B2C8->faceFile, 0x10d);
break;
case 1:
@@ -355,7 +355,7 @@ void sub_802B5B8(void)
void sub_802B5FC(void)
{
s32 temp;
-
+
if (sub_80144A4(&temp) == 0) {
if (!WriteSavePak()) {
FinishWriteSavePak();
@@ -368,7 +368,7 @@ void sub_802B5FC(void)
void sub_802B624(void)
{
s32 temp;
-
+
if (sub_80144A4(&temp) == 0) {
sub_802B548(5);
}