Function Reference
warning.png Unfinished: This page is still under construction and needs to be completed.

CWE_Functions.pbo includes numerous general-purpose sqf-functions, for many kinds of tasks. They can be used in missions and mod scripting, and they are all fully compatible with all CWE systems.

This list is completely unfinished as it stands.

FUNCTION: USAGE:
AddCargo

Added in CWE version 0.92.

Description:
Add cargo (weapons and magazines) to a vehicle.

Syntax:
[Vehicle,MagazineArray,WeaponArray] call loadfile("\CWE_Functions\AddCargo.sqf")

  • "MagazineArray" is an array of magazines, and the amount of said magazines, to be added to the vehicle. For instance: ["CWE_M16Mag",10,"CWE_CARMag",8,"CWE_M14Mag",6]
  • "WeaponArray" is a similar array for weapons. For example: ["CWE_M16A2",2,"CWE_CAR15",3,"CWE_M14",1]
AddMagazines

Description:
Add magazines to a soldier.

Syntax:
[Unit,Magazine,Amount] call loadfile("\CWE_Functions\AddMagazines.sqf")

Example:
[this,"CWE_AK74Mag",6] call loadfile("\CWE_Functions\AddMagazines.sqf")

AmmoSufficient
ArrayToString

Description:
Format array's elements as a string.

Syntax:
[Array,Delimiter] call loadfile("\CWE_Functions\ArrayToString.sqf")

"Delimiter" is a string that is added between each element of the array. This parameter is optional.

Examples:
[SomeArray] call loadfile("\CWE_Functions\ArrayToString.sqf")
[SomeArray,"\n"] call loadfile("\CWE_Functions\ArrayToString.sqf")

BoolEqual

Description:
Check if two boolean values are equal.

Syntax:
[Bool1,Bool2] call loadfile("\CWE_Functions\BoolEqual.sqf")

Returns:
Boolean value. True if both input booleans were either true or false. False if one was true and the other false.

BoolState

Description:
Check if a variable with a boolean value is true, false or undefined.

Syntax:
Bool call loadfile("\CWE_Functions\BoolState.sqf")

Returns:
Number. 1 if the boolean value was true, 0 if false, and -1 if the variable isn't defined.

BuildingPosCount

Description:
Counts the number of A.I. positions in a building.

Syntax:
Building call loadfile("\CWE_Functions\BuildingPosCount.sqf")

Returns:
Number of A.I.-enterable positions in the building.

ChangeLeader

Description:
Replaces group's leader with another unit.

Syntax:
[OldLeader,NewLeader] call loadfile("\CWE_Functions\ChangeLeader.sqf")

ChooseMag
CountWaypoints

Description:
Counts the number of group's waypoints.

Syntax:
Group call loadfile("\CWE_Functions\CountWaypoints.sqf")

Returns:
Index number of the group's last waypoint.

Create

Description:
Creates an object, with the way of creation depending on the game mode. In singleplayer, CamCreate is used to create the object (for efficiency), whereas in multiplayer CreateVehicle is used (for compatibility), but the object is only created if the server is running the function, not if it is run by a client (to avoid creating multiple objects).

Syntax:
[ObjectType,3DPosition] call loadfile("\CWE_Functions\Create.sqf")

Returns:
Pointer to the created object. From CWE version 0.92 onwards, if no object was created (when a client tries to run the function), CWE_ObjNull is returned.

CreateEffect

Description:
Creates an object with CamCreate and adds it to CWE_MiscObj array. Objects in CWE_MiscObj are deleted from time to time to reduce effect objects' performance cost. For instance, blood effects and bullet holes are created with this function, so they will be removed when there are too much of them to be handled by OFP's engine.

Syntax:
[ObjectType,3DPosition] call loadfile("\CWE_Functions\CreateEffect.sqf")

Returns:
Pointer to the created object.

DirCardinal

Description:
Converts direction in degrees to a cardinal direction.

Syntax:
(GetDir player) call loadfile("\CWE_Functions\DirCardinal.sqf")

Returns:
String containing the name of the cardinal direction.

DirCardinal2 Description:
Same as DirCardinal, but doesn't include the hyphen in the direction name.
DirToPos

Description:
Calculates the direction from one position to another.

Syntax:
[Pos1,Pos2] call loadfile("\CWE_Functions\DirToPos.sqf")

Returns:
The direction from one position to another.

DisableErrors
DistancePos

Description:
Calculates the 2D distance from one position to another.

Syntax:
[Pos1,Pos2] call loadfile("\CWE_Functions\DistancePos.sqf")

Returns:
The 2D distance from one position to another.

DistancePos3D

Description:
Calculates the 3D distance from one position to another.

Syntax:
[Pos1,Pos2] call loadfile("\CWE_Functions\DistancePos3D.sqf")

Returns:
The 3D distance from one position to another.

DistRound
EmptySlots
EnemyDir
EstimatePos

Description:
Estimates a moving object's position after a specified amount of time.

Syntax:
[Vehicle,TimeStep] call loadfile("\CWE_Functions\EstimatePos.sqf")

Returns:
Position.

Arrays: AddArrays

Description:
Add the elements of two numeric arrays.

Syntax:
NewArray=[OldArray1, OldArray2] call loadfile("\CWE_Functions\a\AddArrays.sqf")

Returns:
Array of numbers.

Arrays: SelectCondition

Description:
Select items from an array according to a condition.

Syntax:
SelectedItems=[Array, ConditionCode] call loadfile("\CWE_Functions\a\SelectCondition.sqf")

  • "ConditionCode" is a string including the piece of code used as the condition. Inside the code, the variable "_x" refers to the current element of the array.(The same as with the original forEach and count commands). The code must evaluate to a boolean value.

Returns:
Array of elements passing the condition.

Example:
UnitsNear=[CWE_ALLMEN, {_x distance player < 50}] call loadfile("\CWE_Functions\a\SelectCondition.sqf")

Back to Mission Editing

SJ-Studios - 2009-2016

Contents created for Cold War Enhanced by SJ-Studios is licensed under ARMA PUBLIC LICENSE SHARE ALIKE (APL-SA)

The wiki and the textual content of CWE Wiki is licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International