mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
move save stats to master loop and basic radiation system
This commit is contained in:
parent
fcbdd594ae
commit
c76b2badf9
@ -76,4 +76,4 @@ if !(alive player && alive _playerObject && !isPlayer _playerObject) then {
|
||||
deleteVehicle _playerObject;
|
||||
};
|
||||
|
||||
true call EPOCH_pushCustomVar;
|
||||
EPOCH_forceUpdateNow = true;
|
||||
|
@ -1,5 +1,4 @@
|
||||
// init
|
||||
_forceUpdate = false;
|
||||
_forceBloodRise = false;
|
||||
_forceFatigue = false;
|
||||
_allowBloodDrop = false;
|
||||
@ -150,10 +149,7 @@ if (_forceStaminaDrop) then {
|
||||
};
|
||||
};
|
||||
|
||||
// force update
|
||||
if (_forceUpdate) then {
|
||||
true call EPOCH_pushCustomVar;
|
||||
};
|
||||
|
||||
|
||||
// ~ debug
|
||||
if (EPOCH_debugMode) then {
|
||||
@ -273,3 +269,12 @@ if !(EPOCH_ActiveTraderMission isequalto []) then {
|
||||
};
|
||||
} foreach _taskDialogues;
|
||||
};
|
||||
|
||||
// Update read only vars
|
||||
EPOCH_playerRadiation = _playerRadiation;
|
||||
|
||||
// force update
|
||||
if (EPOCH_forceUpdateNow) then {
|
||||
EPOCH_forceUpdateNow = false;
|
||||
call _fnc_forceUpdate;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ if !(EPOCH_arr_interactedObjs isEqualTo[]) then {
|
||||
|
||||
if (damage player != _damagePlayer) then {
|
||||
if (alive player) then {
|
||||
true call EPOCH_pushCustomVar;
|
||||
_forceUpdate = true;
|
||||
_damagePlayer = damage player;
|
||||
};
|
||||
};
|
||||
@ -33,16 +33,23 @@ if (currentVisionMode player == 1) then { //NV enabled
|
||||
|
||||
// Sets visual effect
|
||||
if (EPOCH_playerAlcohol > 20) then {
|
||||
_drunkVal = linearConversion [0,100,EPOCH_playerAlcohol,0.1,1,true];
|
||||
[(round(_drunkVal * 10)/10), 2] call epoch_setDrunk;
|
||||
_drunkVal = (linearConversion [0,100,EPOCH_playerAlcohol,0.1,1,true]) toFixed 2;
|
||||
[_drunkVal, 2] call epoch_setDrunk;
|
||||
} else {
|
||||
[0, 2] call epoch_setDrunk;
|
||||
};
|
||||
|
||||
// Sets visual effect
|
||||
if (_playerRadiation > 1) then {
|
||||
_radiationVal = linearConversion [0,100,_playerRadiation,0.1,1,true];
|
||||
[(round(_radiationVal * 10)/10), 2] call epoch_setRadiation;
|
||||
_radiationVal = (linearConversion [0,100,_playerRadiation,0.1,1,true]) toFixed 2;
|
||||
[_radiationVal, 2] call epoch_setRadiation;
|
||||
|
||||
// if player has geiger counter make sound based on rads level
|
||||
if ('GeigerCounter' in assignedItems player) then { // TODO change classname to match
|
||||
_level = round(linearConversion [0,100,_radsLevel,0,3,true]);
|
||||
_sound = format ["geiger_%1",_level];
|
||||
playSound _sound;
|
||||
};
|
||||
} else {
|
||||
[0, 2] call epoch_setRadiation;
|
||||
};
|
||||
|
@ -1,5 +1,11 @@
|
||||
// runs every 15 seconds
|
||||
if !(_prevEquippedItem isEqualTo EPOCH_equippedItem_PVS) then {
|
||||
_EPOCH_15 = _tickTime;
|
||||
_prevEquippedItem = EPOCH_equippedItem_PVS;
|
||||
EPOCH_equippedItem_PVS remoteExec ["EPOCH_server_equippedItem",2];
|
||||
};
|
||||
// force update
|
||||
if (_forceUpdate || EPOCH_forceUpdate) then {
|
||||
_forceUpdate = false;
|
||||
EPOCH_forceUpdate = false;
|
||||
call _fnc_forceUpdate;
|
||||
};
|
||||
|
@ -1,18 +1,38 @@
|
||||
_position = getPosATL player;
|
||||
|
||||
EPOCH_nearestLocations = nearestLocations[player, ["NameCityCapital", "NameCity", "Airport"], 300];
|
||||
_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 + EPOCH_nearestLocations) select {_x getVariable ["EPOCH_Rads", 0] > 0};
|
||||
|
||||
// check if player is out of map bounds.
|
||||
_worldSize = worldSize/2;
|
||||
_outOfBounds = !(player inArea [[_worldSize,_worldSize,0], _worldSize, _worldSize, 0, true ]);
|
||||
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;
|
||||
|
||||
_radsLevel = _backgroundRadiation;
|
||||
_playerRadiation = ((_playerRadiation + _radsLevel) min 100) max 0;
|
||||
} else {
|
||||
// do in bounds radiation checks here.
|
||||
|
||||
// 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]) / (player distance _radioActiveSite);
|
||||
_playerRadiation = ((_playerRadiation + _radsLevel) min 100) max 0;
|
||||
} else {
|
||||
// handle reduction of rads in master loop
|
||||
_anitRadiation = player getVariable ["EPOCH_antiRadiation", 0];
|
||||
if (_anitRadiation > 0) then {
|
||||
// lower radiation by 0.1 per tick
|
||||
_playerRadiation = ((_playerRadiation - 0.1) min 100) max 0;
|
||||
// lower anti rad level
|
||||
player setVariable ["EPOCH_antiRadiation", _anitRadiation - 1];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
EPOCH_nearestLocations = nearestLocations[player, ["NameCityCapital", "NameCity", "Airport"], 300];
|
||||
|
||||
EPOCH_playerIsSwimming = false;
|
||||
|
||||
if !(surfaceIsWater _position) then {
|
||||
@ -37,7 +57,6 @@ EPOCH_nearPower = false;
|
||||
EPOCH_chargeRate = 0;
|
||||
|
||||
// energy Charge from nearby power plants
|
||||
_powerSources = nearestObjects[player, ["Land_spp_Tower_F","Land_wpp_Turbine_V2_F","Land_wpp_Turbine_V1_F","SolarGen_EPOCH"], _energyRange];
|
||||
if !(_powerSources isEqualTo[]) then {
|
||||
_totalCapacity = 0;
|
||||
{
|
||||
@ -69,3 +88,6 @@ EPOCH_playerAlcohol = ((EPOCH_playerAlcohol - 1) min 100) max 0;
|
||||
|
||||
EPOCH_playerAliveTime = round(EPOCH_playerAliveTime + (_tickTime - EPOCH_clientAliveTimer));
|
||||
EPOCH_clientAliveTimer = _tickTime;
|
||||
|
||||
// force update after 60 seconds
|
||||
_forceUpdate = true;
|
||||
|
@ -1,5 +1,3 @@
|
||||
false call EPOCH_pushCustomVar;
|
||||
|
||||
_spawnChance = ((EPOCH_playerNuisance + EPOCH_playerSoiled)/2) max 1;
|
||||
// add more antagonist spawn chances
|
||||
if (random _antagonistRndChance < _spawnChance) then {
|
||||
|
@ -1,2 +1,2 @@
|
||||
//Updates favorites bar
|
||||
call epoch_favBar_refresh;
|
||||
call epoch_favBar_refresh;
|
||||
|
@ -1,29 +1,60 @@
|
||||
// make sure we wait for Display #46
|
||||
waitUntil {!(isNull (findDisplay 46))};
|
||||
|
||||
// force update within 15 seconds
|
||||
EPOCH_forceUpdate = false;
|
||||
_forceUpdate = false;
|
||||
// force update within 1 second
|
||||
EPOCH_forceUpdateNow = false;
|
||||
|
||||
// init local player stat vars
|
||||
_playerRadiation = EPOCH_playerRadiation;
|
||||
|
||||
// inline function to sync player stats to server
|
||||
_fnc_forceUpdate = {
|
||||
private _customVars = [];
|
||||
{
|
||||
// use local var from inside master loop
|
||||
switch (_x) do {
|
||||
case ("Radiation"): {
|
||||
_customVars pushBack _playerRadiation;
|
||||
};
|
||||
default {
|
||||
_customVars pushBack (missionNamespace getVariable format["EPOCH_player%1",_x]);
|
||||
};
|
||||
};
|
||||
} forEach (missionNamespace getVariable["EPOCH_customVars", []]);
|
||||
[player,_customVars,missionNamespace getVariable "Epoch_personalToken"] remoteExec ["EPOCH_fnc_savePlayer",2];
|
||||
};
|
||||
|
||||
// disable fuel sources client side.
|
||||
{_x setFuelCargo 0;} foreach (missionNamespace getVariable ["EPOCH_staticFuelSources", []]);
|
||||
|
||||
// setup display EH's
|
||||
if (isNil "EPOCH_display_setup_complete") then {
|
||||
EPOCH_display_setup_complete = true;
|
||||
{
|
||||
(findDisplay 46) displayAddEventHandler [_x,(["CfgEpochClient", _x, ""] call EPOCH_fnc_returnConfigEntryV2)];
|
||||
} forEach (["CfgEpochClient", "displayAddEventHandler", []] call EPOCH_fnc_returnConfigEntryV2);
|
||||
// reset anim state
|
||||
player switchMove "";
|
||||
// setup Epoch Hud
|
||||
call epoch_dynamicHUD_start;
|
||||
EPOCH_display_setup_complete = true;
|
||||
{
|
||||
(findDisplay 46) displayAddEventHandler [_x,(["CfgEpochClient", _x, ""] call EPOCH_fnc_returnConfigEntryV2)];
|
||||
} forEach (["CfgEpochClient", "displayAddEventHandler", []] call EPOCH_fnc_returnConfigEntryV2);
|
||||
// reset anim state
|
||||
player switchMove "";
|
||||
// setup Epoch Hud
|
||||
call epoch_dynamicHUD_start;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Background radiation
|
||||
_backgroundRadiation = ["CfgEpochClient", "backgroundRadiation", 10] call EPOCH_fnc_returnConfigEntryV2;
|
||||
_radsLevel = 0;
|
||||
|
||||
_prevEquippedItem = [];
|
||||
_damagePlayer = damage player;
|
||||
_isOnFoot = isNull objectParent player;
|
||||
_panic = false;
|
||||
_prevEnergy = EPOCH_playerEnergy;
|
||||
|
||||
|
||||
// init config data
|
||||
_antagonistRndChance = ["CfgEpochClient", "antagonistRngChance", 100] call EPOCH_fnc_returnConfigEntryV2;
|
||||
|
||||
@ -50,13 +81,13 @@ _antagonistChances = ["CfgEpochClient", "antagonistChances", _antagonistChanceDe
|
||||
|
||||
|
||||
// Init antagonist spawn limits
|
||||
EPOCH_spawnIndex = [];
|
||||
EPOCH_spawnLimits = [];
|
||||
_spawnIndex = [];
|
||||
_spawnLimits = [];
|
||||
_antagonistSpawnDefaults = [
|
||||
["Epoch_Cloak_F", 1],
|
||||
["GreatWhite_F", 2],
|
||||
["Epoch_Sapper_F",2],
|
||||
["Epoch_SapperG_F",1],
|
||||
["Epoch_SapperG_F",1],
|
||||
["Epoch_SapperB_F",1],
|
||||
["I_UAV_01_F",2],
|
||||
["PHANTOM",1],
|
||||
@ -69,19 +100,29 @@ _spawnLimits = ["CfgEpochClient", "antagonistSpawnIndex", _antagonistSpawnDefaul
|
||||
_x params ["_spawnName","_spawnLimit"];
|
||||
if (_spawnName isEqualTo "EPOCH_RyanZombie_1") then {
|
||||
if (EPOCH_mod_Ryanzombies_Enabled) then {
|
||||
EPOCH_spawnIndex pushBack _spawnName;
|
||||
EPOCH_spawnLimits pushBack _spawnLimit;
|
||||
_spawnIndex pushBack _spawnName;
|
||||
_spawnLimits pushBack _spawnLimit;
|
||||
};
|
||||
} else {
|
||||
EPOCH_spawnIndex pushBack _spawnName;
|
||||
EPOCH_spawnLimits pushBack _spawnLimit;
|
||||
_spawnIndex pushBack _spawnName;
|
||||
_spawnLimits pushBack _spawnLimit;
|
||||
};
|
||||
} forEach _spawnLimits;
|
||||
|
||||
EPOCH_spawnIndex = _spawnIndex;
|
||||
EPOCH_spawnLimits = _spawnLimits;
|
||||
|
||||
//
|
||||
_customVars = [];
|
||||
{
|
||||
_customVars pushBack (missionNamespace getVariable format["EPOCH_player%1",_x]);
|
||||
} forEach (missionNamespace getVariable["EPOCH_customVars", []]);
|
||||
_prevCustomVars = _customVars;
|
||||
|
||||
// default data if mismatch
|
||||
if !(EPOCH_playerSpawnArray isEqualTypeParams EPOCH_spawnIndex) then{
|
||||
if !(EPOCH_playerSpawnArray isEqualTypeParams _spawnIndex) then{
|
||||
EPOCH_playerSpawnArray = [];
|
||||
{ EPOCH_playerSpawnArray pushBack 0 } forEach EPOCH_spawnIndex;
|
||||
{ EPOCH_playerSpawnArray pushBack 0 } forEach _spawnIndex;
|
||||
};
|
||||
|
||||
// find radio
|
||||
|
@ -68,18 +68,14 @@ _respawnButton ctrlEnable false;
|
||||
[_display] spawn {
|
||||
disableSerialization;
|
||||
params ["_display"];
|
||||
with missionNamespace do {
|
||||
false call EPOCH_pushCustomVar;
|
||||
};
|
||||
EPOCH_forceUpdate = true;
|
||||
_startTime = diag_tickTime+5;
|
||||
waitUntil {
|
||||
uiSleep 0.2;
|
||||
(isNull _display) || ((_startTime - diag_tickTime) <= 0)
|
||||
};
|
||||
if (!isNull _display) then {
|
||||
with missionNamespace do {
|
||||
true call EPOCH_pushCustomVar;
|
||||
};
|
||||
EPOCH_forceUpdate = true;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,9 @@ if ((count _position) == 2) then{
|
||||
|
||||
_item = createVehicle[(selectRandom _satellites), _position, [], 0.0, "CAN_COLLIDE"];
|
||||
|
||||
// set rads
|
||||
_item setVariable ["EPOCH_Rads", 100, true];
|
||||
|
||||
if (EPOCH_showSatellites) then{
|
||||
_marker = createMarker[str(_position), _position];
|
||||
_marker setMarkerShape "ICON";
|
||||
|
Loading…
Reference in New Issue
Block a user