More changes

This commit is contained in:
johnb432 2024-02-03 17:48:54 +01:00
parent a999c81fec
commit d7dafa4d40
13 changed files with 86 additions and 97 deletions

View File

@ -73,9 +73,6 @@ if (isServer) then {
params ["_vehicle", "", "", "_useEffects"];
if (_useEffects && {_vehicle getVariable [QGVAR(enableAmmoCookoff), true]}) then {
(_vehicle call FUNC(getVehicleAmmo)) params ["_magazines", "_total"];
private _delay = (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY;
[QGVAR(detonateAmmunition), [_vehicle, _magazines, _total, false, objNull, objNull, _delay]] call CBA_fnc_serverEvent;
[QGVAR(detonateAmmunition), [_vehicle, false, objNull, objNull, (random MAX_AMMO_DETONATION_START_DELAY) max MIN_AMMO_DETONATION_START_DELAY]] call CBA_fnc_serverEvent;
};
}, nil, ["CAManBase", "StaticWeapon"]] call CBA_fnc_addClassEventHandler;

View File

@ -107,7 +107,7 @@ if (_delayBetweenSmokeAndFire) then {
};
// Wait until we are ready for the next flame
if (CBA_missionTime >= _vehicle getVariable [QGVAR(nextFlame), 0]) then {
if (_vehicle getVariable [QGVAR(nextFlame), 0] <= CBA_missionTime) then {
private _ring = false;
if (_canRing) then {

View File

@ -70,14 +70,9 @@ if (_delay >= 0) then {
_box setVariable [QGVAR(effects), _effects];
};
// These functions are smart and do all the cooking off work
// Detonate the ammunition
if (isServer) then {
(_box call FUNC(getVehicleAmmo)) params ["_magazines", "_total"];
[QGVAR(detonateAmmunition), [_box, _magazines, _total, true, _killer, _instigator]] call CBA_fnc_localEvent;
// This shit is busy being on fire, magazines aren't accessible/usable
clearMagazineCargoGlobal _box;
[QGVAR(detonateAmmunition), [_box, true, _killer, _instigator]] call CBA_fnc_localEvent;
};
}, _this, _delay] call CBA_fnc_waitAndExecute;
};

View File

