Merge pull request #3916 from acemod/merge-basic-and-advanced

Merge basic and advanced injury systems
This commit is contained in:
Glowbal 2016-07-12 13:36:02 +02:00 committed by GitHub
commit ee8e03a1ae
23 changed files with 185 additions and 510 deletions

View File

@ -15,8 +15,7 @@ class ACE_Medical_Actions {
condition = ""; condition = "";
patientStateCondition = 0; patientStateCondition = 0;
itemConsumed = 1; itemConsumed = 1;
callbackSuccess = QUOTE(DFUNC(treatmentAdvanced_bandage));
callbackSuccess = QUOTE(DFUNC(treatmentBasic_bandage));
callbackFailure = ""; callbackFailure = "";
callbackProgress = ""; callbackProgress = "";
@ -67,7 +66,8 @@ class ACE_Medical_Actions {
requiredMedic = 1; requiredMedic = 1;
treatmentTime = 20; treatmentTime = 20;
items[] = {"ACE_bloodIV"}; items[] = {"ACE_bloodIV"};
callbackSuccess = QUOTE(DFUNC(treatmentBasic_bloodbag)); // callbackSuccess = QUOTE(DFUNC(treatmentBasic_bloodbag));
callbackSuccess = QUOTE(DFUNC(treatmentIV));
animationCaller = "AinvPknlMstpSnonWnonDnon_medic1"; animationCaller = "AinvPknlMstpSnonWnonDnon_medic1";
litter[] = {}; litter[] = {};
}; };
@ -690,6 +690,12 @@ class ACE_Medical_Advanced {
// packing bandage is average treatment, higher reopen change, longer reopening delay // packing bandage is average treatment, higher reopen change, longer reopening delay
// elastic bandage is higher treatment, higher reopen change, shorter reopen delay // elastic bandage is higher treatment, higher reopen change, shorter reopen delay
// quickclot is lower treatment, lower reopen change, longer reopening delay // quickclot is lower treatment, lower reopen change, longer reopening delay
class Bandage { // basic bandage
effectiveness = 5;
reopeningChance = 0;
reopeningMinDelay = 0;
reopeningMaxDelay = 0;
};
class FieldDressing { class FieldDressing {
// How effect is the bandage for treating one wounds type injury // How effect is the bandage for treating one wounds type injury

View File

@ -35,7 +35,6 @@ PREP(handleDamage);
PREP(handleDamage_advanced); PREP(handleDamage_advanced);
PREP(handleDamage_advancedSetDamage); PREP(handleDamage_advancedSetDamage);
PREP(handleDamage_airway); PREP(handleDamage_airway);
PREP(handleDamage_basic);
PREP(handleDamage_caching); PREP(handleDamage_caching);
PREP(handleDamage_fractures); PREP(handleDamage_fractures);
PREP(handleDamage_internalInjuries); PREP(handleDamage_internalInjuries);
@ -61,8 +60,6 @@ PREP(itemCheck);
PREP(medicationEffectLoop); PREP(medicationEffectLoop);
PREP(modifyMedicalAction); PREP(modifyMedicalAction);
PREP(onMedicationUsage); PREP(onMedicationUsage);
PREP(onWoundUpdateRequest);
PREP(onPropagateWound);
PREP(parseConfigForInjuries); PREP(parseConfigForInjuries);
PREP(playInjuredSound); PREP(playInjuredSound);
PREP(reviveStateLoop); PREP(reviveStateLoop);
@ -88,8 +85,6 @@ PREP(treatmentAdvanced_fullHealTreatmentTime);
PREP(treatmentAdvanced_medication); PREP(treatmentAdvanced_medication);
PREP(treatmentAdvanced_medicationLocal); PREP(treatmentAdvanced_medicationLocal);
PREP(treatmentAdvanced_surgicalKit_onProgress); PREP(treatmentAdvanced_surgicalKit_onProgress);
PREP(treatmentBasic_bandage);
PREP(treatmentBasic_bandageLocal);
PREP(treatmentBasic_bloodbag); PREP(treatmentBasic_bloodbag);
PREP(treatmentBasic_bloodbagLocal); PREP(treatmentBasic_bloodbagLocal);
PREP(treatmentBasic_epipen); PREP(treatmentBasic_epipen);
@ -113,7 +108,6 @@ PREP(moduleAssignMedicRoles);
PREP(moduleAssignMedicalVehicle); PREP(moduleAssignMedicalVehicle);
PREP(moduleAssignMedicalFacility); PREP(moduleAssignMedicalFacility);
PREP(copyDeadBody); PREP(copyDeadBody);
PREP(requestWoundSync);
PREP(unconsciousPFH); PREP(unconsciousPFH);
// Networked litter // Networked litter

View File

@ -21,7 +21,6 @@ GVAR(heartBeatSounds_Slow) = ["ACE_heartbeat_slow_1", "ACE_heartbeat_slow_2"];
[QGVAR(treatmentAdvanced_CPRLocal), DFUNC(treatmentAdvanced_CPRLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentAdvanced_CPRLocal), DFUNC(treatmentAdvanced_CPRLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentAdvanced_fullHealLocal), DFUNC(treatmentAdvanced_fullHealLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentAdvanced_fullHealLocal), DFUNC(treatmentAdvanced_fullHealLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentAdvanced_medicationLocal), DFUNC(treatmentAdvanced_medicationLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentAdvanced_medicationLocal), DFUNC(treatmentAdvanced_medicationLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentBasic_bandageLocal), DFUNC(treatmentBasic_bandageLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentBasic_bloodbagLocal), DFUNC(treatmentBasic_bloodbagLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentBasic_bloodbagLocal), DFUNC(treatmentBasic_bloodbagLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentBasic_morphineLocal), DFUNC(treatmentBasic_morphineLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentBasic_morphineLocal), DFUNC(treatmentBasic_morphineLocal)] call CBA_fnc_addEventHandler;
[QGVAR(treatmentIVLocal), DFUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler; [QGVAR(treatmentIVLocal), DFUNC(treatmentIVLocal)] call CBA_fnc_addEventHandler;
@ -271,25 +270,15 @@ GVAR(lastHeartBeatSound) = CBA_missionTime;
// Networked litter (need to wait for GVAR(litterCleanUpDelay) to be set) // Networked litter (need to wait for GVAR(litterCleanUpDelay) to be set)
[QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler); [QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler);
if (GVAR(level) == 2) exitWith {
[
{(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)},
{(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.9},
{(([_this select 0] call FUNC(getBloodLoss)) > 0.25)},
{((_this select 0) getVariable [QGVAR(inReviveState), false])},
{((_this select 0) getVariable [QGVAR(inCardiacArrest), false])},
{((_this select 0) getVariable ["ACE_isDead", false])},
{(((_this select 0) getVariable [QGVAR(airwayStatus), 100]) < 80)}
] call FUNC(addUnconsciousCondition);
};
[ [
{(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 40)}, {(((_this select 0) getVariable [QGVAR(bloodVolume), 100]) < 65)},
{(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.6}, {(((_this select 0) getVariable [QGVAR(pain), 0]) - ((_this select 0) getVariable [QGVAR(painSuppress), 0])) > 0.9},
{(([_this select 0] call FUNC(getBloodLoss)) > 0.1)}, {(([_this select 0] call FUNC(getBloodLoss)) > 0.25)},
{((_this select 0) getVariable [QGVAR(inReviveState), false])}, {((_this select 0) getVariable [QGVAR(inReviveState), false])},
{((_this select 0) getVariable [QGVAR(inCardiacArrest), false])},
{((_this select 0) getVariable ["ACE_isDead", false])} {((_this select 0) getVariable ["ACE_isDead", false])}
] call FUNC(addUnconsciousCondition); ] call FUNC(addUnconsciousCondition);
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
// Prevent all types of interaction while unconscious // Prevent all types of interaction while unconscious

View File

@ -41,7 +41,6 @@ class ACE_newEvents {
treatmentIVLocal = QGVAR(treatmentIVLocal); treatmentIVLocal = QGVAR(treatmentIVLocal);
treatmentBasic_morphineLocal = QGVAR(treatmentBasic_morphineLocal); treatmentBasic_morphineLocal = QGVAR(treatmentBasic_morphineLocal);
treatmentBasic_bloodbagLocal = QGVAR(treatmentBasic_bloodbagLocal); treatmentBasic_bloodbagLocal = QGVAR(treatmentBasic_bloodbagLocal);
treatmentBasic_bandageLocal = QGVAR(treatmentBasic_bandageLocal);
treatmentAdvanced_medicationLocal = QGVAR(treatmentAdvanced_medicationLocal); treatmentAdvanced_medicationLocal = QGVAR(treatmentAdvanced_medicationLocal);
treatmentAdvanced_fullHealLocal = QGVAR(treatmentAdvanced_fullHealLocal); treatmentAdvanced_fullHealLocal = QGVAR(treatmentAdvanced_fullHealLocal);
treatmentAdvanced_CPRLocal = QGVAR(treatmentAdvanced_CPRLocal); treatmentAdvanced_CPRLocal = QGVAR(treatmentAdvanced_CPRLocal);

View File

@ -28,8 +28,6 @@ if (GVAR(level) == 0) exitWith {};
private _pain = ((_unit getVariable [QGVAR(pain), 0]) + _addedPain) max 0; private _pain = ((_unit getVariable [QGVAR(pain), 0]) + _addedPain) max 0;
if (GVAR(level) == 1) then {_pain = _pain min 1;}; //for basic, cap at 1
_unit setVariable [QGVAR(pain), _pain]; _unit setVariable [QGVAR(pain), _pain];
//Start up the vital watching (if not already running) //Start up the vital watching (if not already running)

View File

@ -24,10 +24,6 @@ params ["_target", ["_show", true], ["_selectionN", 0]];
GVAR(currentSelectedSelectionN) = [0, _selectionN] select (IS_SCALAR(_selectionN)); GVAR(currentSelectedSelectionN) = [0, _selectionN] select (IS_SCALAR(_selectionN));
GVAR(displayPatientInformationTarget) = [ObjNull, _target] select _show; GVAR(displayPatientInformationTarget) = [ObjNull, _target] select _show;
if (USE_WOUND_EVENT_SYNC) then {
[_target, ACE_player] call FUNC(requestWoundSync);
};
if (_show) then { if (_show) then {
("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"]; ("ACE_MedicalRscDisplayInformation" call BIS_fnc_rscLayer) cutRsc [QGVAR(DisplayInformation),"PLAIN"];
@ -54,10 +50,8 @@ if (_show) then {
private _allInjuryTexts = []; private _allInjuryTexts = [];
private _genericMessages = []; private _genericMessages = [];
if (GVAR(level) >= 2 && {([_unit] call FUNC(hasMedicalEnabled))}) then { private _partText = [LSTRING(Head), LSTRING(Torso), LSTRING(LeftArm) ,LSTRING(RightArm) ,LSTRING(LeftLeg), LSTRING(RightLeg)] select _selectionN;
private _partText = [LSTRING(Head), LSTRING(Torso), LSTRING(LeftArm) ,LSTRING(RightArm) ,LSTRING(LeftLeg), LSTRING(RightLeg)] select _selectionN; _genericMessages pushback [localize _partText, [1, 1, 1, 1]];
_genericMessages pushback [localize _partText, [1, 1, 1, 1]];
};
if (_target getVariable[QGVAR(isBleeding), false]) then { if (_target getVariable[QGVAR(isBleeding), false]) then {
_genericMessages pushback [localize LSTRING(Status_Bleeding), [1, 0.1, 0.1, 1]]; _genericMessages pushback [localize LSTRING(Status_Bleeding), [1, 0.1, 0.1, 1]];
@ -80,81 +74,57 @@ if (_show) then {
_totalIvVolume = _totalIvVolume + (_target getVariable [_x, 0]); _totalIvVolume = _totalIvVolume + (_target getVariable [_x, 0]);
}; };
} foreach GVAR(IVBags); } foreach GVAR(IVBags);
if (_totalIvVolume >= 1) then { if (_totalIvVolume >= 1) then {
_genericMessages pushback [format[localize LSTRING(receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]]; _genericMessages pushback [format[localize LSTRING(receivingIvVolume), floor _totalIvVolume], [1, 1, 1, 1]];
}; };
private _damaged = [false, false, false, false, false, false]; private _damaged = [false, false, false, false, false, false];
private _selectionBloodLoss = [0,0,0,0,0,0]; private _selectionBloodLoss = [0,0,0,0,0,0];
if (GVAR(level) >= 2 && {([_target] call FUNC(hasMedicalEnabled))}) then {
private _openWounds = _target getVariable [QGVAR(openWounds), []];
{
_x params ["", "_x1", "_selectionX", "_amountOf", "_x4"];
// Find how much this bodypart is bleeding
if (_amountOf > 0) then {
_damaged set [_selectionX, true];
_selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))];
if (_selectionN == _selectionX) then { private _openWounds = _target getVariable [QGVAR(openWounds), []];
// Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] {
if (_amountOf >= 1) then { _x params ["", "_x1", "_selectionX", "_amountOf", "_x4"];
// TODO localization // Find how much this bodypart is bleeding
_allInjuryTexts pushback [format["%2x %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6, ceil _amountOf], [1,1,1,1]]; if (_amountOf > 0) then {
} else { _damaged set [_selectionX, true];
// TODO localization _selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))];
_allInjuryTexts pushback [format["Partial %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6], [1,1,1,1]];
};
};
};
} foreach _openWounds;
private _bandagedwounds = _target getVariable [QGVAR(bandagedWounds), []];
{
_x params ["", "", "_selectionX", "_amountOf", "_x4"];
// Find how much this bodypart is bleeding
if !(_damaged select _selectionX) then {
_selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))];
};
if (_selectionN == _selectionX) then { if (_selectionN == _selectionX) then {
// Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this] // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this]
if (_amountOf > 0) then { if (_amountOf >= 1) then {
if (_amountOf >= 1) then { // TODO localization
// TODO localization _allInjuryTexts pushback [format["%2x %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6, ceil _amountOf], [1,1,1,1]];
_allInjuryTexts pushback [format["[B] %2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, ceil _amountOf], [0.88,0.7,0.65,1]]; } else {
} else { // TODO localization
// TODO localization _allInjuryTexts pushback [format["Partial %1", (GVAR(AllWoundInjuryTypes) select _x1) select 6], [1,1,1,1]];
_allInjuryTexts pushback [format["[B] Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]];
};
}; };
}; };
} foreach _bandagedwounds; };
} else { } foreach _openWounds;
_damaged = [true, true, true, true, true, true];
{ private _bandagedwounds = _target getVariable [QGVAR(bandagedWounds), []];
private _hitPoint = [_target, _x, true] call FUNC(translateSelections); {
_selectionBloodLoss set [_forEachIndex, _target getHitPointDamage _hitPoint]; _x params ["", "", "_selectionX", "_amountOf", "_x4"];
if (_target getHitPointDamage _hitPoint > 0 && {_forEachIndex == _selectionN}) then { // Find how much this bodypart is bleeding
private _pointDamage = _target getHitPointDamage _hitPoint; if !(_damaged select _selectionX) then {
private _severity = switch (true) do { _selectionBloodLoss set [_selectionX, (_selectionBloodLoss select _selectionX) + (20 * (_x4 * _amountOf))];
case (_pointDamage > 0.5): {localize LSTRING(HeavilyWounded)}; };
case (_pointDamage > 0.1): {localize LSTRING(LightlyWounded)}; if (_selectionN == _selectionX) then {
default {localize LSTRING(VeryLightlyWounded)}; // Collect the text to be displayed for this injury [ Select injury class type definition - select the classname DisplayName (6th), amount of injuries for this]
if (_amountOf > 0) then {
if (_amountOf >= 1) then {
// TODO localization
_allInjuryTexts pushback [format["[B] %2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, ceil _amountOf], [0.88,0.7,0.65,1]];
} else {
// TODO localization
_allInjuryTexts pushback [format["[B] Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6], [0.88,0.7,0.65,1]];
}; };
private _part = localize ([
LSTRING(Head),
LSTRING(Torso),
LSTRING(LeftArm),
LSTRING(RightArm),
LSTRING(LeftLeg),
LSTRING(RightLeg)
] select _forEachIndex);
_allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]];
}; };
} forEach GVAR(SELECTIONS); };
}; } foreach _bandagedwounds;
// Handle the body image coloring // Handle the body image coloring
private _availableSelections = [50,51,52,53,54,55]; private _availableSelections = [50,51,52,53,54,55];
{ {
private _total = _x; private _total = _x;

View File

@ -15,35 +15,21 @@
#define BLOODLOSSRATE_BASIC 0.2 #define BLOODLOSSRATE_BASIC 0.2
private ["_totalBloodLoss","_tourniquets","_openWounds", "_cardiacOutput", "_internalWounds"];
// TODO Only use this calculation if medium or higher, otherwise use vanilla calculations (for basic medical). // TODO Only use this calculation if medium or higher, otherwise use vanilla calculations (for basic medical).
params ["_unit"]; params ["_unit"];
_totalBloodLoss = 0;
// Advanced medical bloodloss handling private _totalBloodLoss = 0;
if (GVAR(level) >= 2) then { private _tourniquets = _unit getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]];
_tourniquets = _unit getVariable [QGVAR(tourniquets), [0,0,0,0,0,0]]; {
_openWounds = _unit getVariable [QGVAR(openWounds), []]; if ((_tourniquets select (_x select 2)) == 0) then {
//_cardiacOutput = [_unit] call FUNC(getCardiacOutput); // total bleeding ratio * percentage of injury left
{
if ((_tourniquets select (_x select 2)) == 0) then {
// total bleeding ratio * percentage of injury left
_totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3));
// (((BLOODLOSS_SMALL_WOUNDS * (_x select 0))) + ((BLOODLOSS_MEDIUM_WOUNDS * (_x select 1))) + ((BLOODLOSS_LARGE_WOUNDS * (_x select 2))) * (_cardiacOutput / DEFAULT_CARDIAC_OUTPUT));
};
} forEach _openWounds;
_internalWounds = _unit getVariable [QGVAR(internalWounds), []];
{
_totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3));
} forEach _internalWounds; // (((BLOODLOSS_SMALL_WOUNDS * (_x select 0))) + ((BLOODLOSS_MEDIUM_WOUNDS * (_x select 1))) + ((BLOODLOSS_LARGE_WOUNDS * (_x select 2))) * (_cardiacOutput / DEFAULT_CARDIAC_OUTPUT));
};
} forEach (_unit getVariable [QGVAR(openWounds), []]);
{
_totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3));
} forEach (_unit getVariable [QGVAR(internalWounds), []]);
// cap the blood loss to be no greater as the current cardiac output
//(_totalBloodLoss min _cardiacOutput);
} else {
{ _totalBloodLoss = _totalBloodLoss + _x } forEach (_unit getVariable [QGVAR(bodyPartStatus), []]);
_totalBloodLoss = (_totalBloodLoss / 6) * BLOODLOSSRATE_BASIC;
};
_totalBloodLoss * ((_unit getVariable [QGVAR(bleedingCoefficient), GVAR(bleedingCoefficient)]) max 0); _totalBloodLoss * ((_unit getVariable [QGVAR(bleedingCoefficient), GVAR(bleedingCoefficient)]) max 0);

View File

@ -26,8 +26,6 @@ if !(local _unit) exitWith {
nil nil
}; };
private ["_damageReturn", "_typeOfDamage", "_minLethalDamage", "_newDamage", "_typeIndex", "_preventDeath"];
// bug, assumed fixed, @todo excessive testing, if nothing happens remove // bug, assumed fixed, @todo excessive testing, if nothing happens remove
if (_projectile isEqualType objNull) then { if (_projectile isEqualType objNull) then {
_projectile = typeOf _projectile; _projectile = typeOf _projectile;
@ -62,16 +60,16 @@ if !(_unit getVariable [QGVAR(allowDamage), true]) exitWith {
}; };
// Get return damage // Get return damage
_damageReturn = _damage; private _damageReturn = _damage;
_newDamage = _this call FUNC(handleDamage_caching); private _newDamage = _this call FUNC(handleDamage_caching);
// handleDamage_caching may have modified the projectile string // handleDamage_caching may have modified the projectile string
_typeOfDamage = [_projectile] call FUNC(getTypeOfDamage); private _typeOfDamage = [_projectile] call FUNC(getTypeOfDamage);
TRACE_3("ACE_DEBUG: HandleDamage caching new damage",_selection,_newDamage,_unit); TRACE_3("ACE_DEBUG: HandleDamage caching new damage",_selection,_newDamage,_unit);
_typeIndex = (GVAR(allAvailableDamageTypes) find _typeOfDamage); private _typeIndex = (GVAR(allAvailableDamageTypes) find _typeOfDamage);
_minLethalDamage = if (_typeIndex >= 0) then { private _minLethalDamage = if (_typeIndex >= 0) then {
GVAR(minLethalDamages) select _typeIndex GVAR(minLethalDamages) select _typeIndex
} else { } else {
0.01 0.01

View File

@ -1,61 +0,0 @@
/*
* Author: KoffeinFlummi, Glowbal
* Handle damage basic medical
*
* Arguments:
*
* Return Value:
* <nil>
*
* Public: No
*/
#include "script_component.hpp"
params ["_target"];
TRACE_1("ACE_DEBUG: HandleDamage_BASIC Called",_target);
private _damageBodyParts = _target getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
private _cache_params = _target getVariable [QGVAR(cachedHandleDamageParams), []];
private _cache_damages = _target getVariable QGVAR(cachedDamages);
TRACE_4("ACE_DEBUG: HandleDamage BASIC",_unit, _damageBodyParts,_cache_params,_cache_damages);
{
_x params ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"];
TRACE_6("_x",_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, true, 0.5+random(10)] call FUNC(setUnconscious);
};
};
_pain = _unit getVariable [QGVAR(pain), 0];
_pain = _pain + (_newDamage / 4) * (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];
TRACE_2("ACE_DEBUG: HandleDamage BASIC Broadcast value here",_unit, _target getVariable QGVAR(bodyPartStatus));
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];
{
private _hitPointName = [_target, _x, true] call FUNC(translateSelections);
_target setHitPointDamage [_hitPointName, (_damageBodyParts select _foreachIndex) min 0.95];
}foreach GVAR(SELECTIONS);

View File

@ -17,13 +17,12 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_hitSelections", "_hitPoints", "_impactVelocity", "_newDamage", "_cache_hitpoints", "_cache_projectiles", "_cache_params", "_cache_damages"];
params ["_unit", "_selectionName", "_damage", "_source", "_projectile", "_hitPointIndex"]; params ["_unit", "_selectionName", "_damage", "_source", "_projectile", "_hitPointIndex"];
_hitSelections = GVAR(SELECTIONS); private _hitSelections = GVAR(SELECTIONS);
// Calculate change in damage - use getHitIndex because selection is translated (hitdiaphragm->body) // Calculate change in damage - use getHitIndex because selection is translated (hitdiaphragm->body)
_newDamage = _damage - (damage _unit); private _newDamage = _damage - (damage _unit);
if (_hitPointIndex >= 0) then {_newDamage = _damage - (_unit getHitIndex _hitPointIndex)}; if (_hitPointIndex >= 0) then {_newDamage = _damage - (_unit getHitIndex _hitPointIndex)};
TRACE_7("ACE_DEBUG: HandleDamage_Caching Called",_unit, _selectionName, _damage, _source, _projectile,_hitPointIndex,_newDamage); TRACE_7("ACE_DEBUG: HandleDamage_Caching Called",_unit, _selectionName, _damage, _source, _projectile,_hitPointIndex,_newDamage);
@ -40,7 +39,7 @@ if ((_vehicle != _unit) && {!(_vehicle isKindOf "StaticWeapon")} && {_source in
}; };
// Handle falling damage // Handle falling damage
_impactVelocity = (velocity _unit) select 2; private _impactVelocity = (velocity _unit) select 2;
if (_impactVelocity < -5 && {_vehicle == _unit}) then { if (_impactVelocity < -5 && {_vehicle == _unit}) then {
TRACE_1("Starting isFalling", time); TRACE_1("Starting isFalling", time);
_unit setVariable [QGVAR(isFalling), true]; _unit setVariable [QGVAR(isFalling), true];
@ -51,6 +50,7 @@ if (_impactVelocity < -5 && {_vehicle == _unit}) then {
_unit setVariable [QGVAR(isFalling), false]; _unit setVariable [QGVAR(isFalling), false];
}; };
}; };
if (_unit getVariable [QGVAR(isFalling), false]) then { if (_unit getVariable [QGVAR(isFalling), false]) then {
if !(_selectionName in ["", "leg_l", "leg_r"]) then { if !(_selectionName in ["", "leg_l", "leg_r"]) then {
if (_selectionName == "body") then { if (_selectionName == "body") then {
@ -82,18 +82,12 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t
_args params ["_unit", "_frameno"]; _args params ["_unit", "_frameno"];
if (diag_frameno >= _frameno + 2) then { if (diag_frameno >= _frameno + 2) then {
_unit setDamage 0; _unit setDamage 0;
private _cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []];
if (GVAR(level) < 2 || {!([_unit] call FUNC(hasMedicalEnabled))}) then { private _cache_damages = _unit getVariable QGVAR(cachedDamages);
[_unit] call FUNC(handleDamage_basic); {
} else { (_x + [_cache_damages select _forEachIndex]) call FUNC(handleDamage_advanced);
_cache_params = _unit getVariable [QGVAR(cachedHandleDamageParams), []]; } forEach _cache_params;
_cache_damages = _unit getVariable QGVAR(cachedDamages); [_unit] call FUNC(handleDamage_advancedSetDamage);
{
_params = _x + [_cache_damages select _forEachIndex];
_params call FUNC(handleDamage_advanced);
} forEach _cache_params;
[_unit] call FUNC(handleDamage_advancedSetDamage);
};
[_idPFH] call CBA_fnc_removePerFrameHandler; [_idPFH] call CBA_fnc_removePerFrameHandler;
}; };
}, 0, [_unit, diag_frameno] ] call CBA_fnc_addPerFrameHandler; }, 0, [_unit, diag_frameno] ] call CBA_fnc_addPerFrameHandler;
@ -106,24 +100,23 @@ if (diag_frameno > (_unit getVariable [QGVAR(frameNo_damageCaching), -3]) + 2) t
// Caching of the damage events // Caching of the damage events
if (_selectionName != "") then { if (_selectionName != "") then {
_cache_projectiles = _unit getVariable QGVAR(cachedProjectiles); private _cache_projectiles = _unit getVariable QGVAR(cachedProjectiles);
private ["_index","_otherDamage"]; private _index = _cache_projectiles find _projectile;
_index = _cache_projectiles find _projectile;
// Check if the current projectile has already been handled once // Check if the current projectile has already been handled once
if (_index >= 0 && {_projectile != "falling"}) exitWith { if (_index >= 0 && {_projectile != "falling"}) exitWith {
_cache_damages = _unit getVariable QGVAR(cachedDamages);
// Find the previous damage this projectile has done private _cache_damages = _unit getVariable QGVAR(cachedDamages);
_otherDamage = (_cache_damages select _index); private _otherDamage = (_cache_damages select _index); // Find the previous damage this projectile has done
// Take the highest damage of the two // Take the highest damage of the two
if (_newDamage > _otherDamage) then { if (_newDamage > _otherDamage) then {
_cache_params = _unit getVariable QGVAR(cachedHandleDamageParams); private _cache_params = _unit getVariable QGVAR(cachedHandleDamageParams);
_cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints); private _cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints);
private ["_hitPoint", "_restore"];
// Restore the damage before the previous damage was processed // Restore the damage before the previous damage was processed
_hitPoint = _cache_hitpoints select _index; private _hitPoint = _cache_hitpoints select _index;
_restore = ((_unit getHitIndex _hitPoint) - _otherDamage) max 0; private _restore = ((_unit getHitIndex _hitPoint) - _otherDamage) max 0;
_unit setHitIndex [_hitPoint, _restore]; _unit setHitIndex [_hitPoint, _restore];
_cache_hitpoints set [_index, _hitPointIndex]; _cache_hitpoints set [_index, _hitPointIndex];
@ -137,9 +130,9 @@ if (_selectionName != "") then {
}; };
}; };
_cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints); private _cache_hitpoints = _unit getVariable QGVAR(cachedHitPoints);
_cache_damages = _unit getVariable QGVAR(cachedDamages); private _cache_damages = _unit getVariable QGVAR(cachedDamages);
_cache_params = _unit getVariable QGVAR(cachedHandleDamageParams); private _cache_params = _unit getVariable QGVAR(cachedHandleDamageParams);
// This is an unhandled projectile // This is an unhandled projectile
_cache_projectiles pushBack _projectile; _cache_projectiles pushBack _projectile;

View File

@ -17,27 +17,26 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_bodyPartn", "_injuryTypeInfo", "_allInjuriesForDamageType", "_allPossibleInjuries", "_highestPossibleDamage", "_highestPossibleSpot", "_minDamage", "_openWounds", "_woundID", "_toAddInjury", "_painToAdd", "_bloodLoss", "_bodyPartNToAdd", "_classType", "_damageLevels", "_foundIndex", "_i", "_injury", "_maxDamage", "_pain", "_painLevel", "_selections", "_toAddClassID", "_woundsCreated"];
params ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage"]; params ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage"];
TRACE_6("ACE_DEBUG: HandleDamage Called",_unit, _selectionName, _damage, _shooter, _typeOfProjectile,_typeOfDamage); TRACE_6("ACE_DEBUG: HandleDamage Called",_unit, _selectionName, _damage, _shooter, _typeOfProjectile,_typeOfDamage);
// Administration for open wounds and ids // Administration for open wounds and ids
_openWounds = _unit getVariable[QGVAR(openWounds), []]; private _openWounds = _unit getVariable[QGVAR(openWounds), []];
_woundID = _unit getVariable[QGVAR(lastUniqueWoundID), 1]; private _woundID = _unit getVariable[QGVAR(lastUniqueWoundID), 1];
_extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _selectionName, _damage, _typeOfDamage, _woundID]; private _extensionOutput = "ace_medical" callExtension format ["HandleDamageWounds,%1,%2,%3,%4", _selectionName, _damage, _typeOfDamage, _woundID];
_painToAdd = 0; private _painToAdd = 0;
_woundsCreated = []; private _woundsCreated = [];
call compile _extensionOutput; call compile _extensionOutput;
{ {
_x params ["", "_toAddClassID", "_bodyPartNToAdd"];
_foundIndex = -1; _foundIndex = -1;
_toAddClassID = _x select 1;
_bodyPartNToAdd = _x select 2;
{ {
_x params ["", "_compareId", "_comparyBodyPartN"];
// Check if we have an id of the given class on the given bodypart already // Check if we have an id of the given class on the given bodypart already
if (_x select 1 == _toAddClassID && {_x select 2 == _bodyPartNToAdd}) exitWith { if (_compareId == _toAddClassID && {_comparyBodyPartN2 == _bodyPartNToAdd}) exitWith {
_foundIndex = _forEachIndex; _foundIndex = _forEachIndex;
}; };
} forEach _openWounds; } forEach _openWounds;
@ -47,7 +46,7 @@ call compile _extensionOutput;
_openWounds pushBack _x; _openWounds pushBack _x;
} else { } else {
// We already have one of these, so we are just going to increase the number that we have of it with a new one. // We already have one of these, so we are just going to increase the number that we have of it with a new one.
_injury = _openWounds select _foundIndex; private _injury = _openWounds select _foundIndex;
_injury set [3, (_injury select 3) + 1]; _injury set [3, (_injury select 3) + 1];
}; };
} forEach _woundsCreated; } forEach _woundsCreated;
@ -59,6 +58,6 @@ if (count _woundsCreated > 0) then {
_unit setVariable [QGVAR(lastUniqueWoundID), _woundID, true]; _unit setVariable [QGVAR(lastUniqueWoundID), _woundID, true];
}; };
_painLevel = _unit getVariable [QGVAR(pain), 0]; private _painLevel = _unit getVariable [QGVAR(pain), 0];
_unit setVariable [QGVAR(pain), _painLevel + _painToAdd]; _unit setVariable [QGVAR(pain), _painLevel + _painToAdd];
TRACE_6("ACE_DEBUG: HandleDamage_WoundsOLD",_unit, _painLevel, _painToAdd, _unit getVariable QGVAR(pain), _unit getVariable QGVAR(openWounds),_woundsCreated); TRACE_6("ACE_DEBUG: HandleDamage_WoundsOLD",_unit, _painLevel, _painToAdd, _unit getVariable QGVAR(pain), _unit getVariable QGVAR(openWounds),_woundsCreated);

View File

@ -31,8 +31,8 @@ _unit setVariable [QGVAR(bloodVolume), _bloodVolume, _syncValues];
TRACE_3("ACE_DEBUG",_bloodVolume,_syncValues,_unit); TRACE_3("ACE_DEBUG",_bloodVolume,_syncValues,_unit);
// Set variables for synchronizing information across the net // Set variables for synchronizing information across the net
if (_bloodVolume < 100) then { if (_bloodVolume < 100) then {
if ((_bloodVolume < 90 && (GVAR(level) == 2)) || _bloodVolume <= 45) then { if (_bloodVolume < 90) then {
TRACE_4("ACE_DEBUG_ADVANCED",_bloodVolume,_unit getVariable QGVAR(hasLostBlood),_syncValues,_unit); TRACE_4("ACE_DEBUG",_bloodVolume,_unit getVariable QGVAR(hasLostBlood),_syncValues,_unit);
if (_unit getVariable [QGVAR(hasLostBlood), 0] != 2) then { if (_unit getVariable [QGVAR(hasLostBlood), 0] != 2) then {
_unit setVariable [QGVAR(hasLostBlood), 2, true]; _unit setVariable [QGVAR(hasLostBlood), 2, true];
}; };
@ -41,7 +41,7 @@ if (_bloodVolume < 100) then {
if (_unit getVariable [QGVAR(hasLostBlood), 0] != 1) then { if (_unit getVariable [QGVAR(hasLostBlood), 0] != 1) then {
_unit setVariable [QGVAR(hasLostBlood), 1, true]; _unit setVariable [QGVAR(hasLostBlood), 1, true];
}; };
} };
} else { } else {
TRACE_4("ACE_DEBUG",_bloodVolume,_unit getVariable QGVAR(hasLostBlood),_syncValues,_unit); TRACE_4("ACE_DEBUG",_bloodVolume,_unit getVariable QGVAR(hasLostBlood),_syncValues,_unit);
if (_unit getVariable [QGVAR(hasLostBlood), 0] != 0) then { if (_unit getVariable [QGVAR(hasLostBlood), 0] != 0) then {
@ -72,6 +72,18 @@ if (_painStatus > (_unit getVariable [QGVAR(painSuppress), 0])) then {
}; };
}; };
if (_bloodVolume < 30) exitWith {
[_unit] call FUNC(setDead);
};
if ([_unit] call EFUNC(common,isAwake)) then {
if (_bloodVolume < 60) then {
if (random(1) > 0.9) then {
[_unit, true, 15 + random(20)] call FUNC(setUnconscious);
};
};
};
if (GVAR(level) == 1) then { if (GVAR(level) == 1) then {
TRACE_5("ACE_DEBUG_BASIC_VITALS",_painStatus,_unit getVariable QGVAR(hasPain),_unit getVariable QGVAR(morphine),_syncValues,_unit); TRACE_5("ACE_DEBUG_BASIC_VITALS",_painStatus,_unit getVariable QGVAR(hasPain),_unit getVariable QGVAR(morphine),_syncValues,_unit);
// reduce pain // reduce pain
@ -83,30 +95,11 @@ if (GVAR(level) == 1) then {
if (_unit getVariable [QGVAR(morphine), 0] > 0) then { if (_unit getVariable [QGVAR(morphine), 0] > 0) then {
_unit setVariable [QGVAR(morphine), ((_unit getVariable [QGVAR(morphine), 0]) - 0.0015 * _interval) max 0, _syncValues]; _unit setVariable [QGVAR(morphine), ((_unit getVariable [QGVAR(morphine), 0]) - 0.0015 * _interval) max 0, _syncValues];
}; };
// bleeding
if (_bloodVolume <= 35 and !(_unit getVariable ["ACE_isUnconscious", false])) then {
[_unit, true] call FUNC(setUnconscious);
};
if (_bloodVolume == 0) then {
[_unit] call FUNC(setDead);
};
}; };
// handle advanced medical, with vitals // handle advanced medical, with vitals
if (GVAR(level) >= 2) then { if (GVAR(level) >= 2) then {
TRACE_6("ACE_DEBUG_ADVANCED_VITALS",_painStatus,_bloodVolume, _unit getVariable QGVAR(hasPain),_unit getVariable QGVAR(morphine),_syncValues,_unit); TRACE_6("ACE_DEBUG_ADVANCED_VITALS",_painStatus,_bloodVolume, _unit getVariable QGVAR(hasPain),_unit getVariable QGVAR(morphine),_syncValues,_unit);
if (_bloodVolume < 30) exitWith {
[_unit] call FUNC(setDead);
};
if ([_unit] call EFUNC(common,isAwake)) then {
if (_bloodVolume < 60) then {
if (random(1) > 0.9) then {
[_unit, true, 15 + random(20)] call FUNC(setUnconscious);
};
};
};
// Handle pain due tourniquets, that have been applied more than 120 s ago // Handle pain due tourniquets, that have been applied more than 120 s ago
private _oldTourniquets = (_unit getVariable [QGVAR(tourniquets), []]) select {_x > 0 && {CBA_missionTime - _x > 120}}; private _oldTourniquets = (_unit getVariable [QGVAR(tourniquets), []]) select {_x > 0 && {CBA_missionTime - _x > 120}};
@ -126,28 +119,6 @@ if (GVAR(level) >= 2) then {
_unit setVariable [QGVAR(pain), (_painStatus - _painReduce * _interval) max 0, _syncValues]; _unit setVariable [QGVAR(pain), (_painStatus - _painReduce * _interval) max 0, _syncValues];
TRACE_8("ACE_DEBUG_ADVANCED_VITALS",_painStatus,_painReduce,_heartRate,_bloodVolume,_bloodPressure,_interval,_syncValues,_unit); TRACE_8("ACE_DEBUG_ADVANCED_VITALS",_painStatus,_painReduce,_heartRate,_bloodVolume,_bloodPressure,_interval,_syncValues,_unit);
// TODO Disabled until implemented fully
// Handle airway
/*if (GVAR(setting_allowAirwayInjuries)) then {
private _airwayStatus = _unit getVariable [QGVAR(airwayStatus), 100];
if (((_unit getVariable [QGVAR(airwayOccluded), false]) || (_unit getVariable [QGVAR(airwayCollapsed), false])) && !((_unit getVariable [QGVAR(airwaySecured), false]))) then {
if (_airwayStatus >= 0.5) then {
_unit setVariable [QGVAR(airwayStatus), _airwayStatus - 0.5 * _interval, _syncValues];
};
} else {
if !((_unit getVariable [QGVAR(airwayOccluded), false]) || (_unit getVariable [QGVAR(airwayCollapsed), false])) then {
if (_airwayStatus < 100) then {
_unit setVariable [QGVAR(airwayStatus), (_airwayStatus + 1.5 * _interval) min 100, _syncValues];
};
};
};
if (_airwayStatus < 80) then {
[_unit] call FUNC(setUnconscious);
if (_airwayStatus <= 0) then {
[_unit, true] call FUNC(setDead);
};
};
};*/
// Check vitals for medical status // Check vitals for medical status
// TODO check for in revive state instead of variable // TODO check for in revive state instead of variable

View File

@ -13,18 +13,12 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_openWounds", "_openWounds"];
params ["_unit"]; params ["_unit"];
if (GVAR(level) <= 1) exitWith { private _totalBloodLoss = 0;
([_unit] call FUNC(getBloodloss)) == 0;
};
_totalBloodLoss = 0;
_openWounds = _unit getVariable [QGVAR(openWounds), []];
{ {
// total bleeding ratio * percentage of injury left // total bleeding ratio * percentage of injury left
_totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3)); _totalBloodLoss = _totalBloodLoss + ((_x select 4) * (_x select 3));
} forEach _openWounds; } forEach (_unit getVariable [QGVAR(openWounds), []]);
(_totalBloodLoss == 0); (_totalBloodLoss == 0);

View File

@ -17,23 +17,21 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_target", "_player", "_selectionN", "_actionData"]; params ["_target", "_player", "_partNumber", "_actionData"];
if (GVAR(level) < 2 || {!([_target] call FUNC(hasMedicalEnabled))}) exitWith { private _bloodLossOnSelection = 0;
private _pointDamage = (_target getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]]) select _selectionN; // Add all bleeding from wounds on selection
{
if (_pointDamage >= 0.8) exitWith { _x params ["", "", "_selectionX", "_amountOf", "_percentageOpen"];
_actionData set [2, QPATHTOF(UI\icons\medical_crossRed.paa)]; if (_selectionX == _partNumber) then {
_bloodLossOnSelection = _bloodLossOnSelection + (_amountOf * _percentageOpen);
}; };
if (_pointDamage > 0) exitWith { } forEach (_target getvariable [QGVAR(openWounds), []]);
if (_bloodLossOnSelection >=1 ) then {
_actionData set [2, QPATHTOF(UI\icons\medical_crossRed.paa)];
} else {
if (_bloodLossOnSelection > 0 ) then {
_actionData set [2, QPATHTOF(UI\icons\medical_crossYellow.paa)]; _actionData set [2, QPATHTOF(UI\icons\medical_crossYellow.paa)];
}; };
}; };
private _openWounds = _target getVariable [QGVAR(openWounds), []];
{
_x params ["", "", "_selectionX", "_amountOf", "_x4"];
if (_amountOf > 0 && {(_selectionN == _selectionX)} && {_x4 > 0}) exitWith {
_actionData set [2, QPATHTOF(UI\icons\medical_crossRed.paa)];
};
} forEach _openWounds;

View File

@ -1,36 +0,0 @@
/*
* Author: Glowbal
* Adds a new injury to the wounds collection from remote clients. Is used to split up the large collection of injuries broadcasting across network.
*
* Arguments:
* 0: The remote unit <OBJECT>
* 1: injury <ARRAY>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
private ["_unit", "_injury", "_openWounds", "_injuryID", "_exists"];
params ["_unit", "_injury"];
if (!local _unit) then {
_openWounds = _unit getVariable[QGVAR(openWounds), []];
_injuryID = _injury select 0;
_exists = false;
{
if (_x select 0 == _injuryID) exitWith {
_exists = true;
_openWounds set [_forEachIndex, _injury];
};
} forEach _openWounds;
if (!_exists) then {
_openWounds pushBack _injury;
};
_unit setVariable [QGVAR(openWounds), _openWounds];
};

View File

@ -1,24 +0,0 @@
/*
* Author: Glowbal
* Handles an wound update request.
*
* Arguments:
* 0: The Unit <OBJECT>
* 1: Origin object <OBJECT>
*
* ReturnValue:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
private ["_unit", "_openWounds", "_originOfrequest"];
params ["_unit", "_originOfrequest"];
if (local _unit && !(local _originOfrequest)) then {
_openWounds = _unit getVariable [QGVAR(openWounds), []];
{
["ace_medical_propagateWound", [_unit, _x], [_originOfrequest]] call CBA_fnc_targetEvent;
} forEach _openWounds;
};

View File

@ -1,22 +0,0 @@
/*
* Author: Glowbal
* Ask for the latest wound information.
*
* Arguments:
* 0: The target <OBJECT>
* 1: object belonging to the caller <OBJECT>
*
* ReturnValue:
* None
*
* Public: Yes
*/
#include "script_component.hpp"
params [ "_target", "_caller"];
if (local _target || GVAR(level) < 2) exitWith {}; // if the target is local, we already got the most update to date information
if (_target getVariable [QGVAR(isWoundSynced), false]) exitWith {};
_target setVariable [QGVAR(isWoundSynced), true];
["ace_medical_woundUpdateRequest", [_target, _caller], [_target]] call CBA_fnc_targetEvent;

View File

@ -23,10 +23,6 @@ params ["_caller", "_target", "_selectionName", "_className", "_items", "", ["_s
[_target, "activity", LSTRING(Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); [_target, "activity", LSTRING(Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog);
[_target, "activity_view", LSTRING(Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message [_target, "activity_view", LSTRING(Activity_bandagedPatient), [[_caller, false, true] call EFUNC(common,getName)]] call FUNC(addToLog); // TODO expand message
if !([_target] call FUNC(hasMedicalEnabled)) exitWith {
_this call FUNC(treatmentBasic_bandage);
};
if (local _target) then { if (local _target) then {
[QGVAR(treatmentAdvanced_bandageLocal), [_target, _className, _selectionName, _specificSpot]] call CBA_fnc_localEvent; [QGVAR(treatmentAdvanced_bandageLocal), [_target, _className, _selectionName, _specificSpot]] call CBA_fnc_localEvent;
} else { } else {

View File

@ -34,6 +34,7 @@ if (isClass (_config >> _bandage)) then {
}; };
// Figure out which injury for this bodypart is the best choice to bandage // Figure out which injury for this bodypart is the best choice to bandage
// TODO also use up the remainder on left over injuries
private _mostEffectiveSpot = 0; private _mostEffectiveSpot = 0;
private _effectivenessFound = -1; private _effectivenessFound = -1;
private _mostEffectiveInjury = _openWounds select 0; private _mostEffectiveInjury = _openWounds select 0;
@ -86,13 +87,10 @@ private _impact = if ((_mostEffectiveInjury select 3) >= _effectivenessFound) th
_mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _impact) max 0]; _mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _impact) max 0];
_openWounds set [_mostEffectiveSpot, _mostEffectiveInjury]; _openWounds set [_mostEffectiveSpot, _mostEffectiveInjury];
_target setVariable [QGVAR(openWounds), _openWounds, !USE_WOUND_EVENT_SYNC]; _target setVariable [QGVAR(openWounds), _openWounds, true];
if (USE_WOUND_EVENT_SYNC) then {
["ace_medical_propagateWound", [_target, _mostEffectiveInjury]] call CBA_fnc_globalEvent;
};
// Handle the reopening of bandaged wounds // Handle the reopening of bandaged wounds
if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then { if (_impact > 0 && {GVAR(level) >= 2} && {GVAR(enableAdvancedWounds)}) then {
[_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening); [_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening);
}; };
@ -100,7 +98,7 @@ if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then {
// so that the body part functions normally and blood is removed from the uniform. // so that the body part functions normally and blood is removed from the uniform.
// Arma combines left and right arms into a single body part (HitHands), same with left and right legs (HitLegs). // Arma combines left and right arms into a single body part (HitHands), same with left and right legs (HitLegs).
// Arms are actually hands. // Arms are actually hands.
if (GVAR(healHitPointAfterAdvBandage)) then { if (GVAR(healHitPointAfterAdvBandage) || {GVAR(level) < 2}) then {
// Get the list of the wounds the target is currently suffering from. // Get the list of the wounds the target is currently suffering from.
private _currentWounds = _target getVariable [QGVAR(openWounds), []]; private _currentWounds = _target getVariable [QGVAR(openWounds), []];

View File

@ -1,27 +0,0 @@
/*
* Author: KoffeinFlummi
* Callback when the bandaging treatment is complete
*
* Arguments:
* 0: The medic <OBJECT>
* 1: The patient <OBJECT>
* 2: Selection Name <STRING>
* 3: Treatment classname <STRING>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
#define BANDAGEHEAL 0.8
private ["_hitSelections", "_hitPoints", "_point", "_damage"];
params ["_caller", "_target", "_selection", "_className"];
if (local _target) then {
[QGVAR(treatmentBasic_bandageLocal), [_target, _selection]] call CBA_fnc_localEvent;
} else {
[QGVAR(treatmentBasic_bandageLocal), [_target, _selection], _target] call CBA_fnc_targetEvent;
};

View File

@ -1,51 +0,0 @@
/*
* Author: Glowbal
* Handles the bandage of a patient.
*
* Arguments:
* 0: The patient <OBJECT>
* 1: Treatment classname <STRING>
*
*
* Return Value:
* Succesful treatment started <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
#define BANDAGEHEAL 0.8
params ["_target", "_selectionName"];
private _damageBodyParts = _target getVariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
// Ensure it is a valid bodypart
private _part = [_selectionName] call FUNC(selectionNameToNumber);
if (_part < 0) exitwith {false};
if ((_damageBodyParts select _part) > 0) then {
private _damageOnPart = (_damageBodyParts select _part);
// Temp quick fix to change in behaviour of basic medical bandaging
if (_damageOnPart - BANDAGEHEAL > 0) then {
_damageOnPart = _damageOnPart - (_damageOnPart * BANDAGEHEAL);
} else {
_damageOnPart = _damageOnPart - BANDAGEHEAL;
};
_damageBodyParts set [_part, _damageOnPart max 0];
_target setVariable [QGVAR(bodyPartStatus), _damageBodyParts, true];
TRACE_2("ACE_DEBUG: Treatment BASIC Bandage Broadcast value here",_unit, _target getVariable QGVAR(bodyPartStatus));
};
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];
{
private _hitPointName = [_target, _x, true] call FUNC(translateSelections);
_target setHitPointDamage [_hitPointName, (_damageBodyParts select _foreachIndex) min 0.95];
}foreach GVAR(SELECTIONS);
true;

View File

@ -68,22 +68,16 @@ if (!(_callback isEqualType {})) then {_callback = {TRACE_1("callback was NOT co
//Get current blood loose on limb (for "bloody" litter) //Get current blood loose on limb (for "bloody" litter)
private _bloodLossOnSelection = 0; private _bloodLossOnSelection = 0;
private _partNumber = ([_selectionName] call FUNC(selectionNameToNumber)) max 0; private _partNumber = ([_selectionName] call FUNC(selectionNameToNumber)) max 0;
if ((GVAR(level) >= 2) && {([_target] call FUNC(hasMedicalEnabled))}) then {
//Advanced Medical - Add all bleeding from wounds on selection // Add all bleeding from wounds on selection
private _openWounds = _target getvariable [QGVAR(openWounds), []]; private _openWounds = _target getvariable [QGVAR(openWounds), []];
{ {
_x params ["", "", "_selectionX", "_amountOf", "_bleedingRatio"]; _x params ["", "", "_selectionX", "_amountOf", "_percentageOpen"];
if (_selectionX == _partNumber) then { if (_selectionX == _partNumber) then {
_bloodLossOnSelection = _bloodLossOnSelection + (_amountOf * _bleedingRatio); _bloodLossOnSelection = _bloodLossOnSelection + (_amountOf * _percentageOpen);
}; };
} forEach _openWounds; } forEach _openWounds;
TRACE_1("advanced",_bloodLossOnSelection); TRACE_1("advanced",_bloodLossOnSelection);
} else {
//Basic Medical (just use blodyPartStatus):
private _damageBodyParts = _target getvariable [QGVAR(bodyPartStatus), [0,0,0,0,0,0]];
_bloodLossOnSelection = _damageBodyParts select _partNumber;
TRACE_1("basic",_bloodLossOnSelection);
};
_args call _callback; _args call _callback;
_args pushBack _bloodLossOnSelection; _args pushBack _bloodLossOnSelection;

View File

@ -106,40 +106,53 @@ if ((EGVAR(medical,level) >= 2) && {([_target] call EFUNC(medical,hasMedicalEnab
}; };
} forEach _bandagedwounds; } forEach _bandagedwounds;
} else { } else {
_damaged = [true, true, true, true, true, true];
// Add all bleeding from wounds on selection
_openWounds = _target getVariable [QEGVAR(medical,openWounds), []];
private "_amountOf";
{ {
_selectionBloodLoss set [_forEachIndex, _x]; _amountOf = _x select 3;
// Find how much this bodypart is bleeding
if ((_x > 0) && {_forEachIndex == _selectionN}) then { if (_amountOf > 0) then {
_pointDamage = _x; _damaged set [_x select 2, true];
_severity = switch (true) do { _selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))];
case (_pointDamage > 0.5): {localize ELSTRING(medical,HeavilyWounded)};
case (_pointDamage > 0.1): {localize ELSTRING(medical,LightlyWounded)};
default {localize ELSTRING(medical,VeryLightlyWounded)};
};
_part = localize ([
ELSTRING(medical,Head),
ELSTRING(medical,Torso),
ELSTRING(medical,LeftArm),
ELSTRING(medical,RightArm),
ELSTRING(medical,LeftLeg),
ELSTRING(medical,RightLeg)
] select _forEachIndex);
_allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]];
}; };
} forEach (_target getVariable [QEGVAR(medical,bodyPartStatus), [0,0,0,0,0,0]]); } forEach _openWounds;
_bandagedwounds = _target getVariable [QEGVAR(medical,bandagedWounds), []];
{
_amountOf = _x select 3;
// Find how much this bodypart is bleeding
if !(_damaged select (_x select 2)) then {
_selectionBloodLoss set [_x select 2, (_selectionBloodLoss select (_x select 2)) + (20 * ((_x select 4) * _amountOf))];
};
} forEach _bandagedwounds;
private _bloodLossOnSelection = _selectionBloodLoss select _selectionN;
if (_bloodLossOnSelection > 0) then {
private _severity = switch (true) do {
case (_bloodLossOnSelection > 0.5): {localize ELSTRING(medical,HeavilyWounded)};
case (_bloodLossOnSelection > 0.1): {localize ELSTRING(medical,LightlyWounded)};
default {localize ELSTRING(medical,VeryLightlyWounded)};
};
private _part = localize ([
ELSTRING(medical,Head),
ELSTRING(medical,Torso),
ELSTRING(medical,LeftArm),
ELSTRING(medical,RightArm),
ELSTRING(medical,LeftLeg),
ELSTRING(medical,RightLeg)
] select _selectionN);
_allInjuryTexts pushBack [format ["%1 %2", _severity, toLower _part], [1,1,1,1]];
};
}; };
[_selectionBloodLoss, _damaged, _display] call FUNC(updateBodyImage); [_selectionBloodLoss, _damaged, _display] call FUNC(updateBodyImage);
[_display, _genericMessages, _allInjuryTexts] call FUNC(updateInformationLists); [_display, _genericMessages, _allInjuryTexts] call FUNC(updateInformationLists);
_logs = _target getVariable [QEGVAR(medical,logFile_activity_view), []]; [_display, _target getVariable [QEGVAR(medical,logFile_activity_view), []]] call FUNC(updateActivityLog);
[_display, _logs] call FUNC(updateActivityLog); [_display, _target getVariable [QEGVAR(medical,logFile_quick_view), []]] call FUNC(updateQuickViewLog);
_logs = _target getVariable [QEGVAR(medical,logFile_quick_view), []]; private _triageStatus = [_target] call EFUNC(medical,getTriageStatus);
[_display, _logs] call FUNC(updateQuickViewLog);
_triageStatus = [_target] call EFUNC(medical,getTriageStatus);
(_display displayCtrl 2000) ctrlSetText (_triageStatus select 0); (_display displayCtrl 2000) ctrlSetText (_triageStatus select 0);
(_display displayCtrl 2000) ctrlSetBackgroundColor (_triageStatus select 2); (_display displayCtrl 2000) ctrlSetBackgroundColor (_triageStatus select 2);