//=============================================================================
//
//=============================================================================
class RPGNursejob extends HumanCivilian;

var _MMRPGPlayer talkto;
var int talked;
var bool bTrade;

function Frob(Actor Frobber, Inventory frobWith)
{
	local MMRPGCreditCard Cred;
	local _MMRPGPlayer Player;
	local keydummy2 hmm2;

	If (Frobber.IsA('DeusExPlayer'))
	{
		If(talked != 0)
		{
			if(bTrade)
			{
				Super(Actor).Frob(Frobber, Frobwith);
			}
			if(!bTrade)
			{
				_MMRPGPlayer(Frobber).ReceiveMessage("Someone is already talking to this person!");
				return;
			}
		}
	}

	Player = _MMRPGPlayer(Frobber);
	talkto = Player;

	Player.bInConv = True;
		LookAtActor(Frobber, True, True, False);
	talked = 1;

	if (_MMRPGPlayer(Frobber).bDoctor)
	{
		If ( ! CheckDocMed() )
		{

			foreach AllActors(class'keydummy2', hmm2)
			{
					if (Player.HandleItemPickup(hmm2, True) == False)
					{
						talkto.ReceiveMessage("NURSE: Make some room for a Doctor's Medkit.");
						Player.bInConv = False;
						talked = 0;
						return;
					}
			}

			foreach AllActors(class'keydummy2', hmm2)
			{
					if (Player.HandleItemPickup(hmm2, True) == True)
					{
						Player.ReceiveMessage("NURSE: Have another Doctor's Medkit");
						bTrade=True;
						Player.SpawnItemz(Class'DoctorsMedkit');
						Player.bInConv = False;
						bTrade=False;
						talked = 0;
						return;
					}
			}
		}
		if (talkto.numHealed == 1)
		{
			Player.ReceiveMessage(""$Player.PlayerReplicationInfo.PlayerName$": I have healed "$talkto.numHealed$" person.");
		}
		else
		{
			Player.ReceiveMessage(""$Player.PlayerReplicationInfo.PlayerName$": I have healed "$talkto.numHealed$" people.");
		}
		talked = 9;
		SetTimer(2.9,False);
		return;
	}

	if (_MMRPGPlayer(Frobber).bHasJob)
	{
		Player.ReceiveMessage("NURSE: You already have a job; you are a "$Player.JobName$"");
		Player.bInConv = False;
		talked = 0;
		return;
	}

	if (!_MMRPGPlayer(Frobber).bDoctor)
	{
		Player.ReceiveMessage(""$Player.PlayerReplicationInfo.PlayerName$": Hello I would like a job at the clinic please.");
		talked = 1;
		SetTimer(1.9,False);
		return;
	}
}

function bool CheckDocMed()
{
	local DoctorsMedkit med;
	foreach allactors(class'DoctorsMedkit', med)
	{
		if (med.Owner == talkto)
		{
			return true;
		}
	}
	return false;
}

function Timer()
{
	local int wages;
	local MMRPGCreditCard cred;
	local keydummy2 hmm2;

	if (talked == 1)
	{
		if ( talkto.CheckMedSkill() )
		{
			talkto.ReceiveMessage("NURSE: You appear to be trained enough, I will see if there are any vacancies.");
			talked = 2;
			SetTimer(3.7,False);
			return;
		}
		else if (! talkto.CheckMedSkill() )
		{
			talkto.ReceiveMessage("NURSE: Why don't you improve your medical skill first?");
			talkto.bInConv = False;
			talked = 0;
			return;
		}
	}

	else if (talked == 2)
	{
		talkto.ReceiveMessage("NURSE: Yes, you can start work immediately.");
		talked = 3;
		SetTimer(2.6,False);
		return;
	}
	else if (talked == 3)
	{
		foreach AllActors(class'keydummy2', hmm2)
		{
				if (talkto.HandleItemPickup(hmm2, True) == False)
				{
					talkto.ReceiveMessage("NURSE: Make some room for a Doctor's Medkit.");
					talkto.bInConv = False;
					talked = 0;
					return;
				}

		}

		foreach AllActors(class'keydummy2', hmm2)
		{
				if (talkto.HandleItemPickup(hmm2, True) == True)
				{
					talkto.ReceiveMessage("NURSE: Take this Doctor's Medkit, and heal anyone who is injured.");
					bTrade=True;
					talkto.SpawnItemz(Class'DoctorsMedkit');
					talkto.bDoctor = True;
					talkto.bHasJob = True;
					talkto.JobName = "Doctor";
					bTrade=False;
					talked = 4;
					SetTimer(4.3,False);
					return;
				}

		}
	}
	else if (talked == 4)
	{
		talkto.ReceiveMessage(""$talkto.PlayerReplicationInfo.PlayerName$": OK I got it covered, but what about the pay?");
		talked = 5;
		SetTimer(3.0,False);
		return;
	}
	else if (talked == 5)
	{
		talkto.ReceiveMessage("NURSE: Come back here after you have healed someone to collect your wages.");
		talkto.bInConv = False;
		talked = 0;
		return;
	}
	else if (talked == 9)
	{
		if (talkto.numHealed == 1)
		{
			wages = ( talkto.numHealed * 20 );
			Cred = talkto.CreditCard;
			talkto.ReceiveMessage("NURSE: "$talkto.numHealed$" person, 20c each, that's "$wages$" credits!");
			talkto.numHealed = 0;
			Cred.CreditAmount += wages;
			talkto.bInConv = False;
			talked = 0;
			return;
		}
		else
		{
			wages = ( talkto.numHealed * 20 );
			Cred = talkto.CreditCard;
			talkto.ReceiveMessage("NURSE: "$talkto.numHealed$" people, 20c each, that's "$wages$" credits!");
			talkto.numHealed = 0;
			Cred.CreditAmount += wages;
			talkto.bInConv = False;
			talked = 0;
			return;
		}
	}
}

defaultproperties
{
     bfearAlarm=False
     bFearCarcass=False
     bFearDistress=False
     bFearShot=False
     bFearIndirectInjury=False
     Orders=Standing
     bInvincible=True
     bHateShot=False
     bHateInjury=False
     bReactPresence=False
     bEmitDistress=False
     MinHealth=0.000000
     CarcassType=Class'DeusEx.NurseCarcass'
     WalkingSpeed=0.320000
     BaseAssHeight=-18.000000
     walkAnimMult=0.650000
     bIsFemale=True
     GroundSpeed=120.000000
     BaseEyeHeight=38.000000
     Mesh=LodMesh'DeusExCharacters.GFM_SuitSkirt'
     MultiSkins(0)=Texture'DeusExCharacters.Skins.NurseTex0'
     MultiSkins(1)=Texture'DeusExCharacters.Skins.NurseTex0'
     MultiSkins(2)=Texture'DeusExCharacters.Skins.NurseTex0'
     MultiSkins(3)=Texture'DeusExCharacters.Skins.LegsTex1'
     MultiSkins(4)=Texture'DeusExCharacters.Skins.NurseTex1'
     MultiSkins(5)=Texture'DeusExCharacters.Skins.NurseTex1'
     MultiSkins(6)=Texture'DeusExItems.Skins.GrayMaskTex'
     MultiSkins(7)=Texture'DeusExItems.Skins.BlackMaskTex'
     CollisionRadius=20.000000
     CollisionHeight=43.000000
     BindName="Nurse"
     FamiliarName="Nurse"
     UnfamiliarName="Nurse"
}
