From 1e47d5153823fa6451e523ef24c3ee6aeb680132 Mon Sep 17 00:00:00 2001 From: esteldunedain Date: Fri, 26 Feb 2016 01:12:44 -0300 Subject: [PATCH] Experimental vehicle spatial actions. Cockpit action for the littlebird. --- .../functions/fnc_compileMenuSelfAction.sqf | 26 ++++++++++++++++--- .../functions/fnc_renderActionPoints.sqf | 10 ++++++- addons/interact_menu/script_component.hpp | 4 +-- addons/interaction/CfgVehicles.hpp | 26 ++++++++++++++++++- addons/interaction/XEH_postInit.sqf | 5 ++++ 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf b/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf index eb9727a072..9b50c3d9da 100644 --- a/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf +++ b/addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf @@ -33,10 +33,26 @@ private _recurseFnc = { private _entryCfg = _x; if(isClass _entryCfg) then { private _displayName = getText (_entryCfg >> "displayName"); - + private _distance = 10; + if (isNumber (_entryCfg >> "distance")) then {_distance = getNumber (_entryCfg >> "distance");}; private _icon = getText (_entryCfg >> "icon"); private _statement = compile (getText (_entryCfg >> "statement")); + // If the position entry is present, compile it + private _position = getText (_entryCfg >> "position"); + if (_position != "") then { + _position = compile _position; + } else { + // If the not, but the selection entry is present use that + _position = getText (_entryCfg >> "selection"); + if (_position != "") then { + _position = compile format ["_target selectionPosition '%1'", _position]; + } else { + // Otherwise, just use the origin + _position = {[0,0,0]}; + }; + }; + private _condition = getText (_entryCfg >> "condition"); if (_condition == "") then {_condition = "true"}; @@ -68,8 +84,8 @@ private _recurseFnc = { _condition, _insertChildren, [], - [0,0,0], - 10, //distace + _position, + distace, [_showDisabled,_enableInside,_canCollapse,_runOnHover, true], _modifierFunction ], @@ -125,4 +141,8 @@ private _actions = [ ] ]; +private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfSpatialActions"; +private _actions2 = [_actionsCfg, 0] call _recurseFnc; + +_actions = _actions + _actions2; _namespace setVariable [_objectType, _actions]; diff --git a/addons/interact_menu/functions/fnc_renderActionPoints.sqf b/addons/interact_menu/functions/fnc_renderActionPoints.sqf index c99688564a..8dfcff42f0 100644 --- a/addons/interact_menu/functions/fnc_renderActionPoints.sqf +++ b/addons/interact_menu/functions/fnc_renderActionPoints.sqf @@ -108,7 +108,15 @@ private _fnc_renderSelfActions = { { _action = _x; - [_target, _action, _pos] call FUNC(renderBaseMenu); + if ((_action select 0 select 0) isEqualTo "ACE_SelfActions") then { + if (_target == ACE_player) then { + [_target, _action, _pos] call FUNC(renderBaseMenu); + } else { + [_target, _action, [0.5, 0.2]] call FUNC(renderBaseMenu); + }; + } else { + [_target, _action] call FUNC(renderBaseMenu); + }; nil } count _classActions; }; diff --git a/addons/interact_menu/script_component.hpp b/addons/interact_menu/script_component.hpp index 6a2f4e86f3..6f5155c689 100644 --- a/addons/interact_menu/script_component.hpp +++ b/addons/interact_menu/script_component.hpp @@ -1,8 +1,8 @@ #define COMPONENT interact_menu #include "\z\ace\addons\main\script_mod.hpp" -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +//#define DEBUG_MODE_FULL +#define DISABLE_COMPILE_CACHE // #define CBA_DEBUG_SYNCHRONOUS // #define ENABLE_PERFORMANCE_COUNTERS diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 0b71ebb4e1..04238fa8e1 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -380,6 +380,30 @@ class CfgVehicles { insertChildren = QUOTE(_this call DFUNC(addPassengersActions)); }; }; + class ACE_SelfSpatialActions {}; + }; + + class Helicopter_Base_F: Helicopter {}; + class Helicopter_Base_H: Helicopter_Base_F {}; + class Heli_Light_01_base_F: Helicopter_Base_H { + class ACE_SelfSpatialActions: ACE_SelfSpatialActions { + class ACE_TurnEngineOn { + displayName = "Turn Engine On"; + selection = ""; + position = "[0.15,1.75,0.15]"; + distance = 1.5; + condition = "!isEngineOn _target"; + statement = QUOTE([ARR_3('ace_interaction_engineOn',_target,[ARR_2(_target, true)])] call EFUNC(common,objectEvent);); + }; + class ACE_TurnEngineOff { + displayName = "Turn Engine Off"; + selection = ""; + position = "[0.15,1.75,0.15]"; + distance = 1.5; + condition = "isEngineOn _target"; + statement = QUOTE([ARR_3('ace_interaction_engineOn',_target,[ARR_2(_target, false)])] call EFUNC(common,objectEvent);); + }; + }; }; class Plane: Air { @@ -577,7 +601,7 @@ class CfgVehicles { class Land_PortableLight_double_off_F: Land_PortableLight_double_F { scope = 1; }; - + class RoadCone_F: ThingX { class ACE_Actions { class ACE_MainActions { diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf index 66e0cb1341..ed36946613 100644 --- a/addons/interaction/XEH_postInit.sqf +++ b/addons/interaction/XEH_postInit.sqf @@ -79,3 +79,8 @@ GVAR(isOpeningDoor) = false; ["isNotSwimming", {!underwater (_this select 0)}] call EFUNC(common,addCanInteractWithCondition); ["isNotOnLadder", {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "ACE_isLadder") != 1}] call EFUNC(common,addCanInteractWithCondition); + +[QGVAR(engineOn), { + params ["_unit", "_state"]; + _unit engineOn _state; +}] call EFUNC(common,addEventHandler);