ACE3/addons/vehicle_damage/functions/fnc_injureOccupants.sqf

77 lines
2.8 KiB
Plaintext
Raw Normal View History

Add Vehicle Damage (ACE2 port) & Enhance Cook-Off (#7565) * 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>
2021-10-14 15:49:27 +00:00
#include "script_component.hpp"
/*
* Author: Brandon (TCVM)
* Injures occupants in a vehicle based on percent chance of injury.
*
* Arguments:
* 0: The vehicle <OBJECT>
* 1: Injury Chance <NUMBER>
* 2: Maximum people to injure <NUMBER>
* 3: Projectile source <OBJECT> (default: objNull)
* 4: Modifiers for probability for each crew type to be injured. <ARRAY> (In order of: driver, gunner, commander, cargo)
*
* Return Value:
* None
*
* Example:
* [myVehicle, 0.6, 10] call ace_vehicle_damage_fnc_injureOccupants;
*
* Public: No
*/
params ["_vehicle", "_chance", "_count", ["_source", objNull], ["_probabilityModifier", [1, 1, 1, 1]]];
TRACE_4("adding damage to units", _vehicle, _chance, _count, _source);
private _vehicleCrew = crew _vehicle;
private _crewCount = count _vehicleCrew;
if (_crewCount <= 0) exitWith {};
private _crewInjuryIndices = [];
{
_crewInjuryIndices pushBack _forEachIndex;
} forEach _vehicleCrew;
_crewInjuryIndices = _crewInjuryIndices call BIS_fnc_arrayShuffle;
private _injuryCount = 0;
// Not actually doing anything to any initial vehicle crew in this forEach - just a way to loop through all crew at least once
{
private _indexToInjure = -1;
{
private _modifier = _probabilityModifier select 3;
if ((_vehicleCrew select _x) isEqualTo driver _vehicle) then {
_modifier = _probabilityModifier select 0;
};
if ((_vehicleCrew select _x) isEqualTo gunner _vehicle) then {
_modifier = _probabilityModifier select 1;
};
if ((_vehicleCrew select _x) isEqualTo commander _vehicle) then {
_modifier = _probabilityModifier select 2;
};
if ((_chance * _modifier) > random 1) exitWith {
_indexToInjure = _forEachIndex;
};
} forEach _crewInjuryIndices;
if (_indexToInjure >= 0) then {
private _casualty = _vehicleCrew select (_crewInjuryIndices select _indexToInjure);
if (alive _casualty) then {
_injuryCount = _injuryCount + 1;
private _indexCount = count _crewInjuryIndices;
if (_indexCount >= 0) then {
_crewInjuryIndices deleteAt _indexToInjure;
// arbitrary percentages
private _injuredBodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] selectRandomWeighted [0.3, 0.8, 0.5, 0.5, 0.3, 0.3];
private _currentUnitDamage = _casualty getHitpointDamage _injuredBodyPart;
private _damageAmount = (_currentUnitDamage + random 1.8) max (_currentUnitDamage + 0.1);
[_casualty, _damageAmount, _injuredBodyPart, "shell", _source] call EFUNC(medical,addDamageToUnit);
};
};
};
if (_injuryCount >= _count) exitWith {};
} forEach _vehicleCrew;