From 26527489d63c741ce5599a3a4822448a9fad7eca Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 7 Feb 2015 23:48:24 +0100 Subject: [PATCH] Added initial medium wounds. Fixed merge conflict. --- addons/medical/functions/fnc_handleDamage.sqf | 26 ++------- .../functions/fnc_handleDamage_medium.sqf | 17 ++++++ .../functions/fnc_handleDamage_wounds.sqf | 58 +++++++++++++++++++ 3 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 addons/medical/functions/fnc_handleDamage_wounds.sqf diff --git a/addons/medical/functions/fnc_handleDamage.sqf b/addons/medical/functions/fnc_handleDamage.sqf index b0eab9b679..95f8f851d8 100644 --- a/addons/medical/functions/fnc_handleDamage.sqf +++ b/addons/medical/functions/fnc_handleDamage.sqf @@ -17,12 +17,7 @@ #include "script_component.hpp" -<<<<<<< HEAD -private ["_unit", "_selection", "_damage", "_shooter", "_projectile", "_damageReturn", "_hitPoints"]; -======= -private ["_damageReturn", "_typeOfDamage"]; ->>>>>>> 596d018f45d34ae8f713efcd3c0c3c2e3156af07 - +private ["_unit", "_selection", "_damage", "_shooter", "_projectile", "_damageReturn", "_hitPoints", "_typeOfDamage"]; _unit = _this select 0; _selection = _this select 1; _damage = _this select 2; @@ -38,7 +33,6 @@ if (typeName _projectile == "OBJECT") then { _this set [4, _projectile]; }; -<<<<<<< HEAD // If the damage is being weird, we just tell it to fuck off. _hitSelections = ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"]; if !(_selection in (_hitSelections + [""])) exitWith {0}; @@ -50,28 +44,20 @@ if (isNil QGVAR(level)) then { GVAR(level) = 0; }; -======= _damageReturn = (_this select 2); -_typeOfDamage = [_this select 4] call FUNC(getTypeOfDamage) ->>>>>>> 596d018f45d34ae8f713efcd3c0c3c2e3156af07 +_typeOfDamage = [_this select 4] call FUNC(getTypeOfDamage); + if (GVAR(level) >= 0) then { _damageReturn = (_this + [_damageReturn, _typeOfDamage]) call FUNC(handleDamage_basic); }; -if (GVAR(level) >= 1) then { -<<<<<<< HEAD - _damageReturn = (_this + [_damageReturn]) call FUNC(handleDamage_medium); -}; -if (GVAR(level) >= 2) then { - _damageReturn = (_this + [_damageReturn]) call FUNC(handleDamage_advanced); -}; if (_damageReturn < 0.01) exitWith {0}; -======= - _damageReturn = (_this + [_damageReturn, _typeOfDamage]) call FUNC(handleDamage_medium); +if (GVAR(level) >= 1) then { + _damageReturn = (_this + [_damageReturn, _typeOfDamage]) call FUNC(handleDamage_medium); if (GVAR(level) >= 2) then { _damageReturn = (_this + [_damageReturn, _typeOfDamage]) call FUNC(handleDamage_advanced); }; }; ->>>>>>> 596d018f45d34ae8f713efcd3c0c3c2e3156af07 + _damageReturn diff --git a/addons/medical/functions/fnc_handleDamage_medium.sqf b/addons/medical/functions/fnc_handleDamage_medium.sqf index e69de29bb2..81a5d85917 100644 --- a/addons/medical/functions/fnc_handleDamage_medium.sqf +++ b/addons/medical/functions/fnc_handleDamage_medium.sqf @@ -0,0 +1,17 @@ + +#include "script_component.hpp" + +private ["_unit","_selectionName","_amountOfDamage","_sourceOfDamage","_typeOfProjectile","_typeOfDamage"]; +_unit = _this select 0; +_selectionName = _this select 1; +_amountOfDamage = _this select 2; +_sourceOfDamage = _this select 3; +_typeOfProjectile = _this select 4; +_returnDamage = _this select 5; +_typeOfDamage = _this select 6; //[_typeOfProjectile] call FUNC(getTypeOfDamage); + +if (GVAR(enableAirway)) then { + [_unit,_selectionName,_amountOfDamage,_sourceOfDamage, _typeOfDamage] call FUNC(handleDamage_wounds); +}; + +_returnDamage; diff --git a/addons/medical/functions/fnc_handleDamage_wounds.sqf b/addons/medical/functions/fnc_handleDamage_wounds.sqf new file mode 100644 index 0000000000..68221a2d4e --- /dev/null +++ b/addons/medical/functions/fnc_handleDamage_wounds.sqf @@ -0,0 +1,58 @@ + +#include "script_component.hpp" + +private ["_unit", "_selectionName", "_amountOfDamage", "_sourceOfDamage", "_typeOfDamage", "_bodyPartn", "_woundType"]; +_unit = _this select 0; +_selectionName = _this select 1; +_amountOfDamage = _this select 2; +_sourceOfDamage = _this select 3; +_typeOfDamage = _this select 4; +_bodyPartn = [_selectionName] call FUNC(selectionNameToNumber); + +_woundType = 1; +if (_amountOfDamage > 0.05) then { + + // TODO specify openWounds based off typeOfInjury details better. + switch (_typeOfDamage) do { + case "Bullet": { + _woundType = round(random(2)); + }; + case "Grenade": { + _woundType = round(random(2)); + if (_woundType < 1) then { + _woundType = 1; + }; + }; + case "Explosive": { + _woundType = round(random(2)); + if (_woundType < 1) then { + _woundType = 1; + }; + }; + case "Shell": { + _woundType = round(random(2)); + if (_woundType < 1) then { + _woundType = 1; + }; + }; + case "Unknown": { + _woundType = round(random(1)); + }; + case "VehicleCrash": { + _woundType = round(random(0)); + }; + default { + _woundType = round(random(1)); + }; + }; + + private ["_wounds", "_woundID", "_amountOf"]; + _wounds = _unit getvariable[QGVAR(openWounds), []]; + _woundID = 1; + _amountOf = count _wounds; + if (_amountOf > 0) then { + _woundID = (_wounds select (_amountOf - 1) select 0) + 1; + }; + _wounds pushback [_woundID, _woundType, _bodyPartn, 1 /* percentage treated */]; + _unit setvariable [GVAR(openWounds), _wounds, true]; +}; \ No newline at end of file