mirror of
https://github.com/pret/pokeemerald.git
synced 2026-04-25 15:57:29 -05:00
Change HP bar color calculation from pixel-width to actual values (#8694)
This commit is contained in:
parent
46c690d175
commit
ef48a4d155
|
|
@ -318,6 +318,7 @@
|
|||
#define B_ANIMATE_MON_AFTER_KO TRUE // If set to TRUE, if a Pokémon on the opposite site faints, the non-fainted Pokemon will display a victory animation.
|
||||
#define B_ANIMATE_MON_AFTER_FAILED_POKEBALL TRUE // If set to TRUE, if a Pokémon on the opposite side breaks out of a thrown Poké Ball, the wild Pokémon will display its animation.
|
||||
#define B_SHOW_DYNAMAX_MESSAGE FALSE // If set to TRUE, an additional battle message is shown after completing Dynamaxing/Gigantamaxing.
|
||||
#define B_HPBAR_COLOR_THRESHOLD GEN_LATEST // In Gen 5+, HP bar color thresholds were changed to be based on the actual HP values instead of the pixel length of the HP bar, leading to more accurate HP bar colors.
|
||||
|
||||
// Catching settings
|
||||
#define B_SEMI_INVULNERABLE_CATCH GEN_LATEST // In Gen4+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc)
|
||||
|
|
|
|||
|
|
@ -2078,25 +2078,41 @@ s32 MoveBattleBar(u8 battler, u8 healthboxSpriteId, u8 whichBar, u8 unused)
|
|||
static void MoveBattleBarGraphically(u8 battler, u8 whichBar)
|
||||
{
|
||||
u8 array[8];
|
||||
u8 filledPixelsCount, level;
|
||||
u8 level;
|
||||
u8 barElementId;
|
||||
u8 i;
|
||||
s32 currValue, maxValue;
|
||||
|
||||
switch (whichBar)
|
||||
{
|
||||
case HEALTH_BAR:
|
||||
filledPixelsCount = CalcBarFilledPixels(gBattleSpritesDataPtr->battleBars[battler].maxValue,
|
||||
if (B_HPBAR_COLOR_THRESHOLD < GEN_5)
|
||||
{
|
||||
maxValue = B_HEALTHBAR_PIXELS;
|
||||
currValue = CalcBarFilledPixels(gBattleSpritesDataPtr->battleBars[battler].maxValue,
|
||||
gBattleSpritesDataPtr->battleBars[battler].oldValue,
|
||||
gBattleSpritesDataPtr->battleBars[battler].receivedValue,
|
||||
&gBattleSpritesDataPtr->battleBars[battler].currValue,
|
||||
array, B_HEALTHBAR_PIXELS / 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
CalcBarFilledPixels(gBattleSpritesDataPtr->battleBars[battler].maxValue,
|
||||
gBattleSpritesDataPtr->battleBars[battler].oldValue,
|
||||
gBattleSpritesDataPtr->battleBars[battler].receivedValue,
|
||||
&gBattleSpritesDataPtr->battleBars[battler].currValue,
|
||||
array, B_HEALTHBAR_PIXELS / 8);
|
||||
|
||||
if (filledPixelsCount > (B_HEALTHBAR_PIXELS * 50 / 100)) // more than 50 % hp
|
||||
maxValue = gBattleSpritesDataPtr->battleBars[battler].maxValue;
|
||||
currValue = gBattleSpritesDataPtr->battleBars[battler].currValue;
|
||||
}
|
||||
|
||||
if (currValue > (maxValue * 50 / 100)) // more than 50% hp
|
||||
barElementId = HEALTHBOX_GFX_HP_BAR_GREEN;
|
||||
else if (filledPixelsCount > (B_HEALTHBAR_PIXELS * 20 / 100)) // more than 20% hp
|
||||
else if (currValue > (maxValue * 20 / 100)) // more than 20% hp
|
||||
barElementId = HEALTHBOX_GFX_HP_BAR_YELLOW;
|
||||
else
|
||||
barElementId = HEALTHBOX_GFX_HP_BAR_RED; // 20 % or less
|
||||
barElementId = HEALTHBOX_GFX_HP_BAR_RED; // 20% or less
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
|
|
@ -2294,26 +2310,30 @@ u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale)
|
|||
|
||||
u8 GetHPBarLevel(s16 hp, s16 maxhp)
|
||||
{
|
||||
u8 result;
|
||||
s32 currValue, maxValue;
|
||||
|
||||
if (hp == maxhp)
|
||||
return HP_BAR_FULL;
|
||||
|
||||
if (B_HPBAR_COLOR_THRESHOLD < GEN_5)
|
||||
{
|
||||
result = HP_BAR_FULL;
|
||||
currValue = GetScaledHPFraction(hp, maxhp, B_HEALTHBAR_PIXELS);
|
||||
maxValue = B_HEALTHBAR_PIXELS;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8 fraction = GetScaledHPFraction(hp, maxhp, B_HEALTHBAR_PIXELS);
|
||||
if (fraction > (B_HEALTHBAR_PIXELS * 50 / 100)) // more than 50 % hp
|
||||
result = HP_BAR_GREEN;
|
||||
else if (fraction > (B_HEALTHBAR_PIXELS * 20 / 100)) // more than 20% hp
|
||||
result = HP_BAR_YELLOW;
|
||||
else if (fraction > 0)
|
||||
result = HP_BAR_RED;
|
||||
else
|
||||
result = HP_BAR_EMPTY;
|
||||
currValue = hp;
|
||||
maxValue = maxhp;
|
||||
}
|
||||
|
||||
return result;
|
||||
if (currValue > (maxValue * 50 / 100)) // more than 50% hp
|
||||
return HP_BAR_GREEN;
|
||||
else if (currValue > (maxValue * 20 / 100)) // more than 20% hp
|
||||
return HP_BAR_YELLOW;
|
||||
else if (currValue > 0)
|
||||
return HP_BAR_RED; // 20% or less
|
||||
|
||||
return HP_BAR_EMPTY;
|
||||
}
|
||||
|
||||
static u8 *AddTextPrinterAndCreateWindowOnHealthboxWithFont(const u8 *str, u32 x, u32 y, u32 bgColor, u32 *windowId, u32 fontId)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user