Example Code: Remove NVGs From Enemies: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Page creation) |
Lou Montana (talk | contribs) m (Add comments) |
||
Line 3: | Line 3: | ||
{{ArgTitle|{{arma3}}|2|{{GVI|arma3|1.55}}}} | {{ArgTitle|{{arma3}}|2|{{GVI|arma3|1.55}}}} | ||
[[private]] _enemySide = [[opfor]]; | [[private]] _enemySide = [[opfor]]; {{codecomment|// definition of the enemy side}} | ||
[[private]] _enemies = [[allUnits]] [[select]] { [[side]] [[_x]] == _enemySide; }; | [[private]] _enemies = [[allUnits]] [[select]] { [[side]] [[_x]] == _enemySide; }; {{codecomment|// selection of all enemy units ''from'' allUnits}} | ||
{ | { | ||
[[_x]] [[unlinkItem]] [[hmd]] [[_x]]; | [[_x]] [[unlinkItem]] [[hmd]] [[_x]]; {{codecomment|// removal of each unit's [[hmd]]}} | ||
} [[forEach]] _enemies; | } [[forEach]] _enemies; {{codecomment|// code is to be executed for each enemy}} | ||
{{ArgTitle|{{arma2}}|2|{{GVI|arma2|1.00}}}} | {{ArgTitle|{{arma2}}|2|{{GVI|arma2|1.00}}}} | ||
[[private]] _enemySide = [[east]]; | [[private]] "_enemySide"; {{codecomment|// private definition of the _enemySide variable}} | ||
_enemySide = [[east]]; {{codecomment|// value attribution to _enemySide}} | |||
{ | { | ||
if ([[side]] [[_x]] == _enemySide) [[then]] | if ([[side]] [[_x]] == _enemySide) [[then]] {{codecomment|// if the unit is on the _enemySide, process the next step}} | ||
{ | { | ||
_x removeWeapon "NVGoggles"; | [[_x]] [[removeWeapon]] "NVGoggles"; {{codecomment|// removal of the enemy unit's NVG}} | ||
} | } | ||
} [[forEach]] [[allUnits]]; | } [[forEach]] [[allUnits]]; {{codecomment|// going through ''all'' units}} | ||
[[Category: Example Code]] | [[Category: Example Code]] |
Revision as of 19:47, 17 August 2019
2
private _enemySide = opfor; // definition of the enemy side private _enemies = allUnits select { side _x == _enemySide; }; // selection of all enemy units from allUnits { _x unlinkItem hmd _x; // removal of each unit's hmd } forEach _enemies; // code is to be executed for each enemy
2
private "_enemySide"; // private definition of the _enemySide variable _enemySide = east; // value attribution to _enemySide { if (side _x == _enemySide) then // if the unit is on the _enemySide, process the next step { _x removeWeapon "NVGoggles"; // removal of the enemy unit's NVG } } forEach allUnits; // going through all units