Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secondary/primary effects overhaul #3577

Merged
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
41202a9
Initial struct change + paralysis test
cfmnephrite Nov 18, 2023
45d8491
Fixed macro + implemented working Mortal Spin
cfmnephrite Nov 18, 2023
1dadc79
Triple Arrows redo
cfmnephrite Nov 20, 2023
ba6d223
matcha gotcha
AlexOn1ine Nov 19, 2023
7fb811d
burn_hit -> move_effect_burn
AlexOn1ine Nov 19, 2023
ffe89c7
Redid Fang Moves
cfmnephrite Nov 22, 2023
27c32f1
Fixed compatibilty with current move effect system and other moves
cfmnephrite Nov 23, 2023
d9f64b7
Fixed seteffectwithchance
cfmnephrite Nov 23, 2023
bec0fea
Flinching moves
cfmnephrite Nov 23, 2023
d81bf6a
EFFECT_POISON_HIT
cfmnephrite Nov 23, 2023
b7d77ad
Confusion moves
cfmnephrite Nov 23, 2023
5eae07e
Jaw Lock, Axe Kick, Spin Out
cfmnephrite Nov 23, 2023
98b2c93
Freeze/frostbite causing moves
cfmnephrite Nov 25, 2023
0e23160
Fixed macro + Jaw Lock test
cfmnephrite Nov 25, 2023
4058d16
2-Turn moves + unique moves with secondary effects
cfmnephrite Nov 25, 2023
2d0ec53
Misc moves + cmd_seteffectwithchance fix
cfmnephrite Nov 26, 2023
a1a62f4
More moves
cfmnephrite Nov 27, 2023
460eeff
All moves (I think) that hit and lower a stat
cfmnephrite Nov 28, 2023
a244d7b
Updated moves that raise the target's own stats
cfmnephrite Dec 24, 2023
a8967da
Overheat (and clones)
cfmnephrite Dec 24, 2023
e87fe53
Superpower, CC, Hammer Arm
cfmnephrite Dec 24, 2023
31b3337
Updated moves that raise the target's own stats
cfmnephrite Dec 24, 2023
cda445c
Merge remote-tracking branch 'rhh/upcoming' into secondary_effects_ov…
cfmnephrite Dec 25, 2023
f3e67cf
Removed all unused effects
cfmnephrite Dec 25, 2023
b0b9883
Removed unused effects + fixed tests + removed secondaryEffectChance
cfmnephrite Dec 25, 2023
76b4e08
Trapping moves, Secret Power, rampage moves
cfmnephrite Dec 26, 2023
c5061f0
Updated remaining moves which use secondaryEffectChance
cfmnephrite Dec 26, 2023
cd5c59a
Merge remote-tracking branch 'rhh/upcoming' into secondary_effects_ov…
cfmnephrite Dec 26, 2023
77c722e
Obsoleted 22 more effects
cfmnephrite Dec 27, 2023
417a02c
Fixed Make it Rain
cfmnephrite Dec 28, 2023
7c38056
Review fixes
cfmnephrite Dec 29, 2023
39773c0
Burn Up and Double Shock
cfmnephrite Dec 29, 2023
9d68f4a
Added Throat Chop test
cfmnephrite Dec 29, 2023
e7de08e
Unified Sonic Boom & Dragon Rage
cfmnephrite Dec 30, 2023
f5ae8e0
Rapid Spin uses additional effects + test
cfmnephrite Dec 30, 2023
b6da1a1
Tweaked helper functions
cfmnephrite Dec 30, 2023
be2e3cf
Updated primary/secondary macros
cfmnephrite Dec 30, 2023
e34373e
Renamed seteffectwithchance to setadditionaleffects
cfmnephrite Dec 30, 2023
ff51eb2
Removed unused move effects, various ids, and one script command
cfmnephrite Dec 30, 2023
60a0020
Tweaked macro to be more appealing
cfmnephrite Dec 30, 2023
9dfa0d2
Merge branch 'upcoming' into secondary_effects_overhaul
cfmnephrite Dec 30, 2023
e132f26
Merge corrections and fixes
cfmnephrite Dec 30, 2023
923d22b
Merge branch 'upcoming' of https://github.com/rh-hideout/pokeemerald-…
cfmnephrite Dec 31, 2023
0980253
Merge branch 'upcoming' into secondary_effects_overhaul
cfmnephrite Jan 1, 2024
daeba06
Fixed SetMoveEffect + Sheer Force
cfmnephrite Jan 1, 2024
4556ecc
Removed PRIMARY/SECONDARY macros; added flags
cfmnephrite Jan 2, 2024
59d76c9
A few fixes, added effects for Meteor Beam/Electro Shot
cfmnephrite Jan 2, 2024
25f0179
Review changes
cfmnephrite Jan 9, 2024
67e76f2
Some more review fixes + Fling fix
cfmnephrite Jan 10, 2024
c461673
Merge remote-tracking branch 'rhh/upcoming' into secondary_effects_ov…
cfmnephrite Jan 10, 2024
3c93f97
Apply suggestions from code review
cfmnephrite Jan 11, 2024
a76e3c7
Applied more review fixes
cfmnephrite Jan 11, 2024
baefa08
Merge remote-tracking branch 'rhh/upcoming' into secondary_effects_ov…
cfmnephrite Jan 11, 2024
f6efc75
Move functions to battle_ai_util.c
cfmnephrite Jan 11, 2024
095decb
FINAL review changes
cfmnephrite Jan 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,30 @@
.4byte \ptr
.endm

