In this blog post I’m going to share some tips on how to start with Arma agent entities, but first would like to say my separate thanks to Anthony and to Atomic Gaming Network for your support.
Keep it up you sexy mf
Agents. Nope, don’t mean rabbits and snakes, even though for some reason the word agent brings this association even to BIS devs. I’m talking about entities created with createAgent command and CAManBase class in particular. Why not make units and use them instead? Well, in my experience agents make for lighter and more obedient soldier and driver as well. So first thing is first, let’s create an agent:
As you can see I disabled AI FSM scripts that might have initialised with unit creation. Why did I do this? Because these scripts are looping and stopping the agent from following your orders. For example unless you disable FSMs moveTo command will have no effect. Disable FSM and agent will obey your every order.
I also set bevaviour to CARELESS. This will kinda guarantee your agent moves in straight line. I had an agent behaviour set to COMBAT, and when it was ordered to move to my position, it went around several buildings in circles before arriving to the destination. Apparently it was “sneaking” on me because of set behaviour. If there is no cover agent zigzags in combat mode which could also be undesired behaviour. Lets look at something a bit more complicated:
This will make bob run to you, then dive, then get up again and run. As you can see I used moveTo with getPosATL. You can use normal getPos but this could fail when position is in some structure, because getPos might report z == 0 while the position would be technically above the ground and AI might get confused as to exact whereabouts.
forceSpeed works too. The speed value needed could be obtained from getSpeed command, which is different for different vehicles as well. You cannot make AI sprint with it, but you can always playMove sprinting animation which will make AI sprint shortly.
To stop AI temporary use stop command, it is just like pressing pause button. If AI is moving when you stop it and try to set stance, AI will run and dive. Also I do not know if this is a bug or not, but you can setUnitPos to “MIDDLE” and AI will refuse to return to “UP”, you will have to force it “DOWN” first. Doesnt make sense so could be a bug, an old one at that too.
An alternative to moveTo could be setDestination command, which contained wrong information on BIKI so you wouldn’t be able to make it work. All corrected now, but brings a question, why no dev did anything about it for 6 years. Anyway, the difference between moveTo and setDestination is that you do not need to disable FSM, it works with FSM enabled and you can set different path finding modes. Again, not sure if bug or not, but expectedDestination command shows something else and not the destination and mode you set.
An agent as a driver is also possible and it might even be OK in certain cases, but AI driving is incredibly, incredibly buggy AI refuses to drive backwards no matter what! Just watch some of those vids before you decide if you are ready for this . I made maybe 15 takes before got AI drive forth and back on the same road without issues for the video above. Also, as you can see, for some reason AI stops way before the set destination. Add to it that “VEHICLE PLANNED”, which is supposed to be used for drivers sometimes fails, but “LEADER PLANNED” works a bit better.
Considering how important AI is for Arma series and that the game is also limited in so many ways *because* of AI inabilities or complexities, current AI implementation is Arma 3 is really poor. IMO Arma 2 had better and more interesting AIs. What I cannot understand is why AI is getting all these new features added like suppression and what not, while it remains kinda rotten at the core. You can experience AI driving first hand, here is the script I used in the video: