Friday, September 2, 2011

ArmA 2 Operation Arrowhead - Herding Cats: Trying to Get the AI to Stay at and Fight from a Bunker

If you don't look too close, because AIs from all games will do stupid things, the one in ArmA 2 OA is more than decent. Most loved AI trait in my early days after installing the game: how they fire and maneuver against the enemy. Most hated AI trait this past week: how they fire and maneuver against the enemy ...

I'm trying to edit scenarios where the AI defends from the relative safety of a sandbag bunker and the first attempts have been frustrating.

After some Googling I found some old threads in several discussion forums. All good information, most of it beyond my grasp. So, I'm settling for a relatively simple way to get the enemy AI within the bunkers and them to stay there.

First off, a clarification. I'm no expert ArmA 2 mission editing. The editing tools for ArmA 2's engine are very powerful. From the most humble trigger, passing through elaborate scripts that use a specific programming syntax, all the way to full blown script modules that you plug into the mission to get new and exciting AI behaviors not present in the out of the box version of the game.  ArmA 2's editor is a dream and I can only wish to have more time some day to just scratch the surface. So for those readers out there who are capable of displaying the latest news, the real time value of their portfolio or the local weather in a billboard of  a Takistani town, this post will be rubbish.

Here is what I want to do. I have placed a 4 men Takistani infantry section in two bunkers that overlook an abandoned gas station. Each Takistani infantryman is set to "Special=None" (this means no formation of any sort). A US infantry man will run across the gas station, from cover to cover. I want the Takistanis to fire from their bunkers. The scenario is a test, don't make too much out of it

First try: fire, movement and failure

The setup. The Takistani men (red circles) are overlooking the gas station. Note the blue circle: that's the US infantryman. He will move northwest to the next covered position.

A close up of the Takistani's start position. Those orange things are bunkers.

As soon as the scenario starts, the Takistanis move out of their bunkers. The quickly adopt a default "vee" formation. Even when the special field of each soldier is set to "none" (as opposed to "in formation"). Fails.

But wait, there is more! Right after seeing the American, the Takistanis move two hombres ahead to hunt him down. It's like the bunkers were built just for shade. Fails.

Second try: the Takistanis stay ... blind!

In the next setup I removed those pale blue lines that establish the command structure (compare with previous setup close up image).

And yes, the Takistanis stay in the bunkers at the start of the mission. Success?
The sight of the American spooks the Takistanis and they hit the dirt to never rise again. Can't shoot what you can't see. Fail.
The Takistanis sudden love for mother earth prompts the American soldier for some good old fish-in-a-barrel shooting. Fail.

Third try: fire without movement 

In this new setup I added a line of code at the initialization field of each Takistani soldier. All other things, including the removal of the blue command lines stayed the same. Also note the special field set to "none": if you set it to "in formation" the Takistanis will start the scenario in a default "vee" formation.
That line of code made the Takistanis to start, stay and fire at/from the bunkers. Success.

Well, you can always find a way around the system. In this screenshot, I sneaked through dead ground. Very quietly. The AI noticed me only after I blew out this guy's head.

In conclusion, I'm going to be using what I learnt to set up the enemy AI within bunkers. There are several other possible ways to do it. Some work great, others not so. For example, some people use the following piece of code in the initialization field of the AI units: this disableAI "move". This piece of code freezes ANY type of movement, including rotating towards a threat, but it can be useful in some limited situations. Other very popular piece of code in the initialization field is doStop this. So far I didn't see any difference between this last piece of code and just removing the blue lines of command. But I may be wrong. Ideas for further exploration, that's for sure.



Anonymous said...

Haven't had Arma 2 installed for awhile, but if I remember correctly, you'll find already manned bunkers or perhaps machine-gun nests in the editor under "Units/Static". Hope this is helpful.

kylania said...

To prevent then from going back into formation at the start put this in their init fields in the editor:

doStop this;

It basically will break the unit out of formation. They'll still follow commands like rearm and target and all that, just won't try to respond to formation orders.

They'll also stop where they are to engage enemy units, exactly what you want. :)

Dylan said...

You should get Zeus AI mod if you have not already, Makes the AI so much more realistic.

There is the download link if you want to try it out. :)

RangerX3X said...

this setUnitPos "up"; doStop this is the easiest way to get where you want to go -

The trick is to place the units as individuals first, not as a group first then ungrouping them by F2 to remove the blue line.

Set five individual units with the Special field at "none" all in a straight line. Place the following code in each units (yes, each) initialization field:

this setUnitPos "up"; doStop this

You can use "middle" as well to have them in a permanent crouch. There is no need to name any unit.

Then have waves of enemy attack the position - the units will stand their ground until their death, but as individual units not sharing information because they are not grouped.

After they are set, then you can use F2 to group them together to share information and the group leader can issue targeting orders, and they will still stay put and fight to the death (at least they do for me).

JC said...

Thanks for your comments, gents.

Dylan! That mod is just great. I have it installed and I am using it for my latest games.


Лео said...

oh, you have 2ng lv and up comments disabled. I wanted to respond to kylania, in my experience doStop does nothing. it does break the formation (which is supposed to already be broken, since special is set to "none"), but when there's an enemy force approaching, the units don't hold their ground, they just scatter. the only way to combat this was the disableAI command (thank you for mentioning it, JC).

anyway, I was wondering if somebody has had better experience with doStop. Ranger here seems to be implying it works if the unit was never a part of a group. but I have no idea how to do that, since every time I create a unit he is automatically assigned to an existing unit)

Anonymous said...

Think AI combat modes play an important role too: