|
|
|
|
@@ -1,8 +1,10 @@
|
|
|
|
|
// execute for all
|
|
|
|
|
milsim_respawn_setting_maxRangeToReady = 400; // distance in meters from a base at which players can ready up for pickup. players removed from the queue if they move further away than this distance
|
|
|
|
|
if (isNil "milsim_respawn_setting_reinsertion_maxRangeToReady") then {
|
|
|
|
|
// configured in CBA settings
|
|
|
|
|
milsim_respawn_setting_reinsertion_maxRangeToReady = 400; // distance in meters from a base at which players can ready up for pickup. players removed from the queue if they move further away than this distance
|
|
|
|
|
};
|
|
|
|
|
milsim_respawn_bases = allMissionObjects "ModuleRespawnPosition_F"; // array of all respawn modules in the mission
|
|
|
|
|
|
|
|
|
|
// player self-interacts will be applied in initPlayerLocal via milsim_respawn_fnc_readyForPickup
|
|
|
|
|
|
|
|
|
|
// on the server, initialize the queue and register the CBA event handler by which players can ready up
|
|
|
|
|
if (isServer) then {
|
|
|
|
|
@@ -14,14 +16,19 @@ if (isServer) then {
|
|
|
|
|
["milsim_respawn_fileReinsertRequest", {
|
|
|
|
|
params ["_unit", "_closestBaseName"];
|
|
|
|
|
milsim_respawn_reinsertionQueue pushBackUnique [_unit, _closestBaseName];
|
|
|
|
|
diag_log text format ["[milsim_respawn] [reinsertion] ADDED name=%1 playerUID=%2 closestBase=%3", name _unit, getPlayerUID _unit, _closestBaseName];
|
|
|
|
|
diag_log text format [
|
|
|
|
|
"[milsim] (respawn_reinsertion) ADDED name=%1 playerUID=%2 closestBase=%3",
|
|
|
|
|
name _unit, getPlayerUID _unit, _closestBaseName
|
|
|
|
|
];
|
|
|
|
|
publicVariable "milsim_respawn_reinsertionQueue";
|
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
["milsim_respawn_removeReinsertRequest", {
|
|
|
|
|
params ["_unit"];
|
|
|
|
|
if (milsim_respawn_reinsertionQueue find {_x#0 isEqualTo _unit} == -1) exitWith {};
|
|
|
|
|
if (count (milsim_respawn_reinsertionQueue select {_x#0 isEqualTo _unit}) isEqualTo 0) exitWith {};
|
|
|
|
|
milsim_respawn_reinsertionQueue = milsim_respawn_reinsertionQueue select {_x#0 isNotEqualTo _unit};
|
|
|
|
|
diag_log text format ["[milsim_respawn] [reinsertion] REMOVED BY REQUEST name=%1 playerUID=%2", name _unit, getPlayerUID _unit];
|
|
|
|
|
diag_log text format ["[milsim] (respawn_reinsertion) REMOVED BY REQUEST name=%1 playerUID=%2",
|
|
|
|
|
name _unit, getPlayerUID _unit
|
|
|
|
|
];
|
|
|
|
|
publicVariable "milsim_respawn_reinsertionQueue";
|
|
|
|
|
}] call CBA_fnc_addEventHandler;
|
|
|
|
|
|
|
|
|
|
@@ -41,7 +48,7 @@ if (isServer) then {
|
|
|
|
|
if (_distanceFromBase < _nearestDistance) then {
|
|
|
|
|
_nearestDistance = _distanceFromBase;
|
|
|
|
|
};
|
|
|
|
|
if (_distanceFromBase < milsim_respawn_setting_maxRangeToReady) then {
|
|
|
|
|
if (_distanceFromBase < milsim_respawn_setting_reinsertion_maxRangeToReady) then {
|
|
|
|
|
_nearBase = true;
|
|
|
|
|
};
|
|
|
|
|
} forEach milsim_respawn_bases;
|
|
|
|
|
@@ -49,7 +56,10 @@ if (isServer) then {
|
|
|
|
|
if (_nearBase && alive _player) then {
|
|
|
|
|
_stillValid pushBackUnique _queueData;
|
|
|
|
|
} else {
|
|
|
|
|
diag_log text format ["[milsim_respawn] [reinsertion] REMOVED AUTOMATICALLY name=%1 playerUID=%2 nearestBase=%3m", name _player, getPlayerUID _player, _nearestDistance];
|
|
|
|
|
diag_log text format [
|
|
|
|
|
"[milsim] (respawn_reinsertion) REMOVED AUTOMATICALLY name=%1 playerUID=%2 nearestBase=%3m",
|
|
|
|
|
name _player, getPlayerUID _player, _nearestDistance
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
} forEach milsim_respawn_reinsertionQueue;
|
|
|
|
|
|
|
|
|
|
@@ -81,13 +91,16 @@ if (hasInterface) then {
|
|
|
|
|
{
|
|
|
|
|
params ["_target", "_player", "_params"];
|
|
|
|
|
private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition;
|
|
|
|
|
["milsim_respawn_fileReinsertRequest", [_player, _closestBase getVariable ["name", "unknown"]]] call CBA_fnc_serverEvent;
|
|
|
|
|
format["Re-insert Request Filed at Location %1", _closestBase getVariable ["name", "unknown"]] call CBA_fnc_notify;
|
|
|
|
|
private _closestBaseName = _closestBase getVariable ["name", "unknown"];
|
|
|
|
|
["milsim_respawn_fileReinsertRequest", [_player, _closestBaseName]] call CBA_fnc_serverEvent;
|
|
|
|
|
[["Re-insert Request Filed"], [format["Pickup at %1", _closestBaseName]]] call CBA_fnc_notify;
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
params ["_target", "_player", "_params"];
|
|
|
|
|
private _closestBase = [milsim_respawn_bases, _player] call BIS_fnc_nearestPosition;
|
|
|
|
|
(_player distance _closestBase < milsim_respawn_setting_maxRangeToReady) &&
|
|
|
|
|
|
|
|
|
|
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] &&
|
|
|
|
|
(_player distance _closestBase < milsim_respawn_setting_reinsertion_maxRangeToReady) &&
|
|
|
|
|
not (_player in ((missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) apply {_x#0}))
|
|
|
|
|
}
|
|
|
|
|
] call ace_interact_menu_fnc_createAction;
|
|
|
|
|
@@ -100,10 +113,12 @@ if (hasInterface) then {
|
|
|
|
|
{
|
|
|
|
|
params ["_target", "_player", "_params"];
|
|
|
|
|
["milsim_respawn_removeReinsertRequest", [_player]] call CBA_fnc_serverEvent;
|
|
|
|
|
"Re-insert Request has been rescinded." call CBA_fnc_notify;
|
|
|
|
|
"Re-insert Request Rescinded" call CBA_fnc_notify;
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
params ["_target", "_player", "_params"];
|
|
|
|
|
|
|
|
|
|
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true] &&
|
|
|
|
|
(_player in ((missionNamespace getVariable ["milsim_respawn_reinsertionQueue", []]) apply {_x#0}))
|
|
|
|
|
}
|
|
|
|
|
] call ace_interact_menu_fnc_createAction;
|
|
|
|
|
@@ -149,7 +164,9 @@ if (hasInterface) then {
|
|
|
|
|
|
|
|
|
|
call milsim_respawn_fnc_showReinsertQueueNotification;
|
|
|
|
|
},
|
|
|
|
|
{true} // always allow
|
|
|
|
|
{
|
|
|
|
|
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true]
|
|
|
|
|
} // always allow
|
|
|
|
|
] call ace_interact_menu_fnc_createAction;
|
|
|
|
|
[_type, 1, ["ACE_SelfActions"], _checkReinsertQueueAction, true] call ace_interact_menu_fnc_addActionToClass;
|
|
|
|
|
|
|
|
|
|
@@ -169,8 +186,14 @@ if (hasInterface) then {
|
|
|
|
|
// ADD TIMER FOR PILOTS - IF REINSERT LIST NOT CHECKED FOR 20 MINUTES, SHOW NOTIFICATION AUTOMATICALLY
|
|
|
|
|
if ((typeOf player) in ["B_Helipilot_F", "B_helicrew_F"]) then {
|
|
|
|
|
[{
|
|
|
|
|
if (not (
|
|
|
|
|
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_enabled", true]
|
|
|
|
|
)) exitWith {};
|
|
|
|
|
private _lastCheck = localNamespace getVariable ["milsim_respawn_lastReinsertQueueCheck", diag_tickTime];
|
|
|
|
|
if (diag_tickTime - _lastCheck < (60*20)) exitWith {}; // if last check was less than 20 minutes ago, skip
|
|
|
|
|
if (
|
|
|
|
|
diag_tickTime - _lastCheck <
|
|
|
|
|
missionNamespace getVariable ["milsim_respawn_setting_reinsertion_pilotForcedCheckInterval", 60*20]
|
|
|
|
|
) exitWith {}; // if last check was less than X minutes ago, skip
|
|
|
|
|
|
|
|
|
|
// if last check was greater than 20 minutes ago, we'll prompt the notification now and reset the timer
|
|
|
|
|
localNamespace setVariable ["milsim_respawn_lastReinsertQueueCheck", diag_tickTime];
|
|
|
|
|
|