mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Adjust addDamageToUnit for rewrite
This commit is contained in:
@ -8,13 +8,14 @@
|
|||||||
* 1: Damage to Add <NUMBER>
|
* 1: Damage to Add <NUMBER>
|
||||||
* 2: Body part ("Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg") <STRING>
|
* 2: Body part ("Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg") <STRING>
|
||||||
* 3: Projectile Type <STRING>
|
* 3: Projectile Type <STRING>
|
||||||
|
* 3: Source <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* HandleDamage's return <NUMBER>
|
* Successful <BOOL>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [player, 0.8, "rightleg", "bullet"] call ace_medical_fnc_addDamageToUnit
|
* [player, 0.8, "rightleg", "bullet"] call ace_medical_fnc_addDamageToUnit
|
||||||
* [cursorTarget, 1, "body", "stab"] call ace_medical_fnc_addDamageToUnit
|
* [cursorTarget, 1, "body", "stab", player] call ace_medical_fnc_addDamageToUnit
|
||||||
*
|
*
|
||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
@ -22,42 +23,42 @@
|
|||||||
// #define DEBUG_TESTRESULTS
|
// #define DEBUG_TESTRESULTS
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]]];
|
params [["_unit", objNull, [objNull]], ["_damageToAdd", -1, [0]], ["_bodyPart", "", [""]], ["_typeOfDamage", "", [""]], ["_instigator", objNull, [objNull]]];
|
||||||
TRACE_4("params",_unit,_damageToAdd,_bodyPart,_typeOfDamage);
|
TRACE_5("params",_unit,_damageToAdd,_bodyPart,_typeOfDamage,_instigator);
|
||||||
|
|
||||||
_bodyPart = toLower _bodyPart;
|
private _bodyPartIndex = ALL_BODY_PARTS find (toLower _bodyPart);
|
||||||
if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_1("addDamageToUnit - badUnit %1", _this); -1};
|
if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_1("addDamageToUnit - badUnit %1", _this); false};
|
||||||
if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this); -1};
|
if (_damageToAdd < 0) exitWith {ERROR_1("addDamageToUnit - bad damage %1", _this); false};
|
||||||
if !(_bodyPart in ALL_BODY_PARTS) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); -1};
|
if (_bodyPartIndex < 0) exitWith {ERROR_1("addDamageToUnit - bad selection %1", _this); false};
|
||||||
|
|
||||||
//Get the hitpoint and the index
|
// Extension is case sensitive and expects this format (different from ALL_BODY_PARTS)
|
||||||
private _hitpoint = [_unit, _bodyPart, true] call ace_medical_fnc_translateSelections;
|
_bodyPart = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] select _bodyPartIndex;
|
||||||
(getAllHitPointsDamage _unit) params [["_allHitPoints", []]];
|
|
||||||
private _hitpointIndex = -1;
|
|
||||||
{ //case insensitive find
|
|
||||||
if (_x == _hitpoint) exitWith {_hitpointIndex = _forEachIndex;};
|
|
||||||
} forEach _allHitPoints;
|
|
||||||
if (_hitpointIndex < 0) exitWith {ERROR_1("addDamageToUnit - bad hitpointIndex %1", _this); -1};
|
|
||||||
|
|
||||||
private _currentDamage = _unit getHitIndex _hitpointIndex;
|
if (!isNull _instigator) then {
|
||||||
|
_unit setVariable [QEGVAR(medical_engine,lastShooter), _instigator];
|
||||||
|
_unit setVariable [QEGVAR(medical_engine,lastInstigator), _instigator];
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef DEBUG_TESTRESULTS
|
#ifdef DEBUG_TESTRESULTS
|
||||||
private _checkAtFrame = diag_frameno + 5;
|
private _startDmg = +(_unit getVariable [QGVAR(bodyPartDamage), [-1]]);
|
||||||
private _partNumber = ALL_BODY_PARTS find _bodyPart;
|
private _startPain = _unit getVariable [QGVAR(pain), 0];
|
||||||
private _startDmg = (_unit getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]) select _partNumber;
|
|
||||||
private _debugCode = {
|
|
||||||
params ["", "_unit", "_startDmg", "_damageToAdd", "_partNumber"];
|
|
||||||
private _endDmg = (_unit getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]) select _partNumber;
|
|
||||||
if ((!alive _unit) || {_endDmg > _startDmg}) then {
|
|
||||||
INFO_6("addDamageToUnit - PASSED - [unit:%1, partNo:%2, addDmg:%3] results:[alive:%4 old:%5 new:%6]", _unit, _partNumber, _damageToAdd, alive _unit, _startDmg, _endDmg);
|
|
||||||
} else {
|
|
||||||
ERROR_6("addDamageToUnit - FAILED - [unit:%1, partNo:%2, addDmg:%3] results:[alive:%4 old:%5 new:%6]", _unit, _partNumber, _damageToAdd, alive _unit, _startDmg, _endDmg);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
[{diag_frameno > (_this select 0)}, _debugCode, [_checkAtFrame, _unit, _startDmg, _damageToAdd, _partNumber]] call CBA_fnc_waitUntilAndExecute;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private _return = [_unit, _bodyPart, (_currentDamage + _damageToAdd), _unit, _typeOfDamage, _hitpointIndex, objNull] call FUNC(handleDamage); // todo - switch to medical engine
|
[QEGVAR(medical_engine,woundReceived), [_unit, _bodyPart, _damageToAdd, _instigator, _typeOfDamage]] call CBA_fnc_localEvent;
|
||||||
TRACE_1("handleDamage called",_return);
|
|
||||||
|
|
||||||
_return
|
#ifdef DEBUG_TESTRESULTS
|
||||||
|
private _endDmg = _unit getVariable [QGVAR(bodyPartDamage), [-1]];
|
||||||
|
private _endPain = _unit getVariable [QGVAR(pain), 0];
|
||||||
|
private _typeOfDamageAdj = _typeOfDamage call EFUNC(medical_damage,getTypeOfDamage);
|
||||||
|
private _config = configFile >> "ACE_Medical_Injuries" >> "damageTypes" >> _typeOfDamageAdj;
|
||||||
|
private _selectionSpecific = true;
|
||||||
|
if (isClass _config) then {
|
||||||
|
_selectionSpecific = (getNumber (_config >> "selectionSpecific")) == 1;
|
||||||
|
} else {
|
||||||
|
WARNING_2("Damage type not in config [%1:%2]", _typeOfDamage, _config);
|
||||||
|
};
|
||||||
|
INFO_4("Debug AddDamageToUnit: Type [%1] - Selection Specific [%2] - HitPoint [%3 -> %4]",_typeOfDamage,_selectionSpecific,_startDmg select _bodyPartIndex,_endDmg select _bodyPartIndex);
|
||||||
|
INFO_4("Pain Change [%1 -> %2] - BodyPartDamage Change [%3 -> %4]",_startPain,_endPain,_startDmg,_endDmg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
true
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#define MATH_E 2.71828182846
|
#define MATH_E 2.71828182846
|
||||||
|
|
||||||
params ["_unit", "_bodyPart", "_damage", "_typeOfProjectile", "_typeOfDamage"];
|
params ["_unit", "_bodyPart", "_damage", "_shooter", "_typeOfDamage"];
|
||||||
TRACE_5("start",_unit,_bodyPart,_damage,_typeOfProjectile,_typeOfDamage);
|
TRACE_5("start",_unit,_bodyPart,_damage,_shooter,_typeOfDamage);
|
||||||
|
|
||||||
if (_typeOfDamage isEqualTo "") then {
|
if (_typeOfDamage isEqualTo "") then {
|
||||||
_typeOfDamage = "unknown";
|
_typeOfDamage = "unknown";
|
||||||
@ -29,6 +29,7 @@ if (_typeOfDamage isEqualTo "") then {
|
|||||||
private _openWounds = _unit getVariable [QEGVAR(medical,openWounds), []];
|
private _openWounds = _unit getVariable [QEGVAR(medical,openWounds), []];
|
||||||
private _woundID = _unit getVariable [QEGVAR(medical,lastUniqueWoundID), 1];
|
private _woundID = _unit getVariable [QEGVAR(medical,lastUniqueWoundID), 1];
|
||||||
|
|
||||||
|
TRACE_4("extension call",_bodyPart,_damage,_typeOfDamage,_woundID);
|
||||||
private _extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _bodyPart, _damage, _typeOfDamage, _woundID];
|
private _extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _bodyPart, _damage, _typeOfDamage, _woundID];
|
||||||
TRACE_1("",_extensionOutput);
|
TRACE_1("",_extensionOutput);
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
#ifdef DEBUG_MODE_FULL
|
#ifdef DEBUG_MODE_FULL
|
||||||
[QGVAR(woundReceived), {
|
[QGVAR(woundReceived), {
|
||||||
//diag_log _this;
|
params ["_unit", "_woundedHitPoint", "_receivedDamage", "_shooter", "_ammo"];
|
||||||
|
TRACE_5("wound",_unit,_woundedHitPoint, _receivedDamage, _shooter, _ammo);
|
||||||
//systemChat str _this;
|
//systemChat str _this;
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user