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 - Use triggerAmmo instead of setDamage #10185

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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