Skip to content

Useful Commands

jonpas edited this page Aug 6, 2023 · 37 revisions

This page is for utilising fun or immersive things in missions.

Most if not all of these should be placed inside init.sqf and never in the object init field in the editor.


A.I

This section is dedicated to things you can do with AI.


Combat Unloading

When utilising helicopters in missions units being held in vehicles away from the AO more often than not do spot helicopters, eject from their vehicles and go into combat mode. Essentially even if the pilot doesn't see these units they have become useless. The vehicle will move away without the QRF when activated.

The example on the wiki is: _veh setUnloadInCombat [true, false];

The first part of the command needs to be a vehicle variable name, not the driver.

The second parts are allowing Cargo to dismount and allowing Turrets to dismount.

To prevent any units from dismounting before you force them to you simply need to use Example_Vehicle setUnloadInCombat [false, false];

This doesn't need to be changed if you use a waypoint for "Transport Unload" as they will be ordered to dismount by themselves.


Forcing Flashlight Use

This uses the command enableGunLights

This can be done via:
Example_Group_1 enableGunLights "ForceOn";

or if you have multiple groups you want lights on:

{
    _x enableGunLights "ForceOn";
} forEach [Example_Group_1, Example_Group_2, Example_Group_3];

Limit Speed

Vehicles in Arma can have their speed limited if required, in my experience it does seemingly limit the amount of accidents the AI get into.

A basic example of utilising this is:

ExampleVehicle limitSpeed 50;

The vehicle itself (not the unit driving it) needs a variable name and using the above command will not allow it to go above the speed specified until it reaches it's destination or you change the speed it's allowed to travel at.

The wiki has examples of using loops but that is for much older versions of Arma, it now remains set without being looped.


CBA Functions

This section is for utilising CBA functions.

Wait and Execute

Wait and Execute is the ONLY option when wanting to execute code with delays. There will be no sleep.

A useful method to using it is:

if (isServer) then {
    ied_1 setDamage 1;

    [{
        ied_2 setDamage 1;
    }, [], 1] call CBA_fnc_waitAndExecute;

    [{
        ied_3 setDamage 1;
    }, [], 2] call CBA_fnc_waitAndExecute;

    [{
        ied_4 setDamage 1;
    }, [], 3] call CBA_fnc_waitAndExecute;
};

In this example, when the code runs it will detonate ied_1 then the others with a 1 second delay.

[{ CODE HERE }, [PARAMS], DELAY] call CBA_fnc_waitAndExecute;

The delay is not time since the last one ran, it is time after the block starts. So for code that runs in sequence of 5, it's 5, 10, 15 & 20 instead of using only 5 in each.


Task Patrol

Task Patrol is a useful function for having units dynamically patrol an area with optional "searching" capabilities.

Note: Using this requires you to toggle the "Headless Blacklist" checkbox under Attributes > ACE Options.

Parameters:

  1. Group Variable Name
  2. Position (Default: Group, for markers use getMarkerPos "MarkerName")
  3. Radius in meters
  4. Waypoint count (How many waypoints this will generate)
  5. Waypoint Type (Example: "MOVE")
  6. Behaviour ("CARELESS", "SAFE", "AWARE", "COMBAT", "STEALTH")
  7. Combat Mode (See Here)
  8. Speed Mode ("UNCHANGED", "LIMITED", "NORMAL", "FULL")
  9. Formation (See Here)
  10. Code to execute at each waypoint (Default: "this call CBA_fnc_searchNearby", Can simply change to "" to not use this feature.)
  11. Timeout at each waypoint, Min/Med/Max gravitating towards Medium.

Example:

[MyGroup, nil, 300, 7, "MOVE", "AWARE", "YELLOW", "FULL", "STAG COLUMN", "this call CBA_fnc_searchNearby", [3, 6, 9]] call CBA_fnc_taskPatrol;

This example will setup a 300m, 7 waypoint patrol in staggered column around the group. Stopping for 3-9s between waypoints and conducting a small search.

Alternative Example:

[MyGroup, getMarkerPos "MyMarker", 100, 3, "MOVE", "COMBAT", "RED", "LIMITED", "WEDGE", "", [0, 0, 0]] call CBA_fnc_taskPatrol;

This example will have your group setup a 100m, 3 waypoint patrol in Wedge around your marker position with no delay on waypoints or searching involved.

Code should be ran from initServer.sqf

Note: Because these won't be ran on the headless client, don't spam usage of this in a single mission. We use headless clients for a reason.


Task Defend

Task Defend is a function for having a group take control of an area by garrisoning buildings, manning unmanned turrets and patrolling the vicinity.

Note: Using this requires you to toggle the "Headless Blacklist" checkbox under Attributes > ACE Options.

