diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/code_8040094.c | 10 | ||||
-rw-r--r-- | src/code_80521D0.c | 22 | ||||
-rw-r--r-- | src/dungeon_ai_item_weight.c | 2 | ||||
-rw-r--r-- | src/dungeon_movement.c | 8 | ||||
-rw-r--r-- | src/friend_list_menu.c | 2 | ||||
-rw-r--r-- | src/status_checks.c | 109 | ||||
-rw-r--r-- | src/status_checks_1.c | 44 |
7 files changed, 151 insertions, 46 deletions
diff --git a/src/code_8040094.c b/src/code_8040094.c index c834602..c0e7eac 100644 --- a/src/code_8040094.c +++ b/src/code_8040094.c @@ -1,7 +1,10 @@ #include "global.h" -#include "play_time.h" -#include "file_system.h" + +#include "code_80521D0.h" +#include "dungeon_entity.h" #include "dungeon_global_data.h" +#include "file_system.h" +#include "play_time.h" extern s32 gUnknown_80F6568[]; extern u8 gUnknown_202EE01; @@ -20,14 +23,13 @@ extern void sub_8011860(void); extern void sub_803F580(u32); extern void sub_8049ED4(); extern void sub_8040A84(); -extern void SendMessage(u32, const char *); extern const char *gUnknown_80FD040; // It became brighter on the floor extern struct MapTile *GetMapEntity(u32, u32); // Luminous Orb??? -void HandleLuminousOrbAction(u32 param_1) +void HandleLuminousOrbAction(struct DungeonEntity *param_1) { struct MapTile *mapTile; int XCoord; diff --git a/src/code_80521D0.c b/src/code_80521D0.c index 272991d..4867acf 100644 --- a/src/code_80521D0.c +++ b/src/code_80521D0.c @@ -1,9 +1,9 @@ #include "global.h" -#include "dungeon_entity.h" +#include "code_80521D0.h" extern void sub_80526D0(u8 r0); extern u8 sub_8045888(struct DungeonEntity *r0); -extern void sub_80523A8(struct DungeonEntity *r0, u32 r1, u8 r2); +extern void sub_80523A8(struct DungeonEntity *r0, const char r1[], u8 r2); extern u8 sub_8052DC0(struct DungeonEntity *); extern u8 sub_803F428(u32); @@ -12,26 +12,26 @@ void sub_805229C(void) return sub_80526D0(0x50); } -void SendMessage(struct DungeonEntity *r0, u32 r1) +void SendMessage(struct DungeonEntity *pokemon, const char message[]) { - if (sub_8045888(r0) != 0){ - sub_80523A8(r0, r1, 1); + if (sub_8045888(pokemon) != 0){ + sub_80523A8(pokemon, message, 1); } } -void sub_80522C8(struct DungeonEntity *r0, u32 r1) +void sub_80522C8(struct DungeonEntity *r0, const char r1[]) { if (sub_8045888(r0) != 0){ sub_80523A8(r0, r1, 0); } } -void sub_80522E8(struct DungeonEntity *r0, u32 r1) +void sub_80522E8(struct DungeonEntity *r0, const char r1[]) { sub_80523A8(r0, r1, 0); } -void sub_80522F4(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2) +void sub_80522F4(struct DungeonEntity *r0, struct DungeonEntity *r1, const char r2[]) { u8 temp; u32 temp_reg; @@ -49,7 +49,7 @@ void sub_80522F4(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2) } } -void sub_805232C(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2) +void sub_805232C(struct DungeonEntity *r0, struct DungeonEntity *r1, const char r2[]) { u8 temp; u32 temp_reg; @@ -67,7 +67,7 @@ void sub_805232C(struct DungeonEntity *r0, struct DungeonEntity *r1, u32 r2) } } -void sub_8052364(struct DungeonEntity *r0, u32 r1, u32 r2) +void sub_8052364(struct DungeonEntity *r0, u32 r1, const char r2[]) { u8 temp; u32 temp_reg; @@ -85,7 +85,7 @@ void sub_8052364(struct DungeonEntity *r0, u32 r1, u32 r2) } } -void sub_805239C(struct DungeonEntity *r0, u32 r1) +void sub_805239C(struct DungeonEntity *r0, const char r1[]) { sub_80523A8(r0, r1, 1); } diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c index 34e3440..6c9669b 100644 --- a/src/dungeon_ai_item_weight.c +++ b/src/dungeon_ai_item_weight.c @@ -9,7 +9,7 @@ #include "dungeon_util.h" #include "moves.h" #include "number_util.h" -#include "status_checks.h" +#include "status_checks_1.h" u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 itemTargetFlags) { diff --git a/src/dungeon_movement.c b/src/dungeon_movement.c index bcf6163..3df74ee 100644 --- a/src/dungeon_movement.c +++ b/src/dungeon_movement.c @@ -6,6 +6,7 @@ #include "constants/iq_skill.h" #include "constants/status.h" #include "constants/targeting.h" +#include "code_80521D0.h" #include "dungeon_ai_items.h" #include "dungeon_capabilities_1.h" #include "dungeon_global_data.h" @@ -16,6 +17,7 @@ #include "dungeon_visibility.h" #include "map.h" #include "pokemon.h" +#include "status_checks.h" extern char gAvailablePokemonNames[]; extern char *gPtrCouldntBeUsedMessage; @@ -23,8 +25,6 @@ extern char *gPtrItsaMonsterHouseMessage; extern void SendImmobilizeEndMessage(struct DungeonEntity*, struct DungeonEntity*); extern void SetMessageArgument(char[], struct DungeonEntity*, u32); -extern void SendMessage(struct DungeonEntity*, char*); -extern bool8 HasStatusAffectingActions(struct DungeonEntity*); extern void ResetAction(u16*); extern void SetWalkAction(u16*, s16); extern void DecideAttack(struct DungeonEntity*); @@ -155,7 +155,7 @@ void sub_8075900(struct DungeonEntity *pokemon, u8 r1) void DecideAction(struct DungeonEntity *pokemon) { struct DungeonEntityData *pokemonData = pokemon->entityData; - if ((pokemonData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED) != 0) + if (pokemonData->flags & MOVEMENT_FLAG_SWAPPED_PLACES_PETRIFIED) { if (pokemonData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED) { @@ -210,7 +210,7 @@ void DecideAction(struct DungeonEntity *pokemon) if (pokemonData->clientType == CLIENT_TYPE_CLIENT) { SetWalkAction(&pokemonData->action.action, pokemonData->entityID); - pokemonData->action.facingDir = DungeonRandomCapped(8); + pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS); pokemonData->targetPosition.x = pokemon->posWorld.x; pokemonData->targetPosition.y = pokemon->posWorld.y - 1; } diff --git a/src/friend_list_menu.c b/src/friend_list_menu.c index 7dbc441..50b8c02 100644 --- a/src/friend_list_menu.c +++ b/src/friend_list_menu.c @@ -208,7 +208,7 @@ void sub_8026C14(void) struct unkStruct_8090F58 temp; int menuAction; struct ItemSlot slot; - + menuAction = 0; sub_801A6E8(0); if ((sub_8012FD8(&gUnknown_203B2B8->unkCC) == '\0') && (sub_8013114(&gUnknown_203B2B8->unkCC,&menuAction), menuAction != 1)) { diff --git a/src/status_checks.c b/src/status_checks.c index 346afb5..5abb0fe 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -1,44 +1,103 @@ #include "global.h" #include "status_checks.h" +#include "constants/direction.h" +#include "constants/dungeon_action.h" #include "constants/status.h" +#include "code_80521D0.h" +#include "dungeon_action.h" +#include "dungeon_random.h" -bool8 HasNegativeStatus(struct DungeonEntity *pokemon) +extern char *gPtrFrozenMessage; +extern char *gPtrWrappedAroundMessage; +extern char *gPtrWrappedByMessage; +extern char *gPtrBideMessage; +extern char *gPtrPausedMessage; +extern char *gPtrInfatuatedMessage; + +extern char gAvailablePokemonNames[]; +extern void SetMessageArgument(char[], struct DungeonEntity*, u32); +extern void SetWalkAction(struct DungeonActionContainer*, s16); +extern bool8 CanMoveForward2(struct DungeonEntity*, u8); +extern void DecideAttack(struct DungeonEntity*); + +bool8 HasStatusAffectingActions(struct DungeonEntity *pokemon) { struct DungeonEntityData *pokemonData = pokemon->entityData; - s32 i; - if (pokemonData->sleepStatus == SLEEP_STATUS_SLEEP || - pokemonData->sleepStatus == SLEEP_STATUS_NIGHTMARE || - pokemonData->sleepStatus == SLEEP_STATUS_YAWNING || - pokemonData->nonVolatileStatus != NON_VOLATILE_STATUS_NONE || - (pokemonData->immobilizeStatus != IMMOBILIZE_STATUS_INGRAIN && pokemonData->immobilizeStatus != IMMOBILIZE_STATUS_NONE) || - pokemonData->volatileStatus != VOLATILE_STATUS_NONE || - pokemonData->waitingStatus == WAITING_STATUS_CURSED || - pokemonData->waitingStatus == WAITING_STATUS_DECOY || - pokemonData->linkedStatus == LINKED_STATUS_LEECH_SEED || - pokemonData->moveStatus == MOVE_STATUS_WHIFFER || - pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER || - pokemonData->eyesightStatus == EYESIGHT_STATUS_CROSS_EYED || - pokemonData->muzzledStatus == MUZZLED_STATUS_MUZZLED || - pokemonData->exposedStatus || - pokemonData->perishSongTimer != 0) + SetMessageArgument(gAvailablePokemonNames, pokemon, 0); + SetAction(&pokemonData->action, DUNGEON_ACTION_WAIT); + switch (pokemonData->sleepStatus) { - return TRUE; + case SLEEP_STATUS_NIGHTMARE: + case SLEEP_STATUS_SLEEP: + case SLEEP_STATUS_NAPPING: + return TRUE; } - for (i = 0; i < MAX_MON_MOVES; i++) + switch (pokemonData->immobilizeStatus) { - struct PokemonMove *moves = pokemonData->moves; - if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].sealed & TRUE) - { + case IMMOBILIZE_STATUS_FROZEN: + SendMessage(pokemon, gPtrFrozenMessage); return TRUE; - } + case IMMOBILIZE_STATUS_WRAPPED_AROUND_FOE: + SendMessage(pokemon, gPtrWrappedAroundMessage); + return TRUE; + case IMMOBILIZE_STATUS_WRAPPED_BY_FOE: + SendMessage(pokemon, gPtrWrappedByMessage); + return TRUE; + case IMMOBILIZE_STATUS_PETRIFIED: + return TRUE; + } + switch (pokemonData->volatileStatus) + { + case VOLATILE_STATUS_PAUSED: + SendMessage(pokemon, gPtrPausedMessage); + return TRUE; + case VOLATILE_STATUS_INFATUATED: + SendMessage(pokemon, gPtrInfatuatedMessage); + return TRUE; + } + if (pokemonData->chargingStatus == CHARGING_STATUS_BIDE) + { + SendMessage(pokemon, gPtrBideMessage); + return TRUE; + } + if (pokemonData->waitingStatus == WAITING_STATUS_DECOY) + { + SetWalkAction(&pokemonData->action, pokemonData->entityID); + pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS); + pokemonData->targetPosition.x = pokemon->posWorld.x; + pokemonData->targetPosition.y = pokemon->posWorld.y - 1; + return TRUE; + } + if (pokemonData->shopkeeperMode == SHOPKEEPER_FRIENDLY) + { + return TRUE; } - for (i = 0; i < NUM_SPEED_TURN_COUNTERS; i++) + if (pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER) { - if (pokemonData->slowTurnsLeft[i] != 0) + if (!CanMoveForward2(pokemon, pokemonData->action.facingDir)) + { + if (DungeonRandomCapped(2) != 0) + { + pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS); + pokemonData->action.facingDir = pokemonData->action.facingDir & DIRECTION_MASK; + goto walk; + } + } + else { + walk: + SetWalkAction(&pokemonData->action, pokemonData->entityID); return TRUE; } + DecideAttack(pokemon); + return TRUE; + } + if (pokemonData->eyesightStatus == EYESIGHT_STATUS_CROSS_EYED) + { + SetWalkAction(&pokemonData->action, pokemonData->entityID); + pokemonData->action.facingDir = DungeonRandomCapped(NUM_DIRECTIONS); + return TRUE; } return FALSE; } diff --git a/src/status_checks_1.c b/src/status_checks_1.c new file mode 100644 index 0000000..32ed6bf --- /dev/null +++ b/src/status_checks_1.c @@ -0,0 +1,44 @@ +#include "global.h" +#include "status_checks_1.h" + +#include "constants/status.h" + +bool8 HasNegativeStatus(struct DungeonEntity *pokemon) +{ + struct DungeonEntityData *pokemonData = pokemon->entityData; + s32 i; + if (pokemonData->sleepStatus == SLEEP_STATUS_SLEEP || + pokemonData->sleepStatus == SLEEP_STATUS_NIGHTMARE || + pokemonData->sleepStatus == SLEEP_STATUS_YAWNING || + pokemonData->nonVolatileStatus != NON_VOLATILE_STATUS_NONE || + (pokemonData->immobilizeStatus != IMMOBILIZE_STATUS_INGRAIN && pokemonData->immobilizeStatus != IMMOBILIZE_STATUS_NONE) || + pokemonData->volatileStatus != VOLATILE_STATUS_NONE || + pokemonData->waitingStatus == WAITING_STATUS_CURSED || + pokemonData->waitingStatus == WAITING_STATUS_DECOY || + pokemonData->linkedStatus == LINKED_STATUS_LEECH_SEED || + pokemonData->moveStatus == MOVE_STATUS_WHIFFER || + pokemonData->eyesightStatus == EYESIGHT_STATUS_BLINKER || + pokemonData->eyesightStatus == EYESIGHT_STATUS_CROSS_EYED || + pokemonData->muzzledStatus == MUZZLED_STATUS_MUZZLED || + pokemonData->exposedStatus || + pokemonData->perishSongTimer != 0) + { + return TRUE; + } + for (i = 0; i < MAX_MON_MOVES; i++) + { + struct PokemonMove *moves = pokemonData->moves; + if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].sealed & TRUE) + { + return TRUE; + } + } + for (i = 0; i < NUM_SPEED_TURN_COUNTERS; i++) + { + if (pokemonData->slowTurnsLeft[i] != 0) + { + return TRUE; + } + } + return FALSE; +} |