Silk Trap Effect (#2512)

* add silk trap effect, analog of obstruct

Co-authored-by: ghoulslash <pokevoyager0@gmail.com>
Co-authored-by: Eduardo Quezada D'Ottone <eduardo602002@gmail.com>
This commit is contained in:
ghoulslash 2023-01-23 14:42:47 -05:00 committed by GitHub
parent fbcad9d3ec
commit 321634ed3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 3 deletions

View File

@ -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))

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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,