@ -84,9 +84,10 @@ if (isServer) then {
};
// Make flame push object into ground to make effect seem more "alive"
if (_jet && !isGamePaused && {local _vehicle}) then {
if (_jet && !isGamePaused && {local _vehicle} && {_vehicle getVariable [QGVAR(nextForceTime), 0] <= CBA_missionTime}) then {
private _force = [0, 0, _factor * -(0.5 min random 1.5) * (0.3 min random 1)] vectorMultiply getMass _vehicle;
_vehicle addForce [_force, vectorUpVisual _vehicle];
_vehicle setVariable [QGVAR(nextForceTime), CBA_missionTime + 0.01]; // this prevents bad behaviour when setAccTime is small
};
// Don't spawn visual effects on machines without interfaces

View File

@ -1,34 +1,50 @@
#include "..\script_component.hpp"
/*
* Author: Glowbal
* Author: Glowbal, johnb43
* Detonates ammunition from an object (e.g. vehicle or crate) until no ammo is left.
*
* Arguments:
* 0: Object <OBJECT>
* 1: Magazine array <ARRAY>
* - 0: Magazine classname <STRING>
* - 1: Ammo count <NUMBER>
* 2: Total ammo count <NUMBER>
* 3: Destroy when finished <BOOL> (default: false)
* 4: Killer <OBJECT> (default: objNull)
* 5: Instigator <OBJECT> (default: objNull)
* 6: Initial delay <NUMBER> (default: 0)
* 1: Destroy when finished <BOOL> (default: false)
* 2: Killer <OBJECT> (default: objNull)
* 3: Instigator <OBJECT> (default: objNull)
* 4: Initial delay <NUMBER> (default: 0)
*
* Return Value:
* Nothing Useful
*
* Example:
* [cursorObject, magazinesAmmo vehicle player, 1000] call ace_cookoff_fnc_detonateAmmunition
* [cursorObject] call ace_cookoff_fnc_detonateAmmunition
*
* Public: No
*/
if (!isServer) exitWith {};
params ["_object", "_magazines", "_totalAmmo", ["_destroyWhenFinished", false], ["_killer", objNull], ["_instigator", objNull], ["_initialDelay", 0]];
params ["_object", ["_destroyWhenFinished", false], ["_killer", objNull], ["_instigator", objNull], ["_initialDelay", 0]];
if (isNull _object) exitWith {};
private _vehicleAmmo = _object getVariable QGVAR(cookoffMagazines);
if (isNil "_vehicleAmmo") then {
_vehicleAmmo = _object call FUNC(getVehicleAmmo);
_object setVariable [QGVAR(cookoffMagazines), _vehicleAmmo];
// TODO: When setMagazineTurretAmmo and magazineTurretAmmo are fixed (https://feedback.bistudio.com/T79689),
// we can add gradual ammo removal during cook-off
if (GVAR(removeAmmoDuringCookoff)) then {
clearMagazineCargoGlobal _object;
{
_object removeMagazinesTurret [_x select 0, _x select 1];
} forEach (magazinesAllTurrets _object);
};
};
_vehicleAmmo params ["_magazines", "_totalAmmo"];
// If the cook-off has finished, clean up the effects and destroy the object
if (_magazines isEqualTo [] || {_totalAmmo <= 0}) exitWith {
[QGVAR(cleanupEffects), _object] call CBA_fnc_globalEvent;
@ -53,12 +69,12 @@ if (underwater _object || {
// Initial delay allows for a delay for the first time this function runs in its cycle
if (_initialDelay > 0) exitWith {
[FUNC(detonateAmmunition), [_object, _magazines, _totalAmmo, _destroyWhenFinished, _killer, _instigator], _initialDelay] call CBA_fnc_waitAndExecute;
[FUNC(detonateAmmunition), [_object, _destroyWhenFinished, _killer, _instigator], _initialDelay] call CBA_fnc_waitAndExecute;
};
private _magazineIndex = floor random (count _magazines);
private _magazine = _magazines select _magazineIndex;
_magazine params ["_magazineClassname", "_ammoCount"];
_magazine params ["_magazineClassname", "_ammoCount", "_spawnProjectile"];
// Make sure ammo is at least 0
_ammoCount = _ammoCount max 0;
@ -78,8 +94,10 @@ private _timeBetweenAmmoDetonation = ((random 10 / sqrt _totalAmmo) min MAX_TIME
TRACE_2("",_totalAmmo,_timeBetweenAmmoDetonation);
_totalAmmo = _totalAmmo - _removed;
_object setVariable [QGVAR(cookoffMagazines), [_magazines, _totalAmmo]];
// Detonate the remaining ammo after a delay
[FUNC(detonateAmmunition), [_object, _magazines, _totalAmmo, _destroyWhenFinished, _killer, _instigator], _timeBetweenAmmoDetonation] call CBA_fnc_waitAndExecute;
[FUNC(detonateAmmunition), [_object, _destroyWhenFinished, _killer, _instigator], _timeBetweenAmmoDetonation] call CBA_fnc_waitAndExecute;
// Get magazine info, which is used to spawn projectiles
private _configMagazine = configFile >> "CfgMagazines" >> _magazineClassname;
@ -87,12 +105,14 @@ private _ammo = getText (_configMagazine >> "ammo");
private _configAmmo = configFile >> "CfgAmmo" >> _ammo;
private _simType = toLower getText (_configAmmo >> "simulation");
private _speed = random (getNumber (_configMagazine >> "initSpeed") / 10) max 1;
private _speed = linearConversion [0, 1, random 1, 1, 20, true];
private _effect2pos = _object selectionPosition "destructionEffect2";
// Spawns the projectiles, making them either fly in random directions or explode
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"];
private _spawnPos = _object modelToWorld [-0.2 + random 0.4, -0.2 + random 0.4, random 3];

View File

@ -41,7 +41,7 @@ private _ammo = "";
continue;
};
_ammoToDetonate pushBack [_magazine, _count];
_ammoToDetonate pushBack [_magazine, _count, true];
_totalAmmo = _totalAmmo + _count;
};
} forEach (magazinesAllTurrets [_vehicle, true]);
@ -51,7 +51,7 @@ private _ammo = "";
_x params ["_magazine", "_count"];
if (_count > 0 && {!(_magazine call FUNC(isMagazineFlare))}) then {
_ammoToDetonate pushBack [_magazine, _count];
_ammoToDetonate pushBack [_magazine, _count, false];
_totalAmmo = _totalAmmo + _count;
};
} forEach (magazinesAmmoCargo _vehicle);
@ -63,13 +63,13 @@ private _configSupply = (getNumber (_configVehicle >> "transportAmmo")) max (get
if (_vehicle getVariable [QEGVAR(rearm,isSupplyVehicle), _configSupply > 0]) then {
TRACE_1("transportAmmo vehicle - adding virtual ammo",typeOf _vehicle);
_ammoToDetonate pushBack ["2000Rnd_65x39_belt", 2000];
_ammoToDetonate pushBack ["2000Rnd_65x39_belt", 2000, false];
_totalAmmo = _totalAmmo + 2000;
_ammoToDetonate pushBack ["20Rnd_105mm_HEAT_MP", 100];
_ammoToDetonate pushBack ["20Rnd_105mm_HEAT_MP", 100, true];
_totalAmmo = _totalAmmo + 100;
_ammoToDetonate pushBack ["SatchelCharge_Remote_Mag", 10];
_ammoToDetonate pushBack ["SatchelCharge_Remote_Mag", 10, true];
_totalAmmo = _totalAmmo + 10;
};

View File

@ -67,3 +67,13 @@
1,
{[QGVAR(ammoCookoffDuration), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting;
[
QGVAR(removeAmmoDuringCookoff),
"CHECKBOX",
[LSTRING(removeAmmoDuringCookoff_name), LSTRING(removeAmmoDuringCookoff_tooltip)],
LSTRING(category_displayName),
true,
1,
{[QGVAR(removeAmmoDuringCookoff), _this] call EFUNC(common,cbaSettings_settingChanged)}
] call CBA_fnc_addSetting;

View File

@ -99,5 +99,22 @@
<French>Contrôle si les véhicules seront toujours détruits après l'auto-inflammation.</French>
<Portuguese>Define se os veículos serão sempre destruídos após cozinhamento.</Portuguese>
</Key>
<Key ID="STR_ACE_CookOff_removeAmmoDuringCookoff_name">
<English>Enable ammo removal during cook-off</English>
<Japanese>誘爆中の弾薬除去を有効/無効にする</Japanese>
<French>Retirer les munitions durant l'auto-inflammation</French>
<German>Aktiviert/Deaktiviert Entfernung der Munition beim Durchzünden</German>
<Italian>Abilita rimozione munizioni dopo l'esplosione</Italian>
<Polish>Włącz/Wyłącz usuwanie amunicji podczas samozapłonu</Polish>
<Chinesesimp>启用/禁用殉爆过程中的弹药移除功能</Chinesesimp>
<Korean>쿡오프시 탄약 제거 활성화/비활성화</Korean>
<Russian>Удалять боеприпасы из-за детонации</Russian>
<Spanish>Habilita/Deshabilita ka eliminación de munición durante la detonación inducida por calor</Spanish>
</Key>
<Key ID="STR_ACE_CookOff_removeAmmoDuringCookoff_tooltip">
<English>Removes all ammo during cook-off.</English>
<French>Retire des munitions des véhicules durant une auto-inflammation.</French>
<German>Entfernt Munition während dem Durchzünden der Munition eines Fahrzeuges.</German>
</Key>
</Package>
</Project>

View File

@ -6,7 +6,6 @@
* Arguments:
* 0: The vehicle <OBJECT>
* 1: Person who caused detonation <OBJECT> (default: objNull)
* 2: An array of vehicle ammo in vehicle <ARRAY> (default: [])
*
* Return Value:
* None
@ -17,15 +16,9 @@
* Public: No
*/
params ["_vehicle", ["_injurer", objNull], ["_vehicleAmmo", []]];
params ["_vehicle", ["_injurer", objNull]];
if (_vehicleAmmo isEqualTo []) then {
_vehicleAmmo = [_vehicle] call EFUNC(cookoff,getVehicleAmmo);
};
[QEGVAR(cookoff,detonateAmmunition), [_vehicle] + _vehicleAmmo] call CBA_fnc_serverEvent;
if ((_vehicleAmmo select 1) > 0) then {
if (((_vehicle call EFUNC(cookoff,getVehicleAmmo)) select 1) > 0) then {
{
// random amount of injuries
for "_i" from 0 to random 5 do {
@ -33,3 +26,5 @@ if ((_vehicleAmmo select 1) > 0) then {
};
} forEach crew _vehicle;
};
[QEGVAR(cookoff,detonateAmmunition), [_vehicle, false, _injurer, _injurer]] call CBA_fnc_serverEvent;

View File

@ -23,11 +23,12 @@
params ["_vehicle", "_chanceOfFire", "_intensity", ["_injurer", objNull], ["_hitPart", ""], ["_canRing", false], ["_canJet", true]];
private _alreadyCookingOff = _vehicle getVariable [QEGVAR(cookoff,isCookingOff), false];
// Ignore if the vehicle is already cooking off
if (_vehicle getVariable [QEGVAR(cookoff,isCookingOff), false]) exitWith {true};
_chanceOfFire = _chanceOfFire * EGVAR(cookoff,probabilityCoef);
if (!_alreadyCookingOff && { _chanceOfFire >= random 1 }) exitWith {
if (_chanceOfFire >= random 1) exitWith {
private _configOf = configOf _vehicle;
private _fireDetonateChance = [_configOf >> QGVAR(detonationDuringFireProb), "number", 0] call CBA_fnc_getConfigEntry;
if (_canRing) then {
@ -52,21 +53,8 @@ if (!_alreadyCookingOff && { _chanceOfFire >= random 1 }) exitWith {
[_vehicle] spawn FUNC(abandon);
LOG_1("[%1] is on fire is bailing",_vehicle);
// cant setVehicleAmmo 0 here because it removes FFV unit's ammo
if (GVAR(removeAmmoDuringCookoff)) then {
private _ammo = [_vehicle] call EFUNC(cookoff,getVehicleAmmo);
_ammo params ["_magazines"];
TRACE_1("removing magazines",_magazines);
{
_x params ["_magazine"];
_vehicle removeMagazines _magazine;
} forEach _magazines;
};
true
};
// Avoid RPT spam
if (_alreadyCookingOff) exitWith { true };
LOG_2("[%1] No Cook-off - Chance of fire [%2]",_vehicle,_chanceOfFire);
false

View File

@ -119,12 +119,12 @@ if (_isCar) then {
_ammoEffectiveness = (_ammoEffectiveness + (_ammoEffectiveness * 0.5)) min 1;
};
private _currentVehicleAmmo = [_vehicle] call EFUNC(cookoff,getVehicleAmmo);
private _currentVehicleAmmo = _vehicle call EFUNC(cookoff,getVehicleAmmo);
private _chanceOfDetonation = 0;
private _explosiveAmmoCount = 0;
private _nonExplosiveAmmoCount = 0;
if (count (_currentVehicleAmmo select 0) isNotEqualTo 0) then {
if ((_currentVehicleAmmo select 1) > 0) then {
private _magConfig = configFile >> "CfgMagazines";
private _ammoConfig = configFile >> "CfgAmmo";
private _countOfExplodableAmmo = 0;
@ -163,7 +163,7 @@ switch (_hitArea) do {
_chanceOfFire = 0; // no cookoff for cars
};
if ([_vehicle, _chanceToDetonate, _currentVehicleAmmo, _explosiveAmmoCount, _nonExplosiveAmmoCount, _injurer] call FUNC(handleDetonation)) exitWith {
if ([_vehicle, _chanceToDetonate, _explosiveAmmoCount, _nonExplosiveAmmoCount, _injurer] call FUNC(handleDetonation)) exitWith {
[_vehicle] call FUNC(knockOut);
};
@ -191,7 +191,7 @@ switch (_hitArea) do {
_chanceOfFire = 0; // no cookoff for cars
};
if ([_vehicle, _chanceToDetonate, _currentVehicleAmmo, _explosiveAmmoCount, _nonExplosiveAmmoCount, _injurer] call FUNC(handleDetonation)) exitWith {
if ([_vehicle, _chanceToDetonate, _explosiveAmmoCount, _nonExplosiveAmmoCount, _injurer] call FUNC(handleDetonation)) exitWith {
[_vehicle, _hitIndex, _hitpointName, 0.89 * _penChance] call FUNC(addDamage);
[_vehicle] call FUNC(knockOut);
};
@ -265,7 +265,7 @@ switch (_hitArea) do {
_chanceOfFire = 0; // no cookoff for cars
};
if ([_vehicle, _chanceToDetonate, _currentVehicleAmmo, _explosiveAmmoCount, _nonExplosiveAmmoCount, _injurer] call FUNC(handleDetonation)) exitWith {
if ([_vehicle, _chanceToDetonate, _explosiveAmmoCount, _nonExplosiveAmmoCount, _injurer] call FUNC(handleDetonation)) exitWith {
[_vehicle] call FUNC(knockOut);
};

View File

@ -8,16 +8,6 @@
true // Needs mission restart
] call CBA_settings_fnc_init;
[
QGVAR(removeAmmoDuringCookoff), "CHECKBOX",
[LSTRING(removeAmmoAfterCookoff_setting_enable), LSTRING(removeAmmoAfterCookoff_setting_description)],
LSTRING(category_displayName),
true, // default value
true, // isGlobal
{[QGVAR(removeAmmoDuringCookoff), _this] call EFUNC(common,cbaSettings_settingChanged)},
false // Needs mission restart
] call CBA_settings_fnc_init;
[
QGVAR(enableCarDamage), "CHECKBOX",
[LSTRING(carDamage_setting_enable), LSTRING(carDamage_setting_description)],

View File

@ -49,30 +49,6 @@
<Russian>Продвинутое повреждение машин</Russian>
<Spanish>Habilitar/Deshabilitar daño avanzado de coche (Experimental)</Spanish>
</Key>
<Key ID="STR_ACE_Vehicle_Damage_removeAmmoAfterCookoff_setting_description">
<English>Removes all vehicle ammo after cook-off</English>
<Japanese>誘爆後に車両から全ての弾薬を削除</Japanese>
<French>Retire toutes les munitions des véhicules après une auto-inflammation.</French>
<German>Entfernt die gesamte Munition nach dem Durchzünden der Munition eines Fahrzeuges.</German>
<Italian>Rimuove tutte le munizioni dal veicolo dopo l'esplosione delle stesse</Italian>
<Polish>Usuwa całą amunicję z pojazdu po samozapłonie</Polish>
<Chinesesimp>殉爆后移除所有车辆弹药</Chinesesimp>
<Korean>쿡오프 현상 후 차량에서 모든 탄약을 제거합니다.</Korean>
<Russian>Удалять все боеприпасы из техники после их детонации</Russian>
<Spanish>Elimina toda la munición del vehículo despues ser inducida a detonar por calor</Spanish>
</Key>
<Key ID="STR_ACE_Vehicle_Damage_removeAmmoAfterCookoff_setting_enable">
<English>Enable/Disable Ammo Removal During Cook-Off</English>
<Japanese>誘爆中の弾薬除去を有効/無効にする</Japanese>
<French>Retirer les munitions durant l'auto-inflammation</French>
<German>Aktiviert/Deaktiviert Entfernung der Munition beim Durchzünden</German>
<Italian>Abilita rimozione munizioni dopo l'esplosione</Italian>
<Polish>Włącz/Wyłącz usuwanie amunicji podczas samozapłonu</Polish>
<Chinesesimp>启用/禁用殉爆过程中的弹药移除功能</Chinesesimp>
<Korean>쿡오프시 탄약 제거 활성화/비활성화</Korean>
<Russian>Удалять боеприпасы из-за детонации</Russian>
<Spanish>Habilita/Deshabilita ka eliminación de munición durante la detonación inducida por calor</Spanish>
</Key>
<Key ID="STR_ACE_Vehicle_Damage_generic_turret_wreck">
<English>Wreck (Turret)</English>
<French>Épave (tourelle)</French>