From 9945f9246effa20295c5742f4a8c779071b7fc3a Mon Sep 17 00:00:00 2001 From: He-Man Date: Wed, 18 Apr 2018 19:41:16 +0200 Subject: [PATCH] Energy Tweaks Added some missing and new configs to CfgEpochClient Added Energy settings for default map sources to CfgBaseBuilding Included wind / overcast / distance to energy calculations (depents on powertype) - Solars are affected by SunOrMoon and overcast - Windmills are affected by wind - Satellites are affected by distance --- .../compile/setup/masterLoop/Event2.sqf | 2 +- .../compile/setup/masterLoop/Event5.sqf | 31 ++++++++++--------- .../compile/setup/masterLoop/init.sqf | 2 ++ .../epoch_config/Configs/CfgBaseBuilding.hpp | 19 ++++++++++++ .../epoch_config/Configs/CfgEpochClient.hpp | 13 ++++++++ 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf b/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf index 750d4d9f..edd41f90 100644 --- a/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf +++ b/Sources/epoch_code/compile/setup/masterLoop/Event2.sqf @@ -21,7 +21,7 @@ _energyValue = _chargeRate min _energyRegenMax; _vehicle = vehicle player; if (_vehicle != player && isEngineOn _vehicle) then { if !(_vehicle iskindof "Bicycle") then { - _energyValue = _energyValue + 5; + _energyValue = _energyValue + _energyRegenInVeh; }; }; if (currentVisionMode player == 1) then { //NV enabled diff --git a/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf b/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf index 4d25cee9..ef66bab5 100644 --- a/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf +++ b/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf @@ -2,7 +2,7 @@ _position = getPosATL player; _nearestLocations = nearestLocations[player, _radioactiveLocations, 300]; 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]; +_powerSources = nearestObjects[player, _energyPowerSources, _energyRange]; // TODO: add more sources and config based check instead of global var // _nearestLocations removed as they don't support getVariable @@ -109,25 +109,26 @@ _chargeRate = 0; if !(_powerSources isEqualTo[]) then { _totalCapacity = 0; { - _powerClass = typeOf _x; - _powerCap = getNumber(_cfgBaseBuilding >> _powerClass >> "powerCapacity"); - _powerType = getNumber(_cfgBaseBuilding >> _powerClass >> "powerType"); - if (_powerCap == 0) then { - _powerCap = 100; - }; - if (_powerType == 1) then { - if (sunOrMoon < 1) then { - _powerCap = _powerCap/2; - }; - }; - _totalCapacity = _totalCapacity + _powerCap; + _powerClass = typeOf _x; + _powerCap = getNumber(_cfgBaseBuilding >> _powerClass >> "powerCapacity"); + _powerType = getNumber(_cfgBaseBuilding >> _powerClass >> "powerType"); + if (_powerCap == 0) then { + _powerCap = 100; + }; + _powerCap = switch _powerType do { + case 1: {if (sunOrMoon == 1) then {_powerCap * (1-overcast)} else {(_powerCap * (1 - overcast))/2}}; + case 2: {_powerCap * windstr}; + case 3: {_powerCap * (1 - ((player distance _x) / _energyRange))}; + default {_powerCap}; + }; + _totalCapacity = _totalCapacity + _powerCap; } forEach _powerSources; if (_totalCapacity > 0) then { _players = player nearEntities[["Epoch_Male_F", "Epoch_Female_F"], _energyRange]; if (_players isEqualTo []) then { - _chargeRate = ceil _totalCapacity; + _chargeRate = round _totalCapacity; } else { - _chargeRate = ceil (_totalCapacity / (count _players)); + _chargeRate = round (_totalCapacity / (count _players)); }; }; }; diff --git a/Sources/epoch_code/compile/setup/masterLoop/init.sqf b/Sources/epoch_code/compile/setup/masterLoop/init.sqf index 90681e6b..8a0d69ea 100644 --- a/Sources/epoch_code/compile/setup/masterLoop/init.sqf +++ b/Sources/epoch_code/compile/setup/masterLoop/init.sqf @@ -125,6 +125,8 @@ _baseThirstLoss = ["CfgEpochClient", "baseThirstLoss", 2] call EPOCH_fnc_returnC _baseAlcoholLoss = ["CfgEpochClient", "baseAlcoholLoss", 0.17] call EPOCH_fnc_returnConfigEntryV2; _lossMultiplier = if (["CfgEpochClient", "accelerateHTALoss", true] call EPOCH_fnc_returnConfigEntryV2) then {timeMultiplier} else {1}; _energyCostNV = ["CfgEpochClient", "energyCostNV", 3] call EPOCH_fnc_returnConfigEntryV2; +_energyPowerSources = ["CfgEpochClient", "energyPowerSources", ["Land_spp_Tower_F","Land_wpp_Turbine_V2_F","Land_wpp_Turbine_V1_F","SolarGen_EPOCH","Land_Wreck_Satellite_EPOCH"]] call EPOCH_fnc_returnConfigEntryV2; +_energyRegenInVeh = ["CfgEpochClient", "energyChargeInVeh", 5] call EPOCH_fnc_returnConfigEntryV2; _energyRegenMax = ["CfgEpochClient", "energyRegenMax", 5] call EPOCH_fnc_returnConfigEntryV2; _energyRange = ["CfgEpochClient", "energyRange", 75] call EPOCH_fnc_returnConfigEntryV2; _hudConfigs = ["CfgEpochClient", "hudConfigs", []] call EPOCH_fnc_returnConfigEntryV2; diff --git a/Sources/epoch_config/Configs/CfgBaseBuilding.hpp b/Sources/epoch_config/Configs/CfgBaseBuilding.hpp index 51c722bd..655e2ea9 100644 --- a/Sources/epoch_config/Configs/CfgBaseBuilding.hpp +++ b/Sources/epoch_config/Configs/CfgBaseBuilding.hpp @@ -8,6 +8,25 @@ */ class CfgBaseBuilding { +// Power Sources (only for Energy Calculations) + class Land_spp_Tower_F + { + powerCapacity = 10; + powerType = 1; // Solar + }; + class Land_wpp_Turbine_V1_F + { + powerCapacity = 10; + powerType = 2; // Wind + }; + class Land_wpp_Turbine_V2_F : Land_wpp_Turbine_V1_F {}; + class Land_Wreck_Satellite_EPOCH + { + powerCapacity = 10; + powerType = 3; // Satellite + }; + +// BaseBuilding class Default { upgradeBuilding[] = {}; diff --git a/Sources/epoch_config/Configs/CfgEpochClient.hpp b/Sources/epoch_config/Configs/CfgEpochClient.hpp index b2ac7d85..5adcf467 100644 --- a/Sources/epoch_config/Configs/CfgEpochClient.hpp +++ b/Sources/epoch_config/Configs/CfgEpochClient.hpp @@ -195,6 +195,19 @@ class CfgEpochClient playerDeathMarkerGPSOnly = 1; // Map marker toggle in map dyna menu on death with assigned GPS only mapOnZoomSetMarkerSize = 1; // When in map markers will change to larger size as player zooms in bankTransferTime[] = {0.0006,1.2,0.06}; + + // Player (Building) Energy + energyPowerSources[] = { // Add PowerCapacity and PowerType in CfgBaseBuilding, if you add something here! + "Land_spp_Tower_F", + "Land_wpp_Turbine_V2_F", + "Land_wpp_Turbine_V1_F", + "SolarGen_EPOCH", + "Land_Wreck_Satellite_EPOCH" + }; + energyRange = 75; // Range to check for energy sources + energyRegenMax = 5; // Max energy increase value (every 10 seconds) + energyCostNV = 3; // Energy loss value by using nightvision (every 10 seconds) + energyRegenInVeh = 5; // Energy increase value in Vehicles with Engine On (every 10 seconds) // Favorite Bar Fav_enableFavoriteBar = "true"; // If disabled, players will not be able to use favorite bar