Skip to content

Commit

Permalink
Medical - Add ability for unit specific damage threshold (#7455)
Browse files Browse the repository at this point in the history
  • Loading branch information
diwako authored Apr 20, 2020
1 parent f0f90ec commit 142fc1e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 5 deletions.
49 changes: 49 additions & 0 deletions addons/medical_damage/CfgEden.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class Cfg3DEN {
class Attributes {
class Slider;
class GVAR(slider): Slider {
attributeLoad = "params [""_ctrlGroup""];\
private _slider = _ctrlGroup controlsGroupCtrl 100;\
private _edit = _ctrlGroup controlsGroupCtrl 101;\
_slider sliderSetPosition _value;\
_edit ctrlSetText (if (_value < 0.1) then {localize ""str_disp_default""} else {[_value, 1, 1] call CBA_fnc_formatNumber});";
attributeSave = "params [""_ctrlGroup""];\
sliderPosition (_ctrlGroup controlsGroupCtrl 100); ";
onLoad = "params [""_ctrlGroup""];\
private _slider = _ctrlGroup controlsGroupCtrl 100;\
private _edit = _ctrlGroup controlsGroupCtrl 101;\
_slider sliderSetRange [0, 10];\
_slider ctrlAddEventHandler [""SliderPosChanged"", {\
params [""_slider""];\
private _edit = (ctrlParentControlsGroup _slider) controlsGroupCtrl 101;\
private _value = sliderPosition _slider;\
_edit ctrlSetText (if (_value < 0.1) then {localize ""str_disp_default""} else {[_value, 1, 1] call CBA_fnc_formatNumber});\
}];\
_edit ctrlAddEventHandler [""KillFocus"", {\
params [""_edit""];\
private _slider = (ctrlParentControlsGroup _edit) controlsGroupCtrl 100;\
private _value = ((parseNumber ctrlText _edit) min 10) max 0;\
_slider sliderSetPosition _value;\
_edit ctrlSetText (if (_value < 0.1) then { localize ""str_disp_default"" } else {[_value, 1, 1] call CBA_fnc_formatNumber});\
}];";
};
};
class Object {
class AttributeCategories {
class ace_attributes {
class Attributes {
class GVAR(threshold) {
property = QUOTE(threshold);
control = QGVAR(slider);
displayName = CSTRING(Eden_threshold_DisplayName);
tooltip = CSTRING(Eden_threshold_Description);
expression = QUOTE(if (_value >= 0.1) then {_this setVariable [ARR_3(QQEGVAR(medical,damageThreshold),_value,true)]});
typeName = "NUMBER";
condition = "objectControllable";
defaultValue = 0;
};
};
};
};
};
};
1 change: 1 addition & 0 deletions addons/medical_damage/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CfgPatches {
#include "ACE_Medical_Injuries.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgAmmo.hpp"
#include "CfgEden.hpp"

/*
class ACE_Extensions {
Expand Down
2 changes: 1 addition & 1 deletion addons/medical_damage/functions/fnc_determineIfFatal.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (EGVAR(medical,fatalDamageSource) in [0, 2]) then {
};
if (EGVAR(medical,fatalDamageSource) in [1, 2]) then {
// Sum of trauma to critical areas can be fatal (e.g. many small hits)
private _damageThreshold = if (isPlayer _unit) then { EGVAR(medical,playerDamageThreshold) } else { EGVAR(medical,AIDamageThreshold) };
private _damageThreshold = GET_DAMAGE_THRESHOLD(_unit);
private _headThreshhold = 1.25 * _damageThreshold;
private _bodyThreshhold = 1.5 * _damageThreshold;

Expand Down
5 changes: 1 addition & 4 deletions addons/medical_damage/functions/fnc_handleIncapacitation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ _bodyPartDamage params ["_headDamage", "_bodyDamage", "_leftArmDamage", "_rightA
};
} forEach GET_OPEN_WOUNDS(_unit);

private _damageThreshold = [
EGVAR(medical,AIDamageThreshold),
EGVAR(medical,playerDamageThreshold)
] select (isPlayer _unit);
private _damageThreshold = GET_DAMAGE_THRESHOLD(_unit);

if ((_headDamage > _damageThreshold / 2) || {_bodyDamage > _damageThreshold} || {(_painLevel >= PAIN_UNCONSCIOUS) && {random 1 < 0.1}}) then {
[QEGVAR(medical,CriticalInjury), _unit] call CBA_fnc_localEvent;
Expand Down
8 changes: 8 additions & 0 deletions addons/medical_damage/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -631,5 +631,13 @@
<Turkish>Ikisinden biri</Turkish>
<German>Beide</German>
</Key>
<Key ID="STR_ACE_Medical_Damage_Eden_threshold_DisplayName">
<English>Unit Damage Threshold</English>
<German>Schwelle für Schaden</German>
</Key>
<Key ID="STR_ACE_Medical_Damage_Eden_threshold_Description">
<English>Sets the amount of damage a unit can receive before going unconscious. (0 for mission default)</English>
<German>Legt die Höhe des Schadens fest, den eine Einheit erhalten kann, bevor diese ohnmächtig wird. (0 für Misionsnormalwert)</German>
</Key>
</Package>
</Project>
1 change: 1 addition & 0 deletions addons/medical_engine/script_macros_medical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
#define GET_OPEN_WOUNDS(unit) (unit getVariable [VAR_OPEN_WOUNDS, []])
#define GET_BANDAGED_WOUNDS(unit) (unit getVariable [VAR_BANDAGED_WOUNDS, []])
#define GET_STITCHED_WOUNDS(unit) (unit getVariable [VAR_STITCHED_WOUNDS, []])
#define GET_DAMAGE_THRESHOLD(unit) (unit getVariable [QEGVAR(medical,damageThreshold), [EGVAR(medical,AIDamageThreshold),EGVAR(medical,playerDamageThreshold)] select (isPlayer unit)])

// The following function calls are defined here just for consistency
#define GET_BLOOD_LOSS(unit) ([unit] call EFUNC(medical_status,getBloodLoss))
Expand Down

0 comments on commit 142fc1e

Please sign in to comment.