]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/waypoints.qc
Fix waypoint removal (08 and 09 were considered as 0 in waypoint_removelink)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / waypoints.qc
index 8ce5d2d38b38228eebc3b4ad549687f07e420d4a..182b1b3d395d688b4bc39220247e0ed6afbd9e90 100644 (file)
@@ -363,16 +363,16 @@ void waypoint_removelink(entity from, entity to)
        switch (waypoint_getlinknum(from, to))
        {
                // fallthrough all the way
-               case 00: from.wp00 = from.wp01; from.wp00mincost = from.wp01mincost;
-               case 01: from.wp01 = from.wp02; from.wp01mincost = from.wp02mincost;
-               case 02: from.wp02 = from.wp03; from.wp02mincost = from.wp03mincost;
-               case 03: from.wp03 = from.wp04; from.wp03mincost = from.wp04mincost;
-               case 04: from.wp04 = from.wp05; from.wp04mincost = from.wp05mincost;
-               case 05: from.wp05 = from.wp06; from.wp05mincost = from.wp06mincost;
-               case 06: from.wp06 = from.wp07; from.wp06mincost = from.wp07mincost;
-               case 07: from.wp07 = from.wp08; from.wp07mincost = from.wp08mincost;
-               case 08: from.wp08 = from.wp09; from.wp08mincost = from.wp09mincost;
-               case 09: from.wp09 = from.wp10; from.wp09mincost = from.wp10mincost;
+               case  0: from.wp00 = from.wp01; from.wp00mincost = from.wp01mincost;
+               case  1: from.wp01 = from.wp02; from.wp01mincost = from.wp02mincost;
+               case  2: from.wp02 = from.wp03; from.wp02mincost = from.wp03mincost;
+               case  3: from.wp03 = from.wp04; from.wp03mincost = from.wp04mincost;
+               case  4: from.wp04 = from.wp05; from.wp04mincost = from.wp05mincost;
+               case  5: from.wp05 = from.wp06; from.wp05mincost = from.wp06mincost;
+               case  6: from.wp06 = from.wp07; from.wp06mincost = from.wp07mincost;
+               case  7: from.wp07 = from.wp08; from.wp07mincost = from.wp08mincost;
+               case  8: from.wp08 = from.wp09; from.wp08mincost = from.wp09mincost;
+               case  9: from.wp09 = from.wp10; from.wp09mincost = from.wp10mincost;
                case 10: from.wp10 = from.wp11; from.wp10mincost = from.wp11mincost;
                case 11: from.wp11 = from.wp12; from.wp11mincost = from.wp12mincost;
                case 12: from.wp12 = from.wp13; from.wp12mincost = from.wp13mincost;
@@ -403,9 +403,9 @@ void waypoint_removelink(entity from, entity to)
 
 int waypoint_getlinknum(entity from, entity to)
 {
-       if (from.wp00 == to) return 00; if (from.wp01 == to) return 01; if (from.wp02 == to) return 02; if (from.wp03 == to) return 03;
-       if (from.wp04 == to) return 04; if (from.wp05 == to) return 05; if (from.wp06 == to) return 06; if (from.wp07 == to) return 07;
-       if (from.wp08 == to) return 08; if (from.wp09 == to) return 09; if (from.wp10 == to) return 10; if (from.wp11 == to) return 11;
+       if (from.wp00 == to) return  0; if (from.wp01 == to) return  1; if (from.wp02 == to) return  2; if (from.wp03 == to) return  3;
+       if (from.wp04 == to) return  4; if (from.wp05 == to) return  5; if (from.wp06 == to) return  6; if (from.wp07 == to) return  7;
+       if (from.wp08 == to) return  8; if (from.wp09 == to) return  9; if (from.wp10 == to) return 10; if (from.wp11 == to) return 11;
        if (from.wp12 == to) return 12; if (from.wp13 == to) return 13; if (from.wp14 == to) return 14; if (from.wp15 == to) return 15;
        if (from.wp16 == to) return 16; if (from.wp17 == to) return 17; if (from.wp18 == to) return 18; if (from.wp19 == to) return 19;
        if (from.wp20 == to) return 20; if (from.wp21 == to) return 21; if (from.wp22 == to) return 22; if (from.wp23 == to) return 23;
@@ -1235,11 +1235,12 @@ float waypoint_loadall()
 
 vector waypoint_fixorigin_down_dir(vector position, entity tracetest_ent, vector down_dir)
 {
-       tracebox(position + '0 0 1', PL_MIN_CONST, PL_MAX_CONST, position + down_dir * 3000, MOVE_NOMONSTERS, tracetest_ent);
+       vector endpos = position + down_dir * 3000;
+       tracebox(position + '0 0 1', PL_MIN_CONST, PL_MAX_CONST, endpos, 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);
+               tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z / 2), PL_MIN_CONST, PL_MAX_CONST, endpos, 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);
+               tracebox(position + '0 0 1' * (1 - PL_MIN_CONST.z), PL_MIN_CONST, PL_MAX_CONST, endpos, MOVE_NOMONSTERS, tracetest_ent);
        if(trace_fraction < 1)
                position = trace_endpos;
        return position;
@@ -1321,14 +1322,18 @@ void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent)
        dest += ((e.enemy.warpzone_origin - dest) * v_forward) * v_forward - 16 * v_right;
        vector down_dir_dest = -v_up;
 
+       int extra_flag = 0;
        // don't snap to the ground waypoints for source warpzones pointing downwards
        if (src_angle != 90)
        {
                src = waypoint_fixorigin_down_dir(src, tracetest_ent, down_dir_src);
                dest = waypoint_fixorigin_down_dir(dest, tracetest_ent, down_dir_dest);
+               // oblique warpzones need a jump otherwise bots gets stuck
+               if (src_angle != 0)
+                       extra_flag = WAYPOINTFLAG_JUMP;
        }
 
-       waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT, src, src, dest, dest, 0);
+       waypoint_spawnforteleporter_boxes(e, WAYPOINTFLAG_TELEPORT | extra_flag, src, src, dest, dest, 0);
 }
 
 void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent)