mirror of
https://github.com/pret/pmd-red.git
synced 2026-10-01 15:21:19 -04:00
decomp a few and combine few files
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#include "dungeon_action.h"
|
||||
#include "dungeon_ai_targeting.h"
|
||||
#include "dungeon_ai_targeting_1.h"
|
||||
#include "dungeon_ai_targeting_2.h"
|
||||
#include "dungeon_capabilities_1.h"
|
||||
#include "dungeon_global_data.h"
|
||||
#include "dungeon_map_access.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "constants/status.h"
|
||||
#include "constants/targeting.h"
|
||||
#include "dungeon_ai_targeting_2.h"
|
||||
#include "dungeon_ai_targeting_1.h"
|
||||
#include "dungeon_map_access.h"
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
#include "dungeon_util.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "dungeon_ai_attack.h"
|
||||
#include "dungeon_ai_item_weight.h"
|
||||
#include "dungeon_ai_items.h"
|
||||
#include "dungeon_ai_targeting_2.h"
|
||||
#include "dungeon_ai_targeting_1.h"
|
||||
#include "dungeon_capabilities.h"
|
||||
#include "dungeon_capabilities_1.h"
|
||||
#include "dungeon_entity.h"
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
#include "dungeon_ai_targeting_1.h"
|
||||
|
||||
#include "constants/ability.h"
|
||||
#include "constants/dungeon.h"
|
||||
#include "constants/iq_skill.h"
|
||||
#include "constants/status.h"
|
||||
#include "constants/tactic.h"
|
||||
#include "constants/targeting.h"
|
||||
|
||||
#include "dungeon_engine.h"
|
||||
#include "dungeon_global_data.h"
|
||||
@@ -16,30 +18,67 @@
|
||||
#include "dungeon_util.h"
|
||||
#include "tile_types.h"
|
||||
|
||||
extern void CheckRunAwayVisualFlag(struct DungeonEntity *, bool8 showRunAwayEffect);
|
||||
|
||||
extern u8 gDungeonWaterType[];
|
||||
|
||||
bool8 IsAtJunction(struct DungeonEntity *param_1)
|
||||
extern bool8 SetVisualFlags(struct DungeonEntityData *, u32, bool8);
|
||||
extern void ShowVisualFlags(struct DungeonEntity *r0);
|
||||
|
||||
const u8 gTargetingData[3][2][2][2] = {
|
||||
{
|
||||
{
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
},
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
},
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET}
|
||||
},
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bool8 IsAtJunction(struct DungeonEntity *pokemon)
|
||||
{
|
||||
char cVar2;
|
||||
u32 crossableTerrain;
|
||||
struct MapTile *mapTile;
|
||||
struct DungeonEntityData *iVar7;
|
||||
|
||||
crossableTerrain = GetCrossableTerrain(param_1->entityData->entityID);
|
||||
crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID);
|
||||
if (!IsFixedDungeon()) {
|
||||
if ((param_1->entityData->transformStatus == TRANSFORM_STATUS_MOBILE) || (HasItem(param_1, ITEM_ID_MOBILE_SCARF))) {
|
||||
if ((pokemon->entityData->transformStatus == TRANSFORM_STATUS_MOBILE) || (HasItem(pokemon, ITEM_ID_MOBILE_SCARF))) {
|
||||
crossableTerrain = CROSSABLE_TERRAIN_WALL;
|
||||
}
|
||||
else if (HasIQSkill(param_1, IQ_SKILL_ALL_TERRAIN_HIKER)) {
|
||||
else if (HasIQSkill(pokemon, IQ_SKILL_ALL_TERRAIN_HIKER)) {
|
||||
crossableTerrain = CROSSABLE_TERRAIN_CREVICE;
|
||||
}
|
||||
else if (HasIQSkill(param_1, IQ_SKILL_SUPER_MOBILE)) {
|
||||
else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE)) {
|
||||
crossableTerrain = CROSSABLE_TERRAIN_WALL;
|
||||
}
|
||||
}
|
||||
if (crossableTerrain == CROSSABLE_TERRAIN_WALL) {
|
||||
iVar7 = param_1->entityData;
|
||||
iVar7 = pokemon->entityData;
|
||||
iVar7->mobileTurnTimer += DungeonRandomCapped(100);
|
||||
if (iVar7->mobileTurnTimer < 200) {
|
||||
return FALSE;
|
||||
@@ -50,10 +89,10 @@ bool8 IsAtJunction(struct DungeonEntity *param_1)
|
||||
else {
|
||||
if ((gDungeonWaterType[gDungeonGlobalData->tileset] == DUNGEON_WATER_TYPE_LAVA)
|
||||
&& (crossableTerrain == CROSSABLE_TERRAIN_LIQUID)
|
||||
&& (HasIQSkill(param_1, IQ_SKILL_LAVA_EVADER))) {
|
||||
&& (HasIQSkill(pokemon, IQ_SKILL_LAVA_EVADER))) {
|
||||
crossableTerrain = CROSSABLE_TERRAIN_REGULAR;
|
||||
}
|
||||
mapTile = GetMapTile_1(param_1->posWorld.x, param_1->posWorld.y);
|
||||
mapTile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
|
||||
cVar2 = mapTile->canMoveAdjacent[crossableTerrain];
|
||||
if ((cVar2 != 0x54) && (cVar2 != 0x51) && (cVar2 != 0x45) && (cVar2 != 0x15) && (cVar2 != 0x55)) return FALSE;
|
||||
}
|
||||
@@ -112,3 +151,128 @@ bool8 ShouldAvoidEnemiesAndShowEffect(struct DungeonEntity *pokemon, bool8 showR
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CheckRunAwayVisualFlag(struct DungeonEntity *pokemon, bool8 showRunAwayEffect)
|
||||
{
|
||||
bool8 cVar1;
|
||||
struct DungeonEntityData *iVar2;
|
||||
struct DungeonEntityData *iVar3;
|
||||
|
||||
iVar2 = pokemon->entityData;
|
||||
iVar3 = iVar2;
|
||||
|
||||
if (((!iVar2->isLeader) && HasAbility(pokemon,ABILITY_RUN_AWAY) &&
|
||||
(cVar1 = SetVisualFlags(iVar3,4,iVar2->HP <= iVar2->maxHP / 2), showRunAwayEffect)) &&
|
||||
(cVar1)) {
|
||||
ShowVisualFlags(pokemon);
|
||||
}
|
||||
}
|
||||
|
||||
u8 CanTarget(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified)
|
||||
{
|
||||
struct DungeonEntityData *pokemonData = pokemon->entityData;
|
||||
struct DungeonEntityData *targetData = targetPokemon->entityData;
|
||||
u8 targetingDecoy;
|
||||
u8 pokemonTargetingDecoy;
|
||||
bool8 pokemonIsEnemy;
|
||||
bool8 targetIsEnemy;
|
||||
bool8 targetIsDecoy;
|
||||
if (pokemon == targetPokemon)
|
||||
{
|
||||
return TARGET_CAPABILITY_CANNOT_ATTACK;
|
||||
}
|
||||
if (pokemonData->shopkeeperMode == SHOPKEEPER_FRIENDLY ||
|
||||
targetData->shopkeeperMode == SHOPKEEPER_FRIENDLY ||
|
||||
pokemonData->clientType == CLIENT_TYPE_DONT_MOVE ||
|
||||
targetData->clientType == CLIENT_TYPE_DONT_MOVE ||
|
||||
pokemonData->clientType == CLIENT_TYPE_CLIENT ||
|
||||
targetData->clientType == CLIENT_TYPE_CLIENT ||
|
||||
(checkPetrified && !pokemonData->isEnemy && targetData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED) ||
|
||||
(!ignoreInvisible && targetData->transformStatus == TRANSFORM_STATUS_INVISIBLE && !CanSeeInvisible(pokemon)))
|
||||
{
|
||||
return TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET;
|
||||
}
|
||||
pokemonTargetingDecoy = pokemonData->targetingDecoy;
|
||||
targetingDecoy = TARGETING_DECOY_NONE;
|
||||
if (pokemonTargetingDecoy != TARGETING_DECOY_NONE)
|
||||
{
|
||||
targetingDecoy = TARGETING_DECOY_WILD;
|
||||
if (pokemonTargetingDecoy == TARGETING_DECOY_TEAM)
|
||||
{
|
||||
targetingDecoy = TARGETING_DECOY_TEAM;
|
||||
}
|
||||
}
|
||||
if (pokemonData->shopkeeperMode != SHOPKEEPER_NONE)
|
||||
{
|
||||
pokemonIsEnemy = FALSE;
|
||||
if (pokemonData->shopkeeperMode == SHOPKEEPER_AGGRESSIVE_TO_PLAYER)
|
||||
{
|
||||
pokemonIsEnemy = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pokemonIsEnemy = pokemonData->isEnemy ? TRUE : FALSE;
|
||||
}
|
||||
if (targetData->shopkeeperMode != SHOPKEEPER_NONE)
|
||||
{
|
||||
targetIsEnemy = FALSE;
|
||||
if (targetData->shopkeeperMode == SHOPKEEPER_AGGRESSIVE_TO_PLAYER)
|
||||
{
|
||||
targetIsEnemy = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetIsEnemy = targetData->isEnemy ? TRUE : FALSE;
|
||||
}
|
||||
targetIsDecoy = FALSE;
|
||||
if (targetData->waitingStatus == WAITING_STATUS_DECOY)
|
||||
{
|
||||
targetIsDecoy = TRUE;
|
||||
}
|
||||
return gTargetingData[targetingDecoy][pokemonIsEnemy][targetIsEnemy][targetIsDecoy];
|
||||
}
|
||||
|
||||
static inline bool8 JoinLocationCannotUseItems_1(struct DungeonEntityData *pokemonData)
|
||||
{
|
||||
if (pokemonData->joinLocation == DUNGEON_JOIN_LOCATION_CLIENT_POKEMON)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
if (pokemonData->joinLocation == DUNGEON_RESCUE_TEAM_BASE)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 sub_807167C(struct DungeonEntity * pokemon, struct DungeonEntity * target)
|
||||
{
|
||||
bool8 bVar1;
|
||||
struct DungeonEntityData * iVar3;
|
||||
struct DungeonEntityData * iVar4;
|
||||
|
||||
iVar4 = pokemon->entityData;
|
||||
iVar3 = target->entityData;
|
||||
if (iVar4->clientType != CLIENT_TYPE_CLIENT) {
|
||||
bVar1 = JoinLocationCannotUseItems_1(iVar4);
|
||||
if (!bVar1 && (iVar4->shopkeeperMode == SHOPKEEPER_NONE) && (iVar3->clientType != CLIENT_TYPE_CLIENT)) {
|
||||
bVar1 = JoinLocationCannotUseItems_1(iVar3);
|
||||
if (bVar1 || (iVar3->shopkeeperMode != SHOPKEEPER_NONE)) {
|
||||
error:
|
||||
return TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((iVar4->isEnemy) != (iVar3->isEnemy)) {
|
||||
return TARGET_CAPABILITY_CAN_TARGET;
|
||||
}
|
||||
else {
|
||||
return TARGET_CAPABILITY_CANNOT_ATTACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "dungeon_ai_targeting_2.h"
|
||||
|
||||
#include "constants/status.h"
|
||||
#include "constants/targeting.h"
|
||||
#include "dungeon_pokemon_attributes.h"
|
||||
|
||||
const u8 gTargetingData[3][2][2][2] = {
|
||||
{
|
||||
{
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
},
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
},
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET},
|
||||
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET}
|
||||
},
|
||||
{
|
||||
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
|
||||
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
u8 CanTarget(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified)
|
||||
{
|
||||
struct DungeonEntityData *pokemonData = pokemon->entityData;
|
||||
struct DungeonEntityData *targetData = targetPokemon->entityData;
|
||||
u8 targetingDecoy;
|
||||
u8 pokemonTargetingDecoy;
|
||||
bool8 pokemonIsEnemy;
|
||||
bool8 targetIsEnemy;
|
||||
bool8 targetIsDecoy;
|
||||
if (pokemon == targetPokemon)
|
||||
{
|
||||
return TARGET_CAPABILITY_CANNOT_ATTACK;
|
||||
}
|
||||
if (pokemonData->shopkeeperMode == SHOPKEEPER_FRIENDLY ||
|
||||
targetData->shopkeeperMode == SHOPKEEPER_FRIENDLY ||
|
||||
pokemonData->clientType == CLIENT_TYPE_DONT_MOVE ||
|
||||
targetData->clientType == CLIENT_TYPE_DONT_MOVE ||
|
||||
pokemonData->clientType == CLIENT_TYPE_CLIENT ||
|
||||
targetData->clientType == CLIENT_TYPE_CLIENT ||
|
||||
(checkPetrified && !pokemonData->isEnemy && targetData->immobilizeStatus == IMMOBILIZE_STATUS_PETRIFIED) ||
|
||||
(!ignoreInvisible && targetData->transformStatus == TRANSFORM_STATUS_INVISIBLE && !CanSeeInvisible(pokemon)))
|
||||
{
|
||||
return TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET;
|
||||
}
|
||||
pokemonTargetingDecoy = pokemonData->targetingDecoy;
|
||||
targetingDecoy = TARGETING_DECOY_NONE;
|
||||
if (pokemonTargetingDecoy != TARGETING_DECOY_NONE)
|
||||
{
|
||||
targetingDecoy = TARGETING_DECOY_WILD;
|
||||
if (pokemonTargetingDecoy == TARGETING_DECOY_TEAM)
|
||||
{
|
||||
targetingDecoy = TARGETING_DECOY_TEAM;
|
||||
}
|
||||
}
|
||||
if (pokemonData->shopkeeperMode != SHOPKEEPER_NONE)
|
||||
{
|
||||
pokemonIsEnemy = FALSE;
|
||||
if (pokemonData->shopkeeperMode == SHOPKEEPER_AGGRESSIVE_TO_PLAYER)
|
||||
{
|
||||
pokemonIsEnemy = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pokemonIsEnemy = pokemonData->isEnemy ? TRUE : FALSE;
|
||||
}
|
||||
if (targetData->shopkeeperMode != SHOPKEEPER_NONE)
|
||||
{
|
||||
targetIsEnemy = FALSE;
|
||||
if (targetData->shopkeeperMode == SHOPKEEPER_AGGRESSIVE_TO_PLAYER)
|
||||
{
|
||||
targetIsEnemy = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetIsEnemy = targetData->isEnemy ? TRUE : FALSE;
|
||||
}
|
||||
targetIsDecoy = FALSE;
|
||||
if (targetData->waitingStatus == WAITING_STATUS_DECOY)
|
||||
{
|
||||
targetIsDecoy = TRUE;
|
||||
}
|
||||
return gTargetingData[targetingDecoy][pokemonIsEnemy][targetIsEnemy][targetIsDecoy];
|
||||
}
|
||||
Reference in New Issue
Block a user