//=============================================================================
// ChallengeIndivBotMenu
//=============================================================================
class ChallengeIndivBotMenu expands UnrealIndivBotMenu
	config
	localized;

var class<Weapon> WeaponClasses[16];
var int NumWeaponClasses;

function PostBeginPlay()
{
	local string[64] NextWeapon;
	local class<Weapon> NewWeaponClass;

	Super.PostBeginPlay();
	NextWeapon = GetNextInt("Weapon", 0); 
	NumWeaponClasses = 1; //first choice is none
	while ( (NextWeapon != "") && (NumWeaponClasses < 16) )
	{
		NewWeaponClass = class<weapon>(DynamicLoadObject(NextWeapon, class'Class'));
		if ( NewWeaponClass != None )
		{
			WeaponClasses[NumWeaponClasses] = NewWeaponClass;
			NumWeaponClasses++;
			NextWeapon = GetNextInt("Weapon", NumWeaponClasses);
		}
		else 
		{
			log("Unable to load "$NextWeapon);
			NumWeaponClasses = 16;
		}
	}
}

function bool ProcessLeft()
{
	local int i, n;

	if ( Selection == 7 )
		BotConfig.BotAccuracy[Num] = FMax(-1.0, BotConfig.BotAccuracy[Num] - 0.1);
	else if ( Selection == 8 )
	{
		for ( i=0; i<NumWeaponClasses; i++ )
			if( (WeaponClasses[i]) == BotConfig.FavoriteWeapon[Num] )
			{
				n = i;
				break;
			}

		n--;
		if ( n < 0 )
			n = NumWeaponClasses - 1;

		BotConfig.FavoriteWeapon[Num] = WeaponClasses[n];
	}
	else if ( Selection == 9 )
		BotConfig.CombatStyle[Num] = FMax(-0.5, BotConfig.CombatStyle[Num] - 0.1);
	else if ( Selection == 10 )
		BotConfig.Camping[Num] = FMax(0, BotConfig.Camping[Num] - 0.1);
	else
		return Super.ProcessLeft();

	return true;
}

function bool ProcessRight()
{
	local int i, n;

	if ( Selection == 7 )
		BotConfig.BotAccuracy[Num] = FMin(1.0, BotConfig.BotAccuracy[Num] + 0.1);
	else if ( Selection == 8 )
	{
		for ( i=0; i<NumWeaponClasses; i++ )
			if( (WeaponClasses[i]) == BotConfig.FavoriteWeapon[Num] )
			{
				n = i;
				break;
			}

		n++;
		if ( n == NumWeaponClasses )
			n = 0;

		BotConfig.FavoriteWeapon[Num] = WeaponClasses[n];
	}
	else if ( Selection == 9 )
		BotConfig.CombatStyle[Num] = FMin(0.5, BotConfig.CombatStyle[Num] + 0.1);
	else if ( Selection == 10 )
		BotConfig.Camping[Num] = FMin(1, BotConfig.Camping[Num] + 0.1);
	else
		return Super.ProcessRight();

	return true;}


function DrawMenu(canvas Canvas)
{
	MenuValues[7] = string(BotConfig.BotAccuracy[Num]);
	if ( BotConfig.FavoriteWeapon[Num] != None )
		MenuValues[8] = BotConfig.FavoriteWeapon[Num].Default.ItemName;
	else
		MenuValues[8] = GetItemName(string(BotConfig.FavoriteWeapon[Num]));

	MenuValues[9] = string(BotConfig.CombatStyle[Num] + 0.5);
	MenuValues[10] = string(BotConfig.Camping[Num]);

	Super.DrawMenu(Canvas);
}

defaultproperties
{
     MenuLength=10
     HelpMessage(7)="Aiming accuracy adjustment (-1 to 1).  0 is normal, negative is worse than normal, and postive is better than normal."
     HelpMessage(8)="This Bot's preferred weapon - if none, then no special preference."
     HelpMessage(9)="This Bot's combat style(0 to 1).  Higher values are more aggressive."
     HelpMessage(10)="How likely this bot is to want to camp (0 to 1).  Higher values = more camping."
     MenuList(7)="Accuracy"
     MenuList(8)="Favorite Weapon"
     MenuList(9)="Combat Style"
     MenuList(10)="Camping Rate"
}
