2015-02-08 09:01:32 +00:00
|
|
|
/*
|
|
|
|
* Author: Glowbal
|
|
|
|
* Handling of the open wounds & injuries upon the handleDamage eventhandler.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit That Was Hit <OBJECT>
|
|
|
|
* 1: Name Of Hit Selection <STRING>
|
|
|
|
* 2: Amount Of Damage <NUMBER>
|
|
|
|
* 3: Shooter or source of the damage <OBJECT>
|
|
|
|
* 4: Type of the damage done <STRING>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2015-08-22 14:25:10 +00:00
|
|
|
* None
|
2015-02-08 09:01:32 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-02-07 22:48:24 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-13 21:55:13 +00:00
|
|
|
|
2015-08-22 14:25:10 +00:00
|
|
|
params ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage"];
|
2016-06-30 15:33:29 +00:00
|
|
|
TRACE_6("ACE_DEBUG: woundshandler",_unit, _selectionName, _damage, _shooter, _typeOfProjectile,_typeOfDamage);
|
2015-02-07 22:48:24 +00:00
|
|
|
|
2016-09-18 20:58:56 +00:00
|
|
|
systemChat format["input: %1", _this];
|
|
|
|
|
2016-09-18 11:33:22 +00:00
|
|
|
if (_typeOfDamage == "") then {_typeOfDamage = "unknown";};
|
|
|
|
|
2015-03-03 21:13:22 +00:00
|
|
|
// Administration for open wounds and ids
|
2016-06-30 15:33:29 +00:00
|
|
|
private _openWounds = _unit getVariable[QEGVAR(medical,openWounds), []];
|
|
|
|
private _woundID = _unit getVariable[QEGVAR(medical,lastUniqueWoundID), 1];
|
2015-02-13 21:55:13 +00:00
|
|
|
|
2016-06-13 09:05:21 +00:00
|
|
|
private _extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _selectionName, _damage, _typeOfDamage, _woundID];
|
2016-06-30 15:33:29 +00:00
|
|
|
diag_log format["Extension _extensionOutput: %1", _extensionOutput];
|
2015-05-16 21:21:03 +00:00
|
|
|
|
2016-06-13 09:05:21 +00:00
|
|
|
private _painToAdd = 0;
|
|
|
|
private _woundsCreated = [];
|
2015-03-01 11:33:05 +00:00
|
|
|
|
2015-05-16 21:21:03 +00:00
|
|
|
call compile _extensionOutput;
|
|
|
|
{
|
2016-06-13 09:05:21 +00:00
|
|
|
_x params ["", "_toAddClassID", "_bodyPartNToAdd"];
|
2016-02-16 18:19:18 +00:00
|
|
|
_foundIndex = -1;
|
2015-05-16 21:21:03 +00:00
|
|
|
{
|
2016-06-13 09:05:21 +00:00
|
|
|
_x params ["", "_compareId", "_comparyBodyPartN"];
|
2015-05-16 21:21:03 +00:00
|
|
|
// Check if we have an id of the given class on the given bodypart already
|
2016-06-13 09:05:21 +00:00
|
|
|
if (_compareId == _toAddClassID && {_comparyBodyPartN2 == _bodyPartNToAdd}) exitWith {
|
2015-11-30 16:23:48 +00:00
|
|
|
_foundIndex = _forEachIndex;
|
2015-02-07 22:48:24 +00:00
|
|
|
};
|
2015-11-30 16:23:48 +00:00
|
|
|
} forEach _openWounds;
|
2015-05-16 21:21:03 +00:00
|
|
|
|
|
|
|
if (_foundIndex < 0) then {
|
|
|
|
// Since it is a new injury, we will have to add it to the open wounds array to store it
|
2015-11-30 16:21:28 +00:00
|
|
|
_openWounds pushBack _x;
|
2015-05-16 21:21:03 +00:00
|
|
|
} else {
|
|
|
|
// We already have one of these, so we are just going to increase the number that we have of it with a new one.
|
2016-06-13 09:05:21 +00:00
|
|
|
private _injury = _openWounds select _foundIndex;
|
2015-05-16 21:21:03 +00:00
|
|
|
_injury set [3, (_injury select 3) + 1];
|
2015-02-07 22:48:24 +00:00
|
|
|
};
|
2015-11-30 16:23:48 +00:00
|
|
|
} forEach _woundsCreated;
|
2015-02-21 20:10:57 +00:00
|
|
|
|
2016-06-30 15:33:29 +00:00
|
|
|
_unit setVariable [QEGVAR(medical,openWounds), _openWounds, true];
|
2015-02-28 19:48:34 +00:00
|
|
|
|
2015-03-03 21:13:22 +00:00
|
|
|
// Only update if new wounds have been created
|
|
|
|
if (count _woundsCreated > 0) then {
|
2016-06-30 15:33:29 +00:00
|
|
|
_unit setVariable [QEGVAR(medical,lastUniqueWoundID), _woundID, true];
|
2015-03-03 21:13:22 +00:00
|
|
|
};
|
|
|
|
|
2016-06-30 15:33:29 +00:00
|
|
|
// TODO use medical add pain function instead
|
|
|
|
private _painLevel = _unit getVariable [QEGVAR(medical,pain), 0];
|
|
|
|
_unit setVariable [QEGVAR(medical,pain), _painLevel + _painToAdd];
|
|
|
|
|
|
|
|
TRACE_6("ACE_DEBUG: woundsHandler",_unit, _painLevel, _painToAdd, _unit getVariable QEGVAR(medical,pain), _unit getVariable QEGVAR(medical,openWounds),_woundsCreated);
|