Skip to content

Commit 258d119

Browse files
phr0gzfritogotlayed
authored andcommitted
Major Change Only server side handle server script, now it's fully persistent
1 parent df16398 commit 258d119

File tree

18 files changed

+524
-227
lines changed

18 files changed

+524
-227
lines changed

source/INIT.sqf

Lines changed: 17 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,21 @@
11
diag_log format ["------------------ DUWS-R START ----v0------ player: %1", profileName];
22

3-
//////////////////////////////////////////////////////
4-
// HOW TO MANUALLY CREATE THE MISSION:
5-
// 1)YOU MUST PLACE THE HQ LOCATION
6-
// 2)DEFINE THE CAPTURABLE ZONES
7-
// -- YOU CAN ALSO JUST PUT A HQ SOMEWHERE AND LET THE ZONES BEING RANDOMLY GENERATED
8-
// -- YOU MUST PLACE MANUALLY THE HQ IF YOU ARE ALREADY PLACING THE ZONES BY HAND
9-
// 3) DONT FORGET TO DEFINE THE VARIABLES BELOW. If you are ONLY placing the HQ by hand, you just need to put "hq_manually_placed" to
10-
// "true" instead of "false". If you are also placing the zones by hand, make "zones_manually_placed" to "true".
11-
/////////////////////////////////////////////////////////////
12-
// 1) In the gamelogic, for the HQ( !! MAKE ONLY ONE HQ !!): _null=[getpos this] execVM "initHQ\BluHQinit.sqf"
13-
//
14-
// 2) In the init of gamelogic, to create a capturable enemy zone:
15-
// _null = ["zone name",pts awarded upon capture, zone radius,getpos this,false/true,false/true] execvm "createzone.sqf";
16-
// "zone name": name of the zone
17-
// pts awarded upon capture: points you earn when you capture the zone. Also the amount of points of army power you take and receive
18-
// from the enemy after capture
19-
// zone radius: how large the zone is
20-
// getpos this: It's the position of the zone. The gamelogic actually. You don't have to modify this.
21-
// false/true: if the zone is fortified or not. If the zone is fortified, there will be a bit more enemies and they will be maning
22-
// static defences if there are any
23-
// false/true: if the zone is selecting randomly a prefab base. Prefab is selected according to the zone radius. The bigger the zone,
24-
// the bigger the prefab asset will be chosen.
25-
//
26-
// EXAMPLE, in the init of a gamelogic you have placed on the map:
27-
// _null=["OP Xander",20,200,getpos this,true,false] execvm "initZones\createzone.sqf"
28-
//
29-
// 3) Define these variables:
30-
31-
// choose between "tropical" - "arid" - "temperate" - "temperate_cold" - "mediterranean"
32-
if (isNil "weather_type") then {weather_type = "tropical";};
33-
// set the skill range of ennemy AI
34-
if (isNil "opfor_ai_skill") then {opfor_ai_skill = [0.1,0.3];};
35-
// set the skill range of friendly AI, from 0 to 1 (0 being completely dumb)
36-
if (isNil "blufor_ai_skill") then {blufor_ai_skill = [0.4,0.7];};
37-
38-
// you must specify if you have manually placed HQ or not. false = HQ is randomly placed, true = you have manually placed the HQ
39-
hq_manually_placed = false;
40-
// you must specify if you have manually placed the zones or not. false = zones are randomly generated, true = you have manually placed the zones
41-
zones_manually_placed = false;
42-
zones_max_dist_from_hq = 7500;
43-
dynamic_weather_enable = true;
44-
maually_chosen = false;
45-
46-
if (isNil "enable_fast_travel") then { enable_fast_travel = true; };
47-
// chopper taxi (support) will fast travel (teleport) or not
48-
if (isNil "enableChopperFastTravel") then { enableChopperFastTravel = true; };
49-
// Starting CP
50-
if (isNil "commandpointsblu1") then { commandpointsblu1 = 20; };
51-
// STARTING ARMY POWER
52-
if (isNil "blufor_ap") then {blufor_ap = 0;};
53-
opfor_ap = 0;
54-
55-
///////////////////////////////////////////////////////
56-
// initialise variables
57-
//////////////////////////////////////////////////////
58-
// MOST OF THE VALUES ARE BEING OVERWRITTEN BY PLAYER INPUT AT THE BEGINNING
59-
//////////////////////////////////////////////////////
60-
61-
/////////////////////////////////////////////////////////////
62-
debugmode = false; // Debug mode, kind of obsolete
63-
/// ------------- VALUES UNDER THIS ARE OVERWRITTEN
64-
zones_number = 9; // Number of capturables zones to create (when zones are created randomly)
65-
zones_spacing = 1200; // minimum space between 2 zones (in meters) // SOON OBSOLETE
66-
zones_max_radius = 1000; // Determine the maximum radius a generated zone can have
67-
zones_min_radius = 200; // Determine the minium radius a generated zone can have. SHOULD NOT BE UNDER 200.
68-
69-
///////////////////////////////////////////////////////
70-
// This mission will have a harder time generating stuff if a lot of the terrain of the island is sloped, meaning that valid locations
71-
// will be harder/take longer to find (side missions, mission init).
72-
// Keep that in mind when tweaking the zones amount/radius value.
73-
/////////////////////////////////////////////////////////
74-
// preprocess the qrf file for the EH
75-
QRF_test = compile preprocessFile "WARCOM\WARCOM_opf_qrf.sqf";
76-
persistent_stat_script_init = [] execVM "persistent\persistent_stats_init.sqf";
77-
waitUntil {scriptDone persistent_stat_script_init};
78-
execvm "dynamic_music\dyn_music_init.sqf";
79-
80-
// nber of missions succes(!!dont touch!!)
81-
missions_success = 0;
82-
83-
zones_created = false;
84-
blu_hq_created = false;
85-
can_get_mission = true;
86-
failsafe_zones_not_found = false;
87-
createcenter sideLogic;
88-
LogicGroup = createGroup SideLogic;
89-
PAPABEAR=[West,"HQ"];
90-
locator_hq_actived = false;
91-
op_zones_index = 0;
92-
clientisSync = false;
93-
fobSwitch = false;
94-
player_is_choosing_hqpos = false;
95-
96-
if (isNil "amount_zones_created") then {
97-
amount_zones_created = 0;
98-
};
99-
100-
if (isNil "HQ_pos_found_generated") then {
101-
HQ_pos_found_generated = false;
102-
};
103-
104-
if (isNil "chosen_settings") then {
105-
chosen_settings = false;
106-
};
107-
108-
if (isNil "chosen_hq_placement") then {
109-
chosen_hq_placement = false;
110-
};
111-
112-
if (isNil "zoneundercontrolblu") then {
113-
zoneundercontrolblu = 0;
114-
};
115-
116-
if (isNil "amount_zones_captured") then {
117-
amount_zones_captured = 0;
118-
};
119-
120-
if (isNil "savegameNumber") then {
121-
savegameNumber = 0;
122-
};
123-
124-
if (isNil "capturedZonesNumber") then {
125-
capturedZonesNumber = 0;
126-
};
127-
128-
if (isNil "finishedMissionsNumber") then {
129-
finishedMissionsNumber = 0;
130-
};
1313

