Skip to content

Commit

Permalink
Merge dungeon_capabilities files together
Browse files Browse the repository at this point in the history
  • Loading branch information
Kermalis committed Jul 25, 2023
1 parent 2c3f95a commit eb1b806
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 146 deletions.
4 changes: 4 additions & 0 deletions include/dungeon_capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@

bool8 CannotMove(struct Entity *pokemon, bool8 checkBlinker);
bool8 sub_8070BC0(struct Entity* entity);
bool8 CannotUseItems(struct Entity *pokemon);
bool8 HasStatusThatPreventsActing(struct Entity *pokemon);
bool8 CannotAttack(struct Entity *pokemon, bool8 skipSleep);
bool8 CanMoveInDirection(struct Entity *pokemon, u32 direction);

#endif
11 changes: 0 additions & 11 deletions include/dungeon_capabilities_1.h

This file was deleted.

3 changes: 1 addition & 2 deletions ld_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ SECTIONS {
src/dungeon_movement.o(.text);
src/status_checks_1.o(.text);
src/dungeon_capabilities.o(.text);
src/dungeon_capabilities_1.o(.text);
src/dungeon_ai_targeting.o(.text);
src/dungeon_pokemon_attributes.o(.text);
asm/code_80718D8.o(.text);
Expand Down Expand Up @@ -470,7 +469,7 @@ SECTIONS {
data/data_8106A4C.o(.rodata);
src/type_effectiveness.o(.data);
data/data_8106F7C.o(.rodata);
src/dungeon_capabilities_1.o(.rodata);
src/dungeon_capabilities.o(.rodata);
src/dungeon_ai_targeting.o(.rodata);
data/data_8107010.o(.rodata);
src/friend_area.o(.rodata);
Expand Down
2 changes: 1 addition & 1 deletion src/dungeon_ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "dungeon_ai_items.h"
#include "dungeon_ai_movement.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_capabilities.h"
#include "dungeon_global_data.h"
#include "dungeon_items.h"
#include "dungeon_leader.h"
Expand Down
2 changes: 1 addition & 1 deletion src/dungeon_ai_attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "dungeon_action.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_capabilities.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "dungeon_pokemon_attributes.h"
Expand Down
1 change: 0 additions & 1 deletion src/dungeon_ai_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "dungeon_ai_items.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_capabilities.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_entity.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
Expand Down
2 changes: 1 addition & 1 deletion src/dungeon_ai_movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "dungeon_action.h"
#include "dungeon_ai_leader.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_capabilities.h"
#include "dungeon_global_data.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
Expand Down
107 changes: 107 additions & 0 deletions src/dungeon_capabilities.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#include "global.h"
#include "dungeon_capabilities.h"

#include "constants/dungeon.h"
#include "constants/iq_skill.h"
#include "constants/status.h"
#include "charge_move.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_capabilities.h"
#include "dungeon_engine.h"
#include "dungeon_items.h"
#include "dungeon_map_access.h"
#include "dungeon_movement.h"
#include "dungeon_pokemon_attributes.h"
#include "dungeon_util.h"
#include "map.h"

const u8 gDirectionBitMasks_1[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};

bool8 CannotMove(struct Entity *pokemon, bool8 checkBlinker)
{
Expand Down Expand Up @@ -60,4 +72,99 @@ bool8 sub_8070BC0(struct Entity* entity)
return TRUE;

return FALSE;
}

static inline bool8 JoinLocationCannotUseItems(struct EntityInfo *pokemonInfo)
{
if (pokemonInfo->joinedAt == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
return TRUE;
if (pokemonInfo->joinedAt == DUNGEON_RESCUE_TEAM_BASE)
return TRUE;
return FALSE;
}

bool8 CannotUseItems(struct Entity *pokemon)
{
struct EntityInfo *pokemonInfo = pokemon->info;

if (pokemonInfo->clientType == CLIENT_TYPE_CLIENT
|| JoinLocationCannotUseItems(pokemonInfo)
|| (!pokemonInfo->isTeamLeader && ShouldMonsterRunAway(pokemon))
|| CannotMove(pokemon, FALSE)
|| HasStatusThatPreventsActing(pokemon))
return TRUE;

if (IsCharging(pokemon, FALSE))
return TRUE;

return FALSE;
}

bool8 HasStatusThatPreventsActing(struct Entity *pokemon)
{
struct EntityInfo *pokemonInfo = pokemon->info;

if ((pokemonInfo->sleep != STATUS_SLEEPLESS
&& pokemonInfo->sleep != STATUS_NONE)
|| pokemonInfo->immobilizeStatus == STATUS_FROZEN
|| pokemonInfo->immobilizeStatus == STATUS_PETRIFIED)
return TRUE;

if (pokemonInfo->chargingStatus == STATUS_BIDE)
return TRUE;

return FALSE;
}

bool8 CannotAttack(struct Entity *pokemon, bool8 skipSleep)
{
struct EntityInfo *pokemonInfo = pokemon->info;

if ((skipSleep ||
pokemonInfo->sleep == STATUS_SLEEPLESS ||
pokemonInfo->sleep == STATUS_YAWNING ||
pokemonInfo->sleep == STATUS_NONE) &&
pokemonInfo->immobilizeStatus != STATUS_FROZEN &&
pokemonInfo->immobilizeStatus != STATUS_WRAP &&
pokemonInfo->immobilizeStatus != STATUS_WRAPPED &&
pokemonInfo->immobilizeStatus != STATUS_PETRIFIED &&
pokemonInfo->volatileStatus != STATUS_CRINGE &&
pokemonInfo->volatileStatus != STATUS_PAUSED &&
pokemonInfo->volatileStatus != STATUS_INFATUATED &&
pokemonInfo->nonVolatileStatus != STATUS_PARALYSIS &&
!ShouldMonsterRunAway(pokemon))
return FALSE;

return TRUE;
}

bool8 CanMoveInDirection(struct Entity *pokemon, u32 direction)
{
u8 crossableTerrain = GetCrossableTerrain(pokemon->info->id);
struct Tile *currentMapTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x,
pokemon->pos.y + gAdjacentTileOffsets[direction].y);

if (currentMapTile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL || currentMapTile->monster != NULL)
return FALSE;

if (!IsCurrentFixedRoomBossFight())
{
if (pokemon->info->transformStatus == STATUS_MOBILE || HasHeldItem(pokemon, ITEM_MOBILE_SCARF))
crossableTerrain = CROSSABLE_TERRAIN_WALL;
else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER))
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) {
if (direction & 1)
// Super Mobile can't break walls diagonally.
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
else
crossableTerrain = CROSSABLE_TERRAIN_WALL;
}
}

currentMapTile = GetTile(pokemon->pos.x, pokemon->pos.y);
if (!(currentMapTile->walkableNeighborFlags[crossableTerrain] & gDirectionBitMasks_1[direction & DIRECTION_MASK]))
return FALSE;

return TRUE;
}
127 changes: 0 additions & 127 deletions src/dungeon_capabilities_1.c

This file was deleted.

2 changes: 1 addition & 1 deletion src/move_effects_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "dungeon_ai_items.h"
#include "dungeon_ai_movement.h"
#include "dungeon_ai_targeting.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_capabilities.h"
#include "dungeon_global_data.h"
#include "dungeon_items.h"
#include "dungeon_leader.h"
Expand Down
2 changes: 1 addition & 1 deletion src/status_checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "charge_move.h"
#include "dungeon_action.h"
#include "dungeon_ai_attack.h"
#include "dungeon_capabilities_1.h"
#include "dungeon_capabilities.h"
#include "dungeon_random.h"

const s16 gConfusedAttackChance = 70;
Expand Down

0 comments on commit eb1b806

Please sign in to comment.