mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fixed objects not being able to cook-off again
This commit is contained in:
parent
370f141776
commit
e541b337c5
@ -16,33 +16,24 @@ if (isServer) then {
|
|||||||
["AllVehicles", "Deleted", {
|
["AllVehicles", "Deleted", {
|
||||||
{
|
{
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
} forEach ((_this select 0) getVariable [QGVAR(vehicleEffects), []]);
|
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
|
||||||
}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
|
}, true, ["CAManBase", "StaticWeapon"], true] call CBA_fnc_addClassEventHandler;
|
||||||
|
|
||||||
["ReammoBox_F", "Deleted", {
|
["ReammoBox_F", "Deleted", {
|
||||||
{
|
{
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
} forEach ((_this select 0) getVariable [QGVAR(boxEffects), []]);
|
} forEach ((_this select 0) getVariable [QGVAR(effects), []]);
|
||||||
}, true, [], true] call CBA_fnc_addClassEventHandler;
|
}, true, [], true] call CBA_fnc_addClassEventHandler;
|
||||||
|
|
||||||
[QGVAR(cleanupVehicleEffects), {
|
// Raised when the flames have subsided or after the ammo of a box has finished cooking off
|
||||||
|
[QGVAR(cleanupEffects), {
|
||||||
params ["_object"];
|
params ["_object"];
|
||||||
|
|
||||||
{
|
{
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
} forEach (_object getVariable [QGVAR(vehicleEffects), []]);
|
} forEach (_object getVariable [QGVAR(effects), []]);
|
||||||
|
|
||||||
_object setVariable [QGVAR(vehicleEffects), nil];
|
_object setVariable [QGVAR(effects), nil];
|
||||||
}] call CBA_fnc_addEventHandler;
|
|
||||||
|
|
||||||
[QGVAR(cleanupBoxEffects), {
|
|
||||||
params ["_object"];
|
|
||||||
|
|
||||||
{
|
|
||||||
deleteVehicle _x;
|
|
||||||
} forEach (_object getVariable [QGVAR(boxEffects), []]);
|
|
||||||
|
|
||||||
_object setVariable [QGVAR(boxEffects), nil];
|
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
// Ammo box damage handling
|
// Ammo box damage handling
|
||||||
|
@ -112,7 +112,10 @@ if (_delayBetweenSmokeAndFire) then {
|
|||||||
if (isNull _vehicle) exitWith {};
|
if (isNull _vehicle) exitWith {};
|
||||||
|
|
||||||
// Remove effects
|
// Remove effects
|
||||||
[QGVAR(cleanupVehicleEffects), _vehicle] call CBA_fnc_globalEvent;
|
[QGVAR(cleanupEffects), _vehicle] call CBA_fnc_globalEvent;
|
||||||
|
|
||||||
|
// Reset variable, so it can cook-off again
|
||||||
|
_vehicle setVariable [QGVAR(isCookingOff), nil, true];
|
||||||
|
|
||||||
if (GVAR(destroyVehicleAfterCookoff) || _detonateAfterCookoff) then {
|
if (GVAR(destroyVehicleAfterCookoff) || _detonateAfterCookoff) then {
|
||||||
_vehicle setDamage [1, true, _source, _instigator]; // because it's running on the server, killer and instigator can be set
|
_vehicle setDamage [1, true, _source, _instigator]; // because it's running on the server, killer and instigator can be set
|
||||||
|
@ -49,5 +49,5 @@ params ["", "", "", "_startTime", "_smokeDelay"];
|
|||||||
[QGVAR(detonateAmmunition), [_box, true, _source, _instigator, random [DETONATION_DELAY / 2, DETONATION_DELAY, DETONATION_DELAY / 2 * 3]]] call CBA_fnc_localEvent;
|
[QGVAR(detonateAmmunition), [_box, true, _source, _instigator, random [DETONATION_DELAY / 2, DETONATION_DELAY, DETONATION_DELAY / 2 * 3]]] call CBA_fnc_localEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
_box setVariable [QGVAR(boxEffects), _effects];
|
_box setVariable [QGVAR(effects), _effects];
|
||||||
}, _this, (_startTime - CBA_missionTime + _smokeDelay) max 0] call CBA_fnc_waitAndExecute; // this delay allows for synchronisation for JIP players
|
}, _this, (_startTime - CBA_missionTime + _smokeDelay) max 0] call CBA_fnc_waitAndExecute; // this delay allows for synchronisation for JIP players
|
||||||
|
@ -26,7 +26,9 @@ params ["_object", ["_destroyWhenFinished", false], ["_source", objNull], ["_ins
|
|||||||
if (isNull _object) exitWith {};
|
if (isNull _object) exitWith {};
|
||||||
|
|
||||||
// Don't have an object detonate its ammo twice
|
// Don't have an object detonate its ammo twice
|
||||||
if (!isNil {_object getVariable QGVAR(cookoffMagazines)}) exitWith {};
|
if (_object getVariable [QGVAR(isAmmoDetonating), false]) exitWith {};
|
||||||
|
|
||||||
|
_object setVariable [QGVAR(isAmmoDetonating), true, true];
|
||||||
|
|
||||||
_object setVariable [QGVAR(cookoffMagazines), _object call FUNC(getVehicleAmmo)];
|
_object setVariable [QGVAR(cookoffMagazines), _object call FUNC(getVehicleAmmo)];
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* 3: Instigator <OBJECT>
|
* 3: Instigator <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* Nothing Useful
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [cursorObject, true, player, player] call ace_cookoff_fnc_detonateAmmunitionServer
|
* [cursorObject, true, player, player] call ace_cookoff_fnc_detonateAmmunitionServer
|
||||||
@ -26,19 +26,11 @@ if (isNull _object) exitWith {};
|
|||||||
|
|
||||||
(_object getVariable QGVAR(cookoffMagazines)) params ["_magazines", "_totalAmmo"];
|
(_object getVariable QGVAR(cookoffMagazines)) params ["_magazines", "_totalAmmo"];
|
||||||
|
|
||||||
// If the cook-off has finished, clean up the effects and destroy the object
|
private _hasFinished = _totalAmmo <= 0 || {_magazines isEqualTo []};
|
||||||
if (_magazines isEqualTo [] || {_totalAmmo <= 0}) exitWith {
|
|
||||||
[QGVAR(cleanupBoxEffects), _object] call CBA_fnc_globalEvent;
|
|
||||||
|
|
||||||
_object setVariable [QGVAR(cookoffMagazines), nil];
|
// If the cook-off has finished or been interrupted, clean up the effects for boxes (no vehicle effects)
|
||||||
|
if (_hasFinished ||
|
||||||
if (_destroyWhenFinished) then {
|
{underwater _object} || {
|
||||||
_object setDamage [1, true, _source, _instigator];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
// If the cook-off is interrupted or disabled, clean up the effects
|
|
||||||
if (underwater _object || {
|
|
||||||
if (GVAR(ammoCookoffDuration) == 0) exitWith {true};
|
if (GVAR(ammoCookoffDuration) == 0) exitWith {true};
|
||||||
|
|
||||||
if (_object isKindOf "ReammoBox_F") exitWith {
|
if (_object isKindOf "ReammoBox_F") exitWith {
|
||||||
@ -47,9 +39,21 @@ if (underwater _object || {
|
|||||||
|
|
||||||
!(GVAR(enableAmmoCookoff) && {_object getVariable [QGVAR(enableAmmoCookoff), true]})
|
!(GVAR(enableAmmoCookoff) && {_object getVariable [QGVAR(enableAmmoCookoff), true]})
|
||||||
}) exitWith {
|
}) exitWith {
|
||||||
[QGVAR(cleanupBoxEffects), _object] call CBA_fnc_globalEvent;
|
if (_object isKindOf "ReammoBox_F") then {
|
||||||
|
[QGVAR(cleanupEffects), _object] call CBA_fnc_globalEvent;
|
||||||
|
|
||||||
|
// Reset variable, so the box can cook-off again
|
||||||
|
_object setVariable [QGVAR(isCookingOff), nil, true];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reset variables, so the object can detonate its ammo again
|
||||||
_object setVariable [QGVAR(cookoffMagazines), nil];
|
_object setVariable [QGVAR(cookoffMagazines), nil];
|
||||||
|
_object setVariable [QGVAR(isAmmoDetonating), nil, true];
|
||||||
|
|
||||||
|
// If done, destroy the object if necessary
|
||||||
|
if (_hasFinished && _destroyWhenFinished) then {
|
||||||
|
_object setDamage [1, true, _source, _instigator];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
private _magazineIndex = floor random (count _magazines);
|
private _magazineIndex = floor random (count _magazines);
|
||||||
@ -76,9 +80,6 @@ _totalAmmo = _totalAmmo - _removed;
|
|||||||
|
|
||||||
_object setVariable [QGVAR(cookoffMagazines), [_magazines, _totalAmmo]];
|
_object setVariable [QGVAR(cookoffMagazines), [_magazines, _totalAmmo]];
|
||||||
|
|
||||||
// Detonate the remaining ammo after a delay
|
|
||||||
[FUNC(detonateAmmunitionServer), [_object, _destroyWhenFinished, _source, _instigator], _timeBetweenAmmoDetonation] call CBA_fnc_waitAndExecute;
|
|
||||||
|
|
||||||
// Get magazine info, which is used to spawn projectiles
|
// Get magazine info, which is used to spawn projectiles
|
||||||
private _configMagazine = configFile >> "CfgMagazines" >> _magazineClassname;
|
private _configMagazine = configFile >> "CfgMagazines" >> _magazineClassname;
|
||||||
private _ammo = getText (_configMagazine >> "ammo");
|
private _ammo = getText (_configMagazine >> "ammo");
|
||||||
@ -169,3 +170,6 @@ switch (_simType) do {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Detonate the remaining ammo after a delay
|
||||||
|
[FUNC(detonateAmmunitionServer), [_object, _destroyWhenFinished, _source, _instigator], _timeBetweenAmmoDetonation] call CBA_fnc_waitAndExecute;
|
||||||
|
@ -41,4 +41,4 @@ private _effects = [_smokeBarrel];
|
|||||||
_effects pushBack _smoke;
|
_effects pushBack _smoke;
|
||||||
} forEach _positions;
|
} forEach _positions;
|
||||||
|
|
||||||
_vehicle setVariable [QGVAR(vehicleEffects), _effects];
|
_vehicle setVariable [QGVAR(effects), _effects];
|
||||||
|
@ -21,18 +21,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
params ["_vehicle", "_chanceOfDetonate", "_vehicleAmmo", "_explosiveAmmoCount", "_nonExplosiveAmmoCount", ["_injurer", objNull]];
|
params ["_vehicle", "_chanceOfDetonate", "_vehicleAmmo", "_explosiveAmmoCount", "_nonExplosiveAmmoCount", ["_injurer", objNull]];
|
||||||
private _alreadyDetonating = _vehicle getVariable [QGVAR(detonating), false];
|
|
||||||
private _isKnockedOut = _explosiveAmmoCount > 0;
|
private _isKnockedOut = _explosiveAmmoCount > 0;
|
||||||
|
|
||||||
if (!_alreadyDetonating && { _chanceOfDetonate >= random 1 }) exitWith {
|
// Ignore if the vehicle is already detonating ammo
|
||||||
|
if (_vehicle getVariable [QEGVAR(cookoff,isAmmoDetonating), false]) exitWith {_isKnockedOut};
|
||||||
|
|
||||||
|
if (_chanceOfDetonate >= random 1) exitWith {
|
||||||
[_vehicle, _injurer, _vehicleAmmo] call FUNC(detonate);
|
[_vehicle, _injurer, _vehicleAmmo] call FUNC(detonate);
|
||||||
LOG_2("Detonating [%1] with a chance-to-detonate [%2]",_vehicle,_chanceOfDetonate);
|
LOG_2("Detonating [%1] with a chance-to-detonate [%2]",_vehicle,_chanceOfDetonate);
|
||||||
_vehicle setVariable [QGVAR(detonating), true];
|
|
||||||
_isKnockedOut
|
_isKnockedOut
|
||||||
};
|
};
|
||||||
|
|
||||||
// Avoid RPT spam
|
|
||||||
if (_alreadyDetonating) exitWith { _isKnockedOut };
|
|
||||||
|
|
||||||
LOG_2("[%1] No Detonation - Chance of detonation [%2]",_vehicle,_chanceOfDetonate);
|
LOG_2("[%1] No Detonation - Chance of detonation [%2]",_vehicle,_chanceOfDetonate);
|
||||||
false
|
false
|
||||||
|
Loading…
Reference in New Issue
Block a user