From 2b1468db240bfd4cdc67fd668bf52f1071a62426 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Sat, 16 May 2015 16:09:30 +0200 Subject: [PATCH] Added pain suppression instead of removal --- addons/medical/XEH_postInit.sqf | 16 +++++++++------- .../functions/fnc_addToInjuredCollection.sqf | 2 +- .../medical/functions/fnc_handleUnitVitals.sqf | 2 +- addons/medical/functions/fnc_init.sqf | 1 + .../medical/functions/fnc_onMedicationUsage.sqf | 9 ++++++--- .../fnc_treatmentAdvanced_fullHealLocal.sqf | 1 + .../fnc_treatmentAdvanced_medicationLocal.sqf | 6 +++--- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/addons/medical/XEH_postInit.sqf b/addons/medical/XEH_postInit.sqf index f8129e5e78..8be2544515 100644 --- a/addons/medical/XEH_postInit.sqf +++ b/addons/medical/XEH_postInit.sqf @@ -155,22 +155,24 @@ GVAR(lastHeartBeatSound) = time; // HEARTRATE BASED EFFECTS [{ - private["_heartRate", "_interval", "_minTime", "_sound", "_strength"]; + private["_heartRate", "_interval", "_minTime", "_sound", "_strength", "_pain"]; _heartRate = ACE_player getVariable [QGVAR(heartRate), 70]; + _pain = ACE_player getVariable [QGVAR(pain), 0]; if (GVAR(level) == 1) then { - _heartRate = 60 + 40 * (ACE_player getVariable [QGVAR(pain), 0]); + _heartRate = 60 + 40 * _pain; }; if (_heartRate <= 0) exitwith {}; _interval = 60 / (_heartRate min 50); + if (time > GVAR(lastHeartBeat) + _interval) then { GVAR(lastHeartBeat) = time; // Pain effect - _strength = ACE_player getVariable [QGVAR(pain), 0]; + _strength = (_pain - (ACE_player getvariable [QGVAR(painSuppress), 0])) max 0; _strength = _strength * (ACE_player getVariable [QGVAR(painCoefficient), GVAR(painCoefficient)]); if (GVAR(painEffectType) == 1) then { GVAR(effectPainCC) ppEffectEnable false; - if ((ACE_player getVariable [QGVAR(pain), 0]) > 0 && {alive ACE_player}) then { + if (_pain > (ACE_player getvariable [QGVAR(painSuppress), 0]) && {alive ACE_player}) then { _strength = _strength * 0.15; GVAR(effectPainCA) ppEffectEnable true; GVAR(effectPainCA) ppEffectAdjust [_strength, _strength, false]; @@ -192,7 +194,7 @@ GVAR(lastHeartBeatSound) = time; }; } else { GVAR(effectPainCA) ppEffectEnable false; - if ((ACE_player getVariable [QGVAR(pain), 0]) > 0 && {alive ACE_player}) then { + if (_pain > (ACE_player getvariable [QGVAR(painSuppress), 0]) && {alive ACE_player}) then { _strength = _strength * 0.9; GVAR(effectPainCC) ppEffectEnable true; GVAR(effectPainCC) ppEffectAdjust [1,1,0, [1,1,1,1], [0,0,0,0], [1,1,1,1], [1 - _strength,1 - _strength,0,0,0,0.2,2]]; @@ -250,7 +252,7 @@ if (USE_WOUND_EVENT_SYNC) then { [ {(((_this select 0) getvariable [QGVAR(bloodVolume), 100]) < 65)}, - {(((_this select 0) getvariable [QGVAR(pain), 0]) > 0.9)}, + {(((_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])}, @@ -265,7 +267,7 @@ if (USE_WOUND_EVENT_SYNC) then { // Item Event Handler ["playerInventoryChanged", { [ACE_player] call FUNC(itemCheck); -}] call EFUNC(common,addEventHandler); +}] call EFUNC(common,addEventHandler);ยง // Networked litter [QGVAR(createLitter), FUNC(handleCreateLitter), GVAR(litterCleanUpDelay)] call EFUNC(common,addSyncedEventHandler); diff --git a/addons/medical/functions/fnc_addToInjuredCollection.sqf b/addons/medical/functions/fnc_addToInjuredCollection.sqf index 23ca283693..627d3787aa 100644 --- a/addons/medical/functions/fnc_addToInjuredCollection.sqf +++ b/addons/medical/functions/fnc_addToInjuredCollection.sqf @@ -46,7 +46,7 @@ if ([_unit] call FUNC(hasMedicalEnabled) || _force) then { private "_pain"; _pain = _unit getvariable [QGVAR(pain), 0]; - if (_pain > 0) then { + if (_pain > (_unit getvariable [QGVAR(painSuppress), 0])) then { if (_pain > 0.7 && {random(1) > 0.6}) then { [_unit] call FUNC(setUnconscious); }; diff --git a/addons/medical/functions/fnc_handleUnitVitals.sqf b/addons/medical/functions/fnc_handleUnitVitals.sqf index 3877faf85d..6f11d58e44 100644 --- a/addons/medical/functions/fnc_handleUnitVitals.sqf +++ b/addons/medical/functions/fnc_handleUnitVitals.sqf @@ -58,7 +58,7 @@ if (([_unit] call FUNC(getBloodLoss)) > 0) then { }; _painStatus = _unit getvariable [QGVAR(pain), 0]; -if (_painStatus > 0) then { +if (_painStatus > (_unit getvariable [QGVAR(painSuppress), 0])) then { if !(_unit getvariable [QGVAR(hasPain), false]) then { _unit setvariable [QGVAR(hasPain), true, true]; }; diff --git a/addons/medical/functions/fnc_init.sqf b/addons/medical/functions/fnc_init.sqf index 0ec6ce3ce2..27d80163a5 100644 --- a/addons/medical/functions/fnc_init.sqf +++ b/addons/medical/functions/fnc_init.sqf @@ -64,6 +64,7 @@ _unit setvariable [QGVAR(hasLostBlood), 0, true]; _unit setvariable [QGVAR(isBleeding), false, true]; _unit setvariable [QGVAR(hasPain), false, true]; _unit setvariable [QGVAR(amountOfReviveLives), GVAR(amountOfReviveLives), true]; +_unit setvariable [QGVAR(painSuppress), 0, true]; // medication _allUsedMedication = _unit getVariable [QGVAR(allUsedMedication), []]; diff --git a/addons/medical/functions/fnc_onMedicationUsage.sqf b/addons/medical/functions/fnc_onMedicationUsage.sqf index c56f676744..08f71b4359 100644 --- a/addons/medical/functions/fnc_onMedicationUsage.sqf +++ b/addons/medical/functions/fnc_onMedicationUsage.sqf @@ -18,7 +18,7 @@ #include "script_component.hpp" -private ["_target", "_className", "_variable", "_maxDosage", "_timeInSystem", "_incompatabileMeds", "_foundEntry", "_allUsedMedication","_allMedsFromClassname", "_usedMeds", "_hasOverDosed", "_med", "_limit", "_classNamesUsed", "_decreaseAmount", "_viscosityChange", "_viscosityAdjustment", "_medicationConfig", "_onOverDose"]; +private ["_target", "_className", "_variable", "_maxDosage", "_timeInSystem", "_incompatabileMeds", "_foundEntry", "_allUsedMedication","_allMedsFromClassname", "_usedMeds", "_hasOverDosed", "_med", "_limit", "_classNamesUsed", "_decreaseAmount", "_viscosityChange", "_viscosityAdjustment", "_medicationConfig", "_onOverDose", "_painReduce"]; _target = _this select 0; _className = _this select 1; _variable = _this select 2; @@ -26,6 +26,7 @@ _maxDosage = _this select 3; _timeInSystem = _this select 4; _incompatabileMeds = _this select 5; _viscosityChange = _this select 6; +_painReduce = _this select 7; _foundEntry = false; _allUsedMedication = _target getvariable [QGVAR(allUsedMedication), []]; @@ -84,7 +85,7 @@ _decreaseAmount = 1 / _timeInSystem; _viscosityAdjustment = _viscosityChange / _timeInSystem; [{ - private ["_args", "_target", "_timeInSystem", "_variable", "_amountDecreased","_decreaseAmount", "_usedMeds", "_viscosityAdjustment"]; + private ["_args", "_target", "_timeInSystem", "_variable", "_amountDecreased","_decreaseAmount", "_usedMeds", "_viscosityAdjustment", "_painReduce"]; _args = _this select 0; _target = _args select 0; _timeInSystem = _args select 1; @@ -92,6 +93,7 @@ _viscosityAdjustment = _viscosityChange / _timeInSystem; _amountDecreased = _args select 3; _decreaseAmount = _args select 4; _viscosityAdjustment = _args select 5; + _painReduce = _args select 6; _usedMeds = _target getvariable [_variable, 0]; _usedMeds = _usedMeds - _decreaseAmount; @@ -101,9 +103,10 @@ _viscosityAdjustment = _viscosityChange / _timeInSystem; // Restoring the viscosity while the medication is leaving the system _target setvariable [QGVAR(peripheralResistance), ((_target getvariable [QGVAR(peripheralResistance), 100]) - _viscosityAdjustment) max 0]; + _target setvariable [QGVAR(painSuppress), ((_target getvariable [QGVAR(painSuppress), 0]) - _painReduce) max 0]; if (_amountDecreased >= 1 || (_usedMeds <= 0) || !alive _target) then { [(_this select 1)] call cba_fnc_removePerFrameHandler; }; _args set [3, _amountDecreased]; -}, 1, [_target, _timeInSystem, _variable, 0, _decreaseAmount, _viscosityAdjustment] ] call CBA_fnc_addPerFrameHandler; +}, 1, [_target, _timeInSystem, _variable, 0, _decreaseAmount, _viscosityAdjustment, _painReduce / _timeInSystem] ] call CBA_fnc_addPerFrameHandler; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf index e385c5f7c0..544ef6ae55 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_fullHealLocal.sqf @@ -58,6 +58,7 @@ if (alive _target) exitwith { _target setvariable [QGVAR(hasLostBlood), 0, true]; _target setvariable [QGVAR(isBleeding), false, true]; _target setvariable [QGVAR(hasPain), false, true]; + _target setvariable [QGVAR(painSuppress), 0, true]; // medication _allUsedMedication = _target getVariable [QGVAR(allUsedMedication), []]; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf index 934bc9239a..11e7d85d96 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_medicationLocal.sqf @@ -73,8 +73,8 @@ if (alive _target) then { if (_painReduce > 0) then { // Reduce the pain level - _pain = _target getvariable [QGVAR(pain), 0]; - _target setvariable [QGVAR(pain), (_pain - (_pain * _painReduce)) max 0]; + _painSuppress = _target getvariable [QGVAR(painSuppress), 0]; + _target setvariable [QGVAR(painSuppress), (_painSuppress + _painReduce) max 0]; }; _resistance = _target getvariable [QGVAR(peripheralResistance), 100]; @@ -82,6 +82,6 @@ _resistance = _resistance + _viscosityChange; _target setvariable [QGVAR(peripheralResistance), _resistance max 0]; // Call back to ensure that the medication is decreased over time -[_target, _classname, _varName, _maxDose, _timeInSystem, _inCompatableMedication, _viscosityChange] call FUNC(onMedicationUsage); +[_target, _classname, _varName, _maxDose, _timeInSystem, _inCompatableMedication, _viscosityChange, _painReduce] call FUNC(onMedicationUsage); true