From 065c0ec5887baba3fc374deaf63ef0a599dc6b7a Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 4 Feb 2024 23:23:03 +0100 Subject: [PATCH] Fairy Lock animation fix (#4111) * Fairy Lock animation fix * remove comment * fairy lock anim hopefully works --------- Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com> --- data/battle_anim_scripts.s | 5 ++--- include/battle_anim.h | 1 + src/battle_anim_electric.c | 27 ++++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 4145679f34..4cf2bfdc13 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -9210,13 +9210,12 @@ Boomburst_Doubles: goto Boomburst_Last Move_FAIRY_LOCK:: - loadspritegfx ANIM_TAG_CHAIN_LINK @Chain Colour - loadspritegfx ANIM_TAG_FAIRY_LOCK_CHAINS @AnimTask is missing for Fairy Lock Chain + loadspritegfx ANIM_TAG_FAIRY_LOCK_CHAINS setalpha 8, 8 monbg ANIM_ATK_PARTNER createvisualtask AnimTask_BlendBattleAnimPal, 0xa, F_PAL_BG, 0x1, 0x0, 0x8, 0x6B1F waitforvisualfinish - loopsewithpan SE_M_SCRATCH, SOUND_PAN_TARGET, 0x6, 0x4 + loopsewithpan SE_M_SCRATCH, SOUND_PAN_TARGET, 0x6, 0x9 createvisualtask AnimTask_VoltTackleBolt, 0x5, 0x7 createvisualtask AnimTask_VoltTackleBolt, 0x5, 0x33 createvisualtask AnimTask_VoltTackleBolt, 0x5, 0x2 diff --git a/include/battle_anim.h b/include/battle_anim.h index f8f0dff969..250a3ac447 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -415,6 +415,7 @@ extern const struct OamData gOamData_AffineDouble_ObjNormal_64x64; extern const struct OamData gOamData_AffineDouble_ObjBlend_64x64; extern const struct OamData gOamData_AffineDouble_ObjBlend_64x32; extern const struct OamData gOamData_AffineDouble_ObjNormal_8x16; +extern const struct OamData gOamData_AffineDouble_ObjNormal_64x32; extern const struct OamData gOamData_AffineOff_ObjBlend_16x16; extern const struct OamData gOamData_AffineDouble_ObjBlend_16x16; extern const struct OamData gOamData_AffineNormal_ObjNormal_8x8; diff --git a/src/battle_anim_electric.c b/src/battle_anim_electric.c index 415f112d30..38ca948749 100644 --- a/src/battle_anim_electric.c +++ b/src/battle_anim_electric.c @@ -479,6 +479,17 @@ const struct SpriteTemplate gVoltTackleBoltSpriteTemplate = .callback = AnimVoltTackleBolt, }; +const struct SpriteTemplate gFairyLockChainsSpriteTemplate = +{ + .tileTag = ANIM_TAG_FAIRY_LOCK_CHAINS, + .paletteTag = ANIM_TAG_FAIRY_LOCK_CHAINS, + .oam = &gOamData_AffineOff_ObjNormal_64x32, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = AnimVoltTackleBolt, +}; + const struct SpriteTemplate gGrowingShockWaveOrbSpriteTemplate = { .tileTag = ANIM_TAG_CIRCLE_OF_LIGHT, @@ -1190,11 +1201,20 @@ void AnimTask_VoltTackleBolt(u8 taskId) static bool8 CreateVoltTackleBolt(struct Task *task, u8 taskId) { - u8 spriteId = CreateSprite(&gVoltTackleBoltSpriteTemplate, task->data[3], task->data[5], 35); + u32 spriteId; + bool32 isFairyLock = (gAnimMoveIndex == MOVE_FAIRY_LOCK); + + if (isFairyLock) + spriteId = CreateSprite(&gFairyLockChainsSpriteTemplate, task->data[3], task->data[5] + 10, 35); + else + spriteId = CreateSprite(&gVoltTackleBoltSpriteTemplate, task->data[3], task->data[5], 35); + if (spriteId != MAX_SPRITES) { gSprites[spriteId].data[6] = taskId; gSprites[spriteId].data[7] = 7; + gSprites[spriteId].data[1] = isFairyLock ? 25 : 12; // How long the chains / bolts stay on screen. + gSprites[spriteId].data[2] = isFairyLock; // Whether to destroy the Oam Matrix. task->data[7]++; } @@ -1220,10 +1240,11 @@ static bool8 CreateVoltTackleBolt(struct Task *task, u8 taskId) static void AnimVoltTackleBolt(struct Sprite *sprite) { - if (++sprite->data[0] > 12) + if (++sprite->data[0] > sprite->data[1]) { gTasks[sprite->data[6]].data[sprite->data[7]]--; - FreeOamMatrix(sprite->oam.matrixNum); + if (!sprite->data[2]) + FreeOamMatrix(sprite->oam.matrixNum); DestroySprite(sprite); } }