Class StatusBarMod : BaseStatusBar
{
    DynamicValueInterpolator mHealthInterpolator;
    HUDFont mAmmoFont;
    HUDFont mAmmoFontS;

    Override void Init()
    {
        


        mAmmoFont = HUDFont.Create("AMMOFONT");
        mAmmoFontS = HUDFont.Create("AMMOFONT_SMALL", -1);
        mHealthInterpolator = DynamicValueInterpolator.Create(0, 0.25, 1, 8);
    }
    Override void Tick()
    {
        Super.Tick();
        mHealthInterpolator.Update(CPlayer.health); //Health bar interpolation
    }
	   Override void Draw (int state, double TicFrac)
    {
        Super.Draw (state, TicFrac);
        if (state == HUD_None)
            return; //do nothing
        BeginHUD();
        DrawMainBar(); //Start drawing
    }
	
    void DrawMainBar()
    {    //Ammo
        Inventory ammotype1, ammotype2;
        [ammotype1, ammotype2] = GetCurrentAmmo();
        let weapon = ZWeapon(cplayer.readyWeapon);
		DrawBarKeys();
        if (ammotype1 && weapon && weapon.magazineSize > 0)
        {
          DrawString(mAmmoFont,  StringStruct.Format("%d", weapon.ammoCount), (-45, -45),
          DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM|DI_TEXT_ALIGN_CENTER|DI_NOSHADOW,Font.CR_WHITE);
		  }
		
		if(Cplayer.readyweapon is "BerettaExceptTwo")
			{ 
				DrawImage("BERETTA2", (-35, -50), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
				DrawImage("Infinite", (-15, 5), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
			}
			else
			{
			  If(ammotype1!=null){DrawString(mAmmoFontS, FormatNumber(ammotype1.Amount, 1, 3), (-45, -20), 
				DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM|DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW,Font.CR_WHITE);}
			}

        //If(ammotype2!=null){DrawString(mAmmoFont, FormatNumber(ammotype2.Amount, 3, 3), (345, 160), DI_TEXT_ALIGN_RIGHT|DI_NOSHADOW,Font.CR_WHITE);}
        
		
		
        //Armor
        DrawImage("Vesticon", (52,-12), DI_ITEM_LEFT_BOTTOM|DI_SCREEN_LEFT_BOTTOM);
        DrawString(mAmmoFont, FormatNumber(GetArmorAmount(), 1, 3), (82, -37), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM|DI_TEXT_ALIGN_LEFT|DI_NOSHADOW,Font.CR_WHITE );
        //Health
        DrawImage("Plus", (52,-40), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM);
        DrawString(mAmmoFont, FormatNumber(CPlayer.health, 1, 3), (82,-65), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM|DI_TEXT_ALIGN_LEFT|DI_NOSHADOW,Font.CR_WHITE);
        //Pills
        DrawImage("PILLS1", (65, -70), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM);
        Inventory Pillshere = CPlayer.mo.FindInventory("Pillshere");
        If(Pillshere!=null){DrawString(mAmmoFontS, FormatNumber(Pillshere.Amount, 1, 3), (75, -85), 	
			DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM|DI_TEXT_ALIGN_LEFT|DI_NOSHADOW,Font.CR_WHITE);}
        Else{DrawString(mAmmoFontS, FormatNumber(0, 1, 3), (75, -85), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM|DI_TEXT_ALIGN_LEFT|DI_NOSHADOW,Font.CR_WHITE);}
        //Health bar
        int inthealth =  mHealthInterpolator.GetValue();
        DrawBar("A1","B1",inthealth,100,(1,-10),0,3,DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM);
        //Invulnerability
        If(CPlayer.mo.FindInventory("PowerInvulnerable"))
        {
            DrawImage("E1", (1,-10), DI_SCREEN_LEFT_BOTTOM|DI_ITEM_LEFT_BOTTOM);
        }
        //Weapons
		
		If(CPlayer.ReadyWeapon is "M79")
        {
            DrawImage("GREN", (-16, -44), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
        }
        
        If(CPlayer.ReadyWeapon is "Mac10")
        {
            DrawImage("MAC10", (-30, -48), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
        }
		
		If(CPlayer.ReadyWeapon is "DesertEagle")
        {
            DrawImage("DEAGLE", (10, -50), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
        }
		
		/*If(CPlayer.ReadyWeapon is "Jackhammer")
        {
            DrawImage("JACKHAM", (-10, -48), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
        }*/
		
		If(CPlayer.ReadyWeapon is "LeadPipe")
        {
            DrawImage("PIPE", (-10, -40), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
			DrawImage("sINFINITE", (-15, -5), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
        }
		
        If(CPlayer.ReadyWeapon is "Remington870")
        {
            DrawImage("R870", (-6, -40), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
        }
        
        If(CPlayer.ReadyWeapon is "Kalashnikov")
        {
            DrawImage("AK47", (-8, -44), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
        }
    }
	protected virtual void DrawBarKeys()
	{
		bool locks[6];
		String image;
		for(int i = 0; i < 6; i++) locks[i] = CPlayer.mo.CheckKeys(i + 1, false, true);
		// key 1
		if (locks[1] && locks[4]) image = "STKEYS6";
		else if (locks[1]) image = "STKEYS0";
		else if (locks[4]) image = "STKEYS3";
		DrawImage(image, (-2, -30), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
		// key 2
		if (locks[2] && locks[5]) image = "STKEYS7";
		else if (locks[2]) image = "STKEYS1";
		else if (locks[5]) image = "STKEYS4";
		else image = "";
		DrawImage(image, (-2, -20), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
		// key 3
		if (locks[0] && locks[3]) image = "STKEYS8";
		else if (locks[0]) image = "STKEYS2";
		else if (locks[3]) image = "STKEYS5";
		else image = "";
		DrawImage(image, (-2, -10), DI_SCREEN_RIGHT_BOTTOM|DI_ITEM_RIGHT_BOTTOM);
	}
	
}