Skip to content

Commit

Permalink
Add Snow weather animation (#3440)
Browse files Browse the repository at this point in the history
* Snow weather animation

* Update battle_anim_scripts.s

* Apply changes from review
  • Loading branch information
kittenchilly authored Oct 22, 2023
1 parent 551dc62 commit d495e17
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 8 deletions.
21 changes: 13 additions & 8 deletions data/battle_anim_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ gBattleAnims_Moves::
.4byte Move_SOUL_STEALING_7_STAR_STRIKE
@@@@ MAX MOVES
.4byte Move_MAX_GUARD
.4byte Move_MAX_STRIKE
.4byte Move_MAX_STRIKE
.4byte Move_MAX_KNUCKLE
.4byte Move_MAX_AIRSTREAM
.4byte Move_MAX_OOZE
Expand Down Expand Up @@ -15161,16 +15161,21 @@ Move_SILK_TRAP::
clearmonbg ANIM_ATK_PARTNER
end

@ Also used by Snow weather. Currently identical with Move_HAIL
@ Also used by Snow weather. Credits to Dat.H A
Move_SNOWSCAPE::
loadspritegfx ANIM_TAG_HAIL
loadspritegfx ANIM_TAG_ICE_CRYSTALS
createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 3, 0, 6, RGB_BLACK
loadspritegfx ANIM_TAG_SNOWFLAKES
playsewithpan SE_M_GUST, SOUND_PAN_ATTACKER
createvisualtask AnimTask_BlendBattleAnimPal, 10, (F_PAL_BG | F_PAL_BATTLERS), 2, 0, 4, RGB(11, 18, 22)
waitforvisualfinish
createvisualtask AnimTask_Hail, 5
loopsewithpan SE_M_HAIL, 0, 8, 10
createvisualtask AnimTask_CreateSnowflakes, 2, 0, 3, 120
createvisualtask AnimTask_CreateSnowflakes, 2, 0, 3, 120
createvisualtask AnimTask_CreateSnowflakes, 2, 0, 3, 120
delay 120
playsewithpan SE_M_GUST2, SOUND_PAN_ATTACKER
delay 30
waitforvisualfinish
createvisualtask AnimTask_BlendBattleAnimPal, 10, (F_PAL_BG | F_PAL_BATTLERS), 2, 4, 0, RGB(11, 18, 22)
waitforvisualfinish
createvisualtask AnimTask_BlendBattleAnimPal, 10, F_PAL_BG, 3, 6, 0, RGB_BLACK
end

@Credits to Skeli
Expand Down
Binary file added graphics/battle_anims/sprites/snowflakes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions include/constants/battle_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
#define ANIM_TAG_POLTERGEIST (ANIM_SPRITES_START + 384)
#define ANIM_TAG_TEAPOT (ANIM_SPRITES_START + 385)
#define ANIM_TAG_WOOD_HAMMER_HAMMER (ANIM_SPRITES_START + 386)
#define ANIM_TAG_SNOWFLAKES (ANIM_SPRITES_START + 387)


// battlers
Expand Down
2 changes: 2 additions & 0 deletions include/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -10347,6 +10347,8 @@ extern const u32 gBattleAnimSpriteGfx_Teapot[];
extern const u32 gBattleAnimSpritePal_Teapot[];
extern const u32 gBattleAnimSpriteGfx_WoodHammerHammer[];
extern const u32 gBattleAnimSpritePal_WoodHammerHammer[];
extern const u32 gBattleAnimSpriteGfx_Snowflakes[];
extern const u32 gBattleAnimSpritePal_Snowflakes[];

extern const u32 gBattleAnimBgImage_Dark[];
extern const u32 gBattleAnimBgImage_Ghost[];
Expand Down
68 changes: 68 additions & 0 deletions src/battle_anim_ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ static void AnimTask_Hail2(u8);
static bool8 GenerateHailParticle(u8 hailStructId, u8 affineAnimNum, u8 taskId, u8 c);
static void AvalancheAnim_Step(struct Sprite *sprite);
static void AvalancheAnim_Step2(struct Sprite *sprite);
static void AnimSnowflakes(struct Sprite *sprite);
static void AnimSnowflakes_Step(struct Sprite *sprite);

static const union AnimCmd sAnim_Unused[] =
{
Expand Down Expand Up @@ -1673,3 +1675,69 @@ void AnimTask_GetIceBallCounter(u8 taskId)
gBattleAnimArgs[arg] = gAnimDisableStructPtr->rolloutTimerStartValue - gAnimDisableStructPtr->rolloutTimer - 1;
DestroyAnimVisualTask(taskId);
}

static const union AnimCmd sAnim_Snowflakes[] =
{
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_Snowflakes[] =
{
sAnim_Snowflakes,
};

const struct SpriteTemplate gSnowFlakesSpriteTemplate =
{
.tileTag = ANIM_TAG_SNOWFLAKES,
.paletteTag = ANIM_TAG_SNOWFLAKES,
.oam = &gOamData_AffineOff_ObjNormal_16x32,
.anims = sAnims_Snowflakes,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = AnimSnowflakes,
};

void AnimTask_CreateSnowflakes(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(&gSnowFlakesSpriteTemplate, x, y, 4);
}
if (gTasks[taskId].data[0] == gTasks[taskId].data[3])
DestroyAnimVisualTask(taskId);
}

static void AnimSnowflakes(struct Sprite *sprite)
{
sprite->callback = AnimSnowflakes_Step;
}

static void AnimSnowflakes_Step(struct Sprite *sprite)
{
if (++sprite->data[0] <= 13)
{
sprite->x2++;
sprite->y2 += 2;
sprite->x2--;
}
if (sprite->animEnded)
DestroySprite(sprite);
}
2 changes: 2 additions & 0 deletions src/data/battle_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -1448,6 +1448,7 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] =
{gBattleAnimSpriteGfx_AuraSphere, 0x200, ANIM_TAG_POLTERGEIST},
{gBattleAnimSpriteGfx_Teapot, 0x1800, ANIM_TAG_TEAPOT},
{gBattleAnimSpriteGfx_WoodHammerHammer, 0x800, ANIM_TAG_WOOD_HAMMER_HAMMER},
{gBattleAnimSpriteGfx_Snowflakes, 0x0700, ANIM_TAG_SNOWFLAKES},
};

