Skip to content

Commit

Permalink
Merge pull request #36 from gruppe-adler/linearSD-improvements
Browse files Browse the repository at this point in the history
close #33 linearSD improvements
  • Loading branch information
McDiod authored Jun 23, 2019
2 parents 328dbac + 10ef616 commit d988697
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 5 deletions.
3 changes: 3 additions & 0 deletions functions/linearSD/cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class grad_linearSD {
class createSector {};
class dynamicText {};
class endRound {};
class getWeather {};
class isLastSector {};
class movePlayerToRespawnPos {};
class moveRespawnPositions {};
Expand All @@ -20,10 +21,12 @@ class grad_linearSD {
class setActiveSectors {};
class setLastRound {};
class setTimeAndDate {};
class setWeather {};
class spawnSectorVehicles {};
class startEliminationCheck {};
class startLinearSD {};
class startNewRound {};
class startTimeout {};
class transferRadiosAcrossRespawn {};
};
};
19 changes: 15 additions & 4 deletions functions/linearSD/fn_addTeleportAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]];
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions functions/linearSD/fn_getWeather.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "component.hpp"

// returns array in format for weatherArray entry (fn_startLinearSD)

[overcast,fogParams]
15 changes: 15 additions & 0 deletions functions/linearSD/fn_setWeather.sqf
Original file line number Diff line number Diff line change
@@ -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;
};
4 changes: 3 additions & 1 deletion functions/linearSD/fn_startLinearSD.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#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);
[] call FUNC(addChatCommands);
[] call FUNC(transferRadiosAcrossRespawn);

if (didJIP) then {
[{!isNull player},FUNC(movePlayerToRespawnPos),[]] call CBA_fnc_waitUntilAndExecute;
Expand All @@ -27,6 +28,7 @@ if (isServer) then {

GVAR(opforDirection) = _opforDirection;
GVAR(dateAndTimeArray) = _dateAndTimeArray;
GVAR(weatherArray) = _weatherArray;
GVAR(defendingSide) = sideUnknown;
GVAR(allAttackerVehicles) = [];
GVAR(isLastRound) = false;
Expand Down
1 change: 1 addition & 0 deletions functions/linearSD/fn_startNewRound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
89 changes: 89 additions & 0 deletions functions/linearSD/fn_transferRadiosAcrossRespawn.sqf
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit d988697

Please sign in to comment.