mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-04-23 06:15:43 +00:00
remote waypoints
This commit is contained in:
parent
12d91f83f9
commit
99037ac48a
@ -14,7 +14,7 @@ init()
|
|||||||
if(getDVarint("bots_main_debug"))
|
if(getDVarint("bots_main_debug"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
load_waypoints();
|
thread load_waypoints();
|
||||||
thread hook_callbacks();
|
thread hook_callbacks();
|
||||||
|
|
||||||
setDvar("testClients_watchKillcam", true);
|
setDvar("testClients_watchKillcam", true);
|
||||||
|
36
userraw/maps/mp/bots/_bot_http.gsc
Normal file
36
userraw/maps/mp/bots/_bot_http.gsc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
getRemoteWaypoints(mapname)
|
||||||
|
{
|
||||||
|
printLn( "Getting waypoints from csv: " );
|
||||||
|
//"https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/mp_rust_wp.csv"
|
||||||
|
}
|
||||||
|
|
||||||
|
getLinesFromUrl(url)
|
||||||
|
{
|
||||||
|
result = spawnStruct();
|
||||||
|
result.lines = [];
|
||||||
|
|
||||||
|
request = httpGet( url );
|
||||||
|
request waittill( "done", success, data );
|
||||||
|
request destroy();
|
||||||
|
|
||||||
|
if (!success)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
line = "";
|
||||||
|
for (i=0;i<data.size;i++)
|
||||||
|
{
|
||||||
|
c = data[i];
|
||||||
|
|
||||||
|
if (c == "\n")
|
||||||
|
{
|
||||||
|
result.lines[result.lines.size] = line;
|
||||||
|
|
||||||
|
line = "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
line += c;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
@ -1003,37 +1003,9 @@ onSpawned()
|
|||||||
self.help_time = undefined;
|
self.help_time = undefined;
|
||||||
|
|
||||||
self thread bot_dom_cap_think();
|
self thread bot_dom_cap_think();
|
||||||
self thread httpTest();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
httpTest()
|
|
||||||
{
|
|
||||||
request = httpGet( "https://raw.githubusercontent.com/ineedbots/iw4x_waypoints/master/mp_rust_wp.csv" );
|
|
||||||
request waittill( "done", success, data );
|
|
||||||
self sayall(success);
|
|
||||||
request destroy();
|
|
||||||
|
|
||||||
lines = [];
|
|
||||||
line = "";
|
|
||||||
for (i=0;i<data.size;i++)
|
|
||||||
{
|
|
||||||
c = data[i];
|
|
||||||
|
|
||||||
if (c == "\n")
|
|
||||||
{
|
|
||||||
lines[lines.size] = line;
|
|
||||||
|
|
||||||
line = "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
line += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
self sayall(lines[123]);
|
|
||||||
}
|
|
||||||
|
|
||||||
onDeath()
|
onDeath()
|
||||||
{
|
{
|
||||||
self endon("disconnect");
|
self endon("disconnect");
|
||||||
|
@ -387,7 +387,6 @@ RoundUp( floatVal )
|
|||||||
wpsFromCSV(mapname)
|
wpsFromCSV(mapname)
|
||||||
{
|
{
|
||||||
fileName = "waypoints/"+ toLower(mapname) + "_wp.csv";
|
fileName = "waypoints/"+ toLower(mapname) + "_wp.csv";
|
||||||
printLn( "Getting waypoints from csv: "+fileName );
|
|
||||||
|
|
||||||
waypoints = [];
|
waypoints = [];
|
||||||
|
|
||||||
@ -396,6 +395,8 @@ wpsFromCSV(mapname)
|
|||||||
if (waypointCount == "" || waypointCount <= 0)
|
if (waypointCount == "" || waypointCount <= 0)
|
||||||
return waypoints;
|
return waypoints;
|
||||||
|
|
||||||
|
printLn( "Getting waypoints from csv: "+fileName );
|
||||||
|
|
||||||
for (i = 1; i <= waypointCount; i++)
|
for (i = 1; i <= waypointCount; i++)
|
||||||
{
|
{
|
||||||
waypoint = spawnStruct();
|
waypoint = spawnStruct();
|
||||||
@ -439,6 +440,9 @@ wpsFromCSV(mapname)
|
|||||||
*/
|
*/
|
||||||
load_waypoints()
|
load_waypoints()
|
||||||
{
|
{
|
||||||
|
level.waypointCount = 0;
|
||||||
|
level.waypoints = [];
|
||||||
|
|
||||||
mapname = getDvar("mapname");
|
mapname = getDvar("mapname");
|
||||||
|
|
||||||
wps = wpsFromCSV(mapname);
|
wps = wpsFromCSV(mapname);
|
||||||
@ -449,7 +453,6 @@ load_waypoints()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
level.waypoints = [];
|
|
||||||
switch(mapname)
|
switch(mapname)
|
||||||
{
|
{
|
||||||
case "mp_afghan":
|
case "mp_afghan":
|
||||||
@ -657,6 +660,11 @@ load_waypoints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!level.waypoints.size)
|
||||||
|
{
|
||||||
|
maps\mp\bots\_bot_http::getRemoteWaypoints(mapname);
|
||||||
|
}
|
||||||
|
|
||||||
level.waypointCount = level.waypoints.size;
|
level.waypointCount = level.waypoints.size;
|
||||||
|
|
||||||
for(i = 0; i < level.waypointCount; i++)
|
for(i = 0; i < level.waypointCount; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user