.float 	packs;

void() regtouch =
{
local float	perrin, mat;
local string s;

if (other.classname != "player")
	return;

if ((other == self.owner) && ((self.nextthink - time) > 15)  )
	return;

if (other.health >= 100)
	return;


sound (other, CHAN_ITEM, "tw/twboump.wav", 1, ATTN_NORM);

perrin = 15 + random()*5;
mat = other.health + perrin;


s = ftos(perrin);



	other.health = mat;
	sprint(other, PRINT_HIGH, "You got ");
	sprint(other, PRINT_HIGH, s);
	sprint(other, PRINT_HIGH, " points of health!\n");



remove(self);

};




void() healthtoss =
{
local entity  pack;

if (self.health < 100)
	return;

if (self.packs < 1)
	return;

self.packs = self.packs - 1;

if (self.packs == 3)
	sprint(self, PRINT_HIGH, "You have 3 packs remaining\n");
if (self.packs == 2)
	sprint(self, PRINT_HIGH, "You have 2 packs remaining\n");
if (self.packs == 1)
	sprint(self, PRINT_HIGH, "You have 1 pack remaining\n");
if (self.packs == 0)
	sprint(self, PRINT_HIGH, "That was the last pack\n");


pack = spawn();
pack.owner = self;
makevectors(self.v_angle);
setorigin(pack, self.origin + '0 0 16');
pack.velocity = aim(self, 1000);
pack.velocity =  pack.velocity * 500;
pack.flags = FL_ITEM;
pack.solid = SOLID_TRIGGER;
pack.movetype = MOVETYPE_BOUNCE;
setmodel(pack, "progs/twregpak.mdl");
setsize(pack, '-16 -16 0', '16 16 56');
pack.touch = regtouch;
pack.nextthink = time + 30;
pack.think = SUB_Remove;

self.health = self.health - 20;

};