pokeemerald/src/battle_anim_water.c

1593 lines
47 KiB
C
Raw Normal View History

2018-10-24 21:52:21 +02:00
#include "global.h"
2018-12-19 02:23:07 +01:00
#include "battle.h"
2018-10-24 21:52:21 +02:00
#include "battle_anim.h"
2018-12-19 16:31:37 +01:00
#include "gpu_regs.h"
#include "graphics.h"
#include "palette.h"
2018-12-19 02:23:07 +01:00
#include "random.h"
2018-12-19 16:31:37 +01:00
#include "scanline_effect.h"
2018-12-19 02:23:07 +01:00
#include "sprite.h"
#include "task.h"
#include "trig.h"
#include "util.h"
#include "constants/battle.h"
2018-10-24 21:52:21 +02:00
#include "constants/rgb.h"
2020-02-21 18:38:20 +01:00
static void AnimRainDrop(struct Sprite *);
static void AnimRainDrop_Step(struct Sprite *);
static void AnimWaterBubbleProjectile(struct Sprite *);
static void AnimWaterBubbleProjectile_Step1(struct Sprite *);
static void AnimWaterBubbleProjectile_Step2(struct Sprite *);
static void AnimWaterBubbleProjectile_Step3(struct Sprite *);
2020-02-14 22:05:43 +01:00
static void AnimAuroraBeamRings(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimAuroraBeamRings_Step(struct Sprite *);
2020-02-15 00:11:04 +01:00
static void AnimToTargetInSinWave(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimToTargetInSinWave_Step(struct Sprite *);
2020-02-15 00:11:04 +01:00
static void AnimHydroCannonCharge(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimHydroCannonCharge_Step(struct Sprite *);
2020-02-15 00:11:04 +01:00
static void AnimHydroCannonBeam(struct Sprite *);
2020-02-20 02:22:53 +01:00
static void AnimWaterGunDroplet(struct Sprite *);
2020-02-15 00:11:04 +01:00
static void AnimSmallBubblePair(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimSmallBubblePair_Step(struct Sprite *);
static void AnimSmallDriftingBubbles(struct Sprite *);
static void AnimSmallDriftingBubbles_Step(struct Sprite *);
2020-02-21 18:38:20 +01:00
static void AnimSmallWaterOrb(struct Sprite *);
static void AnimWaterSpoutRain(struct Sprite *);
static void AnimWaterSpoutRainHit(struct Sprite *);
static void AnimWaterSportDroplet(struct Sprite *);
static void AnimWaterSportDroplet_Step(struct Sprite *);
2020-02-20 02:22:53 +01:00
static void AnimWaterPulseBubble(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimWaterPulseBubble_Step(struct Sprite *);
2020-02-21 18:38:20 +01:00
static void AnimWaterPulseRingBubble(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimWaterPulseRing_Step(struct Sprite *);
2020-02-21 18:38:20 +01:00
static void AnimTask_RotateAuroraRingColors_Step(u8);
2020-02-15 00:11:04 +01:00
static void AnimTask_RunSinAnimTimer(u8);
2020-02-21 18:38:20 +01:00
static void AnimTask_CreateSurfWave_Step1(u8);
static void AnimTask_CreateSurfWave_Step2(u8);
static void AnimTask_SurfWaveScanlineEffect(u8);
2020-02-20 22:22:33 +01:00
static void AnimTask_WaterSpoutLaunch_Step(u8);
static void AnimTask_WaterSpoutRain_Step(u8);
2020-02-21 18:38:20 +01:00
static u8 GetWaterSpoutPowerForAnim(void);
static void CreateWaterSpoutLaunchDroplets(struct Task*, u8);
static void CreateWaterSpoutRainDroplet(struct Task*, u8);
static void AnimTask_WaterSport_Step(u8);
static void CreateWaterSportDroplet(struct Task*);
2020-07-30 04:34:10 +02:00
static void CreateWaterPulseRingBubbles(struct Sprite*, s32, s32);
2020-02-21 18:38:20 +01:00
// Both unused
2018-10-24 21:52:21 +02:00
const u8 gUnknown_8593C80[] = INCBIN_U8("graphics/unknown/unknown_593C80.4bpp");
const u8 gUnknown_8593FFC[] = INCBIN_U8("graphics/unknown/unknown_593FFC.bin");
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_RainDrop[] =
2018-10-24 21:52:21 +02:00
{
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,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_RainDrop[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_RainDrop,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
const struct SpriteTemplate gRainDropSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_RAIN_DROPS,
.paletteTag = ANIM_TAG_RAIN_DROPS,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_16x32,
2020-02-21 18:38:20 +01:00
.anims = sAnims_RainDrop,
2018-10-24 21:52:21 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-21 18:38:20 +01:00
.callback = AnimRainDrop,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_WaterBubbleProjectile[] =
2018-10-24 21:52:21 +02:00
{
AFFINEANIMCMD_FRAME(0xFFFB, 0xFFFB, 0, 10),
AFFINEANIMCMD_FRAME(0x5, 0x5, 0, 10),
AFFINEANIMCMD_JUMP(0),
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_WaterBubbleProjectile[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_WaterBubbleProjectile,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_WaterBubbleProjectile[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_FRAME(4, 5),
ANIMCMD_FRAME(8, 5),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_WaterBubbleProjectile[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_WaterBubbleProjectile,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
const struct SpriteTemplate gWaterBubbleProjectileSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_BUBBLE,
.paletteTag = ANIM_TAG_BUBBLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_WaterBubbleProjectile,
2018-10-24 21:52:21 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_WaterBubbleProjectile,
.callback = AnimWaterBubbleProjectile,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_AuroraBeamRing_0[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_AuroraBeamRing_1[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(4, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_AuroraBeamRing[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_AuroraBeamRing_0,
sAnim_AuroraBeamRing_1,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_AuroraBeamRing[] =
2018-10-24 21:52:21 +02:00
{
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 1),
AFFINEANIMCMD_FRAME(0x60, 0x60, 0, 1),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_AuroraBeamRing[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_AuroraBeamRing,
2018-10-24 21:52:21 +02:00
};
2020-02-14 22:05:43 +01:00
const struct SpriteTemplate gAuroraBeamRingSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_RAINBOW_RINGS,
.paletteTag = ANIM_TAG_RAINBOW_RINGS,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjNormal_8x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_AuroraBeamRing,
2018-10-24 21:52:21 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_AuroraBeamRing,
2020-02-14 22:05:43 +01:00
.callback = AnimAuroraBeamRings,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_WaterMudOrb[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_FRAME(4, 1),
ANIMCMD_FRAME(8, 1),
ANIMCMD_FRAME(12, 1),
ANIMCMD_JUMP(0),
};
2020-02-21 18:38:20 +01:00
const union AnimCmd *const gAnims_WaterMudOrb[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_WaterMudOrb,
2018-10-24 21:52:21 +02:00
};
2020-02-15 00:11:04 +01:00
const struct SpriteTemplate gHydroPumpOrbSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_WATER_ORB,
.paletteTag = ANIM_TAG_WATER_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = gAnims_WaterMudOrb,
2018-10-24 21:52:21 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimToTargetInSinWave,
2018-10-24 21:52:21 +02:00
};
2020-02-16 23:49:24 +01:00
const struct SpriteTemplate gMudShotOrbSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_BROWN_ORB,
.paletteTag = ANIM_TAG_BROWN_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = gAnims_WaterMudOrb,
2018-10-24 21:52:21 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimToTargetInSinWave,
2018-10-24 21:52:21 +02:00
};
2020-02-16 23:49:24 +01:00
const struct SpriteTemplate gSignalBeamRedOrbSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_GLOWY_RED_ORB,
.paletteTag = ANIM_TAG_GLOWY_RED_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2018-10-24 21:52:21 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimToTargetInSinWave,
2018-10-24 21:52:21 +02:00
};
2020-02-16 23:49:24 +01:00
const struct SpriteTemplate gSignalBeamGreenOrbSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_GLOWY_GREEN_ORB,
.paletteTag = ANIM_TAG_GLOWY_GREEN_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2018-10-24 21:52:21 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimToTargetInSinWave,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_FlamethrowerFlame[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(16, 2),
ANIMCMD_FRAME(32, 2),
ANIMCMD_FRAME(48, 2),
ANIMCMD_JUMP(0),
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_FlamethrowerFlame[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_FlamethrowerFlame,
2018-10-24 21:52:21 +02:00
};
2020-02-15 00:11:04 +01:00
const struct SpriteTemplate gFlamethrowerFlameSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_SMALL_EMBER,
.paletteTag = ANIM_TAG_SMALL_EMBER,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_32x32,
2020-02-21 18:38:20 +01:00
.anims = sAnims_FlamethrowerFlame,
2018-10-24 21:52:21 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimToTargetInSinWave,
2018-10-24 21:52:21 +02:00
};
2020-02-16 23:49:24 +01:00
const struct SpriteTemplate gPsywaveRingSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_BLUE_RING,
.paletteTag = ANIM_TAG_BLUE_RING,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjNormal_16x32,
2018-10-24 21:52:21 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
2019-10-20 10:47:56 +02:00
.affineAnims = gGrowingRingAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimToTargetInSinWave,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_HydroCannonCharge[] =
2018-10-24 21:52:21 +02:00
{
AFFINEANIMCMD_FRAME(0x3, 0x3, 10, 50),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 10),
AFFINEANIMCMD_FRAME(0xFFEC, 0xFFEC, -10, 20),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_HydroCannonBeam[] =
2018-10-24 21:52:21 +02:00
{
AFFINEANIMCMD_FRAME(0x150, 0x150, 0, 0),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_HydroCannonCharge[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_HydroCannonCharge,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_HydroCannonBeam[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_HydroCannonBeam,
2018-10-24 21:52:21 +02:00
};
2020-02-15 00:11:04 +01:00
const struct SpriteTemplate gHydroCannonChargeSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_WATER_ORB,
.paletteTag = ANIM_TAG_WATER_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = gAnims_WaterMudOrb,
2018-10-24 21:52:21 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_HydroCannonCharge,
2020-02-15 00:11:04 +01:00
.callback = AnimHydroCannonCharge,
2018-10-24 21:52:21 +02:00
};
2020-02-15 00:11:04 +01:00
const struct SpriteTemplate gHydroCannonBeamSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_WATER_ORB,
.paletteTag = ANIM_TAG_WATER_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = gAnims_WaterMudOrb,
2018-10-24 21:52:21 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_HydroCannonBeam,
2020-02-15 00:11:04 +01:00
.callback = AnimHydroCannonBeam,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_WaterBubble[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_WaterGunDroplet[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(4, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
const union AnimCmd *const gAnims_WaterBubble[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_WaterBubble,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_WaterGunDroplet[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_WaterGunDroplet,
2018-10-24 21:52:21 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gWaterGunProjectileSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_SMALL_BUBBLES,
.paletteTag = ANIM_TAG_SMALL_BUBBLES,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = gAnims_WaterBubble,
2018-10-24 21:52:21 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2019-10-20 10:47:56 +02:00
.callback = AnimThrowProjectile,
2018-10-24 21:52:21 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gWaterGunDropletSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_SMALL_BUBBLES,
.paletteTag = ANIM_TAG_SMALL_BUBBLES,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_WaterGunDroplet,
2018-10-24 21:52:21 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = gAffineAnims_Droplet,
2020-02-20 02:22:53 +01:00
.callback = AnimWaterGunDroplet,
2018-10-24 21:52:21 +02:00
};
2020-02-14 22:05:43 +01:00
const struct SpriteTemplate gSmallBubblePairSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
.tileTag = ANIM_TAG_ICE_CRYSTALS, // ice_crystals_4, which are bubbles
2018-10-24 21:52:21 +02:00
.paletteTag = ANIM_TAG_ICE_CRYSTALS,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2020-02-21 18:38:20 +01:00
.anims = gAnims_SmallBubblePair,
2018-10-24 21:52:21 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimSmallBubblePair,
2018-10-24 21:52:21 +02:00
};
2020-02-15 00:11:04 +01:00
const struct SpriteTemplate gSmallDriftingBubblesSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_SMALL_BUBBLES,
.paletteTag = ANIM_TAG_SMALL_BUBBLES,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2018-10-24 21:52:21 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-20 22:22:33 +01:00
.callback = AnimSmallDriftingBubbles,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
// Used by Water Spout / Water Sport
const struct SpriteTemplate gSmallWaterOrbSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_GLOWY_BLUE_ORB,
.paletteTag = ANIM_TAG_GLOWY_BLUE_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2018-10-24 21:52:21 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-21 18:38:20 +01:00
.callback = AnimSmallWaterOrb,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_WaterPulseBubble_0[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(8, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_WaterPulseBubble_1[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(9, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_WeatherBallWaterDown[] =
2018-10-24 21:52:21 +02:00
{
ANIMCMD_FRAME(4, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_WaterPulseBubble[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_WaterPulseBubble_0,
sAnim_WaterPulseBubble_1,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_WeatherBallWaterDown[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_WeatherBallWaterDown,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_WaterPulseRingBubble_0[] =
2018-10-24 21:52:21 +02:00
{
AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0),
AFFINEANIMCMD_FRAME(0xFFF6, 0xFFF6, 0, 15),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_WaterPulseRingBubble_1[] =
2018-10-24 21:52:21 +02:00
{
AFFINEANIMCMD_FRAME(0xE0, 0xE0, 0, 0),
AFFINEANIMCMD_FRAME(0xFFF8, 0xFFF8, 0, 15),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_WeatherBallWaterDown[] =
2018-10-24 21:52:21 +02:00
{
AFFINEANIMCMD_FRAME(0x150, 0x150, 0, 0),
AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 15),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_WaterPulseRingBubble[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_WaterPulseRingBubble_0,
sAffineAnim_WaterPulseRingBubble_1,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_WeatherBallWaterDown[] =
2018-10-24 21:52:21 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_WeatherBallWaterDown,
2018-10-24 21:52:21 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gWaterPulseBubbleSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_SMALL_BUBBLES,
.paletteTag = ANIM_TAG_SMALL_BUBBLES,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2020-02-21 18:38:20 +01:00
.anims = sAnims_WaterPulseBubble,
2018-10-24 21:52:21 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-20 02:22:53 +01:00
.callback = AnimWaterPulseBubble,
2018-10-24 21:52:21 +02:00
};
2020-02-21 18:38:20 +01:00
const struct SpriteTemplate gWaterPulseRingBubbleSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_SMALL_BUBBLES,
.paletteTag = ANIM_TAG_SMALL_BUBBLES,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_8x8,
2020-02-21 18:38:20 +01:00
.anims = sAnims_WaterPulseBubble,
2018-10-24 21:52:21 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_WaterPulseRingBubble,
.callback = AnimWaterPulseRingBubble,
2018-10-24 21:52:21 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gWeatherBallWaterDownSpriteTemplate =
2018-10-24 21:52:21 +02:00
{
.tileTag = ANIM_TAG_SMALL_BUBBLES,
.paletteTag = ANIM_TAG_SMALL_BUBBLES,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_WeatherBallWaterDown,
2018-10-24 21:52:21 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_WeatherBallWaterDown,
2020-02-20 02:22:53 +01:00
.callback = AnimWeatherBallDown,
2018-10-24 21:52:21 +02:00
};
2018-12-19 02:23:07 +01:00
void AnimTask_CreateRaindrops(u8 taskId)
{
u8 x, y;
2019-04-06 18:38:15 +02:00
2018-12-19 02:23:07 +01:00
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() % 240;
y = Random2() % 80;
2020-02-21 18:38:20 +01:00
CreateSprite(&gRainDropSpriteTemplate, x, y, 4);
2018-12-19 02:23:07 +01:00
}
if (gTasks[taskId].data[0] == gTasks[taskId].data[3])
DestroyAnimVisualTask(taskId);
}
2020-02-21 18:38:20 +01:00
static void AnimRainDrop(struct Sprite *sprite)
2018-12-19 02:23:07 +01:00
{
2020-02-21 18:38:20 +01:00
sprite->callback = AnimRainDrop_Step;
2018-12-19 02:23:07 +01:00
}
2020-02-21 18:38:20 +01:00
static void AnimRainDrop_Step(struct Sprite *sprite)
2018-12-19 02:23:07 +01:00
{
if (++sprite->data[0] <= 13)
{
sprite->pos2.x++;
sprite->pos2.y += 4;
}
2018-12-19 16:31:37 +01:00
if (sprite->animEnded)
2018-12-19 02:23:07 +01:00
DestroySprite(sprite);
}
2020-02-14 22:05:43 +01:00
// For water bubbles that move to a dest, as in Bubble/Bubblebeam
2020-02-21 18:38:20 +01:00
static void AnimWaterBubbleProjectile(struct Sprite *sprite)
2018-12-19 02:23:07 +01:00
{
u8 spriteId;
2019-04-06 18:38:15 +02:00
2018-12-19 02:23:07 +01:00
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) - gBattleAnimArgs[0];
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3) + gBattleAnimArgs[1];
sprite->animPaused = TRUE;
}
else
{
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) + gBattleAnimArgs[0];
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3) + gBattleAnimArgs[1];
sprite->animPaused = TRUE;
}
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
sprite->data[0] = gBattleAnimArgs[6];
sprite->data[1] = sprite->pos1.x;
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
InitAnimLinearTranslation(sprite);
spriteId = CreateInvisibleSpriteWithCallback(SpriteCallbackDummy);
sprite->data[5] = spriteId;
sprite->pos1.x -= Sin((u8)gBattleAnimArgs[4], gBattleAnimArgs[2]);
sprite->pos1.y -= Cos((u8)gBattleAnimArgs[4], gBattleAnimArgs[3]);
gSprites[spriteId].data[0] = gBattleAnimArgs[2];
gSprites[spriteId].data[1] = gBattleAnimArgs[3];
gSprites[spriteId].data[2] = gBattleAnimArgs[5];
gSprites[spriteId].data[3] = (u8)gBattleAnimArgs[4] * 256;
gSprites[spriteId].data[4] = gBattleAnimArgs[6];
2020-02-21 18:38:20 +01:00
sprite->callback = AnimWaterBubbleProjectile_Step1;
2018-12-19 16:31:37 +01:00
sprite->callback(sprite);
2018-12-19 02:23:07 +01:00
}
2020-02-21 18:38:20 +01:00
static void AnimWaterBubbleProjectile_Step1(struct Sprite *sprite)
2018-12-19 02:23:07 +01:00
{
u8 otherSpriteId = sprite->data[5];
u8 timer = gSprites[otherSpriteId].data[4];
u16 trigIndex = gSprites[otherSpriteId].data[3];
2019-04-06 18:38:15 +02:00
2018-12-19 02:23:07 +01:00
sprite->data[0] = 1;
2018-12-20 04:13:26 +01:00
AnimTranslateLinear(sprite);
2018-12-19 02:23:07 +01:00
sprite->pos2.x += Sin(trigIndex >> 8, gSprites[otherSpriteId].data[0]);
sprite->pos2.y += Cos(trigIndex >> 8, gSprites[otherSpriteId].data[1]);
gSprites[otherSpriteId].data[3] = trigIndex + gSprites[otherSpriteId].data[2];
if (--timer != 0)
{
gSprites[otherSpriteId].data[4] = timer;
}
else
{
2020-02-21 18:38:20 +01:00
sprite->callback = AnimWaterBubbleProjectile_Step2;
2018-12-19 02:23:07 +01:00
DestroySprite(&gSprites[otherSpriteId]);
}
}
2020-02-21 18:38:20 +01:00
static void AnimWaterBubbleProjectile_Step2(struct Sprite *sprite)
2018-12-19 02:23:07 +01:00
{
sprite->animPaused = FALSE;
sprite->callback = RunStoredCallbackWhenAnimEnds;
2020-02-21 18:38:20 +01:00
StoreSpriteCallbackInData6(sprite, AnimWaterBubbleProjectile_Step3);
2018-12-19 02:23:07 +01:00
}
2018-12-19 16:31:37 +01:00
2020-02-21 18:38:20 +01:00
static void AnimWaterBubbleProjectile_Step3(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
sprite->data[0] = 10;
sprite->callback = WaitAnimForDuration;
StoreSpriteCallbackInData6(sprite, DestroySpriteAndMatrix);
}
2020-02-14 22:05:43 +01:00
static void AnimAuroraBeamRings(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
s16 unkArg;
2019-04-06 18:38:15 +02:00
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimAttacker(sprite, TRUE);
2018-12-19 16:31:37 +01:00
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
unkArg = -gBattleAnimArgs[2];
else
unkArg = gBattleAnimArgs[2];
sprite->data[0] = gBattleAnimArgs[4];
sprite->data[1] = sprite->pos1.x;
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + unkArg;
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3) + gBattleAnimArgs[3];
InitAnimLinearTranslation(sprite);
2020-02-20 22:22:33 +01:00
sprite->callback = AnimAuroraBeamRings_Step;
2018-12-19 16:31:37 +01:00
sprite->affineAnimPaused = TRUE;
sprite->callback(sprite);
}
2020-02-20 22:22:33 +01:00
static void AnimAuroraBeamRings_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
if ((u16)gBattleAnimArgs[7] == 0xFFFF)
2018-12-19 16:31:37 +01:00
{
StartSpriteAnim(sprite, 1);
sprite->affineAnimPaused = FALSE;
}
2018-12-20 04:13:26 +01:00
if (AnimTranslateLinear(sprite))
2018-12-19 16:31:37 +01:00
DestroyAnimSprite(sprite);
}
2020-02-20 06:04:42 +01:00
// Updates the palette on the rainbow rings used in Aurora Beam to make them appear to be rotating counterclockwise
void AnimTask_RotateAuroraRingColors(u8 taskId)
2018-12-19 16:31:37 +01:00
{
gTasks[taskId].data[0] = gBattleAnimArgs[0];
gTasks[taskId].data[2] = IndexOfSpritePaletteTag(ANIM_TAG_RAINBOW_RINGS) * 16 + 256;
2020-02-21 18:38:20 +01:00
gTasks[taskId].func = AnimTask_RotateAuroraRingColors_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-21 18:38:20 +01:00
static void AnimTask_RotateAuroraRingColors_Step(u8 taskId)
2018-12-19 16:31:37 +01:00
{
int i;
u16 palIndex;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
if (++gTasks[taskId].data[10] == 3)
{
u16 tempPlt;
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[10] = 0;
palIndex = gTasks[taskId].data[2] + 1;
tempPlt = gPlttBufferFaded[palIndex];
for (i = 1; i < 8; i++)
gPlttBufferFaded[palIndex + i - 1] = gPlttBufferFaded[palIndex + i];
gPlttBufferFaded[palIndex + 7] = tempPlt;
2018-12-19 16:31:37 +01:00
}
if (++gTasks[taskId].data[11] == gTasks[taskId].data[0])
DestroyAnimVisualTask(taskId);
}
2020-02-15 00:11:04 +01:00
// For animating undulating beam attacks (e.g. Flamethrower, Hydro Pump, Signal Beam)
static void AnimToTargetInSinWave(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
u16 retArg;
2019-04-06 18:38:15 +02:00
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimAttacker(sprite, TRUE);
2018-12-19 16:31:37 +01:00
sprite->data[0] = 30;
sprite->data[1] = sprite->pos1.x;
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
sprite->data[3] = sprite->pos1.y;
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
InitAnimLinearTranslation(sprite);
sprite->data[5] = 0xD200 / sprite->data[0];
sprite->data[7] = gBattleAnimArgs[3];
retArg = gBattleAnimArgs[7];
if (gBattleAnimArgs[7] > 127)
2018-12-19 16:31:37 +01:00
{
sprite->data[6] = (retArg - 127) * 256;
sprite->data[7] = -sprite->data[7];
}
else
{
sprite->data[6] = retArg * 256;
}
2020-02-20 22:22:33 +01:00
sprite->callback = AnimToTargetInSinWave_Step;
2018-12-19 16:31:37 +01:00
sprite->callback(sprite);
}
2020-02-20 22:22:33 +01:00
static void AnimToTargetInSinWave_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
2018-12-20 04:13:26 +01:00
if (AnimTranslateLinear(sprite))
2018-12-19 16:31:37 +01:00
DestroyAnimSprite(sprite);
sprite->pos2.y += Sin(sprite->data[6] >> 8, sprite->data[7]);
if ((sprite->data[6] + sprite->data[5]) >> 8 > 127)
{
sprite->data[6] = 0;
sprite->data[7] = -sprite->data[7];
}
else
{
sprite->data[6] += sprite->data[5];
}
}
2020-02-15 00:11:04 +01:00
void AnimTask_StartSinAnimTimer(u8 taskId)
2018-12-19 16:31:37 +01:00
{
gTasks[taskId].data[0] = gBattleAnimArgs[0];
gBattleAnimArgs[7] = 0;
2020-02-15 00:11:04 +01:00
gTasks[taskId].func = AnimTask_RunSinAnimTimer;
2018-12-19 16:31:37 +01:00
}
2020-02-15 00:11:04 +01:00
static void AnimTask_RunSinAnimTimer(u8 taskId)
2018-12-19 16:31:37 +01:00
{
gBattleAnimArgs[7] = (gBattleAnimArgs[7] + 3) & 0xFF;
2018-12-19 16:31:37 +01:00
if (--gTasks[taskId].data[0] == 0)
DestroyAnimVisualTask(taskId);
}
2020-02-15 00:11:04 +01:00
// Flashing blue orbs grow in size near the attacker. First stage of Hydro Cannon
static void AnimHydroCannonCharge(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
u8 priority;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 0);
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 1);
sprite->pos2.y = -10;
priority = GetBattlerSpriteSubpriority(gBattleAnimAttacker);
if (!IsContest())
{
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{
sprite->pos2.x = 10;
sprite->subpriority = priority + 2;
}
else
{
sprite->pos2.x = -10;
sprite->subpriority = priority - 2;
2019-04-06 18:38:15 +02:00
}
2018-12-19 16:31:37 +01:00
}
else
{
sprite->pos2.x = -10;
sprite->subpriority = priority + 2;
}
2020-02-20 22:22:33 +01:00
sprite->callback = AnimHydroCannonCharge_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimHydroCannonCharge_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
if (sprite->affineAnimEnded)
DestroyAnimSprite(sprite);
}
2020-02-15 00:11:04 +01:00
// Flashing blue orbs move from the attacker to the target. Second stage of Hydro Cannon
static void AnimHydroCannonBeam(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
bool8 animType;
u8 coordType;
if (GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{
gBattleAnimArgs[0] *= -1;
if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT)
gBattleAnimArgs[0] *= -1;
}
2018-12-19 16:31:37 +01:00
if ((gBattleAnimArgs[5] & 0xFF00) == 0)
animType = TRUE;
else
animType = FALSE;
if ((u8)gBattleAnimArgs[5] == 0)
coordType = 3;
else
coordType = 1;
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimAttacker(sprite, animType);
2018-12-19 16:31:37 +01:00
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
sprite->data[0] = gBattleAnimArgs[4];
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 2) + gBattleAnimArgs[2];
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, coordType) + gBattleAnimArgs[3];
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
2020-02-20 02:22:53 +01:00
// Water droplet appears and drips down. Used by Water Gun on impact
static void AnimWaterGunDroplet(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimTarget(sprite, TRUE);
2018-12-19 16:31:37 +01:00
sprite->data[0] = gBattleAnimArgs[4];
sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[2];
sprite->data[4] = sprite->pos1.y + gBattleAnimArgs[4];
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
2020-02-15 00:11:04 +01:00
static void AnimSmallBubblePair(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
2020-02-15 00:11:04 +01:00
if (gBattleAnimArgs[3] != ANIM_ATTACKER)
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimTarget(sprite, TRUE);
2018-12-19 16:31:37 +01:00
else
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimAttacker(sprite, TRUE);
2018-12-19 16:31:37 +01:00
sprite->data[7] = gBattleAnimArgs[2];
2020-02-20 22:22:33 +01:00
sprite->callback = AnimSmallBubblePair_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimSmallBubblePair_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
sprite->data[0] = (sprite->data[0] + 11) & 0xFF;
sprite->pos2.x = Sin(sprite->data[0], 4);
sprite->data[1] += 48;
sprite->pos2.y = -(sprite->data[1] >> 8);
2020-07-30 04:34:10 +02:00
if (sprite->data[7]-- == 0)
2018-12-19 16:31:37 +01:00
DestroyAnimSprite(sprite);
}
void AnimTask_CreateSurfWave(u8 taskId)
{
2019-02-06 20:17:09 +01:00
struct BattleAnimBgData animBg;
2018-12-19 16:31:37 +01:00
u8 taskId2;
2020-08-14 03:18:46 +02:00
u16 *x, *y; //These pointers are needed to match
2019-04-06 18:38:15 +02:00
2020-08-14 03:18:46 +02:00
x = &gBattle_BG1_X;
y = &gBattle_BG1_Y;
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL | BLDCNT_TGT1_BG1);
SetGpuReg(REG_OFFSET_BLDALPHA, (16 << 8));
2018-12-19 16:31:37 +01:00
SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1);
SetAnimBgAttribute(1, BG_ANIM_SCREEN_SIZE, 1);
2019-02-06 20:17:09 +01:00
sub_80A6B30(&animBg);
2020-08-14 03:18:46 +02:00
2018-12-19 16:31:37 +01:00
if (!IsContest())
{
SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 1);
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT)
2020-02-21 18:38:20 +01:00
AnimLoadCompressedBgTilemap(animBg.bgId, gBattleAnimBgTilemap_SurfOpponent);
2018-12-19 16:31:37 +01:00
else
2020-02-21 18:38:20 +01:00
AnimLoadCompressedBgTilemap(animBg.bgId, gBattleAnimBgTilemap_SurfPlayer);
2018-12-19 16:31:37 +01:00
}
else
{
2020-02-21 18:38:20 +01:00
AnimLoadCompressedBgTilemapHandleContest(&animBg, gBattleAnimBgTilemap_SurfContest, 1);
2018-12-19 16:31:37 +01:00
}
2019-04-06 18:38:15 +02:00
AnimLoadCompressedBgGfx(animBg.bgId, gBattleAnimBgImage_Surf, animBg.tilesOffset);
2018-12-19 16:31:37 +01:00
if (gBattleAnimArgs[0] == 0)
2019-04-06 18:38:15 +02:00
LoadCompressedPalette(gBattleAnimBgPalette_Surf, animBg.paletteId * 16, 32);
2018-12-19 16:31:37 +01:00
else
2019-02-06 20:17:09 +01:00
LoadCompressedPalette(gBattleAnimBackgroundImageMuddyWater_Pal, animBg.paletteId * 16, 32);
2020-02-21 18:38:20 +01:00
taskId2 = CreateTask(AnimTask_SurfWaveScanlineEffect, gTasks[taskId].priority + 1);
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[15] = taskId2;
gTasks[taskId2].data[0] = 0;
gTasks[taskId2].data[1] = 0x1000;
gTasks[taskId2].data[2] = 0x1000;
if (IsContest())
{
2020-08-14 03:18:46 +02:00
*x = -80;
*y = -48;
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[0] = 2;
gTasks[taskId].data[1] = 1;
gTasks[taskId2].data[3] = 0;
}
else if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT)
{
2020-08-14 03:18:46 +02:00
*x = -224;
*y = 256;
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[0] = 2;
gTasks[taskId].data[1] = -1;
gTasks[taskId2].data[3] = 1;
}
else
{
2020-08-14 03:18:46 +02:00
*x = 0;
*y = -48;
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[0] = -2;
gTasks[taskId].data[1] = 1;
gTasks[taskId2].data[3] = 0;
}
2020-08-14 03:18:46 +02:00
SetGpuReg(REG_OFFSET_BG1HOFS, *x);
SetGpuReg(REG_OFFSET_BG1VOFS, *y);
2018-12-19 16:31:37 +01:00
if (gTasks[taskId2].data[3] == 0)
{
gTasks[taskId2].data[4] = 48;
gTasks[taskId2].data[5] = 112;
}
else
{
gTasks[taskId2].data[4] = 0;
gTasks[taskId2].data[5] = 0;
}
gTasks[taskId].data[6] = 1;
2020-02-21 18:38:20 +01:00
gTasks[taskId].func = AnimTask_CreateSurfWave_Step1;
2018-12-19 16:31:37 +01:00
}
2020-02-21 18:38:20 +01:00
static void AnimTask_CreateSurfWave_Step1(u8 taskId)
2018-12-19 16:31:37 +01:00
{
u16 rgbBuffer;
2020-08-14 03:18:46 +02:00
u8 i;
u16 *BGptrX, *BGptrY;
struct BattleAnimBgData animBg;
BGptrX = &gBattle_BG1_X;
BGptrY = &gBattle_BG1_Y;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
*BGptrX += gTasks[taskId].data[0];
*BGptrY += gTasks[taskId].data[1];
2019-02-06 20:17:09 +01:00
sub_80A6B30(&animBg);
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[2] += gTasks[taskId].data[1];
if (++gTasks[taskId].data[5] == 4)
{
2020-08-14 03:18:46 +02:00
rgbBuffer = gPlttBufferFaded[16 * animBg.paletteId + 7];
for (i = 6; i != 0; i--) // i > 0 generates the exact same code in this context
2018-12-19 16:31:37 +01:00
{
2020-08-14 03:18:46 +02:00
gPlttBufferFaded[16 * animBg.paletteId + 1 + i] = gPlttBufferFaded[16 * animBg.paletteId + 1 + i - 1]; // 1 + i - 1 is needed to match for some bizarre reason
2018-12-19 16:31:37 +01:00
}
2020-08-14 03:18:46 +02:00
gPlttBufferFaded[16 * animBg.paletteId + 1] = rgbBuffer;
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[5] = 0;
}
if (++gTasks[taskId].data[6] > 1)
{
gTasks[taskId].data[6] = 0;
2020-08-14 03:18:46 +02:00
if (++gTasks[taskId].data[3] < 14)
2018-12-19 16:31:37 +01:00
{
2020-08-14 03:18:46 +02:00
gTasks[gTasks[taskId].data[15]].data[1] = (s16)((gTasks[taskId].data[3]) | ((16 - gTasks[taskId].data[3]) << 8));
2018-12-19 16:31:37 +01:00
gTasks[taskId].data[4]++;
}
if (gTasks[taskId].data[3] > 54)
{
2020-08-14 03:18:46 +02:00
gTasks[taskId].data[4]--;
gTasks[gTasks[taskId].data[15]].data[1] = (s16)((gTasks[taskId].data[4]) | ((16 - gTasks[taskId].data[4]) << 8));
2018-12-19 16:31:37 +01:00
}
}
if (!(gTasks[gTasks[taskId].data[15]].data[1] & 0x1F))
{
gTasks[taskId].data[0] = gTasks[gTasks[taskId].data[15]].data[1] & 0x1F;
2020-02-21 18:38:20 +01:00
gTasks[taskId].func = AnimTask_CreateSurfWave_Step2;
2018-12-19 16:31:37 +01:00
}
}
2020-08-14 03:18:46 +02:00
2018-12-19 16:31:37 +01:00
2020-02-21 18:38:20 +01:00
static void AnimTask_CreateSurfWave_Step2(u8 taskId)
2018-12-19 16:31:37 +01:00
{
u16 *BGptrX = &gBattle_BG1_X;
u16 *BGptrY = &gBattle_BG1_Y;
if (gTasks[taskId].data[0] == 0)
{
sub_80A6C68(1);
sub_80A6C68(2);
gTasks[taskId].data[0]++;
}
else
{
if (!IsContest())
SetAnimBgAttribute(1, BG_ANIM_CHAR_BASE_BLOCK, 0);
*BGptrX = 0;
*BGptrY = 0;
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 0));
gTasks[gTasks[taskId].data[15]].data[15] = -1;
DestroyAnimVisualTask(taskId);
}
}
2020-02-21 18:38:20 +01:00
static void AnimTask_SurfWaveScanlineEffect(u8 taskId)
2018-12-19 16:31:37 +01:00
{
s16 i;
struct ScanlineEffectParams params;
struct Task *task = &gTasks[taskId];
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
switch (task->data[0])
{
2019-04-11 12:05:56 +02:00
case 0:
for (i = 0; i < task->data[4]; i++)
gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2];
for (i = task->data[4]; i < task->data[5]; i++)
gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[1];
for (i = task->data[5]; i < 160; i++)
gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2];
if (task->data[4] == 0)
gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[1];
else
gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[1][i] = task->data[2];
params.dmaDest = (vu16 *)REG_ADDR_BLDALPHA;
params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT;
params.initState = 1;
params.unused9 = 0;
ScanlineEffect_SetParams(params);
task->data[0]++;
break;
case 1:
if (task->data[3] == 0)
{
if (--task->data[4] <= 0)
2018-12-19 16:31:37 +01:00
{
2019-04-11 12:05:56 +02:00
task->data[4] = 0;
2018-12-19 16:31:37 +01:00
task->data[0]++;
}
2019-04-11 12:05:56 +02:00
}
else if (++task->data[5] > 111)
{
task->data[0]++;
}
for (i = 0; i < task->data[4]; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2];
for (i = task->data[4]; i < task->data[5]; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1];
for (i = task->data[5]; i < 160; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2];
break;
case 2:
for (i = 0; i < task->data[4]; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2];
for (i = task->data[4]; i < task->data[5]; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[1];
for (i = task->data[5]; i < 160; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = task->data[2];
if (task->data[15] == -1)
{
ScanlineEffect_Stop();
DestroyTask(taskId);
}
break;
2018-12-19 16:31:37 +01:00
}
}
2020-02-20 22:22:33 +01:00
static void AnimSmallDriftingBubbles(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
s16 randData;
s16 randData2;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
sprite->oam.tileNum += 8;
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimTarget(sprite, TRUE);
2018-12-19 16:31:37 +01:00
randData = (Random2() & 0xFF) | 256;
randData2 = (Random2() & 0x1FF);
if (randData2 > 255)
randData2 = 256 - randData2;
sprite->data[1] = randData;
sprite->data[2] = randData2;
2020-02-20 22:22:33 +01:00
sprite->callback = AnimSmallDriftingBubbles_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimSmallDriftingBubbles_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
sprite->data[3] += sprite->data[1];
sprite->data[4] += sprite->data[2];
if (sprite->data[1] & 1)
sprite->pos2.x = -(sprite->data[3] >> 8);
else
sprite->pos2.x = sprite->data[3] >> 8;
sprite->pos2.y = sprite->data[4] >> 8;
if (++sprite->data[0] == 21)
DestroyAnimSprite(sprite);
}
2020-02-20 02:22:53 +01:00
void AnimTask_WaterSpoutLaunch(u8 taskId)
2018-12-19 16:31:37 +01:00
{
struct Task *task = &gTasks[taskId];
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
task->data[15] = GetAnimBattlerSpriteId(ANIM_ATTACKER);
task->data[5] = gSprites[task->data[15]].pos1.y;
2020-02-21 18:38:20 +01:00
task->data[1] = GetWaterSpoutPowerForAnim();
2018-12-19 16:31:37 +01:00
PrepareBattlerSpriteForRotScale(task->data[15], ST_OAM_OBJ_NORMAL);
2020-02-20 22:22:33 +01:00
task->func = AnimTask_WaterSpoutLaunch_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimTask_WaterSpoutLaunch_Step(u8 taskId)
2018-12-19 16:31:37 +01:00
{
struct Task *task = &gTasks[taskId];
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
switch (task->data[0])
{
2019-04-11 12:05:56 +02:00
case 0:
sub_80A805C(task, task->data[15], 0x100, 0x100, 224, 0x200, 32);
task->data[0]++;
case 1:
if (++task->data[3] > 1)
{
task->data[3] = 0;
if (++task->data[4] & 1)
2018-12-19 16:31:37 +01:00
{
2019-04-11 12:05:56 +02:00
gSprites[task->data[15]].pos2.x = 3;
gSprites[task->data[15]].pos1.y++;
2018-12-19 16:31:37 +01:00
}
2019-04-11 12:05:56 +02:00
else
2018-12-19 16:31:37 +01:00
{
2019-04-11 12:05:56 +02:00
gSprites[task->data[15]].pos2.x = -3;
2018-12-19 16:31:37 +01:00
}
2019-04-11 12:05:56 +02:00
}
if (sub_80A80C8(task) == 0)
{
SetBattlerSpriteYOffsetFromYScale(task->data[15]);
gSprites[task->data[15]].pos2.x = 0;
task->data[3] = 0;
task->data[4] = 0;
task->data[0]++;
}
break;
case 2:
if (++task->data[3] > 4)
{
sub_80A805C(task, task->data[15], 224, 0x200, 384, 224, 8);
task->data[3] = 0;
task->data[0]++;
}
break;
case 3:
if (sub_80A80C8(task) == 0)
{
task->data[3] = 0;
task->data[4] = 0;
2018-12-19 16:31:37 +01:00
task->data[0]++;
2019-04-11 12:05:56 +02:00
}
break;
case 4:
2020-02-21 18:38:20 +01:00
CreateWaterSpoutLaunchDroplets(task, taskId);
2019-04-11 12:05:56 +02:00
task->data[0]++;
case 5:
if (++task->data[3] > 1)
{
task->data[3] = 0;
if (++task->data[4] & 1)
gSprites[task->data[15]].pos2.y += 2;
else
gSprites[task->data[15]].pos2.y -= 2;
if (task->data[4] == 10)
2018-12-19 16:31:37 +01:00
{
2019-04-11 12:05:56 +02:00
sub_80A805C(task, task->data[15], 384, 224, 0x100, 0x100, 8);
2018-12-19 16:31:37 +01:00
task->data[3] = 0;
task->data[4] = 0;
task->data[0]++;
}
2019-04-11 12:05:56 +02:00
}
break;
case 6:
gSprites[task->data[15]].pos1.y--;
if (sub_80A80C8(task) == 0)
{
ResetSpriteRotScale(task->data[15]);
gSprites[task->data[15]].pos1.y = task->data[5];
task->data[4] = 0;
task->data[0]++;
}
break;
case 7:
if (task->data[2] == 0)
DestroyAnimVisualTask(taskId);
break;
2018-12-19 16:31:37 +01:00
}
}
2020-02-21 18:38:20 +01:00
// Returns a value 0-3 relative to which quarter HP the attacker is in
// A higher number results in more water sprites during the Water Spout animation
static u8 GetWaterSpoutPowerForAnim(void)
2018-12-19 16:31:37 +01:00
{
u8 i;
u16 hp;
u16 maxhp;
u16 partyIndex;
struct Pokemon *slot;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{
partyIndex = gBattlerPartyIndexes[gBattleAnimAttacker];
slot = &gPlayerParty[partyIndex];
maxhp = GetMonData(slot, MON_DATA_MAX_HP);
hp = GetMonData(slot, MON_DATA_HP);
maxhp /= 4;
}
else
{
partyIndex = gBattlerPartyIndexes[gBattleAnimAttacker];
slot = &gEnemyParty[partyIndex];
maxhp = GetMonData(slot, MON_DATA_MAX_HP);
hp = GetMonData(slot, MON_DATA_HP);
maxhp /= 4;
}
for (i = 0; i < 3; i++)
{
if (hp < maxhp * (i + 1))
return i;
}
return 3;
}
2020-02-21 18:38:20 +01:00
static void CreateWaterSpoutLaunchDroplets(struct Task *task, u8 taskId)
2018-12-19 16:31:37 +01:00
{
s16 i;
s16 attackerCoordX = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
s16 attackerCoordY = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
s16 trigIndex = 172;
u8 subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1;
s16 increment = 4 - task->data[1];
u8 spriteId;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
if (increment <= 0)
increment = 1;
for (i = 0; i < 20; i += increment)
{
2020-02-21 18:38:20 +01:00
spriteId = CreateSprite(&gSmallWaterOrbSpriteTemplate, attackerCoordX, attackerCoordY, subpriority);
2018-12-19 16:31:37 +01:00
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].data[1] = i;
gSprites[spriteId].data[2] = attackerCoordX * 16;
gSprites[spriteId].data[3] = attackerCoordY * 16;
gSprites[spriteId].data[4] = Cos(trigIndex, 64);
gSprites[spriteId].data[5] = Sin(trigIndex, 64);
gSprites[spriteId].data[6] = taskId;
gSprites[spriteId].data[7] = 2;
if (task->data[2] & 1)
2020-02-21 18:38:20 +01:00
AnimSmallWaterOrb(&gSprites[spriteId]);
2018-12-19 16:31:37 +01:00
task->data[2]++;
}
trigIndex = (trigIndex + increment * 2);
trigIndex &= 0xFF;
}
}
2020-02-21 18:38:20 +01:00
static void AnimSmallWaterOrb(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
switch (sprite->data[0])
{
2019-04-11 12:05:56 +02:00
case 0:
sprite->data[4] += (sprite->data[1] % 6) * 3;
sprite->data[5] += (sprite->data[1] % 3) * 3;
sprite->data[0]++;
case 1:
sprite->data[2] += sprite->data[4];
sprite->data[3] += sprite->data[5];
sprite->pos1.x = sprite->data[2] >> 4;
sprite->pos1.y = sprite->data[3] >> 4;
if (sprite->pos1.x < -8 || sprite->pos1.x > 248 || sprite->pos1.y < -8 || sprite->pos1.y > 120)
{
gTasks[sprite->data[6]].data[sprite->data[7]]--;
DestroySprite(sprite);
}
break;
2018-12-19 16:31:37 +01:00
}
}
2020-02-20 02:22:53 +01:00
void AnimTask_WaterSpoutRain(u8 taskId)
2018-12-19 16:31:37 +01:00
{
struct Task *task = &gTasks[taskId];
2019-04-06 18:38:15 +02:00
2020-02-21 18:38:20 +01:00
task->data[1] = GetWaterSpoutPowerForAnim();
2018-12-19 16:31:37 +01:00
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER)
{
task->data[4] = 136;
task->data[6] = 40;
}
else
{
task->data[4] = 16;
task->data[6] = 80;
}
task->data[5] = 98;
task->data[7] = task->data[4] + 49;
task->data[12] = task->data[1] * 5 + 5;
2020-02-20 22:22:33 +01:00
task->func = AnimTask_WaterSpoutRain_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimTask_WaterSpoutRain_Step(u8 taskId)
2018-12-19 16:31:37 +01:00
{
struct Task *task = &gTasks[taskId];
u8 taskId2;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
switch (task->data[0])
{
2019-04-11 12:05:56 +02:00
case 0:
if (++task->data[2] > 2)
{
task->data[2] = 0;
2020-02-21 18:38:20 +01:00
CreateWaterSpoutRainDroplet(task, taskId);
2019-04-11 12:05:56 +02:00
}
if (task->data[10] != 0 && task->data[13] == 0)
{
2020-02-15 00:11:04 +01:00
gBattleAnimArgs[0] = ANIM_TARGET;
2019-04-11 12:05:56 +02:00
gBattleAnimArgs[1] = 0;
gBattleAnimArgs[2] = 12;
2020-02-15 00:11:04 +01:00
taskId2 = CreateTask(AnimTask_HorizontalShake, 80);
2019-04-11 12:05:56 +02:00
if (taskId2 != 0xFF)
2018-12-19 16:31:37 +01:00
{
2019-04-11 12:05:56 +02:00
gTasks[taskId2].func(taskId2);
gAnimVisualTaskCount++;
2018-12-19 16:31:37 +01:00
}
2020-02-15 00:11:04 +01:00
gBattleAnimArgs[0] = ANIM_DEF_PARTNER;
taskId2 = CreateTask(AnimTask_HorizontalShake, 80);
2019-04-11 12:05:56 +02:00
if (taskId2 != 0xFF)
2018-12-19 16:31:37 +01:00
{
2019-04-11 12:05:56 +02:00
gTasks[taskId2].func(taskId2);
gAnimVisualTaskCount++;
2018-12-19 16:31:37 +01:00
}
2019-04-11 12:05:56 +02:00
task->data[13] = 1;
}
if (task->data[11] >= task->data[12])
task->data[0]++;
break;
case 1:
if (task->data[9] == 0)
DestroyAnimVisualTask(taskId);
break;
2018-12-19 16:31:37 +01:00
}
}
2020-02-21 18:38:20 +01:00
static void CreateWaterSpoutRainDroplet(struct Task *task, u8 taskId)
2018-12-19 16:31:37 +01:00
{
u16 yPosArg = ((gSineTable[task->data[8]] + 3) >> 4) + task->data[6];
2020-02-21 18:38:20 +01:00
u8 spriteId = CreateSprite(&gSmallWaterOrbSpriteTemplate, task->data[7], 0, 0);
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
if (spriteId != MAX_SPRITES)
{
2020-02-21 18:38:20 +01:00
gSprites[spriteId].callback = AnimWaterSpoutRain;
2018-12-19 16:31:37 +01:00
gSprites[spriteId].data[5] = yPosArg;
gSprites[spriteId].data[6] = taskId;
gSprites[spriteId].data[7] = 9;
task->data[9]++;
}
task->data[11]++;
task->data[8] = (task->data[8] + 39) & 0xFF;
task->data[7] = (ISO_RANDOMIZE2(task->data[7]) % task->data[5]) + task->data[4];
2018-12-19 16:31:37 +01:00
}
2020-02-21 18:38:20 +01:00
static void AnimWaterSpoutRain(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
if (sprite->data[0] == 0)
{
sprite->pos1.y += 8;
if (sprite->pos1.y >= sprite->data[5])
{
gTasks[sprite->data[6]].data[10] = 1;
2020-02-14 22:05:43 +01:00
sprite->data[1] = CreateSprite(&gWaterHitSplatSpriteTemplate, sprite->pos1.x, sprite->pos1.y, 1);
2018-12-19 16:31:37 +01:00
if (sprite->data[1] != MAX_SPRITES)
{
StartSpriteAffineAnim(&gSprites[sprite->data[1]], 3);
gSprites[sprite->data[1]].data[6] = sprite->data[6];
gSprites[sprite->data[1]].data[7] = sprite->data[7];
2020-02-21 18:38:20 +01:00
gSprites[sprite->data[1]].callback = AnimWaterSpoutRainHit;
2018-12-19 16:31:37 +01:00
}
DestroySprite(sprite);
}
}
}
2020-02-21 18:38:20 +01:00
static void AnimWaterSpoutRainHit(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
if (++sprite->data[1] > 1)
{
sprite->data[1] = 0;
sprite->invisible ^= 1;
if (++sprite->data[2] == 12)
{
gTasks[sprite->data[6]].data[sprite->data[7]]--;
FreeOamMatrix(sprite->oam.matrixNum);
DestroySprite(sprite);
}
}
}
2020-02-20 02:22:53 +01:00
void AnimTask_WaterSport(u8 taskId)
2018-12-19 16:31:37 +01:00
{
struct Task *task = &gTasks[taskId];
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
task->data[3] = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
task->data[4] = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
task->data[7] = (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_PLAYER) ? 1 : -1;
if (IsContest())
task->data[7] *= -1;
task->data[5] = task->data[3] + task->data[7] * 8;
task->data[6] = task->data[4] - task->data[7] * 8;
task->data[9] = -32;
task->data[1] = 0;
task->data[0] = 0;
2020-02-21 18:38:20 +01:00
task->func = AnimTask_WaterSport_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-21 18:38:20 +01:00
static void AnimTask_WaterSport_Step(u8 taskId)
2018-12-19 16:31:37 +01:00
{
struct Task *task = &gTasks[taskId];
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
switch (task->data[0])
{
2019-04-11 12:05:56 +02:00
case 0:
2020-02-21 18:38:20 +01:00
CreateWaterSportDroplet(task);
2019-04-11 12:05:56 +02:00
if (task->data[10] != 0)
task->data[0]++;
break;
case 1:
2020-02-21 18:38:20 +01:00
CreateWaterSportDroplet(task);
2019-04-11 12:05:56 +02:00
if (++task->data[1] > 16)
{
task->data[1] = 0;
task->data[0]++;
}
break;
case 2:
2020-02-21 18:38:20 +01:00
CreateWaterSportDroplet(task);
2019-04-11 12:05:56 +02:00
task->data[5] += task->data[7] * 6;
if (!(task->data[5] >= -16 && task->data[5] <= 256))
{
if (++task->data[12] > 2)
2018-12-19 16:31:37 +01:00
{
2019-04-11 12:05:56 +02:00
task->data[13] = 1;
task->data[0] = 6;
2018-12-19 16:31:37 +01:00
task->data[1] = 0;
}
2019-04-11 12:05:56 +02:00
else
2018-12-19 16:31:37 +01:00
{
task->data[1] = 0;
task->data[0]++;
}
2019-04-11 12:05:56 +02:00
}
break;
case 3:
2020-02-21 18:38:20 +01:00
CreateWaterSportDroplet(task);
2019-04-11 12:05:56 +02:00
task->data[6] -= task->data[7] * 2;
if (++task->data[1] > 7)
task->data[0]++;
break;
case 4:
2020-02-21 18:38:20 +01:00
CreateWaterSportDroplet(task);
2019-04-11 12:05:56 +02:00
task->data[5] -= task->data[7] * 6;
if (!(task->data[5] >= -16 && task->data[5] <= 256))
{
task->data[12]++;
task->data[1] = 0;
task->data[0]++;
}
break;
case 5:
2020-02-21 18:38:20 +01:00
CreateWaterSportDroplet(task);
2019-04-11 12:05:56 +02:00
task->data[6] -= task->data[7] * 2;
if (++task->data[1] > 7)
task->data[0] = 2;
break;
case 6:
if (task->data[8] == 0)
task->data[0]++;
break;
default:
DestroyAnimVisualTask(taskId);
break;
2018-12-19 16:31:37 +01:00
}
}
2020-02-21 18:38:20 +01:00
static void CreateWaterSportDroplet(struct Task *task)
2018-12-19 16:31:37 +01:00
{
u8 spriteId;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
if (++task->data[2] > 1)
{
task->data[2] = 0;
2020-02-21 18:38:20 +01:00
spriteId = CreateSprite(&gSmallWaterOrbSpriteTemplate, task->data[3], task->data[4], 10);
2018-12-19 16:31:37 +01:00
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].data[0] = 16;
gSprites[spriteId].data[2] = task->data[5];
gSprites[spriteId].data[4] = task->data[6];
gSprites[spriteId].data[5] = task->data[9];
InitAnimArcTranslation(&gSprites[spriteId]);
2020-02-21 18:38:20 +01:00
gSprites[spriteId].callback = AnimWaterSportDroplet;
2018-12-19 16:31:37 +01:00
task->data[8]++;
}
}
}
2020-02-21 18:38:20 +01:00
static void AnimWaterSportDroplet(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
2019-02-06 20:17:09 +01:00
if (TranslateAnimHorizontalArc(sprite))
2018-12-19 16:31:37 +01:00
{
sprite->pos1.x += sprite->pos2.x;
sprite->pos1.y += sprite->pos2.y;
sprite->data[0] = 6;
sprite->data[2] = (Random2() & 0x1F) - 16 + sprite->pos1.x;
sprite->data[4] = (Random2() & 0x1F) - 16 + sprite->pos1.y;
sprite->data[5] = ~(Random2() & 7);
InitAnimArcTranslation(sprite);
2020-02-21 18:38:20 +01:00
sprite->callback = AnimWaterSportDroplet_Step;
2018-12-19 16:31:37 +01:00
}
}
2020-02-21 18:38:20 +01:00
static void AnimWaterSportDroplet_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
u16 i;
2019-04-06 18:38:15 +02:00
2019-02-06 20:17:09 +01:00
if (TranslateAnimHorizontalArc(sprite))
2018-12-19 16:31:37 +01:00
{
for (i = 0; i < NUM_TASKS; i++)
{
2020-02-21 18:38:20 +01:00
if (gTasks[i].func == AnimTask_WaterSport_Step)
2018-12-19 16:31:37 +01:00
{
gTasks[i].data[10] = 1;
gTasks[i].data[8]--;
DestroySprite(sprite);
}
}
}
}
2020-02-20 02:22:53 +01:00
static void AnimWaterPulseBubble(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
sprite->pos1.x = gBattleAnimArgs[0];
sprite->pos1.y = gBattleAnimArgs[1];
sprite->data[0] = gBattleAnimArgs[2];
sprite->data[1] = gBattleAnimArgs[3];
sprite->data[2] = gBattleAnimArgs[4];
sprite->data[3] = gBattleAnimArgs[5];
2020-02-20 22:22:33 +01:00
sprite->callback = AnimWaterPulseBubble_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimWaterPulseBubble_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
sprite->data[4] -= sprite->data[0];
sprite->pos2.y = sprite->data[4] / 10;
sprite->data[5] = (sprite->data[5] + sprite->data[1]) & 0xFF;
sprite->pos2.x = Sin(sprite->data[5], sprite->data[2]);
if (--sprite->data[3] == 0)
DestroyAnimSprite(sprite);
}
2020-02-21 18:38:20 +01:00
static void AnimWaterPulseRingBubble(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
sprite->data[3] += sprite->data[1];
sprite->data[4] += sprite->data[2];
sprite->pos2.x = sprite->data[3] >> 7;
sprite->pos2.y = sprite->data[4] >> 7;
if (--sprite->data[0] == 0)
{
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
}
}
2019-10-20 10:47:56 +02:00
void AnimWaterPulseRing(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimAttacker(sprite, TRUE);
2018-12-19 16:31:37 +01:00
sprite->data[1] = GetBattlerSpriteCoord(gBattleAnimTarget, 2);
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, 3);
sprite->data[3] = gBattleAnimArgs[2];
sprite->data[4] = gBattleAnimArgs[3];
2019-10-20 10:47:56 +02:00
sprite->callback = AnimWaterPulseRing_Step;
2018-12-19 16:31:37 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimWaterPulseRing_Step(struct Sprite *sprite)
2018-12-19 16:31:37 +01:00
{
int xDiff = sprite->data[1] - sprite->pos1.x;
int yDiff = sprite->data[2] - sprite->pos1.y;
2019-04-06 18:38:15 +02:00
2018-12-19 16:31:37 +01:00
sprite->pos2.x = (sprite->data[0] * xDiff) / sprite->data[3];
sprite->pos2.y = (sprite->data[0] * yDiff) / sprite->data[3];
if (++sprite->data[5] == sprite->data[4])
{
sprite->data[5] = 0;
2020-02-21 18:38:20 +01:00
CreateWaterPulseRingBubbles(sprite, xDiff, yDiff);
2018-12-19 16:31:37 +01:00
}
if (sprite->data[3] == sprite->data[0])
DestroyAnimSprite(sprite);
sprite->data[0]++;
}
2020-07-30 04:34:10 +02:00
static void CreateWaterPulseRingBubbles(struct Sprite *sprite, s32 xDiff, s32 yDiff)
2018-12-19 16:31:37 +01:00
{
2020-07-30 04:34:10 +02:00
s16 combinedX, combinedY;
s16 i, something;
s16 unusedVar = 1; //unusedVar is needed to match
s16 somethingRandomX, somethingRandomY;
2018-12-19 16:31:37 +01:00
u8 spriteId;
2019-04-06 18:38:15 +02:00
2020-07-30 04:34:10 +02:00
something = sprite->data[0] / 2;
combinedX = sprite->pos1.x + sprite->pos2.x;
combinedY = sprite->pos1.y + sprite->pos2.y;
if (yDiff < 0)
unusedVar *= -1; //Needed to Match
somethingRandomY = yDiff + (Random2() % 10) - 5;
somethingRandomX = -xDiff + (Random2() % 10) - 5;
for (i = 0; i < 1; i++)
2018-12-19 16:31:37 +01:00
{
2020-02-21 18:38:20 +01:00
spriteId = CreateSprite(&gWaterPulseRingBubbleSpriteTemplate, combinedX, combinedY + something, 130);
2018-12-19 16:31:37 +01:00
gSprites[spriteId].data[0] = 20;
2020-07-30 04:34:10 +02:00
gSprites[spriteId].data[1] = somethingRandomY;
2018-12-19 16:31:37 +01:00
gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1;
2020-07-30 04:34:10 +02:00
if (somethingRandomX < 0)
{
gSprites[spriteId].data[2] = -somethingRandomX;
}
2018-12-19 16:31:37 +01:00
else
2020-07-30 04:34:10 +02:00
{
gSprites[spriteId].data[2] = somethingRandomX;
}
2018-12-19 16:31:37 +01:00
}
2020-07-30 04:34:10 +02:00
for (i = 0; i < 1; i++)
2018-12-19 16:31:37 +01:00
{
2020-02-21 18:38:20 +01:00
spriteId = CreateSprite(&gWaterPulseRingBubbleSpriteTemplate, combinedX, combinedY - something, 130);
2018-12-19 16:31:37 +01:00
gSprites[spriteId].data[0] = 20;
2020-07-30 04:34:10 +02:00
gSprites[spriteId].data[1] = somethingRandomY;
2018-12-19 16:31:37 +01:00
gSprites[spriteId].subpriority = GetBattlerSpriteSubpriority(gBattleAnimAttacker) - 1;
2020-07-30 04:34:10 +02:00
if (somethingRandomX > 0)
{
gSprites[spriteId].data[2] = -somethingRandomX;
}
2018-12-19 16:31:37 +01:00
else
2020-07-30 04:34:10 +02:00
{
gSprites[spriteId].data[2] = somethingRandomX;
}
2018-12-19 16:31:37 +01:00
}
2020-07-30 04:47:03 +02:00
}