#library "SHCD"
#include "zcommon.acs"

#define FACE_NORMAL 1 
#define FACE_EVIL   2 
#define FACE_ANGRY  3 
#define FACE_OUCH   4 

int bercount=0;
int stresscount =0;


int faceState = FACE_NORMAL; 
int faceAnim; 
int faceTimer = 0;  
int monsters = 0;
int diff = 0;
int scrt = 0;
int diverg = 0;

int life = 0; 
int health = 0;
bool damage;
int lifeState = 4;
int a = 0; 
int b = 1;
int c = 3;
int d = 5;
int e = 3;

str facesNormal[5][6] = 
 {{ "STFST40", "STFST41", "STFST42", "STFST43", "STFST44", "STFST45" }, 
  { "STFST30", "STFST31", "STFST32", "STFST33", "STFST34", "STFST35" }, 
  { "STFST20", "STFST21", "STFST22", "STFST23", "STFST24", "STFST25" }, 
  { "STFST10", "STFST11", "STFST12", "STFST13", "STFST14", "STFST15" }, 
  { "STFST00", "STFST01", "STFST02", "STFST03", "STFST04", "STFST05" }}; 
  
str facesOuch[5] = { "STFOUCH4", "STFOUCH3", "STFOUCH2", "STFOUCH1", "STFOUCH0" }; 
str facesAngry[5] = { "STFKILL4", "STFKILL3", "STFKILL2", "STFKILL1", "STFKILL0" }; 
str facesEvil[5] = { "STFEVL4", "STFEVL3", "STFEVL2", "STFEVL1", "STFEVL0" }; 

str Beats[36] = { "puls00", "puls01", "puls02", "puls03", "puls04", "puls05", "puls06", "puls07", "puls08", "puls09", "puls10",
 "puls11", "puls12", "puls13", "puls14", "puls15", "puls16", "puls17", "puls18", "puls19", "puls20", "puls21", "puls22", "puls23", "puls24"
 , "puls25", "puls26", "puls27", "puls28", "puls29", "puls30", "puls31", "puls32", "puls33", "puls34", "puls35"}; 
 
str RBeats[17] = { "Rpuls01", "Rpuls02", "Rpuls03", "Rpuls04", "Rpuls05", "Rpuls06", "Rpuls07", "Rpuls08", "Rpuls09", "Rpuls10", 
"Rpuls11", "Rpuls12", "Rpuls13", "Rpuls14", "Rpuls15", "Rpuls16", "Rpuls17", }; 

script "heartbeat1" Enter
{
while (TRUE)
{
delay(34);
if(life >= 80) a++;
if(a >= 35) a = 1;
}
}

script "heartbeat2" Enter
{
while (TRUE)
{
 if(life < 80 && life >= 60) b++;
 if(b >= 29) b = 1;
 delay(28);
}
}

script "heartbeat3" Enter
{
while (TRUE)
{
 if(life < 60 && life >= 40) c++;
 if(c > 22) c =3;
 delay(20);
}
}

script "heartbeat4" Enter
{
while (TRUE)
{
 if(life < 40 && life >= 20) d++;
 if(d > 16) d = 5;
 delay(14);
}
}

script "Redheartbeat" Enter
{
while (TRUE)
{
 if(life < 20 && life >= 0) e++;
 if(e > 10) e = 3;
 delay(10);
}
}

script "anim" Enter
{
while (TRUE)
{
 if(faceState == FACE_NORMAL) faceAnim = random(0, 5);
 delay(random(16, 20));
}
}

script "damage" Enter
{
health = checkinventory("health");
while (TRUE)
{
int newhealth = checkinventory("health");
 damage = newhealth - health;
 health = newHealth; 
delay(7);
   }
}

script "mons" Enter
{
monsters = GetLevelInfo (LEVELINFO_KILLED_MONSTERS);
while (TRUE)
{
int newmonsters = GetLevelInfo (LEVELINFO_KILLED_MONSTERS);
 diff = newmonsters - monsters;
 monsters = newmonsters; 
if(diff >= 3) faceState = FACE_EVIL;
delay(64);
   }
}

script "secrets" Enter
{
scrt = GetLevelInfo (LEVELINFO_FOUND_SECRETS);
while (TRUE)
{
int newscrt = GetLevelInfo (LEVELINFO_FOUND_SECRETS);
 diverg = newscrt - scrt;
 scrt = newscrt; 
if(diverg > 0) faceState = FACE_EVIL;
delay(48);

   }
}

script "timer" Enter
{
while (TRUE)

{
 if(health > 0) facetimer--;
 if(facetimer <= 0) facetimer = 0;
 delay(1);
}
}

  script "stress" Enter
{
 while (TRUE)
{
 if(OnButton(BT_ATTACK) == 1) stresscount = 20;
 if(OnButton(BT_ATTACK) == 0) stresscount--;
 if (damage < 0) stresscount = 18;
 if (stresscount >= 20) stresscount = 20;
 if (stresscount <= 0) stresscount = 0;
 delay(7);
}
}

