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

Adds Glaive Rush, fixes for Plasma Fists and Relic Song #3476

Merged
merged 13 commits into from
Nov 18, 2023
6 changes: 5 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,10 @@
.4byte \failInstr
.endm

.macro setglaiverush
callnative BS_SetGlaiveRush
.endm

.macro setzeffect
callnative BS_SetZEffect
.endm
Expand Down Expand Up @@ -1500,7 +1504,7 @@
callnative BS_TryRecycleBerry
.4byte \ptr
.endm

.macro updatedynamax
callnative BS_UpdateDynamax
.endm
Expand Down
15 changes: 9 additions & 6 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,17 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectSyrupBomb @ EFFECT_SYRUP_BOMB
.4byte BattleScript_EffectHit @ EFFECT_IVY_CUDGEL
.4byte BattleScript_EffectMaxMove @ EFFECT_MAX_MOVE
.4byte BattleScript_EffectGlaiveRush @ EFFECT_GLAIVE_RUSH

BattleScript_EffectGlaiveRush::
call BattleScript_EffectHit_Ret
jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_TryFaintMon
setglaiverush
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
goto BattleScript_TryFaintMon

BattleScript_EffectSyrupBomb::
setmoveeffect MOVE_EFFECT_SYRUP_BOMB
call BattleScript_EffectHit_Ret
seteffectwithchance
tryfaintmon BS_TARGET
goto BattleScript_MoveEnd

Expand Down Expand Up @@ -529,7 +535,6 @@ BattleScript_EffectMakeItRain:
BattleScript_MakeItRainContinuous:
setmoveeffect MOVE_EFFECT_PAYDAY
call BattleScript_EffectHit_Ret
seteffectwithchance
tryfaintmon BS_TARGET
setmoveeffect MOVE_EFFECT_SP_ATK_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
seteffectprimary
Expand Down Expand Up @@ -1167,7 +1172,6 @@ BattleScript_HyperspaceFuryRemoveProtect::

BattleScript_EffectPlasmaFists:
call BattleScript_EffectHit_Ret
seteffectwithchance
tryfaintmon BS_TARGET
applyplasmafists
printstring STRINGID_IONDELUGEON
Expand Down Expand Up @@ -1347,7 +1351,6 @@ BattleScript_NoMoveEffect:
BattleScript_EffectRelicSong:
setmoveeffect MOVE_EFFECT_RELIC_SONG | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
call BattleScript_EffectHit_Ret
seteffectwithchance
argumentstatuseffect
tryfaintmon BS_TARGET
goto BattleScript_MoveEnd
Expand Down Expand Up @@ -3135,6 +3138,7 @@ BattleScript_HitFromAtkAnimation::
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance
BattleScript_TryFaintMon::
tryfaintmon BS_TARGET
BattleScript_MoveEnd::
moveendall
Expand All @@ -3159,6 +3163,7 @@ BattleScript_EffectHit_Ret::
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance
return

BattleScript_EffectNaturalGift:
Expand Down Expand Up @@ -3353,7 +3358,6 @@ BattleScript_EffectPoisonHit:

BattleScript_EffectAbsorb::
call BattleScript_EffectHit_Ret
seteffectwithchance
AlexOn1ine marked this conversation as resolved.
Show resolved Hide resolved
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_AbsorbHealBlock
setdrainedhp
manipulatedamage DMG_BIG_ROOT
Expand Down Expand Up @@ -3788,7 +3792,6 @@ BattleScript_EffectFlinchHit::
BattleScript_EffectFlinchStatus:
setmoveeffect MOVE_EFFECT_FLINCH
call BattleScript_EffectHit_Ret
seteffectwithchance
argumentstatuseffect
tryfaintmon BS_TARGET
goto BattleScript_MoveEnd
Expand Down
2 changes: 1 addition & 1 deletion include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ bool32 CanBattlerEscape(u32 battler); // no ability check
void BattleScriptExecute(const u8 *BS_ptr);
void BattleScriptPushCursorAndCallback(const u8 *BS_ptr);
u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn);
void ClearFuryCutterDestinyBondGrudge(u32 battler);
void ClearVariousBattlerFlags(u32 battler);
void HandleAction_RunBattleScript(void);
u32 SetRandomTarget(u32 battler);
u32 GetMoveTarget(u16 move, u8 setTarget);
Expand Down
1 change: 1 addition & 0 deletions include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
#define STATUS4_INFINITE_CONFUSION (1 << 4) // Used for Berserk Gene
#define STATUS4_SALT_CURE (1 << 5)
#define STATUS4_SYRUP_BOMB (1 << 6)
#define STATUS4_GLAIVE_RUSH (1 << 7)

#define HITMARKER_WAKE_UP_CLEAR (1 << 4) // Cleared when waking up. Never set or checked.
#define HITMARKER_SKIP_DMG_TRACK (1 << 5)
Expand Down
3 changes: 2 additions & 1 deletion include/constants/battle_move_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@
#define EFFECT_SYRUP_BOMB 411
#define EFFECT_IVY_CUDGEL 412
#define EFFECT_MAX_MOVE 413
#define EFFECT_GLAIVE_RUSH 414

#define NUM_BATTLE_MOVE_EFFECTS 414
#define NUM_BATTLE_MOVE_EFFECTS 415

#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H
18 changes: 12 additions & 6 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,12 +1531,9 @@ static bool8 JumpIfMoveAffectedByProtect(u16 move)

