Nice :> So you could play the original campaign but against Infected AI? That could make some of the levels insanely difficult!
One of the big barriers to making the Infected AI more self-contained is its reliance on the designer inputting a lot of data directly to the AI engine. For example, the engine must be told how many asteroids there are, and the X and Y coords of those asteroids.
First and foremost we need to know how many asteroids are in the level.
I'm not aware of any way to call this directly, so lets try something like this:
roidnumber = 0
for roidcheck = 0,100 do
if GetAsteroid(roidcheck).position.x ~= nil then
-- this roid must exist
elseif roidnumber == 0
-- this roid doesn't exist! the previous roid was the last one.
roidnumber = roidcheck - 1
end
end
-- Now we have auto-calculated the roidnumber variable
For the X and Y coords, I can solve this by using GetAsteroid(0).position.x.
Normally the AI engine stores the coordinates in two arrays, CoordX[] and CoordY[].
So all I have to do is something like this:
for assigncoords = 0,roidnumber do
coordx[assigncoords] = GetAsteroid(assigncoords).position.x
coordy[assigncoords] = GetAsteroid(assigncoords).position.y
end
That will automatically populate the crucial roidnumber, CoordX[] and CoordY[] variables.
This brings us a step closer to a totally independent AI function.