Merge pull request #2230 from SzwedzikPL/interactions_lamps

Interaction with portable lamps
This commit is contained in:
Thomas Kooi 2016-02-20 16:47:28 +01:00
commit 27c6934ff2
9 changed files with 123 additions and 5 deletions

View File

@ -95,4 +95,9 @@ class Extended_InitPost_EventHandlers {
init = QUOTE(_this call DFUNC(initObject)); init = QUOTE(_this call DFUNC(initObject));
}; };
}; };
class Land_PortableLight_single_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
}; };

View File

@ -492,4 +492,10 @@ class CfgVehicles {
}; };
}; };
}; };
class Lamps_base_F;
class Land_PortableLight_single_F: Lamps_base_F {
GVAR(size) = 1;
GVAR(canLoad) = 1;
};
}; };

View File

@ -27,6 +27,11 @@ class Extended_Init_EventHandlers {
init = QUOTE(_this call DFUNC(initObject)); init = QUOTE(_this call DFUNC(initObject));
}; };
}; };
class Land_PortableLight_single_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
}; };
class Extended_Killed_EventHandlers { class Extended_Killed_EventHandlers {

View File

@ -112,4 +112,15 @@ class CfgVehicles {
GVAR(carryPosition[]) = {0,1,1}; GVAR(carryPosition[]) = {0,1,1};
GVAR(carryDirection) = 0; 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;
};
}; };

View File

@ -1,4 +1,3 @@
class CfgVehicles { class CfgVehicles {
class ACE_Module; class ACE_Module;
class ACE_ModuleInteraction: ACE_Module { class ACE_ModuleInteraction: ACE_Module {
@ -10,7 +9,6 @@ class CfgVehicles {
isGlobal = 1; isGlobal = 1;
isSingular = 1; isSingular = 1;
icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa);
class Arguments { class Arguments {
class EnableTeamManagement { class EnableTeamManagement {
displayName = CSTRING(EnableTeamManagement_DisplayName); displayName = CSTRING(EnableTeamManagement_DisplayName);
@ -19,7 +17,6 @@ class CfgVehicles {
defaultValue = 1; defaultValue = 1;
}; };
}; };
class ModuleDescription { class ModuleDescription {
description = CSTRING(Module_Description); description = CSTRING(Module_Description);
}; };
@ -540,6 +537,41 @@ class CfgVehicles {
class ACE_SelfActions {}; class ACE_SelfActions {};
}; };
class Lamps_base_F;
class Land_PortableLight_single_F: Lamps_base_F {
scope = 2;
XEH_ENABLED;
class ACE_Actions {
class ACE_MainActions {
displayName = CSTRING(MainAction);
selection = "";
distance = 2;
condition = "true";
class ACE_LampTurnOn {
displayName = CSTRING(TurnOn);
condition = QUOTE(alive _target && !(_target getVariable [ARR_2('ACE_lampOn',true)]));
statement = QUOTE(_target call DFUNC(switchLamp));
selection = "";
distance = 2;
};
class ACE_LampTurnOff {
displayName = CSTRING(TurnOff);
condition = QUOTE(alive _target && _target getVariable [ARR_2('ACE_lampOn',true)]);
statement = QUOTE(_target call DFUNC(switchLamp));
selection = "";
distance = 2;
};
};
};
};
class Land_PortableLight_single_off_F: Land_PortableLight_single_F {
scope = 1;
};
class Land_PortableLight_double_F: Land_PortableLight_single_F {};
class Land_PortableLight_double_off_F: Land_PortableLight_double_F {
scope = 1;
};
class RoadCone_F: ThingX { class RoadCone_F: ThingX {
class ACE_Actions { class ACE_Actions {
class ACE_MainActions { class ACE_MainActions {

View File

@ -18,6 +18,16 @@ ACE_Modifier = 0;
_unit doMove _position; _unit doMove _position;
}] call EFUNC(common,addEventHandler); }] call EFUNC(common,addEventHandler);
["lampTurnOn", {
params ["_lamp", "_hitPointsDamage", "_disabledLampDMG"];
{if((_x select 1) == _disabledLampDMG) then {_lamp setHit [_x select 0, 0];};nil} count _hitPointsDamage;
}] call EFUNC(common,addEventHandler);
["lampTurnOff", {
params ["_lamp", "_hitPointsDamage", "_disabledLampDMG"];
{_lamp setHit [_x select 0, (_x select 1) max _disabledLampDMG];nil} count _hitPointsDamage;
}] call EFUNC(common,addEventHandler);
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
GVAR(isOpeningDoor) = false; GVAR(isOpeningDoor) = false;

View File

@ -38,4 +38,7 @@ PREP(openDoor);
// interaction with boats // interaction with boats
PREP(push); PREP(push);
PREP(switchLamp);
ADDON = true; ADDON = true;

View File

@ -0,0 +1,38 @@
/*
* Author: SzwedzikPL
* Turn on/off lamp
*
* Arguments:
* 0: Lamp <OBJECT>
*
* Return value:
* None
*
* Example:
* lamp call ace_interaction_fnc_switchLamp
*
* Public: No
*/
#include "script_component.hpp"
#define DISABLED_LAMP_DMG 0.95
params ["_lamp"];
_isOn = _lamp getVariable ["ACE_lampOn", true];
private _reflectors = "true" configClasses (configfile >> "CfgVehicles" >> (typeof _lamp) >> "Reflectors");
private _hitPointsDamage = [];
{
private _hitPoint = getText (_x >> "hitpoint");
_hitPointsDamage pushback [_hitPoint, _lamp getHit _hitPoint];
nil
} count _reflectors;
//if lamp is on turn it off
private _eventName = ["lampTurnOn", "lampTurnOff"] select _isOn;
if(local _lamp) then {
[_eventName, [_lamp, _hitPointsDamage, DISABLED_LAMP_DMG]] call EFUNC(common,localEvent);
} else {
[_eventName, [_lamp], [_lamp, _hitPointsDamage, DISABLED_LAMP_DMG]] call EFUNC(common,targetEvent);
};
_lamp setVariable ["ACE_lampOn", !_isOn, true];

View File

@ -700,6 +700,14 @@
<Russian>Управление группами позволяет назначать цвета членам групп, брать командование, вступать в группы или покидать их.</Russian> <Russian>Управление группами позволяет назначать цвета членам групп, брать командование, вступать в группы или покидать их.</Russian>
<Italian>La gestione del team permette di cambiare colori ai membri, prendere il comando e lasciare o unirsi ai team.</Italian> <Italian>La gestione del team permette di cambiare colori ai membri, prendere il comando e lasciare o unirsi ai team.</Italian>
</Key> </Key>
<Key ID="STR_ACE_Interaction_TurnOn">
<English>Turn on</English>
<Polish>Włącz</Polish>
</Key>
<Key ID="STR_ACE_Interaction_TurnOff">
<English>Turn off</English>
<Polish>Wyłącz</Polish>
</Key>
<Key ID="STR_ACE_Interaction_PassMagazine"> <Key ID="STR_ACE_Interaction_PassMagazine">
<English>Pass magazine</English> <English>Pass magazine</English>
<German>Magazin geben</German> <German>Magazin geben</German>