mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Implemented bandaged wounds setting (adv)
This commit is contained in:
parent
e3e17d8fcb
commit
dca75c5557
@ -74,24 +74,45 @@ if (_show) then {
|
||||
if (_amountOf > 0) then {
|
||||
if (_amountOf >= 1) then {
|
||||
// TODO localization
|
||||
_allInjuryTexts pushback format["%2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf];
|
||||
_allInjuryTexts pushback [format["%2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf], [1,1,1,1]];
|
||||
} else {
|
||||
// TODO localization
|
||||
_allInjuryTexts pushback format["Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6];
|
||||
_allInjuryTexts pushback [format["Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6], [1,1,1,1]];
|
||||
};
|
||||
};
|
||||
};
|
||||
}foreach _openWounds;
|
||||
|
||||
_bandagedwounds = _target getvariable [QGVAR(bandagedWounds), []];
|
||||
{
|
||||
_amountOf = _x select 3;
|
||||
// Find how much this bodypart is bleeding
|
||||
if (_selectionBloodLoss select (_x select 2) == 0) then {
|
||||
_selectionBloodLoss set [(_x select 2), (_selectionBloodLoss select (_x select 2)) + (15 * ((_x select 4) * _amountOf))];
|
||||
};
|
||||
if (GVAR(currentSelectedSelectionN) == (_x select 2)) 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]
|
||||
if (_amountOf > 0) then {
|
||||
if (_amountOf >= 1) then {
|
||||
// TODO localization
|
||||
_allInjuryTexts pushback [format["[B] %2x %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6, _amountOf], [1,0.5,0.5,1]];
|
||||
} else {
|
||||
// TODO localization
|
||||
_allInjuryTexts pushback [format["[B] Partial %1", (GVAR(AllWoundInjuryTypes) select (_x select 1)) select 6], [1,0.5,0.5,1]];
|
||||
};
|
||||
};
|
||||
};
|
||||
}foreach _bandagedwounds;
|
||||
} else {
|
||||
{
|
||||
_selectionBloodLoss set [_forEachIndex, _target getHitPointDamage _x];
|
||||
|
||||
if (_target getHitPointDamage _x > 0.1) then {
|
||||
// @todo localize
|
||||
_allInjuryTexts pushBack format ["%1 %2",
|
||||
_allInjuryTexts pushBack [format ["%1 %2",
|
||||
["Lightly wounded", "Heavily wounded"] select (_target getHitPointDamage _x > 0.5),
|
||||
["head", "torso", "left arm", "right arm", "left leg", "right leg"] select _forEachIndex
|
||||
];
|
||||
], [1,1,1,1]];
|
||||
};
|
||||
} forEach ["HitHead", "HitBody", "HitLeftArm", "HitRightArm", "HitLeftLeg", "HitRightLeg"];
|
||||
};
|
||||
@ -125,7 +146,8 @@ if (_show) then {
|
||||
_lbCtrl lbSetColor [_foreachIndex, _x select 1];
|
||||
}foreach _genericMessages;
|
||||
{
|
||||
_lbCtrl lbAdd _x;
|
||||
_lbCtrl lbAdd (_x select 0);
|
||||
_lbCtrl lbSetColor [_foreachIndex, _x select 1];
|
||||
}foreach _allInjuryTexts;
|
||||
if (count _allInjuryTexts == 0) then {
|
||||
_lbCtrl lbAdd "No injuries on this bodypart..";
|
||||
|
118
addons/medical/functions/fnc_handleBandageOpening.sqf
Normal file
118
addons/medical/functions/fnc_handleBandageOpening.sqf
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Handles the bandage of a patient.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The target <OBJECT>
|
||||
* 1: The impact <NUMBER>
|
||||
* 2: Selection part number <NUMBER>
|
||||
* 3: Injury index <NUMBER>
|
||||
* 4: Injury <ARRAY>
|
||||
* 5: Used Bandage type <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_target", "_impact", "_part", "_injuryIndex", "_injury", "_bandage", "_classID", "_className", "_reopeningChance", "_reopeningMinDelay", "_reopeningMaxDelay", "_config", "_woundTreatmentConfig", "_bandagedWounds", "_exist", "_injuryId", "_existingInjury", "_delay", "_openWounds", "_selectedInjury"];
|
||||
_target = _this select 0;
|
||||
_impact = _this select 1;
|
||||
_part = _this select 2;
|
||||
_injuryIndex = _this select 3;
|
||||
_injury = _this select 4;
|
||||
_bandage = _this select 5;
|
||||
|
||||
_classID = _injury select 1;
|
||||
_className = GVAR(woundClassNames) select _classID;
|
||||
|
||||
// default, just in case..
|
||||
_reopeningChance = 0.1;
|
||||
_reopeningMinDelay = 120;
|
||||
_reopeningMaxDelay = 200;
|
||||
|
||||
// Get the default values for the used bandage
|
||||
_config = (ConfigFile >> "ACE_Medical_Advanced" >> "Treatment" >> "Bandaging");
|
||||
if (isClass (_config >> _bandage)) then {
|
||||
_config = (_config >> _bandage);
|
||||
_reopeningChance = getNumber (_config >> "reopeningChance");
|
||||
_reopeningMinDelay = getNumber (_config >> "reopeningMinDelay");
|
||||
_reopeningMaxDelay = getNumber (_config >> "reopeningMaxDelay") max _reopeningMinDelay;
|
||||
};
|
||||
|
||||
if (isClass (_config >> _className)) then {
|
||||
_woundTreatmentConfig = (_config >> _className);
|
||||
if (isNumber (_woundTreatmentConfig >> "reopeningChance")) then {
|
||||
_reopeningChance = getNumber (_woundTreatmentConfig >> "reopeningChance");
|
||||
};
|
||||
if (isNumber (_woundTreatmentConfig >> "reopeningMinDelay")) then {
|
||||
_reopeningMinDelay = getNumber (_woundTreatmentConfig >> "reopeningMinDelay");
|
||||
};
|
||||
if (isNumber (_woundTreatmentConfig >> "reopeningMaxDelay")) then {
|
||||
_reopeningMaxDelay = getNumber (_woundTreatmentConfig >> "reopeningMaxDelay") max _reopeningMinDelay;
|
||||
};
|
||||
};
|
||||
|
||||
_bandagedWounds = _target getvariable [QGVAR(bandagedWounds), []];
|
||||
_exist = false;
|
||||
_injuryId = _injury select 0;
|
||||
{
|
||||
if ((_x select 0) == _injuryId) exitwith {
|
||||
_exist = true;
|
||||
_existingInjury = _x;
|
||||
_existingInjury set [3, (_existingInjury select 3) + _impact];
|
||||
_bandagedWounds set [_foreachIndex, _existingInjury];
|
||||
};
|
||||
}foreach _bandagedWounds;
|
||||
|
||||
if !(_exist) then {
|
||||
// [ID, classID, bodypart, percentage treated, bloodloss rate]
|
||||
_bandagedWounds pushback [_injuryId, _injury select 1, _injury select 2, _impact, _injury select 4];
|
||||
};
|
||||
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true];
|
||||
|
||||
// Check if we are ever going to reopen this
|
||||
if (random(1) <= _reopeningChance) then {
|
||||
_delay = _reopeningMinDelay + random(_reopeningMaxDelay - _reopeningMinDelay);
|
||||
[{
|
||||
private ["_target", "_impact", "_part", "_injuryIndex", "_bandage", "_injury", "_openWounds", "_selectedInjury","_bandagedWounds","_exist"];
|
||||
_target = _this select 0;
|
||||
_impact = _this select 1;
|
||||
_part = _this select 2;
|
||||
_injuryIndex = _this select 3;
|
||||
_injury = _this select 4;
|
||||
|
||||
if (alive _target) then {
|
||||
_openWounds = _target getvariable [QGVAR(openWounds), []];
|
||||
if ((count _openWounds)-1 < _injuryIndex) exitwith {};
|
||||
_selectedInjury = _openWounds select _injuryIndex;
|
||||
if (_selectedInjury select 0 == _injury select 0) then { // matching the IDs
|
||||
_selectedInjury set [3, (_selectedInjury select 3) + _impact];
|
||||
_openWounds set [_injuryIndex, _selectedInjury];
|
||||
_target setvariable [QGVAR(openWounds), _openWounds, !USE_WOUND_EVENT_SYNC];
|
||||
if (USE_WOUND_EVENT_SYNC) then {
|
||||
["medical_propagateWound", [_target, _selectedInjury]] call EFUNC(common,globalEvent);
|
||||
};
|
||||
_bandagedWounds = _target getvariable [QGVAR(bandagedWounds), []];
|
||||
_exist = false;
|
||||
_injuryId = _injury select 0;
|
||||
{
|
||||
if ((_x select 0) == _injuryId) exitwith {
|
||||
_exist = true;
|
||||
_existingInjury = _x;
|
||||
_existingInjury set [3, ((_existingInjury select 3) - _impact) max 0];
|
||||
_bandagedWounds set [_foreachIndex, _existingInjury];
|
||||
};
|
||||
}foreach _bandagedWounds;
|
||||
|
||||
if (_exist) then {
|
||||
_target setvariable [QGVAR(bandagedWounds), _bandagedWounds, true];
|
||||
};
|
||||
};
|
||||
// Otherwise something went wrong, we we don't reopen them..
|
||||
};
|
||||
}, [_target, _impact, _part, _injuryIndex, _injury], _delay, 0] call EFUNC(common,waitAndExecute);
|
||||
};
|
@ -26,6 +26,7 @@ _unit setvariable [QGVAR(tourniquets), [0,0,0,0,0,0], true];
|
||||
|
||||
// wounds and injuries
|
||||
_unit setvariable [QGVAR(openWounds), [], true];
|
||||
_unit setvariable [QGVAR(bandagedWounds), [], true];
|
||||
_unit setVariable [QGVAR(internalWounds), [], true];
|
||||
|
||||
// vitals
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Return Value:
|
||||
* Succesful treatment started <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
@ -82,18 +82,17 @@ if (_effectivenessFound == -1) exitwith {}; // Seems everything is patched up on
|
||||
// TODO refactor this part
|
||||
// Find the impact this bandage has and reduce the amount this injury is present
|
||||
_impact = if ((_mostEffectiveInjury select 3) >= _effectivenessFound) then {_effectivenessFound} else { (_mostEffectiveInjury select 3) };
|
||||
_mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _effectivenessFound) max 0];
|
||||
_mostEffectiveInjury set [ 3, ((_mostEffectiveInjury select 3) - _impact) max 0];
|
||||
_openWounds set [_mostEffectiveSpot, _mostEffectiveInjury];
|
||||
|
||||
_target setvariable [QGVAR(openWounds), _openWounds, !USE_WOUND_EVENT_SYNC];
|
||||
|
||||
if (USE_WOUND_EVENT_SYNC) then {
|
||||
["medical_propagateWound", [_unit, _mostEffectiveInjury]] call EFUNC(common,globalEvent);
|
||||
["medical_propagateWound", [_target, _mostEffectiveInjury]] call EFUNC(common,globalEvent);
|
||||
};
|
||||
// Handle the reopening of bandaged wounds
|
||||
if (_impact > 0) then {
|
||||
// TODO handle reopening of bandaged wounds
|
||||
// [_target, _impact, _part,_highestSpot, _removeItem] call FUNC(handleBandageOpening);
|
||||
if (_impact > 0 && {GVAR(enableAdvancedWounds)}) then {
|
||||
[_target, _impact, _part, _mostEffectiveSpot, _mostEffectiveInjury, _bandage] call FUNC(handleBandageOpening);
|
||||
};
|
||||
|
||||
// If all wounds have been bandaged, we will reset all damage to 0, so the unit is not showing any blood on the model anymore.
|
||||
|
@ -25,6 +25,7 @@ if (alive _target) exitwith {
|
||||
|
||||
// wounds and injuries
|
||||
_target setvariable [QGVAR(openWounds), [], true];
|
||||
_target setvariable [QGVAR(bandagedWounds), [], true];
|
||||
_target setVariable [QGVAR(internalWounds), [], true];
|
||||
|
||||
// vitals
|
||||
|
Loading…
Reference in New Issue
Block a user