From 307d5d93c4bbf2d1f6a624761a53ceae8d8d32b5 Mon Sep 17 00:00:00 2001 From: hamish Date: Mon, 23 May 2022 08:53:08 -0400 Subject: [PATCH] add potlergeist animation --- data/battle_anim_scripts.s | 37 +++++++++++++- .../battle_anims/sprites/new/poltergeist.pal | 19 +++++++ include/constants/battle_anim.h | 1 + include/graphics.h | 1 + src/battle_anim_ghost.c | 49 ++++++++++++++++++- src/battle_script_commands.c | 1 + src/data/battle_anim.h | 2 + src/graphics.c | 2 + 8 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 graphics/battle_anims/sprites/new/poltergeist.pal diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index d76aff05a..f1ef78fe0 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -14193,7 +14193,42 @@ Move_LASH_OUT:: end @to do: Move_POLTERGEIST:: - end @to do: + loadspritegfx ANIM_TAG_EYE_SPARKLE + loadspritegfx ANIM_TAG_WHITE_SHADOW @Destiny Bond + loadspritegfx ANIM_TAG_QUICK_GUARD_HAND @Black Colour + loadspritegfx ANIM_TAG_IMPACT + loadspritegfx ANIM_TAG_POLTERGEIST + fadetobg BG_NIGHTMARE + waitbgfadein + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 0, 0, 16, RGB_BLACK + waitforvisualfinish + createsprite gEyeSparkleSpriteTemplate, ANIM_ATTACKER, 0, -16, -8 + createsprite gEyeSparkleSpriteTemplate, ANIM_ATTACKER, 0, 16, -8 + playsewithpan SE_M_DETECT, SOUND_PAN_ATTACKER + waitforvisualfinish + createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 2, 0, 16, 0, RGB_BLACK + playsewithpan SE_M_FAINT_ATTACK, SOUND_PAN_ATTACKER + delay 0x1 + launchtask AnimTask_DestinyBondWhiteShadow 0x5 0x2 0x0 0x24 + delay 0x30 + playsewithpan SE_M_SAND_ATTACK, SOUND_PAN_TARGET + createvisualtask AnimTask_PoltergeistItem, 2 + waitforvisualfinish + setalpha 12, 8 + launchtemplate gBasicHitSplatSpriteTemplate 0x2 0x4 0x0 0x0 0x1 0x1 + launchtask AnimTask_ShakeMon 0x5 0x5 0x1 0x0 0x5 0x5 0x1 + launchtemplate gComplexPaletteBlendSpriteTemplate 0x2 0x7 0x7 0x5 0x1 0x0 0xa 0x0 0x0 + playsewithpan SE_M_VITAL_THROW2, SOUND_PAN_TARGET + waitforvisualfinish + launchtask AnimTask_NightmareClone 0x2 0x0 + launchtask AnimTask_ShakeMon 0x2 0x5 0x1 0x3 0x0 0x28 0x1 + playsewithpan SE_M_NIGHTMARE, SOUND_PAN_TARGET + waitforvisualfinish + restorebg + waitbgfadein + clearmonbg 0x3 + blendoff + end Move_CORROSIVE_GAS:: end @to do: diff --git a/graphics/battle_anims/sprites/new/poltergeist.pal b/graphics/battle_anims/sprites/new/poltergeist.pal new file mode 100644 index 000000000..699ab1ffa --- /dev/null +++ b/graphics/battle_anims/sprites/new/poltergeist.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +246 246 246 +246 246 246 +213 197 230 +213 197 230 +180 148 213 +180 148 213 +180 148 213 +148 98 197 +115 65 164 +82 32 131 +82 32 131 +82 32 131 +0 0 0 +0 0 0 +0 0 0 diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index bddb727fd..52f46e46d 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -395,6 +395,7 @@ #define ANIM_TAG_OMEGA_SYMBOL (ANIM_SPRITES_START + 383) #define ANIM_TAG_PRIMAL_PARTICLES (ANIM_SPRITES_START + 384) #define ANIM_TAG_STEEL_BEAM (ANIM_SPRITES_START + 385) +#define ANIM_TAG_POLTERGEIST (ANIM_SPRITES_START + 386) // battlers #define ANIM_ATTACKER 0 diff --git a/include/graphics.h b/include/graphics.h index 1e2a0f4d8..10e10a1c7 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4906,6 +4906,7 @@ extern const u32 gBattleAnimSpriteGfx_StonePillar[]; extern const u32 gBattleAnimSpritePal_StonePillar[]; extern const u32 gBattleAnimSpriteGfx_StraightBeam[]; extern const u32 gBattleAnimSpritePal_StraightBeam[]; +extern const u32 gBattleAnimSpritePal_Poltergeist[]; extern const u32 gBattleAnimSpriteGfx_SubstituteBack[]; extern const u32 gBattleAnimSpriteGfx_SubstituteFront[]; extern const u32 gBattleAnimSpritePal_SubstituteFront[]; diff --git a/src/battle_anim_ghost.c b/src/battle_anim_ghost.c index d9cbc919c..5ced0567b 100644 --- a/src/battle_anim_ghost.c +++ b/src/battle_anim_ghost.c @@ -2,6 +2,7 @@ #include "battle.h" #include "battle_anim.h" #include "gpu_regs.h" +#include "item_icon.h" #include "palette.h" #include "constants/rgb.h" #include "scanline_effect.h" @@ -39,6 +40,7 @@ static void AnimGhostStatusSprite_Step(struct Sprite *); static void AnimGrudgeFlame(struct Sprite *); static void AnimMonMoveCircular(struct Sprite *); static void AnimMonMoveCircular_Step(struct Sprite *); +static void AnimPoltergeistItem(struct Sprite *); static const union AffineAnimCmd sAffineAnim_ConfuseRayBallBounce[] = { @@ -270,6 +272,17 @@ const struct SpriteTemplate gFlashCannonBallMovementTemplate = .callback = AnimShadowBall }; +const struct SpriteTemplate gPoltergeistEffectTemplate = +{ + .tileTag = ANIM_TAG_POLTERGEIST, + .paletteTag = ANIM_TAG_POLTERGEIST, + .oam = &gOamData_AffineNormal_ObjNormal_32x32, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gAffineAnims_ShadowBall, + .callback = AnimPoltergeistItem, +}; + static void AnimConfuseRayBallBounce(struct Sprite *sprite) { InitSpritePosToAnimAttacker(sprite, TRUE); @@ -870,7 +883,8 @@ void AnimTask_DestinyBondWhiteShadow(u8 taskId) && battler != (gBattleAnimAttacker ^ 2) && IsBattlerSpriteVisible(battler)) { - if (gAnimMoveIndex == MOVE_DARK_VOID) + if (gAnimMoveIndex == MOVE_DARK_VOID + || gAnimMoveIndex == MOVE_POLTERGEIST) spriteId = CreateSprite(&gDarkVoidBlackHoleTemplate, baseX, baseY, 55); //dark void else spriteId = CreateSprite(&gDestinyBondWhiteShadowSpriteTemplate, baseX, baseY, 55); //destiny bond @@ -1395,3 +1409,36 @@ static void AnimMonMoveCircular_Step(struct Sprite *sprite) sprite->callback = DestroySpriteAndMatrix; } } + +void AnimTask_PoltergeistItem(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + u8 x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X); + u8 y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y) + (GetBattlerSpriteCoordAttr(gBattleAnimTarget, BATTLER_COORD_ATTR_HEIGHT) / 2); + + task->data[0] = AddItemIconSprite(ANIM_TAG_ITEM_BAG, ANIM_TAG_ITEM_BAG, gLastUsedItem); + gSprites[task->data[0]].x = x + 4; + gSprites[task->data[0]].y = y + 4; + gSprites[task->data[0]].data[0] = x + 4; + gSprites[task->data[0]].data[1] = y + 4; + gSprites[task->data[0]].callback = AnimPoltergeistItem; + + task->data[1] = CreateSprite(&gPoltergeistEffectTemplate, x, y, 1); + gSprites[task->data[1]].data[0] = x; + gSprites[task->data[1]].data[1] = y; + + gAnimVisualTaskCount += 2; + + DestroyAnimVisualTask(taskId); +} + +static void AnimPoltergeistItem(struct Sprite *sprite) +{ + sprite->data[2] += 4; + + sprite->x = sprite->data[0] + Sin(sprite->data[2], 24); + sprite->y = sprite->data[1] + (Cos(sprite->data[2], 24) - 24); + + if (sprite->data[2] == 256) + DestroyAnimSprite(sprite); +} diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 15915c71a..6892e1766 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9448,6 +9448,7 @@ static void Cmd_various(void) else { PREPARE_ITEM_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].item); + gLastUsedItem = gBattleMons[gActiveBattler].item; gBattlescriptCurrInstr += 7; } return; diff --git a/src/data/battle_anim.h b/src/data/battle_anim.h index 5483b8f3b..62f3802a5 100644 --- a/src/data/battle_anim.h +++ b/src/data/battle_anim.h @@ -1451,6 +1451,7 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] = {gBattleAnimSpriteGfx_OmegaSymbol, 0x0200, ANIM_TAG_OMEGA_SYMBOL}, {gBattleAnimSpriteGfx_PrimalParticles, 0x0180, ANIM_TAG_PRIMAL_PARTICLES}, {gBattleAnimSpriteGfx_Orbs, 0x0180, ANIM_TAG_STEEL_BEAM}, + {gBattleAnimSpriteGfx_AuraSphere, 0x200, ANIM_TAG_POLTERGEIST}, }; const struct CompressedSpritePalette gBattleAnimPaletteTable[] = @@ -1902,6 +1903,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] = {gBattleAnimSpritePal_OmegaSymbol, ANIM_TAG_OMEGA_SYMBOL}, {gBattleAnimSpritePal_PrimalParticles, ANIM_TAG_PRIMAL_PARTICLES}, {gBattleAnimSpritePal_SteelBeam, ANIM_TAG_STEEL_BEAM}, + {gBattleAnimSpritePal_Poltergeist, ANIM_TAG_POLTERGEIST}, }; const struct BattleAnimBackground gBattleAnimBackgroundTable[] = diff --git a/src/graphics.c b/src/graphics.c index b735d20b1..6aae37a9f 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -269,6 +269,8 @@ const u32 gBattleAnimSpritePal_Steamroller[] = INCBIN_U32("graphics/battle_anims const u32 gBattleAnimSpriteGfx_StonePillar[] = INCBIN_U32("graphics/battle_anims/sprites/new/stone_pillar.4bpp.lz"); const u32 gBattleAnimSpritePal_StonePillar[] = INCBIN_U32("graphics/battle_anims/sprites/new/stone_pillar.gbapal.lz"); +const u32 gBattleAnimSpritePal_Poltergeist[] = INCBIN_U32("graphics/battle_anims/sprites/new/poltergeist.gbapal.lz"); + const u32 gBattleAnimSpriteGfx_StraightBeam[] = INCBIN_U32("graphics/battle_anims/sprites/new/straight_beam.4bpp.lz"); const u32 gBattleAnimSpritePal_StraightBeam[] = INCBIN_U32("graphics/battle_anims/sprites/new/straight_beam.gbapal.lz");