pokeemerald/src/battle_anim_poison.c

320 lines
8.6 KiB
C
Raw Normal View History

2018-10-25 23:46:23 +02:00
#include "global.h"
#include "battle_anim.h"
2018-11-26 16:13:45 +01:00
#include "trig.h"
2018-10-25 23:46:23 +02:00
#include "constants/rgb.h"
2020-02-20 02:22:53 +01:00
static void AnimSludgeProjectile(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimSludgeProjectile_Step(struct Sprite *);
2020-02-20 02:22:53 +01:00
static void AnimAcidPoisonBubble(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimAcidPoisonBubble_Step(struct Sprite *);
2020-02-20 02:22:53 +01:00
static void AnimSludgeBombHitParticle(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimSludgeBombHitParticle_Step(struct Sprite *);
2020-02-20 02:22:53 +01:00
static void AnimAcidPoisonDroplet(struct Sprite *);
static void AnimBubbleEffect(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimBubbleEffect_Step(struct Sprite *);
2018-10-25 23:46:23 +02:00
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_ToxicBubble[] =
2018-10-25 23:46:23 +02:00
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_FRAME(8, 5),
ANIMCMD_FRAME(16, 5),
ANIMCMD_FRAME(24, 5),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_ToxicBubble[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_ToxicBubble,
2018-10-25 23:46:23 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gToxicBubbleSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_TOXIC_BUBBLE,
.paletteTag = ANIM_TAG_TOXIC_BUBBLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_16x32,
2020-02-21 18:38:20 +01:00
.anims = sAnims_ToxicBubble,
2018-10-25 23:46:23 +02:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2019-10-20 16:22:53 +02:00
.callback = AnimSpriteOnMonPos,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_PoisonProjectile[] =
2018-10-25 23:46:23 +02:00
{
ANIMCMD_FRAME(0, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_AcidPoisonDroplet[] =
2018-10-25 23:46:23 +02:00
{
ANIMCMD_FRAME(4, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd sAnim_SludgeBombHit[] =
2018-10-25 23:46:23 +02:00
{
ANIMCMD_FRAME(8, 1),
ANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_PoisonProjectile[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_PoisonProjectile,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_AcidPoisonDroplet[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_AcidPoisonDroplet,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AnimCmd *const sAnims_SludgeBombHit[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAnim_SludgeBombHit,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_PoisonProjectile[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x160, 0x160, 0, 0),
AFFINEANIMCMD_FRAME(0xFFF6, 0xFFF6, 0, 10),
AFFINEANIMCMD_FRAME(0xA, 0xA, 0, 10),
AFFINEANIMCMD_JUMP(0),
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_SludgeBombHit[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0xEC, 0xEC, 0, 0),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_PoisonProjectile[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_PoisonProjectile,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_SludgeBombHit[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_SludgeBombHit,
2018-10-25 23:46:23 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gSludgeProjectileSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_POISON_BUBBLE,
.paletteTag = ANIM_TAG_POISON_BUBBLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjNormal_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_PoisonProjectile,
2018-10-25 23:46:23 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_PoisonProjectile,
2020-02-20 02:22:53 +01:00
.callback = AnimSludgeProjectile,
2018-10-25 23:46:23 +02:00
};
2020-02-14 22:05:43 +01:00
const struct SpriteTemplate gAcidPoisonBubbleSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_POISON_BUBBLE,
.paletteTag = ANIM_TAG_POISON_BUBBLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjNormal_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_PoisonProjectile,
2018-10-25 23:46:23 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_PoisonProjectile,
2020-02-14 22:05:43 +01:00
.callback = AnimAcidPoisonBubble,
2018-10-25 23:46:23 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gSludgeBombHitParticleSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_POISON_BUBBLE,
.paletteTag = ANIM_TAG_POISON_BUBBLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_SludgeBombHit,
2018-10-25 23:46:23 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_SludgeBombHit,
2020-02-20 02:22:53 +01:00
.callback = AnimSludgeBombHitParticle,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_AcidPoisonDroplet[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0xFFF0, 0x10, 0, 6),
AFFINEANIMCMD_FRAME(0x10, 0xFFF0, 0, 6),
AFFINEANIMCMD_JUMP(0),
};
2020-02-21 18:38:20 +01:00
const union AffineAnimCmd *const gAffineAnims_Droplet[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_AcidPoisonDroplet,
2018-10-25 23:46:23 +02:00
};
2020-02-14 22:05:43 +01:00
const struct SpriteTemplate gAcidPoisonDropletSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_POISON_BUBBLE,
.paletteTag = ANIM_TAG_POISON_BUBBLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjNormal_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_AcidPoisonDroplet,
2018-10-25 23:46:23 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = gAffineAnims_Droplet,
2020-02-14 22:05:43 +01:00
.callback = AnimAcidPoisonDroplet,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_Bubble[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x9C, 0x9C, 0, 0),
AFFINEANIMCMD_FRAME(0x5, 0x5, 0, 20),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_Bubble[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_Bubble,
2018-10-25 23:46:23 +02:00
};
const struct SpriteTemplate gPoisonBubbleSpriteTemplate =
{
.tileTag = ANIM_TAG_POISON_BUBBLE,
.paletteTag = ANIM_TAG_POISON_BUBBLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_16x16,
2020-02-21 18:38:20 +01:00
.anims = sAnims_PoisonProjectile,
2018-10-25 23:46:23 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_Bubble,
2018-11-26 16:13:45 +01:00
.callback = AnimBubbleEffect,
2018-10-25 23:46:23 +02:00
};
const struct SpriteTemplate gWaterBubbleSpriteTemplate =
{
.tileTag = ANIM_TAG_SMALL_BUBBLES,
.paletteTag = ANIM_TAG_SMALL_BUBBLES,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjBlend_16x16,
2020-02-21 18:38:20 +01:00
.anims = gAnims_WaterBubble,
2018-10-25 23:46:23 +02:00
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_Bubble,
2018-11-26 16:13:45 +01:00
.callback = AnimBubbleEffect,
2018-10-25 23:46:23 +02:00
};
2018-11-26 16:13:45 +01:00
2020-02-20 02:22:53 +01:00
static void AnimSludgeProjectile(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
if (!gBattleAnimArgs[3])
StartSpriteAnim(sprite, 2);
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimAttacker(sprite, 1);
2018-11-26 16:13:45 +01:00
sprite->data[0] = gBattleAnimArgs[2];
2021-11-08 17:46:38 +01:00
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2);
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET);
2018-11-26 16:13:45 +01:00
sprite->data[5] = -30;
InitAnimArcTranslation(sprite);
2020-02-20 22:22:33 +01:00
sprite->callback = AnimSludgeProjectile_Step;
2018-11-26 16:13:45 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimSludgeProjectile_Step(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
2019-02-06 20:17:09 +01:00
if (TranslateAnimHorizontalArc(sprite))
2018-11-26 16:13:45 +01:00
DestroyAnimSprite(sprite);
}
2020-02-20 02:22:53 +01:00
static void AnimAcidPoisonBubble(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
s16 l1, l2;
if (!gBattleAnimArgs[3])
StartSpriteAnim(sprite, 2);
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimAttacker(sprite, 1);
2018-11-26 16:13:45 +01:00
SetAverageBattlerPositions(gBattleAnimTarget, 1, &l1, &l2);
if (GetBattlerSide(gBattleAnimAttacker))
gBattleAnimArgs[4] = -gBattleAnimArgs[4];
sprite->data[0] = gBattleAnimArgs[2];
sprite->data[2] = l1 + gBattleAnimArgs[4];
sprite->data[4] = l2 + gBattleAnimArgs[5];
sprite->data[5] = -30;
InitAnimArcTranslation(sprite);
2020-02-20 22:22:33 +01:00
sprite->callback = AnimAcidPoisonBubble_Step;
2018-11-26 16:13:45 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimAcidPoisonBubble_Step(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
2019-02-06 20:17:09 +01:00
if (TranslateAnimHorizontalArc(sprite))
2018-11-26 16:13:45 +01:00
DestroyAnimSprite(sprite);
}
2020-02-20 02:22:53 +01:00
static void AnimSludgeBombHitParticle(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
sprite->data[0] = gBattleAnimArgs[2];
2021-07-07 15:11:52 +02:00
sprite->data[1] = sprite->x;
sprite->data[2] = sprite->x + gBattleAnimArgs[0];
sprite->data[3] = sprite->y;
sprite->data[4] = sprite->y + gBattleAnimArgs[1];
2018-11-26 16:13:45 +01:00
InitSpriteDataForLinearTranslation(sprite);
sprite->data[5] = sprite->data[1] / gBattleAnimArgs[2];
sprite->data[6] = sprite->data[2] / gBattleAnimArgs[2];
2020-02-20 22:22:33 +01:00
sprite->callback = AnimSludgeBombHitParticle_Step;
2018-11-26 16:13:45 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimSludgeBombHitParticle_Step(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
2019-02-06 20:17:09 +01:00
TranslateSpriteLinearFixedPoint(sprite);
2018-11-26 16:13:45 +01:00
sprite->data[1] -= sprite->data[5];
sprite->data[2] -= sprite->data[6];
if (!sprite->data[0])
DestroyAnimSprite(sprite);
}
2020-02-20 02:22:53 +01:00
static void AnimAcidPoisonDroplet(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
2021-07-07 15:11:52 +02:00
SetAverageBattlerPositions(gBattleAnimTarget, TRUE, &sprite->x, &sprite->y);
2018-11-26 16:13:45 +01:00
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
2021-07-07 15:11:52 +02:00
sprite->x += gBattleAnimArgs[0];
sprite->y += gBattleAnimArgs[1];
2018-11-26 16:13:45 +01:00
sprite->data[0] = gBattleAnimArgs[4];
2021-07-07 15:11:52 +02:00
sprite->data[2] = sprite->x + gBattleAnimArgs[2];
sprite->data[4] = sprite->y + sprite->data[0];
2018-11-26 16:13:45 +01:00
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
// Animates a bubble by rising upward, swaying side to side, and
// enlarging the sprite. This is used as an after-effect by poison-type
// moves, along with MOVE_BUBBLE, and MOVE_BUBBLEBEAM.
// arg 0: initial x pixel offset
// arg 1: initial y pixel offset
// arg 2: 0 = single-target, 1 = multi-target
2020-02-20 02:22:53 +01:00
static void AnimBubbleEffect(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
if (!gBattleAnimArgs[2])
{
2018-12-20 04:13:26 +01:00
InitSpritePosToAnimTarget(sprite, TRUE);
2018-11-26 16:13:45 +01:00
}
else
{
2021-07-07 15:11:52 +02:00
SetAverageBattlerPositions(gBattleAnimTarget, TRUE, &sprite->x, &sprite->y);
2018-11-26 16:13:45 +01:00
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
2021-07-07 15:11:52 +02:00
sprite->x += gBattleAnimArgs[0];
sprite->y += gBattleAnimArgs[1];
2018-11-26 16:13:45 +01:00
}
2020-02-20 22:22:33 +01:00
sprite->callback = AnimBubbleEffect_Step;
2018-11-26 16:13:45 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimBubbleEffect_Step(struct Sprite *sprite)
2018-11-26 16:13:45 +01:00
{
sprite->data[0] = (sprite->data[0] + 0xB) & 0xFF;
2021-07-07 15:11:52 +02:00
sprite->x2 = Sin(sprite->data[0], 4);
2018-11-26 16:13:45 +01:00
sprite->data[1] += 0x30;
2021-07-07 15:11:52 +02:00
sprite->y2 = -(sprite->data[1] >> 8);
2018-11-26 16:13:45 +01:00
if (sprite->affineAnimEnded)
DestroyAnimSprite(sprite);
}