Merge pull request #209 from AnonymousRandomPerson/master

Updated some AI symbol names
This commit is contained in:
Seth Barberee 2024-08-30 15:25:35 -07:00 committed by GitHub
commit a771a66ed3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
37 changed files with 596 additions and 591 deletions

View File

@ -2541,7 +2541,7 @@ _080537F8:
adds r1, r7, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
@ -3127,7 +3127,7 @@ _08053CD0:
adds r1, r5, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
cmp r0, 0
bne _08053CEC
@ -3274,7 +3274,7 @@ _08053DF2:
adds r1, r5, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
@ -4532,7 +4532,7 @@ _08054BD8:
adds r1, r5, 0
mov r2, r8
mov r3, r9
bl SandstormMoveAction
bl SandstormMoveAction
bl _080554BA
_08054BE8:
adds r0, r7, 0
@ -5250,7 +5250,7 @@ _08055190:
adds r1, r5, 0
mov r2, r8
mov r3, r9
bl RainDanceMoveAction
bl RainDanceMoveAction
b _080554BA
_0805519E:
adds r0, r7, 0
@ -5313,7 +5313,7 @@ _0805520E:
adds r1, r5, 0
mov r2, r8
mov r3, r9
bl SunnyDayMoveAction
bl SunnyDayMoveAction
b _080554BA
_0805521C:
adds r0, r7, 0
@ -5397,7 +5397,7 @@ _080552B6:
adds r1, r5, 0
mov r2, r8
mov r3, r9
bl HailMoveAction
bl HailMoveAction
b _080554BA
_080552C4:
adds r0, r7, 0
@ -9066,7 +9066,7 @@ _08056FD0:
adds r1, r7, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
@ -9079,7 +9079,7 @@ _08056FE6:
adds r1, r7, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
cmp r0, 0
bne _0805702E
@ -9099,7 +9099,7 @@ _0805700C:
adds r1, r7, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
cmp r0, 0
bne _0805702E

View File

@ -863,7 +863,7 @@ _080620C4:
bl sub_8044F5C
ldr r0, [sp, 0x110]
movs r1, 0x1
bl CannotMove
bl CheckVariousStatuses2
lsls r0, 24
cmp r0, 0
beq _08062102

View File

@ -926,7 +926,7 @@ _08067594:
adds r1, r5, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
@ -937,7 +937,7 @@ _080675AA:
adds r1, r6, 0
movs r2, 0x1
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
@ -966,7 +966,7 @@ _080675C0:
beq _08067600
adds r0, r5, 0
movs r1, 0x1
bl CannotMove
bl CheckVariousStatuses2
lsls r0, 24
cmp r0, 0
beq _08067610

View File

@ -758,12 +758,12 @@ _0806A8C8:
beq _0806A90E
adds r0, r4, 0
movs r1, 0x1
bl CannotMove
bl CheckVariousStatuses2
lsls r0, 24
cmp r0, 0
beq _0806A8EE
adds r0, r4, 0
bl HasStatusThatPreventsActing
bl CheckVariousStatuses
lsls r0, 24
cmp r0, 0
bne _0806A90E

View File

@ -71,7 +71,7 @@ _0806D088:
ldr r0, [sp, 0x44]
mov r9, r0
adds r0, r5, 0
bl HasStatusThatPreventsActing
bl CheckVariousStatuses
lsls r0, 24
cmp r0, 0
bne _0806D0A2

View File

@ -1632,7 +1632,7 @@ _08074A46:
strb r0, [r7]
adds r0, r5, 0
movs r1, 0
bl CannotMove
bl CheckVariousStatuses2
lsls r0, 24
cmp r0, 0
bne _08074AD4
@ -1643,7 +1643,7 @@ _08074A46:
cmp r0, 0
bne _08074AD4
adds r0, r5, 0
bl HasStatusThatPreventsActing
bl CheckVariousStatuses
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0
@ -2659,12 +2659,12 @@ _0807524E:
beq _0807534C
adds r0, r5, 0
movs r1, 0x1
bl CannotMove
bl CheckVariousStatuses2
lsls r0, 24
cmp r0, 0
beq _080752B2
adds r0, r5, 0
bl HasStatusThatPreventsActing
bl CheckVariousStatuses
lsls r0, 24
cmp r0, 0
bne _0807534C

View File

@ -1823,7 +1823,7 @@ _0807F4E4:
adds r1, r4, 0
movs r2, 0
movs r3, 0x1
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
@ -1839,7 +1839,7 @@ _0807F50C:
adds r1, r4, 0
movs r2, 0
movs r3, 0x1
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
cmp r0, 0
bne _0807F602

View File

@ -4,7 +4,7 @@
.syntax unified
.text
thumb_func_start sub_8083660
sub_8083660:
push {r4-r7,lr}
@ -377,7 +377,7 @@ sub_8083904:
ldrb r6, [r5]
mov r0, r10
movs r1, 0x1
bl CannotMove
bl CheckVariousStatuses2
lsls r0, 24
cmp r0, 0
beq _08083954
@ -507,7 +507,7 @@ _08083A00:
adds r1, r4, 0
movs r2, 0
movs r3, 0
bl CanTarget
bl GetTreatmentBetweenMonsters
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,6 @@
bool8 MoveMatchesChargingStatus(Entity *pokemon, Move *move);
// checkCharge = Check for the move named Charge.
bool8 IsCharging(Entity *pokemon, bool8 checkCharge);
bool8 IsChargingAnyTwoTurnMove(Entity *pokemon, bool8 checkCharge);
#endif

View File

@ -5,8 +5,8 @@
#define TARGETING_DECOY_TEAM 1
#define TARGETING_DECOY_WILD 2
#define TARGET_CAPABILITY_CANNOT_ATTACK 0
#define TARGET_CAPABILITY_CAN_TARGET 1
#define TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET 2
#define TREATMENT_TREAT_AS_ALLY 0
#define TREATMENT_TREAT_AS_ENEMY 1
#define TREATMENT_IGNORE 2
#endif

View File

