Dynamic AI Creator Editor Placed Objects & JCOVE.

How To Use Units Placed In the Editor With DAC 2.0 and JCOVE.

So far I’ve concentrated on setting up my mission with random units generated by the DAC script. But what if you wanted to place units using the editor and then have the DAC script control their behavior and have them interact with the other DAC created units?
Glad you asked.

Inserting Units in the Editor

The first thing you will need to do is insert the units into the mission using the mission editor. I’m going to continue building on my existing DAC JCOVE mission, which last time I had added artillery support for the AI.

Just for jun I’m going to insert a civilian unit, but have the unit join up DAC as an insurgent. To do this I’m going to have to do some funny business in the editor to get JCOVE to treat the unarmed civilian as an insurgent, then I’ll do a bit of scripting to integrate my editor placed unit with DAC.

How to Create Civilian Insurgents

The first step is to insert a civilian man. I chose Iraqi Elder 1 and click ok.

Inserting a Civilian in the editor

Inserting a Civilian in the editor

The next step is to insert an insurgent; any Independent unit will do, it doesn’t matter. Before I click ok, I slide the Probability of presence: slide bar all the way to the left. This tells JCOVE that on each mission start there is a 0% probability of this unit being present. Next I set the Rank nice and high to Colonel then click OK.

Inserting an Independent unit in the editor

Inserting an Independent unit in the editor

So now I have two placed units in the editor, one civilian and one independent. Next I chose F2 group and join the two units into one group by clicking and dragging the mouse. The screenshot below shows you what I end up with; an independent and civilian in the same group.

Independent and civilian in the same group

Independent and civilian in the same group.

The civilian man inherits the side, behavior etc. of the group leader, the Independent Colonel, who will never appear in the mission. Next step, a bit of scripting to join my elderly civilian to DAC.

Embedding Editor placed units into DAC

Now for the scripting. first I double click on my elderly man in the editor and insert the following script into his Initialization field:

this setcaptive true;elder = group this;deleteWaypoint [elder,0];
  • this setcaptive true; This tells the AI that the unit is a captive & not a threat. If you don’t include this bit of code the BLUFOR AI will shoot our elderly unarmed man on sight.
  • elder = group this; Here I’m creating a global variable elder which I’ll use to reference the this unit’s group.
  • deleteWaypoint [elder,0]; DAC will not allow any editor placed objects with waypoints to be embedded into DAC. Even though we didn’t give the elder group any waypoints, every editor placed group is automatically assigned a waypoint at it’s starting location. This line of code will delete that initial waypoint 0 from the elder group.

At this point you’re done with the editor, so save the mission and alt-tab to your desktop. Navigate to your mission folder, open up your mission’s Init.sqf and look for the following line of code:

waituntil{DAC_Basic_Value == 1};

This line of code stops the execution of the init.sqf script until DAC is done initializing. Any code placed after this line will be executed after DAC gets initialized, so I stick the next bit of code on the next line:

 [elder,1,[op1,op2],5,2,2,[0,1,1],0] spawn DAC_fInsertGroup;

This is the code to insert my unit into DAC. The parameters are:

  • elder: name of the group I want to insert
  • 1: tells DAC that this is an infantry unit
  • [op1,op2] : my previously created OPFOR zones that elder will grab waypoints from
  • 5: number of waypoints to assign to this group
  • 2: side the unit belongs to – Independent
  • 2: behavior config I’m using
  • [0,1,1] DAC options – [Group Reduction off, Corpse Delete on, Call support on]
  • 0 : event config, which I’m not using

Now if I’ve done everything right, no typos etc. I should have a nice elderly man who will keep an eye out for BLUFOR, call up some DAC friends for support any maybe call an artillery strike or two onto the player.

Reference

Example mission used in post Morning Sweep v1_5
deleteWaypoint
setCaptive
waitUntil