2015-08-27 07:44:23 +00:00
|
|
|
/*
|
2015-08-28 21:52:56 +00:00
|
|
|
DMS_MissionStatusCheck
|
|
|
|
|
|
|
|
Created by eraser1
|
|
|
|
|
|
|
|
Each mission has its own index in "DMS_Mission_Arr".
|
|
|
|
Every index is a subarray with the values:
|
2015-08-27 07:44:23 +00:00
|
|
|
[
|
2015-08-30 00:33:32 +00:00
|
|
|
_pos,
|
|
|
|
_completionInfo, //<--- More info in "DMS_AddMissionToMonitor"
|
2015-08-27 07:44:23 +00:00
|
|
|
[_timeStarted,_timeUntilFail],
|
|
|
|
[_AIUnit1,_AIUnit2,...,_AIUnitX],
|
|
|
|
[
|
|
|
|
[_cleanupObj1,_cleanupObj2,...,_cleanupObjX],
|
2015-09-05 01:28:05 +00:00
|
|
|
[_vehicle1,_vehicle2,...,_vehicleX],
|
|
|
|
[
|
|
|
|
[_crate1,_crate_loot_values1],
|
|
|
|
[_crate2,_crate_loot_values2]
|
|
|
|
]
|
2015-08-27 07:44:23 +00:00
|
|
|
],
|
2015-08-28 08:38:46 +00:00
|
|
|
[_msgWIN,_msgLose],
|
2015-08-30 00:33:32 +00:00
|
|
|
[_markerDot,_markerCircle],
|
|
|
|
_side
|
2015-08-27 07:44:23 +00:00
|
|
|
]
|
|
|
|
*/
|
2015-09-05 01:28:05 +00:00
|
|
|
if (DMS_Mission_Arr isEqualTo []) exitWith {}; // Empty array, no missions running
|
|
|
|
|
|
|
|
private ["_pos", "_success", "_timeStarted", "_timeUntilFail", "_units", "_buildings", "_vehs", "_crate_info_array", "_msgWIN", "_msgLose", "_markers", "_missionSide", "_arr", "_cleanupList"];
|
2015-08-28 21:52:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
{
|
2015-09-05 01:28:05 +00:00
|
|
|
try
|
2015-08-27 07:44:23 +00:00
|
|
|
{
|
2015-08-28 21:52:56 +00:00
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
2015-09-05 01:28:05 +00:00
|
|
|
diag_log format ["DMS_DEBUG MissionStatusCheck :: Checking Mission Status (index %1): %2",_forEachIndex,_x];
|
2015-08-28 21:52:56 +00:00
|
|
|
};
|
2015-08-30 00:33:32 +00:00
|
|
|
_pos = _x select 0;
|
2015-08-28 21:52:56 +00:00
|
|
|
_success = (_x select 1) call DMS_MissionSuccessState;
|
|
|
|
_timeStarted = _x select 2 select 0;
|
|
|
|
_timeUntilFail = _x select 2 select 1;
|
|
|
|
_units = _x select 3;
|
|
|
|
_buildings = _x select 4 select 0;
|
2015-09-05 01:28:05 +00:00
|
|
|
_vehs = _x select 4 select 1;
|
|
|
|
_crate_info_array = _x select 4 select 2;
|
2015-08-28 21:52:56 +00:00
|
|
|
_msgWIN = _x select 5 select 0;
|
|
|
|
_msgLose = _x select 5 select 1;
|
|
|
|
_markers = _x select 6;
|
2015-08-29 01:48:18 +00:00
|
|
|
_missionSide = _x select 7;
|
2015-08-28 21:52:56 +00:00
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
if (_success) then
|
2015-08-28 21:52:56 +00:00
|
|
|
{
|
2015-08-31 07:52:46 +00:00
|
|
|
DMS_CleanUpList pushBack [_units+_buildings,diag_tickTime,DMS_CompletedMissionCleanupTime];
|
2015-08-29 01:48:18 +00:00
|
|
|
|
2015-08-30 00:33:32 +00:00
|
|
|
if (_missionSide == "bandit") then
|
2015-08-29 01:48:18 +00:00
|
|
|
{
|
2015-08-30 00:33:32 +00:00
|
|
|
DMS_RunningBMissionCount = DMS_RunningBMissionCount - 1;
|
2015-08-29 01:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not yet implemented
|
|
|
|
};
|
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
_arr = DMS_Mission_Arr deleteAt _forEachIndex;
|
|
|
|
|
|
|
|
{
|
|
|
|
_x call DMS_FillCrate;
|
|
|
|
} forEach _crate_info_array;
|
2015-08-28 21:52:56 +00:00
|
|
|
|
|
|
|
_msgWIN call DMS_BroadcastMissionStatus;
|
|
|
|
[_markers,"win"] call DMS_RemoveMarkers;
|
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
throw format ["Mission Success at %1 with message %2.",_pos,_msgWIN];
|
2015-08-28 21:52:56 +00:00
|
|
|
};
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
if (DMS_MissionTimeoutReset && {[_pos,DMS_MissionTimeoutResetRange] call ExileServer_util_position_isPlayerNearby}) then
|
2015-08-28 21:52:56 +00:00
|
|
|
{
|
|
|
|
_x set [2,[diag_tickTime,_timeUntilFail]];
|
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
throw format ["Mission Timeout Extended at %1 with timeout after %2 seconds. Position: %3",diag_tickTime,_timeUntilFail,_pos];
|
2015-08-28 21:52:56 +00:00
|
|
|
};
|
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
if ((diag_tickTime-_timeStarted)>_timeUntilFail) then
|
2015-08-28 21:52:56 +00:00
|
|
|
{
|
2015-08-28 22:52:58 +00:00
|
|
|
//Nobody is nearby so just cleanup objects from here
|
2015-09-05 01:28:05 +00:00
|
|
|
_cleanupList = (_units+_buildings+_vehs);
|
|
|
|
|
|
|
|
{
|
|
|
|
_cleanupList pushBack (_x select 0);
|
|
|
|
} forEach _crate_info_array;
|
|
|
|
|
|
|
|
_cleanupList call DMS_CleanUp;
|
|
|
|
|
2015-08-29 01:48:18 +00:00
|
|
|
|
2015-08-30 00:33:32 +00:00
|
|
|
if (_missionSide == "bandit") then
|
2015-08-29 01:48:18 +00:00
|
|
|
{
|
2015-08-30 00:33:32 +00:00
|
|
|
DMS_RunningBMissionCount = DMS_RunningBMissionCount - 1;
|
2015-08-29 01:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not yet implemented
|
|
|
|
};
|
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
_arr = DMS_Mission_Arr deleteAt _forEachIndex;
|
2015-08-27 07:44:23 +00:00
|
|
|
|
2015-08-28 21:52:56 +00:00
|
|
|
_msgLose call DMS_BroadcastMissionStatus;
|
|
|
|
[_markers,"lose"] call DMS_RemoveMarkers;
|
|
|
|
|
2015-09-05 01:28:05 +00:00
|
|
|
throw format ["Mission Fail at %1 with message %2.",_pos,_msgLose];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
if (DMS_DEBUG) then
|
|
|
|
{
|
|
|
|
diag_log format ["DMS_DEBUG MissionStatusCheck :: %1",_exception];
|
2015-08-27 07:44:23 +00:00
|
|
|
};
|
2015-08-28 21:52:56 +00:00
|
|
|
};
|
2015-09-04 16:35:19 +00:00
|
|
|
} forEach DMS_Mission_Arr;
|