The ai is basically following the AStar algorithm for pathfinding (in case anyone here knows about it)
The function looks for waypoint with a .link of "OPEN", and the lowest F value, and it looks at all the waypoints on the map.
Code: Select all
entity(entity treeb) find_open =
{
local entity way;
local float fbest;
local entity best;
fbest = 10000;
way = find(world,classname, "waypoint");
self.loopcount = 0;
while(way)
{
/////////////////////////////////
if(self.loopcount > 300)
{
bprint("find_open-loopcount max! \n");
self.loopcount = 0;
return(world);
}
self.loopcount = self.loopcount + 1;
/////////////////////////////////
if(way.link == "OPEN")
{
if(way.F < fbest)
{
fbest = way.F;
best = way;
}
}
way = find(way, classname, "waypoint");
}
return(best);
};
Could anybody please help?
Thanks.