//=============================================================================
// 
//=============================================================================
class DoctorsMedKit extends DeusExPickup;


var bool bDontDestroy;

function tick(float deltatime)
{
	if (Owner != None)
	{
	If (Owner.IsA('_MMRPGPlayer'))
	{
		if ( ! _MMRPGPlayer(Owner).bDoctor )
		{
			Destroy();
		}
	}
	}
	Super.Tick(deltatime);

}


state Activated
{
	function Activate()
	{
	Super.Activate();
	}

	function BeginState()
	{
	Super.BeginState();
	OpenCheck();
	}
Begin:
}

state DeActivated
{
	function BeginState()
	{
	Super.BeginState();
	OpenCheck();
	}
Begin:
}


function OpenCheck()
{
	local Vector StartTrace, EndTrace, HitLocation, HitNormal;
	local Actor HitActor;


	// trace out one foot in front of the pawn
	StartTrace = Owner.Location;
	EndTrace = StartTrace + Vector(Pawn(Owner).ViewRotation) * 64;

	StartTrace.Z += Pawn(Owner).BaseEyeHeight;
	EndTrace.Z += Pawn(Owner).BaseEyeHeight;

	HitActor = Trace(HitLocation, HitNormal, EndTrace, StartTrace);
	if(HitActor != None)
	{
		if (HitActor.IsA('DeusExPlayer'))
		{
			if ( Role == ROLE_Authority )
			{
				if ( DeusExPlayer(HitActor).Health == DeusExPlayer(HitActor).default.Health )
				{
					DeusExPlayer(Owner).ClientMessage("|p3" $DeusExPlayer(HitActor).PlayerReplicationInfo.PlayerName$ " is not injured!");
				}
				if ( DeusExPlayer(HitActor).Health != DeusExPlayer(HitActor).default.Health )
				{
				DeusExPlayer(HitActor).HealPlayer(9000, True);
				DeusExPlayer(HitActor).ClientMessage("|p3You have been healed by Dr. "$DeusExPlayer(Owner).PlayerReplicationInfo.PlayerName);
				DeusExPlayer(Owner).ClientMessage("|p3You have healed "$DeusExPlayer(HitActor).PlayerReplicationInfo.PlayerName);
				_MMRPGPlayer(Owner).numHealed += 1;
				}
			}
		}
	}
	GotoState('UseIt');
}


simulated function bool TestMPBeltSpot(int BeltSpot)
{
   return (BeltSpot == 9);
}

function DropFrom(vector StartLocation)
{
	LifeSpan = 5.0;
	Super.DropFrom(StartLocation);
}


function BecomeItem()
{
	LifeSpan = 0.0;
	Super.BecomeItem();
}

defaultproperties
{
     M_Activated=""
     maxCopies=1
     bCanHaveMultipleCopies=True
     bActivatable=True
     ItemName="Doctor's Medkit"
     PlayerViewOffset=(X=30.000000,Z=-12.000000)
     PlayerViewMesh=LodMesh'DeusExItems.Medkit'
     PickupViewMesh=LodMesh'DeusExItems.Medkit'
     ThirdPersonMesh=LodMesh'DeusExItems.MedKit3rd'
     LandSound=Sound'DeusExSounds.Generic.PlasticHit2'
     Icon=Texture'DeusExUI.Icons.BeltIconMedKit'
     largeIcon=Texture'DeusExUI.Icons.LargeIconMedKit'
     largeIconWidth=39
     largeIconHeight=46
     beltDescription="DR. MED"
     DrawScale=2.000000
     Mesh=LodMesh'DeusExItems.Medkit'
     Skin=Texture'ContenderStuff.Skins.CreditCardTex'
     MultiSkins(0)=Texture'ContenderStuff.Skins.DocMed'
     largeIconWidth=46
     largeIconHeight=28
     Description="hmm."
     CollisionRadius=7.000000
     CollisionHeight=1.000000
}

