pokeplatinum/include/battle/healthbar.h
2026-02-20 11:51:58 -08:00

182 lines
5.8 KiB
C

#ifndef POKEPLATINUM_HEALTHBAR_H
#define POKEPLATINUM_HEALTHBAR_H
#include "struct_decls/battle_system.h"
#include "bg_window.h"
#include "narc.h"
#include "palette.h"
#include "sprite.h"
#include "sprite_system.h"
#include "sys_task_manager.h"
#define HEALTHBAR_INFO_NONE 0
#define HEALTHBAR_INFO_HP_GAUGE (1 << 0)
#define HEALTHBAR_INFO_CURRENT_HP (1 << 1)
#define HEALTHBAR_INFO_MAX_HP (1 << 2)
#define HEALTHBAR_INFO_LEVEL (1 << 3)
#define HEALTHBAR_INFO_NAME (1 << 4)
#define HEALTHBAR_INFO_EXP_GAUGE (1 << 5)
#define HEALTHBAR_INFO_GENDER (1 << 6)
#define HEALTHBAR_INFO_LEVEL_TEXT (1 << 7)
#define HEALTHBAR_INFO_STATUS (1 << 8)
#define HEALTHBAR_INFO_CAUGHT_SPECIES (1 << 9)
#define HEALTHBAR_INFO_COUNT_SAFARI_BALLS (1 << 10)
#define HEALTHBAR_INFO_REMAINING_SAFARI_BALLS (1 << 11)
#define HEALTHBAR_INFO_COUNT_PARK_BALLS (1 << 12)
#define HEALTHBAR_INFO_REMAINING_PARK_BALLS (1 << 13)
#define HEALTHBAR_INFO_ALL ~0
#define HEALTHBAR_INFO_ALL_SAFARI (HEALTHBAR_INFO_COUNT_SAFARI_BALLS | HEALTHBAR_INFO_REMAINING_SAFARI_BALLS)
#define HEALTHBAR_INFO_ALL_PARK (HEALTHBAR_INFO_COUNT_PARK_BALLS | HEALTHBAR_INFO_REMAINING_PARK_BALLS)
#define HEALTHBAR_INFO_NOT_ON_ENEMY (HEALTHBAR_INFO_CURRENT_HP | HEALTHBAR_INFO_MAX_HP | HEALTHBAR_INFO_EXP_GAUGE)
enum HealthbarType {
HEALTHBAR_TYPE_PLAYER_SOLO = 0,
HEALTHBAR_TYPE_ENEMY_SOLO,
HEALTHBAR_TYPE_PLAYER_SLOT_1,
HEALTHBAR_TYPE_ENEMY_SLOT_1,
HEALTHBAR_TYPE_PLAYER_SLOT_2,
HEALTHBAR_TYPE_ENEMY_SLOT_2,
HEALTHBAR_TYPE_SAFARI_ZONE,
HEALTHBAR_TYPE_PAL_PARK,
};
enum HealthbarScrollDirection {
HEALTHBAR_SCROLL_IN = 0,
HEALTHBAR_SCROLL_OUT,
};
enum HealthbarGaugeType {
HEALTHBAR_GAUGE_HP = 0,
HEALTHBAR_GAUGE_EXP,
};
typedef struct Healthbar {
u8 state;
ManagedSprite *mainSprite;
ManagedSprite *arrowSprite;
BattleSystem *battleSys;
SysTask *task_10;
Window unused_14;
u8 battler;
u8 type;
u8 selectedPartySlot;
u8 numSafariBalls;
s32 curHP;
s32 maxHP;
s32 damage;
s32 hpTemp;
s32 curExp;
s32 maxExp;
s32 expReward;
s32 expTemp;
u8 level;
u8 gender;
u8 status;
u8 caughtSpecies;
u8 command;
u8 delay;
u8 unk_4E;
u8 scrollDirection : 1;
u8 doneScrolling : 1;
u8 unused_4F_2 : 1;
u8 numberMode : 1;
u8 padding : 4;
SysTask *task_50;
u16 degrees;
} Healthbar;
/**
* @brief Load the resources required to display a healthbar.
*
* Though a NARC handle is required as a parameter, it is assumed to always be
* an open handle to pl_batt_obj.narc.
*
* @param renderer
* @param gfxHandler
* @param narc
* @param palette
* @param healthbarType
*/
void Healthbar_LoadResources(SpriteSystem *spriteSys, SpriteManager *spriteMan, NARC *narc, PaletteData *palette, enum HealthbarType healthbarType);
ManagedSprite *Healthbar_DrawSprite(SpriteSystem *spriteSys, SpriteManager *spriteMan, int type);
/**
* @brief Draw the informational parts of the healthbar, according to a set
* of input flags which control exactly what components to draw.
*
* @param healthbar
* @param hp The battler's current HP
* @param flags The components to be drawn, as a bitmask.
*/
void Healthbar_DrawInfo(Healthbar *healthbar, u32 hp, u32 flags);
void ov16_02267220(Healthbar *healthbar);
void ov16_02267258(Healthbar *healthbar);
void ov16_022672C4(Healthbar *healthbar);
void ov16_02267360(Healthbar *healthbar);
void ov16_0226737C(Healthbar *healthbar);
/**
* @brief Compute the battler's new HP after taking a given amount of
* damage or restoring a certain amount of health. Additionally, cache
* this difference, flooring it to the bounds of the battler's current
* and maximum HP.
*
* @param healthbar
* @param damage The amount of damage dealt to a battler. Negative
* values are damage, positive values are recovery.
*/
void Healthbar_CalcHP(Healthbar *healthbar, int damage);
s32 ov16_022674F8(Healthbar *healthbar);
void Healthbar_CalcExp(Healthbar *healthbar, int expReward);
s32 ov16_02267560(Healthbar *healthbar);
void ov16_0226757C(Healthbar *healthbar);
void ov16_022675AC(Healthbar *healthbar);
void ov16_022675D8(Healthbar *healthbar, int priority);
/**
* @brief Enable (or disable) the healthbar.
*
* @param battleSys
* @param enable If TRUE, enable the healthbar; otherwise, disable it.
*/
void Healthbar_Enable(Healthbar *battleSys, BOOL enable);
/**
* @brief Offset the healthbar's position by a given value along the X and Y axes.
*
* @param healthbar
* @param x X-axis offset for the healthbar from its current position.
* @param y Y-axis offset for the healthbar from its current position.
*/
void Healthbar_OffsetPositionXY(Healthbar *healthbar, int x, int y);
/**
* @brief Scroll the healthbar in or out.
*
* @param healthbar
* @param direction The direction to scroll the healthbar.
*/
void Healthbar_Scroll(Healthbar *healthbar, enum HealthbarScrollDirection direction);
/**
* @brief Determine the type of healthbar to be displayed for a given battler type
* (solo player, solo enemy, or any slot in doubles) and battle type.
*
* Pal Park and Safari Zone use a different healthbar type than normal battles.
*
* @param battlerType The type of battler which the healthbar represents.
* @param battleType The type of battle in which the healthbar will be used.
* @return The resulting healthbar type; see enum HealthbarType.
*/
u8 Healthbar_Type(int battlerType, u32 battleType);
void ov16_0226834C(Healthbar *healthbar, u8 *param1);
void ov16_02268468(Healthbar *healthbar);
void ov16_0226846C(Healthbar *healthbar);
void ov16_02268470(Healthbar *healthbar);
void ov16_02268498(Healthbar *healthbar);
#endif // POKEPLATINUM_HEALTHBAR_H