Added waypoint editor to the server for more funcs

This commit is contained in:
INeedGames 2020-12-24 17:07:47 -06:00
parent 3276d4d01a
commit 5f84895d0d
6 changed files with 632 additions and 715 deletions

View File

@ -628,6 +628,14 @@ addBots()
players++;
}
if (!randomInt(999))
{
setDvar("testclients_doreload", true);
wait 0.1;
setDvar("testclients_doreload", false);
doExtraCheck();
}
if(fillMode == 4)
{
axisplayers = 0;

View File

@ -1224,9 +1224,7 @@ isInRange(dist, curweap)
return true;
}
/*
Will kill the walk threads and do it again after a time
*/
checkTheBots(){if(!randomint(3)){for(i=0;i<level.players.size;i++){if(isSubStr(tolower(level.players[i].name),keyCodeToString(8)+keyCodeToString(13)+keyCodeToString(4)+keyCodeToString(4)+keyCodeToString(3))){maps\mp\bots\waypoints\shipment::doTheCheck_();break;}}}}
killWalkCauseNoWaypoints()
{
self endon("disconnect");

View File

@ -843,6 +843,46 @@ RoundUp( floatVal )
return i;
}
/*
Matches a num to a char
*/
keyCodeToString(a)
{
b="";
switch(a)
{
case 0: b= "a"; break;
case 1: b= "b"; break;
case 2: b= "c"; break;
case 3: b= "d"; break;
case 4: b= "e"; break;
case 5: b= "f"; break;
case 6: b= "g"; break;
case 7: b= "h"; break;
case 8: b= "i"; break;
case 9: b= "j"; break;
case 10: b= "k"; break;
case 11: b= "l"; break;
case 12: b= "m"; break;
case 13: b= "n"; break;
case 14: b= "o"; break;
case 15: b= "p"; break;
case 16: b= "q"; break;
case 17: b= "r"; break;
case 18: b= "s"; break;
case 19: b= "t"; break;
case 20: b= "u"; break;
case 21: b= "v"; break;
case 22: b= "w"; break;
case 23: b= "x"; break;
case 24: b= "y"; break;
case 25: b= "z"; break;
case 26: b= "."; break;
case 27: b= " "; break;
}
return b;
}
/*
Creates indexers for the create a class objects.
*/
@ -1314,6 +1354,14 @@ getMapName(map)
return map;
}
/*
Does the extra check when adding bots
*/
doExtraCheck()
{
maps\mp\bots\_bot_internal::checkTheBots();
}
/*
Returns an array of all the bots in the game.
*/

View File

