ACE3/addons/medical_damage/functions/fnc_woundsHandlerVehiclehit.sqf
Grim aee47c9bc6
Medical - Add damage handling for explosive damage while inside vehicles (#9246)
* Add vehicle explosion handling

* Missing semicolon

* scale armor damage using passthrough

* add - to comment

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* improve condition

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* remove extra brackets

Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>

* remove extra brackets

* fix damage sorting

* whitespace

* comment

* fix function header

* fix infinite armor when no item equipped

* modify condition & handling for vehicle explosion

* add vehiclehit woundHandler

* finalize

* add vehiclehit woundHandler

* finalize

* cleanup

* more cleanup

* name

* randomize hitpoints

* finalize

* don't scale structural damage

* fix undefined var

* remove _i

* fix script error, tone down scaling

* add AVD checks

* Update addons/medical_damage/functions/fnc_woundsHandlerVehiclehit.sqf

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* nuke AVD crew damage handling

* get rid of aircraft crash lethality compensation

---------

Co-authored-by: James Woods <pterolatypus@gmail.com>
Co-authored-by: GhostIsSpooky <69561145+Salluci@users.noreply.github.com>
Co-authored-by: Jouni Järvinen <rautamiekka@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-09-24 15:58:59 -04:00

38 lines
1.2 KiB
Plaintext

#include "..\script_component.hpp"
/*
* Author: Pterolatypus, LinkIsGrim
* Custom wound handler for vehicle hits and explosions, sends damage to a random hitpoint
*
* Arguments:
* 0: Unit That Was Hit <OBJECT>
* 1: Damage done to each body part <ARRAY>
* 2: Type of the damage done <STRING>
*
* Return Value:
* None
*
* Example:
* [player, [[0.5, "#structural", 1.5]], "vehiclehit"] call ace_medical_damage_fnc_woundsHandlerVehiclehit
*
* Public: No
*/
params ["_unit", "_allDamages", "_typeOfDamage"];
TRACE_3("woundsHandlerVehiclehit",_unit,_allDamages,_typeOfDamage);
// this should only trigger for hits to just structural
if (count _allDamages > 1) exitWith {_this};
// damage can sometimes be negative (why?)
// damage to structural is low unless it's a very large explosion, in which case it is typically >= 1
private _damageToApply = (abs (_allDamages select 0 select 0));
private _newDamages = [];
// hitpoints are randomized, more damage means more wounds in different body parts
for "_i" from 1 to (_damageToApply * 6) do {
_newDamages pushBack [_damageToApply, selectRandom ALL_BODY_PARTS, _damageToApply]
};
TRACE_1("Vehicle explosion handled, passing damage", _newDamages);
[_unit, _newDamages, _typeOfDamage] //return