From 1dd2547fe2cb78941b9f708d261a8da7a982c9ba Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 29 Dec 2020 07:17:41 +0100 Subject: [PATCH] Client: Added improvements to the waypoint-editor, more options, features... etc. --- src/botlib/way.c | 68 +++++++++++++++- src/client/way.c | 204 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 249 insertions(+), 23 deletions(-) diff --git a/src/botlib/way.c b/src/botlib/way.c index c1152a00..3d2ccbf2 100644 --- a/src/botlib/way.c +++ b/src/botlib/way.c @@ -163,9 +163,9 @@ Way_Waypoint_Create(entity ePlayer, int iAutoLink) if (iAutoLink == 0) { Way_LinkWaypoints(n, &g_pWaypoints[iID-1]); Way_LinkWaypoints(&g_pWaypoints[iID-1], n); - } else if (iAutoLink -1) { + } else if (iAutoLink == -1) { Way_LinkWaypoints(&g_pWaypoints[iID-1], n); - } else { + } else if (iAutoLink == -2) { Way_LinkWaypoints(n, &g_pWaypoints[iID-1]); } } @@ -355,7 +355,7 @@ Way_DrawDebugInfo(void) } void -Way_ConnectTwo(void) +Way_ConnectOne(void) { static int waylink_status; static int way1, way2; @@ -377,6 +377,42 @@ Way_ConnectTwo(void) } } +void +Way_ConnectTwo(void) +{ + static int waylink_status; + static int way1, way2; + + if (waylink_status == 0) { + way1 = Way_FindClosestWaypoint(self.origin); + waylink_status = 1; + centerprint(self, "Selected first waypoint!\n"); + } else if (waylink_status == 1) { + way2 = Way_FindClosestWaypoint(self.origin); + waylink_status = 0; + + if (way1 != way2) { + Way_LinkWaypoints(&g_pWaypoints[way1], &g_pWaypoints[way2]); + Way_LinkWaypoints(&g_pWaypoints[way2], &g_pWaypoints[way1]); + centerprint(self, "Linked first waypoint with second waypoint!\n"); + } else { + centerprint(self, "Failed to link, the two points are the same!\n"); + } + } +} + +void +Way_ConnectAuto(void) +{ + Way_AutoLink(Way_FindClosestWaypoint(self.origin)); +} + +void +Way_Purge(void) +{ + Way_WipeWaypoints(); +} + void Way_Cmd(void) { @@ -387,7 +423,19 @@ Way_Cmd(void) } Way_GoToPoint( self ); break; - case "connect": + case "autolink": + if (!self) { + return; + } + Way_ConnectAuto(); + break; + case "connect1": + if (!self) { + return; + } + Way_ConnectOne(); + break; + case "connect2": if (!self) { return; } @@ -405,6 +453,12 @@ Way_Cmd(void) } Way_Waypoint_Create( self, 0 ); break; + case "addsingle": + if ( !self ) { + return; + } + Way_Waypoint_Create( self, -3 ); + break; case "addltn": if ( !self ) { return; @@ -429,6 +483,12 @@ Way_Cmd(void) } Way_Waypoint_Delete( Way_FindClosestWaypoint( self.origin ) ); break; + case "purge": + if ( !self ) { + return; + } + Way_Purge(); + break; case "radius": if ( !self ) { return; diff --git a/src/client/way.c b/src/client/way.c index 11f458cb..dcf58747 100644 --- a/src/client/way.c +++ b/src/client/way.c @@ -1,20 +1,104 @@ +/* + * Copyright (c) 2016-2020 Marco Hladik + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ void Way_Init(void) { /* main waypoint menu */ { - titles_t way_text; - way_text.m_strName = "WAY_MENU"; - way_text.m_strMessage = "1.\tAdd Waypoint\n" \ - "2.\tAdd Chain Waypoint\n" \ - "3.\tAdd Spawnpoint Waypoints\n" \ - "4.\tDelete Closest Waypoint\n" \ - "5.\tConnect Two Waypoints\n" \ - "6.\tAdd One-Way Last-To-New\n" \ + titles_t way_menu; + way_menu.m_strName = "WAY_MENU"; + way_menu.m_strMessage = "1.\tAdd...\n" \ + "2.\tLink...\n" \ + "3.\tRemove...\n" \ + "4.\tAuto-Link Settings...\n" \ + "\n" \ + "\n" \ "7.\tSave File\n" \ "8.\tLoad File\n" \ "9.\tExit\n"; + way_menu.m_flPosX = 0; + way_menu.m_flPosY = -1; + Titles_AddEntry(way_menu); + } + /* add waypoint menu */ + { + titles_t way_add; + way_add.m_strName = "WAY_ADD"; + way_add.m_strMessage = "1.\tAdd ^1Autolink^7 Waypoint\n" \ + "2.\tAdd ^1Chain^7 Waypoint^7 (last-to-new)\n" \ + "3.\tAdd ^1Single^7 Waypoint\n" \ + "4.\tAdd ^1Spawnpoint^7 Waypoints\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + "9.\tBack\n"; + way_add.m_flPosX = 0; + way_add.m_flPosY = -1; + Titles_AddEntry(way_add); + } + /* add waypoint menu */ + { + titles_t way_link; + way_link.m_strName = "WAY_LINK"; + way_link.m_strMessage = "1.\tLink 2-way (2 steps)\n" \ + "2.\tLink 1-way (2 steps)\n" \ + "3.\tAutolink closest\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + "9.\tBack\n"; + way_link.m_flPosX = 0; + way_link.m_flPosY = -1; + Titles_AddEntry(way_link); + } + /* add waypoint menu */ + { + titles_t way_remove; + way_remove.m_strName = "WAY_REMOVE"; + way_remove.m_strMessage = "1.\tRemove nearest\n" \ + "2.\tRemove ALL\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + "\n" \ + "9.\tBack\n"; + way_remove.m_flPosX = 0; + way_remove.m_flPosY = -1; + Titles_AddEntry(way_remove); + } + /* add waypoint menu */ + { + titles_t way_text; + way_text.m_strName = "WAY_AUTOLINK"; + way_text.m_strMessage = "1.\tDefault radius (256)\n" \ + "2.\t32 radius\n" \ + "3.\t64 radius\n" \ + "4.\t128 radius\n" \ + "5.\t512 radius\n" \ + "6.\t768 radius\n" \ + "7.\t1024 radius\n" \ + "\n" \ + "9.\tBack\n"; way_text.m_flPosX = 0; way_text.m_flPosY = -1; Titles_AddEntry(way_text); @@ -26,22 +110,16 @@ WAY_MENU(int n) { switch (n) { case 1: - localcmd("sv way add\n"); + Textmenu_Call("WAY_ADD"); break; case 2: - localcmd("sv way addchain\n"); + Textmenu_Call("WAY_LINK"); break; case 3: - localcmd("sv way addspawns\n"); + Textmenu_Call("WAY_REMOVE"); break; case 4: - localcmd("sv way delete\n"); - break; - case 5: - localcmd("sv way connect\n"); - break; - case 6: - localcmd("sv way addltn\n"); + Textmenu_Call("WAY_AUTOLINK"); break; case 7: localcmd(sprintf("sv way save %s.way\n", mapname)); @@ -55,4 +133,92 @@ WAY_MENU(int n) Textmenu_Call(""); break; } -} +} + +void +WAY_ADD(int n) +{ + switch (n) { + case 1: + localcmd("sv way add\n"); + break; + case 2: + localcmd("sv way addchain\n"); + break; + case 3: + localcmd("sv way addsingle\n"); + break; + case 4: + localcmd("sv way addspawns\n"); + break; + case 9: + Textmenu_Call("WAY_MENU"); + break; + } +} + +void +WAY_LINK(int n) +{ + switch (n) { + case 1: + localcmd("sv way connect2\n"); + break; + case 2: + localcmd("sv way connect1\n"); + break; + case 3: + localcmd("sv way autolink\n"); + break; + case 9: + Textmenu_Call("WAY_MENU"); + break; + } +} + +void +WAY_REMOVE(int n) +{ + switch (n) { + case 1: + localcmd("sv way delete\n"); + break; + case 2: + localcmd("sv way purge\n"); + break; + case 9: + Textmenu_Call("WAY_MENU"); + break; + } +} + +void +WAY_AUTOLINK(int n) +{ + switch (n) { + case 1: + localcmd("nav_linksize 256\n"); + break; + case 2: + localcmd("nav_linksize 32\n"); + break; + case 3: + localcmd("nav_linksize 64\n"); + break; + case 4: + localcmd("nav_linksize 128\n"); + break; + case 5: + localcmd("nav_linksize 512\n"); + break; + case 6: + localcmd("nav_linksize 768\n"); + break; + case 7: + localcmd("nav_linksize 1024\n"); + break; + case 9: + Textmenu_Call("WAY_MENU"); + break; + } +}