New mega trigger sprite

This commit is contained in:
DizzyEggg 2018-09-20 20:59:00 +02:00
parent 0755240fbc
commit d05875dd04
7 changed files with 105 additions and 570 deletions

View file

@ -0,0 +1,19 @@
JASC-PAL
0100
16
185 207 163
77 105 97
199 159 199
221 177 207
57 151 117
139 221 253
247 161 133
255 255 255
153 87 67
233 233 125
129 255 223
149 147 247
195 207 201
123 151 135
0 0 0
0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,005 B

After

Width:  |  Height:  |  Size: 3.4 KiB

View file

@ -1,259 +0,0 @@
JASC-PAL
0100
256
152 184 136
112 136 120
80 104 96
32 32 32
160 160 160
80 80 80
48 48 48
176 176 176
160 160 160
200 200 200
184 184 184
216 216 216
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0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0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0

View file

@ -46,8 +46,7 @@ enum
#define TAG_STATUS_SUMMARY_BAR_PAL 0xD710
#define TAG_STATUS_SUMMARY_BALLS_PAL 0xD712
#define TAG_MEGA_TRIGGER_OFF_PAL 0xD777
#define TAG_MEGA_TRIGGER_ON_PAL 0xD778
#define TAG_MEGA_TRIGGER_PAL 0xD777
enum
{
@ -76,7 +75,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority);
void InitBattlerHealthboxCoords(u8 battler);
void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent);
void SwapHpBarsWithHpText(void);
void SetMegaTriggerSpritePal(u8 spriteId, u8 palId);
void ChangeMegaTriggerSprite(u8 spriteId, u8 animId);
void CreateMegaTriggerSprite(u8 battlerId, u8 palId);
bool32 IsMegaTriggerSpriteActive(void);
void HideMegaTriggerSprite(void);

View file

@ -644,7 +644,7 @@ static void HandleInputChooseMove(void)
if (CanMegaEvolve(gActiveBattler))
{
gBattleStruct->mega.playerSelect ^= 1;
SetMegaTriggerSpritePal(gBattleStruct->mega.triggerSpriteId, gBattleStruct->mega.playerSelect);
ChangeMegaTriggerSprite(gBattleStruct->mega.triggerSpriteId, gBattleStruct->mega.playerSelect);
PlaySE(SE_SELECT);
}
}

View file

