Epoch/Sources/epoch_code/compile/setup/masterLoop/Event5.sqf

143 lines
5.2 KiB
Plaintext
Raw Normal View History

2015-11-08 15:26:38 +00:00
_position = getPosATL player;
2017-10-22 16:18:52 +00:00
_nearestLocations = nearestLocations[player, _radioactiveLocations, 300];
2017-10-01 23:18:38 +00:00
EPOCH_nearestLocations = _nearestLocations;
_powerSources = nearestObjects[player, _energyPowerSources, _energyRange];
// TODO: add more sources and config based check instead of global var
2017-10-22 16:15:58 +00:00
// _nearestLocations removed as they don't support getVariable
// All sources used as a temp solution, please re-use as much as you can.
2017-10-23 06:31:39 +00:00
_allSources = nearestObjects[player, ["All"], _radiatedObjMaxRange];
2017-10-22 16:15:58 +00:00
_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 ]);
2017-10-22 16:15:58 +00:00
{
_location = [];
_LocName = (_x select 0) joinString " ";
{
if( (str _x) == _LocName ) exitwith { _location = _x; };
} foreach _nearestLocations;
if !(_location isEqualTo []) then {
2017-10-22 16:15:58 +00:00
_x select 1 params ["_str","_intensity"];
_dist = player distance getPos _location;
2017-10-22 16:15:58 +00:00
_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;
_radsLevel = _outOfBoundsRadiation;
} else {
// radiated objects or locations nearby
if !(_nearbyRadioactiveObjects isEqualTo []) then {
2017-10-22 16:15:58 +00:00
{
_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;
};
};
2017-10-22 16:15:58 +00:00
//Reduce radiation by 90%
if ("radiation_mask_epoch" in assignedItems player) then {
_radsLevel = _radsLevel - (90 / 100 * _radsLevel);
2017-10-22 16:15:58 +00:00
};
//Reduce radiation by 50% for respirators (easy to find loot in construction sites?)
if ("respirator_placeholder" in assignedItems player) then {
_radsLevel = _radsLevel / 2;
2017-10-22 16:15:58 +00:00
};
2017-10-22 17:49:47 +00:00
//Reduce % radiation from max armor value possible
_maxArmor = (missionNamespace getVariable ["EPOCH_MAX_ARMOR",[0,0,0,2300]]) select 3;
_currentArmor = ((uniform player) call EPOCH_uniformArmorCalc) + ((vest player) call EPOCH_gearArmorCalc) + ((headgear player) call EPOCH_gearArmorCalc);
_currentArmorPercent = 100 - (_currentArmor / _maxArmor * 100);
_radsLevel = _currentArmorPercent / 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 in ["Epoch_RadiationSuit_F","Epoch_RadiationSuit_M"]) then {
_radsLevel = 0;
};
2017-10-22 16:15:58 +00:00
// Radiation Handler
_playerRadiation = missionNamespace getVariable [_playerRadiationKey, _playerRadiationDefault];
_playerImmunity = missionNamespace getVariable [_playerImmunityKey, _playerImmunityDefault];
2017-10-22 16:15:58 +00:00
if (_radsLevel > 0) then { // increase rads based on radiation levels
_playerRadiation = [_playerRadiationKey,_radsLevel,_playerRadiationMax,_playerRadiationMin] call EPOCH_fnc_setVariableLimited;
} else { //Decrease rad level, but at a cost of immunity loss
if (_playerRadiation > 0) then {
_playerRadiation = [_playerRadiationKey,(_baseRadiationLoss * _playerImmunity / 100),_playerRadiationMax,_playerRadiationMin] call EPOCH_fnc_setVariableLimited;
_playerImmunity = [_playerImmunityKey,_baseRadiationLossImmunityPenalty,_playerImmunityMax,_playerImmunityMin] call EPOCH_fnc_setVariableLimited;
};
};
2015-11-08 15:26:38 +00:00
if !(surfaceIsWater _position) then {
2017-10-01 23:18:38 +00:00
if (_nearestLocations isEqualTo []) then{
if (count(player nearEntities["Animal_Base_F", 800]) < 2) then {
2015-11-08 15:26:38 +00:00
call EPOCH_client_loadAnimalBrain;
};
};
} else {
// spawn shark if player is deep water and not in vehicle
if !(_isOnFoot) then{
2015-11-08 15:26:38 +00:00
_offsetZ = ((_position vectorDiff getPosASL player) select 2);
if (_offsetZ > 50) then {
["GreatWhite_F", player, true] call EPOCH_unitSpawn;
2015-11-08 15:26:38 +00:00
};
};
};
// default power state
_chargeRate = 0;
2015-11-08 15:26:38 +00:00
// energy Charge from nearby power plants
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;
};
_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;
2015-11-08 15:26:38 +00:00
} forEach _powerSources;
if (_totalCapacity > 0) then {
_players = player nearEntities[["Epoch_Male_F", "Epoch_Female_F"], _energyRange];
if (_players isEqualTo []) then {
_chargeRate = round _totalCapacity;
2015-11-08 15:26:38 +00:00
} else {
_chargeRate = round (_totalCapacity / (count _players));
2015-11-08 15:26:38 +00:00
};
};
};
2017-09-27 13:58:36 +00:00
// alive time handler
2017-09-05 21:28:07 +00:00
_playerAliveTime = round(_playerAliveTime + (_tickTime - _clientAliveTimer));
2017-09-27 13:58:36 +00:00
missionNamespace setVariable [_playerAliveTimeKey, _playerAliveTime];
2017-09-05 21:28:07 +00:00
_clientAliveTimer = _tickTime;
// force update after 60 seconds
_forceUpdate = true;