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