Skip to content

Commit

Permalink
Convert move flags and bans into GCC bitfields (#2952)
Browse files Browse the repository at this point in the history
* Slicing moves to new bitfield

* Wind moves to new bitfield

* Two-strike moves to new bitfield

* Forgot to add flagTwoStrikes to battle_moves.h

* Removed "flag" from field names

* FLAG_HIT_IN_SUBSTITUTE and FLAG_THAW_USER

* Airborne moves

* FLAG_POWDER, FLAG_TARGET_ABILITY_IGNORED and FLAG_DANCE

* FLAG_BALLISTIC and FLAG_PROTECTION_MOVE

* Fixed missing uses of MOVE_UNAVAILABLE in battle_ai_util.c

* FLAG_SOUND

* FLAG_DMG_UNDERGROUND and FLAG_DMG_UNDERWATER

* FLAG_DMG_MINIMIZE

* Cleanup

* FLAG_STAT_STAGES_IGNORED

* Updated Pollen Puff's ballistic flag

* FLAG_STRONG_JAW_BOOST and FLAG_MEGA_LAUNCHER_BOOST

* thaw

* FLAG_THREE_STRIKES

* FLAG_IRON_FIST_BOOST

* FLAG_RECKLESS_BOOST

* FLAG_HIGH_CRIT

* Removed empty flags

* Moves that fail when called by Me First + added missing Shell Trap

* Moves that fail when Gravity is active

* Better names for banned fields

* Moves that fail when called by Instruct

* Cleanup

* Contact Moves + Fixed Wandering Spirit skipping contact checks

* Inverted FLAG_PROTECT_AFFECTED so that there's a flag for moves that SKIP protect.

* Simplified B_MOVE_FLAGS configs

* FORBIDDEN_METRONOME

* Renamed hitsPastSubstitute to ignoresSubstitute

* FORBIDDEN_PARENTAL_BOND

* Struggle uncallable by Metronome

* FORBIDDEN_MIMIC

* FLAG_KINGS_ROCK_AFFECTED

* Made a single config for move flags

* Macro for checking move flags

* FLAG_MAGIC_COAT_AFFECTED

* Fixed HasMagicCoatAffectedMove

* FLAG_SNATCH_AFFECTED

* Removed unused EFFECT_FLINCH_MINIMIZE_HIT

* Fixed Stench/King's Rock interaction

* Removed sMovesNotAffectedByStench in favor of checking move effects

* Removed EFFECT_TWISTER, which was a repeat of EFFECT_FLINCH_HIT

* Changed Gen2 configs to less than Gen 3

* FORBIDDEN_SLEEP_TALK

* Cleanup

* Inverted FLAG_MIRROR_MOVE_AFFECTED

* FLAG_SHEER_FORCE_BOOST

* Ordered

* FORBIDDEN_ASSIST and FORBIDDEN_COPYCAT

* Removed TestMoveFlags and TestMoveFlagsInMoveset + flags field

* Fixed Triple Arrows test
  • Loading branch information
AsparagusEduardo authored Jul 3, 2023
1 parent 40a5995 commit 1fa9a05
Show file tree
Hide file tree
Showing 30 changed files with 1,906 additions and 2,107 deletions.
8 changes: 0 additions & 8 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectPsychUp @ EFFECT_PSYCH_UP
.4byte BattleScript_EffectMirrorCoat @ EFFECT_MIRROR_COAT
.4byte BattleScript_EffectSkullBash @ EFFECT_SKULL_BASH
.4byte BattleScript_EffectTwister @ EFFECT_TWISTER
.4byte BattleScript_EffectEarthquake @ EFFECT_EARTHQUAKE
.4byte BattleScript_EffectFutureSight @ EFFECT_FUTURE_SIGHT
.4byte BattleScript_EffectGust @ EFFECT_GUST
.4byte BattleScript_EffectStomp @ EFFECT_FLINCH_MINIMIZE_HIT
.4byte BattleScript_EffectSolarBeam @ EFFECT_SOLAR_BEAM
.4byte BattleScript_EffectThunder @ EFFECT_THUNDER
.4byte BattleScript_EffectTeleport @ EFFECT_TELEPORT
Expand Down Expand Up @@ -5390,12 +5388,6 @@ BattleScript_SkullBashEnd::
call BattleScript_PowerHerbActivation
goto BattleScript_TwoTurnMovesSecondTurn

BattleScript_EffectTwister:
BattleScript_FlinchEffect:
BattleScript_EffectStomp:
setmoveeffect MOVE_EFFECT_FLINCH
goto BattleScript_EffectHit

BattleScript_EffectBulldoze:
setmoveeffect MOVE_EFFECT_SPD_MINUS_1
BattleScript_EffectEarthquake:
Expand Down
7 changes: 6 additions & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ struct BattleStruct
#define IS_MOVE_SPECIAL(move)(GetBattleMoveSplit(move) == SPLIT_SPECIAL)
#define IS_MOVE_STATUS(move)(gBattleMoves[move].split == SPLIT_STATUS)

#define IS_MOVE_RECOIL(move)(gBattleMoves[move].effect == EFFECT_RECOIL_25 \
|| gBattleMoves[move].effect == EFFECT_RECOIL_IF_MISS \
|| gBattleMoves[move].effect == EFFECT_RECOIL_50 \
|| gBattleMoves[move].effect == EFFECT_RECOIL_33 \
|| gBattleMoves[move].effect == EFFECT_RECOIL_33_STATUS)