@ -3,7 +3,7 @@
#include "structs/dungeon_entity.h"
u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags);
bool8 CanTargetAdjacentPokemon(Entity *pokemon);
u32 GetAIUseItemProbability(Entity *targetPokemon, Item *item, u32 itemTargetFlags);
bool8 IsAdjacentToEnemy(Entity *pokemon);
#endif

View File

@ -4,9 +4,9 @@
#include "structs/dungeon_entity.h"
#include "structs/str_position.h"
void DecideUseItem(Entity *pokemon);
void FindStraightThrowableTargets(Entity *pokemon, s32 thrownAIFlag, Item *item, bool8 ignoreRollChance);
void FindRockItemTargets(Entity *pokemon, Item *item, Position potentialTargets[], bool8 ignoreRollChance);
void AIDecideUseItem(Entity *pokemon);
void GetPossibleAIThrownItemDirections(Entity *pokemon, s32 thrownAIFlag, Item *item, bool8 ignoreRollChance);
void GetPossibleAIArcItemTargets(Entity *pokemon, Item *item, Position potentialTargets[], bool8 ignoreRollChance);
void TargetThrownItem(Entity *pokemon, Entity *targetPokemon, Item *item, s32 targetingFlags, bool8 ignoreRollChance);
#endif

View File

@ -10,7 +10,7 @@ bool8 ShouldAvoidFirstHit(Entity *pokemon, bool8 forceAvoid);
bool8 ShouldMonsterRunAway(Entity *pokemon);
bool8 ShouldMonsterRunAwayAndShowEffect(Entity *pokemon, bool8 showRunAwayEffect);
void CheckRunAwayVisualFlag(Entity *pokemon, bool8 showRunAwayEffect);
u8 CanTarget(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified);
u8 GetTreatmentBetweenMonsters(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified);
u8 sub_807167C(Entity * pokemon, Entity * target);
#endif

View File

@ -3,10 +3,10 @@
#include "structs/dungeon_entity.h"
bool8 CannotMove(Entity *pokemon, bool8 checkBlinker);
bool8 CheckVariousStatuses2(Entity *pokemon, bool8 checkBlinker);
bool8 sub_8070BC0(Entity* entity);
bool8 CannotUseItems(Entity *pokemon);
bool8 HasStatusThatPreventsActing(Entity *pokemon);
bool8 CheckVariousConditions(Entity *pokemon);
bool8 CheckVariousStatuses(Entity *pokemon);
bool8 CannotAttack(Entity *pokemon, bool8 skipSleep);
bool8 CanMoveInDirection(Entity *pokemon, u32 direction);

View File

@ -14,7 +14,7 @@ void LoadIQSkills(Entity *pokemon);
bool8 CanSeeTeammate(Entity * pokemon);
u8 GetMoveTypeForMonster(Entity *pokemon, Move *pokeMove);
s32 GetMovePower(Entity *pokemon, Move *pokeMove);
bool8 ToolboxEnabled(EntityInfo *pokemon);
bool8 MonsterCanThrowItems(EntityInfo *pokemon);
bool8 SetVisualFlags(EntityInfo *entityInfo, u16 newFlag, bool8 param_3);
#endif

View File

@ -62,7 +62,7 @@ u32 GetWeight(s16 index);
u32 GetSize(s16 index);
u8 GetFriendArea(s32 index);
u16 GetBaseHP(s16 index);
bool8 IsToolboxEnabled(s16 index);
bool8 MonsterIDCanThrowItems(s16 index);
u8 GetUnk12(s16 index);
s16 GetPokemonEvolveFrom(s16 index);
u16 GetBaseOffensiveStat(s32 index, u32 r1);

View File

@ -143,7 +143,7 @@ typedef struct MonsterDataEntry
u8 unk30; // 10 for all Pokémon.
u8 unk31; // 10 for all Pokémon.
u8 unk32; // 24 for all Pokémon.
/* 0x33 */ bool8 toolboxEnabled; // If false, the AI can't use items. Doesn't seem to be used, as it's true for all Pokémon.
/* 0x33 */ bool8 canThrowItems; // If false, the AI can't use items. Doesn't seem to be used, as it's true for all Pokémon.
/* 0x34 */ PreEvolution preEvolution;
/* 0x38 */ EvolutionRequirements evolutionRequirements;
/* 0x3C */ s16 dexInternal[2]; // dexNo and internalNo

View File