Parameters:

  1. Group Variable Name
  2. Position (Can be Group, Object or Marker.)
  3. Radius in meters
  4. Threshold, minimal amount of positions in building to be considered for garrison.
  5. Patrol Chance, can be true (100%) or false (0%) or a number between 0.1 - 1
  6. Hold Garrison Chance, works the same as above. Can be used to simulate units moving to engage instead of waiting to die.

Example:

[MyGroup, getMarkerPos "MyMarker", 100, 1, 0.5, 0.5] call CBA_fnc_taskDefend;

The example should have your group search for buildings and setup patrol routes 100m around your marker with a 50% chance of patrolling and 50% chance of leaving the garrison to engage.

Alternative Example:

[MyGroup, MyGroup, 50, 3, false, true] call CBA_fnc_taskDefend;

This example should have your group search for buildings 50m around the groups starting position with 0% chance of patrols and 100% chance of leaving the garrison to engage.

Code should be ran from initServer.sqf

Note: Because these won't be ran on the headless client, don't spam usage of this in a single mission. We use headless clients for a reason.


Immersion

This has examples of some commands for useful immersion features in missions.


Cellphone Ringing

This uses the playSound3D command.

playSound3D ["z\ace\addons\explosives\data\audio\cellphone_ring.wss", example, false, getPosASL example, 1, 1, 50];

for this to work properly, you must specify a path to the sound which is already present. Then follow it with the Object that will make the sound, this can be anything but it must have a variable name.

example, false, getPosASL example, 1, 1, 50]; These are the last parameters required.

  • example = Object making the sound
  • false = is inside
  • getPosASL example = location of the object making the sound
  • 1 = Volume, this is capped to 5.
  • 1 = sound pitch, don't touch this.
  • 50 = distance, the distance at which you can hear the sound.

Base Alarms or Ambient Firefights

This uses the createSoundSource command.

You can create a simple base alarm by utilising the following:

if (isServer) then {
    tac_baseAlarm = createSoundSource ["Sound_Alarm", position Example_Object, [], 0];
};

This is wrapped in if (isServer) then { for a reason. If it is not it will execute globally and you'll have more than 1 alarm playing at once and it's bad. There will be no global sound sources.

The parameters of this are:

  • The Sound (the wiki has a list of preconfigured ones)
  • Position of an object, usually using a loudspeaker or something.
  • Marker array, unless you want a randomly placed soundSource leave it as []
  • Random radius around the object for the soundSource to be placed in, recommended to leave as 0.

One final note on using this: Have a way of stopping it.

in this case, the "vehicle" is tac_baseAlarm and can be deleted with deleteVehicle.

if (isServer) then {
    deleteVehicle tac_baseAlarm;
};

This will end the looped sound and bring peace and quiet.


Map Markers

If you want your map markers to be toggled on and off in the mission to not clutter the map you can use the following.

Enter into fn_briefing.sqf

_player createDiaryRecord ["Diary", ["Toggle Markers", "
            <br/><font face='RobotoCondensedBold'>Toggled markers are local to you, not global.</font face>
            <br/>
            <br/><font color='#39823b' face='RobotoCondensedBold'>Objective Markers</font color>
            <br/><execute expression = '{_x setMarkerAlphaLocal 1} forEach tac_ObjectiveMarkers;'>On</execute>/<execute expression = '{_x setMarkerAlphaLocal 0} forEach tac_ObjectiveMarkers;'>Off</execute>
            <br/>
        "]];

Then enter the following line into init.sqf with the markers you want to be togglable.

tac_ObjectiveMarkers = ["Marker_1", "Marker_2", "Marker_3", "Marker_4"];

Other

This section covers anything that doesn't fit into other categories.


Adding wheels to vehicles

Friendly vehicles should have wheels inside the cargo space. It can be done in 2 ways either via the vehicle init box or by initServer.sqf

This is one of the rare cases using an editor init field is acceptable, it's also much easier than doing it via initServer

Init Box:

if (isServer) then { 
    ["ACE_Wheel", this, 4] call ace_cargo_fnc_addCargoItem;
};

initServer:

["ACE_Wheel", My_Vehicle, 4] call ACEFUNC(cargo,addCargoItem);
{
    ["ACE_Wheel", _x, 4] call ACEFUNC(cargo,addCargoItem);
} forEach [My_Vehicle, My_Vehicle2];

Custom AAR Message

Will become available with Modpack v4.0.0 (OCAP v2).

General messages can be added to the AAR timeline. Execute the following event with your own text from wherever, but only on one machine (wrap in isServer or similar if executing from a global trigger). Note: Do not modify "generalEvent"!

["ocap_customEvent", ["generalEvent", "The data drive has been recovered!"]] call CBA_fnc_serverEvent
Clone this wiki locally