static bool32 AccuracyCalcHelper(u16 move)
{
if (gStatuses3[gBattlerTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBattlerTarget].battlerWithSureHit == gBattlerAttacker)
{
JumpIfMoveFailed(7, move);
return TRUE;
}
else if (B_TOXIC_NEVER_MISS >= GEN_6 && gBattleMoves[move].effect == EFFECT_TOXIC && IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_POISON))
if ((gStatuses3[gBattlerTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBattlerTarget].battlerWithSureHit == gBattlerAttacker)
|| (B_TOXIC_NEVER_MISS >= GEN_6 && gBattleMoves[move].effect == EFFECT_TOXIC && IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_POISON))
|| gStatuses4[gBattlerTarget] & STATUS4_GLAIVE_RUSH)
{
JumpIfMoveFailed(7, move);
return TRUE;
Expand Down Expand Up @@ -16283,3 +16280,12 @@ void BS_TrySetOctolock(void)
gBattlescriptCurrInstr = cmd->nextInstr;
}
}

void BS_SetGlaiveRush(void)
{
NATIVE_ARGS();

gStatuses4[gBattlerAttacker] |= STATUS4_GLAIVE_RUSH;

gBattlescriptCurrInstr = cmd->nextInstr;
}
20 changes: 15 additions & 5 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ void HandleAction_UseMove(void)
gCurrentMove = gBattleStruct->zmove.toBeUsed[gBattlerAttacker];
}


if (gBattleMons[gBattlerAttacker].hp != 0)
{
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
Expand Down Expand Up @@ -557,7 +556,7 @@ void HandleAction_UseItem(void)
gBattlerAttacker = gBattlerByTurnOrder[gCurrentTurnActionNumber];
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
ClearFuryCutterDestinyBondGrudge(gBattlerAttacker);
ClearVariousBattlerFlags(gBattlerAttacker);

gLastUsedItem = gBattleResources->bufferB[gBattlerAttacker][1] | (gBattleResources->bufferB[gBattlerAttacker][2] << 8);
gBattlescriptCurrInstr = gBattlescriptsForUsingItem[ItemId_GetBattleUsage(gLastUsedItem) - 1];
Expand Down Expand Up @@ -681,7 +680,7 @@ void HandleAction_Run(void)
{
if (!TryRunFromBattle(gBattlerAttacker)) // failed to run away
{
ClearFuryCutterDestinyBondGrudge(gBattlerAttacker);
ClearVariousBattlerFlags(gBattlerAttacker);
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_CANT_ESCAPE_2;
gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString;
gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT;
Expand Down Expand Up @@ -1334,6 +1333,7 @@ const u8* CancelMultiTurnMoves(u32 battler)

gDisableStructs[battler].rolloutTimer = 0;
gDisableStructs[battler].furyCutterCounter = 0;

return result;
}

Expand Down Expand Up @@ -3314,6 +3314,7 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
case CANCELLER_FLAGS: // flags clear
gBattleMons[gBattlerAttacker].status2 &= ~STATUS2_DESTINY_BOND;
gStatuses3[gBattlerAttacker] &= ~STATUS3_GRUDGE;
gStatuses4[gBattlerAttacker] &= ~ STATUS4_GLAIVE_RUSH;
gBattleScripting.tripleKickPower = 0;
gBattleStruct->atkCancellerTracker++;
break;
Expand Down Expand Up @@ -7866,11 +7867,12 @@ u8 ItemBattleEffects(u8 caseID, u32 battler, bool32 moveTurn)
return effect;
}

void ClearFuryCutterDestinyBondGrudge(u32 battler)
void ClearVariousBattlerFlags(u32 battler)
{
gDisableStructs[battler].furyCutterCounter = 0;
gBattleMons[battler].status2 &= ~STATUS2_DESTINY_BOND;
gStatuses3[battler] &= ~STATUS3_GRUDGE;
gStatuses4[battler] &= ~ STATUS4_GLAIVE_RUSH;
}

void HandleAction_RunBattleScript(void) // identical to RunBattleScriptCommands
Expand Down Expand Up @@ -9520,6 +9522,13 @@ static inline uq4_12_t GetCriticalModifier(bool32 isCrit)
return UQ_4_12(1.0);
}

static inline uq4_12_t GetGlaiveRushModifier(u32 battlerDef)
{
if (gStatuses4[battlerDef] & STATUS4_GLAIVE_RUSH)
return UQ_4_12(2.0);
return UQ_4_12(1.0);
}

static inline uq4_12_t GetZMaxMoveAgainstProtectionModifier(u32 battlerDef, u32 move)
{
if ((gBattleStruct->zmove.active || IsMaxMove(move)) && IS_BATTLER_PROTECTED(battlerDef))
Expand Down Expand Up @@ -9755,7 +9764,8 @@ static inline s32 DoMoveDamageCalcVars(u32 move, u32 battlerAtk, u32 battlerDef,
DAMAGE_APPLY_MODIFIER(GetParentalBondModifier(battlerAtk));
DAMAGE_APPLY_MODIFIER(GetWeatherDamageModifier(battlerAtk, move, moveType, holdEffectAtk, holdEffectDef, weather));
DAMAGE_APPLY_MODIFIER(GetCriticalModifier(isCrit));
// TODO: Glaive Rush (Gen IX effect)
DAMAGE_APPLY_MODIFIER(GetGlaiveRushModifier(battlerDef));

if (randomFactor)
{
dmg *= 100 - RandomUniform(RNG_DAMAGE_MODIFIER, 0, 15);
Expand Down
Loading
Loading