2015-08-28 21:52:56 +00:00
/*
2015-09-05 03:40:00 +00:00
DMS_fnc_MissionSuccessState
2015-08-28 21:52:56 +00:00
Created by eraser1
Usage:
[
2015-09-20 05:37:13 +00:00
[_completionType1,_completionArgs1,_isAbsoluteCondition],
[_completionType2,_completionArgs2,_isAbsoluteCondition],
2015-08-28 21:52:56 +00:00
...
2015-09-20 05:37:13 +00:00
[_completionTypeN,_completionArgsN,_isAbsoluteCondition]
2015-09-05 03:40:00 +00:00
] call DMS_fnc_MissionSuccessState;
2015-08-28 21:52:56 +00:00
*/
2015-08-30 00:33:32 +00:00
2015-09-20 05:37:13 +00:00
if ((typeName _this) != "ARRAY") exitWith
2015-08-28 21:52:56 +00:00
{
2015-09-20 05:37:13 +00:00
diag_log format ["DMS ERROR :: DMS_fnc_MissionSuccessState called with invalid parameter: %1",_this];
2015-08-28 21:52:56 +00:00
};
2015-09-20 05:37:13 +00:00
private ["_success", "_exit"];
2015-08-28 21:52:56 +00:00
_success = true;
2015-09-20 05:37:13 +00:00
_exit = false;
2015-08-28 21:52:56 +00:00
{
2015-09-20 05:37:13 +00:00
if (_exit) exitWith {};
try
2015-08-28 21:52:56 +00:00
{
2015-09-20 05:37:13 +00:00
private ["_OK","_completionType","_completionArgs","_absoluteWinCondition"];
_OK = _x params
[
["_completionType", "", [""] ],
["_completionArgs", [], [[],grpNull] ]
];
if (!_OK) then
2015-08-28 21:52:56 +00:00
{
2015-09-20 05:37:13 +00:00
diag_log format ["DMS ERROR :: DMS_fnc_MissionSuccessState has invalid parameters in: %1",_x];
throw "ERROR";
2015-08-28 21:52:56 +00:00
};
2015-09-20 05:37:13 +00:00
_absoluteWinCondition = false;
if (((count _x)>2) && {_x select 2}) then
{
_absoluteWinCondition = true;
};
2015-08-28 21:52:56 +00:00
2015-09-20 05:37:13 +00:00
if (!_success && {!_absoluteWinCondition}) then
{
throw format ["Skipping completion check for condition |%1|; Condition is not absolute and a previous condition has already been failed.",_x];
};
2015-08-28 21:52:56 +00:00
2015-09-20 05:37:13 +00:00
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG MissionSuccessState :: Checking completion type %1 with parameter %2. Absolute: %3",_completionType,_completionArgs,_absoluteWinCondition];
};
switch (toLower _completionType) do
2015-08-28 21:52:56 +00:00
{
2015-09-20 05:37:13 +00:00
case "kill":
{
_success = _completionArgs call DMS_fnc_TargetsKilled;
};
/*
case "killpercent":
{
_success = _completionArgs call DMS_fnc_TargetsKilledPercent;//<---TODO
};
*/
case "playernear":
{
_success = _completionArgs call DMS_fnc_IsPlayerNearby;
};
default
{
diag_log format ["DMS ERROR :: Invalid completion type (%1) with args: %2",_completionType,_completionArgs];
throw "ERROR";
};
2015-08-28 21:52:56 +00:00
};
2015-09-20 05:37:13 +00:00
if (_success && {_absoluteWinCondition}) then
2015-08-30 00:33:32 +00:00
{
2015-09-20 05:37:13 +00:00
_exit = true;
throw format ["Mission completed because of absolute win condition: %1",_x];
2015-08-30 00:33:32 +00:00
};
2015-09-20 05:37:13 +00:00
}
catch
{
2015-09-20 20:26:08 +00:00
if (DMS_DEBUG) then
2015-08-28 21:52:56 +00:00
{
2015-09-20 05:37:13 +00:00
diag_log format ["DMS_DEBUG MissionSuccessState :: %1",_exception];
2015-08-28 21:52:56 +00:00
};
};
2015-09-04 16:35:19 +00:00
} forEach _this;
2015-08-28 21:52:56 +00:00
_success;