Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookoff - Allow enabling only on player crewed vehicles #7147

Merged
merged 11 commits into from
Nov 5, 2019
2 changes: 1 addition & 1 deletion addons/cookoff/CfgEden.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Cfg3DEN {
expression = QUOTE(if !(_value) then {_this setVariable [ARR_3('%s',_value,true)];};);
typeName = "BOOL";
condition = "objectVehicle";
defaultValue = QUOTE(GETMVAR(QGVAR(enable),true));
defaultValue = QUOTE((GETMVAR(QGVAR(enable),0)) in [ARR_2(1,2)]);
};
class GVAR(enableAmmoCookoff) {
property = QGVAR(enableAmmoCookoff);
Expand Down
14 changes: 4 additions & 10 deletions addons/cookoff/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
};

_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;

Expand All @@ -53,19 +51,15 @@ GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;
};

_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;

["Car", "init", {
params ["_vehicle"];

_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;

Expand All @@ -89,7 +83,7 @@ GVAR(cacheTankDuplicates) = call CBA_fnc_createNamespace;

// blow off turret effect
["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 {
Cyruz143 marked this conversation as resolved.
Show resolved Hide resolved
if (random 1 < 0.15) then {
(_this select 0) call FUNC(blowOffTurret);
};
Expand Down
6 changes: 6 additions & 0 deletions addons/cookoff/functions/fnc_handleDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ _thisHandleDamage params ["_vehicle", "", "_damage", "_source", "_ammo", "_hitIn
// it's already dead, who cares?
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 {};
Cyruz143 marked this conversation as resolved.
Show resolved Hide resolved

// get hitpoint name
private _hitpoint = "#structural";

Expand Down
4 changes: 2 additions & 2 deletions addons/cookoff/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// CBA Settings [ADDON: ace_cookoff]:

[
QGVAR(enable), "CHECKBOX",
QGVAR(enable), "LIST",
[LSTRING(enable_hd_name), LSTRING(enable_hd_tooltip)],
LSTRING(category_displayName),
false, // default value
[[0, 1, 2], ["STR_A3_OPTIONS_DISABLED", ELSTRING(common,playerOnly), ELSTRING(common,playersAndAI)], 0],
true, // isGlobal
{[QGVAR(enable), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
Expand Down