BluRosie / hg-engine

complete heart gold engine
154 stars 86 forks source link

Consolidate ability flags and reset the flag when a forme change or ability change happens #219

Open Aeliko opened 5 months ago

Aeliko commented 5 months ago

Intimidate

Generation IV

Intimidate now also activates when a Pokémon gains the Ability, such as via Skill Swap or Mega Evolution.

This applies to all abilities

Replay

Original conservation: https://discord.com/channels/446824489045721090/810895757309771796/1220691691380539392

BluRosie commented 3 months ago

is there something preventing us from doing this? we already consolidated everything

Aeliko commented 3 months ago

There are limited bits so having 1 flag for each ability wastes space. Skill Swap, etc. resets abilities so no need to track individual ability activations. These should be the vanilla flags, some of them could probably be consolidated to use ability_activated_flag if the AI doesn't read these flags:

...
    /* 0x28 */ u32 appear_check_flag : 1;    /**< has appeared */
               u32 intimidate_flag : 1;      /**< intimidate has activated */
               u32 trace_flag : 1;           /**< trace has activated */
               u32 download_flag : 1;        /**< download has activated */
               u32 anticipation_flag : 1;    /**< anticipation has printed its message */
               u32 forewarn_flag : 1;        /**< forewarn has printed its message */
               u32 slow_start_flag : 1;      /**< slow start has printed its message */
               u32 slow_start_end_flag : 1;  /**< slow start should end */
               u32 frisk_flag : 1;           /**< frisk has printed its message */
               u32 mold_breaker_flag : 1;    /**< mold breaker has printed its message */
               u32 pressure_flag : 1;        /**< pressure has printed its message */
               u32 canMega : 1;              /**< the BattlePokemon can mega */

These new flags could probably be consolidated to use ability_activated_flag:

               u32 unnerve_flag : 1;         /**< unnerve has printed its message */
               u32 dark_aura_flag : 1;       /**< dark aura has printed its message */
               u32 fairy_aura_flag : 1;      /**< fairy aura has printed its message */
               u32 aura_break_flag : 1;      /**< aura break has printed its message */
               u32 sheer_force_flag : 1;     /**< sheer force has printed its message */
               u32 imposter_flag : 1;        /**< imposter has activated */

These can't be consolidated, except that we should consider renaming air_ballon_flag to air_balloon_flag unless there's some reason not to

               u32 critical_hits : 2;        /**< tracks the amount of critical hits the pokémon has landed while in battle so far */
               u32 air_ballon_flag : 1;      /**< the held air balloon has printed its message */
               u32 potentially_affected_by_psychic_terrain_move_used_flag : 1;
               u32 parental_bond_flag : 2;
               u32 parental_bond_is_active : 1;
               u32 ability_activated_flag : 1;
               u32 : 6; // need to add to ClearBattleMonFlags when added to here as well
...