Example Code: Remove NVGs From Enemies: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Add comments)
(Add Arma/OFP examples, remove stub and WIP)
Line 1: Line 1:
{{Stub}}
__NOTOC__
{{wip}}
{{ArgTitle|{{arma3}}|2|{{GVI|arma3|1.55}}}}
{{ArgTitle|{{arma3}}|2|{{GVI|arma3|1.55}}}}
{{Informative |
* [[opfor]] has been introduced in {{GVI|arma3|0.50}}
* {{Inline code|array [[select]] code}} has been introduced in {{GVI|arma3|1.55}}
}}


  [[private]] _enemySide = [[opfor]]; {{codecomment|// definition of the enemy side}}
  [[private]] _enemySide = [[opfor]]; {{cc|definition of the enemy side}}
  [[private]] _enemies = [[allUnits]] [[select]] { [[side]] [[_x]] == _enemySide; }; {{codecomment|// selection of all enemy units ''from'' allUnits}}
  [[private]] _enemies = [[allUnits]] [[select]] { [[side]] [[_x]] == _enemySide; }; {{cc|selection of all enemy units ''from'' allUnits}}
  {
  {
  [[_x]] [[unlinkItem]] [[hmd]] [[_x]]; {{codecomment|// removal of each unit's [[hmd]]}}
  [[_x]] [[unlinkItem]] [[hmd]] [[_x]]; {{cc|removal of each unit's [[hmd]]}}
  } [[forEach]] _enemies; {{codecomment|// code is to be executed for each enemy}}
  } [[forEach]] _enemies; {{cc|code is to be executed for each enemy}}




{{ArgTitle|{{arma2}}|2|{{GVI|arma2|1.00}}}}
{{ArgTitle|{{arma2}}|2|{{GVI|arma2|1.00}}}}
{{Informative |
* [[allUnits]] has been introduced in {{GVI|arma2|1.00}}
}}


  [[private]] "_enemySide"; {{codecomment|// private definition of the _enemySide variable}}
  [[private]] "_enemySide"; {{cc|private definition of the _enemySide variable}}
  _enemySide = [[east]]; {{codecomment|// value attribution to _enemySide}}
  _enemySide = [[east]]; {{cc|value attribution to _enemySide}}
  {
  {
  if ([[side]] [[_x]] == _enemySide) [[then]] {{codecomment|// if the unit is on the _enemySide, process the next step}}
  if ([[side]] [[_x]] == _enemySide) [[then]] {{cc|if the unit is on the _enemySide, process the next step}}
  {
  {
  [[_x]] [[removeWeapon]] "NVGoggles"; {{codecomment|// removal of the enemy unit's NVG}}
  [[_x]] [[removeWeapon]] "NVGoggles"; {{cc|removal of the enemy unit's NVG}}
  }
  }
  } [[forEach]] [[allUnits]]; {{codecomment|// going through ''all'' units}}
  } [[forEach]] [[allUnits]]; {{cc|going through ''all'' units}}
 
 
{{ArgTitle|{{arma}} / {{ofpr}}|2|{{GVI|arma|1.00}} {{GVI|ofpr|1.85}}}}
{{Informative |
* [[SQF syntax]] has been introduced in {{GVI|ofpr|1.85}}
}}
[[private]] "_enemySide"; {{cc|private definition of the _enemySide variable}}
_enemySide = [[east]]; {{cc|value attribution to _enemySide}}
{
if ([[side]] [[_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}}
}
} [[forEach]] ''_unitsArray''; {{cc|going through ''provided'' units - [[allUnits]] has been introduced in {{arma2}}}}
 
 
{{ArgTitle|{{ofp}}|2|{{GVI|ofp|1.00}}}}
{{Informative | This is an [[SQS syntax]] example.}}
{{cc|remove its NVG for each provided '''enemy''' units}}
"[[_x]] [[removeWeapon]] ""NVGoggles""" [[forEach]] ''_enemyUnitsArray''




[[Category: Example Code]]
[[Category: Example Code]]

Revision as of 13:21, 25 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


-wrong parameter ("Arma") defined!-1.00 ofpr version.gif1.85

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 _unitsArray;					// going through provided units - allUnits has been introduced in Arma 2


2

This is an SQS syntax example.
// remove its NVG for each provided enemy units
"_x removeWeapon ""NVGoggles""" forEach _enemyUnitsArray