pokeemerald/src/battle_anim_status_effects.c

585 lines
18 KiB
C
Raw Normal View History

2018-10-07 15:39:46 +02:00
#include "global.h"
#include "battle.h"
#include "battle_anim.h"
#include "decompress.h"
2018-11-14 01:01:50 +01:00
#include "gpu_regs.h"
2018-10-07 15:39:46 +02:00
#include "palette.h"
#include "sprite.h"
#include "task.h"
#include "trig.h"
2018-11-14 01:01:50 +01:00
#include "util.h"
#include "constants/battle_anim.h"
#include "constants/rgb.h"
2018-10-07 15:39:46 +02:00
extern const struct CompressedSpriteSheet gBattleAnimPicTable[];
extern const struct CompressedSpritePalette gBattleAnimPaletteTable[];
extern const u8 *const gBattleAnims_StatusConditions[];
2019-10-15 01:26:47 +02:00
extern const struct OamData gOamData_AffineOff_ObjNormal_8x8;
extern const struct OamData gOamData_AffineOff_ObjBlend_64x64;
2018-10-07 15:39:46 +02:00
2021-04-13 10:04:09 +02:00
static void Task_UpdateFlashingCircleImpacts(u8 taskId);
2020-02-22 00:22:18 +01:00
static void AnimTask_FrozenIceCube_Step1(u8 taskId);
static void AnimTask_FrozenIceCube_Step2(u8 taskId);
static void AnimTask_FrozenIceCube_Step3(u8 taskId);
static void AnimTask_FrozenIceCube_Step4(u8 taskId);
2018-10-07 15:39:46 +02:00
static void Task_DoStatusAnimation(u8 taskId);
2021-04-13 10:04:09 +02:00
static void AnimFlashingCircleImpact(struct Sprite *sprite);
static void AnimFlashingCircleImpact_Step(struct Sprite *sprite);
2018-10-07 15:39:46 +02:00
2021-04-25 00:26:25 +02:00
static const union AnimCmd sAnim_FlickeringOrb[] =
2019-02-02 11:55:11 +01:00
{
ANIMCMD_FRAME(0, 3),
ANIMCMD_FRAME(4, 3),
ANIMCMD_FRAME(8, 3),
ANIMCMD_FRAME(12, 3),
ANIMCMD_JUMP(0)
};
2021-04-25 00:26:25 +02:00
static const union AnimCmd *const sAnims_FlickeringOrb[] =
2019-02-02 11:55:11 +01:00
{
2021-04-25 00:26:25 +02:00
sAnim_FlickeringOrb
2019-02-02 11:55:11 +01:00
};
2020-02-22 00:22:18 +01:00
// Unused
2021-04-25 00:26:25 +02:00
static const struct SpriteTemplate sFlickeringOrbSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
2019-04-06 16:32:02 +02:00
.tileTag = ANIM_TAG_ORB,
.paletteTag = ANIM_TAG_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_16x16,
2021-04-25 00:26:25 +02:00
.anims = sAnims_FlickeringOrb,
2019-02-02 11:55:11 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2021-04-25 00:26:25 +02:00
.callback = AnimTranslateLinearAndFlicker,
2019-02-02 11:55:11 +01:00
};
2020-02-22 00:22:18 +01:00
// Unused
2021-04-25 00:26:25 +02:00
static const struct SpriteTemplate sFlickeringOrbFlippedSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
2019-04-06 16:32:02 +02:00
.tileTag = ANIM_TAG_ORB,
.paletteTag = ANIM_TAG_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_16x16,
2021-04-25 00:26:25 +02:00
.anims = sAnims_FlickeringOrb,
2019-02-02 11:55:11 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2021-04-25 00:26:25 +02:00
.callback = AnimTranslateLinearAndFlicker_Flipped,
2019-02-02 11:55:11 +01:00
};
2020-02-22 00:22:18 +01:00
static const union AnimCmd sAnim_WeatherBallNormal[] =
2019-02-02 11:55:11 +01:00
{
ANIMCMD_FRAME(0, 3),
ANIMCMD_JUMP(0)
};
2020-02-22 00:22:18 +01:00
static const union AnimCmd *const sAnims_WeatherBallNormal[] =
2019-02-02 11:55:11 +01:00
{
2020-02-22 00:22:18 +01:00
sAnim_WeatherBallNormal
2019-02-02 11:55:11 +01:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gWeatherBallUpSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
.tileTag = ANIM_TAG_WEATHER_BALL,
.paletteTag = ANIM_TAG_WEATHER_BALL,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_32x32,
2020-02-22 00:22:18 +01:00
.anims = sAnims_WeatherBallNormal,
2019-02-02 11:55:11 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-20 02:22:53 +01:00
.callback = AnimWeatherBallUp,
2019-02-02 11:55:11 +01:00
};
2020-02-20 02:22:53 +01:00
const struct SpriteTemplate gWeatherBallNormalDownSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
.tileTag = ANIM_TAG_WEATHER_BALL,
.paletteTag = ANIM_TAG_WEATHER_BALL,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_32x32,
2020-02-22 00:22:18 +01:00
.anims = sAnims_WeatherBallNormal,
2019-02-02 11:55:11 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-20 02:22:53 +01:00
.callback = AnimWeatherBallDown,
2019-02-02 11:55:11 +01:00
};
2021-02-28 00:41:30 +01:00
static const union AnimCmd sAnim_SpinningSparkle[] =
2019-02-02 11:55:11 +01:00
{
ANIMCMD_FRAME(0, 3),
ANIMCMD_FRAME(16, 3),
ANIMCMD_FRAME(32, 3),
ANIMCMD_FRAME(48, 3),
ANIMCMD_FRAME(64, 3),
ANIMCMD_END
};
const union AnimCmd *const sAnims_SpinningSparkle[] =
2019-02-02 11:55:11 +01:00
{
2021-02-28 00:41:30 +01:00
sAnim_SpinningSparkle
2019-02-02 11:55:11 +01:00
};
2020-02-15 00:11:04 +01:00
const struct SpriteTemplate gSpinningSparkleSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
.tileTag = ANIM_TAG_SPARKLE_4,
.paletteTag = ANIM_TAG_SPARKLE_4,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_32x32,
2021-02-28 00:41:30 +01:00
.anims = sAnims_SpinningSparkle,
2019-02-02 11:55:11 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2020-02-15 00:11:04 +01:00
.callback = AnimSpinningSparkle,
2019-02-02 11:55:11 +01:00
};
2020-02-22 00:22:18 +01:00
// Unused
2021-04-25 00:26:25 +02:00
static const struct SpriteTemplate sFlickeringFootSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
2019-04-06 16:32:02 +02:00
.tileTag = ANIM_TAG_MONSTER_FOOT,
.paletteTag = ANIM_TAG_MONSTER_FOOT,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_32x32,
2019-02-02 11:55:11 +01:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2021-04-25 00:26:25 +02:00
.callback = AnimTranslateLinearAndFlicker,
2019-02-02 11:55:11 +01:00
};
2021-04-25 00:26:25 +02:00
static const union AnimCmd sAnim_FlickeringImpact_0[] =
2019-02-02 11:55:11 +01:00
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_JUMP(0)
};
2021-04-25 00:26:25 +02:00
static const union AnimCmd sAnim_FlickeringImpact_1[] =
2019-02-02 11:55:11 +01:00
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_JUMP(0)
};
2021-04-25 00:26:25 +02:00
static const union AnimCmd sAnim_FlickeringImpact_2[] =
2019-02-02 11:55:11 +01:00
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_JUMP(0)
};
2021-04-25 00:26:25 +02:00
static const union AnimCmd *const sAnims_FlickeringImpact[] =
2019-02-02 11:55:11 +01:00
{
2021-04-25 00:26:25 +02:00
sAnim_FlickeringImpact_0,
sAnim_FlickeringImpact_1,
sAnim_FlickeringImpact_2,
2019-02-02 11:55:11 +01:00
};
2020-02-22 00:22:18 +01:00
// Unused
2021-04-25 00:26:25 +02:00
static const struct SpriteTemplate sFlickeringImpactSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
.tileTag = ANIM_TAG_IMPACT,
.paletteTag = ANIM_TAG_IMPACT,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_32x32,
2021-04-25 00:26:25 +02:00
.anims = sAnims_FlickeringImpact,
2019-02-02 11:55:11 +01:00
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2021-04-25 00:26:25 +02:00
.callback = AnimTranslateLinearAndFlicker,
2019-02-02 11:55:11 +01:00
};
2021-04-25 00:26:25 +02:00
static const union AnimCmd sAnim_FlickeringShrinkOrb[] =
2019-02-02 11:55:11 +01:00
{
ANIMCMD_FRAME(0, 15),
ANIMCMD_JUMP(0)
};
2021-04-25 00:26:25 +02:00
static const union AnimCmd *const sAnims_FlickeringShrinkOrb[] =
2019-02-02 11:55:11 +01:00
{
2021-04-25 00:26:25 +02:00
sAnim_FlickeringShrinkOrb
2019-02-02 11:55:11 +01:00
};
2021-04-25 00:26:25 +02:00
static const union AffineAnimCmd sAffineAnim_FlickeringShrinkOrb[] =
2019-02-02 11:55:11 +01:00
{
AFFINEANIMCMD_FRAME(96, 96, 0, 0),
AFFINEANIMCMD_FRAME(2, 2, 0, 1),
AFFINEANIMCMD_JUMP(1)
};
2021-04-25 00:26:25 +02:00
static const union AffineAnimCmd *const sAffineAnims_FlickeringShrinkOrb[] =
2019-02-02 11:55:11 +01:00
{
2021-04-25 00:26:25 +02:00
sAffineAnim_FlickeringShrinkOrb
2019-02-02 11:55:11 +01:00
};
2021-02-28 00:41:30 +01:00
// Unused
2021-04-25 00:26:25 +02:00
static const struct SpriteTemplate sFlickeringShrinkOrbSpriteTemplate =
2019-02-02 11:55:11 +01:00
{
2019-04-06 16:32:02 +02:00
.tileTag = ANIM_TAG_ORB,
.paletteTag = ANIM_TAG_ORB,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineDouble_ObjNormal_16x16,
2021-04-25 00:26:25 +02:00
.anims = sAnims_FlickeringShrinkOrb,
2019-02-02 11:55:11 +01:00
.images = NULL,
2021-04-25 00:26:25 +02:00
.affineAnims = sAffineAnims_FlickeringShrinkOrb,
.callback = AnimTranslateLinearAndFlicker_Flipped,
2019-02-02 11:55:11 +01:00
};
2020-02-22 00:22:18 +01:00
static const struct Subsprite sFrozenIceCubeSubsprites[] =
2018-10-07 15:39:46 +02:00
{
{
.x = -16,
.y = -16,
.shape = SPRITE_SHAPE(64x64),
.size = SPRITE_SIZE(64x64),
.tileOffset = 0,
.priority = 2
},
{
.x = -16,
.y = 48,
.shape = SPRITE_SHAPE(64x32),
.size = SPRITE_SIZE(64x32),
.tileOffset = 64,
.priority = 2
},
{
.x = 48,
.y = -16,
.shape = SPRITE_SHAPE(32x64),
.size = SPRITE_SIZE(32x64),
.tileOffset = 96,
.priority = 2
},
{
.x = 48,
.y = 48,
.shape = SPRITE_SHAPE(32x32),
.size = SPRITE_SIZE(32x32),
.tileOffset = 128,
.priority = 2
},
2018-10-07 15:39:46 +02:00
};
2020-02-22 00:22:18 +01:00
static const struct SubspriteTable sFrozenIceCubeSubspriteTable[] =
2018-10-07 15:39:46 +02:00
{
2020-02-22 00:22:18 +01:00
{ARRAY_COUNT(sFrozenIceCubeSubsprites), sFrozenIceCubeSubsprites},
2018-10-07 15:39:46 +02:00
};
2022-05-17 19:51:54 +02:00
static const struct SpriteTemplate sFrozenIceCubeSpriteTemplate =
2018-10-07 15:39:46 +02:00
{
.tileTag = ANIM_TAG_ICE_CUBE,
.paletteTag = ANIM_TAG_ICE_CUBE,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjBlend_64x64,
2018-10-07 15:39:46 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
};
2021-04-13 10:04:09 +02:00
static const struct SpriteTemplate sFlashingCircleImpactSpriteTemplate =
2018-10-07 15:39:46 +02:00
{
2018-10-22 16:36:43 +02:00
.tileTag = ANIM_TAG_CIRCLE_IMPACT,
.paletteTag = ANIM_TAG_CIRCLE_IMPACT,
2019-10-15 01:26:47 +02:00
.oam = &gOamData_AffineOff_ObjNormal_8x8,
2018-10-07 15:39:46 +02:00
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
2021-04-13 10:04:09 +02:00
.callback = AnimFlashingCircleImpact,
2018-10-07 15:39:46 +02:00
};
2020-02-22 00:22:18 +01:00
// Unused
2021-04-13 10:04:09 +02:00
static u8 Task_FlashingCircleImpacts(u8 battlerId, bool8 red)
2018-10-07 15:39:46 +02:00
{
u8 battlerSpriteId = gBattlerSpriteIds[battlerId];
2021-04-13 10:04:09 +02:00
u8 taskId = CreateTask(Task_UpdateFlashingCircleImpacts, 10);
u8 spriteId;
2018-10-07 15:39:46 +02:00
u8 i;
2018-12-17 23:00:08 +01:00
LoadCompressedSpriteSheetUsingHeap(&gBattleAnimPicTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_CIRCLE_IMPACT)]);
LoadCompressedSpritePaletteUsingHeap(&gBattleAnimPaletteTable[GET_TRUE_SPRITE_INDEX(ANIM_TAG_CIRCLE_IMPACT)]);
2018-10-07 15:39:46 +02:00
gTasks[taskId].data[0] = battlerId;
2021-04-13 10:04:09 +02:00
if (red)
2018-10-07 15:39:46 +02:00
{
gTasks[taskId].data[1] = RGB_RED;
for (i = 0; i < 10; i++)
{
2021-07-07 15:11:52 +02:00
spriteId = CreateSprite(&sFlashingCircleImpactSpriteTemplate, gSprites[battlerSpriteId].x, gSprites[battlerSpriteId].y + 32, 0);
2021-04-13 10:04:09 +02:00
gSprites[spriteId].data[0] = i * 51;
gSprites[spriteId].data[1] = -256;
gSprites[spriteId].invisible = TRUE;
2018-10-07 15:39:46 +02:00
if (i > 4)
2021-04-13 10:04:09 +02:00
gSprites[spriteId].data[6] = 21;
2018-10-07 15:39:46 +02:00
}
}
else
{
gTasks[taskId].data[1] = RGB_BLUE;
for (i = 0; i < 10; i++)
{
2021-07-07 15:11:52 +02:00
spriteId = CreateSprite(&sFlashingCircleImpactSpriteTemplate, gSprites[battlerSpriteId].x, gSprites[battlerSpriteId].y - 32, 0);
2021-04-13 10:04:09 +02:00
gSprites[spriteId].data[0] = i * 51;
gSprites[spriteId].data[1] = 256;
gSprites[spriteId].invisible = TRUE;
2018-10-07 15:39:46 +02:00
if (i > 4)
2021-04-13 10:04:09 +02:00
gSprites[spriteId].data[6] = 21;
2018-10-07 15:39:46 +02:00
}
}
2021-04-13 10:04:09 +02:00
gSprites[spriteId].data[7] = 1;
2018-10-07 15:39:46 +02:00
return taskId;
}
2021-04-13 10:04:09 +02:00
static void Task_UpdateFlashingCircleImpacts(u8 taskId)
2018-10-07 15:39:46 +02:00
{
if (gTasks[taskId].data[2] == 2)
{
gTasks[taskId].data[2] = 0;
BlendPalette(0x100 + gTasks[taskId].data[0] * 16, 16, gTasks[taskId].data[4], gTasks[taskId].data[1]);
if (gTasks[taskId].data[5] == 0)
{
gTasks[taskId].data[4]++;
if (gTasks[taskId].data[4] > 8)
gTasks[taskId].data[5] ^= 1;
}
else
{
u16 var = gTasks[taskId].data[4];
gTasks[taskId].data[4]--;
if (gTasks[taskId].data[4] < 0)
{
gTasks[taskId].data[4] = var;
gTasks[taskId].data[5] ^= 1;
gTasks[taskId].data[3]++;
if (gTasks[taskId].data[3] == 2)
DestroyTask(taskId);
}
}
}
else
{
gTasks[taskId].data[2]++;
}
}
2021-04-13 10:04:09 +02:00
static void AnimFlashingCircleImpact(struct Sprite *sprite)
2018-10-07 15:39:46 +02:00
{
if (sprite->data[6] == 0)
{
sprite->invisible = FALSE;
2021-04-13 10:04:09 +02:00
sprite->callback = AnimFlashingCircleImpact_Step;
AnimFlashingCircleImpact_Step(sprite);
2018-10-07 15:39:46 +02:00
}
else
{
sprite->data[6]--;
}
}
2021-04-13 10:04:09 +02:00
static void AnimFlashingCircleImpact_Step(struct Sprite *sprite)
2018-10-07 15:39:46 +02:00
{
2021-07-07 15:11:52 +02:00
sprite->x2 = Cos(sprite->data[0], 32);
sprite->y2 = Sin(sprite->data[0], 8);
2018-10-07 15:39:46 +02:00
if (sprite->data[0] < 128)
sprite->subpriority = 29;
else
sprite->subpriority = 31;
sprite->data[0] = (sprite->data[0] + 8) & 0xFF;
sprite->data[5] += sprite->data[1];
2021-07-07 15:11:52 +02:00
sprite->y2 += sprite->data[5] >> 8;
2018-10-07 15:39:46 +02:00
sprite->data[2]++;
if (sprite->data[2] == 52)
{
if (sprite->data[7])
DestroySpriteAndFreeResources(sprite);
else
DestroySprite(sprite);
}
}
2020-11-29 15:22:31 +01:00
void AnimTask_FrozenIceCubeAttacker(u8 taskId)
{
s16 x = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_X_2) - 32;
s16 y = GetBattlerSpriteCoord(gBattleAnimAttacker, BATTLER_COORD_Y_PIC_OFFSET) - 36;
u8 spriteId;
if (IsContest())
x -= 6;
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
spriteId = CreateSprite(&sFrozenIceCubeSpriteTemplate, x, y, 4);
2020-11-29 15:22:31 +01:00
if (GetSpriteTileStartByTag(ANIM_TAG_ICE_CUBE) == 0xFFFF)
gSprites[spriteId].invisible = TRUE;
SetSubspriteTables(&gSprites[spriteId], sFrozenIceCubeSubspriteTable);
gTasks[taskId].data[15] = spriteId;
gTasks[taskId].func = AnimTask_FrozenIceCube_Step1;
}
2020-02-16 23:49:24 +01:00
void AnimTask_FrozenIceCube(u8 taskId)
2018-10-07 15:39:46 +02:00
{
s16 x = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_X_2) - 32;
2018-12-18 05:08:08 +01:00
s16 y = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET) - 36;
2018-10-07 15:39:46 +02:00
u8 spriteId;
if (IsContest())
x -= 6;
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
2022-05-17 19:51:54 +02:00
spriteId = CreateSprite(&sFrozenIceCubeSpriteTemplate, x, y, 4);
2018-10-07 15:39:46 +02:00
if (GetSpriteTileStartByTag(ANIM_TAG_ICE_CUBE) == 0xFFFF)
gSprites[spriteId].invisible = TRUE;
2020-02-22 00:22:18 +01:00
SetSubspriteTables(&gSprites[spriteId], sFrozenIceCubeSubspriteTable);
2018-10-07 15:39:46 +02:00
gTasks[taskId].data[15] = spriteId;
2020-02-22 00:22:18 +01:00
gTasks[taskId].func = AnimTask_FrozenIceCube_Step1;
2018-10-07 15:39:46 +02:00
}
2020-02-22 00:22:18 +01:00
static void AnimTask_FrozenIceCube_Step1(u8 taskId)
2018-10-07 15:39:46 +02:00
{
gTasks[taskId].data[1]++;
if (gTasks[taskId].data[1] == 10)
{
2020-02-22 00:22:18 +01:00
gTasks[taskId].func = AnimTask_FrozenIceCube_Step2;
2018-10-07 15:39:46 +02:00
gTasks[taskId].data[1] = 0;
}
else
{
u8 var = gTasks[taskId].data[1];
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(var, 16 - var));
}
}
2020-02-22 00:22:18 +01:00
static void AnimTask_FrozenIceCube_Step2(u8 taskId)
2018-10-07 15:39:46 +02:00
{
u8 palIndex = IndexOfSpritePaletteTag(ANIM_TAG_ICE_CUBE);
if (gTasks[taskId].data[1]++ > 13)
{
gTasks[taskId].data[2]++;
if (gTasks[taskId].data[2] == 3)
{
u16 temp;
temp = gPlttBufferFaded[0x100 + palIndex * 16 + 13];
gPlttBufferFaded[0x100 + palIndex * 16 + 13] = gPlttBufferFaded[0x100 + palIndex * 16 + 14];
gPlttBufferFaded[0x100 + palIndex * 16 + 14] = gPlttBufferFaded[0x100 + palIndex * 16 + 15];
gPlttBufferFaded[0x100 + palIndex * 16 + 15] = temp;
gTasks[taskId].data[2] = 0;
gTasks[taskId].data[3]++;
if (gTasks[taskId].data[3] == 3)
{
gTasks[taskId].data[3] = 0;
gTasks[taskId].data[1] = 0;
gTasks[taskId].data[4]++;
if (gTasks[taskId].data[4] == 2)
{
gTasks[taskId].data[1] = 9;
2020-02-22 00:22:18 +01:00
gTasks[taskId].func = AnimTask_FrozenIceCube_Step3;
2018-10-07 15:39:46 +02:00
}
}
}
}
}
2020-02-22 00:22:18 +01:00
static void AnimTask_FrozenIceCube_Step3(u8 taskId)
2018-10-07 15:39:46 +02:00
{
gTasks[taskId].data[1]--;
if (gTasks[taskId].data[1] == -1)
{
2020-02-22 00:22:18 +01:00
gTasks[taskId].func = AnimTask_FrozenIceCube_Step4;
2018-10-07 15:39:46 +02:00
gTasks[taskId].data[1] = 0;
}
else
{
u8 var = gTasks[taskId].data[1];
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(var, 16 - var));
}
}
2020-02-22 00:22:18 +01:00
static void AnimTask_FrozenIceCube_Step4(u8 taskId)
2018-10-07 15:39:46 +02:00
{
gTasks[taskId].data[1]++;
if (gTasks[taskId].data[1] == 37)
{
u8 spriteId = gTasks[taskId].data[15];
FreeSpriteOamMatrix(&gSprites[spriteId]);
DestroySprite(&gSprites[spriteId]);
}
else if (gTasks[taskId].data[1] == 39)
{
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
DestroyAnimVisualTask(taskId);
}
}
#define CASE(by, stat) case (STAT_ANIM_##by + stat - 1)
void AnimTask_StatsChange(u8 taskId)
{
bool16 goesDown = FALSE;
s16 animStatId = 0;
bool16 sharply = FALSE;
switch (gBattleSpritesDataPtr->animationData->animArg)
{
CASE(PLUS1, STAT_ATK): goesDown = FALSE; animStatId = 0; break;
CASE(PLUS1, STAT_DEF): goesDown = FALSE; animStatId = 1; break;
CASE(PLUS1, STAT_SPEED): goesDown = FALSE; animStatId = 3; break;
CASE(PLUS1, STAT_SPATK): goesDown = FALSE; animStatId = 5; break;
CASE(PLUS1, STAT_SPDEF): goesDown = FALSE; animStatId = 6; break;
CASE(PLUS1, STAT_ACC): goesDown = FALSE; animStatId = 2; break;
CASE(PLUS1, STAT_EVASION): goesDown = FALSE; animStatId = 4; break;
CASE(MINUS1, STAT_ATK): goesDown = TRUE; animStatId = 0; break;
CASE(MINUS1, STAT_DEF): goesDown = TRUE; animStatId = 1; break;
CASE(MINUS1, STAT_SPEED): goesDown = TRUE; animStatId = 3; break;
CASE(MINUS1, STAT_SPATK): goesDown = TRUE; animStatId = 5; break;
CASE(MINUS1, STAT_SPDEF): goesDown = TRUE; animStatId = 6; break;
CASE(MINUS1, STAT_ACC): goesDown = TRUE; animStatId = 2; break;
CASE(MINUS1, STAT_EVASION): goesDown = TRUE; animStatId = 4; break;
CASE(PLUS2, STAT_ATK): goesDown = FALSE; animStatId = 0; sharply = TRUE; break;
CASE(PLUS2, STAT_DEF): goesDown = FALSE; animStatId = 1; sharply = TRUE; break;
CASE(PLUS2, STAT_SPEED): goesDown = FALSE; animStatId = 3; sharply = TRUE; break;
CASE(PLUS2, STAT_SPATK): goesDown = FALSE; animStatId = 5; sharply = TRUE; break;
CASE(PLUS2, STAT_SPDEF): goesDown = FALSE; animStatId = 6; sharply = TRUE; break;
CASE(PLUS2, STAT_ACC): goesDown = FALSE; animStatId = 2; sharply = TRUE; break;
CASE(PLUS2, STAT_EVASION): goesDown = FALSE; animStatId = 4; sharply = TRUE; break;
CASE(MINUS2, STAT_ATK): goesDown = TRUE; animStatId = 0; sharply = TRUE; break;
CASE(MINUS2, STAT_DEF): goesDown = TRUE; animStatId = 1; sharply = TRUE; break;
CASE(MINUS2, STAT_SPEED): goesDown = TRUE; animStatId = 3; sharply = TRUE; break;
CASE(MINUS2, STAT_SPATK): goesDown = TRUE; animStatId = 5; sharply = TRUE; break;
CASE(MINUS2, STAT_SPDEF): goesDown = TRUE; animStatId = 6; sharply = TRUE; break;
CASE(MINUS2, STAT_ACC): goesDown = TRUE; animStatId = 2; sharply = TRUE; break;
CASE(MINUS2, STAT_EVASION): goesDown = TRUE; animStatId = 4; sharply = TRUE; break;
case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = 0xFF; sharply = FALSE; break;
case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = 0xFF; sharply = TRUE; break;
case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = 0xFF; sharply = FALSE; break;
case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = 0xFF; sharply = TRUE; break;
default:
DestroyAnimVisualTask(taskId);
return;
}
gBattleAnimArgs[0] = goesDown;
gBattleAnimArgs[1] = animStatId;
gBattleAnimArgs[2] = 0;
gBattleAnimArgs[3] = 0;
gBattleAnimArgs[4] = sharply;
2021-02-28 00:41:30 +01:00
gTasks[taskId].func = InitStatsChangeAnimation;
InitStatsChangeAnimation(taskId);
2018-10-07 15:39:46 +02:00
}
#undef CASE
void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId)
{
u8 taskId;
gBattleAnimAttacker = battlerId;
gBattleAnimTarget = battlerId;
2022-05-27 02:18:52 +02:00
LaunchBattleAnimation(gBattleAnims_StatusConditions, statusAnimId, FALSE);
2018-10-07 15:39:46 +02:00
taskId = CreateTask(Task_DoStatusAnimation, 10);
gTasks[taskId].data[0] = battlerId;
}
static void Task_DoStatusAnimation(u8 taskId)
{
gAnimScriptCallback();
if (!gAnimScriptActive)
{
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].data[0]].statusAnimActive = FALSE;
DestroyTask(taskId);
}
}