]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot waypoints: add command "wpeditor hardwire crosshair" that marks the waypoint...
authorterencehill <piuntn@gmail.com>
Sun, 4 Aug 2019 13:25:33 +0000 (15:25 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 4 Aug 2019 13:25:33 +0000 (15:25 +0200)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/command/cmd.qc

index 7a26fae49457ba7513d6a526e8e23bee70ff2e5a..630f3205297b238c41f01e372ec7ee3ce6f20b38 100644 (file)
@@ -134,7 +134,7 @@ void waypoint_spawnforteleporter_wz(entity e, entity tracetest_ent);
 void waypoint_spawn_fromeditor(entity pl, bool at_crosshair, bool is_jump_wp, bool is_crouch_wp, bool is_support_wp);
 entity waypoint_spawn(vector m1, vector m2, float f);
 void waypoint_unreachable(entity pl);
-void waypoint_start_hardwiredlink(entity pl);
+void waypoint_start_hardwiredlink(entity pl, bool at_crosshair);
 
 void waypoint_getSymmetricalOrigin_cmd(entity caller, bool save, int arg_idx);
 void waypoint_getSymmetricalAxis_cmd(entity caller, bool save, int arg_idx);
index 837ffcf14b6dc3f2cf2622359d2016b5d0c44e03..84def4a8fbd099f9c6d0809f7e7cce4295271f10 100644 (file)
@@ -505,19 +505,40 @@ void waypoint_clear_start_wp_globals(entity pl, bool warn)
 }
 
 void crosshair_trace_waypoints(entity pl);
-void waypoint_start_hardwiredlink(entity pl)
+void waypoint_start_hardwiredlink(entity pl, bool at_crosshair)
 {
        entity wp = pl.nearestwaypoint;
-       if ((!start_wp_is_spawned || start_wp_is_hardwired) && wp && !(wp.wpflags & WPFLAGMASK_NORELINK))
+       if (at_crosshair)
+       {
+               crosshair_trace_waypoints(pl);
+               wp = trace_ent;
+       }
+       string err = "";
+       if (start_wp_is_spawned && !start_wp_is_hardwired)
+               err = "can't hardwire while in the process of creating a special link";
+       else if (!wp)
+       {
+               if (at_crosshair)
+                       err = "couldn't find any waypoint at crosshair";
+               else
+                       err = "couldn't find any waypoint nearby";
+       }
+       else if (wp.wpflags & WPFLAGMASK_NORELINK)
+               err = "can't hardwire a waypoint with special links";
+
+       if (err == "")
        {
                start_wp_is_hardwired = true;
                start_wp_is_spawned = true;
                start_wp_origin = wp.origin;
                pl.wp_locked = wp;
-               LOG_INFOF("^x80fNearest waypoint %s marked as hardwired link origin.\n", vtos(wp.origin));
+               LOG_INFOF("^x80fWaypoint %s marked as hardwired link origin.\n", vtos(wp.origin));
        }
        else
+       {
                start_wp_is_hardwired = false;
+               LOG_INFO("Error: ", err, "\n");
+       }
 }
 
 void waypoint_spawn_fromeditor(entity pl, bool at_crosshair, bool is_jump_wp, bool is_crouch_wp, bool is_support_wp)
index e599231c6586d80acb81c44c15c2ec18b956f53e..ea4cb9022630f463e220eea1808800a640f53203 100644 (file)
@@ -201,7 +201,8 @@ void ClientCommand_wpeditor(entity caller, int request, int argc)
                                }
                                else if (argv(1) == "hardwire")
                                {
-                                       waypoint_start_hardwiredlink(caller);
+                                       string s = argv(2);
+                                       waypoint_start_hardwiredlink(caller, (s == "crosshair"));
                                        return;
                                }
                                else if (argv(1) == "unreachable")
@@ -252,11 +253,12 @@ void ClientCommand_wpeditor(entity caller, int request, int argc)
                        sprint(caller, "   ^5unreachable^7: useful to reveal waypoints and items unreachable from the current position and spawnpoints without a nearest waypoint\n");
                        sprint(caller, "   ^5saveall^7: saves all waypoints and links to file\n");
                        sprint(caller, "   ^5relinkall^7: relink all waypoints as if they were respawned\n");
-                       sprint(caller, "   ^5spawn crosshair^7: spawns a waypoint at crosshair's position (useful to spawn custom jumppad waypoints (spawn another waypoint to create destination))\n");
+                       sprint(caller, "   ^5spawn crosshair^7: spawns a waypoint at crosshair's position (in general useful to create special and hardwired links with ease from existing waypoints, in particular it's the only way to create custom jumppad waypoints (spawn another waypoint to create destination))\n");
                        sprint(caller, "   ^5spawn jump^7: spawns a jump waypoint (spawn another waypoint to create destination)\n");
                        sprint(caller, "   ^5spawn crouch^7: spawns a crouch waypoint\n");
                        sprint(caller, "   ^5spawn support^7: spawns a support waypoint (spawn another waypoint to create destination from which all incoming links are removed), useful to replace links to preblematic jumppad/teleport waypoints\n");
                        sprint(caller, "   ^5hardwire^7: marks the nearest waypoint as origin of a new hardwired link (spawn another waypoint over an existing one to create destination)\n");
+                       sprint(caller, "   ^5hardwire crosshair^7: marks the waypoint at crosshair instead of the nearest waypoint\n");
                        sprint(caller, "   ^5symorigin get|set\n");
                        sprint(caller, "   ^5symorigin get|set p1 p2 ... pX\n");
                        sprint(caller, "   ^5symaxis get|set p1 p2\n");