major cleanup

This commit is contained in:
SzwedzikPL 2016-02-05 03:41:18 +01:00
parent ab297ff97e
commit 374b015ee4
2 changed files with 33 additions and 56 deletions

View File

@ -1,23 +1,3 @@
#define MACRO_PORTABLE_LIGHTS_ACTION(var1) \
class ACE_Actions { \
class ACE_MainActions { \
displayName = CSTRING(MainAction); \
selection = ""; \
distance = 2; \
condition = "true"; \
class ACE_SwitchLamp { \
displayName = CSTRING(var1); \
condition = QUOTE(alive _target); \
statement = QUOTE([ARR_1(_target)] call DFUNC(switchLamp)); \
selection = ""; \
distance = 2; \
showDisabled = 0; \
priority = -1; \
}; \
}; \
}; \
class ACE_SelfActions {}
class CfgVehicles {
class ACE_Module;
class ACE_ModuleInteraction: ACE_Module {
@ -552,28 +532,38 @@ class CfgVehicles {
class Lamps_base_F;
class Land_PortableLight_single_F: Lamps_base_F {
scope = 2;
GVAR(switchLampClass) = "Land_PortableLight_single_off_F";
XEH_ENABLED;
MACRO_PORTABLE_LIGHTS_ACTION(TurnOff);
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;
GVAR(switchLampClass) = "Land_PortableLight_single_F";
GVAR(switchLampOff) = 1;
MACRO_PORTABLE_LIGHTS_ACTION(TurnOn);
};
class Land_PortableLight_double_F: Land_PortableLight_single_F {
scope = 2;
GVAR(switchLampClass) = "Land_PortableLight_double_off_F";
XEH_ENABLED;
MACRO_PORTABLE_LIGHTS_ACTION(TurnOff);
};
class Land_PortableLight_double_F: Land_PortableLight_single_F {};
class Land_PortableLight_double_off_F: Land_PortableLight_double_F {
scope = 1;
GVAR(switchLampClass) = "Land_PortableLight_double_F";
GVAR(switchLampOff) = 1;
MACRO_PORTABLE_LIGHTS_ACTION(TurnOn);
};
class RoadCone_F: ThingX {
class ACE_Actions {
class ACE_MainActions {

View File

@ -9,7 +9,7 @@
* None
*
* Example:
* [lamp] call ace_interaction_fnc_switchLamp
* lamp call ace_interaction_fnc_switchLamp
*
* Public: No
*/
@ -19,15 +19,8 @@
params ["_lamp"];
private _objectClass = typeof _lamp;
private _class = getText (configFile >> "CfgVehicles" >> _objectClass >> QGVAR(switchLampClass));
if (_class == "") exitWith {};
private _vectors = [vectorDir _lamp, vectorUp _lamp];
private _posATL = getPosATL _lamp;
private _reflectors = "true" configClasses (configfile >> "CfgVehicles" >> _objectClass >> "Reflectors");
_isOn = _lamp getVariable ["ACE_lampOn", true];
private _reflectors = "true" configClasses (configfile >> "CfgVehicles" >> (typeof _lamp) >> "Reflectors");
private _hitPointsDamage = [];
{
private _hitPoint = getText (_x >> "hitpoint");
@ -35,17 +28,11 @@ private _hitPointsDamage = [];
nil
} count _reflectors;
deleteVehicle _lamp;
private _newLamp = createVehicle [_class, _posATL, [], 0, "CAN_COLLIDE"];
_newLamp setVectorDirAndUp _vectors;
_newLamp setPosATL _posATL;
private _isOff = getNumber (configFile >> "CfgVehicles" >> _class >> QGVAR(switchLampOff)) == 1;
if(_isOff) then {
//this version of lamp is off
{_newLamp sethit [_x select 0, (_x select 1) max DISABLED_LAMP_DMG];nil} count _hitPointsDamage;
if(_isOn) then {
//turn off this lamp
{_lamp sethit [_x select 0, (_x select 1) max DISABLED_LAMP_DMG];nil} count _hitPointsDamage;
} else {
//this version of lamp is on
{if((_x select 1) > DISABLED_LAMP_DMG) then {_newLamp sethit _x;};nil} count _hitPointsDamage;
//turn on this lamp
{if((_x select 1) == DISABLED_LAMP_DMG) then {_lamp sethit [_x select 0, 0];};nil} count _hitPointsDamage;
};
_lamp setVariable ["ACE_lampOn", !_isOn, true];