DASH_library COMREF:

 

 

addweapons

addmagazines

allarmoury

allvariants

alphabet

ammo3

angle2compass

angle2hour

any2pos

armedandequiped

armedwith

arr2string

bestfit

boss

canmove2

canfire2

cargo

catafter

catbefore

comparearrays

compareheaps

count_buildingpos

cv2string

dec2bin

delimpoint

dir2obj

dirofmove

dist2d

dist3d

elevationangle

emptyslots

emptyslots2

equal

equiplikethis

equipedwith

facingdiff

getgroupid

getrandomvarname

grid2pos

handgun

hascommanderplace

hasdriverplace

hasgunnerplace

hiddenpos

idxdelete

idxtake

idxtoend

idxtostart

indexof

indexof2

inforest

inFOV

instr

int2array

intown

inverse

inwater

isnil

isenemy

isnight

lcase

lineparams

magmass

makearray

markerdist

max

merge2sorted

min

nearestmarker

populate

pos2grid

product

qsort

qsortM

radiostate

realyrandom

regexvariants

selectbykeys

setfog2

setovercast2

setrain2

setspeed

settime

shuffle

soundex

split

splitbyrule

splitbyarrays

squadnumber

sum

take

takernd

time2string

timewindow

transpose

trianglearea

typelist

ucase

unique

usermarkers

vartype

vehiclepos

vehicles

wind

without

 

 

 

 

 

Armouryweapons and magazines

 

Using module  System

 

1)  Man call emptyslots number of empty non-pistol slots of unit Man

 

2)  Man call emptyslots2 - returns 2 numbers number of empty non-pistol slots

 and number of empty pistol slots of unit Man

 

3)  Man call handgun – name of the pistol slot item of unit Man

 

4) MagazineName call magmassdetermines, how many slots will occupy this type of

magazine

 

5)UnitArray call ammo3 – modificated function ammo. Returns 3-element vector, containing

projectile number for each of 3 slots: primary, secondary and pistol. For empty weapon slots  element will be -1.

 

6)UnitArray call allarmouryreturns 2 vectors: list of all  weapons of unit array,

and list of all theirs magazines.

 

7)[UnitArray,WeaponNamesArray] call armedwith - returns 2 vectors:

list of units which has something from WeaponNamesArray in inventory and

list of all units guns, wich belongs to WeaponNamesArray.

Names of weapons are registry-depended!

 

8)[UnitArray,MagazineNamesArray] call equipedwithreturns 2 vectors:

list of units which has something from MagazineNamesArray in inventory and

list of all units mags, wich belongs to MagazineNamesArray.

Names of magazins are registry-depended!

 

9)[UnitArray,WeaponName,MagazineName,IntMinimalMags] call armedandequiped

returns vector of units, having WeaponName and not less then IntMinimalMags

of MagazineName.

 

10) Man call radiostate – radio state.

 >0:radio can work, 0:no battery charge,-1: not has radio. 

 

11) [unitArray,strUnitType] call equiplikethis equip each unit in unitArray

with typical ammunition of strUnitType .

 

12) Unit call  canfire2for soldiers returns true, if he has some ammo and some weapon,

for wehicle returns true if guns are not heavy dammaged and there is at least 1 charged gun.

Binoculars, nightvision and car horn are not considerated as weapons.

 

13) [Unit, MagazineNamesArray] call  addmagazines or

    [Unit, MagazineName, MagsCount] call  addmagazines – equip unit with all mags from MagazineNamesArray, or equip him with MagsCount magazines of type MagazineName.

 

14) [Unit, WeaponNamesArray] call  addweapons  – equip unit with all weapons from array.

 

 

Examples: armory.Intro and armory2.Intro

 

 

 

Arraysarray(vector) processing

 

Using module  System

 

 

1) [Array,N]call shuffle - intermixing -  shift random pairs of array elements N times

 

2) Array call inverseinverse array

 

