diff --git a/include/constants/move.h b/include/constants/move.h index 736d020e9..98a36a0c2 100644 --- a/include/constants/move.h +++ b/include/constants/move.h @@ -61,4 +61,29 @@ enum TargetingFlag TARGETING_FLAG_EXPOSE = 0x600, }; +enum MoveTarget +{ + TARGET_ENEMIES = 0, + TARGET_PARTY = 1, // including the user + TARGET_ALL = 2, // including the user + TARGET_USER = 3, + TARGET_ENEMIES_AFTER_CHARGING = 4, // in some sense the user while charging, then enemies + TARGET_ALL_EXCEPT_USER = 5, + TARGET_TEAMMATES = 6, // excluding the user + TARGET_SPECIAL = 15, // for weird moves +}; + +enum MoveAiCondition +{ + AI_CONDITION_NONE = 0, + // The AI will consider a target elegible wirh a chance equal to the + // move's "ai_condition_random_chance" value + AI_CONDITION_RANDOM = 0x100, + AI_CONDITION_HP_25 = 0x200, // Target has HP <= 25% + AI_CONDITION_STATUS = 0x300, // Target has a negative status condition + AI_CONDITION_ASLEEP = 0x400, // Target is asleep, napping or in a nightmare + AI_CONDITION_HP_25_OR_STATUS = 0x500, // Target has HP <= 25% or a negative status condition + AI_CONDITION_GHOST = 0x600, // Target is ghost-type and not exposed +}; + #endif // GUARD_CONSTANTS_MOVE_H diff --git a/include/dungeon_8041AD0.h b/include/dungeon_8041AD0.h index 7a7bf5455..4361dbffd 100644 --- a/include/dungeon_8041AD0.h +++ b/include/dungeon_8041AD0.h @@ -3,12 +3,13 @@ #include "structs/dungeon_entity.h" #include "structs/str_damage.h" +#include "structs/str_stat_index.h" s32 sub_80416E0(PixelPos *pos, u32 param_2, bool8 param_3); void sub_804178C(u8 param_1); u32 EntityGetStatusSprites(Entity *entity); void sub_8041888(u8 param_1); -void EntityUpdateStatusSprites(Entity *entity); +void UpdateStatusIconFlags(Entity *entity); void sub_8041AD0(Entity *pokemon); void sub_8041AE0(Entity *pokemon); void sub_8041AF4(Entity *pokemon); @@ -36,7 +37,7 @@ void sub_8041BD0(Entity *pokemon, u8 r1); void sub_8041BE8(Entity *pokemon); void sub_8041BF8(Entity *pokemon); void sub_8041C08(Entity *pokemon); -void sub_8041C1C(Entity *pokemon); +void PlayParalysisEffect(Entity *pokemon); void nullsub_69(Entity *pokemon, Entity *target); void sub_8041C34(Entity *pokemon); void nullsub_70(Entity *pokemon); @@ -49,8 +50,8 @@ void nullsub_72(Entity *pokemon); void nullsub_73(Entity *pokemon); void sub_8041C94(Entity *pokemon); void sub_8041CA8(Entity *pokemon); -void sub_8041CB8(Entity *pokemon); -void sub_8041CCC(Entity *pokemon); +void PlaySpeedUpEffect(Entity *pokemon); +void PlaySpeedDownEffect(Entity *pokemon); void sub_8041CDC(Entity *pokemon); void sub_8041CEC(Entity *pokemon); void nullsub_74(Entity *pokemon); @@ -93,18 +94,18 @@ void sub_8041EE8(Entity *pokemon); void sub_8041EF8(Entity *pokemon); void sub_8041F08(Entity *pokemon); void nullsub_90(Entity *pokemon); -void sub_8041F28(Entity *pokemon, u32 r1); -void sub_8041F4C(Entity *pokemon, u32 r1); -void sub_8041F70(Entity *pokemon, u32 r1); -void sub_8041F94(Entity *pokemon, u32 r1); -void sub_8041FB4(Entity *pokemon, u32 r1); -void sub_8041FD8(Entity *pokemon, u32 r1); -void sub_8041FFC(Entity *pokemon, u32 r1); -void sub_804201C(Entity *pokemon, u32 r1); -void sub_8042040(Entity *pokemon, u32 r1); -void sub_8042060(Entity *pokemon, u32 r1); +void PlayOffensiveStatDownEffect(Entity *pokemon, StatIndex stat); +void PlayDefensiveStatDownEffect(Entity *pokemon, StatIndex stat); +void PlayOffensiveStatUpEffect(Entity *pokemon, StatIndex stat); +void PlayDefensiveStatUpEffect(Entity *pokemon, StatIndex stat); +void PlayOffensiveStatMultiplierUpEffect(Entity *pokemon, StatIndex stat); +void PlayOffensiveStatMultiplierDownEffect(Entity *pokemon, StatIndex stat); +void PlayDefensiveStatMultiplierUpEffect(Entity *pokemon, StatIndex stat); +void PlayDefensiveStatMultiplierDownEffect(Entity *pokemon, StatIndex stat); +void PlayHitChanceUpEffect(Entity *pokemon, StatIndex stat); +void PlayHitChanceDownEffect(Entity *pokemon, u32 r1); void sub_8042080(Entity *pokemon, u32 r1); -void sub_80420A0(Entity *pokemon); +void PlayCringeExclamationPointEffect(Entity *pokemon); void nullsub_91(Entity *pokemon); void sub_80420B8(Entity *pokemon); void sub_80420C8(Entity *pokemon); diff --git a/include/dungeon_ai_attack.h b/include/dungeon_ai_attack.h index 70781a844..99e9d5ac4 100644 --- a/include/dungeon_ai_attack.h +++ b/include/dungeon_ai_attack.h @@ -15,11 +15,6 @@ struct AIPossibleMove void ChooseAIMove(Entity *pokemon); s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move *move); -bool8 IsTargetInLineRange(Entity *user, Entity *target, s32 range); -s32 TryAddTargetToAITargetList(s32 numPotentialTargets, s32 targetingFlags, Entity *user, Entity *target, Move *move, u32 hasStatusChecker); -bool8 IsAITargetEligible(s32 targetingFlags, Entity *user, Entity *target, Move *move, bool32 hasStatusChecker); -s32 WeightMove(Entity *user, s32 targetingFlags, Entity *target, u32 moveType); -bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified); bool8 IsTargetInRange(Entity *pokemon, Entity *targetPokemon, s32 direction, s32 maxRange); void HandleUseMoveAIAction(Entity *target); void HandleUseOrbAction(Entity *pokemon); diff --git a/include/dungeon_ai_movement.h b/include/dungeon_ai_movement.h index c4c9c3035..fa36165fa 100644 --- a/include/dungeon_ai_movement.h +++ b/include/dungeon_ai_movement.h @@ -4,11 +4,6 @@ #include "structs/dungeon_entity.h" void AIMovement(Entity *pokemon, bool8 showRunAwayEffect); -bool8 CanTakeItem(Entity *pokemon); -bool8 ChooseTargetPosition(Entity *pokemon); -void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect); -bool8 AvoidEnemies(Entity *pokemon); -bool8 Wander(Entity *pokemon); void sub_807BB78(Entity *pokemon); #endif diff --git a/include/dungeon_logic.h b/include/dungeon_logic.h index 396f14615..8f8d4bf10 100644 --- a/include/dungeon_logic.h +++ b/include/dungeon_logic.h @@ -19,9 +19,9 @@ s32 sub_8070828(Entity *pokemon, bool8 displayMessage); void SetMessageArgument_2(u8 *buffer, EntityInfo *param_2, s32 colorNum); void sub_8070968(u8 *buffer, EntityInfo *entityInfo, s32 colorNum); void CopyEntityNameForDungeonExitSummary(u8 *buffer, EntityInfo *entityInfo); -bool8 HasNegativeStatus(Entity *pokemon); -bool8 IsSleeping(Entity *pokemon); -bool8 HasLowHealth(Entity *pokemon); +bool8 MonsterHasNegativeStatus(Entity *pokemon); +bool8 IsMonsterSleeping(Entity *pokemon); +bool8 MonsterHasQuarterHp(Entity *pokemon); bool8 CheckVariousStatuses2(Entity *pokemon, bool8 checkBlinker); bool8 sub_8070BC0(Entity* entity); bool8 CheckVariousConditions(Entity *pokemon); @@ -40,14 +40,14 @@ bool8 ShouldMonsterRunAwayAndShowEffect(Entity *pokemon, bool8 showRunAwayEffect void CheckRunAwayVisualFlag(Entity *pokemon, bool8 showRunAwayEffect); u8 GetTreatmentBetweenMonsters(Entity *pokemon, Entity *targetPokemon, bool8 ignoreInvisible, bool8 checkPetrified); u8 GetTreatmentBetweenMonstersIgnoreStatus(Entity * pokemon, Entity * target); -bool8 HasSafeguardStatus(Entity * pokemon, Entity * target, bool8 displayMessage); -bool8 sub_8071728(Entity * pokemon, Entity * target, bool8 displayMessage); +bool8 SafeguardIsActive(Entity * pokemon, Entity * target, bool8 displayMessage); +bool8 IsProtectedFromStatDrops(Entity * pokemon, Entity * target, bool8 displayMessage); bool8 sub_80717A4(Entity *pokemon, u16 moveID); bool8 AbilityIsActive(Entity *pokemon, u8 ability); bool8 MonsterIsType(Entity *pokemon, u8 type); bool8 CanSeeInvisibleMonsters(Entity *pokemon); bool8 IsTacticSet(Entity *pokemon, u8 tactic); -bool8 IQSkillIsEnabled(Entity *pokemon, u8 IQSkill); +bool8 IqSkillIsEnabled(Entity *pokemon, u8 IQSkill); void LoadIQSkills(Entity *pokemon); bool8 CanSeeTeammate(Entity * pokemon); u8 GetMoveTypeForMonster(Entity *pokemon, Move *pokeMove); diff --git a/include/dungeon_range.h b/include/dungeon_range.h index cf726f30b..61dc46c52 100644 --- a/include/dungeon_range.h +++ b/include/dungeon_range.h @@ -3,11 +3,22 @@ #include "structs/str_position.h" #include "structs/dungeon_entity.h" +#include "structs/str_dungeon.h" -bool8 IsPositionActuallyInSight(DungeonPos *pos1, DungeonPos *pos2); -bool8 IsPositionInSight(DungeonPos *pos1, DungeonPos *pos2); +// Actual function in Sky. TODO: Find other uses of it and sync with Sky. +static inline s32 GetVisibilityRange(void) +{ + s32 visibilityRange = gDungeon->unk181e8.visibilityRange; + if (visibilityRange == 0) + return 2; + + return visibilityRange; +} + +bool8 IsPositionActuallyInSight(DungeonPos *origin, DungeonPos *target); +bool8 IsPositionInSight(DungeonPos *origin, DungeonPos *target); void sub_80833E8(DungeonPos *param_1, s32 *param_2); -bool8 IsTargetTwoTilesAway(DungeonPos *pos1, DungeonPos *pos2); +bool8 IsPositionWithinTwoTiles(DungeonPos *pos1, DungeonPos *pos2); bool8 sub_8083568(s32 inX, s32 inY, u8 index); Entity* GetLeader(void); EntityInfo* GetLeaderInfo(void); diff --git a/include/items.h b/include/items.h index 6b3e100da..53105cc26 100644 --- a/include/items.h +++ b/include/items.h @@ -125,7 +125,7 @@ static inline bool8 ItemSticky(Item *item) static inline bool8 ItemExists(Item *item) { - return (item->flags & ITEM_FLAG_EXISTS); + return (item->flags & ITEM_FLAG_EXISTS) != 0; // != 0 is necessary for Blue matching } static inline bool8 ItemSet(Item *item) diff --git a/include/math.h b/include/math.h index b682372bb..7eb5e1f96 100644 --- a/include/math.h +++ b/include/math.h @@ -51,38 +51,17 @@ bool8 FP48_16_SLessThan(const s48_16 *a, const s48_16 *b); void FP48_16_Add(s48_16 *dst, s48_16 *a, s48_16 *b); void FP48_16_Subtract(s48_16 *dst, s48_16 *a, s48_16 *b); -//static inline bool8 F248Equal(s24_8 x, s24_8 y) { -// return x.raw == y.raw; -//} - -#define F248LessThanInt(x, y) (x.raw < 0x100 * y) -#define F248LessThanFloat(x, y) (x.raw < (int)(y * 0x100)) -#define FloatLessThanF248(x, y) ((int)(x * 0x100) < y.raw) -//static inline bool8 F248LessThanOne(s24_8 x) { -// return x.raw < 0x100; -//} -#define F248LessThan(x, y) (x.raw < y.raw) -#define F248GreaterThan(x, y) (x.raw > y.raw) -#define F248Equal(x, y) (x.raw == y.raw) -#define F248EqualsInt(x, y) (x.raw == 0x100 * y) - -//static inline bool8 F248LessThan(s24_8 x, s24_8 y) { -// return x.raw < y.raw; -//} - -#define F248_AddInt(x, y) ((s24_8){x.raw + 0x100 * y}) -#define F248_SubInt(x, y) ((s24_8){x.raw - 0x100 * y}) - -static inline s24_8 F248_Add(s24_8 x, s24_8 y) { - return (s24_8){x.raw + y.raw}; -} - -static inline s24_8 F248_Sub(s24_8 x, s24_8 y) { - return (s24_8){x.raw - y.raw}; -} - -static inline s24_8 F248_MulInt(s24_8 x, s32 y) { - return (s24_8){x.raw * y}; -} +#define F248LessThanInt(x, y) ((x) < 0x100 * (y)) +#define F248LessThanFloat(x, y) ((x) < (int)((y) * 0x100)) +#define FloatLessThanF248(x, y) ((int)((x) * 0x100) < (y)) +#define F248LessThan(x, y) ((x) < (y)) +#define F248GreaterThan(x, y) ((x) > (y)) +#define F248Equal(x, y) ((x) == (y)) +#define F248EqualsInt(x, y) ((x) == 0x100 * (y)) +#define F248_AddInt(x, y) ((s24_8)((x) + 0x100 * (y)) +#define F248_SubInt(x, y) ((s24_8)((x) - 0x100 * (y)) +#define F248_Add(x, y)((x) + (y)) +#define F248_Sub(x, y)((x) - (y)) +#define F248_MulInt(x, y)((x) * (y)) #endif // GUARD_MATH_H diff --git a/include/move_orb_actions_1.h b/include/move_orb_actions_1.h index 0dae4dc0c..00218bb6c 100644 --- a/include/move_orb_actions_1.h +++ b/include/move_orb_actions_1.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_1_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 IronTailMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 sub_805768C(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -27,7 +28,7 @@ bool8 SwaggerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 SnoreMoveAction(Entity *pokemon, Entity *target, Move * move, s32 itemId); bool8 ScreechMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 RockSlideMoveAction(Entity *pokemon, Entity *target, Move * move, s32 itemId); -bool32 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId); +bool8 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId); bool8 WhirlpoolMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId); bool8 FakeTearsMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId); bool8 SpiteMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId); @@ -79,7 +80,7 @@ bool8 RapidSpinMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 SureShotMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 CosmicPowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -extern const s32 gStatIndexAtkDef; -extern const s32 gStatIndexSpecial; +extern const StatIndex gStatIndexAtkDef; +extern const StatIndex gStatIndexSpecial; #endif /* ifndef GUARD_MOVE_ORB_ACTIONS_1_H */ diff --git a/include/move_orb_actions_2.h b/include/move_orb_actions_2.h index 46fa2a15a..61d6f85c2 100644 --- a/include/move_orb_actions_2.h +++ b/include/move_orb_actions_2.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_2_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 SkyAttackMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 BasicIceMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -32,7 +33,7 @@ bool8 BlockMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 PoisonGasMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 ToxicMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 PoisonFangMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -bool32 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); +bool8 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 UproarMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 SandstormMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 Conversion2MoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -42,7 +43,7 @@ bool8 SketchMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 NaturePowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 HelpingHandMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 EndureMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -bool8 sub_8058C98(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 param_5); +bool8 DamageLowerDefMoveAction(Entity *pokemon, Entity *target, Move *move, StatIndex stat, u32 param_5); bool8 SonicboomMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 SelfDestructMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 ExplosionMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); diff --git a/include/move_orb_actions_3.h b/include/move_orb_actions_3.h index 29a67736f..97d345459 100644 --- a/include/move_orb_actions_3.h +++ b/include/move_orb_actions_3.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_3_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 PoisonStingMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 TriAttackMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -41,7 +42,7 @@ bool8 SunnyDayMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId bool8 BellyDrumMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 HiJumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemId,u8 param_5); bool8 JumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemId,u8 param_5); -bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 param_5); +bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, StatIndex stat, u32 param_5); bool8 BulkUpMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 AmnesiaMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 HandleColorChange(Entity *pokemon, Entity *target, Move *move, s32 itemId); diff --git a/include/move_orb_actions_4.h b/include/move_orb_actions_4.h index 0ee9f29c5..1c26e3be3 100644 --- a/include/move_orb_actions_4.h +++ b/include/move_orb_actions_4.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_ACTIONS_4_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" bool8 DreamEaterMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 sub_805B734(Entity *pokemon, Entity *target, Move *move, s32 itemId); @@ -50,7 +51,7 @@ bool8 AttractMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 MimicMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 FrustrationMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 LeechSeedMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); -bool8 MetalClawMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId, s32 param_5); +bool8 MetalClawMoveAction(Entity * pokemon,Entity * target,Move *move, StatIndex stat, s32 param_5); bool8 InvisifyOrbAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 CalmMindMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); bool8 DefenseCurlMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId); diff --git a/include/move_orb_effects_1.h b/include/move_orb_effects_1.h index a2b6d9387..aacb9f6c7 100644 --- a/include/move_orb_effects_1.h +++ b/include/move_orb_effects_1.h @@ -2,6 +2,7 @@ #define GUARD_MOVE_ORB_EFFECTS_1_H #include "structs/dungeon_entity.h" +#include "structs/str_stat_index.h" #include "number_util.h" #define FLASH_FIRE_STATUS_NONE 0 @@ -27,20 +28,20 @@ void IngrainedStatusTarget(Entity * pokemon, Entity * target); void WrapTarget(Entity * pokemon, Entity * target); void sub_8076CB4(s32 param_1); void PetrifiedStatusTarget(Entity * pokemon, Entity * target); -void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage); -void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage); -void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment); -void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment); +void LowerOffensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected); +void LowerDefensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected); +void BoostOffensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages); +void BoostDefensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages); u8 GetFlashFireStatus(Entity *pokemon); -void UpdateFlashFireBoost(Entity * pokemon, Entity *target); -void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage); -void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage); -void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage); -void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage, bool8 displayMessage); -void CringeStatusTarget(Entity * pokemon,Entity * target, bool8 displayMessage); -void ParalyzeStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage); -void RaiseMovementSpeedTarget(Entity * pokemon, Entity * target, s32 turns, bool8 diplayMessage); -void LowerMovementSpeedTarget(Entity * pokemon, Entity * target, s32 levels, bool8 displayMessage); +void ActivateFlashFire(Entity * pokemon, Entity *target); +void ApplyOffensiveStatMultiplier(Entity *user, Entity *target, StatIndex stat, s24_8 multiplier, bool8 displayMessage); +void ApplyDefensiveStatMultiplier(Entity *user, Entity *target, StatIndex stat, s24_8 multiplier, bool8 displayMessage); +void BoostHitChanceStat(Entity *user, Entity *target, StatIndex stat); +void LowerHitChanceStat(Entity *user, Entity *target, StatIndex stat, bool8 displayMessage); +void TryInflictCringeStatus(Entity *user ,Entity *target, bool8 displayMessage); +void TryInflictParalysisStatus(Entity *user, Entity *target, bool8 displayMessage); +void BoostSpeed(Entity *user, Entity *target, s32 turns, bool8 displayMessage); +void LowerSpeed(Entity *user, Entity *target, s32 nStages, bool8 displayMessage); #endif diff --git a/include/moves.h b/include/moves.h index 8b29f0cc1..6b86aa892 100644 --- a/include/moves.h +++ b/include/moves.h @@ -48,7 +48,7 @@ bool8 FailsWhileMuzzled(u16 moveID); const u8 *GetHMTMMoves(s16 species); const u8 *GetLevelUpMoves(s16 species); s32 GetLinkedSequence(s32 index, Move *moves, u16 *sequenceMoveIDs); -s32 GetMoveAccuracyOrAIChance(Move *move, u32 accuracyType); +s32 GetMoveAccuracyOrAiChance(Move *move, u32 accuracyType); u8 GetMoveAIWeight(Move *move); s32 GetMoveBasePower(Move *move); u32 GetMoveBasePP(Move *move); diff --git a/include/number_util.h b/include/number_util.h index cbab8120d..d17b6ef3f 100644 --- a/include/number_util.h +++ b/include/number_util.h @@ -17,14 +17,11 @@ typedef struct FixedPoint * significant bits are the integer part and the 8 least significant bits are * the fractional part. */ -typedef struct s24_8 { - // It's almost certainly not an actual struct, but keep it as one until we decomp all structures that include it - s32 raw; -} s24_8; +typedef s32 s24_8; // Does not match as a struct in Blue/Sky. -#define F248_ZERO ((s24_8){}) -#define F248_ONE ((s24_8){0x100}) -#define F248_MAX ((s24_8){0x7FFFFFFF}) +#define F248_ZERO ((s24_8)0) +#define F248_ONE ((s24_8)0x100) +#define F248_MAX ((s24_8)0x7FFFFFFF) /** * This type represents a signed 48.16 fixed-point number, where the 48 most @@ -59,19 +56,7 @@ void WriteBellyBits(DataSerializer *r0, FixedPoint *src); // Sometimes it's used directly as opposed to calling IntToFixedPoint #define IntToFixedPointMacro(x) ((FixedPoint){x, 0}) -#define IntToF248_2(x) ((s24_8){x * 0x100}) -#define FloatToF248_2(x) ((s24_8){(int)(x * 0x100)}) -static inline s24_8 IntToF248(s32 x) { - return (s24_8){x * 256}; -} - -static inline s24_8 FloatToF248(float x) { - return (s24_8){(int)(x * 256)}; -} - -static inline s32 F248ToInt(s24_8 x) { - return x.raw / 256; -} - +#define IntToF248(x) ((int)((x) * 0x100)) +#define F248ToInt(x) ((s24_8)((x) / 256)) #endif diff --git a/include/structs/dungeon_entity.h b/include/structs/dungeon_entity.h index 5d73c3715..6231b5bc9 100644 --- a/include/structs/dungeon_entity.h +++ b/include/structs/dungeon_entity.h @@ -21,13 +21,6 @@ #define NUM_SPEED_COUNTERS 5 #define NUM_PREV_POS 4 -#define STAT_STAGE_ATK 0 -#define STAT_STAGE_SP_ATK 1 -#define STAT_STAGE_DEF 0 -#define STAT_STAGE_SP_DEF 1 -#define STAT_STAGE_ACCURACY 0 -#define STAT_STAGE_EVASION 1 - // size: 0x8 typedef struct ActionParameter { @@ -237,12 +230,10 @@ typedef struct EntityInfo /* 0x8C */ IqSkillFlags IQSkillMenuFlags; // IQ skills selected in the IQ skills menu. /* 0x90 */ IqSkillFlags IQSkillFlags; /* 0x94 */ u8 tactic; - u8 fill95[0x98 - 0x95]; /* 0x98 */ u32 dungeonSpriteId; /* 0x9C */ u32 unk9C; /* 0xA0 */ s32 unkA0; /* 0xA4 */ u8 monsterBehavior; - u8 fillA5[0xA8 - 0xA5]; // Statuses are split into groups based on which ones can't overlap. // See status.h for which statuses are in each group. /* 0xA8 */ SleepClassStatus sleepClassStatus; @@ -299,7 +290,6 @@ typedef struct EntityInfo /* 0x14A */ u8 unk14A; /* 0x14B */ u8 unk14B; /* 0x14C */ u8 unk14C; - /* 0x14D */ u8 unk14D; /* 0x14E */ u16 visualFlags; /* 0x150 */ u16 previousVisualFlags; /* 0x152 */ u8 unk152; diff --git a/include/structs/menu.h b/include/structs/menu.h index 75ecb0d81..259aba18a 100644 --- a/include/structs/menu.h +++ b/include/structs/menu.h @@ -37,7 +37,6 @@ typedef struct MenuInputStruct /* 0x20 */ s16 pagesCount; /* 0x22 */ s16 totalEntriesCount; /* 0x24 */ u16 unk24; - /* 0x26 */ u16 unk26; /* 0x28 */ TouchScreenMenuInput touchScreen; // For obvious reason unused on GBA } MenuInputStruct; diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index 62ae80c98..d81270463 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -452,11 +452,9 @@ typedef struct Dungeon u8 unk1356C; u8 fill1356D[0x13570 - 0x1356D]; /* 0x13570 */ u8 unk13570; - u8 fill13571[0x13574 - 0x13571]; /* 0x13574 */ DungeonPos trapPos; /* 0x13578 */ u8 trapID; /* 0x13579 */ u8 unk13579; - u8 fill1357A[0x1357C - 0x1357A]; /* 0x1357C */ Entity *teamPokemon[MAX_TEAM_MEMBERS]; /* 0x1358C */ Entity *wildPokemon[DUNGEON_MAX_WILD_POKEMON]; /* 0x135CC */ Entity *activePokemon[DUNGEON_MAX_POKEMON]; // Contains both team and wild Pokémon diff --git a/include/structs/str_stat_index.h b/include/structs/str_stat_index.h new file mode 100644 index 000000000..1f3fa8400 --- /dev/null +++ b/include/structs/str_stat_index.h @@ -0,0 +1,15 @@ +#ifndef GUARD_STR_STAT_INDEX_X +#define GUARD_STR_STAT_INDEX_X + +#define STAT_INDEX_PHYSICAL 0 // Atk, Def +#define STAT_INDEX_SPECIAL 1 // Sp Atk, Sp Def +#define STAT_INDEX_ACCURACY STAT_INDEX_PHYSICAL +#define STAT_INDEX_EVASION STAT_INDEX_SPECIAL + +// Needed to match in Blue/Sky. I wonder what was the reason for making it a struct as opposed to a simple int... +typedef struct StatIndex +{ + int id; +} StatIndex; + +#endif // GUARD_STR_STAT_INDEX_X diff --git a/src/blow_away.c b/src/blow_away.c index a25a7e078..086462acb 100644 --- a/src/blow_away.c +++ b/src/blow_away.c @@ -173,7 +173,7 @@ void sub_807D068(Entity *pokemon, DungeonPos *pos) pixelY += incrementY; local_34.x = pixelX; local_34.y = pixelY; - pokemon->unk1C.raw = sin_4096(iVar8) * 0xc; + pokemon->unk1C = sin_4096(iVar8) * 0xc; UpdateEntityPixelPos(pokemon, &local_34); if (ShouldDisplayEntity(pokemon)) { DungeonRunFrameActions(0x1a); diff --git a/src/code_8040094_1.c b/src/code_8040094_1.c index 24f9a03f4..e671e6dea 100644 --- a/src/code_8040094_1.c +++ b/src/code_8040094_1.c @@ -49,7 +49,7 @@ extern s32 sub_800EBC8(struct UnkStruct_8040094 *a0); extern bool8 sub_800E7D0(struct UnkStruct_8040094 *a0); extern bool8 EffectiveMoveHasSineWobble(s32 moveId); extern bool8 MoveMatchesBideClassStatus(Entity *pokemon, Move *move); -extern bool8 IsSleeping(Entity *pokemon); +extern bool8 IsMonsterSleeping(Entity *pokemon); extern const s32 gUnknown_8106A8C[]; @@ -441,7 +441,7 @@ static bool32 MoveHasSpecialEffect(Entity *entity, Move *move) } } else if (move->id == MOVE_SNORE || move->id == MOVE_SLEEP_TALK) { - if (!IsSleeping(entity)) + if (!IsMonsterSleeping(entity)) return TRUE; else return FALSE; diff --git a/src/dungeon_8041AD0.c b/src/dungeon_8041AD0.c index fa893285d..b922a3712 100644 --- a/src/dungeon_8041AD0.c +++ b/src/dungeon_8041AD0.c @@ -212,11 +212,11 @@ static s32 sub_8041550(Entity *entity, s32 a1, u8 a2, u8 a3, s32 a4, u8 a5) sub_800569C(&pos, &entity->axObj.axdata, a3); if (pos.x != 99 && pos.y != 99) { pixelPos.x = entity->pixelPos.x + (pos.x << 8); - pixelPos.y = (entity->pixelPos.y + (pos.y << 8)) - entInfo->unk174.raw; + pixelPos.y = (entity->pixelPos.y + (pos.y << 8)) - entInfo->unk174; } else { pixelPos.x = entity->pixelPos.x; - pixelPos.y = entity->pixelPos.y - entInfo->unk174.raw; + pixelPos.y = entity->pixelPos.y - entInfo->unk174; } var = entity->pixelPos.y / 256; @@ -358,12 +358,12 @@ void sub_8041888(u8 param_1) { entityInfo->unk14C = 1; } - EntityUpdateStatusSprites(entity); + UpdateStatusIconFlags(entity); } } } -void EntityUpdateStatusSprites(Entity *entity) +void UpdateStatusIconFlags(Entity *entity) { bool32 flag; s32 HP; @@ -563,7 +563,7 @@ void sub_8041C08(Entity *pokemon) sub_804151C(pokemon, 423, 1); } -void sub_8041C1C(Entity *pokemon) +void PlayParalysisEffect(Entity *pokemon) { sub_804151C(pokemon, 423, 1); } @@ -623,12 +623,12 @@ void sub_8041CA8(Entity *pokemon) sub_804151C(pokemon, 7, 1); } -void sub_8041CB8(Entity *pokemon) +void PlaySpeedUpEffect(Entity *pokemon) { sub_804151C(pokemon, 0x18b, 1); } -void sub_8041CCC(Entity *pokemon) +void PlaySpeedDownEffect(Entity *pokemon) { sub_804151C(pokemon, 0xC5 << 1, 1); } @@ -840,9 +840,9 @@ void nullsub_90(Entity *pokemon) { } -void sub_8041F28(Entity *pokemon, u32 r1) +void PlayOffensiveStatDownEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xCA << 1, 1); } @@ -852,9 +852,9 @@ void sub_8041F28(Entity *pokemon, u32 r1) } } -void sub_8041F4C(Entity *pokemon, u32 r1) +void PlayDefensiveStatDownEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x18f, 1); } @@ -864,9 +864,9 @@ void sub_8041F4C(Entity *pokemon, u32 r1) } } -void sub_8041F70(Entity *pokemon, u32 r1) +void PlayOffensiveStatUpEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x1a9, 1); } @@ -876,9 +876,9 @@ void sub_8041F70(Entity *pokemon, u32 r1) } } -void sub_8041F94(Entity *pokemon, u32 r1) +void PlayDefensiveStatUpEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xC7 << 1, 1); } @@ -888,9 +888,9 @@ void sub_8041F94(Entity *pokemon, u32 r1) } } -void sub_8041FB4(Entity *pokemon, u32 r1) +void PlayOffensiveStatMultiplierUpEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x1a9, 1); } @@ -900,9 +900,9 @@ void sub_8041FB4(Entity *pokemon, u32 r1) } } -void sub_8041FD8(Entity *pokemon, u32 r1) +void PlayOffensiveStatMultiplierDownEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xCA << 1, 1); } @@ -912,9 +912,9 @@ void sub_8041FD8(Entity *pokemon, u32 r1) } } -void sub_8041FFC(Entity *pokemon, u32 r1) +void PlayDefensiveStatMultiplierUpEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0xC7 << 1, 1); } @@ -924,9 +924,9 @@ void sub_8041FFC(Entity *pokemon, u32 r1) } } -void sub_804201C(Entity *pokemon, u32 r1) +void PlayDefensiveStatMultiplierDownEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if (stat.id == STAT_INDEX_PHYSICAL) { sub_804151C(pokemon, 0x18f, 1); } @@ -936,9 +936,9 @@ void sub_804201C(Entity *pokemon, u32 r1) } } -void sub_8042040(Entity *pokemon, u32 r1) +void PlayHitChanceUpEffect(Entity *pokemon, StatIndex stat) { - if(r1 == 0) + if(stat.id == STAT_INDEX_ACCURACY) { sub_804151C(pokemon, 0xC6 << 1, 1); } @@ -948,7 +948,7 @@ void sub_8042040(Entity *pokemon, u32 r1) } } -void sub_8042060(Entity *pokemon, u32 r1) +void PlayHitChanceDownEffect(Entity *pokemon, u32 r1) { if(r1 == 0) { @@ -972,7 +972,7 @@ void sub_8042080(Entity *pokemon, u32 r1) } } -void sub_80420A0(Entity *pokemon) +void PlayCringeExclamationPointEffect(Entity *pokemon) { sub_804151C(pokemon, 0x143, 1); } @@ -1510,16 +1510,16 @@ static void sub_8042A84(s16 param_1, Entity *entity, u32 param_3) param_1_s16 = param_1; - r6 = IntToF248_2(2).raw; + r6 = IntToF248(2); if (sub_8042768(entity)) { sub_804151C(entity,param_1_s16,0); sub_803E708(param_3,0x42); do { - if (entity->unk1C.raw > IntToF248_2(199.999).raw) break; + if (entity->unk1C > IntToF248(199.999)) break; DungeonRunFrameActions(0x42); - entity->unk1C.raw += + r6; - r6 += IntToF248_2(1).raw; - iVar3 = (entity->pixelPos.y - entity->unk1C.raw) / 256; + entity->unk1C += + r6; + r6 += IntToF248(1); + iVar3 = (entity->pixelPos.y - entity->unk1C) / 256; } while (-8 <= iVar3 - gDungeon->unk181e8.cameraPixelPos.y); entity->isVisible = 0; sub_804178C(0); diff --git a/src/dungeon_action_execution.c b/src/dungeon_action_execution.c index bb3d50d2a..cc6460ee5 100644 --- a/src/dungeon_action_execution.c +++ b/src/dungeon_action_execution.c @@ -155,7 +155,7 @@ bool8 ExecuteEntityDungeonAction(Entity *entity) pos.y = entity->pos.y; sub_80694C0(entity,pos1.x,pos1.y,0); sub_8074FB0(entity,(info->action).direction,&pos); - if (((IQSkillIsEnabled(entity, IQ_SUPER_MOBILE)) && (info->invisibleClassStatus.status != STATUS_MOBILE)) && + if (((IqSkillIsEnabled(entity, IQ_SUPER_MOBILE)) && (info->invisibleClassStatus.status != STATUS_MOBILE)) && (!HasHeldItem(entity,ITEM_MOBILE_SCARF))) { sub_804AE08(&entity->pos); } @@ -342,7 +342,7 @@ static void HandleSleepTalk(void) if(CannotAttack(entity, TRUE)){ info->unk164 |= 0xFF; } - else if(!IsSleeping(entity)){ + else if(!IsMonsterSleeping(entity)){ info->unk164 |= 0xFF; } else if(info->muzzled.muzzled == TRUE){ @@ -418,7 +418,7 @@ static void HandleSnore(void) info->unk165 |= 0xff; info->unk164 |= 0xff; } - else if (!IsSleeping(pokemon)) { + else if (!IsMonsterSleeping(pokemon)) { info->unk165 |= 0xff; info->unk164 |= 0xff; } @@ -460,7 +460,7 @@ static void HandleFlashFire(void) if (EntityIsValid(entity)) { if (GetEntInfo(entity)->unk152 != 0) { GetEntInfo(entity)->unk152 = 0; - UpdateFlashFireBoost(entity, entity); + ActivateFlashFire(entity, entity); } } } diff --git a/src/dungeon_ai.c b/src/dungeon_ai.c index e241ec1c3..fb2ebe63e 100644 --- a/src/dungeon_ai.c +++ b/src/dungeon_ai.c @@ -98,7 +98,7 @@ void RunMonsterAI(Entity *pokemon, u32 unused) AIDecideUseItem(pokemon); if (pokemonInfo->action.action == ACTION_NOTHING) { - if (!IQSkillIsEnabled(pokemon, IQ_DEDICATED_TRAVELER)) + if (!IqSkillIsEnabled(pokemon, IQ_DEDICATED_TRAVELER)) { ChooseAIMove(pokemon); if (pokemonInfo->action.action != ACTION_NOTHING) diff --git a/src/dungeon_ai_attack.c b/src/dungeon_ai_attack.c index 0b48ce4c1..7735ae131 100644 --- a/src/dungeon_ai_attack.c +++ b/src/dungeon_ai_attack.c @@ -44,6 +44,12 @@ EWRAM_DATA u8 gPotentialAttackTargetDirections[NUM_DIRECTIONS] = {0}; EWRAM_DATA s32 gPotentialAttackTargetWeights[NUM_DIRECTIONS] = {0}; EWRAM_DATA Entity *gPotentialTargets[NUM_DIRECTIONS] = {0}; +static bool8 IsTargetInLineRange(Entity *user, Entity *target, s32 range); +static s32 TryAddTargetToAITargetList(s32 numPotentialTargets, s32 targetingFlags, Entity *user, Entity *target, Move *move, bool32 hasStatusChecker); +static bool8 IsAITargetEligible(s32 targetingFlags, Entity *user, Entity *target, Move *move, bool32 hasStatusChecker); +static s32 WeightMove(Entity *user, s32 targetingFlags, Entity *target, u32 moveType); +static bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified); + void ChooseAIMove(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); @@ -121,8 +127,8 @@ void ChooseAIMove(Entity *pokemon) } return; } - hasWeakTypePicker = IQSkillIsEnabled(pokemon, IQ_WEAK_TYPE_PICKER); - hasPPChecker = IQSkillIsEnabled(pokemon, IQ_PP_CHECKER) != FALSE; + hasWeakTypePicker = IqSkillIsEnabled(pokemon, IQ_WEAK_TYPE_PICKER); + hasPPChecker = IqSkillIsEnabled(pokemon, IQ_PP_CHECKER) != FALSE; total = 0; for (i = 0; i < MAX_MON_MOVES; i++) { @@ -214,7 +220,7 @@ void ChooseAIMove(Entity *pokemon) } } aiPossibleMove[REGULAR_ATTACK_INDEX].weight = 0; - if (!IQSkillIsEnabled(pokemon, IQ_EXCLUSIVE_MOVE_USER) && pokemonInfo->bideClassStatus.status != chargeStatus) + if (!IqSkillIsEnabled(pokemon, IQ_EXCLUSIVE_MOVE_USER) && pokemonInfo->bideClassStatus.status != chargeStatus) { aiPossibleMove[REGULAR_ATTACK_INDEX].canBeUsed = TRUE; if (pokemonInfo->bideClassStatus.status == chargeStatus) @@ -268,7 +274,7 @@ void ChooseAIMove(Entity *pokemon) } randomWeight = DungeonRandInt(total); weightCounter = 0; - if (!IQSkillIsEnabled(pokemon, IQ_EXCLUSIVE_MOVE_USER)) + if (!IqSkillIsEnabled(pokemon, IQ_EXCLUSIVE_MOVE_USER)) { canTargetRegularAttack = TargetRegularAttack(pokemon, ®ularAttackTargetDir, TRUE); } @@ -347,7 +353,7 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move gCanAttackInDirection[i] = FALSE; } targetingFlags = GetMoveTargetAndRangeForPokemon(pokemon, move, TRUE); - hasStatusChecker = IQSkillIsEnabled(pokemon, IQ_STATUS_CHECKER); + hasStatusChecker = IqSkillIsEnabled(pokemon, IQ_STATUS_CHECKER); aiPossibleMove->canBeUsed = FALSE; if ((pokemonInfo->cringeClassStatus.status == STATUS_TAUNTED && !MoveIgnoresTaunted(move)) || (hasStatusChecker && !CanUseOnSelfWithStatusChecker(pokemon, move))) @@ -526,59 +532,51 @@ s32 AIConsiderMove(struct AIPossibleMove *aiPossibleMove, Entity *pokemon, Move return moveWeight; } -bool8 IsTargetInLineRange(Entity *user, Entity *target, s32 range) +static bool8 IsTargetInLineRange(Entity *user, Entity *target, s32 range) { s32 direction; s32 distanceX = abs(user->pos.x - target->pos.x); s32 distanceY = abs(user->pos.y - target->pos.y); s32 distance = max(distanceX, distanceY); - if (distance > RANGED_ATTACK_RANGE || distance > range) - { + if (distance > RANGED_ATTACK_RANGE || distance > range) { return FALSE; } direction = -1; - if (distanceX == distanceY) - { - if (user->pos.x < target->pos.x && - (user->pos.y < target->pos.y || user->pos.y > target->pos.y)) - { - returnTrue: - return TRUE; + if (distanceX == distanceY) { + if (user->pos.x < target->pos.x && user->pos.y < target->pos.y) { + direction = DIRECTION_SOUTH; } - if (user->pos.x > target->pos.x); // Fixes register loading order. - direction = DIRECTION_SOUTHWEST; - if (user->pos.x <= target->pos.x || user->pos.y <= target->pos.y) - { - goto checkDirectionSet; + else if (user->pos.x < target->pos.x && user->pos.y > target->pos.y) { + direction = DIRECTION_EAST; + } + else if (user->pos.x > target->pos.x && user->pos.y > target->pos.y) { + direction = DIRECTION_NORTH; + } + else { + direction = DIRECTION_SOUTHWEST; } - goto returnTrue; } - else if (user->pos.x == target->pos.x && user->pos.y < target->pos.y) - { - return TRUE; + else if (user->pos.x == target->pos.x && user->pos.y < target->pos.y) { + direction = DIRECTION_SOUTH; } - else if (user->pos.x < target->pos.x && user->pos.y == target->pos.y) - { - return TRUE; + else if (user->pos.x < target->pos.x && user->pos.y == target->pos.y) { + direction = DIRECTION_SOUTHEAST; } - else if (user->pos.x == target->pos.x && user->pos.y > target->pos.y) - { - return TRUE; + else if (user->pos.x == target->pos.x && user->pos.y > target->pos.y) { + direction = DIRECTION_NORTHEAST; } - else if (user->pos.x > target->pos.x && user->pos.y == target->pos.y) - { + else if (user->pos.x > target->pos.x && user->pos.y == target->pos.y) { direction = DIRECTION_WEST; } - checkDirectionSet: - if (direction < 0) - { - return FALSE; + + if (direction >= 0) { + return TRUE; } - return TRUE; + return FALSE; } -s32 TryAddTargetToAITargetList(s32 numPotentialTargets, s32 targetingFlags, Entity *user, Entity *target, Move *move, bool32 hasStatusChecker) +static s32 TryAddTargetToAITargetList(s32 numPotentialTargets, s32 targetingFlags, Entity *user, Entity *target, Move *move, bool32 hasStatusChecker) { s32 direction; s32 targetingFlags2 = (s16) targetingFlags; @@ -607,133 +605,119 @@ s32 TryAddTargetToAITargetList(s32 numPotentialTargets, s32 targetingFlags, Enti return numPotentialTargets; } -bool8 IsAITargetEligible(s32 targetingFlags, Entity *user, Entity *target, Move *move, bool32 hasStatusChecker) +static bool8 IsAITargetEligible(s32 moveAiRange_, Entity *user, Entity *target, Move *move, bool32 checkAllConditions_) { - EntityInfo *targetData; - s32 targetingFlags2 = (s16) targetingFlags; - bool8 hasStatusChecker2 = hasStatusChecker; + s32 moveAiRange = (s16) moveAiRange_; + bool8 checkAllConditions = checkAllConditions_; bool8 hasTarget = FALSE; - u32 categoryTargetingFlags = targetingFlags2 & 0xF; - u32 *categoryTargetingFlags2 = &categoryTargetingFlags; // Fixes a regswap. - if (*categoryTargetingFlags2 == TARGETING_FLAG_TARGET_OTHER) + u32 moveAiTarget = moveAiRange & 0xF; + // Needed to fix a regswap. + u32 *matchMe = &moveAiTarget; + if (*matchMe == TARGET_ENEMIES) { if (GetTreatmentBetweenMonsters(user, target, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY) - { hasTarget = TRUE; - } } - else if (categoryTargetingFlags == TARGETING_FLAG_HEAL_TEAM) + else if (moveAiTarget == TARGET_PARTY) { - goto checkCanTarget; + if (GetTreatmentBetweenMonsters(user, target, FALSE, TRUE) == TREATMENT_TREAT_AS_ALLY) + hasTarget = TRUE; } - else if (categoryTargetingFlags == TARGETING_FLAG_LONG_RANGE) + else if (moveAiTarget == TARGET_ALL) { - targetData = GetEntInfo(target); - goto checkThirdParty; + EntityInfo *targetData = targetData = GetEntInfo(target); + hasTarget = TRUE; + if (targetData->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER) + return FALSE; + if (targetData->monsterBehavior == BEHAVIOR_DIGLETT) + return FALSE; + if (targetData->monsterBehavior == BEHAVIOR_RESCUE_TARGET) + return FALSE; } - else if (categoryTargetingFlags == TARGETING_FLAG_ATTACK_ALL) + else if (moveAiTarget == TARGET_ALL_EXCEPT_USER) { - targetData = GetEntInfo(target); + EntityInfo *targetData = targetData = GetEntInfo(target); if (user == target) - { - goto returnFalse; - } - checkThirdParty: + return FALSE; + hasTarget = TRUE; - if (targetData->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER || - targetData->monsterBehavior == BEHAVIOR_DIGLETT || - targetData->monsterBehavior == BEHAVIOR_RESCUE_TARGET) - { - returnFalse: + if (targetData->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER) + return FALSE; + if (targetData->monsterBehavior == BEHAVIOR_DIGLETT) + return FALSE; + if (targetData->monsterBehavior == BEHAVIOR_RESCUE_TARGET) return FALSE; - } } - else if (categoryTargetingFlags == TARGETING_FLAG_BOOST_TEAM) + else if (moveAiTarget == TARGET_TEAMMATES) { if (user == target) - { - goto returnFalse; - } - checkCanTarget: + return FALSE; + if (GetTreatmentBetweenMonsters(user, target, FALSE, TRUE) == TREATMENT_TREAT_AS_ALLY) - { hasTarget = TRUE; - } } - else if ((u16) (categoryTargetingFlags - 3) <= 1) // categoryTargetingFlags == TARGETING_FLAG_ITEM - { - hasTarget = TRUE; + else { + // s16 memes + u16 asU16 = moveAiTarget; + if (asU16 == TARGET_USER || asU16 == TARGET_ENEMIES_AFTER_CHARGING) { + hasTarget = TRUE; + } } if (hasTarget) { - if (hasStatusChecker2) + if (checkAllConditions) { if (!CanUseOnTargetWithStatusChecker(user, target, move)) + return FALSE; + + if ((moveAiRange & 0xF00) == AI_CONDITION_RANDOM) { - goto returnFalse; + s32 use_chance = GetMoveAccuracyOrAiChance(move, ACCURACY_AI_CONDITION_RANDOM_CHANCE); + if (DungeonRandInt(100) >= use_chance) + return FALSE; } - if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_SET_TRAP) + else if ((moveAiRange & 0xF00) == AI_CONDITION_HP_25) { - goto rollMoveUseChance; + if (!MonsterHasQuarterHp(target)) + return FALSE; } - else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_HP) + else if ((moveAiRange & 0xF00) == AI_CONDITION_STATUS) { - if (!HasLowHealth(target)) - { - if (*categoryTargetingFlags2); - goto returnFalse; - } + if (!MonsterHasNegativeStatus(target)) + return FALSE; } - else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_STATUS) + else if ((moveAiRange & 0xF00) == AI_CONDITION_ASLEEP) { - if (!HasNegativeStatus(target)) - { - if (*categoryTargetingFlags2); // Flips the conditional. - goto returnFalse; - } + if (!IsMonsterSleeping(target)) + return FALSE; } - else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_DREAM_EATER) + else if ((moveAiRange & 0xF00) == AI_CONDITION_GHOST) { - if (!IsSleeping(target)) - { - if (*categoryTargetingFlags2); // Flips the conditional. - goto returnFalse; - } - } - else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_EXPOSE) - { - targetData = GetEntInfo(target); - if ((targetData->types[0] != TYPE_GHOST && targetData->types[1] != TYPE_GHOST) || targetData->exposed) - { - if (*categoryTargetingFlags2); // Flips the conditional. - goto returnFalse; - } + EntityInfo *targetData = targetData = GetEntInfo(target); + if (targetData->types[0] != TYPE_GHOST && targetData->types[1] != TYPE_GHOST) + return FALSE; + + if (targetData->exposed) + return FALSE; } - else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_HEAL_ALL) + else if ((moveAiRange & 0xF00) == AI_CONDITION_HP_25_OR_STATUS) { - if (!HasNegativeStatus(target) && !HasLowHealth(target)) - { - if (*categoryTargetingFlags2); // Flips the conditional. - goto returnFalse; - } + if (!MonsterHasNegativeStatus(target) && !MonsterHasQuarterHp(target)) + return FALSE; } } - else if ((targetingFlags2 & 0xF00) == TARGETING_FLAG_SET_TRAP) + else if ((moveAiRange & 0xF00) == AI_CONDITION_RANDOM) { - s32 useChance; - rollMoveUseChance: - useChance = GetMoveAccuracyOrAIChance(move, ACCURACY_AI_CONDITION_RANDOM_CHANCE); - if (DungeonRandInt(100) >= useChance) - { - goto returnFalse; - } + s32 use_chance = GetMoveAccuracyOrAiChance(move, ACCURACY_AI_CONDITION_RANDOM_CHANCE); + if (DungeonRandInt(100) >= use_chance) + return FALSE; } } return hasTarget; } -s32 WeightMove(Entity *user, s32 targetingFlags, Entity *target, u32 moveType) +static s32 WeightMove(Entity *user, s32 targetingFlags, Entity *target, u32 moveType) { EntityInfo *targetData; s32 targetingFlags2 = (s16) targetingFlags; @@ -745,29 +729,29 @@ s32 WeightMove(Entity *user, s32 targetingFlags, Entity *target, u32 moveType) if ((targetingFlags2 & 0xF) != TARGETING_FLAG_TARGET_OTHER) return 1; - if (IQSkillIsEnabled(user, IQ_EXP_GO_GETTER)) + if (IqSkillIsEnabled(user, IQ_EXP_GO_GETTER)) { // BUG: expYieldRankings has lower values as the Pokémon's experience yield increases. // This causes Exp. Go-Getter to prioritize Pokémon worth less experience // instead of Pokémon worth more experience. weight = gDungeon->expYieldRankings[targetData->id]; } - else if (IQSkillIsEnabled(user, IQ_EFFICIENCY_EXPERT)) + else if (IqSkillIsEnabled(user, IQ_EFFICIENCY_EXPERT)) { - weight = -12 - targetData->HP; + weight = 500 - targetData->HP; if (weight == 0) { weight = 1; } } - else if (IQSkillIsEnabled(user, IQ_WEAK_TYPE_PICKER)) + else if (IqSkillIsEnabled(user, IQ_WEAK_TYPE_PICKER)) { weight = WeightWeakTypePicker(user, target, moveType2) + 1; } return weight; } -bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified) +static bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); s32 numPotentialTargets = 0; @@ -776,8 +760,8 @@ bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified) s32 i; s32 potentialAttackTargetDirections[NUM_DIRECTIONS]; s32 potentialAttackTargetWeights[NUM_DIRECTIONS]; - bool8 hasTargetingIQ = IQSkillIsEnabled(pokemon, IQ_EXP_GO_GETTER) || IQSkillIsEnabled(pokemon, IQ_EFFICIENCY_EXPERT); - bool8 hasStatusChecker = IQSkillIsEnabled(pokemon, IQ_STATUS_CHECKER); + bool8 hasTargetingIQ = IqSkillIsEnabled(pokemon, IQ_EXP_GO_GETTER) || IqSkillIsEnabled(pokemon, IQ_EFFICIENCY_EXPERT); + bool8 hasStatusChecker = IqSkillIsEnabled(pokemon, IQ_STATUS_CHECKER); for (i = 0; i < faceTurnLimit; i++, direction++) { Entity *target; @@ -843,69 +827,48 @@ bool8 TargetRegularAttack(Entity *pokemon, u32 *targetDir, bool8 checkPetrified) } -bool8 IsTargetInRange(Entity *pokemon, Entity *targetPokemon, s32 direction, s32 maxRange) +bool8 IsTargetInRange(Entity *user, Entity *target, s32 direction, s32 nTiles) { - s32 distanceX = pokemon->pos.x - targetPokemon->pos.x; - s32 effectiveMaxRange; - if (distanceX < 0) - { - distanceX = -distanceX; - } - effectiveMaxRange = pokemon->pos.y - targetPokemon->pos.y; - if (effectiveMaxRange < 0) - { - effectiveMaxRange = -effectiveMaxRange; - } - if (effectiveMaxRange < distanceX) - { - effectiveMaxRange = distanceX; - } - if (effectiveMaxRange > maxRange) - { - effectiveMaxRange = maxRange; - } - if (!IQSkillIsEnabled(pokemon, IQ_COURSE_CHECKER)) - { - // BUG: effectiveMaxRange is already capped at maxRange, so this condition always evaluates to TRUE. + s32 effectiveMaxRange = max(abs(user->pos.x - target->pos.x), abs(user->pos.y - target->pos.y)); + + if (effectiveMaxRange > nTiles) + effectiveMaxRange = nTiles; + + if (!IqSkillIsEnabled(user, IQ_COURSE_CHECKER)) { + // BUG: effectiveMaxRange is already capped at nTiles, so this condition always evaluates to TRUE. // The AI also has range checks elsewhere, so this doesn't become an issue in most cases. // If the AI has the Long Toss or Pierce statuses and Course Checker is disabled, // this incorrect check causes the AI to throw items at targets further than 10 tiles away. - if (effectiveMaxRange <= maxRange) - { + if (effectiveMaxRange <= nTiles) return TRUE; - } + else + return FALSE; } - else - { - s32 currentPosX = pokemon->pos.x; - s32 currentPosY = pokemon->pos.y; + else { + s32 i; + s32 currentPosX = user->pos.x; + s32 currentPosY = user->pos.y; s32 adjacentTileOffsetX = gAdjacentTileOffsets[direction].x; s32 adjacentTileOffsetY = gAdjacentTileOffsets[direction].y; - s32 i; for (i = 0; i <= effectiveMaxRange; i++) { const Tile *mapTile; + currentPosX += adjacentTileOffsetX; currentPosY += adjacentTileOffsetY; - if (currentPosX <= 0 || currentPosY <= 0 || + if (currentPosX < 1 || currentPosY < 1 || currentPosX >= DUNGEON_MAX_SIZE_X - 1 || currentPosY >= DUNGEON_MAX_SIZE_Y - 1) - { break; - } - while (0); // Extra label needed to swap branch locations in ASM. + mapTile = GetTile(currentPosX, currentPosY); - if (!(mapTile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY))) - { - break; - } - if (mapTile->monster == targetPokemon) - { + if (GetTerrainType(mapTile) == TERRAIN_TYPE_WALL) + return FALSE; + + if (mapTile->monster == target) return TRUE; - } + if (mapTile->monster != NULL) - { - break; - } + return FALSE; } } return FALSE; @@ -943,7 +906,7 @@ void HandleUseOrbAction(Entity *pokemon) bool8 r4; Item *item; Item IVar5; - EntityInfo *entityInfo; // r7 + EntityInfo *entityInfo; ActionContainer act; Move move; struct AIPossibleMove sp28; diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c index eacae3dc8..83c69850d 100644 --- a/src/dungeon_ai_item_weight.c +++ b/src/dungeon_ai_item_weight.c @@ -100,7 +100,7 @@ u32 GetAIUseItemProbability(Entity *targetPokemon, Item *item, u32 itemTargetFla } break; case ITEM_HEAL_SEED: - if (HasNegativeStatus(targetPokemon)) + if (MonsterHasNegativeStatus(targetPokemon)) { itemWeight = 80; } diff --git a/src/dungeon_ai_items.c b/src/dungeon_ai_items.c index f7a002344..ea87b8f1f 100644 --- a/src/dungeon_ai_items.c +++ b/src/dungeon_ai_items.c @@ -126,7 +126,7 @@ void AIDecideUseItem(Entity *pokemon) } } } - else if (IQSkillIsEnabled(pokemon, IQ_ITEM_MASTER)) + else if (IqSkillIsEnabled(pokemon, IQ_ITEM_MASTER)) { for (toolboxIndex = 1; toolboxIndex < INVENTORY_SIZE + 2; toolboxIndex++) { diff --git a/src/dungeon_ai_movement.c b/src/dungeon_ai_movement.c index 996117772..dbf0e8617 100644 --- a/src/dungeon_ai_movement.c +++ b/src/dungeon_ai_movement.c @@ -18,6 +18,7 @@ #include "structs/map.h" #include "number_util.h" #include "position_util.h" +#include "items.h" #define INFINITY 999 #define INFINITY_2 999999 @@ -30,6 +31,12 @@ #define TURN_RIGHT_90 4 #define TURN_LEFT_135 5 +static bool8 CanTakeItem(Entity *pokemon); +static bool8 ChooseTargetPosition(Entity *pokemon); +static void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect); +static bool8 AvoidEnemies(Entity *pokemon); +static bool8 Wander(Entity *pokemon); + struct CanMoveInDirectionInfo { bool8 tryTurn; @@ -46,14 +53,13 @@ void AIMovement(Entity *pokemon, bool8 showRunAwayEffect) pokemonInfo->aiTarget.aiTurningAround = FALSE; if (IsTacticSet(pokemon, TACTIC_BE_PATIENT)) { - u32 maxHPStat = pokemonInfo->maxHPStat; - maxHPStat += maxHPStat >> 0x1f; - if (pokemonInfo->HP <= (s16) (maxHPStat / 2)) + if (pokemonInfo->HP <= pokemonInfo->maxHPStat / 2) { pokemonInfo->action.action = ACTION_NOTHING; return; } } + if (IsTacticSet(pokemon, TACTIC_WAIT_THERE)) { pokemonInfo->action.action = ACTION_NOTHING; @@ -85,6 +91,7 @@ void AIMovement(Entity *pokemon, bool8 showRunAwayEffect) { hasAction = ChooseTargetPosition(pokemon); } + if (!hasAction) { pokemonInfo->action.action = ACTION_NOTHING; @@ -96,23 +103,23 @@ void AIMovement(Entity *pokemon, bool8 showRunAwayEffect) } } -bool8 CanTakeItem(Entity *pokemon) +static bool8 CanTakeItem(Entity *pokemon) { - EntityInfo *pokemonInfo = GetEntInfo(pokemon); - const Tile *mapTile; Entity *object; - if (!EntityIsValid(pokemon) || CheckVariousConditions(pokemon)) - { + const Tile *mapTile; + EntityInfo *pokemonInfo = GetEntInfo(pokemon); + + if (!EntityIsValid(pokemon)) return FALSE; - } + if (CheckVariousConditions(pokemon)) + return FALSE; + mapTile = GetTileAtEntitySafe(pokemon); object = mapTile->object; if (object == NULL) - { return FALSE; - } - switch (GetEntityType(object)) - { + + switch (GetEntityType(object)) { case ENTITY_NOTHING: case ENTITY_MONSTER: case ENTITY_TRAP: @@ -121,8 +128,8 @@ bool8 CanTakeItem(Entity *pokemon) break; case ENTITY_ITEM: if (!pokemonInfo->isTeamLeader && - !(pokemonInfo->heldItem.flags & ITEM_FLAG_EXISTS) && - ((mapTile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) || !pokemonInfo->isNotTeamMember) && + !ItemExists(&pokemonInfo->heldItem) && + ((GetTerrainType(mapTile) != TERRAIN_TYPE_WALL) || !pokemonInfo->isNotTeamMember) && !(GetItemInfo(object)->flags & ITEM_FLAG_IN_SHOP)) { return TRUE; @@ -132,17 +139,18 @@ bool8 CanTakeItem(Entity *pokemon) return FALSE; } -bool8 ChooseTargetPosition(Entity *pokemon) +static bool8 ChooseTargetPosition(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); if (!TargetLeader(pokemon)) { Entity **possibleTargets; + s32 i; s32 maxPossibleTargets; s32 targetIndex; bool8 canCrossWalls; s32 targetDistance; - s32 i; + if (gDungeon->decoyIsActive) { possibleTargets = gDungeon->activePokemon; @@ -152,6 +160,7 @@ bool8 ChooseTargetPosition(Entity *pokemon) { possibleTargets = gDungeon->teamPokemon; maxPossibleTargets = MAX_TEAM_MEMBERS; + } else { @@ -161,107 +170,62 @@ bool8 ChooseTargetPosition(Entity *pokemon) canCrossWalls = CanCrossWalls(pokemon); targetIndex = -1; targetDistance = INFINITY; - for (i = 0; i < maxPossibleTargets; i++) - { + + for (i = 0; i < maxPossibleTargets; i++) { Entity *target = possibleTargets[i]; - if (EntityIsValid(target) && GetEntInfo(target)->monsterBehavior == BEHAVIOR_FIXED_ENEMY) - { - if (gDungeon->decoyIsActive) - { + if (EntityIsValid(target) && GetEntInfo(target)->monsterBehavior == BEHAVIOR_FIXED_ENEMY) { + if (gDungeon->decoyIsActive) { if (GetTreatmentBetweenMonsters(pokemon, target, FALSE, TRUE) != TREATMENT_TREAT_AS_ENEMY) - { continue; - } } - else if (!pokemonInfo->isNotTeamMember && GetEntInfo(target)->frozenClassStatus.status == STATUS_PETRIFIED) - { + else if (!pokemonInfo->isNotTeamMember && GetEntInfo(target)->frozenClassStatus.status == STATUS_PETRIFIED) { continue; } - if (GetEntInfo(target)->shopkeeper != SHOPKEEPER_MODE_SHOPKEEPER) - { + + if (GetEntInfo(target)->shopkeeper != SHOPKEEPER_MODE_SHOPKEEPER) { s32 currentDistance; - if (canCrossWalls) - { - s32 distance = pokemon->pos.x - target->pos.x; - if (distance < 0) - { - distance = -distance; - } - if (distance > CHECK_VISIBILITY_DISTANCE) - { - goto checkCanSeeTarget; - } - distance = pokemon->pos.y - target->pos.y; - if (distance < 0) - { - distance = -distance; - } - if (distance > CHECK_VISIBILITY_DISTANCE) - { - goto checkCanSeeTarget; + if (canCrossWalls) { + if (abs(pokemon->pos.x - target->pos.x) > CHECK_VISIBILITY_DISTANCE || abs(pokemon->pos.y - target->pos.y) > CHECK_VISIBILITY_DISTANCE) { + if (!CanTargetEntity(pokemon, target)) + continue; } } - else - { - checkCanSeeTarget: + else { if (!CanTargetEntity(pokemon, target)) - { continue; - } } currentDistance = GetDistance(&pokemon->pos, &target->pos); - if (targetDistance > currentDistance) - { + if (targetDistance > currentDistance) { targetDistance = currentDistance; targetIndex = i; if (targetDistance < 2) - { break; - } } } } } - if (targetIndex > -1) - { + if (targetIndex >= 0) { pokemonInfo->aiTarget.aiObjective = AI_CHASE_TARGET; pokemonInfo->aiTarget.aiTargetPos = possibleTargets[targetIndex]->pos; pokemonInfo->aiTarget.aiTarget = possibleTargets[targetIndex]; - pokemonInfo->aiTarget.aiTargetSpawnGenID = pokemonInfo->aiTarget.aiTarget->spawnGenID; + pokemonInfo->aiTarget.aiTargetSpawnGenID = possibleTargets[targetIndex]->spawnGenID; pokemonInfo->aiTarget.aiTargetingEnemy = TRUE; pokemonInfo->moveRandomly = FALSE; - if (IsTacticSet(pokemon, TACTIC_KEEP_YOUR_DISTANCE) && !CanSeeTeammate(pokemon)) - { - s32 distanceX = pokemon->pos.x - possibleTargets[targetIndex]->pos.x; - if (distanceX < 0) - { - distanceX = -distanceX; - } - if (distanceX < 2) - { - s32 distanceY = pokemon->pos.y - possibleTargets[targetIndex]->pos.y; - if (distanceY < 0) - { - distanceY = -distanceY; - } - if (distanceY < 2) - { - pokemonInfo->aiTarget.aiTurningAround = TRUE; - } + if (IsTacticSet(pokemon, TACTIC_KEEP_YOUR_DISTANCE) && !CanSeeTeammate(pokemon)) { + if (abs(pokemon->pos.x - possibleTargets[targetIndex]->pos.x) <= 1 && abs(pokemon->pos.y - possibleTargets[targetIndex]->pos.y) <= 1) { + pokemonInfo->aiTarget.aiTurningAround = TRUE; } } return TRUE; } } - if (!IsTacticSet(pokemon, TACTIC_GO_THE_OTHER_WAY)) - { - do - { - if (!pokemonInfo->isNotTeamMember) - { + + if (!IsTacticSet(pokemon, TACTIC_GO_THE_OTHER_WAY)) { + if (!pokemonInfo->isNotTeamMember) { + // Do/While loop needed to match + do { Entity *leader = GetLeaderIfVisible(pokemon); - if (EntityIsValid(leader)) - { + if (EntityIsValid(leader)) { pokemonInfo->aiTarget.aiObjective = AI_CHASE_TARGET; pokemonInfo->aiTarget.aiTargetPos = leader->pos; pokemonInfo->aiTarget.aiTarget = leader; @@ -269,45 +233,35 @@ bool8 ChooseTargetPosition(Entity *pokemon) pokemonInfo->moveRandomly = FALSE; return TRUE; } - } - } while (0); + } while (0); + } } - else if (pokemonInfo->isTeamLeader) - { + else if (pokemonInfo->isTeamLeader) { // This item targeting code is never reached because the leader is never AI-controlled. - u8 room; - s32 minX, minY, maxX, maxY, x, y, maxY2; - if (gDungeon->unk181e8.visibilityRange) { - // Dead code. - u8 a = -a; - } - room = GetTile(pokemon->pos.x, pokemon->pos.y)->room; - if (room == CORRIDOR_ROOM) - { - do - { - minX = pokemon->pos.x - CORRIDOR_VISIBILITY; - minY = pokemon->pos.y - CORRIDOR_VISIBILITY; - maxX = pokemon->pos.x + CORRIDOR_VISIBILITY; - maxY = pokemon->pos.y + CORRIDOR_VISIBILITY; - } while (0); + s32 x, y; + s32 minX, minY, maxX, maxY; + UNUSED u8 visib = GetVisibilityRange(); // Unused return value + u8 room = GetTile(pokemon->pos.x, pokemon->pos.y)->room; + + if (room == CORRIDOR_ROOM) { + minX = pokemon->pos.x - CORRIDOR_VISIBILITY; + minY = pokemon->pos.y - CORRIDOR_VISIBILITY; + maxX = pokemon->pos.x + CORRIDOR_VISIBILITY; + maxY = pokemon->pos.y + CORRIDOR_VISIBILITY; } - else - { + else { struct RoomData *mapRoom = &gDungeon->roomData[room]; minX = mapRoom->bottomRightCornerX - 1; minY = mapRoom->bottomRightCornerY - 1; maxX = mapRoom->topLeftCornerX + 1; maxY = mapRoom->topLeftCornerY + 1; } - maxY2 = maxY; - for (y = minY; y <= maxY2; y++) - { - for (x = minX; x <= maxX; x++) - { + + ASM_MATCH_TRICK(maxX); + for (y = minY; y <= maxY; y++) { + for (x = minX; x <= maxX; x++) { Entity *object = GetTileMut(x, y)->object; - if (object && GetEntityType(object) == ENTITY_ITEM) - { + if (object != NULL && GetEntityType(object) == ENTITY_ITEM) { pokemonInfo->aiTarget.aiObjective = AI_TAKE_ITEM; pokemonInfo->aiTarget.aiTargetPos.x = x; pokemonInfo->aiTarget.aiTargetPos.y = y; @@ -319,14 +273,16 @@ bool8 ChooseTargetPosition(Entity *pokemon) } } } - if ((u8) (pokemonInfo->aiTarget.aiObjective - 1) <= 1) + + if (pokemonInfo->aiTarget.aiObjective == AI_CHASE_TARGET || pokemonInfo->aiTarget.aiObjective == AI_CHASE_REMEMBERED_TARGET) { if (pokemonInfo->aiTarget.aiTarget) { if (pokemonInfo->aiTarget.aiTarget->spawnGenID == pokemonInfo->aiTarget.aiTargetSpawnGenID) { - EntityInfo *targetData = GetEntInfo(pokemonInfo->aiTarget.aiTarget); s32 i; + EntityInfo *targetData = GetEntInfo(pokemonInfo->aiTarget.aiTarget); + for (i = 0; i < NUM_PREV_POS; i++) { if (CanTargetPosition(pokemon, &targetData->prevPos[i])) @@ -346,18 +302,20 @@ bool8 ChooseTargetPosition(Entity *pokemon) } } } + Wander(pokemon); return TRUE; } -void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) +static void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) { - EntityInfo *pokemonInfo = GetEntInfo(pokemon); + s32 i; s32 direction; s32 turnLimit; - s32 i; struct CanMoveInDirectionInfo canMoveInDirectionInfo[6]; bool8 pokemonInFront; + EntityInfo *pokemonInfo = GetEntInfo(pokemon); + pokemonInfo->targetPos = pokemonInfo->aiTarget.aiTargetPos; if (pokemon->pos.x == pokemonInfo->aiTarget.aiTargetPos.x && pokemon->pos.y == pokemonInfo->aiTarget.aiTargetPos.y) @@ -369,7 +327,7 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) if (ShouldAvoidFirstHit(pokemon, pokemonInfo->aiTarget.aiTargetingEnemy)) { if (pokemonInfo->aiTarget.aiObjective == AI_CHASE_TARGET && - IsTargetTwoTilesAway(&pokemon->pos, &pokemonInfo->aiTarget.aiTargetPos)) + IsPositionWithinTwoTiles(&pokemon->pos, &pokemonInfo->aiTarget.aiTargetPos)) { s32 distance = GetDistance(&pokemon->pos, &pokemonInfo->aiTarget.aiTargetPos); if (distance == 2) @@ -417,17 +375,9 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) canMoveInDirectionInfo[TURN_LEFT_45].tryTurn = canMoveInDirectionInfo[TURN_RIGHT_45].tryTurn = canMoveInDirectionInfo[TURN_LEFT_90].tryTurn = canMoveInDirectionInfo[TURN_RIGHT_90].tryTurn = canMoveInDirectionInfo[TURN_LEFT_135].tryTurn = TRUE; if (!pokemonInfo->isNotTeamMember && (direction & 1) != 0) { - s32 targetDistanceX = pokemon->pos.x - pokemonInfo->aiTarget.aiTargetPos.x; - s32 targetDistanceY; - if (targetDistanceX < 0) - { - targetDistanceX = -targetDistanceX; - } - targetDistanceY = pokemon->pos.y - pokemonInfo->aiTarget.aiTargetPos.y; - if (targetDistanceY < 0) - { - targetDistanceY = -targetDistanceY; - } + s32 targetDistanceX = abs(pokemon->pos.x - pokemonInfo->aiTarget.aiTargetPos.x); + s32 targetDistanceY = abs(pokemon->pos.y - pokemonInfo->aiTarget.aiTargetPos.y); + if (targetDistanceX <= 2 && targetDistanceY <= 2 && targetDistanceX != targetDistanceY) { if ((direction & 2) != 0) @@ -465,8 +415,7 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) canMoveInDirectionInfo[i].canMoveInDirection = CanAIMonsterMoveInDirection(pokemon, canMoveInDirectionInfo[i].direction, &canMoveInDirectionInfo[i].pokemonInFront); if (!canMoveInDirectionInfo[i].canMoveInDirection && !canMoveInDirectionInfo[i].pokemonInFront) { - canMoveInDirectionInfo[TURN_RIGHT_45].tryTurn = TRUE; - canMoveInDirectionInfo[TURN_LEFT_45].tryTurn = TRUE; + canMoveInDirectionInfo[TURN_LEFT_45].tryTurn = canMoveInDirectionInfo[TURN_RIGHT_45].tryTurn = TRUE; } } for (i = TURN_LEFT_45; i < turnLimit; i++) @@ -495,7 +444,9 @@ void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect) } } -bool8 AvoidEnemies(Entity *pokemon) +// This function is nowhere near close to matching in Blue https://decomp.me/scratch/QNmaT. I suspect abs macros/static inlines or s16 changing the way we need to write code for agbcc. +// Sky's version is not matched either, but I believe it's closer to this one. To revisit later. +static bool8 AvoidEnemies(Entity *pokemon) { bool8 pokemonInFront; u8 closestTargetRoom; @@ -597,16 +548,8 @@ bool8 AvoidEnemies(Entity *pokemon) naturalJunctionListCounts = gDungeon->naturalJunctionListCounts[room]; furthestTargetToExitDistance = -INFINITY_2; furthestTargetExitIndex = 0; - distanceX = closestTarget->pos.x - pokemon->pos.x; - if (distanceX < 0) - { - distanceX = -distanceX; - } - pokemonToTargetDistance = closestTarget->pos.y - pokemon->pos.y; - if (pokemonToTargetDistance < 0) - { - pokemonToTargetDistance = -pokemonToTargetDistance; - } + distanceX = abs(closestTarget->pos.x - pokemon->pos.x); + pokemonToTargetDistance = abs(closestTarget->pos.y - pokemon->pos.y); if (pokemonToTargetDistance < distanceX) { pokemonToTargetDistance = distanceX; @@ -616,48 +559,31 @@ bool8 AvoidEnemies(Entity *pokemon) s32 targetToExitDistance; s32 pokemonToExitSignX, pokemonToExitSignY; s32 adjacentToTargetDistanceX, adjacentToTargetDistance; - s32 distanceX = closestTarget->pos.x - naturalJunctionList[i].x; - if (distanceX < 0) - { - distanceX = -distanceX; - } - targetToExitDistance = closestTarget->pos.y - naturalJunctionList[i].y; - if (targetToExitDistance < 0) - { - targetToExitDistance = -targetToExitDistance; - } + s32 distanceX = abs(closestTarget->pos.x - naturalJunctionList[i].x); + + targetToExitDistance = abs(closestTarget->pos.y - naturalJunctionList[i].y); + if (targetToExitDistance < distanceX) { targetToExitDistance = distanceX; } pokemonToExitSignX = naturalJunctionList[i].x - pokemon->pos.x; pokemonToExitSignY = naturalJunctionList[i].y - pokemon->pos.y; + if (pokemonToExitSignX < -1) - { pokemonToExitSignX = -1; - } + if (pokemonToExitSignY < -1) - { pokemonToExitSignY = -1; - } + if (pokemonToExitSignX > 1) - { pokemonToExitSignX = 1; - } + if (pokemonToExitSignY > 1) - { pokemonToExitSignY = 1; - } - adjacentToTargetDistanceX = closestTarget->pos.x - (pokemon->pos.x + pokemonToExitSignX); - if (adjacentToTargetDistanceX < 0) - { - adjacentToTargetDistanceX = -adjacentToTargetDistanceX; - } - adjacentToTargetDistance = closestTarget->pos.y - (pokemon->pos.y + pokemonToExitSignY); - if (adjacentToTargetDistance < 0) - { - adjacentToTargetDistance = -adjacentToTargetDistance; - } + + adjacentToTargetDistanceX = abs(closestTarget->pos.x - (pokemon->pos.x + pokemonToExitSignX)); + adjacentToTargetDistance = abs(closestTarget->pos.y - (pokemon->pos.y + pokemonToExitSignY)); if (adjacentToTargetDistance < adjacentToTargetDistanceX) { adjacentToTargetDistance = adjacentToTargetDistanceX; @@ -694,17 +620,18 @@ bool8 AvoidEnemies(Entity *pokemon) } } -bool8 Wander(Entity *pokemon) +static bool8 Wander(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); s32 room = GetEntityRoom(pokemon); - s32 targetFacingDir = 0; + s32 targetFacingDir; + s32 randDir; if (room == CORRIDOR_ROOM) { + s32 i; bool8 isAtJunction = FALSE; s32 oppositeFacingDir = (pokemonInfo->action.direction + NUM_DIRECTIONS / 2) & DIRECTION_MASK; - s32 targetFacingDir2; - s32 i; + if (IsAtJunction(pokemon)) { pokemonInfo->action.direction = DungeonRandInt(NUM_DIRECTIONS); @@ -714,18 +641,17 @@ bool8 Wander(Entity *pokemon) { bool8 pokemonInFront; targetFacingDir = (pokemonInfo->action.direction + gFaceDirectionIncrements[i]) & DIRECTION_MASK; - if ((!isAtJunction || targetFacingDir != oppositeFacingDir) && - CanAIMonsterMoveInDirection(pokemon, targetFacingDir, &pokemonInFront)) - { - // It's possible that the goto is an ugly fakematching, but we'll never know for sure. - goto DEFAULT; - } + + if (isAtJunction && targetFacingDir == oppositeFacingDir) + continue; + if (!CanAIMonsterMoveInDirection(pokemon, targetFacingDir, &pokemonInFront)) + continue; + + pokemonInfo->aiTarget.aiObjective = AI_ROAM; + pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[targetFacingDir].x; + pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[targetFacingDir].y; + return TRUE; } - targetFacingDir2 = DungeonRandInt(NUM_DIRECTIONS); - pokemonInfo->aiTarget.aiObjective = AI_STAND_STILL; - pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[targetFacingDir2].x; - pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[targetFacingDir2].y; - return TRUE; } else { @@ -733,10 +659,10 @@ bool8 Wander(Entity *pokemon) DungeonPos *naturalJunctionList = gDungeon->naturalJunctionList[room]; if (pokemonInfo->moveRandomly) { - s32 targetFacingDir = DungeonRandInt(NUM_DIRECTIONS); + s32 randDir = DungeonRandInt(NUM_DIRECTIONS); pokemonInfo->aiTarget.aiObjective = AI_STAND_STILL; - pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[targetFacingDir].x; - pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[targetFacingDir].y; + pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[randDir].x; + pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[randDir].y; return TRUE; } else @@ -792,10 +718,11 @@ bool8 Wander(Entity *pokemon) return TRUE; } } -DEFAULT: - pokemonInfo->aiTarget.aiObjective = AI_ROAM; - pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[targetFacingDir].x; - pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[targetFacingDir].y; + + randDir = DungeonRandInt(NUM_DIRECTIONS); + pokemonInfo->aiTarget.aiObjective = AI_STAND_STILL; + pokemonInfo->aiTarget.aiTargetPos.x = pokemon->pos.x + gAdjacentTileOffsets[randDir].x; + pokemonInfo->aiTarget.aiTargetPos.y = pokemon->pos.y + gAdjacentTileOffsets[randDir].y; return TRUE; } diff --git a/src/dungeon_config.c b/src/dungeon_config.c index e8ba20d69..8ae2535f5 100644 --- a/src/dungeon_config.c +++ b/src/dungeon_config.c @@ -173,16 +173,16 @@ UNUSED static const s16 sUnusedConfig1 = 95; const s16 gGinsengPlus3BoostChance = 12; // Move modifiers -const s24_8 gSolarBeamModifier = IntToF248_2(2.0); -const s24_8 gSkyAttackModifier = IntToF248_2(2.0); -const s24_8 gRazorWindModifier = IntToF248_2(2.0); -const s24_8 gFocusPunchModifier = IntToF248_2(2.0); -const s24_8 gSkullBashModifier = IntToF248_2(2.0); -const s24_8 gFlyModifier = IntToF248_2(2.0); -const s24_8 gBounceModifier = IntToF248_2(2.0); -const s24_8 gDiveModifier = IntToF248_2(2.0); -const s24_8 gDigModifier = IntToF248_2(2.0); -const s24_8 gFacadeModifier = IntToF248_2(2.0); +const s24_8 gSolarBeamModifier = IntToF248(2.0); +const s24_8 gSkyAttackModifier = IntToF248(2.0); +const s24_8 gRazorWindModifier = IntToF248(2.0); +const s24_8 gFocusPunchModifier = IntToF248(2.0); +const s24_8 gSkullBashModifier = IntToF248(2.0); +const s24_8 gFlyModifier = IntToF248(2.0); +const s24_8 gBounceModifier = IntToF248(2.0); +const s24_8 gDiveModifier = IntToF248(2.0); +const s24_8 gDigModifier = IntToF248(2.0); +const s24_8 gFacadeModifier = IntToF248(2.0); // Fixed damage/heal values const s16 gBurnDmgValue = 5; @@ -275,42 +275,42 @@ UNUSED static const s16 sUnusedConfig3 = 0; // Stat stage multipliers const s24_8 gAtkStatStageMultipliers[21] = { - IntToF248_2(0.2500), IntToF248_2(0.2696), IntToF248_2(0.2892), IntToF248_2(0.3087), IntToF248_2(0.3282), IntToF248_2(0.3478), - IntToF248_2(0.3985), IntToF248_2(0.4493), IntToF248_2(0.5000), IntToF248_2(0.6993), IntToF248_2(1.0000), IntToF248_2(1.2969), - IntToF248_2(1.5000), IntToF248_2(1.5978), IntToF248_2(1.6485), IntToF248_2(1.6993), IntToF248_2(1.7500), IntToF248_2(1.7969), - IntToF248_2(1.8478), IntToF248_2(1.8985), IntToF248_2(2.0000) + IntToF248(0.2500), IntToF248(0.2696), IntToF248(0.2892), IntToF248(0.3087), IntToF248(0.3282), IntToF248(0.3478), + IntToF248(0.3985), IntToF248(0.4493), IntToF248(0.5000), IntToF248(0.6993), IntToF248(1.0000), IntToF248(1.2969), + IntToF248(1.5000), IntToF248(1.5978), IntToF248(1.6485), IntToF248(1.6993), IntToF248(1.7500), IntToF248(1.7969), + IntToF248(1.8478), IntToF248(1.8985), IntToF248(2.0000) }; const s24_8 gDefStatStageMultipliers[21] = { - IntToF248_2(0.2500), IntToF248_2(0.2696), IntToF248_2(0.2892), IntToF248_2(0.3087), IntToF248_2(0.3282), IntToF248_2(0.3478), - IntToF248_2(0.3985), IntToF248_2(0.5469), IntToF248_2(0.6993), IntToF248_2(0.8672), IntToF248_2(1.0000), IntToF248_2(1.2969), - IntToF248_2(1.5000), IntToF248_2(1.5978), IntToF248_2(1.6485), IntToF248_2(1.6993), IntToF248_2(1.7500), IntToF248_2(1.7969), - IntToF248_2(1.8478), IntToF248_2(1.8985), IntToF248_2(2.0000) + IntToF248(0.2500), IntToF248(0.2696), IntToF248(0.2892), IntToF248(0.3087), IntToF248(0.3282), IntToF248(0.3478), + IntToF248(0.3985), IntToF248(0.5469), IntToF248(0.6993), IntToF248(0.8672), IntToF248(1.0000), IntToF248(1.2969), + IntToF248(1.5000), IntToF248(1.5978), IntToF248(1.6485), IntToF248(1.6993), IntToF248(1.7500), IntToF248(1.7969), + IntToF248(1.8478), IntToF248(1.8985), IntToF248(2.0000) }; const s24_8 gAccEvsStatStageMultipliers[2][21] = { // Accuracy { - IntToF248_2(0.3282), IntToF248_2(0.3478), IntToF248_2(0.3672), IntToF248_2(0.3985), IntToF248_2(0.4297), IntToF248_2(0.4493), - IntToF248_2(0.5469), IntToF248_2(0.5977), IntToF248_2(0.6993), IntToF248_2(0.7969), IntToF248_2(1.0000), IntToF248_2(1.2500), - IntToF248_2(1.5000), IntToF248_2(1.5978), IntToF248_2(1.6485), IntToF248_2(1.6993), IntToF248_2(1.7500), IntToF248_2(1.7969), - IntToF248_2(1.8478), IntToF248_2(1.8985), IntToF248_2(2.0000) + IntToF248(0.3282), IntToF248(0.3478), IntToF248(0.3672), IntToF248(0.3985), IntToF248(0.4297), IntToF248(0.4493), + IntToF248(0.5469), IntToF248(0.5977), IntToF248(0.6993), IntToF248(0.7969), IntToF248(1.0000), IntToF248(1.2500), + IntToF248(1.5000), IntToF248(1.5978), IntToF248(1.6485), IntToF248(1.6993), IntToF248(1.7500), IntToF248(1.7969), + IntToF248(1.8478), IntToF248(1.8985), IntToF248(2.0000) }, // Evasion { - IntToF248_2(2.0000), IntToF248_2(1.8985), IntToF248_2(1.8478), IntToF248_2(1.7969), IntToF248_2(1.7500), IntToF248_2(1.6993), - IntToF248_2(1.6485), IntToF248_2(1.5978), IntToF248_2(1.5000), IntToF248_2(1.3515), IntToF248_2(1.0000), IntToF248_2(0.7969), - IntToF248_2(0.6993), IntToF248_2(0.5977), IntToF248_2(0.5000), IntToF248_2(0.3985), IntToF248_2(0.3477), IntToF248_2(0.2969), - IntToF248_2(0.2500), IntToF248_2(0.1993), IntToF248_2(0.1485) + IntToF248(2.0000), IntToF248(1.8985), IntToF248(1.8478), IntToF248(1.7969), IntToF248(1.7500), IntToF248(1.6993), + IntToF248(1.6485), IntToF248(1.5978), IntToF248(1.5000), IntToF248(1.3515), IntToF248(1.0000), IntToF248(0.7969), + IntToF248(0.6993), IntToF248(0.5977), IntToF248(0.5000), IntToF248(0.3985), IntToF248(0.3477), IntToF248(0.2969), + IntToF248(0.2500), IntToF248(0.1993), IntToF248(0.1485) }, }; const s32 gDetectBandAccuracyDebuffValue = 30; // For attacking mon, which effectively raises target's evasion const s32 gIqQuickDodgerAccuracyDebuffValue = 30; // For attacking mon, which effectively raises target's evasion // Move modifiers again -const s24_8 gReversalModifiers[4] = {IntToF248_2(8), IntToF248_2(4), IntToF248_2(2), IntToF248_2(1)}; // Based on hp/max HP ratio -const s24_8 gWaterSpoutModifiers[4] = {IntToF248_2(0.1), IntToF248_2(0.2), IntToF248_2(0.5), IntToF248_2(1)}; // Based on hp/max HP ratio -const s24_8 gEruptionModifiers[4] = {IntToF248_2(0.1), IntToF248_2(0.2), IntToF248_2(0.5), IntToF248_2(1)}; // Based on hp/max HP ratio +const s24_8 gReversalModifiers[4] = {IntToF248(8), IntToF248(4), IntToF248(2), IntToF248(1)}; // Based on hp/max HP ratio +const s24_8 gWaterSpoutModifiers[4] = {IntToF248(0.1), IntToF248(0.2), IntToF248(0.5), IntToF248(1)}; // Based on hp/max HP ratio +const s24_8 gEruptionModifiers[4] = {IntToF248(0.1), IntToF248(0.2), IntToF248(0.5), IntToF248(1)}; // Based on hp/max HP ratio const s32 gStockpileHealHpValues[4] = {0, 20, 40, 80}; // Castform related @@ -327,14 +327,14 @@ const u8 gWeatherBallTypes[WEATHER_COUNT] = }; const s24_8 gWeatherBallModifiers[WEATHER_COUNT] = { - [WEATHER_CLEAR] = IntToF248_2(1.0), - [WEATHER_SUNNY] = IntToF248_2(2.0), - [WEATHER_SANDSTORM] = IntToF248_2(2.0), - [WEATHER_CLOUDY] = IntToF248_2(1.0), - [WEATHER_RAIN] = IntToF248_2(2.0), - [WEATHER_HAIL] = IntToF248_2(2.0), - [WEATHER_FOG] = IntToF248_2(2.0), - [WEATHER_SNOW] = IntToF248_2(2.0), + [WEATHER_CLEAR] = IntToF248(1.0), + [WEATHER_SUNNY] = IntToF248(2.0), + [WEATHER_SANDSTORM] = IntToF248(2.0), + [WEATHER_CLOUDY] = IntToF248(1.0), + [WEATHER_RAIN] = IntToF248(2.0), + [WEATHER_HAIL] = IntToF248(2.0), + [WEATHER_FOG] = IntToF248(2.0), + [WEATHER_SNOW] = IntToF248(2.0), }; const struct CastformWeatherData gCastformByWeather[WEATHER_COUNT] = diff --git a/src/dungeon_cutscene.c b/src/dungeon_cutscene.c index 4842acd37..04e147019 100644 --- a/src/dungeon_cutscene.c +++ b/src/dungeon_cutscene.c @@ -949,7 +949,7 @@ void sub_80856E0(Entity * pokemon, s32 direction) entityInfo->unk174 = F248_Sub(entityInfo->unk174, IntToF248(2)); DungeonRunFrameActions(0x46); } - entityInfo->unk174.raw = 0; // weird one that doesn't match with struct assignment + entityInfo->unk174 = 0; DungeonRunFrameActions(0x46); } diff --git a/src/dungeon_cutscene_articuno.c b/src/dungeon_cutscene_articuno.c index 2777bf5bb..d3c32d778 100644 --- a/src/dungeon_cutscene_articuno.c +++ b/src/dungeon_cutscene_articuno.c @@ -246,7 +246,7 @@ static void sub_8088484(Entity *param_1) PlaySoundEffect(0x1ea); for(iVar1 = 250; iVar1 >= 0; iVar1 -= 5) { - GetEntInfo(param_1)->unk174 = IntToF248_2(iVar1); + GetEntInfo(param_1)->unk174 = IntToF248(iVar1); SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,0); DungeonRunFrameActions(0x46); } diff --git a/src/dungeon_cutscene_celebi.c b/src/dungeon_cutscene_celebi.c index ae939d673..19dd0211b 100644 --- a/src/dungeon_cutscene_celebi.c +++ b/src/dungeon_cutscene_celebi.c @@ -194,11 +194,11 @@ static void sub_808C8E0(Entity *entity) PlaySoundEffect(0x1a5); sub_806CDD4(entity, 0, DIRECTION_SOUTH); for(iVar1 = 0; iVar1 < 16; iVar1++){ - GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); + GetEntInfo(entity)->unk174 = IntToF248(iVar1); DungeonRunFrameActions(0x46); } for(iVar1 = 16; iVar1 < 200; iVar1 += 4){ - GetEntInfo(entity)->unk174 = IntToF248_2(iVar1); + GetEntInfo(entity)->unk174 = IntToF248(iVar1); DungeonRunFrameActions(0x46); } sub_8086A3C(entity); diff --git a/src/dungeon_cutscene_hooh.c b/src/dungeon_cutscene_hooh.c index 48319bdde..93c526feb 100644 --- a/src/dungeon_cutscene_hooh.c +++ b/src/dungeon_cutscene_hooh.c @@ -174,16 +174,16 @@ static void HoOhDropInEffect(Entity * param_1) iVar1 = IntToF248(12); PlaySoundEffect(0x1f8); while( 1 ) { - iVar2.raw -= iVar1.raw; - iVar1 = F248_Sub(iVar1, FloatToF248(0.375)); + iVar2 -= iVar1; + iVar1 = F248_Sub(iVar1, IntToF248(0.375)); if (F248LessThanFloat(iVar1, 0.08)) { - iVar1 = FloatToF248_2(0.08); + iVar1 = IntToF248(0.08); } if (F248LessThanInt(iVar2, 0)) break; GetEntInfo(param_1)->unk174 = iVar2; DungeonRunFrameActions(70); } - GetEntInfo(param_1)->unk174 = IntToF248_2(0); + GetEntInfo(param_1)->unk174 = IntToF248(0); } static void HoOhScreenFlash(void) diff --git a/src/dungeon_cutscene_jirachi.c b/src/dungeon_cutscene_jirachi.c index 98193a369..d0077c3e1 100644 --- a/src/dungeon_cutscene_jirachi.c +++ b/src/dungeon_cutscene_jirachi.c @@ -425,15 +425,15 @@ static void JirachiDropInEffect(Entity *jirachiEntity) iVar2 = IntToF248(2); PlaySoundEffect(0x1f8); while (1) { - iVar1.raw = iVar1.raw - iVar2.raw; // FRAGILE! Subtraction and assignment below must use .raw + iVar1 -= iVar2; if (F248LessThanInt(iVar1, 24)) { - iVar2.raw = IntToF248_2(1).raw; + iVar2 = IntToF248(1); } if (F248LessThanInt(iVar1, 0)) break; GetEntInfo(jirachiEntity)->unk174 = iVar1; DungeonRunFrameActions(0x46); } - GetEntInfo(jirachiEntity)->unk174 = IntToF248_2(0); + GetEntInfo(jirachiEntity)->unk174 = IntToF248(0); } static void JirachiSpinEffect(Entity * jirachiEntity) diff --git a/src/dungeon_cutscene_mewtwo.c b/src/dungeon_cutscene_mewtwo.c index df90972ac..7595a0353 100644 --- a/src/dungeon_cutscene_mewtwo.c +++ b/src/dungeon_cutscene_mewtwo.c @@ -144,20 +144,20 @@ static void MewtwoDropInEffect(Entity *mewtwoEntity) s24_8 iVar2; GetEntInfo(mewtwoEntity)->unk15E = 0; - iVar2 = IntToF248_2(200); - iVar1 = IntToF248_2(4); + iVar2 = IntToF248(200); + iVar1 = IntToF248(4); PlaySoundEffect(0x1f8); while( 1 ) { - iVar2.raw -= iVar1.raw; - iVar1 = F248_Sub(iVar1, FloatToF248_2(0.045)); + iVar2 -= iVar1; + iVar1 = F248_Sub(iVar1, IntToF248(0.045)); if (F248LessThanFloat(iVar1, 0.12)) { - iVar1 = FloatToF248_2(0.12); + iVar1 = IntToF248(0.12); } if (F248LessThanInt(iVar2, 0)) break; GetEntInfo(mewtwoEntity)->unk174 = iVar2; DungeonRunFrameActions(0x46); } - GetEntInfo(mewtwoEntity)->unk174 = IntToF248_2(0); + GetEntInfo(mewtwoEntity)->unk174 = IntToF248(0); } static void MewtwoScreenFlash(void) diff --git a/src/dungeon_cutscene_moltres.c b/src/dungeon_cutscene_moltres.c index d1064d6e6..c1f82da5a 100644 --- a/src/dungeon_cutscene_moltres.c +++ b/src/dungeon_cutscene_moltres.c @@ -250,11 +250,11 @@ static void MoltresDropInEffect(Entity * moltresEntity) GetEntInfo(moltresEntity)->unk15C = 1; GetEntInfo(moltresEntity)->unk15E = 0; - GetEntInfo(moltresEntity)->unk174 = IntToF248_2(200); + GetEntInfo(moltresEntity)->unk174 = IntToF248(200); PlaySoundEffect(0x1f8); for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5) { - GetEntInfo(moltresEntity)->unk174 = IntToF248_2(iVar1); + GetEntInfo(moltresEntity)->unk174 = IntToF248(iVar1); DungeonRunFrameActions(0x46); } } diff --git a/src/dungeon_cutscene_rayquaza.c b/src/dungeon_cutscene_rayquaza.c index 17717c4a6..6e2f12151 100644 --- a/src/dungeon_cutscene_rayquaza.c +++ b/src/dungeon_cutscene_rayquaza.c @@ -181,20 +181,20 @@ static void RayquazaDropInEffect(Entity *rayquazaEntity) s24_8 iVar2; GetEntInfo(rayquazaEntity)->unk15E = 0; - iVar2 = IntToF248_2(200); - iVar1 = IntToF248_2(6); + iVar2 = IntToF248(200); + iVar1 = IntToF248(6); PlaySoundEffect(0x1f8); while( 1 ) { - iVar2.raw = iVar2.raw - iVar1.raw; // must be .raw - iVar1 = F248_Sub(iVar1, FloatToF248_2(3./32.)); + iVar2 = iVar2 - iVar1; + iVar1 = F248_Sub(iVar1, IntToF248(0.09375)); if (F248LessThanFloat(iVar1, 0.08)) { - iVar1 = FloatToF248(0.08); + iVar1 = IntToF248(0.08); } if (F248LessThanInt(iVar2, 0)) break; GetEntInfo(rayquazaEntity)->unk174 = iVar2; DungeonRunFrameActions(0x46); } - GetEntInfo(rayquazaEntity)->unk174 = IntToF248_2(0); + GetEntInfo(rayquazaEntity)->unk174 = IntToF248(0); } static void RayquazaScreenFlash(void) diff --git a/src/dungeon_cutscene_suicune.c b/src/dungeon_cutscene_suicune.c index 412128ace..e9ed25d9d 100644 --- a/src/dungeon_cutscene_suicune.c +++ b/src/dungeon_cutscene_suicune.c @@ -171,16 +171,16 @@ static void sub_808A528(Entity * param_1) iVar1 = IntToF248(12); PlaySoundEffect(0x1f8); while( 1 ) { - iVar2.raw -= iVar1.raw; - iVar1 = F248_Sub(iVar1, FloatToF248(0.375)); + iVar2 -= iVar1; + iVar1 = F248_Sub(iVar1, IntToF248(0.375)); if (F248LessThanFloat(iVar1, 0.08)) { - iVar1 = FloatToF248_2(0.08); + iVar1 = IntToF248(0.08); } if (F248LessThanInt(iVar2, 0)) break; GetEntInfo(param_1)->unk174 = iVar2; DungeonRunFrameActions(70); } - GetEntInfo(param_1)->unk174 = IntToF248_2(0); + GetEntInfo(param_1)->unk174 = IntToF248(0); } static void SuicuneScreenFlash(void) diff --git a/src/dungeon_cutscene_zapdos.c b/src/dungeon_cutscene_zapdos.c index d37942aa8..bd587214b 100644 --- a/src/dungeon_cutscene_zapdos.c +++ b/src/dungeon_cutscene_zapdos.c @@ -238,11 +238,11 @@ static void ZapdosDropInEffect(Entity *zapdosEntity) GetEntInfo(zapdosEntity)->unk15C = 1; GetEntInfo(zapdosEntity)->unk15E = 0; - GetEntInfo(zapdosEntity)->unk174.raw = 200; // incorrect value? Overwritten immediately anyway + GetEntInfo(zapdosEntity)->unk174 = 200; // incorrect value? Overwritten immediately anyway PlaySoundEffect(0x1ea); for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5) { - GetEntInfo(zapdosEntity)->unk174 = IntToF248_2(iVar1); + GetEntInfo(zapdosEntity)->unk174 = IntToF248(iVar1); DungeonRunFrameActions(0x46); } sub_803E708(0x1e,0x46); diff --git a/src/dungeon_damage.c b/src/dungeon_damage.c index 901e65496..13bced3a3 100644 --- a/src/dungeon_damage.c +++ b/src/dungeon_damage.c @@ -97,7 +97,7 @@ void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct * } if (GetEntInfo(target)->bideClassStatus.status == STATUS_ENRAGED) { - RaiseAttackStageTarget(attacker, target, gStatIndexAtkDef, 1); + BoostOffensiveStat(attacker, target, gStatIndexAtkDef, 1); } if (!EntityIsValid(attacker) || !EntityIsValid(target)) @@ -532,7 +532,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc sub_800DBBC(); sub_806A390(target); sub_806CCB4(target, sub_806CEBC(target)); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[1], target, 0); DisplayDungeonLoggableMessageTrue(attacker, gUnknown_80FD46C); sub_806F63C(target); @@ -589,7 +589,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc sub_800DBBC(); sub_806A390(target); sub_806CCB4(target, sub_806CEBC(target)); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], target, 0); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[1], teamMember, 0); DisplayDungeonLoggableMessageTrue(attacker, gUnknown_80FD484); @@ -601,7 +601,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc } - if (IQSkillIsEnabled(target, IQ_ITEM_MASTER)) { + if (IqSkillIsEnabled(target, IQ_ITEM_MASTER)) { s32 i; // r3 Item *reviverSeed = NULL; // r4 if (ItemExists(&targetData->heldItem) && !ItemSticky(&targetData->heldItem) && ItemId(&targetData->heldItem) == ITEM_REVIVER_SEED) @@ -643,7 +643,7 @@ static bool8 HandleDealingDamageInternal(Entity *attacker, Entity *target, struc sub_800DBBC(); sub_806A390(target); sub_806CCB4(target, sub_806CEBC(target)); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[1], target, 0); DisplayDungeonLoggableMessageTrue(attacker, gUnknown_80FD46C); sub_806F63C(target); @@ -1026,7 +1026,7 @@ static void ApplyAtkDefStatBoosts(Entity *attacker, Entity *target, u8 moveType, if (AbilityIsActive(attacker, ABILITY_GUTS)) { EntityInfo *entInfo = GetEntInfo(attacker); - bool8 gutsBoost = HasNegativeStatus(attacker); + bool8 gutsBoost = MonsterHasNegativeStatus(attacker); bool8 visFlags_attacker_1 = SetVisualFlags(entInfo,1,gutsBoost); if (gutsBoost) { @@ -1081,7 +1081,7 @@ static void ApplyAtkDefStatBoosts(Entity *attacker, Entity *target, u8 moveType, if ((AbilityIsActive(target, ABILITY_MARVEL_SCALE)) && (splitIndex == 0)) { EntityInfo *targetInfo = GetEntInfo(target); - bool8 hasNegStatus_target = HasNegativeStatus(target); + bool8 hasNegStatus_target = MonsterHasNegativeStatus(target); bool8 visFlags_target = SetVisualFlags(targetInfo, 8, hasNegStatus_target); if (hasNegStatus_target) { @@ -1330,7 +1330,7 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3 critOdds += gCritOddsScopeLensPatsyBand; gDungeon->unk134.unk165 = 1; } - if (r5 && IQSkillIsEnabled(attacker, IQ_TYPE_ADVANTAGE_MASTER)) { + if (r5 && IqSkillIsEnabled(attacker, IQ_TYPE_ADVANTAGE_MASTER)) { critOdds = gCritOddsIqAdvantageMaster; gDungeon->unk134.unk169 = 1; } diff --git a/src/dungeon_entity_movement.c b/src/dungeon_entity_movement.c index a02a6941d..d3e8147f6 100644 --- a/src/dungeon_entity_movement.c +++ b/src/dungeon_entity_movement.c @@ -351,7 +351,7 @@ static void TryInteractWithTile(Entity *entity) return; tile = GetTileAtEntitySafe(entity); - if (IQSkillIsEnabled(entity, IQ_SUPER_MOBILE) + if (IqSkillIsEnabled(entity, IQ_SUPER_MOBILE) && info->invisibleClassStatus.status != STATUS_MOBILE && !(HasHeldItem(entity, ITEM_MOBILE_SCARF))) { @@ -366,7 +366,7 @@ static void TryInteractWithTile(Entity *entity) Trap *trapData = GetTrapInfo(tileEntity); bool8 trigger = FALSE; bool8 onlyMakeVisible = FALSE; - if (IQSkillIsEnabled(entity, IQ_TRAP_SEER) && !tileEntity->isVisible) { + if (IqSkillIsEnabled(entity, IQ_TRAP_SEER) && !tileEntity->isVisible) { tileEntity->isVisible = TRUE; UpdateTrapsVisibility(); onlyMakeVisible = TRUE; @@ -410,7 +410,7 @@ bool8 CheckEntityTileForInteraction(Entity *entity) return FALSE; tile = GetTileAtEntitySafe(entity); - if (IQSkillIsEnabled(entity, IQ_SUPER_MOBILE) && GetTerrainType(tile) == TERRAIN_TYPE_WALL) + if (IqSkillIsEnabled(entity, IQ_SUPER_MOBILE) && GetTerrainType(tile) == TERRAIN_TYPE_WALL) return TRUE; subEntity = tile->object; if (subEntity == NULL) diff --git a/src/dungeon_item_action.c b/src/dungeon_item_action.c index 03d72fdc1..93404fcda 100644 --- a/src/dungeon_item_action.c +++ b/src/dungeon_item_action.c @@ -94,7 +94,7 @@ void sub_80479B8(bool8 param_1, bool8 param_2, u8 param_3, Entity *pokemon, Enti } else { if (GetItemCategory(item->id) != CATEGORY_BERRIES_SEEDS_VITAMINS) { - flag = IQSkillIsEnabled(target, IQ_ITEM_CATCHER); + flag = IqSkillIsEnabled(target, IQ_ITEM_CATCHER); } } @@ -374,7 +374,7 @@ static void sub_80482FC(Entity *pokemon, Entity *target, u32 pp, u8 param_4) InitPokemonMove(&move, MOVE_PROJECTILE); move.PP = pp; - HandleDamagingMove(pokemon, target, &move, IntToF248_2(1.0), param_4); + HandleDamagingMove(pokemon, target, &move, IntToF248(1), param_4); } static void sub_8048340(Entity *pokemon, Entity *target, u32 r2) @@ -419,7 +419,7 @@ static void AllureSeedItemAction(Entity *pokemon, Entity *target) static void QuickSeedItemAction(Entity *pokemon, Entity *target) { - RaiseMovementSpeedTarget(pokemon, target, 0, TRUE); + BoostSpeed(pokemon, target, 0, TRUE); } static void EyedropSeedItemAction(Entity *pokemon, Entity *target) @@ -502,7 +502,7 @@ static void HungerSeedItemAction(Entity *pokemon, Entity * target) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], target, 0); - if (IQSkillIsEnabled(target, IQ_SELF_CURER)) + if (IqSkillIsEnabled(target, IQ_SELF_CURER)) TryDisplayDungeonLoggableMessage3(pokemon, target, gPtrSelfHealPreventedHungerMessage); else { @@ -931,11 +931,11 @@ static void GrimyFoodItemAction(Entity *pokemon, Entity * target) BurnedStatusTarget(pokemon, target, 1, TRUE); break; case 3: - ParalyzeStatusTarget(pokemon, target, TRUE); + TryInflictParalysisStatus(pokemon, target, TRUE); break; case 4: - LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 3, 1, TRUE); - LowerAttackStageTarget(pokemon, target, gStatIndexSpecial, 3, 1, TRUE); + LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 3, TRUE, TRUE); + LowerOffensiveStat(pokemon, target, gStatIndexSpecial, 3, TRUE, TRUE); break; } } diff --git a/src/dungeon_items.c b/src/dungeon_items.c index ce4094bba..9725e1929 100644 --- a/src/dungeon_items.c +++ b/src/dungeon_items.c @@ -388,7 +388,7 @@ bool8 sub_80462AC(Entity * entity, u8 hallucinating, u8 a2, u8 a3, u8 a4) } x = (entity->pixelPos.x / 256) - gDungeon->unk181e8.cameraPixelPos.x; - y = ((entity->pixelPos.y - entity->unk1C.raw) / 256) - gDungeon->unk181e8.cameraPixelPos.y; + y = ((entity->pixelPos.y - entity->unk1C) / 256) - gDungeon->unk181e8.cameraPixelPos.y; y2 = ((entity->pixelPos.y / 256) - gDungeon->unk181e8.cameraPixelPos.y) + 8; y2 /= 2; @@ -549,7 +549,7 @@ static void sub_8046734(Entity *entity, DungeonPos *pos) for (i = 0; i < 24; i++) { calcPixelPos.x += add.x; calcPixelPos.y += add.y; - entity->unk1C.raw = sin_4096(sinVal) * 12; + entity->unk1C = sin_4096(sinVal) * 12; UpdateEntityPixelPos(entity, &calcPixelPos); sub_80462AC(entity, hallucinating, 0, unk, 0); DungeonRunFrameActions(0x13); @@ -562,7 +562,7 @@ static void sub_8046734(Entity *entity, DungeonPos *pos) } SetEntityPixelPos(entity, posPixel.x, posPixel.y); - entity->unk1C.raw = 0; + entity->unk1C = 0; sub_80462AC(entity, hallucinating, 1, 0xFF, 0); DungeonRunFrameActions(0x13); } @@ -669,7 +669,7 @@ void sub_804687C(Entity *entity, DungeonPos *pos1, DungeonPos *pos2, Item *item, for (i = 0; i < count; i++) { if (EntityIsValid(&itemEntities[i])) { IncreaseEntityPixelPos(&itemEntities[i], itemVelocity[i].x, itemVelocity[i].y); - itemEntities[i].unk1C.raw = sin_4096(sinVal) * 12; + itemEntities[i].unk1C = sin_4096(sinVal) * 12; sub_80462AC(&itemEntities[i], hallucinating, 1, dirMaybe, 0); } } diff --git a/src/dungeon_logic.c b/src/dungeon_logic.c index ece394d8e..0bf5c5215 100644 --- a/src/dungeon_logic.c +++ b/src/dungeon_logic.c @@ -105,10 +105,10 @@ u8 sub_80703A0(Entity *pokemon, DungeonPos *pos) if ((IsCurrentFixedRoomBossFight()) || ((entityInfo->invisibleClassStatus.status != STATUS_MOBILE && (!HasHeldItem(pokemon, ITEM_MOBILE_SCARF))))) { crossableTerrain = GetCrossableTerrain(entityInfo->id); tileFlags = tile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { + if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { crossableTerrain = CROSSABLE_TERRAIN_CREVICE; } - if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { + if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { crossableTerrain = CROSSABLE_TERRAIN_WALL; } switch(crossableTerrain) @@ -171,10 +171,10 @@ bool8 sub_807049C(Entity *pokemon, DungeonPos *pos) if (IsCurrentFixedRoomBossFight() || (entityInfo->invisibleClassStatus.status != STATUS_MOBILE && !HasHeldItem(pokemon, ITEM_MOBILE_SCARF))) { crossableTerrain = GetCrossableTerrain(entityInfo->id); tileFlags = tile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { + if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { crossableTerrain = CROSSABLE_TERRAIN_CREVICE; } - if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { + if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { crossableTerrain = CROSSABLE_TERRAIN_WALL; } switch(crossableTerrain) @@ -255,10 +255,10 @@ bool8 sub_80705F0(Entity *pokemon, DungeonPos *pos) if (IsCurrentFixedRoomBossFight() || (entityInfo->invisibleClassStatus.status != STATUS_MOBILE && !HasHeldItem(pokemon, ITEM_MOBILE_SCARF))) { crossableTerrain = GetCrossableTerrain(entityInfo->id); tileFlags = tile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { + if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { crossableTerrain = CROSSABLE_TERRAIN_CREVICE; } - if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { + if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { crossableTerrain = CROSSABLE_TERRAIN_WALL; } @@ -296,10 +296,10 @@ bool8 sub_80706A4(Entity *pokemon, DungeonPos *pos) if (IsCurrentFixedRoomBossFight() || (entityInfo->invisibleClassStatus.status != STATUS_MOBILE && !HasHeldItem(pokemon, ITEM_MOBILE_SCARF))) { crossableTerrain = GetCrossableTerrain(entityInfo->id); tileFlags = tile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY); - if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { + if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { crossableTerrain = CROSSABLE_TERRAIN_CREVICE; } - if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { + if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { crossableTerrain = CROSSABLE_TERRAIN_WALL; } switch(crossableTerrain) @@ -468,7 +468,7 @@ void CopyEntityNameForDungeonExitSummary(u8 *buffer, EntityInfo *entityInfo) } } -bool8 HasNegativeStatus(Entity *pokemon) +bool8 MonsterHasNegativeStatus(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); s32 i; @@ -508,7 +508,7 @@ bool8 HasNegativeStatus(Entity *pokemon) return FALSE; } -bool8 IsSleeping(Entity *pokemon) +bool8 IsMonsterSleeping(Entity *pokemon) { if (GetEntInfo(pokemon)->sleepClassStatus.status != STATUS_SLEEP && GetEntInfo(pokemon)->sleepClassStatus.status != STATUS_NAPPING && @@ -519,7 +519,7 @@ bool8 IsSleeping(Entity *pokemon) return TRUE; } -bool8 HasLowHealth(Entity *pokemon) +bool8 MonsterHasQuarterHp(Entity *pokemon) { EntityInfo *pokemonInfo = GetEntInfo(pokemon); if (pokemonInfo->HP <= pokemonInfo->maxHPStat / 4) @@ -695,9 +695,9 @@ bool8 CanMoveInDirection(Entity *pokemon, u32 direction) { if (GetEntInfo(pokemon)->invisibleClassStatus.status == STATUS_MOBILE || HasHeldItem(pokemon, ITEM_MOBILE_SCARF)) crossableTerrain = CROSSABLE_TERRAIN_WALL; - else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) + else if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) crossableTerrain = CROSSABLE_TERRAIN_CREVICE; - else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { + else if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { if (direction & 1) // Super Mobile can't break walls diagonally. crossableTerrain = CROSSABLE_TERRAIN_CREVICE; @@ -730,13 +730,13 @@ bool8 sub_8070F3C(Entity * pokemon, DungeonPos *pos, s32 direction) { terrain = CROSSABLE_TERRAIN_WALL; } - else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) + else if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { // BUG: If the Pokémon is a Ghost type that can normally attack through walls, // All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls. terrain = CROSSABLE_TERRAIN_CREVICE; } - else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) + else if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { if ((direction & 1) != 0) { @@ -793,13 +793,13 @@ bool8 sub_8070F80(Entity * pokemon, s32 direction) { terrain = CROSSABLE_TERRAIN_WALL; } - else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) + else if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { // BUG: If the Pokémon is a Ghost type that can normally attack through walls, // All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls. terrain = CROSSABLE_TERRAIN_CREVICE; } - else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) + else if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { if ((direction & 1) != 0) { @@ -839,13 +839,13 @@ UNUSED static bool8 sub_8071058(Entity * pokemon, s32 direction) { terrain = CROSSABLE_TERRAIN_WALL; } - else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) + else if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { // BUG: If the Pokémon is a Ghost type that can normally attack through walls, // All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls. terrain = CROSSABLE_TERRAIN_CREVICE; } - else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) + else if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { if ((direction & 1) != 0) { @@ -886,13 +886,13 @@ bool8 CanAttackInDirection(Entity *pokemon, s32 direction) { crossableTerrain = CROSSABLE_TERRAIN_WALL; } - else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) + else if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { // BUG: If the Pokémon is a Ghost type that can normally attack through walls, // All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls. crossableTerrain = CROSSABLE_TERRAIN_CREVICE; } - else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) + else if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { if ((direction & 1) != 0) { @@ -927,12 +927,12 @@ bool8 CanAIMonsterMoveInDirection(Entity *pokemon, s32 direction, bool8 *pokemon } if (frontTile->terrainFlags & TERRAIN_TYPE_IN_MONSTER_HOUSE && !gDungeon->unk644.monsterHouseTriggered && - IQSkillIsEnabled(pokemon, IQ_HOUSE_AVOIDER)) + IqSkillIsEnabled(pokemon, IQ_HOUSE_AVOIDER)) { return FALSE; } if (frontTile->object != NULL && - IQSkillIsEnabled(pokemon, IQ_TRAP_AVOIDER) && + IqSkillIsEnabled(pokemon, IQ_TRAP_AVOIDER) && GetEntityType(frontTile->object) == ENTITY_TRAP && (frontTile->object->isVisible || GetEntInfo(pokemon)->blinkerClassStatus.status == STATUS_EYEDROPS)) { @@ -940,7 +940,7 @@ bool8 CanAIMonsterMoveInDirection(Entity *pokemon, s32 direction, bool8 *pokemon } if ((frontTile->terrainFlags & (TERRAIN_TYPE_NORMAL | TERRAIN_TYPE_SECONDARY)) == TERRAIN_TYPE_SECONDARY && gDungeonWaterType[gDungeon->tileset] == DUNGEON_WATER_TYPE_LAVA && - IQSkillIsEnabled(pokemon, IQ_LAVA_EVADER)) + IqSkillIsEnabled(pokemon, IQ_LAVA_EVADER)) { return FALSE; } @@ -951,13 +951,13 @@ bool8 CanAIMonsterMoveInDirection(Entity *pokemon, s32 direction, bool8 *pokemon { crossableTerrain = CROSSABLE_TERRAIN_WALL; } - else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) + else if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { // BUG: If the Pokémon is a Ghost type that can normally move through walls, // All-Terrain Hiker/Super Mobile may make the AI think it can't move through walls. crossableTerrain = CROSSABLE_TERRAIN_CREVICE; } - else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) + else if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { if ((direction & 1) != 0) { @@ -993,11 +993,11 @@ bool8 IsAtJunction(Entity *pokemon) { crossableTerrain = CROSSABLE_TERRAIN_WALL; } - else if (IQSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) + else if (IqSkillIsEnabled(pokemon, IQ_ALL_TERRAIN_HIKER)) { crossableTerrain = CROSSABLE_TERRAIN_CREVICE; } - else if (IQSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) + else if (IqSkillIsEnabled(pokemon, IQ_SUPER_MOBILE)) { crossableTerrain = CROSSABLE_TERRAIN_WALL; } @@ -1021,7 +1021,7 @@ bool8 IsAtJunction(Entity *pokemon) char walkableNeighborFlags; if (gDungeonWaterType[gDungeon->tileset] == DUNGEON_WATER_TYPE_LAVA && crossableTerrain == CROSSABLE_TERRAIN_LIQUID - && IQSkillIsEnabled(pokemon, IQ_LAVA_EVADER)) + && IqSkillIsEnabled(pokemon, IQ_LAVA_EVADER)) { crossableTerrain = CROSSABLE_TERRAIN_REGULAR; } @@ -1201,7 +1201,7 @@ u8 GetTreatmentBetweenMonstersIgnoreStatus(Entity *monster1, Entity *monster2) return TREATMENT_TREAT_AS_ALLY; } -bool8 HasSafeguardStatus(Entity * pokemon, Entity * target, bool8 displayMessage) +bool8 SafeguardIsActive(Entity * pokemon, Entity * target, bool8 displayMessage) { if (GetEntInfo(target)->reflectClassStatus.status == STATUS_SAFEGUARD) { if (displayMessage) { @@ -1213,7 +1213,7 @@ bool8 HasSafeguardStatus(Entity * pokemon, Entity * target, bool8 displayMessage return FALSE; } -bool8 sub_8071728(Entity * pokemon, Entity * target, bool8 displayMessage) +bool8 IsProtectedFromStatDrops(Entity * pokemon, Entity * target, bool8 displayMessage) { if (GetEntInfo(target)->reflectClassStatus.status == STATUS_MIST) { if (displayMessage) { @@ -1320,7 +1320,7 @@ bool8 IsTacticSet(Entity *pokemon, u8 tactic) return pokemonInfo->tactic == tactic; } -bool8 IQSkillIsEnabled(Entity *pokemon, u8 IQSkill) +bool8 IqSkillIsEnabled(Entity *pokemon, u8 IQSkill) { return IsIQSkillSet(&GetEntInfo(pokemon)->IQSkillFlags, 1 << IQSkill); } diff --git a/src/dungeon_main.c b/src/dungeon_main.c index 0f385a466..8085bc66a 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -936,7 +936,7 @@ void CheckLeaderTile(void) return; tile = GetTileAtEntitySafe(leader); - if (IQSkillIsEnabled(leader, IQ_SUPER_MOBILE) && GetEntInfo(leader)->invisibleClassStatus.status != STATUS_MOBILE && !HasHeldItem(leader, ITEM_MOBILE_SCARF)) + if (IqSkillIsEnabled(leader, IQ_SUPER_MOBILE) && GetEntInfo(leader)->invisibleClassStatus.status != STATUS_MOBILE && !HasHeldItem(leader, ITEM_MOBILE_SCARF)) sub_804AE84(&leader->pos); if (tile->terrainFlags & TERRAIN_TYPE_STAIRS) gDungeon->unk1 = 1; @@ -950,7 +950,7 @@ void CheckLeaderTile(void) Trap *trap = GetTrapInfo(tileObject); bool32 r8 = FALSE; bool32 r7 = FALSE; - if (IQSkillIsEnabled(leader, IQ_TRAP_SEER) && !tileObject->isVisible) { + if (IqSkillIsEnabled(leader, IQ_TRAP_SEER) && !tileObject->isVisible) { tileObject->isVisible = TRUE; UpdateTrapsVisibility(); r7 = TRUE; @@ -1107,18 +1107,23 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) s32 r10; bool8 printAll = fromBPress; s32 chosenOption; - s32 var_24; - struct UnkMenuBitsStruct var_30; - struct UnkMenuBitsStruct var_34; + bool8 var_24; r10 = gDungeon->unk5C0; chosenOption = 0; - var_24 = (gDungeon->unk5C0 > - 1); + var_24 = (gDungeon->unk5C0 >= 0); gDungeon->unk5C0 = -1; + if (r10 >= 0) { chosenOption = r10; } + // Blue/DS only fields? + #if GAME_VERSION == VERSION_BLUE + gDungeon->unk17C = -1; + gDungeon->unk17E = -1; + #endif + if (a1) { PlayFanfareSE(0x137, 0x100); } @@ -1143,7 +1148,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) PlayDungeonCursorSE(1); MoveMenuCursorUpWrapAround(&gDungeonMenu, TRUE); } - if ((gRealInputs.pressed & A_BUTTON || gDungeonMenu.touchScreen.a_button)) { + if ((gRealInputs.pressed & A_BUTTON /* || (gRealInputs.pressed & 0x400) */ || gDungeonMenu.touchScreen.a_button)) { if (gUnknown_202749A[gDungeonMenu.menuIndex + 1] == 7) { PlayDungeonConfirmationSE(); chosenOption = gDungeonMenu.menuIndex; @@ -1165,6 +1170,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) r10 = chosenOption; if (chosenOption == MAIN_MENU_ITEMS) { u16 action; + struct UnkMenuBitsStruct var_34; SetLeaderActionToNothing(TRUE); var_34.a0_8 = 0; @@ -1269,7 +1275,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) break; } else if (chosenOption == MAIN_MENU_MOVES) { - s32 i, currMonId, teamMonsCount, r9; + s32 i, currMonId; Entity *currEntity; currMonId = 0; @@ -1285,8 +1291,10 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) } while (1) { + s32 r9, teamMonsCount; + SetLeaderActionToNothing(0); - LOOP_START_NO_CALL: // Actions 6 and 7 don't call SetLeaderActionToNothing + LOOP_START_NO_CALL: // Actions 6 and 7 don't call SetLeaderActionToNothing. Goto is real here. currEntity = NULL; r9 = 0; teamMonsCount = 0; @@ -1347,7 +1355,10 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) else if (GetLeaderActionId() == ACTION_MOVE_INFO) { ActionShowMoveInfo(GetLeaderActionContainer()); } - else if (GetLeaderActionId() == ACTION_SET_MOVE || GetLeaderActionId() == ACTION_UNSET_MOVE) { + else if (GetLeaderActionId() == ACTION_SET_MOVE) { + ActionSetOrUnsetMove(GetLeaderActionContainer(), FALSE); + } + else if (GetLeaderActionId() == ACTION_UNSET_MOVE) { ActionSetOrUnsetMove(GetLeaderActionContainer(), FALSE); } else if (GetLeaderActionId() == ACTION_SWITCH_AI_MOVE) { @@ -1375,6 +1386,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) if (tileObject != NULL) { if (GetEntityType(tileObject) == ENTITY_ITEM) { u16 action; + struct UnkMenuBitsStruct var_30; SetLeaderActionToNothing(TRUE); var_30.a0_8 = 0; @@ -1449,14 +1461,13 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) if (chosenOption < 0) break; - if (var_24 == 0) { - ResetRepeatTimers(); - ResetUnusedInputStruct(); - } - else { + if (var_24) { TryPointCameraToMonster(GetLeader(), 0); break; } + + ResetRepeatTimers(); + ResetUnusedInputStruct(); } sub_803EAF0(0, NULL); diff --git a/src/dungeon_misc.c b/src/dungeon_misc.c index 0645fdc78..9274e7af1 100644 --- a/src/dungeon_misc.c +++ b/src/dungeon_misc.c @@ -881,9 +881,9 @@ void SetMonSummaryInfoFromEntity(struct MonSummaryInfo *param_1, Entity *target) param_1->unk58[uVar15] = 40; uVar15++; } - if ((((((info->offensiveMultipliers[0].raw < 0x100) || (info->offensiveMultipliers[1].raw < 0x100) - ) || (info->defensiveMultipliers[0].raw < 0x100)) || - ((info->defensiveMultipliers[1].raw < 0x100 || (info->offensiveStages[0] < 10)))) || + if ((((((info->offensiveMultipliers[0] < 0x100) || (info->offensiveMultipliers[1] < 0x100) + ) || (info->defensiveMultipliers[0] < 0x100)) || + ((info->defensiveMultipliers[1] < 0x100 || (info->offensiveStages[0] < 10)))) || ((info->offensiveStages[1] < 10 || ((info->defensiveStages[0] < 10 || (info->defensiveStages[1] < 10)))))) || ((info->hitChanceStages[0] < 10 || (info->hitChanceStages[1] < 10)))) { @@ -1478,7 +1478,7 @@ void sub_806A6E8(Entity *entity) } if (gDungeon->unk644.itemHoldersIdentified) { - EntityUpdateStatusSprites(entity); + UpdateStatusIconFlags(entity); } } else { @@ -1714,7 +1714,7 @@ void EndAbilityImmuneStatus(Entity *attacker, Entity *target) } if ((AbilityIsActive(target, ABILITY_INSOMNIA) || AbilityIsActive(target, ABILITY_VITAL_SPIRIT)) - && (IsSleeping(target) || targetInfo->sleepClassStatus.status == STATUS_YAWNING)) + && (IsMonsterSleeping(target) || targetInfo->sleepClassStatus.status == STATUS_YAWNING)) { EndSleepClassStatus(attacker, target, FALSE, TRUE); } diff --git a/src/dungeon_mon_spawn.c b/src/dungeon_mon_spawn.c index 113bc0baf..5c2547a64 100644 --- a/src/dungeon_mon_spawn.c +++ b/src/dungeon_mon_spawn.c @@ -674,7 +674,7 @@ void UpdateEntitySpecies(Entity *entity, s32 _species) entity->axObj.unk43_animId2 = 0xFF; entity->axObj.unk45_orientation = 1; entity->axObj.unk47 = 1; - entity->unk1C = IntToF248_2(0); + entity->unk1C = IntToF248(0); if (entInfo->frozenClassStatus.status == STATUS_WRAP || entInfo->frozenClassStatus.status == STATUS_WRAPPED) { sub_8076CB4(entInfo->unk9C); @@ -685,7 +685,7 @@ void UpdateEntitySpecies(Entity *entity, s32 _species) entInfo->HP = entInfo->maxHPStat; entInfo->shopkeeper = 0; sub_80429E8(entity); - EntityUpdateStatusSprites(entity); + UpdateStatusIconFlags(entity); } static void InitEntityFromSpawnInfo(bool8 a0, Entity *entity, struct MonSpawnInfo *monSpawnInfo, DungeonPos *pos) @@ -765,7 +765,7 @@ static void InitEntityFromSpawnInfo(bool8 a0, Entity *entity, struct MonSpawnInf entInfo->aiTarget.unkC = 0; entInfo->aiTarget.aiTargetSpawnGenID = 0; entInfo->unkFF = 0; - entInfo->unk174.raw = 0; + entInfo->unk174 = 0; entInfo->decoyAITracker = 0; ResetMonEntityData(entInfo, TRUE); ZeroOutItem(&entInfo->heldItem); @@ -877,8 +877,8 @@ void ResetMonEntityData(EntityInfo *entInfo, bool8 setStatsToOne) entInfo->offensiveStages[i] = 10; entInfo->defensiveStages[i] = 10; entInfo->hitChanceStages[i] = 10; - entInfo->offensiveMultipliers[i].raw = IntToF248_2(1).raw; - entInfo->defensiveMultipliers[i].raw = IntToF248_2(1).raw; + entInfo->offensiveMultipliers[i] = IntToF248(1); + entInfo->defensiveMultipliers[i] = IntToF248(1); } if (hasForecast) { diff --git a/src/dungeon_mon_sprite_render.c b/src/dungeon_mon_sprite_render.c index 9a182e0e3..342f8f086 100644 --- a/src/dungeon_mon_sprite_render.c +++ b/src/dungeon_mon_sprite_render.c @@ -185,7 +185,7 @@ void UpdateMonsterSprite(Entity *entity) entity->prevPixelPos.y = entity->pixelPos.y; x = (entity->pixelPos.x / 256) - gDungeon->unk181e8.cameraPixelPos.x; - y = (((entity->pixelPos.y - entity->unk1C.raw) - entInfo->unk174.raw) / 256) - gDungeon->unk181e8.cameraPixelPos.y; + y = (((entity->pixelPos.y - entity->unk1C) - entInfo->unk174) / 256) - gDungeon->unk181e8.cameraPixelPos.y; y2 = (entity->pixelPos.y / 256) - gDungeon->unk181e8.cameraPixelPos.y; y2 /= 2; if (entInfo->unk156 == 0) { @@ -208,7 +208,7 @@ void UpdateMonsterSprite(Entity *entity) } pos1.x = entity->pixelPos.x / 256; - pos1.y = ((entity->pixelPos.y - entity->unk1C.raw) - entInfo->unk174.raw) / 256; + pos1.y = ((entity->pixelPos.y - entity->unk1C) - entInfo->unk174) / 256; sub_8005700(posArray, &entity->axObj.axdata); UpdateDungeonPokemonSprite2(entInfo->dungeonSpriteId, &pos1, posArray, gDungeon->unk181e8.priority); @@ -219,17 +219,17 @@ void UpdateMonsterSprite(Entity *entity) sub_8042EC8(entity, y2); if (entInfo->unk15C == 0) { if (entInfo->unkFF == 1) { - if (entInfo->unk174.raw <= IntToF248_2(199.999).raw) { - entInfo->unk174.raw += IntToF248_2(8).raw; - if (entInfo->unk174.raw > IntToF248_2(200).raw) { - entInfo->unk174.raw = IntToF248_2(200).raw; + if (entInfo->unk174 <= IntToF248(199.999)) { + entInfo->unk174 += IntToF248(8); + if (entInfo->unk174 > IntToF248(200)) { + entInfo->unk174 = IntToF248(200); } } } else { - entInfo->unk174.raw -= IntToF248_2(12).raw; - if (entInfo->unk174.raw < IntToF248_2(0).raw) { - entInfo->unk174.raw = IntToF248_2(0).raw; + entInfo->unk174 -= IntToF248(12); + if (entInfo->unk174 < IntToF248(0)) { + entInfo->unk174 = IntToF248(0); } } } diff --git a/src/dungeon_monster_house.c b/src/dungeon_monster_house.c index c9958bc75..4ea690223 100644 --- a/src/dungeon_monster_house.c +++ b/src/dungeon_monster_house.c @@ -164,15 +164,15 @@ void TriggerMonsterHouse(Entity *entity, bool8 forcedMonsterHouse) if (sub_806AA0C(spawnStruct.species, 1)) { Entity *newMonster = SpawnWildMon(&spawnStruct, FALSE); if (EntityIsValid(newMonster)) { - newMonster->unk1C = IntToF248_2(200); + newMonster->unk1C = IntToF248(200); for (j = 0; j < 100; j++) { - newMonster->unk1C = s24_8_mul(newMonster->unk1C, IntToF248_2(0.665)); - if (newMonster->unk1C.raw < IntToF248_2(1).raw) { + newMonster->unk1C = s24_8_mul(newMonster->unk1C, IntToF248(0.665)); + if (newMonster->unk1C < IntToF248(1)) { break; } DungeonRunFrameActions(0x57); } - newMonster->unk1C = IntToF248_2(0); + newMonster->unk1C = IntToF248(0); } } } diff --git a/src/dungeon_move.c b/src/dungeon_move.c index decdf3a18..b4e03e5be 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -70,9 +70,9 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, Entity *currTargetSaved; Entity *currTarget; EntityInfo *targetInfo; - bool32 moveHits; - bool32 lightRodRedirect; - bool32 moveRedirected; + bool8 moveHits; + bool8 lightRodRedirect; + bool8 moveRedirected; moveId = move->id; for (i = 0; i < MAX_MOVE_TARGETS; i++) { @@ -86,7 +86,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, if (!EntityIsValid(attacker)) break; if (EntityIsValid(currTarget)) { - bool32 r4; + bool8 r4; bool8 moveHadEffect; originalAttacker = attacker; @@ -188,10 +188,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, } sub_806A1E8(currTarget); TrySendImmobilizeSleepEndMsg(attacker, currTarget); - r4 = FALSE; - if (!MoveMatchesBideClassStatus(attacker, move)) { - r4 = (MoveRequiresCharging(attacker, move->id) != 0); - } + r4 = (!MoveMatchesBideClassStatus(attacker, move) && MoveRequiresCharging(attacker, move->id)); if (!lightRodRedirect) { if (targetInfo->reflectClassStatus.status == STATUS_MAGIC_COAT) { @@ -275,7 +272,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, SetMessageArgument_2(gFormatBuffer_Monsters[1], GetEntInfo(currTarget), 0); // Interesting that these 3 strings are the same. Curious if that's the case in Blue/Europe versions. if (attacker == currTarget) { - TryDisplayDungeonLoggableMessage3(attacker, attacker, gUnknown_80F9380); // The move missed + TryDisplayDungeonLoggableMessage3(attacker, currTarget, gUnknown_80F9380); // The move missed } else if (GetTreatmentBetweenMonsters(attacker, currTarget, TRUE, FALSE) == 0) { TryDisplayDungeonLoggableMessage3(attacker, currTarget, gUnknown_80F9384); // The move missed @@ -304,9 +301,9 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, break; // breaks out of the loop } else { - s32 expMultiplierBeforeMove = targetInfo->expMultiplier; + u32 expMultiplierBeforeMove = targetInfo->expMultiplier; if (targetInfo->isNotTeamMember) { - if (move->id != MOVE_REGULAR_ATTACK && itemId == 0 && expMultiplierBeforeMove == EXP_HALVED) { + if (move->id != MOVE_REGULAR_ATTACK && itemId == 0 && expMultiplierBeforeMove < EXP_REGULAR) { targetInfo->expMultiplier = EXP_REGULAR; } if (isLinkedMove == TRUE) { @@ -392,13 +389,13 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, case MOVE_WIDE_SLASH: case MOVE_SPIN_SLASH: case MOVE_BLOOP_SLASH: - moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248_2(1), itemId) != 0); + moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248(1), itemId) != 0); break; case MOVE_REGULAR_ATTACK: - moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248_2(0.5), itemId) != 0); + moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248(0.5), itemId) != 0); break; case MOVE_NOTHING: - moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248_2(0), itemId) != 0); + moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248(0), itemId) != 0); break; case MOVE_EARTHQUAKE: moveHadEffect = EarthquakeMoveAction(attacker, currTarget, move, itemId); @@ -440,7 +437,7 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, case MOVE_CROSS_CHOP: case MOVE_RAZOR_LEAF: case MOVE_LEAF_BLADE: - moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248_2(1), itemId) != 0); + moveHadEffect = (HandleDamagingMove(attacker, currTarget, move, IntToF248(1), itemId) != 0); break; case MOVE_FISSURE: moveHadEffect = FissureMoveAction(attacker, currTarget, move, itemId); @@ -474,10 +471,10 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, moveHadEffect = PoisonStingMoveAction(attacker, currTarget, move, itemId); break; case MOVE_PSYCHIC: - moveHadEffect = sub_8058C98(attacker, currTarget, move, gStatIndexSpecial, itemId); + moveHadEffect = DamageLowerDefMoveAction(attacker, currTarget, move, gStatIndexSpecial, itemId); break; case MOVE_ACID: - moveHadEffect = sub_8058C98(attacker, currTarget, move, gStatIndexAtkDef, itemId); + moveHadEffect = DamageLowerDefMoveAction(attacker, currTarget, move, gStatIndexAtkDef, itemId); break; case MOVE_METAL_CLAW: moveHadEffect = MetalClawMoveAction(attacker, currTarget, move, gStatIndexAtkDef, itemId); @@ -1324,14 +1321,14 @@ void UseMoveAgainstTargets(Entity **targetsArray, Entity *attacker, Move *move, } if (EntityIsValid(attacker) && GetEntInfo(attacker)->unk155 != 0) { GetEntInfo(attacker)->unk155 = 0; - LowerAttackStageTarget(attacker, attacker, gStatIndexSpecial, 2, 0, FALSE); + LowerOffensiveStat(attacker, attacker, gStatIndexSpecial, 2, 0, FALSE); } } } bool8 HandleRegularDamagingMove(Entity *attacker, Entity *target, Move *move, s32 itemId) { - return (HandleDamagingMove(attacker, target, move, IntToF248_2(1), itemId) != 0); + return (HandleDamagingMove(attacker, target, move, IntToF248(1), itemId) != 0); } s32 HandleDamagingMove(Entity *attacker, Entity *target, Move *move, s24_8 modifier, s32 itemId) diff --git a/src/dungeon_move_util.c b/src/dungeon_move_util.c index 9f342f2de..f63311fe6 100644 --- a/src/dungeon_move_util.c +++ b/src/dungeon_move_util.c @@ -106,7 +106,7 @@ bool32 sub_8055A00(Entity *attacker, s32 firstMoveId, s32 var_34, s32 itemId, s3 break; if (currMove->id == MOVE_SNORE || currMove->id == MOVE_SLEEP_TALK) { - if (!IsSleeping(attacker)) { + if (!IsMonsterSleeping(attacker)) { if (CannotAttack(attacker, TRUE)) break; } @@ -241,11 +241,11 @@ void TriggerTargetAbilityEffect(Entity *attacker) } if (entInfo->abilityEffectFlags & ABILITY_FLAG_STATIC) { LogMessageByIdWithPopupCheckUser(attacker, gUnknown_80FEF0C); // Static caused paralysis! - ParalyzeStatusTarget(attacker, attacker, TRUE); + TryInflictParalysisStatus(attacker, attacker, TRUE); } if (entInfo->abilityEffectFlags & ABILITY_FLAG_EFFECT_SPORE_PRLZ) { LogMessageByIdWithPopupCheckUser(attacker, gUnknown_80FEF30); // Effect Spore scattered spores - ParalyzeStatusTarget(attacker, attacker, TRUE); + TryInflictParalysisStatus(attacker, attacker, TRUE); } if (entInfo->abilityEffectFlags & ABILITY_FLAG_POISON_POINT) { LogMessageByIdWithPopupCheckUser(attacker, gUnknown_80FEF4C); // Poison Point struck! @@ -406,7 +406,7 @@ bool8 TryUseChosenMove(struct Entity *attacker, u32 r6, s32 itemId, u32 var_30, entInfo = GetEntInfo(attacker); if (var_30 != 0 || move->id == MOVE_SNORE || move->id == MOVE_SLEEP_TALK) { - if (!IsSleeping(attacker) && CannotAttack(attacker, TRUE)) + if (!IsMonsterSleeping(attacker) && CannotAttack(attacker, TRUE)) break; } else { @@ -743,14 +743,14 @@ bool8 AccuracyCalc(Entity *attacker, Entity *target, Move *move, s32 accuracyTyp { s32 statStageAccuracy, statStageEvasion; s24_8 statStageMul; - s32 accuracy = GetMoveAccuracyOrAIChance(move, accuracyType); + s32 accuracy = GetMoveAccuracyOrAiChance(move, accuracyType); s32 rand = DungeonRandInt(100); EntityInfo *attackerInfo = GetEntInfo(attacker); EntityInfo *targetInfo = GetEntInfo(target); if (selfAlwaysHits && attacker == target) return TRUE; - if (move->id == MOVE_REGULAR_ATTACK && IQSkillIsEnabled(attacker, IQ_SURE_HIT_ATTACKER)) + if (move->id == MOVE_REGULAR_ATTACK && IqSkillIsEnabled(attacker, IQ_SURE_HIT_ATTACKER)) return TRUE; if (attackerInfo->sureShotClassStatus.status == STATUS_SURE_SHOT) return TRUE; @@ -762,7 +762,7 @@ bool8 AccuracyCalc(Entity *attacker, Entity *target, Move *move, s32 accuracyTyp if (HasHeldItem(target, ITEM_DETECT_BAND)) { accuracy -= gDetectBandAccuracyDebuffValue; } - if (IQSkillIsEnabled(target, IQ_QUICK_DODGER)) { + if (IqSkillIsEnabled(target, IQ_QUICK_DODGER)) { accuracy -= gIqQuickDodgerAccuracyDebuffValue; } @@ -784,10 +784,10 @@ bool8 AccuracyCalc(Entity *attacker, Entity *target, Move *move, s32 accuracyTyp if (statStageAccuracy > 20) statStageAccuracy = 20; statStageMul = gAccEvsStatStageMultipliers[0][statStageAccuracy]; - if (statStageMul.raw < 0) statStageMul.raw = 0; - if (statStageMul.raw > IntToF248_2(100).raw) statStageMul = IntToF248_2(100); + if (statStageMul < 0) statStageMul = 0; + if (statStageMul > IntToF248(100)) statStageMul = IntToF248(100); - accuracy *= statStageMul.raw; + accuracy *= statStageMul; accuracy /= 256; statStageEvasion = targetInfo->hitChanceStages[1]; @@ -808,10 +808,10 @@ bool8 AccuracyCalc(Entity *attacker, Entity *target, Move *move, s32 accuracyTyp if (statStageEvasion > 20) statStageEvasion = 20; statStageMul = gAccEvsStatStageMultipliers[1][statStageEvasion]; - if (statStageMul.raw < 0) statStageMul.raw = 0; - if (statStageMul.raw > IntToF248_2(100).raw) statStageMul = IntToF248_2(100); + if (statStageMul < 0) statStageMul = 0; + if (statStageMul > IntToF248(100)) statStageMul = IntToF248(100); - accuracy *= statStageMul.raw; + accuracy *= statStageMul; accuracy /= 256; if (rand < accuracy) return TRUE; @@ -829,7 +829,7 @@ void SetTargetsForMove(Entity **targetsArray, Entity *attacker, Move *move) || GetEntInfo(attacker)->cringeClassStatus.status == STATUS_COWERING); bool8 canHitSelf = (GetEntInfo(attacker)->cringeClassStatus.status == STATUS_CONFUSED || GetEntInfo(attacker)->cringeClassStatus.status == STATUS_COWERING); - if (IQSkillIsEnabled(attacker, IQ_NONTRAITOR)) { + if (IqSkillIsEnabled(attacker, IQ_NONTRAITOR)) { canHitSelf = FALSE; canHitPartner = FALSE; } diff --git a/src/dungeon_projectile_throw.c b/src/dungeon_projectile_throw.c index c39a2acb4..bcee44498 100644 --- a/src/dungeon_projectile_throw.c +++ b/src/dungeon_projectile_throw.c @@ -50,7 +50,7 @@ void HandleStraightProjectileThrow(Entity *thrower, Item *item, DungeonPos *pos, projectile->isVisible = TRUE; projectile->unk22 = 0; projectile->axObj.info.item = item; - projectile->unk1C.raw = 0; + projectile->unk1C = 0; projectile->pos = *pos; SetEntityPixelPos(projectile, (pos->x * 24 + 4) << 8, (pos->y * 24 + 0) << 8); @@ -241,7 +241,7 @@ void HandleCurvedProjectileThrow(Entity *thrower, Item *item, DungeonPos *startP projectile->isVisible = TRUE; projectile->unk22 = 0; projectile->axObj.info.item = item; - projectile->unk1C.raw = 0; + projectile->unk1C = 0; projectile->pos = *startPos; SetEntityPixelPos(projectile, (startPos->x * 24 + 4) << 8, (startPos->y * 24 + 4) << 8); @@ -305,7 +305,7 @@ void HandleCurvedProjectileThrow(Entity *thrower, Item *item, DungeonPos *startP displayX = posXFixed + 0x400; displayY = posYFixed + 0x400; - projectile->unk1C.raw = sinVal; + projectile->unk1C = sinVal; unkX = (posXFixed / 256) + 8; unkY = (posYFixed / 256) + 16; sinePhase += sinePhaseStep; diff --git a/src/dungeon_random.c b/src/dungeon_random.c index decde9674..115c1c1d8 100644 --- a/src/dungeon_random.c +++ b/src/dungeon_random.c @@ -88,7 +88,7 @@ s32 CalculateStatusTurns(Entity *target, const s16 *turnRange, bool8 factorCurer numTurns = DungeonRandRange(turnRange[0],turnRange[1]); if (EntityIsValid(target) && (GetEntityType(target) == ENTITY_MONSTER) && (factorCurerSkills)) { - if (IQSkillIsEnabled(target, IQ_SELF_CURER) && (numTurns != 0x7f)) { + if (IqSkillIsEnabled(target, IQ_SELF_CURER) && (numTurns != 0x7f)) { numTurns /= 2; } if (AbilityIsActive(target, ABILITY_NATURAL_CURE) && (numTurns != 0x7f) && (4 < numTurns)) { diff --git a/src/dungeon_range.c b/src/dungeon_range.c index 02b49c5ec..ca1c19840 100644 --- a/src/dungeon_range.c +++ b/src/dungeon_range.c @@ -13,96 +13,60 @@ EWRAM_INIT Entity *gLeaderPointer = NULL; -bool8 IsPositionActuallyInSight(DungeonPos *pos1, DungeonPos *pos2) +bool8 IsPositionActuallyInSight(DungeonPos *origin, DungeonPos *target) { - u8 pos1Room; - u8 visibility = gDungeon->unk181e8.visibilityRange; - const Tile *tile1; - if (visibility == 0) - { - visibility = 2; - } - tile1 = GetTile(pos1->x, pos1->y); - pos1Room = tile1->room; - if (pos1Room == CORRIDOR_ROOM) - { - s32 xDiff = pos1->x - pos2->x; - s32 yDiff; - xDiff = xDiff < 0 ? -xDiff : xDiff; - if (xDiff > visibility) - { - return FALSE; - } - - yDiff = pos1->y - pos2->y; - yDiff = yDiff < 0 ? -yDiff : yDiff; - if (yDiff > visibility) - { - return FALSE; - } - returnTrue: - return TRUE; + s32 visibility = GetVisibilityRange(); + const Tile *tile1 = GetTile(origin->x, origin->y); + u8 originRoom = tile1->room; + if (originRoom == CORRIDOR_ROOM) { + if (abs(origin->x - target->x) <= visibility && abs(origin->y - target->y) <= visibility) + return TRUE; } - else - { - struct RoomData *pos1RoomData = &gDungeon->roomData[pos1Room]; - if (pos1RoomData->bottomRightCornerX - 1 > pos2->x || pos1RoomData->bottomRightCornerY - 1 > pos2->y || - pos1RoomData->topLeftCornerX + 1 <= pos2->x || pos1RoomData->topLeftCornerY + 1 <= pos2->y) - { - return FALSE; - } - goto returnTrue; + else { + struct RoomData *originRoomData = &gDungeon->roomData[originRoom]; + if (originRoomData->bottomRightCornerX - 1 <= target->x && + originRoomData->bottomRightCornerY - 1 <= target->y && + originRoomData->topLeftCornerX + 1 > target->x && + originRoomData->topLeftCornerY + 1 > target->y) + return TRUE; } + + return FALSE; } -bool8 IsPositionInSight(DungeonPos *pos1, DungeonPos *pos2) +bool8 IsPositionInSight(DungeonPos *origin, DungeonPos *target) { - const Tile *tile; - u8 pos1Room; - s32 xDiff; - s32 yDiff; - s32 x1; - s32 x2; - s32 y1; - s32 y2; - - tile = GetTile(pos1->x,pos1->y); - pos1Room = tile->room; - if (pos1Room != CORRIDOR_ROOM) { - struct RoomData *pos1RoomData = &gDungeon->roomData[pos1Room]; - if (pos1RoomData->bottomRightCornerX - 1 > pos2->x || pos1RoomData->bottomRightCornerY - 1 > pos2->y || - pos1RoomData->topLeftCornerX + 1 <= pos2->x || pos1RoomData->topLeftCornerY + 1 <= pos2->y) - { - goto _08083394; - } - } - else - { -_08083394: - - x1 = pos1->x; - x2 = pos2->x; - - y1 = pos1->y; - y2 = pos2->y; - - yDiff = y1 - y2; - xDiff = x1 - x2; - - xDiff = xDiff < 0 ? -xDiff : xDiff; - yDiff = yDiff < 0 ? -yDiff : yDiff; + s32 diff; + const Tile *tile = GetTile(origin->x,origin->y); + u8 originRoom = tile->room; + if (originRoom != CORRIDOR_ROOM) { + struct RoomData *originRoomData = &gDungeon->roomData[originRoom]; + if (originRoomData->bottomRightCornerX - 1 <= target->x && + originRoomData->bottomRightCornerY - 1 <= target->y && + originRoomData->topLeftCornerX + 1 > target->x && + originRoomData->topLeftCornerY + 1 > target->y) + return TRUE; + } - if (yDiff < xDiff) { - yDiff = xDiff; + // This looks like a static inline / macro, but I can't get it right for both Red/Sky. See also HandleCurvedProjectileThrow + { + s32 x = origin->x - target->x; + s32 y = origin->y - target->y; + s32 absX = abs(x); + s32 absY = abs(y); + diff = max(absX, absY); } - if ((2 < yDiff)) -returnFalse: + + if (diff > 2) return FALSE; - else if((yDiff == 2) && (!IsTargetTwoTilesAway(pos1,pos2))) { - goto returnFalse; + else if (diff == 2) { + if (IsPositionWithinTwoTiles(origin, target)) + return TRUE; + else + return FALSE; } - } - return TRUE; + + return TRUE; } void sub_80833E8(DungeonPos *param_1, s32 *param_2) @@ -133,7 +97,7 @@ void sub_80833E8(DungeonPos *param_1, s32 *param_2) } } -bool8 IsTargetTwoTilesAway(DungeonPos *pos1, DungeonPos *pos2) +bool8 IsPositionWithinTwoTiles(DungeonPos *pos1, DungeonPos *pos2) { s32 i; const Tile *tile; diff --git a/src/dungeon_turn_effects.c b/src/dungeon_turn_effects.c index 8acbab2f6..5e9013cc5 100644 --- a/src/dungeon_turn_effects.c +++ b/src/dungeon_turn_effects.c @@ -87,7 +87,7 @@ void ApplyEndOfTurnEffects(Entity *entity) arrIndex = 0; if (HasHeldItem(entity, ITEM_STAMINA_BAND)) arrIndex--; - if (IQSkillIsEnabled(entity, IQ_ENERGY_SAVER)) + if (IqSkillIsEnabled(entity, IQ_ENERGY_SAVER)) arrIndex--; if (HasHeldItem(entity, ITEM_DIET_RIBBON)) arrIndex++; @@ -180,7 +180,7 @@ void ApplyEndOfTurnEffects(Entity *entity) // Abilities check rand = DungeonRandInt(100); - if (AbilityIsActive(entity, ABILITY_SHED_SKIN) && rand < gShedSkinActivateChance && HasNegativeStatus(entity)) { + if (AbilityIsActive(entity, ABILITY_SHED_SKIN) && rand < gShedSkinActivateChance && MonsterHasNegativeStatus(entity)) { DisplayActions(NULL); if (!EntityIsValid(entity) || IsFloorOver()) return; @@ -190,7 +190,7 @@ void ApplyEndOfTurnEffects(Entity *entity) entityInfo->speedBoostFrames++; if (entityInfo->speedBoostFrames >= gSpeedBoostActivationFrame) { entityInfo->speedBoostFrames = 0; - RaiseMovementSpeedTarget(entity, entity, 0x7F, FALSE); + BoostSpeed(entity, entity, 0x7F, FALSE); } } diff --git a/src/ground_link.c b/src/ground_link.c index 6c9667914..6419cd6dc 100644 --- a/src/ground_link.c +++ b/src/ground_link.c @@ -49,7 +49,7 @@ s32 GroundLink_GetArea(s32 _arg0, PixelPos *arg1, PixelPos *arg2, PixelPos *arg3 SetUnkInGroundEvent(&ptr->pos, arg1); - arg2->x = arg1->x + IntToF248(ptr->width * 8).raw; - arg2->y = arg1->y + IntToF248(ptr->height * 8).raw; + arg2->x = arg1->x + IntToF248(ptr->width * 8); + arg2->y = arg1->y + IntToF248(ptr->height * 8); return ptr->ret; } diff --git a/src/ground_script.c b/src/ground_script.c index 096cb8a6a..c8af437df 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -2172,7 +2172,7 @@ static s32 ExecuteScriptCommand(Action *action) break; } case 0x71: case 0x77: case 0x7d: case 0x83: { -#define HYPOT FP24_8_Hypot((s24_8){scriptData->pos2.x - scriptData->pos1.x}, (s24_8){scriptData->pos2.y - scriptData->pos1.y}).raw / curCmd.argShort +#define HYPOT FP24_8_Hypot((s24_8){scriptData->pos2.x - scriptData->pos1.x}, (s24_8){scriptData->pos2.y - scriptData->pos1.y}) / curCmd.argShort action->callbacks->getHitboxCenter(action->parentObject, &scriptData->pos1); scriptData->pos2.x = curCmd.arg1 << 8; scriptData->pos2.y = curCmd.arg2 << 8; diff --git a/src/hurl_orb.c b/src/hurl_orb.c index 7447ce24f..2519d2c89 100644 --- a/src/hurl_orb.c +++ b/src/hurl_orb.c @@ -168,7 +168,7 @@ void HandleHurlOrb(Entity *target, Entity *attacker) var_54.y += r10; UpdateEntityPixelPos(attacker, &var_54); if (ShouldDisplayEntity(attacker)) { - attacker->unk1C.raw = sin_4096(var_2C) << 5; + attacker->unk1C = sin_4096(var_2C) << 5; DungeonRunFrameActions(0x3B); if (!(i & 3)) { attackerDirection &= DIRECTION_MASK; @@ -181,7 +181,7 @@ void HandleHurlOrb(Entity *target, Entity *attacker) var_54.x = pixelPosX; var_54.y = pixelPosY; - attacker->unk1C.raw = 0; + attacker->unk1C = 0; UpdateEntityPixelPos(attacker, &var_54); DungeonRunFrameActions(0x3B); GetEntInfo(attacker)->action.direction = attackerDirection & DIRECTION_MASK; diff --git a/src/math.c b/src/math.c index ac9579759..3157b3dce 100644 --- a/src/math.c +++ b/src/math.c @@ -92,25 +92,25 @@ s24_8 s24_8_mul(s24_8 x, s24_8 y) bool8 sgn0; bool8 sgn1; - sgn0 = x.raw < 0; - sgn1 = y.raw < 0; + sgn0 = x < 0; + sgn1 = y < 0; - if (x.raw == 0) + if (x == 0) return (s24_8){0}; - if (y.raw == 0) + if (y == 0) return (s24_8){0}; if (sgn0) - x.raw = -x.raw; + x = -x; if (sgn1) - y.raw = -y.raw; + y = -y; ret = u24_8_mul(x, y); if (sgn0 != sgn1) - ret.raw = -ret.raw; + ret = -ret; return ret; } @@ -129,25 +129,25 @@ static s24_8 s24_8_div(s24_8 x, s24_8 y) bool8 sgn0; bool8 sgn1; - sgn0 = x.raw < 0; - sgn1 = y.raw < 0; + sgn0 = x < 0; + sgn1 = y < 0; - if (y.raw == 0) + if (y == 0) return (s24_8){INT32_MAX}; - if (x.raw == 0) + if (x == 0) return (s24_8){0}; if (sgn0) - x.raw = -x.raw; + x = -x; if (sgn1) - y.raw = -y.raw; + y = -y; ret = u24_8_div(x, y); if (sgn0 != sgn1) - ret.raw = -ret.raw; + ret = -ret; return ret; } @@ -171,13 +171,13 @@ static s24_8 u24_8_mul(s24_8 x, s24_8 y) u32 high_bit_mask; u32 round_up; - if (x.raw == 0 || y.raw == 0) + if (x == 0 || y == 0) return F248_ZERO; x_h = 0; - x_l = x.raw; + x_l = x; y_h = 0; - y_l = y.raw; + y_l = y; out_h = 0; out_l = 0; high_bit_mask = 0x80 << 24; // high bit of u32 @@ -240,15 +240,15 @@ static s24_8 u24_8_div(s24_8 x, s24_8 y) s32 sl; s32 temp; - if (y.raw == 0) + if (y == 0) return F248_MAX; - if (x.raw == 0) + if (x == 0) return F248_ZERO; - r7 = (u32)x.raw >> 24; - r6 = x.raw << 8; - sl = y.raw; + r7 = (u32)x >> 24; + r6 = x << 8; + sl = y; r9 = 0; r5 = 0; r4 = 0; @@ -323,19 +323,19 @@ s24_8 FP24_8_Hypot(s24_8 x, s24_8 y) r5 = x; r6 = y; - if (r5.raw < 0) - r5.raw = -r5.raw; + if (r5 < 0) + r5 = -r5; - if (r6.raw < 0) - r6.raw = -r6.raw; + if (r6 < 0) + r6 = -r6; - if (r5.raw < r6.raw) { + if (r5 < r6) { r4 = r5; r5 = r6; r6 = r4; } - if (r6.raw != 0) { + if (r6 != 0) { for (i = 2; i >= 0; i--) { r4 = s24_8_div(r6, r5); r4 = s24_8_mul(r4, r4); @@ -386,8 +386,8 @@ UNUSED s24_8 FP48_16_ToF248(s48_16 *a) void FP48_16_FromF248(s48_16 *a, s24_8 b) { - a->lo = b.raw << 8; - a->hi = b.raw >> 24; + a->lo = b << 8; + a->hi = b >> 24; if (a->hi & 0x80) a->hi |= ~0x7F; diff --git a/src/move_checks.c b/src/move_checks.c index 71fce7cfc..70eb4c3c4 100644 --- a/src/move_checks.c +++ b/src/move_checks.c @@ -17,6 +17,7 @@ #include "trap.h" #include "weather.h" #include "dungeon_config.h" +#include "structs/str_stat_index.h" bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) { @@ -51,13 +52,13 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) case MOVE_HOWL: case MOVE_MEDITATE: case MOVE_SHARPEN: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_BELLY_DRUM: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE || FixedPointToInt(pokemonInfo->belly) <= 0) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE || FixedPointToInt(pokemonInfo->belly) <= 0) { return FALSE; } @@ -68,13 +69,13 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) case MOVE_HARDEN: case MOVE_IRON_DEFENSE: case MOVE_WITHDRAW: - if (pokemonInfo->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_AMNESIA: - if (pokemonInfo->defensiveStages[STAT_STAGE_SP_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->defensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -100,7 +101,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_COSMIC_POWER: - if (pokemonInfo->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_STAGE_SP_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -130,7 +131,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_MINIMIZE: - if (pokemonInfo->hitChanceStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE) + if (pokemonInfo->hitChanceStages[STAT_INDEX_EVASION] >= MAX_STAT_STAGE) { return FALSE; } @@ -161,7 +162,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_BULK_UP: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -173,7 +174,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_TAIL_GLOW: - if (pokemonInfo->offensiveStages[STAT_STAGE_SP_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -197,7 +198,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_DRAGON_DANCE: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE && GetEntInfo(pokemon)->speedStage >= MAX_SPEED_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && GetEntInfo(pokemon)->speedStage >= MAX_SPEED_STAGE) { return FALSE; } @@ -258,7 +259,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_REST: - if (!HasLowHealth(pokemon) && !HasNegativeStatus(pokemon)) + if (!MonsterHasQuarterHp(pokemon) && !MonsterHasNegativeStatus(pokemon)) { return FALSE; } @@ -327,19 +328,19 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_DOUBLE_TEAM: - if (pokemonInfo->hitChanceStages[STAT_STAGE_EVASION] >= MAX_STAT_STAGE) + if (pokemonInfo->hitChanceStages[STAT_INDEX_EVASION] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_GROWTH: - if (pokemonInfo->offensiveStages[STAT_STAGE_SP_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } break; case MOVE_SWORDS_DANCE: - if (pokemonInfo->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -363,7 +364,7 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) } break; case MOVE_CALM_MIND: - if (pokemonInfo->offensiveStages[STAT_STAGE_SP_ATK] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_STAGE_SP_DEF] >= MAX_STAT_STAGE) + if (pokemonInfo->offensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE && pokemonInfo->defensiveStages[STAT_INDEX_SPECIAL] >= MAX_STAT_STAGE) { return FALSE; } @@ -405,11 +406,11 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) Entity *target = gDungeon->wildPokemon[i]; if (EntityIsValid(target) && target != pokemon && CanSeeTarget(pokemon, target)) { - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { continue; } - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_SP_ATK] < MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_SPECIAL] < MAX_STAT_STAGE) { break; } @@ -429,11 +430,11 @@ bool8 CanUseOnSelfWithStatusChecker(Entity *pokemon, Move *move) Entity *target = gDungeon->teamPokemon[i]; if (EntityIsValid(target) && target != pokemon && CanSeeTarget(pokemon, target)) { - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { continue; } - if (GetEntInfo(target)->offensiveStages[STAT_STAGE_SP_ATK] < MAX_STAT_STAGE) + if (GetEntInfo(target)->offensiveStages[STAT_INDEX_SPECIAL] < MAX_STAT_STAGE) { break; } @@ -466,7 +467,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) case MOVE_SING: case MOVE_SLEEP_POWDER: case MOVE_SPORE: - if (IsSleeping(target)) + if (IsMonsterSleeping(target)) { return FALSE; } @@ -476,7 +477,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) { return FALSE; } - if (IsSleeping(target)) + if (IsMonsterSleeping(target)) { return FALSE; } @@ -488,13 +489,13 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_SWEET_SCENT: - if (targetData->hitChanceStages[STAT_STAGE_EVASION] <= 0) + if (targetData->hitChanceStages[STAT_INDEX_EVASION] <= 0) { return FALSE; } break; case MOVE_CHARM: - if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_ATK], STAT_MULTIPLIER_THRESHOLD)) + if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_INDEX_PHYSICAL], STAT_MULTIPLIER_THRESHOLD)) { return FALSE; } @@ -536,13 +537,13 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_SCREECH: - if (F248LessThanFloat(targetData->defensiveMultipliers[STAT_STAGE_DEF], STAT_MULTIPLIER_THRESHOLD)) + if (F248LessThanFloat(targetData->defensiveMultipliers[STAT_INDEX_PHYSICAL], STAT_MULTIPLIER_THRESHOLD)) { return FALSE; } break; case MOVE_FAKE_TEARS: - if (targetData->defensiveStages[STAT_STAGE_SP_DEF] <= 0) + if (targetData->defensiveStages[STAT_INDEX_SPECIAL] <= 0) { return FALSE; } @@ -560,8 +561,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } break; case MOVE_MEMENTO: - if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_ATK], STAT_MULTIPLIER_THRESHOLD) && - F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_SP_ATK], STAT_MULTIPLIER_THRESHOLD)) + if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_INDEX_PHYSICAL], STAT_MULTIPLIER_THRESHOLD) && + F248LessThanFloat(targetData->offensiveMultipliers[STAT_INDEX_SPECIAL], STAT_MULTIPLIER_THRESHOLD)) { return FALSE; } @@ -581,7 +582,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) break; } } - if (targetData->hitChanceStages[STAT_STAGE_EVASION] <= DEFAULT_STAT_STAGE) + if (targetData->hitChanceStages[STAT_INDEX_EVASION] <= DEFAULT_STAT_STAGE) { return FALSE; } @@ -603,20 +604,20 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) break; case MOVE_LEER: case MOVE_TAIL_WHIP: - if (targetData->defensiveStages[STAT_STAGE_DEF] <= 0) + if (targetData->defensiveStages[STAT_INDEX_PHYSICAL] <= 0) { return FALSE; } break; case MOVE_METAL_SOUND: - if (targetData->defensiveStages[STAT_STAGE_SP_DEF] <= 0) + if (targetData->defensiveStages[STAT_INDEX_SPECIAL] <= 0) { return FALSE; } break; case MOVE_TICKLE: - if (targetData->offensiveStages[STAT_STAGE_ATK] <= 0 && - targetData->defensiveStages[STAT_STAGE_DEF] <= 0) + if (targetData->offensiveStages[STAT_INDEX_PHYSICAL] <= 0 && + targetData->defensiveStages[STAT_INDEX_PHYSICAL] <= 0) { return FALSE; } @@ -661,8 +662,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) if (userData->offensiveStages[i] < targetData->offensiveStages[i]) break; if (userData->defensiveStages[i] < targetData->defensiveStages[i] || userData->hitChanceStages[i] < targetData->hitChanceStages[i] || - userData->offensiveMultipliers[i].raw < targetData->offensiveMultipliers[i].raw || - userData->defensiveMultipliers[i].raw < targetData->defensiveMultipliers[i].raw) + userData->offensiveMultipliers[i] < targetData->offensiveMultipliers[i] || + userData->defensiveMultipliers[i] < targetData->defensiveMultipliers[i]) { break; } @@ -676,7 +677,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) case MOVE_FLASH: case MOVE_KINESIS: case MOVE_SAND_ATTACK: - if (targetData->hitChanceStages[STAT_STAGE_ACCURACY] <= 0) + if (targetData->hitChanceStages[STAT_INDEX_ACCURACY] <= 0) { return FALSE; } @@ -702,7 +703,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) break; case MOVE_FEATHERDANCE: case MOVE_GROWL: - if (targetData->offensiveStages[STAT_STAGE_ATK] <= 0) + if (targetData->offensiveStages[STAT_INDEX_PHYSICAL] <= 0) { return FALSE; } @@ -724,8 +725,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move) } else { - if (userData->offensiveStages[STAT_STAGE_ATK] >= MAX_STAT_STAGE && - userData->defensiveStages[STAT_STAGE_DEF] >= MAX_STAT_STAGE) + if (userData->offensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE && + userData->defensiveStages[STAT_INDEX_PHYSICAL] >= MAX_STAT_STAGE) { return FALSE; } diff --git a/src/move_orb_actions_1.c b/src/move_orb_actions_1.c index 872e358f0..f2e979ae2 100644 --- a/src/move_orb_actions_1.c +++ b/src/move_orb_actions_1.c @@ -38,21 +38,26 @@ #include "move_orb_effects_4.h" #include "move_orb_effects_5.h" +const StatIndex gStatIndexAtkDef = {.id = STAT_INDEX_PHYSICAL}; +const StatIndex gStatIndexSpecial = {.id = STAT_INDEX_SPECIAL}; + bool8 IronTailMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if (HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon, target, gIronTailSecondaryChance)) { - LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE); + LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE); } } return flag; } -static const s24_8 sRolloutModifiers[]; +static const s24_8 sRolloutModifiers[] = { + IntToF248(1.0), IntToF248(1.0), IntToF248(1.5), IntToF248(2.0), IntToF248(2.5), IntToF248(3.0), IntToF248(3.5), IntToF248(4.0), IntToF248(4.5), IntToF248(5.0) +}; bool8 sub_805768C(Entity *pokemon, Entity *target, Move *move, s32 itemId) { @@ -124,13 +129,13 @@ bool8 DigMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId) bool8 SweetScentMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerAccuracyStageTarget(pokemon,target,gStatIndexSpecial,TRUE); + LowerHitChanceStat(pokemon,target,gStatIndexSpecial,TRUE); return TRUE; } bool8 CharmMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - ChangeAttackMultiplierTarget(pokemon,target,gStatIndexAtkDef,FloatToF248(0.5),TRUE); + ApplyOffensiveStatMultiplier(pokemon,target,gStatIndexAtkDef,IntToF248(0.5),TRUE); return TRUE; } @@ -165,10 +170,10 @@ bool8 BubbleMoveAction(Entity *pokemon, Entity *target, Move * move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if (HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target, gBubbleSecondaryChance)) { - LowerMovementSpeedTarget(pokemon, target, 1, FALSE); + LowerSpeed(pokemon, target, 1, FALSE); } } return flag; @@ -288,14 +293,14 @@ bool8 TormentMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 StringShotMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerMovementSpeedTarget(pokemon, target, 1, TRUE); + LowerSpeed(pokemon, target, 1, TRUE); return TRUE; } bool8 SwaggerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { ConfuseStatusTarget(pokemon, target, TRUE); - RaiseAttackStageTarget(pokemon, target, gStatIndexAtkDef, 2); + BoostOffensiveStat(pokemon, target, gStatIndexAtkDef, 2); return TRUE; } @@ -304,11 +309,11 @@ bool8 SnoreMoveAction(Entity *pokemon, Entity *target, Move * move, s32 itemId) bool8 flag; flag = FALSE; - if (IsSleeping(pokemon)) { - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (IsMonsterSleeping(pokemon)) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gSnoreSecondaryChance)) { - CringeStatusTarget(pokemon,target,FALSE); + TryInflictCringeStatus(pokemon,target,FALSE); } } } @@ -320,7 +325,7 @@ bool8 SnoreMoveAction(Entity *pokemon, Entity *target, Move * move, s32 itemId) bool8 ScreechMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - ChangeDefenseMultiplierTarget(pokemon, target, gStatIndexAtkDef, FloatToF248(0.25), 1); + ApplyDefensiveStatMultiplier(pokemon, target, gStatIndexAtkDef, IntToF248(0.25), 1); return TRUE; } @@ -329,27 +334,19 @@ bool8 RockSlideMoveAction(Entity *pokemon, Entity *target, Move * move, s32 item bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if (HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gRockSlideSecondaryChance)) { - CringeStatusTarget(pokemon,target,FALSE); + TryInflictCringeStatus(pokemon,target,FALSE); } } return flag; } -bool32 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId) +bool8 WeatherBallMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId) { - u32 weather; - s32 flag; - - weather = GetApparentWeather(pokemon); - flag = sub_80556BC(pokemon,target,gWeatherBallTypes[weather],move, - gWeatherBallModifiers[weather],itemId); - if (flag) { - flag = TRUE; - } - return flag; + u32 weather = GetApparentWeather(pokemon); + return (sub_80556BC(pokemon,target,gWeatherBallTypes[weather],move,gWeatherBallModifiers[weather],itemId) != 0); } bool8 WhirlpoolMoveAction(Entity * pokemon, Entity * target, Move * move, s32 itemId) @@ -360,9 +357,9 @@ bool8 WhirlpoolMoveAction(Entity * pokemon, Entity * target, Move * move, s32 it flag = FALSE; chargeStatus = GetEntInfo(target)->bideClassStatus.status; - modifier = IntToF248_2(1); + modifier = IntToF248(1); if (chargeStatus == STATUS_DIVING) { - modifier = IntToF248_2(2); + modifier = IntToF248(2); } if (HandleDamagingMove(pokemon,target,move,modifier,itemId) != 0) { flag = TRUE; @@ -375,7 +372,7 @@ bool8 WhirlpoolMoveAction(Entity * pokemon, Entity * target, Move * move, s32 it bool8 FakeTearsMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId) { - LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 2, 1, TRUE); + LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 2, 1, TRUE); return TRUE; } @@ -431,7 +428,7 @@ bool8 OverheatMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId flag = FALSE; entityInfo = GetEntInfo(pokemon); SendThawedMessage(pokemon,target); - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if (RollSecondaryEffect(pokemon, 0)) { entityInfo->unk155 = 1; @@ -445,11 +442,11 @@ bool8 AuroraBeamMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gAuroraBeamAtkLowerChance)) { - ChangeAttackMultiplierTarget(pokemon, target, gStatIndexAtkDef, FloatToF248(0.5), FALSE); + ApplyOffensiveStatMultiplier(pokemon, target, gStatIndexAtkDef, IntToF248(0.5), FALSE); } } return flag; @@ -461,8 +458,8 @@ bool8 MementoMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) entityInfo = GetEntInfo(pokemon); entityInfo->HP = 1; - ChangeAttackMultiplierTarget(pokemon,target,gStatIndexAtkDef,FloatToF248(0.25),TRUE); - ChangeAttackMultiplierTarget(pokemon,target,gStatIndexSpecial,FloatToF248(0.25),TRUE); + ApplyOffensiveStatMultiplier(pokemon,target,gStatIndexAtkDef,IntToF248(0.25),TRUE); + ApplyOffensiveStatMultiplier(pokemon,target,gStatIndexSpecial,IntToF248(0.25),TRUE); entityInfo->unk154 = 1; return TRUE; } @@ -472,11 +469,11 @@ bool8 OctazookaMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gOctazookaAccLowerChance)) { - LowerAccuracyStageTarget(pokemon, target, gStatIndexAtkDef, FALSE); + LowerHitChanceStat(pokemon, target, gStatIndexAtkDef, FALSE); } } return flag; @@ -485,7 +482,7 @@ bool8 OctazookaMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 FlatterMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { ConfuseStatusTarget(pokemon, target, TRUE); - RaiseAttackStageTarget(pokemon, target, gStatIndexSpecial, 1); + BoostOffensiveStat(pokemon, target, gStatIndexSpecial, 1); return TRUE; } @@ -562,7 +559,7 @@ bool8 FlameWheelMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item flag = FALSE; SendThawedMessage(pokemon, target); - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gFlameWheelSecondaryChance)) { @@ -579,7 +576,7 @@ bool8 BasicFireMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI flag = FALSE; SendThawedMessage(pokemon, target); - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gFireMoveBurnSecondaryChance)) { @@ -599,7 +596,7 @@ bool8 ExposeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 DoubleTeamMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseAccuracyStageTarget(pokemon, target, gStatIndexSpecial); + BoostHitChanceStat(pokemon, target, gStatIndexSpecial); return TRUE; } @@ -613,27 +610,27 @@ bool8 GustMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) targetInfo = GetEntInfo(target); if(targetInfo->bideClassStatus.status == STATUS_FLYING || targetInfo->bideClassStatus.status == STATUS_BOUNCING) modifierInt = 2; - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(modifierInt),itemId) ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon,target,move,IntToF248(modifierInt),itemId) ? TRUE : FALSE; return flag; } // NOTE: Is there a better name for this? bool8 BasicRaiseDefenseMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1); + BoostDefensiveStat(pokemon, target, gStatIndexAtkDef, 1); return TRUE; } bool8 DisableMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - ParalyzeStatusTarget(pokemon, target, TRUE); + TryInflictParalysisStatus(pokemon, target, TRUE); return TRUE; } // NOTE: Is there a better name for this? bool8 BasicRaiseAttackMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1); + BoostOffensiveStat(pokemon, target, gStatIndexAtkDef, 1); return TRUE; } @@ -679,11 +676,11 @@ bool8 ShadowBallMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gShadowBallSecondaryChance)) { - LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 1, 1, FALSE); + LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 1, 1, FALSE); } } return flag; @@ -694,11 +691,11 @@ bool8 BiteMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gBiteSecondaryChance)) { - CringeStatusTarget(pokemon, target, FALSE); + TryInflictCringeStatus(pokemon, target, FALSE); } } return flag; @@ -709,11 +706,11 @@ bool8 ThunderMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gThunderSecondaryChance)) { - ParalyzeStatusTarget(pokemon, target, FALSE); + TryInflictParalysisStatus(pokemon, target, FALSE); } } return flag; @@ -745,7 +742,7 @@ bool8 FacadeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; s24_8 modifier; - modifier = IntToF248_2(1); + modifier = IntToF248(1); if((GetEntInfo(pokemon)->burnClassStatus.status) != STATUS_NONE) modifier = gFacadeModifier; flag = HandleDamagingMove(pokemon,target,move,modifier,itemId) ? TRUE : FALSE; @@ -757,11 +754,11 @@ bool8 sub_8058580(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gConstrictBubblebeamSecondaryChance)) { - LowerMovementSpeedTarget(pokemon, target, 1, FALSE); + LowerSpeed(pokemon, target, 1, FALSE); } } return flag; @@ -778,7 +775,7 @@ bool8 BrickBreakMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item flag = TRUE; } - flag |= (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0); + flag |= (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0); return flag; } @@ -787,11 +784,11 @@ bool8 RockTombMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, 0)) { - LowerMovementSpeedTarget(pokemon, target, 1, FALSE); + LowerSpeed(pokemon, target, 1, FALSE); } } return flag; @@ -821,7 +818,7 @@ bool8 GigaDrainMoveAction(Entity * pokemon, Entity * target, Move * move, s32 it EntityInfo *entityInfo; hasLiquidOoze = AbilityIsActive(target, ABILITY_LIQUID_OOZE); - uVar3 = HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId); + uVar3 = HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId); flag = uVar3 != 0 ? TRUE : FALSE; if (flag && RollSecondaryEffect(pokemon, 0)) { newHP = uVar3 / 2; @@ -869,26 +866,25 @@ bool8 SmellingSaltMoveAction(Entity * pokemon, Entity * target, Move * move, s32 bool8 flag; if (GetEntInfo(target)->burnClassStatus.status == STATUS_PARALYSIS) { - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(2),itemId) ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon,target,move,IntToF248(2),itemId) ? TRUE : FALSE; EndBurnClassStatus(pokemon, target); } else { - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) ? TRUE : FALSE; } return flag; } bool8 MetalSoundMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 3, 1, TRUE); + LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 3, 1, TRUE); return TRUE; } bool8 TickleMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - s32 index = gStatIndexAtkDef; - LowerAttackStageTarget(pokemon, target, index, 1, 1, TRUE); - LowerDefenseStageTarget(pokemon, target, index, 1, 1, TRUE); + LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); + LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); return TRUE; } @@ -907,7 +903,7 @@ bool8 HazeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 OutrageMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { bool8 flag = FALSE; - if(HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) + if(HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if(RollSecondaryEffect(pokemon, 0)) @@ -924,7 +920,7 @@ bool8 LowKickMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; EntityInfo *entityInfo = GetEntInfo(target); - weight.raw = GetWeight(entityInfo->apparentID); + weight = GetWeight(entityInfo->apparentID); flag = HandleDamagingMove(pokemon, target, move, weight, itemId) != 0 ? TRUE: FALSE; return flag; } @@ -933,21 +929,17 @@ bool8 AncientPowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it { bool8 flag = FALSE; EntityInfo *entityInfo; - s32 index1; - s32 index2; - if(HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) + if(HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if(RollSecondaryEffect(pokemon, gAncientPowerSecondaryChance)) { entityInfo = GetEntInfo(pokemon); - RaiseMovementSpeedTarget(pokemon, pokemon, 0, TRUE); - index1 = gStatIndexAtkDef; - RaiseAttackStageTarget(pokemon, pokemon, index1, 1); - index2 = gStatIndexSpecial; - RaiseAttackStageTarget(pokemon, pokemon, index2, 1); - RaiseDefenseStageTarget(pokemon, pokemon, index1, 1); - RaiseDefenseStageTarget(pokemon, pokemon, index2, 1); + BoostSpeed(pokemon, pokemon, 0, TRUE); + BoostOffensiveStat(pokemon, pokemon, gStatIndexAtkDef, 1); + BoostOffensiveStat(pokemon, pokemon, gStatIndexSpecial, 1); + BoostDefensiveStat(pokemon, pokemon, gStatIndexAtkDef, 1); + BoostDefensiveStat(pokemon, pokemon, gStatIndexSpecial, 1); SetExpMultplier(entityInfo); } } @@ -962,14 +954,14 @@ bool8 SynthesisMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 AgilityMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseMovementSpeedTarget(pokemon, target, 0, TRUE); + BoostSpeed(pokemon, target, 0, TRUE); return TRUE; } bool8 RapidSpinMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { bool8 flag = FALSE; - if(HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) + if(HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if(RollSecondaryEffect(pokemon, 0)) @@ -988,15 +980,7 @@ bool8 SureShotMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId bool8 CosmicPowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1); - RaiseDefenseStageTarget(pokemon, target, gStatIndexSpecial, 1); + BoostDefensiveStat(pokemon, target, gStatIndexAtkDef, 1); + BoostDefensiveStat(pokemon, target, gStatIndexSpecial, 1); return TRUE; } - -// Put all the way below for matching. -const s32 gStatIndexAtkDef = 0; -const s32 gStatIndexSpecial = 1; - -static const s24_8 sRolloutModifiers[] = { - IntToF248_2(1.0), IntToF248_2(1.0), IntToF248_2(1.5), IntToF248_2(2.0), IntToF248_2(2.5), IntToF248_2(3.0), IntToF248_2(3.5), IntToF248_2(4.0), IntToF248_2(4.5), IntToF248_2(5.0) -}; diff --git a/src/move_orb_actions_2.c b/src/move_orb_actions_2.c index 3e16b214d..9332480c6 100644 --- a/src/move_orb_actions_2.c +++ b/src/move_orb_actions_2.c @@ -51,7 +51,7 @@ bool8 SkyAttackMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI if (HandleDamagingMove(pokemon, target, move, gSkyAttackModifier, itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gSkyAttackSecondaryChance)) - CringeStatusTarget(pokemon, target, FALSE); + TryInflictCringeStatus(pokemon, target, FALSE); } sub_8079764(pokemon); } @@ -68,7 +68,7 @@ bool8 BasicIceMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gIceMoveFreezeSecondaryChance)) { @@ -84,12 +84,12 @@ bool8 MeteorMashMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item EntityInfo *entityInfo; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, pokemon, gMeteorMashSecondaryChance)) { entityInfo = GetEntInfo(pokemon); - RaiseAttackStageTarget(pokemon, pokemon, gStatIndexAtkDef, 1); + BoostOffensiveStat(pokemon, pokemon, gStatIndexAtkDef, 1); SetExpMultplier(entityInfo); } } @@ -104,7 +104,7 @@ bool8 EndureMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 ScaryFaceMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerMovementSpeedTarget(pokemon, target, 1, TRUE); + LowerSpeed(pokemon, target, 1, TRUE); return TRUE; } @@ -113,7 +113,7 @@ bool8 sub_8058C00(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gMovesConfusionSecondaryChance)) { @@ -140,16 +140,16 @@ bool8 PsywaveMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) return flag; } -bool8 sub_8058C98(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 param_5) +bool8 DamageLowerDefMoveAction(Entity *pokemon, Entity *target, Move *move, StatIndex stat, u32 param_5) { bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),param_5) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),param_5) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gPsychicSecondaryChance)) { - LowerDefenseStageTarget(pokemon, target, itemId, 1, 1, FALSE); + LowerDefensiveStat(pokemon, target, stat, 1, 1, FALSE); } } return flag; @@ -158,12 +158,12 @@ bool8 sub_8058C98(Entity *pokemon, Entity *target, Move *move, s32 itemId, u32 p bool8 PsychoBoostMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { bool8 flag = FALSE; - if(HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) + if(HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if(RollSecondaryEffect(pokemon, 0)) { - LowerAttackStageTarget(pokemon, pokemon, gStatIndexSpecial, 2, 0, FALSE); + LowerOffensiveStat(pokemon, pokemon, gStatIndexSpecial, 2, 0, FALSE); } } return flag; @@ -229,7 +229,7 @@ bool8 sub_8058E5C(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if ((HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) && (EntityIsValid(pokemon))) { + if ((HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) && (EntityIsValid(pokemon))) { iVar2 = GetEntInfo(pokemon)->maxHPStat; if (iVar2 < 0) { iVar2 = iVar2 + 7; @@ -252,9 +252,8 @@ bool8 sub_8058EE0(Entity *pokemon, Entity *target, Move *move, s32 itemId) return TRUE; } -bool32 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) +bool8 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - bool32 flag; EntityInfo *entityInfo; s32 modifierInt; @@ -265,11 +264,8 @@ bool32 EarthquakeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite if (entityInfo->bideClassStatus.status == STATUS_DIGGING) { modifierInt = 2; } - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(modifierInt),itemId); - if (flag != 0) { - flag = TRUE; - } - return flag; + + return (HandleDamagingMove(pokemon,target,move,IntToF248(modifierInt),itemId) != 0); } bool8 NaturePowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) @@ -295,11 +291,11 @@ bool8 LickMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gLickSecondaryChance)) { - ParalyzeStatusTarget(pokemon, target, FALSE); + TryInflictParalysisStatus(pokemon, target, FALSE); } } return flag; @@ -313,7 +309,7 @@ bool8 SelfDestructMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it bool8 StunSporeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - ParalyzeStatusTarget(pokemon, target, TRUE); + TryInflictParalysisStatus(pokemon, target, TRUE); return TRUE; } @@ -328,11 +324,11 @@ bool8 ThunderboltMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gThunderboltSecondaryChance)) { - ParalyzeStatusTarget(pokemon, target, FALSE); + TryInflictParalysisStatus(pokemon, target, FALSE); } } return flag; @@ -373,11 +369,11 @@ bool8 ExtrasensoryMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gExtrasensorySecondaryChance)) { - CringeStatusTarget(pokemon, target, FALSE); + TryInflictCringeStatus(pokemon, target, FALSE); } } return flag; @@ -398,7 +394,7 @@ bool8 AbsorbMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) flag = FALSE; hasLiquidOoze = AbilityIsActive(target, ABILITY_LIQUID_OOZE); - iVar3 = HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId); + iVar3 = HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId); if (iVar3 != 0) { iVar4 = iVar3 / 2; if (iVar4 < 1) { @@ -496,11 +492,11 @@ bool8 HeadbuttMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gHeadbuttSecondaryChance)) { - CringeStatusTarget(pokemon, target, FALSE); + TryInflictCringeStatus(pokemon, target, FALSE); } } return flag; @@ -512,7 +508,7 @@ bool8 DoubleEdgeMoveAction(Entity * pokemon,Entity * target,Move * move,s32 item bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if (HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if ((!AbilityIsActive(pokemon, ABILITY_ROCK_HEAD)) && (RollSecondaryEffect(pokemon,0) != 0)) { HP = GetEntInfo(pokemon)->maxHPStat; @@ -541,7 +537,7 @@ bool8 SandstormMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 sub_8059528(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerAccuracyStageTarget(pokemon, target, gStatIndexAtkDef, TRUE); + LowerHitChanceStat(pokemon, target, gStatIndexAtkDef, TRUE); return TRUE; } @@ -550,7 +546,7 @@ bool8 SmogMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gSmogSecondaryChance)) { @@ -562,7 +558,7 @@ bool8 SmogMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 GrowthMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseAttackStageTarget(pokemon, target, gStatIndexSpecial, 1); + BoostOffensiveStat(pokemon, target, gStatIndexSpecial, 1); return TRUE; } @@ -571,7 +567,7 @@ bool8 SacredFireMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gSacredFireSecondaryChance)) { @@ -609,7 +605,7 @@ bool8 SolarBeamMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemI modifier = gSolarBeamModifier; if (((weather == WEATHER_SANDSTORM) || (weather == WEATHER_RAIN)) || weather == WEATHER_HAIL) { - modifier.raw /= 2; + modifier /= 2; } weather = HandleDamagingMove(pokemon,target,move,modifier,itemId) != 0 ? TRUE : FALSE; sub_8079764(pokemon); @@ -677,11 +673,11 @@ bool8 MuddyWaterMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gMuddyWaterAccLowerChance)) { - LowerAccuracyStageTarget(pokemon, target, gStatIndexAtkDef, FALSE); + LowerHitChanceStat(pokemon, target, gStatIndexAtkDef, FALSE); } } return flag; @@ -702,11 +698,11 @@ bool8 TwisterMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemId) if (entInfo->bideClassStatus.status == STATUS_FLYING || entInfo->bideClassStatus.status == STATUS_BOUNCING) { modifierInt = 2; } - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(modifierInt),itemId) != 0) + if (HandleDamagingMove(pokemon,target,move,IntToF248(modifierInt),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon,target,gTwisterSecondaryChance) != 0) { - CringeStatusTarget(pokemon,target,FALSE); + TryInflictCringeStatus(pokemon,target,FALSE); } } return flag; @@ -717,7 +713,7 @@ bool8 TwineedleMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemI bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; gUnknown_202F218 = 1; } @@ -741,7 +737,7 @@ bool8 sub_80599EC(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 MinimizeMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseAccuracyStageTarget(pokemon, target, gStatIndexSpecial); + BoostHitChanceStat(pokemon, target, gStatIndexSpecial); return TRUE; } @@ -793,7 +789,7 @@ bool8 HornDrillMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemI bool8 SwordsDanceMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseAttackStageTarget(pokemon, target, gStatIndexAtkDef, 2); + BoostOffensiveStat(pokemon, target, gStatIndexAtkDef, 2); return TRUE; } @@ -856,8 +852,8 @@ bool8 HelpingHandMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite TryDisplayDungeonLoggableMessage3(target, target, gUnknown_80FEB60); } else { - RaiseAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1); - RaiseAttackStageTarget(pokemon, target, gStatIndexSpecial, 1); + BoostOffensiveStat(pokemon, target, gStatIndexAtkDef, 1); + BoostOffensiveStat(pokemon, target, gStatIndexSpecial, 1); flag = TRUE; } return flag; @@ -865,7 +861,7 @@ bool8 HelpingHandMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite bool8 sub_8059CD8(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 2); + BoostDefensiveStat(pokemon, target, gStatIndexAtkDef, 2); return TRUE; } @@ -880,11 +876,11 @@ bool8 ThundershockMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gThundershockSecondaryChance)) { - ParalyzeStatusTarget(pokemon, target, FALSE); + TryInflictParalysisStatus(pokemon, target, FALSE); } } return flag; @@ -892,7 +888,7 @@ bool8 ThundershockMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it bool8 ThunderWaveMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - ParalyzeStatusTarget(pokemon, target, TRUE); + TryInflictParalysisStatus(pokemon, target, TRUE); return TRUE; } @@ -901,11 +897,11 @@ bool8 ZapCannonMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, 0)) { - ParalyzeStatusTarget(pokemon, target, FALSE); + TryInflictParalysisStatus(pokemon, target, FALSE); } } return flag; @@ -934,7 +930,7 @@ bool8 PoisonFangMoveAction(Entity *pokemon, Entity *target, Move *move, s32 item bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gPoisonFangSecondaryChance)) { diff --git a/src/move_orb_actions_3.c b/src/move_orb_actions_3.c index fb430e705..569d8bc93 100644 --- a/src/move_orb_actions_3.c +++ b/src/move_orb_actions_3.c @@ -56,7 +56,7 @@ bool8 PoisonStingMoveAction(Entity *pokemon, Entity *target, Move *move, s32 ite bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gPoisonStingSecondaryChance)) { @@ -77,13 +77,13 @@ bool8 JumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemId flag = FALSE; if (param_5 == 0) { - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0 ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0 ? TRUE : FALSE; } if (!flag) { moveType = GetMoveTypeForMonster(pokemon,move); movePower = GetMovePower(pokemon,move); moveCritChance = GetMoveCritChance(move); - CalcDamage(pokemon,target,moveType,movePower,moveCritChance,&dmgStruct, IntToF248_2(1),move->id,0); + CalcDamage(pokemon,target,moveType,movePower,moveCritChance,&dmgStruct, IntToF248(1),move->id,0); SetMessageArgument_2(gFormatBuffer_Monsters[0],GetEntInfo(pokemon),0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC7C8); dmgStruct.dmg /= 2; @@ -104,7 +104,7 @@ bool8 BounceMoveAction(Entity * pokemon,Entity * target,Move * move,s32 itemId) if (HandleDamagingMove(pokemon, target, move, gBounceModifier, itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon, target, gBounceSecondaryChance) != 0) { - ParalyzeStatusTarget(pokemon, target, FALSE); + TryInflictParalysisStatus(pokemon, target, FALSE); } } sub_8079764(pokemon); @@ -127,13 +127,13 @@ bool8 HiJumpKickMoveAction(Entity * pokemon,Entity * target,Move * move,s32 item flag = FALSE; if (param_5 == 0) { - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(2),itemId) != 0 ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon,target,move,IntToF248(2),itemId) != 0 ? TRUE : FALSE; } if (!flag) { moveType = GetMoveTypeForMonster(pokemon,move); movePower = GetMovePower(pokemon,move); moveCritChance = GetMoveCritChance(move); - CalcDamage(pokemon,target,moveType,movePower,moveCritChance,&dmgStruct,IntToF248_2(2),move->id,0); + CalcDamage(pokemon,target,moveType,movePower,moveCritChance,&dmgStruct,IntToF248(2),move->id,0); SetMessageArgument_2(gFormatBuffer_Monsters[0],GetEntInfo(pokemon),0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC7C8); dmgStruct.dmg /= 2; @@ -150,7 +150,7 @@ bool8 TriAttackMoveAction(Entity * pokemon, Entity * target, Move *move, s32 ite bool8 flag; flag = FALSE; - if(HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId)) + if(HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId)) { flag = TRUE; if(sub_805727C(pokemon, target, gTriAttackSecondaryChance)) @@ -159,7 +159,7 @@ bool8 TriAttackMoveAction(Entity * pokemon, Entity * target, Move *move, s32 ite { case 0: default: - ParalyzeStatusTarget(pokemon, target, FALSE); + TryInflictParalysisStatus(pokemon, target, FALSE); break; case 1: BurnedStatusTarget(pokemon, target, 0, FALSE); @@ -234,7 +234,7 @@ bool8 TripleKickMoveAction(Entity * pokemon, Entity * target, Move *move, s32 it bool8 flag; gUnknown_202F210++; - flag = HandleDamagingMove(pokemon, target, move, IntToF248_2(gUnknown_202F210), itemId) ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon, target, move, IntToF248(gUnknown_202F210), itemId) ? TRUE : FALSE; return flag; } @@ -256,11 +256,11 @@ bool8 MudSlapMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, 0)) { - LowerAccuracyStageTarget(pokemon, target, gStatIndexAtkDef, FALSE); + LowerHitChanceStat(pokemon, target, gStatIndexAtkDef, FALSE); } } return flag; @@ -273,13 +273,13 @@ bool8 ThiefMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 AmnesiaMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - RaiseDefenseStageTarget(pokemon, target, gStatIndexSpecial, 2); + BoostDefensiveStat(pokemon, target, gStatIndexSpecial, 2); return TRUE; } bool8 GrowlMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); + LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); return TRUE; } @@ -291,12 +291,12 @@ bool8 SurfMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) flag = FALSE; if (GetEntInfo(target)->bideClassStatus.status == STATUS_DIVING) { - modifierInt = IntToF248_2(2).raw; + modifierInt = IntToF248(2); } else { - modifierInt = IntToF248_2(1).raw; + modifierInt = IntToF248(1); } - modifier.raw = modifierInt; + modifier = modifierInt; if(HandleDamagingMove(pokemon,target,move,modifier,itemId) != 0) flag = TRUE; return flag; @@ -336,7 +336,7 @@ bool8 SunnyDayMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId bool8 LeerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); + LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, TRUE); return TRUE; } @@ -351,11 +351,11 @@ bool8 FakeOutMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gFakeOutSecondaryChance)) { - CringeStatusTarget(pokemon, target, FALSE); + TryInflictCringeStatus(pokemon, target, FALSE); } } return flag; @@ -374,7 +374,7 @@ bool8 PayDayMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) DungeonPos pos; flag = FALSE; - if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if (HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (RollSecondaryEffect(pokemon, 0) != 0) { if (!EntityIsValid(target)) { @@ -431,38 +431,36 @@ bool8 sub_805A568(Entity * pokemon, Entity * target, Move *move, s32 itemId) { bool8 flag; - flag = HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) ? TRUE : FALSE; return flag; } bool8 SuperpowerMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - u32 stat; bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if (HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,pokemon,0) != 0) { - stat = gStatIndexAtkDef; - LowerAttackStageTarget(pokemon,pokemon,stat,1,0,FALSE); - LowerDefenseStageTarget(pokemon,pokemon,stat,1,0,FALSE); + LowerOffensiveStat(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE); + LowerDefensiveStat(pokemon,pokemon,gStatIndexAtkDef,1,0,FALSE); } } return flag; } -bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, s32 stat, u32 param_5) +bool8 SteelWingMoveAction(Entity *pokemon, Entity *target, Move *move, StatIndex stat, u32 param_5) { EntityInfo *entityInfo; bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),param_5) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),param_5) != 0) { flag = TRUE; if (sub_805727C(pokemon,pokemon,gSteelWingSecondaryChance) != 0) { entityInfo = GetEntInfo(pokemon); - RaiseDefenseStageTarget(pokemon,pokemon,stat,1); + BoostDefensiveStat(pokemon,pokemon,stat,1); SetExpMultplier(entityInfo); } } @@ -475,7 +473,7 @@ bool8 SpitUpMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) stockpileStage = &GetEntInfo(pokemon)->stockpileStage; if (*stockpileStage != 0) { - HandleDamagingMove(pokemon,target,move,IntToF248_2(*stockpileStage),itemId); + HandleDamagingMove(pokemon,target,move,IntToF248(*stockpileStage),itemId); *stockpileStage = 0; } else { @@ -489,7 +487,7 @@ bool8 DynamicPunchMoveAction(Entity *pokemon, Entity *target, Move *move, s32 it bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, 0)) { @@ -675,7 +673,7 @@ bool8 BellyDrumMoveAction(Entity * pokemon,Entity * target, Move *move, s32 item info = GetEntInfo(pokemon); flag = FALSE; if (FixedPointToInt(info->belly) > 1) { - RaiseAttackStageTarget(pokemon,target,gStatIndexAtkDef,99); + BoostOffensiveStat(pokemon,target,gStatIndexAtkDef,99); info->belly = IntToFixedPoint(1); flag = TRUE; } @@ -697,7 +695,7 @@ bool8 SecretPowerMoveAction(Entity * pokemon, Entity * target, Move *move, s32 i bool8 flag; flag = FALSE; - if ( HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if ( HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gSecretPowerSecondaryEffectChance) != 0) { switch(gSecretPowerTable[gDungeon->tileset]) { @@ -708,26 +706,26 @@ bool8 SecretPowerMoveAction(Entity * pokemon, Entity * target, Move *move, s32 i SleepStatusTarget(pokemon,target,CalculateStatusTurns(target,gSleepTurnRange,TRUE),FALSE); break; case 2: - LowerMovementSpeedTarget(pokemon,target,1,FALSE); + LowerSpeed(pokemon,target,1,FALSE); break; case 3: - LowerAttackStageTarget(pokemon,target,gStatIndexAtkDef,1,1,FALSE); + LowerOffensiveStat(pokemon,target,gStatIndexAtkDef,1,1,FALSE); break; case 4: - LowerDefenseStageTarget(pokemon,target,gStatIndexAtkDef,1,1,FALSE); + LowerDefensiveStat(pokemon,target,gStatIndexAtkDef,1,1,FALSE); break; case 5: - LowerAccuracyStageTarget(pokemon,target,gStatIndexAtkDef,FALSE); + LowerHitChanceStat(pokemon,target,gStatIndexAtkDef,FALSE); break; case 6: ConfuseStatusTarget(pokemon,target,FALSE); break; case 7: - CringeStatusTarget(pokemon,target,FALSE); + TryInflictCringeStatus(pokemon,target,FALSE); break; case 8: default: - ParalyzeStatusTarget(pokemon,target,FALSE); + TryInflictParalysisStatus(pokemon,target,FALSE); break; } } @@ -740,7 +738,7 @@ bool8 sub_805AC90(Entity * pokemon, Entity * target, Move *move, s32 itemId) bool8 flag; flag = FALSE; - if ( HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if ( HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gDizzyPunchSecondaryChance) != 0) { ConfuseStatusTarget(pokemon, target, FALSE); @@ -751,9 +749,8 @@ bool8 sub_805AC90(Entity * pokemon, Entity * target, Move *move, s32 itemId) bool8 BulkUpMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - s32 stat = gStatIndexAtkDef; - RaiseAttackStageTarget(pokemon, target, stat, 1); - RaiseDefenseStageTarget(pokemon, target, stat, 1); + BoostOffensiveStat(pokemon, target, gStatIndexAtkDef, 1); + BoostDefensiveStat(pokemon, target, gStatIndexAtkDef, 1); return TRUE; } @@ -765,7 +762,7 @@ bool8 ObserverOrbAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) bool8 FeatherDanceMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerAttackStageTarget(pokemon, target, gStatIndexAtkDef, 2, 1, TRUE); + LowerOffensiveStat(pokemon, target, gStatIndexAtkDef, 2, 1, TRUE); return TRUE; } @@ -812,7 +809,7 @@ bool8 BlastBurnMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemI bool8 flag; SendThawedMessage(pokemon, target); - flag = HandleDamagingMove(pokemon,target,move,IntToF248_2(2),itemId) != 0 ? TRUE : FALSE; + flag = HandleDamagingMove(pokemon,target,move,IntToF248(2),itemId) != 0 ? TRUE : FALSE; return flag; } @@ -821,10 +818,10 @@ bool8 CrushClawMoveAction(Entity * pokemon, Entity * target, Move *move, s32 ite bool8 flag; flag = FALSE; - if ( HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if ( HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gCrushClawSecondaryChance) != 0) { - LowerDefenseStageTarget(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE); + LowerDefensiveStat(pokemon, target, gStatIndexAtkDef, 1, 1, FALSE); } } return flag; @@ -836,7 +833,7 @@ bool8 BlazeKickMoveAction(Entity * pokemon, Entity * target, Move *move, s32 ite flag = FALSE; SendThawedMessage(pokemon, target); - if ( HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if ( HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gBlazeKickSecondaryChance) != 0) { BurnedStatusTarget(pokemon, target, 0, FALSE); @@ -901,7 +898,7 @@ bool8 EruptionMoveAction(Entity * pokemon, Entity * target, Move *move, s32 item bool8 GlareMoveAction(Entity * pokemon,Entity * target,Move *move,s32 itemId) { - ParalyzeStatusTarget(pokemon,target, TRUE); + TryInflictParalysisStatus(pokemon,target, TRUE); return TRUE; } @@ -923,7 +920,7 @@ bool8 PoisonTailMoveAction(Entity * pokemon, Entity * target, Move *move, s32 it bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gPoisonTailSecondaryChance) != 0) { PoisonedStatusTarget(pokemon,target,FALSE); @@ -964,7 +961,7 @@ bool8 HandleColorChange(Entity * pokemon, Entity * target, Move *move, s32 itemI bool8 TailGlowMoveAction(Entity * pokemon, Entity * target, Move *move, s32 itemId) { - RaiseAttackStageTarget(pokemon,target,gStatIndexSpecial, 2); + BoostOffensiveStat(pokemon,target,gStatIndexSpecial, 2); return TRUE; } @@ -984,7 +981,7 @@ bool8 sub_805B17C(Entity * pokemon, Entity * target, Move *move, s32 itemId) uVar4 = 0x7e; } } - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gMovesConstrictionChance) != 0) { SqueezedStatusTarget(pokemon,target,uVar4,0); diff --git a/src/move_orb_actions_4.c b/src/move_orb_actions_4.c index 472750e64..7490f8a30 100644 --- a/src/move_orb_actions_4.c +++ b/src/move_orb_actions_4.c @@ -59,7 +59,7 @@ bool8 ProtectMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId) bool8 DefenseCurlMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId) { - RaiseDefenseStageTarget(pokemon,target,gStatIndexAtkDef,1); + BoostDefensiveStat(pokemon,target,gStatIndexAtkDef,1); return TRUE; } @@ -74,10 +74,10 @@ bool8 MistBallMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target,gMistBallSecondaryChance) != 0) { - LowerAttackStageTarget(pokemon,target,gStatIndexSpecial,1,1,0); + LowerOffensiveStat(pokemon,target,gStatIndexSpecial,1,1,0); } } return flag; @@ -91,7 +91,7 @@ bool8 DestinyBondMoveAction(Entity * pokemon,Entity * target,Move *move, s32 ite bool8 FalseSwipeMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId) { - return (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId)) ? TRUE : FALSE; + return (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId)) ? TRUE : FALSE; } bool8 MirrorCoatMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId) @@ -102,29 +102,28 @@ bool8 MirrorCoatMoveAction(Entity * pokemon,Entity * target,Move *move, s32 item bool8 CalmMindMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId) { - u32 stat = gStatIndexSpecial; - RaiseAttackStageTarget(pokemon,target,stat,1); - RaiseDefenseStageTarget(pokemon,target,stat,1); + BoostOffensiveStat(pokemon,target,gStatIndexSpecial,1); + BoostDefensiveStat(pokemon,target,gStatIndexSpecial,1); return TRUE; } bool8 HiddenPowerMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId) { - HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId); + HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId); return TRUE; } -bool8 MetalClawMoveAction(Entity * pokemon,Entity * target,Move *move, s32 itemId, s32 param_5) +bool8 MetalClawMoveAction(Entity * pokemon,Entity * target,Move *move, StatIndex stat, s32 param_5) { EntityInfo *entityInfo; bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),param_5) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),param_5) != 0) { flag = TRUE; if (sub_805727C(pokemon,pokemon,gMetalClawSecondaryChance) != 0) { entityInfo = GetEntInfo(pokemon); - RaiseAttackStageTarget(pokemon,pokemon,itemId,1); + BoostOffensiveStat(pokemon,pokemon,stat,1); SetExpMultplier(entityInfo); } } @@ -222,8 +221,8 @@ bool8 DreamEaterMoveAction(Entity * pokemon, Entity * target, Move *move, s32 it flag = FALSE; hasLiquidOoze = AbilityIsActive(target, ABILITY_LIQUID_OOZE); - if (IsSleeping(target)) { - iVar3 = HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId); + if (IsMonsterSleeping(target)) { + iVar3 = HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId); if (iVar3 != 0) { flag = TRUE; newHP = iVar3 / 2; @@ -306,8 +305,8 @@ bool8 DragonRageMoveAction(Entity * pokemon, Entity * target, Move *move, s32 it bool8 DragonDanceMoveAction( Entity * pokemon, Entity * target, Move *move, s32 itemId) { - RaiseAttackStageTarget(pokemon, target, gStatIndexAtkDef, 1); - RaiseMovementSpeedTarget(pokemon, target, 0, TRUE); + BoostOffensiveStat(pokemon, target, gStatIndexAtkDef, 1); + BoostSpeed(pokemon, target, 0, TRUE); return TRUE; } @@ -331,11 +330,11 @@ bool8 LusterPurgeMoveAction(Entity * pokemon, Entity * target, Move * move, s32 bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if(sub_805727C(pokemon, target, gLusterPurgeSecondaryChance)) { - LowerDefenseStageTarget(pokemon, target, gStatIndexSpecial, 1, 1, 0); + LowerDefensiveStat(pokemon, target, gStatIndexSpecial, 1, 1, 0); } } return flag; @@ -348,7 +347,7 @@ bool8 StruggleMoveAction(Entity * pokemon, Entity * target, Move * move, s32 ite bool8 flag; flag = FALSE; - if (HandleDamagingMove(pokemon, target, move, IntToF248_2(1), itemId) != 0) { + if (HandleDamagingMove(pokemon, target, move, IntToF248(1), itemId) != 0) { flag = TRUE; if (RollSecondaryEffect(pokemon, 0) != 0) { entityHP = GetEntInfo(pokemon)->maxHPStat; @@ -402,7 +401,7 @@ bool8 ThiefAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) Item *targetItem; flag = FALSE; - if (HandleDamagingMove(pokemon,target,move,IntToF248_2(1),itemId) != 0) { + if (HandleDamagingMove(pokemon,target,move,IntToF248(1),itemId) != 0) { flag = TRUE; if (sub_805727C(pokemon,target, 0) != 0) { pokemonInfo1 = GetEntInfo(pokemon); @@ -603,7 +602,7 @@ bool8 TransferOrbAction(Entity *pokemon, Entity * target, Move *move, s32 itemId bool8 SlowDownMoveAction(Entity *pokemon, Entity *target, Move *move, s32 itemId) { - LowerMovementSpeedTarget(pokemon, target, 1, TRUE); + LowerSpeed(pokemon, target, 1, TRUE); return TRUE; } diff --git a/src/move_orb_effects_1.c b/src/move_orb_effects_1.c index 7d43c7bec..7cac41669 100644 --- a/src/move_orb_effects_1.c +++ b/src/move_orb_effects_1.c @@ -60,7 +60,7 @@ u8 sub_8075BF4(Entity * pokemon, s32 sleepClassStatusTurns) uVar4 = 1; else if(entityInfo->sleepClassStatus.status == STATUS_NIGHTMARE) uVar4 = 2; - EntityUpdateStatusSprites(pokemon); + UpdateStatusIconFlags(pokemon); } return uVar4; } @@ -100,10 +100,10 @@ bool8 CannotSleep(Entity * pokemon, Entity * target, u8 param_3, bool8 displayMe { if ((!EntityIsValid(target)) || ((SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0), param_3 != 0 && - (HasSafeguardStatus(pokemon,target,displayMessage))))) { + (SafeguardIsActive(pokemon,target,displayMessage))))) { return TRUE; } - else if (IQSkillIsEnabled(target, IQ_NONSLEEPER)) { + else if (IqSkillIsEnabled(target, IQ_NONSLEEPER)) { if (displayMessage) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCD54); } @@ -163,7 +163,7 @@ void NightmareStatusTarget(Entity * pokemon, Entity * target, s32 turns) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB3D0); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -200,7 +200,7 @@ void NappingStatusTarget(Entity * pokemon, Entity * target, s32 turns) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB388); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -231,7 +231,7 @@ void YawnedStatusTarget(Entity * pokemon, Entity * target, s32 turns) else TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB3E0); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void SleeplessStatusTarget(Entity * pokemon, Entity * target) @@ -266,7 +266,7 @@ void SleeplessStatusTarget(Entity * pokemon, Entity * target) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB43C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void PausedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, s32 turns, bool8 displayMessage) @@ -277,7 +277,7 @@ void PausedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, s32 turns return; } entityInfo = GetEntInfo(target); - if ((param_3 != 0) && (HasSafeguardStatus(pokemon,target,displayMessage))) { + if ((param_3 != 0) && (SafeguardIsActive(pokemon,target,displayMessage))) { return; } SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); @@ -301,7 +301,7 @@ void PausedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, s32 turns TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB4F0); } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void InfatuateStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) @@ -311,7 +311,7 @@ void InfatuateStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessa if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); - if (!HasSafeguardStatus(pokemon,target,displayMessage)) { + if (!SafeguardIsActive(pokemon,target,displayMessage)) { if (AbilityIsActive(target,ABILITY_OBLIVIOUS)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (displayMessage) { @@ -330,7 +330,7 @@ void InfatuateStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessa else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB52C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -350,7 +350,7 @@ void BurnedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, bool8 dis return; } - if (!HasSafeguardStatus(pokemon,target,displayMessage)) { + if (!SafeguardIsActive(pokemon,target,displayMessage)) { entityInfo = GetEntInfo(target); SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); if (AbilityIsActive(target, ABILITY_WATER_VEIL)) { @@ -388,7 +388,7 @@ void BurnedStatusTarget(Entity * pokemon, Entity * target, u8 param_3, bool8 dis else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB564); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); if (!AbilityIsActive(target, ABILITY_SYNCHRONIZE)) { return; @@ -437,7 +437,7 @@ void PoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag return; } - if (!HasSafeguardStatus(pokemon,target,displayMessage)) { + if (!SafeguardIsActive(pokemon,target,displayMessage)) { entityInfo = GetEntInfo(target); SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); if (HasHeldItem(target, ITEM_PECHA_SCARF)) { @@ -506,7 +506,7 @@ void PoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessag } } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -526,7 +526,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM return; } - if (!HasSafeguardStatus(pokemon,target,displayMessage)) { + if (!SafeguardIsActive(pokemon,target,displayMessage)) { entityInfo = GetEntInfo(target); SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); if (HasHeldItem(target, ITEM_PECHA_SCARF)) { @@ -588,7 +588,7 @@ void BadlyPoisonedStatusTarget(Entity * pokemon, Entity * target, bool8 displayM } } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -607,7 +607,7 @@ void FrozenStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], target, 0); entityInfo = GetEntInfo(target); - if ((entityInfo->frozenClassStatus.status != STATUS_FROZEN) && !HasSafeguardStatus(pokemon,target,displayMessage)) { + if ((entityInfo->frozenClassStatus.status != STATUS_FROZEN) && !SafeguardIsActive(pokemon,target,displayMessage)) { if (AbilityIsActive(target, ABILITY_MAGMA_ARMOR)) { if (displayMessage) TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCDE0); @@ -636,7 +636,7 @@ void FrozenStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) entityInfo->frozenClassStatus.turns = CalculateStatusTurns(target,gFreezeTurnRange,TRUE) + 1; entityInfo->frozenClassStatus.damageCountdown = 0; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB610); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -649,7 +649,7 @@ void SqueezedStatusTarget(Entity * pokemon, Entity * target, s32 param_3, bool32 s32 param_3_s32 = (s16) param_3; bool8 displayMessage_u8 = displayMessage; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage_u8))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon,target,displayMessage_u8))) { entityInfo = GetEntInfo(target); if (entityInfo->frozenClassStatus.status == STATUS_WRAP || entityInfo->frozenClassStatus.status == STATUS_WRAPPED) { sub_8076CB4(entityInfo->unk9C); @@ -671,7 +671,7 @@ void SqueezedStatusTarget(Entity * pokemon, Entity * target, s32 param_3, bool32 else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB64C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -679,7 +679,7 @@ void ImmobilizedStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon,target,TRUE))) { entityInfo = GetEntInfo(target); if (entityInfo->frozenClassStatus.status == STATUS_WRAP || entityInfo->frozenClassStatus.status == STATUS_WRAPPED) { sub_8076CB4(entityInfo->unk9C); @@ -700,7 +700,7 @@ void ImmobilizedStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB688); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -724,7 +724,7 @@ void IngrainedStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB6C0); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -735,7 +735,7 @@ void WrapTarget(Entity *pokemon, Entity *target) if (!EntityIsValid(target)) return; - if (HasSafeguardStatus(pokemon, target, TRUE)) + if (SafeguardIsActive(pokemon, target, TRUE)) return; pokemonEntityData = GetEntInfo(pokemon); @@ -778,7 +778,7 @@ void WrapTarget(Entity *pokemon, Entity *target) } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void sub_8076CB4(s32 param_1) @@ -798,7 +798,7 @@ void sub_8076CB4(s32 param_1) } entityInfo->unk9C = 0; } - EntityUpdateStatusSprites(entity); + UpdateStatusIconFlags(entity); } } } @@ -810,7 +810,7 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target) Entity * entity; s32 index; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon,target,TRUE))) { sub_8041C08(target); targetEntityInfo = GetEntInfo(target); if ((u8)(targetEntityInfo->frozenClassStatus.status - 3U) < 2) { @@ -847,208 +847,213 @@ void PetrifiedStatusTarget(Entity * pokemon, Entity * target) } } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } -void LowerAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage) +void LowerOffensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected) { EntityInfo *entityInfo; - s32 attackStage = decrement; + s32 newStage; if (!EntityIsValid(target)) return; - if (index != STAT_STAGE_ATK) { + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0], gUnknown_80FC0C8); } else { strcpy(gFormatBuffer_Items[0], gUnknown_80FC0B8); } - if (param_5) { - if (sub_8071728(pokemon,target,displayMessage)) + if (checkProtected) { + if (IsProtectedFromStatDrops(user,target,logMsgProtected)) return; if (HasHeldItem(target, ITEM_TWIST_BAND)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FD550); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FD550); return; } - if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && index == STAT_STAGE_ATK) { + if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && stat.id == STAT_INDEX_PHYSICAL) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA60); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FCA60); return; } } entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F28(target,index); - if (decrement == 1) { + PlayOffensiveStatDownEffect(target,stat); + if (nStages == 1) { strcpy(gFormatBuffer_Items[1], gUnknown_80FC0E4); } else { strcpy(gFormatBuffer_Items[1], gUnknown_80FC0D4); } - attackStage = entityInfo->offensiveStages[index]; - attackStage -= decrement; - if (attackStage < 0) { - attackStage = 0; + + newStage = entityInfo->offensiveStages[stat.id]; + newStage -= nStages; + if (newStage < 0) { + newStage = 0; } - if (entityInfo->offensiveStages[index] != attackStage) { - entityInfo->offensiveStages[index] = attackStage; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC15C); + if (entityInfo->offensiveStages[stat.id] != newStage) { + entityInfo->offensiveStages[stat.id] = newStage; + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC15C); } else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC274); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC274); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } -void LowerDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 decrement, u8 param_5, bool8 displayMessage) +void LowerDefensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages, bool8 checkProtected, bool8 logMsgProtected) { EntityInfo *entityInfo; - s32 defenseStage = decrement; + s32 newStage; if (!EntityIsValid(target)) return; - if (index != STAT_STAGE_DEF) { + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC09C); } - if (param_5) { - if (sub_8071728(pokemon,target,displayMessage)) + if (checkProtected) { + if (IsProtectedFromStatDrops(user,target,logMsgProtected)) return; } entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F4C(target,index); - if (decrement == 1) { + PlayDefensiveStatDownEffect(target,stat); + if (nStages == 1) { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0E4); } else { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); } - defenseStage = entityInfo->defensiveStages[index]; - defenseStage = defenseStage - decrement; - if (defenseStage < 0) { - defenseStage = 0; + + newStage = entityInfo->defensiveStages[stat.id]; + newStage -= nStages; + if (newStage < 0) { + newStage = 0; } - if (entityInfo->defensiveStages[index] != defenseStage) { - entityInfo->defensiveStages[index] = defenseStage; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC158); + if (entityInfo->defensiveStages[stat.id] != newStage) { + entityInfo->defensiveStages[stat.id] = newStage; + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC158); } else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC248); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC248); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } -void RaiseAttackStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment) +void BoostOffensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages) { EntityInfo *entityInfo; - s32 attackStage = increment; + s32 newStage; - if (!EntityIsValid(target)) { + if (!EntityIsValid(target)) return; - } + entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F70(target,index); - if (index != STAT_STAGE_ATK) { + PlayOffensiveStatUpEffect(target,stat); + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0C8); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0B8); } - if (increment == 1) { + if (nStages == 1) { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0E4); } else { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); } - attackStage = entityInfo->offensiveStages[index]; - attackStage = attackStage + increment; - if (attackStage >= MAX_STAT_STAGE) { - attackStage = MAX_STAT_STAGE; + newStage = entityInfo->offensiveStages[stat.id]; + newStage += nStages; + if (newStage >= MAX_STAT_STAGE) { + newStage = MAX_STAT_STAGE; } - if (entityInfo->offensiveStages[index] != attackStage) { - entityInfo->offensiveStages[index] = attackStage; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC13C); + + if (entityInfo->offensiveStages[stat.id] != newStage) { + entityInfo->offensiveStages[stat.id] = newStage; + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC13C); } else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC270); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC270); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } -void RaiseDefenseStageTarget(Entity * pokemon, Entity * target, s32 index, s32 increment) +void BoostDefensiveStat(Entity *user, Entity *target, StatIndex stat, s32 nStages) { EntityInfo *entityInfo; - s32 defenseStage = increment; + s32 newStage; - if (!EntityIsValid(target)) { + if (!EntityIsValid(target)) return; - } + entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8041F94(target,index); - if (index != STAT_STAGE_DEF) { + PlayDefensiveStatUpEffect(target,stat); + if (stat.id != STAT_INDEX_PHYSICAL) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC09C); } - if (increment == 1) { + if (nStages == 1) { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0E4); } else { strcpy(gFormatBuffer_Items[1],gUnknown_80FC0D4); } - defenseStage = entityInfo->defensiveStages[index]; - defenseStage = defenseStage + increment; - if (defenseStage >= MAX_STAT_STAGE) { - defenseStage = MAX_STAT_STAGE; + newStage = entityInfo->defensiveStages[stat.id]; + newStage += nStages; + if (newStage >= MAX_STAT_STAGE) { + newStage = MAX_STAT_STAGE; } - if (entityInfo->defensiveStages[index] != defenseStage) { - entityInfo->defensiveStages[index] = defenseStage; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC138); + + if (entityInfo->defensiveStages[stat.id] != newStage) { + entityInfo->defensiveStages[stat.id] = newStage; + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC138); } else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC21C); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC21C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } -u8 GetFlashFireStatus(Entity *pokemon) +u8 GetFlashFireStatus(Entity *defender) { - if (!EntityIsValid(pokemon) || !AbilityIsActive(pokemon, ABILITY_FLASH_FIRE)) - { + if (!EntityIsValid(defender)) return FLASH_FIRE_STATUS_NONE; - } - if (GetEntInfo(pokemon)->flashFireBoost > 1) - { + + if (!AbilityIsActive(defender, ABILITY_FLASH_FIRE)) + return FLASH_FIRE_STATUS_NONE; + + if (GetEntInfo(defender)->flashFireBoost >= 2) return FLASH_FIRE_STATUS_MAXED; - } + return FLASH_FIRE_STATUS_NOT_MAXED; } -void UpdateFlashFireBoost(Entity * pokemon, Entity *target) +void ActivateFlashFire(Entity * pokemon, Entity *target) { s32 flashFireBoost; @@ -1063,363 +1068,366 @@ void UpdateFlashFireBoost(Entity * pokemon, Entity *target) entityInfo->flashFireBoost = flashFireBoost; sub_8041C58(target); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } -void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage) +void ApplyOffensiveStatMultiplier(Entity *user, Entity *target, StatIndex stat, s24_8 multiplier, bool8 displayMessage) { - EntityInfo *entityInfo; - s24_8 oldMulti; + EntityInfo *entityInfo; + s24_8 oldMulti; - if (!EntityIsValid(target)) { - return; - } + if (!EntityIsValid(target)) + return; - if (statStage != STAT_STAGE_ATK) { - strcpy(gFormatBuffer_Items[0],gUnknown_80FC0C8); - } - else { - strcpy(gFormatBuffer_Items[0],gUnknown_80FC0B8); - } - if (F248LessThanInt(param_4, 1) && sub_8071728(pokemon,target,displayMessage)) { - return; - } + if (stat.id != STAT_INDEX_PHYSICAL) { + strcpy(gFormatBuffer_Items[0],gUnknown_80FC0C8); + } + else { + strcpy(gFormatBuffer_Items[0],gUnknown_80FC0B8); + } - if ((HasHeldItem(target,ITEM_TWIST_BAND)) && F248LessThanInt(param_4, 1)) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FD550); - return; - } + if (F248LessThanInt(multiplier, 1) && IsProtectedFromStatDrops(user,target,displayMessage)) + return; - if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) && (statStage == STAT_STAGE_ATK) && F248LessThanInt(param_4, 1)) { - if (displayMessage) { + if (HasHeldItem(target,ITEM_TWIST_BAND) && F248LessThanInt(multiplier, 1)) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA60); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FD550); + return; } - return; - } - entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - oldMulti = entityInfo->offensiveMultipliers[statStage]; + if (AbilityIsActive(target, ABILITY_HYPER_CUTTER) + && stat.id == STAT_INDEX_PHYSICAL + && F248LessThanInt(multiplier, 1)) + { + if (displayMessage) { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FCA60); + } + return; + } - if (F248LessThanInt(param_4, 1)) { - sub_8041FD8(target,statStage); - } - else { - sub_8041FB4(target,statStage); - } + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + oldMulti = entityInfo->offensiveMultipliers[stat.id]; - entityInfo->offensiveMultipliers[statStage] = s24_8_mul(entityInfo->offensiveMultipliers[statStage],param_4); + if (F248LessThanInt(multiplier, 1)) { + PlayOffensiveStatMultiplierDownEffect(target,stat); + } + else { + PlayOffensiveStatMultiplierUpEffect(target,stat); + } - if (F248LessThanFloat(entityInfo->offensiveMultipliers[statStage], 0.01)) { - entityInfo->offensiveMultipliers[statStage] = FloatToF248(0.01); - } - if (FloatLessThanF248(99.99, entityInfo->offensiveMultipliers[statStage])) { - entityInfo->offensiveMultipliers[statStage] = FloatToF248(99.99); - } - if (F248GreaterThan(oldMulti, entityInfo->offensiveMultipliers[statStage])) { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC11C); - } - else if (F248LessThan(oldMulti, entityInfo->offensiveMultipliers[statStage])) { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC118); - } - else - { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC184); - } - EntityUpdateStatusSprites(target); + entityInfo->offensiveMultipliers[stat.id] = s24_8_mul(entityInfo->offensiveMultipliers[stat.id],multiplier); + + if (F248LessThanFloat(entityInfo->offensiveMultipliers[stat.id], 0.01)) { + entityInfo->offensiveMultipliers[stat.id] = IntToF248(0.01); + } + if (FloatLessThanF248(99.99, entityInfo->offensiveMultipliers[stat.id])) { + entityInfo->offensiveMultipliers[stat.id] = IntToF248(99.99); + } + + if (F248GreaterThan(oldMulti, entityInfo->offensiveMultipliers[stat.id])) { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC11C); + } + else if (F248LessThan(oldMulti, entityInfo->offensiveMultipliers[stat.id])) { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC118); + } + else { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC184); + } + UpdateStatusIconFlags(target); } -void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage) +void ApplyDefensiveStatMultiplier(Entity *user, Entity *target, StatIndex stat, s24_8 multiplier, bool8 displayMessage) { - EntityInfo *entityInfo; - s24_8 oldMulti; + EntityInfo *entityInfo; + s24_8 oldMulti; - if (!EntityIsValid(target)) { - return; - } + if (!EntityIsValid(target)) + return; - if (statStage != STAT_STAGE_DEF) { - strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); - } - else { - strcpy(gFormatBuffer_Items[0],gUnknown_80FC09C); - } - if (F248LessThanInt(param_4, 1) && sub_8071728(pokemon,target,displayMessage)) { - return; - } + if (stat.id != STAT_INDEX_PHYSICAL) { + strcpy(gFormatBuffer_Items[0],gUnknown_80FC0AC); + } + else { + strcpy(gFormatBuffer_Items[0],gUnknown_80FC09C); + } - entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - oldMulti = entityInfo->defensiveMultipliers[statStage]; + if (F248LessThanInt(multiplier, 1) && IsProtectedFromStatDrops(user,target,displayMessage)) { + return; + } - if (F248LessThanInt(param_4, 1)) { - sub_804201C(target,statStage); - } - else { - sub_8041FFC(target,statStage); - } + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + oldMulti = entityInfo->defensiveMultipliers[stat.id]; - entityInfo->defensiveMultipliers[statStage] = s24_8_mul(entityInfo->defensiveMultipliers[statStage],param_4); + if (F248LessThanInt(multiplier, 1)) { + PlayDefensiveStatMultiplierDownEffect(target,stat); + } + else { + PlayDefensiveStatMultiplierUpEffect(target,stat); + } - if (F248LessThanFloat(entityInfo->defensiveMultipliers[statStage], 0.01)) { - entityInfo->defensiveMultipliers[statStage] = FloatToF248(0.01); - } - if (FloatLessThanF248(99.99, entityInfo->defensiveMultipliers[statStage])) { - entityInfo->defensiveMultipliers[statStage] = FloatToF248(99.99); - } - if (F248GreaterThan(oldMulti, entityInfo->defensiveMultipliers[statStage])) { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC114); - } - else if (F248LessThan(oldMulti, entityInfo->defensiveMultipliers[statStage])) { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC0FC); - } - else - { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC180); - } - EntityUpdateStatusSprites(target); + entityInfo->defensiveMultipliers[stat.id] = s24_8_mul(entityInfo->defensiveMultipliers[stat.id],multiplier); + + if (F248LessThanFloat(entityInfo->defensiveMultipliers[stat.id], 0.01)) { + entityInfo->defensiveMultipliers[stat.id] = IntToF248(0.01); + } + if (FloatLessThanF248(99.99, entityInfo->defensiveMultipliers[stat.id])) { + entityInfo->defensiveMultipliers[stat.id] = IntToF248(99.99); + } + + if (F248GreaterThan(oldMulti, entityInfo->defensiveMultipliers[stat.id])) { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC114); + } + else if (F248LessThan(oldMulti, entityInfo->defensiveMultipliers[stat.id])) { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC0FC); + } + else { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC180); + } + UpdateStatusIconFlags(target); } -void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage) +void BoostHitChanceStat(Entity *user, Entity *target, StatIndex stat) { - EntityInfo *entityInfo; + EntityInfo *entityInfo; + + if (!EntityIsValid(target)) + return; - if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8042040(target,statStage); - if (statStage != STAT_STAGE_ACCURACY) { + PlayHitChanceUpEffect(target,stat); + if (stat.id != STAT_INDEX_ACCURACY) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC090); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC084); } - if (entityInfo->hitChanceStages[statStage] < MAX_STAT_STAGE) { - entityInfo->hitChanceStages[statStage]++; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC1C4); + + if (entityInfo->hitChanceStages[stat.id] < MAX_STAT_STAGE) { + entityInfo->hitChanceStages[stat.id]++; + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC1C4); } else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC218); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC218); } - EntityUpdateStatusSprites(target); - } + UpdateStatusIconFlags(target); } -void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage, bool8 displayMessage) +void LowerHitChanceStat(Entity *user, Entity *target, StatIndex stat, bool8 displayMessage) { - EntityInfo *entityInfo; + EntityInfo *entityInfo; - if (EntityIsValid(target)) { - if (statStage != STAT_STAGE_ACCURACY) { + if (!EntityIsValid(target)) + return; + + if (stat.id != STAT_INDEX_ACCURACY) { strcpy(gFormatBuffer_Items[0],gUnknown_80FC090); } else { strcpy(gFormatBuffer_Items[0],gUnknown_80FC084); } - if (!sub_8071728(pokemon,target,displayMessage)) { - if (AbilityIsActive(target, ABILITY_KEEN_EYE) && (statStage == STAT_STAGE_ACCURACY)){ - if(displayMessage) - { + + if (IsProtectedFromStatDrops(user,target,displayMessage)) + return; + + if (AbilityIsActive(target, ABILITY_KEEN_EYE) && stat.id == STAT_INDEX_ACCURACY) { + if (displayMessage) { SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCA64); - } - } - else { - entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - sub_8042060(target,statStage); - if (entityInfo->hitChanceStages[statStage] != 0) { - entityInfo->hitChanceStages[statStage]--; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC1A4); - } - else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC1F0); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FCA64); } - EntityUpdateStatusSprites(target); - } + return; } - } + + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + PlayHitChanceDownEffect(target,stat.id); + if (entityInfo->hitChanceStages[stat.id] != 0) { + entityInfo->hitChanceStages[stat.id]--; + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC1A4); + } + else { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC1F0); + } + UpdateStatusIconFlags(target); } -void CringeStatusTarget(Entity * pokemon,Entity * target, bool8 displayMessage) +void TryInflictCringeStatus(Entity *user ,Entity *target, bool8 displayMessage) { - EntityInfo *entityInfo; + EntityInfo *entityInfo; - if (EntityIsValid(target)) { - if (!HasSafeguardStatus(pokemon, target, displayMessage)) { - if (AbilityIsActive(target, ABILITY_INNER_FOCUS)){ - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - if(displayMessage) - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCC18); - } - else { - entityInfo = GetEntInfo(target); + if (!EntityIsValid(target)) + return; + + if (SafeguardIsActive(user, target, displayMessage)) + return; + + if (AbilityIsActive(target, ABILITY_INNER_FOCUS)){ SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - if(entityInfo->cringeClassStatus.status != STATUS_CRINGE) - { - entityInfo->cringeClassStatus.status = STATUS_CRINGE; - entityInfo->cringeClassStatus.turns = CalculateStatusTurns(target, gCringeTurnRange, TRUE) + 1; - sub_80420A0(target); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB2E0); - } - else - { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB300); - } - EntityUpdateStatusSprites(target); - } + if (displayMessage) + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FCC18); + return; } - } + + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + if (entityInfo->cringeClassStatus.status != STATUS_CRINGE) { + entityInfo->cringeClassStatus.status = STATUS_CRINGE; + entityInfo->cringeClassStatus.turns = CalculateStatusTurns(target, gCringeTurnRange, TRUE) + 1; + PlayCringeExclamationPointEffect(target); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FB2E0); + } + else { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FB300); + } + UpdateStatusIconFlags(target); } -void ParalyzeStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) +void TryInflictParalysisStatus(Entity *user, Entity *target, bool8 displayMessage) { - const Tile *mapTile; - EntityInfo *entityInfo; - Entity *mapPokemonEntity; - int index; - bool8 bVar6; - bool8 bVar7; + EntityInfo *entityInfo; + bool8 alreadyParalyzed; + + if (!EntityIsValid(target)) + return; + + if (SafeguardIsActive(user, target, displayMessage)) + return; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage))) { if (AbilityIsActive(target, ABILITY_LIMBER)) { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - if (displayMessage) { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCBF8); - } + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + if (displayMessage) { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FCBF8); + } + return; } - else - { - bVar6 = TRUE; - entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - if (entityInfo->burnClassStatus.status != STATUS_PARALYSIS) { + + alreadyParalyzed = TRUE; + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + if (entityInfo->burnClassStatus.status != STATUS_PARALYSIS) { entityInfo->burnClassStatus.status = STATUS_PARALYSIS; entityInfo->burnClassStatus.turns = CalculateStatusTurns(target,gParalysisTurnRange,TRUE) + 1; entityInfo->burnClassStatus.damageCountdown = 0; entityInfo->burnClassStatus.badlyPoisonedDamageCount = 0; - bVar6 = FALSE; - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB2AC); - sub_8041C1C(target); + alreadyParalyzed = FALSE; + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FB2AC); + PlayParalysisEffect(target); CalcSpeedStage(target); - } - else { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB2CC); - } - if ((AbilityIsActive(target, ABILITY_SYNCHRONIZE)) && (!bVar6)) { - bVar7 = FALSE; + } + else { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FB2CC); + } - for(index = 0; index < NUM_DIRECTIONS; index++) - { - mapTile = GetTile(target->pos.x + gAdjacentTileOffsets[index].x,target->pos.y + gAdjacentTileOffsets[index].y); - mapPokemonEntity = mapTile->monster; - if ((EntityIsValid(mapPokemonEntity)) && (GetEntityType(mapPokemonEntity) == ENTITY_MONSTER)) { - if (!bVar7) { - bVar7 = TRUE; - SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FF01C); - } - if (GetTreatmentBetweenMonstersIgnoreStatus(target,mapPokemonEntity) == TREATMENT_TREAT_AS_ENEMY) { - ParalyzeStatusTarget(pokemon, mapPokemonEntity, displayMessage); + if (AbilityIsActive(target, ABILITY_SYNCHRONIZE) && !alreadyParalyzed) { + s32 i; + bool8 synchronizePrinted = FALSE; + + for (i = 0; i < NUM_DIRECTIONS; i++) { + const Tile *mapTile = GetTile(target->pos.x + gAdjacentTileOffsets[i].x,target->pos.y + gAdjacentTileOffsets[i].y); + Entity *mapMonster = mapTile->monster; + if (EntityIsValid(mapMonster) && GetEntityType(mapMonster) == ENTITY_MONSTER) { + if (!synchronizePrinted) { + synchronizePrinted = TRUE; + SetMessageArgument_2(gFormatBuffer_Monsters[0],entityInfo,0); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FF01C); + } + if (GetTreatmentBetweenMonstersIgnoreStatus(target,mapMonster) == TREATMENT_TREAT_AS_ENEMY) { + TryInflictParalysisStatus(user, mapMonster, displayMessage); + } } - } } - } - EntityUpdateStatusSprites(target); } - } + + UpdateStatusIconFlags(target); } -void RaiseMovementSpeedTarget(Entity * pokemon, Entity * target, s32 turns, bool8 displayMessage) +void BoostSpeed(Entity *user, Entity *target, s32 turns, bool8 displayMessage) { - s32 movSpeed; - s32 index; - s32 movSpeed_1; - EntityInfo *entityInfo; + s32 speedBefore; + s32 i; + s32 speedAfter; + EntityInfo *entityInfo; - if (!EntityIsValid(target)) { - return; - } - if (turns == 0) { - turns = CalculateStatusTurns(target,gSpeedRaiseTurnRange,FALSE) + 1; - } - entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - movSpeed = CalcSpeedStage(target); - if (movSpeed == MAX_SPEED_STAGE) { - if (displayMessage) - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC2B8); - } - else { - for(index = 0; index < NUM_SPEED_COUNTERS; index++) - { - if(entityInfo->speedUpCounters[index] == 0) - { - entityInfo->speedUpCounters[index] = turns; - break; - } + if (!EntityIsValid(target)) + return; + + if (turns == 0) { + turns = CalculateStatusTurns(target,gSpeedRaiseTurnRange,FALSE) + 1; } - movSpeed_1 = CalcSpeedStage(target); - if (movSpeed == movSpeed_1) { - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC298); + + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + speedBefore = CalcSpeedStage(target); + if (speedBefore == MAX_SPEED_STAGE) { + if (displayMessage) + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC2B8); } - else - { - sub_8041CB8(target); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FA124[movSpeed_1]); - entityInfo->speedStageChanged = TRUE; - entityInfo->attacking = FALSE; + else { + for (i = 0; i < NUM_SPEED_COUNTERS; i++) { + if (entityInfo->speedUpCounters[i] == 0) { + entityInfo->speedUpCounters[i] = turns; + break; + } + } + + speedAfter = CalcSpeedStage(target); + if (speedBefore == speedAfter) { + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC298); + } + else { + PlaySpeedUpEffect(target); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FA124[speedAfter]); + entityInfo->speedStageChanged = TRUE; + entityInfo->attacking = FALSE; + } } - } - EntityUpdateStatusSprites(target); + + UpdateStatusIconFlags(target); } -void LowerMovementSpeedTarget(Entity * pokemon, Entity * target, s32 levels, bool8 displayMessage) +void LowerSpeed(Entity *user, Entity *target, s32 nStages, bool8 displayMessage) { - s32 movSpeed; - s32 counter; - s32 index; - s32 movSpeed_1; - EntityInfo *entityInfo; + s32 speedBefore; + s32 speedAfter; + EntityInfo *entityInfo; - if (!EntityIsValid(target)) { - return; - } - if (HasSafeguardStatus(pokemon,target,displayMessage)) { - return; - } - entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); - movSpeed = CalcSpeedStage(target); - if (movSpeed == 0) { - if (displayMessage) - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC2D8); - } - else { - for(counter = 0; counter < levels; counter++) - { - for(index = 0; index < NUM_SPEED_COUNTERS; index++) - { - if (entityInfo->speedDownCounters[index]== 0) { - entityInfo->speedDownCounters[index] = CalculateStatusTurns(target,gSpeedLowerTurnRange,TRUE) + 1; - break; - } - } - } - movSpeed_1 = CalcSpeedStage(target); - if (movSpeed == movSpeed_1) { + if (!EntityIsValid(target)) + return; + + if (SafeguardIsActive(user,target,displayMessage)) + return; + + entityInfo = GetEntInfo(target); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); + speedBefore = CalcSpeedStage(target); + if (speedBefore == 0) { if (displayMessage) - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC298); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC2D8); } - else - { - sub_8041CCC(target); - TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FA124[movSpeed_1]); + else { + s32 counter, i; + for (counter = 0; counter < nStages; counter++) { + for (i = 0; i < NUM_SPEED_COUNTERS; i++) { + if (entityInfo->speedDownCounters[i]== 0) { + entityInfo->speedDownCounters[i] = CalculateStatusTurns(target,gSpeedLowerTurnRange,TRUE) + 1; + break; + } + } + } + speedAfter = CalcSpeedStage(target); + if (speedBefore == speedAfter) { + if (displayMessage) + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FC298); + } + else { + PlaySpeedDownEffect(target); + TryDisplayDungeonLoggableMessage3(user,target,gUnknown_80FA124[speedAfter]); + } } - } - EntityUpdateStatusSprites(target); -} + UpdateStatusIconFlags(target); +} diff --git a/src/move_orb_effects_2.c b/src/move_orb_effects_2.c index 15cb8849f..5ff7d68cd 100644 --- a/src/move_orb_effects_2.c +++ b/src/move_orb_effects_2.c @@ -40,7 +40,7 @@ void ConfuseStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage return; } - if (HasSafeguardStatus(pokemon,target,displayMessage)) { + if (SafeguardIsActive(pokemon,target,displayMessage)) { return; } @@ -67,7 +67,7 @@ void ConfuseStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB27C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -76,7 +76,7 @@ void CowerStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) { EntityInfo *entityInfo; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,displayMessage))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon,target,displayMessage))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->cringeClassStatus.status != STATUS_COWERING) { @@ -88,7 +88,7 @@ void CowerStatusTarget(Entity * pokemon, Entity * target, bool8 displayMessage) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB960); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -132,7 +132,7 @@ void HealTargetHP(Entity *pokemon, Entity *target, s32 param_3, s32 param_4, boo } maxHPStat = entityInfo->maxHPStat - maxHPStat; HP = entityInfo->HP - HP; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); gFormatArgs[0] = HP; gFormatArgs[1] = maxHPStat; SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); @@ -186,7 +186,7 @@ void HandleScannerOrb(Entity* pokemon, Entity* target) TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FAEA0); // Item locations became evident UpdateCamera(0); UpdateMinimap(); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -211,7 +211,7 @@ void HandleStairsOrb(Entity* pokemon, Entity* target) TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FAEC8); UpdateCamera(0); UpdateMinimap(); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -231,7 +231,7 @@ void HandleRadarOrb(Entity* pokemon, Entity* target) TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FAFAC); UpdateCamera(0); UpdateMinimap(); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -250,7 +250,7 @@ void HandleLeechSeed(Entity * pokemon, Entity * target, bool8 displayMessage) TryDisplayDungeonLoggableMessage3(pokemon,target,gPtrCantLeechSeedSelfMessage); } else { - if (HasSafeguardStatus(pokemon,target,displayMessage)) { + if (SafeguardIsActive(pokemon,target,displayMessage)) { return; } SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); @@ -284,7 +284,7 @@ void HandleLeechSeed(Entity * pokemon, Entity * target, bool8 displayMessage) } } TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FAE58); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -308,7 +308,7 @@ void sub_8078084(Entity * pokemon) if(entityInfo2->leechSeedClassStatus.unk4 == entityInfo->dungeonSpriteId) { entityInfo2->leechSeedClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -350,7 +350,7 @@ void DestinyBondStatusTarget(Entity * pokemon, Entity * target) } } TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBB4C); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -370,7 +370,7 @@ void SureShotStatusTarget(Entity *pokemon, Entity * target, s32 turns) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB764); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -378,7 +378,7 @@ void WhifferStatusTarget(Entity *pokemon, Entity * target, s32 turns) { EntityInfo *entityInfo; - if (EntityIsValid(target) && !HasSafeguardStatus(pokemon, target, TRUE)) { + if (EntityIsValid(target) && !SafeguardIsActive(pokemon, target, TRUE)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->sureShotClassStatus.status != STATUS_WHIFFER) { @@ -390,7 +390,7 @@ void WhifferStatusTarget(Entity *pokemon, Entity * target, s32 turns) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB7A0); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -410,7 +410,7 @@ void FixedDamageStatusTarget(Entity *pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB8E4); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -430,7 +430,7 @@ void FocusEnergyStatusTarget(Entity *pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB924); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -443,7 +443,7 @@ void sub_80783C4(Entity * pokemon, Entity * target, bool8 param_3) ActionContainer action; s32 index; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon, target, TRUE))) { targetEntityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (targetEntityInfo->curseClassStatus.status == STATUS_DECOY) { @@ -488,7 +488,7 @@ void sub_80783C4(Entity * pokemon, Entity * target, bool8 param_3) } } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -504,7 +504,7 @@ void CurseStatusTarget(Entity *pokemon, Entity * target) pokemonEntityData = GetEntInfo(pokemon); targetEntityInfo = GetEntInfo(target); if (MonsterIsType(pokemon, TYPE_GHOST)) { - if (HasSafeguardStatus(pokemon,target, TRUE)) { + if (SafeguardIsActive(pokemon,target, TRUE)) { return; } EndCurseClassStatus(pokemon,target,STATUS_CURSED); @@ -523,11 +523,11 @@ void CurseStatusTarget(Entity *pokemon, Entity * target) TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB004); } else { - RaiseAttackStageTarget(pokemon,pokemon,gStatIndexAtkDef,1); - RaiseDefenseStageTarget(pokemon,pokemon,gStatIndexAtkDef,1); - LowerMovementSpeedTarget(pokemon,pokemon,1,TRUE); + BoostOffensiveStat(pokemon,pokemon,gStatIndexAtkDef,1); + BoostDefensiveStat(pokemon,pokemon,gStatIndexAtkDef,1); + LowerSpeed(pokemon,pokemon,1,TRUE); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -560,7 +560,7 @@ void SnatchStatusTarget(Entity * pokemon, Entity * target) gDungeon->unk17B3C = targetEntityInfo->dungeonSpriteId; SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB01C); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -568,7 +568,7 @@ void TauntStatusTarget(Entity * pokemon, Entity * target) { EntityInfo *entityInfo; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon,target,TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->cringeClassStatus.status != STATUS_TAUNTED) { @@ -580,7 +580,7 @@ void TauntStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBA14); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -601,7 +601,7 @@ void HandleStockpile(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBA60); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -624,7 +624,7 @@ void InvisibleStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBAA0); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -632,7 +632,7 @@ void PerishSongTarget(Entity * pokemon, Entity * target) { EntityInfo * entityInfo; - if (EntityIsValid(target) && !HasSafeguardStatus(pokemon, target, TRUE)) { + if (EntityIsValid(target) && !SafeguardIsActive(pokemon, target, TRUE)) { nullsub_82(target); entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); @@ -643,7 +643,7 @@ void PerishSongTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBB28); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -654,7 +654,7 @@ void EncoreStatusTarget(Entity *pokemon,Entity *target) EntityInfo *EntityInfo; EntityInfo = GetEntInfo(target); - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon,target,TRUE))) { for(index = 0; index < MAX_MON_MOVES; index++) { movePtr = &EntityInfo->moves.moves[index]; @@ -675,7 +675,7 @@ void EncoreStatusTarget(Entity *pokemon,Entity *target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBBB8); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -719,7 +719,7 @@ void sub_8078A58(Entity *pokemon, Entity *target, s32 param_3, s32 param_4) TryDisplayDungeonLoggableMessage3(pokemon, target, gUnknown_80FBE40); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void sub_8078B5C(Entity *pokemon, Entity *target, u32 bellyIncrement, s32 maxBellyIncrement, bool8 displayMessage) @@ -807,14 +807,14 @@ void sub_8078B5C(Entity *pokemon, Entity *target, u32 bellyIncrement, s32 maxBel } } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void MuzzleTarget(Entity *pokemon, Entity *target) { EntityInfo *entityInfo; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon, target, TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->muzzled.muzzled != TRUE) { @@ -827,7 +827,7 @@ void MuzzleTarget(Entity *pokemon, Entity *target) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBF84); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -882,7 +882,7 @@ void TransformStatusTarget(Entity * pokemon, Entity * target) sub_806CCB4(target, sub_806CEBC(target)); CopyCyanMonsterNametoBuffer(gFormatBuffer_Monsters[1], entityInfo->apparentID); TryDisplayDungeonLoggableMessage3(pokemon, target, gUnknown_80FBEC0); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -909,7 +909,7 @@ void MobileStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBF50); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -926,7 +926,7 @@ void ExposeStatusTarget(Entity * pokemon, Entity * target, s16 param_3) flag = FALSE; flag2 = FALSE; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon,target,TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon,target,TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->hitChanceStages[1] > 10) { @@ -954,19 +954,19 @@ void ExposeStatusTarget(Entity * pokemon, Entity * target, s16 param_3) entityInfo->exposed = TRUE; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBF9C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } void IdentityItemHolders(Entity *pokemon, Entity *target) { - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon, target, TRUE))) { UNUSED EntityInfo *entityInfo = GetEntInfo(target); if (!gDungeon->unk644.itemHoldersIdentified) { nullsub_89(target); gDungeon->unk644.itemHoldersIdentified = TRUE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC028); } else @@ -980,7 +980,7 @@ void BlindTarget(Entity *pokemon, Entity *target) { EntityInfo *entityInfo; - if ((EntityIsValid(target)) && (!HasSafeguardStatus(pokemon, target, TRUE))) { + if ((EntityIsValid(target)) && (!SafeguardIsActive(pokemon, target, TRUE))) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); if (entityInfo->blinkerClassStatus.status != STATUS_BLINKER) { @@ -996,7 +996,7 @@ void BlindTarget(Entity *pokemon, Entity *target) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB810); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -1006,7 +1006,7 @@ void CrossEyeVisionTarget(Entity *pokemon, Entity *target) if (EntityIsValid(target)) { - if(!HasSafeguardStatus(pokemon, target, TRUE)) + if(!SafeguardIsActive(pokemon, target, TRUE)) { entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); @@ -1023,7 +1023,7 @@ void CrossEyeVisionTarget(Entity *pokemon, Entity *target) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB85C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -1049,7 +1049,7 @@ void RestoreVisionTarget(Entity *pokemon, Entity *target) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB89C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -1091,7 +1091,7 @@ void RestorePPTarget(Entity * pokemon,Entity * target, s32 param_3) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FDBF0); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -1121,7 +1121,7 @@ void RaiseAtkStatTarget(Entity * pokemon, Entity *target, s32 increment) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC360); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -1151,7 +1151,7 @@ void RaiseSpAtkStatTarget(Entity * pokemon, Entity *target, s32 increment) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC3B4); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -1181,7 +1181,7 @@ void RaiseDefStatTarget(Entity * pokemon, Entity *target, s32 increment) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC3FC); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -1211,7 +1211,7 @@ void RaiseSpDefStatTarget(Entity * pokemon, Entity *target, s32 increment) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FC454); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -1229,7 +1229,7 @@ void LongTossStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FD22C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void PierceStatusTarget(Entity * pokemon, Entity * target) @@ -1246,5 +1246,5 @@ void PierceStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FD27C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } diff --git a/src/move_orb_effects_3.c b/src/move_orb_effects_3.c index b6cc71822..88a4fa367 100644 --- a/src/move_orb_effects_3.c +++ b/src/move_orb_effects_3.c @@ -75,13 +75,13 @@ void SetChargeStatusTarget(Entity *pokemon, Entity *target, u8 newStatus, Move * } sub_8041BD0(target,uVar5); TryDisplayDungeonLoggableMessage3(pokemon,target,message); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); // TODO: this could probably be cleaner.. for (index = 0, iVar8 = 0xc7ff; index < 400; index++) { bVar2 = TRUE; if (entityInfo->unkFF == 1) - if(iVar7 = entityInfo->unk174.raw, bVar2 = FALSE, iVar7 > iVar8) // unk174 -> u32 to s32 + if(iVar7 = entityInfo->unk174, bVar2 = FALSE, iVar7 > iVar8) // unk174 -> u32 to s32 { bVar2 = TRUE; } @@ -105,6 +105,6 @@ void sub_8079764(Entity * pokemon) entityInfo->unk14A = 0; entityInfo->unkFF = 0; } - EntityUpdateStatusSprites(pokemon); + UpdateStatusIconFlags(pokemon); } } diff --git a/src/move_orb_effects_4.c b/src/move_orb_effects_4.c index 8fa1da254..00d47eecd 100644 --- a/src/move_orb_effects_4.c +++ b/src/move_orb_effects_4.c @@ -45,7 +45,7 @@ void CounterStatusTarget(Entity * pokemon, Entity * target, u8 newStatus) } entityInfo->reflectClassStatus.status = newStatus; TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB0E0); - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -66,7 +66,7 @@ void SafeguardStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB074); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -86,7 +86,7 @@ void MistStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB0C4); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -106,7 +106,7 @@ void WishStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FAE3C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -126,7 +126,7 @@ void MagicCoatStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FAF8C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -146,7 +146,7 @@ void LightScreenStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB160); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -166,7 +166,7 @@ void ReflectStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB1A8); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -187,7 +187,7 @@ void ProtectStatusTarget(Entity * pokemon, Entity * target) SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FB9D8); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -207,7 +207,7 @@ void MirrorCoatStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBAE4); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -227,7 +227,7 @@ void EndureStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBC14); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -247,7 +247,7 @@ void MirrorMoveStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBC5C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -272,7 +272,7 @@ void Conversion2StatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBCA4); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } @@ -293,7 +293,7 @@ void VitalThrowStatusTarget(Entity * pokemon, Entity * target) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBCF0); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -343,7 +343,7 @@ void sub_8079E34(Entity * pokemon, Entity * target, bool8 param_3) else { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FBD3C); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } diff --git a/src/move_orb_effects_5.c b/src/move_orb_effects_5.c index 6a4942275..502498b52 100644 --- a/src/move_orb_effects_5.c +++ b/src/move_orb_effects_5.c @@ -49,7 +49,7 @@ void sub_8079F20(Entity * pokemon, Entity * target, u8 param_3, u8 param_4) moveUnsealed = FALSE; if (EntityIsValid(target)) { entityInfo = GetEntInfo(target); - if (HasNegativeStatus(target)) { + if (MonsterHasNegativeStatus(target)) { bVar8 = TRUE; EndSleepClassStatus(pokemon,target,0,0); if (!EntityIsValid(target)) { @@ -105,7 +105,7 @@ void sub_8079F20(Entity * pokemon, Entity * target, u8 param_3, u8 param_4) else if (param_4 == 0) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_81004E8); } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -128,7 +128,7 @@ void sub_807A0CC(Entity * pokemon, Entity * target) move->moveFlags2 &= ~(MOVE_FLAG_EXISTS); } } - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); }; } @@ -178,7 +178,7 @@ void EndSleepClassStatus(Entity * pokemon, Entity * target, bool8 param_3, bool8 break; } entityInfo->sleepClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); if (isAsleep) { sub_806CE68(target,8); } @@ -210,7 +210,7 @@ void EndBurnClassStatus(Entity * pokemon, Entity * target) } entityInfo->burnClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void EndFrozenClassStatus(Entity * pokemon, Entity *target) @@ -249,7 +249,7 @@ void EndFrozenClassStatus(Entity * pokemon, Entity *target) break; } entityInfo->frozenClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); if (isFrozen) { sub_8042A74(target); } @@ -291,7 +291,7 @@ void EndCringeClassStatus(Entity * pokemon, Entity *target) break; } entityInfo->cringeClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); CalcSpeedStage(target); } @@ -350,7 +350,7 @@ void EndReflectClassStatus(Entity * pokemon, Entity *target) break; } entityInfo->reflectClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void EndCurseClassStatus(Entity * pokemon, Entity * target, u8 curseClassStatus) @@ -389,7 +389,7 @@ void EndCurseClassStatus(Entity * pokemon, Entity * target, u8 curseClassStatus) break; } entityInfo->curseClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -413,7 +413,7 @@ void EndLeechSeedClassStatus(Entity * pokemon, Entity * target) } entityInfo->leechSeedClassStatus.status = STATUS_NONE; entityInfo->leechSeedClassStatus.unk8 = 0xff; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } @@ -444,7 +444,7 @@ void SendMoveEndMessage(Entity * pokemon, Entity * target) break; } entityInfo->sureShotClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } void SendTransformEndMessage(Entity * pokemon, Entity *target) @@ -479,7 +479,7 @@ void SendTransformEndMessage(Entity * pokemon, Entity *target) break; } entityInfo->invisibleClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); if (isInvisible) { sub_807EC28(TRUE); } @@ -509,7 +509,7 @@ void SendEyesightEndMessage(Entity * pokemon,Entity * target) break; } entityInfo->blinkerClassStatus.status = STATUS_NONE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); if (entityInfo->isTeamLeader) { DungeonRunFrameActions(0x31); UpdateTrapsVisibility(); @@ -535,7 +535,7 @@ void SendMuzzledEndMessage(Entity * pokemon, Entity * target) break; } entityInfo->muzzled.muzzled = FALSE; - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } bool8 TrySendImmobilizeSleepEndMsg(Entity * pokemon, Entity * target) @@ -562,7 +562,7 @@ void WakeUpPokemon(Entity * pokemon) entityInfo->sleepClassStatus.status = STATUS_NONE; entityInfo->sleepClassStatus.turns = 0; sub_806A898(pokemon, 1, 1); - EntityUpdateStatusSprites(pokemon); + UpdateStatusIconFlags(pokemon); } void SendThawedMessage(Entity *pokemon, Entity *target) @@ -577,7 +577,7 @@ void SendThawedMessage(Entity *pokemon, Entity *target) entityInfo->frozenClassStatus.damageCountdown = 0; SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0); TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FA8BC); // $m0 thawed out! - EntityUpdateStatusSprites(target); + UpdateStatusIconFlags(target); } } } diff --git a/src/moves.c b/src/moves.c index 3486190b1..2b9be4c56 100644 --- a/src/moves.c +++ b/src/moves.c @@ -190,7 +190,7 @@ s32 GetMoveBasePower(Move *move) return sMovesData[move->id].basePower; } -s32 GetMoveAccuracyOrAIChance(Move *move, u32 accuracyType) +s32 GetMoveAccuracyOrAiChance(Move *move, u32 accuracyType) { return sMovesData[move->id].accuracy[accuracyType]; } diff --git a/src/trap.c b/src/trap.c index 120bdfe23..3b6e7fcf2 100644 --- a/src/trap.c +++ b/src/trap.c @@ -410,16 +410,16 @@ void HandleMudTrap(Entity *pokemon, Entity *target) rand = DungeonRandInt(100); randDef = rand; if (rand < 25) { - LowerAttackStageTarget(pokemon,target,gStatIndexAtkDef,1,1,1); + LowerOffensiveStat(pokemon,target,gStatIndexAtkDef,1,1,1); } else if (rand < 50) { - LowerAttackStageTarget(pokemon,target,gStatIndexSpecial,1,1,1); + LowerOffensiveStat(pokemon,target,gStatIndexSpecial,1,1,1); } else if (randDef < 75) { - LowerDefenseStageTarget(pokemon,target,gStatIndexAtkDef,1,1,1); + LowerDefensiveStat(pokemon,target,gStatIndexAtkDef,1,1,1); } else { - LowerDefenseStageTarget(pokemon,target,gStatIndexSpecial,1,1,1); + LowerDefensiveStat(pokemon,target,gStatIndexSpecial,1,1,1); } } @@ -493,7 +493,7 @@ void HandleSlumberTrap(Entity *pokemon, Entity *target) void HandleSlowTrap(Entity *pokemon, Entity *target) { if(target != NULL) - LowerMovementSpeedTarget(pokemon, target, 1, TRUE); + LowerSpeed(pokemon, target, 1, TRUE); } void HandlePoisonTrap(Entity *pokemon, Entity *target) @@ -713,7 +713,7 @@ void HandleSealTrap(Entity *param_1,Entity *param_2) bool8 flag = FALSE; - if (param_2 != NULL && !HasSafeguardStatus(param_1, param_2, TRUE)) { + if (param_2 != NULL && !SafeguardIsActive(param_1, param_2, TRUE)) { info = GetEntInfo(param_2); counter = 0; for(i = 0; i < MAX_MON_MOVES;i++) diff --git a/src/trawl_orb.c b/src/trawl_orb.c index a17ca95fe..045372727 100644 --- a/src/trawl_orb.c +++ b/src/trawl_orb.c @@ -60,7 +60,7 @@ void HandleTrawlOrb(Entity *user, Entity *target) currItemEntity->spawnGenID = 0; currItemEntity->isVisible = TRUE; currItemEntity->unk22 = 0; - currItemEntity->unk1C = IntToF248_2(0); + currItemEntity->unk1C = IntToF248(0); itemInfo[itemsCount] = gDungeon->unk3804[i]; currItemEntity++; itemsCount++; @@ -132,7 +132,7 @@ void HandleTrawlOrb(Entity *user, Entity *target) for (i = 0; i < itemsCount; i++) { if (EntityIsValid(&itemEntities[i])) { IncreaseEntityPixelPos(&itemEntities[i], itemVelocity[i].x, itemVelocity[i].y); - itemEntities[i].unk1C.raw = sin_4096(unkAngle) * 0xC; + itemEntities[i].unk1C = sin_4096(unkAngle) * 0xC; sub_80462AC(&itemEntities[i], hallucinating, 0, var, 0); } } diff --git a/src/warp_target.c b/src/warp_target.c index f7eefb725..e25addd36 100644 --- a/src/warp_target.c +++ b/src/warp_target.c @@ -64,15 +64,15 @@ void WarpTarget(Entity *pokemon, Entity *target, u32 param_3, DungeonPos *pos) sub_80421AC(pokemon,target); if (ShouldDisplayEntity(target)) { direction = (info->action).direction; - target->unk1C.raw += + 0x800; - while ( target->unk1C.raw < 0xa000) { + target->unk1C += + 0x800; + while ( target->unk1C < 0xa000) { if ((gDungeonFramesCounter & 3) == 0) { direction = (direction + 1) & DIRECTION_MASK; info->action.direction = direction & DIRECTION_MASK; sub_806CE68(target,direction); } DungeonRunFrameActions(0x22); - target->unk1C.raw += 0x800; + target->unk1C += 0x800; } } @@ -110,7 +110,7 @@ void WarpTarget(Entity *pokemon, Entity *target, u32 param_3, DungeonPos *pos) UpdateCamera(1); if (ShouldDisplayEntity(target)) { direction = (info->action).direction; - target->unk1C.raw = 0x9c00; + target->unk1C = 0x9c00; do { if ((gDungeonFramesCounter & 3) == 0) { direction = (direction + 1) & DIRECTION_MASK; @@ -118,10 +118,10 @@ void WarpTarget(Entity *pokemon, Entity *target, u32 param_3, DungeonPos *pos) sub_806CE68(target,direction); } DungeonRunFrameActions(0x22); - target->unk1C.raw -= 0x400; - } while (0 < target->unk1C.raw); + target->unk1C -= 0x400; + } while (0 < target->unk1C); } - target->unk1C = IntToF248_2(0); + target->unk1C = IntToF248(0); DungeonRunFrameActions(0x22); if (flag) { TryDisplayDungeonLoggableMessage3(pokemon,target,gUnknown_80FCB14); // But it dropped back at the same spot!