mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
Geiger counter GUI release
This commit is contained in:
parent
414013497c
commit
a893e7aa74
@ -423,6 +423,10 @@ switch _slot do {
|
||||
//can't find a way to display it in A3
|
||||
"Use [O] to toggle watch" call epoch_message;
|
||||
};
|
||||
case "ItemGeigerCounter_EPOCH":
|
||||
{
|
||||
call epoch_geiger_show_hide;
|
||||
};
|
||||
case default
|
||||
{
|
||||
//do stuff with radios here
|
||||
|
@ -47,13 +47,6 @@ _playerRadiation = missionNamespace getVariable [_playerRadiationKey, _playerRad
|
||||
if (_playerRadiation > 1) then {
|
||||
_radiationVal = linearConversion [0,100,_playerRadiation,0.1,1,true];
|
||||
[_radiationVal, 2] call epoch_setRadiation;
|
||||
|
||||
// if player has geiger counter make sound based on rads level
|
||||
if ('ItemGeigerCounter_EPOCH' in assignedItems player) then {
|
||||
_level = round(linearConversion [0,100,_radsLevel,0,3,true]);
|
||||
_sound = format ["geiger_%1",_level];
|
||||
playSound _sound;
|
||||
};
|
||||
} else {
|
||||
[0, 2] call epoch_setRadiation;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ 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", 0] > 0};
|
||||
_nearbyRadioactiveObjects = (_powerSources + _nearestLocations) select {(_x getVariable ["EPOCH_Rads", []]) select 0 > 0};
|
||||
|
||||
// check if player is out of map bounds.
|
||||
_radsLevel = 0;
|
||||
@ -20,7 +20,7 @@ if (_outOfBounds) then {
|
||||
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);
|
||||
_radsLevel = ((_radioActiveSite getVariable ["EPOCH_Rads", 0])select 0) / (player distance _radioActiveSite);
|
||||
};
|
||||
};
|
||||
|
||||
|
9
Sources/epoch_code/compile/setup/masterLoop/Event9.sqf
Normal file
9
Sources/epoch_code/compile/setup/masterLoop/Event9.sqf
Normal file
@ -0,0 +1,9 @@
|
||||
if ('ItemGeigerCounter_EPOCH' in assignedItems player) then {
|
||||
if (!EPOCH_geiger_mute_counter || !EPOCH_geiger_mute_warning || EPOCH_geiger_shown) then { //only run if geiger activated
|
||||
_energyRange call epoch_geiger_simulate;
|
||||
};
|
||||
} else {
|
||||
if (EPOCH_geiger_shown) then {
|
||||
call epoch_geiger_show_hide;
|
||||
};
|
||||
};
|
@ -335,8 +335,13 @@ EPOCH_ActiveTraderMission = [];
|
||||
_LastMissionTrigger = 0;
|
||||
|
||||
// setup radio active locations
|
||||
//Commented out by Raymix: Does not set variable on locations for some reason
|
||||
/*
|
||||
{
|
||||
_x params ["_loc", "_rads"];
|
||||
_loc setVariable ["EPOCH_Rads", _rads];
|
||||
_locSize = size _loc;
|
||||
_radius = sqrt((_locSize select 0)^2 + (_locSize select 1)^2);
|
||||
_loc setVariable ["EPOCH_Rads", [_rads,_radius]];
|
||||
} forEach (missionNamespace getVariable ["EPOCH_radioactiveLocations", []]);
|
||||
*/
|
||||
//
|
||||
|
@ -0,0 +1,51 @@
|
||||
disableSerialization;
|
||||
_rads = param [0,0,[0]];
|
||||
_play = {
|
||||
if (!EPOCH_geiger_mute_counter) then {
|
||||
playSound "geiger_epoch_tick";
|
||||
playSound "geiger_epoch_tick"; //makes geiger louder, remove if affects performance
|
||||
};
|
||||
};
|
||||
_lcd = uiNamespace getVariable ["EPOCH_geiger_LCD",controlNull];
|
||||
_led = uiNamespace getVariable ["EPOCH_geiger_LED",controlNull];
|
||||
|
||||
if (_rads >= 10) then {
|
||||
if (!EPOCH_geiger_mute_warning) then {
|
||||
playSound "geiger_epoch_alarm";
|
||||
};
|
||||
[] spawn {
|
||||
disableSerialization;
|
||||
_lcd = uiNamespace getVariable ["EPOCH_geiger_LCD",controlNull];
|
||||
_lcd ctrlSetFade 1;
|
||||
_lcd ctrlCommit 1;
|
||||
uiSleep 1;
|
||||
if (EPOCH_playerEnergy <= 100) then {
|
||||
_lcd ctrlSetFade 1-(EPOCH_playerEnergy / 100);
|
||||
} else {
|
||||
_lcd ctrlSetFade 0;
|
||||
};
|
||||
_lcd ctrlCommit 1;
|
||||
};
|
||||
};
|
||||
|
||||
for "_i" from 1 to (ceil _rads) do {
|
||||
if (!EPOCH_geiger_mute_counter) then {
|
||||
playSound "geiger_epoch_tick";
|
||||
playSound "geiger_epoch_tick"; //makes geiger louder, remove if affects performance
|
||||
};
|
||||
_led ctrlSetText "x\addons\a3_epoch_assets_1\pictures\geiger\geiger_4on";
|
||||
uiSleep (random 0.5);
|
||||
_led ctrlSetText "";
|
||||
};
|
||||
|
||||
if (EPOCH_playerEnergy <= 100) then {
|
||||
_lcd ctrlSetFade 1-(EPOCH_playerEnergy / 100);
|
||||
_lcd ctrlCommit 1;
|
||||
_led ctrlSetFade 1-(EPOCH_playerEnergy / 100);
|
||||
_led ctrlCommit 1;
|
||||
} else {
|
||||
_lcd ctrlSetFade 0;
|
||||
_lcd ctrlCommit 1;
|
||||
_led ctrlSetFade 0;
|
||||
_led ctrlCommit 1;
|
||||
};
|
@ -0,0 +1,44 @@
|
||||
_removeControls = {
|
||||
EPOCH_geiger_shown = false;
|
||||
for "_i" from 1 to 8 do{
|
||||
(["geigerCounter", _i] call epoch_getHUDCtrl) ctrlSetText "";
|
||||
};
|
||||
ctrlDelete (uiNamespace getVariable ["EPOCH_geiger_LCD",controlNull]);
|
||||
ctrlDelete (uiNamespace getVariable ["EPOCH_geiger_LED",controlNull]);
|
||||
};
|
||||
|
||||
if !('ItemGeigerCounter_EPOCH' in assignedItems player) exitWith {call _removeControls; false};
|
||||
|
||||
if (ctrlText(["geigerCounter", 1] call epoch_getHUDCtrl) isEqualTo "") then {
|
||||
EPOCH_geiger_shown = true;
|
||||
|
||||
for "_i" from 1 to 8 do{
|
||||
(["geigerCounter", _i] call epoch_getHUDCtrl) ctrlSetText format ["x\addons\a3_epoch_assets_1\pictures\geiger\geiger_%1",_i];
|
||||
};
|
||||
_ledBG = (["geigerCounter", 4] call epoch_getHUDCtrl);
|
||||
_lcdBG = (["geigerCounter", 5] call epoch_getHUDCtrl);
|
||||
_lcdPos = ctrlPosition _lcdBG;
|
||||
_ledPos = ctrlPosition _ledBG;
|
||||
_parent = ctrlParentControlsGroup _lcdBG;
|
||||
|
||||
_lcdPos set [0,(_lcdPos select 2) / 3.35];
|
||||
_lcdPos set [2,(_lcdPos select 2) * 43 / 100];
|
||||
|
||||
_lcd = (findDisplay 46) ctrlCreate ["rmx_geigerTXT",65765,_parent];
|
||||
_lcd ctrlSetPosition _lcdPos;
|
||||
_lcd ctrlCommit 0;
|
||||
_lcd ctrlSetText ""; //(random 1000 toFixed 1);
|
||||
|
||||
_led = (findDisplay 46) ctrlCreate ["RscPicture",65766,_parent];
|
||||
_led ctrlSetPosition _ledPos;
|
||||
_led ctrlCommit 0;
|
||||
_led ctrlSetText ""; //"x\addons\a3_epoch_assets_1\pictures\geiger\geiger_4on";
|
||||
|
||||
uiNamespace setVariable ["EPOCH_geiger_LCD",_lcd];
|
||||
uiNamespace setVariable ["EPOCH_geiger_LED",_led];
|
||||
|
||||
} else {
|
||||
call _removeControls;
|
||||
};
|
||||
|
||||
true
|
@ -0,0 +1,46 @@
|
||||
disableSerialization;
|
||||
_energyRange = _this;
|
||||
_lcd = uiNamespace getVariable ["EPOCH_geiger_LCD",controlNull];
|
||||
_led = uiNamespace getVariable ["EPOCH_geiger_LED",controlNull];
|
||||
|
||||
_src = nearestObjects[player,["All"],_energyRange];
|
||||
_radObjects = _src select {(_x getVariable ["EPOCH_Rads", []]) select 0 > 0};
|
||||
_rads = 0;
|
||||
{
|
||||
_reldir = player getRelDir _x;
|
||||
|
||||
if (_reldir > 315 || _reldir < 45) then { //only capture 90 degrees in front of player
|
||||
_reldir = if (_reldir > 315) then { 360 - _reldir} else {_reldir}; //convert into 0-45 degrees
|
||||
_prc = 100 - (_reldir / 45 * 100); //current direction percent, 45 = 100%
|
||||
|
||||
_x getVariable "EPOCH_Rads" params ["_str","_intensity"];
|
||||
_dist = player distance _x;
|
||||
_radIntensity = if (_dist <= _intensity) then { //only capture rads when within distance
|
||||
_rds = (_str / _dist);
|
||||
_rdsPrc = (_prc / 100 * _rds);
|
||||
_rdsPrc
|
||||
} else {
|
||||
0
|
||||
};
|
||||
_rads = _rads + _radIntensity
|
||||
};
|
||||
} forEach _radObjects; //sum up radiation of all objects in vicinity and in FOV
|
||||
|
||||
{
|
||||
if ((_x select 0) in EPOCH_nearestLocations) then {
|
||||
_x select 1 params ["_str","_intensity"];
|
||||
_dist = player distance getPos (_x select 0);
|
||||
_radIntensity = if (_dist <= _intensity) then {
|
||||
_str / _dist
|
||||
} else {
|
||||
0
|
||||
};
|
||||
_rads = _rads + _radIntensity;
|
||||
};
|
||||
}foreach EPOCH_radioactiveLocations; //sum up radiation of all radiactive locations in vicinity
|
||||
|
||||
_rads = _rads + EPOCH_ambientRadiation;
|
||||
_lcd ctrlSetText format ["%1r",_rads toFixed 1];
|
||||
_rads spawn epoch_geiger_animate;
|
||||
|
||||
true
|
@ -58,6 +58,13 @@ EPOCH_buildOption = 0;
|
||||
EPOCH_nearestLocations = [];
|
||||
EPOCH_lastFiredLocation = [];
|
||||
|
||||
//Radiation
|
||||
EPOCH_geiger_shown = false;
|
||||
EPOCH_geiger_on = false;
|
||||
EPOCH_geiger_mute_counter = false;
|
||||
EPOCH_geiger_mute_warning = false;
|
||||
EPOCH_ambientRadiation = 0; //TODO: needs to go server side. Adds constant incremental radiation to all players. Use in special events.
|
||||
|
||||
rmx_var_drag_MouseDown = false;
|
||||
rmx_var_dynamicHUD_groups = [];
|
||||
rmx_var_dynamicHUD_groupCTRL = [];
|
||||
|
@ -219,3 +219,46 @@ class veh_RemoveAmmo4
|
||||
icon = "x\addons\a3_epoch_code\Data\UI\buttons\RemoveMag.paa";
|
||||
tooltipcode = "format['Remove %1 from %2',getText(configFile >> 'CfgMagazines' >> (dyna_WeapsMagsTurret select 3 select 1) >> 'displayName'),getText(configFile >> 'CfgWeapons' >> (dyna_WeapsMagsTurret select 3 select 0) >> 'displayName')]";
|
||||
};
|
||||
|
||||
class geiger_menu
|
||||
{
|
||||
condition = "'ItemGeigerCounter_EPOCH' in dyna_assigneditems";
|
||||
icon = "x\addons\a3_epoch_assets_1\pictures\geiger\geiger_radiation.paa";
|
||||
tooltip = "Geiger counter settings";
|
||||
|
||||
class geiger_toggle
|
||||
{
|
||||
condition = "true";
|
||||
action = "call epoch_geiger_show_hide";
|
||||
icon = "x\addons\a3_epoch_assets_1\pictures\geiger\geiger_toggle.paa";
|
||||
tooltip = "Toggle HUD";
|
||||
};
|
||||
class geiger_counter_mute
|
||||
{
|
||||
condition = "!EPOCH_geiger_mute_counter";
|
||||
action = "EPOCH_geiger_mute_counter = !EPOCH_geiger_mute_counter";
|
||||
icon = "x\addons\a3_epoch_assets_1\pictures\geiger\geiger_volumeoff.paa";
|
||||
tooltip = "Mute counter";
|
||||
};
|
||||
class geiger_counter_unmute
|
||||
{
|
||||
condition = "EPOCH_geiger_mute_counter";
|
||||
action = "EPOCH_geiger_mute_counter = !EPOCH_geiger_mute_counter";
|
||||
icon = "x\addons\a3_epoch_assets_1\pictures\geiger\geiger_volumeon.paa";
|
||||
tooltip = "Unmute counter";
|
||||
};
|
||||
class geiger_warning_mute
|
||||
{
|
||||
condition = "!EPOCH_geiger_mute_warning";
|
||||
action = "EPOCH_geiger_mute_warning = !EPOCH_geiger_mute_warning";
|
||||
icon = "x\addons\a3_epoch_assets_1\pictures\geiger\geiger_alarmoff.paa";
|
||||
tooltip = "Mute warnings";
|
||||
};
|
||||
class geiger_warning_unmute
|
||||
{
|
||||
condition = "EPOCH_geiger_mute_warning";
|
||||
action = "EPOCH_geiger_mute_warning = !EPOCH_geiger_mute_warning";
|
||||
icon = "x\addons\a3_epoch_assets_1\pictures\geiger\geiger_alarmon.paa";
|
||||
tooltip = "Unmute warnings";
|
||||
};
|
||||
};
|
||||
|
@ -387,6 +387,12 @@ class CfgClientFunctions
|
||||
class favBar_getGearItem {};
|
||||
class favBar_modifier {};
|
||||
};
|
||||
class geiger {
|
||||
file = "epoch_code\gui\scripts\geiger";
|
||||
class geiger_animate {};
|
||||
class geiger_show_hide {};
|
||||
class geiger_simulate {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -48,6 +48,10 @@ class CfgMasterLoop
|
||||
{
|
||||
delay = 5; //used for FavBar, adjust as required
|
||||
};
|
||||
class Event9
|
||||
{
|
||||
delay = 2; //used for geiger counter UI
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -269,7 +269,9 @@ if !(_radioactiveLocations isEqualTo []) then {
|
||||
if (_locations isEqualTo []) exitWith {};
|
||||
private _selectedLoc = selectRandom _locations;
|
||||
_locations = _locations - [_selectedLoc];
|
||||
_radioactiveLocationsTmp pushBack [_selectedLoc,random 666];
|
||||
_locSize = size _selectedLoc;
|
||||
_radius = sqrt((_locSize select 0)^2 + (_locSize select 1)^2);
|
||||
_radioactiveLocationsTmp pushBack [_selectedLoc,[random 666,_radius]];
|
||||
private _position = locationPosition _selectedLoc;
|
||||
_markers = ["Radiation", _position] call EPOCH_server_createGlobalMarkerSet;
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ if ((count _position) == 2) then{
|
||||
};
|
||||
|
||||
// set rads
|
||||
_satellite setVariable ["EPOCH_Rads", 10, true];
|
||||
_satellite setVariable ["EPOCH_Rads", [30,50], true]; //30 rads within 50 meters
|
||||
|
||||
if (EPOCH_showSatellites) then{
|
||||
_markers = ["Satellite",_position] call EPOCH_server_createGlobalMarkerSet;
|
||||
|
Loading…
Reference in New Issue
Block a user