From 203435295d13f71dabd46e58acd2431055e8c995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Mon, 28 Feb 2022 23:24:33 +0100 Subject: [PATCH 01/46] First itteration Test task is working with the system, no obvious errors --- A3A/addons/Task/$PBOPREFIX$ | 1 + A3A/addons/Task/CfgFunctions.hpp | 26 ++++++ A3A/addons/Task/Core/fn_genTaskID.sqf | 6 ++ A3A/addons/Task/Core/fn_getSettings.sqf | 22 +++++ A3A/addons/Task/Core/fn_requestTask.sqf | 46 +++++++++++ A3A/addons/Task/Core/fn_runTask.sqf | 82 +++++++++++++++++++ A3A/addons/Task/Core/fn_updateTaskState.sqf | 66 +++++++++++++++ .../Task/Helpers/fn_nearFriendlyMarkers.sqf | 25 ++++++ .../Task/Helpers/fn_nearHostileMarkers.sqf | 23 ++++++ A3A/addons/Task/Params/fn_testTask_p.sqf | 6 ++ A3A/addons/Task/Tasks.hpp | 7 ++ A3A/addons/Task/Tasks/fn_testTask.sqf | 63 ++++++++++++++ A3A/addons/Task/config.cpp | 26 ++++++ A3A/addons/Task/script_component.hpp | 2 + A3A/addons/core/Includes/script_macros.hpp | 10 --- .../core/Includes/script_macros_common.hpp | 7 -- 16 files changed, 401 insertions(+), 17 deletions(-) create mode 100644 A3A/addons/Task/$PBOPREFIX$ create mode 100644 A3A/addons/Task/CfgFunctions.hpp create mode 100644 A3A/addons/Task/Core/fn_genTaskID.sqf create mode 100644 A3A/addons/Task/Core/fn_getSettings.sqf create mode 100644 A3A/addons/Task/Core/fn_requestTask.sqf create mode 100644 A3A/addons/Task/Core/fn_runTask.sqf create mode 100644 A3A/addons/Task/Core/fn_updateTaskState.sqf create mode 100644 A3A/addons/Task/Helpers/fn_nearFriendlyMarkers.sqf create mode 100644 A3A/addons/Task/Helpers/fn_nearHostileMarkers.sqf create mode 100644 A3A/addons/Task/Params/fn_testTask_p.sqf create mode 100644 A3A/addons/Task/Tasks.hpp create mode 100644 A3A/addons/Task/Tasks/fn_testTask.sqf create mode 100644 A3A/addons/Task/config.cpp create mode 100644 A3A/addons/Task/script_component.hpp diff --git a/A3A/addons/Task/$PBOPREFIX$ b/A3A/addons/Task/$PBOPREFIX$ new file mode 100644 index 0000000000..6994d7efda --- /dev/null +++ b/A3A/addons/Task/$PBOPREFIX$ @@ -0,0 +1 @@ +x\A3A\addons\Task \ No newline at end of file diff --git a/A3A/addons/Task/CfgFunctions.hpp b/A3A/addons/Task/CfgFunctions.hpp new file mode 100644 index 0000000000..cf8ddec798 --- /dev/null +++ b/A3A/addons/Task/CfgFunctions.hpp @@ -0,0 +1,26 @@ +class CfgFunctions { + class ADDON { + class Core { + file = QPATHTOFOLDER(Core); + class genTaskID {}; + class getSettings { postInit = 1; }; + class requestTask {}; + class runTask {}; + class updateTaskState {}; + }; + + class Helpers { // task helper functions | Common functionality used by tasks or the params getters + file = QPATHTOFOLDER(Helpers); + class nearFriendlyMarkers {}; + class nearHostileMarkers {}; + }; + class Params { // params getter functions for the tasks | returns false if failed, otherwise params array + file = QPATHTOFOLDER(Params); + class testTask_p {}; + }; + class Tasks { // task | Passed task HM to store task instructions into + file = QPATHTOFOLDER(Tasks); + class testTask {}; + }; + }; +}; diff --git a/A3A/addons/Task/Core/fn_genTaskID.sqf b/A3A/addons/Task/Core/fn_genTaskID.sqf new file mode 100644 index 0000000000..c8f606b395 --- /dev/null +++ b/A3A/addons/Task/Core/fn_genTaskID.sqf @@ -0,0 +1,6 @@ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() +if (!isServer) exitWith {}; + +GVAR(TaskID) = GVAR(TaskID) + 1; +str GVAR(TaskID); diff --git a/A3A/addons/Task/Core/fn_getSettings.sqf b/A3A/addons/Task/Core/fn_getSettings.sqf new file mode 100644 index 0000000000..e4340ce662 --- /dev/null +++ b/A3A/addons/Task/Core/fn_getSettings.sqf @@ -0,0 +1,22 @@ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() +if (isNil QGVAR(TaskID)) then { GVAR(TaskID) = 0 }; + +GVAR(Settings) = createHashMap; + +//no cba fallback +GVAR(Settings) set ["TaskLingerTime", 180]; +GVAR(Settings) set ["MaxTestMissions", 3]; + +//CBA settings +if (isClass (configfile >> "CBA_Extended_EventHandlers")) then { + + [QGVAR(TaskLingerTime), "SLIDER", ["Task linger time", "Time in minutes a task remains in the task list after compleation"], ["Antistasi","Tasks"], [1, 15, 3, 0], true, { + GVAR(Settings) set ["TaskLingerTime",round _this * 60]; + }] call CBA_fnc_addSetting; + + [QGVAR(MaxTestMissions), "SLIDER", ["Max test missions", "maximum amount of test missions that can be active at the same time"], ["Antistasi","Tasks"], [0, 10, 3, 0], true, { + GVAR(Settings) set ["MaxTasksOfCat_Test",round _this]; + }] call CBA_fnc_addSetting; + +}; diff --git a/A3A/addons/Task/Core/fn_requestTask.sqf b/A3A/addons/Task/Core/fn_requestTask.sqf new file mode 100644 index 0000000000..b7eae9baea --- /dev/null +++ b/A3A/addons/Task/Core/fn_requestTask.sqf @@ -0,0 +1,46 @@ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() + +params [ + ["_taskTypes",[],[[], createHashMap]] //task types or task hm +]; + +#define TASKS_CFG (configFile/"A3A"/"Tasks") + +if (!isServer) exitWith { Error("Server function called on client"); "10" }; +if (isNil QGVAR(ActiveTasks)) then { GVAR(ActiveTasks) = [] }; +if (isNil QGVAR(Settings)) then { call FUNC(getSettings)}; +if (_taskTypes isEqualType createHashMap) exitWith { [_taskTypes] spawn FUNC(runTask); "13" }; //loading task from save + +// select task type from the ones we can create more of atm +if (_taskTypes isEqualTo []) then {_taskTypes = "true" configClasses TASKS_CFG}; +_taskTypes = _taskTypes select { + // Task type missconfigured + if (!isClass _x) then { Error_1("Invalid task type: %1", configName _x); continueWith false }; + + //Common criterias + private _cat = getText (_x/"Category"); + if !( + { (_x get "Category") isEqualTo _cat } count GVAR(ActiveTasks) + < ( GVAR(Settings) get ("MaxTasksOfCat_" + _cat) ) + ) then { Debug_1("Max tasks of type %1 active", configName _x); continueWith false}; + + //parameters getters of the mission type should handle mission type specific criterias + private _paramsGetter = missionNamespace getVariable getText (_x / "Params"); + if (isNil "_paramsGetter") then { Debug_1("No params getter for task %1", configName _x); continueWith false; }; + if ((call _paramsGetter) isEqualType false) then { Debug_1("No valid params for task %1",configName _x); continueWith false }; + + true; //ToDo: add more criterias +}; + +private _selectedTask = selectRandom _taskTypes; +if (isNil "_selectedTask") exitWith { Info_1("Unable to start a task of types: ", if ((_this#0) isEqualTo []) then {"All", _this#0}); "38" }; + +// determine task parameters +private _taskHM = createHashMap; +_taskHM set ["Cfg", _selectedTask]; +_taskHM set ["Params", call (missionNameSpace getVariable [getText (_selectedTask/"Params"), {[]}])]; + +// start task +[_taskHM] spawn FUNC(runTask); +true; diff --git a/A3A/addons/Task/Core/fn_runTask.sqf b/A3A/addons/Task/Core/fn_runTask.sqf new file mode 100644 index 0000000000..bf2af5e63a --- /dev/null +++ b/A3A/addons/Task/Core/fn_runTask.sqf @@ -0,0 +1,82 @@ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() +private _emptyHM = createHashMap; +params [["_taskHM", _emptyHM, [_emptyHM]]]; + +//validation +if (_taskHM isEqualTo _emptyHM) exitWith { Error_1("Invalid parameters passed: %1", _this) }; +if (!canSuspend) exitWith { Error_1("Tasks needs to run in scheduled environment") }; + +_taskHM set ["TaskID", call FUNC(genTaskID)]; + +//load task +private _taskData = missionNameSpace getVariable getText ((_taskHM get "Cfg") / "Func"); +if (isNil "_taskData") exitWith { Error_1("Function does not exist: %1", _taskData) }; +_taskHM call _taskData; + +//run task +_taskHM call FUNC(updateTaskState); +if !("Constructor" in _taskHM) exitWith { Error_1("Task %1 lacks a constructor", configName (_taskHM get "Cfg")) }; +GVAR(ActiveTasks) pushBackUnique _taskHM; +call (_taskHM get "Constructor"); + +private _stage = _taskHM getOrDefault ["__CurrentStage", 1]; +private _stages = (_taskHM get "Stages") select [_stage-1, count (_taskHM get "Stages")]; +if (_stage > 1) then { call ((_stages#0) getOrDefault ["Init",{}]) }; + +_taskHM set ["Rewards",[]]; +{ + _taskHM set ["__CurrentStage", (_taskHM get "__CurrentStage") +1]; //increment stage count (for saving/loading) + _taskHM call FUNC(updateTaskState); + if !("Action" in _x) exitWith { Error_1("Stage %1 is missing the action",_x) }; + if !("Condition" in _x) exitWith { Error_1("Stage %1 is missing the condition",_x) }; + + private _endTime = time + (_x getOrDefault ["Timeout", 1e12]); + call (_x get "Action"); + + waitUntil { + sleep 1; + (if ("Timeout" in _x) then {time >= _endTime} else {false}) + || call (_x get "Condition") + || (_taskHM getOrDefault ["cancellationToken", false]) + || (_x getOrDefault ["cancellationToken", false]) + }; + + if (_taskHM getOrDefault ["cancellationToken", false]) exitWith { + _taskHM set ["Successful", false]; + _taskHM set ["state", "CANCELED"]; + }; + + private _successful = (if ("Timeout" in _x) then {time < _endTime} else {true}) && !(_x getOrDefault ["cancellationToken", false]); + _x set ["Successful", _successful]; + if (_successful) then { + if (_x getOrDefault ["Reward-instant",false]) then (_x getOrDefault ["Reward",{}]) else { + if ("Reward" in _x) then { + (_taskHM get "Rewards") pushBack (_x get "Reward"); + }; + }; + _x set ["state", "SUCCEEDED"]; + } else { + if (_x getOrDefault ["cancellationToken", false]) then { + _x set ["state", "CANCELED"] + } else { + _x set ["state", "FAILED"] + }; + }; + + if (!_successful && (_x getOrDefault ["Required", true])) exitWith { + _taskHM set ["Successful", false]; + _taskHM set ["state", "FAILED"]; + }; +} forEach _stages; + +if (_taskHM getOrDefault ["Successful", true]) then { + _taskHM set ["state", "SUCCEEDED"] +}; + +call (_taskHM getOrDefault ["Destructor", {}]); + +{call _x} forEach (_taskHM get "Rewards"); + +_taskHM call FUNC(updateTaskState); +GVAR(ActiveTasks) deleteAt ( GVAR(ActiveTasks) findIf {(_x get "TaskID") isEqualTo (_taskHM get "TaskID")} ); diff --git a/A3A/addons/Task/Core/fn_updateTaskState.sqf b/A3A/addons/Task/Core/fn_updateTaskState.sqf new file mode 100644 index 0000000000..b23a846870 --- /dev/null +++ b/A3A/addons/Task/Core/fn_updateTaskState.sqf @@ -0,0 +1,66 @@ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() +params ["_taskHM"]; + +//get task state from hm +private _taskID = _taskHM get "TaskID"; +if (isNil "_taskID") then { _taskID = call FUNC(genTaskID); _taskHM set ["TaskID", _taskID]; }; +if (_taskID isEqualType []) then {_taskID = _taskID#0}; + +private _description = [ + _taskHM getOrDefault ["description", ""], + _taskHM get "title", + _taskHM getOrDefault ["marker", ""] +]; +if (isNil {_description#1}) exitWith { Error_1("No title set for task %1", configName (_taskHM get "Cfg")) }; + +private _destination = _taskHM getOrDefault ["destination",objNull]; +private _state = _taskHM getOrDefault ["state","CREATED"]; +private _priority = _taskHM getOrDefault ["priority", -1]; +private _showNotification = _taskHM getOrDefault ["showNotification",true]; +private _type = _taskHM getOrDefault ["type",""]; +private _visibleIn3D = _taskHM getOrDefault ["visibleIn3D",false]; + +//update task state +if !([_taskID] call BIS_fnc_taskExists) then { + Debug_1("Task created | ID: %1", _taskHM get "TaskID"); + [ + true, _taskHM get "TaskID", _description, _destination, _state, _priority, _showNotification, _type, _visibleIn3D + ] call BIS_fnc_taskCreate; +}; + +if (_taskID call BIS_fnc_taskState isNotEqualTo _state) then { + [_taskID, _state, _showNotification] call BIS_fnc_taskSetState; +}; + +if (_taskID call BIS_fnc_taskDescription isNotEqualTo _description) then { + [_taskID, _description] call BIS_fnc_taskSetDescription; +}; + +private _destinationCheck = switch (true) do { + case (_destination isEqualType objNull): { getPos _destination }; + case (_destination isEqualType ""): { getPos _destination }; + default { _destination }; +}; +if (_taskId call BIS_fnc_taskDestination isNotEqualTo _destinationCheck) then { + [_taskID, _destination] call BIS_fnc_taskSetDestination; +}; + +if (_taskId call BIS_fnc_taskType isNotEqualTo _type) then { + [_taskID, _type] call BIS_fnc_taskSetType; +}; + +if (_taskID call BIS_fnc_taskAlwaysVisible isNotEqualTo _visibleIn3D) then { + [_taskID, _visibleIn3D] call BIS_fnc_taskSetAlwaysVisible; +}; + +//update child tasks +{ _x call FUNC(updateTaskState) } forEach (_taskHM getOrDefault ["Children", []]); + +//task removal +if (_state in ["SUCCEEDED","FAILED","CANCELED"]) then { + _taskID spawn { + sleep (GVAR(Settings) get "TaskLingerTime"); + [_this, true, true] call BIS_fnc_deleteTask; + }; +}; diff --git a/A3A/addons/Task/Helpers/fn_nearFriendlyMarkers.sqf b/A3A/addons/Task/Helpers/fn_nearFriendlyMarkers.sqf new file mode 100644 index 0000000000..b84f867f9d --- /dev/null +++ b/A3A/addons/Task/Helpers/fn_nearFriendlyMarkers.sqf @@ -0,0 +1,25 @@ +/* +Author: Håkon +Description: + Returns all friendly markers within mission distance + +Arguments: + +Return Value: + Friendly markers within mission distance + +Scope: Any +Environment: Any +Public: Yes +Dependencies: + +Example: + +License: MIT License +*/ +private _nearbyFriendlyMarkers = markersX select { + (getMarkerPos _x inArea [getMarkerPos respawnTeamPlayer, distanceMission+distanceSPWN, distanceMission+distanceSPWN, 0, false]) + and (sidesX getVariable [_x,sideUnknown] isEqualTo teamPlayer) +}; +_nearbyFriendlyMarkers deleteAt (_nearbyFriendlyMarkers find "Synd_HQ"); +_nearbyFriendlyMarkers; diff --git a/A3A/addons/Task/Helpers/fn_nearHostileMarkers.sqf b/A3A/addons/Task/Helpers/fn_nearHostileMarkers.sqf new file mode 100644 index 0000000000..b282b42547 --- /dev/null +++ b/A3A/addons/Task/Helpers/fn_nearHostileMarkers.sqf @@ -0,0 +1,23 @@ +/* +Author: Håkon +Description: + Filters given array of markers into hostile markers within mission distance + +Arguments: +0. > Markers to filter + +Return Value: +> Filtered markers + +Scope: Server,Server/HC,Clients,Any +Environment: Scheduled/unscheduled/Any +Public: Yes/No +Dependencies: + +Example: + +License: MIT License +*/ +params ["_Markers"]; +_Markers = _Markers select {(getMarkerPos _x distance2D getMarkerPos respawnTeamPlayer < distanceMission) && (sidesX getVariable [_x,sideUnknown] != teamPlayer)}; +_Markers diff --git a/A3A/addons/Task/Params/fn_testTask_p.sqf b/A3A/addons/Task/Params/fn_testTask_p.sqf new file mode 100644 index 0000000000..425ad6a4ab --- /dev/null +++ b/A3A/addons/Task/Params/fn_testTask_p.sqf @@ -0,0 +1,6 @@ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() +// this function returns the valid params for the task an array, or false if it cant generate valid params +if (!isNil QGVAR(BlockTestTask)) exitWith { false }; + +[]; diff --git a/A3A/addons/Task/Tasks.hpp b/A3A/addons/Task/Tasks.hpp new file mode 100644 index 0000000000..7d184050e4 --- /dev/null +++ b/A3A/addons/Task/Tasks.hpp @@ -0,0 +1,7 @@ +class Tasks { + class TestTask { + Category = "Test"; + Func = QFUNC(testTask); + Params = QFUNC(testTask_p); + }; +}; diff --git a/A3A/addons/Task/Tasks/fn_testTask.sqf b/A3A/addons/Task/Tasks/fn_testTask.sqf new file mode 100644 index 0000000000..c49796a893 --- /dev/null +++ b/A3A/addons/Task/Tasks/fn_testTask.sqf @@ -0,0 +1,63 @@ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() + +/* + Note: the task sets all feedback to players automaticly based on the info in the task hm passed to the task + the modifyable values are: + description, title, marker, destination, state, priority, showNotification, type, visibleIn3D + + note that TaskID is also available but should only be used when creating sub tasks, and NEVER modified within the task. + of the afformentioned only title is required, but it is recomended to set: + description, marker, and destination + in addition to the title +*/ +_this set ["title", "Test task"]; +_this set ["description", "Test task description"]; +_this set ["destination", [allPlayers#0, true]]; + +_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task + Info("Constructor called"); +}]; + +_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task + Info("Destructor called"); +}]; + +_stages = [ + createHashMapFromArray [ + ["Init", { //Type: code | Optional | only stage 2 and beyond can use a stage init function + Info("Stage 1 init called"); + }], + ["Action", { //Type: code | Required | Action to be done in that stage + Info("Stage 1 action called"); + }], + ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + false; + }], + ["Required", true], //Type: bool | Optional | if the task needs the stage to succeed + ["Reward", { //Type: code | Optional | the reward given for completing the stage + Info("Stage 1 reward called"); + }], + ["Reward-Instant", false], //Type: bool | Optional | if the reward should be given instantly on compleation of stage + ["Timeout", 10] //Type: number | Optional | Time limit for the stage before auto fail + ] +]; +_this set ["Stages", _stages]; + +/* + to add sub tasks -> add them to the Children entry in the task hm + each one of these children should be a hashmap containing the same task information as the parent task, + but importantly the task needs the TaskID to be set to an array in the following format: [unique sub ID, ParentID] + + example: + private _subTaskA = createHashMap; + _subTaskA set ["TaskID", ["A", _this get "TaskID"]]; + _subTaskA set ["title", "Test sub task A"]; + _subTaskA set ["description", "Test sub task A description"]; + _this set ["Children", [_subTaskA]]; +*/ +private _subTaskA = createHashMap; +_subTaskA set ["TaskID", [call FUNC(genTaskID), _this get "TaskID"]]; +_subTaskA set ["title", "Test sub task A"]; +_subTaskA set ["description", "Test sub task A description"]; +_this set ["Children", [_subTaskA]]; // Type: Array of hashMaps | Optional | sub tasks of the main task diff --git a/A3A/addons/Task/config.cpp b/A3A/addons/Task/config.cpp new file mode 100644 index 0000000000..d655cb6862 --- /dev/null +++ b/A3A/addons/Task/config.cpp @@ -0,0 +1,26 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {}; + author = AUTHOR; + authors[] = { AUTHORS }; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +class A3A { + #include "Tasks.hpp" +#if __A3_DEBUG__ + #include "CfgFunctions.hpp" +#endif +}; +#if __A3_DEBUG__ +#else + #include "CfgFunctions.hpp" +#endif diff --git a/A3A/addons/Task/script_component.hpp b/A3A/addons/Task/script_component.hpp new file mode 100644 index 0000000000..0672474fe7 --- /dev/null +++ b/A3A/addons/Task/script_component.hpp @@ -0,0 +1,2 @@ +#define COMPONENT Task +#include "\x\A3A\addons\core\Includes\script_mod.hpp" diff --git a/A3A/addons/core/Includes/script_macros.hpp b/A3A/addons/core/Includes/script_macros.hpp index cc1561a540..de162e0e27 100644 --- a/A3A/addons/core/Includes/script_macros.hpp +++ b/A3A/addons/core/Includes/script_macros.hpp @@ -1,14 +1,4 @@ #include "script_macros_common.hpp" -#undef QFUNC -#undef QEFUNC -#define QFUNC(fncName) QUOTE(DFUNC(fncName)) -#define QEFUNC(comp,fncName) QUOTE(DEFUNC(comp,fncName)) - -#undef PREP -#undef PREPSUB -#define PREP(fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QPATHTOF(functions\DOUBLES(fn,fncName).sqf) -#define PREPSUB(folder,fncName) DFUNC(fncName) = compile preprocessFileLineNumbers QPATHTOF(folder\DOUBLES(fn,fncName).sqf) - #undef VARDEF #define VARDEF(Var, Def) (if (isNil #Var) then {Def} else {Var}) diff --git a/A3A/addons/core/Includes/script_macros_common.hpp b/A3A/addons/core/Includes/script_macros_common.hpp index dba54d5771..a9f3281e68 100644 --- a/A3A/addons/core/Includes/script_macros_common.hpp +++ b/A3A/addons/core/Includes/script_macros_common.hpp @@ -404,13 +404,6 @@ Macro: PATHTO_FNC() CFGFUNCTION_HEADER;\ RECOMPILE;\ } -#define DFUNC(func) class func {\ - RECOMPILE;\ -}; -#define DFUNCP(func, properties) class func {\ - RECOMPILE;\ - properties\ -}; #define FUNC(var1) TRIPLES(ADDON,fnc,var1) #define FUNCMAIN(var1) TRIPLES(PREFIX,fnc,var1) From 55e500ad669f5db8968433b938388260d82f4ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Tue, 1 Mar 2022 19:46:08 +0100 Subject: [PATCH 02/46] Renamed component to 'Tasks' --- A3A/addons/Task/$PBOPREFIX$ | 1 - A3A/addons/Tasks/$PBOPREFIX$ | 1 + A3A/addons/{Task => Tasks}/CfgFunctions.hpp | 0 .../{Task => Tasks}/Core/fn_genTaskID.sqf | 0 .../{Task => Tasks}/Core/fn_getSettings.sqf | 0 .../{Task => Tasks}/Core/fn_requestTask.sqf | 27 ++++++++++++------- .../{Task => Tasks}/Core/fn_runTask.sqf | 0 .../Core/fn_updateTaskState.sqf | 0 .../Helpers/fn_nearFriendlyMarkers.sqf | 0 .../Helpers/fn_nearHostileMarkers.sqf | 0 .../{Task => Tasks}/Params/fn_testTask_p.sqf | 0 A3A/addons/{Task => Tasks}/Tasks.hpp | 0 .../{Task => Tasks}/Tasks/fn_testTask.sqf | 0 A3A/addons/{Task => Tasks}/config.cpp | 0 .../{Task => Tasks}/script_component.hpp | 2 +- 15 files changed, 20 insertions(+), 11 deletions(-) delete mode 100644 A3A/addons/Task/$PBOPREFIX$ create mode 100644 A3A/addons/Tasks/$PBOPREFIX$ rename A3A/addons/{Task => Tasks}/CfgFunctions.hpp (100%) rename A3A/addons/{Task => Tasks}/Core/fn_genTaskID.sqf (100%) rename A3A/addons/{Task => Tasks}/Core/fn_getSettings.sqf (100%) rename A3A/addons/{Task => Tasks}/Core/fn_requestTask.sqf (67%) rename A3A/addons/{Task => Tasks}/Core/fn_runTask.sqf (100%) rename A3A/addons/{Task => Tasks}/Core/fn_updateTaskState.sqf (100%) rename A3A/addons/{Task => Tasks}/Helpers/fn_nearFriendlyMarkers.sqf (100%) rename A3A/addons/{Task => Tasks}/Helpers/fn_nearHostileMarkers.sqf (100%) rename A3A/addons/{Task => Tasks}/Params/fn_testTask_p.sqf (100%) rename A3A/addons/{Task => Tasks}/Tasks.hpp (100%) rename A3A/addons/{Task => Tasks}/Tasks/fn_testTask.sqf (100%) rename A3A/addons/{Task => Tasks}/config.cpp (100%) rename A3A/addons/{Task => Tasks}/script_component.hpp (69%) diff --git a/A3A/addons/Task/$PBOPREFIX$ b/A3A/addons/Task/$PBOPREFIX$ deleted file mode 100644 index 6994d7efda..0000000000 --- a/A3A/addons/Task/$PBOPREFIX$ +++ /dev/null @@ -1 +0,0 @@ -x\A3A\addons\Task \ No newline at end of file diff --git a/A3A/addons/Tasks/$PBOPREFIX$ b/A3A/addons/Tasks/$PBOPREFIX$ new file mode 100644 index 0000000000..0b257e4552 --- /dev/null +++ b/A3A/addons/Tasks/$PBOPREFIX$ @@ -0,0 +1 @@ +x\A3A\addons\Tasks \ No newline at end of file diff --git a/A3A/addons/Task/CfgFunctions.hpp b/A3A/addons/Tasks/CfgFunctions.hpp similarity index 100% rename from A3A/addons/Task/CfgFunctions.hpp rename to A3A/addons/Tasks/CfgFunctions.hpp diff --git a/A3A/addons/Task/Core/fn_genTaskID.sqf b/A3A/addons/Tasks/Core/fn_genTaskID.sqf similarity index 100% rename from A3A/addons/Task/Core/fn_genTaskID.sqf rename to A3A/addons/Tasks/Core/fn_genTaskID.sqf diff --git a/A3A/addons/Task/Core/fn_getSettings.sqf b/A3A/addons/Tasks/Core/fn_getSettings.sqf similarity index 100% rename from A3A/addons/Task/Core/fn_getSettings.sqf rename to A3A/addons/Tasks/Core/fn_getSettings.sqf diff --git a/A3A/addons/Task/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf similarity index 67% rename from A3A/addons/Task/Core/fn_requestTask.sqf rename to A3A/addons/Tasks/Core/fn_requestTask.sqf index b7eae9baea..1ce332b646 100644 --- a/A3A/addons/Task/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -12,23 +12,32 @@ if (isNil QGVAR(ActiveTasks)) then { GVAR(ActiveTasks) = [] }; if (isNil QGVAR(Settings)) then { call FUNC(getSettings)}; if (_taskTypes isEqualType createHashMap) exitWith { [_taskTypes] spawn FUNC(runTask); "13" }; //loading task from save -// select task type from the ones we can create more of atm -if (_taskTypes isEqualTo []) then {_taskTypes = "true" configClasses TASKS_CFG}; +// gather tasks pool +private _allTasks = ("true" configClasses TASKS_CFG) apply {configName _x}; +private _tasksOfCat = _allTasks select { + getText (TASKS_CFG/_x/"Category") in _taskTypes; +}; +if (_taskTypes isEqualTo []) then { _taskTypes = _allTasks }; +{ + _taskTypes deleteAt (_taskTypes find (getText (TASKS_CFG/_x/"Category"))); + _taskTypes pushBackUnique _x; +} forEach _tasksOfCat; + +//filter task that can be run _taskTypes = _taskTypes select { - // Task type missconfigured - if (!isClass _x) then { Error_1("Invalid task type: %1", configName _x); continueWith false }; + private _cfg = TASKS_CFG / _x; //Common criterias - private _cat = getText (_x/"Category"); + private _cat = getText (_cfg/"Category"); if !( { (_x get "Category") isEqualTo _cat } count GVAR(ActiveTasks) < ( GVAR(Settings) get ("MaxTasksOfCat_" + _cat) ) - ) then { Debug_1("Max tasks of type %1 active", configName _x); continueWith false}; + ) then { Debug_1("Max tasks of type %1 active", _x); continueWith false}; //parameters getters of the mission type should handle mission type specific criterias - private _paramsGetter = missionNamespace getVariable getText (_x / "Params"); - if (isNil "_paramsGetter") then { Debug_1("No params getter for task %1", configName _x); continueWith false; }; - if ((call _paramsGetter) isEqualType false) then { Debug_1("No valid params for task %1",configName _x); continueWith false }; + private _paramsGetter = missionNamespace getVariable getText (_cfg / "Params"); + if (isNil "_paramsGetter") then { Debug_1("No params getter for task %1", _x); continueWith false; }; + if ((call _paramsGetter) isEqualType false) then { Debug_1("No valid params for task %1", _x); continueWith false }; true; //ToDo: add more criterias }; diff --git a/A3A/addons/Task/Core/fn_runTask.sqf b/A3A/addons/Tasks/Core/fn_runTask.sqf similarity index 100% rename from A3A/addons/Task/Core/fn_runTask.sqf rename to A3A/addons/Tasks/Core/fn_runTask.sqf diff --git a/A3A/addons/Task/Core/fn_updateTaskState.sqf b/A3A/addons/Tasks/Core/fn_updateTaskState.sqf similarity index 100% rename from A3A/addons/Task/Core/fn_updateTaskState.sqf rename to A3A/addons/Tasks/Core/fn_updateTaskState.sqf diff --git a/A3A/addons/Task/Helpers/fn_nearFriendlyMarkers.sqf b/A3A/addons/Tasks/Helpers/fn_nearFriendlyMarkers.sqf similarity index 100% rename from A3A/addons/Task/Helpers/fn_nearFriendlyMarkers.sqf rename to A3A/addons/Tasks/Helpers/fn_nearFriendlyMarkers.sqf diff --git a/A3A/addons/Task/Helpers/fn_nearHostileMarkers.sqf b/A3A/addons/Tasks/Helpers/fn_nearHostileMarkers.sqf similarity index 100% rename from A3A/addons/Task/Helpers/fn_nearHostileMarkers.sqf rename to A3A/addons/Tasks/Helpers/fn_nearHostileMarkers.sqf diff --git a/A3A/addons/Task/Params/fn_testTask_p.sqf b/A3A/addons/Tasks/Params/fn_testTask_p.sqf similarity index 100% rename from A3A/addons/Task/Params/fn_testTask_p.sqf rename to A3A/addons/Tasks/Params/fn_testTask_p.sqf diff --git a/A3A/addons/Task/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp similarity index 100% rename from A3A/addons/Task/Tasks.hpp rename to A3A/addons/Tasks/Tasks.hpp diff --git a/A3A/addons/Task/Tasks/fn_testTask.sqf b/A3A/addons/Tasks/Tasks/fn_testTask.sqf similarity index 100% rename from A3A/addons/Task/Tasks/fn_testTask.sqf rename to A3A/addons/Tasks/Tasks/fn_testTask.sqf diff --git a/A3A/addons/Task/config.cpp b/A3A/addons/Tasks/config.cpp similarity index 100% rename from A3A/addons/Task/config.cpp rename to A3A/addons/Tasks/config.cpp diff --git a/A3A/addons/Task/script_component.hpp b/A3A/addons/Tasks/script_component.hpp similarity index 69% rename from A3A/addons/Task/script_component.hpp rename to A3A/addons/Tasks/script_component.hpp index 0672474fe7..4051fd3fea 100644 --- a/A3A/addons/Task/script_component.hpp +++ b/A3A/addons/Tasks/script_component.hpp @@ -1,2 +1,2 @@ -#define COMPONENT Task +#define COMPONENT Tasks #include "\x\A3A\addons\core\Includes\script_mod.hpp" From 2ff8e5c48fa6083c245c11536260179452372dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Tue, 1 Mar 2022 19:46:25 +0100 Subject: [PATCH 03/46] added task saving and load from save --- A3A/addons/core/functions/Save/fn_loadServer.sqf | 1 + A3A/addons/core/functions/Save/fn_loadStat.sqf | 6 +++++- A3A/addons/core/functions/Save/fn_saveLoop.sqf | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/A3A/addons/core/functions/Save/fn_loadServer.sqf b/A3A/addons/core/functions/Save/fn_loadServer.sqf index 724ab6c7ad..2344285d02 100644 --- a/A3A/addons/core/functions/Save/fn_loadServer.sqf +++ b/A3A/addons/core/functions/Save/fn_loadServer.sqf @@ -30,6 +30,7 @@ if (isServer) then { ["vehInGarage"] call A3A_fnc_getStatVariable; ["HR_Garage"] call A3A_fnc_getStatVariable; ["A3A_fuelAmountleftArray"] call A3A_fnc_getStatVariable; + [QEGVAR(Tasks,ActiveTasks)] call A3A_fnc_getStatVariable; ["destroyedBuildings"] call A3A_fnc_getStatVariable; ["idlebases"] call A3A_fnc_getStatVariable; ["idleassets"] call A3A_fnc_getStatVariable; diff --git a/A3A/addons/core/functions/Save/fn_loadStat.sqf b/A3A/addons/core/functions/Save/fn_loadStat.sqf index ca786e5ed7..112d9cb0cb 100644 --- a/A3A/addons/core/functions/Save/fn_loadStat.sqf +++ b/A3A/addons/core/functions/Save/fn_loadStat.sqf @@ -42,7 +42,7 @@ private _specialVarLoads = [ "garrison","tasks","smallCAmrk","membersX","vehInGarage","destroyedBuildings","idlebases", "idleassets","chopForest","weather","killZones","jna_dataList","controlsSDK","mrkCSAT","nextTick", "bombRuns","wurzelGarrison","aggressionOccupants", "aggressionInvaders", - "countCA", "attackCountdownInvaders", "testingTimerIsActive", "version", "HR_Garage","A3A_fuelAmountleftArray" + "countCA", "attackCountdownInvaders", "testingTimerIsActive", "version", "HR_Garage","A3A_fuelAmountleftArray", QEGVAR(Tasks,ActiveTasks) ]; private _varName = _this select 0; @@ -375,6 +375,10 @@ if (_varName in _specialVarLoads) then { }; testingTimerIsActive = _varValue; }; + + if (_varname == QEGVAR(Tasks,ActiveTasks)) then { + {_x call EFUNC(Tasks,requestTask)} forEach _varValue; + }; } else { call compile format ["%1 = %2",_varName,_varValue]; }; diff --git a/A3A/addons/core/functions/Save/fn_saveLoop.sqf b/A3A/addons/core/functions/Save/fn_saveLoop.sqf index 47754cdc41..3e96f52e7a 100644 --- a/A3A/addons/core/functions/Save/fn_saveLoop.sqf +++ b/A3A/addons/core/functions/Save/fn_saveLoop.sqf @@ -258,6 +258,8 @@ _fuelAmountleftArray = []; //Saving the state of the testing timer ["testingTimerIsActive", testingTimerIsActive] call A3A_fnc_setStatVariable; +[QEGVAR(Tasks,ActiveTasks), +EGVAR(Tasks,ActiveTasks)] call A3A_fnc_setStatVariable; + saveProfileNamespace; savingServer = false; _saveHintText = ["",FactionGet(reb,"name")," Assets:
HR: ",str _hrBackground,"
Money: ",str _resourcesBackground," €


Further infomation is provided in Map Screen > Game Options > Persistent Save-game."] joinString ""; From d8349a4f5fceb83703366a0a1807cc72af7b61ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Thu, 3 Mar 2022 20:02:22 +0100 Subject: [PATCH 04/46] added support for chained tasks --- A3A/addons/Tasks/Core/fn_getSettings.sqf | 8 ++++---- A3A/addons/Tasks/Core/fn_requestTask.sqf | 26 ++++++++++++++++++------ A3A/addons/Tasks/Core/fn_runTask.sqf | 16 ++++++++++++++- A3A/addons/Tasks/Tasks.hpp | 15 +++++++++++--- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_getSettings.sqf b/A3A/addons/Tasks/Core/fn_getSettings.sqf index e4340ce662..e83afe110a 100644 --- a/A3A/addons/Tasks/Core/fn_getSettings.sqf +++ b/A3A/addons/Tasks/Core/fn_getSettings.sqf @@ -1,12 +1,12 @@ #include "..\script_component.hpp" FIX_LINE_NUMBERS() if (isNil QGVAR(TaskID)) then { GVAR(TaskID) = 0 }; - -GVAR(Settings) = createHashMap; +if (isNil QGVAR(ChainStates)) then { GVAR(ChainStates) = createHashMap }; +if (isNil QGVAR(Settings)) then { GVAR(Settings) = createHashMap }; //no cba fallback -GVAR(Settings) set ["TaskLingerTime", 180]; -GVAR(Settings) set ["MaxTestMissions", 3]; +if !("TaskLingerTime" in GVAR(Settings)) then { GVAR(Settings) set ["TaskLingerTime", 180] }; +if !("MaxTestMissions" in GVAR(Settings)) then { GVAR(Settings) set ["MaxTestMissions", 3] }; //CBA settings if (isClass (configfile >> "CBA_Extended_EventHandlers")) then { diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index 1ce332b646..d9f4101bcb 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -7,10 +7,10 @@ params [ #define TASKS_CFG (configFile/"A3A"/"Tasks") -if (!isServer) exitWith { Error("Server function called on client"); "10" }; +if (!isServer) exitWith { Error("Server function called on client"); false }; if (isNil QGVAR(ActiveTasks)) then { GVAR(ActiveTasks) = [] }; if (isNil QGVAR(Settings)) then { call FUNC(getSettings)}; -if (_taskTypes isEqualType createHashMap) exitWith { [_taskTypes] spawn FUNC(runTask); "13" }; //loading task from save +if (_taskTypes isEqualType createHashMap) exitWith { [_taskTypes] spawn FUNC(runTask); false }; //loading task from save // gather tasks pool private _allTasks = ("true" configClasses TASKS_CFG) apply {configName _x}; @@ -32,18 +32,32 @@ _taskTypes = _taskTypes select { if !( { (_x get "Category") isEqualTo _cat } count GVAR(ActiveTasks) < ( GVAR(Settings) get ("MaxTasksOfCat_" + _cat) ) - ) then { Debug_1("Max tasks of type %1 active", _x); continueWith false}; + ) then { Debug_1("Max tasks of type %1 active", _x); continueWith false; }; + + //chained tasks + if (isClass (_cfg/"chain")) then { + private _chain = getText (_cfg/"chain"/"name"); + if (_chain isEqualTo "") then { Error_1("Missconfigured task %1, lacking name of chain", _x); continueWith false; }; + private _requiredStage = getNumber (_cfg/"chain"/"stage"); + if (_requiredStage < 1) then { Error_1("Missconfigured task %1, chain stage requirement: >=1", _x); continueWith false; }; + + private _stage = GVAR(ChainStates) getOrDefault [_chain, 1]; + if (_stage isNotEqualTo _requiredStage) then { + Debug_1("%1 Chain not at the required stage for task %2 | Current: %3 | Required: %4", _chain, _x, _stage, _requiredStage); + continueWith false; + }; + }; //parameters getters of the mission type should handle mission type specific criterias private _paramsGetter = missionNamespace getVariable getText (_cfg / "Params"); if (isNil "_paramsGetter") then { Debug_1("No params getter for task %1", _x); continueWith false; }; - if ((call _paramsGetter) isEqualType false) then { Debug_1("No valid params for task %1", _x); continueWith false }; + if ((call _paramsGetter) isEqualType false) then { Debug_1("No valid params for task %1", _x); continueWith false; }; - true; //ToDo: add more criterias + true; }; private _selectedTask = selectRandom _taskTypes; -if (isNil "_selectedTask") exitWith { Info_1("Unable to start a task of types: ", if ((_this#0) isEqualTo []) then {"All", _this#0}); "38" }; +if (isNil "_selectedTask") exitWith { Info_1("Unable to start a task of types: ", if ((_this#0) isEqualTo []) then {"All", _this#0}); false }; // determine task parameters private _taskHM = createHashMap; diff --git a/A3A/addons/Tasks/Core/fn_runTask.sqf b/A3A/addons/Tasks/Core/fn_runTask.sqf index bf2af5e63a..8dcac572b8 100644 --- a/A3A/addons/Tasks/Core/fn_runTask.sqf +++ b/A3A/addons/Tasks/Core/fn_runTask.sqf @@ -33,6 +33,7 @@ _taskHM set ["Rewards",[]]; private _endTime = time + (_x getOrDefault ["Timeout", 1e12]); call (_x get "Action"); + _taskHM call FUNC(updateTaskState); waitUntil { sleep 1; @@ -71,7 +72,20 @@ _taskHM set ["Rewards",[]]; } forEach _stages; if (_taskHM getOrDefault ["Successful", true]) then { - _taskHM set ["state", "SUCCEEDED"] + _taskHM set ["state", "SUCCEEDED"]; + + if (isClass ((_taskHM get "Cfg")/"chain")) then { + private _chain = (_taskHM get "Cfg")/"chain"; + private _name = _chain/"name"; + + if (getNumber (_chain/"blockProgress") < 1) then { + GVAR(ChainStates) set [_name, (GVAR(ChainStates) getOrDefault [_name, 1]) +1]; + }; + + if (getNumber (_chain/"lastStage") > 0) then { //reset chain when last stage hit + GVAR(ChainStates) deleteAt _name; + }; + }; }; call (_taskHM getOrDefault ["Destructor", {}]); diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index 7d184050e4..f1716e3823 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -1,7 +1,16 @@ class Tasks { class TestTask { - Category = "Test"; - Func = QFUNC(testTask); - Params = QFUNC(testTask_p); + Category = "Test"; // what Category the task bellongs to + Func = QFUNC(testTask); // the task information needed to run the task + Params = QFUNC(testTask_p); // determines the parameters for a task, if no valid ones can be genereated return false + + /* Make the task a part of a chain of tasks to only run after other task have been succeded + class chain { + name = "TestChain"; // the chain name this task belongs to + stage = 1; // the stage in the chain this task is available + lastStage = 1; // if this task should be considered a task end stage (restart chain) + blockProgress = 1; // stop task from increasing the chain stage + }; + */ }; }; From 3b2bffe125a4343e565c465f29db6f48eadbf2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 5 Mar 2022 11:21:00 +0100 Subject: [PATCH 05/46] typos --- A3A/addons/Tasks/Core/fn_getSettings.sqf | 4 ++-- A3A/addons/Tasks/Core/fn_requestTask.sqf | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_getSettings.sqf b/A3A/addons/Tasks/Core/fn_getSettings.sqf index e83afe110a..b9b89420a3 100644 --- a/A3A/addons/Tasks/Core/fn_getSettings.sqf +++ b/A3A/addons/Tasks/Core/fn_getSettings.sqf @@ -11,11 +11,11 @@ if !("MaxTestMissions" in GVAR(Settings)) then { GVAR(Settings) set ["MaxTestMis //CBA settings if (isClass (configfile >> "CBA_Extended_EventHandlers")) then { - [QGVAR(TaskLingerTime), "SLIDER", ["Task linger time", "Time in minutes a task remains in the task list after compleation"], ["Antistasi","Tasks"], [1, 15, 3, 0], true, { + [QGVAR(TaskLingerTime), "SLIDER", ["Task linger time", "Time in minutes a task remains in the task list after completion"], ["Antistasi","Tasks"], [1, 15, 3, 0], true, { GVAR(Settings) set ["TaskLingerTime",round _this * 60]; }] call CBA_fnc_addSetting; - [QGVAR(MaxTestMissions), "SLIDER", ["Max test missions", "maximum amount of test missions that can be active at the same time"], ["Antistasi","Tasks"], [0, 10, 3, 0], true, { + [QGVAR(MaxTestMissions), "SLIDER", ["Max test missions", "Maximum amount of test missions that can be active at the same time"], ["Antistasi","Tasks"], [0, 10, 3, 0], true, { GVAR(Settings) set ["MaxTasksOfCat_Test",round _this]; }] call CBA_fnc_addSetting; diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index d9f4101bcb..46efd298ca 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -37,13 +37,13 @@ _taskTypes = _taskTypes select { //chained tasks if (isClass (_cfg/"chain")) then { private _chain = getText (_cfg/"chain"/"name"); - if (_chain isEqualTo "") then { Error_1("Missconfigured task %1, lacking name of chain", _x); continueWith false; }; + if (_chain isEqualTo "") then { Error_1("Misconfigured task %1, lacking name of chain", _x); continueWith false; }; private _requiredStage = getNumber (_cfg/"chain"/"stage"); - if (_requiredStage < 1) then { Error_1("Missconfigured task %1, chain stage requirement: >=1", _x); continueWith false; }; + if (_requiredStage < 1) then { Error_1("Misconfigured task %1, chain stage requirement: >=1", _x); continueWith false; }; private _stage = GVAR(ChainStates) getOrDefault [_chain, 1]; if (_stage isNotEqualTo _requiredStage) then { - Debug_1("%1 Chain not at the required stage for task %2 | Current: %3 | Required: %4", _chain, _x, _stage, _requiredStage); + Debug_1("%1 chain not at the required stage for task %2 | Current: %3 | Required: %4", _chain, _x, _stage, _requiredStage); continueWith false; }; }; From 89837129d5bdf75f1d6e8df799c4777d019e248d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 6 Mar 2022 15:55:07 +0100 Subject: [PATCH 06/46] fixed: passing task hm to all function calls in runtask --- A3A/addons/Tasks/Core/fn_runTask.sqf | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_runTask.sqf b/A3A/addons/Tasks/Core/fn_runTask.sqf index 8dcac572b8..9e9513e108 100644 --- a/A3A/addons/Tasks/Core/fn_runTask.sqf +++ b/A3A/addons/Tasks/Core/fn_runTask.sqf @@ -18,11 +18,11 @@ _taskHM call _taskData; _taskHM call FUNC(updateTaskState); if !("Constructor" in _taskHM) exitWith { Error_1("Task %1 lacks a constructor", configName (_taskHM get "Cfg")) }; GVAR(ActiveTasks) pushBackUnique _taskHM; -call (_taskHM get "Constructor"); +_taskHM call (_taskHM get "Constructor"); private _stage = _taskHM getOrDefault ["__CurrentStage", 1]; private _stages = (_taskHM get "Stages") select [_stage-1, count (_taskHM get "Stages")]; -if (_stage > 1) then { call ((_stages#0) getOrDefault ["Init",{}]) }; +if (_stage > 1) then { _taskHM call ((_stages#0) getOrDefault ["Init",{}]) }; _taskHM set ["Rewards",[]]; { @@ -32,13 +32,13 @@ _taskHM set ["Rewards",[]]; if !("Condition" in _x) exitWith { Error_1("Stage %1 is missing the condition",_x) }; private _endTime = time + (_x getOrDefault ["Timeout", 1e12]); - call (_x get "Action"); + _taskHM call (_x get "Action"); _taskHM call FUNC(updateTaskState); waitUntil { sleep 1; (if ("Timeout" in _x) then {time >= _endTime} else {false}) - || call (_x get "Condition") + || _taskHM call (_x get "Condition") || (_taskHM getOrDefault ["cancellationToken", false]) || (_x getOrDefault ["cancellationToken", false]) }; @@ -88,9 +88,8 @@ if (_taskHM getOrDefault ["Successful", true]) then { }; }; -call (_taskHM getOrDefault ["Destructor", {}]); - -{call _x} forEach (_taskHM get "Rewards"); +_taskHM call (_taskHM getOrDefault ["Destructor", {}]); +{_taskHM call _x} forEach (_taskHM get "Rewards"); _taskHM call FUNC(updateTaskState); GVAR(ActiveTasks) deleteAt ( GVAR(ActiveTasks) findIf {(_x get "TaskID") isEqualTo (_taskHM get "TaskID")} ); From c302ca66c3363248f83e5f65b069e4d22f4bc736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 6 Mar 2022 15:56:27 +0100 Subject: [PATCH 07/46] - improved saving efficiency - added task weights - cached task params --- A3A/addons/Tasks/Core/fn_getSaveData.sqf | 8 +++++ A3A/addons/Tasks/Core/fn_requestTask.sqf | 33 +++++++++++++++---- A3A/addons/Tasks/Tasks.hpp | 2 ++ .../core/functions/Save/fn_saveLoop.sqf | 2 +- 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 A3A/addons/Tasks/Core/fn_getSaveData.sqf diff --git a/A3A/addons/Tasks/Core/fn_getSaveData.sqf b/A3A/addons/Tasks/Core/fn_getSaveData.sqf new file mode 100644 index 0000000000..82e02c9165 --- /dev/null +++ b/A3A/addons/Tasks/Core/fn_getSaveData.sqf @@ -0,0 +1,8 @@ +#include "..\script_component.sqf" +FIX_LINE_NUMBERS() +private _saveData = []; +{ + private _cfg = _x get "Cfg"; + _saveData pushBack [configName _cfg, _x get "Params" ,_x getOrDefault ["__CurrentStage",1], getNumber (_cfg/"Version")]; +} forEach GVAR(ActiveTasks); +_saveData; diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index 46efd298ca..f36baae7cd 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -2,7 +2,7 @@ FIX_LINE_NUMBERS() params [ - ["_taskTypes",[],[[], createHashMap]] //task types or task hm + ["_taskTypes",[],[[]]] //task types or task save ]; #define TASKS_CFG (configFile/"A3A"/"Tasks") @@ -10,7 +10,22 @@ params [ if (!isServer) exitWith { Error("Server function called on client"); false }; if (isNil QGVAR(ActiveTasks)) then { GVAR(ActiveTasks) = [] }; if (isNil QGVAR(Settings)) then { call FUNC(getSettings)}; -if (_taskTypes isEqualType createHashMap) exitWith { [_taskTypes] spawn FUNC(runTask); false }; //loading task from save + +//Task loading from save, format: TaskName, Params, stage, task version +if (_taskTypes isEqualTypeParams ["",[],0,0]) exitWith { + private _cfg = TASK_CFG/(_taskTypes#0); + private _version = getNumber (_cfg/"Version"); + + if (_version isNotEqualTo (_taskTypes#3)) exitWith { false; }; + + private _taskHM = createHashMapFromArray [ + ["Cfg", _cfg] + , ["Params", _taskTypes#1] + ] + + [_taskHM] spawn FUNC(runTask); + true +}; //loading task from save // gather tasks pool private _allTasks = ("true" configClasses TASKS_CFG) apply {configName _x}; @@ -24,6 +39,7 @@ if (_taskTypes isEqualTo []) then { _taskTypes = _allTasks }; } forEach _tasksOfCat; //filter task that can be run +private _taskParams = createHashMap; _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; @@ -51,18 +67,23 @@ _taskTypes = _taskTypes select { //parameters getters of the mission type should handle mission type specific criterias private _paramsGetter = missionNamespace getVariable getText (_cfg / "Params"); if (isNil "_paramsGetter") then { Debug_1("No params getter for task %1", _x); continueWith false; }; - if ((call _paramsGetter) isEqualType false) then { Debug_1("No valid params for task %1", _x); continueWith false; }; + private _taskParam = call _paramsGetter; + private _taskParams = set [_x, _taskParam]; + + if (_taskParam isEqualType false) then { Debug_1("No valid params for task %1", _x); continueWith false; }; true; }; -private _selectedTask = selectRandom _taskTypes; +private _taskTypesWeighted = []; +{ _taskTypesWeighted append [getNumber (TASKS_CFG/_x/"Weight"), _x] } forEach _taskTypes; +private _selectedTask = selectRandomWeighted _taskTypesWeighted; if (isNil "_selectedTask") exitWith { Info_1("Unable to start a task of types: ", if ((_this#0) isEqualTo []) then {"All", _this#0}); false }; // determine task parameters private _taskHM = createHashMap; -_taskHM set ["Cfg", _selectedTask]; -_taskHM set ["Params", call (missionNameSpace getVariable [getText (_selectedTask/"Params"), {[]}])]; +_taskHM set ["Cfg", TASKS_CFG/_selectedTask]; +_taskHM set ["Params", _taskParams get _selectedTask]; // start task [_taskHM] spawn FUNC(runTask); diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index f1716e3823..bd5993670e 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -3,6 +3,8 @@ class Tasks { Category = "Test"; // what Category the task bellongs to Func = QFUNC(testTask); // the task information needed to run the task Params = QFUNC(testTask_p); // determines the parameters for a task, if no valid ones can be genereated return false + Version = 1; //version number of task, update when compatibility is broken between last version and new update + Weight = 1; /* Make the task a part of a chain of tasks to only run after other task have been succeded class chain { diff --git a/A3A/addons/core/functions/Save/fn_saveLoop.sqf b/A3A/addons/core/functions/Save/fn_saveLoop.sqf index 3e96f52e7a..4e281bdf53 100644 --- a/A3A/addons/core/functions/Save/fn_saveLoop.sqf +++ b/A3A/addons/core/functions/Save/fn_saveLoop.sqf @@ -258,7 +258,7 @@ _fuelAmountleftArray = []; //Saving the state of the testing timer ["testingTimerIsActive", testingTimerIsActive] call A3A_fnc_setStatVariable; -[QEGVAR(Tasks,ActiveTasks), +EGVAR(Tasks,ActiveTasks)] call A3A_fnc_setStatVariable; +[QEGVAR(Tasks,ActiveTasks), call EFUNC(Tasks,getSaveData)] call A3A_fnc_setStatVariable; saveProfileNamespace; savingServer = false; From 7c704e381a7a05fe795189462a8a4053e1b08c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 19 Mar 2022 19:16:34 +0100 Subject: [PATCH 08/46] fixed syntax errors whit requested changes --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index f36baae7cd..f533b5a84a 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -21,7 +21,7 @@ if (_taskTypes isEqualTypeParams ["",[],0,0]) exitWith { private _taskHM = createHashMapFromArray [ ["Cfg", _cfg] , ["Params", _taskTypes#1] - ] + ]; [_taskHM] spawn FUNC(runTask); true @@ -59,7 +59,7 @@ _taskTypes = _taskTypes select { private _stage = GVAR(ChainStates) getOrDefault [_chain, 1]; if (_stage isNotEqualTo _requiredStage) then { - Debug_1("%1 chain not at the required stage for task %2 | Current: %3 | Required: %4", _chain, _x, _stage, _requiredStage); + Debug_4("%1 chain not at the required stage for task %2 | Current: %3 | Required: %4", _chain, _x, _stage, _requiredStage); continueWith false; }; }; @@ -68,7 +68,7 @@ _taskTypes = _taskTypes select { private _paramsGetter = missionNamespace getVariable getText (_cfg / "Params"); if (isNil "_paramsGetter") then { Debug_1("No params getter for task %1", _x); continueWith false; }; private _taskParam = call _paramsGetter; - private _taskParams = set [_x, _taskParam]; + _taskParams set [_x, _taskParam]; if (_taskParam isEqualType false) then { Debug_1("No valid params for task %1", _x); continueWith false; }; From 108a4c45182771ae04adacc172f44e2c70860d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 19 Mar 2022 19:20:06 +0100 Subject: [PATCH 09/46] corrected weigthed array value weight order --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index f533b5a84a..1d6b06d276 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -76,7 +76,7 @@ _taskTypes = _taskTypes select { }; private _taskTypesWeighted = []; -{ _taskTypesWeighted append [getNumber (TASKS_CFG/_x/"Weight"), _x] } forEach _taskTypes; +{ _taskTypesWeighted append [_x, getNumber (TASKS_CFG/_x/"Weight")] } forEach _taskTypes; private _selectedTask = selectRandomWeighted _taskTypesWeighted; if (isNil "_selectedTask") exitWith { Info_1("Unable to start a task of types: ", if ((_this#0) isEqualTo []) then {"All", _this#0}); false }; From cd9d28538559a2fcaab72b881c26ca17207d5082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 19 Mar 2022 19:22:02 +0100 Subject: [PATCH 10/46] streamlined weigth based randomisation --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index 1d6b06d276..c56215a55f 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -75,9 +75,7 @@ _taskTypes = _taskTypes select { true; }; -private _taskTypesWeighted = []; -{ _taskTypesWeighted append [_x, getNumber (TASKS_CFG/_x/"Weight")] } forEach _taskTypes; -private _selectedTask = selectRandomWeighted _taskTypesWeighted; +private _selectedTask = _taskTypes selectRandomWeighted (_taskTypes apply {getNumber (TASKS_CFG/_x/"Weight")}); if (isNil "_selectedTask") exitWith { Info_1("Unable to start a task of types: ", if ((_this#0) isEqualTo []) then {"All", _this#0}); false }; // determine task parameters From 16c11f4759cfdd17bee978c731dcb63491a45bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Mon, 28 Mar 2022 23:29:05 +0200 Subject: [PATCH 11/46] ported legacy task as official --- A3A/addons/Tasks/CfgFunctions.hpp | 11 +++ .../Tasks/Helpers/fn_minutesFromNow.sqf | 40 +++++++++ .../Params/LegacyParams/fn_AS_Officail_p.sqf | 24 +++++ A3A/addons/Tasks/Tasks.hpp | 9 ++ .../Tasks/LegacyTasks/fn_AS_Official.sqf | 87 +++++++++++++++++++ A3A/addons/Tasks/stringtable.xml | 14 +++ 6 files changed, 185 insertions(+) create mode 100644 A3A/addons/Tasks/Helpers/fn_minutesFromNow.sqf create mode 100644 A3A/addons/Tasks/Params/LegacyParams/fn_AS_Officail_p.sqf create mode 100644 A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf create mode 100644 A3A/addons/Tasks/stringtable.xml diff --git a/A3A/addons/Tasks/CfgFunctions.hpp b/A3A/addons/Tasks/CfgFunctions.hpp index cf8ddec798..9026290a6e 100644 --- a/A3A/addons/Tasks/CfgFunctions.hpp +++ b/A3A/addons/Tasks/CfgFunctions.hpp @@ -11,6 +11,7 @@ class CfgFunctions { class Helpers { // task helper functions | Common functionality used by tasks or the params getters file = QPATHTOFOLDER(Helpers); + class minutesFromNow {}; class nearFriendlyMarkers {}; class nearHostileMarkers {}; }; @@ -22,5 +23,15 @@ class CfgFunctions { file = QPATHTOFOLDER(Tasks); class testTask {}; }; + + //Legacy missions + class LegacyParams { + file = QPATHTOFOLDER(Params\LegacyParams); + class AS_Official_p {}; + }; + class LegacyTasks { + file = QPATHTOFOLDER(Tasks\LegacyTasks); + class AS_Official {}; + }; }; }; diff --git a/A3A/addons/Tasks/Helpers/fn_minutesFromNow.sqf b/A3A/addons/Tasks/Helpers/fn_minutesFromNow.sqf new file mode 100644 index 0000000000..a3f2870df8 --- /dev/null +++ b/A3A/addons/Tasks/Helpers/fn_minutesFromNow.sqf @@ -0,0 +1,40 @@ +/* +Author: Håkon +Description: + returns the ingame time X minutes from now + +Arguments: +0. minutes + +Return Value: + formated time string "H:M" + +Scope: Any +Environment: Any +Public: Yes +Dependencies: + +Example: + private _time = [20] call FUNC(minutesFromNow); //returns formated time 20 minutes from the call +License: MIT License +*/ +#include "..\script_component.hpp" +FIX_LINE_NUMBERS() + +params [["_minutesDiff", 0, [0]]]; +if (_minutesDiff < 0) then { + Error_1("Function does not support negative time: %1", _minutesDiff); + _minutesDiff = 0; +}; + +// get current time +private _dayTime = daytime; +private _hours = floor _dayTime; +private _minutes = floor ((_dayTime - _hours) * 60); + +// calculate time from now +_minutes = _minutes + _minutesDiff; +_hours = _hours + floor (_minutes/60); +_minutes = floor (_minutes % 60); + +str _hours + ":" + str _minutes; diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_Officail_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_Officail_p.sqf new file mode 100644 index 0000000000..4985f2a36b --- /dev/null +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_Officail_p.sqf @@ -0,0 +1,24 @@ +/* +Author: Håkon +Description: + Can spawn in any hostile cities in mission distance from the current rebel HQ location + +Return Value: + false if valid location couldn't be found +> an array containing a single marker from the citiesX array + +Scope: Any +Environment: Any +Public: Yes +Dependencies: + +Example: + +License: MIT License +*/ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() +private _possibleMarkers = [citiesX] call FUNC(nearHostileMarkers); +private _marker = selectRandom _possibleMarkers; +if (isNil "_marker") exitWith {false}; +[_marker]; diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index bd5993670e..03ae19773a 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -15,4 +15,13 @@ class Tasks { }; */ }; + + //Legacy tasks + class L_AS_Official { + Category = "AS"; // what Category the task bellongs to + Func = QFUNC(AS_Official); // the task information needed to run the task + Params = QFUNC(AS_Official_p); // determines the parameters for a task, if no valid ones can be genereated return false + Version = 1; //version number of task, update when compatibility is broken between last version and new update + Weight = 1; + }; }; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf new file mode 100644 index 0000000000..c3315c3a1a --- /dev/null +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf @@ -0,0 +1,87 @@ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() + +(_this get "Params") params [["_marker", "", [""]]]; +if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { + Error_1("Assassinate official mission started with bad marker name | %1", _this); +}; + +private _side = sidesX getVariable _marker; +private _faction = Faction(_side); + +_this set ["side", _side]; +_this set ["faction", _faction]; +_this set ["isDifficult",(random 10 < tierWar)]; + +//get info for description +private _nameDest = [_marker] call A3A_fnc_localizar; +private _timeLimit = if (_this get "isDifficult") then {15} else {30}; +private _endTime = [_timeLimit] call FUNC(minutesFromNow); + +_this set ["title", "STR_antistasi_LTasks_AS_official_title"]; //test if it will localize from key +_this set ["description", format [ + localize "STR_antistasi_LTasks_AS_official_description", + _faction get "name", + _nameDest, + _endTime +]]; +_this set ["marker", _marker]; +_this set ["destination", getMarkerPos _marker]; + +_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task + private _faction = _this get "faction"; + private _group = createGroup (_this get "side"); + private _official = [_group, _faction get "unitOfficial", _this get "destination", [], 0, "NONE"] call A3A_fnc_createUnit; + + private _guardsTypes = [_faction get "unitBodyguard"]; + if (_this get "isDifficult") then {_guardsTypes append [ + _faction get "unitBodyguard",_faction get "unitBodyguard",_faction get "unitBodyguard",_faction get "unitBodyguard" + ]}; + private _guards = []; + { + _guards pushBack [_group, _x, _this get "destination", [], 0, "NONE"] call A3A_fnc_createUnit; + } forEach _guardsTypes; + + _this set ["official", _official]; + _this set ["guards", _guards]; +}]; + +_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task + waitUntil { + (spawner getVariable (_this get "marker")) isEqualTo 2 // not spawned + }; + { deleteVehicle _x } forEach ([_this get "official"] + (_this get "guards")); +}]; + +_stages = [ + createHashMapFromArray [ + ["Action", { //Type: code | Required | Action to be done in that stage + private _official = _this get "official"; + private _group = group _official; + _group selectLeader _official; + + //patrol behaviour to be replaced by vcom + [leader _group, _this get "marker", "SAFE", "SPAWNED", "NOVEH", "NOFOLLOW"] execVM EQPATHTOFOLDER(core,scripts\UPSMON.sqf); + { + [_x] call A3A_fnc_NATOinit; + _x allowFleeing 0; + } forEach ([_official] + (_this get "guards")); + }], + ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + !alive (_this get "official"); + }], + ["Reward", { //Type: code | Optional | the reward given for completing the stage + private _multiplier = if (_this get "isDifficult") then {2} else {1}; + + [0,300 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; + [1200 + 600 * _multiplier, _this get "side"] remoteExec ["A3A_fnc_timingCA",2]; + { + if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}; + } forEach ([500,0,getMarkerPos (_this get "marker"),teamPlayer] call A3A_fnc_distanceUnits); + [5 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; + [_this get "marker",30 * _multiplier] call A3A_fnc_addTimeForIdle; + }], + ["Timeout", (if (_this get "isDifficult") then {15} else {30}) * 60] //Type: number | Optional | Time limit for the stage before auto fail + ] +]; +_this set ["Stages", _stages]; diff --git a/A3A/addons/Tasks/stringtable.xml b/A3A/addons/Tasks/stringtable.xml new file mode 100644 index 0000000000..58b5c4c552 --- /dev/null +++ b/A3A/addons/Tasks/stringtable.xml @@ -0,0 +1,14 @@ + + + + + + Kill the Officer + + + + A %1 officer is inspecting %2. Go there and kill him before %3. + + + + From 248fe4412513ce2cbea50ee1ed3b63b122279caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Mon, 28 Mar 2022 23:34:46 +0200 Subject: [PATCH 12/46] added punishment for failing mission... whops --- .../Tasks/LegacyTasks/fn_AS_Official.sqf | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf index c3315c3a1a..591b2c9440 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf @@ -72,14 +72,19 @@ _stages = [ }], ["Reward", { //Type: code | Optional | the reward given for completing the stage private _multiplier = if (_this get "isDifficult") then {2} else {1}; - - [0,300 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; - [1200 + 600 * _multiplier, _this get "side"] remoteExec ["A3A_fnc_timingCA",2]; - { - if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}; - } forEach ([500,0,getMarkerPos (_this get "marker"),teamPlayer] call A3A_fnc_distanceUnits); - [5 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; - [_this get "marker",30 * _multiplier] call A3A_fnc_addTimeForIdle; + if ((_this get "state") isEqualTo "SUCCEEDED") then { + [0,300 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; + [1200 + 600 * _multiplier, _this get "side"] remoteExec ["A3A_fnc_timingCA",2]; + { + if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}; + } forEach ([500,0,getMarkerPos (_this get "marker"),teamPlayer] call A3A_fnc_distanceUnits); + [5 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; + [_this get "marker",30 * _multiplier] call A3A_fnc_addTimeForIdle; + } else { + [-600 * _multiplier, _this get "side"] remoteExec ["A3A_fnc_timingCA",2]; + [-10 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; + [_this get "marker",-30 * _multiplier] call A3A_fnc_addTimeForIdle; + }; }], ["Timeout", (if (_this get "isDifficult") then {15} else {30}) * 60] //Type: number | Optional | Time limit for the stage before auto fail ] From e621d7ee387f154c3645334db6cf7cce46864cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Tue, 29 Mar 2022 00:20:31 +0200 Subject: [PATCH 13/46] added support for addon dependancies for missions (uses standard requiredAddons syntax in config) --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index c56215a55f..91e8020ffc 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -39,11 +39,17 @@ if (_taskTypes isEqualTo []) then { _taskTypes = _allTasks }; } forEach _tasksOfCat; //filter task that can be run +private _fnc_requirementMeet = { getArray (_this/"requiredAddons") findIf { !(isClass (configFile/"CfgPatches"/_x)) } == -1 }; private _taskParams = createHashMap; _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; //Common criterias + private _requiredAddons = getArray (_cfg/"requiredAddons"); + if (_requiredAddons findIf {!([_x] call _fnc_requirementMeet)} < 0) then { + Debug_2("Task %1 is missing one or more required addons: %2", _x, _requiredAddons); continueWith false; + }; + private _cat = getText (_cfg/"Category"); if !( { (_x get "Category") isEqualTo _cat } count GVAR(ActiveTasks) From e18c5f7447446662fcc1d0b139f5b247c8c8f9e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 2 Apr 2022 18:02:00 +0200 Subject: [PATCH 14/46] unified timelimit to one line --- A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf index 591b2c9440..2fc403298f 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf @@ -86,7 +86,7 @@ _stages = [ [_this get "marker",-30 * _multiplier] call A3A_fnc_addTimeForIdle; }; }], - ["Timeout", (if (_this get "isDifficult") then {15} else {30}) * 60] //Type: number | Optional | Time limit for the stage before auto fail + ["Timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail ] ]; _this set ["Stages", _stages]; From f972ec9bfc54aca263b98e8450c1badbd6cc1649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 2 Apr 2022 18:02:25 +0200 Subject: [PATCH 15/46] ported specOp task to new framework --- A3A/addons/Tasks/CfgFunctions.hpp | 2 + .../Params/LegacyParams/fn_AS_specOP_p.sqf | 13 ++++ A3A/addons/Tasks/Tasks.hpp | 7 ++ .../Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf | 70 +++++++++++++++++++ A3A/addons/Tasks/stringtable.xml | 7 ++ 5 files changed, 99 insertions(+) create mode 100644 A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf create mode 100644 A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf diff --git a/A3A/addons/Tasks/CfgFunctions.hpp b/A3A/addons/Tasks/CfgFunctions.hpp index 9026290a6e..4584f9979b 100644 --- a/A3A/addons/Tasks/CfgFunctions.hpp +++ b/A3A/addons/Tasks/CfgFunctions.hpp @@ -28,10 +28,12 @@ class CfgFunctions { class LegacyParams { file = QPATHTOFOLDER(Params\LegacyParams); class AS_Official_p {}; + class AS_specOP_p {}; }; class LegacyTasks { file = QPATHTOFOLDER(Tasks\LegacyTasks); class AS_Official {}; + class AS_specOP {}; }; }; }; diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf new file mode 100644 index 0000000000..d5545aea53 --- /dev/null +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf @@ -0,0 +1,13 @@ + +private _possibleMarkers = []; +private _controlsX = [controlsX] FUNC(nearHostileMarkers); +private _nearbyFriendlyMarkers = FUNC(nearFriendlyMarkers); +{ + private _pos = getmarkerPos _x; + if !(isOnRoad _pos) then { + if (_nearbyFriendlyMarkers findIf {getMarkerPos _x distance _pos < distanceSPWN} != -1) then {_possibleMarkers pushBack _x}; + }; +}forEach _controlsX; + +if (_possibleMarkers isEqualTo []) exitWith {false}; +_possibleMarkers; diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index 03ae19773a..fcbbc1b32d 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -24,4 +24,11 @@ class Tasks { Version = 1; //version number of task, update when compatibility is broken between last version and new update Weight = 1; }; + class L_AS_specOP { + Category = "AS"; // what Category the task bellongs to + Func = QFUNC(AS_specOP); // the task information needed to run the task + Params = QFUNC(AS_specOP_p); // determines the parameters for a task, if no valid ones can be genereated return false + Version = 1; //version number of task, update when compatibility is broken between last version and new update + Weight = 1; + }; }; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf new file mode 100644 index 0000000000..3d241524cf --- /dev/null +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf @@ -0,0 +1,70 @@ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() + +(_this get "Params") params [["_marker", "", [""]]]; +if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { + Error_1("SpecOP mission started with bad marker name | %1", _this); +}; + +private _side = sidesX getVariable _marker; +private _faction = Faction(_side); + +_this set ["side", _side]; +_this set ["faction", _faction]; +_this set ["isDifficult",(random 10 < tierWar)]; + +//get info for description +private _nameDest = [_marker] call A3A_fnc_localizar; +private _timeLimit = if (_this get "isDifficult") then {60} else {120}; +private _endTime = [_timeLimit] call FUNC(minutesFromNow); + +_this set ["title", "STR_antistasi_LTasks_AS_specOP_title"]; //test if it will localize from key +_this set ["description", format [ + localize "STR_antistasi_LTasks_AS_specOP_description", + _faction get "name", + _nameDest, + _endTime +]]; +_this set ["marker", _marker]; +_this set ["destination", getMarkerPos _marker]; + +_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task +}]; + +_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task +}]; + +_stages = [ + createHashMapFromArray [ + ["Action", { //Type: code | Required | Action to be done in that stage + //relies on createAIControl, this should change for the future + }], + ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + (sidesX getVariable [_this get "marker", sideUnknown]) isEqualTo teamPlayer; + }], + ["Reward", { //Type: code | Optional | the reward given for completing the stage + private _multiplier = if (_this get "isDifficult") then {2} else {1}; + private _pos = getMarkerPos (_this get "marker"); + private _side = _this get "side"; + + if ((_this get "state") isEqualTo "SUCCEEDED") then { //to do check environment of the remoteExec funcs as we are already on server + [0,200 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; + { + if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd} + } forEach ([500,0,_pos,teamPlayer] call A3A_fnc_distanceUnits); + [10 * _multiplier, theBoss] call A3A_fnc_playerScoreAdd; + + [600 * _multiplier, _side] remoteExec ["A3A_fnc_timingCA",2]; + [0, 5 * _multiplier, _pos] remoteExec ["A3A_fnc_citySupportChange",2]; + + [_side, 10, 60] remoteExec ["A3A_fnc_addAggression", 2]; + } else { + [-10 * _multiplier, theBoss] call A3A_fnc_playerScoreAdd; + [5 * _multiplier, 0, _pos] remoteExec ["A3A_fnc_citySupportChange",2]; + [-600 * _multiplier, _side] remoteExec ["A3A_fnc_timingCA",2]; + }; + }], + ["Timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail + ] +]; +_this set ["Stages", _stages]; diff --git a/A3A/addons/Tasks/stringtable.xml b/A3A/addons/Tasks/stringtable.xml index 58b5c4c552..0418e9be11 100644 --- a/A3A/addons/Tasks/stringtable.xml +++ b/A3A/addons/Tasks/stringtable.xml @@ -9,6 +9,13 @@ A %1 officer is inspecting %2. Go there and kill him before %3. + + SpecOps + + + + We have spotted a %1 SpecOp team patrolling around a %2. Ambush them and we will have one less problem. Do this before %3. Be careful, they are tough boys. + From 6e8733f91702f7d8b006f2c48d357eb3d1aaff60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 2 Apr 2022 18:39:15 +0200 Subject: [PATCH 16/46] added missing calls in new task params getter --- A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf index d5545aea53..623bb211da 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf @@ -1,7 +1,7 @@ private _possibleMarkers = []; -private _controlsX = [controlsX] FUNC(nearHostileMarkers); -private _nearbyFriendlyMarkers = FUNC(nearFriendlyMarkers); +private _controlsX = [controlsX] call FUNC(nearHostileMarkers); +private _nearbyFriendlyMarkers = call FUNC(nearFriendlyMarkers); { private _pos = getmarkerPos _x; if !(isOnRoad _pos) then { From 0553f56ed29b10ccd935bce33f310e2efec18ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Apr 2022 22:41:18 +0200 Subject: [PATCH 17/46] - corrected typo in filename - corrected incorrect site pool for as_official --- .../LegacyParams/{fn_AS_Officail_p.sqf => fn_AS_Official_p.sqf} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename A3A/addons/Tasks/Params/LegacyParams/{fn_AS_Officail_p.sqf => fn_AS_Official_p.sqf} (87%) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_Officail_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_Official_p.sqf similarity index 87% rename from A3A/addons/Tasks/Params/LegacyParams/fn_AS_Officail_p.sqf rename to A3A/addons/Tasks/Params/LegacyParams/fn_AS_Official_p.sqf index 4985f2a36b..1e6e3e5eed 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_Officail_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_Official_p.sqf @@ -18,7 +18,7 @@ License: MIT License */ #include "..\..\script_component.hpp" FIX_LINE_NUMBERS() -private _possibleMarkers = [citiesX] call FUNC(nearHostileMarkers); +private _possibleMarkers = [airportsX] call FUNC(nearHostileMarkers); private _marker = selectRandom _possibleMarkers; if (isNil "_marker") exitWith {false}; [_marker]; From f51333b67a9fb7a77500d45ba10d923ae2dc8e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 10:12:35 +0200 Subject: [PATCH 18/46] fixed required addons check --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index 91e8020ffc..cde4329777 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -45,9 +45,8 @@ _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; //Common criterias - private _requiredAddons = getArray (_cfg/"requiredAddons"); - if (_requiredAddons findIf {!([_x] call _fnc_requirementMeet)} < 0) then { - Debug_2("Task %1 is missing one or more required addons: %2", _x, _requiredAddons); continueWith false; + if ([_cfg] call _fnc_requirementMeet) then { + Debug_2("Task %1 is missing one or more required addons: %2", _x, getArray (_cfg/_requiredAddons)); continueWith false; }; private _cat = getText (_cfg/"Category"); From 86698ef74ea0721cac092f56d70ea81d67df7ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 10:16:46 +0200 Subject: [PATCH 19/46] corrected max task of cat default when no setting has been mae for it (deafults to 1) --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index cde4329777..060e1d4f88 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -52,7 +52,7 @@ _taskTypes = _taskTypes select { private _cat = getText (_cfg/"Category"); if !( { (_x get "Category") isEqualTo _cat } count GVAR(ActiveTasks) - < ( GVAR(Settings) get ("MaxTasksOfCat_" + _cat) ) + < ( GVAR(Settings) getOrDefault ["MaxTasksOfCat_" + _cat, 1, true] ) ) then { Debug_1("Max tasks of type %1 active", _x); continueWith false; }; //chained tasks From 299e1ac9c386a052ae32718ca03d0abd7f3fa58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 10:21:06 +0200 Subject: [PATCH 20/46] changed naming of genTaskID -> genTaskUID --- A3A/addons/Tasks/CfgFunctions.hpp | 2 +- A3A/addons/Tasks/Core/{fn_genTaskID.sqf => fn_genTaskUID.sqf} | 4 ++-- A3A/addons/Tasks/Core/fn_getSettings.sqf | 2 +- A3A/addons/Tasks/Core/fn_runTask.sqf | 2 +- A3A/addons/Tasks/Core/fn_updateTaskState.sqf | 2 +- A3A/addons/Tasks/Tasks/fn_testTask.sqf | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename A3A/addons/Tasks/Core/{fn_genTaskID.sqf => fn_genTaskUID.sqf} (60%) diff --git a/A3A/addons/Tasks/CfgFunctions.hpp b/A3A/addons/Tasks/CfgFunctions.hpp index 4584f9979b..6dce0ebada 100644 --- a/A3A/addons/Tasks/CfgFunctions.hpp +++ b/A3A/addons/Tasks/CfgFunctions.hpp @@ -2,7 +2,7 @@ class CfgFunctions { class ADDON { class Core { file = QPATHTOFOLDER(Core); - class genTaskID {}; + class genTaskUID {}; class getSettings { postInit = 1; }; class requestTask {}; class runTask {}; diff --git a/A3A/addons/Tasks/Core/fn_genTaskID.sqf b/A3A/addons/Tasks/Core/fn_genTaskUID.sqf similarity index 60% rename from A3A/addons/Tasks/Core/fn_genTaskID.sqf rename to A3A/addons/Tasks/Core/fn_genTaskUID.sqf index c8f606b395..09330aab1c 100644 --- a/A3A/addons/Tasks/Core/fn_genTaskID.sqf +++ b/A3A/addons/Tasks/Core/fn_genTaskUID.sqf @@ -2,5 +2,5 @@ FIX_LINE_NUMBERS() if (!isServer) exitWith {}; -GVAR(TaskID) = GVAR(TaskID) + 1; -str GVAR(TaskID); +GVAR(TaskUID) = GVAR(TaskUID) + 1; +str GVAR(TaskUID); diff --git a/A3A/addons/Tasks/Core/fn_getSettings.sqf b/A3A/addons/Tasks/Core/fn_getSettings.sqf index b9b89420a3..deba6ac798 100644 --- a/A3A/addons/Tasks/Core/fn_getSettings.sqf +++ b/A3A/addons/Tasks/Core/fn_getSettings.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" FIX_LINE_NUMBERS() -if (isNil QGVAR(TaskID)) then { GVAR(TaskID) = 0 }; +if (isNil QGVAR(TaskUID)) then { GVAR(TaskUID) = 0 }; if (isNil QGVAR(ChainStates)) then { GVAR(ChainStates) = createHashMap }; if (isNil QGVAR(Settings)) then { GVAR(Settings) = createHashMap }; diff --git a/A3A/addons/Tasks/Core/fn_runTask.sqf b/A3A/addons/Tasks/Core/fn_runTask.sqf index 9e9513e108..b199dc8c40 100644 --- a/A3A/addons/Tasks/Core/fn_runTask.sqf +++ b/A3A/addons/Tasks/Core/fn_runTask.sqf @@ -7,7 +7,7 @@ params [["_taskHM", _emptyHM, [_emptyHM]]]; if (_taskHM isEqualTo _emptyHM) exitWith { Error_1("Invalid parameters passed: %1", _this) }; if (!canSuspend) exitWith { Error_1("Tasks needs to run in scheduled environment") }; -_taskHM set ["TaskID", call FUNC(genTaskID)]; +_taskHM set ["TaskID", call FUNC(genTaskUID)]; //load task private _taskData = missionNameSpace getVariable getText ((_taskHM get "Cfg") / "Func"); diff --git a/A3A/addons/Tasks/Core/fn_updateTaskState.sqf b/A3A/addons/Tasks/Core/fn_updateTaskState.sqf index b23a846870..7fa88c8d63 100644 --- a/A3A/addons/Tasks/Core/fn_updateTaskState.sqf +++ b/A3A/addons/Tasks/Core/fn_updateTaskState.sqf @@ -4,7 +4,7 @@ params ["_taskHM"]; //get task state from hm private _taskID = _taskHM get "TaskID"; -if (isNil "_taskID") then { _taskID = call FUNC(genTaskID); _taskHM set ["TaskID", _taskID]; }; +if (isNil "_taskID") then { _taskID = call FUNC(genTaskUID); _taskHM set ["TaskID", _taskID]; }; if (_taskID isEqualType []) then {_taskID = _taskID#0}; private _description = [ diff --git a/A3A/addons/Tasks/Tasks/fn_testTask.sqf b/A3A/addons/Tasks/Tasks/fn_testTask.sqf index c49796a893..4cb58abf3a 100644 --- a/A3A/addons/Tasks/Tasks/fn_testTask.sqf +++ b/A3A/addons/Tasks/Tasks/fn_testTask.sqf @@ -57,7 +57,7 @@ _this set ["Stages", _stages]; _this set ["Children", [_subTaskA]]; */ private _subTaskA = createHashMap; -_subTaskA set ["TaskID", [call FUNC(genTaskID), _this get "TaskID"]]; +_subTaskA set ["TaskID", [call FUNC(genTaskUID), _this get "TaskID"]]; _subTaskA set ["title", "Test sub task A"]; _subTaskA set ["description", "Test sub task A description"]; _this set ["Children", [_subTaskA]]; // Type: Array of hashMaps | Optional | sub tasks of the main task From 31aff5b41dc05335e4a1a7482059f2e6e33ddc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 15:41:37 +0200 Subject: [PATCH 21/46] fixed bad arguments for requiredAddons check --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index 060e1d4f88..ea3c2c117f 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -45,7 +45,7 @@ _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; //Common criterias - if ([_cfg] call _fnc_requirementMeet) then { + if (_cfg call _fnc_requirementMeet) then { Debug_2("Task %1 is missing one or more required addons: %2", _x, getArray (_cfg/_requiredAddons)); continueWith false; }; From 507d862c07630ee7571fa1fc6e6781a3e919b8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 15:53:50 +0200 Subject: [PATCH 22/46] corrected inverted if statement --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index ea3c2c117f..e15bc0daa1 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -45,7 +45,7 @@ _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; //Common criterias - if (_cfg call _fnc_requirementMeet) then { + if (!_cfg call _fnc_requirementMeet) then { Debug_2("Task %1 is missing one or more required addons: %2", _x, getArray (_cfg/_requiredAddons)); continueWith false; }; From 8b87cd3fc59df9f0b0f912097edff15e94ecaf09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 15:53:58 +0200 Subject: [PATCH 23/46] added missing includes --- A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf index 623bb211da..765c3c91f5 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf @@ -1,3 +1,5 @@ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() private _possibleMarkers = []; private _controlsX = [controlsX] call FUNC(nearHostileMarkers); From 5a25685dbb99394b016d16ffab13204e75ec2c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 15:58:09 +0200 Subject: [PATCH 24/46] fixed wrong oop --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index e15bc0daa1..a066232827 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -45,7 +45,7 @@ _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; //Common criterias - if (!_cfg call _fnc_requirementMeet) then { + if !(_cfg call _fnc_requirementMeet) then { Debug_2("Task %1 is missing one or more required addons: %2", _x, getArray (_cfg/_requiredAddons)); continueWith false; }; From 92722999b53d80bf9cc5cc683ec61340ac880842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 15:41:37 +0200 Subject: [PATCH 25/46] fixed bad arguments for requiredAddons check --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index a066232827..7518f8d9b4 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -45,7 +45,11 @@ _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; //Common criterias +<<<<<<< HEAD if !(_cfg call _fnc_requirementMeet) then { +======= + if (_cfg call _fnc_requirementMeet) then { +>>>>>>> 31aff5b4 (fixed bad arguments for requiredAddons check) Debug_2("Task %1 is missing one or more required addons: %2", _x, getArray (_cfg/_requiredAddons)); continueWith false; }; From df06727996414032839fa4ee448333218f7880a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 3 Jul 2022 15:53:50 +0200 Subject: [PATCH 26/46] corrected inverted if statement --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index 7518f8d9b4..3626c540ba 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -45,11 +45,8 @@ _taskTypes = _taskTypes select { private _cfg = TASKS_CFG / _x; //Common criterias -<<<<<<< HEAD + if !(_cfg call _fnc_requirementMeet) then { -======= - if (_cfg call _fnc_requirementMeet) then { ->>>>>>> 31aff5b4 (fixed bad arguments for requiredAddons check) Debug_2("Task %1 is missing one or more required addons: %2", _x, getArray (_cfg/_requiredAddons)); continueWith false; }; From ae1519cafe39dc6df5350cf65030d8ad7ad9cd85 Mon Sep 17 00:00:00 2001 From: Julia Kowalik Date: Sun, 3 Jul 2022 16:00:51 +0200 Subject: [PATCH 27/46] Ported CON_Outpost to new Framework --- A3A/addons/Tasks/CfgFunctions.hpp | 2 + .../Params/LegacyParams/fn_CON_Outpost_p.sqf | 8 ++ A3A/addons/Tasks/Tasks.hpp | 7 ++ .../Tasks/LegacyTasks/fn_CON_Outpost.sqf | 86 +++++++++++++++++++ A3A/addons/Tasks/stringtable.xml | 30 +++++++ 5 files changed, 133 insertions(+) create mode 100644 A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf create mode 100644 A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf diff --git a/A3A/addons/Tasks/CfgFunctions.hpp b/A3A/addons/Tasks/CfgFunctions.hpp index 6dce0ebada..66b5c0df1d 100644 --- a/A3A/addons/Tasks/CfgFunctions.hpp +++ b/A3A/addons/Tasks/CfgFunctions.hpp @@ -29,11 +29,13 @@ class CfgFunctions { file = QPATHTOFOLDER(Params\LegacyParams); class AS_Official_p {}; class AS_specOP_p {}; + class CON_Outpost_p {}; }; class LegacyTasks { file = QPATHTOFOLDER(Tasks\LegacyTasks); class AS_Official {}; class AS_specOP {}; + class CON_Outpost {}; }; }; }; diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf new file mode 100644 index 0000000000..1d61aac82f --- /dev/null +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf @@ -0,0 +1,8 @@ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() + +private _roadblocks = controlsX findIf { isOnRoad getMarkerPos _x }; +private _possibleMarkers = [outposts + resourcesX + factories + seaports + _roadblocks] call FUNC(nearHostileMarkers); + +if (_possibleMarkers isEqualTo []) exitWith {false}; +_possibleMarkers; \ No newline at end of file diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index fcbbc1b32d..d0021b825f 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -31,4 +31,11 @@ class Tasks { Version = 1; //version number of task, update when compatibility is broken between last version and new update Weight = 1; }; + class L_CON_Outpost { + Category = "CON"; // what Category the task bellongs to + Func = QFUNC(CON_Outpost); // the task information needed to run the task + Params = QFUNC(CON_Outpost_p); // determines the parameters for a task, if no valid ones can be genereated return false + Version = 1; //version number of task, update when compatibility is broken between last version and new update + Weight = 1; + }; }; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf new file mode 100644 index 0000000000..71dfeb9ea3 --- /dev/null +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf @@ -0,0 +1,86 @@ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() + +(_this get "Params") params [["_marker", "", [""]]]; +if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { + Error_1("Conquest mission started with bad marker name | %1", _this); +}; + +private _side = sidesX getVariable _marker; +private _faction = Faction(_side); + +_this set ["side", _side]; +_this set ["faction", _faction]; +_this set ["isDifficult", (random 10 < tierWar)]; +_this set ["destination", getMarkerPos _marker]; +_this set ["marker", _marker]; + +private _nameDest = [_marker] call A3A_fnc_localizar; + +private _timeLimit = if (_this get "isDifficult") then {30} else {90}; +if (A3A_hasIFA) then {_timeLimit = _timeLimit * 2}; + +private _displayTime = [_timeLimit] call FUNC(minutesFromNow); +private _markerSide = sidesX getVariable [_marker, sideUnknown]; + +private _taskName = ""; +private _taskDescription = ""; + +if (_marker in resourcesX) then { + _taskName = localize "STR_antistasi_LTasks_CON_Outpost_resource_title"; + _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_resource_description"), _nameDest, _displayTime]; +}; +if (_marker in outposts) then { + _taskName = localize "STR_antistasi_LTasks_CON_Outpost_outpost_title"; + _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_outpost_description"), _nameDest, _displayTime]; +}; +if (_marker in seaports) then { + _taskName = localize "STR_antistasi_LTasks_CON_Outpost_seaport_title"; + _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_seaport_description"), _nameDest, _displayTime]; +}; +if (_marker in factories) then { + _taskName = localize "STR_antistasi_LTasks_CON_Outpost_factory_title"; + _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_factory_description"), _nameDest, _displayTime]; +}; + +_this set ["title", _taskName]; +_this set ["description", _taskDescription]; + +_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task +}]; + +_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task +}]; + +_stages = [ + createHashMapFromArray [ + ["Action", { //Type: code | Required | Action to be done in that stage + }], + ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + (sidesX getVariable [_this get "marker", sideUnknown]) isEqualTo teamPlayer; + }], + ["Required", true], //Type: bool | Optional | if the task needs the stage to succeed + ["Reward", { //Type: code | Optional | the reward given for completing the stage + private _multiplier = if (_this get "isDifficult") then {2} else {1}; + private _pos = getMarkerPos (_this get "marker"); + private _side = _this get "side"; + + if ((_this get "state") isEqualTo "SUCCEEDED") then + { + [0,200 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; + [-5 * _multiplier,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; + [600 * _multiplier, _side] remoteExec ["A3A_fnc_timingCA",2]; + {if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}} forEach ([500,0,_pos,teamPlayer] call A3A_fnc_distanceUnits); + [10 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; + } + else + { + [5,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; + [-600, _side] remoteExec ["A3A_fnc_timingCA",2]; + [-10,theBoss] call A3A_fnc_playerScoreAdd; + }; + }], + ["Timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail + ] +]; +_this set ["Stages", _stages]; \ No newline at end of file diff --git a/A3A/addons/Tasks/stringtable.xml b/A3A/addons/Tasks/stringtable.xml index 0418e9be11..938da55283 100644 --- a/A3A/addons/Tasks/stringtable.xml +++ b/A3A/addons/Tasks/stringtable.xml @@ -16,6 +16,36 @@ We have spotted a %1 SpecOp team patrolling around a %2. Ambush them and we will have one less problem. Do this before %3. Be careful, they are tough boys. + + + + Resource Acquisition + + + + A %1 would be a fine addition to our cause. Go there and capture it before %2. + + + Take the Outpost + + + + A %1 is disturbing our operations in the area. Go there and capture it before %2. + + + Secure the Seaport + + + + %1 is an important fishing supplier for our local Fish&Chips dinners. Go there and capture it before %2. + + + Reclaim means of production + + + + %1 is being used to aid the enemy. Go there and capture it before %2. + From e0d02c75a4451942ec8f83a6b805ccf07a5bab06 Mon Sep 17 00:00:00 2001 From: Julia Kowalik Date: Sun, 3 Jul 2022 17:05:50 +0200 Subject: [PATCH 28/46] Fixed array concatenation of non-array type --- A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf index 1d61aac82f..a7b62172ad 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf @@ -1,7 +1,7 @@ #include "..\..\script_component.hpp" FIX_LINE_NUMBERS() -private _roadblocks = controlsX findIf { isOnRoad getMarkerPos _x }; +private _roadblocks = controlsX select { isOnRoad getMarkerPos _x }; private _possibleMarkers = [outposts + resourcesX + factories + seaports + _roadblocks] call FUNC(nearHostileMarkers); if (_possibleMarkers isEqualTo []) exitWith {false}; From 3976fd92f1a86331e3892a2d88ca848fa4739e74 Mon Sep 17 00:00:00 2001 From: Julia Kowalik Date: Sun, 3 Jul 2022 17:06:59 +0200 Subject: [PATCH 29/46] Code style and formatting improvements --- .../Tasks/LegacyTasks/fn_CON_Outpost.sqf | 65 +++++++++---------- A3A/addons/Tasks/stringtable.xml | 2 - 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf index 71dfeb9ea3..fa7d3d7913 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf @@ -23,25 +23,24 @@ if (A3A_hasIFA) then {_timeLimit = _timeLimit * 2}; private _displayTime = [_timeLimit] call FUNC(minutesFromNow); private _markerSide = sidesX getVariable [_marker, sideUnknown]; -private _taskName = ""; -private _taskDescription = ""; - -if (_marker in resourcesX) then { - _taskName = localize "STR_antistasi_LTasks_CON_Outpost_resource_title"; - _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_resource_description"), _nameDest, _displayTime]; -}; -if (_marker in outposts) then { - _taskName = localize "STR_antistasi_LTasks_CON_Outpost_outpost_title"; - _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_outpost_description"), _nameDest, _displayTime]; -}; -if (_marker in seaports) then { - _taskName = localize "STR_antistasi_LTasks_CON_Outpost_seaport_title"; - _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_seaport_description"), _nameDest, _displayTime]; -}; -if (_marker in factories) then { - _taskName = localize "STR_antistasi_LTasks_CON_Outpost_factory_title"; - _taskDescription = format [(localize "STR_antistasi_LTasks_CON_Outpost_factory_description"), _nameDest, _displayTime]; -}; +switch (true) do { + case (_marker in resourcesX): { [ + localize "STR_antistasi_LTasks_CON_Outpost_resource_title", + format [(localize "STR_antistasi_LTasks_CON_Outpost_resource_description"), _nameDest, _displayTime] + ]}; + case (_marker in outposts): { [ + localize "STR_antistasi_LTasks_CON_Outpost_outpost_title", + format [(localize "STR_antistasi_LTasks_CON_Outpost_outpost_description"), _nameDest, _displayTime] + ]}; + case (_marker in seaports): { [ + localize "STR_antistasi_LTasks_CON_Outpost_seaport_title", + format [(localize "STR_antistasi_LTasks_CON_Outpost_seaport_description"), _nameDest, _displayTime] + ]}; + case (_marker in factories): { [ + localize "STR_antistasi_LTasks_CON_Outpost_factory_title", + format [(localize "STR_antistasi_LTasks_CON_Outpost_factory_description"), _nameDest, _displayTime] + ]}; +} params ["_taskName", "_taskDescription"]; _this set ["title", _taskName]; _this set ["description", _taskDescription]; @@ -62,22 +61,22 @@ _stages = [ ["Required", true], //Type: bool | Optional | if the task needs the stage to succeed ["Reward", { //Type: code | Optional | the reward given for completing the stage private _multiplier = if (_this get "isDifficult") then {2} else {1}; - private _pos = getMarkerPos (_this get "marker"); - private _side = _this get "side"; + private _pos = getMarkerPos (_this get "marker"); + private _side = _this get "side"; - if ((_this get "state") isEqualTo "SUCCEEDED") then - { - [0,200 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; - [-5 * _multiplier,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; - [600 * _multiplier, _side] remoteExec ["A3A_fnc_timingCA",2]; - {if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}} forEach ([500,0,_pos,teamPlayer] call A3A_fnc_distanceUnits); - [10 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; + if ((_this get "state") isEqualTo "SUCCEEDED") then + { + [0,200 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; + [-5 * _multiplier,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; + [600 * _multiplier, _side] remoteExec ["A3A_fnc_timingCA",2]; + {if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}} forEach ([500,0,_pos,teamPlayer] call A3A_fnc_distanceUnits); + [10 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; } - else - { - [5,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; - [-600, _side] remoteExec ["A3A_fnc_timingCA",2]; - [-10,theBoss] call A3A_fnc_playerScoreAdd; + else + { + [5,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; + [-600, _side] remoteExec ["A3A_fnc_timingCA",2]; + [-10,theBoss] call A3A_fnc_playerScoreAdd; }; }], ["Timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail diff --git a/A3A/addons/Tasks/stringtable.xml b/A3A/addons/Tasks/stringtable.xml index 938da55283..8840160286 100644 --- a/A3A/addons/Tasks/stringtable.xml +++ b/A3A/addons/Tasks/stringtable.xml @@ -16,8 +16,6 @@ We have spotted a %1 SpecOp team patrolling around a %2. Ambush them and we will have one less problem. Do this before %3. Be careful, they are tough boys. - - Resource Acquisition From dc7d8e53934251a55c6e855c3780165646e0794d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Mon, 4 Jul 2022 18:13:51 +0200 Subject: [PATCH 30/46] corrected typo in macro --- A3A/addons/Tasks/Core/fn_requestTask.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index 3626c540ba..ac3279b52e 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -13,7 +13,7 @@ if (isNil QGVAR(Settings)) then { call FUNC(getSettings)}; //Task loading from save, format: TaskName, Params, stage, task version if (_taskTypes isEqualTypeParams ["",[],0,0]) exitWith { - private _cfg = TASK_CFG/(_taskTypes#0); + private _cfg = TASKS_CFG/(_taskTypes#0); private _version = getNumber (_cfg/"Version"); if (_version isNotEqualTo (_taskTypes#3)) exitWith { false; }; From 7d5fcd2cc3bbb9b16950adafdb5d7dadd1284231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Mon, 4 Jul 2022 19:59:34 +0200 Subject: [PATCH 31/46] moved stage counter increment to after stage condition is meet --- A3A/addons/Tasks/Core/fn_runTask.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Core/fn_runTask.sqf b/A3A/addons/Tasks/Core/fn_runTask.sqf index b199dc8c40..eb65660a9c 100644 --- a/A3A/addons/Tasks/Core/fn_runTask.sqf +++ b/A3A/addons/Tasks/Core/fn_runTask.sqf @@ -26,7 +26,6 @@ if (_stage > 1) then { _taskHM call ((_stages#0) getOrDefault ["Init",{}]) }; _taskHM set ["Rewards",[]]; { - _taskHM set ["__CurrentStage", (_taskHM get "__CurrentStage") +1]; //increment stage count (for saving/loading) _taskHM call FUNC(updateTaskState); if !("Action" in _x) exitWith { Error_1("Stage %1 is missing the action",_x) }; if !("Condition" in _x) exitWith { Error_1("Stage %1 is missing the condition",_x) }; @@ -42,6 +41,7 @@ _taskHM set ["Rewards",[]]; || (_taskHM getOrDefault ["cancellationToken", false]) || (_x getOrDefault ["cancellationToken", false]) }; + _taskHM set ["__CurrentStage", (_taskHM get "__CurrentStage") +1]; //increment stage count (for saving/loading) if (_taskHM getOrDefault ["cancellationToken", false]) exitWith { _taskHM set ["Successful", false]; From 08c8db09a43adc37fdf5dc2146f95b49fc329876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 25 Sep 2022 13:02:49 +0200 Subject: [PATCH 32/46] fixed param getter bug for two legacy missions --- A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf | 2 +- A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf index 765c3c91f5..2a96aca6a5 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_AS_specOP_p.sqf @@ -12,4 +12,4 @@ private _nearbyFriendlyMarkers = call FUNC(nearFriendlyMarkers); }forEach _controlsX; if (_possibleMarkers isEqualTo []) exitWith {false}; -_possibleMarkers; +selectRandom _possibleMarkers; diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf index a7b62172ad..86a64897e2 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_CON_Outpost_p.sqf @@ -5,4 +5,4 @@ private _roadblocks = controlsX select { isOnRoad getMarkerPos _x }; private _possibleMarkers = [outposts + resourcesX + factories + seaports + _roadblocks] call FUNC(nearHostileMarkers); if (_possibleMarkers isEqualTo []) exitWith {false}; -_possibleMarkers; \ No newline at end of file +selectRandom _possibleMarkers; From 9d6f5b345af4d4b84c0e1727d0ff77155b5b8143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sun, 25 Sep 2022 13:03:11 +0200 Subject: [PATCH 33/46] update naming convention to agreed upon standard (per meeting) --- A3A/addons/Tasks/Core/fn_genTaskUID.sqf | 4 +- A3A/addons/Tasks/Core/fn_getSaveData.sqf | 6 +- A3A/addons/Tasks/Core/fn_getSettings.sqf | 18 +++--- A3A/addons/Tasks/Core/fn_requestTask.sqf | 32 +++++----- A3A/addons/Tasks/Core/fn_runTask.sqf | 58 +++++++++---------- A3A/addons/Tasks/Core/fn_updateTaskState.sqf | 12 ++-- A3A/addons/Tasks/Tasks.hpp | 40 ++++++------- .../Tasks/LegacyTasks/fn_AS_Official.sqf | 48 +++++++-------- .../Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf | 28 ++++----- .../Tasks/LegacyTasks/fn_CON_Outpost.sqf | 38 ++++++------ A3A/addons/Tasks/Tasks/fn_testTask.sqf | 22 +++---- 11 files changed, 153 insertions(+), 153 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_genTaskUID.sqf b/A3A/addons/Tasks/Core/fn_genTaskUID.sqf index 09330aab1c..1e8675465c 100644 --- a/A3A/addons/Tasks/Core/fn_genTaskUID.sqf +++ b/A3A/addons/Tasks/Core/fn_genTaskUID.sqf @@ -2,5 +2,5 @@ FIX_LINE_NUMBERS() if (!isServer) exitWith {}; -GVAR(TaskUID) = GVAR(TaskUID) + 1; -str GVAR(TaskUID); +GVAR(taskUID) = GVAR(taskUID) + 1; +str GVAR(taskUID); diff --git a/A3A/addons/Tasks/Core/fn_getSaveData.sqf b/A3A/addons/Tasks/Core/fn_getSaveData.sqf index 82e02c9165..a97ac819ec 100644 --- a/A3A/addons/Tasks/Core/fn_getSaveData.sqf +++ b/A3A/addons/Tasks/Core/fn_getSaveData.sqf @@ -2,7 +2,7 @@ FIX_LINE_NUMBERS() private _saveData = []; { - private _cfg = _x get "Cfg"; - _saveData pushBack [configName _cfg, _x get "Params" ,_x getOrDefault ["__CurrentStage",1], getNumber (_cfg/"Version")]; -} forEach GVAR(ActiveTasks); + private _cfg = _x get "cfg"; + _saveData pushBack [configName _cfg, _x get "params" ,_x getOrDefault ["__CurrentStage",1], getNumber (_cfg/"version")]; +} forEach GVAR(activeTasks); _saveData; diff --git a/A3A/addons/Tasks/Core/fn_getSettings.sqf b/A3A/addons/Tasks/Core/fn_getSettings.sqf index deba6ac798..f3e7c2d060 100644 --- a/A3A/addons/Tasks/Core/fn_getSettings.sqf +++ b/A3A/addons/Tasks/Core/fn_getSettings.sqf @@ -1,22 +1,22 @@ #include "..\script_component.hpp" FIX_LINE_NUMBERS() -if (isNil QGVAR(TaskUID)) then { GVAR(TaskUID) = 0 }; -if (isNil QGVAR(ChainStates)) then { GVAR(ChainStates) = createHashMap }; -if (isNil QGVAR(Settings)) then { GVAR(Settings) = createHashMap }; +if (isNil QGVAR(taskUID)) then { GVAR(taskUID) = 0 }; +if (isNil QGVAR(chainStates)) then { GVAR(chainStates) = createHashMap }; +if (isNil QGVAR(settings)) then { GVAR(settings) = createHashMap }; //no cba fallback -if !("TaskLingerTime" in GVAR(Settings)) then { GVAR(Settings) set ["TaskLingerTime", 180] }; -if !("MaxTestMissions" in GVAR(Settings)) then { GVAR(Settings) set ["MaxTestMissions", 3] }; +if !("taskLingerTime" in GVAR(settings)) then { GVAR(settings) set ["taskLingerTime", 180] }; +if !("maxTestMissions" in GVAR(settings)) then { GVAR(settings) set ["maxTestMissions", 3] }; //CBA settings if (isClass (configfile >> "CBA_Extended_EventHandlers")) then { - [QGVAR(TaskLingerTime), "SLIDER", ["Task linger time", "Time in minutes a task remains in the task list after completion"], ["Antistasi","Tasks"], [1, 15, 3, 0], true, { - GVAR(Settings) set ["TaskLingerTime",round _this * 60]; + [QGVAR(taskLingerTime), "SLIDER", ["Task linger time", "Time in minutes a task remains in the task list after completion"], ["Antistasi","Tasks"], [1, 15, 3, 0], true, { + GVAR(settings) set ["taskLingerTime",round _this * 60]; }] call CBA_fnc_addSetting; - [QGVAR(MaxTestMissions), "SLIDER", ["Max test missions", "Maximum amount of test missions that can be active at the same time"], ["Antistasi","Tasks"], [0, 10, 3, 0], true, { - GVAR(Settings) set ["MaxTasksOfCat_Test",round _this]; + [QGVAR(maxTestMissions), "SLIDER", ["Max test missions", "Maximum amount of test missions that can be active at the same time"], ["Antistasi","Tasks"], [0, 10, 3, 0], true, { + GVAR(settings) set ["maxTasksOfCat_Test",round _this]; }] call CBA_fnc_addSetting; }; diff --git a/A3A/addons/Tasks/Core/fn_requestTask.sqf b/A3A/addons/Tasks/Core/fn_requestTask.sqf index ac3279b52e..8a5ca34518 100644 --- a/A3A/addons/Tasks/Core/fn_requestTask.sqf +++ b/A3A/addons/Tasks/Core/fn_requestTask.sqf @@ -8,19 +8,19 @@ params [ #define TASKS_CFG (configFile/"A3A"/"Tasks") if (!isServer) exitWith { Error("Server function called on client"); false }; -if (isNil QGVAR(ActiveTasks)) then { GVAR(ActiveTasks) = [] }; -if (isNil QGVAR(Settings)) then { call FUNC(getSettings)}; +if (isNil QGVAR(activeTasks)) then { GVAR(activeTasks) = [] }; +if (isNil QGVAR(settings)) then { call FUNC(getSettings)}; -//Task loading from save, format: TaskName, Params, stage, task version +//Task loading from save, format: taskName, params, stage, task version if (_taskTypes isEqualTypeParams ["",[],0,0]) exitWith { private _cfg = TASKS_CFG/(_taskTypes#0); - private _version = getNumber (_cfg/"Version"); + private _version = getNumber (_cfg/"version"); if (_version isNotEqualTo (_taskTypes#3)) exitWith { false; }; private _taskHM = createHashMapFromArray [ - ["Cfg", _cfg] - , ["Params", _taskTypes#1] + ["cfg", _cfg] + , ["params", _taskTypes#1] ]; [_taskHM] spawn FUNC(runTask); @@ -30,11 +30,11 @@ if (_taskTypes isEqualTypeParams ["",[],0,0]) exitWith { // gather tasks pool private _allTasks = ("true" configClasses TASKS_CFG) apply {configName _x}; private _tasksOfCat = _allTasks select { - getText (TASKS_CFG/_x/"Category") in _taskTypes; + getText (TASKS_CFG/_x/"category") in _taskTypes; }; if (_taskTypes isEqualTo []) then { _taskTypes = _allTasks }; { - _taskTypes deleteAt (_taskTypes find (getText (TASKS_CFG/_x/"Category"))); + _taskTypes deleteAt (_taskTypes find (getText (TASKS_CFG/_x/"category"))); _taskTypes pushBackUnique _x; } forEach _tasksOfCat; @@ -50,10 +50,10 @@ _taskTypes = _taskTypes select { Debug_2("Task %1 is missing one or more required addons: %2", _x, getArray (_cfg/_requiredAddons)); continueWith false; }; - private _cat = getText (_cfg/"Category"); + private _cat = getText (_cfg/"category"); if !( - { (_x get "Category") isEqualTo _cat } count GVAR(ActiveTasks) - < ( GVAR(Settings) getOrDefault ["MaxTasksOfCat_" + _cat, 1, true] ) + { (_x get "category") isEqualTo _cat } count GVAR(activeTasks) + < ( GVAR(settings) getOrDefault ["maxTasksOfCat_" + _cat, 1, true] ) ) then { Debug_1("Max tasks of type %1 active", _x); continueWith false; }; //chained tasks @@ -63,7 +63,7 @@ _taskTypes = _taskTypes select { private _requiredStage = getNumber (_cfg/"chain"/"stage"); if (_requiredStage < 1) then { Error_1("Misconfigured task %1, chain stage requirement: >=1", _x); continueWith false; }; - private _stage = GVAR(ChainStates) getOrDefault [_chain, 1]; + private _stage = GVAR(chainStates) getOrDefault [_chain, 1]; if (_stage isNotEqualTo _requiredStage) then { Debug_4("%1 chain not at the required stage for task %2 | Current: %3 | Required: %4", _chain, _x, _stage, _requiredStage); continueWith false; @@ -71,7 +71,7 @@ _taskTypes = _taskTypes select { }; //parameters getters of the mission type should handle mission type specific criterias - private _paramsGetter = missionNamespace getVariable getText (_cfg / "Params"); + private _paramsGetter = missionNamespace getVariable getText (_cfg / "params"); if (isNil "_paramsGetter") then { Debug_1("No params getter for task %1", _x); continueWith false; }; private _taskParam = call _paramsGetter; _taskParams set [_x, _taskParam]; @@ -81,13 +81,13 @@ _taskTypes = _taskTypes select { true; }; -private _selectedTask = _taskTypes selectRandomWeighted (_taskTypes apply {getNumber (TASKS_CFG/_x/"Weight")}); +private _selectedTask = _taskTypes selectRandomWeighted (_taskTypes apply {getNumber (TASKS_CFG/_x/"weight")}); if (isNil "_selectedTask") exitWith { Info_1("Unable to start a task of types: ", if ((_this#0) isEqualTo []) then {"All", _this#0}); false }; // determine task parameters private _taskHM = createHashMap; -_taskHM set ["Cfg", TASKS_CFG/_selectedTask]; -_taskHM set ["Params", _taskParams get _selectedTask]; +_taskHM set ["cfg", TASKS_CFG/_selectedTask]; +_taskHM set ["params", _taskParams get _selectedTask]; // start task [_taskHM] spawn FUNC(runTask); diff --git a/A3A/addons/Tasks/Core/fn_runTask.sqf b/A3A/addons/Tasks/Core/fn_runTask.sqf index eb65660a9c..4b26a2647c 100644 --- a/A3A/addons/Tasks/Core/fn_runTask.sqf +++ b/A3A/addons/Tasks/Core/fn_runTask.sqf @@ -7,53 +7,53 @@ params [["_taskHM", _emptyHM, [_emptyHM]]]; if (_taskHM isEqualTo _emptyHM) exitWith { Error_1("Invalid parameters passed: %1", _this) }; if (!canSuspend) exitWith { Error_1("Tasks needs to run in scheduled environment") }; -_taskHM set ["TaskID", call FUNC(genTaskUID)]; +_taskHM set ["taskID", call FUNC(genTaskUID)]; //load task -private _taskData = missionNameSpace getVariable getText ((_taskHM get "Cfg") / "Func"); +private _taskData = missionNameSpace getVariable getText ((_taskHM get "cfg") / "func"); if (isNil "_taskData") exitWith { Error_1("Function does not exist: %1", _taskData) }; _taskHM call _taskData; //run task _taskHM call FUNC(updateTaskState); -if !("Constructor" in _taskHM) exitWith { Error_1("Task %1 lacks a constructor", configName (_taskHM get "Cfg")) }; -GVAR(ActiveTasks) pushBackUnique _taskHM; -_taskHM call (_taskHM get "Constructor"); +if !("constructor" in _taskHM) exitWith { Error_1("Task %1 lacks a constructor", configName (_taskHM get "cfg")) }; +GVAR(activeTasks) pushBackUnique _taskHM; +_taskHM call (_taskHM get "constructor"); private _stage = _taskHM getOrDefault ["__CurrentStage", 1]; -private _stages = (_taskHM get "Stages") select [_stage-1, count (_taskHM get "Stages")]; +private _stages = (_taskHM get "stages") select [_stage-1, count (_taskHM get "stages")]; if (_stage > 1) then { _taskHM call ((_stages#0) getOrDefault ["Init",{}]) }; -_taskHM set ["Rewards",[]]; +_taskHM set ["rewards",[]]; { _taskHM call FUNC(updateTaskState); - if !("Action" in _x) exitWith { Error_1("Stage %1 is missing the action",_x) }; - if !("Condition" in _x) exitWith { Error_1("Stage %1 is missing the condition",_x) }; + if !("action" in _x) exitWith { Error_1("Stage %1 is missing the action",_x) }; + if !("condition" in _x) exitWith { Error_1("Stage %1 is missing the condition",_x) }; - private _endTime = time + (_x getOrDefault ["Timeout", 1e12]); - _taskHM call (_x get "Action"); + private _endTime = time + (_x getOrDefault ["timeout", 1e12]); + _taskHM call (_x get "action"); _taskHM call FUNC(updateTaskState); waitUntil { sleep 1; - (if ("Timeout" in _x) then {time >= _endTime} else {false}) - || _taskHM call (_x get "Condition") + (if ("timeout" in _x) then {time >= _endTime} else {false}) + || _taskHM call (_x get "condition") || (_taskHM getOrDefault ["cancellationToken", false]) || (_x getOrDefault ["cancellationToken", false]) }; _taskHM set ["__CurrentStage", (_taskHM get "__CurrentStage") +1]; //increment stage count (for saving/loading) if (_taskHM getOrDefault ["cancellationToken", false]) exitWith { - _taskHM set ["Successful", false]; + _taskHM set ["successful", false]; _taskHM set ["state", "CANCELED"]; }; - private _successful = (if ("Timeout" in _x) then {time < _endTime} else {true}) && !(_x getOrDefault ["cancellationToken", false]); - _x set ["Successful", _successful]; + private _successful = (if ("timeout" in _x) then {time < _endTime} else {true}) && !(_x getOrDefault ["cancellationToken", false]); + _x set ["successful", _successful]; if (_successful) then { - if (_x getOrDefault ["Reward-instant",false]) then (_x getOrDefault ["Reward",{}]) else { - if ("Reward" in _x) then { - (_taskHM get "Rewards") pushBack (_x get "Reward"); + if (_x getOrDefault ["rewardInstant",false]) then (_x getOrDefault ["reward",{}]) else { + if ("reward" in _x) then { + (_taskHM get "rewards") pushBack (_x get "reward"); }; }; _x set ["state", "SUCCEEDED"]; @@ -65,31 +65,31 @@ _taskHM set ["Rewards",[]]; }; }; - if (!_successful && (_x getOrDefault ["Required", true])) exitWith { - _taskHM set ["Successful", false]; + if (!_successful && (_x getOrDefault ["required", true])) exitWith { + _taskHM set ["successful", false]; _taskHM set ["state", "FAILED"]; }; } forEach _stages; -if (_taskHM getOrDefault ["Successful", true]) then { +if (_taskHM getOrDefault ["successful", true]) then { _taskHM set ["state", "SUCCEEDED"]; - if (isClass ((_taskHM get "Cfg")/"chain")) then { - private _chain = (_taskHM get "Cfg")/"chain"; + if (isClass ((_taskHM get "cfg")/"chain")) then { + private _chain = (_taskHM get "cfg")/"chain"; private _name = _chain/"name"; if (getNumber (_chain/"blockProgress") < 1) then { - GVAR(ChainStates) set [_name, (GVAR(ChainStates) getOrDefault [_name, 1]) +1]; + GVAR(chainStates) set [_name, (GVAR(chainStates) getOrDefault [_name, 1]) +1]; }; if (getNumber (_chain/"lastStage") > 0) then { //reset chain when last stage hit - GVAR(ChainStates) deleteAt _name; + GVAR(chainStates) deleteAt _name; }; }; }; -_taskHM call (_taskHM getOrDefault ["Destructor", {}]); -{_taskHM call _x} forEach (_taskHM get "Rewards"); +_taskHM call (_taskHM getOrDefault ["destructor", {}]); +{_taskHM call _x} forEach (_taskHM get "rewards"); _taskHM call FUNC(updateTaskState); -GVAR(ActiveTasks) deleteAt ( GVAR(ActiveTasks) findIf {(_x get "TaskID") isEqualTo (_taskHM get "TaskID")} ); +GVAR(activeTasks) deleteAt ( GVAR(activeTasks) findIf {(_x get "taskID") isEqualTo (_taskHM get "taskID")} ); diff --git a/A3A/addons/Tasks/Core/fn_updateTaskState.sqf b/A3A/addons/Tasks/Core/fn_updateTaskState.sqf index 7fa88c8d63..e72072836d 100644 --- a/A3A/addons/Tasks/Core/fn_updateTaskState.sqf +++ b/A3A/addons/Tasks/Core/fn_updateTaskState.sqf @@ -3,8 +3,8 @@ FIX_LINE_NUMBERS() params ["_taskHM"]; //get task state from hm -private _taskID = _taskHM get "TaskID"; -if (isNil "_taskID") then { _taskID = call FUNC(genTaskUID); _taskHM set ["TaskID", _taskID]; }; +private _taskID = _taskHM get "taskID"; +if (isNil "_taskID") then { _taskID = call FUNC(genTaskUID); _taskHM set ["taskID", _taskID]; }; if (_taskID isEqualType []) then {_taskID = _taskID#0}; private _description = [ @@ -12,7 +12,7 @@ private _description = [ _taskHM get "title", _taskHM getOrDefault ["marker", ""] ]; -if (isNil {_description#1}) exitWith { Error_1("No title set for task %1", configName (_taskHM get "Cfg")) }; +if (isNil {_description#1}) exitWith { Error_1("No title set for task %1", configName (_taskHM get "cfg")) }; private _destination = _taskHM getOrDefault ["destination",objNull]; private _state = _taskHM getOrDefault ["state","CREATED"]; @@ -23,9 +23,9 @@ private _visibleIn3D = _taskHM getOrDefault ["visibleIn3D",false]; //update task state if !([_taskID] call BIS_fnc_taskExists) then { - Debug_1("Task created | ID: %1", _taskHM get "TaskID"); + Debug_1("Task created | ID: %1", _taskHM get "taskID"); [ - true, _taskHM get "TaskID", _description, _destination, _state, _priority, _showNotification, _type, _visibleIn3D + true, _taskHM get "taskID", _description, _destination, _state, _priority, _showNotification, _type, _visibleIn3D ] call BIS_fnc_taskCreate; }; @@ -60,7 +60,7 @@ if (_taskID call BIS_fnc_taskAlwaysVisible isNotEqualTo _visibleIn3D) then { //task removal if (_state in ["SUCCEEDED","FAILED","CANCELED"]) then { _taskID spawn { - sleep (GVAR(Settings) get "TaskLingerTime"); + sleep (GVAR(settings) get "taskLingerTime"); [_this, true, true] call BIS_fnc_deleteTask; }; }; diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index d0021b825f..b2eb99f17a 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -1,10 +1,10 @@ class Tasks { class TestTask { - Category = "Test"; // what Category the task bellongs to - Func = QFUNC(testTask); // the task information needed to run the task - Params = QFUNC(testTask_p); // determines the parameters for a task, if no valid ones can be genereated return false - Version = 1; //version number of task, update when compatibility is broken between last version and new update - Weight = 1; + category = "Test"; // what category the task bellongs to + func = QFUNC(testTask); // the task information needed to run the task + params = QFUNC(testTask_p); // determines the parameters for a task, if no valid ones can be genereated return false + version = 1; //version number of task, update when compatibility is broken between last version and new update + weight = 1; /* Make the task a part of a chain of tasks to only run after other task have been succeded class chain { @@ -18,24 +18,24 @@ class Tasks { //Legacy tasks class L_AS_Official { - Category = "AS"; // what Category the task bellongs to - Func = QFUNC(AS_Official); // the task information needed to run the task - Params = QFUNC(AS_Official_p); // determines the parameters for a task, if no valid ones can be genereated return false - Version = 1; //version number of task, update when compatibility is broken between last version and new update - Weight = 1; + category = "AS"; // what category the task bellongs to + func = QFUNC(AS_Official); // the task information needed to run the task + params = QFUNC(AS_Official_p); // determines the parameters for a task, if no valid ones can be genereated return false + version = 1; //version number of task, update when compatibility is broken between last version and new update + weight = 1; }; class L_AS_specOP { - Category = "AS"; // what Category the task bellongs to - Func = QFUNC(AS_specOP); // the task information needed to run the task - Params = QFUNC(AS_specOP_p); // determines the parameters for a task, if no valid ones can be genereated return false - Version = 1; //version number of task, update when compatibility is broken between last version and new update - Weight = 1; + category = "AS"; // what category the task bellongs to + func = QFUNC(AS_specOP); // the task information needed to run the task + params = QFUNC(AS_specOP_p); // determines the parameters for a task, if no valid ones can be genereated return false + version = 1; //version number of task, update when compatibility is broken between last version and new update + weight = 1; }; class L_CON_Outpost { - Category = "CON"; // what Category the task bellongs to - Func = QFUNC(CON_Outpost); // the task information needed to run the task - Params = QFUNC(CON_Outpost_p); // determines the parameters for a task, if no valid ones can be genereated return false - Version = 1; //version number of task, update when compatibility is broken between last version and new update - Weight = 1; + category = "CON"; // what category the task bellongs to + func = QFUNC(CON_Outpost); // the task information needed to run the task + params = QFUNC(CON_Outpost_p); // determines the parameters for a task, if no valid ones can be genereated return false + version = 1; //version number of task, update when compatibility is broken between last version and new update + weight = 1; }; }; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf index 2fc403298f..83bfe0b5c6 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf @@ -1,7 +1,7 @@ #include "..\..\script_component.hpp" FIX_LINE_NUMBERS() -(_this get "Params") params [["_marker", "", [""]]]; +(_this get "params") params [["_marker", "", [""]]]; if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { Error_1("Assassinate official mission started with bad marker name | %1", _this); }; @@ -9,13 +9,13 @@ if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { private _side = sidesX getVariable _marker; private _faction = Faction(_side); -_this set ["side", _side]; -_this set ["faction", _faction]; -_this set ["isDifficult",(random 10 < tierWar)]; +_this set ["_side", _side]; +_this set ["_faction", _faction]; +_this set ["_isDifficult",(random 10 < tierWar)]; //get info for description private _nameDest = [_marker] call A3A_fnc_localizar; -private _timeLimit = if (_this get "isDifficult") then {15} else {30}; +private _timeLimit = if (_this get "_isDifficult") then {15} else {30}; private _endTime = [_timeLimit] call FUNC(minutesFromNow); _this set ["title", "STR_antistasi_LTasks_AS_official_title"]; //test if it will localize from key @@ -28,13 +28,13 @@ _this set ["description", format [ _this set ["marker", _marker]; _this set ["destination", getMarkerPos _marker]; -_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task - private _faction = _this get "faction"; - private _group = createGroup (_this get "side"); +_this set ["constructor", { // Type: code | Required | Constructor to run at start of task + private _faction = _this get "_faction"; + private _group = createGroup (_this get "_side"); private _official = [_group, _faction get "unitOfficial", _this get "destination", [], 0, "NONE"] call A3A_fnc_createUnit; private _guardsTypes = [_faction get "unitBodyguard"]; - if (_this get "isDifficult") then {_guardsTypes append [ + if (_this get "_isDifficult") then {_guardsTypes append [ _faction get "unitBodyguard",_faction get "unitBodyguard",_faction get "unitBodyguard",_faction get "unitBodyguard" ]}; private _guards = []; @@ -42,21 +42,21 @@ _this set ["Constructor", { // Type: code | Required | Constructor to run at sta _guards pushBack [_group, _x, _this get "destination", [], 0, "NONE"] call A3A_fnc_createUnit; } forEach _guardsTypes; - _this set ["official", _official]; - _this set ["guards", _guards]; + _this set ["_official", _official]; + _this set ["_guards", _guards]; }]; -_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task +_this set ["destructor", { // Type: code | Optional | Destructor to run at end of task waitUntil { (spawner getVariable (_this get "marker")) isEqualTo 2 // not spawned }; - { deleteVehicle _x } forEach ([_this get "official"] + (_this get "guards")); + { deleteVehicle _x } forEach ([_this get "_official"] + (_this get "_guards")); }]; _stages = [ createHashMapFromArray [ - ["Action", { //Type: code | Required | Action to be done in that stage - private _official = _this get "official"; + ["action", { //Type: code | Required | Action to be done in that stage + private _official = _this get "_official"; private _group = group _official; _group selectLeader _official; @@ -65,28 +65,28 @@ _stages = [ { [_x] call A3A_fnc_NATOinit; _x allowFleeing 0; - } forEach ([_official] + (_this get "guards")); + } forEach ([_official] + (_this get "_guards")); }], - ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage - !alive (_this get "official"); + ["condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + !alive (_this get "_official"); }], - ["Reward", { //Type: code | Optional | the reward given for completing the stage - private _multiplier = if (_this get "isDifficult") then {2} else {1}; + ["reward", { //Type: code | Optional | the reward given for completing the stage + private _multiplier = if (_this get "_isDifficult") then {2} else {1}; if ((_this get "state") isEqualTo "SUCCEEDED") then { [0,300 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; - [1200 + 600 * _multiplier, _this get "side"] remoteExec ["A3A_fnc_timingCA",2]; + [1200 + 600 * _multiplier, _this get "_side"] remoteExec ["A3A_fnc_timingCA",2]; { if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}; } forEach ([500,0,getMarkerPos (_this get "marker"),teamPlayer] call A3A_fnc_distanceUnits); [5 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; [_this get "marker",30 * _multiplier] call A3A_fnc_addTimeForIdle; } else { - [-600 * _multiplier, _this get "side"] remoteExec ["A3A_fnc_timingCA",2]; + [-600 * _multiplier, _this get "_side"] remoteExec ["A3A_fnc_timingCA",2]; [-10 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; [_this get "marker",-30 * _multiplier] call A3A_fnc_addTimeForIdle; }; }], - ["Timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail + ["timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail ] ]; -_this set ["Stages", _stages]; +_this set ["stages", _stages]; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf index 3d241524cf..870db0c169 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_specOP.sqf @@ -1,7 +1,7 @@ #include "..\..\script_component.hpp" FIX_LINE_NUMBERS() -(_this get "Params") params [["_marker", "", [""]]]; +(_this get "params") params [["_marker", "", [""]]]; if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { Error_1("SpecOP mission started with bad marker name | %1", _this); }; @@ -9,13 +9,13 @@ if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { private _side = sidesX getVariable _marker; private _faction = Faction(_side); -_this set ["side", _side]; -_this set ["faction", _faction]; -_this set ["isDifficult",(random 10 < tierWar)]; +_this set ["_side", _side]; +_this set ["_faction", _faction]; +_this set ["_isDifficult",(random 10 < tierWar)]; //get info for description private _nameDest = [_marker] call A3A_fnc_localizar; -private _timeLimit = if (_this get "isDifficult") then {60} else {120}; +private _timeLimit = if (_this get "_isDifficult") then {60} else {120}; private _endTime = [_timeLimit] call FUNC(minutesFromNow); _this set ["title", "STR_antistasi_LTasks_AS_specOP_title"]; //test if it will localize from key @@ -28,24 +28,24 @@ _this set ["description", format [ _this set ["marker", _marker]; _this set ["destination", getMarkerPos _marker]; -_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task +_this set ["constructor", { // Type: code | Required | Constructor to run at start of task }]; -_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task +_this set ["destructor", { // Type: code | Optional | Destructor to run at end of task }]; _stages = [ createHashMapFromArray [ - ["Action", { //Type: code | Required | Action to be done in that stage + ["action", { //Type: code | Required | Action to be done in that stage //relies on createAIControl, this should change for the future }], - ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + ["condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage (sidesX getVariable [_this get "marker", sideUnknown]) isEqualTo teamPlayer; }], - ["Reward", { //Type: code | Optional | the reward given for completing the stage - private _multiplier = if (_this get "isDifficult") then {2} else {1}; + ["reward", { //Type: code | Optional | the reward given for completing the stage + private _multiplier = if (_this get "_isDifficult") then {2} else {1}; private _pos = getMarkerPos (_this get "marker"); - private _side = _this get "side"; + private _side = _this get "_side"; if ((_this get "state") isEqualTo "SUCCEEDED") then { //to do check environment of the remoteExec funcs as we are already on server [0,200 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; @@ -64,7 +64,7 @@ _stages = [ [-600 * _multiplier, _side] remoteExec ["A3A_fnc_timingCA",2]; }; }], - ["Timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail + ["timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail ] ]; -_this set ["Stages", _stages]; +_this set ["stages", _stages]; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf index fa7d3d7913..eae1e9d35c 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf @@ -1,7 +1,7 @@ #include "..\..\script_component.hpp" FIX_LINE_NUMBERS() -(_this get "Params") params [["_marker", "", [""]]]; +(_this get "params") params [["_marker", "", [""]]]; if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { Error_1("Conquest mission started with bad marker name | %1", _this); }; @@ -9,15 +9,15 @@ if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { private _side = sidesX getVariable _marker; private _faction = Faction(_side); -_this set ["side", _side]; -_this set ["faction", _faction]; -_this set ["isDifficult", (random 10 < tierWar)]; -_this set ["destination", getMarkerPos _marker]; +_this set ["_side", _side]; +_this set ["_faction", _faction]; +_this set ["_isDifficult", (random 10 < tierWar)]; +_this set ["_destination", getMarkerPos _marker]; _this set ["marker", _marker]; private _nameDest = [_marker] call A3A_fnc_localizar; -private _timeLimit = if (_this get "isDifficult") then {30} else {90}; +private _timeLimit = if (_this get "_isDifficult") then {30} else {90}; if (A3A_hasIFA) then {_timeLimit = _timeLimit * 2}; private _displayTime = [_timeLimit] call FUNC(minutesFromNow); @@ -45,41 +45,41 @@ switch (true) do { _this set ["title", _taskName]; _this set ["description", _taskDescription]; -_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task +_this set ["constructor", { // Type: code | Required | Constructor to run at start of task }]; -_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task +_this set ["destructor", { // Type: code | Optional | Destructor to run at end of task }]; _stages = [ createHashMapFromArray [ - ["Action", { //Type: code | Required | Action to be done in that stage + ["action", { //Type: code | Required | Action to be done in that stage }], - ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + ["condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage (sidesX getVariable [_this get "marker", sideUnknown]) isEqualTo teamPlayer; }], - ["Required", true], //Type: bool | Optional | if the task needs the stage to succeed - ["Reward", { //Type: code | Optional | the reward given for completing the stage - private _multiplier = if (_this get "isDifficult") then {2} else {1}; + ["required", true], //Type: bool | Optional | if the task needs the stage to succeed + ["reward", { //Type: code | Optional | the reward given for completing the stage + private _multiplier = if (_this get "_isDifficult") then {2} else {1}; private _pos = getMarkerPos (_this get "marker"); - private _side = _this get "side"; + private _side = _this get "_side"; if ((_this get "state") isEqualTo "SUCCEEDED") then - { + { [0,200 * _multiplier] remoteExec ["A3A_fnc_resourcesFIA",2]; [-5 * _multiplier,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; [600 * _multiplier, _side] remoteExec ["A3A_fnc_timingCA",2]; {if (isPlayer _x) then {[10 * _multiplier,_x] call A3A_fnc_playerScoreAdd}} forEach ([500,0,_pos,teamPlayer] call A3A_fnc_distanceUnits); [10 * _multiplier,theBoss] call A3A_fnc_playerScoreAdd; - } - else + } + else { [5,0,_pos] remoteExec ["A3A_fnc_citySupportChange",2]; [-600, _side] remoteExec ["A3A_fnc_timingCA",2]; [-10,theBoss] call A3A_fnc_playerScoreAdd; }; }], - ["Timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail + ["timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail ] ]; -_this set ["Stages", _stages]; \ No newline at end of file +_this set ["stages", _stages]; diff --git a/A3A/addons/Tasks/Tasks/fn_testTask.sqf b/A3A/addons/Tasks/Tasks/fn_testTask.sqf index 4cb58abf3a..91f39da570 100644 --- a/A3A/addons/Tasks/Tasks/fn_testTask.sqf +++ b/A3A/addons/Tasks/Tasks/fn_testTask.sqf @@ -15,11 +15,11 @@ _this set ["title", "Test task"]; _this set ["description", "Test task description"]; _this set ["destination", [allPlayers#0, true]]; -_this set ["Constructor", { // Type: code | Required | Constructor to run at start of task +_this set ["constructor", { // Type: code | Required | Constructor to run at start of task Info("Constructor called"); }]; -_this set ["Destructor", { // Type: code | Optional | Destructor to run at end of task +_this set ["destructor", { // Type: code | Optional | Destructor to run at end of task Info("Destructor called"); }]; @@ -28,21 +28,21 @@ _stages = [ ["Init", { //Type: code | Optional | only stage 2 and beyond can use a stage init function Info("Stage 1 init called"); }], - ["Action", { //Type: code | Required | Action to be done in that stage + ["action", { //Type: code | Required | Action to be done in that stage Info("Stage 1 action called"); }], - ["Condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + ["condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage false; }], - ["Required", true], //Type: bool | Optional | if the task needs the stage to succeed - ["Reward", { //Type: code | Optional | the reward given for completing the stage + ["required", true], //Type: bool | Optional | if the task needs the stage to succeed + ["reward", { //Type: code | Optional | the reward given for completing the stage Info("Stage 1 reward called"); }], - ["Reward-Instant", false], //Type: bool | Optional | if the reward should be given instantly on compleation of stage - ["Timeout", 10] //Type: number | Optional | Time limit for the stage before auto fail + ["rewardInstant", false], //Type: bool | Optional | if the reward should be given instantly on compleation of stage + ["timeout", 10] //Type: number | Optional | Time limit for the stage before auto fail ] ]; -_this set ["Stages", _stages]; +_this set ["stages", _stages]; /* to add sub tasks -> add them to the Children entry in the task hm @@ -51,13 +51,13 @@ _this set ["Stages", _stages]; example: private _subTaskA = createHashMap; - _subTaskA set ["TaskID", ["A", _this get "TaskID"]]; + _subTaskA set ["taskID", ["A", _this get "taskID"]]; _subTaskA set ["title", "Test sub task A"]; _subTaskA set ["description", "Test sub task A description"]; _this set ["Children", [_subTaskA]]; */ private _subTaskA = createHashMap; -_subTaskA set ["TaskID", [call FUNC(genTaskUID), _this get "TaskID"]]; +_subTaskA set ["taskID", [call FUNC(genTaskUID), _this get "taskID"]]; _subTaskA set ["title", "Test sub task A"]; _subTaskA set ["description", "Test sub task A description"]; _this set ["Children", [_subTaskA]]; // Type: Array of hashMaps | Optional | sub tasks of the main task From 7797675f7bd5f48b54946d0b3bc7de3ff3ba3311 Mon Sep 17 00:00:00 2001 From: John Jordan Date: Mon, 28 Nov 2022 05:47:17 +0000 Subject: [PATCH 34/46] Fix missing task marker for CON_Outpost plus incorrect conversion of marker-type destinations --- A3A/addons/Tasks/Core/fn_updateTaskState.sqf | 2 +- A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_updateTaskState.sqf b/A3A/addons/Tasks/Core/fn_updateTaskState.sqf index e72072836d..ad8a287c9b 100644 --- a/A3A/addons/Tasks/Core/fn_updateTaskState.sqf +++ b/A3A/addons/Tasks/Core/fn_updateTaskState.sqf @@ -39,7 +39,7 @@ if (_taskID call BIS_fnc_taskDescription isNotEqualTo _description) then { private _destinationCheck = switch (true) do { case (_destination isEqualType objNull): { getPos _destination }; - case (_destination isEqualType ""): { getPos _destination }; + case (_destination isEqualType ""): { getMarkerPos _destination }; default { _destination }; }; if (_taskId call BIS_fnc_taskDestination isNotEqualTo _destinationCheck) then { diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf index eae1e9d35c..8c436fe1b5 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_CON_Outpost.sqf @@ -12,7 +12,7 @@ private _faction = Faction(_side); _this set ["_side", _side]; _this set ["_faction", _faction]; _this set ["_isDifficult", (random 10 < tierWar)]; -_this set ["_destination", getMarkerPos _marker]; +_this set ["destination", getMarkerPos _marker]; _this set ["marker", _marker]; private _nameDest = [_marker] call A3A_fnc_localizar; From 57b8027b245d140d2097048ccddb4d499a794053 Mon Sep 17 00:00:00 2001 From: Killerswin2 Date: Thu, 12 Jan 2023 21:04:28 -0600 Subject: [PATCH 35/46] ported LOG_Supplies with some changes --- A3A/addons/Tasks/CfgFunctions.hpp | 2 + .../Params/LegacyParams/fn_LOG_Supplies_p.sqf | 15 +++ A3A/addons/Tasks/Tasks.hpp | 7 + .../Tasks/LegacyTasks/fn_LOG_Supplies.sqf | 121 ++++++++++++++++++ A3A/addons/Tasks/stringtable.xml | 12 ++ 5 files changed, 157 insertions(+) create mode 100644 A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Supplies_p.sqf create mode 100644 A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf diff --git a/A3A/addons/Tasks/CfgFunctions.hpp b/A3A/addons/Tasks/CfgFunctions.hpp index 66b5c0df1d..c596574e0e 100644 --- a/A3A/addons/Tasks/CfgFunctions.hpp +++ b/A3A/addons/Tasks/CfgFunctions.hpp @@ -30,12 +30,14 @@ class CfgFunctions { class AS_Official_p {}; class AS_specOP_p {}; class CON_Outpost_p {}; + class LOG_Supplies_p {}; }; class LegacyTasks { file = QPATHTOFOLDER(Tasks\LegacyTasks); class AS_Official {}; class AS_specOP {}; class CON_Outpost {}; + class LOG_Supplies {}; }; }; }; diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Supplies_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Supplies_p.sqf new file mode 100644 index 0000000000..169d46de87 --- /dev/null +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Supplies_p.sqf @@ -0,0 +1,15 @@ + +private _possibleMarkers = []; +private _weightedMarkers = []; +{ + private _dist = getMarkerPos _x distance2D getMarkerPos respawnTeamPlayer; + private _supportReb = (server getVariable _x) select 3; + if (_dist < distanceMission && _supportReb < 90) then { + private _weight = (100 - _supportReb) * ((distanceMission - _dist) ^ 2); + _possibleMarkers pushBack _x; + _weightedMarkers append [_x, _weight]; + }; +}forEach (citiesX - destroyedSites); + +if ( _possibleMarkers isEqualTo []) exitWith {false}; +selectRandomWeighted _weightedMarkers; diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index b2eb99f17a..12967e9dd8 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -38,4 +38,11 @@ class Tasks { version = 1; //version number of task, update when compatibility is broken between last version and new update weight = 1; }; + class L_LOG_Supplies { + category = "LOG"; + func = QFUNC(LOG_Supplies); + params = QFUNC(LOG_Supplies_p); + version = 1; + weight = 1; + }; }; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf new file mode 100644 index 0000000000..7bdcebfe88 --- /dev/null +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf @@ -0,0 +1,121 @@ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() + +(_this get "params") params [["_marker", "", [""]]]; +if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { + Error_1("Conquest mission started with bad marker name | %1", _this); +}; + +private _side = sidesX getVariable _marker; +private _faction = Faction(_side); + +_this set ["_side", _side]; +_this set ["_faction", _faction]; +_this set ["_isDifficult", (random 10 < tierWar)]; +_this set ["destination", getMarkerPos _marker]; +_this set ["marker", _marker]; +_this set ["timer", 120]; + + +private _nameDest = [_marker] call A3A_fnc_localizar; +private _timeLimit = if (_this get "_isDifficult") then {30} else {60}; +if (A3A_hasIFA) then {_timeLimit = _timeLimit * 2}; + +private _displayTime = [_timeLimit] call FUNC(minutesFromNow); +private _markerSide = sidesX getVariable [_marker, sideUnknown]; + + +private _pos = (getMarkerPos respawnTeamPlayer) findEmptyPosition [1,50,"C_Van_01_box_F"]; +private _truckX = "Land_FoodSacks_01_cargo_brown_F" createVehicle _pos; +_truckX enableRopeAttach true; +_truckX allowDamage false; +[_truckX] call A3A_Logistics_fnc_addLoadAction; +[_truckX, teamPlayer] call A3A_fnc_AIVEHinit; +//{_x reveal _truckX} forEach (allPlayers - (entities "HeadlessClient_F")); +[_truckX,"Supply Box"] spawn A3A_fnc_inmuneConvoy; + +_this set ["truckX", _truckX]; +/* + Note: the task sets all feedback to players automaticly based on the info in the task hm passed to the task + the modifyable values are: + description, title, marker, destination, state, priority, showNotification, type, visibleIn3D + + note that TaskID is also available but should only be used when creating sub tasks, and NEVER modified within the task. + of the afformentioned only title is required, but it is recomended to set: + description, marker, and destination + in addition to the title +*/ + +private _holdTime = if(_this get "_isDifficult") then {4} else {2}; +private _taskName = localize "STR_antistasi_LTasks_LOG_Supplies_title"; +private _taskDescription = format [localize "STR_antistasi_LTasks_LOG_Supplies_description",_nameDest,_displayTime, _holdTime]; + + +_this set ["title", _taskName]; +_this set ["description", _taskDescription]; + +_this set ["constructor", { // Type: code | Required | Constructor to run at start of task + Info("Constructor called"); +}]; + +_this set ["destructor", { // Type: code | Optional | Destructor to run at end of task + Info("Destructor called"); +}]; + +_stages = [ + createHashMapFromArray [ + ["Init", { //Type: code | Optional | only stage 2 and beyond can use a stage init function + Info("Stage 1 init called"); + }], + ["action", { //Type: code | Required | Action to be done in that stage + Info("Stage 1 action called"); + waitUntil {sleep 1; (((_this get "truckX") distance (_this get "destination") < 40) and (isNull attachedTo (_this get "truckX")) and (isNull ropeAttachedTo (_this get "truckX")))}; + + while {(((_this get "timer") isNotEqualTo 0) and (((allPlayers - (entities "HeadlessClient_F")) inAreaArray [getPosATL (_this get "truckX"), 80, 80]) findIf {!([_x] call A3A_fnc_canFight)} isEqualTo -1))} do + { + _formatX = format [localize "STR_antistasi_LTasks_LOG_Supplies_distributing_supplies", (_this get "timer")]; + {[petros,"hint",_formatX,"Logistics Mission"] remoteExec ["A3A_fnc_commsMP",_x]} forEach ((allPlayers - (entities "HeadlessClient_F")) inAreaArray [getPosATL (_this get "truckX"), 80, 80]); + _this set ["timer", (_this get "timer") - 1]; + sleep 1; + }; + }], + ["condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + (((_this get "truckX") distance (_this get "destination") < 40) and (isNull attachedTo (_this get "truckX")) and (isNull ropeAttachedTo (_this get "truckX")) and ((_this get "timer") isEqualTo 0)) + }], + ["required", true], //Type: bool | Optional | if the task needs the stage to succeed + ["reward", { //Type: code | Optional | the reward given for completing the stage + Info("Stage 1 reward called"); + private _bonus = if (_this get "_isDifficult") then {2} else {1}; + private _markerX =(_this get "destination"); + private _markerX =(_this get "marker"); + private _side = _this get "_side"; + private _truckX = (_this get "truckX"); + + // OKAY TASK IS GOOD + if ((_this get "state") isEqualTo "SUCCEEDED") then + { + [petros,"hint",(localize "STR_antistasi_LTasks_LOG_Supplies_supplies_delivered"), "Logistics Mission"] remoteExec ["A3A_fnc_commsMP",[teamPlayer,civilian]]; + private _playersInRange = (allPlayers - (entities "HeadlessClient_F")) inAreaArray [_markerX, 250, 250]; + {[10*_bonus * tierWar,_x] call A3A_fnc_playerScoreAdd} forEach _playersInRange; + [5*_bonus * tierWar,theBoss] call A3A_fnc_playerScoreAdd; + [-15*_bonus,15*_bonus,_markerX] remoteExec ["A3A_fnc_citySupportChange",2]; + Debug("aggroEvent | Rebels won a supply mission"); + [Occupants, -10, 60] remoteExec ["A3A_fnc_addAggression",2]; + [0,200 * _bonus * tierWar] remoteExec ["A3A_fnc_resourcesFIA",2]; + } + else + { + [5*_bonus,-5*_bonus,_positionX] remoteExec ["A3A_fnc_citySupportChange",2]; + [-10*_bonus,theBoss] call A3A_fnc_playerScoreAdd; + }; + private _ecpos = getpos _truckX; + deleteVehicle _truckX; + private _emptybox = "Land_Pallet_F" createVehicle _ecpos; + [_emptybox] spawn A3A_fnc_postmortem; + + }], + ["rewardInstant", false], //Type: bool | Optional | if the reward should be given instantly on compleation of stage + ["timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail + ] +]; +_this set ["stages", _stages]; diff --git a/A3A/addons/Tasks/stringtable.xml b/A3A/addons/Tasks/stringtable.xml index 8840160286..ac8ed98848 100644 --- a/A3A/addons/Tasks/stringtable.xml +++ b/A3A/addons/Tasks/stringtable.xml @@ -44,6 +44,18 @@ %1 is being used to aid the enemy. Go there and capture it before %2. + + City Supplies + + + %1 population is in need of supplies. We may improve our relationship with that city if we are the ones who provide them. I have placed a crate with supplies near our HQ. Deliver the crate to %1 city center, hold it there for %3 minutes and it's done. Do this before %2. + + + Keep distributing supplies for %1 more seconds. + + + Supplies Delivered. + From 6110aa6f11adde8516679b04cee8c8eecaa9e446 Mon Sep 17 00:00:00 2001 From: Killerswin2 Date: Fri, 17 Mar 2023 16:24:36 -0500 Subject: [PATCH 36/46] ported log_ammo --- A3A/addons/Tasks/CfgFunctions.hpp | 2 + .../Params/LegacyParams/fn_LOG_Ammo_p.sqf | 17 ++ A3A/addons/Tasks/Tasks.hpp | 7 + .../Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf | 168 ++++++++++++++++++ .../Tasks/LegacyTasks/fn_LOG_Supplies.sqf | 7 +- A3A/addons/Tasks/stringtable.xml | 12 ++ .../core/functions/Missions/fn_LOG_Ammo.sqf | 2 +- 7 files changed, 210 insertions(+), 5 deletions(-) create mode 100644 A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf create mode 100644 A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf diff --git a/A3A/addons/Tasks/CfgFunctions.hpp b/A3A/addons/Tasks/CfgFunctions.hpp index c596574e0e..bfaeba2f4b 100644 --- a/A3A/addons/Tasks/CfgFunctions.hpp +++ b/A3A/addons/Tasks/CfgFunctions.hpp @@ -31,6 +31,7 @@ class CfgFunctions { class AS_specOP_p {}; class CON_Outpost_p {}; class LOG_Supplies_p {}; + class LOG_Ammo_p {}; }; class LegacyTasks { file = QPATHTOFOLDER(Tasks\LegacyTasks); @@ -38,6 +39,7 @@ class CfgFunctions { class AS_specOP {}; class CON_Outpost {}; class LOG_Supplies {}; + class LOG_Ammo {}; }; }; }; diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf new file mode 100644 index 0000000000..b6badfdc01 --- /dev/null +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf @@ -0,0 +1,17 @@ +private _findIfNearAndHostile = { + /* + Input : single array of markers, do 'array + array' for multiple. + Returns: array of markers within max mission distance and is not rebel. + */ + params ["_Markers"]; + _Markers = _Markers select {(getMarkerPos _x distance2D getMarkerPos respawnTeamPlayer < distanceMission) && (sidesX getVariable [_x,sideUnknown] != teamPlayer)}; + _Markers +}; + +//Add unspawned outposts for ammo trucks, and seaports for salvage +_possibleMarkers = [ outposts] call _findIfNearAndHostile; +_possibleMarkers = _possibleMarkers select {(_x in seaports) or (spawner getVariable _x != 0)}; + +if ( _possibleMarkers isEqualTo []) exitWith {false}; + +selectRandom _possibleMarkers diff --git a/A3A/addons/Tasks/Tasks.hpp b/A3A/addons/Tasks/Tasks.hpp index 12967e9dd8..4e6bc6c702 100644 --- a/A3A/addons/Tasks/Tasks.hpp +++ b/A3A/addons/Tasks/Tasks.hpp @@ -45,4 +45,11 @@ class Tasks { version = 1; weight = 1; }; + class L_LOG_Ammo { + category = "LOG"; + func = QFUNC(LOG_Ammo); + params = QFUNC(LOG_Ammo_p); + version = 1; + weight = 1; + }; }; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf new file mode 100644 index 0000000000..ea0856afb9 --- /dev/null +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf @@ -0,0 +1,168 @@ +#include "..\..\script_component.hpp" +FIX_LINE_NUMBERS() +(_this get "params") params [["_marker", "", [""]]]; +if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { + Error_1("Ammo truck mission started with bad marker name | %1", _this); +}; + +private _side = sidesX getVariable _marker; +private _faction = Faction(_side); + +_this set ["_side", _side]; +_this set ["_faction", _faction]; +_this set ["_isDifficult", (random 10 < tierWar)]; +_this set ["destination", getMarkerPos _marker]; +_this set ["marker", _marker]; + + +private _nameDest = [_marker] call A3A_fnc_localizar; +private _timeLimit = if (_this get "_isDifficult") then {30} else {60}; +if (A3A_hasIFA) then {_timeLimit = _timeLimit * 2}; + +private _displayTime = [_timeLimit] call FUNC(minutesFromNow); +private _markerSide = sidesX getVariable [_marker, sideUnknown]; + + +_typeVehX = selectRandom (_faction get "vehiclesAmmoTrucks"); + +private _road = [getMarkerPos _marker] call A3A_fnc_findNearestGoodRoad; +private _pos = position _road; +_pos = _pos findEmptyPosition [1,60,_typeVehX]; + +_this set ["_typeVehX", _typeVehX]; +_this set ["_pos", _pos]; +_this set ["_road", _road]; +_this set ["_nameDest", _nameDest]; +/* + Note: the task sets all feedback to players automaticly based on the info in the task hm passed to the task + the modifyable values are: + description, title, marker, destination, state, priority, showNotification, type, visibleIn3D + + note that TaskID is also available but should only be used when creating sub tasks, and NEVER modified within the task. + of the afformentioned only title is required, but it is recomended to set: + description, marker, and destination + in addition to the title +*/ + +private _taskName = localize "STR_antistasi_LTasks_LOG_Ammo_title"; +private _taskDescription = format [localize "STR_antistasi_LTasks_LOG_Ammo_description",_nameDest,_displayTime]; + + +_this set ["title", _taskName]; +_this set ["description", _taskDescription]; + +_this set ["constructor", { // Type: code | Required | Constructor to run at start of task + Info("Constructor called"); +}]; + +_this set ["destructor", { // Type: code | Optional | Destructor to run at end of task + Info("Destructor called"); +}]; + +_stages = [ + createHashMapFromArray [ + ["Init", { //Type: code | Optional | only stage 2 and beyond can use a stage init function + Info("Stage 1 init called"); + }], + ["action", { //Type: code | Required | Action to be done in that stage + Info("Stage 1 action called"); + private _faction = (_this get "_faction"); + private _difficultX = (_this get "_isDifficult"); + private _side = (_this get "_side"); + private _pos = (_this get "_pos"); + private _markerX = (_this get "marker"); + + waitUntil {sleep 1; ((spawner getVariable _markerX != 2) and !(sidesX getVariable [_markerX,sideUnknown] == teamPlayer))}; + + //create truck + private _truckX = (_this get "_typeVehX") createVehicle _pos; + _truckX setDir (getDir (_this get "_road")); + + _this set ["truckX", _truckX]; + + //fill the truck with loot + [_truckX] spawn A3A_fnc_fillLootCrate; + [_truckX, _side] call A3A_fnc_AIVEHinit; + + //upsmon stuff + private _mrk = createMarkerLocal [format ["%1patrolarea", floor random 100], _pos]; + _mrk setMarkerShapeLocal "RECTANGLE"; + _mrk setMarkerSizeLocal [20,20]; + _mrk setMarkerTypeLocal "hd_warning"; + _mrk setMarkerColorLocal "ColorRed"; + _mrk setMarkerBrushLocal "DiagGrid"; + if (!debug) then {_mrk setMarkerAlphaLocal 0}; + + private _typeGroup = if (_difficultX) then {selectRandom (_faction get "groupsSquads")} else {_faction get "groupSentry"}; + private _groupX = [_pos,_side, _typeGroup] call A3A_fnc_spawnGroup; + + sleep 1; + if (random 10 < 33) then + { + _dog = [_groupX, "Fin_random_F",(_this get "destination"),[],0,"FORM"] call A3A_fnc_createUnit; + [_dog] spawn A3A_fnc_guardDog; + }; + _nul = [leader _groupX, _mrk, "SAFE","SPAWNED", "NOVEH2"] spawn UPSMON_fnc_UPSMON; + + _groupX1 = [_pos,_side,_typeGroup] call A3A_fnc_spawnGroup; + sleep 1; + _nul = [leader _groupX1, _mrk, "SAFE","SPAWNED", "NOVEH2"] spawn UPSMON_fnc_UPSMON; + + {[_x,""] call A3A_fnc_NATOinit} forEach units _groupX; + {[_x,""] call A3A_fnc_NATOinit} forEach units _groupX1; + + _truckX setVariable ["ammoTruckLocation", _this get "_nameDest"]; + _truckX addEventHandler ["GetIn", { + params ["_vehicle", "_role", "_unit", "_turret"]; + + private _owningSide = (_vehicle getVariable "originalSide"); // set by AIVEHinit + + if (_unit getVariable ["spawner",false]) then { + ["TaskFailed", ["", format ["Ammotruck Stolen in an %1",(_vehicle getVariable ["ammoTruckLocation", ""])]]] remoteExec ["BIS_fnc_showNotification",_owningSide]; + }; + + _vehicle removeEventHandler ["GetIn", _thisEventHandler]; + }]; + + }], + ["condition", { //Type: code | Required | Return type: bool | Condition to compleate the stage + ((not alive (_this get "truckX")) or (((_this get "truckX") distanceSqr posHQ) < 10000)) + }], + ["required", true], //Type: bool | Optional | if the task needs the stage to succeed + ["reward", { //Type: code | Optional | the reward given for completing the stage + Info("Stage 1 reward called"); + private _bonus = if (_this get "_isDifficult") then {2} else {1}; + private _positionX =(_this get "destination"); + private _markerX =(_this get "marker"); + private _side = _this get "_side"; + private _truckX = (_this get "truckX"); + + // OKAY TASK IS GOOD + if (((_this get "state") isEqualTo "SUCCEEDED") and (alive (_this get "truckX"))) then + { + [petros,"hint",(localize "STR_antistasi_LTasks_LOG_Ammo_captured"), "Logistics Mission"] remoteExec ["A3A_fnc_commsMP",[teamPlayer,civilian]]; + private _allPlayers = (allPlayers - (entities "HeadlessClient_F")); + private _playersInRange = _allPlayers inAreaArray [posHQ, 250, 250]; + {[10*_bonus * tierWar,_x] call A3A_fnc_playerScoreAdd} forEach _playersInRange; + [5*_bonus * tierWar,theBoss] call A3A_fnc_playerScoreAdd; + [0,200 * _bonus * tierWar] remoteExec ["A3A_fnc_resourcesFIA",2]; + }; + if (((_this get "state") isEqualTo "SUCCEEDED") and (not alive (_this get "truckX"))) then + { + [petros,"hint",(localize "STR_antistasi_LTasks_LOG_Ammo_destroyed_description"), "Logistics Mission"] remoteExec ["A3A_fnc_commsMP",[teamPlayer,civilian]]; + private _allPlayers = (allPlayers - (entities "HeadlessClient_F")); + private _playersInRange = _allPlayers inAreaArray [_positionX, 250, 250]; + {[5*_bonus * tierWar,_x] call A3A_fnc_playerScoreAdd} forEach _playersInRange; + [5*_bonus * tierWar,theBoss] call A3A_fnc_playerScoreAdd; + [0,200 * _bonus * tierWar] remoteExec ["A3A_fnc_resourcesFIA",2]; + }; + if((_this get "state") isNotEqualTo "SUCCEEDED") then + { + [-10*_bonus,theBoss] call A3A_fnc_playerScoreAdd; + }; + }], + ["rewardInstant", false], //Type: bool | Optional | if the reward should be given instantly on compleation of stage + ["timeout", _timeLimit * 60] //Type: number | Optional | Time limit for the stage before auto fail + ] +]; +_this set ["stages", _stages]; diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf index 7bdcebfe88..5f6b6cbfe4 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf @@ -3,7 +3,7 @@ FIX_LINE_NUMBERS() (_this get "params") params [["_marker", "", [""]]]; if ((getMarkerPos _marker) isEqualTo [0,0,0]) exitWith { - Error_1("Conquest mission started with bad marker name | %1", _this); + Error_1("Supply mission started with bad marker name | %1", _this); }; private _side = sidesX getVariable _marker; @@ -84,9 +84,8 @@ _stages = [ }], ["required", true], //Type: bool | Optional | if the task needs the stage to succeed ["reward", { //Type: code | Optional | the reward given for completing the stage - Info("Stage 1 reward called"); private _bonus = if (_this get "_isDifficult") then {2} else {1}; - private _markerX =(_this get "destination"); + private _positionX =(_this get "destination"); private _markerX =(_this get "marker"); private _side = _this get "_side"; private _truckX = (_this get "truckX"); @@ -98,7 +97,7 @@ _stages = [ private _playersInRange = (allPlayers - (entities "HeadlessClient_F")) inAreaArray [_markerX, 250, 250]; {[10*_bonus * tierWar,_x] call A3A_fnc_playerScoreAdd} forEach _playersInRange; [5*_bonus * tierWar,theBoss] call A3A_fnc_playerScoreAdd; - [-15*_bonus,15*_bonus,_markerX] remoteExec ["A3A_fnc_citySupportChange",2]; + [-15*_bonus,15*_bonus,_positionX] remoteExec ["A3A_fnc_citySupportChange",2]; Debug("aggroEvent | Rebels won a supply mission"); [Occupants, -10, 60] remoteExec ["A3A_fnc_addAggression",2]; [0,200 * _bonus * tierWar] remoteExec ["A3A_fnc_resourcesFIA",2]; diff --git a/A3A/addons/Tasks/stringtable.xml b/A3A/addons/Tasks/stringtable.xml index ac8ed98848..c65529ebb0 100644 --- a/A3A/addons/Tasks/stringtable.xml +++ b/A3A/addons/Tasks/stringtable.xml @@ -56,6 +56,18 @@ Supplies Delivered. + + Steal or Destroy Ammotruck + + + We've spotted an Ammotruck in an %1. Go there and destroy or steal it before %2.%2. + + + Ammo Truck Destroyed. + + + Ammo Truck Captured. + diff --git a/A3A/addons/core/functions/Missions/fn_LOG_Ammo.sqf b/A3A/addons/core/functions/Missions/fn_LOG_Ammo.sqf index 361ace287d..f745c3c836 100644 --- a/A3A/addons/core/functions/Missions/fn_LOG_Ammo.sqf +++ b/A3A/addons/core/functions/Missions/fn_LOG_Ammo.sqf @@ -89,7 +89,7 @@ if ((spawner getVariable _markerX != 2) and !(sidesX getVariable [_markerX,sideU ["TaskFailed", ["", format ["Ammotruck Stolen in an %1",(_vehicle getVariable ["ammoTruckLocation", ""])]]] remoteExec ["BIS_fnc_showNotification",_owningSide]; }; - _truckX removeEventHandler ["GetIn", _thisEventHandler]; + _vehicle removeEventHandler ["GetIn", _thisEventHandler]; }]; waitUntil {sleep 3; (not alive _truckX) or (dateToNumber date > _dateLimitNum) or (call _fnc_truckReturnedToBase)}; From ee53bf21d5348c62223c8d218fbec7ff81158988 Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:22:07 +0100 Subject: [PATCH 37/46] Update A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf index ea0856afb9..3c2bee60fc 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf @@ -34,7 +34,7 @@ _this set ["_pos", _pos]; _this set ["_road", _road]; _this set ["_nameDest", _nameDest]; /* - Note: the task sets all feedback to players automaticly based on the info in the task hm passed to the task + Note: the task sets all feedback to players automatically based on the info in the task hm passed to the task the modifyable values are: description, title, marker, destination, state, priority, showNotification, type, visibleIn3D From 3f6cba3cd53d722723892b50f929f858aef2283f Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:22:16 +0100 Subject: [PATCH 38/46] Update A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf index 3c2bee60fc..d669efd129 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf @@ -35,7 +35,7 @@ _this set ["_road", _road]; _this set ["_nameDest", _nameDest]; /* Note: the task sets all feedback to players automatically based on the info in the task hm passed to the task - the modifyable values are: + the modifiable values are: description, title, marker, destination, state, priority, showNotification, type, visibleIn3D note that TaskID is also available but should only be used when creating sub tasks, and NEVER modified within the task. From f0ee2f48257ec0b05fde539fb8f9209f1721c835 Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:22:23 +0100 Subject: [PATCH 39/46] Update A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf index b6badfdc01..14df677a0c 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf @@ -9,7 +9,7 @@ private _findIfNearAndHostile = { }; //Add unspawned outposts for ammo trucks, and seaports for salvage -_possibleMarkers = [ outposts] call _findIfNearAndHostile; +_possibleMarkers = [outposts] call _findIfNearAndHostile; _possibleMarkers = _possibleMarkers select {(_x in seaports) or (spawner getVariable _x != 0)}; if ( _possibleMarkers isEqualTo []) exitWith {false}; From 1d2e24cafb1805c82770d6e6e30e443a2af3e0ba Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:22:47 +0100 Subject: [PATCH 40/46] Update A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf index 14df677a0c..ca2de7796e 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf @@ -4,8 +4,7 @@ private _findIfNearAndHostile = { Returns: array of markers within max mission distance and is not rebel. */ params ["_Markers"]; - _Markers = _Markers select {(getMarkerPos _x distance2D getMarkerPos respawnTeamPlayer < distanceMission) && (sidesX getVariable [_x,sideUnknown] != teamPlayer)}; - _Markers + _Markers select {(getMarkerPos _x distance2D getMarkerPos respawnTeamPlayer < distanceMission) && (sidesX getVariable [_x,sideUnknown] != teamPlayer)} }; //Add unspawned outposts for ammo trucks, and seaports for salvage From 18b555038135b974b449b4ebf253b06f0c7db814 Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:22:55 +0100 Subject: [PATCH 41/46] Update A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf index ca2de7796e..8e03efc15b 100644 --- a/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf +++ b/A3A/addons/Tasks/Params/LegacyParams/fn_LOG_Ammo_p.sqf @@ -11,6 +11,6 @@ private _findIfNearAndHostile = { _possibleMarkers = [outposts] call _findIfNearAndHostile; _possibleMarkers = _possibleMarkers select {(_x in seaports) or (spawner getVariable _x != 0)}; -if ( _possibleMarkers isEqualTo []) exitWith {false}; +if (_possibleMarkers isEqualTo []) exitWith {false}; selectRandom _possibleMarkers From 9e27cf7c26d57412a73b33fffec4b2112c1ef273 Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:23:28 +0100 Subject: [PATCH 42/46] Update A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf index d669efd129..eb11d198fe 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Ammo.sqf @@ -156,9 +156,9 @@ _stages = [ [5*_bonus * tierWar,theBoss] call A3A_fnc_playerScoreAdd; [0,200 * _bonus * tierWar] remoteExec ["A3A_fnc_resourcesFIA",2]; }; - if((_this get "state") isNotEqualTo "SUCCEEDED") then + if ((_this get "state") isNotEqualTo "SUCCEEDED") then { - [-10*_bonus,theBoss] call A3A_fnc_playerScoreAdd; + [-10 * _bonus,theBoss] call A3A_fnc_playerScoreAdd; }; }], ["rewardInstant", false], //Type: bool | Optional | if the reward should be given instantly on compleation of stage From 2d408064cda50b71272c8e222cb3ff52fbbede7d Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:23:59 +0100 Subject: [PATCH 43/46] Update A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf index 5f6b6cbfe4..4ce37d5e29 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf @@ -85,7 +85,7 @@ _stages = [ ["required", true], //Type: bool | Optional | if the task needs the stage to succeed ["reward", { //Type: code | Optional | the reward given for completing the stage private _bonus = if (_this get "_isDifficult") then {2} else {1}; - private _positionX =(_this get "destination"); + private _positionX = (_this get "destination"); private _markerX =(_this get "marker"); private _side = _this get "_side"; private _truckX = (_this get "truckX"); From 820de60f4e1109b4a8757399f3f03a277029d07c Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Sat, 18 Mar 2023 09:24:18 +0100 Subject: [PATCH 44/46] Update A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf index 4ce37d5e29..07ac0aa0a7 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_LOG_Supplies.sqf @@ -97,7 +97,7 @@ _stages = [ private _playersInRange = (allPlayers - (entities "HeadlessClient_F")) inAreaArray [_markerX, 250, 250]; {[10*_bonus * tierWar,_x] call A3A_fnc_playerScoreAdd} forEach _playersInRange; [5*_bonus * tierWar,theBoss] call A3A_fnc_playerScoreAdd; - [-15*_bonus,15*_bonus,_positionX] remoteExec ["A3A_fnc_citySupportChange",2]; + [-15 * _bonus,15 * _bonus,_positionX] remoteExec ["A3A_fnc_citySupportChange",2]; Debug("aggroEvent | Rebels won a supply mission"); [Occupants, -10, 60] remoteExec ["A3A_fnc_addAggression",2]; [0,200 * _bonus * tierWar] remoteExec ["A3A_fnc_resourcesFIA",2]; From b61761c639687a78187a82feff7f0387125535ca Mon Sep 17 00:00:00 2001 From: HakonRydland <61709767+HakonRydland@users.noreply.github.com> Date: Mon, 20 Mar 2023 06:13:05 +0100 Subject: [PATCH 45/46] Update A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf Co-authored-by: Ellis Nielsen --- A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf index 83bfe0b5c6..834b9f2dc9 100644 --- a/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf +++ b/A3A/addons/Tasks/Tasks/LegacyTasks/fn_AS_Official.sqf @@ -61,7 +61,7 @@ _stages = [ _group selectLeader _official; //patrol behaviour to be replaced by vcom - [leader _group, _this get "marker", "SAFE", "SPAWNED", "NOVEH", "NOFOLLOW"] execVM EQPATHTOFOLDER(core,scripts\UPSMON.sqf); + [leader _group, _this get "marker", "SAFE", "SPAWNED", "NOVEH", "NOFOLLOW"] spawn UPSMON_fnc_UPSMON; { [_x] call A3A_fnc_NATOinit; _x allowFleeing 0; From a4417c66427ef1bfc3cc9829e48e07c50843190d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon?= Date: Sat, 25 Mar 2023 10:02:59 +0100 Subject: [PATCH 46/46] - updated the task runner to correctly give out rewards and punishments - added comments to make the proccess more readable - minor code readability improvements --- A3A/addons/Tasks/Core/fn_runTask.sqf | 72 +++++++++++++++------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/A3A/addons/Tasks/Core/fn_runTask.sqf b/A3A/addons/Tasks/Core/fn_runTask.sqf index 4b26a2647c..96ea43310a 100644 --- a/A3A/addons/Tasks/Core/fn_runTask.sqf +++ b/A3A/addons/Tasks/Core/fn_runTask.sqf @@ -22,74 +22,82 @@ _taskHM call (_taskHM get "constructor"); private _stage = _taskHM getOrDefault ["__CurrentStage", 1]; private _stages = (_taskHM get "stages") select [_stage-1, count (_taskHM get "stages")]; -if (_stage > 1) then { _taskHM call ((_stages#0) getOrDefault ["Init",{}]) }; +if (_stage > 1) then { _taskHM call ((_stages#0) getOrDefault ["Init",{}]) }; //if loading any state other than first stage, run innit code to set prepare for to run the stage _taskHM set ["rewards",[]]; { + //update the map task info _taskHM call FUNC(updateTaskState); if !("action" in _x) exitWith { Error_1("Stage %1 is missing the action",_x) }; if !("condition" in _x) exitWith { Error_1("Stage %1 is missing the condition",_x) }; - private _endTime = time + (_x getOrDefault ["timeout", 1e12]); - _taskHM call (_x get "action"); - _taskHM call FUNC(updateTaskState); + //start stage + private _endTime = time + (_x getOrDefault ["timeout", 1e12]); //stage time limit + _taskHM call (_x get "action"); //run stage action + _taskHM call FUNC(updateTaskState); //update task map task info + //condition for moving to next stage waitUntil { sleep 1; - (if ("timeout" in _x) then {time >= _endTime} else {false}) - || _taskHM call (_x get "condition") - || (_taskHM getOrDefault ["cancellationToken", false]) - || (_x getOrDefault ["cancellationToken", false]) + (if ("timeout" in _x) then {time >= _endTime} else {false}) //check timelimit for stage + || _taskHM call (_x get "condition") //check stage specific conditions + || (_taskHM getOrDefault ["cancellationToken", false]) //allow cancelation at the global level + || (_x getOrDefault ["cancellationToken", false]) // allow cancelation at the stage level }; - _taskHM set ["__CurrentStage", (_taskHM get "__CurrentStage") +1]; //increment stage count (for saving/loading) + _taskHM set ["__CurrentStage", (_taskHM get "__CurrentStage") +1]; //stage finished, increment stage count (for saving/loading) + //if global canceled bail as fast as possible if (_taskHM getOrDefault ["cancellationToken", false]) exitWith { _taskHM set ["successful", false]; _taskHM set ["state", "CANCELED"]; }; - private _successful = (if ("timeout" in _x) then {time < _endTime} else {true}) && !(_x getOrDefault ["cancellationToken", false]); - _x set ["successful", _successful]; - if (_successful) then { - if (_x getOrDefault ["rewardInstant",false]) then (_x getOrDefault ["reward",{}]) else { - if ("reward" in _x) then { - (_taskHM get "rewards") pushBack (_x get "reward"); - }; - }; - _x set ["state", "SUCCEEDED"]; - } else { - if (_x getOrDefault ["cancellationToken", false]) then { - _x set ["state", "CANCELED"] - } else { - _x set ["state", "FAILED"] + //reward is always run even for failures, if stage is canceled no reward is triggered for that stage, but delayed rewarded previous stages still run reward code + //reward code handles both reward and punishment + if ("reward" in _x) then { + if (_x getOrDefault ["rewardInstant",false]) then ( + _x getOrDefault ["reward",{}] //returns code block + ) else { + (_taskHM get "rewards") pushBack (_x get "reward"); }; }; + //stage state info + private _successful = (if ("timeout" in _x) then {time < _endTime} else {true}) && !(_x getOrDefault ["cancellationToken", false]); + _x set ["successful", _successful]; + _x set ["state", (switch true do { + case _successful: {"SUCCEEDED"}; + case (_x getOrDefault ["cancellationToken", false]): {"CANCELED"}; + Default {"FAILED"}; + })]; + + //if stage failed/canceled and was required for the task, fail and bail if (!_successful && (_x getOrDefault ["required", true])) exitWith { _taskHM set ["successful", false]; _taskHM set ["state", "FAILED"]; }; } forEach _stages; -if (_taskHM getOrDefault ["successful", true]) then { - _taskHM set ["state", "SUCCEEDED"]; +//update task state info and if part of chain update record +if (_taskHM getOrDefault ["successful", true]) then {// on completion assume task successful unless otherwise state (global cancel or failed/canceled required stage) + _taskHM set ["state", "SUCCEEDED"]; //update tasks state (failed or canceled updated above in stage loop) - if (isClass ((_taskHM get "cfg")/"chain")) then { + if (isClass ((_taskHM get "cfg")/"chain")) then { //if part of chain private _chain = (_taskHM get "cfg")/"chain"; private _name = _chain/"name"; - if (getNumber (_chain/"blockProgress") < 1) then { + if (getNumber (_chain/"blockProgress") < 1) then { //if task is part of chain only increment chain progress if not side task in chain GVAR(chainStates) set [_name, (GVAR(chainStates) getOrDefault [_name, 1]) +1]; }; - if (getNumber (_chain/"lastStage") > 0) then { //reset chain when last stage hit + if (getNumber (_chain/"lastStage") > 0) then { //reset chain when last chain completed GVAR(chainStates) deleteAt _name; }; }; }; -_taskHM call (_taskHM getOrDefault ["destructor", {}]); -{_taskHM call _x} forEach (_taskHM get "rewards"); +{_taskHM call _x} forEach (_taskHM get "rewards"); //dish out none instat rewards for all completed stages of the task +_taskHM call (_taskHM getOrDefault ["destructor", {}]); //run task destructor to clean up, should be none halting -_taskHM call FUNC(updateTaskState); -GVAR(activeTasks) deleteAt ( GVAR(activeTasks) findIf {(_x get "taskID") isEqualTo (_taskHM get "taskID")} ); +_taskHM call FUNC(updateTaskState); //update the task map info +GVAR(activeTasks) deleteAt ( GVAR(activeTasks) findIf {(_x get "taskID") isEqualTo (_taskHM get "taskID")} ); // cleare from active task record