mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge branch 'master' into explosiveInteraction
This commit is contained in:
commit
1e8a8e79fe
@ -1,6 +1,10 @@
|
||||
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) );
|
||||
};
|
||||
};
|
||||
|
@ -4,23 +4,23 @@
|
||||
class ACE_MainActions { \
|
||||
class GVAR(AttachVehicle) { \
|
||||
displayName = "$STR_ACE_Attach_AttachDetach"; \
|
||||
condition = QUOTE(([ARR_3(_player, _target, '')] call FUNC(canAttach))); \
|
||||
statement = QUOTE( [ARR_2(_player, _target)] call FUNC(openAttachUI);); \
|
||||
exceptions[] = {"isNotDragging"}; \
|
||||
condition = QUOTE(_this call FUNC(canAttach)); \
|
||||
insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions)); \
|
||||
exceptions[] = {}; \
|
||||
showDisabled = 0; \
|
||||
priority = 0; \
|
||||
icon = PATHTOF(UI\attach_ca.paa); \
|
||||
distance = 4; \
|
||||
distance = 4.5; \
|
||||
}; \
|
||||
class GVAR(DetachVehicle) { \
|
||||
displayName = "$STR_ACE_Attach_Detach"; \
|
||||
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(canDetach))); \
|
||||
statement = QUOTE( [ARR_2(_player, _target)] call FUNC(detach) ); \
|
||||
exceptions[] = {"isNotDragging"}; \
|
||||
condition = QUOTE(_this call FUNC(canDetach)); \
|
||||
statement = QUOTE(_this call FUNC(detach) ); \
|
||||
exceptions[] = {}; \
|
||||
showDisabled = 0; \
|
||||
priority = 0; \
|
||||
priority = 0.1; \
|
||||
icon = PATHTOF(UI\detach_ca.paa); \
|
||||
distance = 4; \
|
||||
distance = 4.5; \
|
||||
}; \
|
||||
}; \
|
||||
};
|
||||
@ -55,18 +55,18 @@ class CfgVehicles {
|
||||
class ACE_Equipment {
|
||||
class GVAR(Attach) {
|
||||
displayName = "$STR_ACE_Attach_AttachDetach";
|
||||
condition = QUOTE(([ARR_3(_player, _player, '')] call FUNC(canAttach)));
|
||||
statement = QUOTE( [ARR_2(_player, _player)] call FUNC(openAttachUI); );
|
||||
condition = QUOTE(_this call FUNC(canAttach));
|
||||
insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions));
|
||||
exceptions[] = {"isNotDragging"};
|
||||
showDisabled = 0;
|
||||
priority = 5;
|
||||
icon = PATHTOF(UI\attach_ca.paa);
|
||||
hotkey = "T";
|
||||
// hotkey = "T";
|
||||
};
|
||||
class GVAR(Detach) {
|
||||
displayName = "$STR_ACE_Attach_Detach";
|
||||
condition = QUOTE(([ARR_2(_player, _player)] call FUNC(canDetach)));
|
||||
statement = QUOTE( [ARR_2(_player, _player)] call FUNC(detach) );
|
||||
condition = QUOTE(_this call FUNC(canDetach));
|
||||
statement = QUOTE(_this call FUNC(detach));
|
||||
exceptions[] = {"isNotDragging"};
|
||||
showDisabled = 0;
|
||||
priority = 5;
|
||||
|
6
addons/attach/XEH_clientInit.sqf
Normal file
6
addons/attach/XEH_clientInit.sqf
Normal file
@ -0,0 +1,6 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
//If attach placing, stop when opening menu:
|
||||
["interactMenuOpened", {GVAR(placeAction) = 0;}] call EFUNC(common,addEventHandler);
|
@ -6,8 +6,7 @@ PREP(attach);
|
||||
PREP(canAttach);
|
||||
PREP(canDetach);
|
||||
PREP(detach);
|
||||
PREP(openAttachUI);
|
||||
PREP(getChildrenAttachActions);
|
||||
PREP(placeApprove);
|
||||
PREP(placeCancel);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -1,53 +1,54 @@
|
||||
/*
|
||||
* Author: eRazeri and esteldunedain
|
||||
* Author: eRazeri, esteldunedain, PabstMirror
|
||||
* Attach an item to the unit
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the attach (player) <OBJECT>
|
||||
* 1: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 2: Name of the attachable item <STRING>
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the attach (player) <OBJECT>
|
||||
* 2: Array containing a string of the attachable item <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
* [bob, bob, ["light"]] call ace_attach_fnc_attach;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_unit,_attachToVehicle,_itemName);
|
||||
private ["_itemClassname", "_itemVehClass", "_onAtachText", "_selfAttachPosition", "_attachedItem", "_tempObject", "_actionID"];
|
||||
|
||||
PARAMS_3(_attachToVehicle,_unit,_args);
|
||||
_itemClassname = [_args, 0, ""] call CBA_fnc_defaultParam;
|
||||
|
||||
//Sanity Check (_unit has item in inventory, not over attach limit)
|
||||
if !([_unit, _attachToVehicle, _itemName] call FUNC(canAttach)) exitWith {ERROR("Tried to attach, but check failed");};
|
||||
|
||||
private ["_itemVehClass", "_onAtachText", "_selfAttachPosition"];
|
||||
if ((_itemClassname == "") || {!(_this call FUNC(canAttach))}) exitWith {ERROR("Tried to attach, but check failed");};
|
||||
|
||||
_itemVehClass = "";
|
||||
_onAtachText = "";
|
||||
_selfAttachPosition = [_unit, [-0.05, 0, 0.12], "rightshoulder"];
|
||||
|
||||
switch (true) do {
|
||||
case (_itemName == "ACE_IR_Strobe_Item"): {
|
||||
case (_itemClassname == "ACE_IR_Strobe_Item"): {
|
||||
_itemVehClass = "ACE_IR_Strobe_Effect";
|
||||
_onAtachText = localize "STR_ACE_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"): {
|
||||
case (_itemClassname == "B_IR_Grenade"): {
|
||||
_itemVehClass = "B_IRStrobe";
|
||||
_onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached";
|
||||
};
|
||||
case (_itemName == "O_IR_Grenade"): {
|
||||
case (_itemClassname == "O_IR_Grenade"): {
|
||||
_itemVehClass = "O_IRStrobe";
|
||||
_onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached";
|
||||
};
|
||||
case (_itemName == "I_IR_Grenade"): {
|
||||
case (_itemClassname == "I_IR_Grenade"): {
|
||||
_itemVehClass = "I_IRStrobe";
|
||||
_onAtachText = localize "STR_ACE_Attach_IrGrenade_Attached";
|
||||
};
|
||||
case (toLower _itemName in ["chemlight_blue", "chemlight_green", "chemlight_red", "chemlight_yellow"]): {
|
||||
_itemVehClass = _itemName;
|
||||
case (toLower _itemClassname in ["chemlight_blue", "chemlight_green", "chemlight_red", "chemlight_yellow"]): {
|
||||
_itemVehClass = _itemClassname;
|
||||
_onAtachText = localize "STR_ACE_Attach_Chemlight_Attached";
|
||||
};
|
||||
};
|
||||
@ -55,36 +56,50 @@ switch (true) do {
|
||||
if (_itemVehClass == "") exitWith {ERROR("no _itemVehClass for Item");};
|
||||
|
||||
if (_unit == _attachToVehicle) then { //Self Attachment
|
||||
_unit removeItem _itemName; // Remove item
|
||||
_unit removeItem _itemClassname; // Remove item
|
||||
_attachedItem = _itemVehClass createVehicle [0,0,0];
|
||||
_attachedItem attachTo _selfAttachPosition;
|
||||
[_onAtachText] call EFUNC(common,displayTextStructured);
|
||||
_attachToVehicle setVariable [QGVAR(Objects), [_attachedItem], true];
|
||||
_attachToVehicle setVariable [QGVAR(ItemNames), [_itemName], true];
|
||||
_attachToVehicle setVariable [QGVAR(ItemNames), [_itemClassname], true];
|
||||
} else {
|
||||
GVAR(setupObject) = _itemVehClass createVehicleLocal [0,0,-10000];
|
||||
GVAR(setupObject) enableSimulationGlobal false;
|
||||
GVAR(SetupPlacmentText) = _onAtachText;
|
||||
GVAR(SetupPlacmentItem) = _itemName;
|
||||
GVAR(SetupAttachVehicle) = _attachToVehicle;
|
||||
GVAR(placer) = _unit;
|
||||
GVAR(placeAction) = -1;
|
||||
|
||||
_tempObject = _itemVehClass createVehicleLocal [0,0,-10000];
|
||||
_tempObject enableSimulationGlobal false;
|
||||
|
||||
[_unit, QGVAR(vehAttach), true] call EFUNC(common,setForceWalkStatus);
|
||||
|
||||
[QGVAR(PlacementEachFrame),"OnEachFrame", {
|
||||
private "_player";
|
||||
_player = ACE_player;
|
||||
//Stop if player switch or player gets to far from vehicle
|
||||
if (GVAR(placer) != _player || {_player distance GVAR(SetupAttachVehicle) > 7}) exitWith {
|
||||
call FUNC(placeCancel);
|
||||
//MenuBack isn't working for now (localize "STR_ACE_Attach_CancelAction")
|
||||
[{[localize "STR_ACE_Attach_PlaceAction", ""] call EFUNC(interaction,showMouseHint)}, [], 0, 0] call EFUNC(common,waitAndExecute);
|
||||
_unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {true}, {GVAR(placeAction) = 1;}] call EFUNC(common,AddActionEventHandler)];
|
||||
// _unit setVariable [QGVAR(cancelActionEH), [_unit, "MenuBack", {true}, {GVAR(placeAction) = 0;}] call EFUNC(common,AddActionEventHandler)];
|
||||
|
||||
_actionID = _unit addAction [format ["<t color='#FF0000'>%1</t>", localize "STR_ACE_Attach_CancelAction"], {GVAR(placeAction) = 0}];
|
||||
|
||||
[{
|
||||
PARAMS_2(_args,_pfID);
|
||||
EXPLODE_7_PVT(_args,_unit,_attachToVehicle,_itemClassname,_itemVehClass,_tempObject,_onAtachText,_actionID);
|
||||
|
||||
if ((GVAR(placeAction) != -1) ||
|
||||
{_unit != ACE_player} ||
|
||||
{!([_unit, _attachToVehicle, []] call EFUNC(common,canInteractWith))} ||
|
||||
{!([_attachToVehicle, _unit, _itemClassname] call FUNC(canAttach))}) then {
|
||||
|
||||
[_pfID] call CBA_fnc_removePerFrameHandler;
|
||||
[_unit, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[] call EFUNC(interaction,hideMouseHint);
|
||||
[_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler);
|
||||
//[_unit, "MenuBack", (_unit getVariable [QGVAR(cancelActionEH), -1])] call EFUNC(common,removeActionEventHandler);
|
||||
_unit removeAction _actionID;
|
||||
|
||||
if (GVAR(placeAction) == 1) then {
|
||||
_startingPosition = _tempObject modelToWorld [0,0,0];
|
||||
[_unit, _attachToVehicle, _itemClassname, _itemVehClass, _onAtachText, _startingPosition] call FUNC(placeApprove);
|
||||
};
|
||||
deleteVehicle _tempObject;
|
||||
} else {
|
||||
_tempObject setPosATL ((ASLtoATL eyePos _unit) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]));;
|
||||
};
|
||||
GVAR(pfeh_running) = true;
|
||||
_pos = (ASLtoATL eyePos _player) vectorAdd (positionCameraToWorld [0,0,1] vectorDiff positionCameraToWorld [0,0,0]);
|
||||
GVAR(setupObject) setPosATL _pos;
|
||||
}] call BIS_fnc_addStackedEventHandler; // @todo replace with CBA PFH
|
||||
|
||||
//had to delay the mouseHint, not sure why
|
||||
[{[localize "STR_ACE_Attach_PlaceAction", localize "STR_ACE_Attach_CancelAction"] call EFUNC(interaction,showMouseHint)}, [], 0, 0] call EFUNC(common,waitAndExecute);
|
||||
|
||||
_unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {GVAR(pfeh_running) && {!isNull (GVAR(setupObject))}}, {call FUNC(placeApprove);}] call EFUNC(common,AddActionEventHandler)];
|
||||
_unit setVariable [QGVAR(cancelActionEH), [_unit, "MenuBack", {GVAR(pfeh_running) && {!isNull (GVAR(setupObject))}}, {call FUNC(placeCancel);}] call EFUNC(common,AddActionEventHandler)];
|
||||
}, 0, [_unit, _attachToVehicle, _itemClassname, _itemVehClass, _tempObject, _onAtachText, _actionID]] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
@ -3,25 +3,28 @@
|
||||
* Check if a unit can attach a specific item.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the attach (player) <OBJECT>
|
||||
* 1: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 2: Name of the attachable item <STRING>
|
||||
* 0: vehicle that it will be attached to (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the attach (player) <OBJECT>
|
||||
* 2: Array empty or containing a string of the attachable item <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Boolean <BOOL>
|
||||
* Can Attach <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
* [bob, bob, ["light"]] call ace_attach_fnc_canAttach;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_3(_unit,_attachToVehicle,_item);
|
||||
PARAMS_3(_attachToVehicle,_player,_args);
|
||||
|
||||
private ["_attachLimit", "_attachedObjects"];
|
||||
private ["_itemName", "_attachLimit", "_attachedObjects"];
|
||||
|
||||
_attachLimit = [10, 1] select (_unit == _attachToVehicle);
|
||||
_itemName = [_args, 0, ""] call CBA_fnc_defaultParam;
|
||||
_attachLimit = [6, 1] select (_player == _attachToVehicle);
|
||||
_attachedObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
|
||||
|
||||
canStand _unit && {alive _attachToVehicle} && {count _attachedObjects < _attachLimit} && {_item in (itemsWithMagazines _unit + [""])}
|
||||
_playerPos = (ACE_player modelToWorld (ACE_player selectionPosition "pilot"));
|
||||
|
||||
(canStand _player) && {(_attachToVehicle distance _player) < 7} && {alive _attachToVehicle} && {(count _attachedObjects) < _attachLimit} && {_itemName in ((itemsWithMagazines _player) + [""])};
|
||||
|
@ -3,20 +3,20 @@
|
||||
* Check if a unit has an item attached and if it can remove that item.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the detaching (player) <STRING>
|
||||
* 1: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 0: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the detaching (player) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Boolean <BOOL>
|
||||
* Can Detach <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
* [bob, bob] call ace_attach_fnc_canDetach;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_attachToVehicle);
|
||||
PARAMS_2(_attachToVehicle,_unit);
|
||||
|
||||
private ["_attachedObjects", "_inRange"];
|
||||
|
||||
|
@ -3,20 +3,20 @@
|
||||
* Detach an item from a unit
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit doing the attaching (player) <STRING>
|
||||
* 1: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 0: vehicle that it will be detached from (player or vehicle) <OBJECT>
|
||||
* 1: unit doing the detaching (player) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
* [car, bob] call ace_attach_fnc_detach
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_unit,_attachToVehicle);
|
||||
PARAMS_2(_attachToVehicle,_unit);
|
||||
|
||||
private ["_attachedObjects", "_attachedItems"];
|
||||
|
||||
@ -74,13 +74,13 @@ _attachToVehicle setVariable [QGVAR(ItemNames), _attachedItems, true];
|
||||
|
||||
// Display message
|
||||
switch (true) do {
|
||||
case (_itemName == "ACE_IR_Strobe_Item") : {
|
||||
case (_itemName == "ACE_IR_Strobe_Item") : {
|
||||
[localize "STR_ACE_Attach_IrStrobe_Detached"] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
case (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) : {
|
||||
case (toLower _itemName in ["b_ir_grenade", "o_ir_grenade", "i_ir_grenade"]) : {
|
||||
[localize "STR_ACE_Attach_IrGrenade_Detached"] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
case (toLower _itemName in ["chemlight_blue", "chemlight_green", "chemlight_red", "chemlight_yellow"]) : {
|
||||
case (toLower _itemName in ["chemlight_blue", "chemlight_green", "chemlight_red", "chemlight_yellow"]) : {
|
||||
[localize "STR_ACE_Attach_Chemlight_Detached"] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
};
|
||||
|
51
addons/attach/functions/fnc_getChildrenAttachActions.sqf
Normal file
51
addons/attach/functions/fnc_getChildrenAttachActions.sqf
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Author: Garth de Wet (LH), PabstMirror
|
||||
* Show the ammo counts for a static weapon.
|
||||
* Called from "insertChildren" on interact_menu
|
||||
*
|
||||
* Argument:
|
||||
* 0: Target <OBJECT>
|
||||
* 1: Player <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* ChildActiosn<ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [player, player] call ace_attach_fnc_getChildrenAttachActions
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_target,_player);
|
||||
|
||||
_listed = [];
|
||||
_actions = [];
|
||||
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_listed pushBack _x;
|
||||
_item = ConfigFile >> "CfgMagazines" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_displayName = getText(_item >> "displayName");
|
||||
_picture = getText(_item >> "picture");
|
||||
_action = [_x, _displayName, _picture, {_this call FUNC(attach)}, {_this call FUNC(canAttach)}, {}, [_x]] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _target];
|
||||
};
|
||||
};
|
||||
} forEach (magazines _player);
|
||||
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_listed pushBack _x;
|
||||
_item = ConfigFile >> "CfgWeapons" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_displayName = getText(_item >> "displayName");
|
||||
_picture = getText(_item >> "picture");
|
||||
_action = [_x, _displayName, _picture, {_this call FUNC(attach)}, {_this call FUNC(canAttach)}, {}, [_x]] call EFUNC(interact_menu,createAction);
|
||||
_actions pushBack [_action, [], _target];
|
||||
};
|
||||
};
|
||||
} forEach (items _player);
|
||||
|
||||
_actions
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Author: Garth de Wet (LH)
|
||||
* Opens the UI for attaching objects.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <STRING>
|
||||
* 1: target <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_actions", "_attachables", "_item"];
|
||||
|
||||
PARAMS_2(_unit,_target);
|
||||
|
||||
GVAR(attachTarget) = _target;
|
||||
_listed = [];
|
||||
_attachables = magazines _unit;
|
||||
_actions = [localize "STR_ACE_Attach_AttachDetach", localize "STR_ACE_Attach_Attach"] call EFUNC(interaction,prepareSelectMenu);
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_item = ConfigFile >> "CfgMagazines" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_actions = [
|
||||
_actions,
|
||||
getText(_item >> "displayName"),
|
||||
getText(_item >> "picture"),
|
||||
_x
|
||||
] call EFUNC(interaction,addSelectableItem);
|
||||
};
|
||||
_listed pushBack _x;
|
||||
};
|
||||
} forEach _attachables;
|
||||
_attachables = items _unit;
|
||||
{
|
||||
if !(_x in _listed) then {
|
||||
_item = ConfigFile >> "CfgWeapons" >> _x;
|
||||
if (getNumber (_item >> "ACE_Attachable") == 1) then {
|
||||
_actions = [
|
||||
_actions,
|
||||
getText(_item >> "displayName"),
|
||||
getText(_item >> "picture"),
|
||||
_x
|
||||
] call EFUNC(interaction,addSelectableItem);
|
||||
};
|
||||
_listed pushBack _x;
|
||||
};
|
||||
} forEach _attachables;
|
||||
|
||||
[
|
||||
_actions,
|
||||
{
|
||||
[ACE_player, GVAR(attachTarget), _this] call FUNC(attach);
|
||||
call EFUNC(interaction,hideMenu);
|
||||
},
|
||||
{
|
||||
call EFUNC(interaction,hideMenu);
|
||||
}
|
||||
] call EFUNC(interaction,openSelectMenu);
|
@ -1,69 +1,55 @@
|
||||
/*
|
||||
* Author: Pabst Mirror (based on Explosive attach by Garth de Wet (LH))
|
||||
* Approves placement of the lightObject, scans for an appropriate location and attaches
|
||||
* 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.
|
||||
*
|
||||
* Arguments:
|
||||
* Nothing
|
||||
* 0: Unit (player) <OBJECT>
|
||||
* 1: attachToVehicle <OBJECT>
|
||||
* 2: Item Classname (cfgWeapon/cfgMagazine) <STRING>
|
||||
* 3: Light Vehicle Classname <STRING>
|
||||
* 4: On Attach Text <STRING>
|
||||
* 5: Starting Pos of dummy item <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
* No
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_setupObject", "_setupClassname", "_itemClassname", "_placementText", "_attachToVehicle", "_placer", "_startingPosition", "_startingOffset", "_distanceFromCenter", "_closeInUnitVector", "_keepGoingCloser", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"];
|
||||
private ["_startingOffset", "_startDistanceFromCenter", "_closeInUnitVector", "_closeInMax", "_closeInMin", "_setupObject", "_closeInDistance", "_endPosTestOffset", "_endPosTest", "_doesIntersect", "_startingPosShifted", "_startASL", "_endPosShifted", "_endASL", "_attachedObject", "_currentObjects", "_currentItemNames"];
|
||||
|
||||
PARAMS_6(_unit,_attachToVehicle,_itemClassname,_itemVehClass,_onAtachText,_startingPosition);
|
||||
|
||||
if (GVAR(pfeh_running)) then {
|
||||
[QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler;
|
||||
GVAR(pfeh_running) = false;
|
||||
};
|
||||
|
||||
_setupObject = GVAR(setupObject);
|
||||
_setupClassname = typeOf _setupObject;
|
||||
_itemClassname = GVAR(SetupPlacmentItem);
|
||||
_placementText = GVAR(SetupPlacmentText);
|
||||
_attachToVehicle = GVAR(SetupAttachVehicle);
|
||||
_placer = GVAR(placer);
|
||||
|
||||
GVAR(SetupPlacmentItem) = "";
|
||||
GVAR(SetupPlacmentText) = "";
|
||||
GVAR(setupObject) = objNull;
|
||||
GVAR(SetupAttachVehicle) = objNull;
|
||||
GVAR(placer) = objNull;
|
||||
|
||||
[_placer, QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
[_placer, "DefaultAction", _placer getVariable [QGVAR(placeActionEH), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
[_placer, "MenuBack", _placer getVariable [QGVAR(cancelActionEH), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
call EFUNC(interaction,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.
|
||||
|
||||
_startingPosition = _setupObject modelToWorld [0,0,0];
|
||||
_startingOffset = _attachToVehicle worldToModel _startingPosition;
|
||||
|
||||
_distanceFromCenter = vectorMagnitude _startingOffset;
|
||||
_startDistanceFromCenter = vectorMagnitude _startingOffset;
|
||||
_closeInUnitVector = vectorNormalized (_startingOffset vectorFromTo [0,0,0]);
|
||||
_keepGoingCloser = true;
|
||||
_closeInDistance = 0;
|
||||
|
||||
while {_keepGoingCloser} do {
|
||||
if (_closeInDistance >= _distanceFromCenter) exitWith {};
|
||||
_closeInMax = _startDistanceFromCenter;
|
||||
_closeInMin = 0;
|
||||
|
||||
_closeInDistance = _closeInDistance + 0.01; //10mm each step
|
||||
//Delete Local Placement Object
|
||||
deleteVehicle _setupObject;
|
||||
|
||||
while {(_closeInMax - _closeInMin) > 0.01} do {
|
||||
_closeInDistance = (_closeInMax + _closeInMin) / 2;
|
||||
// systemChat format ["Trying %1 from %2 start %3", _closeInDistance, [_closeInMax, _closeInMin], _startDistanceFromCenter];
|
||||
_endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance);
|
||||
_endPosTestOffset set [2, (_startingOffset select 2)];
|
||||
_endPosTest = _attachToVehicle modelToWorld _endPosTestOffset;
|
||||
|
||||
_doesIntersect = false;
|
||||
{
|
||||
if (_doesIntersect) exitWith {};
|
||||
_startingPosShifted = _startingPosition vectorAdd _x;
|
||||
_startASL = if (surfaceIsWater _startingPosShifted) then {_startingPosShifted} else {ATLtoASL _startingPosShifted};
|
||||
{
|
||||
@ -71,33 +57,37 @@ while {_keepGoingCloser} do {
|
||||
_endASL = if (surfaceIsWater _startingPosShifted) then {_endPosShifted} else {ATLtoASL _endPosShifted};
|
||||
|
||||
//Uncomment to see the lazor show, and see how the scanning works:
|
||||
drawLine3D [_startingPosShifted, _endPosShifted, [1,0,0,1]];
|
||||
|
||||
if (_attachToVehicle in lineIntersectsWith [_startASL, _endASL, _placer, _setupObject]) exitWith {_keepGoingCloser = false};
|
||||
// drawLine3D [_startingPosShifted, _endPosShifted, [1,0,0,1]];
|
||||
if (_attachToVehicle in lineIntersectsWith [_startASL, _endASL, _unit]) exitWith {_doesIntersect = true};
|
||||
} forEach [[0,0,0.045], [0,0,-0.045], [0,0.045,0], [0,-0.045,0], [0.045,0,0], [-0.045,0,0]];
|
||||
} forEach [[0,0,0], [0,0,0.05], [0,0,-0.05]];
|
||||
|
||||
if (_doesIntersect) then {
|
||||
_closeInMax = _closeInDistance;
|
||||
} else {
|
||||
_closeInMin = _closeInDistance;
|
||||
};
|
||||
};
|
||||
|
||||
//Delete Local Placement Object
|
||||
deleteVehicle _setupObject;
|
||||
_closeInDistance = (_closeInMax + _closeInMin) / 2;
|
||||
|
||||
//Checks
|
||||
if ((_closeInDistance >= _distanceFromCenter) || (!([_placer,_attachToVehicle,_itemClassname] call FUNC(canAttach)))) exitWith {
|
||||
TRACE_2("no valid spot found",_closeInDistance,_distanceFromCenter);
|
||||
//Checks (too close to center or can't attach)
|
||||
if (((_startDistanceFromCenter - _closeInDistance) < 0.1) || {!([_attachToVehicle, _unit, _itemClassname] call FUNC(canAttach))}) exitWith {
|
||||
TRACE_2("no valid spot found",_closeInDistance,_startDistanceFromCenter);
|
||||
[localize "STR_ACE_Attach_Failed"] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
//Move it out slightly, for visability sake (better to look a little funny than be embedded//sunk in the hull)
|
||||
//Move it out slightly, for visability sake (better to look a little funny than be embedded//sunk in the hull and be useless)
|
||||
_closeInDistance = (_closeInDistance - 0.0085);
|
||||
|
||||
//Create New 'real' Object
|
||||
_endPosTestOffset = _startingOffset vectorAdd (_closeInUnitVector vectorMultiply _closeInDistance);
|
||||
_endPosTestOffset set [2, (_startingOffset select 2)];
|
||||
_attachedObject = _setupClassname createVehicle (getPos _placer);
|
||||
_attachedObject = _itemVehClass createVehicle (getPos _unit);
|
||||
_attachedObject attachTo [_attachToVehicle, _endPosTestOffset];
|
||||
|
||||
//Remove Item from inventory
|
||||
_placer removeItem _itemClassname;
|
||||
_unit removeItem _itemClassname;
|
||||
|
||||
//Add Object to ACE_AttachedObjects and ACE_AttachedItemNames
|
||||
_currentObjects = _attachToVehicle getVariable [QGVAR(Objects), []];
|
||||
@ -107,4 +97,4 @@ _currentItemNames = _attachToVehicle getVariable [QGVAR(ItemNames), []];
|
||||
_currentItemNames pushBack _itemClassname;
|
||||
_attachToVehicle setVariable [QGVAR(ItemNames), _currentItemNames, true];
|
||||
|
||||
[_placementText] call EFUNC(common,displayTextStructured);
|
||||
[_onAtachText] call EFUNC(common,displayTextStructured);
|
||||
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Author: Pabst Mirror (based on Explosive attach by Garth de Wet (LH))
|
||||
* Cancels placement of the lightObject
|
||||
*
|
||||
* Arguments:
|
||||
* Nothing
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* Nothing
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (GVAR(pfeh_running)) then {
|
||||
[QGVAR(PlacementEachFrame),"OnEachFrame"] call BIS_fnc_removeStackedEventHandler;
|
||||
GVAR(pfeh_running) = false;
|
||||
};
|
||||
if (!isNull (GVAR(setupObject))) then {
|
||||
deleteVehicle GVAR(setupObject);
|
||||
};
|
||||
|
||||
[GVAR(placer), QGVAR(vehAttach), false] call EFUNC(common,setForceWalkStatus);
|
||||
call EFUNC(interaction,hideMouseHint);
|
||||
[GVAR(placer), "DefaultAction", GVAR(placer) getVariable [QGVAR(placeActionEH), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
[GVAR(placer), "MenuBack", GVAR(placer) getVariable [QGVAR(cancelActionEH), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
|
||||
GVAR(placer) = objNull;
|
||||
GVAR(SetupPlacmentItem) = "";
|
||||
GVAR(SetupPlacmentText) = "";
|
||||
GVAR(setupObject) = objNull;
|
||||
GVAR(SetupAttachVehicle) = objNull;
|
@ -156,7 +156,7 @@ GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
|
||||
};
|
||||
|
||||
// "playerTurretChanged" event
|
||||
[ACE_player] call FUNC(getTurretIndex);
|
||||
_newPlayerTurret = [ACE_player] call FUNC(getTurretIndex);
|
||||
if !(_newPlayerTurret isEqualTo GVAR(OldPlayerTurret)) then {
|
||||
// Raise ACE event locally
|
||||
GVAR(OldPlayerTurret) = _newPlayerTurret;
|
||||
@ -179,4 +179,11 @@ GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
|
||||
["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler);
|
||||
|
||||
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
|
||||
["isNotInside", {_this select 0 == _this select 1 || {vehicle (_this select 0) == _this select 0}}] call FUNC(addCanInteractWithCondition);
|
||||
["isNotInside", {
|
||||
// Players can always interact with himself if not boarded
|
||||
vehicle (_this select 0) == (_this select 0) ||
|
||||
// Players can always interact with his vehicle
|
||||
{vehicle (_this select 0) == (_this select 1)} ||
|
||||
// Players can always interact with passengers of the same vehicle
|
||||
{!((_this select 0) isEqualTo (_this select 1)) && {vehicle (_this select 0) == vehicle (_this select 1)}}
|
||||
}] call FUNC(addCanInteractWithCondition);
|
||||
|
@ -4,13 +4,11 @@
|
||||
ADDON = false;
|
||||
|
||||
// ACE Common Function
|
||||
PREP(addActionEventHandler);
|
||||
PREP(addActionMenuEventHandler);
|
||||
|
||||
PREP(addCanInteractWithCondition);
|
||||
PREP(addLineToDebugDraw);
|
||||
PREP(addMapMarkerCreatedEventHandler);
|
||||
PREP(addScrollWheelEventHandler);
|
||||
PREP(addSetting);
|
||||
PREP(addToInventory);
|
||||
PREP(adminKick);
|
||||
PREP(ambientBrightness);
|
||||
PREP(applyForceWalkStatus);
|
||||
@ -55,20 +53,15 @@ PREP(fixPosition);
|
||||
PREP(getAllDefinedSetVariables);
|
||||
PREP(getAllGear);
|
||||
PREP(getCaptivityStatus);
|
||||
PREP(getConfigCommander);
|
||||
PREP(getConfigGunner);
|
||||
PREP(getDeathAnim);
|
||||
PREP(getDefaultAnim);
|
||||
PREP(getDefinedVariable);
|
||||
PREP(getDefinedVariableDefault);
|
||||
PREP(getDefinedVariableInfo);
|
||||
PREP(getDoorTurrets);
|
||||
PREP(getFirstObjectIntersection);
|
||||
PREP(getFirstTerrainIntersection);
|
||||
PREP(getForceWalkStatus);
|
||||
PREP(getGunner);
|
||||
PREP(getHitPoints);
|
||||
PREP(getHitPointsWithSelections);
|
||||
PREP(getInPosition);
|
||||
PREP(getMarkerType);
|
||||
PREP(getName);
|
||||
@ -80,25 +73,13 @@ PREP(getStringFromMissionSQM);
|
||||
PREP(getTargetAzimuthAndInclination);
|
||||
PREP(getTargetDistance);
|
||||
PREP(getTargetObject);
|
||||
PREP(getTurretCommander);
|
||||
PREP(getTurretConfigPath);
|
||||
PREP(getTurretCopilot);
|
||||
PREP(getTurretGunner);
|
||||
PREP(getTurretIndex);
|
||||
PREP(getTurrets);
|
||||
PREP(getTurretsFFV);
|
||||
PREP(getTurretsOther);
|
||||
PREP(getUavControlPosition);
|
||||
PREP(getVehicleCargo);
|
||||
PREP(getVehicleCodriver);
|
||||
PREP(getVehicleCrew);
|
||||
PREP(getVersion);
|
||||
PREP(getWeaponAzimuthAndInclination);
|
||||
PREP(getWeaponIndex);
|
||||
PREP(getWeaponModes);
|
||||
PREP(getWeaponMuzzles);
|
||||
PREP(getWeaponState);
|
||||
PREP(getWeaponType);
|
||||
PREP(getWindDirection);
|
||||
PREP(goKneeling);
|
||||
PREP(hadamardProduct);
|
||||
@ -141,11 +122,7 @@ PREP(progressBar);
|
||||
PREP(queueAnimation);
|
||||
PREP(readSettingFromModule);
|
||||
PREP(receiveRequest);
|
||||
PREP(removeActionEventHandler);
|
||||
PREP(removeActionMenuEventHandler);
|
||||
PREP(removeCanInteractWithCondition);
|
||||
PREP(removeMapMarkerCreatedEventHandler);
|
||||
PREP(removeScrollWheelEventHandler);
|
||||
PREP(removeSpecificMagazine);
|
||||
PREP(requestCallback);
|
||||
PREP(resetAllDefaults);
|
||||
@ -188,6 +165,32 @@ PREP(useItem);
|
||||
PREP(useMagazine);
|
||||
PREP(waitAndExecute);
|
||||
|
||||
// config items
|
||||
PREP(getConfigType);
|
||||
PREP(getItemType);
|
||||
PREP(getWeaponType);
|
||||
PREP(getWeaponModes);
|
||||
PREP(getWeaponMuzzles);
|
||||
|
||||
// config objects
|
||||
PREP(getConfigTypeObject);
|
||||
PREP(getConfigGunner);
|
||||
PREP(getConfigCommander);
|
||||
PREP(getHitPoints);
|
||||
PREP(getHitPointsWithSelections);
|
||||
PREP(getVehicleCrew);
|
||||
|
||||
// turrets
|
||||
PREP(getTurrets);
|
||||
PREP(getTurretIndex);
|
||||
PREP(getTurretConfigPath);
|
||||
PREP(getTurretGunner);
|
||||
PREP(getTurretCommander);
|
||||
PREP(getTurretCopilot);
|
||||
PREP(getDoorTurrets);
|
||||
PREP(getTurretsFFV);
|
||||
PREP(getTurretsOther);
|
||||
|
||||
// ACE_Debug
|
||||
PREP(exportConfig);
|
||||
PREP(getChildren);
|
||||
@ -195,6 +198,7 @@ PREP(getDisplayConfigName);
|
||||
PREP(log);
|
||||
PREP(logControls);
|
||||
PREP(logDisplays);
|
||||
PREP(logModEntries);
|
||||
PREP(monitor);
|
||||
PREP(showUser);
|
||||
|
||||
@ -217,6 +221,17 @@ PREP(localEvent);
|
||||
PREP(removeEventHandler);
|
||||
PREP(removeAlLEventHandlers);
|
||||
|
||||
// other eventhandlers
|
||||
PREP(addActionEventHandler);
|
||||
PREP(addActionMenuEventHandler);
|
||||
PREP(addScrollWheelEventHandler);
|
||||
PREP(addMapMarkerCreatedEventHandler);
|
||||
|
||||
PREP(removeActionEventHandler);
|
||||
PREP(removeActionMenuEventHandler);
|
||||
PREP(removeScrollWheelEventHandler);
|
||||
PREP(removeMapMarkerCreatedEventHandler);
|
||||
|
||||
// hashes
|
||||
PREP(hashCreate);
|
||||
PREP(hashSet);
|
||||
|
101
addons/common/functions/fnc_addToInventory.sqf
Normal file
101
addons/common/functions/fnc_addToInventory.sqf
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
* Adds an item,weapon,magazine to the unit's inventory
|
||||
* or places it in a weaponHolder if no space.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit (OBJECT)
|
||||
* 1: Classname (String)
|
||||
* 2: Container (String, Optional) uniform, vest, backpack
|
||||
*
|
||||
* Return Value:
|
||||
* Array:
|
||||
* 0: Added to player (Bool)
|
||||
* 1: weaponholder (OBJECT)
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_unit,_classname);
|
||||
private "_addedToPlayer";
|
||||
private "_container";
|
||||
private "_canAdd";
|
||||
private "_type";
|
||||
|
||||
_canAdd = false;
|
||||
_addedToPlayer = true;
|
||||
|
||||
if((count _this) > 2) then {
|
||||
_container = _this select 2;
|
||||
} else {
|
||||
_container = nil;
|
||||
};
|
||||
|
||||
_type = [_classname] call EFUNC(common,getItemType);
|
||||
|
||||
if(!isNil "_container") then {
|
||||
switch (_container) do {
|
||||
case "vest": { _canAdd = _unit canAddItemToVest _classname; };
|
||||
case "backpack": { _canAdd = _unit canAddItemToBackpack _classname; };
|
||||
case "uniform": { _canAdd = _unit canAddItemToUniform _classname; };
|
||||
};
|
||||
} else {
|
||||
_container = "";
|
||||
_canAdd = _unit canAdd _classname;
|
||||
};
|
||||
|
||||
switch ((_type select 0)) do {
|
||||
case "weapon": {
|
||||
if (_canAdd) then {
|
||||
switch (_container) do {
|
||||
case "vest": { (vestContainer _unit) addWeaponCargoGlobal [_classname, 1]; };
|
||||
case "backpack": { (backpackContainer _unit) addWeaponCargoGlobal [_classname, 1]; };
|
||||
case "uniform": { (uniformContainer _unit) addWeaponCargoGlobal [_classname, 1]; };
|
||||
default { _unit addWeaponGlobal _classname; };
|
||||
};
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorld [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addWeaponCargoGlobal [_classname,1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
case "magazine": {
|
||||
if (_canAdd) then {
|
||||
switch (_container) do {
|
||||
case "vest": { (vestContainer _unit) addMagazineCargoGlobal [_classname, 1]; };
|
||||
case "backpack": { (backpackContainer _unit) addMagazineCargoGlobal [_classname, 1]; };
|
||||
case "uniform": { (uniformContainer _unit) addMagazineCargoGlobal [_classname, 1]; };
|
||||
default { _unit addMagazineGlobal _classname; };
|
||||
};
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorld [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addMagazineCargoGlobal [_classname, 1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
case "item": {
|
||||
if (_canAdd) then {
|
||||
switch (_container) do {
|
||||
case "vest": { _unit addItemToVest _classname; };
|
||||
case "backpack": { _unit addItemToBackpack _classname; };
|
||||
case "uniform": { _unit addItemToUniform _classname; };
|
||||
default { _unit addItem _classname; };
|
||||
};
|
||||
} else {
|
||||
_addedToPlayer = false;
|
||||
_pos = _unit modelToWorld [0,1,0.05];
|
||||
_unit = createVehicle ["WeaponHolder_Single_F",_pos,[],0,"NONE"];
|
||||
_unit addItemCargoGlobal [_classname,1];
|
||||
_unit setPosATL _pos;
|
||||
};
|
||||
};
|
||||
default {diag_log format ["ACE: Incorrect item type passed to %1, passed: %2",QFUNC(AddToInventory),_type];};
|
||||
};
|
||||
|
||||
[_addedToPlayer,_unit]
|
24
addons/common/functions/fnc_getConfigType.sqf
Normal file
24
addons/common/functions/fnc_getConfigType.sqf
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* What kind of Cfg is the item. Works for CfgMagaines, CfgWeapons and CfgGlasses
|
||||
*
|
||||
* Argument:
|
||||
* 0: A item's classname. (String)
|
||||
*
|
||||
* Return value:
|
||||
* CfgWhatever (String)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_item";
|
||||
|
||||
_item = _this select 0;
|
||||
|
||||
if (isClass (configFile >> "CfgWeapons" >> _item)) exitWith {"CfgWeapons"};
|
||||
|
||||
if (isClass (configFile >> "CfgMagazines" >> _item)) exitWith {"CfgMagazines"};
|
||||
|
||||
if (isClass (configFile >> "CfgGlasses" >> _item)) exitWith {"CfgGlasses"};
|
||||
|
||||
""
|
22
addons/common/functions/fnc_getConfigTypeObject.sqf
Normal file
22
addons/common/functions/fnc_getConfigTypeObject.sqf
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* What kind of Cfg is the object. Works for CfgVehicles and CfgAmmo
|
||||
*
|
||||
* Argument:
|
||||
* 0: An object's classname. (String)
|
||||
*
|
||||
* Return value:
|
||||
* CfgWhatever (String)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_object";
|
||||
|
||||
_object = _this select 0;
|
||||
|
||||
if (isClass (configFile >> "CfgVehicles" >> _object)) exitWith {"CfgVehicles"};
|
||||
|
||||
if (isClass (configFile >> "CfgAmmo" >> _object)) exitWith {"CfgAmmo"};
|
||||
|
||||
""
|
@ -16,6 +16,8 @@ private ["_vehicle", "_weapon"];
|
||||
_vehicle = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
|
||||
if (gunner _vehicle == _vehicle && {_weapon in weapons _vehicle}) exitWith {gunner _vehicle};
|
||||
|
||||
private "_gunner";
|
||||
_gunner = objNull;
|
||||
|
||||
@ -23,6 +25,6 @@ _gunner = objNull;
|
||||
if (_weapon in (_vehicle weaponsTurret _x)) exitWith {
|
||||
_gunner = _vehicle turretUnit _x;
|
||||
};
|
||||
} forEach allTurrets _vehicle;
|
||||
} forEach allTurrets [_vehicle, true];
|
||||
|
||||
_gunner
|
||||
|
83
addons/common/functions/fnc_getItemType.sqf
Normal file
83
addons/common/functions/fnc_getItemType.sqf
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* What kind of item is given classname
|
||||
*
|
||||
* Argument:
|
||||
* 0: Classname of a item. (String)
|
||||
*
|
||||
* Return value:
|
||||
* Item type. (Array)
|
||||
* 0: "weapon", "item", "magazine" or "" (String)
|
||||
* 1: A description of the item (e.g. "primary" for a weapon or "vest" for a vest item)
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_item";
|
||||
|
||||
_item = _this select 0;
|
||||
|
||||
_cfgType = [_item] call FUNC(getConfigType);
|
||||
|
||||
if (_cfgType == "") exitWith {["",""]};
|
||||
|
||||
if (_cfgType == "CfgGlasses") exitWith {["item","glasses"]};
|
||||
|
||||
private ["_config", "_type"];
|
||||
|
||||
_config = configFile >> _cfgType >> _item;
|
||||
|
||||
_type = getNumber (_config >> "type");
|
||||
|
||||
if (isNumber (_config >> "ItemInfo" >> "type")) then {
|
||||
_type = getNumber (_config >> "ItemInfo" >> "type");
|
||||
};
|
||||
|
||||
private "_default";
|
||||
_default = ["item", "magazine"] select (_cfgType == "CfgMagazines");
|
||||
|
||||
switch (true) do {
|
||||
case (_type == 0): {[_default,"unknown"]};
|
||||
case (_type == 2^0): {["weapon","primary"]};
|
||||
case (_type == 2^1): {["weapon","handgun"]};
|
||||
case (_type == 2^2): {["weapon","secondary"]};
|
||||
case (_type < 2^4): {["weapon","unknown"]};
|
||||
case (_type == 2^4): {["magazine","handgun"]}; // handgun
|
||||
case (_type == 2^8): {["magazine","primary"]}; // rifle
|
||||
case (_type == 2^9): {["magazine","secondary"]}; // rpg, mg, mines
|
||||
//case (_type < 2^11): {["magazine","unknown"]};
|
||||
|
||||
case (_type == 101): {["item","muzzle"]};
|
||||
case (_type == 201): {["item","optics"]};
|
||||
case (_type == 301): {["item","flashlight"]};
|
||||
case (_type == 302): {["item","under"]}; // czech for bipod item
|
||||
case (_type == 401): {["item","first_aid_kit"]};
|
||||
case (_type == 501): {["item","fins"]}; // not implemented
|
||||
case (_type == 601): {["item","breathing_bomb"]}; // not implemented
|
||||
case (_type == 603): {["item","goggles"]};
|
||||
case (_type == 604): {["item","scuba"]}; // not implemented
|
||||
case (_type == 605): {["item","headgear"]};
|
||||
case (_type == 611): {["item","radio"]};
|
||||
case (_type == 616): {["item","hmd"]};
|
||||
case (_type == 617): {["item","binocular"]};
|
||||
case (_type == 619): {["item","medikit"]};
|
||||
case (_type == 620): {["item","toolkit"]};
|
||||
case (_type == 621): {["item","uav_terminal"]};
|
||||
case (_type == 701): {["item","vest"]};
|
||||
case (_type == 801): {["item","uniform"]};
|
||||
|
||||
case (_type == 2^12): {
|
||||
switch (toLower getText (_config >> "simulation")) do {
|
||||
case ("weapon"): {["weapon","binocular"]};
|
||||
case ("binocular"): {["weapon","binocular"]};
|
||||
case ("nvgoggles"): {["item","nvgoggles"]};
|
||||
case ("itemminedetector"): {["item","minedetector"]};
|
||||
default {[_default,"unknown"]};
|
||||
};
|
||||
};
|
||||
|
||||
case (_type == 2^16): {["weapon","vehicle"]};
|
||||
case (_type == 2^17): {[_default,"unknown"]}; // ???
|
||||
default {[_default,"unknown"]};
|
||||
};
|
17
addons/common/functions/fnc_logModEntries.sqf
Normal file
17
addons/common/functions/fnc_logModEntries.sqf
Normal file
@ -0,0 +1,17 @@
|
||||
// by commy2
|
||||
|
||||
private ["_configs", "_entries"];
|
||||
|
||||
_configs = "true" configClasses (configFile >> _this);
|
||||
|
||||
_entries = [];
|
||||
|
||||
{
|
||||
{
|
||||
_name = toLower configName _x;
|
||||
if !(_name in _entries) then {
|
||||
diag_log text _name;
|
||||
_entries pushBack _name;
|
||||
};
|
||||
} forEach configProperties [_x, "toLower configName _x find 'ace' == 0", false];
|
||||
} forEach _configs;
|
@ -3,7 +3,7 @@
|
||||
["ACE3", QGVAR(lazeTarget), localize "STR_ACE_FCS_LaseTarget",
|
||||
{
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// Conditions: specific
|
||||
if !((!GVAR(enabled) && FUNC(canUseFCS)) || FUNC(canUseRangefinder)) exitWith {false};
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
GVAR(isDownStateKey1) = false;
|
||||
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// Conditions: specific
|
||||
if !(GVAR(enabled) && FUNC(canUseFCS)) exitWith {false};
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
["ACE3", QGVAR(adjustRangeUp), localize "STR_ACE_FCS_AdjustRangeUp",
|
||||
{
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// Conditions: specific
|
||||
if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false};
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
["ACE3", QGVAR(adjustRangDown), localize "STR_ACE_FCS_AdjustRangeDown",
|
||||
{
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
if !([ACE_player, vehicle ACE_player, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// Conditions: specific
|
||||
if !(call FUNC(canUseRangefinder) || FUNC(canUseFCS)) exitWith {false};
|
||||
|
||||
|
@ -43,7 +43,7 @@ _recurseFnc = {
|
||||
if (_condition == "") then {_condition = "true"};
|
||||
|
||||
// Add canInteract (including exceptions) and canInteractWith to condition
|
||||
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, objNull, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
|
||||
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
|
||||
|
||||
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
|
||||
|
||||
@ -79,18 +79,29 @@ _recurseFnc = {
|
||||
private "_actionsCfg";
|
||||
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions";
|
||||
|
||||
private ["_baseDisplayName", "_baseIcon"];
|
||||
_baseDisplayName = "";
|
||||
_baseIcon = "";
|
||||
if (_objectType isKindOf "CAManBase") then {
|
||||
_baseDisplayName = "Self Actions";
|
||||
_baseIcon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa";
|
||||
} else {
|
||||
_baseDisplayName = getText (configFile >> "CfgVehicles" >> _objectType >> "displayName");
|
||||
_baseIcon = getText (configFile >> "CfgVehicles" >> _objectType >> "Icon");
|
||||
};
|
||||
|
||||
// Create a master action to base on self action
|
||||
_actions = [
|
||||
[
|
||||
[
|
||||
"ACE_SelfActions",
|
||||
"Self Actions",
|
||||
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
|
||||
_baseDisplayName,
|
||||
_baseIcon,
|
||||
{
|
||||
// Dummy statement so it's not collapsed when there's no available actions
|
||||
true
|
||||
},
|
||||
{[ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering"]] call EFUNC(common,canInteractWith)},
|
||||
{[ACE_player, _target, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering"]] call EFUNC(common,canInteractWith)},
|
||||
{},
|
||||
[],
|
||||
"Spine3",
|
||||
|
@ -15,6 +15,10 @@
|
||||
// Exit if there's no menu opened
|
||||
if (GVAR(openedMenuType) < 0) exitWith {true};
|
||||
|
||||
if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
||||
closeDialog 0;
|
||||
};
|
||||
|
||||
if(GVAR(actionSelected)) then {
|
||||
this = GVAR(selectedTarget);
|
||||
|
||||
@ -40,10 +44,6 @@ GVAR(keyDown) = false;
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
GVAR(openedMenuType) = -1;
|
||||
|
||||
if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
||||
closeDialog 0;
|
||||
};
|
||||
|
||||
GVAR(expanded) = false;
|
||||
GVAR(lastPath) = [];
|
||||
GVAR(menuDepthPath) = [];
|
||||
|
Loading…
Reference in New Issue
Block a user