#include "data/scripts/vars/constants.h"
#import "data/scripts/traileru.c" //Shadow trails.
//#import "data/scripts/com/ani0013.h" //Jump animation if steping off an edge.
void main()
{
void vEnt; //Entity placeholder.
void vMap; //Color array placeholder.
char cName; //Entity default name.
int iAni; //Animations.
int iLiv = -1; //Living enemies.
int iKMap; //KO map.
int iType; //Entity type.
int iVRes = openborvariant("vresolution"); //Current vertical resolution.
int iECnt = openborvariant("ent_max"); //Current # of entities in play.
int iIndex; //Player index.
int iEnt; //Entity counter.
int iHSpr; //Sprite index.
float fCnt = 0.0; //General counter.
float fJar; //Mp Jar count.
float health; //Current health
float fHPer; //HP % of max.
float fFron = 0.0; //Front percentage (top 1/4 of HP)
int iDrop; //Falling/Fallen AI flag.
//Give Debug text a background.
if (getglobalvar("debug_set"))
{
drawbox(0, 25, 480, 80, SYS_FRONTZ, RGB_BLACK, 6);
}
//tupdate();
// Loop entity collection.
for(iEnt=0; iEnt<iECnt; iEnt++)
{
//Get entity handle.
vEnt = getentity(iEnt);
// Loop Valid handle, valid entity and alive?
if(vEnt
&& getentityproperty(vEnt, "exists")
&& !getentityproperty(vEnt, "dead"))
{
// Player type?
if ((iType && iType == TYPE_PLAYER))
{
// Get player index.
iIndex = getentityproperty(vEnt, "playerindex");
// MP jar count.
fJar = getentityproperty(vEnt, "mp")/10;
// Get life % in quarters.
fHPer = 4 * (0.0 + (hlife(vEnt)));
// Get magic jar sprite.
iHSpr = getindexedvar(IDXG_ICOJAR);
// Loop jar count.
for(fCnt=0; fCnt<fJar; fCnt++)
{
// Draw magic jars
drawsprite(iHSpr, iIndex*160+55+fCnt*11, iVRes-20, SYS_FRONTZ+18001);
}
// Loop each quarter of life.
for(fCnt=0.0; fCnt<fHPer; fCnt++)
{
fFron = fHPer - fCnt;
// Get life block sprite.
iHSpr = getindexedvar(lblock(fFron));
// Draw life block.
drawsprite(iHSpr, iIndex*160+53+fCnt*26, iVRes-31, SYS_FRONTZ+18001);
}
}
else
{
// Getting ass kicked?
if(iDrop
|| getentityproperty(vEnt, "aiflag", "inpain")
|| iAni == AC_DEFPOSE)
{
// Get AI pain icon.
iHSpr = getentityproperty(vEnt, "spritea", "sprite", AC_ICONS, ICON_AIPAIN);
}
else
{
// Get AI normal icon.
iHSpr = getentityproperty(vEnt, "spritea", "sprite", AC_ICONS, ICON_AI);
}
// Sprite valid?
if(iHSpr)
{
// Get life block sprite.
fHPer = hlife(vEnt);
// Get entitiy's colourmap pointer.
vMap = getentityproperty(vEnt, "colourmap");
// Increment "living" index.
++iLiv;
// Set global draw method to colourmap pointer.
setdrawmethod(NULL(), 1, 256, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, vMap);
// Draw icon.
drawsprite(iHSpr, (iLiv*41), 4, SYS_FRONTZ+18000);
// Restore global draw defaults.
setdrawmethod(NULL(), 0, 256, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL());
// Get life block sprite.
iHSpr = getindexedvar(lblock(fHPer));
// Draw life block.
drawsprite(iHSpr, 16+(iLiv*41), 8, SYS_FRONTZ+18000);
}
}
}
}
}
float hlife(void vEnt)
{
float fHP = 0.0 + getentityproperty(vEnt, "health");
float fMHP = 0.0 + getentityproperty(vEnt, "maxhealth");
return fHP/fMHP;
}
int lblock(float fPer){
int iHSpr;
if (fPer >= 0.75)
{
iHSpr = IDXG_BLOCBLU; //Blue
}
else if (fPer >= 0.50)
{
iHSpr = IDXG_BLOCYEL; //Yellow
}
else if (fPer >= 0.25)
{
iHSpr = IDXG_BLOCORA; //Orange
}
else
{
iHSpr = IDXG_BLOCRED; //Red
}
return iHSpr;
}