Cookoff - Allow enabling only on player crewed vehicles (#7147)

* Add setting for cookoff to only run for player crewed vehicles

* No point having per vehicle selection

* Merging mutliple settings in to one

* Fixing missing comma

* Using LSTRING for settings

* merging suggested fixes

* Moving enabled check to fnc

* Use existing strings for CBA options

* Reverting change to support legacy eden attribute settings

* Adding Pabsts fix for 3den attribute

* Update addons/cookoff/CfgEden.hpp

Co-Authored-By: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Cyruz143 2019-11-05 17:55:15 +00:00 committed by PabstMirror
parent 2c5df0be77
commit 5d07029db7
4 changed files with 13 additions and 13 deletions

View File

@ -12,7 +12,7 @@ class Cfg3DEN {
expression = QUOTE(if !(_value) then {_this setVariable [ARR_3('%s',_value,true)];};); expression = QUOTE(if !(_value) then {_this setVariable [ARR_3('%s',_value,true)];};);
typeName = "BOOL"; typeName = "BOOL";
condition = "objectVehicle"; condition = "objectVehicle";
defaultValue = QUOTE(GETMVAR(QGVAR(enable),true)); defaultValue = QUOTE((GETMVAR(QGVAR(enable),0)) in [ARR_2(1,2)]);
}; };
class GVAR(enableAmmoCookoff) { class GVAR(enableAmmoCookoff) {
property = QGVAR(enableAmmoCookoff); property = QGVAR(enableAmmoCookoff);

View File

@ -27,9 +27,7 @@ GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
}; };
_vehicle addEventHandler ["HandleDamage", { _vehicle addEventHandler ["HandleDamage", {
if ((_this select 0) getVariable [QGVAR(enable), GVAR(enable)]) then { ["tank", _this] call FUNC(handleDamage);
["tank", _this] call FUNC(handleDamage);
};
}]; }];
}, nil, nil, true] call CBA_fnc_addClassEventHandler; }, nil, nil, true] call CBA_fnc_addClassEventHandler;
@ -53,9 +51,7 @@ GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
}; };
_vehicle addEventHandler ["HandleDamage", { _vehicle addEventHandler ["HandleDamage", {
if ((_this select 0) getVariable [QGVAR(enable), GVAR(enable)]) then { ["tank", _this] call FUNC(handleDamage);
["tank", _this] call FUNC(handleDamage);
};
}]; }];
}, nil, nil, true] call CBA_fnc_addClassEventHandler; }, nil, nil, true] call CBA_fnc_addClassEventHandler;
@ -63,9 +59,7 @@ GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
params ["_vehicle"]; params ["_vehicle"];
_vehicle addEventHandler ["HandleDamage", { _vehicle addEventHandler ["HandleDamage", {
if ((_this select 0) getVariable [QGVAR(enable), GVAR(enable)]) then { ["car", _this] call FUNC(handleDamage);
["car", _this] call FUNC(handleDamage);
};
}]; }];
}, nil, ["Wheeled_APC_F"], true] call CBA_fnc_addClassEventHandler; }, nil, ["Wheeled_APC_F"], true] call CBA_fnc_addClassEventHandler;
@ -89,7 +83,7 @@ GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
// blow off turret effect // blow off turret effect
["Tank", "killed", { ["Tank", "killed", {
if ((_this select 0) getVariable [QGVAR(enable),GVAR(enable)]) then { if ((_this select 0) getVariable [QGVAR(enable), GVAR(enable)] in [1, 2, true]) then {
if (random 1 < 0.15) then { if (random 1 < 0.15) then {
(_this select 0) call FUNC(blowOffTurret); (_this select 0) call FUNC(blowOffTurret);
}; };

View File

@ -21,6 +21,12 @@ _thisHandleDamage params ["_vehicle", "", "_damage", "_source", "_ammo", "_hitIn
// it's already dead, who cares? // it's already dead, who cares?
if (damage _vehicle >= 1) exitWith {}; if (damage _vehicle >= 1) exitWith {};
// If cookoff is disabled exit
if (_vehicle getVariable [QGVAR(enable), GVAR(enable)] in [0, false]) exitWith {};
// Check for players and exit if none found and the enable for players only setting is true
if (_vehicle getVariable [QGVAR(enable), GVAR(enable)] isEqualTo 2 && {fullCrew [_vehicle, "", false] findIf {isPlayer (_x select 0)} == -1}) exitWith {};
// get hitpoint name // get hitpoint name
private _hitpoint = "#structural"; private _hitpoint = "#structural";

View File

@ -1,10 +1,10 @@
// CBA Settings [ADDON: ace_cookoff]: // CBA Settings [ADDON: ace_cookoff]:
[ [
QGVAR(enable), "CHECKBOX", QGVAR(enable), "LIST",
[LSTRING(enable_hd_name), LSTRING(enable_hd_tooltip)], [LSTRING(enable_hd_name), LSTRING(enable_hd_tooltip)],
LSTRING(category_displayName), LSTRING(category_displayName),
false, // default value [[0, 1, 2], ["STR_A3_OPTIONS_DISABLED", ELSTRING(common,playerOnly), ELSTRING(common,playersAndAI)], 0],
true, // isGlobal true, // isGlobal
{[QGVAR(enable), _this] call EFUNC(common,cbaSettings_settingChanged)}, {[QGVAR(enable), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart true // Needs mission restart