SOLVED Simple Enemy AI that Works with Lots of Instances

So, basically what I'm making is a top-down shooter real-time strategy game. In order to do so, I need a lot of AI's in the room at once, for both the enemy team and ally team. I have looked lots into finite state machines and other ways of creating AI's, and have tried countless times to create some good ones, but I run into a few problems:

1. The AI's hide on the wrong side of the cover and get shot immediately.
2. Once they are in range, they won't move into cover, just stand there.
3. When I try to solve either of those problems (by using collision_line or checking for cover every step) the game gets very slow and slideshowey.
4. The game also gets slow if I try placing a lot of enemies (which is not good if I want there to be a full-scale war going on in the room).

Could I get any good tips for making simple AI's that can be used for lots of instances without running at 1 fps?
(Sorry if this is kind of a stupid question as I am very new to gamemaker)
 

curato

Member
Well just of the top of my head you don't need to check for cover every frame you just need to identify the times you want cover then set a state to seek cover like in range of an enemy or if they are moving to a position and stopping there. Then if you are using you might want to try using something like instance)nearest to locate the closest cover then have it navigate there.
 
Well just of the top of my head you don't need to check for cover every frame you just need to identify the times you want cover then set a state to seek cover like in range of an enemy or if they are moving to a position and stopping there. Then if you are using you might want to try using something like instance)nearest to locate the closest cover then have it navigate there.
Thanks. For finding cover I have some requirements for suitable cover and check up to 10 instances of cover around the object using a function called instance_nth_nearest I found on GMLscripts.com.
 
Top