ArmA 3 Alpha: TL_fnc_removeGear, a script that allows custom gear removal from any unit

Overview

This function allows for quick, custom gear removal from any unit in ArmA 3.

Note: This function relies on another script that I have written, called TL_fnc_getParameter. TL_fnc_getParameter is a lightweight function that handles required and optional parameters passed to a script.

Read more about TL_fnc_getParameter and how to implement it

Basic Usage

TL_fnc_removeGear requires a unit to be passed as the first argument.

By default, with only a unit provided, the script will remove a unit’s weapons, headgear, uniform, vest, and night vision goggles. Leaving the map, radio, compass, and watch in the unit’s inventory.

// Replace X-X with version number, or provide appropriate filepath
TL_fnc_getParameter = compile preprocessFile "TL_fnc_getParameter_X-X.sqf"; 
TL_fnc_removeGear = compile preprocessFile "TL_fnc_removeGear_X-X.sqf";

/*********************************************************************
 * DEFAULT USAGE:
 * Remove: Weapons, Headgear, Uniform, Vest, Night Vision Goggles
 * Keep: Map, Radio, Compass, Watch
 ********************************************************************/
player call TL_fnc_removeGear;
// OR
[player] call TL_fnc_removeGear;

Custom Gear Removal

If you don’t like what the function removes by default, you can pick and choose what to remove. The function has 9 options to customize. True means it will be removed, and false means it will be kept.

The example below will remove everything from the player.

[
	player,  // Unit
	true,	// Weapons
	true,	// Headgear
	true,	// Uniform
	true,	// Vest
	true,	// Night Vision Goggles
	true,	// Map
	true,	// Radio
	true,    // Compass
	true 	// Watch
] call TL_fnc_removeGear;

TL_fnc_removeGear.sqf

Please note that TL_fnc_removeGear relies on another script that I have written, called TL_fnc_getParameter. TL_fnc_getParameter is a lightweight function that handles required and optional parameters passed to a script.

Changelog

April 5, 2013 – Version 1.2

  • Upgraded to use TL_fnc_getParameter v1.2
  • Function can now be called with either: player call TL_fnc_removeGear OR [player] call TL_fnc_removeGear
/*********************************************************************
 *
 * FUNCTION: TL_fnc_removeGear
 *
 * @description		Removes gear from the specified unit
 * @dependsOn		TL_fnc_getParameter.sqf
 * @author 			TechLethal
 * @website 		http://www.techlethal.com
 * @version 		1.2
 *
 *********************************************************************
 *
 * PARAMETERS { expected type, required/optional, default value }
 * Note: Remove = true, Keep = false for bool parameters.
 * 0 - { unit, required} The unit to remove default gear from.
 * 1 - { bool, optional, true } Weapons. 
 * 2 - { bool, optional, true } Headgear
 * 3 - { bool, optional, true } Uniform
 * 4 - { bool, optional, true } Vest
 * 5 - { bool, optional, true } Night Vision Goggles.
 * 6 - { bool, optional, false } Map
 * 7 - { bool, optional, false } Radio
 * 8 - { bool, optional, false } Compass
 * 9 - { bool, optional, false } Watch
 *
 *********************************************************************
 *
 * EXAMPLE 1 USAGE:
 * TL_fnc_removeGear = compile preprocessFile "TL_fnc_removeGear.sqf";
 * [player] call TL_fnc_removeGear;
 *
 * Based on the default values, example 1 will
 * remove the following gear from the player:
 * Weapons, Headgear, Uniform, Vest, Night Vision Goggles
 *
 *********************************************************************
 *
 * EXAMPLE 2 USAGE: 
 * TL_fnc_removeGear = compile preprocessFile "TL_fnc_removeGear.sqf";
 * [player, false, true, false] call TL_fnc_removeGear;
 *
 * Based on the default values, the above example
 * removes thefollowing gear from the player:
 * Headgear, Vest, Night Vision Googles
 *
 ********************************************************************/

private[
	"_debug",

	// Default values
	"_removeWeaponsDefault",
	"_removeHeadgearDefault",
	"_removeUniformDefault",
	"_removeVestDefault",
	"_removeMapDefault",
	"_removeRadioDefault",
	"_removeCompassDefault",
	"_removeWatchDefault",
	"_removeNVGogglesDefault",

	// Parameters
	"_unit",
	"_removeWeapons",
	"_removeHeadgear",
	"_removeUniform",
	"_removeVest",
	"_removeMap",
	"_removeRadio",
	"_removeCompass",
	"_removeWatch",
	"_removeNVGoggles"
];

// Output debug messages
_debug = false;

