Routing: Added ability to nudge existing waypoints along an axis as well as

an option to move the nearest waypoint to the player's position.
This commit is contained in:
Marco Cawthorne 2021-01-03 12:52:51 +01:00
parent 6dc054f94b
commit 6c3814a2b1
2 changed files with 82 additions and 15 deletions

View file

@ -282,8 +282,8 @@ Way_GoToPoint(entity pl)
traceline(vecSrc, vecSrc + (v_forward * 4096), FALSE, pl); traceline(vecSrc, vecSrc + (v_forward * 4096), FALSE, pl);
print(sprintf("Telling all bots to go to %v\n", trace_endpos)); print(sprintf("Telling all bots to go to %v\n", trace_endpos));
for (entity a = world; ( a = find( a, classname, "player" ) ); ) { for (entity a = world; (a = find(a, classname, "player"));) {
if ( clienttype(a) != CLIENTTYPE_REAL ) { if (clienttype(a) != CLIENTTYPE_REAL) {
bot targ; bot targ;
targ = (bot)a; targ = (bot)a;
targ.RouteClear(); targ.RouteClear();
@ -409,7 +409,7 @@ Way_Cmd(void)
switch (argv(1)) { switch (argv(1)) {
case "goto": case "goto":
Way_GoToPoint( self ); Way_GoToPoint(self);
break; break;
case "autolink": case "autolink":
Way_AutoLink(Way_FindClosestNode(self.origin)); Way_AutoLink(Way_FindClosestNode(self.origin));
@ -421,31 +421,31 @@ Way_Cmd(void)
Way_ConnectTwo(); Way_ConnectTwo();
break; break;
case "add": case "add":
Way_CreateNode( self, 1 ); Way_CreateNode(self, 1);
break; break;
case "addchain": case "addchain":
Way_CreateNode( self, 0 ); Way_CreateNode(self, 0);
break; break;
case "addsingle": case "addsingle":
Way_CreateNode( self, -3 ); Way_CreateNode(self, -3);
break; break;
case "addltn": case "addltn":
Way_CreateNode( self, -1 ); Way_CreateNode(self, -1);
break; break;
case "addntl": case "addntl":
Way_CreateNode( self, -2 ); Way_CreateNode(self, -2);
break; break;
case "addspawns": case "addspawns":
Way_HelperSpawns(); Way_HelperSpawns();
break; break;
case "delete": case "delete":
Way_DeleteNode( Way_FindClosestNode( self.origin ) ); Way_DeleteNode(Way_FindClosestNode(self.origin));
break; break;
case "purge": case "purge":
Way_WipeWaypoints(); Way_WipeWaypoints();
break; break;
case "radius": case "radius":
Way_SetRadius( Way_FindClosestNode( self.origin ), stof( argv( 2 ) ) ); Way_SetRadius(Way_FindClosestNode(self.origin), stof(argv(2)));
break; break;
case "radiushack": case "radiushack":
for (int i = 0i; i < g_iWaypoints; i++) { for (int i = 0i; i < g_iWaypoints; i++) {
@ -461,11 +461,27 @@ Way_Cmd(void)
case "linkwalk": case "linkwalk":
Way_FlagWalk(); Way_FlagWalk();
break; break;
case "move":
vector p;
int n = Way_FindClosestNode(self.origin);
if (n >= 0) {
p[0] = stof(argv(2));
p[1] = stof(argv(3));
p[2] = stof(argv(4));
g_pWaypoints[n].m_vecOrigin += p;
}
break;
case "movetopos":
int nearest = Way_FindClosestNode(self.origin);
if (nearest >= 0) {
g_pWaypoints[nearest].m_vecOrigin = self.origin;
}
break;
case "save": case "save":
Way_SaveFile( argv( 2 ) ); Way_SaveFile(argv(2));
break; break;
case "load": case "load":
Way_ReadFile( argv( 2 ) ); Way_ReadFile(argv(2));
break; break;
} }
} }

View file

@ -27,8 +27,8 @@ Way_Init(void)
"4.\tLink Flags...\n" \ "4.\tLink Flags...\n" \
"5.\tRadius Settings...\n" \ "5.\tRadius Settings...\n" \
"6.\tAuto-Link Settings...\n" \ "6.\tAuto-Link Settings...\n" \
"7.\tSave/Load...\n" \ "7.\tMove waypoint...\n" \
"\n" \ "8.\tSave/Load...\n" \
"9.\tExit\n"; "9.\tExit\n";
way_menu.m_flPosX = 0; way_menu.m_flPosX = 0;
way_menu.m_flPosY = -1; way_menu.m_flPosY = -1;
@ -109,7 +109,7 @@ Way_Init(void)
way_flags.m_strMessage = "1.\tFlag ^3JUMP^7 (2 steps)\n" \ way_flags.m_strMessage = "1.\tFlag ^3JUMP^7 (2 steps)\n" \
"2.\tFlag ^2CROUCH^7 (2 steps)\n" \ "2.\tFlag ^2CROUCH^7 (2 steps)\n" \
"3.\tFlag ^1WALK^7 (2 steps)\n" \ "3.\tFlag ^1WALK^7 (2 steps)\n" \
"\n" \ "4.\tFlag ^4AIM^7 (2 steps)\n" \
"\n" \ "\n" \
"\n" \ "\n" \
"\n" \ "\n" \
@ -153,6 +153,23 @@ Way_Init(void)
way_text.m_flPosY = -1; way_text.m_flPosY = -1;
Titles_AddEntry(way_text); Titles_AddEntry(way_text);
} }
/* add waypoint menu */
{
titles_t way_move;
way_move.m_strName = "WAY_MOVE";
way_move.m_strMessage = "1.\tMove nearest +1 X-axis\n" \
"2.\tMove nearest -1 X-axis\n" \
"3.\tMove nearest +1 Y-axis\n" \
"4.\tMove nearest -1 Y-axis\n" \
"5.\tMove nearest +1 Z-axis\n" \
"6.\tMove nearest -1 Z-axis\n" \
"\n" \
"8.\tMove nearest to player-position\n" \
"9.\tBack\n";
way_move.m_flPosX = 0;
way_move.m_flPosY = -1;
Titles_AddEntry(way_move);
}
} }
void void
@ -178,6 +195,9 @@ WAY_MENU(int n)
Textmenu_Call("WAY_AUTOLINK"); Textmenu_Call("WAY_AUTOLINK");
break; break;
case 7: case 7:
Textmenu_Call("WAY_MOVE");
break;
case 8:
Textmenu_Call("WAY_FILE"); Textmenu_Call("WAY_FILE");
break; break;
case 9: case 9:
@ -343,3 +363,34 @@ WAY_RADIUS(int n)
break; break;
} }
} }
void
WAY_MOVE(int n)
{
switch (n) {
case 1:
localcmd("sv way move 1 0 0\n");
break;
case 2:
localcmd("sv way move -1 0 0\n");
break;
case 3:
localcmd("sv way move 0 1 0\n");
break;
case 4:
localcmd("sv way move 0 -1 0\n");
break;
case 5:
localcmd("sv way move 0 0 1\n");
break;
case 6:
localcmd("sv way move 0 0 -1\n");
break;
case 8:
localcmd("sv way movetopos\n");
break;
case 9:
Textmenu_Call("WAY_MENU");
break;
}
}