// Default ET Bot Profile
print( "Sample Default Bot Profile" );

// Load some scripts we might use.
ExecScript( "health_goal.gm" );
//ExecScript( "ammo_goal.gm" );
ExecScript( "disguise_goal.gm" );
ExecScript( "mountvehicle_goal.gm" );
ExecScript( "dispenseammo_goal.gm" );
ExecScript( "dispensehealth_goal.gm" );

// FieldOfView is the angle(in degrees) that the bot can 'see' in front of them.
//this.FieldOfView = 90.0;

// ReactionTime is the time delay(in seconds) from when a bot first see's a target, to when
// the bot will begin to react and target them.
this.ReactionTime = 0.0;

// MemorySpan is how long it takes(in seconds) for a bot to consider his memory of someone or something
// 'out of date' and not considered for targeting and such
this.MemorySpan = 2.0;

// AimPersistance is how long the bot will aim in the direction of a target after the target has gone out of view.
// This is useful for keeping the bot aiming toward the target in the event of brief obstructions of their view.
this.AimPersistance = 2.0;

// MaxViewDistance is the maximum distance(in game units) the bot is capable of seeing something.
// This could be tweaked lower for maps with fog or for a closer to human view distance
// Typically this value is best set in the map script in the OnBotJoin callback.
//this.MaxViewDistance = 10000.0;

// These 3 values are aim properties. Care must be taken when tweaking aim properties, since
// improper values can produce aim oscillations and hurt the bots combat abilities.
this.MaxTurnSpeed = 720.0; // degree's / second
this.AimStiffness = 75.0;
this.AimDamping = 10.0;

// Set Weapon & Item properties.

// Vector3 is a 3d x,y,z value.
// Vector2 is a 2d x,y value. When used with AimError, it represents a horizontal(x), and vertical(y) error.

//GENERAL TOYS 1
this.Weapons["AXIS_GRENADE"] =
{
	Bias = 1.0,
	AimOffset = Vector3(0.0, 0.0, 5.0)
};
this.Weapons["ALLIES_GRENADE"] =
{
	Bias = 1.0,
	AimOffset = Vector3(0.0, 0.0, 5.0)
};
this.Weapons["KNIFE"] =
{
	Bias = 0.35,
	AimOffset = Vector3(0.0, 0.0, -10)
};

//SOLDIER TOYS
this.Weapons["MOBILE_MG42"] =
{
	Bias = 1.25,
	AimError = Vector2(5.0, 6.0),
	AimOffset = Vector3(0.0, 0.0, -20.0)
};
this.Weapons["FLAMETHROWER"] =
{
	Bias = 1.20,
	AimError = Vector2(0.0, 6.0),
	AimOffset = Vector3(2.0, 2.0, -10)
};

//GENERAL TOYS 2
this.Weapons["LUGER"] =
{
	Bias = 0.75,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-20)
};

this.Weapons["COLT"] =
{
	Bias = 0.75,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0, -20)
};

