From 130d6042e0cd0fcf56d713c8c5901d87637da3fb Mon Sep 17 00:00:00 2001 From: kittenchilly Date: Thu, 10 Oct 2024 15:37:57 -0500 Subject: [PATCH] Add Ion Deluge animation (#5467) --- data/battle_anim_scripts.s | 11 ++++++ src/battle_anim_electric.c | 71 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index c16a5c7859..215b8deaff 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -7710,6 +7710,17 @@ gBattleAnimMove_NobleRoar:: end gBattleAnimMove_IonDeluge:: + loadspritegfx ANIM_TAG_IONS + loopsewithpan SE_M_THUNDERBOLT2, SOUND_PAN_ATTACKER, 10, 12 + createvisualtask AnimTask_BlendBattleAnimPal, 10, (F_PAL_BG | F_PAL_BATTLERS_2), 2, 0, 4, RGB_YELLOW + waitforvisualfinish + createvisualtask AnimTask_CreateIons, 2, 0, 3, 120 + createvisualtask AnimTask_CreateIons, 2, 0, 3, 120 + delay 120 + delay 30 + waitforvisualfinish + createvisualtask AnimTask_BlendBattleAnimPal, 10, (F_PAL_BG | F_PAL_BATTLERS_2), 2, 4, 0, RGB_YELLOW + waitforvisualfinish end gBattleAnimMove_ParabolicCharge:: diff --git a/src/battle_anim_electric.c b/src/battle_anim_electric.c index de6d820264..64114227e1 100644 --- a/src/battle_anim_electric.c +++ b/src/battle_anim_electric.c @@ -29,6 +29,8 @@ static bool8 CreateShockWaveBoltSprite(struct Task *task, u8 taskId); static void AnimShockWaveProgressingBolt(struct Sprite *); static bool8 CreateShockWaveLightningSprite(struct Task *task, u8 taskId); static void AnimShockWaveLightning(struct Sprite *sprite); +static void AnimIon(struct Sprite *); +static void AnimIon_Step(struct Sprite *); static const union AnimCmd sAnim_Lightning[] = { @@ -559,6 +561,34 @@ const struct SpriteTemplate gSeedFlareGreenChargeTemplate = .callback = AnimGrowingChargeOrb }; +static const union AnimCmd sAnim_Ion[] = +{ + ANIMCMD_FRAME(0, 2), + ANIMCMD_FRAME(8, 2), + ANIMCMD_FRAME(16, 2), + ANIMCMD_FRAME(24, 6), + ANIMCMD_FRAME(32, 2), + ANIMCMD_FRAME(40, 2), + ANIMCMD_FRAME(48, 2), + ANIMCMD_END, +}; + +static const union AnimCmd *const sAnims_Ion[] = +{ + sAnim_Ion, +}; + +const struct SpriteTemplate gIonSpriteTemplate = +{ + .tileTag = ANIM_TAG_IONS, + .paletteTag = ANIM_TAG_IONS, + .oam = &gOamData_AffineOff_ObjNormal_16x32, + .anims = sAnims_Ion, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = AnimIon, +}; + // functions static void AnimLightning(struct Sprite *sprite) { @@ -1452,3 +1482,44 @@ static void AnimShockWaveLightning(struct Sprite *sprite) DestroySprite(sprite); } } + +// Copy of Rain Dance's function but displays the ion sprite instead +// arg 0: initial step +// arg 1: amount (?) +// arg 2: duration +void AnimTask_CreateIons(u8 taskId) +{ + u8 x, y; + + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[1] = gBattleAnimArgs[0]; + gTasks[taskId].data[2] = gBattleAnimArgs[1]; + gTasks[taskId].data[3] = gBattleAnimArgs[2]; + } + gTasks[taskId].data[0]++; + if (gTasks[taskId].data[0] % gTasks[taskId].data[2] == 1) + { + x = Random2() % DISPLAY_WIDTH; + y = Random2() % (DISPLAY_HEIGHT / 2); + CreateSprite(&gIonSpriteTemplate, x, y, 4); + } + if (gTasks[taskId].data[0] == gTasks[taskId].data[3]) + DestroyAnimVisualTask(taskId); +} + +static void AnimIon(struct Sprite *sprite) +{ + sprite->callback = AnimIon_Step; +} + +static void AnimIon_Step(struct Sprite *sprite) +{ + if (++sprite->data[0] <= 13) + { + sprite->x2++; + sprite->y2 += 4; + } + if (sprite->animEnded) + DestroySprite(sprite); +}