From 70f0018c08c1ad9028e65b13ae1bc178177b460d Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Mon, 22 Nov 2021 14:14:41 +1300 Subject: [PATCH] Partially implement Shell Trap Doesn't play the animation when the trap triggers, but kinda works? May also be incredibly buggy, but I'm not interested in working on this move any further. --- asm/macros/battle_script.inc | 5 +++-- data/battle_scripts_1.s | 2 +- include/battle.h | 13 ++++++------ src/battle_script_commands.c | 38 ++++++++++++++++++++++++++++++++---- src/data/battle_moves.h | 2 +- 5 files changed, 46 insertions(+), 14 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index cf2045eb6f..2498bce64e 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1946,9 +1946,10 @@ various \battler, VARIOUS_CLEAR_SHELL_TRAP .endm - .macro checkshelltrap battler:req, ptr:req + .macro checkshelltrap battler:req, ptr1:req, ptr2:req various \battler, VARIOUS_CHECK_SHELL_TRAP - .4byte \ptr + .4byte \ptr1 + .4byte \ptr2 .endm @ helpful macros diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d5d5707ff5..e453e37056 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -413,7 +413,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectShellTrap @ EFFECT_SHELL_TRAP BattleScript_EffectShellTrap:: - checkshelltrap BS_ATTACKER, BattleScript_MoveEnd + checkshelltrap BS_ATTACKER, BattleScript_ShellTrapExplode, BattleScript_MoveEnd clearshelltrap BS_ATTACKER attackcanceler attackstring diff --git a/include/battle.h b/include/battle.h index fbeb3ffb17..ad79240176 100644 --- a/include/battle.h +++ b/include/battle.h @@ -153,12 +153,13 @@ struct ProtectStruct u32 usedCustapBerry:1; // also quick claw u32 touchedProtectLike:1; // End of 32-bit bitfield - u8 disableEjectPack:1; - u8 statFell:1; - u8 pranksterElevated:1; - u8 quickDraw:1; - u8 beakBlastCharge:1; - u8 shellTrap:1; + u16 disableEjectPack:1; + u16 statFell:1; + u16 pranksterElevated:1; + u16 quickDraw:1; + u16 beakBlastCharge:1; + u16 shellTrapSet:1; + u16 shellTrapTriggered:1; u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 31a2d4fc6a..aa3c85375f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1543,7 +1543,8 @@ static void Cmd_attackcanceler(void) gBattleCommunication[MISS_TYPE] = B_MSG_PROTECTED; gBattlescriptCurrInstr++; } - else if (gProtectStructs[gBattlerTarget].beakBlastCharge && IsMoveMakingContact(gCurrentMove, gBattlerAttacker)) + else if ((gProtectStructs[gBattlerTarget].beakBlastCharge || gProtectStructs[gBattlerTarget].shellTrapSet) + && IsMoveMakingContact(gCurrentMove, gBattlerAttacker)) { gProtectStructs[gBattlerAttacker].touchedProtectLike = TRUE; gBattlescriptCurrInstr++; @@ -4983,7 +4984,7 @@ static void Cmd_moveend(void) effect = 1; } // Not strictly a protect effect, but works the same way - else if (gProtectStructs[gBattlerTarget].beakBlastCharge + else if (gProtectStructs[gBattlerTarget].beakBlastCharge && CanBeBurned(gBattlerAttacker) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { @@ -4993,6 +4994,21 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_BeakBlastBurn; effect = 1; } + else if (gProtectStructs[gBattlerTarget].shellTrapSet + && !TestSheerForceFlag(gBattlerAttacker, gCurrentMove) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) + { + u32 temp; + gProtectStructs[gBattlerTarget].shellTrapTriggered = TRUE; + gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; + // Swap battlers so target attacks attacker with Shell Trap + SWAP(gBattlerAttacker, gBattlerTarget, temp); + // Set current move to Shell Trap + gCurrentMove = MOVE_SHELL_TRAP; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_EffectShellTrap; + effect = TRUE; + } } gBattleScripting.moveendState++; break; @@ -9387,10 +9403,24 @@ static void Cmd_various(void) } } case VARIOUS_SET_BEAK_BLAST: - gProtectStructs[gBattlerAttacker].beakBlastCharge = 1; + gProtectStructs[gBattlerAttacker].beakBlastCharge = TRUE; break; case VARIOUS_SET_SHELL_TRAP: - gProtectStructs[gBattlerAttacker].shellTrap = 1; + gProtectStructs[gBattlerAttacker].shellTrapSet = TRUE; + break; + case VARIOUS_CLEAR_SHELL_TRAP: + gProtectStructs[gBattlerAttacker].shellTrapSet = FALSE; + break; + case VARIOUS_CHECK_SHELL_TRAP: + // Attack with Shell Trap + if (gProtectStructs[gBattlerAttacker].shellTrapSet == TRUE && gProtectStructs[gBattlerAttacker].shellTrapTriggered == TRUE) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + // Attacked with Shell Trap, go to move end + else if (gProtectStructs[gBattlerAttacker].shellTrapSet == FALSE && gProtectStructs[gBattlerAttacker].shellTrapTriggered == TRUE) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 7); + // Shell Trap failed + else + gBattlescriptCurrInstr += 11; break; case VARIOUS_SWAP_SIDE_STATUSES: { diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index bf591dac41..62c0595a61 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10218,7 +10218,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 100, .pp = 5, .secondaryEffectChance = 0, - .target = MOVE_TARGET_OPPONENTS_FIELD, + .target = MOVE_TARGET_BOTH, .priority = -3, .flags = FLAG_PROTECT_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_SPECIAL,