const struct CompressedSpritePalette gBattleAnimPaletteTable[] =
Expand Down Expand Up @@ -1896,6 +1897,7 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] =
{gBattleAnimSpritePal_Poltergeist, ANIM_TAG_POLTERGEIST},
{gBattleAnimSpritePal_Teapot, ANIM_TAG_TEAPOT},
{gBattleAnimSpritePal_WoodHammerHammer, ANIM_TAG_WOOD_HAMMER_HAMMER},
{gBattleAnimSpritePal_RainDrops, ANIM_TAG_SNOWFLAKES},
};

const struct BattleAnimBackground gBattleAnimBackgroundTable[] =
Expand Down
3 changes: 3 additions & 0 deletions src/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ const u32 gBattleAnimSpritePal_SpinningBall2[] = INCBIN_U32("graphics/battle_ani
const u32 gBattleAnimSpriteGfx_WoodHammerHammer[] = INCBIN_U32("graphics/battle_anims/sprites/wood_hammer_hammer.4bpp.lz");
const u32 gBattleAnimSpritePal_WoodHammerHammer[] = INCBIN_U32("graphics/battle_anims/sprites/wood_hammer_hammer.gbapal.lz");

const u32 gBattleAnimSpriteGfx_Snowflakes[] = INCBIN_U32("graphics/battle_anims/sprites/snowflakes.4bpp.lz");
const u32 gBattleAnimSpritePal_Snowflakes[] = INCBIN_U32("graphics/battle_anims/sprites/snowflakes.gbapal.lz");

// old battle interface data, unused

const u32 gOldBattleInterfaceGfx[] = INCBIN_U32("graphics/unused/obi1.4bpp.lz");
Expand Down

0 comments on commit d495e17

Please sign in to comment.