WIP: Bot waypoints: add new command "wpeditor spawn crosshair" that spawn a waypoint...
authorterencehill <piuntn@gmail.com>
Sun, 12 May 2019 00:46:56 +0000 (02:46 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 12 May 2019 00:46:56 +0000 (02:46 +0200)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/bot/default/waypoints.qh
qcsrc/server/bot/null/bot_null.qc
qcsrc/server/command/cmd.qc

index 3f434db..9321931 100644 (file)
@@ -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);
 
index 9de3779..8dc27c5 100644 (file)
@@ -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,
index 0b69dcb..3b741f8 100644 (file)
@@ -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);
 
index bdca146..8671cd0 100644 (file)
@@ -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
index 1395986..9ce1504 100644 (file)
@@ -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")