mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
c4156a6888
* Initital port of ACE2 Vehicle Damage * Add fire damage and burning people * Migrate vehicle damge stuff from cookoff. Change cookoff function to enhance effect. * Minor tweaks * Add incendiary values to all applicable ammunition. Add engine fire/smoke if hit enough * Handle car damage more elegantly. * Added ability to create fire sources arbitrarily * tweaks * Add chance to detonate after cookoff * disable compile cache * Move blown-off turret config to vehicle damage. Add settings inititalized EH for initializing off settings * tabs->spaces * Various code improvements * Change to count loop for deleting effects * update addon requirements * remove vanilla config requirements * Add RHS compatability * RHS compat. Various QOL fixes/changes * Various tweaks to compats and code. * High-Explosive damage tweak * Change how penetration is calculated for parts * Fix RHS compat * Create setting for flare effect * increase burning scream sounds * swap out file name for snake_case * move incendiary values out of vehicle damage. remove medical dependency * vehicle_dammage - update all refs to snake * sqf fixes * fix fire string package caps * fix pboprefix * Default setting to on * Add variables to enable/disable ring fire to avoid goofy looking vehicles. Enhance how particles are cleaned up. Remove advanced penetration simulation. Change how fire intensity is calculated. Add setting to "disable" vehicle after cookoff * Fix bug where event handler wasn't giving the damage last. * change to snake * fix build errors * Fix UBC * Fix Order of Operations * avoid O^2 events * Make sure that no damage processing happens on dead units * Change some if statements * Keep track of player's death to stop various things * add quotes to right middle wheen * Add VD documentation * fire docs * Code quality fixes * Clarify documentation * define IDD * switch global -> server * Add newline between header and first code statement * stop the dead from suffering Its hard to tell when a unit is dead or in spectator, so check the config of the unit to determine it. * Add settings to disable cook-off effects * Delete effects if vehicle is deleted before cookoff occurs. Don't cookoff player ammo. Throw weapon better * Move fire into own PR * fix tabs and macro * Shuffle crew indices so that a random person is first on the list to be injured each time * fix effects not clearing Co-authored-by: PabstMirror <pabstmirror@gmail.com>
136 lines
5.3 KiB
Plaintext
136 lines
5.3 KiB
Plaintext
#include "script_component.hpp"
|
|
/*
|
|
* Author: Glowbal
|
|
* Detonates ammunition from a vehicle until no ammo left
|
|
*
|
|
* Arguments:
|
|
* 0: vehicle <OBJECT>
|
|
* 1: Ammo Array <ARRAY>
|
|
* 0: Magazine Classname <STRING>
|
|
* 1: Ammo Count <NUMBER>
|
|
* 2: Total Ammo Count <NUMBER>
|
|
*
|
|
* Return Value:
|
|
* None
|
|
*
|
|
* Example:
|
|
* [_vehicle, magazinesAmmo _vehicle] call ace_cookoff_fnc_detonateAmmunition
|
|
*
|
|
* Public: No
|
|
*/
|
|
|
|
params ["_vehicle", "_magazines", "_totalAmmo"];
|
|
|
|
if (GVAR(enable) == 0) exitWith {};
|
|
if !(GVAR(enableAmmoCookoff)) exitWith {};
|
|
|
|
if (isNull _vehicle) exitWith {}; // vehicle got deleted
|
|
if (_magazines isEqualTo []) exitWith {}; // nothing to detonate anymore
|
|
if (underwater _vehicle) exitWith {};
|
|
|
|
private _magazineIndex = floor random(count _magazines);
|
|
private _magazine = _magazines select _magazineIndex;
|
|
_magazine params ["_magazineClassname", "_amountOfMagazines"];
|
|
|
|
if (_amountOfMagazines > 0) exitWith {
|
|
private _removed = _amountOfMagazines min floor(1 + random(6 / GVAR(ammoCookoffDuration)));
|
|
|
|
_amountOfMagazines = _amountOfMagazines - _removed;
|
|
if (_amountOfMagazines <= 0) then {
|
|
_magazines deleteAt _magazineIndex;
|
|
} else {
|
|
_magazine set [1, _amountOfMagazines]; // clear out the magazine
|
|
};
|
|
private _timeBetweenAmmoDetonation = (((random 10) / (sqrt _totalAmmo)) min MAX_TIME_BETWEEN_AMMO_DET) max 0.1;
|
|
TRACE_2("",_totalAmmo,_timeBetweenAmmoDetonation);
|
|
_totalAmmo = _totalAmmo - _removed;
|
|
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _magazineClassname >> "ammo");
|
|
private _ammoCfg = configFile >> "CfgAmmo" >> _ammo;
|
|
|
|
private _speedOfAmmo = getNumber (configFile >> "CfgMagazines" >> _magazineClassname >> "initSpeed");
|
|
private _simType = getText (_ammoCfg >> "simulation");
|
|
|
|
private _effect2pos = _vehicle selectionPosition "destructionEffect2";
|
|
|
|
private _spawnProjectile = {
|
|
params ["_vehicle", "_ammo", "_speed", "_flyAway"];
|
|
|
|
private _spawnPos = _vehicle modelToWorld [-0.2 + (random 0.4), -0.2 + (random 0.4), random 3];
|
|
if (_spawnPos select 2 < 0) then {
|
|
_spawnPos set [2, 0];
|
|
};
|
|
|
|
private _projectile = createVehicle [_ammo, _spawnPos, [], 0, "CAN_COLLIDE"];
|
|
if (_flyAway) then {
|
|
private _vectorAmmo = [(-1 + (random 2)), (-1 + (random 2)), -0.2 + (random 1)];
|
|
private _velVec = _vectorAmmo vectorMultiply _speed;
|
|
_projectile setVectorDir _velVec;
|
|
_projectile setVelocity _velVec;
|
|
} else {
|
|
_projectile setDamage 1;
|
|
};
|
|
|
|
_projectile;
|
|
};
|
|
|
|
private _speed = random (_speedOfAmmo / 10) max 1;
|
|
|
|
if (toLower _simType == "shotbullet") then {
|
|
private _sound = selectRandom [QUOTE(PATHTO_R(sounds\light_crack_close.wss)), QUOTE(PATHTO_R(sounds\light_crack_close_filtered.wss)), QUOTE(PATHTO_R(sounds\heavy_crack_close.wss)), QUOTE(PATHTO_R(sounds\heavy_crack_close_filtered.wss))];
|
|
playSound3D [_sound, objNull, false, (getPosASL _vehicle), 2, 1, 1250];
|
|
|
|
if (random 1 < 0.6) then {
|
|
[_vehicle, _ammo, _speed, true] call _spawnProjectile;
|
|
};
|
|
};
|
|
if (toLower _simType == "shotshell") then {
|
|
private _sound = selectRandom [QUOTE(PATHTO_R(sounds\heavy_crack_close.wss)), QUOTE(PATHTO_R(sounds\heavy_crack_close_filtered.wss))];
|
|
playSound3D [_sound, objNull, false, (getPosASL _vehicle), 2, 1, 1300];
|
|
|
|
if (random 1 < 0.15) then {
|
|
[_vehicle, _ammo, _speed, true] call _spawnProjectile;
|
|
};
|
|
};
|
|
if (toLower _simType == "shotgrenade") then {
|
|
if (random 1 < 0.9) then {
|
|
_speed = 0;
|
|
};
|
|
[_vehicle, _ammo, _speed, random 1 < 0.5] call _spawnProjectile;
|
|
};
|
|
if (toLower _simType in ["shotrocket", "shotmissile", "shotsubmunitions"]) then {
|
|
if (random 1 < 0.1) then {
|
|
private _sound = selectRandom [QUOTE(PATHTO_R(sounds\cannon_crack_close.wss)), QUOTE(PATHTO_R(sounds\cannon_crack_close_filtered.wss))];
|
|
playSound3D [_sound, objNull, false, (getPosASL _vehicle), 3, 1, 1600];
|
|
|
|
[_vehicle, _ammo, _speed, random 1 < 0.3] call _spawnProjectile;
|
|
} else {
|
|
createvehicle ["ACE_ammoExplosionLarge", (_vehicle modelToWorld _effect2pos), [], 0 , "CAN_COLLIDE"];
|
|
};
|
|
};
|
|
if (toLower _simType in ["shotdirectionalbomb", "shotmine"]) then {
|
|
if (random 1 < 0.5) then {
|
|
// Not all explosives detonate on destruction, some have scripted alternatives
|
|
private _scripted = getNumber (_ammoCfg >> "triggerWhenDestroyed") == 1;
|
|
if !(_scripted) then {
|
|
_ammo = getText (_ammoCfg >> "ace_explosives_Explosive");
|
|
};
|
|
|
|
// If a scripted alternative doesn't exist use generic explosion
|
|
if (_ammo != "") then {
|
|
[_vehicle, _ammo, 0, false] call _spawnProjectile;
|
|
} else {
|
|
createvehicle ["SmallSecondary", (_vehicle modelToWorld _effect2pos), [], 0 , "CAN_COLLIDE"];
|
|
};
|
|
};
|
|
};
|
|
if (toLower _simType == "shotilluminating") then {
|
|
if (random 1 < 0.15) then {
|
|
[_vehicle, _ammo, _speed, random 1 < 0.3] call _spawnProjectile;
|
|
};
|
|
};
|
|
|
|
[FUNC(detonateAmmunition), [_vehicle, _magazines, _totalAmmo], _timeBetweenAmmoDetonation] call CBA_fnc_waitAndExecute;
|
|
};
|
|
ERROR_1("mag with no ammo - %1", _magazine);
|