From e996d786955513f7d998c7082108a5d3a398583c Mon Sep 17 00:00:00 2001 From: Raymix Date: Sun, 22 Oct 2017 17:15:58 +0100 Subject: [PATCH] Radioactive sickness calc --- .../compile/setup/masterLoop/Event2.sqf | 10 +--- .../compile/setup/masterLoop/Event5.sqf | 56 +++++++++++++++++-- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf b/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf index 8412b208..7cdc8758 100644 --- a/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf +++ b/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf @@ -45,8 +45,9 @@ if (_playerAlcohol > 20) then { // Sets visual effect _playerRadiation = missionNamespace getVariable [_playerRadiationKey, _playerRadiationDefault]; if (_playerRadiation > 1) then { - _radiationVal = linearConversion [0,100,_playerRadiation,0.1,1,true]; - [_radiationVal, 2] call epoch_setRadiation; + _radiationVal = linearConversion [0,100,_playerRadiation,1,10,true]; + [(ceil _radiationVal)/10, 2] call epoch_setRadiation; + diag_log ((ceil _radiationVal)/10); } else { [0, 2] call epoch_setRadiation; }; @@ -192,11 +193,6 @@ _playerThirst = [_playerThirstKey,-_thirstlossRate,_playerThirstMax,_playerThirs // Nuisance Handler _playerNuisance = [_playerNuisanceKey,-1,_playerNuisanceMax,_playerNuisanceMin] call EPOCH_fnc_setVariableLimited; -// Radiation Handler -if (_radsLevel > 0) then { - // increase rads based on radiation levels - _playerRadiation = [_playerRadiationKey,_radsLevel,_playerRadiationMax,_playerRadiationMin] call EPOCH_fnc_setVariableLimited; -}; // calculate max stamina EPOCH_playerStaminaMax = (100 * (round(_playerAliveTime/360)/10)) min 2500; diff --git a/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf b/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf index 8368c3ea..9edab396 100644 --- a/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf +++ b/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf @@ -5,12 +5,29 @@ EPOCH_nearestLocations = _nearestLocations; _powerSources = nearestObjects[player, ["Land_spp_Tower_F","Land_wpp_Turbine_V2_F","Land_wpp_Turbine_V1_F","SolarGen_EPOCH","Land_Wreck_Satellite_EPOCH"], _energyRange]; // TODO: add more sources and config based check instead of global var -_nearbyRadioactiveObjects = (_powerSources + _nearestLocations) select {(_x getVariable ["EPOCH_Rads", []]) select 0 > 0}; +// _nearestLocations removed as they don't support getVariable +// All sources used as a temp solution +_allSources = nearestObjects[player, ["All"], _energyRange]; +_nearbyRadioactiveObjects = _allSources select {(_x getVariable ["EPOCH_Rads", []]) select 0 > 0}; // check if player is out of map bounds. _radsLevel = 0; _worldSize = worldSize/2; _outOfBounds = !(player inArea [[_worldSize,_worldSize,0], _worldSize, _worldSize, 0, true ]); + +{ + if ((_x select 0) in _nearestLocations) then { + _x select 1 params ["_str","_intensity"]; + _dist = player distance getPos (_x select 0); + _radIntensity = if (_dist <= _intensity) then { + _str / _dist + } else { + 0 + }; + _radsLevel = _radsLevel + _radIntensity; + }; +}foreach EPOCH_radioactiveLocations; + if (_outOfBounds) then { // player is out of map bounds, give ten times background rads ["You are out of the play area!", 5] call Epoch_message; @@ -18,12 +35,43 @@ if (_outOfBounds) then { } else { // radiated objects or locations nearby if !(_nearbyRadioactiveObjects isEqualTo []) then { - // add extra rads based on intensity and distance from site. - _radioActiveSite = _nearbyRadioactiveObjects select 0; - _radsLevel = ((_radioActiveSite getVariable ["EPOCH_Rads", 0])select 0) / (player distance _radioActiveSite); + { + _x getVariable "EPOCH_Rads" params ["_str","_intensity"]; + _dist = player distance _x; + _radIntensity = if (_dist <= _intensity) then { + _str / _dist + } else { + 0 + }; + _radsLevel = _radsLevel + _radIntensity; + }forEach _nearbyRadioactiveObjects; }; }; +//Reduce % radiation from max armor value possible +_maxArmor = (missionNamespace getVariable ["EPOCH_MAX_ARMOR",[0,0,0,2300]]) select 3; +_currentArmorPercent = (((uniform player) call EPOCH_uniformArmorCalc) + ((vest player) call EPOCH_gearArmorCalc) + ((headgear player) call EPOCH_gearArmorCalc)) / _maxArmor * 100; +_radsLevel = _currentArmorPercent / 100 * _radsLevel; + +//Reduce radiation by 50% for respirators (easy to find loot in construction sites?) +if ("respirator_placeholder" in assignedItems player) then { + _radsLevel = _radsLevel / 2; +}; +//Reduce radiation by 90% +if ("radiation_mask_epoch" in assignedItems player) then { + _radsLevel = 90 / 100 * _radsLevel; +}; +//Reduce radiation by 100% TODO: move this to top, no point in doing all this calc if hazmat is on. +if (uniform player == "hazmat_placeholder") then { + _radsLevel = 0; +}; + +// Radiation Handler +if (_radsLevel > 0) then { + // increase rads based on radiation levels + _playerRadiation = [_playerRadiationKey,_radsLevel,_playerRadiationMax,_playerRadiationMin] call EPOCH_fnc_setVariableLimited; +}; + if !(surfaceIsWater _position) then { if (_nearestLocations isEqualTo []) then{ if (count(player nearEntities["Animal_Base_F", 800]) < 2) then {