Added random destruction of fuel and ammo storage

This commit is contained in:
johnb432 2024-06-28 09:20:08 +02:00
parent fa5923378f
commit b9531b0644
2 changed files with 28 additions and 0 deletions

View File

@ -39,6 +39,31 @@
[QGVAR(unloadedCargoOnKilled), {
params ["_item", "_vehicle"];
// Remove invulernability from this addon
[_item, "blockDamage", QUOTE(ADDON), false] call EFUNC(common,statusEffect_set);
// Check if item can take damage
if (isDamageAllowed _item) then {
// Random chance of destroying fuel and ammo storage
if (
random 1 < CARGO_DESTROY_FUEL_CHANCE &&
{getFuelCargo _item > 0 || {missionNamespace getVariable [QEGVAR(refuel,enabled), false] && {(_item call EFUNC(refuel,getFuel)) > 0}}}
) then {
_item setDamage 1;
};
// If the item has ammunition, detonate it
if (["ace_cookoff"] call EFUNC(common,isModLoaded) && {random 1 < CARGO_DESTROY_AMMO_CHANCE} && {(_item call EFUNC(cookoff,getVehicleAmmo)) select 1 > 0}) then {
[QEGVAR(cookoff,cookOffBoxServer), _item] call CBA_fnc_serverEvent;
};
// Readd invulnerability for while, so that items aren't destroyed when being thrown
[_item, "blockDamage", QUOTE(ADDON), true] call EFUNC(common,statusEffect_set);
// Even though QGVAR(serverUnload) handles that on the server, make sure invulnerability from this addon is removed
[EFUNC(common,statusEffect_set), [_item, "blockDamage", QUOTE(ADDON), false], 2] call CBA_fnc_waitAndExecute;
};
// Get direction from vehicle to item, so that item is thrown away from vehicle
private _vectorDir = (getPosWorld _vehicle) vectorFromTo (getPosWorld _item);

View File

@ -20,5 +20,8 @@
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
#define CARGO_DESTROY_FUEL_CHANCE 0.5
#define CARGO_DESTROY_AMMO_CHANCE 0.8
#define CARGO_TUMBLE_RANDOM_MUL 8
#define CARGO_TUMBLE_TORQUE 500