From beeef83112bc9ecdf9ac65542c21ceeafb1c38d4 Mon Sep 17 00:00:00 2001 From: McDiod Date: Sun, 23 Jun 2019 18:22:01 +0200 Subject: [PATCH 1/4] linearSD: block teleport if not in any sector --- functions/linearSD/fn_addTeleportAction.sqf | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/functions/linearSD/fn_addTeleportAction.sqf b/functions/linearSD/fn_addTeleportAction.sqf index 89e451c..8c851d3 100644 --- a/functions/linearSD/fn_addTeleportAction.sqf +++ b/functions/linearSD/fn_addTeleportAction.sqf @@ -12,7 +12,10 @@ private _insertChildrenFunc = { "", // action { - params ["_unit","",["_sector",objNull]]; + params ["_unit","","_args"]; + _args params [["_sectors",[]],["_sectorID",0]]; + + private _sector = _sectors param [_sectorID,objNull]; if (isNull _sector) exitWith {systemChat "ERROR: Sector unknown."}; _pos = _sector getVariable [QGVAR(respawnPosition),(getPos _sector) findEmptyPosition [0,100,"B_Soldier_F"]]; @@ -21,11 +24,19 @@ private _insertChildrenFunc = { }, // condition { - params ["_unit","",["_sector",objNull]]; - !(_unit inArea _sector) + params ["_unit","","_args"]; + _args params [["_sectors",[]],["_sectorID",0]]; + + private _sector = _sectors param [_sectorID,objNull]; + + // don't allow teleport to current sector + !(_unit inArea _sector) && + + // don't allow teleport from outside a sector + {_unit inArea _x} count _sectors > 0 }, {}, - _x + [_sectors,_forEachIndex] ] call ace_interact_menu_fnc_createAction; _actions pushBack [_action,[],_target]; } forEach _sectors; From f04130fa1f2a190b301a66e4bb8f243695728f93 Mon Sep 17 00:00:00 2001 From: McDiod Date: Sun, 23 Jun 2019 20:19:35 +0200 Subject: [PATCH 2/4] linearSD: close #26 save radio settings across rounds --- functions/linearSD/cfgFunctions.hpp | 1 + functions/linearSD/fn_startLinearSD.sqf | 1 + .../fn_transferRadiosAcrossRespawn.sqf | 89 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 functions/linearSD/fn_transferRadiosAcrossRespawn.sqf diff --git a/functions/linearSD/cfgFunctions.hpp b/functions/linearSD/cfgFunctions.hpp index 75741db..2327967 100644 --- a/functions/linearSD/cfgFunctions.hpp +++ b/functions/linearSD/cfgFunctions.hpp @@ -25,5 +25,6 @@ class grad_linearSD { class startLinearSD {}; class startNewRound {}; class startTimeout {}; + class transferRadiosAcrossRespawn {}; }; }; diff --git a/functions/linearSD/fn_startLinearSD.sqf b/functions/linearSD/fn_startLinearSD.sqf index b1098ea..495c5a5 100644 --- a/functions/linearSD/fn_startLinearSD.sqf +++ b/functions/linearSD/fn_startLinearSD.sqf @@ -5,6 +5,7 @@ params [["_startingSectorID",-1],["_roundLength",60],["_opforDirection",1],["_da if (hasInterface) then { [] call FUNC(addTeleportAction); [] call FUNC(addChatCommands); + [] call FUNC(transferRadiosAcrossRespawn); if (didJIP) then { [{!isNull player},FUNC(movePlayerToRespawnPos),[]] call CBA_fnc_waitUntilAndExecute; diff --git a/functions/linearSD/fn_transferRadiosAcrossRespawn.sqf b/functions/linearSD/fn_transferRadiosAcrossRespawn.sqf new file mode 100644 index 0000000..886b305 --- /dev/null +++ b/functions/linearSD/fn_transferRadiosAcrossRespawn.sqf @@ -0,0 +1,89 @@ +#include "component.hpp" + +// save entire settings array once anything is changed basically +private _fnc_saveSWSettings = { + params ["_unit"]; + if (_unit != player) exitWith {}; + player setVariable [QGVAR(swSettings),(call TFAR_fnc_activeSwRadio) call TFAR_fnc_getSwSettings]; +}; +{[_x,_fnc_saveSWSettings] call CBA_fnc_addEventHandler} forEach [ + "TFAR_event_OnSWchannelSet", + "TFAR_event_OnSWstereoSet", + "TFAR_event_OnSWvolumeSet", + "TFAR_event_OnSWChange", + "TFAR_event_OnSWspeakersSet" +]; + +// same for longrange +private _fnc_saveLRSettings = { + params ["_unit"]; + if (_unit != player) exitWith {}; + player setVariable [QGVAR(lrSettings),(call TFAR_fnc_activeLrRadio) call TFAR_fnc_getLrSettings]; +}; +{[_x,_fnc_saveLRSettings] call CBA_fnc_addEventHandler} forEach [ + "TFAR_event_OnLRchannelSet", + "TFAR_event_OnLRstereoSet", + "TFAR_event_OnLRvolumeSet", + "TFAR_event_OnLRChange", + "TFAR_event_OnLRspeakersSet" +]; + +// frequency changed event gets special treatment, because it fires for both sw and lr +[ + "TFAR_event_OnFrequencyChanged", + { + params ["_unit","_radio"]; + if (_unit != player) exitWith {}; + + private _activeSw = call TFAR_fnc_activeSwRadio; + if (_activeSw isEqualTo _radio) exitWith { + player setVariable [QGVAR(swSettings),(call TFAR_fnc_activeSwRadio) call TFAR_fnc_getSwSettings]; + }; + + private _activeLr = call TFAR_fnc_activeLRRadio; + if (_activeLr isEqualTo _radio) exitWith { + player setVariable [QGVAR(lrSettings),(call TFAR_fnc_activeLrRadio) call TFAR_fnc_getLrSettings]; + }; + } +] call CBA_fnc_addEventHandler; + +// apply SR settings every time a radio is instanced +[ + "TFAR_event_OnRadiosReceived", + { + params ["_unit","_radio"]; + if (_unit != player) exitWith {}; + private _settings = player getVariable [QGVAR(swSettings),[]]; + if (count _settings > 0) then { + [call TFAR_fnc_activeSwRadio, _settings] call TFAR_fnc_setSwSettings; + }; + } +] call CBA_fnc_addEventHandler; + +// apply LR settings every time a new loadout is applied +[ + "grad_loadout_loadoutApplied", + { + params ["_unit","_loadout"]; + if (_unit != player) exitWith {}; + + private _backpack = (_loadout param [5,[]]) param [0,""]; + if !(_backpack call TFAR_fnc_isLRRadio) exitWith {}; + + private _settings = player getVariable [QGVAR(lrSettings),[]]; + if (count _settings > 0) then { + [ + { + params ["_unit","_backpack"]; + backpack _unit == _backpack + }, + { + params ["_unit","","_settings"]; + [call TFAR_fnc_activeLrRadio, _settings] call TFAR_fnc_setLrSettings; + }, + [_unit,_backpack,_settings], + 5 + ] call CBA_fnc_waitUntilAndExecute; + }; + } +] call CBA_fnc_addEventHandler; From 7d7bb6d0d4b68dbc67b5936897d93600914ae2f6 Mon Sep 17 00:00:00 2001 From: McDiod Date: Sun, 23 Jun 2019 21:00:16 +0200 Subject: [PATCH 3/4] linearSD: ability to set weather per round --- functions/linearSD/cfgFunctions.hpp | 2 ++ functions/linearSD/fn_getWeather.sqf | 8 ++++++++ functions/linearSD/fn_setWeather.sqf | 15 +++++++++++++++ functions/linearSD/fn_startLinearSD.sqf | 3 ++- functions/linearSD/fn_startNewRound.sqf | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 functions/linearSD/fn_getWeather.sqf create mode 100644 functions/linearSD/fn_setWeather.sqf diff --git a/functions/linearSD/cfgFunctions.hpp b/functions/linearSD/cfgFunctions.hpp index 2327967..a2267ab 100644 --- a/functions/linearSD/cfgFunctions.hpp +++ b/functions/linearSD/cfgFunctions.hpp @@ -10,6 +10,7 @@ class grad_linearSD { class createSector {}; class dynamicText {}; class endRound {}; + class getWeather {}; class isLastSector {}; class movePlayerToRespawnPos {}; class moveRespawnPositions {}; @@ -20,6 +21,7 @@ class grad_linearSD { class setActiveSectors {}; class setLastRound {}; class setTimeAndDate {}; + class setWeather {}; class spawnSectorVehicles {}; class startEliminationCheck {}; class startLinearSD {}; diff --git a/functions/linearSD/fn_getWeather.sqf b/functions/linearSD/fn_getWeather.sqf new file mode 100644 index 0000000..9289ed9 --- /dev/null +++ b/functions/linearSD/fn_getWeather.sqf @@ -0,0 +1,8 @@ +#include "component.hpp" + +// returns array in format for weatherArray entry (fn_startLinearSD) + +private _return = [overcast,fogParams,wind]; +(_return select 2) set [2,false]; + +_return diff --git a/functions/linearSD/fn_setWeather.sqf b/functions/linearSD/fn_setWeather.sqf new file mode 100644 index 0000000..a3a1106 --- /dev/null +++ b/functions/linearSD/fn_setWeather.sqf @@ -0,0 +1,15 @@ +#include "component.hpp" + +if (!isServer) exitWith {}; + +private _targetWeather = GVAR(weatherArray) deleteAt 0; +if (isNil "_targetWeather") exitWith {}; + +[_targetWeather] spawn { + (_this select 0) params [["_overcast",random 0.4],["_fogParams",[0,0,0]]]; + + [_overcast] call BIS_fnc_setOvercast; + + sleep 1; + 0.5 setFog _fogParams; +}; diff --git a/functions/linearSD/fn_startLinearSD.sqf b/functions/linearSD/fn_startLinearSD.sqf index 495c5a5..e06e626 100644 --- a/functions/linearSD/fn_startLinearSD.sqf +++ b/functions/linearSD/fn_startLinearSD.sqf @@ -1,6 +1,6 @@ #include "component.hpp" -params [["_startingSectorID",-1],["_roundLength",60],["_opforDirection",1],["_dateAndTimeArray",[]]]; +params [["_startingSectorID",-1],["_roundLength",60],["_opforDirection",1],["_dateAndTimeArray",[]],["_weatherArray",[]]]; if (hasInterface) then { [] call FUNC(addTeleportAction); @@ -28,6 +28,7 @@ if (isServer) then { GVAR(opforDirection) = _opforDirection; GVAR(dateAndTimeArray) = _dateAndTimeArray; + GVAR(weatherArray) = _weatherArray; GVAR(defendingSide) = sideUnknown; GVAR(allAttackerVehicles) = []; GVAR(isLastRound) = false; diff --git a/functions/linearSD/fn_startNewRound.sqf b/functions/linearSD/fn_startNewRound.sqf index 02b29ca..9ca2fea 100644 --- a/functions/linearSD/fn_startNewRound.sqf +++ b/functions/linearSD/fn_startNewRound.sqf @@ -24,6 +24,7 @@ publicVariable QGVAR(roundNumber); [] remoteExec [QFUNC(respawnPlayer),0,false]; [] call FUNC(playzoneCleanup); [] call FUNC(setTimeAndDate); + [] call FUNC(setWeather); // move players to respawn position manually in first round } else { From 10ef616854e752ad74afe0959b974b8feafc8044 Mon Sep 17 00:00:00 2001 From: McDiod Date: Sun, 23 Jun 2019 21:16:39 +0200 Subject: [PATCH 4/4] linearSD: remove unnecessary getWeather param --- functions/linearSD/fn_getWeather.sqf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/functions/linearSD/fn_getWeather.sqf b/functions/linearSD/fn_getWeather.sqf index 9289ed9..0e5bea6 100644 --- a/functions/linearSD/fn_getWeather.sqf +++ b/functions/linearSD/fn_getWeather.sqf @@ -2,7 +2,4 @@ // returns array in format for weatherArray entry (fn_startLinearSD) -private _return = [overcast,fogParams,wind]; -(_return select 2) set [2,false]; - -_return +[overcast,fogParams]