From 5111c6daa0b6d0d6ae16fd84de1a7940d856704d Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 16 Mar 2017 18:48:35 +0100 Subject: [PATCH] Add possibility to set waypoints up only on one side of the map and automatically set waypoints on the other side on symmetrical maps --- defaultXonotic.cfg | 2 ++ qcsrc/server/autocvars.qh | 2 ++ qcsrc/server/impulse.qc | 44 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 0c916558e..5b3105c8c 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 85b767fc9..8f397397f 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index a7f955429..074175676 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -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) -- 2.39.2