fix various issues with handleDamage engine component

This commit is contained in:
commy2 2016-09-26 18:30:39 +02:00
parent 033c7c7eec
commit 4b9873d304
4 changed files with 58 additions and 40 deletions

View File

@ -14,7 +14,6 @@
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage"];

View File

@ -2,9 +2,9 @@
#define COMPONENT_BEAUTIFIED Medical Damage
#include "\z\ace\addons\main\script_mod.hpp"
#define DEBUG_MODE_FULL
#define DISABLE_COMPILE_CACHE
#define CBA_DEBUG_SYNCHRONOUS
//#define DEBUG_MODE_FULL
//#define DISABLE_COMPILE_CACHE
//#define CBA_DEBUG_SYNCHRONOUS
#define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_MEDICAL_DAMAGE

View File

@ -12,8 +12,6 @@
*/
#include "script_component.hpp"
#define DAMAGE_STRUCTURAL QGVAR(newDamage$#structural)
params ["_unit", "_selection", "_damage", "_shooter", "_ammo", "_hitPointIndex"];
//diag_log _this;
@ -32,50 +30,63 @@ if (_hitPointIndex < 0) then {
};
private _newDamage = _damage - _oldDamage;
_unit setVariable [format [QGVAR(newDamage$%1), _hitPoint], _newDamage];
_unit setVariable [format [QGVAR($%1), _hitPoint], _newDamage];
// Never kill the unit by the critical hit points of the engine.
if (_hitPoint in ["#structural", "hitbody", "hithead"]) then {
// Because Arma now uses TOH 'depends' system, every hitpoint can cause this
_damage = _damage min 0.99;
};
// These control blood material visuals.
// If damage is in dummy hitpoints, "hands" and "legs", don't change anything
if (_hitPoint in ["hithead", "hitbody", "hithands", "hitlegs"]) exitWith {_oldDamage};
if (_hitPoint in ["hithead", "hitbody", "hithands", "hitlegs"]) exitWith {
TRACE_2("hd exited (hardcoded)",_hitPoint,_oldDamage);
_oldDamage
};
// Add injury
if (_hitPoint isEqualTo "ace_hdbracket") exitWith {
private _damageStructural = _unit getVariable [QGVAR($#structural), 0];
// --- Head
private _damageFace = _unit getVariable [QGVAR(newDamage$HitFace), 0];
private _damageNeck = _unit getVariable [QGVAR(newDamage$HitNeck), 0];
private _damageHead = (_unit getVariable [QGVAR(newDamage$HitHead), 0]) max _damageFace max _damageNeck;
private _damageFace = _unit getVariable [QGVAR($HitFace), 0];
private _damageNeck = _unit getVariable [QGVAR($HitNeck), 0];
private _damageHead = (_unit getVariable [QGVAR($HitHead), 0]) max _damageFace max _damageNeck;
// --- Body
private _damageStructural = _unit getVariable [DAMAGE_STRUCTURAL, 0];
private _damagePelvis = _unit getVariable [QGVAR(newDamage$HitPelvis), 0];
private _damageAbdomen = _unit getVariable [QGVAR(newDamage$HitAbdomen), 0];
private _damageDiaphragm = _unit getVariable [QGVAR(newDamage$HitDiaphragm), 0];
private _damageChest = _unit getVariable [QGVAR(newDamage$HitChest), 0];
private _damageBody = (_unit getVariable [QGVAR(newDamage$HitBody), 0]) max _damagePelvis max _damageAbdomen max _damageDiaphragm max _damageChest max _damageStructural;
private _damagePelvis = _unit getVariable [QGVAR($HitPelvis), 0];
private _damageAbdomen = _unit getVariable [QGVAR($HitAbdomen), 0];
private _damageDiaphragm = _unit getVariable [QGVAR($HitDiaphragm), 0];
private _damageChest = _unit getVariable [QGVAR($HitChest), 0];
private _damageBody = (_unit getVariable [QGVAR($HitBody), 0]) max _damagePelvis max _damageAbdomen max _damageDiaphragm max _damageChest;
// --- Arms and Legs
private _damageLeftArm = _unit getVariable [QGVAR(newDamage$HitLeftArm), 0];
private _damageRightArm = _unit getVariable [QGVAR(newDamage$HitRightArm), 0];
private _damageLeftLeg = _unit getVariable [QGVAR(newDamage$HitLeftLeg), 0];
private _damageRightLeg = _unit getVariable [QGVAR(newDamage$HitRightLeg), 0];
private _damageLeftArm = _unit getVariable [QGVAR($HitLeftArm), 0];
private _damageRightArm = _unit getVariable [QGVAR($HitRightArm), 0];
private _damageLeftLeg = _unit getVariable [QGVAR($HitLeftLeg), 0];
private _damageRightLeg = _unit getVariable [QGVAR($HitRightLeg), 0];
// Find hit point that received the maxium damage.
// second param is a priority. should multiple hitpoints receive the same
// amount of damage (e.g. max which is 4), we don't want them to be sorted
// alphabetically (which would mean that RightLeg is always chosen)
private _allDamages = [
[_damageHead, "Head"],
[_damageBody, "Body"],
[_damageLeftArm, "LeftArm"],
[_damageRightArm, "RightArm"],
[_damageLeftLeg, "LeftLeg"],
[_damageRightLeg, "RightLeg"]
[_damageHead, PRIORITY_HEAD, "Head"],
[_damageBody, PRIORITY_BODY, "Body"],
[_damageLeftArm, PRIORITY_LEFT_ARM, "LeftArm"],
[_damageRightArm, PRIORITY_RIGHT_ARM, "RightArm"],
[_damageLeftLeg, PRIORITY_LEFT_LEG, "LeftLeg"],
[_damageRightLeg, PRIORITY_RIGHT_LEG, "RightLeg"]
];
TRACE_2("incoming",_allDamages,_damageStructural);
_allDamages sort false;
(_allDamages select 0) params ["_receivedDamage", "_woundedHitPoint"];
(_allDamages select 0) params ["_receivedDamage", "", "_woundedHitPoint"];
if (_receivedDamage == 0) then {
_receivedDamage = _damageStructural;
_woundedHitPoint = "Body";
};
TRACE_2("received",_receivedDamage,_woundedHitPoint);
// Check for falling damage.
if (_ammo isEqualTo "") then {
@ -104,4 +115,5 @@ if (_hitPoint isEqualTo "#structural" && {getOxygenRemaining _unit <= 0.5} && {_
[QGVAR(woundReceived), [_unit, "Body", _newDamage, _unit, "#drowning"]] call CBA_fnc_localEvent;
};
TRACE_2("hd exited",_hitPoint,_damage);
_damage

View File

@ -3,8 +3,8 @@
#include "\z\ace\addons\main\script_mod.hpp"
#define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define CBA_DEBUG_SYNCHRONOUS
#define DISABLE_COMPILE_CACHE
#define CBA_DEBUG_SYNCHRONOUS
//#define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_MEDICAL_ENGINE
@ -17,12 +17,6 @@
#include "\z\ace\addons\main\script_macros.hpp"
#define DISABLE_VANILLA_SCREAMS
#define DISABLE_VANILLA_MOANS
#define DISABLE_VANILLA_HEARTBEAT
#define DISABLE_VANILLA_BLOOD_TEXTURES
#define DISABLE_VANILLA_DAMAGE_EFFECTS
#include "script_macros_medical.hpp"
#define EMPTY_SOUND {"A3\Sounds_F\dummysound.wss",1,1}
@ -35,3 +29,16 @@
}, {\
diag_log format ["Preload done for ""%1""",_this];\
}, class] call CBA_fnc_waitUntilAndExecute
#define DISABLE_VANILLA_SCREAMS
#define DISABLE_VANILLA_MOANS
#define DISABLE_VANILLA_HEARTBEAT
#define DISABLE_VANILLA_BLOOD_TEXTURES
#define DISABLE_VANILLA_DAMAGE_EFFECTS
#define PRIORITY_HEAD 3
#define PRIORITY_BODY 4
#define PRIORITY_LEFT_ARM (1 + random 1)
#define PRIORITY_RIGHT_ARM (1 + random 1)
#define PRIORITY_LEFT_LEG (1 + random 1)
#define PRIORITY_RIGHT_LEG (1 + random 1)