From fe39b5e14f943d7013278440bbe4e3f491f65983 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 4 Aug 2019 15:25:33 +0200 Subject: [PATCH] Bot waypoints: add command "wpeditor hardwire crosshair" that marks the waypoint at crosshair instead of the nearest waypoint as origin of a new hardwired link --- qcsrc/server/bot/api.qh | 2 +- qcsrc/server/bot/default/waypoints.qc | 27 ++++++++++++++++++++++++--- qcsrc/server/command/cmd.qc | 6 ++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 7a26fae49..630f32052 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -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); diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 837ffcf14..84def4a8f 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -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) diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index e599231c6..ea4cb9022 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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"); -- 2.39.2