Example Code: Remove NVGs From Enemies: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\{\{( *)Informative( *)\|" to "{{$1Feature$2|$2Informative$2|") |
Lou Montana (talk | contribs) |
||
Line 7: | Line 7: | ||
[[private]] _enemySide = [[opfor]]; {{cc|definition of the enemy side}} | [[private]] _enemySide = [[opfor]]; {{cc|definition of the enemy side}} | ||
[[private]] _enemies = [[allUnits]] [[select]] { [[side]] [[_x]] == _enemySide; }; {{cc|selection of all enemy units ''from'' allUnits}} | [[private]] _enemies = [[allUnits]] [[select]] { [[side]] [[Magic Variables#x|_x]] == _enemySide; }; {{cc|selection of all enemy units ''from'' allUnits}} | ||
{ | { | ||
[[_x]] [[unlinkItem]] [[hmd]] [[_x]]; {{cc|removal of each unit's [[hmd]]}} | [[Magic Variables#x|_x]] [[unlinkItem]] [[hmd]] [[Magic Variables#x|_x]]; {{cc|removal of each unit's [[hmd]]}} | ||
} [[forEach]] _enemies; {{cc|code is to be executed for each enemy}} | } [[forEach]] _enemies; {{cc|code is to be executed for each enemy}} | ||
Line 21: | Line 21: | ||
_enemySide = [[east]]; {{cc|value attribution to _enemySide}} | _enemySide = [[east]]; {{cc|value attribution to _enemySide}} | ||
{ | { | ||
if ([[side]] [[_x]] == _enemySide) [[then]] {{cc|if the unit is on the _enemySide, process the next step}} | if ([[side]] [[Magic Variables#x|_x]] == _enemySide) [[then]] {{cc|if the unit is on the _enemySide, process the next step}} | ||
{ | { | ||
[[_x]] [[removeWeapon]] "NVGoggles"; {{cc|removal of the enemy unit's NVG}} | [[Magic Variables#x|_x]] [[removeWeapon]] "NVGoggles"; {{cc|removal of the enemy unit's NVG}} | ||
} | } | ||
} [[forEach]] [[allUnits]]; {{cc|going through ''all'' units}} | } [[forEach]] [[allUnits]]; {{cc|going through ''all'' units}} | ||
Line 35: | Line 35: | ||
_enemySide = [[east]]; {{cc|value attribution to _enemySide}} | _enemySide = [[east]]; {{cc|value attribution to _enemySide}} | ||
{ | { | ||
if ([[side]] [[_x]] == _enemySide) [[then]] {{cc|if the unit is on the _enemySide, process the next step}} | if ([[side]] [[Magic Variables#x|_x]] == _enemySide) [[then]] {{cc|if the unit is on the _enemySide, process the next step}} | ||
{ | { | ||
[[_x]] [[removeWeapon]] "NVGoggles"; {{cc|removal of the enemy unit's NVG}} | [[Magic Variables#x|_x]] [[removeWeapon]] "NVGoggles"; {{cc|removal of the enemy unit's NVG}} | ||
} | } | ||
} [[forEach]] ''_unitsArray''; {{cc|going through ''provided'' units - [[allUnits]] has been introduced in {{arma2}}}} | } [[forEach]] ''_unitsArray''; {{cc|going through ''provided'' units - [[allUnits]] has been introduced in {{arma2}}}} | ||
Line 45: | Line 45: | ||
{{Feature | Informative | This is an [[SQS syntax]] example.}} | {{Feature | Informative | This is an [[SQS syntax]] example.}} | ||
{{cc|remove its NVG for each provided '''enemy''' units}} | {{cc|remove its NVG for each provided '''enemy''' units}} | ||
"[[_x]] [[removeWeapon]] ""NVGoggles""" [[forEach]] ''_enemyUnitsArray'' | "[[Magic Variables#x|_x]] [[removeWeapon]] ""NVGoggles""" [[forEach]] ''_enemyUnitsArray'' | ||
[[Category: Example Code]] | [[Category: Example Code]] |
Revision as of 12:57, 25 February 2021
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
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 _unitsArray; // going through provided units - allUnits has been introduced in Arma 2
2
// remove its NVG for each provided enemy units "_x removeWeapon ""NVGoggles""" forEach _enemyUnitsArray