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 /Server/Functions | |
| download | a2wf_chernarus-a3a91d4f45b22fd487ecbc954ad979be5d03efdd.tar.gz a2wf_chernarus-a3a91d4f45b22fd487ecbc954ad979be5d03efdd.tar.bz2 a2wf_chernarus-a3a91d4f45b22fd487ecbc954ad979be5d03efdd.zip | |
Diffstat (limited to '')
26 files changed, 1300 insertions, 0 deletions
diff --git a/Server/Functions/Server_AlliesBuyUnit.sqf b/Server/Functions/Server_AlliesBuyUnit.sqf new file mode 100644 index 0000000..8a40f0e --- /dev/null +++ b/Server/Functions/Server_AlliesBuyUnit.sqf @@ -0,0 +1,144 @@ +Private ["_building","_built","_config","_crew","_direction","_dir","_distance","_factoryPosition","_factoryType","_id","_index","_isVehicle","_longest","_position","_queu","_queu2","_ret","_side","_sideText","_soldier","_team","_turrets","_type","_unitType","_vehicle","_waitTime"];
+_id = _this select 0;
+_building = _this select 1;
+_unitType = _this select 2;
+_side = _this select 3;
+_team = _this select 4;
+_isVehicle = _this select 5;
+
+_sideText = str _side;
+
+if ((!alive _building)||(isNull _building)) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_AlliesBuyUnit.sqf: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime];};
+
+diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_AlliesBuyUnit: AI Team %1 has purchased a '%2'",_team,_unitType,diag_frameno,diag_tickTime];
+
+_queu = _building getVariable "queu";
+if (isNil "_queu") then {_queu = []};
+_queu = _queu + [_id select 0];
+_building setVariable ["queu",_queu];
+
+_type = typeOf _building;
+if (_type == "CDF_WarfareBBarracks" || _type == "Ins_WarfareBBarracks") then {_type = Call Compile Format ["%1BAR",str _side]};
+if (_type == "CDF_WarfareBLightFactory" || _type == "Ins_WarfareBLightFactory") then {_type = Call Compile Format ["%1LVF",str _side]};
+if (_type == "CDF_WarfareBHeavyFactory" || _type == "Ins_WarfareBHeavyFactory") then {_type = Call Compile Format ["%1HEAVY",str _side]};
+if (_type == "CDF_WarfareBAircraftFactory" || _type == "Ins_WarfareBAircraftFactory") then {_type = Call Compile Format ["%1AIR",str _side]};
+
+_index = (Format ["WFBE_%1STRUCTURENAMES",_sideText] Call GetNamespace) find _type;
+_distance = (Format ["WFBE_%1STRUCTUREDISTANCES",_sideText] Call GetNamespace) select _index;
+_direction = (Format ["WFBE_%1STRUCTUREDIRECTIONS",_sideText] Call GetNamespace) select _index;
+_factoryType = (Format ["WFBE_%1STRUCTURES",_sideText] Call GetNamespace) select _index;
+
+_waitTime = (_unitType Call GetNamespace) select QUERYUNITTIME;
+_position = [getPos _building,_distance,getDir _building + _direction] Call GetPositionFrom;
+_longest = Format ["WFBE_LONGEST%1BUILDTIME",_factoryType] Call GetNamespace;
+
+_ret = 0;
+_queu2 = [0];
+
+if (count _queu > 0) then {
+ _queu2 = _building getVariable "queu";
+};
+
+while {_id select 0 != _queu select 0} do {
+ sleep 4;
+ _ret = _ret + 4;
+ _queu = _building getVariable "queu";
+
+ if (!(alive _building)||(isNull _building)) exitWith {
+ _queu = _building getVariable "queu";
+ _queu = _queu - [_queu select 0];
+ _building setVariable ["queu",_queu];
+ diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit.sqf: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime];
+ };
+
+ if (_queu select 0 == _queu2 select 0) then {
+ if (_ret > _longest) then {
+ if (count _queu > 0) then {
+ _queu = _building getVariable "queu";
+ _queu = _queu - [_queu select 0];
+ _building setVariable ["queu",_queu];
+ };
+ };
+ };
+ if (count _queu != count _queu2) then {
+ _ret = 0;
+ _queu2 = _building getVariable "queu";
+ };
+};
+
+sleep _waitTime;
+
+_queu = _building getVariable "queu";
+_queu = _queu - [_id select 0];
+_building setVariable ["queu",_queu];
+
+if ((!alive _building)||(isNull _building)) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_AlliesBuyUnit.sqf: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime];};
+
+if (_unitType isKindOf "Man") then {
+ _soldier = [_unitType,_team,_position,_side] Call CreateMan;
+ [_sideText,'UnitsCreated',1] Call UpdateStatistics;
+
+ //--- Infantry can use the team vehicles as cargo.
+ _vehicle = [_team,true] Call GetTeamVehicles;
+ {_team addVehicle _x} forEach _vehicle;
+} else {
+ _crew = Format["WFBE_%1ALLIESSOLDIER",_sideText] Call GetNamespace;
+ if (_unitType isKindOf "Tank") then {_crew = Format ["WFBE_%1ALLIESCREW",_sideText] Call GetNamespace};
+ if (_unitType isKindOf "Air") then {_crew = Format ["WFBE_%1ALLIESPILOT",_sideText] Call GetNamespace};
+ _vehicle = [_unitType,_position,_side,true] Call CreateVehi;
+ _factoryPosition = getPos _building;
+ _dir = -((((_position select 1) - (_factoryPosition select 1)) atan2 ((_position select 0) - (_factoryPosition select 0))) - 90);
+ _vehicle setDir _dir;
+ _vehicle setVelocity [0,0,-1];
+ //--- AI Can fly...? (*roll eyes at the harriers*).
+ if (_vehicle isKindOf "Plane") then {
+ _vehicle setPos [_position select 0,_position select 1,1500];
+ _vehicle setVelocity [(sin _direction) * 250,(cos _direction) * 250,0];
+ };
+
+ /* Clear the vehicle */
+ clearWeaponCargo _vehicle;
+ clearMagazineCargo _vehicle;
+
+ emptyQueu = emptyQueu + [_vehicle];
+ _vehicle Spawn HandleEmptyVehicle;
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ [_soldier] orderGetIn true;
+ _soldier assignAsDriver _vehicle;
+ _soldier moveInDriver _vehicle;
+
+ [_sideText,'VehiclesCreated',1] Call UpdateStatistics;
+ _built = 1;
+ if (_isVehicle select 1) then {
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ [_soldier] orderGetIn true;
+ _soldier assignAsGunner _vehicle;
+ _soldier moveInGunner _vehicle;
+ _built = _built + 1;
+ };
+ if (_isVehicle select 2) then {
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ [_soldier] orderGetIn true;
+ _soldier assignAsCommander _vehicle;
+ _soldier moveInCommander _vehicle;
+ _built = _built + 1;
+ };
+ if (_isVehicle select 3) then {
+ Private ["_get","_turrets"];
+ _get = _unitType Call GetNamespace;
+ _turrets = _get select QUERYUNITTURRETS;
+
+ {
+ if (isNull (_vehicle turretUnit _x)) then {
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ _soldier moveInTurret [_vehicle, _x];
+ _built = _built + 1;
+ };
+ } forEach _turrets;
+ };
+ [_sideText,'UnitsCreated',_built] Call UpdateStatistics;
+};
\ No newline at end of file diff --git a/Server/Functions/Server_BuildingDamaged.sqf b/Server/Functions/Server_BuildingDamaged.sqf new file mode 100644 index 0000000..034a8ef --- /dev/null +++ b/Server/Functions/Server_BuildingDamaged.sqf @@ -0,0 +1,18 @@ +Private["_currentDammages","_damage","_damagedBy","_side","_structure","_timeAttacked"];
+
+_structure = _this Select 0;
+_damagedBy = _this Select 1;
+_damage = _this Select 2;
+_currentDammages = getDammage _structure;
+
+_side = east;
+if ((typeOf _structure) in ('WFBE_WESTSTRUCTURENAMES' Call GetNamespace)) then {_side = west};
+
+_timeAttacked = Format["WFBE_%1_TimeUnderAttack",str _side] Call GetNamespace;
+
+if (_side != Side _damagedBy) then {
+ if (time - _timeAttacked > 30 && _damage > 0.05 && ((_currentDammages + _damage) < 1)) then {
+ [Format["WFBE_%1_TimeUnderAttack",str _side],time,true] Call SetNamespace;
+ ["IsUnderAttack",TypeOf _structure ,_side] Spawn SideMessage;
+ };
+};
\ No newline at end of file diff --git a/Server/Functions/Server_BuildingHandleDamages.sqf b/Server/Functions/Server_BuildingHandleDamages.sqf new file mode 100644 index 0000000..f5b5913 --- /dev/null +++ b/Server/Functions/Server_BuildingHandleDamages.sqf @@ -0,0 +1,22 @@ +Private ['_building','_dammages','_origin','_side','_sideBuilding','_side'];
+
+_building = _this select 0;
+_dammages = _this select 1;
+_origin = _this select 2;
+_sideBuilding = _this select 3;
+
+_side = civilian;
+if (side _origin == sideEnemy) then {
+ if (_origin isKindOf westSoldierBaseClass) then {_side = west};
+ if (_origin isKindOf eastSoldierBaseClass) then {_side = east};
+} else {
+ _side = side _origin;
+};
+
+if (_sideBuilding == _side) then {
+ _dammages = false;
+} else {
+ _dammages = [_building, _dammages] Call HandleBuildingDamage;
+};
+
+_dammages
\ No newline at end of file diff --git a/Server/Functions/Server_BuildingKilled.sqf b/Server/Functions/Server_BuildingKilled.sqf new file mode 100644 index 0000000..77b3f2c --- /dev/null +++ b/Server/Functions/Server_BuildingKilled.sqf @@ -0,0 +1,72 @@ +Private ['_current','_find','_killer','_structure','_structures','_side','_tked','_type','_uid'];
+_structure = _this select 0;
+_killer = _this select 1;
+_side = _this select 2;
+_type = _this select 3;
+
+diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuildingKilled: A %1 %2 Structure has been destroyed (By: %5)",str _side,_type,diag_frameno,diag_tickTime,_killer];
+
+//--- Building Teamkill.
+if ((side _killer == _side)&&(isPlayer(_killer))) then {
+ _uid = getPlayerUID _killer;
+ if !(paramShowUID) then {_uid = "xxxxxxx"};
+ _tked = [_type, 'displayName'] Call GetConfigInfo;
+ WFBE_LocalizeMessage = [_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]];
+ publicVariable 'WFBE_LocalizeMessage';
+ if (isHostedServer) then {[_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]] Spawn HandlePVF};
+ if (mysql) then {
+ WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_Update?%1?%2?teamkillstr?%3",_uid,name _killer,worldName]]];
+ };
+
+ diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuildingKilled: Player %1 (%2) has teamkilled a friendly building.",name _killer,_uid,diag_frameno,diag_tickTime];
+};
+
+if (mysql) then {
+ if ((side _killer != _side)&&(isPlayer(_killer))) then {
+ WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?3?%5",_type,getPlayerUID _killer,name _killer,"killed",worldName]]];
+ };
+};
+
+//--- Decrement building limit.
+_find = (Format ['WFBE_%1STRUCTURENAMES',_side] Call GetNamespace) find _type;
+if (_find != -1) then {
+ _current = Call Compile Format ['%1BuildingsCurrent',_side];
+ _current set [_find - 1, (_current select (_find-1)) - 1];
+ Call Compile Format ['%1BuildingsCurrent = _current',_side];
+ publicVariable Format ['%1BuildingsCurrent',_side];
+};
+
+Call Compile Format ["%1BaseStructures = %1BaseStructures - [_structure] - [objNull]; publicVariable '%1BaseStructures';",str _side];
+
+["Destroyed",_type,_side] Spawn SideMessage;
+
+//--- Can be fixed with workers.
+if (paramUseWorkers) then {
+ Private ["_nearLogic","_position","_sold"];
+
+ _sold = _structure getVariable "sold";
+
+ if (isNil '_sold') then {
+ //--- Grab the logic.
+ _position = getPos _structure;
+ _nearLogic = _position nearEntities [["LocationLogicStart"],15];
+ if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull};
+
+ if (isNull _nearLogic) exitWith {};
+
+ //--- Completed at 25% on destruction, dropping until it reach 0 (delete).
+ _nearLogic setVariable ["WFBE_B_Completion", 25];
+ //--- The ratio gets lower after each destruction.
+ _nearLogic setVariable ["WFBE_B_CompletionRatio", (_nearLogic getVariable "WFBE_B_CompletionRatio")*0.8];
+ //--- Can be repaired.
+ _nearLogic setVariable ["WFBE_B_Repair", true];
+
+ [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) + [_nearLogic],true] Call SetNamespace;
+
+ [_nearLogic, typeOf _structure, _side, _find - 1] Spawn HandleBuildingRepair;
+ };
+};
+
+sleep 10;
+
+deleteVehicle _structure;
diff --git a/Server/Functions/Server_BuyUnit.sqf b/Server/Functions/Server_BuyUnit.sqf new file mode 100644 index 0000000..e028685 --- /dev/null +++ b/Server/Functions/Server_BuyUnit.sqf @@ -0,0 +1,163 @@ +Private ["_building","_built","_config","_crew","_direction","_dir","_distance","_factoryType","_factoryPosition","_gbq","_id","_index","_isVehicle","_longest","_position","_queu","_queu2","_ret","_side","_sideText","_soldier","_team","_turrets","_type","_unitType","_vehicle","_waitTime"];
+_id = _this select 0;
+_building = _this select 1;
+_unitType = _this select 2;
+_side = _this select 3;
+_team = _this select 4;
+_isVehicle = _this select 5;
+
+_sideText = str _side;
+
+if (!(alive _building)||(isPlayer (leader _team))) exitWith {
+ _gbq = (_team getVariable "queue") - _id;
+ _team setVariable ["queue",_gbq];
+ if !(alive _building) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime]};
+ if (isPlayer (leader _team)) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuyUnit: Canceled unit '%1', Player %2 has replaced the AI Team leader.",_unitType, name (leader _team),diag_frameno,diag_tickTime]};
+};
+
+diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_BuyUnit: %1 Team '%2' has purchased a %3",_side,_team,_unitType,diag_frameno,diag_tickTime];
+
+_queu = _building getVariable "queu";
+if (isNil "_queu") then {_queu = []};
+_queu = _queu + [_id select 0];
+_building setVariable ["queu",_queu,true];
+
+_type = typeOf _building;
+_index = (Format ["WFBE_%1STRUCTURENAMES",_sideText] Call GetNamespace) find _type;
+_distance = (Format ["WFBE_%1STRUCTUREDISTANCES",_sideText] Call GetNamespace) select _index;
+_direction = (Format ["WFBE_%1STRUCTUREDIRECTIONS",_sideText] Call GetNamespace) select _index;
+_factoryType = (Format ["WFBE_%1STRUCTURES",_sideText] Call GetNamespace) select _index;
+_waitTime = (_unitType Call GetNamespace) select QUERYUNITTIME;
+_position = [getPos _building,_distance,getDir _building + _direction] Call GetPositionFrom;
+_longest = Format ["WFBE_LONGEST%1BUILDTIME",_factoryType] Call GetNamespace;
+
+_ret = 0;
+_queu2 = [0];
+
+if (count _queu > 0) then {
+ _queu2 = _building getVariable "queu";
+};
+
+while {_id select 0 != _queu select 0} do {
+ sleep 4;
+ _ret = _ret + 4;
+ _queu = _building getVariable "queu";
+
+ if (!(alive _building)||(isNull _building)||(isPlayer (leader _team))) exitWith {
+ _gbq = (_team getVariable "queue") - _id;
+ _team setVariable ["queue",_gbq];
+ _queu = _building getVariable "queu";
+ _queu = _queu - [_queu select 0];
+ _building setVariable ["queu",_queu,true];
+ if !(alive _building) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime]};
+ if (isPlayer (leader _team)) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuyUnit: Canceled unit '%1', Player %2 has replaced the AI Team leader.",_unitType, name (leader _team),diag_frameno,diag_tickTime]};
+ };
+
+ if (_queu select 0 == _queu2 select 0) then {
+ if (_ret > _longest) then {
+ if (count _queu > 0) then {
+ _queu = _building getVariable "queu";
+ _queu = _queu - [_queu select 0];
+ _building setVariable ["queu",_queu,true];
+ };
+ };
+ };
+ if (count _queu != count _queu2) then {
+ _ret = 0;
+ _queu2 = _building getVariable "queu";
+ };
+};
+
+sleep _waitTime;
+
+_queu = _building getVariable "queu";
+_queu = _queu - [_id select 0];
+_building setVariable ["queu",_queu,true];
+
+if (!(alive _building)||(isPlayer (leader _team))) exitWith {
+ _gbq = (_team getVariable "queue") - _id;
+ _team setVariable ["queue",_gbq];
+ if !(alive _building) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime]};
+ if (isPlayer (leader _team)) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuyUnit: Canceled unit '%1', Player %2 has replaced the AI Team leader.",_unitType, name (leader _team),diag_frameno,diag_tickTime]};
+};
+
+if (_unitType isKindOf "Man") then {
+ _soldier = [_unitType,_team,_position,_side] Call CreateMan;
+ [_sideText,'UnitsCreated',1] Call UpdateStatistics;
+} else {
+ _crew = Format ["WFBE_%1SOLDIER",_sideText] Call GetNamespace;
+ if (_unitType isKindOf "Tank") then {_crew = Format ["WFBE_%1CREW",_sideText] Call GetNamespace};
+ if (_unitType isKindOf "Air") then {_crew = Format ["WFBE_%1PILOT",_sideText] Call GetNamespace};
+ _vehicle = [_unitType,_position,_side,true] Call CreateVehi;
+ _factoryPosition = getPos _building;
+ _dir = -((((_position select 1) - (_factoryPosition select 1)) atan2 ((_position select 0) - (_factoryPosition select 0))) - 90);
+ _vehicle setDir _dir;
+ _vehicle setVelocity [0,0,-1];
+ //--- AI Can fly.
+ if (_vehicle isKindOf "Air") then {
+ _vehicle flyInHeight 120;
+ if (_vehicle isKindOf "Plane") then {
+ _vehicle setPos [_position select 0,_position select 1,1500];
+ _vehicle setVelocity [sin _dir * 250,cos _dir * 250,0];
+ };
+ };
+
+ emptyQueu = emptyQueu + [_vehicle];
+ _vehicle Spawn HandleEmptyVehicle;
+ if (_vehicle distance (leader _team) < 200) then {(units _team) allowGetIn true;_team addVehicle _vehicle};
+
+ /* Clear the vehicle */
+ clearWeaponCargo _vehicle;
+ clearMagazineCargo _vehicle;
+
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ [_soldier] orderGetIn true;
+ if (_unitType in ('WFBE_BALANCEDUNITS' Call GetNamespace) && paramBalancing) then {[_vehicle] Spawn BalanceInit};
+ _soldier assignAsDriver _vehicle;
+ _soldier moveInDriver _vehicle;
+ [_sideText,'VehiclesCreated',1] Call UpdateStatistics;
+ _built = 1;
+ if (_isVehicle select 1) then {
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ [_soldier] orderGetIn true;
+ _soldier assignAsGunner _vehicle;
+ _soldier moveInGunner _vehicle;
+ _built = _built + 1;
+ };
+ if (_isVehicle select 2) then {
+ if (vehicle leader _team == leader _team && leader _team distance _vehicle < 200 && alive leader _team) then {
+ [leader _team] allowGetIn true;
+ [leader _team] orderGetIn true;
+ (leader _team) assignAsCommander _vehicle;
+ (leader _team) moveInCommander _vehicle;
+ } else {
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ [_soldier] orderGetIn true;
+ _soldier assignAsCommander _vehicle;
+ _soldier moveInCommander _vehicle;
+ };
+ _built = _built + 1;
+ };
+
+ if (_isVehicle select 3) then {
+ Private ["_get","_turrets"];
+ _get = _unitType Call GetNamespace;
+ _turrets = _get select QUERYUNITTURRETS;
+
+ {
+ if (isNull (_vehicle turretUnit _x)) then {
+ _soldier = [_crew,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ _soldier moveInTurret [_vehicle, _x];
+ _built = _built + 1;
+ };
+ } forEach _turrets;
+ };
+ [_sideText,'UnitsCreated',_built] Call UpdateStatistics;
+};
+
+_gbq = (_team getVariable "queue") - _id;
+_team setVariable ["queue",_gbq];
\ No newline at end of file diff --git a/Server/Functions/Server_CanUpdateTeam.sqf b/Server/Functions/Server_CanUpdateTeam.sqf new file mode 100644 index 0000000..e4863b7 --- /dev/null +++ b/Server/Functions/Server_CanUpdateTeam.sqf @@ -0,0 +1,19 @@ +/*
+ Author: Benny
+ Name: Server_CanUpdateTeam.sqf
+ Parameters:
+ 0 - Group
+ Description:
+ This function detect whether a human commander is in command or not and if a team is in the 'main' teams.
+*/
+
+Private ['_canUpdate','_commander','_team'];
+_team = _this;
+
+_canUpdate = true;
+if (((leader _team) Call GetClientID) != 0) then {
+ _commander = (side _team) Call GetCommanderTeam;
+ if !(isNull _commander) then {_canUpdate = false};
+};
+
+_canUpdate
\ No newline at end of file diff --git a/Server/Functions/Server_ChangeAICommanderFunds.sqf b/Server/Functions/Server_ChangeAICommanderFunds.sqf new file mode 100644 index 0000000..447fd09 --- /dev/null +++ b/Server/Functions/Server_ChangeAICommanderFunds.sqf @@ -0,0 +1,7 @@ +Private ["_amount","_funds","_side"];
+_side = _this select 0;
+_amount = _this select 1;
+
+_funds = (_side) Call GetAICommanderFunds;
+
+[Format ["WFBE_%1_AICommanderFunds",_side], _funds + _amount, true] Call SetNamespace;
\ No newline at end of file diff --git a/Server/Functions/Server_CreateDefenseTemplate.sqf b/Server/Functions/Server_CreateDefenseTemplate.sqf new file mode 100644 index 0000000..ae00769 --- /dev/null +++ b/Server/Functions/Server_CreateDefenseTemplate.sqf @@ -0,0 +1,36 @@ +Private ["_created","_current","_dir","_i","_object","_origin","_relDir","_relPos","_skip","_template","_toplace","_toWorld"];
+_origin = _this select 0;
+_template = _this select 1;
+_existingTemplate = if (count _this > 2) then {_this select 2} else {[]};
+
+_dir = getDir _origin;
+_created = [];
+_toplace = objNull;
+
+for '_i' from 0 to count(_template)-1 do {
+ _current = _template select _i;
+ _object = _current select 0;
+ _relPos = _current select 1;
+ _relDir = _current select 2;
+
+ _skip = false;
+ if (_i < count(_existingTemplate)) then {
+ if (alive(_existingTemplate select _i)) then {_skip = true};
+ };
+
+ if !(_skip) then {
+ _toplace = _object createVehicle [0,0,0];
+
+ _toWorld = _origin modelToWorld _relPos;
+ _toWorld set [2,0];
+
+ _toplace setDir (_dir - _relDir);
+ _toplace setPos _toWorld;
+ } else {
+ _toplace = _existingTemplate select _i;
+ };
+
+ _created = _created + [_toplace];
+};
+
+_created
\ No newline at end of file diff --git a/Server/Functions/Server_CreateTeam.sqf b/Server/Functions/Server_CreateTeam.sqf new file mode 100644 index 0000000..83f9151 --- /dev/null +++ b/Server/Functions/Server_CreateTeam.sqf @@ -0,0 +1,47 @@ +Private ['_canCreate','_commander','_crews','_ctype','_driver','_firstDone','_gunner','_list','_lockVehicles','_position','_probability','_side','_team','_type','_unit','_units','_vehicle','_vehicles'];
+
+_list = _this select 0;
+_position = _this select 1;
+_side = _this select 2;
+_lockVehicles = _this select 3;
+_team = _this select 4;
+_probability = if (count _this > 5) then {_this select 5} else {-1};
+_units = [];
+_vehicles = [];
+_crews = [];
+_firstDone = false;
+
+//--- Create a group if none are given as a parameter.
+if (isNull _team) then {_team = createGroup _side};
+
+_ctype = switch (_side) do {case West: {'WEST'}; case East: {'EAST'}; case Resistance: {'GUER'}; case Civilian: {'CIV'}};
+
+//--- Create.
+{
+ _canCreate = true;
+ if (_probability != -1) then {
+ if (random 100 > _probability && _firstDone) then {_canCreate = false};
+ _firstDone = true;
+ };
+
+ if (_canCreate) then {
+ if (_x isKindOf 'Man') then {
+ _unit = [_x,_team,_position,_side] Call CreateMan;
+ _units = _units + [_unit];
+ } else {
+ _vehicle = [_x,_position,_side,_lockVehicles] Call CreateVehi;
+ _type = if (_vehicle isKindOf 'Man') then {Format ['WFBE_%1SOLDIER',_ctype] Call GetNamespace} else {if (_vehicle isKindOf 'Air') then {Format ['WFBE_%1PILOT',_ctype] Call GetNamespace} else {Format ['WFBE_%1CREW',_ctype] Call GetNamespace}};
+ if (_vehicle emptyPositions 'driver' > 0) then {_driver = [_type,_team,_position,_side] Call CreateMan;_driver moveInDriver _vehicle;_crews = _crews + [_driver]};
+ if (_vehicle emptyPositions 'gunner' > 0) then {_gunner = [_type,_team,_position,_side] Call CreateMan;_gunner moveInGunner _vehicle;_crews = _crews + [_gunner]};
+ if (_vehicle emptyPositions 'commander' > 0) then {_commander = [_type,_team,_position,_side] Call CreateMan;_commander moveInCommander _vehicle;_crews = _crews + [_commander]};
+ _vehicles = _vehicles + [_vehicle];
+ };
+ };
+} forEach _list;
+
+//--- Add vehicles.
+{
+ _team addVehicle _x;
+} forEach _vehicles;
+
+[_units,_vehicles,_team,_crews]
\ No newline at end of file diff --git a/Server/Functions/Server_GetAICommanderFunds.sqf b/Server/Functions/Server_GetAICommanderFunds.sqf new file mode 100644 index 0000000..841814d --- /dev/null +++ b/Server/Functions/Server_GetAICommanderFunds.sqf @@ -0,0 +1 @@ +Format ["WFBE_%1_AICommanderFunds",_this] Call GetNamespace
\ No newline at end of file diff --git a/Server/Functions/Server_HQKilled.sqf b/Server/Functions/Server_HQKilled.sqf new file mode 100644 index 0000000..b24be73 --- /dev/null +++ b/Server/Functions/Server_HQKilled.sqf @@ -0,0 +1,46 @@ +Private ["_deployed","_dir","_hq","_HQName","_killer","_kname","_kuid","_MHQ","_pos","_side","_tked","_type","_uid"];
+_hq = _this select 0;
+_killer = _this select 1;
+_side = _this select 2;
+_type = _this select 3;
+
+_pos = getPos _hq;
+_dir = getDir _hq;
+_kuid = if (isPlayer _killer) then {getPlayerUID _killer} else {'0'};
+_kname = name _killer;
+
+_deployed = (str _side) Call GetSideHQDeployed;
+
+diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_HQKilled: The %1 MHQ has been destroyed",str _side,diag_frameno,diag_tickTime];
+
+//--- Building Teamkill.
+if ((side _killer == _side)&&(isPlayer(_killer))) then {
+ _uid = if !(paramShowUID) then {_uid = 'xxxxxxx'} else {_kuid};
+ _tked = [_type, 'displayName'] Call GetConfigInfo;
+ WFBE_LocalizeMessage = [_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]];
+ publicVariable 'WFBE_LocalizeMessage';
+ if (isHostedServer) then {[_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]] Spawn HandlePVF};
+
+ diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_HQKilled: Player %1 (%2) has teamkilled the MHQ.",name _killer,_uid,diag_frameno,diag_tickTime];
+};
+
+sleep random(2);
+if (_deployed) then {
+ _HQName = Format["WFBE_%1MHQNAME",_side] Call GetNamespace;
+ _MHQ = _HQName createVehicle _pos;
+ _MHQ setDir _dir;
+ _MHQ setDammage 1;
+
+ Call Compile Format ["%1MHQ = _MHQ; %1MHQDeployed = false; publicVariable '%1MHQ'; publicVariable '%1MHQDeployed';",str _side];
+};
+
+if (mysql) then {
+ if ((side _killer != _side)&&(isPlayer(_killer))) then {
+ WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_Update?%1?%2?killedhq?%3",getPlayerUID _killer,name _killer,worldName]]];
+ WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?%5?%6",_type,_kuid,_kname,"killed",4,worldName]]];
+ };
+};
+
+if (_type == WESTHQ) then {_type = 'WFBE_WESTMHQNAME' Call GetNamespace};
+if (_type == EASTHQ) then {_type = 'WFBE_EASTMHQNAME' Call GetNamespace};
+['Destroyed',_type,_side] Spawn SideMessage;
diff --git a/Server/Functions/Server_HandleBuildingDamage.sqf b/Server/Functions/Server_HandleBuildingDamage.sqf new file mode 100644 index 0000000..31da5c2 --- /dev/null +++ b/Server/Functions/Server_HandleBuildingDamage.sqf @@ -0,0 +1,3 @@ +Private ["_difference"];
+_difference = ((_this select 1) - (getDammage (_this select 0)))/('WFBE_BUILDINGDAMAGEREDUCTION' Call GetNamespace);
+((getDammage (_this select 0))+_difference)
\ No newline at end of file diff --git a/Server/Functions/Server_HandleBuildingRepair.sqf b/Server/Functions/Server_HandleBuildingRepair.sqf new file mode 100644 index 0000000..04e082c --- /dev/null +++ b/Server/Functions/Server_HandleBuildingRepair.sqf @@ -0,0 +1,104 @@ +Private ["_bindex","_degradation","_direction","_etat","_group","_lastCompletionCheck","_logic","_position","_ruins","_ruinsType","_side","_type"];
+
+_logic = _this select 0;
+_type = _this select 1;
+_side = _this select 2;
+_bindex = _this select 3;
+
+_lastCompletionCheck = 0;
+_degradation = 'WFBE_WORKERS_DEGRADATION' Call GetNamespace;
+
+_ruinsType = "WFBE_WORKERS_RUINS" Call GetNamespace;
+_position = _logic getVariable "WFBE_B_Position";
+_direction = _logic getVariable "WFBE_B_Direction";
+
+//--- Create ruins wherever the building get destroyed.
+_ruins = _ruinsType createVehicle _position;
+_ruins setDir _direction;
+_ruins setPos _position;
+
+while {true} do {
+ _etat = _logic getVariable 'WFBE_B_Completion';
+
+ //--- Completed.
+ if (_etat >= 100) exitWith {
+ Private ["_buildingsCosts","_buildingsNames","_buildingsType","_current","_index","_limit","_site"];
+ _buildingsType = Format["WFBE_%1STRUCTURES",str _side] Call GetNamespace;
+ _buildingsType = _buildingsType - [_buildingsType select 0];
+ _buildingsNames = Format["WFBE_%1STRUCTURENAMES",str _side] Call GetNamespace;
+ _buildingsNames = _buildingsNames - [_buildingsNames select 0];
+ _buildingsCosts = Format["WFBE_%1STRUCTURECOSTS",str _side] Call GetNamespace;
+
+ //--- Place if limits allows us to do so.
+ _index = _buildingsNames find _type;
+
+ if (_index != -1) then {
+ _current = Call Compile Format ['%1BuildingsCurrent',str _side];
+ _limit = (Format['WFBE_BUILDINGMAX%1',(_buildingsType select _index)]) Call GetNamespace;
+ if (isNil '_limit') then {_limit = 4}; //--- Default.
+
+ //--- We can build, the limist hasn't been reached yet.
+ if ((_current select _index) < _limit) then {
+ _site = _type createVehicle _position;
+ _site setDir _direction;
+ _site setPos _position;
+
+ ["Constructed",_type,_side] Spawn SideMessage;
+
+ //--- Site is created, we add the rest.
+ if !(isNull _site) then {
+ _current set [_bindex, (_current select _bindex) + 1];
+ Call Compile Format ['%1BuildingsCurrent = _current',_side];
+ publicVariable Format ['%1BuildingsCurrent',_side];
+
+ 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',{getDammage (_this select 0)+((_this select 2)/('WFBE_BUILDINGDAMAGEREDUCTION' Call GetNamespace))}];
+ };
+ Call Compile Format ["_site AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn BuildingKilled}];",_side,_type];
+
+ if !(paramMoneyOnly) then {
+ [_side, -round((_buildingsCosts select _index)/2)] Call ChangeSideSupply;
+ };
+
+ diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_HandleBuildingRepair: A %1 %2 has been repaired",str _side,_type,diag_frameno,diag_tickTime];
+ };
+
+ _logic setVariable ["WFBE_B_Repair",false];
+ };
+ };
+
+ [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_logic],true] Call SetNamespace;
+ };
+
+ sleep 5;
+
+ //--- Has the etat changed?
+ if ((_logic getVariable 'WFBE_B_Completion') == _etat) then {_lastCompletionCheck = _lastCompletionCheck + 5} else {_lastCompletionCheck = 0};
+
+ //--- Degradation if nothing happened.
+ if (_lastCompletionCheck > 30) then {
+ _etat = (_logic getVariable "WFBE_B_Completion") - _degradation;
+ if (_etat < 0) then {_etat = 0};
+ _logic setVariable ["WFBE_B_Completion",_etat];
+ _lastCompletionCheck = 0;
+ };
+
+ //--- If the etat reach 0, the building is lost.
+ if (_etat <= 0) exitWith {
+ [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_logic],true] Call SetNamespace;
+
+ _group = group _logic;
+ deleteVehicle _logic;
+ deleteGroup _group;
+ };
+};
+
+deleteVehicle _ruins;
\ No newline at end of file diff --git a/Server/Functions/Server_HandleDefense.sqf b/Server/Functions/Server_HandleDefense.sqf new file mode 100644 index 0000000..8182271 --- /dev/null +++ b/Server/Functions/Server_HandleDefense.sqf @@ -0,0 +1,40 @@ +Private ["_buildings","_closest","_defense","_direction","_distance","_index","_position","_side","_soldier","_team","_type","_unit"];
+_defense = _this select 0;
+_side = _this select 1;
+_team = _this select 2;
+_closest = _this select 3;
+
+while {alive _defense} do {
+ if (isNull(gunner _defense) || !alive gunner _defense) then {
+
+ sleep 7;
+
+ if (alive _closest && !(isNull _closest )) then {
+ _type = typeOf _closest;
+ _index = (Format["WFBE_%1STRUCTURENAMES",str _side] Call GetNamespace) find _type;
+ _distance = (Format["WFBE_%1STRUCTUREDISTANCES",str _side] Call GetNamespace) select _index;
+ _direction = (Format["WFBE_%1STRUCTUREDIRECTIONS",str _side] Call GetNamespace) select _index;
+ _position = [getPos _closest,_distance,getDir (_closest) + _direction] Call GetPositionFrom;
+
+ _type = Format ["WFBE_%1SOLDIER",str _side] Call GetNamespace;
+ _soldier = [_type,_team,_position,_side] Call CreateMan;
+ [_soldier] allowGetIn true;
+ _soldier assignAsGunner _defense;
+ [_soldier] orderGetIn true;
+
+ [str _side,'UnitsCreated',1] Call UpdateStatistics;
+
+ diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_HandleDefense: A Soldier has been dispatched to the %1 defense %2",str _side,_type,diag_frameno,diag_tickTime];
+
+ //--- Calculate the average time in function of the distance and the speed.
+ sleep ((((_soldier distance _defense)/(14*1000))*3600)+20);
+
+ if ((vehicle _soldier != _defense)&& alive _soldier &&(!isNull _soldier)) then {
+ if ((_defense EmptyPositions "gunner" > 0) && alive _defense && (!isNull _defense)) then {_soldier MoveInGunner _defense} else {deleteVehicle _soldier};
+ };
+ } else {
+ diag_log Format["[WFBE (INFORMATION)][frameno:%1 | ticktime:%2] Server_HandleDefense.sqf: Canceled auto manning, the barracks is destroyed.",diag_frameno,diag_tickTime];
+ };
+ };
+ sleep 420;
+};
\ No newline at end of file diff --git a/Server/Functions/Server_HandleEmptyVehicle.sqf b/Server/Functions/Server_HandleEmptyVehicle.sqf new file mode 100644 index 0000000..29307a8 --- /dev/null +++ b/Server/Functions/Server_HandleEmptyVehicle.sqf @@ -0,0 +1,36 @@ +Private ['_abtimer','_exit','_skip','_timer','_trash','_vehicle'];
+
+_vehicle = _this;
+
+_exit = false;
+_timer = 0;
+_abtimer = ('WFBE_ABANDONVEHICLETIMER' Call GetNamespace);
+
+while {!_exit} do {
+ sleep 20;
+ _skip = false;
+ if (!(alive _vehicle) && !(isNull _vehicle)) then {
+ _skip = true;
+ _exit = true;
+ if !(_vehicle in trashQueu) then {
+ trashQueu = trashQueu + [_vehicle];
+ _vehicle Spawn TrashObject;
+ };
+ };
+ if (!(isNull _vehicle) && !_skip) then {
+ if (({alive _x} count (crew _vehicle)) > 0) then {_timer = 0};
+ if (_timer > _abtimer) then {
+ _exit = true;
+ if (someAmmo _vehicle) then {_vehicle setVehicleAmmo 0};
+ _vehicle setDammage 1;
+ sleep 2;
+ if !(_vehicle in trashQueu) then {
+ trashQueu = trashQueu + [_vehicle];
+ (_vehicle) Spawn TrashObject;
+ };
+ };
+ _timer = _timer + 20;
+ } else {_exit = true};
+};
+
+emptyQueu = emptyQueu - [_vehicle];
\ No newline at end of file diff --git a/Server/Functions/Server_HandleReloadDefense.sqf b/Server/Functions/Server_HandleReloadDefense.sqf new file mode 100644 index 0000000..61eeee2 --- /dev/null +++ b/Server/Functions/Server_HandleReloadDefense.sqf @@ -0,0 +1,71 @@ +private ["_defense", "_side", "_sideID", "_turret", "_closestTown", "_reload", "_buildings", "_mhq", "_magazine"];
+
+_defense = _this select 0;
+_side = _this select 1;
+_sideID = _side Call GetSideID;
+
+if(!isArray(configFile >> "CfgVehicles" >> (typeOf _defense) >> "Turrets" >> "MainTurret" >> "weapons")) exitWith { };
+
+_turret = getArray(configFile >> "CfgVehicles" >> (typeOf _defense) >> "Turrets" >> "MainTurret" >> "weapons") select 0;
+_closestTown = [_defense] Call GetClosestLocation;
+
+if(isNull _closestTown || _closestTown distance _defense > 400) then
+{
+ _closestTown = ObjNull;
+};
+
+// 0: no auto reloading
+if(paramDefenseReloading == 0) exitWith { };
+
+while { alive _defense } do
+{
+ sleep 10;
+ if((_defense ammo _turret) == 0) then
+ {
+ _reload = false;
+
+ // 3: Reload everywhere
+ if(paramDefenseReloading == 3) then
+ {
+ _reload = true;
+ };
+
+ // 2: Reload near towns or base/HQ
+ if(!_reload && paramDefenseReloading == 2) then
+ {
+ _reload = false;
+ if(!isNull _closestTown && (_closestTown getVariable "sideID") == _sideID) then
+ {
+ _reload = true;
+ };
+ };
+
+ // 1: Reload near base/HQ
+ if(!_reload && (paramDefenseReloading == 1 || paramDefenseReloading == 2)) then
+ {
+ _buildings = (str _side) Call GetSideStructures;
+ _mhq = call compile format ["%1MHQ", str _side];
+
+ if(!isNil "_mhq") then
+ {
+ _buildings = _buildings + [ _mhq ];
+ };
+
+ {
+ if(_defense distance _x < 200) exitWith
+ {
+ _reload = true;
+ }
+ } forEach(_buildings);
+ };
+
+ if(_reload) then
+ {
+ _magazine = (_defense magazinesTurret [0]) select 0;
+ if(!isNil "_magazine") then
+ {
+ ["ACE_sys_crewserved_remadd", [_defense, _magazine, 1]] call CBA_fnc_globalEvent;
+ };
+ };
+ };
+};
\ No newline at end of file diff --git a/Server/Functions/Server_HandleSPVF.sqf b/Server/Functions/Server_HandleSPVF.sqf new file mode 100644 index 0000000..3b955bf --- /dev/null +++ b/Server/Functions/Server_HandleSPVF.sqf @@ -0,0 +1,16 @@ +/*
+ description:
+ - New network system handler.
+ note:
+ - addPublicVariableEventHandler is triggered everywhere BUT on the caller.
+ usage:
+ - [server PVF to run, parameters]
+*/
+
+Private ["_parameters","_publicVar","_script"];
+_publicVar = _this;
+
+_script = _publicVar select 0;
+_parameters = if (count _publicVar > 1) then {_publicVar select 1} else {[]};
+
+_parameters Spawn (Call Compile _script);
\ No newline at end of file diff --git a/Server/Functions/Server_HandleSpecial.sqf b/Server/Functions/Server_HandleSpecial.sqf new file mode 100644 index 0000000..fc3fec8 --- /dev/null +++ b/Server/Functions/Server_HandleSpecial.sqf @@ -0,0 +1,48 @@ +Private['_args','_base','_dropPosX','_dropPosY','_dropPosZ','_droppos1','_droppos2','_playerTeam','_side','_st','_target'];
+
+_args = _this;
+_side = _args select 1;
+
+switch (_args select 0) do {
+ case "Paratroops": {
+ _args spawn KAT_Paratroopers;
+ };
+
+ case "ParaVehi": {
+ _args spawn KAT_ParaVehicles;
+ };
+
+ case "ParaAmmo": {
+ _args spawn KAT_ParaAmmo;
+ };
+
+ case "RespawnST": {
+ _st = Format ["WFBE_%1_AISupplyTrucks",Str _side] Call GetNamespace;
+ {if (!isNull (driver _x)) then {driver _x setDammage 1};_x setDammage 1} forEach _st;
+ diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_HandleSpecial: The %1 supply trucks have been respawned.",str _side,diag_frameno,diag_tickTime];
+ };
+
+ case "uav": {
+ _args spawn KAT_UAV;
+ };
+
+ case "upgrade": {["NewIntelAvailable","",_side,""] Spawn SideMessage};
+
+ case "ICBM": {
+ _base = (_args select 2);
+ _target = (_args select 3);
+ _playerTeam = (_args select 4);
+ diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_HandleSpecial: The %1 %2 Team (Leader: %3) has called an ICBM Nuke.",str _side,_playerTeam,name (leader _playerTeam),diag_frameno,diag_tickTime];
+ if (isNull _target || !alive _target) exitWith {};
+ _dropPosX = getPos _base select 0;
+ _dropPosY = getPos _base select 1;
+ _dropPosZ = getPos _base select 2;
+ _droppos1 = [_dropPosX + 4, _dropPosY + 4, _dropPosZ];
+ _droppos2 = [_dropPosX + 8, _dropPosY + 8, _dropPosZ];
+ waitUntil {!alive _target || isNull _target};
+ det1 = "BO_GBU12_LGB" createVehicle [(getpos _target select 0),(getpos _target select 1), 0];
+ det2 = createVehicle ["BO_GBU12_LGB",_droppos1,[], 0, "None"];
+ det3 = createVehicle ["BO_GBU12_LGB",_droppos2,[], 0, "None"];
+ [_base] Spawn NukeDammage;
+ };
+};
\ No newline at end of file diff --git a/Server/Functions/Server_MHQRepair.sqf b/Server/Functions/Server_MHQRepair.sqf new file mode 100644 index 0000000..ae8b533 --- /dev/null +++ b/Server/Functions/Server_MHQRepair.sqf @@ -0,0 +1,38 @@ +Private ["_commanderTeam","_direction","_hq","_HQName","_MHQ","_position","_side","_sideText","_text"];
+_side = _this select 0;
+_sideText = str _side;
+
+_hq = (_sideText) Call GetSideHQ;
+_position = getPos _hq;
+_direction = getDir _hq;
+
+_commanderTeam = (_side) Call GetCommanderTeam;
+if !(isNull _commanderTeam) then {
+ WFBE_SetHQStatus = [vehicleVarName (leader _commanderTeam),'CLTFNCSETHQSTATUS',false];
+ publicVariable 'WFBE_SetHQStatus';
+ if (isHostedServer) then {[vehicleVarName (leader _commanderTeam),'CLTFNCSETHQSTATUS',false] Spawn HandlePVF};
+};
+
+sleep 15;
+
+_HQName = Format["WFBE_%1MHQNAME",_sideText] Call GetNamespace;
+_MHQ = _HQName createVehicle _position;
+
+Call Compile Format ["%1MHQ = _MHQ; publicVariable '%1MHQ';",_sideText];
+
+_MHQ setDir _direction;
+_MHQ setVelocity [0,0,-1];
+
+Call Compile Format ["_MHQ AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",_side,typeOf _MHQ];
+
+_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;
+
+deleteVehicle _hq;
+
+Call Compile Format ["%1MHQDeployed = false; publicVariable '%1MHQDeployed';",_sideText];
+WF_Logic setVariable [Format ["%1MHQRepair",_sideText],false,true];
+
+diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_MHQRepair: The %1 MHQ was repaired.",_sideText,diag_frameno,diag_tickTime];
\ No newline at end of file diff --git a/Server/Functions/Server_PlaceJoiningUnit.sqf b/Server/Functions/Server_PlaceJoiningUnit.sqf new file mode 100644 index 0000000..99deb63 --- /dev/null +++ b/Server/Functions/Server_PlaceJoiningUnit.sqf @@ -0,0 +1,18 @@ +Private ["_buildings","_hq","_placeAt","_side","_unit"];
+
+_unit = _this select 0;
+_side = _this select 1;
+
+waitUntil {!isNil Format["%1StartingLocation",str _side]};
+
+_buildings = (str _side) Call GetSideStructures;
+_hq = (str _side) Call GetSideHQ;
+
+_placeAt = objNull;
+if (count _buildings > 0) then {
+ _placeAt = ([_hq, _buildings] Call SortByDistance) select 0;
+} else {
+ _placeAt = _hq;
+};
+
+_unit setPos ([getPos _placeAt,20,30] Call GetRandomPosition);
\ No newline at end of file diff --git a/Server/Functions/Server_SelectOccupTeam.sqf b/Server/Functions/Server_SelectOccupTeam.sqf new file mode 100644 index 0000000..a28bf3c --- /dev/null +++ b/Server/Functions/Server_SelectOccupTeam.sqf @@ -0,0 +1,41 @@ +private ["_difficulty","_probaOccupation","_oc1","_oc2","_oc3","_oc4","_oc5","_oc6","_ran1","_ran2","_supplyValue","_teams","_type","_x"];
+_supplyValue = _this select 0;
+_type = [];
+_teams = [];
+
+_oc1 = 'WFBE_OCCUPATIONTEAM1' Call GetNamespace;
+_oc2 = 'WFBE_OCCUPATIONTEAM2' Call GetNamespace;
+_oc3 = 'WFBE_OCCUPATIONTEAM3' Call GetNamespace;
+_oc4 = 'WFBE_OCCUPATIONTEAM4' Call GetNamespace;
+_oc5 = 'WFBE_OCCUPATIONTEAM5' Call GetNamespace;
+_oc6 = 'WFBE_OCCUPATIONTEAM6' Call GetNamespace;
+
+_probaOccupation = 75;
+if ((_supplyValue >= _oc1)&&(_supplyValue < _oc2)) then {_type = ["SmallTeam"];_probaOccupation = 95};
+if ((_supplyValue >= _oc2)&&(_supplyValue < _oc3)) then {_type = ["SmallTeam","SmallVehTeam"];_probaOccupation = 85};
+if ((_supplyValue >= _oc3)&&(_supplyValue < _oc4)) then {_type = ["SmallTeam","MediumTeam","MediumVehTeam"];_probaOccupation = 75};
+if ((_supplyValue >= _oc4)&&(_supplyValue < _oc5)) then {_type = ["SmallTeam","MediumTeam","LargeTeam","MediumVehTeam"];_probaOccupation = 65};
+if ((_supplyValue >= _oc5)&&(_supplyValue < _oc6)) then {_type = ["SmallTeam","MediumTeam","LargeTeam","MediumVehTeam","LargeVehTeam"];_probaOccupation = 60};
+if (_supplyValue >= _oc6) then {_type = ["SmallTeam","MediumTeam","LargeTeam","SmallVehTeam","MediumVehTeam","LargeVehTeam"];_probaOccupation = 55};
+
+_difficulty = 'WFBE_TOWNOCCUPATIONDIFFICULTY' Call GetNamespace;
+if (_difficulty == 5) then {
+ if (diag_fps >= 35) then {_difficulty = 4};
+ if (diag_fps >= 25 && diag_fps < 30) then {_difficulty = 3};
+ if (diag_fps >= 15 && diag_fps < 25) then {_difficulty = 2};
+ if (diag_fps < 15) then {_difficulty = 1};
+} else {
+ _probaOccupation = _probaOccupation - (_difficulty * 5);
+ if (_probaOccupation < 10) then {_probaOccupation = 10};
+};
+
+for [{_z = 0},{_z <= _difficulty},{_z = _z + 1}] do {
+ _ran1 = random 100;
+ if (_ran1 < _probaOccupation) then {
+ {_ran2 = round(1 + random 2);_teams = _teams + [Format ["%1%2",_x,_ran2]]} forEach _type;
+ };
+};
+
+if (count _teams < 1) then {_teams = ["SmallTeam1"]};
+
+_teams
\ No newline at end of file diff --git a/Server/Functions/Server_SelectResTeam.sqf b/Server/Functions/Server_SelectResTeam.sqf new file mode 100644 index 0000000..63e1218 --- /dev/null +++ b/Server/Functions/Server_SelectResTeam.sqf @@ -0,0 +1,144 @@ +Private ['_difficulty','_factor','_infAssign','_minInfSpawnRatio','_minVehSpawnRatio','_poolInf','_poolVeh','_ratioInfantry','_ranArr','_ratioVehicle','_teams','_try','_vehAssign'];
+
+_difficulty = _this select 0;
+
+_ratioVehicle = 0;
+_ratioInfantry = 0;
+
+_teams = [];
+_poolInf = [];
+_poolVeh = [];
+
+_vehAssign = 0;
+_infAssign = 0;
+_minInfSpawnRatio = 0;
+_minVehSpawnRatio = 0;
+_try = 0;
+
+switch (_difficulty) do {
+ case 'light1': {
+ _ratioVehicle = 10;
+ _ratioInfantry = 90;
+ _try = 3;
+ _minInfSpawnRatio = 15;
+ _minVehSpawnRatio = 35;
+
+ _poolInf = ['Group','Patrol1','Patrol2','Militia'];
+ _poolVeh = ['MotorizedGroup'];
+ };
+ case 'light2': {
+ _ratioVehicle = 20;
+ _ratioInfantry = 80;
+ _try = 4;
+ _minInfSpawnRatio = 20;
+ _minVehSpawnRatio = 40;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','Patrol2','Militia'];
+ _poolVeh = ['Technical'];
+ };
+ case 'medium1': {
+ _ratioVehicle = 20;
+ _ratioInfantry = 80;
+ _try = 5;
+ _minInfSpawnRatio = 18;
+ _minVehSpawnRatio = 35;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','SniperTeam'];
+ _poolVeh = ['Technical'];
+ };
+ case 'medium2': {
+ _ratioVehicle = 40;
+ _ratioInfantry = 60;
+ _try = 5;
+ _minInfSpawnRatio = 22;
+ _minVehSpawnRatio = 39;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam'];
+ _poolVeh = ['MechanizedGroup','MechanizedPatrol','LightArmor','Technical','MotorizedGroup'];
+ };
+ case 'medium3': {
+ _ratioVehicle = 30;
+ _ratioInfantry = 70;
+ _try = 5;
+ _minInfSpawnRatio = 26;
+ _minVehSpawnRatio = 32;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault'];
+ _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','Technical','MotorizedGroup'];
+ };
+ case 'medium4': {
+ _ratioVehicle = 35;
+ _ratioInfantry = 65;
+ _try = 5;
+ _minInfSpawnRatio = 28;
+ _minVehSpawnRatio = 32;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam'];
+ _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','Technical','HeavyArmor'];
+ };
+ case 'large1': {
+ _ratioVehicle = 30;
+ _ratioInfantry = 70;
+ _try = 5;
+ _minInfSpawnRatio = 25;
+ _minVehSpawnRatio = 35;
+
+ _poolInf = ['GroupWeapons','ATTeam','GroupAssault','SniperTeam'];
+ _poolVeh = ['MechanizedGroup','MechanizedPatrol','LightArmor','LightArmor','HeavyArmor','Technical'];
+ };
+ case 'large2': {
+ _ratioVehicle = 45;
+ _ratioInfantry = 55;
+ _try = 6;
+ _minInfSpawnRatio = 25;
+ _minVehSpawnRatio = 32;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam','SniperTeam'];
+ _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','HeavyArmor','HeavyArmor','Technical'];
+ };
+ case 'huge1': {
+ _ratioVehicle = 50;
+ _ratioInfantry = 50;
+ _try = 6;
+ _minInfSpawnRatio = 30;
+ _minVehSpawnRatio = 35;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam','SniperTeam'];
+ _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','LightArmor','HeavyArmor','HeavyArmor','Technical'];
+ };
+ case 'huge2': {
+ _ratioVehicle = 50;
+ _ratioInfantry = 50;
+ _try = 7;
+ _minInfSpawnRatio = 35;
+ _minVehSpawnRatio = 35;
+
+ _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam','SniperTeam'];
+ _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','LightArmor','HeavyArmor','HeavyArmor','Technical'];
+ };
+};
+
+_try = _try * ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace);
+_vehAssign = round(_try * (_ratioVehicle / 100));
+_infAssign = round(_try * (_ratioInfantry / 100));
+
+for [{_z = 0},{_z < _try},{_z = _z + 1}] do {
+ if (_vehAssign > 0) then {
+ _vehAssign = _vehAssign - 1;
+ if (random 100 > _minVehSpawnRatio) then {
+ _ranArr = round(random((count _poolVeh)-1));
+ _teams = _teams + [_poolVeh select _ranArr];
+ };
+ };
+ if (_infAssign > 0) then {
+ _infAssign = _infAssign - 1;
+ if (random 100 > _minInfSpawnRatio) then {
+ _ranArr = round(random((count _poolInf)-1));
+ _teams = _teams + [_poolInf select _ranArr];
+ };
+ };
+};
+
+if (count _teams < 1) then {_teams = ['Group']};
+
+_teams
\ No newline at end of file diff --git a/Server/Functions/Server_SetCampsToSide.sqf b/Server/Functions/Server_SetCampsToSide.sqf new file mode 100644 index 0000000..36df4d6 --- /dev/null +++ b/Server/Functions/Server_SetCampsToSide.sqf @@ -0,0 +1,30 @@ +Private["_camp","_camps","_count","_notifyAllSides","_objects","_previousSide","_side","_sideID","_startingSV","_texture","_town"];
+
+_town = _this Select 0;
+_side = _this Select 1;
+_previousSide = _this Select 2;
+
+_sideID = _side Call GetSideID;
+_camps = _town getVariable "camps";
+_startingSV = _town getVariable "supplyValue";
+
+for [{_count = Count _camps - 1},{_count >= 0},{_count = _count - 1}] do {
+ _camp = _camps Select _count;
+ _camp setVariable ["sideID",_sideID,true];
+ _camp setVariable ["supplyValue",_startingSV,true];
+
+ _texture = Format["WFBE_%1FLAG",str _side] Call GetNamespace;
+
+ _objects = _camp nearEntities[[WFFLAG],20];
+ if (count _objects > 0) then {(_objects Select 0) setFlagTexture _texture};
+};
+
+sleep 0.5;
+
+_notifyAllSides = (_previousSide == East || _previousSide == West);
+
+WFBE_AllCampsCaptured = [nil,'CLTFNCALLCAMPSCAPTURED',[_town,_sideID,_notifyAllSides]];
+publicVariable 'WFBE_AllCampsCaptured';
+if (isHostedServer) then {[nil,'CLTFNCALLCAMPSCAPTURED',[_town,_sideID,_notifyAllSides]] Spawn HandlePVF};
+
+diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_SetCampsToSide: '%1' Camps have been set to %2",_town,str _side,diag_frameno,diag_tickTime];
diff --git a/Server/Functions/Server_SideMessage.sqf b/Server/Functions/Server_SideMessage.sqf new file mode 100644 index 0000000..b2bdad0 --- /dev/null +++ b/Server/Functions/Server_SideMessage.sqf @@ -0,0 +1,94 @@ +Private ["_canSpeak","_extra","_localizedString","_locRaw","_receiver","_rlName","_side","_speaker","_special","_specialb","_topicSide","_value"];
+_special = _this select 0;
+_specialb = _this select 1;
+_side = _this select 2;
+_extra = "";
+if (count _this > 3) then {_extra = _this select 3};
+
+_speaker = BIS_WF_HQEAST; _receiver = BIS_WF_HQEAST2; _topicSide = BIS_WF_HQEAST_TI;
+if (_side == west) then {_speaker = BIS_WF_HQWEST;_receiver = BIS_WF_HQWEST2; _topicSide = BIS_WF_HQWEST_TI};
+
+//--- Radio: Base building / attacks / destruction.
+if (_special in ["Destroyed","IsUnderAttack","Constructed"]) then {
+ _localizedString = localize "strwfbarracks";
+ _value = "Barracks";
+ switch (typeName _specialb) do {
+ case "OBJECT": {
+ _localizedString = _specialb getVariable "name";
+ _value = _extra;
+ };
+ case "STRING": {
+ if (_specialb == ('WFBE_WESTMHQNAME' Call GetNamespace) || _specialb == ('WFBE_EASTMHQNAME' Call GetNamespace)) then {_localizedString = localize "STRHeadquarters";_value = "Headquarters";if (_special == "Constructed") then {_special = "Mobilized"}};
+ if (_specialb == WESTHQ || _specialb == EASTHQ) then {_localizedString = localize "STRHeadquarters";_value = "Headquarters";if (_special == "Constructed") then {_special = "Deployed"}};
+ if (_specialb == WESTLVF || _specialb == EASTLVF) then {_localizedString = localize "STRLightVehicleSupply";_value = "LightVehicleSupply"};
+ if (_specialb == WESTCC || _specialb == EASTCC) then {
+ _localizedString = localize "STR_WF_CommandCenter";
+ _value = "UAVTerminal";
+ if (WF_A2_Arrowhead || (WF_A2_CombinedOps && _side == west)) then {_value = "CommandPost"};
+ };
+ if (_specialb == WESTHEAVY || _specialb == EASTHEAVY) then {_localizedString = localize "STRHeavyVehicleSupply";_value = "HeavyVehicleSupply"};
+ if (_specialb == WESTAIR || _specialb == EASTAIR) then {_localizedString = localize "STRHelipad";_value = "Helipad"};
+ if (_specialb == WESTSP || _specialb == EASTSP) then {_localizedString = localize "STRServicePoint";_value = "ServicePoint"};
+ if (_specialb == WESTAAR || _specialb == EASTAAR) then {_localizedString = localize "STRAntiAirRadar";_value = "AntiAirRadar"};
+ };
+ };
+ _speaker kbTell [_receiver, _topicSide, _special,["1","",_localizedString,[_value]],true];
+};
+
+//--- Radio: Town Capture/Loss.
+if (_special in ["Lost","Captured","HostilesDetectedNear"]) then {
+ _locRaw = str _specialb;
+ _rlName = _specialb getVariable "name";
+ _canSpeak = if (_side == east && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false};
+ if !(_canSpeak) then {_canSpeak = if (_side == west && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}};
+ if !(_canSpeak) then {_canSpeak = if (WF_A2_Vanilla && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false}};
+ if !(_canSpeak) then {_canSpeak = if (WF_A2_Arrowhead && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}};
+
+ if !(_canSpeak) then {_locRaw = "Town"} else {
+ switch (_locRaw) do {
+ case "Vyshnoye": {_locRaw = "Vyshnoe"};
+ case "Shahbaz": {_locRaw = "Town"};
+ case "Qeslaq": {_locRaw = "Town"};
+ };
+ };
+ _speaker kbTell [_receiver, _topicSide, _special,["1","",_rlName,[_locRaw]],true];
+};
+
+//--- Radio: Voting for a new commander.
+if (_special in ["VotingForNewCommander","NewIntelAvailable"]) then {_speaker kbTell [_receiver, _topicSide, _special,true]};
+
+//--- Radio: Camp Capture/Loss.
+if (_special in ["CapturedNear","LostAt"]) then {
+ _locRaw = str _extra;
+ _rlName = _extra getVariable "name";
+ _canSpeak = if (_side == east && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false};
+ if !(_canSpeak) then {_canSpeak = if (_side == west && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}};
+ if !(_canSpeak) then {_canSpeak = if (WF_A2_Vanilla && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false}};
+ if !(_canSpeak) then {_canSpeak = if (WF_A2_Arrowhead && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}};
+
+ if !(_canSpeak) then {_locRaw = "Town"} else {
+ switch (_locRaw) do {
+ case "Vyshnoye": {_locRaw = "Vyshnoe"};
+ case "Shahbaz": {_locRaw = "Town"};
+ case "Qeslaq": {_locRaw = "Town"};
+ };
+ };
+ _speaker kbTell [_receiver, _topicSide, _special,["1","",_specialb,[_specialb]],["2","",_rlName,[_locRaw]],true];
+};
+
+if (paramSecondaryMissions) then {
+ //--- Radio: Mission.
+ if (_special in ['MMissionFailed','NewMissionAvailable']) then {
+ _speaker kbTell [_receiver, _topicSide, _special,true];
+ };
+
+ //--- Radio: Mission Complete.
+ if (_special == 'MMissionComplete') then {
+ _speaker kbTell [_receiver, _topicSide, _special,["1","",_specialb,[_extra]],true];
+ };
+
+ //--- Radio: Extraction Team.
+ if (_special in ['ExtractionTeam','ExtractionTeamCancel']) then {
+ _speaker kbTell [_receiver, _topicSide, _special,["1","",_specialb,[_specialb]],true];
+ };
+};
\ No newline at end of file diff --git a/Server/Functions/Server_TrashObject.sqf b/Server/Functions/Server_TrashObject.sqf new file mode 100644 index 0000000..bb983f1 --- /dev/null +++ b/Server/Functions/Server_TrashObject.sqf @@ -0,0 +1,34 @@ +/*
+ Author: Benny
+ Name: Server_TrashObject.sqf
+ Parameters:
+ 0 - Object
+ Description:
+ This function will remove an object after the defined amount of time.
+*/
+
+private ["_alive","_group","_isMan","_object","_get"];
+_object = _this;
+
+if !(isNull _object) then {
+ _group = [];
+ _isMan = if (_object isKindOf "Man") then {true} else {false};
+
+ if (_isMan) then {_group = group _object};
+
+ sleep ('WFBE_UNITREMOVEDLAY' Call GetNamespace);
+ trashQueu = trashQueu - [_object];
+
+ if (_isMan) then {hideBody _object; sleep 6};
+
+ deleteVehicle _object;
+
+ if (_isMan) then {
+ if !(isNull _group) then {
+ _get = _group getVariable 'queue';
+ if (isNil '_get') then {
+ if (count (units _group) <= 0) then {deleteGroup _group;};
+ };
+ };
+ };
+};
\ No newline at end of file diff --git a/Server/Functions/Server_UpdateTeam.sqf b/Server/Functions/Server_UpdateTeam.sqf new file mode 100644 index 0000000..274c420 --- /dev/null +++ b/Server/Functions/Server_UpdateTeam.sqf @@ -0,0 +1,8 @@ +Private ['_formations','_team'];
+_team = _this;
+
+_formations = ['FILE','DIAMOND','STAG COLUMN','WEDGE'];
+_team setFormation (_formations select round(random(count _formations -1)));
+_team setBehaviour "AWARE";
+_team setSpeedMode "NORMAL";
+_team setCombatMode "YELLOW";
\ No newline at end of file |
