pokeemerald/src/battle_anim_bug.c

496 lines
14 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:03:50 +01:00
#include "gpu_regs.h"
#include "trig.h"
2018-10-25 23:46:23 +02:00
#include "constants/rgb.h"
2020-02-16 23:49:24 +01:00
static void AnimMegahornHorn(struct Sprite *);
static void AnimLeechLifeNeedle(struct Sprite *);
2020-02-20 06:04:42 +01:00
static void AnimTranslateWebThread(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimTranslateWebThread_Step(struct Sprite *);
2020-02-20 02:22:53 +01:00
static void AnimStringWrap(struct Sprite *);
2020-02-20 22:22:33 +01:00
static void AnimSpiderWeb_Step(struct Sprite *);
static void AnimSpiderWeb_End(struct Sprite *);
static void AnimTranslateStinger(struct Sprite *);
2020-02-20 02:22:53 +01:00
static void AnimTailGlowOrb(struct Sprite *);
2018-10-25 23:46:23 +02:00
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_MegahornHorn_0[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x100, 0x100, 30, 0),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_MegahornHorn_1[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x100, 0x100, -99, 0),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_MegahornHorn_2[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x100, 0x100, 94, 0),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_MegahornHorn[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_MegahornHorn_0,
sAffineAnim_MegahornHorn_1,
sAffineAnim_MegahornHorn_2,
2018-10-25 23:46:23 +02:00
};
2020-02-16 23:49:24 +01:00
const struct SpriteTemplate gMegahornHornSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_HORN_HIT_2,
.paletteTag = ANIM_TAG_HORN_HIT_2,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjNormal_32x16,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_MegahornHorn,
2020-02-16 23:49:24 +01:00
.callback = AnimMegahornHorn,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_LeechLifeNeedle_0[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x0, 0x0, -33, 1),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_LeechLifeNeedle_1[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x0, 0x0, 96, 1),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_LeechLifeNeedle_2[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x0, 0x0, -96, 1),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_LeechLifeNeedle[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_LeechLifeNeedle_0,
sAffineAnim_LeechLifeNeedle_1,
sAffineAnim_LeechLifeNeedle_2,
2018-10-25 23:46:23 +02:00
};
2020-02-16 23:49:24 +01:00
const struct SpriteTemplate gLeechLifeNeedleSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_NEEDLE,
.paletteTag = ANIM_TAG_NEEDLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_16x16,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_LeechLifeNeedle,
2020-02-16 23:49:24 +01:00
.callback = AnimLeechLifeNeedle,
2018-10-25 23:46:23 +02:00
};
2019-04-02 08:36:22 +02:00
const struct SpriteTemplate gWebThreadSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_WEB_THREAD,
.paletteTag = ANIM_TAG_WEB_THREAD,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2019-04-02 08:36:22 +02:00
.callback = AnimTranslateWebThread,
2018-10-25 23:46:23 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gStringWrapSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_STRING,
.paletteTag = ANIM_TAG_STRING,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_64x32,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-20 02:22:53 +01:00
.callback = AnimStringWrap,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_SpiderWeb[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x10, 0x10, 0, 0),
AFFINEANIMCMD_FRAME(0x6, 0x6, 0, 1),
AFFINEANIMCMD_JUMP(1),
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_SpiderWeb[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_SpiderWeb,
2018-10-25 23:46:23 +02:00
};
2019-04-02 08:36:22 +02:00
const struct SpriteTemplate gSpiderWebSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_SPIDER_WEB,
.paletteTag = ANIM_TAG_SPIDER_WEB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjBlend_64x64,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_SpiderWeb,
2020-02-20 22:22:33 +01:00
.callback = AnimSpiderWeb,
2018-10-25 23:46:23 +02:00
};
const struct SpriteTemplate gLinearStingerSpriteTemplate =
{
.tileTag = ANIM_TAG_NEEDLE,
.paletteTag = ANIM_TAG_NEEDLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_16x16,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2018-11-26 16:03:50 +01:00
.callback = AnimTranslateStinger,
2018-10-25 23:46:23 +02:00
};
const struct SpriteTemplate gPinMissileSpriteTemplate =
{
.tileTag = ANIM_TAG_NEEDLE,
.paletteTag = ANIM_TAG_NEEDLE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_16x16,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2018-11-26 16:03:50 +01:00
.callback = AnimMissileArc,
2018-10-25 23:46:23 +02:00
};
const struct SpriteTemplate gIcicleSpearSpriteTemplate =
{
.tileTag = ANIM_TAG_ICICLE_SPEAR,
.paletteTag = ANIM_TAG_ICICLE_SPEAR,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjNormal_32x32,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2018-11-26 16:03:50 +01:00
.callback = AnimMissileArc,
2018-10-25 23:46:23 +02:00
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd sAffineAnim_TailGlowOrb[] =
2018-10-25 23:46:23 +02:00
{
AFFINEANIMCMD_FRAME(0x10, 0x10, 0, 0),
AFFINEANIMCMD_FRAME(0x8, 0x8, 0, 18),
AFFINEANIMCMD_LOOP(0),
AFFINEANIMCMD_FRAME(0xFFFB, 0xFFFB, 0, 8),
AFFINEANIMCMD_FRAME(0x5, 0x5, 0, 8),
AFFINEANIMCMD_LOOP(5),
AFFINEANIMCMD_END,
};
2020-02-21 18:38:20 +01:00
static const union AffineAnimCmd *const sAffineAnims_TailGlowOrb[] =
2018-10-25 23:46:23 +02:00
{
2020-02-21 18:38:20 +01:00
sAffineAnim_TailGlowOrb,
2018-10-25 23:46:23 +02:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gTailGlowOrbSpriteTemplate =
2018-10-25 23:46:23 +02:00
{
.tileTag = ANIM_TAG_CIRCLE_OF_LIGHT,
.paletteTag = ANIM_TAG_CIRCLE_OF_LIGHT,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineNormal_ObjBlend_64x64,
2018-10-25 23:46:23 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
2020-02-21 18:38:20 +01:00
.affineAnims = sAffineAnims_TailGlowOrb,
2020-02-20 02:22:53 +01:00
.callback = AnimTailGlowOrb,
2018-10-25 23:46:23 +02:00
};
2018-11-26 16:03:50 +01:00
2020-02-16 23:49:24 +01:00
static void AnimMegahornHorn(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
if (IsContest())
{
StartSpriteAffineAnim(sprite, 2);
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
}
else if (!GetBattlerSide(gBattleAnimTarget))
{
StartSpriteAffineAnim(sprite, 1);
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
gBattleAnimArgs[3] = -gBattleAnimArgs[3];
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
}
2021-11-08 19:18:58 +01:00
sprite->x = GetBattlerSpriteCoord2(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[0];
sprite->y = GetBattlerSpriteCoord2(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[1];
2018-11-26 16:03:50 +01:00
sprite->data[0] = gBattleAnimArgs[4];
2021-11-08 19:18:58 +01:00
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[2];
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3];
2018-11-26 16:03:50 +01:00
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
2020-02-16 23:49:24 +01:00
static void AnimLeechLifeNeedle(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
if (IsContest())
{
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
StartSpriteAffineAnim(sprite, 2);
}
else if (!GetBattlerSide(gBattleAnimTarget))
{
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
gBattleAnimArgs[0] = -gBattleAnimArgs[0];
}
2021-11-08 19:18:58 +01:00
sprite->x = GetBattlerSpriteCoord2(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[0];
sprite->y = GetBattlerSpriteCoord2(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[1];
2018-11-26 16:03:50 +01:00
sprite->data[0] = gBattleAnimArgs[2];
2021-11-08 19:18:58 +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:03:50 +01:00
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
2019-04-02 08:36:22 +02:00
// Creates a single web thread that travels from attacker to target.
// Used by MOVE_STRING_SHOT and MOVE_SPIDER_WEB in their first move phase.
// arg 0: x
// arg 1: y
// arg 2: controls the left-to-right movement
// arg 3: amplitude
// arg 4: if targets both opponents
2020-02-20 06:04:42 +01:00
static void AnimTranslateWebThread(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
if (IsContest())
gBattleAnimArgs[2] /= 2;
2019-04-02 08:36:22 +02:00
InitSpritePosToAnimAttacker(sprite, TRUE);
2018-11-26 16:03:50 +01:00
sprite->data[0] = gBattleAnimArgs[2];
2021-07-07 15:11:52 +02:00
sprite->data[1] = sprite->x;
sprite->data[3] = sprite->y;
2018-11-26 16:03:50 +01:00
if (!gBattleAnimArgs[4])
{
2021-11-08 19:18:58 +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:03:50 +01:00
}
else
{
2022-07-25 20:59:14 +02:00
SetAverageBattlerPositions(gBattleAnimTarget, TRUE, &sprite->data[2], &sprite->data[4]);
2018-11-26 16:03:50 +01:00
}
2021-01-23 06:40:46 +01:00
InitAnimLinearTranslationWithSpeed(sprite);
2018-11-26 16:03:50 +01:00
sprite->data[5] = gBattleAnimArgs[3];
2020-02-20 22:22:33 +01:00
sprite->callback = AnimTranslateWebThread_Step;
2018-11-26 16:03:50 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimTranslateWebThread_Step(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
2018-12-20 04:13:26 +01:00
if (AnimTranslateLinear(sprite))
2018-11-26 16:03:50 +01:00
{
DestroyAnimSprite(sprite);
return;
}
2021-07-07 15:11:52 +02:00
sprite->x2 += Sin(sprite->data[6], sprite->data[5]);
2018-11-26 16:03:50 +01:00
sprite->data[6] = (sprite->data[6] + 13) & 0xFF;
}
2020-02-20 02:22:53 +01:00
// Second stage of String Shot
static void AnimStringWrap(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
2022-07-25 20:59:14 +02:00
SetAverageBattlerPositions(gBattleAnimTarget, FALSE, &sprite->x, &sprite->y);
2018-11-26 16:03:50 +01:00
if (GetBattlerSide(gBattleAnimAttacker))
2021-07-07 15:11:52 +02:00
sprite->x -= gBattleAnimArgs[0];
2018-11-26 16:03:50 +01:00
else
2021-07-07 15:11:52 +02:00
sprite->x += gBattleAnimArgs[0];
2018-11-26 16:03:50 +01:00
2021-07-07 15:11:52 +02:00
sprite->y += gBattleAnimArgs[1];
2018-11-26 16:03:50 +01:00
if (!GetBattlerSide(gBattleAnimTarget))
2021-07-07 15:11:52 +02:00
sprite->y += 8;
2018-11-26 16:03:50 +01:00
2020-02-20 22:22:33 +01:00
sprite->callback = AnimStringWrap_Step;
2018-11-26 16:03:50 +01:00
}
2020-05-25 08:37:32 +02:00
void AnimStringWrap_Step(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
if (++sprite->data[0] == 3)
{
sprite->data[0] = 0;
sprite->invisible ^= 1;
}
if (++sprite->data[1] == 51)
{
DestroyAnimSprite(sprite);
}
}
2019-04-05 12:43:44 +02:00
// arg0: x
// arg1: y
// arg2: targets both
2020-05-25 08:37:32 +02:00
void AnimSpiderWeb(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT2_ALL | BLDCNT_EFFECT_BLEND);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
2019-04-05 12:43:44 +02:00
if (gBattleAnimArgs[2])
SetAverageBattlerPositions(gBattleAnimTarget, FALSE, &sprite->x, &sprite->y);
2019-04-05 12:43:44 +02:00
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT)
sprite->x -= gBattleAnimArgs[0];
2019-01-15 01:11:34 +01:00
else
sprite->x += gBattleAnimArgs[0];
2018-11-26 16:03:50 +01:00
sprite->y += gBattleAnimArgs[1];
2018-11-26 16:03:50 +01:00
sprite->data[0] = 16;
2020-02-20 22:22:33 +01:00
sprite->callback = AnimSpiderWeb_Step;
2018-11-26 16:03:50 +01:00
}
2020-02-20 22:22:33 +01:00
static void AnimSpiderWeb_Step(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
if (sprite->data[2] < 20)
{
sprite->data[2]++;
}
else if (sprite->data[1]++ & 1)
{
sprite->data[0]--;
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(sprite->data[0], 16 - sprite->data[0]));
if (sprite->data[0] == 0)
{
sprite->invisible = TRUE;
2020-02-20 22:22:33 +01:00
sprite->callback = AnimSpiderWeb_End;
2018-11-26 16:03:50 +01:00
}
}
}
2020-02-20 22:22:33 +01:00
static void AnimSpiderWeb_End(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
DestroyAnimSprite(sprite);
}
// Translates a stinger sprite linearly to a destination location. The sprite is
// initially rotated so that it appears to be traveling in a straight line.
// arg 0: initial x pixel offset
// arg 1: initial y pixel offset
// arg 2: target x pixel offset
// arg 3: target y pixel offset
// arg 4: duration
2020-02-20 22:22:33 +01:00
static void AnimTranslateStinger(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
s16 lVarX, lVarY;
u16 rot;
if (IsContest())
{
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
}
else
2018-11-26 16:03:50 +01:00
{
if (GetBattlerSide(gBattleAnimAttacker))
{
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
gBattleAnimArgs[1] = -gBattleAnimArgs[1];
gBattleAnimArgs[3] = -gBattleAnimArgs[3];
}
2018-11-26 16:03:50 +01:00
}
if (!IsContest() && GetBattlerSide(gBattleAnimAttacker) == GetBattlerSide(gBattleAnimTarget))
{
if (GetBattlerPosition(gBattleAnimTarget) == B_POSITION_PLAYER_LEFT
|| GetBattlerPosition(gBattleAnimTarget) == B_POSITION_OPPONENT_LEFT)
{
gBattleAnimArgs[2] *= -1;
gBattleAnimArgs[0] *= -1;
2018-11-26 16:03:50 +01:00
}
}
2022-07-25 20:59:14 +02:00
InitSpritePosToAnimAttacker(sprite, TRUE);
2018-11-26 16:03:50 +01:00
2021-11-08 19:18:58 +01:00
lVarX = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[2];
lVarY = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3];
2021-07-07 15:11:52 +02:00
rot = ArcTan2Neg(lVarX - sprite->x, lVarY - sprite->y);
2018-11-26 16:03:50 +01:00
rot += 0xC000;
2018-12-18 05:08:08 +01:00
TrySetSpriteRotScale(sprite, FALSE, 0x100, 0x100, rot);
2018-11-26 16:03:50 +01:00
sprite->data[0] = gBattleAnimArgs[4];
sprite->data[2] = lVarX;
sprite->data[4] = lVarY;
sprite->callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(sprite, DestroyAnimSprite);
}
// Rotates sprite and moves it in an arc, so that it appears like a missle or arrow traveling.
// arg 0: initial x pixel offset
// arg 1: initial y pixel offset
// arg 2: target x pixel offset
// arg 3: target y pixel offset
// arg 4: duration
// arg 5: wave amplitude
2020-05-25 08:37:32 +02:00
void AnimMissileArc(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
2022-07-25 20:59:14 +02:00
InitSpritePosToAnimAttacker(sprite, TRUE);
2018-11-26 16:03:50 +01:00
if (GetBattlerSide(gBattleAnimAttacker))
gBattleAnimArgs[2] = -gBattleAnimArgs[2];
sprite->data[0] = gBattleAnimArgs[4];
2021-11-08 19:18:58 +01:00
sprite->data[2] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) + gBattleAnimArgs[2];
sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + gBattleAnimArgs[3];
2018-11-26 16:03:50 +01:00
sprite->data[5] = gBattleAnimArgs[5];
InitAnimArcTranslation(sprite);
2020-02-20 22:22:33 +01:00
sprite->callback = AnimMissileArc_Step;
2018-11-26 16:03:50 +01:00
sprite->invisible = TRUE;
}
2020-05-25 08:37:32 +02:00
void AnimMissileArc_Step(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
sprite->invisible = FALSE;
2019-02-06 20:17:09 +01:00
if (TranslateAnimHorizontalArc(sprite))
2018-11-26 16:03:50 +01:00
{
DestroyAnimSprite(sprite);
}
else
{
s16 tempData[8];
u16 *data = sprite->data;
2021-07-07 15:11:52 +02:00
u16 x1 = sprite->x;
s16 x2 = sprite->x2;
u16 y1 = sprite->y;
s16 y2 = sprite->y2;
2018-11-26 16:03:50 +01:00
int i;
for (i = 0; i < 8; i++)
tempData[i] = data[i];
2018-11-26 16:03:50 +01:00
x2 += x1;
y2 += y1;
2018-11-26 16:03:50 +01:00
2019-02-06 20:17:09 +01:00
if (!TranslateAnimHorizontalArc(sprite))
2018-11-26 16:03:50 +01:00
{
2021-07-07 15:11:52 +02:00
u16 rotation = ArcTan2Neg(sprite->x + sprite->x2 - x2,
sprite->y + sprite->y2 - y2);
2018-11-26 16:03:50 +01:00
rotation += 0xC000;
2018-12-18 05:08:08 +01:00
TrySetSpriteRotScale(sprite, FALSE, 0x100, 0x100, rotation);
2018-11-26 16:03:50 +01:00
for (i = 0; i < 8; i++)
data[i] = tempData[i];
2018-11-26 16:03:50 +01:00
}
}
}
2020-02-20 02:22:53 +01:00
static void AnimTailGlowOrb(struct Sprite *sprite)
2018-11-26 16:03:50 +01:00
{
2020-02-20 02:22:53 +01:00
if (gBattleAnimArgs[0] == ANIM_ATTACKER)
2018-11-26 16:03:50 +01:00
{
2021-11-08 19:18:58 +01:00
sprite->x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2);
sprite->y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET) + 18;
2018-11-26 16:03:50 +01:00
}
else
{
2021-11-08 19:18:58 +01:00
sprite->x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2);
sprite->y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) + 18;
2018-11-26 16:03:50 +01:00
}
2018-12-18 05:08:08 +01:00
StoreSpriteCallbackInData6(sprite, DestroySpriteAndMatrix);
sprite->callback = RunStoredCallbackWhenAffineAnimEnds;
2018-11-26 16:03:50 +01:00
}