From 321634ed3baa8843ae102a7108d3d732c1308347 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Mon, 23 Jan 2023 14:42:47 -0500 Subject: [PATCH] Silk Trap Effect (#2512) * add silk trap effect, analog of obstruct Co-authored-by: ghoulslash Co-authored-by: Eduardo Quezada D'Ottone --- include/battle.h | 4 +++- src/battle_main.c | 1 + src/battle_script_commands.c | 17 +++++++++++++++++ src/battle_util.c | 2 +- src/data/battle_moves.h | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/battle.h b/include/battle.h index 9a745b4f61..94119f9b43 100644 --- a/include/battle.h +++ b/include/battle.h @@ -148,6 +148,7 @@ struct ProtectStruct u16 quickDraw:1; u16 beakBlastCharge:1; u16 quash:1; + u16 silkTrapped:1; u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; @@ -702,7 +703,8 @@ struct BattleStruct || gProtectStructs[battlerId].spikyShielded \ || gProtectStructs[battlerId].kingsShielded \ || gProtectStructs[battlerId].banefulBunkered \ - || gProtectStructs[battlerId].obstructed) \ + || gProtectStructs[battlerId].obstructed \ + || gProtectStructs[battlerId].silkTrapped) #define GET_STAT_BUFF_ID(n)((n & 7)) // first three bits 0x1, 0x2, 0x4 #define GET_STAT_BUFF_VALUE_WITH_SIGN(n)((n & 0xF8)) diff --git a/src/battle_main.c b/src/battle_main.c index 3393c8d9b0..c29775082a 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3200,6 +3200,7 @@ void FaintClearSetData(void) gProtectStructs[gActiveBattler].banefulBunkered = FALSE; gProtectStructs[gActiveBattler].quash = FALSE; gProtectStructs[gActiveBattler].obstructed = FALSE; + gProtectStructs[gActiveBattler].silkTrapped = FALSE; gProtectStructs[gActiveBattler].endured = FALSE; gProtectStructs[gActiveBattler].noValidMoves = FALSE; gProtectStructs[gActiveBattler].helpingHand = FALSE; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2e27f5fdb7..4b12f52ec8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3506,6 +3506,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gProtectStructs[gBattlerTarget].kingsShielded = FALSE; gProtectStructs[gBattlerTarget].banefulBunkered = FALSE; gProtectStructs[gBattlerTarget].obstructed = FALSE; + gProtectStructs[gBattlerTarget].silkTrapped = FALSE; BattleScriptPush(gBattlescriptCurrInstr + 1); if (gCurrentMove == MOVE_HYPERSPACE_FURY) gBattlescriptCurrInstr = BattleScript_HyperspaceFuryRemoveProtect; @@ -5230,6 +5231,17 @@ static void Cmd_moveend(void) gBattlescriptCurrInstr = BattleScript_KingsShieldEffect; effect = 1; } + else if (gProtectStructs[gBattlerTarget].silkTrapped) + { + gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; + i = gBattlerAttacker; + gBattlerAttacker = gBattlerTarget; + gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable + gBattleScripting.moveEffect = MOVE_EFFECT_SPD_MINUS_1; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_KingsShieldEffect; + effect = 1; + } // Not strictly a protect effect, but works the same way else if (gProtectStructs[gBattlerTarget].beakBlastCharge && CanBeBurned(gBattlerAttacker) @@ -10305,6 +10317,11 @@ static void Cmd_setprotectlike(void) gProtectStructs[gBattlerAttacker].obstructed = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } + else if (gCurrentMove == MOVE_SILK_TRAP) + { + gProtectStructs[gBattlerAttacker].silkTrapped = TRUE; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } gDisableStructs[gBattlerAttacker].protectUses++; fail = FALSE; diff --git a/src/battle_util.c b/src/battle_util.c index 23dd320c66..a4c6dbedcd 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8255,7 +8255,7 @@ bool32 IsBattlerProtected(u8 battlerId, u16 move) return TRUE; else if (gProtectStructs[battlerId].banefulBunkered) return TRUE; - else if (gProtectStructs[battlerId].obstructed && !IS_MOVE_STATUS(move)) + else if ((gProtectStructs[battlerId].obstructed || gProtectStructs[battlerId].silkTrapped) && !IS_MOVE_STATUS(move)) return TRUE; else if (gProtectStructs[battlerId].spikyShielded) return TRUE; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 41779a0c5b..67a65c638f 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -13721,7 +13721,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_SILK_TRAP] = { - .effect = EFFECT_PLACEHOLDER, // EFFECT_PROTECT with extra checks + .effect = EFFECT_PROTECT, .power = 0, .type = TYPE_BUG, .accuracy = 0,