3) [Integer,Item]call populate -  repeat element Item Integer times

 

4)[Array,N]call taketake first N elements from Array (take from left if N>0, take from right/tail if N<0)

 

5) NumericArray call sumsum of array elements

 

6)  NumericArray call productproduct of all array elements

 

7)[Vec1,Vec2]call withoutremove from the vector Vec1 corresponding elements of Vec2,

 [[1,2,2,3,3,3],[3,1,2]] call without  returns [2,3,3]

 

8)[Array,N] call takernd take N elements from array with random non-repeating indexes.

 

9)[Array,Condition]call splitbyrule - split Array into 2 parts using string Condition

(if element call Condition=true then put it into first array else put it to second one)

 

10) [Array,Indexes]call idxtostartshift elements with Indexes to the head of Array

 

11) [Array,Indexes]call idxtoend - shift elements with Indexes to the tail of Array

 

12) [Array,ConditionList]call bestfit element of Array, what best fit to the ConditionList

 

13) [Array1,Array2]call merge2sortedmerge 2 ordered in ascending order arrays

 

14) [Array,ArrayOfArrays]call splitbyarrays -  split elements of  Array among the ArrayOfArrays

 

15) Arithmetic progressions

[start,end,step]call makearray – numeric array from start, not exceed end,

with step.

[start,end]call makearray - (default step=1)

 

16) [Array1,Array2] call comparearrays compares 2 arrays element by element.

 

17) [Array1,Array2] call compareheaps compares 2 arrays with no respect to element order

 

18) [Array,IntegerArray]call idxtaketakes elements from Array with indexes

IntegerArray (repeating is possible). Returns an array.

 

19) [Array,IntegerArray]call idxdeleteremove elements from Array with indexes

IntegerArray (repeating is possible). Returns an “cleaned” array.

 

 

Examples: arrays.Intro, arrays2.Intro and arrays3.Intro

 

 

 

Convertion converts one values to another ones

 

Using module  System

 

1)  Angle call angle2hourdegrees 0-360  to hours 1-12

 

2) Angle call angle2compass - degrees 0-360 to compass bearing (string)

 

3) [X,Y]call pos2grid - [X,Y]coordinates to grid name(string)

 

4) [Oclock,TimeFormat] call time2stringformat time Oclock (in hours)according pattern TimeFormat. Defined patterns: "HH", "HHMM", "HH:MM", "HH:MM:SS", "HH:MM:SS:MM".   

Default pattern is "HHMM" («military time» in US army)

 

5) Number call int2arraynumber to array of digits

 

6) StrQuad call grid2pos grid name(string)to [X,Y]coordinates 

 

7) [Array]call arr2stringmerge array elements into 1 string, using space as delimiter

    or

   [Array,String]call arr2string - merge array elements into 1 string, using String as delimiter

 

 

8) dec2bin

 

Examples: convertion.Intro

 

 

 

Environ    interaction with environment

 

Independent module

 

1)  call isnight - return true in night time

 

2) Position call inwater - return true, if Position is under water

 

3) Obj call intown - return true, if object is in town/in village

 

4) Building call count_buildingpos number of predefined positions in Building

 

5) [Position,Radius] call inforest - true, if there is a forest in the range of Radius

 meters from Position (several trees!=forest).

 

6) Number call settimeset time to number hours.

 

 

3 functions below works correctly, if starting levels of fog and rain ðàâíû 0,

and starting level of overcast = 0.5. Whis is default weather options in mission editor.

 

 

7) [Time, Level] call setfog2 –works like time setFog fog,

but also allows to find current fog level, which carried in  fog global variable

and changing while function  setfog2 ends all work.

Time of fog level changing must be in seconds, fog level must be in range 0(no fog)- 1(maximal possible fog)

 

8) [Time, Level] call setovercast2 – clouds control, see setfog2

 

9) [Time, Level] call setrain2 – rain control, see setfog2

 

 

