diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:38:09 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:38:09 +0300 |
| commit | a3a91d4f45b22fd487ecbc954ad979be5d03efdd (patch) | |
| tree | a554ab159a347dcd6c00ca1c7c26c1ec3ac0a6bd /Client/Functions/Client_TaskSystem.sqf | |
| download | a2wf_chernarus-a3a91d4f45b22fd487ecbc954ad979be5d03efdd.tar.gz a2wf_chernarus-a3a91d4f45b22fd487ecbc954ad979be5d03efdd.tar.bz2 a2wf_chernarus-a3a91d4f45b22fd487ecbc954ad979be5d03efdd.zip | |
Diffstat (limited to 'Client/Functions/Client_TaskSystem.sqf')
| -rw-r--r-- | Client/Functions/Client_TaskSystem.sqf | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Client/Functions/Client_TaskSystem.sqf b/Client/Functions/Client_TaskSystem.sqf new file mode 100644 index 0000000..3072fb2 --- /dev/null +++ b/Client/Functions/Client_TaskSystem.sqf @@ -0,0 +1,69 @@ +Private ["_i","_location","_locations","_next","_sideID","_sorted","_task","_type"];
+_type = _this select 0;
+_location = if (count _this > 1) then {_this select 1} else {objNull};
+
+switch (_type) do {
+ //--- Complete Towns set initialization.
+ case "TownAddComplete": {
+ //--- Todo: improve the sort by with other digits instead of the first one.
+ sleep 4;
+ Private ["_addOrder","_returned","_town","_towns","_townsLabel"];
+ _townsLabel = [];
+ {_townsLabel = _townsLabel + [_x getVariable 'name']} forEach towns;
+ _towns = ([_townsLabel,true,towns] Call CIPHER_SortArray) select 1;
+
+ for '_i' from 0 to count(_towns)-1 do {
+ _town = _towns select _i;
+ waitUntil {_sideID = _town getVariable 'sideID';!isNil '_sideID'};
+ _sideID = _town getVariable "sideID";
+ _task = player createSimpleTask [Format["TakeTowns_%1",str _town]];
+ if (_sideID != sideID) then {
+ _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"]];
+ } else {
+ _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown_Complete",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"]];
+ _task setTaskState "Succeeded";
+ };
+ _task setSimpleTaskDestination (getPos _town);
+ _town setVariable ['taskLink',_task];
+ };
+
+ ["TownAssignClosest"] Spawn TaskSystem;
+ };
+
+ //--- Assign the closest town to the player.
+ case "TownAssignClosest": {
+ sleep 4;
+ _next = [player,sideJoined] Call GetClosestLocationBySide;
+ if !(isNull _next) then {
+ ["TownHintNew",_next] Spawn TaskSystem;
+ _task = (_next getVariable 'taskLink');
+ /* Keep the commander order ! */
+ if (!isNull comTask) then {
+ if (taskState comTask == "Succeeded") then {player setCurrentTask _task};
+ } else {
+ player setCurrentTask _task;
+ };
+ };
+ };
+
+ //--- Update a town's value.
+ case "TownUpdate": {
+ _task = _location getVariable 'taskLink';
+ _sideID = _location getVariable "sideID";
+ if !(isNil '_task') then {
+ if (_sideID == sideID) then {
+ _task setTaskState "Succeeded";
+ _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown_Complete",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]];
+ } else {
+ _task setTaskState "Created";
+ _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]];
+ };
+ }
+ };
+
+ //--- Hint for a new town task.
+ case "TownHintNew": {taskHint [format [localize "str_taskNew" + "\n%1",Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]], [1,1,1,1], "taskNew"]};
+
+ //--- Hint for a completed town task.
+ case "TownHintDone": {taskHint [format [localize "str_taskAccomplished" + "\n%1",Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]], [1,1,1,1], "taskDone"]};
+};
\ No newline at end of file |