this.Weapons["MP40"] =
{
	Bias = 1.25,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["THOMPSON"] =
{
	Bias = 1.25,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["AKIMBO_LUGER"] =
{
	Bias = 0.85,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["AKIMBO_COLT"] =
{
	Bias = 0.85,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

//COVERT OPS TOYS 1
this.Weapons["SILENCED_COLT"] =
{
	Bias = 0.85,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["SILENCED_LUGER"] =
{
	Bias = 0.85,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["AKIMBO_SILENCED_COLT"] =
{
	Bias = 0.85,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["AKIMBO_SILENCED_LUGER"] =
{
	Bias = 0.85,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-15)
};

//ENGINEERS TOYS 1
this.Weapons["GARAND"] =
{
	Bias = 1.25,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-20)
};

this.Weapons["K43"] =
{
	Bias = 1.25,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-20)
};

//COVERT OPS TOYS 2
this.Weapons["KAR98"] =
{
	Bias = 1.0,
	AimError = Vector2(1.0, 1.0),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["CARBINE"] =
{
	Bias = 1.0,
	AimError = Vector2(1.0, 21.0),
	AimOffset = Vector3(0.0, 0.0,-15)
};

this.Weapons["STEN"] =
{
	Bias = 1.25,
	AimError = Vector2(1.0, 1.0),
	AimOffset = Vector3(0.0, 0.0,-10)
};

this.Weapons["FG42"] =
{
	Bias = 1.25,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,-10)
};

//ENGINEERS TOYS2 - GRENADE LAUNCHERS
this.Weapons["M7"] =
{
	Bias = 1.0,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,+10)
};

this.Weapons["GPG40"] =
{
	Bias = 1.0,
	AimError = Vector2(2.5, 2.5),
	AimOffset = Vector3(0.0, 0.0,+10)
};

global saySkills = function()
{
	this.mySkills = table();
	if(this.GetSkills(this.mySkills))
	{
		this.Say("Battle Sense: ", this.mySkills[SKILL.BATTLE_SENSE]);
		this.Say("Engineering: ", this.mySkills[SKILL.ENGINEERING]);
		this.Say("First Aid: ", this.mySkills[SKILL.FIRST_AID]);
		this.Say("Signals: ", this.mySkills[SKILL.SIGNALS]);
		this.Say("Lght Wpns: ", this.mySkills[SKILL.LIGHT_WEAPONS]);
		this.Say("Hvy Wpns: ", this.mySkills[SKILL.HEAVY_WEAPONS]);
		this.Say("Cov Ops: ", this.mySkills[SKILL.COVERTOPS]);
	}
	else
	{
		this.Say("Don't know my skills!");
	}	
};

global watchForProjectiles = function()
{
	while(true)
	{
		
	}
};

// How about a simple script for field ops and medics when they spawn to drop some ammo/health
spawn_func = function(_source, _params)
{
	if(this.WatchForVehicleThread == null)
	{
		this.WatchForVehicleThread  = this:thread(ScriptGoals.mount_vehicle.watchForMountableVehicles);		
	}

	//if(this.watchForProjectileThread == null)
	//{
	//	this.SetScriptControlled(true);
	//	this.watchForProjectileThread  = this:thread(watchForProjectiles);		
	//}
	
	// Sample Usage of health_goal.gm
	//if(this.WatchHealthThread == null)
	//{
	//	this.WatchHealthThread = this:thread(ScriptGoals.watch_health.watchHealthFunc);
	//}

	// Sample usage of disguise_goal.gm
	//if( this.GetClass() == CLASS.COVERTOPS )
	//{
	//	if(this.WatchForCorpsesThread == null)
	//	{
	//		this.WatchForCorpsesThread = this:thread(ScriptGoals.disguise_goal.LookForDisguiseGoalThread);
	//	}		
	//}
	
	
	// Check if this bot is a Medic, and drop some Medkits for a few seconds.
	if(this.GetClass() == CLASS.MEDIC)
	{
		this.DispenseHealthThread  = this:thread(ScriptGoals.dispense_health.DispenseHealth);
	}
	
	// Check if this bot is a Field-Ops, and drop some Ammo for a few seconds.
	if(this.GetClass() == CLASS.FIELDOPS)
	{	
		this.DispenseAmmoThread  = this:thread(ScriptGoals.dispense_ammo.DispenseAmmo);
	}
};

death_func = function(_source, _params)
{
	if( RandRange(0, 100) < 10 )
	{
		this.SayVoice(VOICE.G_GREATSHOT);	
	}	
};

team_chatmsg_func = function(_source, _params)
{
	if(_params.msg == "snipe here")
	{
		if( this.CanSnipe() )
		{
			this.SayVoice(VOICE.AFFIRMATIVE);
			
			sourceEntPos = GetEntPosition(_source);
			sourceEntFacing = GetEntFacing(_source);
			
			if(sourceEntPos && sourceEntFacing)
			{
				this.Snipe(sourceEntPos, sourceEntFacing);
				
				status = block(EVENT.GOAL_SUCCESS, EVENT.GOAL_FAILED);
				if(status == EVENT.GOAL_FAILED)
				{
					this.Say("Can't do it!");
				}
			}
		}		
		return;
	}
	
	if( _params.msg == "skills" )
	{
		this:saySkills();
		return;
	}
		
	// Restrict it to only when waypoint mode is on for now.
	if( IsWaypointViewOn() )
	{
		if(_params.msg == "come")
		{
			this.SayVoice(VOICE.AFFIRMATIVE);
			
			sourceEntPos = GetEntPosition(_source);
			sourceEntFacing = GetEntFacing(_source);
			
			if(sourceEntPos && sourceEntFacing)
			{
				this.SetScriptControlled(true);
				this.GoTo(sourceEntPos, sourceEntFacing);
			}
			
			status = block(EVENT.GOAL_SUCCESS, EVENT.GOAL_FAILED);
			if(status == EVENT.GOAL_SUCCESS)
			{
				this.Say("Now What?");
			}
		}
		else if(_params.msg == "roam")
		{
			this.SayVoice(VOICE.AFFIRMATIVE);
			this.SetScriptControlled(false);
		}
	}
};

// Do this on spawn. Comment this out if you dont want them to do this.
this.Events[EVENT.SPAWNED] = spawn_func;
//this.Events[EVENT.DEATH] = death_func;
this.Events[EVENT.TEAM_CHAT_MSG] = team_chatmsg_func;
difficulties.InitBotDifficultyProperties(this);