10) windnot the function but global varisble, contains current wind direction

in degrees and current wind speed(in meters per second)

 

 

Examples: environmental.eden

 

 

 

Geometry decides different geometrical problems

 

Independent module

 

1)  obj call dirofmove direction of moving object Veh in degrees

 

2)[Watcher,Target] call facingdiff absolute difference between face direction

 of unit Watcher and the angle from  Watcher to object Target(in degrees)

 

3)[Watcher,Target] call dir2objdirection in degrees from Watcher to Target

 

4) [Shelter,Guard,StepBack]call hiddenpos – find position StepBack  meters behind

the Shelter, to hide some unit from the unit Guard

(Let Shelter be big enought, opaque and with no windows)

 

5) [obj1,obj2] call  inFOVtrue, if obj1 in field of view obj2

 (less then 43 degrees from the sight line of obj1)

 [obj1,obj2,FOV] call  inFOV – 3rd argument= custom field of view angle/2

 

6) [obj1,obj2] call elevationanglevertical angle from  obj1

to obj2. If first object located higherthe result >0 degrees.

 

7) [Position1, Position2]  call  dist2d distance between positions on map

 

8) [Position1, Position2]  call  dist3d distance between positions in 3-D word

 

9) [Position1, Position2]   call  delimpoint point between 2 positions

which divides line segment in some proportion (default proportion=1/1=1)

 

10) [Position1,Position2,Position3] call trianglearea – triangle area with

sign of rotation.

 

11) [Position1, Position2]call lineparams a and b coefficients

of the line Y=a*X+b, painted from one position to another.

 

Examples: geometry.Intro and geometry2.Noe

 

 

Groups  affects on groups and units

 

Independent module

 

1) [Unit1,Unit2]call isenemy - is Unit2 a visible enemy of Unit1

 

2) Unit call getgroupid or

Group call getgroupidvector with the  name and color  of particular unit/group

 

3)Unit call bossunit becomes a leader in his group.

 

4)unit call squadnumberreturns unit number in squad, this is a number unit use in group chat.

 

 

Examples: groups.Intro

 

 

 

Markers  works with markers on map

 

Independent module

 

1) call usermarkers return array of all usermarkers.

Deleted usermarkers will not be shown.

 

2)[«Marker1», «Marker5»] call markerdist distance between 2 markers.

 

3)[Pos,Markerarray] call nearestmarker or

  [Pos,Markerarray,Maxdistance] call nearestmarker

        marker from Markerarray, closest to position Pos. You also can use maximal

search radius.

 

Examples: markers.Intro

 

 

 

 

Systembase functions

 

This independent module need for correct work of modules Armoury, Arrays , Text and Vehicles.

 

1) [VarName] call isnil or

   «VarName» call isnil return true, if variable VarName not defined,

 or destroyed with expression VarName=nil

 

2) Variable call  vartype return variable type («number»,«string»,«array»,«bool»,«side»,«object» or «group»).

 

3) Array call uniquereturn all element types from array(only unique elements)

Array may contain numbers, strings, objects and groups.

Strings are case-sensitive.

 

4) Array call  typelist  array of unique elements and corresponding array of

Element types from array Array. Strings are case-sensitive.

 

5) NumericArray call minminimal element and corresponding index

 

6) NumericArray call max - maximal element and corresponding index

 

7) [item,Array]call indexof find the position of  item in Array;

Return -1 if no such element.

 

8) Integer call realyrandom array of random numbers, constantly distributed between 0 and 1. OFP generates not very «clean» random numbers, this function realize MATLAB algorithm.

 

9) [var1,var2]call equalcompares 2 variables despite of it’s type.

Not recommended for big array comparison,  use comparearrays instead.

 

10)  call getrandomvarnamereturn string like tmp_abcd, where abcd is a random

latin letter combination (~450 000 variants). You can use this string as a free

global variable name to get some info from scripts.

 

