From 73fa9f23bb4be30b257a4a7fa0e95622aafeb192 Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 18 Apr 2017 18:51:24 +0200 Subject: [PATCH] Waypoint link cost: take into account height difference --- qcsrc/server/bot/default/waypoints.qc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 599a8ad99..93ab1efe7 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -401,6 +401,16 @@ void waypoint_addlink(entity from, entity to) } c = vlen(v2 - v1) / autocvar_sv_maxspeed; + float height = v1.z - v2.z; + if(height > 0 && autocvar_sv_gravity > 0) + { + float height_cost = sqrt(height / autocvar_sv_gravity); + float xydist = vlen((v2 - eZ * v2.z) - (v1 - eZ * v1.z)); + float xydist_cost = xydist / autocvar_sv_maxspeed; + if(max(height_cost, xydist_cost) < c) + c = max(height_cost, xydist_cost); + } + if (from.wp31mincost < c) return; if (from.wp30mincost < c) {from.wp31 = to;from.wp31mincost = c;return;} from.wp31 = from.wp30;from.wp31mincost = from.wp30mincost; if (from.wp29mincost < c) {from.wp30 = to;from.wp30mincost = c;return;} from.wp30 = from.wp29;from.wp30mincost = from.wp29mincost; -- 2.39.2