From 3e19b33493c49f23fc047dad0d5cb7f39958d481 Mon Sep 17 00:00:00 2001 From: SzwedzikPL Date: Sat, 22 Aug 2015 20:00:26 +0200 Subject: [PATCH] interaction with portable lamps --- addons/cargo/CfgEventHandlers.hpp | 14 +- addons/cargo/CfgVehicles.hpp | 12 +- addons/dragging/CfgEventHandlers.hpp | 10 ++ addons/dragging/CfgVehicles.hpp | 14 ++ addons/interaction/CfgVehicles.hpp | 133 +++++++++++++++--- addons/interaction/XEH_preInit.sqf | 1 + .../interaction/functions/fnc_switchLamp.sqf | 58 ++++++++ addons/interaction/stringtable.xml | 6 + 8 files changed, 226 insertions(+), 22 deletions(-) create mode 100644 addons/interaction/functions/fnc_switchLamp.sqf diff --git a/addons/cargo/CfgEventHandlers.hpp b/addons/cargo/CfgEventHandlers.hpp index 76e367bbd3..4ea648a0c1 100644 --- a/addons/cargo/CfgEventHandlers.hpp +++ b/addons/cargo/CfgEventHandlers.hpp @@ -94,4 +94,16 @@ class Extended_Init_EventHandlers { init = QUOTE(_this call DFUNC(initObject)); }; }; -}; + + class Land_PortableLight_single_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject)); + }; + }; + + class Land_PortableLight_double_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject)); + }; + }; +}; \ No newline at end of file diff --git a/addons/cargo/CfgVehicles.hpp b/addons/cargo/CfgVehicles.hpp index 25bd441b90..89dc527844 100644 --- a/addons/cargo/CfgVehicles.hpp +++ b/addons/cargo/CfgVehicles.hpp @@ -289,6 +289,16 @@ class CfgVehicles { selection = ""; }; }; - }; + }; + + class Lamps_base_F; + class Land_PortableLight_single_F: Lamps_base_F { + GVAR(size) = 1; + GVAR(canLoad) = 1; + }; + class Land_PortableLight_double_F: Land_PortableLight_single_F { + GVAR(size) = 1; + GVAR(canLoad) = 1; + }; }; diff --git a/addons/dragging/CfgEventHandlers.hpp b/addons/dragging/CfgEventHandlers.hpp index 2ff7d07c0d..000aa02b52 100644 --- a/addons/dragging/CfgEventHandlers.hpp +++ b/addons/dragging/CfgEventHandlers.hpp @@ -33,6 +33,16 @@ class Extended_Init_EventHandlers { init = QUOTE(_this call DFUNC(initObject)); }; }; + class Land_PortableLight_single_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject)); + }; + }; + class Land_PortableLight_double_F { + class ADDON { + init = QUOTE(_this call DFUNC(initObject)); + }; + }; }; class Extended_Killed_EventHandlers { diff --git a/addons/dragging/CfgVehicles.hpp b/addons/dragging/CfgVehicles.hpp index d4d791724b..e32dc302c5 100644 --- a/addons/dragging/CfgVehicles.hpp +++ b/addons/dragging/CfgVehicles.hpp @@ -97,4 +97,18 @@ class CfgVehicles { GVAR(carryPosition[]) = {0,1,1}; GVAR(carryDirection) = 0; }; + + class Lamps_base_F; + class Land_PortableLight_single_F: Lamps_base_F { + GVAR(canCarry) = 1; + GVAR(carryPosition[]) = {0,1.2,0}; + GVAR(carryDirection) = 180; + + GVAR(canDrag) = 1; + GVAR(dragPosition[]) = {0,1.2,0}; + GVAR(dragDirection) = 180; + }; + class Land_PortableLight_single_off_F: Land_PortableLight_single_F {}; + class Land_PortableLight_double_F: Land_PortableLight_single_F {}; + class Land_PortableLight_double_off_F: Land_PortableLight_double_F {}; }; diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index 997974d2e3..116dee7bdc 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -1,25 +1,25 @@ class CfgVehicles { - class ACE_Module; - class ACE_ModuleInteraction: ACE_Module { - author = ECSTRING(common,ACETeam); - category = "ACE"; - displayName = CSTRING(Module_DisplayName); - function = "ACE_Interaction_fnc_moduleInteraction"; - scope = 2; - isGlobal = 1; - icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); - class Arguments { - class EnableTeamManagement { - displayName = CSTRING(EnableTeamManagement_DisplayName); - description = CSTRING(EnableTeamManagement_Description); - typeName = "BOOL"; - defaultValue = 1; - }; + class ACE_Module; + class ACE_ModuleInteraction: ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE"; + displayName = CSTRING(Module_DisplayName); + function = "ACE_Interaction_fnc_moduleInteraction"; + scope = 2; + isGlobal = 1; + icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); + class Arguments { + class EnableTeamManagement { + displayName = CSTRING(EnableTeamManagement_DisplayName); + description = CSTRING(EnableTeamManagement_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + class ModuleDescription { + description = CSTRING(Module_Description); + }; }; - class ModuleDescription { - description = CSTRING(Module_Description); - }; - }; class Man; class CAManBase: Man { @@ -604,4 +604,97 @@ class CfgVehicles { }; class ACE_SelfActions {}; }; + + class Lamps_base_F; + class Land_PortableLight_single_F: Lamps_base_F { + scope = 2; + GVAR(switchLampClass) = "Land_PortableLight_single_off_F"; + XEH_ENABLED; + class ACE_Actions { + class ACE_MainActions { + displayName = CSTRING(MainAction); + selection = ""; + distance = 2; + condition = "true"; + class ACE_SwitchLamp { + displayName = CSTRING(TurnOff); + condition = QUOTE(alive _target); + statement = QUOTE([ARR_1(_target)] call DFUNC(switchLamp)); + selection = ""; + distance = 2; + showDisabled = 0; + priority = -1; + }; + }; + }; + class ACE_SelfActions {}; + }; + class Land_PortableLight_single_off_F: Land_PortableLight_single_F { + scope = 1; + GVAR(switchLampClass) = "Land_PortableLight_single_F"; + GVAR(switchLampOff) = 1; + class ACE_Actions { + class ACE_MainActions { + displayName = CSTRING(MainAction); + selection = ""; + distance = 2; + condition = "true"; + class ACE_SwitchLamp { + displayName = CSTRING(TurnOn); + condition = QUOTE(alive _target); + statement = QUOTE([ARR_1(_target)] call DFUNC(switchLamp)); + selection = ""; + distance = 2; + showDisabled = 0; + priority = -1; + }; + }; + }; + }; + class Land_PortableLight_double_F: Land_PortableLight_single_F { + scope = 2; + GVAR(switchLampClass) = "Land_PortableLight_double_off_F"; + XEH_ENABLED; + class ACE_Actions { + class ACE_MainActions { + displayName = CSTRING(MainAction); + selection = ""; + distance = 2; + condition = "true"; + class ACE_SwitchLamp { + displayName = CSTRING(TurnOff); + condition = QUOTE(alive _target); + statement = QUOTE([ARR_1(_target)] call DFUNC(switchLamp)); + selection = ""; + distance = 2; + showDisabled = 0; + priority = -1; + }; + }; + }; + class ACE_SelfActions {}; + }; + class Land_PortableLight_double_off_F: Land_PortableLight_double_F { + scope = 1; + GVAR(switchLampClass) = "Land_PortableLight_double_F"; + GVAR(switchLampOff) = 1; + class ACE_Actions { + class ACE_MainActions { + displayName = CSTRING(MainAction); + selection = ""; + distance = 2; + condition = "true"; + class ACE_SwitchLamp { + displayName = CSTRING(TurnOn); + condition = QUOTE(alive _target); + statement = QUOTE([ARR_1(_target)] call DFUNC(switchLamp)); + selection = ""; + distance = 2; + showDisabled = 0; + priority = -1; + }; + }; + }; + class ACE_SelfActions {}; + }; }; diff --git a/addons/interaction/XEH_preInit.sqf b/addons/interaction/XEH_preInit.sqf index c2534b44b9..5f62a83824 100644 --- a/addons/interaction/XEH_preInit.sqf +++ b/addons/interaction/XEH_preInit.sqf @@ -34,5 +34,6 @@ PREP(sendAway); PREP(showMouseHint); PREP(sortOptionsByPriority); PREP(tapShoulder); +PREP(switchLamp); ADDON = true; diff --git a/addons/interaction/functions/fnc_switchLamp.sqf b/addons/interaction/functions/fnc_switchLamp.sqf new file mode 100644 index 0000000000..d0a82b1c40 --- /dev/null +++ b/addons/interaction/functions/fnc_switchLamp.sqf @@ -0,0 +1,58 @@ +/* + * Author: SzwedzikPL + * Turn on/off lamp + * + * Arguments: + * 0: Lamp + * 1: On/Off + * + * Return value: + * None + * + * Example: + * [lamp] call ace_interaction_fnc_switchLamp + * + * Public: No + */ +#include "script_component.hpp" + +#define DISABLED_LAMP_DMG 0.95 + +params ["_object"]; + +private ["_objectClass", "_class"]; + +_objectClass = typeof _object; +_class = getText (configFile >> "CfgVehicles" >> _objectClass >> QGVAR(switchLampClass)); + +if (_class == "") exitWith {}; + +private ["_vectors", "_pos", "_reflectors", "_hitpointsdmg"]; + +_vectors = [vectorDir _object, vectorUp _object]; +_pos = getPosATL _object; + +_reflectors = (configfile >> "CfgVehicles" >> _objectClass >> "Reflectors") call BIS_fnc_getCfgSubClasses; +_hitpointsdmg = []; +{ + _hitpoint = getText (configfile >> "CfgVehicles" >> _objectClass >> "Reflectors" >> _x >> "hitpoint"); + _hitpointsdmg pushback [_hitpoint, _object getHit _hitpoint]; + nil +} count _reflectors; + +deleteVehicle _object; + +private ["_newobject", "_isOff"]; + +_newobject = createVehicle [_class, _pos, [], 0, "CAN_COLLIDE"]; +_newobject setVectorDirAndUp _vectors; +_newobject setPosATL _pos; +_isOff = getNumber (configFile >> "CfgVehicles" >> _class >> QGVAR(switchLampOff)) == 1; + +if(_isOff) then { + //this lamp is off + {_newobject sethit [_x select 0, (_x select 1) max DISABLED_LAMP_DMG];nil} count _hitpointsdmg; +} else { + //new lamp is on + {if((_x select 1) > DISABLED_LAMP_DMG) then {_newobject sethit _x;};nil} count _hitpointsdmg; +}; \ No newline at end of file diff --git a/addons/interaction/stringtable.xml b/addons/interaction/stringtable.xml index 4f1df733b7..0476469861 100644 --- a/addons/interaction/stringtable.xml +++ b/addons/interaction/stringtable.xml @@ -807,5 +807,11 @@ O módulo de gestão de equipe é composto por: a atribuição de cores para os membros da equipe, comando das equipes, juntando-se / deixando equipes. La gestión del equipo permite la asignación de colores para los miembros del equipo, tomando el mando del equipo y uniendo/dejando equipos. + + Turn on + + + Turn off + \ No newline at end of file