This commit is contained in:
Glowbal
2015-08-29 12:01:00 +02:00
parent 1c9e88f213
commit 1a4736e663
5 changed files with 36 additions and 231 deletions

View File

@ -257,8 +257,6 @@ if (USE_WOUND_EVENT_SYNC) then {
}; };
}; };
["SettingsInitialized", { ["SettingsInitialized", {
if (GVAR(level) == 2) exitwith { if (GVAR(level) == 2) exitwith {
[ [

View File

@ -2,8 +2,6 @@
ADDON = false; ADDON = false;
PREP(handleDamage_basic2);
PREP(actionCheckBloodPressure); PREP(actionCheckBloodPressure);
PREP(actionCheckBloodPressureLocal); PREP(actionCheckBloodPressureLocal);
PREP(actionCheckPulse); PREP(actionCheckPulse);

View File

@ -1,191 +1,56 @@
/* /*
* Author: KoffeinFlummi * Author: KoffeinFlummi, Glowbal
* Basic HandleDamage EH function. * Handle damage basic medical
* *
* Arguments: * Arguments:
* 0: Unit That Was Hit <OBJECT>
* 1: Name Of Hit Selection <STRING>
* 2: Amount Of Damage <NUMBER>
* 3: Shooter <OBJECT>
* 4: Projectile <STRING>
* 5: Current damage to be returned <NUMBER>
* *
* Return Value: * Return Value:
* Damage To Be Inflicted <NUMBER> * <nil>
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
#define LEGDAMAGETRESHOLD1 1 private ["_damageBodyParts", "_cache_params", "_cache_damages"];
#define LEGDAMAGETRESHOLD2 1.7 params ["_target"];
#define ARMDAMAGETRESHOLD1 1
#define ARMDAMAGETRESHOLD2 1.7
#define UNCONSCIOUSNESSTRESHOLD 0.7
private ["_damage", "_armdamage", "_hitPoint", "_index", "_legdamage", "_newDamage", "_otherDamage", "_pain", "_restore"]; _damageBodyParts = _target getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
params ["_unit", "_selectionName", "_damage", "_shooter", "_projectile"]; _cache_params = _target getVariable [QGVAR(cachedHandleDamageParams), []];
_cache_damages = _target getVariable QGVAR(cachedDamages);
// Apply damage treshold / coefficient {
_threshold = [ _x params ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"];
_unit getVariable [QGVAR(damageThreshold), GVAR(AIDamageThreshold)], if !(isNull _sourceOfDamage && {_typeOfProjectile == ""} && {vehicle _unit == _unit} && {(_selectionName == "head" || isBurning _unit)}) then {
_unit getVariable [QGVAR(damageThreshold), GVAR(playerDamageThreshold)] _part = [_selectionName] call FUNC(selectionNameToNumber);
] select ([_unit] call EFUNC(common,isPlayer)); if (_part < 0) exitwith {};
if (_selectionName in ["leg_l", "leg_r", "hand_l", "hand_r"]) then {_threshold = _threshold * 1.7};
_damage = _damage * (1 / _threshold); private ["_newDamage", "_pain"];
_newDamage = (_cache_damages select _foreachIndex);
_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage];
_unit setvariable [QGVAR(bodyPartStatus), _damageBodyParts];
// This is a new hit, reset variables. if (alive _unit && {!(_unit getvariable ["ACE_isUnconscious", false])}) then {
// Note: sometimes handleDamage spans over 2 or even 3 frames. // If it reaches this, we can assume that the hit did not kill this unit, as this function is called 3 frames after the damage has been passed.
if (diag_frameno > (_unit getVariable [QGVAR(basic_frameNo), -3]) + 2) then { if ([_unit, _part, if (_part > 1) then {_newDamage * 1.3} else {_newDamage * 2}] call FUNC(determineIfFatal)) then {
_unit setVariable [QGVAR(basic_frameNo), diag_frameno]; [_unit] call FUNC(setUnconscious);
_unit setVariable [QGVAR(isFalling), false];
_unit setVariable [QGVAR(projectiles), []];
_unit setVariable [QGVAR(hitPoints), []];
_unit setVariable [QGVAR(damages), []];
_unit setVariable [QGVAR(structDamage), 0];
if (isnil {_unit getvariable QGVAR(structDamagePFH)}) then {
// Assign orphan structural damage to torso
[{
private "_damagesum";
params ["_args", "_idPFH"];
_args params ["_unit"];
if (ACE_diagTime - (_unit getvariable [QGVAR(structDamagePFH),-2]) >= 2) then {
_unit setVariable [QGVAR(structDamagePFH), nil];
_damagesum = (_unit getHitPointDamage "HitHead") +
(_unit getHitPointDamage "HitBody") +
(_unit getHitPointDamage "HitLeftArm") +
(_unit getHitPointDamage "HitRightArm") +
(_unit getHitPointDamage "HitLeftLeg") +
(_unit getHitPointDamage "HitRightLeg");
if (_damagesum < 0.06 and damage _unit > 0.06 and alive _unit) then {
// _unit setHitPointDamage ["HitBody", damage _unit];
};
[_idPFH] call CBA_fnc_removePerFrameHandler;
}; };
}, 0, [_unit]] call CBA_fnc_addPerFrameHandler;
};
_unit setVariable [QGVAR(structDamagePFH), ACE_diagTime]; // Assign starting ACE_time or reset it
};
_newDamage = _damage - (damage _unit);
if (_selectionName in GVAR(SELECTIONS)) then {
_newDamage = _damage - (_unit getHitPointDamage (GVAR(HITPOINTS) select (GVAR(SELECTIONS) find _selectionName)));
};
_damage = _damage - _newDamage;
// Exclude falling damage to everything other than legs and reduce it overall.
if (((velocity _unit) select 2 < -5) and (vehicle _unit == _unit)) then {
_unit setVariable [QGVAR(isFalling), true];
};
if (_unit getVariable [QGVAR(isFalling), false] and !(_selectionName in ["", "leg_l", "leg_r"])) exitWith {
(_unit getHitPointDamage (GVAR(HITPOINTS) select (GVAR(SELECTIONS) find _selectionName))) max 0.01;
};
if (_unit getVariable [QGVAR(isFalling), false]) then {
_newDamage = _newDamage * 0.7;
};
// Make sure there's only one damaged selection per projectile per frame.
if (_selectionName != "" and !(_unit getVariable QGVAR(isFalling))) then {
_cache_projectiles = _unit getVariable QGVAR(projectiles);
_cache_hitpoints = _unit getVariable QGVAR(hitPoints);
_cache_damages = _unit getVariable QGVAR(damages);
if (_projectile in _cache_projectiles) then {
_index = _cache_projectiles find _projectile;
_otherDamage = (_cache_damages select _index);
if (_otherDamage > _newDamage) then {
_newDamage = 0;
} else {
_hitPoint = _cache_hitpoints select _index;
_restore = ((_unit getHitPointDamage _hitPoint) - _otherDamage) max 0;
_unit setHitPointDamage [_hitPoint, _restore];
// Make entry unfindable
_cache_projectiles set [_index, objNull];
_cache_projectiles pushBack _projectile;
_cache_hitpoints pushBack (GVAR(HITPOINTS) select (GVAR(SELECTIONS) find _selectionName));
_cache_damages pushBack _newDamage;
}; };
} else { _pain = _unit getVariable [QGVAR(pain), 0];
_cache_projectiles pushBack _projectile; _pain = _pain + _newDamage * (1 - (_unit getVariable [QGVAR(morphine), 0]));
_cache_hitpoints pushBack (GVAR(HITPOINTS) select (GVAR(SELECTIONS) find _selectionName)); _unit setVariable [QGVAR(pain), _pain min 1, true];
_cache_damages pushBack _newDamage;
}; };
_unit setVariable [QGVAR(projectiles), _cache_projectiles]; }foreach _cache_params;
_unit setVariable [QGVAR(hitPoints), _cache_hitpoints];
_unit setVariable [QGVAR(damages), _cache_damages];
};
// Get rid of double structural damage (seriously arma, what the fuck?) // We broadcast the value across the net here, in order to avoid broadcasting it multiple times earlier in the above code block
if (_selectionName == "") then { _target setvariable [QGVAR(bodyPartStatus), _damageBodyParts, true];
_cache_structDamage = _unit getVariable QGVAR(structDamage);
if (_newDamage > _cache_structDamage) then {
_unit setVariable [QGVAR(structDamage), _newDamage];
_newDamage = _newDamage - _cache_structDamage;
} else {
_newDamage = 0;
};
};
if (_selectionName == "") then { EXPLODE_6_PVT(_damageBodyParts,_headDamage,_torsoDamage,_handsDamageR,_handsDamageL,_legsDamageR,_legsDamageL);
_damage = _damage + (_unit getVariable QGVAR(structDamage)); _target setHitPointDamage ["hitHead", _headDamage min 0.95];
} else { _target setHitPointDamage ["hitBody", _torsoDamage min 0.95];
_damage = _damage + _newDamage; _target setHitPointDamage ["hitHands", (_handsDamageR + _handsDamageL) min 0.95];
}; _target setHitPointDamage ["hitLegs", (_legsDamageR + _legsDamageL) min 0.95];
// Leg Damage {
_legdamage = (_unit getHitPointDamage "HitLeftLeg") + (_unit getHitPointDamage "HitRightLeg"); _target setHitPointDamage [_x, (_damageBodyParts select _foreachIndex) min 0.95];
if (_selectionName == "leg_l") then { }foreach GVAR(HITPOINTS);
_legdamage = _damage + (_unit getHitPointDamage "HitRightLeg");
};
if (_selectionName == "leg_r") then {
_legdamage = (_unit getHitPointDamage "HitLeftLeg") + _damage;
};
if (_legdamage >= LEGDAMAGETRESHOLD1) then {
_unit setHitPointDamage ["HitLegs", 1];
} else {
_unit setHitPointDamage ["HitLegs", 0];
};
// @todo: force prone for completely fucked up legs.
// Arm Damage
_armdamage = (_unit getHitPointDamage "HitLeftArm") + (_unit getHitPointDamage "HitRightArm");
if (_selectionName == "hand_l") then {
_armdamage = _damage + (_unit getHitPointDamage "HitRightArm");
};
if (_selectionName == "hand_r") then {
_armdamage = (_unit getHitPointDamage "HitLeftArm") + _damage;
};
if (_armdamage >= ARMDAMAGETRESHOLD1) then {
_unit setHitPointDamage ["HitHands", 1];
} else {
_unit setHitPointDamage ["HitHands", 0];
};
// @todo: Drop weapon for full damage.
// Set Pain
if (_selectionName == "") then {
_pain = _unit getVariable [QGVAR(pain), 0];
_pain = _pain + _newDamage * (1 - (_unit getVariable [QGVAR(morphine), 0]));
_unit setVariable [QGVAR(pain), _pain min 1, true];
};
// Unconsciousness
if (_selectionName == "" and
_damage >= UNCONSCIOUSNESSTRESHOLD and
_damage < 1 and
!(_unit getVariable ["ACE_isUnconscious", False]
)) then {
[_unit, true] call FUNC(setUnconscious);
};
_damage

View File

@ -1,56 +0,0 @@
/*
* Author: KoffeinFlummi, Glowbal
* Cache a handleDamage call to execute it 3 frames later
*
* Arguments:
*
* Return Value:
* <nil>
*
* Public: No
*/
#include "script_component.hpp"
private ["_damageBodyParts", "_cache_params", "_cache_damages"];
params ["_target"];
_damageBodyParts = _target getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
_cache_params = _target getVariable [QGVAR(cachedHandleDamageParams), []];
_cache_damages = _target getVariable QGVAR(cachedDamages);
{
_x params ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"];
if !(isNull _sourceOfDamage && {_typeOfProjectile == ""} && {vehicle _unit == _unit} && {(_selectionName == "head" || isBurning _unit)}) then {
_part = [_selectionName] call FUNC(selectionNameToNumber);
if (_part < 0) exitwith {};
private ["_newDamage", "_pain"];
_newDamage = (_cache_damages select _foreachIndex);
_damageBodyParts set [_part, (_damageBodyParts select _part) + _newDamage];
_unit setvariable [QGVAR(bodyPartStatus), _damageBodyParts];
if (alive _unit && {!(_unit getvariable ["ACE_isUnconscious", false])}) then {
// If it reaches this, we can assume that the hit did not kill this unit, as this function is called 3 frames after the damage has been passed.
if ([_unit, _part, if (_part > 1) then {_newDamage * 1.3} else {_newDamage * 2}] call FUNC(determineIfFatal)) then {
[_unit] call FUNC(setUnconscious);
};
};
_pain = _unit getVariable [QGVAR(pain), 0];
_pain = _pain + _newDamage * (1 - (_unit getVariable [QGVAR(morphine), 0]));
_unit setVariable [QGVAR(pain), _pain min 1, true];
};
}foreach _cache_params;
// We broadcast the value across the net here, in order to avoid broadcasting it multiple times earlier in the above code block
_target setvariable [QGVAR(bodyPartStatus), _damageBodyParts, true];
EXPLODE_6_PVT(_damageBodyParts,_headDamage,_torsoDamage,_handsDamageR,_handsDamageL,_legsDamageR,_legsDamageL);
_target setHitPointDamage ["hitHead", _headDamage min 0.95];
_target setHitPointDamage ["hitBody", _torsoDamage min 0.95];
_target setHitPointDamage ["hitHands", (_handsDamageR + _handsDamageL) min 0.95];
_target setHitPointDamage ["hitLegs", (_legsDamageR + _legsDamageL) min 0.95];
{
_target setHitPointDamage [_x, (_damageBodyParts select _foreachIndex) min 0.95];
}foreach GVAR(HITPOINTS);

View File

@ -80,7 +80,7 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t
_unit setDamage 0; _unit setDamage 0;
if (GVAR(level) < 2 || {!([_unit] call FUNC(hasMedicalEnabled))}) then { if (GVAR(level) < 2 || {!([_unit] call FUNC(hasMedicalEnabled))}) then {
[_unit] call FUNC(handleDamage_basic2); [_unit] call FUNC(handleDamage_basic);
} else { } else {
_cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []]; _cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []];
_cache_damages = _unit getVariable QGVAR(cachedDamages); _cache_damages = _unit getVariable QGVAR(cachedDamages);