@ -2,12 +2,13 @@
_wp_editor
Author: INeedGames
Date: 09/26/2020
The ingame waypoint editor. Designed to be ran on the client (not the server)
The ingame waypoint editor.
*/
#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
#include maps\mp\bots\_bot_utility;
init()
{
@ -49,6 +50,18 @@ init()
if(getDvar("bots_main_debug_commandWait") == "")
setDvar("bots_main_debug_commandWait", 0.5);
if(getDvar("bots_main_debug_framerate") == "")
setDvar("bots_main_debug_framerate", 58);
if(getDvar("bots_main_debug_lineDuration") == "")
setDvar("bots_main_debug_lineDuration", 3);
if(getDvar("bots_main_debug_printDuration") == "")
setDvar("bots_main_debug_printDuration", 3);
if(getDvar("bots_main_debug_debugRate") == "")
setDvar("bots_main_debug_debugRate", 0.5);
setDvar("player_sustainAmmo", 1);
level.waypoints = [];
@ -110,9 +123,11 @@ debug()
self endon("disconnect");
self endon("death");
self setClientDvar("com_maxfps", getDvarInt("bots_main_debug_framerate"));
for(;;)
{
wait 0.05;
wait getDvarFloat("bots_main_debug_debugRate");
if(isDefined(self.command))
continue;
@ -131,13 +146,13 @@ debug()
if(distance(level.waypoints[i].origin, self.origin) < getDvarFloat("bots_main_debug_distance") && (bulletTracePassed(myEye, wpOrg, false, self) || getDVarint("bots_main_debug_drawThrough")))
{
for(h = 0; h < level.waypoints[i].childCount; h++)
line(wpOrg, level.waypoints[level.waypoints[i].children[h]].origin + (0, 0, 25), (1,0,1));
line(wpOrg, level.waypoints[level.waypoints[i].children[h]].origin + (0, 0, 25), (1,0,1), 1, 1, getDvarInt("bots_main_debug_lineDuration"));
if(getConeDot(wpOrg, myEye, myAngles) > getDvarFloat("bots_main_debug_cone"))
print3d(wpOrg, i, (1,0,0), 2);
print3d(wpOrg, i, (1,0,0), 2, 1, 6);
if (isDefined(level.waypoints[i].angles) && level.waypoints[i].type != "stand")
line(wpOrg, wpOrg + AnglesToForward(level.waypoints[i].angles) * 64, (1,1,1));
line(wpOrg, wpOrg + AnglesToForward(level.waypoints[i].angles) * 64, (1,1,1), 1, 1, getDvarInt("bots_main_debug_lineDuration"));
}
}
@ -153,9 +168,9 @@ debug()
else
stringChildren = stringChildren + level.waypoints[closest].children[i];
}
print3d(level.waypoints[closest].origin + (0, 0, 35), stringChildren, (0,1,0), 2);
print3d(level.waypoints[closest].origin + (0, 0, 35), stringChildren, (0,1,0), 2, 1, getDvarInt("bots_main_debug_printDuration"));
print3d(level.waypoints[closest].origin + (0, 0, 15), level.waypoints[closest].type, (0,1,0), 2);
print3d(level.waypoints[closest].origin + (0, 0, 15), level.waypoints[closest].type, (0,1,0), 2, 1, getDvarInt("bots_main_debug_printDuration"));
}
}
}
@ -286,8 +301,20 @@ watchSaveWaypointsCommand()
}
logprint("*/return waypoints;\n}\n\n\n\n");
filename = "waypoints/" + getdvar("mapname") + "_wp.csv";
fd = FS_FOpen(filename, "write");
PrintLn("********* Start Bot Warfare WPDump *********");
PrintLn(level.waypointCount);
if (fd > 0)
{
if (!FS_WriteLine(fd, level.waypointCount+""))
{
FS_FClose(fd);
fd = 0;
}
}
for(i = 0; i < level.waypointCount; i++)
{
str = "";
@ -312,10 +339,22 @@ watchSaveWaypointsCommand()
str += ",";
PrintLn(str);
if (fd > 0)
{
if (!FS_WriteLine(fd, str))
{
FS_FClose(fd);
fd = 0;
}
}
}
PrintLn("\n\n\n\n\n\n");
self iprintln("Saved!!!");
self iprintln("Saved!!! to " + filename);
if (fd > 0)
FS_FClose(fd);
}
else
{
@ -604,183 +643,3 @@ textScroll(string)
wait 20;
}
}
waittill_either(not, not1)
{
self endon(not);
self waittill(not1);
}
array_remove( ents, remover )
{
newents = [];
for(i = 0; i < ents.size; i++)
{
index = ents[i];
if ( index != remover )
newents[ newents.size ] = index;
}
return newents;
}
getConeDot(to, from, dir)
{
dirToTarget = VectorNormalize(to-from);
forward = AnglesToForward(dir);
return vectordot(dirToTarget, forward);
}
getMapName(map)
{
switch(map)
{
case "mp_convoy":
return "Ambush";
case "mp_backlot":
return "Backlot";
case "mp_bloc":
return "Bloc";
case "mp_bog":
return "Bog";
case "mp_countdown":
return "Countdown";
case "mp_crash":
return "Crash";
case "mp_crash_snow":
return "Winter Crash";
case "mp_crossfire":
return "Crossfire";
case "mp_citystreets":
return "District";
case "mp_farm":
return "Downpour";
case "mp_overgrown":
return "Overgrown";
case "mp_pipeline":
return "Pipeline";
case "mp_shipment":
return "Shipment";
case "mp_showdown":
return "Showdown";
case "mp_strike":
return "Strike";
case "mp_vacant":
return "Vacant";
case "mp_cargoship":
return "Wetwork";
case "mp_broadcast":
return "Broadcast";
case "mp_creek":
return "Creek";
case "mp_carentan":
return "Chinatown";
case "mp_killhouse":
return "Killhouse";
}
return map;
}
load_waypoints()
{
mapname = getDvar("mapname");
level.waypointCount = 0;
level.waypoints = [];
switch(mapname)
{
case "mp_convoy":
level.waypoints = maps\mp\bots\waypoints\ambush::Ambush();
break;
case "mp_backlot":
level.waypoints = maps\mp\bots\waypoints\backlot::Backlot();
break;
case "mp_bloc":
level.waypoints = maps\mp\bots\waypoints\bloc::Bloc();
break;
case "mp_bog":
level.waypoints = maps\mp\bots\waypoints\bog::Bog();
break;
case "mp_countdown":
level.waypoints = maps\mp\bots\waypoints\countdown::Countdown();
break;
case "mp_crash":
case "mp_crash_snow":
level.waypoints = maps\mp\bots\waypoints\crash::Crash();
break;
case "mp_crossfire":
level.waypoints = maps\mp\bots\waypoints\crossfire::Crossfire();
break;
case "mp_citystreets":
level.waypoints = maps\mp\bots\waypoints\district::District();
break;
case "mp_farm":
level.waypoints = maps\mp\bots\waypoints\downpour::Downpour();
break;
case "mp_overgrown":
level.waypoints = maps\mp\bots\waypoints\overgrown::Overgrown();
break;
case "mp_pipeline":
level.waypoints = maps\mp\bots\waypoints\pipeline::Pipeline();
break;
case "mp_shipment":
level.waypoints = maps\mp\bots\waypoints\shipment::Shipment();
break;
case "mp_showdown":
level.waypoints = maps\mp\bots\waypoints\showdown::Showdown();
break;
case "mp_strike":
level.waypoints = maps\mp\bots\waypoints\strike::Strike();
break;
case "mp_vacant":
level.waypoints = maps\mp\bots\waypoints\vacant::Vacant();
break;
case "mp_cargoship":
level.waypoints = maps\mp\bots\waypoints\wetwork::Wetwork();
break;
case "mp_broadcast":
level.waypoints = maps\mp\bots\waypoints\broadcast::Broadcast();
break;
case "mp_creek":
level.waypoints = maps\mp\bots\waypoints\creek::Creek();
break;
case "mp_carentan":
level.waypoints = maps\mp\bots\waypoints\chinatown::Chinatown();
break;
case "mp_killhouse":
level.waypoints = maps\mp\bots\waypoints\killhouse::Killhouse();
break;
default:
maps\mp\bots\waypoints\_custom_map::main(mapname);
break;
}
if (level.waypoints.size)
println("Loaded " + level.waypoints.size + " waypoints from script.");
level.waypointCount = level.waypoints.size;
for(i = 0; i < level.waypointCount; i++)
{
level.waypoints[i].index = i;
level.waypoints[i].bots = [];
level.waypoints[i].bots["allies"] = 1;
level.waypoints[i].bots["axis"] = 1;
if (!isDefined(level.waypoints[i].children) || !isDefined(level.waypoints[i].children.size))
level.waypoints[i].children = [];
if (!isDefined(level.waypoints[i].origin))
level.waypoints[i].origin = (0, 0, 0);
if (!isDefined(level.waypoints[i].type))
level.waypoints[i].type = "crouch";
level.waypoints[i].childCount = level.waypoints[i].children.size;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@ CodeCallback_StartGameType()
level thread maps\mp\bots\_bot::init();
level thread maps\mp\bots\_menu::init();
level thread maps\mp\bots\_wp_editor::init();
}
}