//=============================================================================
// NaliFruit.
//=============================================================================
class NaliFruit expands Health;

#exec MESH IMPORT MESH=NaliFruitMesh ANIVFILE=MODELS\nalipl_a.3D DATAFILE=MODELS\nalipl_d.3D X=0 Y=0 Z=0
#exec  MESH ORIGIN MESH=NaliFruitMesh X=0 Y=0 Z=70 YAW=0
#exec  MESH SEQUENCE MESH=NaliFruitMesh SEQ=All    STARTFRAME=0  NUMFRAMES=29
#exec  MESH SEQUENCE MESH=NaliFruitMesh SEQ=Still  STARTFRAME=0  NUMFRAMES=1
#exec  MESH SEQUENCE MESH=NaliFruitMesh SEQ=Root   STARTFRAME=1  NUMFRAMES=1
#exec  MESH SEQUENCE MESH=NaliFruitMesh SEQ=Grow  STARTFRAME=1  NUMFRAMES=26
#exec  MESH SEQUENCE MESH=NaliFruitMesh SEQ=Waver STARTFRAME=27  NUMFRAMES=2
#exec  TEXTURE IMPORT NAME=JNaliFruit1 FILE=MODELS\Nalipl.PCX GROUP="Skins" FLAGS=2
#exec  MESHMAP SCALE MESHMAP=NaliFruitMesh X=0.15 Y=0.15 Z=0.3
#exec  MESHMAP SETTEXTURE MESHMAP=NaliFruitMesh NUM=1 TEXTURE=JNaliFruit1

var() bool bGrowWhenSeen;

auto state Pickup
{	
	function Timer()
	{
		local actor Victims;
		
		if (!bGrowWhenSeen) {
			HealingAmount += 1;
			SetTimer(1.0,True);
		}
		else if ( PlayerCanSeeMe() )
		{
			PlayAnim('Grow',0.01);
			bGrowWhenSeen=False;				
		}
	}

	function Touch( actor Other )
	{
		local int HealMax;
		local string[70] HealthMessage;
	
		if ( !ValidTouch(Other) ) Return;
	
		if (HealingAmount<1) Return;
	
		HealMax = Pawn(Other).default.Health;
		if (Pawn(Other).Health < HealMax) 
		{
			Pawn(Other).Health += HealingAmount;
			if (Pawn(Other).Health > HealMax) Pawn(Other).Health = HealMax;
			HealthMessage = PickupMessage $ HealingAmount;
			Pawn(Other).ClientMessage(HealthMessage);				
			PlaySound (PickupSound);			
			SetRespawn();
			if ( Level.Game.Difficulty > 1 )
				MakeNoise(0.1 * Level.Game.Difficulty);		
		}
	}
Begin:
	PlayAnim('Root');
	HealingAmount = 0;
	if (!bGrowWhenSeen) 
	{
		Sleep(FRand()*3);
		SetTimer(17,False);
		PlayAnim('Grow',0.018);
		FinishAnim();
		SetTimer(0.0,False);
		LoopAnim('Waver',0.1);
	}
	else SetTimer(2.0,True);
}