/*********************************************************************
 * SETUP OPTIONS
 * Get optional parameters if they exist and are boolean.
 * If they don't exist, assign default values.
 ********************************************************************/

// Default values
_removeWeaponsDefault 	= true;		// Remove weapons
_removeHeadgearDefault	= true;		// Remove headgear
_removeUniformDefault	= true;		// Remove uniform
_removeVestDefault		= true;		// Remove vest
_removeNVGogglesDefault	= true;		// Remove night vision goggles
_removeMapDefault 		= false;	// Keep map
_removeRadioDefault 	= false;	// Keep radio
_removeCompassDefault 	= false;	// Keep compass
_removeWatchDefault		= false;	// Keep watch

// TL_fnc_removeGear has required parameters.
// If no parameters were passed, exit.
if( isNil {_this} ) exitWith {
	titleText ["TL_fnc_removeGear: No arguments passed. Expected Unit.", "PLAIN"];
};

// Parameter 0 - Unit (Required) - The unit to remove gear from.

// TL_fnc_getParameter allows parameter 0 to be passed in 2 different ways:
// player call TL_fnc_removeGear OR [player] call TL_fnc_removeGear
_unit = [_this] call TL_fnc_getParameter;

// Unit wasn't passed. Exit
if( isNil "_unit" ) exitWith {
	titleText ["TL_fnc_removeGear: Expected Unit as first argument.", "PLAIN"];
};

// Parameter 1 - Remove Weapons (Optional)
_removeWeapons = [_this, 1, "BOOL", _removeWeaponsDefault] call TL_fnc_getParameter;

// Parameter 2 - Remove Headgear (Optional)
_removeHeadgear = [_this, 2, "BOOL", _removeHeadgearDefault] call TL_fnc_getParameter;

// Parameter 3 - Remove Uniform (Optional)
_removeUniform = [_this, 3, "BOOL", _removeUniformDefault] call TL_fnc_getParameter;

// Parameter 4 - Remove Vest (Optional)
_removeVest = [_this, 4, "BOOL", _removeVestDefault] call TL_fnc_getParameter;

// Parameter 5 - Remove Night Vision Goggles (Optional)
_removeNVGoggles = [_this, 5, "BOOL", _removeNVGogglesDefault] call TL_fnc_getParameter;

// Parameter 6 - Remove Map (Optional)
_removeMap = [_this, 6, "BOOL", _removeMapDefault] call TL_fnc_getParameter;

// Parameter 7 - Remove Radio (Optional)
_removeRadio = [_this, 7, "BOOL", _removeRadioDefault] call TL_fnc_getParameter;

// Parameter 8 - Remove Compass (Optional)
_removeCompass = [_this, 8, "BOOL", _removeCompassDefault] call TL_fnc_getParameter;

// Parameter 9 - Remove Watch (Optional)
_removeWatch = [_this, 9, "BOOL", _removeWatchDefault] call TL_fnc_getParameter;

/*********************************************************************
 * REMOVE GEAR
 * Based on the above options, remove the
 * necessary gear from the specified unit.
 ********************************************************************/

// Weapons
if(_removeWeapons) then {
	removeAllWeapons _unit;
};

// Headgear
if(_removeHeadgear) then {
	removeHeadgear _unit;
};

// Uniform
if(_removeUniform) then {
	removeUniform _unit;
};

// Vest
if(_removeVest) then {
	removeVest _unit;
};

// Night Vision Goggles
if(_removeNVGoggles) then {
	_unit unassignItem "NVGoggles";
	_unit removeItem "NVGoggles";
};

// Map
if(_removeMap) then {
	_unit unassignItem "ItemMap";
	_unit removeItem "ItemMap";
};

// Radio
if(_removeRadio) then {
	_unit unassignItem "ItemRadio";
	_unit removeItem "ItemRadio";
};

// Compass
if(_removeCompass) then {
	_unit unassignItem "ItemCompass";
	_unit removeItem "ItemCompass";
};

// Watch
if(_removeWatch) then {
	_unit unassignItem "ItemWatch";
	_unit removeItem "ItemWatch";
};

/*********************************************************************
 * DEBUGGING
 ********************************************************************/

if(_debug) then {
	titleText [
		format[
			"Weapons: %1, " +
			"Headgear: %2, " +
			"Uniform: %3, " + 
			"Vest: %4,\n" +
			"NVGoggles: %5, " + 
			"Map: %6, " +
			"Radio: %7, " + 
			"Compass: %8, " +
			"Watch: %9",
			_removeWeapons,
			_removeHeadgear,
			_removeUniform,
			_removeVest,
			_removeNVGoggles,
			_removeMap,
			_removeRadio,
			_removeCompass,
			_removeWatch
		],
		"PLAIN"
	];
};