]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 3f434dbecc7ab529dcc0794ba514e31c60e4eb68..93219319a4ad68841980ae48d9eaeac8c101e1ca 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 9de3779870e7c732a9193357cdaba18ecd6af1b8..8dc27c515a668fb39e490a113611d081256a7969 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 0b69dcbb8bca3e80fa9d543c5fcab6305e1f3b8c..3b741f8d103e6cb3e01be2a5ea6572d154b60db8 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 bdca146c2e549128e2e208fec27f8b118e091af4..8671cd0900b7c87e4b3e23cdf85626ddb4f3802b 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 1395986b97bd3a463ab33c16e8508da381f992ca..9ce1504d8e48e311774ca6222fb9bbfe4f7ca9e6 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")