.macro seteffectwithchance
.macro setadditionaleffects
1:
.byte 0x15
jumpifhalfword CMP_EQUAL, sMOVE_EFFECT, MOVE_EFFECT_CONTINUE, 1b
.endm

.macro seteffectprimary
.macro seteffectprimary moveEffect=0
.if \moveEffect != 0
setmoveeffect \moveEffect
.endif
.byte 0x16
.endm

.macro seteffectsecondary
.macro seteffectsecondary moveEffect=0
.if \moveEffect != 0
setmoveeffect \moveEffect
.endif
.byte 0x17
.endm

.macro clearstatusfromeffect battler:req
.macro clearstatusfromeffect battler:req, moveEffect=0
.if \moveEffect != 0
setmoveeffect \moveEffect
.endif
.byte 0x18
.byte \battler
.endm
Expand Down Expand Up @@ -764,7 +775,7 @@
.byte 0x8b
.endm

.macro confuseifrepeatingattackends
.macro unused0x8C
.byte 0x8c
.endm

Expand Down Expand Up @@ -1175,8 +1186,10 @@
.4byte \jumpInstr
.endm

.macro getsecretpowereffect
.macro jumpifnotcurrentmoveargtype battler:req, failInstr:req
.byte 0xe4
.byte \battler
.4byte \failInstr
.endm

.macro pickup
Expand Down Expand Up @@ -1810,8 +1823,8 @@
.4byte \jumpInstr
.endm

.macro argumentstatuseffect
various BS_ATTACKER, VARIOUS_ARGUMENT_STATUS_EFFECT
.macro setargtobattledamage
various BS_ATTACKER, VARIOUS_SET_ARG_TO_BATTLE_DAMAGE
.endm

.macro tryhitswitchtarget failInstr:req
Expand Down Expand Up @@ -1855,10 +1868,6 @@
various \battler, VARIOUS_POWER_TRICK
.endm

.macro argumenttomoveeffect
various BS_ATTACKER, VARIOUS_ARGUMENT_TO_MOVE_EFFECT
.endm

