mirror of
https://github.com/pret/pmd-sky.git
synced 2026-04-25 15:42:34 -05:00
Synced some param names with pmdsky-debug
This commit is contained in:
parent
85adf50cbd
commit
1e66f00068
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
// Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
|
||||
bool8 EntityIsValid__022E1A1C(struct entity *entity);
|
||||
// Updates an entity's pixel_pos field using the specified pixel_position struct, or its own pos field if it's null.
|
||||
void UpdateEntityPixelPos(struct entity *entity, struct pixel_position *pixel_pos);
|
||||
void SetEntityPixelPosXY(struct entity *entity, u32 x, u32 y);
|
||||
void IncrementEntityPixelPosXY(struct entity *entity, u32 x, u32 y);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "util.h"
|
||||
|
||||
// Compute a pseudorandom integer under a given maximum value using the dungeon PRNG.
|
||||
// pseudorandom integer on the interval [0, end - 1]
|
||||
s32 DungeonRandInt(s32 end);
|
||||
s32 DungeonRandRange(s32 from, s32 to);
|
||||
// Returns the result of a possibly biased coin flip (a Bernoulli random variable) with some success probability p, using the dungeon PRNG.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@
|
|||
#include "dungeon_mode.h"
|
||||
|
||||
// Runs the AI for a single monster to determine whether the monster can act and which action it should perform if so
|
||||
void RunMonsterAi(struct entity *pokemon, u32 unused);
|
||||
void RunMonsterAi(struct entity *monster, u32 unused);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_AI_H
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ extern u32 AI_THROWN_ITEM_DIRECTIONS[NUM_DIRECTIONS];
|
|||
// Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
|
||||
bool8 EntityIsValid__0230E8F0(struct entity *entity);
|
||||
// Decides whether or not an AI should use its held item and updates its action_data fields accordingly.
|
||||
void AiDecideUseItem(struct entity *pokemon);
|
||||
void AiDecideUseItem(struct entity *entity);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_AI_ITEMS_H
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
// The caller function will select the direction to throw the item by iterating through the array(s), rolling the probability, and then throwing in that direction if the roll succeeds.
|
||||
// Nothing will be thrown if all rolls fail.
|
||||
//
|
||||
// pokemon: Entity pointer
|
||||
// thrown_ai_flag: Integer in {1, 2}. If 1, target allies; if 2, target enemies.
|
||||
// entity: Entity pointer
|
||||
// ally_or_enemy: Integer in {1, 2}. If 1, target allies; if 2, target enemies.
|
||||
// item: Item struct pointer
|
||||
// ignore_roll_chance: If false, will call GetAiUseItemProbability to get the probability of throwing in a certain direction.
|
||||
// always_add: If false, will call GetAiUseItemProbability to get the probability of throwing in a certain direction.
|
||||
// If true, the added probability will always be 100.
|
||||
void GetPossibleAiThrownItemDirections(struct entity *pokemon, s32 thrown_ai_flag, struct item *item, bool8 ignore_roll_chance);
|
||||
void GetPossibleAiThrownItemDirections(struct entity *entity, s32 ally_or_enemy, struct item *item, bool8 always_add);
|
||||
// Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
|
||||
bool8 EntityIsValid__0230F008(struct entity *entity);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
|
||||
// Checks if a monster should run away from other monsters
|
||||
// return: True if the monster should run away, false otherwise
|
||||
bool8 ShouldMonsterRunAway(struct entity *pokemon);
|
||||
bool8 ShouldMonsterRunAway(struct entity *monster);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_AI_TARGETING_H
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
// Returns 0 if none of these conditions holds for the given entity: is a rescue client,
|
||||
// doesn't gain experience (a mission client/story teammate?), is a terrified non-team-leader,
|
||||
// meets any of the conditions in CheckVariousStatuses2 (with blind_check = 0), is charging a two-turn move.
|
||||
bool8 CheckVariousConditions(struct entity *pokemon);
|
||||
bool8 CheckVariousConditions(struct entity *entity);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_CAPABILITIES_H
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "dungeon_mode.h"
|
||||
|
||||
// Returns 0 if none of these conditions holds for the given entity: asleep, frozen, petrified, biding.
|
||||
bool8 CheckVariousStatuses(struct entity *pokemon);
|
||||
// Returns false if none of these conditions holds for the given entity: asleep, frozen, petrified, biding.
|
||||
bool8 CheckVariousStatuses(struct entity *entity);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_CAPABILITIES_2_H
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@
|
|||
// pokemon: Entity pointer
|
||||
// check_charge: Unused boolean which was supposed to make function return true if the entity is under the effect of Charge (the Electric-type move).
|
||||
// However, the conditional which uses this boolean will never be activated, as the loop will always terminate before getting to it.
|
||||
bool8 IsChargingAnyTwoTurnMove(struct entity *pokemon, bool8 check_charge);
|
||||
bool8 IsChargingAnyTwoTurnMove(struct entity *entity, bool8 charge_check_unused);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_MOVE_H
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
#include "dungeon_mode.h"
|
||||
|
||||
// Checks if a monster does not have the Gastro Acid status.
|
||||
bool8 NoGastroAcidStatus(struct entity *entity, enum ability_id ability);
|
||||
bool8 NoGastroAcidStatus(struct entity *entity, enum ability_id ability_id);
|
||||
// Checks if a monster has a certain ability that isn't disabled by Gastro Acid.
|
||||
bool8 AbilityIsActive(struct entity *pokemon, enum ability_id ability);
|
||||
bool8 AbilityIsActive(struct entity *entity, enum ability_id ability_id);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_POKEMON_ATTRIBUTES_H
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
#include "dungeon_mode.h"
|
||||
|
||||
bool8 ShouldRunMonsterAi(struct entity *pokemon);
|
||||
bool8 ShouldRunMonsterAi(struct entity *monster);
|
||||
|
||||
#endif //PMDSKY_DUNGEON_UTIL_H
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
// Checks if a monster is a special story ally.
|
||||
// This is a hard-coded check that looks at the monster's "Joined At" field. If the value is in the range [DUNGEON_JOINED_AT_BIDOOF, DUNGEON_DUMMY_0xE3], this check will return true.
|
||||
bool8 IsSpecialStoryAlly(struct monster *pokemon_info);
|
||||
bool8 IsSpecialStoryAlly(struct monster *monster);
|
||||
// Checks if a monster does not gain experience.
|
||||
// This basically just inverts IsSpecialStoryAlly, with the exception of also checking for the "Joined At" field being DUNGEON_CLIENT (set for mission clients).
|
||||
bool8 IsExperienceLocked(struct monster *pokemon_info);
|
||||
bool8 IsExperienceLocked(struct monster *monster);
|
||||
|
||||
#endif //PMDSKY_JOINED_AT_CHECKS_H
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dungeon_ai.h"
|
||||
#include "dg_random.h"
|
||||
#include "direction.h"
|
||||
#include "dungeon_ai_items.h"
|
||||
#include "dungeon_capabilities_1.h"
|
||||
#include "dungeon_util_static.h"
|
||||
#include "dungeon_util.h"
|
||||
|
|
@ -16,50 +17,49 @@
|
|||
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern void EndFrozenClassStatus(struct entity *pokemon, struct entity *target, bool8 log);
|
||||
extern void SubstitutePlaceholderStringTags(u8 *buffer, struct entity *entity, u32 param_3);
|
||||
extern void LogMessageByIdWithPopupCheckUser(struct entity *pokemon, u32 message_id);
|
||||
extern void AiDecideUseItem(struct entity *pokemon);
|
||||
extern bool8 HasStatusThatPreventsActing(struct entity *pokemon);
|
||||
extern void ClearMonsterActionFields(struct action_data *action_pointer);
|
||||
extern void SetActionPassTurnOrWalk(struct action_data *action_pointer, s16 species);
|
||||
extern bool8 IqSkillIsEnabled(struct entity *pokemon, enum iq_skill_id iq_skill);
|
||||
extern void ChooseAiMove(struct entity *pokemon);
|
||||
extern bool8 GetCanMoveFlag(s16 index);
|
||||
extern void AiMovement(struct entity *pokemon, bool8 show_run_away_effect);
|
||||
extern void EndFrozenClassStatus(struct entity *user, struct entity *target, bool8 log);
|
||||
extern void SubstitutePlaceholderStringTags(u8 *string_id, struct entity *entity, u32 param_3);
|
||||
extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id);
|
||||
extern bool8 HasStatusThatPreventsActing(struct entity *monster);
|
||||
extern void ClearMonsterActionFields(struct action_data *monster_action);
|
||||
extern void SetActionPassTurnOrWalk(struct action_data *monster_action, s16 monster_id);
|
||||
extern bool8 IqSkillIsEnabled(struct entity *entity, enum iq_skill_id iq_id);
|
||||
extern void ChooseAiMove(struct entity *monster);
|
||||
extern bool8 GetCanMoveFlag(s16 monster_id);
|
||||
extern void AiMovement(struct entity *monster, bool8 show_run_away_effect);
|
||||
extern void SetDecoyAiTracker(struct entity* entity);
|
||||
extern bool8 CanSeeTarget(struct entity *entity, struct entity *target_entity);
|
||||
extern bool8 CanSeeTarget(struct entity *user, struct entity *target);
|
||||
|
||||
void RunMonsterAi(struct entity *pokemon, u32 unused)
|
||||
void RunMonsterAi(struct entity *monster, u32 unused)
|
||||
{
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
struct monster *pokemon_info = GetEntInfo(monster);
|
||||
if (pokemon_info->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY)
|
||||
{
|
||||
if (pokemon_info->frozen_class_status.freeze == STATUS_FROZEN_PETRIFIED)
|
||||
{
|
||||
EndFrozenClassStatus(pokemon, pokemon, TRUE);
|
||||
EndFrozenClassStatus(monster, monster, TRUE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
pokemon_info->decoy_ai_tracker = DECOY_AI_NONE;
|
||||
if (pokemon_info->monster_behavior <= BEHAVIOR_FIXED_ENEMY || ShouldRunMonsterAi(pokemon))
|
||||
if (pokemon_info->monster_behavior <= BEHAVIOR_FIXED_ENEMY || ShouldRunMonsterAi(monster))
|
||||
{
|
||||
if (pokemon_info->monster_behavior != BEHAVIOR_RESCUE_TARGET && pokemon_info->use_held_item)
|
||||
{
|
||||
if (CheckVariousConditions(pokemon))
|
||||
if (CheckVariousConditions(monster))
|
||||
{
|
||||
pokemon_info->use_held_item = FALSE;
|
||||
SubstitutePlaceholderStringTags(0, pokemon, 0);
|
||||
LogMessageByIdWithPopupCheckUser(pokemon, CANNOT_USE_ITEM_MESSAGE);
|
||||
SubstitutePlaceholderStringTags(0, monster, 0);
|
||||
LogMessageByIdWithPopupCheckUser(monster, CANNOT_USE_ITEM_MESSAGE);
|
||||
return;
|
||||
}
|
||||
AiDecideUseItem(pokemon);
|
||||
AiDecideUseItem(monster);
|
||||
if (pokemon_info->action.action_id != ACTION_NOTHING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!HasStatusThatPreventsActing(pokemon))
|
||||
if (!HasStatusThatPreventsActing(monster))
|
||||
{
|
||||
#ifdef JAPAN
|
||||
if (DUNGEON_PTR[0]->decoy_is_active)
|
||||
|
|
@ -78,7 +78,7 @@ void RunMonsterAi(struct entity *pokemon, u32 unused)
|
|||
}
|
||||
if (entity_is_valid &&
|
||||
GetEntInfo(target)->curse_class_status.curse == STATUS_CURSE_DECOY &&
|
||||
CanSeeTarget(pokemon, target))
|
||||
CanSeeTarget(monster, target))
|
||||
{
|
||||
pokemon_info->decoy_ai_tracker = GetEntInfo(target)->curse_class_status.curse_applier_non_team_member_flag ? DECOY_AI_WILD : DECOY_AI_TEAM;
|
||||
break;
|
||||
|
|
@ -86,23 +86,23 @@ void RunMonsterAi(struct entity *pokemon, u32 unused)
|
|||
}
|
||||
}
|
||||
#else
|
||||
SetDecoyAiTracker(pokemon);
|
||||
SetDecoyAiTracker(monster);
|
||||
#endif
|
||||
ClearMonsterActionFields(&pokemon_info->action);
|
||||
if (pokemon_info->monster_behavior == BEHAVIOR_RESCUE_TARGET)
|
||||
{
|
||||
SetActionPassTurnOrWalk(&pokemon_info->action, pokemon_info->id);
|
||||
pokemon_info->action.direction = (enum direction_id) DungeonRandInt(DIR_CURRENT);
|
||||
pokemon_info->target_pos.x = pokemon->pos.x;
|
||||
pokemon_info->target_pos.y = pokemon->pos.y - 1;
|
||||
pokemon_info->target_pos.x = monster->pos.x;
|
||||
pokemon_info->target_pos.y = monster->pos.y - 1;
|
||||
return;
|
||||
}
|
||||
AiDecideUseItem(pokemon);
|
||||
AiDecideUseItem(monster);
|
||||
if (pokemon_info->action.action_id == ACTION_NOTHING)
|
||||
{
|
||||
if (!IqSkillIsEnabled(pokemon, IQ_DEDICATED_TRAVELER))
|
||||
if (!IqSkillIsEnabled(monster, IQ_DEDICATED_TRAVELER))
|
||||
{
|
||||
ChooseAiMove(pokemon);
|
||||
ChooseAiMove(monster);
|
||||
if (pokemon_info->action.action_id != ACTION_NOTHING)
|
||||
{
|
||||
return;
|
||||
|
|
@ -117,11 +117,11 @@ void RunMonsterAi(struct entity *pokemon, u32 unused)
|
|||
{
|
||||
return;
|
||||
}
|
||||
AiMovement(pokemon, TRUE);
|
||||
if (pokemon_info->is_not_team_member && IqSkillIsEnabled(pokemon, IQ_EXCLUSIVE_MOVE_USER) && pokemon_info->action.action_id <= ACTION_PASS_TURN)
|
||||
AiMovement(monster, TRUE);
|
||||
if (pokemon_info->is_not_team_member && IqSkillIsEnabled(monster, IQ_EXCLUSIVE_MOVE_USER) && pokemon_info->action.action_id <= ACTION_PASS_TURN)
|
||||
{
|
||||
SubstitutePlaceholderStringTags(0, pokemon, 0);
|
||||
LogMessageByIdWithPopupCheckUser(pokemon, WATCHING_CAREFULLY_MESSAGE);
|
||||
SubstitutePlaceholderStringTags(0, monster, 0);
|
||||
LogMessageByIdWithPopupCheckUser(monster, WATCHING_CAREFULLY_MESSAGE);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -133,20 +133,20 @@ void RunMonsterAi(struct entity *pokemon, u32 unused)
|
|||
}
|
||||
if (GetCanMoveFlag(pokemon_info->id))
|
||||
{
|
||||
AiMovement(pokemon, TRUE);
|
||||
AiMovement(monster, TRUE);
|
||||
}
|
||||
if (pokemon_info->action.action_id != ACTION_NOTHING && pokemon_info->action.action_id != ACTION_PASS_TURN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ChooseAiMove(pokemon);
|
||||
ChooseAiMove(monster);
|
||||
if (GetCanMoveFlag(pokemon_info->id) &&
|
||||
pokemon_info->is_not_team_member &&
|
||||
IqSkillIsEnabled(pokemon, IQ_EXCLUSIVE_MOVE_USER) &&
|
||||
IqSkillIsEnabled(monster, IQ_EXCLUSIVE_MOVE_USER) &&
|
||||
pokemon_info->action.action_id <= ACTION_PASS_TURN)
|
||||
{
|
||||
SubstitutePlaceholderStringTags(0, pokemon, 0);
|
||||
LogMessageByIdWithPopupCheckUser(pokemon, WATCHING_CAREFULLY_MESSAGE);
|
||||
SubstitutePlaceholderStringTags(0, monster, 0);
|
||||
LogMessageByIdWithPopupCheckUser(monster, WATCHING_CAREFULLY_MESSAGE);
|
||||
}
|
||||
if (pokemon_info->action.action_id != ACTION_NOTHING && pokemon_info->action.action_id != ACTION_PASS_TURN)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "dungeon_ai_items.h"
|
||||
#include "dg_random.h"
|
||||
#include "direction.h"
|
||||
#include "dungeon_ai_items_1.h"
|
||||
#include "dungeon_capabilities_1.h"
|
||||
#include "dungeon_util_static.h"
|
||||
#include "item.h"
|
||||
|
|
@ -15,16 +16,15 @@ u32 AI_THROWN_ITEM_DIRECTIONS[NUM_DIRECTIONS] = {0};
|
|||
extern volatile s32 AI_THROWN_ITEM_ACTION_CHOICE_COUNT;
|
||||
extern struct bag_items *BAG_ITEMS_PTR_MIRROR;
|
||||
|
||||
extern void GetPossibleAiThrownItemDirections(struct entity *pokemon, s32 thrown_ai_flag, struct item *item, bool8 ignore_roll_chance);
|
||||
extern void SetMonsterActionFields(struct action_data *action_pointer, u16 action);
|
||||
extern bool8 IqSkillIsEnabled(struct entity *pokemon, u8 iq_skill);
|
||||
extern bool8 IqSkillIsEnabled(struct entity *entity, u8 iq_skill);
|
||||
extern const struct tile *GetTile(s32 x, s32 y);
|
||||
extern bool8 TestItemAiFlag(s16 id, s32 aiFlag);
|
||||
extern void GetPossibleAiArcItemTargets(struct entity *pokemon, struct item *item, struct position potential_targets[], bool8 ignore_roll_chance);
|
||||
extern s32 GetDirectionTowardsPosition(struct position *origin_pos, struct position *target_pos);
|
||||
extern struct item *GetItemInfo(struct entity *entity);
|
||||
extern u32 GetAiUseItemProbability(struct entity *target_pokemon, struct item *item, u32 item_target_flags);
|
||||
extern bool8 MonsterCanThrowItems(struct monster *pokemon);
|
||||
extern bool8 TestItemAiFlag(s16 item_id, s32 flag);
|
||||
extern void GetPossibleAiArcItemTargets(struct entity *user, struct item *item, struct position positions[], bool8 always_add_position);
|
||||
extern s32 GetDirectionTowardsPosition(struct position *origin, struct position *target);
|
||||
extern struct item *GetItemInfo(struct entity *item_entity);
|
||||
extern u32 GetAiUseItemProbability(struct entity *item_consumer, struct item *item, u32 flags);
|
||||
extern bool8 MonsterCanThrowItems(struct monster *monster);
|
||||
|
||||
bool8 EntityIsValid__0230E8F0(struct entity *entity)
|
||||
{
|
||||
|
|
@ -35,14 +35,14 @@ bool8 EntityIsValid__0230E8F0(struct entity *entity)
|
|||
return entity->type != ENTITY_NOTHING;
|
||||
}
|
||||
|
||||
void AiDecideUseItem(struct entity *pokemon)
|
||||
void AiDecideUseItem(struct entity *entity)
|
||||
{
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
struct monster *pokemon_info = GetEntInfo(entity);
|
||||
struct item *item;
|
||||
struct position potential_target_positions[NUM_POTENTIAL_ROCK_TARGETS];
|
||||
s32 i;
|
||||
u32 chosen_target_index;
|
||||
if (CheckVariousConditions(pokemon))
|
||||
if (CheckVariousConditions(entity))
|
||||
{
|
||||
pokemon_info->use_held_item = FALSE;
|
||||
return;
|
||||
|
|
@ -58,15 +58,15 @@ void AiDecideUseItem(struct entity *pokemon)
|
|||
enum item_category item_type = GetItemCategoryVeneer(item->id);
|
||||
if (item_type == CATEGORY_THROWN_LINE)
|
||||
{
|
||||
GetPossibleAiThrownItemDirections(pokemon, ITEM_AI_FLAG_TARGET_ENEMY, item, TRUE);
|
||||
GetPossibleAiThrownItemDirections(entity, ITEM_AI_FLAG_TARGET_ENEMY, item, TRUE);
|
||||
for (i = 0; i < AI_THROWN_ITEM_ACTION_CHOICE_COUNT; i++)
|
||||
{
|
||||
if (DungeonRandOutcome__022EAB20(AI_THROWN_ITEM_PROBABILITIES[i]))
|
||||
{
|
||||
SetMonsterActionFields(&pokemon_info->action, ACTION_THROW_ITEM_AI);
|
||||
pokemon_info->action.action_parameters[0].action_use_idx = selected_toolbox_index;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = pokemon->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = pokemon->pos.y;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = entity->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = entity->pos.y;
|
||||
pokemon_info->action.direction = (enum direction_id) (AI_THROWN_ITEM_DIRECTIONS[i] & DIRECTION_MASK);
|
||||
break;
|
||||
}
|
||||
|
|
@ -78,15 +78,15 @@ void AiDecideUseItem(struct entity *pokemon)
|
|||
}
|
||||
else if (item_type == CATEGORY_THROWN_ARC)
|
||||
{
|
||||
GetPossibleAiArcItemTargets(pokemon, item, potential_target_positions, TRUE);
|
||||
GetPossibleAiArcItemTargets(entity, item, potential_target_positions, TRUE);
|
||||
if (AI_THROWN_ITEM_ACTION_CHOICE_COUNT != 0)
|
||||
{
|
||||
chosen_target_index = DungeonRandInt(AI_THROWN_ITEM_ACTION_CHOICE_COUNT);
|
||||
SetMonsterActionFields(&pokemon_info->action, ACTION_THROW_ITEM_AI);
|
||||
pokemon_info->action.action_parameters[0].action_use_idx = selected_toolbox_index;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = pokemon->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = pokemon->pos.y;
|
||||
pokemon_info->action.direction = (enum direction_id) (GetDirectionTowardsPosition(&pokemon->pos, &potential_target_positions[chosen_target_index]) & DIRECTION_MASK);
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = entity->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = entity->pos.y;
|
||||
pokemon_info->action.direction = (enum direction_id) (GetDirectionTowardsPosition(&entity->pos, &potential_target_positions[chosen_target_index]) & DIRECTION_MASK);
|
||||
pokemon_info->action.item_target_position = potential_target_positions[chosen_target_index];
|
||||
}
|
||||
else
|
||||
|
|
@ -98,15 +98,15 @@ void AiDecideUseItem(struct entity *pokemon)
|
|||
{
|
||||
SetMonsterActionFields(&pokemon_info->action, ACTION_EAT_AI);
|
||||
pokemon_info->action.action_parameters[0].action_use_idx = selected_toolbox_index;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = pokemon->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = pokemon->pos.y;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = entity->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = entity->pos.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMonsterActionFields(&pokemon_info->action, ACTION_SECOND_THOUGHTS);
|
||||
}
|
||||
}
|
||||
else if (IqSkillIsEnabled(pokemon, IQ_ITEM_MASTER))
|
||||
else if (IqSkillIsEnabled(entity, IQ_ITEM_MASTER))
|
||||
{
|
||||
s32 thrown_ai_flag;
|
||||
for (s32 toolbox_index = 1; toolbox_index < INVENTORY_SIZE; toolbox_index++)
|
||||
|
|
@ -120,7 +120,7 @@ void AiDecideUseItem(struct entity *pokemon)
|
|||
else if (toolbox_index == 0)
|
||||
{
|
||||
// This seems unused. toolbox_index can never be 0.
|
||||
const struct tile *map_tile = GetTile(pokemon->pos.x, pokemon->pos.y);
|
||||
const struct tile *map_tile = GetTile(entity->pos.x, entity->pos.y);
|
||||
if (map_tile->object != NULL && map_tile->object->type == ENTITY_ITEM)
|
||||
{
|
||||
item = GetItemInfo(map_tile->object);
|
||||
|
|
@ -150,7 +150,7 @@ void AiDecideUseItem(struct entity *pokemon)
|
|||
|
||||
if (TestItemAiFlag(item->id, ITEM_AI_FLAG_TARGET_SELF))
|
||||
{
|
||||
u32 item_weight = GetAiUseItemProbability(pokemon, item, ITEM_TARGET_ALLY);
|
||||
u32 item_weight = GetAiUseItemProbability(entity, item, ITEM_TARGET_ALLY);
|
||||
if (item_weight != 0)
|
||||
{
|
||||
enum item_category item_type = GetItemCategoryVeneer(item->id);
|
||||
|
|
@ -162,8 +162,8 @@ void AiDecideUseItem(struct entity *pokemon)
|
|||
SetMonsterActionFields(&pokemon_info->action, ACTION_EAT_AI);
|
||||
|
||||
pokemon_info->action.action_parameters[0].action_use_idx = selected_toolbox_index;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = pokemon->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = pokemon->pos.y;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = entity->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = entity->pos.y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -177,30 +177,30 @@ void AiDecideUseItem(struct entity *pokemon)
|
|||
{
|
||||
if (GetItemCategoryVeneer(item->id) == CATEGORY_THROWN_ARC)
|
||||
{
|
||||
GetPossibleAiArcItemTargets(pokemon, item, potential_target_positions, FALSE);
|
||||
GetPossibleAiArcItemTargets(entity, item, potential_target_positions, FALSE);
|
||||
if (AI_THROWN_ITEM_ACTION_CHOICE_COUNT != 0)
|
||||
{
|
||||
chosen_target_index = DungeonRandInt(AI_THROWN_ITEM_ACTION_CHOICE_COUNT);
|
||||
SetMonsterActionFields(&pokemon_info->action, ACTION_THROW_ITEM_AI);
|
||||
pokemon_info->action.action_parameters[0].action_use_idx = selected_toolbox_index;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = pokemon->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = pokemon->pos.y;
|
||||
pokemon_info->action.direction = (enum direction_id) (GetDirectionTowardsPosition(&pokemon->pos, &potential_target_positions[chosen_target_index]) & DIRECTION_MASK);
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = entity->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = entity->pos.y;
|
||||
pokemon_info->action.direction = (enum direction_id) (GetDirectionTowardsPosition(&entity->pos, &potential_target_positions[chosen_target_index]) & DIRECTION_MASK);
|
||||
pokemon_info->action.item_target_position = potential_target_positions[chosen_target_index];
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GetPossibleAiThrownItemDirections(pokemon, thrown_ai_flag, item, FALSE);
|
||||
GetPossibleAiThrownItemDirections(entity, thrown_ai_flag, item, FALSE);
|
||||
for (i = 0; i < AI_THROWN_ITEM_ACTION_CHOICE_COUNT; i++)
|
||||
{
|
||||
if (DungeonRandOutcome__022EAB20(AI_THROWN_ITEM_PROBABILITIES[i]))
|
||||
{
|
||||
SetMonsterActionFields(&pokemon_info->action, ACTION_THROW_ITEM_AI);
|
||||
pokemon_info->action.action_parameters[0].action_use_idx = selected_toolbox_index;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = pokemon->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = pokemon->pos.y;
|
||||
pokemon_info->action.action_parameters[0].item_pos.x = entity->pos.x;
|
||||
pokemon_info->action.action_parameters[0].item_pos.y = entity->pos.y;
|
||||
pokemon_info->action.direction = (enum direction_id) (AI_THROWN_ITEM_DIRECTIONS[i] & DIRECTION_MASK);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
extern s32 AI_THROWN_ITEM_ACTION_CHOICE_COUNT;
|
||||
extern struct dungeon *DUNGEON_PTR[];
|
||||
|
||||
extern bool8 CanSeeTarget(struct entity *entity, struct entity *target_entity);
|
||||
extern bool8 IsTargetInRange(struct entity *pokemon, struct entity *target_pokemon, s32 direction, s32 max_range);
|
||||
extern u32 GetAiUseItemProbability(struct entity *target_pokemon, struct item *item, u32 item_target_flags);
|
||||
extern bool8 CanSeeTarget(struct entity *user, struct entity *target);
|
||||
extern bool8 IsTargetInRange(struct entity *user, struct entity *target, s32 direction, s32 n_tiles);
|
||||
extern u32 GetAiUseItemProbability(struct entity *item_consumer, struct item *item, u32 flags);
|
||||
extern s32 abs(s32 value);
|
||||
|
||||
void GetPossibleAiThrownItemDirections(struct entity *pokemon, s32 thrown_ai_flag, struct item *item, bool8 ignore_roll_chance)
|
||||
void GetPossibleAiThrownItemDirections(struct entity *entity, s32 ally_or_enemy, struct item *item, bool8 always_add)
|
||||
{
|
||||
AI_THROWN_ITEM_ACTION_CHOICE_COUNT = 0;
|
||||
s32 i;
|
||||
|
|
@ -34,33 +34,33 @@ void GetPossibleAiThrownItemDirections(struct entity *pokemon, s32 thrown_ai_fla
|
|||
if (!EntityIsValid__0230F008(target_pokemon))
|
||||
continue;
|
||||
|
||||
if (pokemon == target_pokemon)
|
||||
if (entity == target_pokemon)
|
||||
continue;
|
||||
|
||||
s32 targeting_flags;
|
||||
if (thrown_ai_flag == ITEM_AI_FLAG_TARGET_ALLY)
|
||||
if (ally_or_enemy == ITEM_AI_FLAG_TARGET_ALLY)
|
||||
{
|
||||
if (GetTreatmentBetweenMonsters(pokemon, target_pokemon, FALSE, FALSE) == TREATMENT_TREAT_AS_ALLY)
|
||||
if (GetTreatmentBetweenMonsters(entity, target_pokemon, FALSE, FALSE) == TREATMENT_TREAT_AS_ALLY)
|
||||
targeting_flags = ITEM_TARGET_OTHER | ITEM_TARGET_ALLY;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else if (GetTreatmentBetweenMonsters(pokemon, target_pokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
|
||||
else if (GetTreatmentBetweenMonsters(entity, target_pokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
|
||||
targeting_flags = ITEM_TARGET_OTHER;
|
||||
else
|
||||
continue;
|
||||
|
||||
if (!CanSeeTarget(pokemon, target_pokemon))
|
||||
if (!CanSeeTarget(entity, target_pokemon))
|
||||
continue;
|
||||
|
||||
s32 target_direction;
|
||||
s32 target_pos_x = target_pokemon->pos.x;
|
||||
s32 pokemon_pos_x = pokemon->pos.x;
|
||||
s32 pokemon_pos_x = entity->pos.x;
|
||||
s32 distance_x = abs(pokemon_pos_x - target_pos_x);
|
||||
s32 target_pos_y = target_pokemon->pos.y;
|
||||
s32 pokemon_pos_y = pokemon->pos.y;
|
||||
s32 distance_y = abs(pokemon->pos.y - target_pos_y);
|
||||
if (GetEntInfo(pokemon)->long_toss_class_status.status == STATUS_NONE)
|
||||
s32 pokemon_pos_y = entity->pos.y;
|
||||
s32 distance_y = abs(entity->pos.y - target_pos_y);
|
||||
if (GetEntInfo(entity)->long_toss_class_status.status == STATUS_NONE)
|
||||
{
|
||||
s32 distance = distance_x > distance_y ? distance_x : distance_y;
|
||||
if (distance > RANGED_ATTACK_RANGE)
|
||||
|
|
@ -91,11 +91,11 @@ void GetPossibleAiThrownItemDirections(struct entity *pokemon, s32 thrown_ai_fla
|
|||
target_direction = DIR_LEFT;
|
||||
}
|
||||
|
||||
if (target_direction >= DIR_DOWN && !AI_THROWN_ITEM_DIRECTION_IS_USED[target_direction] && IsTargetInRange(pokemon, target_pokemon, target_direction, RANGED_ATTACK_RANGE))
|
||||
if (target_direction >= DIR_DOWN && !AI_THROWN_ITEM_DIRECTION_IS_USED[target_direction] && IsTargetInRange(entity, target_pokemon, target_direction, RANGED_ATTACK_RANGE))
|
||||
{
|
||||
AI_THROWN_ITEM_DIRECTION_IS_USED[target_direction] = TRUE;
|
||||
AI_THROWN_ITEM_DIRECTIONS[AI_THROWN_ITEM_ACTION_CHOICE_COUNT] = target_direction;
|
||||
AI_THROWN_ITEM_PROBABILITIES[AI_THROWN_ITEM_ACTION_CHOICE_COUNT] = ignore_roll_chance ? 100 : GetAiUseItemProbability(target_pokemon, item, targeting_flags);
|
||||
AI_THROWN_ITEM_PROBABILITIES[AI_THROWN_ITEM_ACTION_CHOICE_COUNT] = always_add ? 100 : GetAiUseItemProbability(target_pokemon, item, targeting_flags);
|
||||
AI_THROWN_ITEM_ACTION_CHOICE_COUNT++;
|
||||
}
|
||||
} while (++i < DUNGEON_MAX_POKEMON);
|
||||
|
|
|
|||
|
|
@ -4,19 +4,19 @@
|
|||
#include "dungeon_util_static.h"
|
||||
#include "overlay_29_023000E4.h"
|
||||
|
||||
bool8 ShouldMonsterRunAway(struct entity *pokemon)
|
||||
bool8 ShouldMonsterRunAway(struct entity *monster)
|
||||
{
|
||||
if (!EntityIsValid__023000E4(pokemon))
|
||||
if (!EntityIsValid__023000E4(monster))
|
||||
return FALSE;
|
||||
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
struct monster *pokemon_info = GetEntInfo(monster);
|
||||
|
||||
if (pokemon_info->terrified != 0 && pokemon_info->terrified_turns != 0)
|
||||
return TRUE;
|
||||
|
||||
if (!pokemon_info->is_team_leader)
|
||||
{
|
||||
if (AbilityIsActive(pokemon, ABILITY_RUN_AWAY))
|
||||
if (AbilityIsActive(monster, ABILITY_RUN_AWAY))
|
||||
{
|
||||
s32 max_hp = pokemon_info->max_hp_stat + pokemon_info->max_hp_boost;
|
||||
if (max_hp > 999)
|
||||
|
|
@ -27,10 +27,10 @@ bool8 ShouldMonsterRunAway(struct entity *pokemon)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (IsTacticSet(pokemon, TACTIC_GET_AWAY_FROM_HERE))
|
||||
if (IsTacticSet(monster, TACTIC_GET_AWAY_FROM_HERE))
|
||||
return TRUE;
|
||||
|
||||
if (IsTacticSet(pokemon, TACTIC_AVOID_TROUBLE))
|
||||
if (IsTacticSet(monster, TACTIC_AVOID_TROUBLE))
|
||||
{
|
||||
s32 max_hp = pokemon_info->max_hp_stat + pokemon_info->max_hp_boost;
|
||||
if (max_hp > 999)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
#include "dungeon_util_static.h"
|
||||
#include "joined_at_checks.h"
|
||||
|
||||
bool8 CheckVariousConditions(struct entity *pokemon)
|
||||
bool8 CheckVariousConditions(struct entity *entity)
|
||||
{
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
struct monster *pokemon_info = GetEntInfo(entity);
|
||||
|
||||
if (pokemon_info->monster_behavior == BEHAVIOR_RESCUE_TARGET)
|
||||
return TRUE;
|
||||
|
|
@ -16,16 +16,16 @@ bool8 CheckVariousConditions(struct entity *pokemon)
|
|||
if (IsExperienceLocked(pokemon_info))
|
||||
return TRUE;
|
||||
|
||||
if (!pokemon_info->is_team_leader && ShouldMonsterRunAway(pokemon))
|
||||
if (!pokemon_info->is_team_leader && ShouldMonsterRunAway(entity))
|
||||
return TRUE;
|
||||
|
||||
if (CheckVariousStatuses2(pokemon, FALSE))
|
||||
if (CheckVariousStatuses2(entity, FALSE))
|
||||
return TRUE;
|
||||
|
||||
if (CheckVariousStatuses(pokemon))
|
||||
if (CheckVariousStatuses(entity))
|
||||
return TRUE;
|
||||
|
||||
if (IsChargingAnyTwoTurnMove(pokemon, FALSE))
|
||||
if (IsChargingAnyTwoTurnMove(entity, FALSE))
|
||||
return TRUE;
|
||||
|
||||
if (pokemon_info->frozen_class_status.freeze == STATUS_FROZEN_WRAP)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "dungeon_capabilities_2.h"
|
||||
#include "dungeon_util_static.h"
|
||||
|
||||
bool8 CheckVariousStatuses(struct entity *pokemon)
|
||||
bool8 CheckVariousStatuses(struct entity *entity)
|
||||
{
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
struct monster *pokemon_info = GetEntInfo(entity);
|
||||
|
||||
if (pokemon_info->sleep_class_status.sleep != STATUS_SLEEP_SLEEPLESS &&
|
||||
pokemon_info->sleep_class_status.sleep != STATUS_SLEEP_YAWNING &&
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ const enum status_two_turn_id TWO_TURN_STATUSES[11] =
|
|||
STATUS_TWO_TURN_NONE
|
||||
};
|
||||
|
||||
bool8 IsChargingAnyTwoTurnMove(struct entity *pokemon, bool8 check_charge)
|
||||
bool8 IsChargingAnyTwoTurnMove(struct entity *entity, bool8 charge_check_unused)
|
||||
{
|
||||
if (!EntityIsValid__02321438(pokemon))
|
||||
if (!EntityIsValid__02321438(entity))
|
||||
return FALSE;
|
||||
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
struct monster *pokemon_info = GetEntInfo(entity);
|
||||
for (s32 i = 0; i < 100; i++)
|
||||
{
|
||||
if (TWO_TURN_STATUSES[i] == STATUS_NONE)
|
||||
|
|
@ -33,7 +33,7 @@ bool8 IsChargingAnyTwoTurnMove(struct entity *pokemon, bool8 check_charge)
|
|||
}
|
||||
|
||||
// BUG: This condition is never reached because the for loop terminates by returning FALSE at the end of the TWO_TURN_STATUSES array.
|
||||
if (check_charge && pokemon_info->bide_class_status.bide == STATUS_TWO_TURN_CHARGING)
|
||||
if (charge_check_unused && pokemon_info->bide_class_status.bide == STATUS_TWO_TURN_CHARGING)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "dungeon_util_static.h"
|
||||
#include "overlay_29_02301A60.h"
|
||||
|
||||
bool8 NoGastroAcidStatus(struct entity *entity, enum ability_id ability)
|
||||
bool8 NoGastroAcidStatus(struct entity *entity, enum ability_id ability_id)
|
||||
{
|
||||
if (!IsMonster__02301A60(entity))
|
||||
return FALSE;
|
||||
|
|
@ -13,20 +13,20 @@ bool8 NoGastroAcidStatus(struct entity *entity, enum ability_id ability)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
bool8 AbilityIsActive(struct entity *pokemon, enum ability_id ability)
|
||||
bool8 AbilityIsActive(struct entity *entity, enum ability_id ability_id)
|
||||
{
|
||||
if (!IsMonster__02301A60(pokemon))
|
||||
if (!IsMonster__02301A60(entity))
|
||||
return FALSE;
|
||||
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
if (ability == ABILITY_UNKNOWN)
|
||||
struct monster *pokemon_info = GetEntInfo(entity);
|
||||
if (ability_id == ABILITY_UNKNOWN)
|
||||
return FALSE;
|
||||
|
||||
if (pokemon_info->abilities[0] == ability)
|
||||
return NoGastroAcidStatus(pokemon, ability);
|
||||
if (pokemon_info->abilities[0] == ability_id)
|
||||
return NoGastroAcidStatus(entity, ability_id);
|
||||
|
||||
if (pokemon_info->abilities[1] == ability)
|
||||
return NoGastroAcidStatus(pokemon, ability);
|
||||
if (pokemon_info->abilities[1] == ability_id)
|
||||
return NoGastroAcidStatus(entity, ability_id);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "dungeon_util.h"
|
||||
#include "dungeon_util_static.h"
|
||||
|
||||
bool8 ShouldRunMonsterAi(struct entity *pokemon)
|
||||
bool8 ShouldRunMonsterAi(struct entity *monster)
|
||||
{
|
||||
struct monster *pokemon_info = GetEntInfo(pokemon);
|
||||
struct monster *pokemon_info = GetEntInfo(monster);
|
||||
switch (pokemon_info->monster_behavior)
|
||||
{
|
||||
case BEHAVIOR_RESCUE_TARGET:
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
#include "joined_at_checks.h"
|
||||
|
||||
bool8 IsSpecialStoryAlly(struct monster *pokemon_info)
|
||||
bool8 IsSpecialStoryAlly(struct monster *monster)
|
||||
{
|
||||
if (pokemon_info->joined_at >= DUNGEON_JOINED_AT_BIDOOF && pokemon_info->joined_at < DUNGEON_DUMMY_0xE4)
|
||||
if (monster->joined_at >= DUNGEON_JOINED_AT_BIDOOF && monster->joined_at < DUNGEON_DUMMY_0xE4)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 IsExperienceLocked(struct monster *pokemon_info)
|
||||
bool8 IsExperienceLocked(struct monster *monster)
|
||||
{
|
||||
if (pokemon_info->joined_at == DUNGEON_CLIENT)
|
||||
if (monster->joined_at == DUNGEON_CLIENT)
|
||||
return TRUE;
|
||||
|
||||
if (IsSpecialStoryAlly(pokemon_info))
|
||||
if (IsSpecialStoryAlly(monster))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user