ACE3/addons/attach/functions/fnc_attach.sqf

63 lines
2.2 KiB
Plaintext
Raw Normal View History

2015-01-11 20:39:49 +00:00
#include "script_component.hpp"
/*
Author: eRazeri and CAA-Picard
Attach an item to the unit
Arguments:
0: unit
1: Item name
Return Value:
none
*/
private ["_unit", "_itemName", "_attachedItem"];
_unit = _this select 0;
_itemName = _this select 1;
// Check if unit has an attached item
if (_unit getVariable [QGVAR(ItemName), ""] != "") exitWith {};
// Check if the unit still has the item
if !((_itemName in items _unit) or (_itemName in magazines _unit)) exitWith {};
// Attach item
switch true do {
2015-01-13 23:07:52 +00:00
case (_itemName == "ACE_IR_Strobe_Item") : {
_attachedItem = "ACE_IR_Strobe_Effect" createVehicle [0,0,0];
2015-01-11 20:39:49 +00:00
_attachedItem attachTo [_unit,[0,-0.11,0.16],"pilot"];//makes it attach to the head a bit better, shoulder is not good for visibility - eRazeri
2015-01-13 23:07:52 +00:00
[localize "STR_ACE_Attach_IrStrobe_Attached"] call EFUNC(common,displayTextStructured);
2015-01-11 20:39:49 +00:00
};
case (_itemName == "B_IR_Grenade") : {
_attachedItem = "B_IRStrobe" createVehicle [0,0,0];
_attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"];
2015-01-13 23:07:52 +00:00
[localize "STR_ACE_Attach_IrGrenade_Attached"] call EFUNC(common,displayTextStructured);
2015-01-11 20:39:49 +00:00
};
case (_itemName == "O_IR_Grenade") : {
_attachedItem = "O_IRStrobe" createVehicle [0,0,0];
_attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"];
2015-01-13 23:07:52 +00:00
[localize "STR_ACE_Attach_IrGrenade_Attached"] call EFUNC(common,displayTextStructured);
2015-01-11 20:39:49 +00:00
};
case (_itemName == "I_IR_Grenade") : {
_attachedItem = "I_IRStrobe" createVehicle [0,0,0];
_attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"];
2015-01-13 23:07:52 +00:00
[localize "STR_ACE_Attach_IrGrenade_Attached"] call EFUNC(common,displayTextStructured);
2015-01-11 20:39:49 +00:00
};
case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : {
_attachedItem = _itemName createVehicle [0,0,0];
_attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"];
2015-01-13 23:07:52 +00:00
[localize "STR_ACE_Attach_Chemlight_Attached"] call EFUNC(common,displayTextStructured);;
2015-01-11 20:39:49 +00:00
};
default {
if (true) exitWith {};
};
};
// Remove item
_unit removeItem _itemName;
_unit setVariable [QGVAR(ItemName), _itemName, true];
_unit setVariable [QGVAR(Item), _attachedItem, true];