// Default ET Bot Profile

// this script is executed every time bot changes class,
//  return immediately if this bot is already initialized
if (this.ClassPrimaryWeaponChoice) { return; }

// 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 = 1.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 = 4000.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;

// optionally set a fixed skill level for this bot
// this will ensure that any global difficulty changes will not effect it
// default difficulty levels are between 1 and 6 with 1 being the easiest
// this.ProfileSkill = 3;

// optionally set a moveskill for the bot. this will effect how they react when in combat (i.e. strafing and crouching)
// setting this will over-ride any value set in goal_combatmovement
// 0 - off, 1 - easy, 2 - medium, 3 - hard, 4 - random
// this.moveskill = 3;

if (this.Name == "testbot") {
	this.AddScriptGoal("TestBot");
}

//////////////////////////////////////////////////////////////////////////
// Utility Callbacks
this.SelectTeam = function()
{
	return null;
};

this.SelectClass = function()
{
	return null;
};

// cs: moved from global so it can be called externally and be unique per bot
this.ClassPrimaryWeaponChoice = function(excludeweapons)
{
	myclass = this.GetClass();
	weaponChoice = 0;
	wpns = WeaponTable.GetPrimaryWeapons(this.GetTeam(), myclass);

	// copy only usable weapons
	if (wpns)
	{
		tmp = table();
		foreach ( weapon and avail in wpns ) {
			if ( avail && (!excludeweapons || !excludeweapons[weapon]) ) {
				tmp[ tableCount(tmp) ] = weapon;
			}
		}

		tc = tableCount(tmp);
		if ( tc > 0 ) {
			if ( _PreferredWeapon && _PreferredWeapon[ this.Name ] ) {
				ind = Util.GetTableKey(tmp, _PreferredWeapon[ this.Name ]);
				if ( typeId(ind) == 1 ) {
					weaponChoice = tmp[ind];
				}
			}

			if ( !weaponChoice ) {
				weaponChoice = Util.GetRandomTableValue(tmp);
			}
		}
	}

	return ToInt(weaponChoice);
};

// cs: moved from global so it can be called externally and be unique per bot
this.ClassSecondaryWeaponChoice = function(excludeweapons)
{
	return null;
};

this.SelectWeapons = function()
{
	Primary = this.ClassPrimaryWeaponChoice();
	Secondary = this.ClassSecondaryWeaponChoice();

	if ( Primary )
		{ this.ChangePrimaryWeapon( Primary ); }

	if ( Secondary )
		{ this.ChangeSecondaryWeapon( Secondary ); }
};

//////////////////////////////////////////////////////////////////////////
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!");
	}
};
