X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ft_items.qc;h=4f6cf459ebc203d20ded5c825e3760b6152d254f;hp=19aa6ba54aa3136348469a5cf5912a0a077849a3;hb=ea49a8838f3ca63f65bf966d6b4b4ec8a4285af8;hpb=b4fbbbce9f643f769b92c35bc3185f31f53d80bc diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 19aa6ba54a..4f6cf459eb 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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) @@ -945,27 +945,44 @@ float weapon_pickupevalfunc(entity player, entity item) // If custom weapon priorities for bots is enabled rate most wanted weapons higher if( bot_custom_weapon && c ) { - // Find the highest position on any range - int position = -1; - 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 - ) + int best_ratio = 0; + int missing = 0; + + // evaluate weapon usefulness in all ranges + for(int list = 0; list < 3; list++) + { + int position = -1; + int wep_count = 0; + int wpn = item.weapon; + for (int j = 0; j < WEP_LAST; ++j) { - position = j; - break; + int list_wpn = 0; + if (list == 0) list_wpn = bot_weapons_far[j]; + else if (list == 1) list_wpn = bot_weapons_mid[j]; + else list_wpn = bot_weapons_close[j]; + + if (weaponsInMap & Weapons_from(list_wpn).m_wepset) // only if available + { + if (list_wpn > 0) + wep_count++; + if (position == -1 && list_wpn == wpn) + position = wep_count; + } + } + if (position == -1) + { + missing++; + position = wep_count; // if missing assume last + } + if (wep_count) + { + if (!best_ratio || position / wep_count < best_ratio) + best_ratio = position / wep_count; } } - // Rate it - if (position >= 0 ) - { - position = WEP_LAST - position; - // item.bot_pickupbasevalue is overwritten here - return (BOT_PICKUP_RATING_LOW + ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * (position / WEP_LAST ))) * c; - } + if (missing < 3 && best_ratio) + return (BOT_PICKUP_RATING_HIGH - ( (BOT_PICKUP_RATING_HIGH - BOT_PICKUP_RATING_LOW) * best_ratio )) * c; } return item.bot_pickupbasevalue * c;