Added pain suppression instead of removal

This commit is contained in:
Glowbal 2015-05-16 16:09:30 +02:00 committed by KoffeinFlummi
parent 429c85c9f1
commit 2b1468db24
7 changed files with 22 additions and 15 deletions

View File

@ -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);

View File

@ -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);
};

View File

@ -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];
};

View File

@ -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), []];

View File

@ -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;

View File

@ -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), []];

View File

@ -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