Add arm fractures and aim effects

This commit is contained in:
PabstMirror 2019-04-23 22:17:45 -05:00
parent ad3f0fd263
commit 80aa05e6e6
18 changed files with 87 additions and 50 deletions

View File

@ -6,7 +6,7 @@
* Arguments:
* 0: Namespace <OBJECT><LOCATION><MISSIONNAMESPACE>
* 1: Number Set ID <STRING>
* 2: Operation (sum, product, min, max, avg) <STRING>
* 2: Operation (sum, product, min, max, avg) (Case Sensitive) <STRING>
*
* Return Value:
* Value <NUMBER>
@ -19,11 +19,19 @@
*/
params ["_namespace", "_setID", "_op"];
TRACE_3("params",_namespace,_setID,_op);
TRACE_3("arithmeticGetResult",_namespace,_setID,_op);
private _data = (_namespace getVariable _setID) param [2, []];
switch (_op) do {
case ("max"): {
private _result = -1e99;
{
_result = _result max (call _x);
nil
} count _data;
_result // return
};
case ("sum"): {
private _result = 0;
{
@ -48,14 +56,6 @@ switch (_op) do {
} count _data;
_result // return
};
case ("max"): {
private _result = -1e99;
{
_result = _result max (call _x);
nil
} count _data;
_result // return
};
case ("avg"): {
private _result = 0;
{

View File

@ -6,9 +6,7 @@
if (!hasInterface) exitWith {};
[missionNamespace, "ACE_setCustomAimCoef", QUOTE(ADDON), {
private _pain = GET_PAIN_PERCEIVED(ACE_player);
linearConversion [0, 1, _pain, 1, 5, true];
(linearConversion [0, 1, GET_PAIN_PERCEIVED(ACE_player), 1, 5, true]) + (ACE_player getVariable [QEGVAR(medical_engine,aimFracture), 0])
}] call EFUNC(common,arithmeticSetSource);
#ifdef DEBUG_MODE_FULL

View File

@ -144,6 +144,10 @@
_return pushBack "------- Medications Raw: -------";
_return append _rawMedications;
if (_unit isEqualTo ACE_player) then {
_return pushBack format ["ACE_setCustomAimCoef: %1", [missionNamespace, "ACE_setCustomAimCoef", "max"] call ace_common_fnc_arithmeticGetResult];
};
// Footer:
_return pushBack "</t>";

View File

@ -67,7 +67,7 @@ if (_highestPossibleSpot < 0) exitWith { TRACE_2("no wounds possible",_damage,_h
// Administration for open wounds and ids
private _openWounds = _unit getVariable [QEGVAR(medical,openWounds), []];
private _updateLimping = false;
private _updateDamageEffects = false;
private _painLevel = 0;
private _critialDamage = false;
private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,0,0,0,0,0]];
@ -133,16 +133,16 @@ private _bodyPartVisParams = [_unit, false, false, false, false]; // params arra
[QEGVAR(medical,FatalInjury), _unit] call CBA_fnc_localEvent;
};
};
case (_causeFracture && {EGVAR(medical,fractures) > 0} && {_bodyPartNToAdd > 3} && {_woundDamage > FRACTURE_DAMAGE_THRESHOLD}): { // ToDo: Arm fractures?
TRACE_1("fracture",_bodyPartNToAdd);
case (_causeFracture && {EGVAR(medical,fractures) > 0} && {_bodyPartNToAdd > 1} && {_woundDamage > FRACTURE_DAMAGE_THRESHOLD}): {
TRACE_1("limb fracture",_bodyPartNToAdd);
// todo: play sound?
private _fractures = _unit getVariable [QEGVAR(medical,fractures), [0,0,0,0,0,0]];
_fractures set [_bodyPartNToAdd, 1];
_unit setVariable [QEGVAR(medical,fractures), _fractures, true];
_updateLimping = true;
_updateDamageEffects = true;
};
case (_causeLimping && {EGVAR(medical,limping) > 0} && {_bodyPartNToAdd > 3} && {_woundDamage > LIMPING_DAMAGE_THRESHOLD}): {
_updateLimping = true;
_updateDamageEffects = true;
};
};
@ -175,8 +175,8 @@ private _bodyPartVisParams = [_unit, false, false, false, false]; // params arra
};
} forEach _thresholds;
if (_updateLimping) then {
[_unit] call EFUNC(medical_engine,setLimping);
if (_updateDamageEffects) then {
[_unit] call EFUNC(medical_engine,updateDamageEffects);
};
_unit setVariable [QEGVAR(medical,openWounds), _openWounds, true];

View File

@ -1,6 +1,6 @@
PREP(handleDamage);
PREP(damageBodyPart);
PREP(updateBodyPartVisuals);
PREP(setLimping);
PREP(updateDamageEffects);
PREP(setStructuralDamage);
PREP(setUnconsciousAnim);

View File

@ -1,5 +1,12 @@
#include "script_component.hpp"
[QGVAR(updateDamageEffects), LINKFUNC(updateDamageEffects)] call CBA_fnc_addEventHandler;
["unit", {
params ["_new"];
[_new] call FUNC(updateDamageEffects); // Run on new controlled unit to update QGVAR(aimFracture)
}, true] call CBA_fnc_addPlayerEventHandler;
["CAManBase", "init", {
params ["_unit"];

View File

@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: commy2
* Forces a unit to limp or not.
* Author: commy2, PabstMirror
* Updates damage effects for limping and fractures
*
* Arguments:
* 0: Unit <OBJECT>
@ -11,7 +11,7 @@
* None
*
* Example:
* [player] call ace_medical_engine_fnc_setLimping
* [player] call ace_medical_engine_fnc_updateDamageEffects
*
* Public: No
*/
@ -24,24 +24,31 @@ private _isLimping = false;
if (EGVAR(medical,fractures) > 0) then {
private _fractures = _unit getVariable [QEGVAR(medical,fractures), [0,0,0,0,0,0]];
TRACE_1("",_fractures);
if (((_fractures select 4) == 1) || {(_fractures select 5) == 1}) then {
TRACE_1("limping because of fracture",_fractures);
_isLimping = true;
};
private _aimFracture = 0;
if ((_fractures select 2) == 1) then { _aimFracture = _aimFracture + 4; };
if ((_fractures select 3) == 1) then { _aimFracture = _aimFracture + 4; };
if (EGVAR(medical,fractures) == 2) then { // block sprinting if we have a leg splint on
private _isSprintBlocked = ((_fractures select 4) == -1) || {(_fractures select 5) == -1};
TRACE_2("",_isSprintBlocked,_fractures);
if (EGVAR(medical,fractures) == 2) then { // the limp with a splint will still cause effects
private _isSprintBlocked = ((_fractures select 4) == -1) || {(_fractures select 5) == -1}; // block sprinting if we have a leg splint on
if (_isSprintBlocked || {!isSprintAllowed _unit}) then { // only update status effect if we need to
TRACE_1("updating status effect",_isSprintBlocked);
[_unit, "blockSprint", QEGVAR(medical,fracture), _isSprintBlocked] call EFUNC(common,statusEffect_set);
};
if ((_fractures select 2) == 1) then { _aimFracture = _aimFracture + 2; };
if ((_fractures select 3) == 1) then { _aimFracture = _aimFracture + 2; };
};
_unit setVariable [QGVAR(aimFracture), _aimFracture, false]; // local only var, used in ace_medical's postInit to set ACE_setCustomAimCoef
};
if (!_isLimping && {EGVAR(medical,limping) > 0}) then {
private _woundsToCheck = _unit getVariable [QEGVAR(medical,openWounds), []];
if (EGVAR(medical,limping) == 2) then {
_woundsToCheck = _woundsToCheck + (_unit getVariable [QEGVAR(medical,bandagedWounds), []]); // append will break things
_woundsToCheck = _woundsToCheck + (_unit getVariable [QEGVAR(medical,bandagedWounds), []]); // do not append
};
{
_x params ["_xClassID", "_xBodyPartN", "_xAmountOf", "", "_xDamage"];

Binary file not shown.

Binary file not shown.

View File

@ -68,8 +68,8 @@ private _bodyPartBloodLoss = [0, 0, 0, 0, 0, 0];
} forEach [
[IDC_BODY_HEAD],
[IDC_BODY_TORSO],
[IDC_BODY_ARMLEFT, IDC_BODY_ARMLEFT_T],
[IDC_BODY_ARMRIGHT, IDC_BODY_ARMRIGHT_T],
[IDC_BODY_ARMLEFT, IDC_BODY_ARMLEFT_T, IDC_BODY_ARMLEFT_B],
[IDC_BODY_ARMRIGHT, IDC_BODY_ARMRIGHT_T, IDC_BODY_ARMRIGHT_B],
[IDC_BODY_LEGLEFT, IDC_BODY_LEGLEFT_T, IDC_BODY_LEGLEFT_B],
[IDC_BODY_LEGRIGHT, IDC_BODY_LEGRIGHT_T, IDC_BODY_LEGRIGHT_B]
];

View File

@ -45,6 +45,24 @@ class GVAR(BodyImage): RscControlsGroupNoScrollbars {
idc = IDC_BODY_LEGRIGHT;
text = QPATHTOF(data\body_image\leg_right.paa);
};
class ArmLeftB: Background {
idc = IDC_BODY_ARMLEFT_B;
text = QPATHTOF(data\body_image\arm_left_bonel.paa);
colorText[] = {0, 0, 0.8, 1};
show = 0;
};
class ArmRightB: ArmLeftB {
idc = IDC_BODY_ARMRIGHT_B;
text = QPATHTOF(data\body_image\arm_right_boner.paa);
};
class LegLeftB: ArmLeftB {
idc = IDC_BODY_LEGLEFT_B;
text = QPATHTOF(data\body_image\leg_left_bonel.paa);
};
class LegRightB: ArmLeftB {
idc = IDC_BODY_LEGRIGHT_B;
text = QPATHTOF(data\body_image\leg_right_boner.paa);
};
class ArmLeftT: Background {
idc = IDC_BODY_ARMLEFT_T;
text = QPATHTOF(data\body_image\arm_left_t.paa);
@ -55,14 +73,6 @@ class GVAR(BodyImage): RscControlsGroupNoScrollbars {
idc = IDC_BODY_ARMRIGHT_T;
text = QPATHTOF(data\body_image\arm_right_t.paa);
};
class LegLeftB: ArmLeftT {
idc = IDC_BODY_LEGLEFT_B;
text = QPATHTOF(data\body_image\leg_left_bonel.paa);
};
class LegRightB: ArmLeftT {
idc = IDC_BODY_LEGRIGHT_B;
text = QPATHTOF(data\body_image\leg_right_boner.paa);
};
class LegLeftT: ArmLeftT {
idc = IDC_BODY_LEGLEFT_T;
text = QPATHTOF(data\body_image\leg_left_t.paa);
@ -557,11 +567,11 @@ class RscTitles {
w = POS_W(8.5);
h = POS_H(8.5);
};
class ArmLeftT: ArmLeftT {
class ArmLeftB: ArmLeftB {
w = POS_W(8.5);
h = POS_H(8.5);
};
class ArmRightT: ArmRightT {
class ArmRightB: ArmRightB {
w = POS_W(8.5);
h = POS_H(8.5);
};
@ -573,6 +583,14 @@ class RscTitles {
w = POS_W(8.5);
h = POS_H(8.5);
};
class ArmLeftT: ArmLeftT {
w = POS_W(8.5);
h = POS_H(8.5);
};
class ArmRightT: ArmRightT {
w = POS_W(8.5);
h = POS_H(8.5);
};
class LegLeftT: LegLeftT {
w = POS_W(8.5);
h = POS_H(8.5);

View File

@ -67,8 +67,10 @@
#define IDC_BODY_ARMRIGHT_T 6040
#define IDC_BODY_LEGLEFT_T 6045
#define IDC_BODY_LEGRIGHT_T 6050
#define IDC_BODY_LEGRIGHT_B 6055
#define IDC_BODY_LEGLEFT_B 6060
#define IDC_BODY_ARMLEFT_B 6055
#define IDC_BODY_ARMRIGHT_B 6060
#define IDC_BODY_LEGRIGHT_B 6065
#define IDC_BODY_LEGLEFT_B 6070
#define IDC_TRIAGE_STATUS 7000
#define IDC_TRIAGE_SELECT 7100

View File

@ -16,7 +16,6 @@ if (isServer) then {
[QGVAR(treatmentIVLocal), FUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentCPRLocal), FUNC(treatmentCPRLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentFullHealLocal), FUNC(treatmentFullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentSplintLocal), FUNC(splintLocal)] call CBA_fnc_addEventHandler;
// action events

View File

@ -120,7 +120,7 @@ if (random 1 <= _reopeningChance) then {
// Check if we gained limping from this wound re-opening
if ((EGVAR(medical,limping) == 1) && {_bodyPartN > 3}) then {
[_target] call EFUNC(medical_engine,setLimping);
[_target] call EFUNC(medical_engine,updateDamageEffects);
};
};
} else {

View File

@ -26,6 +26,6 @@ _fractures set [_bodyPartNum, -1];
_target setVariable [QEGVAR(medical,fractures), _fractures, true];
// Check if we fixed limping from this treatment
[_target] call EFUNC(medical_engine,setLimping);
[_target] call EFUNC(medical_engine,updateDamageEffects);
// toDo: AddToLog:

View File

@ -47,8 +47,8 @@ if (_impact > 0 && {GVAR(advancedBandages) && {GVAR(woundReopening)}}) then {
};
// Check if we fixed limping from this treatment
if ((EGVAR(medical,limping) == 1) && {_amountOf <= 0} && {_target getVariable [QEGVAR(medical,isLimping), false]}) then {
[_target] call EFUNC(medical_engine,setLimping);
if ((EGVAR(medical,limping) == 1) && {_partIndex > 3} && {_amountOf <= 0} && {_target getVariable [QEGVAR(medical,isLimping), false]}) then {
[_target] call EFUNC(medical_engine,updateDamageEffects);
};
true

View File

@ -71,7 +71,7 @@ _target setVariable [VAR_MEDICATIONS, [], true];
// Reset triage card since medication is all reset
_target setVariable [QEGVAR(medical,triageCard), [], true];
[_target] call EFUNC(medical_engine,setLimping);
[_target] call EFUNC(medical_engine,updateDamageEffects);
// Resetting damage
_target setDamage 0;

View File

@ -39,8 +39,10 @@ if (_totalTime - _elapsedTime <= (count _bandagedWounds - 1) * 5) then {
// Check if we fixed limping from this treatment
if ((EGVAR(medical,limping) == 2) && {_target getVariable [QEGVAR(medical,isLimping), false]}) then {
_treatedWound params ["", "_partN"];
if (_partN < 4) exitWith {};
[_target] call EFUNC(medical_engine,setLimping);
if (_partN > 3) then { // only for LEG wounds
TRACE_3("updating damage effects",_target,_partN,local _target);
[QEGVAR(medical_engine,updateDamageEffects), [_target], _target] call CBA_fnc_targetEvent;
};
};
};