From 628d33984d9228f1781d13a65fbb80f35facc899 Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:55:24 +0300 Subject: init --- Server/Construction/Construction_HQSite.sqf | 83 +++++++++++++ Server/Construction/Construction_MediumSite.sqf | 135 +++++++++++++++++++++ Server/Construction/Construction_SmallSite.sqf | 126 +++++++++++++++++++ .../Construction_StationaryDefense.sqf | 94 ++++++++++++++ 4 files changed, 438 insertions(+) create mode 100644 Server/Construction/Construction_HQSite.sqf create mode 100644 Server/Construction/Construction_MediumSite.sqf create mode 100644 Server/Construction/Construction_SmallSite.sqf create mode 100644 Server/Construction/Construction_StationaryDefense.sqf (limited to 'Server/Construction') diff --git a/Server/Construction/Construction_HQSite.sqf b/Server/Construction/Construction_HQSite.sqf new file mode 100644 index 0000000..3e4bef6 --- /dev/null +++ b/Server/Construction/Construction_HQSite.sqf @@ -0,0 +1,83 @@ +Private ["_areas","_deployed","_direction","_grp","_HQ","_HQName","_logic","_MHQ","_near","_position","_side","_sideText","_site","_text","_type","_update","_varTH"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_sideText = _side; + +/* Handle the LAG. */ +_varTH = format['WF_CHQInUse_%1',_sideText]; +waitUntil {!(WF_Logic getVariable _varTH)}; +WF_Logic setVariable [_varTH,true]; + +_HQ = (_sideText) Call GetSideHQ; +_deployed = (_sideText) Call GetSideHQDeployed; + +if (!_deployed) then { + _HQ setPos [1,1,1]; + + _site = _type CreateVehicle _position; + _site SetDir _direction; + _site SetPos _position; + + Call Compile Format ["%1MHQ = _site; %1MHQDeployed = true; publicVariable '%1MHQ'; publicVariable '%1MHQDeployed';",_sideText]; + + _site setVehicleInit Format["[this,true,%1] ExecVM 'Client\Init\Init_BaseStructure.sqf'",_side]; + processInitCommands; + + ["Constructed",_type,_side] Spawn SideMessage; + Call Compile Format ["_site addEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",_side,typeOf _site]; + _site addEventHandler ["hit",{_this Spawn BuildingDamaged}]; + if (paramHandleFF) then {Call Compile Format ["_site addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]}; + + //--- base area limits. + if (paramBaseArea) then { + _update = true; + _areas = WF_Logic getVariable Format['%1Area',_sideText]; + _near = [_position,_areas] Call SortByDistance; + if (count _near > 0) then { + if ((_near select 0) distance _position < (('WFBE_BASEAREARANGE' Call GetNamespace) + ('WFBE_MHQBUILDINGRANGE' Call GetNamespace))) then {_update = false}; + }; + if (_update) then { + _grp = createGroup sideLogic; + _logic = _grp createUnit ["Logic",[0,0,0],[],0,"NONE"]; + _logic setPos _position; + WF_Logic setVariable [Format['%1Area',_sideText],_areas + [_logic],true]; + }; + }; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_HQSite: The %1 MHQ (%2) was deployed",_sideText,_type,diag_frameno,diag_tickTime]; + + deleteVehicle _HQ; +} else { + _position = getPos _HQ; + _direction = getDir _HQ; + _HQName = Format["WFBE_%1MHQNAME",_sideText] Call GetNamespace; + + _HQ SetPos [1,1,1]; + + _MHQ = _HQName createVehicle _position; + + Call Compile Format ["%1MHQ = _MHQ; %1MHQDeployed = false; publicVariable '%1MHQ'; publicVariable '%1MHQDeployed';",_sideText]; + + _MHQ setDir _direction; + _MHQ setVelocity [0,0,-1]; + _MHQ setVariable ["WFBE_Taxi_Prohib", true]; + + ["Constructed",_HQName,_side] Spawn SideMessage; + Call Compile Format ["_MHQ AddEventHandler [""killed"",{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",_side,typeOf _MHQ]; + if (paramHandleFF) then {Call Compile Format ["_MHQ addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]}; + + _text = ""; + if (('WFBE_INCOMINGMISSILEMAXRANGE' Call GetNamespace) != 0) then {_text = "this addEventHandler ['IncomingMissile', {_this Spawn HandleIncomingMissile}];"}; + + _MHQ setVehicleInit Format["['Headquarters','ColorGreen',[1,1],'','HQUndeployed',this,0.2,false,'','',false,%1] ExecVM 'Common\Common_MarkerUpdate.sqf';%2",_side,_text]; + processInitCommands; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_HQSite: The %1 MHQ (%2) was mobilized",_sideText,_HQName,diag_frameno,diag_tickTime]; + + deleteVehicle _HQ; +}; + +/* Handle the LAG. */ +WF_Logic setVariable [_varTH,false]; \ No newline at end of file diff --git a/Server/Construction/Construction_MediumSite.sqf b/Server/Construction/Construction_MediumSite.sqf new file mode 100644 index 0000000..c153784 --- /dev/null +++ b/Server/Construction/Construction_MediumSite.sqf @@ -0,0 +1,135 @@ +//***************************************************************************************** +//Description: Creates a small construction site. +//***************************************************************************************** +Private ["_construct","_constructed","_direction","_group","_index","_nearLogic","_objects","_position","_rlType","_side","_site","_siteName","_startTime","_structures","_structuresNames","_time","_timeNextUpdate","_type"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_index = _this select 4; + +_time = ((Format ["WFBE_%1STRUCTURETIMES",str _side] Call GetNamespace) select _index) / 2; + +_siteName = Format["WFBE_%1CONSTRUCTIONSITE",str _side] Call GetNamespace; + +_structures = Format ['WFBE_%1STRUCTURES',str _side] Call GetNamespace; +_structuresNames = Format ['WFBE_%1STRUCTURENAMES',str _side] Call GetNamespace; +_rlType = _structures select (_structuresNames find _type); + +_startTime = time; +_timeNextUpdate = _startTime + _time; + +_objects = []; +if (WF_A2_Arrowhead) then {_objects = [[_siteName,[0,0,0.00242043],359.958,1,0],["Paleta2",[0.430908,-5.60693,-0.30535],359.945,1,0],["Paleta1",[-2.62598,-6.0437,0.000275612],359.951,1,0],["Land_Barrel_sand",[-10.1826,0.356689,7.62939e-005],0.00146227,1,0],["Land_Barrel_sand",[-10.7854,-1.97974,0.000187874],359.987,1,0],["Paleta1",[-9.7251,5.53955,0.000106812],359.976,1,0],["Land_Barrel_sand",[-11.053,-4.12183,0.00019455],359.987,1,0],["Land_Barrel_sand",[-12.3416,-1.57056,7.43866e-005],0.00146227,1,0],["Barrels",[-12.5134,0.682861,0.000136375],0.00146227,1,0],["RoadBarrier_long",[1.63794,-12.8806,-0.000716209],359.92,1,0],["Land_Barrel_sand",[-11.5149,-6.25757,0.00084877],359.938,1,0],["Land_Barrel_sand",[-12.7363,-3.63184,0.000207901],359.938,1,0],["Barrel4",[14.1938,0.500732,0.000412941],359.98,1,0],["Land_Barrel_sand",[-13.0708,-5.9082,0.000863075],359.938,1,0],["Barrel5",[14.7661,-1.11182,0.000411987],359.98,1,0],["Barrel1",[14.7314,2.21338,0.000409126],359.98,1,0],["Paleta2",[12.0034,9.8418,-0.305568],0.0412118,1,0],["RoadCone",[-12.2202,-13.7024,0.000279427],359.984,1,0],["RoadCone",[-12.1877,15.0469,0.000328064],359.969,1,0],["RoadCone",[14.5701,-13.311,0.000322342],359.995,1,0],["RoadCone",[14.6084,14.6824,0.000889778],359.994,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [[_siteName,[0,0,0.00242043],359.958,1,0],["Paleta2",[0.430908,-5.60693,-0.30535],359.945,1,0],["Paleta1",[-2.62598,-6.0437,0.000275612],359.951,1,0],["Land_Ind_BoardsPack1",[-0.82251,-9.15479,0.00291061],49.9467,1,0],["Land_Barrel_sand",[-10.1826,0.356689,7.62939e-005],0.00146227,1,0],["Land_Barrel_sand",[-10.7854,-1.97974,0.000187874],359.987,1,0],["Paleta1",[-9.7251,5.53955,0.000106812],359.976,1,0],["Land_Ind_Timbers",[1.88354,11.1238,-0.487763],95.0061,1,0],["Land_Barrel_sand",[-11.053,-4.12183,0.00019455],359.987,1,0],["Land_Ind_BoardsPack1",[-6.6582,-10.0774,0.0021534],324.956,1,0],["Land_Ind_BoardsPack1",[9.50244,-7.4668,0.00151634],270,1,0],["Land_Ind_Timbers",[12.0264,4.19629,-0.534346],359.98,1,0],["Land_Barrel_sand",[-12.3416,-1.57056,7.43866e-005],0.00146227,1,0],["Barrels",[-12.5134,0.682861,0.000136375],0.00146227,1,0],["RoadBarrier_long",[1.63794,-12.8806,-0.000716209],359.92,1,0],["Land_Barrel_sand",[-11.5149,-6.25757,0.00084877],359.938,1,0],["Land_Barrel_sand",[-12.7363,-3.63184,0.000207901],359.938,1,0],["Land_Ind_BoardsPack1",[-4.74194,-12.4204,0.00105476],49.9807,1,0],["Barrel4",[14.1938,0.500732,0.000412941],359.98,1,0],["Land_Barrel_sand",[-13.0708,-5.9082,0.000863075],359.938,1,0],["Barrel5",[14.7661,-1.11182,0.000411987],359.98,1,0],["Land_Ind_BoardsPack1",[9.42847,-11.5142,0.00151634],359.964,1,0],["Barrel1",[14.7314,2.21338,0.000409126],359.98,1,0],["Paleta2",[12.0034,9.8418,-0.305568],0.0412118,1,0],["RoadCone",[-12.2202,-13.7024,0.000279427],359.984,1,0],["RoadCone",[-12.1877,15.0469,0.000328064],359.969,1,0],["RoadCone",[14.5701,-13.311,0.000322342],359.995,1,0],["RoadCone",[14.6084,14.6824,0.000889778],359.994,1,0]]}; +_construct = Compile PreprocessFile "ca\modules\dyno\data\scripts\objectMapper.sqf"; +_constructed = ([_position,_direction,_objects] Call _construct); + +//--- Create the logic. +(createGroup sideLogic) createUnit ["LocationLogicStart",_position,[],0,"NONE"]; + +_nearLogic = objNull; +if !(paramUseWorkers) then { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + waitUntil {time >= _timeNextUpdate}; + _timeNextUpdate = _startTime + _time * 2; +} else { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + //--- Instanciate the logic. + _nearLogic setVariable ["WFBE_B_Completion", 0]; + _nearLogic setVariable ["WFBE_B_CompletionRatio", 0.6]; + _nearLogic setVariable ["WFBE_B_Direction", _direction]; + _nearLogic setVariable ["WFBE_B_Position", _position]; + _nearLogic setVariable ["WFBE_B_Repair", false]; + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + //--- Add the logic to the list. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) + [_nearLogic],true] Call SetNamespace; + + //--- Awaits for 33% of completion. + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 33.33) exitWith {}; + }; +}; + +if (WF_A2_Arrowhead) then {_objects = [[_siteName,[2.52539,-0.0065918,-0.000685692],359.928,1,0],["Land_WoodenRamp",[-2.27954,-0.582764,0.377601],270,1,0],["Land_WoodenRamp",[0.94751,-4.2085,0.388518],179.986,1,0],[_siteName,[2.60547,6.20386,-0.000685692],359.928,1,0],["Land_Dirthump01_EP1",[-8.63159,8.021,-0.00167847],29.985,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [[_siteName,[2.52539,-0.0065918,-0.000685692],359.928,1,0],["Land_WoodenRamp",[-2.27954,-0.582764,0.377601],270,1,0],["Land_WoodenRamp",[0.94751,-4.2085,0.388518],179.986,1,0],[_siteName,[2.60547,6.20386,-0.000685692],359.928,1,0],["Land_Dirthump01",[-8.63159,8.021,-0.00167847],29.985,1,0]]}; +_constructed = _constructed + ([_position,_direction,_objects] Call _construct); + +if !(paramUseWorkers) then { + waitUntil {time >= _timeNextUpdate}; + _timeNextUpdate = _startTime + _time * 3; +} else { + //--- Awaits for 66% + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 66.66) exitWith {}; + }; +}; + +if (WF_A2_Arrowhead) then {_objects = [["Land_Misc_Scaffolding",[5.67456,2.39307,0.0763969],179.92,1,0],["Land_Dirthump02_EP1",[-8.63159,8.021,0.000141144],29.9958,1,0],["Barrels",[11.4519,12.5623,0.00311279],359.877,1,0],["RoadCone",[-12.1465,-13.7354,0.000406265],359.958,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [["Land_Misc_Scaffolding",[5.67456,2.39307,0.0763969],179.92,1,0],["Land_Ind_Timbers",[10.0811,4.63477,-0.127748],359.961,1,0],["Land_Dirthump02",[-8.63159,8.021,0.000141144],29.9958,1,0],["Land_Ind_BoardsPack1",[13.3027,-7.63159,0.00639725],359.838,1,0],["Land_Ind_BoardsPack1",[-9.70117,-12.4263,0.00152397],324.976,1,0],["Land_Ind_BoardsPack1",[-7.78491,-14.7693,0.00152779],49.9774,1,0],["Barrels",[11.4519,12.5623,0.00311279],359.877,1,0],["Land_Ind_BoardsPack1",[13.4668,-11.5061,0.00515175],359.942,1,0],["RoadCone",[-12.1465,-13.7354,0.000406265],359.958,1,0]]}; +_constructed = _constructed + ([_position,_direction,_objects] Call _construct); + +if !(paramUseWorkers) then { + waitUntil {time >= _timeNextUpdate}; + + if !(isNull _nearLogic) then { + _group = group _nearLogic; + deleteVehicle _nearLogic; + deleteGroup _group; + }; +} else { + //--- Awaits for 100% + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 100) exitWith {}; + }; + + //--- Remove the logic from the list since it's built. Add it back if destroyed. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_nearLogic],true] Call SetNamespace; +}; + +{if !(isNull _x) then {deleteVehicle _x}} forEach _constructed; + +_site = _type createVehicle _position; +_site setDir _direction; +_site setPos _position; + +["Constructed",_type,_side] Spawn SideMessage; + +if (!IsNull _site) then { + Call Compile Format ["%1BaseStructures = %1BaseStructures + [_site]; publicVariable '%1BaseStructures';",str _side]; + + _site setVehicleInit Format["[this,false,%1] ExecVM 'Client\Init\Init_BaseStructure.sqf'",_side]; + processInitCommands; + + _site addEventHandler ["hit",{_this Spawn BuildingDamaged}]; + if (paramHandleFF) then { + Call Compile Format ["_site addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]; + } else { + _site addEventHandler ['handleDamage',{[_this select 0, _this select 2] Call HandleBuildingDamage}]; + }; + Call Compile Format ["_site AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn BuildingKilled}];",_side,_type]; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_MediumSite: A %1 %2 has been constructed",str _side,_type,diag_frameno,diag_tickTime]; +}; \ No newline at end of file diff --git a/Server/Construction/Construction_SmallSite.sqf b/Server/Construction/Construction_SmallSite.sqf new file mode 100644 index 0000000..30e77c5 --- /dev/null +++ b/Server/Construction/Construction_SmallSite.sqf @@ -0,0 +1,126 @@ +//***************************************************************************************** +//Description: Creates a small construction site. +//***************************************************************************************** +Private ["_construct","_constructed","_direction","_group","_index","_nearLogic","_objects","_position","_rlType","_side","_site","_siteName","_startTime","_structures","_structuresNames","_time","_timeNextUpdate","_type"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_index = _this select 4; + +_time = ((Format ["WFBE_%1STRUCTURETIMES",str _side] Call GetNamespace) select _index) / 2; + +_siteName = Format["WFBE_%1CONSTRUCTIONSITE",str _side] Call GetNamespace; + +_structures = Format ['WFBE_%1STRUCTURES',str _side] Call GetNamespace; +_structuresNames = Format ['WFBE_%1STRUCTURENAMES',str _side] Call GetNamespace; +_rlType = _structures select (_structuresNames find _type); + +_startTime = time; +_timeNextUpdate = _startTime + _time; + +_objects = []; +if (WF_A2_Arrowhead) then {_objects = [[_siteName,[0,0,-0.000230789],359.997,1,0],["Paleta2",[0.416992,-5.62012,-0.305746],0.0130822,1,0],["Land_Barrel_sand",[-5.59448,3.26929,6.29425e-005],359.997,1,0],["Paleta1",[-2.62976,-6.04736,5.53131e-005],0.0130822,1,0],["Barrel4",[6.63696,0.694336,0.000753403],359.991,1,0],["Land_Barrel_sand",[-6.73267,2.06372,6.10352e-005],359.997,1,0],["Barrel5",[7.19604,2.8855,0.00028801],0.0135841,1,0],["Barrel1",[6.08984,5.5415,0.00028801],0.0135841,1,0],["Land_Barrel_sand",[-7.13452,4.40747,6.29425e-005],359.997,1,0],["RoadBarrier_long",[0.221924,-8.58496,0.00206566],0.0130822,1,0],["Land_Barrel_sand",[-8.27271,2.80054,6.10352e-005],359.997,1,0],["Barrels",[-7.91895,-4.09668,0.00037384],0.0128253,1,0],["RoadCone",[-10.4381,-8.94336,0.000131607],0.0119093,1,0],["RoadCone",[11.1655,-8.79932,0.00034523],359.991,1,0],["RoadCone",[-10.5692,12.6655,0.000509262],359.948,1,0],["RoadCone",[11.0276,12.3904,0.000509262],359.948,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [[_siteName,[0,0,-0.000230789],359.997,1,0],["Paleta2",[0.416992,-5.62012,-0.305746],0.0130822,1,0],["Land_Barrel_sand",[-5.59448,3.26929,6.29425e-005],359.997,1,0],["Paleta1",[-2.62976,-6.04736,5.53131e-005],0.0130822,1,0],["Barrel4",[6.63696,0.694336,0.000753403],359.991,1,0],["Land_Ind_BoardsPack2",[6.41797,-2.52051,0.000915527],270,1,0],["Land_Barrel_sand",[-6.73267,2.06372,6.10352e-005],359.997,1,0],["Barrel5",[7.19604,2.8855,0.00028801],0.0135841,1,0],["Barrel1",[6.08984,5.5415,0.00028801],0.0135841,1,0],["Land_Barrel_sand",[-7.13452,4.40747,6.29425e-005],359.997,1,0],["RoadBarrier_long",[0.221924,-8.58496,0.00206566],0.0130822,1,0],["Land_Barrel_sand",[-8.27271,2.80054,6.10352e-005],359.997,1,0],["Barrels",[-7.91895,-4.09668,0.00037384],0.0128253,1,0],["Land_Ind_BoardsPack1",[6.40332,-7.16162,0.000520706],0.0130822,1,0],["Land_Ind_BoardsPack1",[-6.18384,-8.09961,0.000535965],50.0093,1,0],["RoadCone",[-10.4381,-8.94336,0.000131607],0.0119093,1,0],["RoadCone",[11.1655,-8.79932,0.00034523],359.991,1,0],["RoadCone",[-10.5692,12.6655,0.000509262],359.948,1,0],["RoadCone",[11.0276,12.3904,0.000509262],359.948,1,0]]}; +_construct = Compile PreprocessFile "ca\modules\dyno\data\scripts\objectMapper.sqf"; +_constructed = ([_position,_direction,_objects] Call _construct); + +//--- Create the logic. +(createGroup sideLogic) createUnit ["LocationLogicStart",_position,[],0,"NONE"]; + +_nearLogic = objNull; +if !(paramUseWorkers) then { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + waitUntil {time >= _timeNextUpdate}; + _timeNextUpdate = _startTime + _time * 2; +} else { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + //--- Instanciate the logic. + _nearLogic setVariable ["WFBE_B_Completion", 0]; + _nearLogic setVariable ["WFBE_B_CompletionRatio", 1.1]; + _nearLogic setVariable ["WFBE_B_Direction", _direction]; + _nearLogic setVariable ["WFBE_B_Position", _position]; + _nearLogic setVariable ["WFBE_B_Repair", false]; + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + //--- Add the logic to the list. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) + [_nearLogic],true] Call SetNamespace; + + //--- Awaits for 50% of completion. + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 50) exitWith {}; + }; +}; + +if (WF_A2_Arrowhead) then {_objects = [["Land_WoodenRamp",[-2.45703,-0.593262,0.357508],270,1,0],["Land_WoodenRamp",[-2.5083,1.3811,0.357508],270,1,0],[_siteName,[4.6333,0.338135,0.00393867],90,1,0],["Land_Dirthump02_EP1",[-0.587891,8.57935,0.00207901],359.967,1,0],["Land_Dirthump01_EP1",[-3.97363,-8.49219,-4.57764e-005],29.9804,1,0],["Land_WoodenRamp",[8.8335,-0.125977,0.403545],90,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [["Land_WoodenRamp",[-2.45703,-0.593262,0.357508],270,1,0],["Land_WoodenRamp",[-2.5083,1.3811,0.357508],270,1,0],[_siteName,[4.6333,0.338135,0.00393867],90,1,0],["Land_Dirthump02",[-0.587891,8.57935,0.00207901],359.967,1,0],["Land_Dirthump01",[-3.97363,-8.49219,-4.57764e-005],29.9804,1,0],["Land_WoodenRamp",[8.8335,-0.125977,0.403545],90,1,0]]}; +_constructed = _constructed + ([_position,_direction,_objects] Call _construct); + +if !(paramUseWorkers) then { + waitUntil {time >= _timeNextUpdate}; + + if !(isNull _nearLogic) then { + _group = group _nearLogic; + deleteVehicle _nearLogic; + deleteGroup _group; + }; +} else { + //--- Awaits for 100% + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 100) exitWith {}; + }; + + //--- Remove the logic from the list since it's built. Add it back if destroyed. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_nearLogic],true] Call SetNamespace; +}; + +{if !(isNull _x) then {DeleteVehicle _x}} ForEach _constructed; + +_site = _type CreateVehicle _position; +_site SetDir _direction; +_site SetPos _position; + +["Constructed",_type,_side] Spawn SideMessage; + +if (!IsNull _site) then { + Call Compile Format ["%1BaseStructures = %1BaseStructures + [_site]; publicVariable '%1BaseStructures';",str _side]; + + _site SetVehicleInit Format["[this,false,%1] ExecVM 'Client\Init\Init_BaseStructure.sqf'",_side]; + ProcessInitCommands; + + _site addEventHandler ["hit",{_this Spawn BuildingDamaged}]; + if (paramHandleFF) then { + Call Compile Format ["_site addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]; + } else { + _site addEventHandler ['handleDamage',{[_this select 0, _this select 2] Call HandleBuildingDamage}]; + }; + Call Compile Format ["_site AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn BuildingKilled}];",_side,_type]; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_SmallSite: A %1 %2 has been constructed",str _side,_type,diag_frameno,diag_tickTime]; +}; + +//--- Base Patrols. +if ((_type == WESTBAR || _type == EASTBAR) && paramBasePatrols) then { + [_site, _side] ExecFSM 'Server\FSM\basepatrol.fsm'; + diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Construction_SmallSite: A %1 Base Patrol Module has been launched",str _side,diag_frameno,diag_tickTime]; +} \ No newline at end of file diff --git a/Server/Construction/Construction_StationaryDefense.sqf b/Server/Construction/Construction_StationaryDefense.sqf new file mode 100644 index 0000000..1c62e25 --- /dev/null +++ b/Server/Construction/Construction_StationaryDefense.sqf @@ -0,0 +1,94 @@ +/* Description: Creates Defenses. */ +Private ["_buildings","_defense","_direction","_isAIQuery","_isArtillery","_manned","_position","_side","_type"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_manned = _this select 4; +_isAIQuery = _this select 5; +_manRange = if (count _this > 6) then {_this select 6} else {'WFBE_DEFENSEMANRANGE' Call GetNamespace}; + +_defense = _type createVehicle _position; +_defense setDir _direction; +_defense setPos _position; + +diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_StationaryDefense: A %1 %2 was created",str _side,_type,diag_frameno,diag_tickTime]; + +//--- If it's a minefield, we exit the script while spawning it. +if (_type == 'Sign_Danger') exitWith { + Private ["_c","_h","_mine","_mineType","_toWorld"]; + _mineType = if (_side == east) then {'MineMineE'} else {'MineMine'}; + _h = -4; + _c = 0; + for [{_z=0}, {_z<9}, {_z=_z+1}] do{ + _array = [((_defense worldToModel (getPos _defense)) select 0) - 16 +_c,((_defense worldToModel (getPos _defense)) select 1) + _h]; + _toWorld = _defense modelToWorld _array; + _toWorld set[2,0]; + _mine = createMine [_mineType, _toWorld,[], 0]; + _c = _c + 4; + }; + + _h = 0; + _c = 2; + for [{_z=0}, {_z<8}, {_z=_z+1}] do{ + _array = [((_defense worldToModel (getPos _defense)) select 0) - 16 +_c,((_defense worldToModel (getPos _defense)) select 1) + _h]; + _toWorld = _defense modelToWorld _array; + _toWorld set[2,0]; + _mine = createMine [_mineType, _toWorld,[], 0]; + _c = _c + 4; + }; + + _h = 4; + _c = 0; + for [{_z=0}, {_z<9}, {_z=_z+1}] do{ + _array = [((_defense worldToModel (getPos _defense)) select 0) - 16 +_c,((_defense worldToModel (getPos _defense)) select 1) + _h]; + _toWorld = _defense modelToWorld _array; + _toWorld set[2,0]; + _mine = createMine [_mineType, _toWorld,[], 0]; + _c = _c + 4; + }; + deleteVehicle _defense; +}; + +if (_type == 'Concrete_Wall_EP1') then { + _defense addEventHandler ['handleDamage',{getDammage (_this select 0)+(_this select 2)/160}]; +}; + +Call Compile Format ["_defense addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; + +if (_defense EmptyPositions "gunner" > 0 && ((('WFBE_AIDEFENSE' Call GetNamespace) > 0) || _isAIQuery)) then { + Private ["_alives","_check","_closest","_team"]; + _team = if (_side == WEST) then {WF_DefenseWestGrp} else {WF_DefenseEastGrp}; + emptyQueu = emptyQueu + [_defense]; + [_defense, _side] Spawn HandleReloadDefense; + _defense Spawn HandleEmptyVehicle; + if (_manned) then { + _alives = (units _team) Call GetLiveUnits; + if (count _alives < ('WFBE_AIDEFENSE' Call GetNamespace) || _isAIQuery) then { + _buildings = (str _side) Call GetSideStructures; + _closest = ['BARRACKSTYPE',_buildings,_manRange,_side,_defense] Call BuildingInRange; + + //--- Manning Defenses. + if !(isNull _closest) then { + [_defense,_side,_team,_closest] Spawn HandleDefense; + }; + }; + }; +}; + +if (paramArtyUI) then { + Private ["_isAC","_isVeh"]; + _isVeh = getNumber(configFile >> "CfgVehicles" >> typeOf(_defense) >> "ARTY_IsArtyVehicle"); + _isAC = getNumber(configFile >> "CfgVehicles" >> typeOf(_defense) >> "artilleryScanner"); + if (_isVeh == 1 || _isAC == 1) then { + _defense setVehicleInit "[this] ExecVM 'Common\Common_InitArtillery.sqf'"; + processInitCommands; + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_StationaryDefense: Artillery UI has been set over the %1 %2",str _side,_type,diag_frameno,diag_tickTime]; + }; +}; + +/* Are we dealing with an artillery unit ? */ +_isArtillery = [_type,_side] Call IsArtillery; +if (_isArtillery != -1) then {[_defense,_isArtillery,_side] Call EquipArtillery}; + +_defense \ No newline at end of file -- cgit v1.3.1