Skip to content

Commit

Permalink
Fix switching non-local portable light on (#6522)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dystopian authored and PabstMirror committed Aug 17, 2018
1 parent 48b4592 commit d8b54a8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 51 deletions.
8 changes: 4 additions & 4 deletions addons/interaction/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,14 @@ class CfgVehicles {
class GVAR(TurnOn) {
displayName = CSTRING(TurnOn);
icon = "\A3\Ui_f\data\IGUI\Cfg\VehicleToggles\LightsIconOn_ca.paa";
condition = QUOTE(alive _target && !(_target getVariable [ARR_2('ACE_lampOn',true)]));
statement = QUOTE(_target call DFUNC(switchLamp));
condition = QUOTE(alive _target && !(_target getVariable [ARR_2(QQGVAR(isLightOn),true)]));
statement = QUOTE([ARR_3(QQGVAR(setLight),[ARR_2(_target,true)],_target)] call CBA_fnc_targetEvent);
};
class GVAR(TurnOff) {
displayName = CSTRING(TurnOff);
icon = "\A3\ui_f\data\igui\cfg\actions\ico_cpt_land_OFF_ca.paa";
condition = QUOTE(alive _target && _target getVariable [ARR_2('ACE_lampOn',true)]);
statement = QUOTE(_target call DFUNC(switchLamp));
condition = QUOTE(alive _target && _target getVariable [ARR_2(QQGVAR(isLightOn),true)]);
statement = QUOTE([ARR_3(QQGVAR(setLight),[ARR_2(_target,false)],_target)] call CBA_fnc_targetEvent);
};
};
};
Expand Down
1 change: 0 additions & 1 deletion addons/interaction/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ PREP(canPush);
PREP(push);

PREP(canFlip);
PREP(switchLamp);
29 changes: 18 additions & 11 deletions addons/interaction/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,31 @@ ACE_Modifier = 0;
_unit doMove _position;
}] call CBA_fnc_addEventHandler;

[QGVAR(setLampOn), {
params ["_lamp", "_hitPointsDamage", "_disabledLampDMG"];
{if((_x select 1) == _disabledLampDMG) then {_lamp setHit [_x select 0, 0];};nil} count _hitPointsDamage;
}] call CBA_fnc_addEventHandler;

[QGVAR(setLampOff), {
params ["_lamp", "_hitPointsDamage", "_disabledLampDMG"];
{_lamp setHit [_x select 0, (_x select 1) max _disabledLampDMG];nil} count _hitPointsDamage;
}] call CBA_fnc_addEventHandler;


[QGVAR(flip), {
params ["_vehicle"];
private _position = getPosATL _vehicle;
_vehicle setVectorUp surfaceNormal _position;
_vehicle setPosATL _position;
}] call CBA_fnc_addEventHandler;

[QGVAR(setLight), {
params ["_lamp", "_state"];
private _hitpoints = _lamp call EFUNC(common,getReflectorsWithSelections) select 1;
{
private _damage = _lamp getHit _x;
if (_state) then {
if (_damage == DISABLED_LAMP_DAMAGE) then {
_lamp setHit [_x, 0];
};
} else {
if (_damage < DISABLED_LAMP_DAMAGE) then {
_lamp setHit [_x, DISABLED_LAMP_DAMAGE];
};
};
} forEach _hitpoints;
_lamp setVariable [QGVAR(isLightOn), _state, true];
}] call CBA_fnc_addEventHandler;

[QGVAR(setCollisionLight), {
(_this select 0) setCollisionLight (_this select 1);
}] call CBA_fnc_addEventHandler;
Expand Down
35 changes: 0 additions & 35 deletions addons/interaction/functions/fnc_switchLamp.sqf

This file was deleted.

2 changes: 2 additions & 0 deletions addons/interaction/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
#include "\z\ace\addons\main\script_macros.hpp"

#define MACRO_DOOR_REACH_DISTANCE (AGLToASL positionCameraToWorld [0,0,0] vectorDistance AGLToASL (ACE_player modelToWorld (ACE_player selectionPosition "Head"))) + 2

#define DISABLED_LAMP_DAMAGE 0.95

0 comments on commit d8b54a8

Please sign in to comment.