// File created by Sixten Hilborn

#include clientapi.jss



Func Paint()
{
	Var MyNr = GetMyNr();
	Var MyPos = PlayerPosition(MyNr);
	
	/*
	Var Char = PlayerInfo(MyNr);
	DrawBox(100, 5, 300, 15, 1.0, 1.0, 1.0, 1.0);
	DrawFillBox(101, 6, 101 + int(198.0 * float(Char[2]) / float(Char[1])), 14, 1.0, 0.0, 0.0, 1.0);
	*/
	
	Var MaxPly = GetMaxPly();
	Var PlyName;
	Var Pos;
	Var Scroll = GetScroll();
	for(Var i = 0; i < MaxPly; i+=1)
	{
		Pos = PlayerPosition(i);
		// In owr place ?
		if(MyPos[6] == Pos[6])
		{
			Var Char = PlayerInfo(i);
			Var HP = float(Char[2]) / float(Char[1]);
			Var x = Pos[0] - Scroll[0];
			Var y = Pos[1] - Scroll[1];
			DrawBox(x - 25, y - 53, x + 25, y - 49, 1.0, 1.0, 1.0, 1.0);
			DrawFillBox(x - 24, y - 52, x - 24 + int(48.0 * HP), y - 50, 1.0, 0.0, 0.0, 1.0);
			
			PlyName = PlayerName(i);
			Var Colour = GetPlayerColor(i);
			DrawText(x, y - 59, PlyName, Colour[0], Colour[1], Colour[2], Colour[3]);
		}
	}
	
	return 0;
}


Func _Main()
{
	AddFunc("Paint", 1, 1); // Paint called when painting, blocking call
}

Func _Shutdown()
{
	RemoveFunc("Paint");
}
