[nexuiz-commits] r6832 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun May 31 14:36:34 EDT 2009


Author: mand1nga
Date: 2009-05-31 14:36:34 -0400 (Sun, 31 May 2009)
New Revision: 6832

Modified:
   trunk/data/qcsrc/server/havocbot_roles.qc
Log:
Improved rating of items

Modified: trunk/data/qcsrc/server/havocbot_roles.qc
===================================================================
--- trunk/data/qcsrc/server/havocbot_roles.qc	2009-05-31 17:32:01 UTC (rev 6831)
+++ trunk/data/qcsrc/server/havocbot_roles.qc	2009-05-31 18:36:34 UTC (rev 6832)
@@ -17,19 +17,62 @@
 	need_cells = self.weapons & ( WEPBIT_HOOK | WEPBIT_HLAC | WEPBIT_MINSTANEX | WEPBIT_NEX | WEPBIT_ELECTRO | WEPBIT_CRYLINK );
 	need_rockets = self.weapons & ( WEPBIT_ROCKET_LAUNCHER | WEPBIT_GRENADE_LAUNCHER | WEPBIT_HAGAR | WEPBIT_SEEKER );
 
+	// Rate ammo items
+	if (item.ammo_shells)
+	if (self.ammo_shells < g_pickup_shells_max && need_cells )
+		rating = rating + max(0, 1 - self.ammo_shells / g_pickup_shells_max);
+
+	if (item.ammo_nails)
+	if (self.ammo_nails < g_pickup_nails_max && need_nails )
+		rating = rating + max(0, 1 - self.ammo_nails / g_pickup_nails_max);
+
+	if (item.ammo_rockets)
+	if (self.ammo_rockets < g_pickup_rockets_max && need_rockets)
+		rating = rating + max(0, 1 - self.ammo_rockets / g_pickup_rockets_max);
+
+	if (item.ammo_cells)
+	if (self.ammo_cells < g_pickup_cells_max && need_cells)
+		rating = rating + max(0, 1 - self.ammo_cells / g_pickup_cells_max);
+
+	// Rate health items (aim to grab half the max capacity)
+	if (item.armorvalue)
+	if (self.armorvalue < item.max_armorvalue * 0.5)
+		rating = rating + max(0, 1 - self.armorvalue / (item.max_armorvalue * 0.5));
+
+	if (item.health)
+	if (self.health < item.max_health * 0.5)
+	{
+		rating = rating + max(0, 1 - self.health / (item.max_health * 0.5));
+	}
+
+	// Rate weapons
 	if( item.weapons )
 	{
+		// See if I have it already
 		if( self.weapons & item.weapons == item.weapons )
-			rating = 0.5 + bound(0, skill / 20, 0.5);
+		{
+			// If I can pick it up
+			if(rating)
+			if not(cvar("g_weapon_stay"))
+			{
+				// Skilled bots will grab more
+				local float divisor = 2;
+				rating += bound(0, skill / (10*divisor), 1/divisor);
+			}
+		}
 		else
-			rating = 1;
+			rating += 1;
 
-		if( bot_custom_weapon )
+		// If custom weapon priorities for bots is enabled rate most wanted weapons higher
+		if( bot_custom_weapon && rating )
 		{
-			for(i = WEP_FIRST; i < WEP_LAST ; ++i){
+			for(i = WEP_FIRST; i < WEP_LAST ; ++i)
+			{
+				// Find weapon
 				if( power2of(i-1) & item.weapons  != item.weapons )
 					continue;
 
+				// Find the highest position on any range
 				position = -1;
 				for(j = 0; j < WEP_LAST ; ++j){
 					if(
@@ -43,6 +86,7 @@
 					}
 				}
 
+				// Rate it
 				if (position >= 0 )
 				{
 					position = WEP_LAST - position;
@@ -54,34 +98,7 @@
 		}
 	}
 
-	if (item.ammo_shells)
-	if (self.ammo_shells < g_pickup_shells_max && need_cells )
-		rating = rating + max(0, 1 - self.ammo_shells / g_pickup_shells_max);
-
-	if (item.ammo_nails)
-	if (self.ammo_nails < g_pickup_nails_max && need_nails )
-		rating = rating + max(0, 1 - self.ammo_nails / g_pickup_nails_max);
-
-	if (item.ammo_rockets)
-	if (self.ammo_rockets < g_pickup_rockets_max && need_rockets)
-		rating = rating + max(0, 1 - self.ammo_rockets / g_pickup_rockets_max);
-
-	if (item.ammo_cells)
-	if (self.ammo_cells < g_pickup_cells_max && need_cells)
-		rating = rating + max(0, 1 - self.ammo_cells / g_pickup_cells_max);
-
-	if (item.armorvalue)
-	if (self.armorvalue < item.max_armorvalue * 0.5)
-		rating = rating + max(0, 1 - self.armorvalue / (item.max_armorvalue * 0.5));
-
-	if (item.health)
-	if (self.health < item.max_health * 0.5)
-	{
-		rating = rating + max(0, 1 - self.health / (item.max_health * 0.5));
-	}
-
 	// TODO: if the item is not recognized then default to item.bot_pickupevalfunc(self, item);
-
 	return base * rating;
 };
 



More information about the nexuiz-commits mailing list