Skip to content

Commit 80fd35a

Browse files
committed
Fixed end conditions on dedicated server
Mission would not properly end on dedicated as it would only trigger on the client side. Mission endings are now handled by the server and remoteexeced to the clients.
1 parent 4f2352e commit 80fd35a

File tree

5 files changed

+35
-28
lines changed

5 files changed

+35
-28
lines changed

source/functions/initHQ/fn_BluHQinit.sqf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ _handle = [(getpos hq_blu1), _hq] call duws_fnc_guards;
5151
//STATIC DEFENSES
5252
_handle = [(getpos hq_blu1), _hq] spawn duws_fnc_fortify;
5353

54-
// IF THE OFFICER IS DEAD -- BEGIN OF "SPAWN"
55-
[_hq] spawn {
56-
_hq = _this select 0;
57-
waitUntil {sleep 1;!alive _hq};
58-
_hq switchMove "AidlPercMstpSnonWnonDnon01";
59-
["TaskFailed",["","Your commanding officer has been killed"]] call bis_fnc_showNotification;
60-
sleep 6;
61-
["officerkilled",false,true] call BIS_fnc_endMission;
62-
};
63-
6454
//CREATE PATROL
6555
[getpos hq_blu1, 40] call duws_fnc_guardsHQ;
6656
[getpos hq_blu1, 60] call duws_fnc_guardsHQ;

source/functions/initMission/fn_clientInit.sqf

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,9 @@ if (isMultiplayer) then {
211211
};
212212
};
213213

214-
// create mission victory script //SPAWN BEGIN
215-
[] spawn {
216-
217-
// CREATE MAIN OBJECTIVE
218-
capture_island_obj = player createSimpleTask ["taskIsland"];
219-
capture_island_obj setSimpleTaskDescription ["The ennemy is controlling the island, we must take it back! Capture every zone under enemy control and the mission will succeed.<br />You can let your BLUFOR forces take the island by themselves and help them getting a bigger army by accomplishing side missions. Or you can capture the zones yourself and do all the big work. As the campaign progress, the war will escalate and the armies will get stronger and start to use bigger guns.<br />To capture a zone, you need to have more units inside the zone than the enemy.<br /><br />It's up to you on how you want to play this.<br />Good luck, soldier!","Take the island",""];
220-
221-
// WAIT UNTIL ALL ZONES ARE CAPTURED
222-
waitUntil {sleep 1; amount_zones_created > 0};
223-
waitUntil {sleep 3; (zoneundercontrolblu >= amount_zones_created);}; // Toutes les zones sont capturées
224-
persistent_stat_script_win = [] call duws_fnc_persistent_stats_win;
225-
["TaskSucceeded",["","Island captured!"]] call bis_fnc_showNotification;
226-
capture_island_obj setTaskState "Succeeded";
227-
sleep 3;
228-
["island_captured_win",true,true] call BIS_fnc_endMission;
229-
};
230-
231-
214+
// Generate main task
215+
capture_island_obj = player createSimpleTask ["taskIsland"];
216+
capture_island_obj setSimpleTaskDescription ["The ennemy is controlling the island, we must take it back! Capture every zone under enemy control and the mission will succeed.<br />You can let your BLUFOR forces take the island by themselves and help them getting a bigger army by accomplishing side missions. Or you can capture the zones yourself and do all the big work. As the campaign progress, the war will escalate and the armies will get stronger and start to use bigger guns.<br />To capture a zone, you need to have more units inside the zone than the enemy.<br /><br />It's up to you on how you want to play this.<br />Good luck, soldier!","Take the island",""];
232217

233218
if (mission_DUWS_firstlaunch) then {
234219
waitUntil {chosen_settings};

source/functions/initMission/fn_serverInit.sqf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ game_master = ["player1"];publicVariable "game_master";
213213
// init the bonuses you get when capturing zones
214214
_basepoint = [] spawn duws_fnc_zones_bonus;
215215

216+
// Mission ending handler
217+
missionEndHandle = [] spawn duws_fnc_endconditions;
218+
216219
waitUntil { !isNil "serv_zones_array" };
217220
diag_log format ["serv_zones_array: %1", serv_zones_array];
218221
[serv_zones_array, getpos hq_blu1, [0,0,0], blufor_ap, opfor_ap, 2700,blufor_ai_skill,opfor_ai_skill, 2000] call duws_fnc_WARCOM_init; // 2700 is 40 mins
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
waitUntil {!isNil "hq_blu1"};
2+
3+
// End mission if HQ unit is killed
4+
hq_blu1 spawn {
5+
waitUntil {time > 1};
6+
_this addMPEventHandler ["MPKilled",
7+
{
8+
[] spawn
9+
{
10+
["TaskFailed",["","Your commanding officer has been killed"]] call bis_fnc_showNotification;
11+
sleep 6;
12+
["officerkilled",false,true] call BIS_fnc_endMission;
13+
};
14+
}];
15+
};
16+
17+
waitUntil {!isNil "amount_zones_created" && {amount_zones_created > 0}};
18+
19+
// WAIT UNTIL ALL ZONES ARE CAPTURED
20+
waitUntil {sleep 3; (zoneundercontrolblu >= amount_zones_created);}; // Toutes les zones sont capturées
21+
{
22+
persistent_stat_script_win = [] call duws_fnc_persistent_stats_win;
23+
["TaskSucceeded",["","Island captured!"]] call bis_fnc_showNotification;
24+
capture_island_obj setTaskState "Succeeded";
25+
sleep 3;
26+
["island_captured_win",true,true] call BIS_fnc_endMission;
27+
} remoteExecCall ["BIS_fnc_spawn", 0, true];

source/includes/CfgFunctions.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ class CfgFunctions
182182

183183
class startup
184184
{
185+
class endconditions {};
186+
// [] spawn duws_fnc_endconditions
185187
class manual {};
186188
// [] spawn duws_fnc_manual
187189
class placement {};

0 commit comments

Comments
 (0)