From: terencehill Date: Sun, 12 May 2019 00:46:56 +0000 (+0200) Subject: WIP: Bot waypoints: add new command "wpeditor spawn crosshair" that spawn a waypoint... X-Git-Tag: xonotic-v0.8.5~1356^2~39 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b3f50407c94a92bef5c50cb9e1c3ffec949fc67b;p=xonotic%2Fxonotic-data.pk3dir.git WIP: Bot waypoints: add new command "wpeditor spawn crosshair" that spawn a waypoint at crosshair --- diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 3f434dbecc..93219319a4 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -121,7 +121,7 @@ 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, entity tracetest_ent); -void waypoint_spawn_fromeditor(entity pl); +void waypoint_spawn_fromeditor(entity pl, bool at_crosshair); entity waypoint_spawn(vector m1, vector m2, float f); void waypoint_unreachable(entity pl); diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 9de3779870..8dc27c515a 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -345,10 +345,15 @@ entity waypoint_spawn(vector m1, vector m2, float f) return w; } -void waypoint_spawn_fromeditor(entity pl) +void waypoint_spawn_fromeditor(entity pl, bool at_crosshair) { entity e; vector org = pl.origin; + if (at_crosshair) + { + crosshair_trace(pl); + org = trace_endpos - eZ * STAT(PL_MIN, pl).z; + } int ctf_flags = havocbot_symmetry_origin_order; bool sym = ((autocvar_g_waypointeditor_symmetrical > 0 && ctf_flags >= 2) || (autocvar_g_waypointeditor_symmetrical < 0)); @@ -358,7 +363,7 @@ void waypoint_spawn_fromeditor(entity pl) ctf_flags = 2; int wp_num = ctf_flags; - if(!PHYS_INPUT_BUTTON_CROUCH(pl)) + if(!PHYS_INPUT_BUTTON_CROUCH(pl) && !at_crosshair) { // snap waypoint to item's origin if close enough IL_EACH(g_items, true, diff --git a/qcsrc/server/bot/default/waypoints.qh b/qcsrc/server/bot/default/waypoints.qh index 0b69dcbb8b..3b741f8d10 100644 --- a/qcsrc/server/bot/default/waypoints.qh +++ b/qcsrc/server/bot/default/waypoints.qh @@ -70,7 +70,7 @@ bool waypoint_load_links(); #define waypoint_remove_links_hardwired() waypoint_load_or_remove_links_hardwired(true) void waypoint_load_or_remove_links_hardwired(bool removal_mode); -void waypoint_spawn_fromeditor(entity pl); +void waypoint_spawn_fromeditor(entity pl, bool at_crosshair); entity waypoint_spawn(vector m1, vector m2, float f); entity waypoint_spawnpersonal(entity this, vector position); diff --git a/qcsrc/server/bot/null/bot_null.qc b/qcsrc/server/bot/null/bot_null.qc index bdca146c2e..8671cd0900 100644 --- a/qcsrc/server/bot/null/bot_null.qc +++ b/qcsrc/server/bot/null/bot_null.qc @@ -39,6 +39,6 @@ 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, entity tracetest_ent) { } -void waypoint_spawn_fromeditor(entity pl) { } +void waypoint_spawn_fromeditor(entity pl, bool at_crosshair) { } entity waypoint_spawn(vector m1, vector m2, float f) { return NULL; } #endif diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 1395986b97..9ce1504d8e 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -187,7 +187,7 @@ void ClientCommand_wpeditor(entity caller, int request, int argc) if (!IS_PLAYER(caller)) sprint(caller, "ERROR: this command works only if you are player\n"); else - waypoint_spawn_fromeditor(caller); + waypoint_spawn_fromeditor(caller, (argv(2) == "crosshair")); return; } else if (argv(1) == "remove")