Don't cookoff when commander turret is hit (#4280)

This commit is contained in:
PabstMirror 2016-08-23 02:57:54 -05:00 committed by commy2
parent aaa6b75302
commit 5a83659136
2 changed files with 21 additions and 1 deletions

View File

@ -3,9 +3,25 @@
[QGVAR(engineFire), FUNC(engineFire)] call CBA_fnc_addEventHandler;
[QGVAR(cookOff), FUNC(cookOff)] call CBA_fnc_addEventHandler;
GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
// cookoff and burning engine
["Tank", "init", {
(_this select 0) addEventHandler ["HandleDamage", {
params ["_vehicle"];
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];
};
_vehicle addEventHandler ["HandleDamage", {
if (GVAR(enable)) then {
["tank", _this] call FUNC(handleDamage);
};

View File

@ -60,6 +60,10 @@ if (_simulationType == "tank") exitWith {
// determine ammo storage location
private _ammoLocationHitpoint = getText (_vehicle call CBA_fnc_getObjectConfig >> QGVAR(ammoLocation));
if (_hitIndex in (GVAR(cacheTankDuplicates) getVariable (typeOf _vehicle))) then {
_hitpoint = "#subturret";
};
// ammo was hit, high chance for cook-off
if (_hitpoint == _ammoLocationHitpoint) then {
if (_damage > 0.5 && {random 1 < 0.7}) then {