diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index bceb584af..bd6a2ac7e 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1365,6 +1365,14 @@ various \battler, VARIOUS_SWITCHIN_ABILITIES .endm + .macro savetarget + various BS_TARGET, VARIOUS_SAVE_TARGET + .endm + + .macro restoretarget + various BS_TARGET, VARIOUS_RESTORE_TARGET + .endm + @ helpful macros .macro setstatchanger stat, stages, down setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index db1effac8..0d20dd5ed 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3854,6 +3854,26 @@ BattleScript_ToxicSpikesPoisoned:: updatestatusicon BS_SCRIPTING waitstate return + +BattleScript_StickyWebOnSwitchIn:: + savetarget + copybyte gBattlerTarget sBANK + printstring STRINGID_STICKYWEBSWITCHIN + waitmessage 0x40 + statbuffchange 0x1, BattleScript_StickyWebOnSwitchInEnd + jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, 0x2, BattleScript_StickyWebOnSwitchInStatAnim + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_StickyWebOnSwitchInEnd + pause 0x20 + goto BattleScript_StickyWebOnSwitchInPrintStatMsg +BattleScript_StickyWebOnSwitchInStatAnim: + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 +BattleScript_StickyWebOnSwitchInPrintStatMsg: + printfromtable gStatDownStringIds + waitmessage 0x40 +BattleScript_StickyWebOnSwitchInEnd: + restoretarget + return BattleScript_PerishSongTakesLife:: printstring STRINGID_PKMNPERISHCOUNTFELL diff --git a/include/battle.h b/include/battle.h index cb1abd43c..37bccc3cd 100644 --- a/include/battle.h +++ b/include/battle.h @@ -257,6 +257,7 @@ struct SideTimer /*0x0A*/ u8 spikesAmount; u8 toxicSpikesAmount; u8 stealthRockAmount; + u8 stickyWebAmount; u8 auroraVeilTimer; u8 auroraVeilBattlerId; u8 tailwindTimer; @@ -592,6 +593,7 @@ struct BattleStruct u8 magnitudeBasePower; u8 presentBasePower; u8 roostTypes[MAX_BATTLERS_COUNT][3]; + u8 savedBattlerTarget; }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 8c809671f..ef220ee56 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -316,5 +316,6 @@ extern const u8 BattleScript_BadDreamsActivates[]; extern const u8 BattleScript_SwitchInAbilityMsg[]; extern const u8 BattleScript_ToxicSpikesPoisoned[]; extern const u8 BattleScript_ToxicSpikesAbsorbed[]; +extern const u8 BattleScript_StickyWebOnSwitchIn[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index bf88aba9c..2e73bd808 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -74,6 +74,8 @@ #define VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC 26 #define VARIOUS_STAT_TEXT_BUFFER 27 #define VARIOUS_SWITCHIN_ABILITIES 28 +#define VARIOUS_SAVE_TARGET 29 +#define VARIOUS_RESTORE_TARGET 30 // atk80, dmg manipulation #define ATK80_DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 558dfcef9..3ba5c7b4d 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -476,7 +476,8 @@ #define STRINGID_STEALTHROCKDMG 473 #define STRINGID_TOXICSPIKESABSORBED 474 #define STRINGID_TOXICSPIKESPOISONED 475 +#define STRINGID_STICKYWEBSWITCHIN 476 -#define BATTLESTRINGS_COUNT 466 +#define BATTLESTRINGS_COUNT 467 #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_debug.c b/src/battle_debug.c index 94ec9db24..e0b69c4b6 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -118,6 +118,7 @@ enum LIST_SIDE_TAILWIND, LIST_SIDE_STEALTH_ROCK, LIST_SIDE_TOXIC_SPIKES, + LIST_SIDE_STICKY_WEB, }; // const rom data @@ -177,6 +178,7 @@ static const u8 sText_Tailwind[] = _("Tailwind"); static const u8 sText_PP[] = _("PP"); static const u8 sText_StealthRock[] = _("Stealth Rock"); static const u8 sText_ToxicSpikes[] = _("Toxic Spikes"); +static const u8 sText_StickyWeb[] = _("Sticky Web"); static const u8 sText_EmptyString[] = _(""); @@ -329,6 +331,7 @@ static const struct ListMenuItem sSideStatusListItems[] = {sText_Tailwind, LIST_SIDE_TAILWIND}, {sText_StealthRock, LIST_SIDE_STEALTH_ROCK}, {sText_ToxicSpikes, LIST_SIDE_TOXIC_SPIKES}, + {sText_StickyWeb, LIST_SIDE_STICKY_WEB}, }; static const struct ListMenuItem sSecondaryListItems[] = @@ -1135,6 +1138,15 @@ static u8 *GetSideStatusValue(struct BattleDebugMenu *data, bool32 changeStatus, *(u32*)(data->modifyArrows.modifiedValPtr) &= ~(SIDE_STATUS_TOXIC_SPIKES); } return &sideTimer->toxicSpikesAmount; + case LIST_SIDE_STICKY_WEB: + if (changeStatus) + { + if (statusTrue) + *(u32*)(data->modifyArrows.modifiedValPtr) |= SIDE_STATUS_STICKY_WEB; + else + *(u32*)(data->modifyArrows.modifiedValPtr) &= ~(SIDE_STATUS_STICKY_WEB); + } + return &sideTimer->stickyWebAmount; default: return NULL; } @@ -1243,7 +1255,7 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data) if (data->currentSecondaryListItemId == LIST_SIDE_SPIKES) data->modifyArrows.maxValue = 3; - else if (data->currentSecondaryListItemId == LIST_SIDE_STEALTH_ROCK) + else if (data->currentSecondaryListItemId == LIST_SIDE_STEALTH_ROCK || data->currentSecondaryListItemId == LIST_SIDE_STICKY_WEB) data->modifyArrows.maxValue = 1; else data->modifyArrows.maxValue = 9; diff --git a/src/battle_message.c b/src/battle_message.c index fd0cfed58..df02f9fcd 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -617,6 +617,7 @@ static const u8 sText_SymbiosisItemPass[] = _("{B_ATK_NAME_WITH_PREFIX} passed i static const u8 sText_StealthRockDmg[] = _("Pointed stones dug into\n{B_SCR_ACTIVE_NAME_WITH_PREFIX}!"); static const u8 sText_ToxicSpikesAbsorbed[] = _(""); static const u8 sText_ToxicSpikesPoisoned[] = _(""); +static const u8 sText_StickyWebSwitchIn[] = _(""); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1085,6 +1086,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = sText_StealthRockDmg, sText_ToxicSpikesAbsorbed, sText_ToxicSpikesPoisoned, + sText_StickyWebSwitchIn, }; const u16 gDmgHazardsStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 80e70dc8a..460583071 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5395,6 +5395,16 @@ static void atk52_switchineffects(void) } } } + else if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STICKY_WEB_DAMAGED) + && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_STICKY_WEB) + && IsBattlerGrounded(gActiveBattler)) + { + gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_STICKY_WEB_DAMAGED; + gBattleScripting.battler = gActiveBattler; + SET_STATCHANGER(STAT_SPEED, 1, TRUE); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_StickyWebOnSwitchIn; + } else { if (gBattleMons[gActiveBattler].ability == ABILITY_TRUANT && !gDisableStructs[gActiveBattler].truantUnknownBit) @@ -6606,6 +6616,12 @@ static void atk76_various(void) gBattlescriptCurrInstr += 3; AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBattler, 0, 0, 0); return; + case VARIOUS_SAVE_TARGET: + gBattleStruct->savedBattlerTarget = gBattlerTarget; + break; + case VARIOUS_RESTORE_TARGET: + gBattlerTarget = gBattleStruct->savedBattlerTarget; + break; } gBattlescriptCurrInstr += 3;