From b878f9fb8651b7b023eeb23dc0e2231d5cf4045d Mon Sep 17 00:00:00 2001 From: mand1nga Date: Sun, 31 May 2009 18:36:34 +0000 Subject: [PATCH] Improved rating of items git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6832 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/havocbot_roles.qc | 79 ++++++++++++++++++----------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/data/qcsrc/server/havocbot_roles.qc b/data/qcsrc/server/havocbot_roles.qc index 1a8b02d18..d2350b097 100644 --- a/data/qcsrc/server/havocbot_roles.qc +++ b/data/qcsrc/server/havocbot_roles.qc @@ -17,19 +17,62 @@ float havocbot_pickupevalfunc(entity item) 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 @@ float havocbot_pickupevalfunc(entity item) } } + // Rate it if (position >= 0 ) { position = WEP_LAST - position; @@ -54,34 +98,7 @@ float havocbot_pickupevalfunc(entity item) } } - 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; }; -- 2.39.2