@ -85,7 +85,7 @@ bool8 MoveMatchesChargingStatus(Entity *pokemon, Move *move)
}
}
bool8 IsCharging(Entity *pokemon, bool8 checkCharge)
bool8 IsChargingAnyTwoTurnMove(Entity *pokemon, bool8 checkCharge)
{
if (!EntityExists(pokemon))
{
@ -113,6 +113,7 @@ bool8 IsCharging(Entity *pokemon, bool8 checkCharge)
return TRUE;
}
}
// BUG: This condition is never reached because the for loop terminates by returning FALSE at the end of the gMultiTurnChargingStatuses array.
if (checkCharge && *chargingStatusPointer2 == chargeStatus)
{
return TRUE;

View File

@ -218,7 +218,7 @@ void sub_80479B8(char param_1, char param_2, u8 param_3, Entity *pokemon, Entity
flag = IQSkillIsEnabled(target, IQ_ITEM_CATCHER);
}
}
if (CannotUseItems(target)) {
if (CheckVariousConditions(target)) {
flag = FALSE;
}
if (flag && ((info->heldItem.flags & ITEM_FLAG_EXISTS) == 0)) {
@ -867,7 +867,7 @@ bool8 sub_8048950(Entity *param_1,Item *item)
if (EntityExists(entity)) {
entityInfo = entity->info;
flag = CanMonLearnMove(moveID, entityInfo->id);
if (CannotMove(entity, FALSE)) {
if (CheckVariousStatuses2(entity, FALSE)) {
flag = FALSE;
}
if (entityInfo->clientType == CLIENT_TYPE_CLIENT) {
@ -942,7 +942,7 @@ bool8 sub_8048A68(Entity *param_1,Item *item)
flag = FALSE;
}
if (CannotMove(entity, FALSE)) {
if (CheckVariousStatuses2(entity, FALSE)) {
flag = FALSE;
}
if (pEVar6->clientType == CLIENT_TYPE_CLIENT) {
@ -1016,7 +1016,7 @@ bool32 sub_8048B9C(Entity *entity,Item *param_2)
if (EntityExists(entity1)) {
entity1Info = entity1->info;
flag = TRUE;
if(CannotMove(entity1, FALSE))
if(CheckVariousStatuses2(entity1, FALSE))
{
flag = FALSE;
}

View File

@ -2668,7 +2668,7 @@ bool8 sub_805EC4C(Entity *a0, u8 a1)
if (tileMonsterInfo->sleep.sleep != STATUS_NONE && tileMonsterInfo->sleep.sleep != STATUS_SLEEPLESS && tileMonsterInfo->sleep.sleep != STATUS_YAWNING) return FALSE;
if (entityInfo->sleep.sleep != STATUS_NONE && entityInfo->sleep.sleep != STATUS_SLEEPLESS && entityInfo->sleep.sleep != STATUS_YAWNING) return FALSE;
if (IsCharging(tileMonster, FALSE)) return FALSE;
if (IsChargingAnyTwoTurnMove(tileMonster, FALSE)) return FALSE;
if (!sub_8070F80(a0, entityInfo->action.direction)) return FALSE;
if (a1 != 0 && sub_807049C(tileMonster, &a0->pos) && !sub_8052B8C(0, gUnknown_8100208, 0)) return FALSE;
@ -4063,7 +4063,7 @@ void sub_8060900(Entity *a0)
if (EntityExists(teamMon)) {
EntityInfo *teamMonInfo = teamMon->info;
teamMonInfo->unk157 = FALSE;
if (!CannotUseItems(teamMon)) {
if (!CheckVariousConditions(teamMon)) {
r8 = TRUE;
teamMonInfo->unk157 = TRUE;
}
@ -4082,7 +4082,7 @@ void sub_8060900(Entity *a0)
sub_8044F5C(0x37, item->id);
}
if (CannotUseItems(a0)) {
if (CheckVariousConditions(a0)) {
sub_8044FF0(0x37);
sub_8044FF0(0x3E);
}
@ -4108,7 +4108,7 @@ void sub_8060900(Entity *a0)
sub_8044F5C(0xB, item->id);
}
if (!ToolboxEnabled(a0Info)) {
if (!MonsterCanThrowItems(a0Info)) {
sub_8044FF0(0x27);
sub_8044FF0(0x41);
sub_8044FF0(0xB);
@ -4122,7 +4122,7 @@ void sub_8060900(Entity *a0)
EntityInfo *teamMonInfo = teamMon->info;
r5 = FALSE;
if (CannotUseItems(teamMon))
if (CheckVariousConditions(teamMon))
r6 = TRUE;
else
r6 = FALSE;
@ -4571,7 +4571,7 @@ void sub_806145C(struct UnkFieldTeamMenuStruct *a0)
}
}
if (CannotMove(teamMon, FALSE)) {
if (CheckVariousStatuses2(teamMon, FALSE)) {
r5 = FALSE;
}
if (!r5) {
@ -4723,7 +4723,7 @@ void ShowTacticsMenu(ActionContainer *a0)
gUnknown_202EE6C = 0;
sub_8044F5C(0x2F, 0);
sub_8044F5C(0xC, 0);
if (CannotMove(teamMon, TRUE)) {
if (CheckVariousStatuses2(teamMon, TRUE)) {
sub_8044FF0(0x2F);
}
sub_805FC30(&sp, 0x16);

View File

@ -40,7 +40,7 @@ void sub_8075680(void)
if (targetPos->x == entity->pos.x && targetPos->y == entity->pos.y)
continue;
if (CannotMove(entity, TRUE))
if (CheckVariousStatuses2(entity, TRUE))
continue;
direction = GetDirectionTowardsPosition(&entity->pos, targetPos);

View File

@ -87,14 +87,14 @@ void RunMonsterAI(Entity *pokemon, u32 unused)
{
if (pokemonInfo->clientType != CLIENT_TYPE_CLIENT && pokemonInfo->useHeldItem)
{
if (CannotUseItems(pokemon))
if (CheckVariousConditions(pokemon))
{
pokemonInfo->useHeldItem = FALSE;
SetMessageArgument(gAvailablePokemonNames, pokemon, 0);
SendMessage(pokemon, gPtrCouldntBeUsedMessage);
return;
}
DecideUseItem(pokemon);
AIDecideUseItem(pokemon);
if (pokemonInfo->action.action != ACTION_NOTHING)
{
return;
@ -134,7 +134,7 @@ void RunMonsterAI(Entity *pokemon, u32 unused)
}
else
{
DecideUseItem(pokemon);
AIDecideUseItem(pokemon);
if (pokemonInfo->action.action == ACTION_NOTHING)
{
if (!IQSkillIsEnabled(pokemon, IQ_DEDICATED_TRAVELER))

View File

@ -653,7 +653,7 @@ bool8 IsAITargetEligible(s32 targetingFlags, Entity *user, Entity *target, Move
u32 *categoryTargetingFlags2 = &categoryTargetingFlags; // Fixes a regswap.
if (*categoryTargetingFlags2 == TARGETING_FLAG_TARGET_OTHER)
{
if (CanTarget(user, target, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
if (GetTreatmentBetweenMonsters(user, target, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
{
hasTarget = TRUE;
}
@ -691,7 +691,7 @@ bool8 IsAITargetEligible(s32 targetingFlags, Entity *user, Entity *target, Move
goto returnFalse;
}
checkCanTarget:
if (CanTarget(user, target, FALSE, TRUE) == TARGET_CAPABILITY_CANNOT_ATTACK)
if (GetTreatmentBetweenMonsters(user, target, FALSE, TRUE) == TREATMENT_TREAT_AS_ALLY)
{
hasTarget = TRUE;
}
@ -827,7 +827,7 @@ bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified)
if (target != NULL &&
GetEntityType(target) == ENTITY_MONSTER &&
CanAttackInDirection(pokemon, direction) &&
CanTarget(pokemon, target, FALSE, checkPetrified) == TARGET_CAPABILITY_CAN_TARGET &&
GetTreatmentBetweenMonsters(pokemon, target, FALSE, checkPetrified) == TREATMENT_TREAT_AS_ENEMY &&
(!hasStatusChecker || target->info->immobilize.immobilizeStatus != STATUS_FROZEN))
{
potentialAttackTargetDirections[numPotentialTargets] = direction;

View File

@ -11,7 +11,7 @@
#include "number_util.h"
#include "status_checks_1.h"
u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
u32 GetAIUseItemProbability(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
{
EntityInfo *pokemonInfo = targetPokemon->info;
s32 itemWeight = 0;
@ -62,7 +62,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
{
if (!targetOther)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 100;
}
@ -153,7 +153,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
case ITEM_LIFE_SEED:
if (!targetOther)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 10;
}
@ -170,7 +170,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
case ITEM_EYEDROP_SEED:
if (!CanSeeInvisibleMonsters(targetPokemon))
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -187,7 +187,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
case ITEM_QUICK_SEED:
if (targetPokemon->info->speedStage < MAX_SPEED_STAGE)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -204,7 +204,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
case ITEM_ALLURE_SEED:
if (pokemonInfo->eyesightStatus.eyesightStatus != STATUS_CROSS_EYED)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -223,7 +223,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
{
return 0;
}
else if (CanTargetAdjacentPokemon(targetPokemon))
else if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -235,7 +235,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
case ITEM_TOTTER_SEED:
if (pokemonInfo->volatileStatus.volatileStatus != STATUS_CONFUSED)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -255,7 +255,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
{
return 0;
}
else if (CanTargetAdjacentPokemon(targetPokemon))
else if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 100;
}
@ -267,7 +267,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
case ITEM_BLINKER_SEED:
if (pokemonInfo->eyesightStatus.eyesightStatus != STATUS_BLINKER)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -284,7 +284,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
case ITEM_WARP_SEED:
if (!targetAlly)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 40;
}
@ -297,7 +297,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
{
if (!targetOther)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 100;
}
@ -320,7 +320,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
pokemonInfo->sleep.sleep != STATUS_NAPPING &&
pokemonInfo->sleep.sleep != STATUS_NIGHTMARE)
{
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -392,7 +392,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
{
return 0;
}
else if (CanTargetAdjacentPokemon(targetPokemon))
else if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -402,7 +402,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
}
break;
case ITEM_BLAST_SEED:
if (CanTargetAdjacentPokemon(targetPokemon))
if (IsAdjacentToEnemy(targetPokemon))
{
itemWeight = 80;
}
@ -443,7 +443,7 @@ u32 EvaluateItem(Entity *targetPokemon, Item *item, u32 itemTargetFlags)
return itemWeight;
}
bool8 CanTargetAdjacentPokemon(Entity *pokemon)
bool8 IsAdjacentToEnemy(Entity *pokemon)
{
s32 direction;
for (direction = 0; direction < NUM_DIRECTIONS; direction++)
@ -451,7 +451,7 @@ bool8 CanTargetAdjacentPokemon(Entity *pokemon)
struct Tile *mapTile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y);
Entity *adjacentPokemon = mapTile->monster;
if (adjacentPokemon != NULL && GetEntityType(adjacentPokemon) != ENTITY_NOTHING &&
CanTarget(pokemon, adjacentPokemon, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
GetTreatmentBetweenMonsters(pokemon, adjacentPokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
{
return TRUE;
}

View File

@ -34,11 +34,11 @@ enum ItemTargetFlag
ITEM_TARGET_ALLY = 1 << 1
};
EWRAM_DATA_2 s32 gNumPotentialTargets = {0};
EWRAM_DATA_2 s32 gAIThrowItemActionChoiceCount = {0};
EWRAM_DATA u32 gPotentialItemTargetDirections[NUM_DIRECTIONS] = {0};
EWRAM_DATA bool8 gTargetAhead[NUM_DIRECTIONS] = {0};
EWRAM_DATA u32 gPotentialItemTargetWeights[NUM_DIRECTIONS] = {0};
EWRAM_DATA u32 gAIThrownItemDirections[NUM_DIRECTIONS] = {0};
EWRAM_DATA bool8 gAIThrownItemDirectionIsUsed[NUM_DIRECTIONS] = {0};
EWRAM_DATA u32 gAIThrownItemProbabilities[NUM_DIRECTIONS] = {0};
extern TeamInventory *gTeamInventoryRef;
@ -61,7 +61,7 @@ void sub_807360C(void)
}
}
void DecideUseItem(Entity *pokemon)
void AIDecideUseItem(Entity *pokemon)
{
EntityInfo *pokemonInfo = pokemon->info;
void *null;
@ -69,7 +69,7 @@ void DecideUseItem(Entity *pokemon)
s32 toolboxIndex;
u8 selectedToolboxIndex;
u32 *potentialTargetWeights;
if (CannotUseItems(pokemon))
if (CheckVariousConditions(pokemon))
{
pokemonInfo->useHeldItem = FALSE;
return;
@ -90,20 +90,20 @@ void DecideUseItem(Entity *pokemon)
if (itemType == CATEGORY_THROWN_LINE)
{
s32 targetIndex;
FindStraightThrowableTargets(pokemon, 2, item, 1);
for (targetIndex = 0; targetIndex < gNumPotentialTargets; targetIndex++)
GetPossibleAIThrownItemDirections(pokemon, ITEM_AI_FLAG_TARGET_ENEMY, item, TRUE);
for (targetIndex = 0; targetIndex < gAIThrowItemActionChoiceCount; targetIndex++)
{
if (DungeonRandOutcome(gPotentialItemTargetWeights[targetIndex]))
if (DungeonRandOutcome(gAIThrownItemProbabilities[targetIndex]))
{
SetMonsterActionFields(&pokemonInfo->action, ACTION_THROW_ITEM_AI);
pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex;
pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x;
pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y;
pokemonInfo->action.direction = gPotentialItemTargetDirections[targetIndex] & DIRECTION_MASK;
pokemonInfo->action.direction = gAIThrownItemDirections[targetIndex] & DIRECTION_MASK;
break;
}
}
if (targetIndex == gNumPotentialTargets)
if (targetIndex == gAIThrowItemActionChoiceCount)
{
SetMonsterActionFields(&pokemonInfo->action, ACTION_SECOND_THOUGHTS);
}
@ -111,14 +111,14 @@ void DecideUseItem(Entity *pokemon)
else if (itemType == CATEGORY_THROWN_ARC)
{
Position potentialTargetPositions[NUM_POTENTIAL_ROCK_TARGETS];
FindRockItemTargets(pokemon, item, potentialTargetPositions, TRUE);
if (gNumPotentialTargets == 0)
GetPossibleAIArcItemTargets(pokemon, item, potentialTargetPositions, TRUE);
if (gAIThrowItemActionChoiceCount == 0)
{
SetMonsterActionFields(&pokemonInfo->action, ACTION_SECOND_THOUGHTS);
}
else
{
u32 chosenTargetIndex = DungeonRandInt(gNumPotentialTargets);
u32 chosenTargetIndex = DungeonRandInt(gAIThrowItemActionChoiceCount);
SetMonsterActionFields(&pokemonInfo->action, ACTION_THROW_ITEM_AI);
pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex;
pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x;
@ -191,7 +191,7 @@ void DecideUseItem(Entity *pokemon)
{
if (GetItemAIFlag(item->id, ITEM_AI_FLAG_TARGET_SELF))
{
u32 itemWeight = EvaluateItem(pokemon, item, ITEM_TARGET_ALLY);
u32 itemWeight = GetAIUseItemProbability(pokemon, item, ITEM_TARGET_ALLY);
if (itemWeight != 0)
{
u8 itemType = GetItemCategory(item->id);
@ -222,22 +222,22 @@ void DecideUseItem(Entity *pokemon)
{
continue;
}
if (ToolboxEnabled(pokemonInfo))
if (MonsterCanThrowItems(pokemonInfo))
{
s32 thrownAIFlag;
for (thrownAIFlag = ITEM_AI_FLAG_TARGET_ALLY; thrownAIFlag <= ITEM_AI_FLAG_TARGET_ENEMY; thrownAIFlag++)
{
potentialTargetWeights = gPotentialItemTargetWeights;
potentialTargetWeights = gAIThrownItemProbabilities;
if (GetItemAIFlag(item->id, thrownAIFlag))
{
u8 itemType = GetItemCategory(item->id);
if (itemType == CATEGORY_THROWN_ARC)
{
Position potentialTargetPositions[NUM_POTENTIAL_ROCK_TARGETS];
FindRockItemTargets(pokemon, item, potentialTargetPositions, FALSE);
if (gNumPotentialTargets != 0)
GetPossibleAIArcItemTargets(pokemon, item, potentialTargetPositions, FALSE);
if (gAIThrowItemActionChoiceCount != 0)
{
u32 chosenTargetIndex = DungeonRandInt(gNumPotentialTargets);
u32 chosenTargetIndex = DungeonRandInt(gAIThrowItemActionChoiceCount);
SetMonsterActionFields(&pokemonInfo->action, ACTION_THROW_ITEM_AI);
pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex;
pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x;
@ -250,8 +250,8 @@ void DecideUseItem(Entity *pokemon)
else
{
s32 targetIndex;
FindStraightThrowableTargets(pokemon, thrownAIFlag, item, FALSE);
for (targetIndex = 0; targetIndex < gNumPotentialTargets; targetIndex++)
GetPossibleAIThrownItemDirections(pokemon, thrownAIFlag, item, FALSE);
for (targetIndex = 0; targetIndex < gAIThrowItemActionChoiceCount; targetIndex++)
{
if (DungeonRandOutcome(potentialTargetWeights[targetIndex]))
{
@ -259,7 +259,7 @@ void DecideUseItem(Entity *pokemon)
pokemonInfo->action.unk4[0].actionUseIndex = selectedToolboxIndex;
pokemonInfo->action.unk4[0].lastItemThrowPosition.x = pokemon->pos.x;
pokemonInfo->action.unk4[0].lastItemThrowPosition.y = pokemon->pos.y;
pokemonInfo->action.direction = gPotentialItemTargetDirections[targetIndex] & DIRECTION_MASK;
pokemonInfo->action.direction = gAIThrownItemDirections[targetIndex] & DIRECTION_MASK;
return;
}
}
@ -271,13 +271,13 @@ void DecideUseItem(Entity *pokemon)
}
}
void FindStraightThrowableTargets(Entity *pokemon, s32 thrownAIFlag, Item *item, bool8 ignoreRollChance)
void GetPossibleAIThrownItemDirections(Entity *pokemon, s32 thrownAIFlag, Item *item, bool8 ignoreRollChance)
{
s32 i;
gNumPotentialTargets = 0;
gAIThrowItemActionChoiceCount = 0;
for (i = 0; i < NUM_DIRECTIONS; i++)
{
gTargetAhead[i] = FALSE;
gAIThrownItemDirectionIsUsed[i] = FALSE;
}
for (i = 0; i < DUNGEON_MAX_POKEMON; i++)
{
@ -287,7 +287,7 @@ void FindStraightThrowableTargets(Entity *pokemon, s32 thrownAIFlag, Item *item,
s32 targetingFlags;
if (thrownAIFlag == ITEM_AI_FLAG_TARGET_ALLY)
{
if (CanTarget(pokemon, targetPokemon, FALSE, FALSE) == TARGET_CAPABILITY_CANNOT_ATTACK)
if (GetTreatmentBetweenMonsters(pokemon, targetPokemon, FALSE, FALSE) == TREATMENT_TREAT_AS_ALLY)
{
targetingFlags = ITEM_TARGET_OTHER | ITEM_TARGET_ALLY;
}
@ -296,7 +296,7 @@ void FindStraightThrowableTargets(Entity *pokemon, s32 thrownAIFlag, Item *item,
continue;
}
}
else if (CanTarget(pokemon, targetPokemon, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
else if (GetTreatmentBetweenMonsters(pokemon, targetPokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
{
targetingFlags = ITEM_TARGET_OTHER;
}
@ -312,15 +312,15 @@ void FindStraightThrowableTargets(Entity *pokemon, s32 thrownAIFlag, Item *item,
}
}
void FindRockItemTargets(Entity *pokemon, Item *item, Position potentialTargets[], bool8 ignoreRollChance)
void GetPossibleAIArcItemTargets(Entity *pokemon, Item *item, Position potentialTargets[], bool8 ignoreRollChance)
{
s32 i;
gNumPotentialTargets = 0;
gAIThrowItemActionChoiceCount = 0;
for (i = 0; i < DUNGEON_MAX_POKEMON; i++)
{
Entity *targetPokemon = gDungeon->allPokemon[i];
if (EntityExists(targetPokemon) && pokemon != targetPokemon &&
CanSeeTarget(pokemon, targetPokemon) && CanTarget(pokemon, targetPokemon, FALSE, TRUE) == TARGET_CAPABILITY_CAN_TARGET)
CanSeeTarget(pokemon, targetPokemon) && GetTreatmentBetweenMonsters(pokemon, targetPokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
{
s32 distanceX;
s32 distance;
@ -343,16 +343,16 @@ void FindRockItemTargets(Entity *pokemon, Item *item, Position potentialTargets[
Position *newPotentialTarget;
if (!ignoreRollChance)
{
u32 itemWeight = EvaluateItem(targetPokemon, item, ITEM_TARGET_OTHER);
u32 itemWeight = GetAIUseItemProbability(targetPokemon, item, ITEM_TARGET_OTHER);
if (!DungeonRandOutcome(itemWeight))
{
continue;
}
}
newPotentialTarget = &potentialTargets[gNumPotentialTargets];
newPotentialTarget = &potentialTargets[gAIThrowItemActionChoiceCount];
newPotentialTarget->x = targetPokemon->pos.x;
newPotentialTarget->y = targetPokemon->pos.y;
gNumPotentialTargets++;
gAIThrowItemActionChoiceCount++;
}
}
}
@ -414,15 +414,15 @@ void TargetThrownItem(Entity *pokemon, Entity *targetPokemon, Item *item, s32 ta
}
}
if (targetDirection > -1 && !gTargetAhead[targetDirection] && IsTargetInRange(pokemon, targetPokemon, targetDirection, RANGED_ATTACK_RANGE))
if (targetDirection > -1 && !gAIThrownItemDirectionIsUsed[targetDirection] && IsTargetInRange(pokemon, targetPokemon, targetDirection, RANGED_ATTACK_RANGE))
{
u32 itemWeight;
u32 *targetWeight;
gTargetAhead[targetDirection] = TRUE;
gPotentialItemTargetDirections[gNumPotentialTargets] = targetDirection;
targetWeight = &gPotentialItemTargetWeights[gNumPotentialTargets];
itemWeight = !ignoreRollChance ? EvaluateItem(targetPokemon, item, targetingFlags) : 100;
gAIThrownItemDirectionIsUsed[targetDirection] = TRUE;
gAIThrownItemDirections[gAIThrowItemActionChoiceCount] = targetDirection;
targetWeight = &gAIThrownItemProbabilities[gAIThrowItemActionChoiceCount];
itemWeight = !ignoreRollChance ? GetAIUseItemProbability(targetPokemon, item, targetingFlags) : 100;
*targetWeight = itemWeight;
gNumPotentialTargets++;
gAIThrowItemActionChoiceCount++;
}
}

View File

@ -100,7 +100,7 @@ Entity* GetLeaderIfVisible(Entity *pokemon)
Entity *leader = GetLeader();
if (leader &&
leader->info->waitingStruct.waitingStatus != STATUS_DECOY &&
CanTarget(pokemon, leader, FALSE, FALSE) == TARGET_CAPABILITY_CANNOT_ATTACK &&
GetTreatmentBetweenMonsters(pokemon, leader, FALSE, FALSE) == TREATMENT_TREAT_AS_ALLY &&
CanTargetEntity(pokemon, leader))
{
return leader;
@ -134,7 +134,7 @@ bool8 sub_8072CF4(Entity *entity)
sub_8075BA4(entity,gUnknown_80F58F4[(info->action).action][1]);
}
}
if ((CannotAttack(entity, FALSE)) && (IsCharging(entity, TRUE))) {
if ((CannotAttack(entity, FALSE)) && (IsChargingAnyTwoTurnMove(entity, TRUE))) {
sub_8079764(entity);
}
@ -280,7 +280,7 @@ bool8 sub_8072CF4(Entity *entity)
case ACTION_THROW_ITEM_PLAYER:
case ACTION_THROW_STRAIGHT_PLAYER:
case ACTION_THROW_ARC_PLAYER:
if (ToolboxEnabled(info)) {
if (MonsterCanThrowItems(info)) {
nullsub_95(entity);
sub_80671A0(entity);
break;

View File

@ -106,7 +106,7 @@ bool8 CanTakeItem(Entity *pokemon)
EntityInfo *pokemonInfo = pokemon->info;
struct Tile *mapTile;
Entity *object;
if (!EntityExists(pokemon) || CannotUseItems(pokemon))
if (!EntityExists(pokemon) || CheckVariousConditions(pokemon))
{
return FALSE;
}
@ -173,7 +173,7 @@ bool8 ChooseTargetPosition(Entity *pokemon)
{
if (gDungeon->decoyActive)
{
if (CanTarget(pokemon, target, FALSE, TRUE) != TARGET_CAPABILITY_CAN_TARGET)
if (GetTreatmentBetweenMonsters(pokemon, target, FALSE, TRUE) != TREATMENT_TREAT_AS_ENEMY)
{
continue;
}
@ -534,7 +534,7 @@ bool8 AvoidEnemies(Entity *pokemon)
if (EntityExists(target) && CanSeeTarget(pokemon, target))
{
s32 distance;
if (gDungeon->decoyActive && CanTarget(pokemon, target, FALSE, TRUE) != TARGET_CAPABILITY_CAN_TARGET)
if (gDungeon->decoyActive && GetTreatmentBetweenMonsters(pokemon, target, FALSE, TRUE) != TREATMENT_TREAT_AS_ENEMY)
{
continue;
}

View File

@ -29,35 +29,35 @@ const u8 gDirectionBitMasks_5[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gDirectionBitMasks_6[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gDirectionBitMasks_7[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gTargetingData[3][2][2][2] = {
const u8 gTreatmentData[3][2][2][2] = {
{
{
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE}
},
{
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE}
}
},
{
{
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE}
},
{
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET},
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET}
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY},
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY}
}
},
{
{
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET},
{TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET, TARGET_CAPABILITY_CAN_TARGET}
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY},
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY}
},
{
{TARGET_CAPABILITY_CAN_TARGET, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET},
{TARGET_CAPABILITY_CANNOT_ATTACK, TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET}
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE}
}
}
};
@ -66,7 +66,7 @@ bool8 sub_8070F3C(Entity * pokemon, Position *pos, s32 direction)
{
u8 terrain;
struct Tile *tile;
terrain = GetCrossableTerrain(pokemon->info->id);
tile = GetTile(pos->x + gAdjacentTileOffsets[direction].x, pos->y + gAdjacentTileOffsets[direction].y);
@ -110,7 +110,7 @@ bool8 sub_8070F3C(Entity * pokemon, Position *pos, s32 direction)
bool8 sub_8070F14(Entity * pokemon, s32 direction)
{
struct Tile *tile;
tile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y);
if ((!(tile->terrainType & TERRAIN_TYPE_IMPASSABLE_WALL)) &&
@ -129,7 +129,7 @@ bool8 sub_8070F80(Entity * pokemon, s32 direction)
{
u8 terrain;
struct Tile *tile;
terrain = GetCrossableTerrain(pokemon->info->id);
tile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y);
@ -174,7 +174,7 @@ bool8 sub_8071058(Entity * pokemon, s32 direction)
{
u8 terrain;
struct Tile *tile;
terrain = GetCrossableTerrain(pokemon->info->id);
tile = GetTile(pokemon->pos.x + gAdjacentTileOffsets[direction].x, pokemon->pos.y + gAdjacentTileOffsets[direction].y);
@ -460,7 +460,7 @@ void CheckRunAwayVisualFlag(Entity *pokemon, bool8 showRunAwayEffect)
}
}
u8 CanTarget(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified)
u8 GetTreatmentBetweenMonsters(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified)
{
EntityInfo *pokemonInfo = pokemon->info;
EntityInfo *targetData = targetPokemon->info;
@ -471,7 +471,7 @@ u8 CanTarget(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool
bool8 targetIsDecoy;
if (pokemon == targetPokemon)
{
return TARGET_CAPABILITY_CANNOT_ATTACK;
return TREATMENT_TREAT_AS_ALLY;
}
if (pokemonInfo->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER ||
targetData->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER ||
@ -482,7 +482,7 @@ u8 CanTarget(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool
(checkPetrified && !pokemonInfo->isNotTeamMember && targetData->immobilize.immobilizeStatus == STATUS_PETRIFIED) ||
(!ignoreInvisible && targetData->transformStatus.transformStatus == STATUS_INVISIBLE && !CanSeeInvisibleMonsters(pokemon)))
{
return TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET;
return TREATMENT_IGNORE;
}
pokemonTargetingDecoy = pokemonInfo->targetingDecoy;
targetingDecoy = TARGETING_DECOY_NONE;
@ -523,7 +523,7 @@ u8 CanTarget(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool
{
targetIsDecoy = TRUE;
}
return gTargetingData[targetingDecoy][pokemonIsEnemy][targetIsEnemy][targetIsDecoy];
return gTreatmentData[targetingDecoy][pokemonIsEnemy][targetIsEnemy][targetIsDecoy];
}
static inline bool8 JoinLocationCannotUseItems_1(EntityInfo *pokemonInfo)
@ -553,15 +553,15 @@ u8 sub_807167C(Entity * pokemon, Entity * target)
cannotUseItems = JoinLocationCannotUseItems_1(targetEntityInfo);
if (cannotUseItems || (targetEntityInfo->shopkeeper != SHOPKEEPER_MODE_NORMAL)) {
error:
return TARGET_CAPABILITY_CAN_ATTACK_NOT_TARGET;
return TREATMENT_IGNORE;
}
else
{
if ((pokemonEntityData->isNotTeamMember) != (targetEntityInfo->isNotTeamMember)) {
return TARGET_CAPABILITY_CAN_TARGET;
return TREATMENT_TREAT_AS_ENEMY;
}
else {
return TARGET_CAPABILITY_CANNOT_ATTACK;
return TREATMENT_TREAT_AS_ALLY;
}
}
}

View File

@ -17,7 +17,10 @@
const u8 gDirectionBitMasks_1[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
bool8 CannotMove(Entity *pokemon, bool8 checkBlinker)
// TODO CheckVariousStatuses, CheckVariousStatuses2, CheckVariousConditions all check for different conditions that interfere with a Pokémon's ability to act,
// but I'm not sure what the reason is for each function checking the conditions that they do.
// These functions could use better names if someone figures out a clear pattern/reasoning.
bool8 CheckVariousStatuses2(Entity *pokemon, bool8 checkBlinker)
{
EntityInfo *pokemonInfo = pokemon->info;
@ -40,7 +43,7 @@ bool8 sub_8070BC0(Entity* entity)
{
EntityInfo *entityInfo = entity->info;
if (IsCharging(entity, FALSE)
if (IsChargingAnyTwoTurnMove(entity, FALSE)
|| entityInfo->sleep.sleep == STATUS_YAWNING
|| entityInfo->sleep.sleep == STATUS_NIGHTMARE
|| ShouldMonsterRunAway(entity)
@ -70,7 +73,7 @@ bool8 sub_8070BC0(Entity* entity)
if (entityInfo->volatileStatus.volatileStatus != STATUS_INFATUATED
&& entityInfo->volatileStatus.volatileStatus != STATUS_PAUSED)
return TRUE;
return FALSE;
}
@ -83,24 +86,24 @@ static inline bool8 JoinLocationCannotUseItems(EntityInfo *pokemonInfo)
return FALSE;
}
bool8 CannotUseItems(Entity *pokemon)
bool8 CheckVariousConditions(Entity *pokemon)
{
EntityInfo *pokemonInfo = pokemon->info;
if (pokemonInfo->clientType == CLIENT_TYPE_CLIENT
|| JoinLocationCannotUseItems(pokemonInfo)
|| (!pokemonInfo->isTeamLeader && ShouldMonsterRunAway(pokemon))
|| CannotMove(pokemon, FALSE)
|| HasStatusThatPreventsActing(pokemon))
|| CheckVariousStatuses2(pokemon, FALSE)
|| CheckVariousStatuses(pokemon))
return TRUE;
if (IsCharging(pokemon, FALSE))
if (IsChargingAnyTwoTurnMove(pokemon, FALSE))
return TRUE;
return FALSE;
}
bool8 HasStatusThatPreventsActing(Entity *pokemon)
bool8 CheckVariousStatuses(Entity *pokemon)
{
EntityInfo *pokemonInfo = pokemon->info;

View File

@ -370,7 +370,7 @@ bool8 sub_8046F00(Item *item)
entity = gDungeon->teamPokemon[index];
if (EntityExists(entity)) {
canLearnMove = CanMonLearnMove(moveID, entity->info->id);
cannotMove = CannotMove(entity, FALSE);
cannotMove = CheckVariousStatuses2(entity, FALSE);
if (cannotMove) {
canLearnMove = FALSE;
}

View File

@ -231,9 +231,9 @@ s32 GetMovePower(Entity *pokemon, Move *pokeMove)
return (GetMoveBasePower(pokeMove) + pokeMove->ginseng);
}
bool8 ToolboxEnabled(EntityInfo *pokemon)
bool8 MonsterCanThrowItems(EntityInfo *pokemon)
{
if(!IsToolboxEnabled(pokemon->id))
if(!MonsterIDCanThrowItems(pokemon->id))
return FALSE;
return TRUE;
}

View File

@ -3230,7 +3230,7 @@ bool8 sub_805AD54(Entity * pokemon, Entity * target, Move *move, u32 param_4)
for ( index = 0; index < numPossibleTargets; index++) {
targetEntity = possibleTargets[index];
if ((((EntityExists(targetEntity)) && (pokemon != targetEntity)) &&
(CanTarget(pokemon,targetEntity,FALSE,FALSE) == TARGET_CAPABILITY_CANNOT_ATTACK)) &&
(GetTreatmentBetweenMonsters(pokemon,targetEntity,FALSE,FALSE) == TREATMENT_TREAT_AS_ALLY)) &&
(targetEntity->info->clientType != CLIENT_TYPE_CLIENT)) {
if (!sub_805AD54_sub(targetEntity)) {
sub_807D148(pokemon,targetEntity,2,&target->pos);

View File

@ -544,7 +544,7 @@ void BurnedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, bool8 dis
SetMessageArgument_2(gAvailablePokemonNames,entityInfo,0);
sub_80522F4(pokemon,target,*gUnknown_80FF01C);
}
if (sub_807167C(target,entity) == TARGET_CAPABILITY_CAN_TARGET) {
if (sub_807167C(target,entity) == TREATMENT_TREAT_AS_ENEMY) {
// Recurse with the new target
BurnedStatusTarget(pokemon,entity,1,displayMessage);
}
@ -631,7 +631,7 @@ void PoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag
SetMessageArgument_2(gAvailablePokemonNames,entityInfo,0);
sub_80522F4(pokemon,target,*gUnknown_80FF01C);
}
if (sub_807167C(target,entity) == TARGET_CAPABILITY_CAN_TARGET) {
if (sub_807167C(target,entity) == TREATMENT_TREAT_AS_ENEMY) {
// Recurse with the new target
PoisonedStatusTarget(pokemon,entity,displayMessage);
}
@ -713,7 +713,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM
SetMessageArgument_2(gAvailablePokemonNames,entityInfo,0);
sub_80522F4(pokemon,target,*gUnknown_80FF01C);
}
if (sub_807167C(target,entity) == TARGET_CAPABILITY_CAN_TARGET) {
if (sub_807167C(target,entity) == TREATMENT_TREAT_AS_ENEMY) {
// Recurse with the new target
BadlyPoisonedStatusTarget(pokemon,entity,displayMessage);
}

View File

@ -483,9 +483,9 @@ u16 GetBaseHP(s16 index)
return gMonsterParameters[index].baseHP;
}
bool8 IsToolboxEnabled(s16 index)
bool8 MonsterIDCanThrowItems(s16 index)
{
return gMonsterParameters[index].toolboxEnabled;
return gMonsterParameters[index].canThrowItems;
}
u8 GetUnk12(s16 index)

View File

@ -10,6 +10,7 @@
#include "constants/ability.h"
#include "constants/move_id.h"
#include "constants/status.h"
#include "constants/targeting.h"
#include "constants/type.h"
#include "constants/weather.h"
#include "dungeon_ai_targeting.h"
@ -1083,7 +1084,7 @@ bool8 sub_805C080(Entity * pokemon, Entity *target, Move *move, s32 param_4)
for(index = 0; index < numPossibleTargets; index++){
targetEntity = possibleTargets[index];
if (((EntityExists(targetEntity)) && (pokemon != targetEntity)) &&
(CanTarget(pokemon,targetEntity,1,FALSE) == 0)) {
(GetTreatmentBetweenMonsters(pokemon,targetEntity,TRUE,FALSE) == TREATMENT_TREAT_AS_ALLY)) {
sub_807D148(pokemon,targetEntity,2,&pokemon->pos);
foundTarget = TRUE;
}

View File

@ -634,7 +634,7 @@ string generate_monster_data_text(Json data) {
<< read_json_int(data_entry["unk30"], 1)
<< read_json_int(data_entry["unk31"], 1)
<< read_json_int(data_entry["unk32"], 1)
<< read_json_bool(data_entry["toolboxEnabled"])
<< read_json_bool(data_entry["canThrowItems"])
<< read_json_string(data_entry["preEvolution"]["evolveFrom"], 2)
<< read_json_string(data_entry["preEvolution"]["evolveType"], 2);