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);
print(sprintf("Telling all bots to go to %v\n", trace_endpos));
for (entity a = world; ( a = find( a, classname, "player" ) ); ) {
if ( clienttype(a) != CLIENTTYPE_REAL ) {
for (entity a = world; (a = find(a, classname, "player"));) {
if (clienttype(a) != CLIENTTYPE_REAL) {
bot targ;
targ = (bot)a;
targ.RouteClear();
@ -409,7 +409,7 @@ Way_Cmd(void)
switch (argv(1)) {
case "goto":
Way_GoToPoint( self );
Way_GoToPoint(self);
break;
case "autolink":
Way_AutoLink(Way_FindClosestNode(self.origin));
@ -421,31 +421,31 @@ Way_Cmd(void)
Way_ConnectTwo();
break;
case "add":
Way_CreateNode( self, 1 );
Way_CreateNode(self, 1);
break;
case "addchain":
Way_CreateNode( self, 0 );
Way_CreateNode(self, 0);
break;
case "addsingle":
Way_CreateNode( self, -3 );
Way_CreateNode(self, -3);
break;
case "addltn":
Way_CreateNode( self, -1 );
Way_CreateNode(self, -1);
break;
case "addntl":
Way_CreateNode( self, -2 );
Way_CreateNode(self, -2);
break;
case "addspawns":
Way_HelperSpawns();
break;
case "delete":
Way_DeleteNode( Way_FindClosestNode( self.origin ) );
Way_DeleteNode(Way_FindClosestNode(self.origin));
break;
case "purge":
Way_WipeWaypoints();
break;
case "radius":
Way_SetRadius( Way_FindClosestNode( self.origin ), stof( argv( 2 ) ) );
Way_SetRadius(Way_FindClosestNode(self.origin), stof(argv(2)));
break;
case "radiushack":
for (int i = 0i; i < g_iWaypoints; i++) {
@ -461,11 +461,27 @@ Way_Cmd(void)
case "linkwalk":
Way_FlagWalk();
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":
Way_SaveFile( argv( 2 ) );
Way_SaveFile(argv(2));
break;
case "load":
Way_ReadFile( argv( 2 ) );
Way_ReadFile(argv(2));
break;
}
}

View file

@ -27,8 +27,8 @@ Way_Init(void)
"4.\tLink Flags...\n" \
"5.\tRadius Settings...\n" \
"6.\tAuto-Link Settings...\n" \
"7.\tSave/Load...\n" \
"\n" \
"7.\tMove waypoint...\n" \
"8.\tSave/Load...\n" \
"9.\tExit\n";
way_menu.m_flPosX = 0;
way_menu.m_flPosY = -1;
@ -109,7 +109,7 @@ Way_Init(void)
way_flags.m_strMessage = "1.\tFlag ^3JUMP^7 (2 steps)\n" \
"2.\tFlag ^2CROUCH^7 (2 steps)\n" \
"3.\tFlag ^1WALK^7 (2 steps)\n" \
"\n" \
"4.\tFlag ^4AIM^7 (2 steps)\n" \
"\n" \
"\n" \
"\n" \
@ -153,6 +153,23 @@ Way_Init(void)
way_text.m_flPosY = -1;
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
@ -178,6 +195,9 @@ WAY_MENU(int n)
Textmenu_Call("WAY_AUTOLINK");
break;
case 7:
Textmenu_Call("WAY_MOVE");
break;
case 8:
Textmenu_Call("WAY_FILE");
break;
case 9:
@ -343,3 +363,34 @@ WAY_RADIUS(int n)
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;
}
}