@ -561,20 +561,15 @@ static const u16 sStatusIconColors[] =
static const struct WindowTemplate sHealthboxWindowTemplate = {0, 0, 0, 8, 2, 0, 0}; // width = 8, height = 2
static const u8 sMegaTriggerGfx[] = INCBIN_U8("graphics/battle_interface/mega_trigger.4bpp");
static const u16 sMegaTriggerOnPal[] = INCBIN_U16("graphics/battle_interface/mega_trigger_on.gbapal");
static const u16 sMegaTriggerOffPal[] = INCBIN_U16("graphics/battle_interface/mega_trigger_off.gbapal");
static const u16 sMegaTriggerPal[] = INCBIN_U16("graphics/battle_interface/mega_trigger.gbapal");
static const struct SpriteSheet sSpriteSheet_MegaTrigger =
{
sMegaTriggerGfx, sizeof(sMegaTriggerGfx), TAG_MEGA_TRIGGER_TILE
};
static const struct SpritePalette sSpritePalette_MegaTriggerOn =
static const struct SpritePalette sSpritePalette_MegaTrigger =
{
sMegaTriggerOnPal, TAG_MEGA_TRIGGER_ON_PAL
};
static const struct SpritePalette sSpritePalette_MegaTriggerOff =
{
sMegaTriggerOffPal, TAG_MEGA_TRIGGER_OFF_PAL
sMegaTriggerPal, TAG_MEGA_TRIGGER_PAL
};
static const struct OamData sOamData_MegaTrigger =
@ -589,17 +584,35 @@ static const struct OamData sOamData_MegaTrigger =
.matrixNum = 0,
.size = 2,
.tileNum = 0,
.priority = 3,
.priority = 1,
.paletteNum = 0,
.affineParam = 0,
};
static const union AnimCmd sSpriteAnim_MegaTriggerOff[] =
{
ANIMCMD_FRAME(0, 0),
ANIMCMD_END
};
static const union AnimCmd sSpriteAnim_MegaTriggerOn[] =
{
ANIMCMD_FRAME(16, 0),
ANIMCMD_END
};
static const union AnimCmd *const sSpriteAnimTable_MegaTrigger[] =
{
sSpriteAnim_MegaTriggerOff,
sSpriteAnim_MegaTriggerOn,
};
static const struct SpriteTemplate sSpriteTemplate_MegaTrigger =
{
.tileTag = TAG_MEGA_TRIGGER_TILE,
.paletteTag = TAG_MEGA_TRIGGER_ON_PAL,
.paletteTag = TAG_MEGA_TRIGGER_PAL,
.oam = &sOamData_MegaTrigger,
.anims = gDummySpriteAnimTable,
.anims = sSpriteAnimTable_MegaTrigger,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCb_MegaTrigger
@ -1532,71 +1545,93 @@ void SwapHpBarsWithHpText(void)
}
// Mega Evolution gfx functions.
void SetMegaTriggerSpritePal(u8 spriteId, u8 palId)
void ChangeMegaTriggerSprite(u8 spriteId, u8 animId)
{
switch (palId)
{
case 0: // off
FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_ON_PAL);
LoadSpritePalette(&sSpritePalette_MegaTriggerOff);
if (spriteId != 0xFF)
gSprites[spriteId].oam.paletteNum = IndexOfSpritePaletteTag(TAG_MEGA_TRIGGER_OFF_PAL);
break;
case 1: // on
FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_OFF_PAL);
LoadSpritePalette(&sSpritePalette_MegaTriggerOn);
if (spriteId != 0xFF)
gSprites[spriteId].oam.paletteNum = IndexOfSpritePaletteTag(TAG_MEGA_TRIGGER_ON_PAL);
break;
}
StartSpriteAnim(&gSprites[spriteId], animId);
}
#define MEGA_TRIGGER_POS_X_DIFF 19
#define MEGA_TRIGGER_POS_Y_DIFF 1
#define SINGLES_MEGA_TRIGGER_POS_X_OPTIMAL (30)
#define SINGLES_MEGA_TRIGGER_POS_X_PRIORITY (31)
#define SINGLES_MEGA_TRIGGER_POS_X_SLIDE (15)
#define SINGLES_MEGA_TRIGGER_POS_Y_DIFF (-11)
#define DOUBLES_MEGA_TRIGGER_POS_X_OPTIMAL (30)
#define DOUBLES_MEGA_TRIGGER_POS_X_PRIORITY (31)
#define DOUBLES_MEGA_TRIGGER_POS_X_SLIDE (15)
#define DOUBLES_MEGA_TRIGGER_POS_Y_DIFF (-4)
#define tBattler data[0]
#define tHide data[1]
void CreateMegaTriggerSprite(u8 battlerId, u8 palId)
{
LoadSpritePalette(&sSpritePalette_MegaTrigger);
if (GetSpriteTileStartByTag(TAG_MEGA_TRIGGER_TILE) == 0xFFFF)
LoadSpriteSheet(&sSpriteSheet_MegaTrigger);
if (gBattleStruct->mega.triggerSpriteId == 0xFF)
{
gBattleStruct->mega.triggerSpriteId = CreateSprite(&sSpriteTemplate_MegaTrigger,
gSprites[gHealthboxSpriteIds[battlerId]].pos1.x,
gSprites[gHealthboxSpriteIds[battlerId]].pos1.y - MEGA_TRIGGER_POS_Y_DIFF, 0);
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
gBattleStruct->mega.triggerSpriteId = CreateSprite(&sSpriteTemplate_MegaTrigger,
gSprites[gHealthboxSpriteIds[battlerId]].pos1.x - SINGLES_MEGA_TRIGGER_POS_X_SLIDE,
gSprites[gHealthboxSpriteIds[battlerId]].pos1.y - SINGLES_MEGA_TRIGGER_POS_Y_DIFF, 0);
else
gBattleStruct->mega.triggerSpriteId = CreateSprite(&sSpriteTemplate_MegaTrigger,
gSprites[gHealthboxSpriteIds[battlerId]].pos1.x - DOUBLES_MEGA_TRIGGER_POS_X_SLIDE,
gSprites[gHealthboxSpriteIds[battlerId]].pos1.y - DOUBLES_MEGA_TRIGGER_POS_Y_DIFF, 0);
}
gSprites[gBattleStruct->mega.triggerSpriteId].tBattler = battlerId;
gSprites[gBattleStruct->mega.triggerSpriteId].tHide = FALSE;
SetMegaTriggerSpritePal(gBattleStruct->mega.triggerSpriteId, palId);
ChangeMegaTriggerSprite(gBattleStruct->mega.triggerSpriteId, palId);
}
static void SpriteCb_MegaTrigger(struct Sprite *sprite)
{
s32 xSlide, xPriority, xOptimal;
s32 yDiff;
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{
xSlide = DOUBLES_MEGA_TRIGGER_POS_X_SLIDE;
xPriority = DOUBLES_MEGA_TRIGGER_POS_X_PRIORITY;
xOptimal = DOUBLES_MEGA_TRIGGER_POS_X_OPTIMAL;
yDiff = DOUBLES_MEGA_TRIGGER_POS_Y_DIFF;
}
else
{
xSlide = SINGLES_MEGA_TRIGGER_POS_X_SLIDE;
xPriority = SINGLES_MEGA_TRIGGER_POS_X_PRIORITY;
xOptimal = SINGLES_MEGA_TRIGGER_POS_X_OPTIMAL;
yDiff = SINGLES_MEGA_TRIGGER_POS_Y_DIFF;
}
if (sprite->tHide)
{
if (sprite->pos1.x != gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.x + MEGA_TRIGGER_POS_X_DIFF)
if (sprite->pos1.x != gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.x - xSlide)
sprite->pos1.x++;
if (sprite->pos2.x != gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos2.x + MEGA_TRIGGER_POS_X_DIFF)
sprite->pos2.x++;
sprite->pos1.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.y - MEGA_TRIGGER_POS_Y_DIFF;
sprite->pos2.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos2.y - MEGA_TRIGGER_POS_Y_DIFF;
if (sprite->pos1.x == gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.x + MEGA_TRIGGER_POS_X_DIFF
&& sprite->pos2.x == gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos2.x + MEGA_TRIGGER_POS_X_DIFF)
if (sprite->pos1.x >= xPriority)
sprite->oam.priority = 2;
else
sprite->oam.priority = 1;
sprite->pos1.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.y - yDiff;
sprite->pos2.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos2.y - yDiff;
if (sprite->pos1.x == gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.x - xSlide)
DestroyMegaTriggerSprite();
}
else
{
if (sprite->pos1.x != gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.x - MEGA_TRIGGER_POS_X_DIFF)
if (sprite->pos1.x != gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.x - xOptimal)
sprite->pos1.x--;
if (sprite->pos2.x != gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos2.x - MEGA_TRIGGER_POS_X_DIFF)
sprite->pos2.x--;
sprite->pos1.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.y - MEGA_TRIGGER_POS_Y_DIFF;
sprite->pos2.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos2.y - MEGA_TRIGGER_POS_Y_DIFF;
if (sprite->pos1.x >= xPriority)
sprite->oam.priority = 2;
else
sprite->oam.priority = 1;
sprite->pos1.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos1.y - yDiff;
sprite->pos2.y = gSprites[gHealthboxSpriteIds[sprite->tBattler]].pos2.y - yDiff;
}
}
@ -1604,7 +1639,7 @@ bool32 IsMegaTriggerSpriteActive(void)
{
if (GetSpriteTileStartByTag(TAG_MEGA_TRIGGER_TILE) == 0xFFFF)
return FALSE;
else if (IndexOfSpritePaletteTag(TAG_MEGA_TRIGGER_OFF_PAL) != 0xFF || IndexOfSpritePaletteTag(TAG_MEGA_TRIGGER_ON_PAL) != 0xFF)
else if (IndexOfSpritePaletteTag(TAG_MEGA_TRIGGER_PAL) != 0xFF)
return TRUE;
else
return FALSE;
@ -1612,13 +1647,13 @@ bool32 IsMegaTriggerSpriteActive(void)
void HideMegaTriggerSprite(void)
{
ChangeMegaTriggerSprite(gBattleStruct->mega.triggerSpriteId, 0);
gSprites[gBattleStruct->mega.triggerSpriteId].tHide = TRUE;
}
void DestroyMegaTriggerSprite(void)
{
FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_OFF_PAL);
FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_ON_PAL);
FreeSpritePaletteByTag(TAG_MEGA_TRIGGER_PAL);
FreeSpriteTilesByTag(TAG_MEGA_TRIGGER_TILE);
if (gBattleStruct->mega.triggerSpriteId != 0xFF)
DestroySprite(&gSprites[gBattleStruct->mega.triggerSpriteId]);