2016-07-14 14:16:53 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
[QGVAR(engineFire), FUNC(engineFire)] call CBA_fnc_addEventHandler;
|
|
|
|
[QGVAR(cookOff), FUNC(cookOff)] call CBA_fnc_addEventHandler;
|
2016-10-06 20:37:38 +00:00
|
|
|
[QGVAR(cookOffBox), FUNC(cookOffBox)] call CBA_fnc_addEventHandler;
|
2016-07-14 14:16:53 +00:00
|
|
|
|
2016-08-23 07:57:54 +00:00
|
|
|
GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
|
|
|
|
|
2016-07-14 14:16:53 +00:00
|
|
|
// cookoff and burning engine
|
|
|
|
["Tank", "init", {
|
2016-08-23 07:57:54 +00:00
|
|
|
params ["_vehicle"];
|
2016-09-18 09:31:28 +00:00
|
|
|
|
2016-08-23 07:57:54 +00:00
|
|
|
private _typeOf = typeOf _vehicle;
|
2016-09-18 09:31:28 +00:00
|
|
|
|
2016-08-23 07:57:54 +00:00
|
|
|
if (isNil {GVAR(cacheTankDuplicates) getVariable _typeOf}) then {
|
|
|
|
private _hitpoints = (getAllHitPointsDamage _vehicle param [0, []]) apply {toLower _x};
|
|
|
|
private _duplicateHitpoints = [];
|
2016-09-18 09:31:28 +00:00
|
|
|
|
2016-08-23 07:57:54 +00:00
|
|
|
{
|
|
|
|
if ((_x != "") && {_x in (_hitpoints select [0,_forEachIndex])}) then {
|
|
|
|
_duplicateHitpoints pushBack _forEachIndex;
|
|
|
|
};
|
|
|
|
} forEach _hitpoints;
|
2016-09-18 09:31:28 +00:00
|
|
|
|
2016-08-23 07:57:54 +00:00
|
|
|
TRACE_2("dupes",_typeOf,_duplicateHitpoints);
|
|
|
|
GVAR(cacheTankDuplicates) setVariable [_typeOf, _duplicateHitpoints];
|
|
|
|
};
|
|
|
|
|
|
|
|
_vehicle addEventHandler ["HandleDamage", {
|
2016-09-18 09:31:28 +00:00
|
|
|
if ((_this select 0) getVariable [QGVAR(enable), GVAR(enable)]) then {
|
2016-08-13 10:12:34 +00:00
|
|
|
["tank", _this] call FUNC(handleDamage);
|
|
|
|
};
|
2016-07-14 14:16:53 +00:00
|
|
|
}];
|
|
|
|
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
|
|
|
["Wheeled_APC_F", "init", {
|
2016-09-18 09:31:28 +00:00
|
|
|
params ["_vehicle"];
|
|
|
|
|
2016-10-28 20:10:40 +00:00
|
|
|
private _typeOf = typeOf _vehicle;
|
|
|
|
|
|
|
|
if (isNil {GVAR(cacheTankDuplicates) getVariable _typeOf}) then {
|
|
|
|
private _hitpoints = (getAllHitPointsDamage _vehicle param [0, []]) apply {toLower _x};
|
|
|
|
private _duplicateHitpoints = [];
|
|
|
|
|
|
|
|
{
|
|
|
|
if ((_x != "") && {_x in (_hitpoints select [0,_forEachIndex])}) then {
|
|
|
|
_duplicateHitpoints pushBack _forEachIndex;
|
|
|
|
};
|
|
|
|
} forEach _hitpoints;
|
|
|
|
|
|
|
|
TRACE_2("dupes",_typeOf,_duplicateHitpoints);
|
|
|
|
GVAR(cacheTankDuplicates) setVariable [_typeOf, _duplicateHitpoints];
|
|
|
|
};
|
|
|
|
|
2016-09-18 09:31:28 +00:00
|
|
|
_vehicle addEventHandler ["HandleDamage", {
|
|
|
|
if ((_this select 0) getVariable [QGVAR(enable), GVAR(enable)]) then {
|
2016-08-13 10:12:34 +00:00
|
|
|
["tank", _this] call FUNC(handleDamage);
|
|
|
|
};
|
2016-07-14 14:16:53 +00:00
|
|
|
}];
|
|
|
|
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
|
|
|
["Car", "init", {
|
2016-09-18 09:31:28 +00:00
|
|
|
params ["_vehicle"];
|
|
|
|
|
|
|
|
_vehicle addEventHandler ["HandleDamage", {
|
|
|
|
if ((_this select 0) getVariable [QGVAR(enable), GVAR(enable)]) then {
|
2016-08-13 10:12:34 +00:00
|
|
|
["car", _this] call FUNC(handleDamage);
|
|
|
|
};
|
2016-07-14 14:16:53 +00:00
|
|
|
}];
|
|
|
|
}, nil, ["Wheeled_APC_F"], true] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
2016-10-06 20:37:38 +00:00
|
|
|
["ReammoBox_F", "init", {
|
|
|
|
(_this select 0) addEventHandler ["HandleDamage", {
|
2016-11-05 14:48:48 +00:00
|
|
|
if ((_this select 0) getVariable [QGVAR(enable), GVAR(enableAmmobox)]) then {
|
2016-10-06 20:37:38 +00:00
|
|
|
["box", _this] call FUNC(handleDamage);
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
}, nil, nil, true] call CBA_fnc_addClassEventHandler;
|
|
|
|
|
2016-07-14 14:16:53 +00:00
|
|
|
// secondary explosions
|
2016-08-13 10:12:34 +00:00
|
|
|
["AllVehicles", "killed", {
|
2016-09-18 09:31:28 +00:00
|
|
|
params ["_vehicle"];
|
2016-10-06 20:37:38 +00:00
|
|
|
if (_vehicle getVariable [QGVAR(enable),GVAR(enable)]) then {
|
2016-09-18 09:31:28 +00:00
|
|
|
_vehicle call FUNC(secondaryExplosions);
|
2016-10-06 20:37:38 +00:00
|
|
|
if (_vehicle getVariable [QGVAR(enableAmmoCookoff), GVAR(enableAmmoCookoff)]) then {
|
|
|
|
[_vehicle, magazinesAmmo _vehicle] call FUNC(detonateAmmunition);
|
|
|
|
};
|
2016-08-13 10:12:34 +00:00
|
|
|
};
|
2016-10-06 20:37:38 +00:00
|
|
|
}, nil, ["Man","StaticWeapon"]] call CBA_fnc_addClassEventHandler;
|
2016-07-14 14:16:53 +00:00
|
|
|
|
|
|
|
// blow off turret effect
|
2016-08-13 10:12:34 +00:00
|
|
|
["Tank", "killed", {
|
2016-10-06 20:37:38 +00:00
|
|
|
if ((_this select 0) getVariable [QGVAR(enable),GVAR(enable)]) then {
|
|
|
|
if (random 1 < 0.15) then {
|
|
|
|
(_this select 0) call FUNC(blowOffTurret);
|
|
|
|
};
|
2016-08-13 10:12:34 +00:00
|
|
|
};
|
|
|
|
}] call CBA_fnc_addClassEventHandler;
|
2016-09-18 09:31:28 +00:00
|
|
|
|
|
|
|
// event to add a turret to a curator if the vehicle already belonged to that curator
|
|
|
|
if (isServer) then {
|
|
|
|
[QGVAR(addTurretToEditable), {
|
|
|
|
params ["_vehicle", "_turret"];
|
|
|
|
|
|
|
|
{
|
|
|
|
if (_vehicle in curatorEditableObjects _x) then {
|
|
|
|
_x addCuratorEditableObjects [[_turret], false];
|
|
|
|
};
|
|
|
|
} forEach allCurators;
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
};
|