mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added new injury and treatment systems for advanced medical
This commit is contained in:
parent
b3e7431e67
commit
ead5f2ee79
@ -19,3 +19,140 @@ class ACE_Medical_Treatments {
|
||||
animationCaller = "";
|
||||
};
|
||||
};
|
||||
|
||||
class ACE_Medical_Advanced {
|
||||
// Defines all the possible injury types for advanced medical
|
||||
class Injuries {
|
||||
// All the possible wounds
|
||||
class wounds {
|
||||
class Scratch {
|
||||
// Name displayed in a diagnose or injury overview list
|
||||
name = "It's just a Scratch";
|
||||
// Possible selections that this injury can occur for
|
||||
selections[] = {"All"};
|
||||
// How much does this injury bleed per second?
|
||||
bleedingRate = 0.01;
|
||||
// How much pain is present while this injury is present
|
||||
pain = 15;
|
||||
// Possible damage causes for this injury
|
||||
causes[] = {"Bullet", "VehicleCrash", "Backblast", "Explosive", "Shell", "Grenade"};
|
||||
// Minimal amount of damage for this injury to occure
|
||||
minDamage = 0.01;
|
||||
};
|
||||
};
|
||||
class fractures {
|
||||
class Femur {
|
||||
name = "Broken Femur";
|
||||
selections[] = {"Head", "Torso"};
|
||||
pain = 20;
|
||||
causes[] = {"Bullet", "VehicleCrash", "Backblast", "Explosive", "Shell", "Grenade"};
|
||||
minDamage = 0.5;
|
||||
};
|
||||
};
|
||||
class damageTypes {
|
||||
thresholds[] = {{0.1, 1}};
|
||||
selectionSpecific = 1;
|
||||
class bullet {
|
||||
// above damage, amount. Put the highest threshold to the left and lower the threshold with the elements to the right of it.
|
||||
thresholds[] = {{0.1, 1}};
|
||||
selectionSpecific = 1;
|
||||
};
|
||||
class grenade {
|
||||
thresholds[] = {{0.1, 3}, {0, 1}};
|
||||
selectionSpecific = 0;
|
||||
};
|
||||
class explosive {
|
||||
thresholds[] = {{1, 6}, {0.1, 4}, {0, 1}};
|
||||
selectionSpecific = 0;
|
||||
};
|
||||
class shell {
|
||||
thresholds[] = {{1, 7}, {0.1, 5}, {0, 1}};
|
||||
selectionSpecific = 0;
|
||||
};
|
||||
class vehiclecrash {
|
||||
thresholds[] = {{0.25, 5}};
|
||||
selectionSpecific = 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
class Treatment {
|
||||
class Bandaging {
|
||||
Class ACE_bandage {
|
||||
// How effect is the bandage for treating one wounds type injury
|
||||
effectiveness = 1;
|
||||
// What is the chance and delays (in seconds) of the treated default injury reopening
|
||||
reopeningChance = 0.1;
|
||||
reopeningMinDelay = 120;
|
||||
reopeningMaxDelay = 200;
|
||||
// Specific details for the Scratch type Wound
|
||||
class Scratch {
|
||||
effectiveness = 1;
|
||||
reopeningChance = 0;
|
||||
reopeningMinDelay = 0;
|
||||
reopeningMaxDelay = 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
class Medication {
|
||||
// How much does the pain get reduced?
|
||||
painReduce = 0;
|
||||
// How much will the heart rate be increased when the HR is low (below 55)? {minIncrease, maxIncrease, seconds}
|
||||
hrIncreaseLow[] = {10, 20, 35};
|
||||
hrIncreaseNormal[] = {10, 50, 40};
|
||||
hrIncreaseHigh[] = {10, 40, 50};
|
||||
// How long until this medication has disappeared
|
||||
timeInSystem = 120;
|
||||
// How many of this type of medication can be in the system before the patient overdoses?
|
||||
maxDose = 4;
|
||||
// specific details for the ACE_Morphine treatment action.
|
||||
class ACE_Morphine {
|
||||
painReduce = 1;
|
||||
hrIncreaseLow[] = {10, 20, 35};
|
||||
hrIncreaseNormal[] = {10, 50, 40};
|
||||
hrIncreaseHigh[] = {10, 40, 50};
|
||||
timeInSystem = 120;
|
||||
maxDose = 4;
|
||||
// {Other medication classname, total amount combined}
|
||||
inCompatableMedication[] = {{"MySampleMedication", 2}};
|
||||
};
|
||||
};
|
||||
class IV {
|
||||
// volume is in millileters
|
||||
volume = 1000;
|
||||
ratio[] = {};
|
||||
type = "Blood";
|
||||
class ACE_blood_iv {
|
||||
volume = 1000;
|
||||
ratio[] = {"Plasma", 1};
|
||||
};
|
||||
class ACE_blood_iv_500: ACE_blood_iv {
|
||||
volume = 500;
|
||||
};
|
||||
class ACE_blood_iv_250: ACE_blood_iv {
|
||||
volume = 250;
|
||||
};
|
||||
class ACE_plasma_iv {
|
||||
volume = 1000;
|
||||
ratio[] = {"Blood", 1};
|
||||
type = "Plasma";
|
||||
};
|
||||
class ACE_plasma_iv_500: ACE_plasma_iv {
|
||||
volume = 500;
|
||||
};
|
||||
class ACE_plasma_iv_250: ACE_plasma_iv {
|
||||
volume = 250;
|
||||
};
|
||||
|
||||
class ACE_saline_iv {
|
||||
volume = 1000;
|
||||
type = "Saline";
|
||||
};
|
||||
class ACE_saline_iv_500: ACE_saline_iv {
|
||||
volume = 500;
|
||||
};
|
||||
class ACE_saline_iv_250: ACE_saline_iv {
|
||||
volume = 250;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -27,8 +27,15 @@ PREP(setDead);
|
||||
PREP(playInjuredSound);
|
||||
PREP(treatment);
|
||||
PREP(canTreat);
|
||||
|
||||
PREP(treatmentAdvanced_bandage);
|
||||
PREP(treatmentAdvanced_bandageLocal);
|
||||
PREP(treatmentAdvanced_medication);
|
||||
PREP(treatmentAdvanced_medicationLocal);
|
||||
PREP(teatmentIV);
|
||||
PREP(treatmentIVLocal);
|
||||
PREP(parseConfigForInjuries);
|
||||
|
||||
GVAR(injuredUnitCollection) = [];
|
||||
call FUNC(parseConfigForInjuries);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -13,18 +13,7 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define BLOODLOSS_SMALL_WOUNDS 0.025
|
||||
#define BLOODLOSS_MEDIUM_WOUNDS 0.05
|
||||
#define BLOODLOSS_LARGE_WOUNDS 0.1
|
||||
|
||||
/**
|
||||
* The default cardiac output when all stats are set to normal is 5.25.
|
||||
*/
|
||||
#define DEFAULT_CARDIAC_OUTPUT 5.25
|
||||
|
||||
private ["_totalBloodLoss","_tourniquets","_openWounds", "_value", "_cardiacOutput", "_internalWounds"];
|
||||
|
||||
|
||||
// TODO Only use this calculation if medium or higher, otherwise use vanilla calculations (for basic medical).
|
||||
_totalBloodLoss = 0;
|
||||
|
||||
@ -50,5 +39,7 @@ if (GVAR(level) >= 1) then {
|
||||
|
||||
// cap the blood loss to be no greater as the current cardiac output
|
||||
//(_totalBloodLoss min _cardiacOutput);
|
||||
} else {
|
||||
// TODO basic medical
|
||||
};
|
||||
_totalBloodLoss;
|
||||
|
@ -31,4 +31,5 @@ _typeOfInjury = switch (true) do {
|
||||
case (_typeOfProjectile == "VehicleCrash"): {"VehicleCrash"};
|
||||
default {"Unknown"};
|
||||
};
|
||||
_typeOfInjury
|
||||
// TODO replace the capitalization on the switch results instead..
|
||||
toLower _typeOfInjury;
|
||||
|
@ -17,17 +17,7 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define RANDOM_BODY_PART round(random(6))
|
||||
#define RANDOM_OPEN_WOUND (1 + round(random(2)))
|
||||
#define ADD_INJURY(BODYPART,TYPE,AMOUNT) _woundID = 1; \
|
||||
_amountOf = count _openWounds; \
|
||||
if (_amountOf > 0) then { _woundID = (_openWounds select (_amountOf - 1) select 0) + 1; }; \
|
||||
for "_i" from 1 to AMOUNT /* step +1 */ do { \
|
||||
_openWounds pushback [_woundID, _woundType, BODYPART, 1 /* percentage treated */, FIND_BLEEDING_RATE(TYPE)]; \
|
||||
_woundID = _woundID + 1; \
|
||||
};
|
||||
|
||||
private ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage", "_bodyPartn", "_woundType"];
|
||||
private ["_unit", "_selectionName", "_damage", "_typeOfProjectile", "_typeOfDamage", "_bodyPartn", "_woundType", "_injuryTypeInfo", "_allInjuriesForDamageType", "_allPossibleInjuries", "_highestPossibleDamage", "_highestPossibleSpot", "_minDamage", "_openWounds", "_woundID", "_toAddInjury"];
|
||||
_unit = _this select 0;
|
||||
_selectionName = _this select 1;
|
||||
_damage = _this select 2;
|
||||
@ -35,109 +25,48 @@ _typeOfProjectile = _this select 3;
|
||||
_typeOfDamage = _this select 4;
|
||||
_bodyPartn = [_selectionName] call FUNC(selectionNameToNumber);
|
||||
|
||||
_woundType = 1;
|
||||
if (_damage > 0.05) then {
|
||||
private ["_wounds", "_woundID", "_amountOf"];
|
||||
_openWounds = _unit getvariable[QGVAR(openWounds), []];
|
||||
if (_bodyPartn < 0) exitwith {};
|
||||
|
||||
// TODO specify openWounds based off typeOfInjury details better.
|
||||
switch (toLower _typeOfInjury) do {
|
||||
case "bullet": {
|
||||
if (_damage < 0.1) exitwith {
|
||||
if (random(1) => 0.5) then {
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(_bodyPartn, SCRATCH, 1);
|
||||
} else {
|
||||
ADD_INJURY(_bodyPartn, BRUISES, 1); // didn't do much damage, so the skin got only bruised.
|
||||
};
|
||||
} else {
|
||||
ADD_INJURY(_bodyPartn, GRAZE_WOUND, 1);
|
||||
};
|
||||
};
|
||||
// TODO base upon caliber of the round and damage done, using _typeOfProjectile and CfgAmmo class.
|
||||
switch (true) do {
|
||||
case (_damage >= 1.2): {ADD_INJURY(_bodyPartn, LARGE_OPEN_WOUND, 1);};
|
||||
case (_damage >= 0.7): {ADD_INJURY(_bodyPartn, MEDIUM_OPEN_WOUND, 1);};
|
||||
default {ADD_INJURY(_bodyPartn, MINOR_OPEN_WOUND, 1);};
|
||||
};
|
||||
_injuryTypeInfo = missionNamespace getvariable [format[QGVAR(woundInjuryType_%1), _typeOfDamage],[[],[]]];
|
||||
_allInjuriesForDamageType = _injuryTypeInfo select 2;
|
||||
_highestPossibleSpot = -1;
|
||||
_highestPossibleDamage = 0;
|
||||
_allPossibleInjuries = [];
|
||||
{
|
||||
/*_classType = _x select 0;
|
||||
_selections = _x select 1;
|
||||
_bloodLoss = _x select 2;
|
||||
_pain = _x select 3;*/
|
||||
_minDamage = _x select 4;
|
||||
if (_damage >= _minDamage) then {
|
||||
if (_minDamage > _highestPossibleDamage) then {
|
||||
_highestPossibleSpot = _foreachIndex;
|
||||
_highestPossibleDamage = _minDamage;
|
||||
};
|
||||
case "grenade": {
|
||||
if (_damage < 0.1) exitwith {
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, BRUISES, 1);
|
||||
} else {
|
||||
ADD_INJURY(RANDOM_BODY_PART, GRAZE_WOUND, 1);
|
||||
};
|
||||
};
|
||||
for "_i" from 0 to round(random(3)) /* step +1 */ do {
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, RANDOM_OPEN_WOUND, 1);
|
||||
} else {
|
||||
ADD_INJURY(RANDOM_BODY_PART, SCHRAPNEL_WOUND, 1);
|
||||
};
|
||||
};
|
||||
};
|
||||
case "explosive": {
|
||||
if (_damage < 0.1) exitwith {
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, BRUISES, 1);
|
||||
} else {
|
||||
ADD_INJURY(RANDOM_BODY_PART, GRAZE_WOUND, 1);
|
||||
};
|
||||
};
|
||||
_allPossibleInjuries pushback _x;
|
||||
};
|
||||
}foreach _allInjuriesForDamageType;
|
||||
|
||||
ADD_INJURY(RANDOM_BODY_PART, RANDOM_OPEN_WOUND, 1);
|
||||
for "_i" from 0 to round(random(4)) /* step +1 */ do {
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, SCHRAPNEL_WOUND, 1);
|
||||
};
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, RANDOM_OPEN_WOUND, 1);
|
||||
}:
|
||||
};
|
||||
};
|
||||
case "shell": {
|
||||
if (_damage < 0.1) exitwith {
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, BRUISES, 1);
|
||||
} else {
|
||||
ADD_INJURY(RANDOM_BODY_PART, GRAZE_WOUND, 1);
|
||||
};
|
||||
};
|
||||
if (_highestPossibleSpot < 0) exitwith {
|
||||
// It appears we are dealing with an unknown type of damage.
|
||||
if (count _allInjuriesForDamageType == 0) then {
|
||||
|
||||
ADD_INJURY(RANDOM_BODY_PART, RANDOM_OPEN_WOUND, 1);
|
||||
for "_i" from 0 to round(random(5)) /* step +1 */ do {
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, SCHRAPNEL_WOUND, 1);
|
||||
};
|
||||
if (random(1) => 0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, RANDOM_OPEN_WOUND, 1);
|
||||
}:
|
||||
};
|
||||
};
|
||||
};
|
||||
_openWounds = _unit getvariable[QGVAR(openWounds), []];
|
||||
_woundID = 1;
|
||||
_amountOf = count _openWounds;
|
||||
if (_amountOf > 0) then { _woundID = (_openWounds select (_amountOf - 1) select 0) + 1; };
|
||||
|
||||
};
|
||||
case "backblast": {
|
||||
if (random(1)>=0.5) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, BRUISES, 1);
|
||||
};
|
||||
};
|
||||
case "unknown": {
|
||||
ADD_INJURY(_bodyPartn, RANDOM_OPEN_WOUND, 1);
|
||||
};
|
||||
case "vehiclecrash": {
|
||||
if (random(1)>=0.5) then {
|
||||
ADD_INJURY(_bodyPartn, RANDOM_OPEN_WOUND, 1);
|
||||
};
|
||||
for "_i" from 0 to round(random(5)) /* step +1 */ do {
|
||||
if (random(_damage) => 0.25) then {
|
||||
ADD_INJURY(RANDOM_BODY_PART, BRUISES, 1);
|
||||
};
|
||||
};
|
||||
};
|
||||
default {
|
||||
ADD_INJURY(_bodyPartn, RANDOM_OPEN_WOUND, 1);
|
||||
// TODO allow third party to handle this instead ?
|
||||
{
|
||||
if (_x select 0 <= _damage) exitwith {
|
||||
for "_i" from 0 to (1+ floor(random(_x select 1)-1)) /* step +1 */ do {
|
||||
_toAddInjury = _allPossibleInjuries select (floor(random (count _allPossibleInjuries)));
|
||||
// ID, classname, bodypart, percentage treated, bloodloss rate
|
||||
_openWounds pushback [_woundID, _toAddInjury select 0, if (_injuryTypeInfo select 1) then {_bodyPartn} else {floor(random(6))}, 1, _toAddInjury select 2];
|
||||
_woundID = _woundID + 1;
|
||||
};
|
||||
};
|
||||
_unit setvariable [GVAR(openWounds), _openWounds, true];
|
||||
};
|
||||
}foreach (_injuryTypeInfo select 0);
|
||||
|
||||
_unit setvariable [GVAR(openWounds), _openWounds, true];
|
||||
|
63
addons/medical/functions/fnc_parseConfigForInjuries.sqf
Normal file
63
addons/medical/functions/fnc_parseConfigForInjuries.sqf
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Parse the ACE_Medical_Advanced config for all injury types.
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* ReturnValue:
|
||||
* <NIL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_injuriesRootConfig", "_woundsConfig", "_allWoundClasses", "_amountOf", "_entry","_classType", "_selections", "_bloodLoss", "_pain","_minDamage","_causes", "_allTypes", "_damageTypesConfig", "_thresholds", "_typeThresholds", "_selectionSpecific", "_selectionSpecificType"];
|
||||
|
||||
_injuriesRootConfig = (configFile >> "ACE_Medical_Advanced" >> "Injuries");
|
||||
_allTypes = ["backblast", "bullet", "grenade", "explosive", "shell", "vehiclecrash"];
|
||||
|
||||
_woundsConfig = (_injuriesRootConfig >> "wounds");
|
||||
_allWoundClasses = [];
|
||||
if (isClass _woundsConfig) then {
|
||||
_amountOf = count _woundsConfig;
|
||||
for "_i" from 0 to (_amountOf -1) /* step +1 */ do {
|
||||
_entry = _woundsConfig select _i;
|
||||
if (isClass _entry) then {
|
||||
_classType = (ConfigName _entry);
|
||||
_selections = if (isArray(_entry >> "selections")) then { getArray(_entry >> "selections");} else {[]};
|
||||
_bloodLoss = if (isNumber(_entry >> "bleedingRate")) then { getNumber(_entry >> "bleedingRate");} else {0};
|
||||
_pain = if (isNumber(_entry >> "pain")) then { getNumber(_entry >> "pain");} else {0};
|
||||
_minDamage = if (isNumber(_entry >> "minDamage")) then { getNumber(_entry >> "minDamage");} else {0};
|
||||
_causes = if (isArray(_entry >> "causes")) then { getArray(_entry >> "causes");} else {[]};
|
||||
|
||||
if (count _selections > 0 && count _causes > 0) then {
|
||||
_allWoundClasses pushback [_classType, _selections, _bloodLoss, _pain, _minDamage, _causes];
|
||||
};
|
||||
true;
|
||||
};
|
||||
};
|
||||
};
|
||||
GVAR(AllWoundInjuryTypes) = _allWoundClasses;
|
||||
|
||||
_damageTypesConfig = (configFile >> "ACE_Medical_Advanced" >> "Injuries" >> "damageTypes");
|
||||
_thresholds = getArray(_damageTypesConfig >> "thresholds");
|
||||
_selectionSpecific = getNumber(_damageTypesConfig >> "selectionSpecific");
|
||||
|
||||
{
|
||||
_varName = format[QGVAR(woundInjuryType_%1),_x];
|
||||
_woundTypes = [];
|
||||
_type = _x;
|
||||
{
|
||||
if (_type in (_x select 4)) then {
|
||||
_woundTypes pushback _x;
|
||||
};
|
||||
}foreach _allWoundClasses;
|
||||
_typeThresholds = _thresholds;
|
||||
_selectionSpecificType = _selectionSpecific;
|
||||
if (isClass(_damageTypesConfig >> _x)) then {
|
||||
if (isArray(_damageTypesConfig >> _x >> "thresholds")) then { _typeThresholds = getArray(_damageTypesConfig >> _x >> "thresholds");};
|
||||
if (isNumber(_damageTypesConfig >> _x >> "selectionSpecific")) then { _selectionSpecificType = getNumber(_damageTypesConfig >> _x >> "selectionSpecific");};
|
||||
};
|
||||
missionNamespace setvariable [_varName, [_typeThresholds, _selectionSpecificType > 0, _woundTypes]];
|
||||
}foreach _allTypes;
|
33
addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf
Normal file
33
addons/medical/functions/fnc_treatmentAdvanced_bandage.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* IV Treatment callback
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The medic <OBJECT>
|
||||
* 1: The patient <OBJECT>
|
||||
* 2: SelectionName <STRING>
|
||||
* 3: Treatment classname <STRING>
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* Succesful treatment started <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_caller", "_target", "_selectionName", "_className", "_items", "_removeItem"];
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
_selectionName = _this select 2;
|
||||
_className = _this select 3;
|
||||
_items = _this select 4;
|
||||
|
||||
if (count _items == 0) exitwith {};
|
||||
|
||||
if ([_caller, _target, _items] call FUNC(useEquipment)) then {
|
||||
[[_target, _className], QUOTE(FUNC(treatmentBandageLocal)), _target] call EFUNC(common,execRemoteFnc);
|
||||
};
|
||||
|
||||
true;
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Handles the bandage of a patient.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The patient <OBJECT>
|
||||
* 1: Treatment classname <STRING>
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* Succesful treatment started <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_target", "_bandage", "_part", "_openWounds", "_config", "_effectiveness","_mostEffectiveInjury", "_mostEffectiveSpot", "_woundEffectivenss", "_mostEffectiveInjury", "_impact"];
|
||||
_target = _this select 0;
|
||||
_bandage = _this select 1;
|
||||
|
||||
// Ensure it is a valid bodypart
|
||||
_part = [_selectionName] call FUNC(selectionNameToNumber);
|
||||
if (_part < 0) exitwith {};
|
||||
|
||||
// Get the open wounds for this unit
|
||||
_openWounds = _target getvariable [QGVAR(openWounds), []];
|
||||
if (count _openWounds == 0) exitwith {}; // nothing to do here!
|
||||
|
||||
// Get the default effectiveness for the used bandage
|
||||
_config = (ConfigFile >> "ACE_Medical_Advanced" >> "Treatment" >> "Bandaging");
|
||||
_effectiveness = getNumber (_config >> "effectiveness");
|
||||
if (isClass (_config >> _bandage)) then {
|
||||
_config = (_config >> _bandage);
|
||||
if (isNumber (_config >> "effectiveness")) then { _effectiveness = getNumber (_config >> "effectiveness");};
|
||||
};
|
||||
|
||||
// Figure out which injury for this bodypart is the best choice to bandage
|
||||
_mostEffectiveSpot = 0;
|
||||
_effectivenessFound = 0;
|
||||
_mostEffectiveInjury = _openWounds select 0;
|
||||
{
|
||||
// Only parse injuries that are for the selected bodypart.
|
||||
if (_x select 2 == _part) then {
|
||||
_woundEffectivenss = _effectiveness;
|
||||
|
||||
// Check if this wound type has attributes specified for the used bandage
|
||||
if (isClass (_config >> (_x select 1))) then {
|
||||
|
||||
// Collect the effectiveness from the used bandage for this wound type
|
||||
_woundTreatmentConfig = (_config >> (_x select 1));
|
||||
if (isNumber (_woundTreatmentConfig >> "effectiveness")) then {
|
||||
_woundEffectivenss = getNumber (_woundTreatmentConfig >> "effectiveness");
|
||||
};
|
||||
};
|
||||
|
||||
// Check if this is the currently most effective found.
|
||||
if (_woundEffectivenss * ((_x select 4) * (_x select 3)) > _effectivenessFound * ((_mostEffectiveInjury select 4) * (_mostEffectiveInjury select 3))) then {
|
||||
_effectivenessFound = _woundEffectivenss;
|
||||
_mostEffectiveSpot = _foreachIndex;
|
||||
_mostEffectiveInjury = _x;
|
||||
};
|
||||
};
|
||||
}foreach _openWounds;
|
||||
|
||||
if (_effectivenessFound == 0) exitwith {}; // Seems everything is patched up on this body part already..
|
||||
|
||||
// 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];
|
||||
_openWounds set [_mostEffectiveSpot, _mostEffectiveInjury];
|
||||
_target setvariable [QGVAR(openWounds), _openWounds];
|
||||
|
||||
// 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 all wounds have been bandaged, we will reset all damage to 0, so the unit is not showing any blood on the model anymore.
|
||||
if (count _openWounds == 0) then {
|
||||
_target setDamage 0;
|
||||
// TODO also set hitpoints to 0
|
||||
};
|
||||
|
||||
true;
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* IV Treatment callback
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The medic <OBJECT>
|
||||
* 1: The patient <OBJECT>
|
||||
* 2: SelectionName <STRING>
|
||||
* 3: Treatment classname <STRING>
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* Succesful treatment started <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_caller", "_target", "_selectionName", "_className", "_items", "_removeItem"];
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
_selectionName = _this select 2;
|
||||
_className = _this select 3;
|
||||
_items = _this select 4;
|
||||
|
||||
if (count _items == 0) exitwith {};
|
||||
|
||||
if ([_caller, _target, _items] call FUNC(useEquipment)) then {
|
||||
[[_target, _className], QUOTE(FUNC(treatmentMedicationLocal)), _target] call EFUNC(common,execRemoteFnc);
|
||||
};
|
||||
|
||||
true;
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Handles the medication given to a patient.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The patient <OBJECT>
|
||||
* 1: Treatment classname <STRING>
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* Succesful treatment started <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_target", "_className", "_currentInSystem", "_medicationConfig", "_painReduce", "_hrIncreaseLow", "_hrIncreaseNorm", "_hrIncreaseHigh", "_maxDose", "_inCompatableMedication", "_timeInSystem", "_heartRate", "_pain"];
|
||||
_target = _this select 0;
|
||||
_className = _this select 1;
|
||||
|
||||
// We have added a new dose of this medication to our system, so let's increase it
|
||||
_varName = format["ACE_Medical_%1_inSystem", _className];
|
||||
_currentInSystem = _target getvariable [_varName, 0];
|
||||
_currentInSystem = _currentInSystem + 1;
|
||||
_target setvariable [_varName, _currentInSystem];
|
||||
|
||||
// Find the proper attributes for the used medication
|
||||
_medicationConfig = (configFile >> "ACE_Medical_Advanced" >> "Treatment" >> "Medication");
|
||||
_painReduce = getNumber (_medicationConfig >> "painReduce");
|
||||
_hrIncreaseLow = getArray (_medicationConfig >> "hrIncreaseLow");
|
||||
_hrIncreaseNorm = getArray (_medicationConfig >> "hrIncreaseNormal");
|
||||
_hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh");
|
||||
_timeInSystem = getNumber (_medicationConfig >> "timeInSystem");
|
||||
_maxDose = getNumber (_medicationConfig >> "maxDose");
|
||||
_inCompatableMedication = [];
|
||||
if (isClass (_medicationConfig >> _className)) then {
|
||||
_medicationConfig = (_medicationConfig >> _className);
|
||||
if (isNumber (_medicationConfig >> "painReduce")) then { _painReduce = getNumber (_medicationConfig >> "painReduce");};
|
||||
if (isArray (_medicationConfig >> "hrIncreaseLow")) then { _hrIncreaseLow = getArray (_medicationConfig >> "hrIncreaseLow"); };
|
||||
if (isArray (_medicationConfig >> "hrIncreaseNormal")) then { _hrIncreaseNorm = getArray (_medicationConfig >> "hrIncreaseNormal"); };
|
||||
if (isArray (_medicationConfig >> "hrIncreaseHigh")) then { _hrIncreaseHigh = getArray (_medicationConfig >> "hrIncreaseHigh"); };
|
||||
if (isNumber (_medicationConfig >> "timeInSystem")) then { _timeInSystem = getNumber (_medicationConfig >> "timeInSystem"); };
|
||||
if (isNumber (_medicationConfig >> "maxDose")) then { _maxDose = getNumber (_medicationConfig >> "maxDose"); };
|
||||
if (isArray (_medicationConfig >> "inCompatableMedication")) then { _inCompatableMedication = getArray (_medicationConfig >> "inCompatableMedication"); };
|
||||
};
|
||||
|
||||
// Adjust the heart rate based upon config entry
|
||||
_heartRate = _target getvariable [QGVAR(heartRate), 70];
|
||||
if (alive _target) then {
|
||||
if (_heartRate > 0) then {
|
||||
if (_heartRate <= 45) then {
|
||||
[_target, ((_hrIncreaseLow select 0) + random((_hrIncreaseLow select 1))), (_hrIncreaseLow select 2)] call FUNC(addHeartRateAdjustment);
|
||||
} else {
|
||||
if (_heartRate > 120) then {
|
||||
[_target, ((_hrIncreaseHigh select 0) + random((_hrIncreaseHigh select 1))), (_hrIncreaseHigh select 2)] call FUNC(addHeartRateAdjustment);
|
||||
} else {
|
||||
[_target, ((_hrIncreaseNorm select 0) + random((_hrIncreaseNorm select 1))), (_hrIncreaseNorm select 2)] call FUNC(addHeartRateAdjustment);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Reduce the pain level
|
||||
_pain = _target getvariable [QGVAR(pain), 0];
|
||||
_pain = _pain * _painReduce;
|
||||
if (_pain <= 0) then {
|
||||
_pain = 0;
|
||||
};
|
||||
_target setvariable [QGVAR(pain), _pain];
|
||||
|
||||
// Call back to ensure that the medication is decreased over time
|
||||
[_target, _varName, _maxDose, _timeInSystem, _inCompatableMedication] call FUNC(onMedicationUsage);
|
||||
|
||||
true
|
33
addons/medical/functions/fnc_treatmentIV.sqf
Normal file
33
addons/medical/functions/fnc_treatmentIV.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Patient IV Treatment callback
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The medic <OBJECT>
|
||||
* 1: The patient <OBJECT>
|
||||
* 2: SelectionName <STRING>
|
||||
* 3: Treatment classname <STRING>
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_caller", "_target", "_selectionName", "_className", "_items", "_removeItem", "_attributes"];
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
_selectionName = _this select 2;
|
||||
_className = _this select 3;
|
||||
_items = _this select 4;
|
||||
|
||||
if (count _items == 0) exitwith {};
|
||||
|
||||
if ([_caller, _target, _items] call FUNC(useEquipment)) then {
|
||||
_removeItem = _items select 0;
|
||||
[[_target, _removeItem], QUOTE(FUNC(treatmentIVLocal)), _target] call EFUNC(common,execRemoteFnc);
|
||||
};
|
40
addons/medical/functions/fnc_treatmentIVLocal.sqf
Normal file
40
addons/medical/functions/fnc_treatmentIVLocal.sqf
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* IV Treatment callback
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The medic <OBJECT>
|
||||
* 1: The patient <OBJECT>
|
||||
* 2: SelectionName <STRING>
|
||||
* 3: Treatment classname <STRING>
|
||||
*
|
||||
*
|
||||
* Return Value:
|
||||
* Succesful treatment started <BOOL>
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_target", "_ivItem", "_config", "_volumeAdded", "_typeOf", "_varName"];
|
||||
_target = _this select 0;
|
||||
_ivItem = _this select 1;
|
||||
|
||||
// Find the proper attributes for the used IV
|
||||
_config = (configFile >> "ACE_Medical_Advanced" >> "Treatment" >> "IV");
|
||||
_volumeAdded = getNumber (_medicationConfig >> "volume");
|
||||
_typeOf = getText (_medicationConfig >> "type");
|
||||
|
||||
if (isClass (_config >> _className)) then {
|
||||
_config = (_config >> _className);
|
||||
if (isNumber (_config >> "volume")) then { _volumeAdded = getNumber (_config >> "volume");};
|
||||
if (isText (_config >> "type")) then { _typeOf = getText (_config >> "type"); };
|
||||
};
|
||||
|
||||
_varName = format["ACE_Medical_IVVolume_%1",_typeOf];
|
||||
_target setvariable [_varName, (_target getvariable [_varName, 0]) + _volumeAdded];
|
||||
|
||||
// TODO localization
|
||||
//[_target,"treatment",format["%1 has given %4 a %2(%3ml)",[_caller] call EFUNC(common,getName),_attributes select 2,_attributes select 1,_target]] call FUNC(addActivityToLog);
|
||||
//[_target,_removeItem] call FUNC(addToTriageList);
|
Loading…
Reference in New Issue
Block a user