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
|
|
|
private ["_bodyPartn", "_injuryTypeInfo", "_allInjuriesForDamageType", "_allPossibleInjuries", "_highestPossibleDamage", "_highestPossibleSpot", "_minDamage", "_openWounds", "_woundID", "_toAddInjury", "_painToAdd", "_bloodLoss", "_bodyPartNToAdd", "_classType", "_damageLevels", "_foundIndex", "_i", "_injury", "_maxDamage", "_pain", "_painLevel", "_selections", "_toAddClassID", "_woundsCreated"];
|
|
|
|
params ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage"];
|
2015-09-05 22:31:14 +00:00
|
|
|
TRACE_6("ACE_DEBUG: HandleDamage Called",_unit, _selectionName, _damage, _shooter, _typeOfProjectile,_typeOfDamage);
|
2015-02-07 22:48:24 +00:00
|
|
|
|
2015-03-03 21:13:22 +00:00
|
|
|
// Administration for open wounds and ids
|
2015-02-21 20:10:57 +00:00
|
|
|
_openWounds = _unit getvariable[QGVAR(openWounds), []];
|
2015-02-28 19:48:34 +00:00
|
|
|
_woundID = _unit getvariable[QGVAR(lastUniqueWoundID), 1];
|
2015-02-13 21:55:13 +00:00
|
|
|
|
2015-05-16 21:21:03 +00:00
|
|
|
_extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _selectionName, _damage, _typeOfDamage, _woundID];
|
|
|
|
|
2015-03-01 11:33:05 +00:00
|
|
|
_painToAdd = 0;
|
2015-02-28 19:48:34 +00:00
|
|
|
_woundsCreated = [];
|
2015-03-01 11:33:05 +00:00
|
|
|
|
2015-05-16 21:21:03 +00:00
|
|
|
call compile _extensionOutput;
|
|
|
|
_foundIndex = -1;
|
|
|
|
{
|
2015-08-22 15:10:19 +00:00
|
|
|
_toAddClassID = _x select 1;
|
|
|
|
_bodyPartNToAdd = _x select 2;
|
2015-05-16 21:21:03 +00:00
|
|
|
{
|
|
|
|
// Check if we have an id of the given class on the given bodypart already
|
|
|
|
if (_x select 1 == _toAddClassID && {_x select 2 == _bodyPartNToAdd}) exitwith {
|
|
|
|
_foundIndex = _foreachIndex;
|
2015-02-07 22:48:24 +00:00
|
|
|
};
|
2015-08-22 14:25:10 +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
|
|
|
|
_openWounds pushback _x;
|
|
|
|
} 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.
|
|
|
|
_injury = _openWounds select _foundIndex;
|
|
|
|
_injury set [3, (_injury select 3) + 1];
|
2015-02-07 22:48:24 +00:00
|
|
|
};
|
2015-08-22 14:25:10 +00:00
|
|
|
} foreach _woundsCreated;
|
2015-02-21 20:10:57 +00:00
|
|
|
|
2015-05-16 21:21:03 +00:00
|
|
|
_unit setvariable [QGVAR(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 {
|
|
|
|
_unit setvariable [QGVAR(lastUniqueWoundID), _woundID, true];
|
|
|
|
};
|
|
|
|
|
2015-03-01 11:33:05 +00:00
|
|
|
_painLevel = _unit getvariable [QGVAR(pain), 0];
|
|
|
|
_unit setvariable [QGVAR(pain), _painLevel + _painToAdd];
|
2015-09-05 22:31:14 +00:00
|
|
|
TRACE_6("ACE_DEBUG: HandleDamage_WoundsOLD",_unit, _painLevel, _painToAdd, _unit getvariable QGVAR(pain), _unit getvariable QGVAR(openWounds),_woundsCreated);
|