mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Refactor battle animations
This commit is contained in:
parent
cba4b78df6
commit
bdb04da9a5
@ -5,6 +5,14 @@
|
||||
#include "constants/battle_anim.h"
|
||||
#include "task.h"
|
||||
|
||||
enum
|
||||
{
|
||||
ANIM_TYPE_GENERAL,
|
||||
ANIM_TYPE_MOVE,
|
||||
ANIM_TYPE_STATUS,
|
||||
ANIM_TYPE_SPECIAL,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
BG_ANIM_SCREEN_SIZE,
|
||||
@ -54,7 +62,7 @@ extern u16 gAnimMoveIndex;
|
||||
|
||||
void ClearBattleAnimationVars(void);
|
||||
void DoMoveAnim(u16 move);
|
||||
void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim);
|
||||
void LaunchBattleAnimation(u32 animType, u32 animId);
|
||||
void DestroyAnimSprite(struct Sprite *sprite);
|
||||
void DestroyAnimVisualTask(u8 taskId);
|
||||
void DestroyAnimSoundTask(u8 taskId);
|
||||
|
@ -27,7 +27,10 @@
|
||||
#define ANIM_SPRITE_INDEX_COUNT 8
|
||||
|
||||
extern const u16 gMovesWithQuietBGM[];
|
||||
extern const u8 *const gBattleAnims_General[];
|
||||
extern const u8 *const gBattleAnims_Moves[];
|
||||
extern const u8 *const gBattleAnims_Special[];
|
||||
extern const u8 *const gBattleAnims_StatusConditions[];
|
||||
|
||||
static void Cmd_loadspritegfx(void);
|
||||
static void Cmd_unloadspritegfx(void);
|
||||
@ -211,17 +214,35 @@ void DoMoveAnim(u16 move)
|
||||
gBattleAnimTarget = 0;
|
||||
}
|
||||
}
|
||||
LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE);
|
||||
LaunchBattleAnimation(ANIM_TYPE_MOVE, move);
|
||||
}
|
||||
|
||||
void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMoveAnim)
|
||||
void LaunchBattleAnimation(u32 animType, u32 animId)
|
||||
{
|
||||
s32 i;
|
||||
bool32 hideHpBoxes = (tableId == MOVE_TRANSFORM) ? FALSE : TRUE;
|
||||
const u8 *const *animsTable;
|
||||
bool32 hideHpBoxes;
|
||||
|
||||
if (!isMoveAnim)
|
||||
switch (animType)
|
||||
{
|
||||
switch (tableId)
|
||||
case ANIM_TYPE_GENERAL:
|
||||
animsTable = gBattleAnims_General;
|
||||
break;
|
||||
case ANIM_TYPE_MOVE:
|
||||
animsTable = gBattleAnims_Moves;
|
||||
break;
|
||||
case ANIM_TYPE_STATUS:
|
||||
animsTable = gBattleAnims_StatusConditions;
|
||||
break;
|
||||
case ANIM_TYPE_SPECIAL:
|
||||
animsTable = gBattleAnims_Special;
|
||||
break;
|
||||
}
|
||||
|
||||
hideHpBoxes = !(animType == ANIM_TYPE_MOVE && animId == MOVE_TRANSFORM);
|
||||
if (animType != ANIM_TYPE_MOVE)
|
||||
{
|
||||
switch (animId)
|
||||
{
|
||||
case B_ANIM_TURN_TRAP:
|
||||
case B_ANIM_LEECH_SEED_DRAIN:
|
||||
@ -258,17 +279,17 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
|
||||
gAnimBattlerSpecies[i] = gContestResources->moveAnim->species;
|
||||
}
|
||||
|
||||
if (!isMoveAnim)
|
||||
if (animType != ANIM_TYPE_MOVE)
|
||||
gAnimMoveIndex = 0;
|
||||
else
|
||||
gAnimMoveIndex = tableId;
|
||||
gAnimMoveIndex = animId;
|
||||
|
||||
for (i = 0; i < ANIM_ARGS_COUNT; i++)
|
||||
gBattleAnimArgs[i] = 0;
|
||||
|
||||
sMonAnimTaskIdArray[0] = TASK_NONE;
|
||||
sMonAnimTaskIdArray[1] = TASK_NONE;
|
||||
sBattleAnimScriptPtr = animsTable[tableId];
|
||||
sBattleAnimScriptPtr = animsTable[animId];
|
||||
gAnimScriptActive = TRUE;
|
||||
sAnimFramesToWait = 0;
|
||||
gAnimScriptCallback = RunAnimScriptCommand;
|
||||
@ -276,11 +297,11 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
|
||||
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
|
||||
sAnimSpriteIndexArray[i] = 0xFFFF;
|
||||
|
||||
if (isMoveAnim)
|
||||
if (animType == ANIM_TYPE_MOVE)
|
||||
{
|
||||
for (i = 0; gMovesWithQuietBGM[i] != 0xFFFF; i++)
|
||||
{
|
||||
if (tableId == gMovesWithQuietBGM[i])
|
||||
if (animId == gMovesWithQuietBGM[i])
|
||||
{
|
||||
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 128);
|
||||
break;
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
extern const struct CompressedSpriteSheet gBattleAnimPicTable[];
|
||||
extern const struct CompressedSpritePalette gBattleAnimPaletteTable[];
|
||||
extern const u8 *const gBattleAnims_StatusConditions[];
|
||||
extern const struct OamData gOamData_AffineOff_ObjNormal_8x8;
|
||||
extern const struct OamData gOamData_AffineOff_ObjBlend_64x64;
|
||||
|
||||
@ -568,7 +567,7 @@ void LaunchStatusAnimation(u8 battlerId, u8 statusAnimId)
|
||||
|
||||
gBattleAnimAttacker = battlerId;
|
||||
gBattleAnimTarget = battlerId;
|
||||
LaunchBattleAnimation(gBattleAnims_StatusConditions, statusAnimId, FALSE);
|
||||
LaunchBattleAnimation(ANIM_TYPE_STATUS, statusAnimId);
|
||||
taskId = CreateTask(Task_DoStatusAnimation, 10);
|
||||
gTasks[taskId].data[0] = battlerId;
|
||||
}
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include "constants/battle_palace.h"
|
||||
|
||||
extern const u8 gBattlePalaceNatureToMoveTarget[];
|
||||
extern const u8 *const gBattleAnims_General[];
|
||||
extern const u8 *const gBattleAnims_Special[];
|
||||
extern const struct CompressedSpriteSheet gSpriteSheet_EnemyShadow;
|
||||
extern const struct SpriteTemplate gSpriteTemplate_EnemyShadow;
|
||||
|
||||
@ -465,7 +463,7 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBattler, u8 atkBattler, u8 de
|
||||
gBattleAnimAttacker = atkBattler;
|
||||
gBattleAnimTarget = defBattler;
|
||||
gBattleSpritesDataPtr->animationData->animArg = argument;
|
||||
LaunchBattleAnimation(gBattleAnims_General, tableId, FALSE);
|
||||
LaunchBattleAnimation(ANIM_TYPE_GENERAL, tableId);
|
||||
taskId = CreateTask(Task_ClearBitWhenBattleTableAnimDone, 10);
|
||||
gTasks[taskId].tBattlerId = activeBattler;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].animFromTableActive = 1;
|
||||
@ -509,7 +507,7 @@ void InitAndLaunchSpecialAnimation(u8 activeBattler, u8 atkBattler, u8 defBattle
|
||||
|
||||
gBattleAnimAttacker = atkBattler;
|
||||
gBattleAnimTarget = defBattler;
|
||||
LaunchBattleAnimation(gBattleAnims_Special, tableId, FALSE);
|
||||
LaunchBattleAnimation(ANIM_TYPE_SPECIAL, tableId);
|
||||
taskId = CreateTask(Task_ClearBitWhenSpecialAnimDone, 10);
|
||||
gTasks[taskId].tBattlerId = activeBattler;
|
||||
gBattleSpritesDataPtr->healthBoxesData[gTasks[taskId].tBattlerId].specialAnimActive = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user