Archive for category Demo Missions

On Demand Artillery Strike

This is from Riouken on the BIS forums:

The Grad is artillery you need to create a fire mission and execute it.  There is also a demo mission of this available.

// There is a arty logic ingame named arty1;
_myBattery = arty1;

// We need to make a arty fire mission template
_heTemplate = ["IMMEDIATE", "HE", 0, 15];

// We need the postion of the target Above Sea Level.
_targetPos = getPosASL target_1;

// Here we check and make sure it is range then we exicute the fire mission.
if ([_myBattery, _targetPos, _heTemplate select 1] call BIS_ARTY_F_PosInRange) then
     [_myBattery, _targetPos, _heTemplate] call BIS_ARTY_F_ExecuteTemplateMission;
     hint "Firing... Sit back and wait, it will take about 60-90 seconds for the rounds to impact";
} else
     hint "Target out of range!";

No Comments

Zone Restriction Signposts

R.Flagg on the BIS forums wanted to know how to give players a visual cue that they were leaving a zone restricted area.  The ZORA module is used to limit the area a player can leave by spawning groups to hunt them should they leave a trigger area.  Here’s a method (including a demo mission) of reminding the player they are about to enter a no-go zone.

This script uses code adapted from MH6 to create a ring of No Entry signs around a Zora trigger zone at 15m intervals. Main drawback is that since I suck at math the trigger has to be a circle. Perhaps some math wiz would be able to make this work with other shapes.

Run it from init.sqf as:

nul = [BIS_Zora_0] execVM "zoraSigns.sqf";
_zoraZone = _this select 0;
_zoraPos = getPos _zoraZone;

_sizeZone = triggerArea _zoraZone;
_angle = _sizeZone select 2;
_radius = _sizeZone select 0; // needs to be a circle with equal a and b
_distanceBetweenPosts = 15; // meters
_count = round((2 * 3.14592653589793 * _radius) / _distanceBetweenPosts);
_step = 360/_count;

for "_x" from 0 to _count do
	_a = (_zoraPos select 0)+(sin(_angle)*_radius);
	_b = (_zoraPos select 1)+(cos(_angle)*_radius);

	_pos = [_a,_b,_zoraPos select 2];
	_angle = _angle + _step;

	_post = "Sign_1L_Noentry_EP1" createVehicle _pos;
	_post setPos _pos;
	_relDir = [_post, _zoraZone] call BIS_fnc_DirTo;
	_post setDir _relDir - 180;

_mrkCrossName = format["%1CrossMarker",_zoraZone];
_mrkCross = createMarker[_mrkCrossName,_zoraPos];
_mrkCross setMarkerShape "ELLIPSE";
_mrkCross setMarkerBrush "CROSS";
_mrkCross setMarkerColor "ColorRed";
_mrkCross setMarkerSize [_radius,_radius];
_mrkCross setMarkerAlpha 0.2;

_mrkBorderName = format["%1BorderMarker",_zoraZone];
_mrkBorder = createMarker[_mrkBorderName,_zoraPos];
_mrkBorder setMarkerShape "ELLIPSE";
_mrkBorder setMarkerBrush "BORDER";
_mrkBorder setMarkerColor "ColorRed";
_mrkBorder setMarkerSize [_radius,_radius];
_mrkBorder setMarkerAlpha 1;


Using BAF IEDs via scripting

The new BAF IEDs work like Satchel Charges. You can place them and detonate them within 300m remotely. You can even command, via the Action Commands, a grouped AI to place and Touchoff a BAF IED. A demo mission showing these commands at work is available.

There are two types of IED in BAF – garbage (shells under garbage) and ground (buried IED). Each type has a large and small explosion version:

Satchel charges in A2 just need “pipebombmuzzle” to be used via scripting. BAF IEDs are slightly more complicated, with each IED having it’s own muzzle name as shown here. An ammobox filled with IEDs is available under Empty -> Ammo -> Explosives Stash (or by using the BAF_IEDBox classname to create one).

IED Classnames and Muzzlenames:

BAF_ied_v1      BAF_ied_v1_muzzle
BAF_ied_v2      BAF_ied_v2_muzzle
BAF_ied_v3      BAF_ied_v3_muzzle
BAF_ied_v4      BAF_ied_v4_muzzle


In A2:BAF to get an AI to place an IED via scripting you use these commands:

To equip an AI with an IED:

this addMagazine "BAF_ied_v2";

To place an IED (replace the muzzle classname with the matching muzzle type for whatever class IED the unit has):

placingUnit Fire ["BAF_ied_v2_muzzle"]

To explode an IED:

anyUnit action ["TOUCHOFF", placingUnit];

The action command TOUCHOFF can use any unit to set off the IED. Even if the placing unit is dead.

IEDs can be set to explode via timer as well, just like a satchel charge.

Bug Notes:
Players will see incorrect labels in their action menu for these IEDs. They will see “Put IED (ground large)” for the V3 version which is actually just “ground”, the small charge.

V1 (garbage small) is also broken to various degrees. Players won’t even get the option to place it. If you use the action commands to tell an AI to place it your action will be blank and he’ll set it to 30 seconds automatically. Thankfully it’s a small bang!

1 Comment

Fire Detection – Undercover Team

Militantsausage on the BIS forums wanted a method of detecting if under cover units fired their weapons or left an area.

Here’s a demo mission. Try driving out of the compound; shooting someone; having your AI shoot someone; having an AI walk out of the compound.

