Skip to content

Commit

Permalink
automatic task creation for elimination preset
Browse files Browse the repository at this point in the history
  • Loading branch information
McDiod committed Sep 8, 2017
1 parent ae2cabc commit 8b90e66
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
2 changes: 2 additions & 0 deletions description.ext
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ disabledAI = 0;
allowFunctionsRecompile = 1;

enableDebugConsole = 1;
/*enableTargetDebug = 1;*/

/*//mcdiod, nomisum
enableDebugConsole[] = {
"76561198044320063",
Expand Down
2 changes: 1 addition & 1 deletion functions/endings/fn_endMissionClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _this spawn {
_text = format ([_winText] + _winTextParams);
[_text,0,0,4,2] spawn BIS_fnc_dynamicText;

diag_log [_winText,_text,_winners];
INFO_3("%1 %2 %3",_winText,_text,_winners);

sleep 5;

Expand Down
36 changes: 36 additions & 0 deletions functions/endings/fn_presetDestroy.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,42 @@ params ["_winName",["_presetParams",[]]];

_presetParams = _presetParams apply {call compile _x};

//CREATE TASK ==================================================================
/*private _winners = [missionConfigFile >> "CfgWinConditions" >> _winName, "winners",[]] call BIS_fnc_returnConfigEntry;
_winners = _winners apply {call compile _x};
private _taskID = "taskDestroy";
{_taskID = _taskID + "_w" + str _x} forEach _winners;
{_taskID = _taskID + "_l" + str _x} forEach _sides;
private _taskDesc = "";
private _typeID = -1;
{
_lastTypeID = _typeID;
_typeID = [0,1] select (name _x == "Error: No unit");
_descriptor = switch (true) do {
case (_forEachIndex == 0): {["Kill ","Destroy "] select _typeID};
case (_lastTypeID != _typeID): {["kill ","destroy "] select _typeID};
default {""};
};
_conjunction = switch (true) do {
case (_forEachIndex == 0): {""};
case (_lastTypeID != _typeID): {" and "};
default {", "};
};
_name = if (_typeID == 0) then {name _x} else {
"the " + ([configFile >> "CfgVehicles" >> typeOf _x,"displayName","object"] call BIS_fnc_returnConfigEntry)
};
_taskDesc = _taskDesc + _conjunction + _descriptor + _name;
} forEach _presetParams;
_taskDesc = _taskDesc + ".";
[_taskID,_winners,[_taskDesc,"Destroy",""],objNull,"AUTOASSIGNED",3,true,true,"destroy"] call BIS_fnc_setTask;*/


//PFH ==========================================================================
[{
params ["_args","_handle"];
_args params ["_winName","_presetParams"];
Expand Down
29 changes: 25 additions & 4 deletions functions/endings/fn_presetElimination.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,42 @@
params ["_winName","_sides"];
_sides = _sides apply {call compile _x};

private _winners = [missionConfigFile >> "CfgWinConditions" >> _winName, "winners",[]] call BIS_fnc_returnConfigEntry;
_winners = _winners apply {call compile _x};

//CREATE TASK ==================================================================
private _taskID = "taskElimination";
{_taskID = _taskID + "_w" + str _x} forEach _winners;
{_taskID = _taskID + "_l" + str _x} forEach _sides;

private _taskDesc = format ["Eliminate all players of side %1",[_sides select 0] call grad_common_fnc_getSideDisplayName];
{
if (_forEachIndex > 0) then {
_taskDesc = _taskDesc + "and " + ([_x] call grad_common_fnc_getSideDisplayName);
};
} forEach _sides;
_taskDesc = _taskDesc + ".";

[_taskID,_winners,[_taskDesc,"Eliminate Enemies",""],objNull,"AUTOASSIGNED",3,true,true,"kill"] call BIS_fnc_setTask;

//PFH ==========================================================================
[{
params ["_args","_handle"];
_args params ["_winName","_sides"];
_args params ["_winName","_sides","_taskID"];

if ({_side = _x; ({side _x == _side} count playableUnits) > 0} count _sides == 0) exitWith {

[{
params ["_winName","_sides"];
params ["_winName","_sides","_taskID"];
if ({_side = _x; ({side _x == _side} count playableUnits) > 0} count _sides == 0) then {

[_taskID,"SUCCEEDED",true] call BIS_fnc_taskSetState;
[_winName] call grad_endings_fnc_endMissionServer;
} else {
_this call grad_endings_fnc_presetElimination;
};
}, [_winName,_sides], 10] call CBA_fnc_waitAndExecute;
}, [_winName,_sides,_taskID], 10] call CBA_fnc_waitAndExecute;

[_handle] call CBA_fnc_removePerFrameHandler;
};
},10,[_winName,_sides]] call CBA_fnc_addPerFrameHandler;
},10,[_winName,_sides,_taskID]] call CBA_fnc_addPerFrameHandler;
5 changes: 4 additions & 1 deletion functions/endings/fn_startPreset.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ private _preset = [_winCondition,"preset",""] call BIS_fnc_returnConfigEntry;
private _presetParams = [_winCondition,"presetParams",[]] call BIS_fnc_returnConfigEntry;;
private _winName = configName _winCondition;

INFO_1("Initializing preset %1.",_preset);
INFO_1("Initializing preset %1 (%2).",_preset,_winName);

_preset = toUpper _preset;
switch (_preset) do {
Expand All @@ -22,6 +22,9 @@ switch (_preset) do {
case ("POINTS"): {
[_winName,_presetParams] call grad_endings_fnc_presetPoints;
};
case ("DESTROY"): {
[_winName,_presetParams] call grad_endings_fnc_presetDestroy;
};
default {
ERROR_1("Preset %1 not found!",_preset);
};
Expand Down

0 comments on commit 8b90e66

Please sign in to comment.