Skip to content

Commit

Permalink
Cookoff - Use triggerAmmo instead of setDamage (acemod#10185)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 authored and blake8090 committed Aug 18, 2024
1 parent 3854a6c commit 80e4de4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
29 changes: 10 additions & 19 deletions addons/cookoff/functions/fnc_detonateAmmunitionServerLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private _configMagazine = configFile >> "CfgMagazines" >> _magazineClassname;
private _ammo = getText (_configMagazine >> "ammo");
private _configAmmo = configFile >> "CfgAmmo" >> _ammo;

private _simType = toLower getText (_configAmmo >> "simulation");
private _simType = toLowerANSI getText (_configAmmo >> "simulation");
private _speed = linearConversion [0, 1, random 1, 1, 20, true];
private _effect2pos = _object selectionPosition "destructionEffect2";

Expand All @@ -100,7 +100,7 @@ private _fnc_spawnProjectile = {
// If the magazines are inside of the cargo (inventory), don't let their projectiles escape the interior of the vehicle
if (!_spawnProjectile) exitWith {};

params ["_object", "_ammo", "_speed", "_flyAway"];
params ["_flyAway"];

private _spawnPos = _object modelToWorld [-0.2 + random 0.4, -0.2 + random 0.4, random 3];

Expand All @@ -117,7 +117,7 @@ private _fnc_spawnProjectile = {
_projectile setVectorDir _vectorVelocity;
_projectile setVelocity _vectorVelocity;
} else {
_projectile setDamage 1;
triggerAmmo _projectile;
};
};

Expand All @@ -126,53 +126,44 @@ switch (_simType) do {
[QGVAR(playCookoffSound), [_object, _simType]] call CBA_fnc_globalEvent;

if (random 1 < 0.6) then {
[_object, _ammo, _speed, true] call _fnc_spawnProjectile;
true call _fnc_spawnProjectile;
};
};
case "shotshell": {
[QGVAR(playCookoffSound), [_object, _simType]] call CBA_fnc_globalEvent;

if (random 1 < 0.15) then {
[_object, _ammo, _speed, true] call _fnc_spawnProjectile;
true call _fnc_spawnProjectile;
};
};
case "shotgrenade": {
if (random 1 < 0.9) then {
_speed = 0;
};

[_object, _ammo, _speed, random 1 < 0.5] call _fnc_spawnProjectile;
(random 1 < 0.5) call _fnc_spawnProjectile;
};
case "shotrocket";
case "shotmissile";
case "shotsubmunitions": {
if (random 1 < 0.1) then {
[QGVAR(playCookoffSound), [_object, _simType]] call CBA_fnc_globalEvent;

[_object, _ammo, _speed, random 1 < 0.3] call _fnc_spawnProjectile;
(random 1 < 0.3) call _fnc_spawnProjectile;
} else {
createVehicle ["ACE_ammoExplosionLarge", _object modelToWorld _effect2pos, [], 0 , "CAN_COLLIDE"];
};
};
case "shotdirectionalbomb";
case "shotmine": {
if (random 1 < 0.5) then {
// Not all explosives detonate on destruction, some have scripted alternatives
if (getNumber (_configAmmo >> "triggerWhenDestroyed") != 1) then {
_ammo = getText (_configAmmo >> QEGVAR(explosives,explosive));
};

// If a scripted alternative doesn't exist use generic explosion
if (_ammo != "") then {
[_object, _ammo, 0, false] call _fnc_spawnProjectile;
} else {
createVehicle ["SmallSecondary", _object modelToWorld _effect2pos, [], 0 , "CAN_COLLIDE"];
};
// _speed should be 0, but as it doesn't fly away, no need to set _speed
false call _fnc_spawnProjectile;
};
};
case "shotilluminating": {
if (random 1 < 0.15) then {
[_object, _ammo, _speed, random 1 < 0.3] call _fnc_spawnProjectile;
(random 1 < 0.3) call _fnc_spawnProjectile;
};
};
};
Expand Down
2 changes: 1 addition & 1 deletion addons/cookoff/functions/fnc_getVehicleAmmo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private _ammo = "";
_x params ["_magazine", "_count"];

if (_count > 0 && {!(_magazine call FUNC(isMagazineFlare))}) then {
_ammoToDetonate pushBack [_magazine, _count, false];
_ammoToDetonate pushBack [_magazine, _count, random 1 < 0.5];
_totalAmmo = _totalAmmo + _count;
};
} forEach (magazinesAmmoCargo _object);
Expand Down

0 comments on commit 80e4de4

Please sign in to comment.