function bool OnButton (int button)
{
 if((GetPlayerInput(-1,INPUT_BUTTONS) & button))
  return true;
  
  return false;
}

script "berzerker" Enter
{
while (TRUE)
{
 if (bercount >= 35) Takeinventory("PowerStrength", 1);
 if (bercount >= 35) bercount = 0;
 if (checkinventory("PowerStrength") >= 0 && bercount == 35)   
 break; 
 if(checkinventory("PowerStrength") == 1) bercount++; 
 delay(25);
}
}



script "HUD" ENTER
{
if (GameType () != GAME_TITLE_MAP)
{
 int x = 0.5;
 int y = 0.5;
 int xres = 1024;
 int yres = 576;
 SetHudSize(xres,yres,0);
 
 int mtotal = GetLevelInfo (LEVELINFO_TOTAL_MONSTERS);
 int mkilled = GetLevelInfo (LEVELINFO_KILLED_MONSTERS);
 int itotal = GetLevelInfo (LEVELINFO_TOTAL_ITEMS);
 int ifound = GetLevelInfo (LEVELINFO_FOUND_ITEMS);
 int stotal = GetLevelInfo (LEVELINFO_TOTAL_SECRETS);
 int sfound = GetLevelInfo (LEVELINFO_FOUND_SECRETS);
 int armor = CheckInventory("BasicArmor");
 int savepercent = GetArmorInfo (ARMORINFO_SAVEPERCENT);
 int savepint = 0;
 int bkey = checkinventory("bluecard");
 int ykey = checkinventory("yellowcard");
 int rkey = checkinventory("redcard");
 int bskull = checkinventory("blueskull");
 int yskull = checkinventory("yellowskull");
 int rskull = checkinventory("redskull");
 int BuzzAm = 0;
 int ammo = 0;
 int ammo2 = 0;
 int ammo3 = 0;
 str weapon = GetWeapon();
 str weicon = "";
 int clip = 0;
 int Pclip = 0;
 int shell = 0;
 int cell = 0;
 int rocket = 0;
 int souls = 0;
 int gas = 0;
 int hellish = 0;
 int nukes = 0;
 
   //ClearInventory();
 //SetPlayerProperty(0, ON, PROP_TOTALLYFROZEN);
 
 while(true) //Here starts the constant movement and such
 {
  SetFont("BLANK");
  
  itotal = GetLevelInfo (LEVELINFO_TOTAL_ITEMS);
  ifound = GetLevelInfo (LEVELINFO_FOUND_ITEMS);
  stotal = GetLevelInfo (LEVELINFO_TOTAL_SECRETS);
  sfound = GetLevelInfo (LEVELINFO_FOUND_SECRETS);
  mtotal = GetLevelInfo (LEVELINFO_TOTAL_MONSTERS);
  mkilled = GetLevelInfo (LEVELINFO_KILLED_MONSTERS);
  life = GetActorProperty(0, APROP_Health);
  armor = CheckInventory("BasicArmor");
  savepercent = GetArmorInfo (ARMORINFO_SAVEPERCENT);
  savepint = 0;
  weapon = GetWeapon();
  bkey = checkinventory("bluecard");
  ykey = checkinventory("yellowcard");
  rkey = checkinventory("redcard");
  bskull = checkinventory("blueskull");
  yskull = checkinventory("yellowskull");
  rskull = checkinventory("redskull");
  ammo = 0;
  ammo2 = 0;
  ammo3 = 0;
  weicon = "";
 clip = 0;
 Pclip = 0;
 shell = 0;
 cell = 0;
 rocket = 0;
 gas = 0;
 souls = 0;
 hellish = 0;
 BuzzAm = 0;
 nukes = 0;
 
  if(life > 0)
  {
   int Angle = FixedMul(GetPlayerInput(-1,INPUT_YAW),0.5);
   int Pitch = FixedMul(GetPlayerInput(-1,INPUT_PITCH),1.2);
  }
  
 
   //Setting the limits
  if(x > 0.52) x=0.52;
  if(x < 0.48) x=0.48;
  if(y > 0.52) y=0.52;
  if(y < 0.48) y=0.48;
  
   
  if(OnButton(BT_FORWARD) && life > 0) y += 0.005; 
  if(OnButton(BT_BACK) && life > 0) y -= 0.005;
  if(OnButton(BT_MOVELEFT) && life > 0) x -= 0.005;
  if(OnButton(BT_MOVERIGHT) && life > 0) x += 0.005;
  
  x+= +Angle;
  y+= +Pitch;	
  
    
  if(x > 0.5 && OnButton(BT_MOVERIGHT) == 0 && Angle == 0 && life > 0) x -= 0.0015;
  if(x < 0.5 && OnButton(BT_MOVELEFT) == 0 && Angle == 0 && life > 0) x += 0.0015;
  if(y > 0.5 && OnButton(BT_Forward) == 0 && Pitch == 0 && life > 0) y -= 0.0015;
  if(y < 0.5 && OnButton(BT_back) == 0 && Pitch == 0 && life > 0) y += 0.0015;
  
  if (life < 0) life = 0;
    
      if (life > 0)
	  { 
        lifeState = life / 20;
		if(lifestate > 4) lifestate = 4;
      } 

  savepint = (FixedMul(100.000, savepercent) >> 16);

   //life
{
  if(life == 0) setfont("ARM21");
  if(life >= 1 && life <= 5) SetFont("HEAL20");
  if(life >= 6 && life <= 10) SetFont("HEAL19");
  if(life >= 11 && life <= 15) SetFont("HEAL18");
  if(life >= 16 && life <= 20) SetFont("HEAL17");
  if(life >= 21 && life <= 25) SetFont("HEAL16");
  if(life >= 26 && life <= 30) SetFont("HEAL15");
  if(life >= 31 && life <= 35) SetFont("HEAL14");
  if(life >= 36 && life <= 40) SetFont("HEAL13");
  if(life >= 41 && life <= 45) SetFont("HEAL12");
  if(life >= 46 && life <= 50) SetFont("HEAL11");
  if(life >= 51 && life <= 55) SetFont("HEAL10");
  if(life >= 56 && life <= 60) SetFont("HEAL9");
  if(life >= 61 && life <= 65) SetFont("HEAL8");
  if(life >= 66 && life <= 70) SetFont("HEAL7");
  if(life >= 71 && life <= 75) SetFont("HEAL6");
  if(life >= 76 && life <= 80) SetFont("HEAL5");
  if(life >= 81 && life <= 85) SetFont("HEAL4");
  if(life >= 86 && life <= 90) SetFont("HEAL3");
  if(life >= 91 && life <= 95) SetFont("HEAL2");
  if(life >= 96) SetFont("HEAL1");
  {
  HudMessage(s:"A"; HUDMSG_ALPHA, 1644461, CR_green, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
  } 
  }
   
 //pulsstate
   {
  if(life >=80 && a++)
   {
   setfont(Beats[a]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }
   
  If(life < 80 && life >= 60 && b++) 
   {
   SETFONT(Beats[b]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }  
   
  If(life < 60 && life >=40 && c++) 
   {
   SETFONT(Beats[c]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }  
  
  If(life < 40 && life >=20 && d++) 
   {
   SETFONT(Beats[d]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }
  
  If(life < 20 && life >0 && e++ ) 
   {
   SETFONT(RBeats[e]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }  
  
   If( life <= 0)  
   {
   SetFont("BLANK");
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }  
  
  if(bercount > 1 && bercount < 35) 
   {
   SETFONT(RBeats[e]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }  
  
  If(CheckActorProperty(ActivatorTID(), APROP_Invulnerable, 1)) 
   {
   SETFONT(RBeats[e]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }   
  
  If(life >=60 && checkinventory("PowerStrength") == 0 && stresscount >= 3 && stresscount <= 12 ) 
   {
   SETFONT(Beats[c]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   }  
  
  If(life >=40 && checkinventory("PowerStrength") == 0 && stresscount >= 12) 
   {
   SETFONT(Beats[d]);
   HudMessage(s:"A"; HUDMSG_ALPHA, 1644462, CR_untranslated, (FixedMul((x - 0.272),xres<<16)>>16<<16), (FixedMul((y +0.200),yres<<16)>>16<<16), 0.01, 0.55);
   } 
   }
   
   
   
//Weapon and Ammo 
  //BDv21 RC
  if(strICmp(weapon, "BrutalPistol") == 0)             ammo = CheckInventory("Clip1"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  if(strICmp(weapon, "DualPistols") == 0)              ammo = CheckInventory("Clip1"), ammo2 = CheckInventory("BDDualPistolAmmo"), weicon="PINADA"; 
  if(StrICmp(weapon, "BrutalSMG") == 0)                ammo = CheckInventory("Clip1"), ammo2 = checkinventory("BDSMGAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "DualSMG") == 0)                  ammo = CheckInventory("Clip1"), ammo2 = checkinventory("BDDualSMGAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "MP40") == 0)                     ammo = CheckInventory("Clip1"), ammo2 = CheckInventory("MP40Ammo"), weicon="PINADA";
  if(StrICmp(weapon, "DualMP40") == 0)                 ammo = CheckInventory("Clip1"), ammo2 = CheckInventory("DualMP40Ammo"), weicon="PINADA";
 
  if(strICmp(weapon, "ClassicPistol") == 0)            ammo2 = CheckInventory("Clip2"), weicon="PINADA";
  if(strICmp(weapon, "ClassicSMG") == 0)               ammo2 = CheckInventory("Clip2"), weicon="PINADA";
  if(StrICmp(weapon, "Rifle") == 0)                    ammo = CheckInventory("Clip2"), ammo2 = CheckInventory("rifleammo"), weicon="PINADA";
  if(StrICmp(weapon, "MiniGun") == 0)                  ammo2 = CheckInventory("Clip2"), weicon="PINADA";
  if(StrICmp(weapon, "ClassicChaingun") == 0)          ammo2 = CheckInventory("Clip2"), weicon="PINADA";
  if(StrICmp(weapon, "DualRifles") == 0)               ammo = CheckInventory("Clip2"), ammo2 = checkinventory("dOUBLERifleAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "Machinegun") == 0)               ammo = CheckInventory("AmmoRocket"), ammo2 = CheckInventory("Clip2"), weicon="PINADA";
  if(StrICmp(weapon, "Revolver2") == 0)                ammo = CheckInventory("Clip2"), ammo2 = CheckInventory("RevolverAmmo"), weicon="PINADA";

  if(StrICmp(weapon, "Shot_Gun") == 0)                 ammo = CheckInventory("AmmoShell"), ammo2 = CheckInventory("ShotgunAmmo"), weicon="PINAEA"; 
  if(StrICmp(weapon, "ClassicShotgun") == 0)           ammo2 = CheckInventory("AmmoShell"), weicon="PINAEA"; 
  if(StrICmp(weapon, "SSG") == 0)                      ammo = CheckInventory("AmmoShell"), ammo2 = CheckInventory("SSGAmmo"), weicon="PINAEA";
  if(StrICmp(weapon, "ClassicSSG") == 0)               ammo2 = CheckInventory("AmmoShell"), weicon="PINAEA";
  if(StrICmp(weapon, "AssaultShotgun") == 0)           ammo = CheckInventory("AmmoShell"), ammo2 = CheckInventory("AssaultShotgunAmmo"), weicon="PINAEA"; 
  if(StrICmp(weapon, "Revolver") == 0)                 ammo = CheckInventory("AmmoShell"), ammo2 = CheckInventory("RevolverAmmo"), weicon="PINAEA";
 
  if(StrIcmp(weapon, "Rocket_Launcher") == 0)          ammo = CheckInventory("AmmoRocket"), ammo2 = CheckInventory("RocketRounds"), weicon="PINAGA";
  if(StrIcmp(weapon, "ClassicRocketLauncher") == 0)    ammo2 = CheckInventory("AmmoRocket"), weicon="PINAGA";
  if(StrIcmp(weapon, "GrenadeLauncher") == 0)          ammo = CheckInventory("AmmoRocket"), ammo2 = CheckInventory("AmmoRocket"), weicon="PINAGA";
  if(StrIcmp(weapon, "NukeLauncher") == 0)             ammo2 = CheckInventory("Nuke"), weicon="PINAGA";
  
  if(StrIcmp(weapon, "Plasma_Gun") == 0)               ammo = CheckInventory("AmmoCell"), ammo2 = CheckInventory("PlasmaAmmo"), weicon="PINAFA";
  if(StrIcmp(weapon, "ClassicPlasmaRifle") == 0)       ammo2 = CheckInventory("AmmoCell"), weicon="PINAFA";
  if(StrIcmp(weapon, "BIG_FUCKING_GUN") == 0)          ammo2 = CheckInventory("AmmoCell"), weicon="PINAFA";
  if(StrIcmp(weapon, "VanillaBFG9000") == 0)           ammo2 = CheckInventory("AmmoCell"), weicon="PINAFA";
  if(StrIcmp(weapon, "BFG10k") == 0)                   ammo2 = CheckInventory("AmmoCell"), weicon="PINAFA";
  if(StrICmp(weapon, "DualPlasmaRifles") == 0)         ammo = CheckInventory("AmmoCell"), ammo2 = checkinventory("DoublePlasmaAmmo"), weicon="PINAFA";
  if(StrIcmp(weapon, "RailGun") == 0)                  ammo = CheckInventory("AmmoCell"), ammo2 = CheckInventory("RailgunAmmo"), weicon="PINAFA";

  if(StrIcmp(weapon, "HandGrenades") == 0)             ammo2 = CheckInventory("GrenadeAmmo"), weicon = "BLANK"; ammo3 = CheckInventory("GrenadeAmmo");
  
  if(strICmp(weapon, "Chain_Saw") ==0)                 ammo2 = 0, weicon = "BLANK";
  if(strICmp(weapon, "ClassicSaw") ==0)                ammo2 = 0, weicon = "BLANK";
  if(strICmp(weapon, "ClassicModernSaw") ==0)          ammo2 = 0, weicon = "BLANK";
  if(StrIcmp(weapon, "Melee_Attacks") == 0)            ammo2 = 0, weicon = "BLANK";
  if(StrIcmp(weapon, "ClassicFist") == 0)              ammo2 = 0, weicon = "BLANK";
  if(StrIcmp(weapon, "BrutalAxe") == 0)                ammo2 = 0, weicon = "BLANK";
  if(StrIcmp(weapon, "DSweap") == 0)                   ammo2 = 0, weicon = "BLANK";
  
  if(StrICmp(weapon, "ImpShield") == 0)                ammo = CheckInventory("MeatAmmo"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "ZMANShield") == 0)               ammo = CheckInventory("MeatAmmo"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "SguyShield") == 0)               ammo = CheckInventory("MeatAmmo"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "CguyShield") == 0)               ammo = CheckInventory("MeatAmmo"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "NaziShield") == 0)               ammo = CheckInventory("MeatAmmo"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "EvilMarineShield") == 0)         ammo = CheckInventory("MeatAmmo"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  if(StrICmp(weapon, "ZombieCivilianShield") == 0)     ammo = CheckInventory("MeatAmmo"), ammo2 = CheckInventory("BDPistolAmmo"), weicon="PINADA";
  
  if(StrICmp(weapon, "HitlersBuzzsaw") == 0)           ammo2 = CheckInventory("BuzzsawAmmo"), weicon="PINAIA";
  if(StrIcmp(weapon, "FlameCannon") == 0)              ammo2 = CheckInventory("Gas"), weicon="PINGASA";
  if(StrIcmp(weapon, "HellishMissileLauncher") == 0)   ammo2 = CheckInventory("MiniHellRocketAmmo"), weicon="PINHLSA";
  if(StrIcmp(weapon, "Flamethrower2") == 0)            ammo2 = CheckInventory("Gas"), weicon="PINGASA";
  if(StrIcmp(weapon, "UnmakerLaser") == 0)             ammo2 = CheckInventory("SoulAmmo"), weicon="PINAKA";

  if(StrICmp(weapon, "TankGun") == 0)                  ammo = CheckInventory("TankAmmo"), ammo2 = CheckInventory("HeavyMachinegunAmmo");
  if(StrICmp(weapon, "ArtilleryTankGun") == 0)         ammo = CheckInventory("HelicopterRocketAmmo"),ammo2 = CheckInventory("HeavyMachinegunAmmo");
  if(StrICmp(weapon, "attackhelicopterGun") == 0)      ammo = CheckInventory("HelicopterRocketAmmo"), ammo2 = CheckInventory("HeavyMachinegunAmmo");
  if(StrICmp(weapon, "HeavyMachinegunHUD") == 0)       ammo2 = CheckInventory("HeavyMachinegunAmmo");
  if(StrICmp(weapon, "BikeHUD") == 0)                  ammo2 = CheckInventory("Shell");


  
  clip = CheckInventory("Clip2");
  Pclip = CheckInventory("Clip1");
  shell = CheckInventory("AmmoShell");
  cell = CheckInventory("AmmoCell");
  souls = CheckInventory("SoulAmmo");
  rocket = CheckInventory("AmmoRocket");
  gas = CheckInventory("Gas");
  hellish = CheckInventory("MiniHellRocketAmmo");
  BuzzAm = CheckInventory("BuzzsawAmmo");
  nukes = CheckInventory("Nuke");
  {
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:ammo; HUDMSG_ALPHA, 1644463, CR_gold, (FixedMul((x + 0.270),xres<<16)>>16<<16), (FixedMul((y + 0.206),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont(weicon);
  HudMessage(s:"A"; HUDMSG_ALPHA, 1644464, CR_untranslated, (FixedMul((x + 0.370),xres<<16)>>16<<16), (FixedMul((y + 0.197),yres<<16)>>16<<16), 0.01, 0.45);

  SetFont("DIGIFONT_SMALL");
  HudMessage(s:"/        AMMO"; HUDMSG_ALPHA, 1644465, CR_gold, (FixedMul((x + 0.295),xres<<16)>>16<<16), (FixedMul((y + 0.206),yres<<16)>>16<<16), 0.01, 0.45);
  
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:ammo2; HUDMSG_ALPHA, 1644466, CR_gold, (FixedMul((x + 0.215),xres<<16)>>16<<16), (FixedMul((y + 0.206),yres<<16)>>16<<16), 0.01, 0.45);
  
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:ammo3; HUDMSG_ALPHA, 1644467, CR_gold, (FixedMul((x + 0.165),xres<<16)>>16<<16), (FixedMul((y + 0.276),yres<<16)>>16<<16), 0.01, 0.45);
  
  SetFont("DIGIFONT_SMALL");
  HudMessage(s:"/ GRENADES"; HUDMSG_ALPHA, 1644468, CR_gold, (FixedMul((x + 0.240),xres<<16)>>16<<16), (FixedMul((y + 0.276),yres<<16)>>16<<16), 0.01, 0.45);
  
  Setfont("PINAD");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 1644469, CR_untranslated, (FixedMul((x + 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.00),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:clip; HUDMSG_ALPHA, 16444610, CR_gold, (FixedMul((x + 0.475),xres<<16)>>16<<16), (FixedMul((y + 0.008),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:Pclip; HUDMSG_ALPHA, 16444611, CR_gold, (FixedMul((x + 0.435),xres<<16)>>16<<16), (FixedMul((y + 0.008),yres<<16)>>16<<16), 0.01, 0.45);
  Setfont("PINAI");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 16444644, CR_untranslated, (FixedMul((x - 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.15),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:BuzzAm; HUDMSG_ALPHA, 164446451, CR_gold, (FixedMul((x - 0.475),xres<<16)>>16<<16), (FixedMul((y - 0.144),yres<<16)>>16<<16), 0.01, 0.45);

  
  Setfont("PINAE");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 16444612, CR_untranslated, (FixedMul((x + 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.075),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:shell; HUDMSG_ALPHA, 16444613, CR_gold, (FixedMul((x + 0.475),xres<<16)>>16<<16), (FixedMul((y - 0.068),yres<<16)>>16<<16), 0.01, 0.45);
    
  Setfont("PINAF");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 16444614, CR_untranslated, (FixedMul((x + 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.15),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:cell; HUDMSG_ALPHA, 16444615, CR_gold, (FixedMul((x + 0.475),xres<<16)>>16<<16), (FixedMul((y - 0.142),yres<<16)>>16<<16), 0.01, 0.45);
  
  Setfont("PINAG");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 16444616, CR_untranslated, (FixedMul((x + 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.225),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:rocket; HUDMSG_ALPHA, 16444617, CR_gold, (FixedMul((x + 0.475),xres<<16)>>16<<16), (FixedMul((y - 0.217),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:nukes; HUDMSG_ALPHA, 1644461711, CR_gold, (FixedMul((x + 0.435),xres<<16)>>16<<16), (FixedMul((y - 0.217),yres<<16)>>16<<16), 0.01, 0.45);


  Setfont("PINGAS");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 16444618, CR_untranslated, (FixedMul((x - 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.00),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:gas; HUDMSG_ALPHA, 16444619, CR_orange, (FixedMul((x - 0.475),xres<<16)>>16<<16), (FixedMul((y + 0.008),yres<<16)>>16<<16), 0.01, 0.45);
      
  Setfont("PINHLSH");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 16444620, CR_untranslated, (FixedMul((x - 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.075),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:hellish; HUDMSG_ALPHA, 16444621, CR_red, (FixedMul((x - 0.475),xres<<16)>>16<<16), (FixedMul((y - 0.068),yres<<16)>>16<<16), 0.01, 0.45);
 
  Setfont("PINAK");
  Hudmessage(s:"A"; HUDMSG_ALPHA, 1644462911111, CR_untranslated, (FixedMul((x - 0.500),xres<<16)>>16<<16), (FixedMul((y - 0.225),yres<<16)>>16<<16), 0.01, 0.45);
  SetFont("AMMOFONT");
  HudMessage(i:souls; HUDMSG_ALPHA, 1644463011111, CR_cyan, (FixedMul((x - 0.475),xres<<16)>>16<<16), (FixedMul((y - 0.217),yres<<16)>>16<<16), 0.01, 0.45);

  }
  
  //mugshot
{     
    if(damage == 0 );
	{ 
	 faceState = FACE_NORMAL;
	 {
	  if (faceState == FACE_NORMAL) 
	  {
       SetFont(facesNormal[lifeState][faceAnim]);
	   hudmessage(s:"A"; HUDMSG_ALPHA, 16444622, CR_untranslated, (FixedMul((x + 0.0565),xres<<16)>>16<<16), (FixedMul((y-0.315),yres<<16)>>16<<16), 0.01, 0.5);
      } 
     }
	}
	 
	 if(damage < 0 && damage >= -29) faceState = FACE_ANGRY;
	 if( OnButton(BT_ATTACK) == 1 && facetimer <= 28 && diff <= 3) facetimer = 28;
	 {
   	  if (faceState == FACE_ANGRY | facetimer >= 1 && facetimer <= 28) 
	  {
       SetFont(facesAngry[lifeState]);
	   hudmessage(s:"A"; HUDMSG_ALPHA, 16444622, CR_untranslated, (FixedMul((x + 0.0565),xres<<16)>>16<<16), (FixedMul((y-0.315),yres<<16)>>16<<16), 0.01, 0.5);
      } 
   }
   
   	 if( damage <= -30) facetimer = 62;
	  {
   	  if (facetimer >= 29 && facetimer <= 62)
	  {
       SetFont(facesOuch[lifeState]);
	   hudmessage(s:"A"; HUDMSG_ALPHA, 16444622, CR_untranslated, (FixedMul((x + 0.0565),xres<<16)>>16<<16), (FixedMul((y-0.315),yres<<16)>>16<<16), 0.01, 0.5);
      } 
      }
   
     if(diff > 3) faceState = FACE_EVIL;
	 if(diverg > 0) faceState = FACE_EVIL;
	 {
	  if(faceState == FACE_EVIL)
   	  {
       SetFont(facesEvil[lifeState]);
	   hudmessage(s:"A"; HUDMSG_ALPHA, 16444622, CR_untranslated, (FixedMul((x + 0.0565),xres<<16)>>16<<16), (FixedMul((y-0.315),yres<<16)>>16<<16), 0.01, 0.5);
      } 
    }
	
	  if(strICmp(weapon, "Chain_Saw" | "ClassicSaw" | "ClassicModernSaw") ==0 && diff > 0) faceState = FACE_EVIL;
	 {
	  if(faceState == FACE_EVIL)
   	  {
       SetFont(facesEvil[lifeState]);
	   hudmessage(s:"A"; HUDMSG_ALPHA, 16444622, CR_untranslated, (FixedMul((x + 0.0565),xres<<16)>>16<<16), (FixedMul((y-0.315),yres<<16)>>16<<16), 0.01, 0.5);
      } 
    }
	
      if (life <= 0) setfont("STFDEAD0"); 
      {
       hudmessage(s:"A"; HUDMSG_ALPHA, 16444622, CR_untranslated, (FixedMul((x + 0.0565),xres<<16)>>16<<16), (FixedMul((y-0.315),yres<<16)>>16<<16), 0.01, 0.5);
      }
  
  If(CheckActorProperty(ActivatorTID(), APROP_Invulnerable, 1)) SETFONT("STFGOD0");
  {
  hudmessage(s:"A"; HUDMSG_ALPHA, 16444622, CR_untranslated, (FixedMul((x + 0.0565),xres<<16)>>16<<16), (FixedMul((y-0.315),yres<<16)>>16<<16), 0.01, 0.5);
  }
  }
  
     
  //armor
  {
  if(armor == 0) setfont("ARM21");
  if(armor >= 1 && armor <= 5) SetFont("ARM20");
  if(armor >= 6 && armor <= 10) SetFont("ARM19");
  if(armor >= 11 && armor <= 15) SetFont("ARM18");
  if(armor >= 16 && armor <= 20) SetFont("ARM17");
  if(armor >= 21 && armor <= 25) SetFont("ARM16");
  if(armor >= 26 && armor <= 30) SetFont("ARM15");
  if(armor >= 31 && armor <= 35) SetFont("ARM14");
  if(armor >= 36 && armor <= 40) SetFont("ARM13");
  if(armor >= 41 && armor <= 45) SetFont("ARM12");
  if(armor >= 46 && armor <= 50) SetFont("ARM11");
  if(armor >= 51 && armor <= 55) SetFont("ARM10");
  if(armor >= 56 && armor <= 60) SetFont("ARM9");
  if(armor >= 61 && armor <= 65) SetFont("ARM8");
  if(armor >= 66 && armor <= 70) SetFont("ARM7");
  if(armor >= 71 && armor <= 75) SetFont("ARM6");
  if(armor >= 76 && armor <= 80) SetFont("ARM5");
  if(armor >= 81 && armor <= 85) SetFont("ARM4");
  if(armor >= 86 && armor <= 90) SetFont("ARM3");
  if(armor >= 91 && armor <= 95) SetFont("ARM2");
  if(armor >= 96) SetFont("ARM1");
  {
  HudMessage(s:"A"; HUDMSG_ALPHA, 16444624, CR_green, (FixedMul((x - 0.242),xres<<16)>>16<<16), (FixedMul((y +0.270),yres<<16)>>16<<16), 0.01, 0.55);
  } 
  }
  
   //keys
   {
   if(bkey == 1) 
   {
   SetFont("stkeys0");
   Hudmessage(s:"A"; HUDMSG_ALPHA, 16444625, CR_untranslated, (FixedMul((x + 0.288),xres<<16)>>16<<16), (FixedMul((y - 0.33),yres<<16)>>16<<16), 0.01, 0.65);
   }
   if(ykey == 1)
   {
   setfont("stkeys1");
   HudMessage(s:"A"; HUDMSG_ALPHA, 16444626, CR_untranslated, (FixedMul((x + 0.324),xres<<16)>>16<<16), (FixedMul((y - 0.33),yres<<16)>>16<<16), 0.01, 0.65);
   }
   if(rkey == 1)
   {
   setfont("stkeys2");
   HudMessage(s:"A"; HUDMSG_ALPHA, 16444627, CR_untranslated, (FixedMul((x + 0.356),xres<<16)>>16<<16), (FixedMul((y - 0.33),yres<<16)>>16<<16), 0.01, 0.65);
   }  	
   if(bskull == 1) 
   {
   setfont("stkeys3");
   Hudmessage(s:"A"; HUDMSG_ALPHA, 16444628, CR_untranslated, (FixedMul((x + 0.294),xres<<16)>>16<<16), (FixedMul((y - 0.313),yres<<16)>>16<<16), 0.01, 0.65);
   }
   if(yskull == 1)
   {
   setfont("stkeys4");
   HudMessage(s:"A"; HUDMSG_ALPHA, 16444629, CR_untranslated, (FixedMul((x + 0.328),xres<<16)>>16<<16), (FixedMul((y - 0.313),yres<<16)>>16<<16), 0.01, 0.65);
   }
   if(rskull == 1)
   {
   setfont("stkeys5");
   HudMessage(s:"A"; HUDMSG_ALPHA, 16444630, CR_untranslated, (FixedMul((x + 0.360),xres<<16)>>16<<16), (FixedMul((y - 0.313),yres<<16)>>16<<16), 0.01, 0.65);
   }
 }
 
 
 //status 
{
  SetFont("PINAB");
  HudMessage(s:"A"; HUDMSG_ALPHA, 16444631, CR_untranslated, (FixedMul((x - 0.370),xres<<16)>>16<<16), (FixedMul((y + 0.190),yres<<16)>>16<<16), 0.01, 0.55);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:life; HUDMSG_ALPHA, 16444632, CR_cyan, (FixedMul((x - 0.175),xres<<16)>>16<<16), (FixedMul((y + 0.206),yres<<16)>>16<<16), 0.01, 0.55);
  SetFont("PINAA");
  HudMessage(s:"A"; HUDMSG_ALPHA, 16444633, CR_untranslated, (FixedMul((x - 0.340),xres<<16)>>16<<16), (FixedMul((y + 0.265),yres<<16)>>16<<16), 0.01, 0.55);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:armor; HUDMSG_ALPHA, 16444634, CR_green, (FixedMul((x - 0.145),xres<<16)>>16<<16), (FixedMul((y +0.276),yres<<16)>>16<<16), 0.01, 0.55);
  setfont("headsup");
  HudMessage(s:"A"; HUDMSG_ALPHA, 16444635, CR_gold, (FixedMul((x - 0.05),xres<<16)>>16<<16), (FixedMul((y-0.300),yres<<16)>>16<<16), 0.01, 0.80);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:mtotal; HUDMSG_ALPHA, 16444636, CR_gold, (FixedMul((x - 0.220),xres<<16)>>16<<16), (FixedMul((y-0.305),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:mkilled; HUDMSG_ALPHA, 16444637, CR_gold, (FixedMul((x - 0.280),xres<<16)>>16<<16), (FixedMul((y-0.305),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:itotal; HUDMSG_ALPHA, 16444638, CR_gold, (FixedMul((x - 0.220),xres<<16)>>16<<16), (FixedMul((y-0.245),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:ifound; HUDMSG_ALPHA, 16444639, CR_gold, (FixedMul((x - 0.280),xres<<16)>>16<<16), (FixedMul((y-0.245),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:stotal; HUDMSG_ALPHA, 16444640, CR_gold, (FixedMul((x - 0.220),xres<<16)>>16<<16), (FixedMul((y-0.275),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("DIGIFONT_SMALL");
  HudMessage(i:sfound; HUDMSG_ALPHA, 16444641, CR_gold, (FixedMul((x - 0.280),xres<<16)>>16<<16), (FixedMul((y-0.275),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("DIGIFONT_SMALL");
  HudMessage(n:0; HUDMSG_ALPHA, 16444641222, CR_gold, (FixedMul((x - 0.087),xres<<16)>>16<<16), (FixedMul((y-0.340),yres<<16)>>16<<16), 0.01, 0.3);
  SetFont("decrline");
  HudMessage(s:"A"; HUDMSG_ALPHA, 164345455, CR_green, (FixedMul((x - 0.233),xres<<16)>>16<<16), (FixedMul((y +0.282),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("CYANLINE");
  HudMessage(s:"A"; HUDMSG_ALPHA, 16434545522, CR_green, (FixedMul((x - 0.263),xres<<16)>>16<<16), (FixedMul((y +0.210),yres<<16)>>16<<16), 0.01, 0.35);
  SetFont("AMMOFONT");
  HudMessage(i:savepint; HUDMSG_ALPHA, 16444634224321, CR_green, (FixedMul((x - 0.308),xres<<16)>>16<<16), (FixedMul((y +0.248),yres<<16)>>16<<16), 0.01, 0.55);

  }

  //HUD Layout
  if(armor == 0) SetFont("AIM2");
  if(armor >= 1 && armor <= 29) SetFont("AIM1");
  if(armor >= 30 && armor <= 69) SetFont("ALT16090");
  if(armor >= 70 && armor <= 100) SetFont("ALT16100");
  if(armor >= 101 && armor <= 133) SetFont("ALT16110");
  if(armor >= 134 && armor <= 166) SetFont("ALT16120");
  if(armor >= 167 && armor <= 200) SetFont("ALT16130");
  if(armor >= 201) SetFont("ALT16140");
  if(life <=0 && armor >= 0) SetFont("AIM4");
  if(life == 0) SetFont("AIM4");
  {
  HudMessage(s:"A"; HUDMSG_LAYER_UNDERHUD, 16444643, CR_UNTRANSLATED, (FixedMul(x,xres<<16)>>16<<16), (FixedMul(y,yres<<16)>>16<<16), 0.01);
  delay(1);
  }
  }
  }
  }
  
