]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/t_items.qc
Custom weapon priorities for bots: improve rating scale calculation by excluding...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / t_items.qc
index 2f1a4c3aa6b7e4087a9de95a8136ade2204d54a5..6ee8869e45ce33b4c4ec555fd3a45970d7a4f380 100644 (file)
@@ -926,7 +926,7 @@ float weapon_pickupevalfunc(entity player, entity item)
        float c;
 
        // See if I have it already
-       if(item.weapons & ~player.weapons)
+       if(!(item.weapons & ~player.weapons))
        {
                // If I can pick it up
                if(!item.spawnshieldtime)
@@ -947,24 +947,22 @@ float weapon_pickupevalfunc(entity player, entity item)
        {
                // Find the highest position on any range
                int position = -1;
+               int wep_count = 0;
+               int wpn = item.weapon;
                for (int j = 0; j < WEP_LAST ; ++j){
-                       if(
-                                       bot_weapons_far[j] == item.weapon ||
-                                       bot_weapons_mid[j] == item.weapon ||
-                                       bot_weapons_close[j] == item.weapon
-                         )
-                       {
-                               position = j;
-                               break;
-                       }
+                       if (position == -1)
+                       if (bot_weapons_far[j] == wpn || bot_weapons_mid[j] == wpn || bot_weapons_close[j] == wpn)
+                               position = wep_count;
+                       if (bot_weapons_far[j] > 0 || bot_weapons_mid[j] > 0 || bot_weapons_close[j] > 0)
+                               wep_count++;
                }
 
                // Rate it
                if (position >= 0 )
                {
-                       position = WEP_LAST - position;
+                       position = wep_count - position;
                        // item.bot_pickupbasevalue is overwritten here
-                       return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c;
+                       return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / wep_count) )) * c;
                }
        }
 
@@ -1346,17 +1344,17 @@ spawnfunc(item_armor_big)
                this.max_armorvalue = g_pickup_armorbig_max;
        if(!this.pickup_anyway)
                this.pickup_anyway = g_pickup_armorbig_anyway;
-       StartItem(this, ITEM_ArmorLarge);
+       StartItem(this, ITEM_ArmorBig);
 }
 
-spawnfunc(item_armor_large)
+spawnfunc(item_armor_mega)
 {
        if(!this.armorvalue)
-               this.armorvalue = g_pickup_armorlarge;
+               this.armorvalue = g_pickup_armormega;
        if(!this.max_armorvalue)
-               this.max_armorvalue = g_pickup_armorlarge_max;
+               this.max_armorvalue = g_pickup_armormega_max;
        if(!this.pickup_anyway)
-               this.pickup_anyway = g_pickup_armorlarge_anyway;
+               this.pickup_anyway = g_pickup_armormega_anyway;
        StartItem(this, ITEM_ArmorMega);
 }
 
@@ -1382,15 +1380,15 @@ spawnfunc(item_health_medium)
     StartItem(this, ITEM_HealthMedium);
 }
 
-spawnfunc(item_health_large)
+spawnfunc(item_health_big)
 {
        if(!this.max_health)
-               this.max_health = g_pickup_healthlarge_max;
+               this.max_health = g_pickup_healthbig_max;
        if(!this.health)
-               this.health = g_pickup_healthlarge;
+               this.health = g_pickup_healthbig;
        if(!this.pickup_anyway)
-               this.pickup_anyway = g_pickup_healthlarge_anyway;
-       StartItem(this, ITEM_HealthLarge);
+               this.pickup_anyway = g_pickup_healthbig_anyway;
+       StartItem(this, ITEM_HealthBig);
 }
 
 spawnfunc(item_health_mega)
@@ -1406,9 +1404,11 @@ spawnfunc(item_health_mega)
 
 // support old misnamed entities
 spawnfunc(item_armor1) { spawnfunc_item_armor_small(this); }  // FIXME: in Quake this is green armor, in Xonotic maps it is an armor shard
-spawnfunc(item_armor25) { spawnfunc_item_armor_large(this); }
+spawnfunc(item_armor25) { spawnfunc_item_armor_mega(this); }
+spawnfunc(item_armor_large) { spawnfunc_item_armor_mega(this); }
 spawnfunc(item_health1) { spawnfunc_item_health_small(this); }
 spawnfunc(item_health25) { spawnfunc_item_health_medium(this); }
+spawnfunc(item_health_large) { spawnfunc_item_health_big(this); }
 spawnfunc(item_health100) { spawnfunc_item_health_mega(this); }
 
 spawnfunc(item_strength)