diff --git a/asm/include/overlay_29_0230AD04.inc b/asm/include/overlay_29_0230AD04.inc index 356bf0ef..4c386ab4 100644 --- a/asm/include/overlay_29_0230AD04.inc +++ b/asm/include/overlay_29_0230AD04.inc @@ -12,7 +12,7 @@ .public FixedPoint32To64 .public FixedPoint64IsZero .public GetApparentWeather -.public GetFlashFireStatus +.public FlashFireShouldActivate .public GetTypeMatchup .public GhostImmunityIsActive .public IntToFixedPoint64 diff --git a/asm/include/overlay_29_0230BBAC.inc b/asm/include/overlay_29_0230BBAC.inc index 3009da80..be009503 100644 --- a/asm/include/overlay_29_0230BBAC.inc +++ b/asm/include/overlay_29_0230BBAC.inc @@ -45,7 +45,7 @@ .public GenerateStandardItem .public GetApparentWeather .public GetEquivItemIndex -.public GetFlashFireStatus +.public FlashFireShouldActivate .public GetItemAtIdx .public GetMonsterGenderVeneer .public GetMoveCategory diff --git a/asm/include/overlay_29_0232692C.inc b/asm/include/overlay_29_0232692C.inc index 30f15aa9..2fa565eb 100644 --- a/asm/include/overlay_29_0232692C.inc +++ b/asm/include/overlay_29_0232692C.inc @@ -9,7 +9,7 @@ .public DungeonRandOutcomeUserTargetInteraction .public EndFrozenStatus .public GetDamageSourceWrapper -.public GetFlashFireStatus +.public FlashFireShouldActivate .public GetMoveCategory .public GetMoveType .public LogMessageByIdWithPopupCheckUserTarget diff --git a/asm/overlay_29_0230AD04.s b/asm/overlay_29_0230AD04.s index efba6e62..19702152 100644 --- a/asm/overlay_29_0230AD04.s +++ b/asm/overlay_29_0230AD04.s @@ -308,7 +308,7 @@ _0230B14C: bne _0230B198 mov r0, sl mov r1, sb - bl GetFlashFireStatus + bl FlashFireShouldActivate cmp r0, #0 beq _0230B198 ldr r1, _0230B798 ; =DUNGEON_PTR diff --git a/asm/overlay_29_0230BBAC.s b/asm/overlay_29_0230BBAC.s index ce541f9d..e4e04f64 100644 --- a/asm/overlay_29_0230BBAC.s +++ b/asm/overlay_29_0230BBAC.s @@ -1132,7 +1132,7 @@ _0230CB78: bne _0230CC78 mov r0, sl mov r1, sb - bl GetFlashFireStatus + bl FlashFireShouldActivate movs r4, r0 beq _0230CC78 ldrb r0, [r7, #0x15c + CALC_DAMAGE_OFFSET] diff --git a/asm/overlay_29_0232692C.s b/asm/overlay_29_0232692C.s index d118743d..1c36e92b 100644 --- a/asm/overlay_29_0232692C.s +++ b/asm/overlay_29_0232692C.s @@ -170,7 +170,7 @@ DoMoveWillOWisp: ; 0x02326B24 sub sp, sp, #4 mov r6, r0 mov r5, r1 - bl GetFlashFireStatus + bl FlashFireShouldActivate movs r4, r0 beq _02326B94 ldr r3, [r5, #0xb4] diff --git a/include/move_orb_effects.h b/include/move_orb_effects.h index 2554d69c..bddfa993 100644 --- a/include/move_orb_effects.h +++ b/include/move_orb_effects.h @@ -20,24 +20,24 @@ struct StatIndex int id; }; -void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 nStagesRaw, bool8 checkProtected, bool8 logMsgProtected); -void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 increment, bool8 checkProtected, bool8 logMsgProtected); -void BoostOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 nStagesRaw); -void BoostDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 nStagesRaw); +void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 n_stages, bool8 check_is_protected_from_stat_drops, bool8 log_message_if_protected_from_stat_drops); +void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 increment, bool8 check_is_protected_from_stat_drops, bool8 log_message_if_protected_from_stat_drops); +void BoostOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 n_stages); +void BoostDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 n_stages); // Checks whether Flash Fire should activate, assuming the defender is being hit by a Fire-type move. // This checks that the defender is valid and Flash Fire is active, and that Normalize isn't active on the attacker. -enum flash_fire_status GetFlashFireStatus(struct entity *attacker, struct entity *defender); -void ActivateFlashFire(struct entity *pokemon, struct entity *target); -void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat, fx32_8 multiplier, bool8 displayMessage); -void ApplyDefensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat, fx32_8 multiplier, bool8 displayMessage); -void BoostHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat); -void LowerHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat, bool8 displayMessage); -bool8 TryInflictCringeStatus(struct entity *user ,struct entity *target, bool8 displayMessage, bool8 onlyCheck); -bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool8 displayMessage, bool8 onlyCheck); +enum flash_fire_status FlashFireShouldActivate(struct entity *attacker, struct entity *defender); +void ActivateFlashFire(struct entity *attacker, struct entity *defender); +void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat_idx, fx32_8 multiplier, bool8 display_message); +void ApplyDefensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat_idx, fx32_8 multiplier, bool8 display_message); +void BoostHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat_idx); +void LowerHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat_idx, bool8 display_message); +bool8 TryInflictCringeStatus(struct entity *user ,struct entity *target, bool8 log_failure, bool8 check_only); +bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool8 log_failure, bool8 check_only); // Checks if a monster is a team member under the effects of a certain exclusive item effect. bool8 ExclusiveItemEffectIsActive__023147EC(struct entity *entity, enum exclusive_item_effect_id effect_id); -void BoostSpeed(struct entity *user, struct entity *target, s32 nStages, s32 turns, bool8 displayMessage); -void BoostSpeedOneStage(struct entity *user, struct entity *target, s32 turns, bool8 displayMessage); -void LowerSpeed(struct entity *user, struct entity *target, s32 nStages, bool8 displayMessage); +void BoostSpeed(struct entity *user, struct entity *target, s32 n_stages, s32 turns, bool8 log_failure); +void BoostSpeedOneStage(struct entity *user, struct entity *target, s32 turns, bool8 log_failure); +void LowerSpeed(struct entity *user, struct entity *target, s32 n_stages, bool8 log_failure); #endif //PMDSKY_MOVE_ORB_EFFECTS_H diff --git a/include/overlay_29_02344AF8.h b/include/overlay_29_02344AF8.h index 326143d6..fc1af72c 100644 --- a/include/overlay_29_02344AF8.h +++ b/include/overlay_29_02344AF8.h @@ -1,19 +1,18 @@ #ifndef PMDSKY_OVERLAY_29_02344AF8_H #define PMDSKY_OVERLAY_29_02344AF8_H +#include "util.h" +#include "dungeon_mode.h" + struct unk_023531A4 { u8 field_0x0[4]; }; -#include "util.h" - -#include "dungeon_mode.h" - // Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity). bool8 EntityIsValid__02344AF8(struct entity *entity); void ov29_02344B1C(void); void ov29_02344B30(void); -void PrepareItemForPrinting__02345728(s32 a, s32 b); -void PrepareItemForPrinting__02345754(s32 a, s32 b); +void PrepareItemForPrinting__02345728(s32 tag_id, struct item *item); +void PrepareItemForPrinting__02345754(s32 tag_id, struct item *item); #endif //PMDSKY_OVERLAY_29_02344AF8_H diff --git a/include/overlay_29_0234B024.h b/include/overlay_29_0234B024.h index 4b81013f..2602363d 100644 --- a/include/overlay_29_0234B024.h +++ b/include/overlay_29_0234B024.h @@ -5,13 +5,54 @@ #include "main_0200C4FC.h" #include "dungeon_mode.h" -void SetMessageLogGroupStartFlag(bool8 flag); +// Contains information for the "popup alert" messages at the bottom of the screen, which are also +// printed to the message log. +struct alert_box_info { + char alert_box_messages[10][320]; + // 0xC80: Whether the message specified by the index is the start of a group + bool8 message_starts_group[10]; + u8 field_0xc8a; + u8 field_0xc8b; + u16 alert_box_current_idx; // 0xC8C: Index of current message in alert_box_messages + // 0xC8E: Index of current fully loaded message in alert_box_messages + // (i.e. for which the scrolling is finished) + u16 alert_box_current_loaded_idx; + s16 frames_until_close; // 0xC90 + u8 field_0xc92; + u8 field_0xc94; + u8 field_0xc95; + u8 field_0xc96; + u8 field_0xc97; + // 0xC98: 0 means nothing is being loaded, 1 means a message is about to start loading, + // 2 means a message is currently loading/scrolling. + u32 loading_status; + struct preprocessor_args preprocessor_args; + u8 alert_box_window_id; // 0xCEC + u8 field_0xced; + u8 field_0xcee; + u8 field_0xcef; +}; + +// Contains the alert_box_info struct as well as information related to the current message group. +struct message_log_info { + // 0x0: If true, a new message group will start on the next LogMessage call, even if the user + // matches the last user. A "group" of messages is separated by a horizontal line. + bool8 should_start_group; + u8 field_0x1; + u8 field_0x2; + u8 field_0x3; + struct alert_box_info *alert_box_info; + // 0x8: If this does not match the current user, a new group will always start + struct entity *last_user; +}; + +void SetMessageLogGroupStartFlag(bool8 should_start_group); struct preprocessor_args* GetMessageLogPreprocessorArgs(void); void InitMessageLogPreprocessorArgs(void); -void SetMessageLogPreprocessorArgsFlagVal(s32 idx, u32 val); -void SetPreprocessorArgsIdVal(s32 idx, u32 val); -void SetMessageLogPreprocessorArgsNumberVal(s32 idx, s32 val); -void SetMessageLogPreprocessorArgsString(s32 idx, char *str); -void SetMessageLogPreprocessorArgsStringToName(s32 idx, struct entity* entity); +void SetMessageLogPreprocessorArgsFlagVal(s32 pos, u32 val); +void SetPreprocessorArgsIdVal(s32 pos, u32 val); +void SetMessageLogPreprocessorArgsNumberVal(s32 pos, s32 val); +void SetMessageLogPreprocessorArgsString(s32 pos, char *string); +void SetMessageLogPreprocessorArgsStringToName(u8 pos, enum monster_id monster_id); #endif diff --git a/include/overlay_29_0234B104.h b/include/overlay_29_0234B104.h index f218eaae..16167cf0 100644 --- a/include/overlay_29_0234B104.h +++ b/include/overlay_29_0234B104.h @@ -4,7 +4,7 @@ #include "util.h" #include "main_0200C4FC.h" -void SetMessageLogPreprocessorArgsSpeakerId(u32 speaker_id); -void SetMessageLogPreprocessorArgsSpeakerId0x30000(u32 speaker_id); +void SetMessageLogPreprocessorArgsSpeakerId(u32 monster_id); +void SetMessageLogPreprocessorArgsSpeakerId0x30000(u32 team_index); #endif diff --git a/include/overlay_29_0234BA54.h b/include/overlay_29_0234BA54.h index c8584d83..2b3108db 100644 --- a/include/overlay_29_0234BA54.h +++ b/include/overlay_29_0234BA54.h @@ -1,36 +1,17 @@ #ifndef PMDSKY_OVERLAY_29_0234BA54_H #define PMDSKY_OVERLAY_29_0234BA54_H -#include "util.h" +#include "window.h" -struct unk_0234BAC0 { - s16 field_0x0; - u8 field_0x2; - u8 field_0x3; - s32 field_0x4; - s32 field_0x8; - u8 field_0xC; - u8 field_0xD; - u8 field_0xE; -}; - -struct unk_023537CC { - bool8 field_0x0; - u8 field_0x1; - u8 field_0x2; - u8 field_0x3; - u8 *field_0x4; -}; - -void WaitUntilAlertBoxPauseIsOver(u32 a); -void InitPortraitDungeon(struct unk_0234BAC0 *p, s16 a, u8 b); +void WaitUntilAlertBoxPauseIsOver(u32 param_1); +void InitPortraitDungeon(portrait_params *portrait, enum monster_id monster_id, u8 emotion); void ov29_0234BB10(void); void ov29_0234BB20(s32 a); void ov29_0234BB2C(s32 a); void ov29_0234BB38(s32 a); void ov29_0234BB44(s32 a); void ov29_0234BB50(s32 a); -s32 OpenMessageLog(s32 a, s32 b); +s32 OpenMessageLog(s32 param_1, s32 param_2); void ov29_0234BBDC(s32 a); #endif diff --git a/include/window.h b/include/window.h index 8300baba..61d470b5 100644 --- a/include/window.h +++ b/include/window.h @@ -2,6 +2,7 @@ #define PMDSKY_WINDOW_H #include "enums.h" +#include "util.h" // Represents the state of a portrait to be displayed inside a window typedef struct { @@ -11,15 +12,12 @@ typedef struct { u8 layout_idx; // 0x3: Represents the current layout to display the portrait u32 offset_x; // 0x4: Tile offset (x / 8) in the X axis to draw the portrait u32 offset_y; // 0x8: Tile offset (y / 8) in the Y axis to draw the portrait - u8 try_flip; // 0xC: Whether to try to get a flipped portrait from kaomado.kao - u8 has_flip; // 0xD: Whether the specified emote has a flipped variant - u8 hw_flip; // 0xE: Whether the portrait should be flipped using the hardware - u8 allow_default; // 0xF: If true, try using emote index 0 if the desired emote can't be found + bool8 try_flip; // 0xC: Whether to try to get a flipped portrait from kaomado.kao + bool8 has_flip; // 0xD: Whether the specified emote has a flipped variant + bool8 hw_flip; // 0xE: Whether the portrait should be flipped using the hardware + bool8 allow_default; // 0xF: If true, try using emote index 0 if the desired emote can't be found } portrait_params; - -#include "util.h" - typedef struct { s32 x; s32 y; diff --git a/src/dungeon_damage.c b/src/dungeon_damage.c index 90669778..5443c958 100644 --- a/src/dungeon_damage.c +++ b/src/dungeon_damage.c @@ -30,7 +30,7 @@ s32 WeightWeakTypePicker(struct entity *user, struct entity *target, enum type_i if (move_type == TYPE_NORMAL || move_type == TYPE_FIGHTING) check_exposed = TRUE; - if (move_type == TYPE_FIRE && GetFlashFireStatus(user, target) != FLASH_FIRE_STATUS_NONE) + if (move_type == TYPE_FIRE && FlashFireShouldActivate(user, target) != FLASH_FIRE_STATUS_NONE) return 0; #ifdef JAPAN diff --git a/src/dungeon_projectile_throw.c b/src/dungeon_projectile_throw.c index c46184f6..79db778a 100644 --- a/src/dungeon_projectile_throw.c +++ b/src/dungeon_projectile_throw.c @@ -9,6 +9,7 @@ #include "exclusive_item.h" #include "MSL_C/stdlib.h" #include "moves_1.h" +#include "overlay_29_02344AF8.h" #ifdef JAPAN #define CURVED_PROJECTILE_LOG_MESSAGE_1 0x920 @@ -25,14 +26,13 @@ extern struct dungeon *DUNGEON_PTR[]; extern bool8 ov29_022E2CA0(struct position *pos); extern void ov29_0234B4CC(bool8 val); extern s32 SinAbs4096(s32 x); -extern bool8 DisplayThrownItemShadow(s32 inX, s32 inY, u8 index); -extern bool8 DisplayItem(struct entity *entity, bool8 hallucinating, u8 a2, u8 a3, u8 a4); -extern void AdvanceFrame(u32); +extern bool8 DisplayThrownItemShadow(s32 x, s32 y, u8 index); +extern bool8 DisplayItem(struct entity *item, bool8 hallucinate, u8 on_floor, u8 dir, u8 priority); +extern void AdvanceFrame(u32 param_1); extern bool8 TwoTurnMoveForcedMiss(struct entity *target, struct move *move); extern bool8 DoesProjectileHitTarget(struct entity *user, struct entity *target); -extern void PrepareItemForPrinting__02345754(u8 *buffer, struct item *item); -extern void SubstitutePlaceholderStringTags(s32 slot, struct entity *entity, u32 param_3); -extern void ChangeMonsterAnimationToHurt(struct entity *entity, u32 new_dir); +extern void SubstitutePlaceholderStringTags(s32 string_id, struct entity *entity, u32 param_3); +extern void ChangeMonsterAnimationToHurt(struct entity *monster, u32 direction); extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); extern bool8 TryEndPetrifiedOrSleepStatus(struct entity *user, struct entity *target); extern void ApplyItemEffect(char param_1, u8 param_2, u8 param_3, struct entity *attacker, struct entity *defender, struct item *thrown_item); diff --git a/src/move_orb_effects.c b/src/move_orb_effects.c index d9610217..9c37f883 100644 --- a/src/move_orb_effects.c +++ b/src/move_orb_effects.c @@ -1,48 +1,48 @@ #include "dungeon_pokemon_attributes.h" +#include "dungeon_map_access.h" #include "dungeon_util_static.h" -#include "overlay_29_023118B4.h" -#include "move_orb_effects.h" -#include "overlay_29_02311BF8.h" -#include "overlay_29_023018AC.h" -#include "math.h" #include "dungeon_util.h" #include "exclusive_item.h" +#include "math.h" +#include "move_orb_effects.h" +#include "overlay_29_023018AC.h" +#include "overlay_29_023118B4.h" +#include "overlay_29_02311BF8.h" +#include "overlay_29_02344AF8.h" extern u8* AllocateTemp1024ByteBufferFromPool(void); extern void CopyStringFromId(u8* buf, u32 string_id); extern void SetMessageLogPreprocessorArgsString(u32 a, u8 *buf); -extern bool8 IsProtectedFromStatDrops(struct entity *user, struct entity *target, bool8 logMsg); -extern void SubstitutePlaceholderStringTags(int a, struct entity *entity, u32 param_3); -extern void PlayOffensiveStatUpEffect(struct entity *user, struct StatIndex); -extern void PlayDefensiveStatDownEffect(struct entity *user, struct StatIndex); -extern void PlayDefensiveStatUpEffect(struct entity *user, struct StatIndex); -extern void PlayOffensiveStatDownEffect(struct entity *user, struct StatIndex); -extern void PlayOffensiveStatMultiplierDownEffect(struct entity *user, struct StatIndex); -extern void PlayOffensiveStatMultiplierUpEffect(struct entity *user, struct StatIndex); -extern void PlayDefensiveStatMultiplierDownEffect(struct entity *user, struct StatIndex); -extern void PlayDefensiveStatMultiplierUpEffect(struct entity *user, struct StatIndex); -extern void PlayHitChanceUpEffect(struct entity *user, struct StatIndex); -extern void PlayHitChanceDownEffect(struct entity *user, struct StatIndex); +extern bool8 IsProtectedFromStatDrops(struct entity *user, struct entity *target, bool8 log_message); +extern void SubstitutePlaceholderStringTags(s32 string_id, struct entity *entity, u32 param_3); +extern void PlayOffensiveStatUpEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayDefensiveStatDownEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayDefensiveStatUpEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayOffensiveStatDownEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayOffensiveStatMultiplierDownEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayOffensiveStatMultiplierUpEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayDefensiveStatMultiplierDownEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayDefensiveStatMultiplierUpEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayHitChanceUpEffect(struct entity *entity, struct StatIndex stat_index); +extern void PlayHitChanceDownEffect(struct entity *entity, struct StatIndex stat_index); extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); -extern void UpdateStatusIconFlags(struct entity *); +extern void UpdateStatusIconFlags(struct entity *entity); extern void ov29_022E4338(struct entity *); -extern void PlayExclamationPointEffect__022E5D4C(struct entity *); -extern void PlayParalysisEffect(struct entity *); -extern void PlaySpeedUpEffect(struct entity *); -extern void PlaySpeedDownEffect(struct entity *); -extern fx32_8 MultiplyByFixedPoint(fx32_8 a, fx32_8 b); -extern bool8 IsProtectedFromNegativeStatus(struct entity *user ,struct entity *target, bool8 displayMessage); -extern bool8 SafeguardIsActive(struct entity *user ,struct entity *target, bool8 displayMessage); -extern void TryActivateSteadfast(struct entity *user ,struct entity *target); -extern void TryActivateQuickFeet(struct entity *user ,struct entity *target); -extern s32 CalcStatusDuration(struct entity *target, const s16 *turnRange, bool8 factorCurerSkills); -extern struct tile* GetTile(int x, int y); -extern bool8 GetExclusiveItemWithEffectFromBag(struct entity *, enum exclusive_item_effect_id effect_id, struct item *); +extern void PlayExclamationPointEffect__022E5D4C(struct entity *entity); +extern void PlayParalysisEffect(struct entity *entity); +extern void PlaySpeedUpEffect(struct entity *entity); +extern void PlaySpeedDownEffect(struct entity *entity); +extern fx32_8 MultiplyByFixedPoint(fx32_8 x, fx32_8 mult_fp); +extern bool8 IsProtectedFromNegativeStatus(struct entity *user ,struct entity *target, bool8 log_message); +extern bool8 SafeguardIsActive(struct entity *user ,struct entity *target, bool8 log_message); +extern void TryActivateSteadfast(struct entity *attacker, struct entity *defender); +extern void TryActivateQuickFeet(struct entity *attacker ,struct entity *defender); +extern s32 CalcStatusDuration(struct entity *entity, const s16 *turn_range, bool8 iq_skill_effects); +extern bool8 GetExclusiveItemWithEffectFromBag(struct entity *, enum exclusive_item_effect_id effect_id, struct item *item); extern struct preprocessor_args* GetMessageLogPreprocessorArgs(void); -extern void SetPreprocessorArgsStringToName(struct preprocessor_args* preprocessor_args, u8 pos,struct monster* monster, u8 param_4, u8 name_type); -extern void PrepareItemForPrinting__02345728(u8, struct item*); +extern void SetPreprocessorArgsStringToName(struct preprocessor_args* preprocessor_args, u8 pos, struct monster* monster, u8 param_4, u8 name_type); extern int CalcSpeedStageWrapper(struct entity* entity); -extern int CalcSpeedStage(struct entity *, int); +extern int CalcSpeedStage(struct entity *entity, s32 counter_weight); extern const s16 CRINGE_TURN_RANGE[]; extern const s16 PARALYSIS_TURN_RANGE[]; @@ -56,12 +56,12 @@ extern const u16 ov29_02353318[]; #define JPN_MSG_OFFSET 0 #endif // JAPAN -void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 nStagesRaw, bool8 checkProtected, bool8 logMsgProtected) +void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 n_stages, bool8 check_is_protected_from_stat_drops, bool8 log_message_if_protected_from_stat_drops) { struct monster *entityInfo; u8 *buffer1 = AllocateTemp1024ByteBufferFromPool(); u8 *buffer2 = AllocateTemp1024ByteBufferFromPool(); - s16 nStages = nStagesRaw; + s16 n_stages_internal = n_stages; s32 newStage; if (!EntityIsValid__023118B4(target)) @@ -76,8 +76,8 @@ void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatI SetMessageLogPreprocessorArgsString(1, buffer1); } - if (checkProtected) { - if (IsProtectedFromStatDrops(user, target, logMsgProtected)) + if (check_is_protected_from_stat_drops) { + if (IsProtectedFromStatDrops(user, target, log_message_if_protected_from_stat_drops)) return; if (ItemIsActive__02311BF8(target, ITEM_TWIST_BAND)) { @@ -102,9 +102,9 @@ void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatI PlayOffensiveStatDownEffect(target,stat); if (AbilityIsActiveVeneer(target, ABILITY_SIMPLE)) - nStages *= 2; + n_stages_internal *= 2; - if (nStages == 1) { + if (n_stages_internal == 1) { CopyStringFromId(buffer2, 0xdcd + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(2, buffer2); } @@ -114,7 +114,7 @@ void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatI } newStage = entityInfo->stat_modifiers.offensive_stages[stat.id]; - newStage -= nStages; + newStage -= n_stages_internal; if (newStage < 0) { newStage = 0; } @@ -129,12 +129,12 @@ void LowerOffensiveStat(struct entity *user, struct entity *target, struct StatI UpdateStatusIconFlags(target); } -void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 nStagesRaw, bool8 checkProtected, bool8 logMsgProtected) +void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 n_stages, bool8 check_is_protected_from_stat_drops, bool8 log_message_if_protected_from_stat_drops) { struct monster *entityInfo; u8 *buffer1 = AllocateTemp1024ByteBufferFromPool(); u8 *buffer2 = AllocateTemp1024ByteBufferFromPool(); - s16 nStages = nStagesRaw; + s16 n_stages_internal = n_stages; s32 newStage; if (!EntityIsValid__023118B4(target)) @@ -149,8 +149,8 @@ void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatI SetMessageLogPreprocessorArgsString(1, buffer1); } - if (checkProtected) { - if (IsProtectedFromStatDrops(user, target, logMsgProtected)) + if (check_is_protected_from_stat_drops) { + if (IsProtectedFromStatDrops(user, target, log_message_if_protected_from_stat_drops)) return; } @@ -159,9 +159,9 @@ void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatI PlayDefensiveStatDownEffect(target,stat); if (AbilityIsActiveVeneer(target, ABILITY_SIMPLE)) - nStages *= 2; + n_stages_internal *= 2; - if (nStages == 1) { + if (n_stages_internal == 1) { CopyStringFromId(buffer2, 0xdcd + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(2, buffer2); } @@ -171,7 +171,7 @@ void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatI } newStage = entityInfo->stat_modifiers.defensive_stages[stat.id]; - newStage -= nStages; + newStage -= n_stages_internal; if (newStage < 0) { newStage = 0; } @@ -186,12 +186,12 @@ void LowerDefensiveStat(struct entity *user, struct entity *target, struct StatI UpdateStatusIconFlags(target); } -void BoostOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 nStagesRaw) +void BoostOffensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 n_stages) { struct monster *entityInfo; u8 *buffer1 = AllocateTemp1024ByteBufferFromPool(); u8 *buffer2 = AllocateTemp1024ByteBufferFromPool(); - s16 nStages = nStagesRaw; + s16 n_stages_internal = n_stages; s32 newStage; if (!EntityIsValid__023118B4(target)) @@ -210,9 +210,9 @@ void BoostOffensiveStat(struct entity *user, struct entity *target, struct StatI } if (AbilityIsActiveVeneer(target, ABILITY_SIMPLE)) - nStages *= 2; + n_stages_internal *= 2; - if (nStages == 1) { + if (n_stages_internal == 1) { CopyStringFromId(buffer2, 0xdcd + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(2, buffer2); } @@ -222,7 +222,7 @@ void BoostOffensiveStat(struct entity *user, struct entity *target, struct StatI } newStage = entityInfo->stat_modifiers.offensive_stages[stat.id]; - newStage += nStages; + newStage += n_stages_internal; if (newStage >= MAX_STAT_STAGE) { newStage = MAX_STAT_STAGE; } @@ -237,12 +237,12 @@ void BoostOffensiveStat(struct entity *user, struct entity *target, struct StatI UpdateStatusIconFlags(target); } -void BoostDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 nStagesRaw) +void BoostDefensiveStat(struct entity *user, struct entity *target, struct StatIndex stat, s32 n_stages) { struct monster *entityInfo; u8 *buffer1 = AllocateTemp1024ByteBufferFromPool(); u8 *buffer2 = AllocateTemp1024ByteBufferFromPool(); - s16 nStages = nStagesRaw; + s16 n_stages_internal = n_stages; s32 newStage; if (!EntityIsValid__023118B4(target)) @@ -261,9 +261,9 @@ void BoostDefensiveStat(struct entity *user, struct entity *target, struct StatI } if (AbilityIsActiveVeneer(target, ABILITY_SIMPLE)) - nStages *= 2; + n_stages_internal *= 2; - if (nStages == 1) { + if (n_stages_internal == 1) { CopyStringFromId(buffer2, 0xdcd + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(2, buffer2); } @@ -273,7 +273,7 @@ void BoostDefensiveStat(struct entity *user, struct entity *target, struct StatI } newStage = entityInfo->stat_modifiers.defensive_stages[stat.id]; - newStage += nStages; + newStage += n_stages_internal; if (newStage >= MAX_STAT_STAGE) { newStage = MAX_STAT_STAGE; } @@ -288,7 +288,7 @@ void BoostDefensiveStat(struct entity *user, struct entity *target, struct StatI UpdateStatusIconFlags(target); } -enum flash_fire_status GetFlashFireStatus(struct entity *attacker, struct entity *defender) +enum flash_fire_status FlashFireShouldActivate(struct entity *attacker, struct entity *defender) { if (!EntityIsValid__023118B4(defender)) return FLASH_FIRE_STATUS_NONE; @@ -309,26 +309,26 @@ enum flash_fire_status GetFlashFireStatus(struct entity *attacker, struct entity return FLASH_FIRE_STATUS_NOT_MAXED; } -void ActivateFlashFire(struct entity *pokemon, struct entity *target) +void ActivateFlashFire(struct entity *attacker, struct entity *defender) { s32 flashFireBoost; - if (EntityIsValid__023118B4(target)) { - struct monster * entityInfo = GetEntInfo(target); - SubstitutePlaceholderStringTags(0,target,0); + if (EntityIsValid__023118B4(defender)) { + struct monster * entityInfo = GetEntInfo(defender); + SubstitutePlaceholderStringTags(0,defender,0); flashFireBoost = entityInfo->stat_modifiers.flash_fire_boost; if (++flashFireBoost >= 2) { flashFireBoost = 2; } if (entityInfo->stat_modifiers.flash_fire_boost != flashFireBoost) { entityInfo->stat_modifiers.flash_fire_boost = flashFireBoost; - ov29_022E4338(target); + ov29_022E4338(defender); } - UpdateStatusIconFlags(target); + UpdateStatusIconFlags(defender); } } -void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat, fx32_8 multiplier, bool8 displayMessage) +void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat_idx, fx32_8 multiplier, bool8 display_message) { struct monster *entityInfo; fx32_8 oldMulti; @@ -337,7 +337,7 @@ void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, st if (!EntityIsValid__023118B4(target)) return; - if (stat.id != STAT_INDEX_PHYSICAL) { + if (stat_idx.id != STAT_INDEX_PHYSICAL) { CopyStringFromId(buffer1, 0xdcb + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(1, buffer1); } @@ -346,7 +346,7 @@ void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, st SetMessageLogPreprocessorArgsString(1, buffer1); } - if (F248LessThanInt(multiplier, 1) && IsProtectedFromStatDrops(user,target,displayMessage)) + if (F248LessThanInt(multiplier, 1) && IsProtectedFromStatDrops(user,target,display_message)) return; if (ItemIsActive__02311BF8(target,ITEM_TWIST_BAND) && F248LessThanInt(multiplier, 1)) { @@ -360,10 +360,10 @@ void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, st #else if (DefenderAbilityIsActive__02311B94(user, target, ABILITY_HYPER_CUTTER, TRUE) #endif // JAPAN - && stat.id == STAT_INDEX_PHYSICAL + && stat_idx.id == STAT_INDEX_PHYSICAL && F248LessThanInt(multiplier, 1)) { - if (displayMessage) { + if (display_message) { SubstitutePlaceholderStringTags(0,target,0); LogMessageByIdWithPopupCheckUserTarget(user,target,0xd9e + JPN_MSG_OFFSET); } @@ -372,28 +372,28 @@ void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, st entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(0,target,0); - oldMulti = entityInfo->stat_modifiers.offensive_multipliers[stat.id]; + oldMulti = entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id]; if (F248LessThanInt(multiplier, 1)) { - PlayOffensiveStatMultiplierDownEffect(target,stat); + PlayOffensiveStatMultiplierDownEffect(target,stat_idx); } else { - PlayOffensiveStatMultiplierUpEffect(target,stat); + PlayOffensiveStatMultiplierUpEffect(target,stat_idx); } - entityInfo->stat_modifiers.offensive_multipliers[stat.id] = MultiplyByFixedPoint(entityInfo->stat_modifiers.offensive_multipliers[stat.id],multiplier); + entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id] = MultiplyByFixedPoint(entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id],multiplier); - if (F248LessThanFloat(entityInfo->stat_modifiers.offensive_multipliers[stat.id], 0.01)) { - entityInfo->stat_modifiers.offensive_multipliers[stat.id] = IntToF248(0.01); + if (F248LessThanFloat(entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id], 0.01)) { + entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id] = IntToF248(0.01); } - if (FloatLessThanF248(99.99, entityInfo->stat_modifiers.offensive_multipliers[stat.id])) { - entityInfo->stat_modifiers.offensive_multipliers[stat.id] = IntToF248(99.99); + if (FloatLessThanF248(99.99, entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id])) { + entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id] = IntToF248(99.99); } - if (F248GreaterThan(oldMulti, entityInfo->stat_modifiers.offensive_multipliers[stat.id])) { + if (F248GreaterThan(oldMulti, entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id])) { LogMessageByIdWithPopupCheckUserTarget(user,target,0xdd1 + JPN_MSG_OFFSET); } - else if (F248LessThan(oldMulti, entityInfo->stat_modifiers.offensive_multipliers[stat.id])) { + else if (F248LessThan(oldMulti, entityInfo->stat_modifiers.offensive_multipliers[stat_idx.id])) { LogMessageByIdWithPopupCheckUserTarget(user,target,0xdd0 + JPN_MSG_OFFSET); } else { @@ -402,7 +402,7 @@ void ApplyOffensiveStatMultiplier(struct entity *user, struct entity *target, st UpdateStatusIconFlags(target); } -void ApplyDefensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat, fx32_8 multiplier, bool8 displayMessage) +void ApplyDefensiveStatMultiplier(struct entity *user, struct entity *target, struct StatIndex stat_idx, fx32_8 multiplier, bool8 display_message) { struct monster *entityInfo; fx32_8 oldMulti; @@ -411,7 +411,7 @@ void ApplyDefensiveStatMultiplier(struct entity *user, struct entity *target, st if (!EntityIsValid__023118B4(target)) return; - if (stat.id != STAT_INDEX_PHYSICAL) { + if (stat_idx.id != STAT_INDEX_PHYSICAL) { CopyStringFromId(buffer1, 0xdc9 + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(1, buffer1); } @@ -420,33 +420,33 @@ void ApplyDefensiveStatMultiplier(struct entity *user, struct entity *target, st SetMessageLogPreprocessorArgsString(1, buffer1); } - if (F248LessThanInt(multiplier, 1) && IsProtectedFromStatDrops(user,target,displayMessage)) + if (F248LessThanInt(multiplier, 1) && IsProtectedFromStatDrops(user,target,display_message)) return; entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(0,target,0); - oldMulti = entityInfo->stat_modifiers.defensive_multipliers[stat.id]; + oldMulti = entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id]; if (F248LessThanInt(multiplier, 1)) { - PlayDefensiveStatMultiplierDownEffect(target,stat); + PlayDefensiveStatMultiplierDownEffect(target,stat_idx); } else { - PlayDefensiveStatMultiplierUpEffect(target,stat); + PlayDefensiveStatMultiplierUpEffect(target,stat_idx); } - entityInfo->stat_modifiers.defensive_multipliers[stat.id] = MultiplyByFixedPoint(entityInfo->stat_modifiers.defensive_multipliers[stat.id],multiplier); + entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id] = MultiplyByFixedPoint(entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id],multiplier); - if (F248LessThanFloat(entityInfo->stat_modifiers.defensive_multipliers[stat.id], 0.01)) { - entityInfo->stat_modifiers.defensive_multipliers[stat.id] = IntToF248(0.01); + if (F248LessThanFloat(entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id], 0.01)) { + entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id] = IntToF248(0.01); } - if (FloatLessThanF248(99.99, entityInfo->stat_modifiers.defensive_multipliers[stat.id])) { - entityInfo->stat_modifiers.defensive_multipliers[stat.id] = IntToF248(99.99); + if (FloatLessThanF248(99.99, entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id])) { + entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id] = IntToF248(99.99); } - if (F248GreaterThan(oldMulti, entityInfo->stat_modifiers.defensive_multipliers[stat.id])) { + if (F248GreaterThan(oldMulti, entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id])) { LogMessageByIdWithPopupCheckUserTarget(user,target,0xdcf + JPN_MSG_OFFSET); } - else if (F248LessThan(oldMulti, entityInfo->stat_modifiers.defensive_multipliers[stat.id])) { + else if (F248LessThan(oldMulti, entityInfo->stat_modifiers.defensive_multipliers[stat_idx.id])) { LogMessageByIdWithPopupCheckUserTarget(user,target,0xdce + JPN_MSG_OFFSET); } else { @@ -455,19 +455,19 @@ void ApplyDefensiveStatMultiplier(struct entity *user, struct entity *target, st UpdateStatusIconFlags(target); } -void BoostHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat) +void BoostHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat_idx) { struct monster *entityInfo; u8 *buffer1 = AllocateTemp1024ByteBufferFromPool(); - s16 nStages = 1; + s16 n_stages = 1; if (!EntityIsValid__023118B4(target)) return; entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(0,target,0); - PlayHitChanceUpEffect(target,stat); - if (stat.id != STAT_INDEX_ACCURACY) { + PlayHitChanceUpEffect(target,stat_idx); + if (stat_idx.id != STAT_INDEX_ACCURACY) { CopyStringFromId(buffer1, 0xdc7 + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(1, buffer1); } @@ -477,15 +477,15 @@ void BoostHitChanceStat(struct entity *user, struct entity *target, struct StatI } if (AbilityIsActiveVeneer(target, ABILITY_SIMPLE)) - nStages *= 2; + n_stages *= 2; - if (entityInfo->stat_modifiers.hit_chance_stages[stat.id] < MAX_STAT_STAGE) { - entityInfo->stat_modifiers.hit_chance_stages[stat.id] += nStages; - if (entityInfo->stat_modifiers.hit_chance_stages[stat.id] > MAX_STAT_STAGE) { - entityInfo->stat_modifiers.hit_chance_stages[stat.id] = MAX_STAT_STAGE; + if (entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] < MAX_STAT_STAGE) { + entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] += n_stages; + if (entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] > MAX_STAT_STAGE) { + entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] = MAX_STAT_STAGE; } - if (nStages >= 2) { + if (n_stages >= 2) { LogMessageByIdWithPopupCheckUserTarget(user,target,0xd95 + JPN_MSG_OFFSET); } else { @@ -499,16 +499,16 @@ void BoostHitChanceStat(struct entity *user, struct entity *target, struct StatI UpdateStatusIconFlags(target); } -void LowerHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat, bool8 displayMessage) +void LowerHitChanceStat(struct entity *user, struct entity *target, struct StatIndex stat_idx, bool8 display_message) { struct monster *entityInfo; u8 *buffer1 = AllocateTemp1024ByteBufferFromPool(); - s16 nStages = 1; + s16 n_stages = 1; if (!EntityIsValid__023118B4(target)) return; - if (stat.id != STAT_INDEX_ACCURACY) { + if (stat_idx.id != STAT_INDEX_ACCURACY) { CopyStringFromId(buffer1, 0xdc7 + JPN_MSG_OFFSET); SetMessageLogPreprocessorArgsString(1, buffer1); } @@ -517,15 +517,15 @@ void LowerHitChanceStat(struct entity *user, struct entity *target, struct StatI SetMessageLogPreprocessorArgsString(1, buffer1); } - if (IsProtectedFromStatDrops(user,target,displayMessage)) + if (IsProtectedFromStatDrops(user,target,display_message)) return; #ifdef JAPAN if (DefenderAbilityIsActive__02311B94(user, target, ABILITY_KEEN_EYE) && stat.id == STAT_INDEX_ACCURACY) { #else - if (DefenderAbilityIsActive__02311B94(user, target, ABILITY_KEEN_EYE, TRUE) && stat.id == STAT_INDEX_ACCURACY) { + if (DefenderAbilityIsActive__02311B94(user, target, ABILITY_KEEN_EYE, TRUE) && stat_idx.id == STAT_INDEX_ACCURACY) { #endif // JAPAN - if (displayMessage) { + if (display_message) { SubstitutePlaceholderStringTags(0,target,0); LogMessageByIdWithPopupCheckUserTarget(user,target,0xd9f + JPN_MSG_OFFSET); } @@ -533,19 +533,19 @@ void LowerHitChanceStat(struct entity *user, struct entity *target, struct StatI } if (AbilityIsActiveVeneer(target, ABILITY_SIMPLE)) - nStages *= 2; + n_stages *= 2; entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(0,target,0); - PlayHitChanceDownEffect(target,stat); + PlayHitChanceDownEffect(target,stat_idx); - if (entityInfo->stat_modifiers.hit_chance_stages[stat.id] > 0) { - entityInfo->stat_modifiers.hit_chance_stages[stat.id] -= nStages; - if (entityInfo->stat_modifiers.hit_chance_stages[stat.id] < 0) { - entityInfo->stat_modifiers.hit_chance_stages[stat.id] = 0; + if (entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] > 0) { + entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] -= n_stages; + if (entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] < 0) { + entityInfo->stat_modifiers.hit_chance_stages[stat_idx.id] = 0; } - if (nStages >= 2) { + if (n_stages >= 2) { LogMessageByIdWithPopupCheckUserTarget(user,target,0xd94 + JPN_MSG_OFFSET); } else { @@ -559,7 +559,7 @@ void LowerHitChanceStat(struct entity *user, struct entity *target, struct StatI UpdateStatusIconFlags(target); } -bool8 TryInflictCringeStatus(struct entity *user ,struct entity *target, bool8 displayMessage, bool8 onlyCheck) +bool8 TryInflictCringeStatus(struct entity *user ,struct entity *target, bool8 log_failure, bool8 check_only) { struct monster *entityInfo; u8 *buffer1 = AllocateTemp1024ByteBufferFromPool(); @@ -567,10 +567,10 @@ bool8 TryInflictCringeStatus(struct entity *user ,struct entity *target, bool8 d if (!EntityIsValid__023118B4(target)) return FALSE; - if (SafeguardIsActive(user, target, displayMessage)) + if (SafeguardIsActive(user, target, log_failure)) return FALSE; - if (IsProtectedFromNegativeStatus(user, target, displayMessage)) + if (IsProtectedFromNegativeStatus(user, target, log_failure)) return FALSE; #ifdef JAPAN @@ -579,12 +579,12 @@ bool8 TryInflictCringeStatus(struct entity *user ,struct entity *target, bool8 d if (DefenderAbilityIsActive__02311B94(user, target, ABILITY_INNER_FOCUS, TRUE)) { #endif SubstitutePlaceholderStringTags(0,target,0); - if (displayMessage) + if (log_failure) LogMessageByIdWithPopupCheckUserTarget(user,target,0xda2 + JPN_MSG_OFFSET); return FALSE; } - if (onlyCheck) + if (check_only) return TRUE; entityInfo = GetEntInfo(target); @@ -604,7 +604,7 @@ bool8 TryInflictCringeStatus(struct entity *user ,struct entity *target, bool8 d return TRUE; } -bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool8 displayMessage, bool8 onlyCheck) +bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool8 log_failure, bool8 check_only) { struct monster *entityInfo; bool8 alreadyParalyzed; @@ -612,10 +612,10 @@ bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool if (!EntityIsValid__023118B4(target)) return FALSE; - if (SafeguardIsActive(user, target, displayMessage)) + if (SafeguardIsActive(user, target, log_failure)) return FALSE; - if (IsProtectedFromNegativeStatus(user, target, displayMessage)) + if (IsProtectedFromNegativeStatus(user, target, log_failure)) return FALSE; #ifdef JAPAN @@ -624,13 +624,13 @@ bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool if (DefenderAbilityIsActive__02311B94(user, target, ABILITY_LIMBER, TRUE)) { #endif SubstitutePlaceholderStringTags(0,target,0); - if (displayMessage) + if (log_failure) LogMessageByIdWithPopupCheckUserTarget(user,target,0xda0 + JPN_MSG_OFFSET); return FALSE; } if (ExclusiveItemEffectIsActive__023147EC(target, EXCLUSIVE_EFF_NO_PARALYSIS)) { - if (displayMessage) { + if (log_failure) { struct item item; SubstitutePlaceholderStringTags(0,target,0); @@ -641,7 +641,7 @@ bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool return FALSE; } - if (onlyCheck) + if (check_only) return TRUE; alreadyParalyzed = TRUE; @@ -676,7 +676,7 @@ bool8 TryInflictParalysisStatus(struct entity *user, struct entity *target, bool LogMessageByIdWithPopupCheckUserTarget(user,target,0xdc5 + JPN_MSG_OFFSET); } if (GetTreatmentBetweenMonstersIgnoreStatus(target,mapMonster) == TREATMENT_TREAT_AS_ENEMY) { - TryInflictParalysisStatus(user, mapMonster, displayMessage, FALSE); + TryInflictParalysisStatus(user, mapMonster, log_failure, FALSE); } } } @@ -695,7 +695,7 @@ bool8 ExclusiveItemEffectIsActive__023147EC(struct entity *entity, enum exclusiv return FALSE; } -void BoostSpeed(struct entity *user, struct entity *target, s32 nStages, s32 turns, bool8 displayMessage) +void BoostSpeed(struct entity *user, struct entity *target, s32 n_stages, s32 turns, bool8 log_failure) { s32 speedBefore; s32 i; @@ -711,9 +711,9 @@ void BoostSpeed(struct entity *user, struct entity *target, s32 nStages, s32 tur entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(0,target,0); - speedBefore = CalcSpeedStage(target, nStages); + speedBefore = CalcSpeedStage(target, n_stages); if (speedBefore == MAX_SPEED_STAGE) { - if (displayMessage) + if (log_failure) LogMessageByIdWithPopupCheckUserTarget(user,target,0xddb + JPN_MSG_OFFSET); } else { @@ -724,7 +724,7 @@ void BoostSpeed(struct entity *user, struct entity *target, s32 nStages, s32 tur } } - speedAfter = CalcSpeedStage(target, nStages); + speedAfter = CalcSpeedStage(target, n_stages); if (speedBefore == speedAfter) { LogMessageByIdWithPopupCheckUserTarget(user,target,0xdda + JPN_MSG_OFFSET); } @@ -739,12 +739,12 @@ void BoostSpeed(struct entity *user, struct entity *target, s32 nStages, s32 tur UpdateStatusIconFlags(target); } -void BoostSpeedOneStage(struct entity *user, struct entity *target, s32 turns, bool8 displayMessage) +void BoostSpeedOneStage(struct entity *user, struct entity *target, s32 turns, bool8 log_failure) { - BoostSpeed(user, target, 1, turns, displayMessage); + BoostSpeed(user, target, 1, turns, log_failure); } -void LowerSpeed(struct entity *user, struct entity *target, s32 nStages, bool8 displayMessage) +void LowerSpeed(struct entity *user, struct entity *target, s32 n_stages, bool8 log_failure) { s32 speedBefore; s32 speedAfter; @@ -753,22 +753,22 @@ void LowerSpeed(struct entity *user, struct entity *target, s32 nStages, bool8 d if (!EntityIsValid__023118B4(target)) return; - if (SafeguardIsActive(user,target,displayMessage)) + if (SafeguardIsActive(user,target,log_failure)) return; - if (IsProtectedFromNegativeStatus(user, target, displayMessage)) + if (IsProtectedFromNegativeStatus(user, target, log_failure)) return; entityInfo = GetEntInfo(target); SubstitutePlaceholderStringTags(0,target,0); speedBefore = CalcSpeedStageWrapper(target); if (speedBefore == 0) { - if (displayMessage) + if (log_failure) LogMessageByIdWithPopupCheckUserTarget(user,target,0xddc + JPN_MSG_OFFSET); } else { s32 counter, i; - for (counter = 0; counter < nStages; counter++) { + for (counter = 0; counter < n_stages; counter++) { for (i = 0; i < NUM_SPEED_COUNTERS; i++) { if (entityInfo->speed_down_counters[i] == 0) { entityInfo->speed_down_counters[i] = CalcStatusDuration(target,SPEED_LOWER_TURN_RANGE,TRUE) + 1; @@ -778,7 +778,7 @@ void LowerSpeed(struct entity *user, struct entity *target, s32 nStages, bool8 d } speedAfter = CalcSpeedStageWrapper(target); if (speedBefore == speedAfter) { - if (displayMessage) + if (log_failure) LogMessageByIdWithPopupCheckUserTarget(user,target,0xdda + JPN_MSG_OFFSET); } else { diff --git a/src/overlay_29_0232D368.c b/src/overlay_29_0232D368.c index 38fabd33..93fbb945 100644 --- a/src/overlay_29_0232D368.c +++ b/src/overlay_29_0232D368.c @@ -6,15 +6,10 @@ #define GUARD_SWAP_LOG_MESSAGE 0xF2E #endif - extern void LogMessageByIdWithPopupCheckUserTarget(struct entity *user, struct entity *target, u32 message_id); - -extern void SubstitutePlaceholderStringTags(s32 slot, struct entity *entity, u32 a); - -extern void SwapDefensiveStages(struct entity *user, struct entity *target, s32 a); - -extern void SwapDefensiveMultipliers(struct entity *user, struct entity *target, s32 a); - +extern void SubstitutePlaceholderStringTags(s32 string_id, struct entity *entity, u32 param_3); +extern void SwapDefensiveStages(struct entity *attacker, struct entity *defender, s32 log_message); +extern void SwapDefensiveMultipliers(struct entity *attacker, struct entity *defender, s32 log_message); extern void TryInflictLuckyChantStatus(struct entity *user, struct entity *target); bool8 DoMoveLuckyChant(struct entity* attacker, struct entity* defender, struct move* move, enum item_id item_id) diff --git a/src/overlay_29_02344AF8.c b/src/overlay_29_02344AF8.c index 7748ba18..8ab64e58 100644 --- a/src/overlay_29_02344AF8.c +++ b/src/overlay_29_02344AF8.c @@ -1,18 +1,13 @@ #include "overlay_29_02344AF8.h" - -extern struct unk_023531A4 ov29_023531A4; - -extern struct unk_023531A4 ov29_023531BC; - -extern void SetPreprocessorArgsIdVal(s32 idx, u32 val); - -extern void SubstitutePlaceholderItemTags(s32 a, s32 b, struct unk_023531A4 *p); +#include "dungeon_util_static.h" #include "main_02001188.h" #include "overlay_29_0234B024.h" +extern struct unk_023531A4 ov29_023531A4; +extern struct unk_023531A4 ov29_023531BC; extern bool8 ov29_023537B0; -#include "dungeon_util_static.h" +extern void SubstitutePlaceholderItemTags(s32 tag_id, struct item *item, struct unk_023531A4 *param_3); bool8 EntityIsValid__02344AF8(struct entity *entity) { @@ -32,14 +27,14 @@ void ov29_02344B30(void) ov29_023537B0 = FALSE; } -void PrepareItemForPrinting__02345728(s32 a, s32 b) +void PrepareItemForPrinting__02345728(s32 tag_id, struct item *item) { - SetPreprocessorArgsIdVal(a, a | 0x40000); - SubstitutePlaceholderItemTags(a, b, &ov29_023531BC); + SetPreprocessorArgsIdVal(tag_id, tag_id | 0x40000); + SubstitutePlaceholderItemTags(tag_id, item, &ov29_023531BC); } -void PrepareItemForPrinting__02345754(s32 a, s32 b) +void PrepareItemForPrinting__02345754(s32 tag_id, struct item *item) { - SetPreprocessorArgsIdVal(a, a | 0x40000); - SubstitutePlaceholderItemTags(a, b, &ov29_023531A4); + SetPreprocessorArgsIdVal(tag_id, tag_id | 0x40000); + SubstitutePlaceholderItemTags(tag_id, item, &ov29_023531A4); } diff --git a/src/overlay_29_0234AFFC.c b/src/overlay_29_0234AFFC.c index b756d5b4..bbf9333c 100644 --- a/src/overlay_29_0234AFFC.c +++ b/src/overlay_29_0234AFFC.c @@ -1,22 +1,15 @@ #include "overlay_29_0234AFFC.h" #include "main_0200C4FC.h" +#include "overlay_29_0234B024.h" -struct unk_023537CC { - bool8 field_0x0; - u8 field_0x1; - u8 field_0x2; - u8 field_0x3; - u8 *field_0x4; -}; - -extern struct unk_023537CC MESSAGE_LOG_INFO; +extern struct message_log_info MESSAGE_LOG_INFO; void ov29_0234AFFC(u8 value) { - MESSAGE_LOG_INFO.field_0x4[0xCED] = value; + MESSAGE_LOG_INFO.alert_box_info->field_0xced = value; } void ov29_0234B010(u8 value) { - MESSAGE_LOG_INFO.field_0x4[0xCEE] = value; + MESSAGE_LOG_INFO.alert_box_info->field_0xcee = value; } diff --git a/src/overlay_29_0234B024.c b/src/overlay_29_0234B024.c index 3cb6697b..aed92fe8 100644 --- a/src/overlay_29_0234B024.c +++ b/src/overlay_29_0234B024.c @@ -1,62 +1,52 @@ #include "overlay_29_0234B024.h" #include "dungeon_mode.h" - -extern char *GetSize0x80Buffer(void); - -extern void GetName(char *buffer, struct entity *entity, s32 a); #include "main_0200C4FC.h" +extern struct message_log_info MESSAGE_LOG_INFO; + +extern char *GetSize0x80Buffer(void); +extern void GetName(char *dst, enum monster_id monster_id, char color_id); extern void InitPreprocessorArgs(struct preprocessor_args *args); -struct unk_023537CC { - bool8 field_0x0; - u8 field_0x1; - u8 field_0x2; - u8 field_0x3; - u8 *field_0x4; -}; - -extern struct unk_023537CC MESSAGE_LOG_INFO; - -void SetMessageLogGroupStartFlag(bool8 flag) +void SetMessageLogGroupStartFlag(bool8 should_start_group) { - MESSAGE_LOG_INFO.field_0x0 = flag; + MESSAGE_LOG_INFO.should_start_group = should_start_group; } struct preprocessor_args* GetMessageLogPreprocessorArgs(void) { - return ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C)); + return &MESSAGE_LOG_INFO.alert_box_info->preprocessor_args; } void InitMessageLogPreprocessorArgs(void) { - InitPreprocessorArgs(((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))); + InitPreprocessorArgs(&MESSAGE_LOG_INFO.alert_box_info->preprocessor_args); } -void SetMessageLogPreprocessorArgsFlagVal(s32 idx, u32 val) +void SetMessageLogPreprocessorArgsFlagVal(s32 pos, u32 val) { - ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))->flag_vals[idx] = val; + MESSAGE_LOG_INFO.alert_box_info->preprocessor_args.flag_vals[pos] = val; } -void SetPreprocessorArgsIdVal(s32 idx, u32 val) +void SetPreprocessorArgsIdVal(s32 pos, u32 val) { - ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))->id_vals[idx] = val; + MESSAGE_LOG_INFO.alert_box_info->preprocessor_args.id_vals[pos] = val; } -void SetMessageLogPreprocessorArgsNumberVal(s32 idx, s32 val) +void SetMessageLogPreprocessorArgsNumberVal(s32 pos, s32 val) { - ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))->number_vals[idx] = val; + MESSAGE_LOG_INFO.alert_box_info->preprocessor_args.number_vals[pos] = val; } -void SetMessageLogPreprocessorArgsString(s32 idx, char *str) +void SetMessageLogPreprocessorArgsString(s32 pos, char *string) { - ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))->strings[idx] = str; + MESSAGE_LOG_INFO.alert_box_info->preprocessor_args.strings[pos] = string; } -void SetMessageLogPreprocessorArgsStringToName(s32 idx, struct entity* entity) +void SetMessageLogPreprocessorArgsStringToName(u8 pos, enum monster_id monster_id) { char *buffer = GetSize0x80Buffer(); - GetName(buffer, entity, 0x4E); - ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))->strings[idx] = buffer; + GetName(buffer, monster_id, 0x4E); + MESSAGE_LOG_INFO.alert_box_info->preprocessor_args.strings[pos] = buffer; } diff --git a/src/overlay_29_0234B104.c b/src/overlay_29_0234B104.c index e957e9c3..3ce15f79 100644 --- a/src/overlay_29_0234B104.c +++ b/src/overlay_29_0234B104.c @@ -1,22 +1,15 @@ #include "overlay_29_0234B104.h" #include "main_0200C4FC.h" +#include "overlay_29_0234B024.h" -struct unk_023537CC { - bool8 field_0x0; - u8 field_0x1; - u8 field_0x2; - u8 field_0x3; - u8 *field_0x4; -}; +extern struct message_log_info MESSAGE_LOG_INFO; -extern struct unk_023537CC MESSAGE_LOG_INFO; - -void SetMessageLogPreprocessorArgsSpeakerId(u32 speaker_id) +void SetMessageLogPreprocessorArgsSpeakerId(u32 monster_id) { - ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))->speaker_id = speaker_id; + MESSAGE_LOG_INFO.alert_box_info->preprocessor_args.speaker_id = monster_id; } -void SetMessageLogPreprocessorArgsSpeakerId0x30000(u32 speaker_id) +void SetMessageLogPreprocessorArgsSpeakerId0x30000(u32 team_index) { - ((struct preprocessor_args *) (MESSAGE_LOG_INFO.field_0x4 + 0xC9C))->speaker_id = speaker_id | 0x30000; + MESSAGE_LOG_INFO.alert_box_info->preprocessor_args.speaker_id = team_index | 0x30000; } diff --git a/src/overlay_29_0234BA54.c b/src/overlay_29_0234BA54.c index 4a561cba..e8b277d5 100644 --- a/src/overlay_29_0234BA54.c +++ b/src/overlay_29_0234BA54.c @@ -1,50 +1,34 @@ #include "overlay_29_0234BA54.h" +#include "overlay_29_0234B024.h" -extern void ov29_022E0B60(s32 a); - -extern void UnkMapRelatedFunc(u32 a, u32 b); - -extern void ov29_0233A248(s32 a); - -extern void sub_0204833C(void); - -extern s32 sub_02048360(void); - -extern void sub_02048240(s32 a); - -extern void sub_02048150(s32 a); - -extern void sub_02048134(s32 a); - -extern void sub_020480CC(s32 a); - -extern void sub_0204804C(s32 a); - -extern void sub_02047FFC(s32 a); - -extern void InitPortraitParams(struct unk_0234BAC0 *p); - -extern void AllowPortraitDefault(struct unk_0234BAC0 *p, s32 a); - -extern struct unk_023537CC MESSAGE_LOG_INFO; - +extern struct message_log_info MESSAGE_LOG_INFO; extern u16 DUNGEON_BUTTON_INPUT[8]; -extern void WaitUntilAlertBoxTextIsLoaded(u32 a); +extern void ov29_022E0B60(s32 a); +extern void UnkMapRelatedFunc(u32 switch_case, u32 param_2); +extern void ov29_0233A248(s32 a); +extern void sub_0204833C(void); +extern s32 sub_02048360(void); +extern void sub_02048240(s32 a); +extern void sub_02048150(s32 a); +extern void sub_02048134(s32 a); +extern void sub_020480CC(s32 a); +extern void sub_0204804C(s32 a); +extern void sub_02047FFC(s32 a); +extern void InitPortraitParams(portrait_params *portrait); +extern void AllowPortraitDefault(portrait_params *portrait, bool32 allow); +extern void WaitUntilAlertBoxTextIsLoaded(u32 param_1); +extern void AdvanceFrame(u32 param_1); -extern void AdvanceFrame(u32 a); - -void WaitUntilAlertBoxPauseIsOver(u32 a) +void WaitUntilAlertBoxPauseIsOver(u32 param_1) { - u8 *p; + struct alert_box_info *alert_box_info = MESSAGE_LOG_INFO.alert_box_info; s32 i; - p = MESSAGE_LOG_INFO.field_0x4; - WaitUntilAlertBoxTextIsLoaded(a); - p += 0xC00; + WaitUntilAlertBoxTextIsLoaded(param_1); - for (i = 0; i < 0xF0; i++) { - if (*(s16 *) &p[0x90] < 0xB4) { + for (i = 0; i < 240; i++) { + if (alert_box_info->frames_until_close < 180) { return; } @@ -52,26 +36,26 @@ void WaitUntilAlertBoxPauseIsOver(u32 a) return; } - if (DUNGEON_BUTTON_INPUT[1] & 0xF0) { + if (DUNGEON_BUTTON_INPUT[1] & 240) { return; } - AdvanceFrame(a); + AdvanceFrame(param_1); } } -void InitPortraitDungeon(struct unk_0234BAC0 *p, s16 a, u8 b) +void InitPortraitDungeon(portrait_params *portrait, enum monster_id monster_id, u8 emotion) { - InitPortraitParams(p); - p->field_0x0 = a; - p->field_0x2 = b; - p->field_0x3 = 0; - p->field_0x4 = 2; - p->field_0x8 = 9; - p->field_0xC = 0; - p->field_0xD = 0; - p->field_0xE = 0; - AllowPortraitDefault(p, 1); + InitPortraitParams(portrait); + portrait->monster_id = monster_id; + portrait->portrait_emotion = emotion; + portrait->layout_idx = 0; + portrait->offset_x = 2; + portrait->offset_y = 9; + portrait->try_flip = FALSE; + portrait->has_flip = FALSE; + portrait->hw_flip = FALSE; + AllowPortraitDefault(portrait, 1); } void ov29_0234BB10(void) @@ -104,13 +88,13 @@ void ov29_0234BB50(s32 a) sub_02048240(a); } -s32 OpenMessageLog(s32 a, s32 b) +s32 OpenMessageLog(s32 param_1, s32 param_2) { s32 r; UnkMapRelatedFunc(6, 0); - if (a == 0) { + if (param_1 == 0) { ov29_0233A248(0); } @@ -125,7 +109,7 @@ s32 OpenMessageLog(s32 a, s32 b) AdvanceFrame(0x62); - if (b != 0) { + if (param_2 != 0) { UnkMapRelatedFunc(0, 0); } diff --git a/src/status_checks.c b/src/status_checks.c index 812b87e0..c2bb54a1 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -19,7 +19,7 @@ #define INFATUATED_MESSAGE (0xC2C + HAS_STATUS_THAT_PREVENTS_ACTING_OFFSET) #define BIDE_MESSAGE (0xC2D + HAS_STATUS_THAT_PREVENTS_ACTING_OFFSET) -extern void SubstitutePlaceholderStringTags(s32 slot, struct entity *entity, u32 param_3); +extern void SubstitutePlaceholderStringTags(s32 string_id, struct entity *entity, u32 param_3); extern void LogMessageByIdWithPopupCheckUser(struct entity *user, u32 message_id); bool8 HasStatusThatPreventsActing(struct entity *monster)