132-
if (isNil "OvercastVar") then {
133-
OvercastVar = 0;
134-
};
135-
136-
if (isNil "FogVar") then {
137-
FogVar = 0;
138-
};
4+
if (isServer) then { nul = [] execVM "serverinit.sqf"; };
5+
if (isDedicated) exitWith {};
6+
waitUntil {!isNull player};
1397

140-
// this is a special one (if/else)
141-
if (isNil "Array_of_FOBS") then {
142-
// if the player is sp or server or no fobs have been created
143-
Array_of_FOBS = [];
144-
}
145-
else /// JIP for the client
146-
{
147-
{
148-
[_x] execVM "support\FOBactions.sqf";
149-
} forEach Array_of_FOBS;
150-
};
8+
player allowDamage false;
1519

152-
if (isNil "Array_of_FOBname") then {
153-
Array_of_FOBname = [];
154-
};
10+
persistent_stat_script_init = [] execVM "persistent\persistent_stats_init.sqf";
11+
waitUntil {scriptDone persistent_stat_script_init};
12+
execvm "dynamic_music\dyn_music_init.sqf";
15513

156-
game_master = ["player1"];
157-
158-
player allowDamage false;
15914

16015
#include "dialog\supports_init.hpp"
16116
#include "dialog\squad_number_init.hpp"
16217

