decomp a few and combine few files

This commit is contained in:
Seth Barberee 2022-04-23 08:29:33 -07:00
parent 519c9ebb6a
commit 6e4fce8608
10 changed files with 181 additions and 250 deletions

View File

@ -1,54 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start CheckRunAwayVisualFlag
CheckRunAwayVisualFlag:
push {r4-r7,lr}
adds r5, r0, 0
lsls r1, 24
lsrs r7, r1, 24
ldr r4, [r5, 0x70]
adds r6, r4, 0
ldrb r0, [r4, 0x7]
cmp r0, 0
bne _08071590
adds r0, r5, 0
movs r1, 0x2B
bl HasAbility
lsls r0, 24
cmp r0, 0
beq _08071590
movs r2, 0
movs r1, 0x10
ldrsh r0, [r4, r1]
lsrs r1, r0, 31
adds r0, r1
movs r3, 0xE
ldrsh r1, [r4, r3]
asrs r0, 1
cmp r1, r0
bgt _08071576
movs r2, 0x1
_08071576:
adds r0, r6, 0
movs r1, 0x4
bl SetVisualFlags
lsls r0, 24
lsrs r0, 24
cmp r7, 0
beq _08071590
cmp r0, 0
beq _08071590
adds r0, r5, 0
bl ShowVisualFlags
_08071590:
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end CheckRunAwayVisualFlag
.align 2, 0

View File

@ -5,72 +5,5 @@
.text
thumb_func_start sub_807167C
sub_807167C:
push {lr}
ldr r2, [r0, 0x70]
ldr r1, [r1, 0x70]
adds r0, r2, 0
adds r0, 0xA4
ldrb r0, [r0]
cmp r0, 0x1
beq _080716D2
adds r0, r2, 0
adds r0, 0x40
ldrb r0, [r0]
cmp r0, 0x4A
beq _0807169A
cmp r0, 0x47
bne _0807169E
_0807169A:
movs r0, 0x1
b _080716A0
_0807169E:
movs r0, 0
_080716A0:
cmp r0, 0
bne _080716D2
ldrb r0, [r2, 0x8]
cmp r0, 0
bne _080716D2
adds r0, r1, 0
adds r0, 0xA4
ldrb r0, [r0]
cmp r0, 0x1
beq _080716D2
adds r0, r1, 0
adds r0, 0x40
ldrb r0, [r0]
cmp r0, 0x4A
beq _080716C2
cmp r0, 0x47
bne _080716C6
_080716C2:
movs r0, 0x1
b _080716C8
_080716C6:
movs r0, 0
_080716C8:
cmp r0, 0
bne _080716D2
ldrb r0, [r1, 0x8]
cmp r0, 0
beq _080716D6
_080716D2:
movs r0, 0x2
b _080716E4
_080716D6:
ldrb r0, [r2, 0x6]
ldrb r1, [r1, 0x6]
cmp r0, r1
bne _080716E2
movs r0, 0
b _080716E4
_080716E2:
movs r0, 0x1
_080716E4:
pop {r1}
bx r1
thumb_func_end sub_807167C
.align 2, 0

View File

@ -3,7 +3,12 @@
#include "dungeon_entity.h"
bool8 IsAtJunction(struct DungeonEntity *pokemon);
bool8 ShouldAvoidFirstHit(struct DungeonEntity *pokemon, bool8 forceAvoid);
bool8 ShouldAvoidEnemies(struct DungeonEntity *pokemon);
bool8 ShouldAvoidEnemiesAndShowEffect(struct DungeonEntity *pokemon, bool8 showRunAwayEffect);
void CheckRunAwayVisualFlag(struct DungeonEntity *pokemon, bool8 showRunAwayEffect);
u8 CanTarget(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified);
u8 sub_807167C(struct DungeonEntity * pokemon, struct DungeonEntity * target);
#endif

View File

@ -1,8 +0,0 @@
#ifndef GUARD_DUNGEON_AI_TARGETING_2_H
#define GUARD_DUNGEON_AI_TARGETING_2_H
#include "dungeon_entity.h"
u8 CanTarget(struct DungeonEntity *pokemon, struct DungeonEntity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified);
#endif

View File

@ -234,9 +234,6 @@ SECTIONS {
src/dungeon_ai_targeting.o(.text);
asm/code_8071214.o(.text);
src/dungeon_ai_targeting_1.o(.text);
asm/code_8071518.o(.text);
src/dungeon_ai_targeting_2.o(.text);
asm/code_807167C.o(.text);
src/dungeon_pokemon_attributes.o(.text);
asm/code_80718D8.o(.text);
src/dungeon_ai_items.o(.text);
@ -452,7 +449,7 @@ SECTIONS {
data/data_8106FB5.o(.rodata);
src/dungeon_ai_targeting.o(.rodata);
data/data_8106FDD.o(.rodata);
src/dungeon_ai_targeting_2.o(.rodata);
src/dungeon_ai_targeting_1.o(.rodata);
data/data_8107010.o(.rodata);
src/friend_area.o(.rodata);
data/data_810AC60.o(.rodata);

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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;
}

View File

@ -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];
}