]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add possibility to set waypoints up only on one side of the map and automatically...
authorterencehill <piuntn@gmail.com>
Thu, 16 Mar 2017 17:48:35 +0000 (18:48 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 16 Mar 2017 17:48:35 +0000 (18:48 +0100)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/impulse.qc

index 0c916558e4f12db13729a3b75233c4f30b2b122c..5b3105c8c1d58c9c0cc70251c64f9cad9601d2d2 100644 (file)
@@ -402,6 +402,8 @@ set bot_ai_aimskill_order_filter_5th 0.5 "Movement prediction filter. Used rarel
 // waypoint editor enable
 set g_waypointeditor 0
 set g_waypointeditor_auto 0 "Automatically create waypoints for bots while playing; BEWARE, this currently creates too many of them"
+set g_waypointeditor_symmetrical 0 "Enable symmetrical editing of waypoints, useful in symmetrical CTF maps. NOTE: it assumes that the map is perfectly symmetrical"
+set g_waypointeditor_symmetrical_center "0 0" "Center (x y) for symmetrical editing of waypoints"
 set bot_ignore_bots 0  "When set, bots don't shoot at other bots"
 set bot_join_empty 0   "When set, bots also play if no player has joined the server"
 set bot_vs_human 0     "Bots and humans play in different teams when set. positive values to make an all-bot blue team, set to negative values to make an all-bot red team, the absolute value is the ratio bots vs humans (1 for equal count). Changes will be correctly applied only from the next game"
index 85b767fc91a0a9a2076aaa19b58af288ed634d4f..8f397397f341d1135787f24b021854b5128e86a6 100644 (file)
@@ -244,6 +244,8 @@ float autocvar_g_turrets_targetscan_maxdelay;
 float autocvar_g_turrets_targetscan_mindelay;
 bool autocvar_g_use_ammunition;
 bool autocvar_g_waypointeditor;
+bool autocvar_g_waypointeditor_symmetrical;
+vector autocvar_g_waypointeditor_symmetrical_center;
 bool autocvar_g_waypoints_for_items;
 #define autocvar_g_weapon_stay cvar("g_weapon_stay")
 bool autocvar_g_weapon_throwable;
index a7f9554294fc40ad246505743f4721a6b194b199..0741756767c4d2648c6b53fe881d138b79e8228f 100644 (file)
@@ -574,14 +574,33 @@ IMPULSE(waypoint_clear)
 IMPULSE(navwaypoint_spawn)
 {
        if (!autocvar_g_waypointeditor) return;
-       waypoint_schedulerelink(waypoint_spawn(this.origin, this.origin, 0));
-       bprint(strcat("Waypoint spawned at ", vtos(this.origin), "\n"));
+       vector org = this.origin;
+       bool sym = boolean(autocvar_g_waypointeditor_symmetrical);
+
+       LABEL(add_wp);
+       waypoint_schedulerelink(waypoint_spawn(org, org, 0));
+       bprint(strcat("Waypoint spawned at ", vtos(org), "\n"));
+       if(sym)
+       {
+               vector map_center = autocvar_g_waypointeditor_symmetrical_center;
+               org = this.origin;
+               org.x = map_center.x - (org.x - map_center.x);
+               org.y = map_center.y - (org.y - map_center.y);
+               if (vdist(org - this.origin, >, 10))
+               {
+                       sym = false;
+                       goto add_wp;
+               }
+       }
 }
 
 IMPULSE(navwaypoint_remove)
 {
        if (!autocvar_g_waypointeditor) return;
        entity e = navigation_findnearestwaypoint(this, false);
+       bool sym = boolean(autocvar_g_waypointeditor_symmetrical);
+
+       LABEL(remove_wp);
        if (!e) return;
        if (e.wpflags & WAYPOINTFLAG_GENERATED) return;
 
@@ -591,8 +610,29 @@ IMPULSE(navwaypoint_remove)
                return;
        }
 
+       entity wp_sym = NULL;
+       if (sym)
+       {
+               vector map_center = autocvar_g_waypointeditor_symmetrical_center;
+               vector org = this.origin;
+               org.x = map_center.x - (org.x - map_center.x);
+               org.y = map_center.y - (org.y - map_center.y);
+               FOREACH_ENTITY_CLASS("waypoint", !(it.wpflags & WAYPOINTFLAG_GENERATED), {
+                       if(vdist(org - it.origin, <, 3))
+                       {
+                               wp_sym = it;
+                               break;
+                       }
+               });
+       }
        bprint(strcat("Waypoint removed at ", vtos(e.origin), "\n"));
        waypoint_remove(e);
+       if (sym && wp_sym)
+       {
+               e = wp_sym;
+               sym = false;
+               goto remove_wp;
+       }
 }
 
 IMPULSE(navwaypoint_relink)