mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 04:04:17 +01:00
Fix Mega Indicator appearing and priority
This commit is contained in:
parent
e96e98a8de
commit
c97869018d
@ -82,7 +82,7 @@ void CreateMegaTriggerSprite(u8 battlerId, u8 palId);
|
||||
bool32 IsMegaTriggerSpriteActive(void);
|
||||
void HideMegaTriggerSprite(void);
|
||||
void DestroyMegaTriggerSprite(void);
|
||||
void CreateMegaIndicatorSprite(u32 battlerId, u32 which);
|
||||
u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which);
|
||||
void DestroyMegaIndicatorSprite(u8 battlerId);
|
||||
u8 CreatePartyStatusSummarySprites(u8 battler, struct HpAndStatus *partyInfo, u8 arg2, bool8 isBattleStart);
|
||||
void Task_HidePartyStatusSummary(u8 taskId);
|
||||
|
@ -573,7 +573,7 @@ static const struct OamData sOamData_MegaIndicator =
|
||||
.matrixNum = 0,
|
||||
.size = SPRITE_SIZE(16x16),
|
||||
.tileNum = 0,
|
||||
.priority = 0,
|
||||
.priority = 1,
|
||||
.paletteNum = 0,
|
||||
.affineParam = 0,
|
||||
};
|
||||
@ -614,7 +614,7 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId)
|
||||
{
|
||||
s16 data6 = 0;
|
||||
u8 healthboxLeftSpriteId, healthboxRightSpriteId;
|
||||
u8 healthbarSpriteId;
|
||||
u8 healthbarSpriteId, megaIndicatorSpriteId;
|
||||
struct Sprite *healthBarSpritePtr;
|
||||
|
||||
if (!IsDoubleBattle())
|
||||
@ -693,7 +693,10 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId)
|
||||
|
||||
// Create mega indicator sprite if is a mega evolved mon.
|
||||
if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]])
|
||||
{
|
||||
CreateMegaIndicatorSprite(battlerId, 0);
|
||||
gSprites[megaIndicatorSpriteId].invisible = TRUE;
|
||||
}
|
||||
|
||||
return healthboxLeftSpriteId;
|
||||
}
|
||||
@ -786,9 +789,18 @@ void SetHealthboxSpriteInvisible(u8 healthboxSpriteId)
|
||||
|
||||
void SetHealthboxSpriteVisible(u8 healthboxSpriteId)
|
||||
{
|
||||
u8 battlerId = gSprites[healthboxSpriteId].hMain_Battler;
|
||||
|
||||
gSprites[healthboxSpriteId].invisible = FALSE;
|
||||
gSprites[gSprites[healthboxSpriteId].hMain_HealthBarSpriteId].invisible = FALSE;
|
||||
gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = FALSE;
|
||||
if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]])
|
||||
{
|
||||
if (gBattleStruct->mega.indicatorSpriteIds[battlerId] != 0xFF)
|
||||
gSprites[gBattleStruct->mega.indicatorSpriteIds[battlerId]].invisible = FALSE;
|
||||
else
|
||||
CreateMegaIndicatorSprite(battlerId, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateSpritePos(u8 spriteId, s16 x, s16 y)
|
||||
@ -823,6 +835,8 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
|
||||
gSprites[healthboxLeftSpriteId].oam.priority = priority;
|
||||
gSprites[healthboxRightSpriteId].oam.priority = priority;
|
||||
gSprites[healthbarSpriteId].oam.priority = priority;
|
||||
if (gBattleStruct->mega.indicatorSpriteIds[i] != 0xFF)
|
||||
gSprites[gBattleStruct->mega.indicatorSpriteIds[i]].oam.priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1351,9 +1365,9 @@ static const s8 sIndicatorPosDoubles[][2] =
|
||||
[B_POSITION_OPPONENT_RIGHT] = {45, -8},
|
||||
};
|
||||
|
||||
void CreateMegaIndicatorSprite(u32 battlerId, u32 which)
|
||||
u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which)
|
||||
{
|
||||
u8 spriteId, position;
|
||||
u32 spriteId, position;
|
||||
s16 x, y;
|
||||
|
||||
LoadSpritePalette(&sSpritePalette_MegaIndicator);
|
||||
@ -1375,6 +1389,7 @@ void CreateMegaIndicatorSprite(u32 battlerId, u32 which)
|
||||
gBattleStruct->mega.indicatorSpriteIds[battlerId] = spriteId;
|
||||
|
||||
gSprites[spriteId].tBattler = battlerId;
|
||||
return spriteId;
|
||||
}
|
||||
|
||||
void DestroyMegaIndicatorSprite(u8 battlerId)
|
||||
|
@ -5718,6 +5718,7 @@ static void atk5B_yesnoboxstoplearningmove(void)
|
||||
gBattleCommunication[CURSOR_POSITION] = 1;
|
||||
BattleCreateYesNoCursorAt(1);
|
||||
}
|
||||
|
||||
if (gMain.newKeys & A_BUTTON)
|
||||
{
|
||||
PlaySE(SE_SELECT);
|
||||
@ -6081,17 +6082,6 @@ static void atk6B_atknameinbuff1(void)
|
||||
gBattlescriptCurrInstr++;
|
||||
}
|
||||
|
||||
// Because the indicator must have priority 0 to be properly displayed on healthbox, it needs to be temporarily changed while displaying lvl-up-box.
|
||||
static void ChangeMegaIndicatorsPriority(u32 priority)
|
||||
{
|
||||
s32 i;
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
if (gBattleStruct->mega.indicatorSpriteIds[i] != 0xFF)
|
||||
gSprites[gBattleStruct->mega.indicatorSpriteIds[i]].oam.priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
static void atk6C_drawlvlupbox(void)
|
||||
{
|
||||
if (gBattleScripting.atk6C_state == 0)
|
||||
@ -6122,7 +6112,6 @@ static void atk6C_drawlvlupbox(void)
|
||||
SetBgAttribute(1, BG_ATTR_PRIORITY, 0);
|
||||
ShowBg(0);
|
||||
ShowBg(1);
|
||||
ChangeMegaIndicatorsPriority(1);
|
||||
HandleBattleWindow(0x12, 7, 0x1D, 0x13, WINDOW_x80);
|
||||
gBattleScripting.atk6C_state = 4;
|
||||
break;
|
||||
@ -6175,7 +6164,6 @@ static void atk6C_drawlvlupbox(void)
|
||||
case 10:
|
||||
if (!IsDma3ManagerBusyWithBgCopy())
|
||||
{
|
||||
ChangeMegaIndicatorsPriority(0);
|
||||
SetBgAttribute(0, BG_ATTR_PRIORITY, 0);
|
||||
SetBgAttribute(1, BG_ATTR_PRIORITY, 1);
|
||||
ShowBg(0);
|
||||
@ -11365,7 +11353,7 @@ static void atkF2_displaydexinfo(void)
|
||||
|
||||
void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags)
|
||||
{
|
||||
s32 destY, destX;
|
||||
s32 destY, destX, bgId;
|
||||
u16 var = 0;
|
||||
|
||||
for (destY = yStart; destY <= yEnd; destY++)
|
||||
@ -11403,10 +11391,8 @@ void HandleBattleWindow(u8 xStart, u8 yStart, u8 xEnd, u8 yEnd, u8 flags)
|
||||
if (flags & WINDOW_CLEAR)
|
||||
var = 0;
|
||||
|
||||
if (flags & WINDOW_x80)
|
||||
CopyToBgTilemapBufferRect_ChangePalette(1, &var, destX, destY, 1, 1, 0x11);
|
||||
else
|
||||
CopyToBgTilemapBufferRect_ChangePalette(0, &var, destX, destY, 1, 1, 0x11);
|
||||
bgId = (flags & WINDOW_x80) ? 1 : 0;
|
||||
CopyToBgTilemapBufferRect_ChangePalette(bgId, &var, destX, destY, 1, 1, 0x11);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user