#define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0))
#define BATTLER_DAMAGED(battlerId) ((gSpecialStatuses[battlerId].physicalDmg != 0 || gSpecialStatuses[battlerId].specialDmg != 0))
Expand All @@ -703,7 +709,6 @@ struct BattleStruct
gBattleMons[battlerId].type3 = TYPE_MYSTERY; \
}


#define IS_BATTLER_PROTECTED(battlerId)(gProtectStructs[battlerId].protected \
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_WIDE_GUARD \
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_QUICK_GUARD \
Expand Down
8 changes: 5 additions & 3 deletions include/battle_ai_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ bool32 HasMoveWithType(u32 battler, u8 type);
bool32 HasMoveWithTypeAndSplit(u32 battler, u8 type, u8 split);
bool32 HasMoveEffect(u32 battlerId, u16 moveEffect);
bool32 HasMoveWithLowAccuracy(u8, u8, u8, bool32, u16, u16, u16, u16);
bool32 TestMoveFlagsInMoveset(u8 battler, u32 flags);
bool32 IsAromaVeilProtectedMove(u16 move);
bool32 IsNonVolatileStatusMoveEffect(u16 moveEffect);
bool32 IsStatLoweringMoveEffect(u16 moveEffect);
Expand All @@ -107,7 +106,6 @@ bool32 IsMoveEncouragedToHit(u8 battlerAtk, u8 battlerDef, u16 move);
bool32 IsHazardMoveEffect(u16 moveEffect);
bool32 MoveCallsOtherMove(u16 move);
bool32 MoveRequiresRecharging(u16 move);
bool32 IsInstructBannedMove(u16 move);
bool32 IsEncoreEncouragedEffect(u16 moveEffect);
void ProtectChecks(u8 battlerAtk, u8 battlerDef, u16 move, u16 predictedMove, s16 *score);
bool32 ShouldSetSandstorm(u8 battler, u16 ability, u16 holdEffect);
Expand All @@ -121,13 +119,17 @@ bool32 HasHealingEffect(u32 battler);
bool32 IsTrappingMoveEffect(u16 effect);
bool32 HasTrappingMoveEffect(u8 battler);
bool32 ShouldFakeOut(u8 battlerAtk, u8 battlerDef, u16 move);
bool32 HasThawingMove(u8 battlerId);
bool32 HasThawingMove(u8 battler);
bool32 IsStatRaisingEffect(u16 effect);
bool32 IsStatLoweringEffect(u16 effect);
bool32 IsStatRaisingEffect(u16 effect);
bool32 IsAttackBoostMoveEffect(u16 effect);
bool32 IsUngroundingEffect(u16 effect);
bool32 IsSemiInvulnerable(u8 battlerDef, u16 move);
bool32 HasSoundMove(u8 battler);
bool32 HasHighCritRatioMove(u8 battler);
bool32 HasMagicCoatAffectedMove(u8 battler);
bool32 HasSnatchAffectedMove(u8 battler);

// status checks
bool32 AI_CanBeBurned(u8 battler, u16 ability);
Expand Down
1 change: 0 additions & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ void ClearIllusionMon(u32 battlerId);
bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId);
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
u8 GetBattleMoveSplit(u32 moveId);
bool32 TestMoveFlags(u16 move, u32 flag);
bool32 CanFling(u8 battlerId);
bool32 IsTelekinesisBannedSpecies(u16 species);
bool32 IsHealBlockPreventingMove(u32 battler, u32 move);
Expand Down
1 change: 1 addition & 0 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
// Move data settings
#define B_UPDATED_MOVE_DATA GEN_LATEST // Updates move data in gBattleMoves, including Power, Accuracy, PP, stat changes, targets and chances of secondary effects.
#define B_UPDATED_MOVE_TYPES GEN_LATEST // Updates move types.
#define B_UPDATED_MOVE_FLAGS GEN_LATEST // Updates move flags.
#define B_PHYSICAL_SPECIAL_SPLIT GEN_LATEST // In Gen3, the move's type determines if it will do physical or special damage. The split icon in the summary will reflect this.
#define B_RECOIL_IF_MISS_DMG GEN_LATEST // In Gen5+, Jump Kick and High Jump Kick will always do half of the user's max HP when missing.
#define B_KLUTZ_FLING_INTERACTION GEN_LATEST // In Gen5+, Pokémon with the Klutz ability can't use Fling.
Expand Down
Loading

0 comments on commit 1fa9a05

Please sign in to comment.