11) [ArrayKeys,ArrayRecords] call selectbykeys return records from the table

ArrayRecords, which starts from corresponding elements of ArrayKeys.

 

12) ArrayOfArrays call transposearray of rows to array of columns.

 

13)) [Integer,Item]call populate -  repeat element Item Integer times

 

14) ArrayOfArrays call  allvariantsall combinations: for [[true,false],[1,2,3],[“a”, “b”]]it will be an array of 12 arrays - from [true, 1, “a”] to [false, 3, “b”]

 

15) [item,ArrayOfArrays] call  indexof2 -  index of the first array in ArrayOfArrays

which contains item; return «-1» if no such array. Strings are case-sensitive.

 

16) NumArray call qsort sort an array in ascending order. Method - fast sort.

 Returns no result,deals with array itself.

 

17) [NumArray,Array1,Array2...ArrayN] call qsortMsort several arrays in ascending order of

first array. Method - fast sort. Returns no result,deals with array itself.

 

18) array call any2pos or

    Object1 call any2pos or

    Group2 call any2pos or

    SomeMarkerName call any2pos return 3-D  position,

In case of group return the position of group leader.

 

 

Examples: base.Intro and base2.Intro

 

 

 

 

Textfunctions what works with strings and character(string) arrays   

 

Using module  System

 

1) CharArray call soundex – char array hash function

the result is 4-char array (1 letter + 3 digits)

 

2) CharArray call cv2string – merge char array to make 1 string

 

3) Any call alphabet – returns char array: latin alphabet. If first argument

 is  1, «l», or «L» - returns lowercase array, else – uppercase alphabet.

 

4) CharArray call lcase – char array to lower case.

 

5) CharArray call ucase –char array to upper case.

 

6)[Array1, Array2] call  instr –returns a position in Array1,

where starts Array2 or  -1 if no match.

 

7) [Array1,Delimiter]  call split –splits array on 2 subarrays,

using 2nd argument as a delimiter.

 

8) [Array_of_CharArrays, CharArray]call catafter èëè

[Array_of_ Strings,String]  call catafter – add string/string vector

to the end of each array element.

 

9) [Array_of_CharArrays, CharArray]call catbefore or

[Array_of_ Strings,String]  call catbefore – add string/string vector

to the start of each array element.

 

Examples: text.Intro

 

 

 

 

Vehiclesworks with transport

 

 

1) Unit call vehiclepos – unit position name in unit’s transport.

Awailable results: "Driver","Gunner","Commander","Cargo","None".

 

2) Vehicle call cargo -  array of units in cargo section of Vehicle

 

3) [Veh,NewSpeed] call setspeed – immediately set speed of Veh to NewSpeed

 

4) Vehicle call  hasdriverplace – self-evident

 

5) Vehicle call  hasgunnerplace – self-evident

 

6) Vehicle call  hascommanderplace – self-evident

 

7) Vehicle  call  canmove2 – modification of native canmove, it also

checks fuel level and driver position presence.

 

8) UnitArray call vehicles – returns array of transports, occupied by UnitArray

 

 

Examples: vehicles.Intro

 

 

 

 

STEALED BORROWED

 

Some of discribed functions are renamed and/or revorked functions,

originally created by experiensed scripters from OFP community:

Respect for this SQF-masters:

 

Baddo - count_buildingpos

BINMOD team -dirofmove, vehiclepos

Bn880 - vartype

The Chain of Command team  - transpose

Dschulle - grid2pos

ECP mod team - isnil

Faguss - qsort, qsortM

General Baron - indexof,squadnumber

LIBMOD team - cargo

Mandoble – inFOV

Raptorsaurus –  elevationangle, inforest

SLX mod team - radiostate, HOR_VehicleTester(model+config)

snYpir - dir2obj

 

 

Special thanks for Rinza (excellent OFP mission making tutorial)

 and for  DenVdmj ,who translated into Russian BIS scripting comref.