diff --git a/AGM_Attach/config.cpp b/AGM_Attach/config.cpp index d0f954697..f591394ca 100644 --- a/AGM_Attach/config.cpp +++ b/AGM_Attach/config.cpp @@ -21,6 +21,10 @@ class CfgFunctions { class canDetach; class detach; class openAttachUI; + class Place_Approve; + class Place_Cancel; + class vehicleCanAttach; + class vehicleCanDetach; }; }; }; @@ -30,6 +34,29 @@ class CfgFunctions { count = COUNT; \ }; +#define MACRO_ATTACHTOVEHICLE \ + class AGM_Actions { \ + class AGM_AttachVehicle { \ + displayName = "$STR_AGM_Attach_AttachDetach"; \ + condition = "[_player, AGM_Interaction_Target] call AGM_Attach_fnc_vehicleCanAttach"; \ + statement = "[_player, AGM_Interaction_Target] call AGM_Attach_fnc_openAttachUI;"; \ + exceptions[] = {"AGM_Drag_isNotDragging"}; \ + showDisabled = 0; \ + priority = 0; \ + icon = "\AGM_Attach\UI\attach_ca.paa"; \ + hotkey = "T"; \ + }; \ + class AGM_Attach_DetachVehicle { \ + displayName = "$STR_AGM_Attach_Detach"; \ + condition = "[_player, AGM_Interaction_Target] call AGM_Attach_fnc_vehicleCanDetach"; \ + statement = "[_player, AGM_Interaction_Target] call AGM_Attach_fnc_detach"; \ + exceptions[] = {"AGM_Drag_isNotDragging"}; \ + showDisabled = 0; \ + priority = 0; \ + icon = "\AGM_Attach\UI\detach_ca.paa"; \ + }; \ + }; + class CfgVehicles { class Man; class CAManBase: Man { @@ -38,7 +65,7 @@ class CfgVehicles { class AGM_Attach { displayName = "$STR_AGM_Attach_AttachDetach"; condition = "[_player, ''] call AGM_Attach_fnc_canAttach"; - statement = "[_player] call AGM_Attach_fnc_openAttachUI;"; + statement = "[_player, _player] call AGM_Attach_fnc_openAttachUI;"; exceptions[] = {"AGM_Drag_isNotDragging"}; showDisabled = 0; priority = 5; @@ -48,7 +75,7 @@ class CfgVehicles { class AGM_Attach_Detach { displayName = "$STR_AGM_Attach_Detach"; condition = "[_player] call AGM_Attach_fnc_canDetach"; - statement = "[_player] call AGM_Attach_fnc_detach"; + statement = "[_player, _player] call AGM_Attach_fnc_detach"; exceptions[] = {"AGM_Drag_isNotDragging"}; showDisabled = 0; priority = 5; @@ -59,6 +86,25 @@ class CfgVehicles { }; }; + class LandVehicle; + class Car: LandVehicle { + MACRO_ATTACHTOVEHICLE + }; + class Tank: LandVehicle { + MACRO_ATTACHTOVEHICLE + }; + class Air; + class Helicopter: Air { + MACRO_ATTACHTOVEHICLE + }; + class Plane: Air { + MACRO_ATTACHTOVEHICLE + }; + class Ship; + class Ship_F: Ship { + MACRO_ATTACHTOVEHICLE + }; + class All; class AGM_IR_Strobe_Effect: All { scope = 1; diff --git a/AGM_Attach/functions/fn_Place_Approve.sqf b/AGM_Attach/functions/fn_Place_Approve.sqf new file mode 100644 index 000000000..54d5ae46f --- /dev/null +++ b/AGM_Attach/functions/fn_Place_Approve.sqf @@ -0,0 +1,90 @@ +/* + Name: AGM_Attach_fnc_Place_Approve + + Author(s): + Pabst Mirror (based on Explosive attach by Garth de Wet (LH)) + + Description: + Approves placement of the lightObject, releases the placement object for it to settle in a location + + Parameters: + Nothing + + Returns: + Nothing + + Example: + call AGM_Attach_fnc_Place_Approve; +*/ +private ["_setupObject", "_setupClassname", "_itemClassname", "_placementText", "_attachToVehicle", "_player", "_position0", "_closeInRatio", "_offset", "_keepGoingCloser", "_pos0temp", "_position1", "_attachedObject", "_currentObjects", "_currentItemNames"]; + +if (AGM_Attach_pfeh_running) then { + ["AGM_Attach_Placement","OnEachFrame"] call BIS_fnc_removeStackedEventHandler; + AGM_Attach_pfeh_running = false; +}; + +_setupObject = AGM_Attach_SetupObject; +_setupClassname = typeOf _setupObject; +_itemClassname = AGM_Attach_SetupPlacmentItem; +_placementText = AGM_Attach_SetupPlacmentText; +_attachToVehicle = AGM_Attach_SetupAttachVehicle; + +AGM_Attach_SetupPlacmentItem = ""; +AGM_Attach_SetupPlacmentText = ""; +AGM_Attach_SetupObject = objNull; +AGM_Attach_SetupAttachVehicle = objNull; +AGM_Attach_placer forceWalk false; +AGM_Attach_placer = objNull; + +_player = AGM_player; +[_player, "DefaultAction", _player getVariable ["AGM_Attach_Place", -1]] call AGM_Core_fnc_removeActionEventHandler; +[_player, "MenuBack", _player getVariable ["AGM_Attach_Cancel", -1]] call AGM_Core_fnc_removeActionEventHandler; +call AGM_Interaction_fnc_hideMouseHint; + +//A player can release the attachObject with it floating in mid-air. +//This will use lineIntersectsWith to scan towards the center of the vehicle to find a collision +//ArmA's collision detection is of couse terrible and often misses collisions (difference between what we see and collision LOD) +//So it does multiple scans at slighly different angles +//This is VERY computationaly intensive, but doesn't happen that often. + +_position0 = getPosAtl _setupObject; +_closeInRatio = 1; +_offset = _attachToVehicle worldToModel _position0; +_keepGoingCloser = true; +while {_keepGoingCloser} do { + _closeInRatio = _closeInRatio - 0.004; + if (_closeInRatio <= 0) exitWith {}; + { + _pos0temp = _position0 vectorAdd _x; + { + _position1 = [(_offset select 0) * _closeInRatio, (_offset select 1) * _closeInRatio, (_offset select 2)]; + _position1 = _attachToVehicle modelToWorld _position1; + _position1 = _position1 vectorAdd _x; + //Uncomment to see the lazor show, and see how the scanning works: + // drawLine3D [_pos0temp, _position1, [1,0,0,1]]; + if (_attachToVehicle in lineIntersectsWith [(ATLToASL _pos0temp), (ATLToASL _position1), player, _setupObject]) exitWith {_keepGoingCloser = false}; + } forEach [[0,0,0], [0,0,0.075], [0,0,-0.075], [0,0.075,0], [0,-0.075,0], [0.075,0,0], [-.075,0,0]]; + } forEach [[0,0,0], [0,0,0.075], [0,0,-0.075]]; +}; +//Move it out slightly, for visability sake (better to look a little funny than be embedded//sunk in the hull) +_closeInRatio = (_closeInRatio + 0.006) min 1; + +//Delete Local Placement Object +deleteVehicle _setupObject; + +//Create New 'real' Object +_attachedObject = _setupClassname createVehicle (getPos _player); +_attachedObject attachTo [_attachToVehicle, [(_offset select 0) * _closeInRatio, (_offset select 1) * _closeInRatio, (_offset select 2)]]; + +//Remove Item from inventory +_player removeItem _itemClassname; + +//Add Object to AGM_AttachedObjects and AGM_AttachedItemNames +_currentObjects = _attachToVehicle getVariable ["AGM_AttachedObjects", []]; +_currentObjects pushBack _attachedObject; +_attachToVehicle setVariable ["AGM_AttachedObjects", _currentObjects, true]; +_currentItemNames = _attachToVehicle getVariable ["AGM_AttachedItemNames", []]; +_currentItemNames pushBack _itemClassname; +_attachToVehicle setVariable ["AGM_AttachedItemNames", _currentItemNames, true]; + +[_placementText] call AGM_Core_fnc_displayTextStructured; diff --git a/AGM_Attach/functions/fn_Place_Cancel.sqf b/AGM_Attach/functions/fn_Place_Cancel.sqf new file mode 100644 index 000000000..4b6ac3613 --- /dev/null +++ b/AGM_Attach/functions/fn_Place_Cancel.sqf @@ -0,0 +1,37 @@ +/* + Name: AGM_Attach_fnc_Place_Cancel + + Author(s): + Pabst Mirror (based on Explosive attach by Garth de Wet (LH)) + + Description: + Cancels placement of the lightObject + + Parameters: + Nothing + + Returns: + Nothing + + Example: + call AGM_Attach_fnc_Place_Cancel; +*/ +if (AGM_Attach_pfeh_running) then { + ["AGM_Attach_Placement","OnEachFrame"] call BIS_fnc_removeStackedEventHandler; + AGM_Attach_pfeh_running = false; +}; +if (!isNull (AGM_Attach_SetupObject)) then { + deleteVehicle AGM_Attach_SetupObject; +}; +AGM_Attach_SetupPlacmentItem = ""; +AGM_Attach_SetupPlacmentText = ""; +AGM_Attach_SetupObject = objNull; +AGM_Attach_SetupAttachVehicle = objNull; +if (isNil {AGM_Attach_placer}) then { + AGM_Attach_placer = objNull; +}; +AGM_Attach_placer forceWalk false; +AGM_Attach_placer = objNull; +call AGM_Interaction_fnc_hideMouseHint; +[AGM_player, "DefaultAction", AGM_player getVariable ["AGM_Attach_Place", -1]] call AGM_Core_fnc_removeActionEventHandler; +[AGM_player, "MenuBack", AGM_player getVariable ["AGM_Attach_Cancel", -1]] call AGM_Core_fnc_removeActionEventHandler; diff --git a/AGM_Attach/functions/fn_attach.sqf b/AGM_Attach/functions/fn_attach.sqf index c82e4a2d2..9bb0cca51 100644 --- a/AGM_Attach/functions/fn_attach.sqf +++ b/AGM_Attach/functions/fn_attach.sqf @@ -1,60 +1,95 @@ /* +Name: AGM_Attach_fnc_attach + Author: eRazeri and CAA-Picard -Attach an item to the unit +Attach an item to the unit. For vehicles, it starts the custom placement) Arguments: -0: unit -1: Item name +0: OBJECT - unit doing the attaching (player) +1: OBJECT - vehicle that it will be attached to (player or vehicle) +2: STRING - classname of attached item (from CfgMagazines or CfgWeapons) Return Value: none */ - -private ["_unit", "_itemName", "_attachedItem"]; +private ["_unit", "_attachToVehicle", "_itemName", "_selfAttachPosition", "_itemVehClass", "_onAtachText", "_attachedItem", "_player"]; _unit = _this select 0; -_itemName = _this select 1; +_attachToVehicle = _this select 1; +_itemName = _this select 2; -// Check if unit has an attached item -if (_unit getVariable ["AGM_AttachedItemName", ""] != "") exitWith {}; +// For Self Placement - Check if unit has an attached item +if (_unit == _attachToVehicle) then { + if ((count (_attachToVehicle getVariable ["AGM_AttachedObjects", []])) > 0) exitWith {}; +}; // Check if the unit still has the item if !((_itemName in items _unit) or (_itemName in magazines _unit)) exitWith {}; -// Attach item +_selfAttachPosition = [_unit, [-0.05,0,0.12], "rightshoulder"]; +_itemVehClass = ""; +_onAtachText = ""; + switch true do { - case (_itemName == "AGM_IR_Strobe_Item") : { - _attachedItem = "AGM_IR_Strobe_Effect" createVehicle [0,0,0]; - _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 - [localize "STR_AGM_Attach_IrStrobe_Attached"] call AGM_Core_fnc_displayTextStructured; + case (_itemName == "AGM_IR_Strobe_Item"): { + _itemVehClass = "AGM_IR_Strobe_Effect"; + _onAtachText = localize "STR_AGM_Attach_IrStrobe_Attached"; + _selfAttachPosition = [_unit,[0,-0.11,0.16],"pilot"]; //makes it attach to the head a bit better, shoulder is not good for visibility - eRazeri }; - case (_itemName == "B_IR_Grenade") : { - _attachedItem = "B_IRStrobe" createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; - [localize "STR_AGM_Attach_IrGrenade_Attached"] call AGM_Core_fnc_displayTextStructured; + case (_itemName == "B_IR_Grenade"): { + _itemVehClass = "B_IRStrobe"; + _onAtachText = localize "STR_AGM_Attach_IrGrenade_Attached"; }; - case (_itemName == "O_IR_Grenade") : { - _attachedItem = "O_IRStrobe" createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; - [localize "STR_AGM_Attach_IrGrenade_Attached"] call AGM_Core_fnc_displayTextStructured; + case (_itemName == "O_IR_Grenade"): { + _itemVehClass = "O_IRStrobe"; + _onAtachText = localize "STR_AGM_Attach_IrGrenade_Attached"; }; - case (_itemName == "I_IR_Grenade") : { - _attachedItem = "I_IRStrobe" createVehicle [0,0,0]; - _attachedItem attachTo [_unit,[-0.05,0,0.12],"rightshoulder"]; - [localize "STR_AGM_Attach_IrGrenade_Attached"] call AGM_Core_fnc_displayTextStructured; + case (_itemName == "I_IR_Grenade"): { + _itemVehClass = "I_IRStrobe"; + _onAtachText = localize "STR_AGM_Attach_IrGrenade_Attached"; }; - 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"]; - [localize "STR_AGM_Attach_Chemlight_Attached"] call AGM_Core_fnc_displayTextStructured; + case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}): { + _itemVehClass = _itemName; + _onAtachText = localize "STR_AGM_Attach_Chemlight_Attached"; }; default { if (true) exitWith {}; }; }; -// Remove item -_unit removeItem _itemName; -_unit setVariable ["AGM_AttachedItemName", _itemName, true]; -_unit setVariable ["AGM_AttachedItem", _attachedItem, true]; +if (_itemVehClass == "") exitWith {["AGM_Attach_fnc_attach - no _itemVehClass for Item [%1]", _itemName] call bis_fnc_error;}; + +if (_unit == _attachToVehicle) then { //Self Attachment + _unit removeItem _itemName; // Remove item + _attachedItem = _itemVehClass createVehicle [0,0,0]; + _attachedItem attachTo _selfAttachPosition; + [_onAtachText] call AGM_Core_fnc_displayTextStructured; + _attachToVehicle setVariable ["AGM_AttachedObjects", [_attachedItem], true]; + _attachToVehicle setVariable ["AGM_AttachedItemNames", [_itemName], true]; +} else { + AGM_Attach_SetupObject = _itemVehClass createVehicleLocal [0,0,-10000]; + AGM_Attach_SetupObject enableSimulationGlobal false; + AGM_Attach_SetupPlacmentText = _onAtachText; + AGM_Attach_SetupPlacmentItem = _itemName; + AGM_Attach_SetupAttachVehicle = _attachToVehicle; + AGM_Attach_placer = _unit; + _unit forceWalk true; + + ["AGM_Attach_Placement","OnEachFrame", { + private "_player"; + _player = AGM_player; + //Stop if player switch or player gets to far from vehicle + if ((AGM_Attach_placer != _player) || ((_player distance AGM_Attach_SetupAttachVehicle) > 9)) exitWith { + call AGM_Attach_fnc_Place_Cancel; + }; + AGM_Attach_pfeh_running = true; + _pos = (ASLtoATL eyePos _player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]); + AGM_Attach_SetupObject setPosATL _pos; + }] call BIS_fnc_addStackedEventHandler; + + //had to spawn the mouseHint, not sure why + [localize "STR_AGM_Attach_PlaceAction", localize "STR_AGM_Attach_CancelAction"] spawn AGM_Interaction_fnc_showMouseHint; + _unit setVariable ["AGM_Attach_Place", [_unit, "DefaultAction", {AGM_Attach_pfeh_running AND !isNull (AGM_Attach_SetupObject)}, {call AGM_Attach_fnc_Place_Approve;}] call AGM_Core_fnc_AddActionEventHandler]; + _unit setVariable ["AGM_Attach_Cancel", [_unit, "MenuBack", {AGM_Attach_pfeh_running AND !isNull (AGM_Attach_SetupObject)}, {call AGM_Attach_fnc_Place_Cancel;}] call AGM_Core_fnc_AddActionEventHandler]; +}; diff --git a/AGM_Attach/functions/fn_canAttach.sqf b/AGM_Attach/functions/fn_canAttach.sqf index 0401f9d21..0b3be9454 100644 --- a/AGM_Attach/functions/fn_canAttach.sqf +++ b/AGM_Attach/functions/fn_canAttach.sqf @@ -1,7 +1,7 @@ /* * Author: commy2 * - * Check if a unit can attach a specific item. + * Check if a unit can attach a specific item to themselves. * * Argument: * 0: Unit that wants to attach the object (Object) @@ -16,4 +16,4 @@ private ["_unit", "_item"]; _unit = _this select 0; _item = _this select 1; -canStand _unit && {_unit getVariable ["AGM_AttachedItemName", ""] == ""} && {_item in (magazines _unit + items _unit + [""])} +canStand _unit && {(count (_unit getVariable ["AGM_AttachedObjects", []])) == 0} && {_item in (magazines _unit + items _unit + [""])} diff --git a/AGM_Attach/functions/fn_canDetach.sqf b/AGM_Attach/functions/fn_canDetach.sqf index fcda3cbdd..5f87aa677 100644 --- a/AGM_Attach/functions/fn_canDetach.sqf +++ b/AGM_Attach/functions/fn_canDetach.sqf @@ -1,4 +1,5 @@ -/* +/* AGM_Attach_fnc_canDetach + * * Author: commy2 * * Check if a unit has an item attached and if it can remove that item. @@ -14,4 +15,4 @@ private "_unit"; _unit = _this select 0; -canStand _unit && {_unit getVariable ["AGM_AttachedItemName", ""] != ""} +canStand _unit && {(count (_unit getVariable ["AGM_AttachedObjects", []])) != 0} diff --git a/AGM_Attach/functions/fn_detach.sqf b/AGM_Attach/functions/fn_detach.sqf index f84bb163c..85c2f10a6 100644 --- a/AGM_Attach/functions/fn_detach.sqf +++ b/AGM_Attach/functions/fn_detach.sqf @@ -1,22 +1,45 @@ /* +Name: AGM_Attach_fnc_detach + Author: eRazeri and CAA-Picard Detach an item from a unit Arguments: -unit + 0: OBJECT - unit doing the attaching (player) + 1: OBJECT - vehicle that it will be attached to (player or vehicle) Return Value: -none + none */ +private ["_unit", "_attachToVehicle", "_attachedObjectsArray", "_attachedItemsArray", "_attachedObject", "_itemName", "_minDistance", "_unitPos", "_objectPos", "_count", "_attachedItem"]; -private ["_unit", "_itemName", "_count", "_attachedItem"]; _unit = _this select 0; -_itemName = _unit getVariable ["AGM_AttachedItemName", ""]; +_attachToVehicle = _this select 1; + +_attachedObjectsArray = _attachToVehicle getVariable ["AGM_AttachedObjects", []]; +_attachedItemsArray = _attachToVehicle getVariable ["AGM_AttachedItemNames", []]; +_attachedObject = objNull; +_itemName = ""; + +//Find closest attached object +_minDistance = 1000; +_unitPos = getPos _unit; +_unitPos set [2,0]; +{ + _objectPos = getPos _x; + _objectPos set [2, 0]; + if ((_objectPos distance _unitPos) < _minDistance) then { + _minDistance = (_objectPos distance _unitPos); + _attachedObject = _x; + _itemName = _attachedItemsArray select _forEachIndex; + }; +} forEach _attachedObjectsArray; -// Check if unit has an attached item -if (_itemName == "") exitWith {}; +//Error Checking +if (isNull _attachedObject) exitWith {["AGM_Attach_fnc_detach - null _attachedObject [%1]", _this] call bis_fnc_error;}; +if (_itemName == "") exitWith {["AGM_Attach_fnc_detach - _itemName is empty"] call bis_fnc_error;}; // Add item to inventory _count = (count items _unit) + (count magazines _unit); @@ -27,7 +50,7 @@ if ((count items _unit) + (count magazines _unit) <= _count) exitWith { if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") then { // Hack for dealing with X_IR_Grenade effect not dissapearing on deleteVehicle - [_unit getVariable "AGM_AttachedItem", _unit] spawn { + [_attachedObject, _unit] spawn { _attachedItem = _this select 0; _unit = _this select 1; detach _attachedItem; @@ -35,26 +58,30 @@ if (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == " sleep 0.5; deleteVehicle _attachedItem; }; -} -else -{ +} else { // Delete attached item - deleteVehicle (_unit getVariable "AGM_AttachedItem"); + deleteVehicle _attachedObject; }; -// Reset unit variables -_unit setVariable ["AGM_AttachedItemName","", true]; -_unit setVariable ["AGM_AttachedItem",nil, true]; +// Remove Deleted (null) entries +{ + if (isNull _x) then { + _attachedObjectsArray deleteAt _forEachIndex; + _attachedItemsArray deleteAt _forEachIndex; + }; +} forEach _attachedObjectsArray; +_attachToVehicle setVariable ["AGM_AttachedObjects", _attachedObjectsArray, true]; +_attachToVehicle setVariable ["AGM_AttachedItemNames", _attachedItemsArray, true]; // Display message switch true do { - case (_itemName == "AGM_IR_Strobe_Item") : { +case (_itemName == "AGM_IR_Strobe_Item") : { [localize "STR_AGM_Attach_IrStrobe_Detached"] call AGM_Core_fnc_displayTextStructured; }; - case (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") : { +case (_itemName == "B_IR_Grenade" or _itemName == "O_IR_Grenade" or _itemName == "I_IR_Grenade") : { [localize "STR_AGM_Attach_IrGrenade_Detached"] call AGM_Core_fnc_displayTextStructured; }; - case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : { +case (_itemName == "Chemlight_blue" or {_itemName == "Chemlight_green"} or {_itemName == "Chemlight_red"} or {_itemName == "Chemlight_yellow"}) : { [localize "STR_AGM_Attach_Chemlight_Detached"] call AGM_Core_fnc_displayTextStructured; }; default { diff --git a/AGM_Attach/functions/fn_openAttachUI.sqf b/AGM_Attach/functions/fn_openAttachUI.sqf index 2a1f0cf78..bd58fdde1 100644 --- a/AGM_Attach/functions/fn_openAttachUI.sqf +++ b/AGM_Attach/functions/fn_openAttachUI.sqf @@ -13,10 +13,14 @@ Nothing Example: - [player] call AGM_Attach_fnc_openAttachUI; + [player, player] call AGM_Attach_fnc_openAttachUI; */ -private ["_unit", "_actions", "_attachables", "_item"]; +private ["_unit", "_attachToVehicle", "_attachToPointName", "_listed", "_attachables", "_actions", "_item"]; + _unit = _this select 0; +_attachToVehicle = _this select 1; +_attachToPointName = _this select 2; + _listed = []; _attachables = magazines _unit; _actions = [localize "STR_AGM_Attach_AttachDetach", localize "STR_AGM_Attach_Attach"] call AGM_Interaction_fnc_prepareSelectMenu; @@ -53,7 +57,7 @@ _attachables = items _unit; [ _actions, { - [AGM_player, _this] call AGM_Attach_fnc_attach; + [AGM_player, AGM_Interaction_Target, _this] call AGM_Attach_fnc_attach; call AGM_Interaction_fnc_hideMenu; }, { diff --git a/AGM_Attach/functions/fn_vehicleCanAttach.sqf b/AGM_Attach/functions/fn_vehicleCanAttach.sqf new file mode 100644 index 000000000..901ec98e1 --- /dev/null +++ b/AGM_Attach/functions/fn_vehicleCanAttach.sqf @@ -0,0 +1,24 @@ +/* +Name: AGM_Attach_fnc_vehicleCanAttach + +Author: Pabst Mirror + +Description: + Tests if the unit can attach to the vehicle + +Parameters: + 0: OBJECT - unit doing the attaching (usualy the player) + 1: OBJECT - vehicle that it will be attached to (player or vehicle) + +Returns: + BOOL + +Example: + [player, tank] call AGM_Attach_fnc_vehicleCanAttach +*/ +private ["_unit", "_attachToVehicle"]; + +_unit = _this select 0; +_attachToVehicle = _this select 1; + +canStand _unit && {alive _attachToVehicle} diff --git a/AGM_Attach/functions/fn_vehicleCanDetach.sqf b/AGM_Attach/functions/fn_vehicleCanDetach.sqf new file mode 100644 index 000000000..33119b7f1 --- /dev/null +++ b/AGM_Attach/functions/fn_vehicleCanDetach.sqf @@ -0,0 +1,36 @@ +/* +Name: AGM_Attach_fnc_vehicleCanDetach + +Author: Pabst Mirror + +Description: + Tests if the unit can detach from the vehicle + +Parameters: + 0: OBJECT - unit doing the detaching (usualy the player) + 1: OBJECT - vehicle that it will be attached to (player or vehicle) + +Returns: + BOOL + +Example: + [player, tank] call AGM_Attach_fnc_vehicleCanDetach +*/ +private ["_unit", "_attachToVehicle", "_attachedObjects", "_unitPos", "_minDistance", "_objectPos"]; + +_unit = _this select 0; +_attachToVehicle = _this select 1; + +_attachedObjects = _attachToVehicle getVariable ["AGM_AttachedObjects", []]; + +//Scan if unit is within range (using 2d distance) +_unitPos = getPos _unit; +_unitPos set [2,0]; +_minDistance = 1000; +{ + _objectPos = getPos _x; + _objectPos set [2, 0]; + _minDistance = _minDistance min (_objectPos distance _unitPos); +} forEach _attachedObjects; + +canStand _unit && {alive _attachToVehicle} && {_minDistance < 2.4} diff --git a/AGM_Attach/stringtable.xml b/AGM_Attach/stringtable.xml index 42d2fa493..473d67539 100644 --- a/AGM_Attach/stringtable.xml +++ b/AGM_Attach/stringtable.xml @@ -133,6 +133,28 @@ O Marcador IV permite que você sinalize sua posição através de um pulso visível somente com equipamento de visão noturna. La Strobo IR è una luce stroboscopica che ti permette di segnalare la tua posizione grazie all'emissione di impulsi ad infrarossi visibili solo con i visori notturni. Az infravörös jeladóval megjelölheted a helyzetedet úgy, hogy annak pulzáló fénye csak éjjellátó készülékkel látható. + + + Place + Platzieren + Colocar + Umieść + Placer + Položit + Colocar + Posiziona + Elhelyez + + + Cancel + Abbrechen + Cancelar + Anuluj + Annuler + Zrušit + Cancelar + Annulla + Mégse