mirror of
https://github.com/ineedbots/iw5_bot_warfare.git
synced 2025-04-26 15:44:49 +00:00
Added low mem mode
This commit is contained in:
parent
1e5c65eafb
commit
215ea9c6c1
@ -23,6 +23,11 @@ init()
|
|||||||
if (!getDvarInt("bots_main"))
|
if (!getDvarInt("bots_main"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(getDvar("bots_main_lowmem") == "")
|
||||||
|
setDvar("bots_main_lowmem", false);//lower memory usage mode, more cpu
|
||||||
|
|
||||||
|
level.bots_lowmem = getDvarInt("bots_main_lowmem");
|
||||||
|
|
||||||
thread load_waypoints();
|
thread load_waypoints();
|
||||||
thread hook_callbacks();
|
thread hook_callbacks();
|
||||||
|
|
||||||
|
@ -934,7 +934,10 @@ load_waypoints()
|
|||||||
level.waypoints[i].childCount = level.waypoints[i].children.size;
|
level.waypoints[i].childCount = level.waypoints[i].children.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!level.bots_lowmem)
|
||||||
|
{
|
||||||
level.waypointsKDTree = WaypointsToKDTree();
|
level.waypointsKDTree = WaypointsToKDTree();
|
||||||
|
}
|
||||||
|
|
||||||
level.waypointsCamp = [];
|
level.waypointsCamp = [];
|
||||||
level.waypointsTube = [];
|
level.waypointsTube = [];
|
||||||
@ -1492,6 +1495,27 @@ GetNearestWaypointWithSight(pos)
|
|||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Will linearly search for the nearest waypoint
|
||||||
|
*/
|
||||||
|
GetNearestWaypoint(pos)
|
||||||
|
{
|
||||||
|
candidate = undefined;
|
||||||
|
dist = 2147483647;
|
||||||
|
|
||||||
|
for(i = 0; i < level.waypointCount; i++)
|
||||||
|
{
|
||||||
|
curdis = DistanceSquared(level.waypoints[i].origin, pos);
|
||||||
|
if(curdis > dist)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dist = curdis;
|
||||||
|
candidate = level.waypoints[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Modified Pezbot astar search.
|
Modified Pezbot astar search.
|
||||||
This makes use of sets for quick look up and a heap for a priority queue instead of simple lists which require to linearly search for elements everytime.
|
This makes use of sets for quick look up and a heap for a priority queue instead of simple lists which require to linearly search for elements everytime.
|
||||||
@ -1505,6 +1529,10 @@ AStarSearch(start, goal, team, greedy_path)
|
|||||||
|
|
||||||
closed = [];//set for quick lookup
|
closed = [];//set for quick lookup
|
||||||
|
|
||||||
|
startwp = undefined;
|
||||||
|
if (level.bots_lowmem)
|
||||||
|
startwp = getNearestWaypoint(start);
|
||||||
|
else
|
||||||
startwp = level.waypointsKDTree KDTreeNearest(start);//balanced kdtree, for nns
|
startwp = level.waypointsKDTree KDTreeNearest(start);//balanced kdtree, for nns
|
||||||
if(!isDefined(startwp))
|
if(!isDefined(startwp))
|
||||||
return [];
|
return [];
|
||||||
@ -1515,6 +1543,10 @@ AStarSearch(start, goal, team, greedy_path)
|
|||||||
startwp = _startwp;
|
startwp = _startwp;
|
||||||
startwp = startwp.index;
|
startwp = startwp.index;
|
||||||
|
|
||||||
|
goalwp = undefined;
|
||||||
|
if (level.bots_lowmem)
|
||||||
|
goalwp = getNearestWaypoint(goal);
|
||||||
|
else
|
||||||
goalwp = level.waypointsKDTree KDTreeNearest(goal);
|
goalwp = level.waypointsKDTree KDTreeNearest(goal);
|
||||||
if(!isDefined(goalwp))
|
if(!isDefined(goalwp))
|
||||||
return [];
|
return [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user