From: terencehill Date: Mon, 30 Jan 2017 16:45:35 +0000 (+0100) Subject: Check if rating a waypoint is better than the enemy himself in navigation_routerating... X-Git-Tag: xonotic-v0.8.2~202^2~22 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=dd874c7f5fcf06e3bb8fb623b20f74161cabf542;p=xonotic%2Fxonotic-data.pk3dir.git Check if rating a waypoint is better than the enemy himself in navigation_routerating, so game modes calling it can benefit from this feature --- diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index dfa2f4540..27710bf08 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -135,7 +135,7 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org ratingscale = ratingscale * 0.00005; // enemies are rated around 20000 already - int t; + float t; FOREACH_CLIENT(IS_PLAYER(it) && bot_shouldattack(this, it), LAMBDA( // TODO: Merge this logic with the bot_shouldattack function if(vdist(it.origin - org, <, 100) || vdist(it.origin - org, >, sradius)) @@ -148,24 +148,6 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org continue; */ - bool rate_wps = false; - if((it.flags & FL_INWATER) || (it.flags & FL_PARTIALGROUND)) - rate_wps = true; - - // not falling - if(!IS_ONGROUND(it)) - { - traceline(it.origin, it.origin + '0 0 -1500', true, NULL); - t = pointcontents(trace_endpos + '0 0 1'); - if(t != CONTENT_SOLID ) - { - if(t == CONTENT_WATER || t == CONTENT_SLIME || t == CONTENT_LAVA) - rate_wps = true; - else if(tracebox_hits_trigger_hurt(it.origin, it.mins, it.maxs, trace_endpos)) - continue; - } - } - t = ((this.health + this.armorvalue) - (it.health + it.armorvalue)) / 150; t = bound(0, 1 + t, 3); if (skill > 3) @@ -176,27 +158,7 @@ void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org t += max(0, 8 - skill) * 0.05; // less skilled bots attack more mindlessly ratingscale *= t; if (ratingscale > 0) - { - if(rate_wps) - { - entity theEnemy = it; - entity best_wp = NULL; - float best_dist = 10000; - IL_EACH(g_waypoints, vdist(it.origin - theEnemy.origin, <, 500) && vdist(it.origin - this.origin, >, 100), - { - float dist = vlen(it.origin - theEnemy.origin); - if (dist < best_dist) - { - best_wp = it; - best_dist = dist; - } - }); - if (best_wp) - navigation_routerating(this, best_wp, ratingscale * BOT_RATING_ENEMY, 2000); - } - else - navigation_routerating(this, it, ratingscale * BOT_RATING_ENEMY, 2000); - } + navigation_routerating(this, it, ratingscale * BOT_RATING_ENEMY, 2000); )); } diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index eb869601a..fd8a521d1 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -643,15 +643,52 @@ void navigation_markroutes_inverted(entity fixed_source_waypoint) // updates the best goal according to a weighted calculation of travel cost and item value of a new proposed item void navigation_routerating(entity this, entity e, float f, float rangebias) { - entity nwp; - vector o; if (!e) return; if(e.blacklisted) return; - o = (e.absmin + e.absmax) * 0.5; + if (IS_PLAYER(e)) + { + bool rate_wps = false; + if((e.flags & FL_INWATER) || (e.flags & FL_PARTIALGROUND)) + rate_wps = true; + + if(!IS_ONGROUND(e)) + { + traceline(e.origin, e.origin + '0 0 -1500', true, NULL); + int t = pointcontents(trace_endpos + '0 0 1'); + if(t != CONTENT_SOLID ) + { + if(t == CONTENT_WATER || t == CONTENT_SLIME || t == CONTENT_LAVA) + rate_wps = true; + else if(tracebox_hits_trigger_hurt(e.origin, e.mins, e.maxs, trace_endpos)) + return; + } + } + + if(rate_wps) + { + entity theEnemy = e; + entity best_wp = NULL; + float best_dist = 10000; + IL_EACH(g_waypoints, vdist(it.origin - theEnemy.origin, <, 500) && vdist(it.origin - this.origin, >, 100), + { + float dist = vlen(it.origin - theEnemy.origin); + if (dist < best_dist) + { + best_wp = it; + best_dist = dist; + } + }); + if (!best_wp) + return; + e = best_wp; + } + } + + vector o = (e.absmin + e.absmax) * 0.5; //print("routerating ", etos(e), " = ", ftos(f), " - ", ftos(rangebias), "\n"); @@ -744,6 +781,7 @@ void navigation_routerating(entity this, entity e, float f, float rangebias) } } + entity nwp; //te_wizspike(e.origin); //bprint(etos(e)); //bprint("\n");