163-
execVM "misc\gps_marker.sqf";
18+
if (hasInterface) then { execVM "misc\gps_marker.sqf";};
16419
if (!isMultiplayer) then {
16520
getsize_script = [player] execVM "mapsize.sqf";
16621
};
@@ -206,6 +61,9 @@ if (isMultiplayer) then {
20661
"finishedMissionsNumber" addPublicVariableEventHandler {[] execVM "persistent\persistent_stats_missions_total.sqf";}; // change the shown CP for request dialog
20762
};
20863

64+
player globalChat format ["gamemaster: %1", game_master];
65+
player globalChat format ["HQ_pos_found_generated: %1", HQ_pos_found_generated];
66+
20967
if (!isDedicated && !HQ_pos_found_generated) then { // SERVER INIT
21068
if (((vehiclevarname player) in game_master)) then {
21169
DUWS_host_start = false;
@@ -226,9 +84,11 @@ if (!isDedicated && !HQ_pos_found_generated) then {
22684
if (((vehiclevarname player) in game_master)) then {
22785
_null = [] execVM "dialog\startup\hq_placement\placement.sqf";
22886
waitUntil {chosen_hq_placement};
229-
87+
player globalChat format ["hq_manually_placed: %1", hq_manually_placed];
88+
player globalChat format ["player_is_choosing_hqpos: %1", player_is_choosing_hqpos];
23089
// create random HQ
23190
if (!hq_manually_placed && !player_is_choosing_hqpos) then {
91+
player globalChat "lance recherche position...";
23292
hq_create = [20, 0.015] execVM "initHQ\locatorHQ.sqf";
23393
waitUntil {scriptDone hq_create};
23494
};
@@ -249,16 +109,6 @@ if (!isDedicated && !HQ_pos_found_generated) then {
249109
// AMBIANCE LOOP
250110
//_nul = [] execVM "musicloop.sqf";
251111

252-
if (isServer) then {
253-
// group cleaning script
254-
0 = [
255-
60*60, // seconds to delete dead bodies (0 means don't delete)
256-
60*60, // seconds to delete dead vehicles (0 means don't delete)
257-
60*60, // seconds to delete dropped weapons (0 means don't delete)
258-
0, // seconds to deleted planted explosives (0 means don't delete)
259-
60*60 // seconds to delete dropped smokes/chemlights (0 means don't delete)
260-
] execVM 'repetitive_cleanup.sqf';
261-
};
262112

263113
if (hasInterface) then {
264114
// WHEN CLIENT CONNECTS INIT (might need sleep)
@@ -284,13 +134,9 @@ if (!isMultiplayer) then {
284134
_handle = [] execVM "dialog\hc_init.sqf";
285135
};
286136

287-
if (isServer) then {
288-
// initialise the ressources per zone bonus
289-
_basepoint = [] execVM "zonesundercontrol.sqf";
290-
};
291137

292-
// init the bonuses you get when capturing zones
293-
_basepoint = [] execVM "zones_bonus.sqf";
138+
139+
294140

295141
// INIT the operative list
296142
execVM "dialog\operative\operator_init.sqf";
@@ -347,11 +193,7 @@ if (isMultiplayer) then {
347193
["island_captured_win",true,true] call BIS_fnc_endMission;
348194
};
349195

350-
if (zones_manually_placed) then {
351-
waitUntil {!isNil ("Array_of_OPFOR_zones")};
352-
sleep 1;
353-
_warcom_init = [Array_of_OPFOR_zones, getpos hq_blu1, [0,0,0], blufor_ap, opfor_ap, 2700,blufor_ai_skill,opfor_ai_skill, 1500] execVM "WARCOM\WARCOM_init.sqf";
354-
};
196+
355197

356198
if (mission_DUWS_firstlaunch) then {
357199
waitUntil {chosen_settings};

source/WARCOM/WARCOM_blu_assault.sqf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ WARCOM_blu_attack_wave_avalaible = false;
66
// Type of attack wave
77
[] spawn {
88
//WARCOM_blu_attack_wave_type = ["B_Soldier_TL_F","B_Soldier_F"];
9-
9+
diag_log format ["WARCOM_blufor_ap_assault: %1", WARCOM_blufor_ap];
1010
waitUntil {sleep 1; WARCOM_blufor_ap>=10};
1111
[West,"HQ"] sidechat "This is HQ, BLUFOR troops just arrived on the island, we'll soon be able to push through the enemy lines";
1212
WARCOM_blu_attack_wave_avalaible = true;

source/WARCOM/WARCOM_blu_patrol.sqf

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
_loop = true;
22

33
WARCOM_blu_patrol_type = "";
4+
diag_log format ["WARCOM_blufor_ap_patrol: %1", WARCOM_blufor_ap];
45

56
// Type of attack wave
67
[] spawn {
8+
diag_log "spawn1";
79
WARCOM_blu_patrol_type = (configFile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam");
810

911
waitUntil {sleep 1; WARCOM_blufor_ap>40};
@@ -36,25 +38,25 @@ WARCOM_blu_patrol_type = "";
3638

3739
while {true} do {
3840
if (count WARCOM_zones_controled_by_BLUFOR > 1) then { // make sure blufor is controlling at least 2 zones
39-
sleep 2;
40-
41-
// find a zone where to spawn OPF wave *** BEGIN
42-
_found = false;
43-
_randomZone = [];
44-
_failSafe = 0;
41+
sleep 2;
42+
43+
// find a zone where to spawn OPF wave *** BEGIN
44+
_found = false;
45+
_randomZone = [];
46+
_failSafe = 0;
4547
while {!_found} do {
46-
_randomZone = WARCOM_zones_controled_by_BLUFOR call BIS_fnc_selectRandom;
47-
if (_randomZone distance player > 2000) then {_found=true;};
48-
sleep 0.2;
48+
_randomZone = WARCOM_zones_controled_by_BLUFOR call BIS_fnc_selectRandom;
49+
if (_randomZone distance player > 2000) then {_found=true;};
50+
sleep 0.2;
4951
// player sidechat format["Failsafe: %1",_failsafe];
50-
_failSafe = _failSafe + 1;
51-
if (_failsafe > 10) then {sleep 300; _failsafe = 0;}
52+
_failSafe = _failSafe + 1;
53+
if (_failsafe > 10) then {sleep 300; _failsafe = 0;}
5254
};
5355
// find a zone *** end
54-
_randomZone = [(_randomZone select 0)+40,_randomZone select 1];
55-
_group = [_randomZone, WEST, WARCOM_blu_patrol_type,[],[],WARCOM_blu_ai_skill_range] call BIS_fnc_spawnGroup;
56-
_opf_assault = [_group] execVM "WARCOM\WARCOM_wp_blu_patrol.sqf";
57-
// _blu_assault = [_group,"derp"] execVM "WARCOM\WARCOM_gps_marker.sqf";
56+
_randomZone = [(_randomZone select 0)+40,_randomZone select 1];
57+
_group = [_randomZone, WEST, WARCOM_blu_patrol_type,[],[],WARCOM_blu_ai_skill_range] call BIS_fnc_spawnGroup;
58+
_opf_assault = [_group] execVM "WARCOM\WARCOM_wp_blu_patrol.sqf";
59+
// _blu_assault = [_group,"derp"] execVM "WARCOM\WARCOM_gps_marker.sqf";
5860

5961
// spawn armored
6062
if (WARCOM_blufor_ap>50) then {
@@ -69,3 +71,4 @@ WARCOM_blu_patrol_type = "";
6971
sleep (random 1200); // patrol delay
7072
};
7173
};
74+

source/WARCOM/WARCOM_init.sqf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,25 @@ _WARCOM_zones_controled_by_OPFOR = WARCOM_createdZones;
4444
WARCOM_zones_controled_by_OPFOR = [] + _WARCOM_zones_controled_by_OPFOR;
4545

4646
// Init BLU patrols
47+
diag_log "Init BLU patrols";
4748
_blu_patrol = [] execVM "WARCOM\WARCOM_blu_patrol.sqf";
48-
waitUntil {scriptDone _blu_patrol};
49+
//waitUntil {scriptDone _blu_patrol};
4950

5051
// Init OPF patrols
52+
diag_log "Init OPF patrols";
5153
_opf_patrol = [] execVM "WARCOM\WARCOM_opf_patrol.sqf";
52-
waitUntil {scriptDone _opf_patrol};
54+
//waitUntil {scriptDone _opf_patrol};
5355

5456
// Initialize the BLU attack waves
57+
diag_log "Initialize the BLU attack waves";
5558
_blu_assault = [] execVM "WARCOM\WARCOM_blu_assault.sqf";
56-
waitUntil {scriptDone _blu_assault};
59+
//waitUntil {scriptDone _blu_assault};
5760

5861

5962
// Init the OPF attack waves
63+
diag_log "Init the OPF attack waves";
6064
_opf_assault = [] execVM "WARCOM\WARCOM_opf_assault.sqf";
61-
waitUntil {scriptDone _opf_assault};
65+
//waitUntil {scriptDone _opf_assault};
6266

6367

6468

source/dialog/startup/startup_common.sqf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,17 @@ switch (_index) do {
393393
if (zones_max_radius <= zones_min_radius) exitWith {Hint "Unable to generate campaign:\nMaximum radius of a zone\nmust be superior to\nMinimum radius of a zone"};
394394

395395
zones_spacing = zones_max_radius + 200;
396+
publicVariable "chosen_settings";
397+
publicVariable "zones_max_radius";
398+
publicVariable "zones_min_radius";
399+
publicVariable "zones_number";
396400
publicVariable "commandpointsblu1";
397401
publicVariable "weather_type";
398402
publicVariable "blufor_ai_skill";
399403
publicVariable "opfor_ai_skill";
404+
publicVariable "opfor_ap";
405+
publicVariable "blufor_ap";
400406
publicVariable "enableChopperFastTravel";
407+
publicVariable "enable_fast_travel";
408+
publicVariable "zones_max_dist_from_hq";
409+

source/initHQ/locatorhq.sqf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
_found = false;
22
_foundSafePos = [];
3+
player globalChat "recherche zone";
34
while {!_found} do {
45
_foundSafePos = [center_of_map, 0,half_of_map,5,0,0.1,0,[],[[0,0],[0,0]]] call BIS_fnc_findSafePos;
56
if (_foundSafePos select 0 != 0 && _foundSafePos select 1 != 0) then {_found=true;};
67
};
7-
8+
player globalChat format ["foundSafePos: %1", _foundSafePos];
89
_handle = [_foundSafePos] execVM "initHQ\bluHQinit.sqf";

source/initZones/locatorzonesV1.sqf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ sleep 20;
111111
_zones_array = [_zones_array, 0] call BIS_fnc_removeIndex;
112112

113113
//player globalchat format["%1",_zones_array];
114-
_warcom_init = [_zones_array, getpos hq_blu1, [0,0,0], blufor_ap, opfor_ap, 2700,blufor_ai_skill,opfor_ai_skill, 2000] execVM "WARCOM\WARCOM_init.sqf"; // 2700 is 40 mins
115-
waitUntil {scriptDone _warcom_init};
114+
serv_zones_array = [] + _zones_array;
115+
publicVariable "serv_zones_array";
116+
//_warcom_init = [_zones_array, getpos hq_blu1, [0,0,0], blufor_ap, opfor_ap, 2700,blufor_ai_skill,opfor_ai_skill, 2000] execVM "WARCOM\WARCOM_init.sqf"; // 2700 is 40 mins
117+
//waitUntil {scriptDone _warcom_init};
116118
savegame;
117119
sleep 1;
118120
[[format["Campaign generated<br />Welcome to %1, %2",_worldName,profilename]]] spawn BIS_fnc_typeText;

0 commit comments

Comments
 (0)