.macro jumpifnotgrounded battler:req, jumpInstr:req
various \battler, VARIOUS_JUMP_IF_NOT_GROUNDED
.4byte \jumpInstr
Expand Down
682 changes: 81 additions & 601 deletions data/battle_scripts_1.s

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ struct BattleStruct
u32 expValue;
u8 expGettersOrder[PARTY_SIZE]; // First battlers which were sent out, then via exp-share
u8 expGetterMonId;
u8 additionalEffectsCounter:2;
u8 expOrderId:3;
u8 expGetterBattlerId:2;
u8 teamGotExpMsgPrinted:1; // The 'Rest of your team got msg' has been printed.
Expand Down Expand Up @@ -780,9 +781,7 @@ STATIC_ASSERT(sizeof(((struct BattleStruct *)0)->palaceFlags) * 8 >= MAX_BATTLER
#define IS_MOVE_SPECIAL(move)(GetBattleMoveCategory(move) == BATTLE_CATEGORY_SPECIAL)
#define IS_MOVE_STATUS(move)(gBattleMoves[move].category == BATTLE_CATEGORY_STATUS)

#define IS_EFFECT_RECOIL(effect)(effect == EFFECT_RECOIL || effect == EFFECT_RECOIL_IF_MISS)

#define IS_MOVE_RECOIL(move)(IS_EFFECT_RECOIL(gBattleMoves[move].effect))
#define IS_MOVE_RECOIL(move)(gBattleMoves[move].recoil > 0 || gBattleMoves[move].effect == EFFECT_RECOIL_IF_MISS)

#define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)
#define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0) || (gBattleStruct->enduredDamage & gBitTable[gBattlerTarget]))
Expand Down
6 changes: 4 additions & 2 deletions include/battle_ai_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ bool32 AI_IsAbilityOnSide(u32 battlerId, u32 ability);
bool32 AI_MoveMakesContact(u32 ability, u32 holdEffect, u32 move);
u32 AI_GetBattlerMoveTargetType(u32 battlerId, u32 move);
bool32 ShouldUseZMove(u32 battlerAtk, u32 battlerDef, u32 chosenMove);
u32 AI_CalcSecondaryEffectChance(u32 battler, u32 secondaryEffectChance);

// stat stage checks
bool32 AnyStatIsRaised(u32 battlerId);
Expand Down Expand Up @@ -101,6 +100,9 @@ bool32 HasOnlyMovesWithCategory(u32 battlerId, u32 category, bool32 onlyOffensiv
bool32 HasMoveWithCategory(u32 battler, u32 category);
bool32 HasMoveWithType(u32 battler, u32 type);
bool32 HasMoveEffect(u32 battlerId, u32 moveEffect);
bool32 HasMoveEffectANDArg(u32 battlerId, u32 effect, u32 argument);
bool32 HasMoveWithMoveEffect(u32 battlerId, u32 moveEffect);
bool32 HasMoveWithMoveEffectExcept(u32 battlerId, u32 moveEffect, u32 exception);
bool32 HasMoveWithLowAccuracy(u32 battlerAtk, u32 battlerDef, u32 accCheck, bool32 ignoreStatus, u32 atkAbility, u32 defAbility, u32 atkHoldEffect, u32 defHoldEffect);
bool32 IsAromaVeilProtectedMove(u32 move);
bool32 IsNonVolatileStatusMoveEffect(u32 moveEffect);
Expand All @@ -119,7 +121,7 @@ bool32 ShouldSetSun(u32 battlerAtk, u32 atkAbility, u32 holdEffect);
bool32 HasSleepMoveWithLowAccuracy(u32 battlerAtk, u32 battlerDef);
bool32 IsHealingMove(u32 move);
bool32 HasHealingEffect(u32 battler);
bool32 IsTrappingMoveEffect(u32 effect);
bool32 IsTrappingMove(u32 move);
bool32 HasTrappingMoveEffect(u32 battler);
bool32 ShouldFakeOut(u32 battlerAtk, u32 battlerDef, u32 move);
bool32 HasThawingMove(u32 battler);
Expand Down
3 changes: 1 addition & 2 deletions include/battle_script_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move, u32 atkAbility, u
u8 GetBattlerTurnOrderNum(u8 battlerId);
bool32 NoAliveMonsForPlayer(void);
bool32 NoAliveMonsForEitherParty(void);
void SetMoveEffect(bool32 primary, u32 certain);
void SetMoveEffect(bool32 primary, bool32 certain);
bool32 CanBattlerSwitch(u32 battlerId);
void BattleDestroyYesNoCursorAt(u8 cursorPosition);
void BattleCreateYesNoCursorAt(u8 cursorPosition);
Expand All @@ -48,7 +48,6 @@ u32 IsAbilityStatusProtected(u32 battler);
bool32 TryResetBattlerStatChanges(u8 battler);
bool32 CanCamouflage(u8 battlerId);
u16 GetNaturePowerMove(void);
u16 GetSecretPowerMoveEffect(void);
void StealTargetItem(u8 battlerStealer, u8 battlerItem);
u8 GetCatchingBattler(void);
u32 GetHighestStatId(u32 battlerId);
Expand Down
7 changes: 3 additions & 4 deletions include/battle_scripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ extern const u8 BattleScript_StickyWebDefog[];
extern const u8 BattleScript_StealthRockDefog[];
extern const u8 BattleScript_MegaEvolution[];
extern const u8 BattleScript_WishMegaEvolution[];
extern const u8 BattleScript_MoveEffectRecoilWithStatus[];
extern const u8 BattleScript_EffectWithChance[];
extern const u8 BattleScript_MoveEffectClearSmog[];
extern const u8 BattleScript_SideStatusWoreOffReturn[];
extern const u8 BattleScript_MoveEffectSmackDown[];
Expand Down Expand Up @@ -444,9 +442,9 @@ extern const u8 BattleScript_AffectionBasedStatusHeal[];
extern const u8 BattleScript_AffectionBasedEndurance[];
extern const u8 BattleScript_SymbiosisActivates[];
extern const u8 BattleScript_MultiHitPrintStrings[];
extern const u8 BattleScript_BurnUpRemoveType[];
extern const u8 BattleScript_RemoveFireType[];
extern const u8 BattleScript_TargetAbilityStatRaiseRet[];
extern const u8 BattleScript_DoubleShockRemoveType[];
extern const u8 BattleScript_RemoveElectricType[];
extern const u8 BattleScript_SeedSowerActivates[];
extern const u8 BattleScript_AngerShellActivates[];
extern const u8 BattleScript_WellBakedBodyActivates[];
Expand Down Expand Up @@ -525,6 +523,7 @@ extern const u8 BattleScript_EffectRaiseCritAlliesAnim[];
extern const u8 BattleScript_EffectHealOneSixthAllies[];
extern const u8 BattleScript_EffectCureStatusAllies[];
extern const u8 BattleScript_EffectRecycleBerriesAllies[];
extern const u8 BattleScript_RemoveGenericType[];

// dynamax and max raids
extern const u8 BattleScript_DynamaxBegins[];
Expand Down
8 changes: 7 additions & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ void CopyMonAbilityAndTypesToBattleMon(u32 battler, struct Pokemon *mon);
void RecalcBattlerStats(u32 battler, struct Pokemon *mon);
bool32 IsAlly(u32 battlerAtk, u32 battlerDef);
bool32 IsGen6ExpShareEnabled(void);
bool32 MoveHasMoveEffect(u32 move, u32 moveEffect);
bool32 MoveHasMoveEffectWithChance(u32 move, u32 moveEffect, u32 chance);
bool32 MoveHasMoveEffectSelf(u32 move, u32 moveEffect);
bool32 MoveHasMoveEffectSelfArg(u32 move, u32 moveEffect, u32 argument);

bool32 CanSleep(u32 battler);
bool32 CanBePoisoned(u32 battlerAttacker, u32 battlerTarget);
Expand All @@ -238,9 +242,11 @@ void RemoveConfusionStatus(u32 battler);
u8 GetBattlerGender(u32 battler);
bool32 AreBattlersOfOppositeGender(u32 battler1, u32 battler2);
bool32 AreBattlersOfSameGender(u32 battler1, u32 battler2);
u32 CalcSecondaryEffectChance(u32 battler, u8 secondaryEffectChance, u16 moveEffect);
u32 CalcSecondaryEffectChance(u32 battler, u32 battlerAbility, const struct AdditionalEffect *additionalEffect);
bool32 MoveEffectIsGuaranteed(u32 battler, u32 battlerAbility, const struct AdditionalEffect *additionalEffect);
u8 GetBattlerType(u32 battler, u8 typeIndex);
bool8 CanMonParticipateInSkyBattle(struct Pokemon *mon);
bool8 IsMonBannedFromSkyBattles(u16 species);
void RemoveBattlerType(u32 battler, u8 type);

#endif // GUARD_BATTLE_UTIL_H
2 changes: 1 addition & 1 deletion include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
#define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8.
#define B_FOG_TERRAIN TRUE // If TRUE, overworld Fog generates Misty Terrain as in Gen 8.
#define B_TERRAIN_TYPE_BOOST GEN_LATEST // In Gen8, damage is boosted by 30% instead of 50%.
#define B_SECRET_POWER_EFFECT GEN_LATEST // Secret Power's effects change depending on terrain and generation. See GetSecretPowerMoveEffect.
#define B_SECRET_POWER_EFFECT GEN_LATEST // Secret Power's effects change depending on terrain and generation. See MOVE_EFFECT_SECRET_POWER's case in `SetMoveEffect`.
#define B_SECRET_POWER_ANIMATION GEN_LATEST // Secret Power's animations change depending on terrain and generation.
#define B_NATURE_POWER_MOVES GEN_LATEST // Nature Power calls different moves depending on terrain and generation. See sNaturePowerMoves.
#define B_CAMOUFLAGE_TYPES GEN_LATEST // Camouflage changes the user to different types depending on terrain and generation. See sTerrainToType.
Expand Down
31 changes: 16 additions & 15 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
#define MOVE_EFFECT_TOXIC 6
#define MOVE_EFFECT_FROSTBITE 7
#define PRIMARY_STATUS_MOVE_EFFECT MOVE_EFFECT_FROSTBITE // All above move effects apply primary status
#define MOVE_EFFECT_FREEZE_OR_FROSTBITE (B_USE_FROSTBITE == TRUE ? MOVE_EFFECT_FROSTBITE : MOVE_EFFECT_FREEZE)
#define MOVE_EFFECT_CONFUSION 8
#define MOVE_EFFECT_FLINCH 9
#define MOVE_EFFECT_TRI_ATTACK 10
Expand All @@ -345,7 +346,7 @@
#define MOVE_EFFECT_SP_DEF_MINUS_1 26
#define MOVE_EFFECT_ACC_MINUS_1 27
#define MOVE_EFFECT_EVS_MINUS_1 28
#define MOVE_EFFECT_BURN_UP 29
#define MOVE_EFFECT_REMOVE_ARG_TYPE 29
#define MOVE_EFFECT_RECHARGE 30
#define MOVE_EFFECT_RAGE 31
#define MOVE_EFFECT_STEAL_ITEM 32
Expand Down Expand Up @@ -387,20 +388,20 @@
#define MOVE_EFFECT_BUG_BITE 68
#define MOVE_EFFECT_RECOIL_HP_25 69
#define MOVE_EFFECT_TRAP_BOTH 70
#define MOVE_EFFECT_DOUBLE_SHOCK 71
#define MOVE_EFFECT_ROUND 72
#define MOVE_EFFECT_STOCKPILE_WORE_OFF 73
#define MOVE_EFFECT_DIRE_CLAW 74
#define MOVE_EFFECT_STEALTH_ROCK 75
#define MOVE_EFFECT_SPIKES 76
#define MOVE_EFFECT_TRIPLE_ARROWS 77
#define MOVE_EFFECT_SYRUP_BOMB 78
#define MOVE_EFFECT_FLORAL_HEALING 79

#define NUM_MOVE_EFFECTS 80

#define MOVE_EFFECT_AFFECTS_USER 0x4000
#define MOVE_EFFECT_CERTAIN 0x8000
#define MOVE_EFFECT_ROUND 71
#define MOVE_EFFECT_STOCKPILE_WORE_OFF 72
#define MOVE_EFFECT_DIRE_CLAW 73
#define MOVE_EFFECT_STEALTH_ROCK 74
#define MOVE_EFFECT_SPIKES 75
#define MOVE_EFFECT_SYRUP_BOMB 76
#define MOVE_EFFECT_FLORAL_HEALING 77
#define MOVE_EFFECT_SECRET_POWER 78

#define NUM_MOVE_EFFECTS 79

#define MOVE_EFFECT_AFFECTS_USER 0x2000
#define MOVE_EFFECT_CERTAIN 0x4000
#define MOVE_EFFECT_CONTINUE 0x8000

// Battle terrain defines for gBattleTerrain.
#define BATTLE_TERRAIN_GRASS 0
Expand Down
Loading
Loading