]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/bot_waypoints' into martin-t/master
authorMartin Taibr <taibr.martin@gmail.com>
Sun, 3 Sep 2017 19:14:40 +0000 (21:14 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Sun, 3 Sep 2017 19:14:40 +0000 (21:14 +0200)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/bot/default/waypoints.qh
qcsrc/server/bot/null/bot_null.qc
qcsrc/server/sv_main.qc

index 5c41731ddfba7279398800ae89abb2d50ff97335..27651bf8135c7d7eca91b7b948bc42586c9c9fc3 100644 (file)
@@ -98,7 +98,7 @@ void waypoint_schedulerelink(entity wp);
 void waypoint_spawnforitem(entity e);
 void waypoint_spawnforitem_force(entity e, vector org);
 void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent);
-void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent);
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, entity tracetest_ent);
 void waypoint_spawn_fromeditor(entity pl);
 entity waypoint_spawn(vector m1, vector m2, float f);
 void waypoint_unreachable(entity pl);
index 0777f2cb63a457675fdc92ce4471d9b76b212232..64e960ff760f975a3ac36a9c7204ac6648978a82 100644 (file)
@@ -766,6 +766,12 @@ entity navigation_findnearestwaypoint_withdist_except(entity ent, float walkfrom
        vector v = '0 0 0', v2 = '0 0 0';
        float v2_height = 0;
 
+       if(ent.size && !IS_PLAYER(ent))
+       {
+               org += 0.5 * (ent.mins + ent.maxs);
+               org.z = ent.origin.z + ent.mins.z - PL_MIN_CONST.z; // player height
+       }
+
        if(!autocvar_g_waypointeditor && walkfromwp && !ent.navigation_dynamicgoal)
        {
                waypoint_clearlinks(ent); // initialize wpXXmincost fields
index f4c56027ed5eec73843baabc6922991147249f1a..c3b67a378fef08ac1a7823ceeb7064f049ef86a3 100644 (file)
@@ -710,8 +710,8 @@ bool waypoint_load_links()
                {
                        if(substring(s, 0, 2) == "//")
                        {
-                               if(substring(s, 2, 8) == "VERSION ")
-                                       ver = stof(substring(s, 10, -1));
+                               if(substring(s, 2, 17) == "WAYPOINT_VERSION ")
+                                       ver = stof(substring(s, 19, -1));
                                continue;
                        }
                        else
@@ -944,7 +944,7 @@ void waypoint_save_links()
                return;
        }
 
-       fputs(file, strcat("//", "VERSION ", ftos_decimals(WAYPOINT_VERSION, 2), "\n"));
+       fputs(file, strcat("//", "WAYPOINT_VERSION ", ftos_decimals(WAYPOINT_VERSION, 2), "\n"));
 
        int c = 0;
        IL_EACH(g_waypoints, true,
@@ -984,7 +984,7 @@ void waypoint_saveall()
 
        // add 3 comments to not break compatibility with older Xonotic versions
        // (they are read as a waypoint with origin '0 0 0' and flag 0 though)
-       fputs(file, strcat("//", "VERSION ", ftos_decimals(WAYPOINT_VERSION, 2), "\n"));
+       fputs(file, strcat("//", "WAYPOINT_VERSION ", ftos_decimals(WAYPOINT_VERSION, 2), "\n"));
        fputs(file, strcat("//", "\n"));
        fputs(file, strcat("//", "\n"));
 
@@ -1037,8 +1037,8 @@ float waypoint_loadall()
                {
                        if(substring(s, 0, 2) == "//")
                        {
-                               if(substring(s, 2, 8) == "VERSION ")
-                                       ver = stof(substring(s, 10, -1));
+                               if(substring(s, 2, 17) == "WAYPOINT_VERSION ")
+                                       ver = stof(substring(s, 19, -1));
                                continue;
                        }
                        else
@@ -1069,9 +1069,16 @@ float waypoint_loadall()
        return cwp + cwb;
 }
 
-vector waypoint_fixorigin(vector position, entity tracetest_ent)
+#define waypoint_fixorigin(position, tracetest_ent) \
+       waypoint_fixorigin_down_dir(position, tracetest_ent, '0 0 -1')
+
+vector waypoint_fixorigin_down_dir(vector position, entity tracetest_ent, vector down_dir)
 {
-       tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z), PL_MIN_CONST, PL_MAX_CONST, position + '0 0 -512', MOVE_NOMONSTERS, tracetest_ent);
+       tracebox(position + '0 0 1', PL_MIN_CONST, PL_MAX_CONST, position + down_dir * 3000, MOVE_NOMONSTERS, tracetest_ent);
+       if(trace_startsolid)
+               tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z / 2), PL_MIN_CONST, PL_MAX_CONST, position + down_dir * 3000, MOVE_NOMONSTERS, tracetest_ent);
+       if(trace_startsolid)
+               tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z), PL_MIN_CONST, PL_MAX_CONST, position + down_dir * 3000, MOVE_NOMONSTERS, tracetest_ent);
        if(trace_fraction < 1)
                position = trace_endpos;
        return position;
