class Health expands PickUp;

#exec AUDIO IMPORT FILE="Sounds\Pickups\HEALTH2.WAV"  NAME="Health2"     GROUP="Pickups"

#exec TEXTURE IMPORT NAME=I_Health FILE=TEXTURES\HUD\i_Health.PCX GROUP="Icons"

#exec MESH IMPORT MESH=Health ANIVFILE=MODELS\aniv38.3D DATAFILE=MODELS\data38.3D X=0 Y=0 Z=0
#exec  MESH ORIGIN MESH=Health X=0 Y=0 Z=0 YAW=0
#exec  MESH SEQUENCE MESH=Health SEQ=All    STARTFRAME=0  NUMFRAMES=1
#exec  TEXTURE IMPORT NAME=Jhealth1 FILE=MODELS\health.PCX GROUP="Skins" FLAGS=2
#exec  MESHMAP SCALE MESHMAP=Health X=0.02 Y=0.02 Z=0.04
#exec  MESHMAP SETTEXTURE MESHMAP=Health NUM=0 TEXTURE=Jhealth1

var() int HealingAmount;
var() bool bSuperHeal;

auto state Pickup
{	
	function Touch( actor Other )
	{
		local int HealMax;
	
		if ( ValidTouch(Other) ) 
		{		
			HealMax = Pawn(Other).default.health;
			if (bSuperHeal) HealMax = HealMax * 2.0;
			if (Pawn(Other).Health < HealMax) 
			{
				Pawn(Other).Health += HealingAmount;
				if (Pawn(Other).Health > HealMax) Pawn(Other).Health = HealMax;
				Pawn(Other).ClientMessage(PickupMessage $ HealingAmount);				
				PlaySound (PickupSound);			
				if ( Level.Game.Difficulty > 1 )
					MakeNoise(0.1 * Level.Game.Difficulty);		
				SetRespawn();
			}
		}
	}
}