Three triggers are needed.  The group is named uct.

First trigger covers the compound, Anybody Present Repeatedly, named compound.


{vehicle _x in thislist} count units uct < count units uct

No onAct needed.

Second trigger, no size or settings.


triggerActivated compound


{_x setCaptive false;} forEach units uct;

Third trigger just assigns the eventHandlers, this could do in an init or init.sqf or wherever really.




{_x addEventHandler ["fired", "{_x setCaptive false;} forEach units uct;"]} forEach units uct;

That’s what checks if any of your guys fired and drops their captive state if they do.


MarketDay – a random suicide bomber script.

Here’s a version of a “random hunter killer suicide bomber” script. The best part is if called right, you’ll never know who the bomber is till it might be too late.

Call the script from a Trigger to pick a random bomber:

nul = [thislist select floor(random count thislist), WEST, 7, 20, true, true] execVM "hkRandom.sqf";

or from a unit’s init field to specify the bomber:

nul = [this] execVM "hkRandom.sqf";

There are optional arguments for the side to attack, percentage chance to attack once a target is found, range to start looking for targets within, whether or not to warn the group that’s being attacked and an optional sound file to be played by the attacking bomber.

MarketDay is a demo mission where you can see this script in action. Here’s the code:

// Function file for Armed Assault 2
// Created by: kylania
// Based on code from SNKMAN
//  Examples: 
//  Called from a trigger, Civilians - Present - Once to set 1 bomber out of preset Civs, attacking WEST, 70% chance of attack and 50m range.
//  nul = [thislist select floor(random count thislist), WEST, 7, 50] execVM "hkRandom.sqf";
//  Called from a unit's init, 100% chance to attack EAST units within 100m with a warning and shout.
//  nul = [this, EAST, 10, 100, true, true];
//  Default, attacking WEST targets 30% of the time within 20m warning the group but not yelling out a shout.
//  nul = [this] execVM "hkRandom.sqf";

_unit = _this select 0;  // Bomber unit, set randomly by trigger.
_side = if (count _this > 1) then {_this select 1} else {WEST};  // Side to attack, default West.
_prob = if (count _this > 2) then {_this select 2} else {3};  // Probilitiy of attack once a target is found, Number 1 - 10, higher = more chance.  Default 3 (30% chance or so);
_range = if (count _this > 3) then {_this select 3} else {20};  // Range to look for targets in, default 20m.
_warn = if (count _this > 4) then {_this select 4} else {true};  // Option to warn the attacked group, all group members will target the bomber, AI won't shoot civs though.  Default true.
_shout = if (count _this > 5) then {_this select 5} else {false};  // Option to make the bomber say a sound (declared below) before attacking.  Default false.
_sound = "allahu";  // Sound file declared in CfgSounds in description.ext for use with _shout option.

// Defaults.
_looking = true;
_target = objNull;

// Set to true to see status messages from the bomber.
_demo = true; 

if (isServer) then {

  // Init the target array.
  if (isNil "TargetArray") then {TargetArray = [];};

  // Start hunting.
  while {_looking} do {
	_targets = _unit nearTargets _range;  // Check targets within range.

	if (count TargetArray > 0) then {_targets = _targets - TargetArray;};

	// We have targets in range...
	if (count _targets > 0) then
		_count = 0;
		while { (_count < count _targets) } do
			_selectTarget = (_targets select _count);
			// Make sure we know about the target and that they match the side we want to attack.
			if ( (_unit knowsAbout (_selectTarget select 4) > 0) && (_selectTarget select 2 == _side) ) then
				TargetArray = TargetArray + [_selectTarget select 4];  // Grab the target unit objects
		_count = _count + 1;

	// If we have valid target objects...
	if (count TargetArray > 0) then {
		// Lets see if we're ready to die...
		_chance = round(random 9) + 1;
		// Demo text.
		if (_demo) then {_txt = format["Probability: %1, Roll: %2",_prob, _chance]; titleText[_txt, "PLAIN"];};
		// If the bomber is ready to die, stop looking and pick one of the random targets found...
		if (_chance <= _prob) then {
			if (_demo) then {hint format["Found these targets: %1", TargetArray];};
			_looking = false;
			_target = TargetArray select floor(random count TargetArray);
		} else {
			// The bomber is NOT ready to die, so do nothing.
			if (_demo) then {hintSilent "Sill hunting, not ready to die...";};
	} else {
		// No targets found so do nothing.
		if (_demo) then { hintSilent "Still hunting...";};

	// Wait a while and clear any targets previously found.
	sleep 5;
	TargetArray = [];

  // At this point we've found a target (broke out of loop via _looking = false)

  // Charge at the target!
  _unit SetUnitPos "Up";
  _unit SetSpeedMode "Full";
  _unit SetCombatMode "Red";
  _unit SetBehaviour "Careless";
  if (_demo) then {hint format["INCOMING for you %1!", _target];};

  // Shout or warn per options
  if (_shout) then {_unit say [_sound,5]};
  if (_warn) then {units (group _target) commandTarget _unit};

  // Make the bomber keep chasing the target till dead or within 3m.
  while {alive _unit && (_unit distance _target > 3)} do {
	_unit doMove getPos _target;
	sleep 3;

  // We're in range, make sure we're still alive then pull the pin!
  if (alive _unit) then {"grenade" createVehicle getPos _unit};