@@ -1129,10 +1136,18 @@ void waypoint_spawnforteleporter_boxes(entity e, int teleport_flag, vector org1,
        e.nearestwaypointtimeout = -1;
 }
 
-void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent)
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, entity tracetest_ent)
 {
-       org = waypoint_fixorigin(org, tracetest_ent);
-       destination = waypoint_fixorigin(destination, tracetest_ent);
+       // warpzones with oblique warp plane rely on down_dir to snap waypoints
+       // to the ground without leaving the warp plane
+       // warpzones with horizontal warp plane (down_dir.x == -1) generate
+       // destination waypoint snapped to the ground (leaving warpzone), source
+       // waypoint in the center of the warp plane
+       if(down_dir.x != -1)
+               org = waypoint_fixorigin_down_dir(org, tracetest_ent, down_dir);
+       if(down_dir.x == -1)
+               down_dir = '0 0 -1';
+       destination = waypoint_fixorigin_down_dir(destination, tracetest_ent, down_dir);
        waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, org, org, destination, destination, timetaken);
 }
 
index d3cb3a4e311fffcc5c3fe52ed57f4a16087d1be1..bea11e9299986ce180765f09a520e37c8295f6de 100644 (file)
@@ -57,7 +57,7 @@ void waypoint_saveall();
 void waypoint_spawnforitem_force(entity e, vector org);
 void waypoint_spawnforitem(entity e);
 void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent);
-void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent);
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, entity tracetest_ent);
 void botframe_showwaypointlinks();
 
 float waypoint_loadall();
@@ -72,6 +72,6 @@ entity waypoint_spawnpersonal(entity this, vector position);
 
 void waypoint_unreachable(entity pl);
 
-vector waypoint_fixorigin(vector position, entity tracetest_ent);
+vector waypoint_fixorigin_down_dir(vector position, entity tracetest_ent, vector down_dir);
 
 void botframe_autowaypoints();
index ddf7abd9de70b9c3ea95063dc7dff71895122ce5..f8738f80fb5cdc855eda4bd6bb9ad351ddf9d5cb 100644 (file)
@@ -38,7 +38,7 @@ void waypoint_schedulerelink(entity wp) { }
 void waypoint_spawnforitem(entity e) { }
 void waypoint_spawnforitem_force(entity e, vector org) { }
 void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent) { }
-void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, entity tracetest_ent) { }
+void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, float timetaken, vector down_dir, entity tracetest_ent) { }
 void waypoint_spawn_fromeditor(entity pl) { }
 entity waypoint_spawn(vector m1, vector m2, float f) { return NULL; }
 #endif
index f0f18b826bdae4d4409a8559f87dd2587c63e75d..34f3cdc21b63e6d405b5a9306fe432c8c78bb0ba 100644 (file)
@@ -380,7 +380,7 @@ void WarpZone_PostInitialize_Callback()
                dst = (e.enemy.absmin + e.enemy.absmax) * 0.5;
                makevectors(e.enemy.warpzone_angles);
                dst = dst + ((e.enemy.warpzone_origin - dst) * v_forward) * v_forward - 16 * v_right;
-               waypoint_spawnforteleporter_wz(e, src, dst, 0, tracetest_ent);
+               waypoint_spawnforteleporter_wz(e, src, dst, 0, -v_up, tracetest_ent);
        }
        delete(tracetest_ent);
 }