From e670b4ed55c459a21090bd0178ceaaaf12d87989 Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:58:31 +0300 Subject: init --- Common/Functions/Common_BackpackHasSpace.sqf | 16 ++ Common/Functions/Common_BalanceInit.sqf | 48 +++++ Common/Functions/Common_BuildingInRange.sqf | 17 ++ Common/Functions/Common_ChangeClientFunds.sqf | 7 + Common/Functions/Common_ChangeSideSupply.sqf | 11 ++ Common/Functions/Common_ChangeTeamFunds.sqf | 8 + Common/Functions/Common_CivilianKilled.sqf | 29 +++ Common/Functions/Common_CreateUnit.sqf | 28 +++ Common/Functions/Common_CreateVehicle.sqf | 20 +++ Common/Functions/Common_EquipArtillery.sqf | 19 ++ Common/Functions/Common_EquipBackpack.sqf | 9 + Common/Functions/Common_EquipLoadout.sqf | 26 +++ Common/Functions/Common_FireArtillery.sqf | 65 +++++++ Common/Functions/Common_GetAIDigit.sqf | 21 +++ Common/Functions/Common_GetClientID.sqf | 6 + Common/Functions/Common_GetClientIDFromTeam.sqf | 11 ++ Common/Functions/Common_GetClientTeam.sqf | 7 + Common/Functions/Common_GetClosestLocation.sqf | 5 + .../Functions/Common_GetClosestLocationBySide.sqf | 21 +++ Common/Functions/Common_GetCommanderFromVotes.sqf | 36 ++++ Common/Functions/Common_GetCommanderTeam.sqf | 7 + Common/Functions/Common_GetCommanderVotes.sqf | 19 ++ Common/Functions/Common_GetConfigInfo.sqf | 8 + .../Functions/Common_GetConfigVehicleCrewSlot.sqf | 21 +++ .../Functions/Common_GetConfigVehicleTurrets.sqf | 16 ++ .../Common_GetConfigVehicleTurretsReturn.sqf | 54 ++++++ Common/Functions/Common_GetFactories.sqf | 10 ++ Common/Functions/Common_GetFriendlyCamps.sqf | 14 ++ Common/Functions/Common_GetGroupFromConfig.sqf | 23 +++ Common/Functions/Common_GetHostilesInArea.sqf | 18 ++ Common/Functions/Common_GetLiveUnits.sqf | 8 + Common/Functions/Common_GetNameSpace.sqf | 5 + Common/Functions/Common_GetPositionFrom.sqf | 11 ++ Common/Functions/Common_GetRandomPosition.sqf | 12 ++ Common/Functions/Common_GetRespawnCamps.sqf | 14 ++ Common/Functions/Common_GetSafePlace.sqf | 27 +++ Common/Functions/Common_GetSideFromID.sqf | 7 + Common/Functions/Common_GetSideHQ.sqf | 1 + Common/Functions/Common_GetSideHQDeployed.sqf | 1 + Common/Functions/Common_GetSideID.sqf | 7 + Common/Functions/Common_GetSideStructures.sqf | 1 + Common/Functions/Common_GetSideSupply.sqf | 1 + Common/Functions/Common_GetSideTowns.sqf | 10 ++ Common/Functions/Common_GetSideUpgrades.sqf | 1 + Common/Functions/Common_GetSleepFPS.sqf | 11 ++ Common/Functions/Common_GetTeamArtillery.sqf | 32 ++++ Common/Functions/Common_GetTeamAutonomous.sqf | 3 + Common/Functions/Common_GetTeamFunds.sqf | 7 + Common/Functions/Common_GetTeamMoveMode.sqf | 3 + Common/Functions/Common_GetTeamMovePos.sqf | 3 + Common/Functions/Common_GetTeamRespawn.sqf | 3 + Common/Functions/Common_GetTeamType.sqf | 3 + Common/Functions/Common_GetTeamVehicles.sqf | 30 ++++ Common/Functions/Common_GetTotalCamps.sqf | 7 + Common/Functions/Common_GetTotalCampsOnSide.sqf | 15 ++ Common/Functions/Common_GetTotalSupplyValue.sqf | 13 ++ Common/Functions/Common_GetTownsHeld.sqf | 8 + Common/Functions/Common_GetTownsIncome.sqf | 18 ++ Common/Functions/Common_GetTurretsMags.sqf | 42 +++++ Common/Functions/Common_GetUnitVehicle.sqf | 6 + Common/Functions/Common_GetUnitsBelowHeight.sqf | 11 ++ Common/Functions/Common_GetVehicleMags.sqf | 4 + Common/Functions/Common_HandleArtillery.sqf | 104 +++++++++++ Common/Functions/Common_HandleIncomingMissile.sqf | 22 +++ Common/Functions/Common_IsArtillery.sqf | 12 ++ Common/Functions/Common_PlaceNear.sqf | 34 ++++ Common/Functions/Common_PlaceSafe.sqf | 28 +++ Common/Functions/Common_RearmVehicle.sqf | 39 ++++ Common/Functions/Common_RearmVehicleOA.sqf | 51 ++++++ Common/Functions/Common_RevealArea.sqf | 11 ++ Common/Functions/Common_SetCommanderVotes.sqf | 14 ++ Common/Functions/Common_SetNamespace.sqf | 15 ++ Common/Functions/Common_SetTeamAutonomous.sqf | 8 + Common/Functions/Common_SetTeamMoveMode.sqf | 8 + Common/Functions/Common_SetTeamMovePos.sqf | 8 + Common/Functions/Common_SetTeamRespawn.sqf | 8 + Common/Functions/Common_SetTeamType.sqf | 8 + Common/Functions/Common_SetTurretsMags.sqf | 30 ++++ Common/Functions/Common_SortByDistance.sqf | 24 +++ Common/Functions/Common_SpawnTurrets.sqf | 22 +++ Common/Functions/Common_UnitKilled.sqf | 196 +++++++++++++++++++++ Common/Functions/Common_UpdateStatistics.sqf | 1 + Common/Functions/Common_UseStationaryDefense.sqf | 32 ++++ 83 files changed, 1600 insertions(+) create mode 100644 Common/Functions/Common_BackpackHasSpace.sqf create mode 100644 Common/Functions/Common_BalanceInit.sqf create mode 100644 Common/Functions/Common_BuildingInRange.sqf create mode 100644 Common/Functions/Common_ChangeClientFunds.sqf create mode 100644 Common/Functions/Common_ChangeSideSupply.sqf create mode 100644 Common/Functions/Common_ChangeTeamFunds.sqf create mode 100644 Common/Functions/Common_CivilianKilled.sqf create mode 100644 Common/Functions/Common_CreateUnit.sqf create mode 100644 Common/Functions/Common_CreateVehicle.sqf create mode 100644 Common/Functions/Common_EquipArtillery.sqf create mode 100644 Common/Functions/Common_EquipBackpack.sqf create mode 100644 Common/Functions/Common_EquipLoadout.sqf create mode 100644 Common/Functions/Common_FireArtillery.sqf create mode 100644 Common/Functions/Common_GetAIDigit.sqf create mode 100644 Common/Functions/Common_GetClientID.sqf create mode 100644 Common/Functions/Common_GetClientIDFromTeam.sqf create mode 100644 Common/Functions/Common_GetClientTeam.sqf create mode 100644 Common/Functions/Common_GetClosestLocation.sqf create mode 100644 Common/Functions/Common_GetClosestLocationBySide.sqf create mode 100644 Common/Functions/Common_GetCommanderFromVotes.sqf create mode 100644 Common/Functions/Common_GetCommanderTeam.sqf create mode 100644 Common/Functions/Common_GetCommanderVotes.sqf create mode 100644 Common/Functions/Common_GetConfigInfo.sqf create mode 100644 Common/Functions/Common_GetConfigVehicleCrewSlot.sqf create mode 100644 Common/Functions/Common_GetConfigVehicleTurrets.sqf create mode 100644 Common/Functions/Common_GetConfigVehicleTurretsReturn.sqf create mode 100644 Common/Functions/Common_GetFactories.sqf create mode 100644 Common/Functions/Common_GetFriendlyCamps.sqf create mode 100644 Common/Functions/Common_GetGroupFromConfig.sqf create mode 100644 Common/Functions/Common_GetHostilesInArea.sqf create mode 100644 Common/Functions/Common_GetLiveUnits.sqf create mode 100644 Common/Functions/Common_GetNameSpace.sqf create mode 100644 Common/Functions/Common_GetPositionFrom.sqf create mode 100644 Common/Functions/Common_GetRandomPosition.sqf create mode 100644 Common/Functions/Common_GetRespawnCamps.sqf create mode 100644 Common/Functions/Common_GetSafePlace.sqf create mode 100644 Common/Functions/Common_GetSideFromID.sqf create mode 100644 Common/Functions/Common_GetSideHQ.sqf create mode 100644 Common/Functions/Common_GetSideHQDeployed.sqf create mode 100644 Common/Functions/Common_GetSideID.sqf create mode 100644 Common/Functions/Common_GetSideStructures.sqf create mode 100644 Common/Functions/Common_GetSideSupply.sqf create mode 100644 Common/Functions/Common_GetSideTowns.sqf create mode 100644 Common/Functions/Common_GetSideUpgrades.sqf create mode 100644 Common/Functions/Common_GetSleepFPS.sqf create mode 100644 Common/Functions/Common_GetTeamArtillery.sqf create mode 100644 Common/Functions/Common_GetTeamAutonomous.sqf create mode 100644 Common/Functions/Common_GetTeamFunds.sqf create mode 100644 Common/Functions/Common_GetTeamMoveMode.sqf create mode 100644 Common/Functions/Common_GetTeamMovePos.sqf create mode 100644 Common/Functions/Common_GetTeamRespawn.sqf create mode 100644 Common/Functions/Common_GetTeamType.sqf create mode 100644 Common/Functions/Common_GetTeamVehicles.sqf create mode 100644 Common/Functions/Common_GetTotalCamps.sqf create mode 100644 Common/Functions/Common_GetTotalCampsOnSide.sqf create mode 100644 Common/Functions/Common_GetTotalSupplyValue.sqf create mode 100644 Common/Functions/Common_GetTownsHeld.sqf create mode 100644 Common/Functions/Common_GetTownsIncome.sqf create mode 100644 Common/Functions/Common_GetTurretsMags.sqf create mode 100644 Common/Functions/Common_GetUnitVehicle.sqf create mode 100644 Common/Functions/Common_GetUnitsBelowHeight.sqf create mode 100644 Common/Functions/Common_GetVehicleMags.sqf create mode 100644 Common/Functions/Common_HandleArtillery.sqf create mode 100644 Common/Functions/Common_HandleIncomingMissile.sqf create mode 100644 Common/Functions/Common_IsArtillery.sqf create mode 100644 Common/Functions/Common_PlaceNear.sqf create mode 100644 Common/Functions/Common_PlaceSafe.sqf create mode 100644 Common/Functions/Common_RearmVehicle.sqf create mode 100644 Common/Functions/Common_RearmVehicleOA.sqf create mode 100644 Common/Functions/Common_RevealArea.sqf create mode 100644 Common/Functions/Common_SetCommanderVotes.sqf create mode 100644 Common/Functions/Common_SetNamespace.sqf create mode 100644 Common/Functions/Common_SetTeamAutonomous.sqf create mode 100644 Common/Functions/Common_SetTeamMoveMode.sqf create mode 100644 Common/Functions/Common_SetTeamMovePos.sqf create mode 100644 Common/Functions/Common_SetTeamRespawn.sqf create mode 100644 Common/Functions/Common_SetTeamType.sqf create mode 100644 Common/Functions/Common_SetTurretsMags.sqf create mode 100644 Common/Functions/Common_SortByDistance.sqf create mode 100644 Common/Functions/Common_SpawnTurrets.sqf create mode 100644 Common/Functions/Common_UnitKilled.sqf create mode 100644 Common/Functions/Common_UpdateStatistics.sqf create mode 100644 Common/Functions/Common_UseStationaryDefense.sqf (limited to 'Common/Functions') diff --git a/Common/Functions/Common_BackpackHasSpace.sqf b/Common/Functions/Common_BackpackHasSpace.sqf new file mode 100644 index 0000000..7e90dd6 --- /dev/null +++ b/Common/Functions/Common_BackpackHasSpace.sqf @@ -0,0 +1,16 @@ +private ["_backpackHasRoom","_bp","_bpContent","_bpItem","_max","_space","_type"]; +_bp = _this select 0; +_bpContent = _this select 1; +_bpItem = _this select 2; + +_type = _bp; +if (typeName _bp == 'OBJECT') then {_type = typeOf _bp}; +_max = getNumber(configFile >> 'CfgVehicles' >> _type >> 'transportMaxMagazines'); + +_space = 0; +for '_u' from 0 to count(_bpContent select 0)-1 do { + _space = _space + (ceil (getNumber(configFile >> 'CfgMagazines' >> ((_bpContent select 0) select _u) >> 'type') / 256)) * ((_bpContent select 1) select _u); +}; + +_backpackHasRoom = if ((ceil(getNumber(configFile >> 'CfgMagazines' >> _bpItem >> 'type') / 256)) + _space > _max) then {false} else {true}; +_backpackHasRoom \ No newline at end of file diff --git a/Common/Functions/Common_BalanceInit.sqf b/Common/Functions/Common_BalanceInit.sqf new file mode 100644 index 0000000..befed3b --- /dev/null +++ b/Common/Functions/Common_BalanceInit.sqf @@ -0,0 +1,48 @@ +Private ["_unit"]; +_unit = _this select 0; + +switch (typeOf _unit) do { + case "HMMWV_Avenger": { + if (WF_A2_Vanilla) then { + _unit removeWeapon "SidewinderLaucher_AH1Z"; + _unit removeWeapon "StingerLaucher"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addMagazine "2Rnd_Sidewinder_AH1Z"; + _unit addWeapon "SidewinderLaucher_AH1Z"; + }; + }; + case "M6_EP1": { + _unit removeWeapon "StingerLaucher_4x"; + _unit addMagazine "8Rnd_9M311"; + _unit addWeapon "9M311Laucher"; + }; + case "Ka52": { + _unit removeWeapon "AT9Launcher"; + _unit removeWeapon "VikhrLauncher"; + _unit addMagazine "4Rnd_AT9_Mi24P"; + _unit addMagazine "4Rnd_AT9_Mi24P"; + _unit addweapon "AT9Launcher"; + _unit addMagazine "4Rnd_R73"; + _unit addweapon "R73Launcher"; + }; + case "Ka52Black": { + _unit removeWeapon "AT9Launcher"; + _unit removeWeapon "VikhrLauncher"; + _unit addMagazine "4Rnd_AT9_Mi24P"; + _unit addMagazine "4Rnd_AT9_Mi24P"; + _unit addweapon "AT9Launcher"; + _unit addMagazine "4Rnd_R73"; + _unit addweapon "R73Launcher"; + }; + case "An2_TK_EP1": { + _unit addMagazine "500Rnd_TwinVickers"; + _unit addMagazine "500Rnd_TwinVickers"; + _unit addweapon "TwinVickers"; + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_BuildingInRange.sqf b/Common/Functions/Common_BuildingInRange.sqf new file mode 100644 index 0000000..49eb893 --- /dev/null +++ b/Common/Functions/Common_BuildingInRange.sqf @@ -0,0 +1,17 @@ +Private ['_buildings','_buildingType','_checks','_closest','_range','_side','_sorted','_unit']; +_buildingType = _this select 0; +_buildings = _this select 1; +_range = _this select 2; +_side = _this select 3; +_unit = _this select 4; + +_closest = objNull; + +_checks = [_side,Format ["WFBE_%1%2",str _side,_buildingType] Call GetNamespace,_buildings] Call GetFactories; +if (count _checks > 0) then { + _sorted = [_unit,_checks] Call SortByDistance; + _closest = _sorted select 0; + if (_unit distance _closest > _range) then {_closest = objNull}; +}; + +_closest \ No newline at end of file diff --git a/Common/Functions/Common_ChangeClientFunds.sqf b/Common/Functions/Common_ChangeClientFunds.sqf new file mode 100644 index 0000000..17d840f --- /dev/null +++ b/Common/Functions/Common_ChangeClientFunds.sqf @@ -0,0 +1,7 @@ +private ["_id","_side","_amount"]; + +_amount = _this Select 0; +_side = _this Select 1; +_id = _this Select 2; + +Call Compile Format ["%1Funds%2 = %1Funds%2 + %3; publicVariable '%1Funds%2';",str _side,_id,_amount]; \ No newline at end of file diff --git a/Common/Functions/Common_ChangeSideSupply.sqf b/Common/Functions/Common_ChangeSideSupply.sqf new file mode 100644 index 0000000..6bcdc91 --- /dev/null +++ b/Common/Functions/Common_ChangeSideSupply.sqf @@ -0,0 +1,11 @@ +Private ['_amount','_change','_currentSupply','_side']; + +_side = _this select 0; +_amount = _this select 1; + +_currentSupply = (_side) Call GetSideSupply; +if (isNil '_currentSupply') then {_currentSupply = 0}; +_change = _currentSupply + _amount; +if (_change < 0) then {_change = _currentSupply - _amount}; + +WF_Logic setVariable [Format["%1Supplies",_side],_change,true]; \ No newline at end of file diff --git a/Common/Functions/Common_ChangeTeamFunds.sqf b/Common/Functions/Common_ChangeTeamFunds.sqf new file mode 100644 index 0000000..f0d8ef0 --- /dev/null +++ b/Common/Functions/Common_ChangeTeamFunds.sqf @@ -0,0 +1,8 @@ +Private['_amount','_team']; + +_team = _this select 0; +_amount = _this select 1; + +if (isNull _team) exitWith {}; + +Call Compile Format ["%1Funds = %1Funds + _amount; publicVariable '%1Funds';",_team getVariable 'identification']; \ No newline at end of file diff --git a/Common/Functions/Common_CivilianKilled.sqf b/Common/Functions/Common_CivilianKilled.sqf new file mode 100644 index 0000000..3086451 --- /dev/null +++ b/Common/Functions/Common_CivilianKilled.sqf @@ -0,0 +1,29 @@ +Private ["_killed","_killer","_killerTeam","_sideKiller"]; +_killed = _this select 0; +_killer = _this select 1; +_sideKiller = side _killer; +_killerTeam = group _killer; + +//--- Renegade. +if (_sideKiller == sideEnemy) then { + if (_killer isKindOf westSoldierBaseClass) then {_sideKiller = west}; + if (_killer isKindOf eastSoldierBaseClass) then {_sideKiller = east}; +}; + +//--- Benny's Garbage Collector. +if (WF_A2_Vanilla) then { + trashQueu = trashQueu + [_killed]; + _killed Spawn TrashObject; +}; + +sleep random(2)+random(4); + +//--- Civilian's death. +if (!isNull _killerTeam && (_sideKiller == west) || (_sideKiller == east)) then { + if (isPlayer (leader _killerTeam)) then { + /* Penalty */ + WFBE_Penalty = [vehicleVarName (leader _killerTeam),'CLTFNCPENALTY']; + publicVariable 'WFBE_Penalty'; + if (isHostedServer) then {[vehicleVarName (leader _killerTeam),'CLTFNCPENALTY'] Spawn HandlePVF}; + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_CreateUnit.sqf b/Common/Functions/Common_CreateUnit.sqf new file mode 100644 index 0000000..8a42df6 --- /dev/null +++ b/Common/Functions/Common_CreateUnit.sqf @@ -0,0 +1,28 @@ +Private ["_get","_position","_side","_skill","_team","_type","_unit"]; +_type = _this select 0; +_team = _this select 1; +_position = _this select 2; +_side = _this select 3; + +_get = _type Call GetNamespace; +_skill = if !(isNil '_get') then {_get select QUERYUNITSKILL} else {'WFBE_AISKILL' Call GetNamespace}; +_unit = _team createUnit [_type,_position,[],0,"FORM"]; +_unit setSkill _skill; +if (_side != resistance) then { + if (paramTrackAI) then { + _unit setVehicleInit Format["[this,%1] ExecVM 'Common\Common_InitUnit.sqf';",_side]; + processInitCommands; + } else { + if (isPlayer leader _team) then {[_unit,_side] ExecVM 'Common\Common_InitUnit.sqf'}; + }; + Call Compile Format ["_unit addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}];",_side]; +} else { + //--- Note To be optimized, 1.03 BIS BUG, cannot add resistance side via call compile format. + _unit addEventHandler ['Killed',{[_this select 0,_this select 1,resistance] Spawn UnitKilled}]; +}; + +if (('WFBE_ISIS' Call GetNamespace) == 2) then {_unit addEventHandler['handleDamage',{_this Call ISIS_Wound}]}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%5 | ticktime:%6] Common_CreateUnit: A '%1' unit was created (position: %2) and has joined the %3 %4 Team",_type,_position,str _side,_team,diag_frameno,diag_tickTime]; + +_unit \ No newline at end of file diff --git a/Common/Functions/Common_CreateVehicle.sqf b/Common/Functions/Common_CreateVehicle.sqf new file mode 100644 index 0000000..b110416 --- /dev/null +++ b/Common/Functions/Common_CreateVehicle.sqf @@ -0,0 +1,20 @@ +Private ["_lock","_position","_side","_type","_vehicle"]; +_type = _this select 0; +_position = _this select 1; +_side = _this select 2; +_lock = _this select 3; + +_vehicle = _type createVehicle _position; +if (_side != resistance) then { + _vehicle SetVehicleInit Format["[this,%1] ExecVM 'Common\Common_InitUnit.sqf';",_side]; + ProcessInitCommands; + Call Compile Format ["_vehicle addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; +} else { + //--- Note To be optimized, 1.03 BIS BUG, cannot add resistance side via call compile format? which still isn't fixed in OA 1.59... + _vehicle addEventHandler ["Killed",{[_this select 0,_this select 1,resistance] Spawn UnitKilled}]; +}; +_vehicle lock _lock; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Common_CreateVehicle: A %1 '%2' vehicle has been created (position: %3)",str _side,_type,_position,diag_frameno,diag_tickTime]; + +_vehicle \ No newline at end of file diff --git a/Common/Functions/Common_EquipArtillery.sqf b/Common/Functions/Common_EquipArtillery.sqf new file mode 100644 index 0000000..fc1d315 --- /dev/null +++ b/Common/Functions/Common_EquipArtillery.sqf @@ -0,0 +1,19 @@ +Private ['_ammo','_currentUpgrades','_extMagUpgr','_i','_index','_side','_unit']; +_unit = _this select 0; +_index = _this select 1; +_side = _this select 2; + +//--- Browse for extended Mags (WP, SADARM... ) +_ammo = (Format['WFBE_%1_ARTILLERY_EXTENDED_MAGS',_side] Call GetNamespace) select _index; +if (count _ammo == 0) exitWith {}; + +_extMagUpgr = Format['WFBE_%1_ARTILLERY_EXTENDED_MAGS_UPGRD',_side] Call GetNamespace; + +//--- Retrieve the Artillery upgrade level. +_currentUpgrades = ((str _side) Call GetSideUpgrades) select 17; + +for [{_i = 0},{_i < count(_ammo)},{_i = _i + 1}] do { + if (_currentUpgrades >= ((_extMagUpgr select _index) select _i)) then { + _unit addMagazine (_ammo select _i); + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_EquipBackpack.sqf b/Common/Functions/Common_EquipBackpack.sqf new file mode 100644 index 0000000..27293ef --- /dev/null +++ b/Common/Functions/Common_EquipBackpack.sqf @@ -0,0 +1,9 @@ +private ["_bp","_bpItems"]; +_bp = _this select 0; +_bpItems = _this select 1; + +clearMagazineCargo _bp; + +for '_u' from 0 to count(_bpItems select 0)-1 do { + _bp addMagazineCargo [(_bpItems select 0) select _u, (_bpItems select 1) select _u]; +}; \ No newline at end of file diff --git a/Common/Functions/Common_EquipLoadout.sqf b/Common/Functions/Common_EquipLoadout.sqf new file mode 100644 index 0000000..d14b136 --- /dev/null +++ b/Common/Functions/Common_EquipLoadout.sqf @@ -0,0 +1,26 @@ +Private['_ammo','_unit','_use','_weapon','_weapons']; + +_unit = _this select 0; +_weapons = _this select 1; +_ammo = _this select 2; + +removeAllWeapons _unit; +removeAllItems _unit; + +{_unit addMagazine _x} forEach _ammo; +{_unit addWeapon _x} forEach _weapons; + +_use = primaryWeapon _unit; +if (_use == "") then { + Private ["_kind"]; + { + _kind = getNumber(configFile >> 'CfgWeapons' >> _x >> "type"); + if (_kind in [1,2,4,5]) exitWith {_use = _x}; + } forEach _weapons; +}; + +if (_use != "") then { + Private ["_muzzles"]; + _muzzles = getArray (configFile >> "CfgWeapons" >> _use >> "muzzles"); + if !("this" in _muzzles) then {_unit selectWeapon (_muzzles select 0)} else {_unit selectWeapon _use}; +}; \ No newline at end of file diff --git a/Common/Functions/Common_FireArtillery.sqf b/Common/Functions/Common_FireArtillery.sqf new file mode 100644 index 0000000..87a8367 --- /dev/null +++ b/Common/Functions/Common_FireArtillery.sqf @@ -0,0 +1,65 @@ +Private["_ammo","_angle","_artillery","_burst","_destination","_dispersion","_direction","_distance","_FEH","_gunner","_i","_index","_minRange","_maxRange","_position","_radius","_reloadTime","_side","_type","_velocity","_watchPosition","_weapon","_xcoord","_ycoord"]; + +_artillery = _this select 0; +_destination = _this select 1; +_side = _this select 2; +_radius = _this select 3; +_index = _this select 4; + +_gunner = gunner _artillery; +if (_index == -1) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Common_FireArtillery.sqf: No artillery types were found for '%1'.",_artillery,diag_frameno,diag_tickTime]}; +if (isNull _gunner) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Common_FireArtillery.sqf: Artillery '%1' gunner is null.",_artillery,diag_frameno,diag_tickTime]}; +if (isPlayer _gunner) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Common_FireArtillery.sqf: Artillery '%1' gunner is player.",_artillery,diag_frameno,diag_tickTime]}; + +_minRange = (Format ["WFBE_%1_ARTILLERY_MINRANGES",_side] Call GetNamespace) select _index; +_maxRange = (Format ["WFBE_%1_ARTILLERY_MAXRANGES",_side] Call GetNamespace) select _index; +_weapon = (Format ["WFBE_%1_ARTILLERY_WEAPONS",_side] Call GetNamespace) select _index; +_ammo = (Format ["WFBE_%1_ARTILLERY_AMMOS",_side] Call GetNamespace) select _index; +_velocity = (Format ["WFBE_%1_ARTILLERY_VELOCITIES",_side] Call GetNamespace) select _index; +_dispersion = (Format ["WFBE_%1_ARTILLERY_DISPERSIONS",_side] Call GetNamespace) select _index; + +//--- Move function to global later on. +if (local player) then {[_artillery] Call ARTY_Prep}; + +//--- Artillery Calculations. +_position = getPos _artillery; +_xcoord = (_destination select 0) - (_position select 0); +_ycoord = (_destination select 1) - (_position select 1); +_direction = -(((_ycoord atan2 _xcoord) + 270) % 360); +if (_direction < 0) then {_direction = _direction + 360}; +_distance = sqrt (((_xcoord ^ 2) + (_ycoord ^ 2))) - _minRange; +_angle = _distance / (_maxRange - _minRange) * 100 + 15; +if (_angle > 70) then {_angle = 70}; +if (_distance < 0 || _distance + _minRange > _maxRange) exitWith {}; + +_FEH = Call Compile Format ["_artillery addEventHandler ['Fired',{[_this select 4,_this select 6,%1,%2,%3,%4,%5,%6,%7,%8,%9] Spawn HandleArtillery}];",_ammo,_destination,_velocity,_dispersion,getPos _artillery,_distance,_radius,_maxRange,sideJoinedText]; + +{_gunner disableAI _x} forEach ['ANIM','MOVE','TARGET','AUTOTARGET']; +_watchPosition = [_destination select 0, _destination select 1, (_artillery distance _destination)/(tan(90-_angle))]; +(_gunner) doWatch _watchPosition; + +sleep 10; +if !(alive (_gunner)) exitWith {if !(isNull _artillery) then {_artillery removeEventHandler ['Fired',_FEH]}}; +if !(alive _artillery) exitWith { + if (alive (_gunner)) then {{_gunner enableAI _x} forEach ['ANIM','MOVE','TARGET','AUTOTARGET']}; +}; + +_reloadTime = (Format ["WFBE_%1_ARTILLERY_RELOADTIME",_side] Call GetNamespace) select _index; +_burst = (Format ["WFBE_%1_ARTILLERY_BURST",_side] Call GetNamespace) select _index; + +for [{_i = 0},{_i < _burst},{_i = _i + 1}] do { + sleep _reloadTime; + if (!alive (_gunner) || !alive _artillery) exitWith {}; + + _artillery fire _weapon; +}; + +sleep 1; + +if !(isNull _artillery) then {_artillery removeEventHandler ['Fired',_FEH]}; + +sleep _reloadTime; + +if (alive (_gunner)) then {{_gunner enableAI _x} forEach ['ANIM','MOVE','TARGET','AUTOTARGET']}; + +if (local player) then {[_artillery] Call ARTY_Finish}; \ No newline at end of file diff --git a/Common/Functions/Common_GetAIDigit.sqf b/Common/Functions/Common_GetAIDigit.sqf new file mode 100644 index 0000000..935b372 --- /dev/null +++ b/Common/Functions/Common_GetAIDigit.sqf @@ -0,0 +1,21 @@ +Private ["_i","_split","_unit","_yield"]; + +_unit = _this; + +if (_unit == leader (group _unit)) exitWith {"Leader"}; + +_split = toArray(str _unit); + +_find = _split find 58; +_yield = []; + +if (_find != -1) then { + for '_i' from (_find+1) to count(_split)-1 do { + if ((_split select _i) == 65 || (_split select _i) == 32) exitWith {}; + _yield = _yield + [_split select _i]; + }; +}; + +if (count _yield == 0) exitWith {"0"}; + +toString(_yield) \ No newline at end of file diff --git a/Common/Functions/Common_GetClientID.sqf b/Common/Functions/Common_GetClientID.sqf new file mode 100644 index 0000000..54fc0c3 --- /dev/null +++ b/Common/Functions/Common_GetClientID.sqf @@ -0,0 +1,6 @@ +Private["_index"]; + +_index = ('WFBE_EASTSLOTNAMES' Call GetNamespace) find (vehicleVarName _this); +if (_index < 0) then {_index = ('WFBE_WESTSLOTNAMES' Call GetNamespace) find (vehicleVarName _this)}; + +_index + 1 \ No newline at end of file diff --git a/Common/Functions/Common_GetClientIDFromTeam.sqf b/Common/Functions/Common_GetClientIDFromTeam.sqf new file mode 100644 index 0000000..dd732a7 --- /dev/null +++ b/Common/Functions/Common_GetClientIDFromTeam.sqf @@ -0,0 +1,11 @@ +Private ['_index','_team']; + +_team = _this; + +if (isNil '_team') exitWith {0}; +if (isNull _team) exitWith {0}; + +_index = (Format["WFBE_%1TEAMS",str (side _team)] Call GetNamespace) find _team; +if (_index < 0) exitWith {0}; + +_index+1 \ No newline at end of file diff --git a/Common/Functions/Common_GetClientTeam.sqf b/Common/Functions/Common_GetClientTeam.sqf new file mode 100644 index 0000000..3212017 --- /dev/null +++ b/Common/Functions/Common_GetClientTeam.sqf @@ -0,0 +1,7 @@ +Private["_ID","_side","_team"]; + +_side = _this Select 0; +_ID = _this Select 1; + +_team = ((Format["WFBE_%1TEAMS",str _side]) Call GetNamespace) select (_ID - 1); +_team \ No newline at end of file diff --git a/Common/Functions/Common_GetClosestLocation.sqf b/Common/Functions/Common_GetClosestLocation.sqf new file mode 100644 index 0000000..63b6c59 --- /dev/null +++ b/Common/Functions/Common_GetClosestLocation.sqf @@ -0,0 +1,5 @@ +Private["_object"]; + +_object = _this select 0; + +([_object,towns] Call SortByDistance) select 0; \ No newline at end of file diff --git a/Common/Functions/Common_GetClosestLocationBySide.sqf b/Common/Functions/Common_GetClosestLocationBySide.sqf new file mode 100644 index 0000000..ec76f29 --- /dev/null +++ b/Common/Functions/Common_GetClosestLocationBySide.sqf @@ -0,0 +1,21 @@ +Private["_enemyTowns","_object","_nearest","_side"]; + +_object = _this select 0; +_side = _this select 1; +_cvar = if (count _this > 2) then {_this select 2} else {""}; + +_enemyTowns = towns - ((_side) Call GetSideTowns); +_nearest = objNull; + +if (count _enemyTowns > 0) then { + _nearests = [_object,_enemyTowns] Call SortByDistance; + if (_cvar != "") then { + for '_i' from 0 to count(_nearests)-1 do { + if ((_nearests select _i) getVariable _cvar) exitWith{_nearest = (_nearests select _i)}; + }; + } else { + _nearest = _nearests select 0; + } +}; + +_nearest \ No newline at end of file diff --git a/Common/Functions/Common_GetCommanderFromVotes.sqf b/Common/Functions/Common_GetCommanderFromVotes.sqf new file mode 100644 index 0000000..c0210f6 --- /dev/null +++ b/Common/Functions/Common_GetCommanderFromVotes.sqf @@ -0,0 +1,36 @@ +Private["_AI","_commander","_count","_highest","_highestTeam","_side","_teams","_tie","_total","_vote","_votes"]; + +_side = _this Select 0; + +_AI = 0; +_teams = (Format["WFBE_%1TEAMS",str _side] Call GetNamespace); +_total = Count _teams; + +_votes = []; +for [{_count = 0},{_count < _total},{_count = _count + 1}] do {_votes = _votes + [0]}; + +//Count votes. +for [{_count = 0},{_count < _total},{_count = _count + 1}] do { + if (isPlayer (leader (_teams Select _count))) then { + _vote = Call Compile Format ["%1Team%2Vote",Str _side,_count + 1]; + if (_vote != -1) then { + _votes Set[_vote,(_votes Select _vote) + 1]; + } else { + _AI = _AI + 1; + }; + }; +}; + +_count = 0; +_highest = 0; +_highestTeam = -1; +_tie = false; +{if (_x == _highest && _x > 0) then {_tie = true};if (_x > _highest) then {_highestTeam = _count;_highest = _x;_tie = false};_count = _count + 1} ForEach _votes; + +_commander = ObjNull; + +if (!_tie && _highest > _AI && _highestTeam != -1) then { + _commander = _teams select _highestTeam; +}; + +_commander \ No newline at end of file diff --git a/Common/Functions/Common_GetCommanderTeam.sqf b/Common/Functions/Common_GetCommanderTeam.sqf new file mode 100644 index 0000000..7de4fec --- /dev/null +++ b/Common/Functions/Common_GetCommanderTeam.sqf @@ -0,0 +1,7 @@ +Private ["_cmdrTeam","_side"]; +_side = _this; + +_cmdrTeam = WF_Logic getVariable Format ["%1CommanderTeam",str _side]; +if (isNil "_cmdrTeam") then {_cmdrTeam = objNull}; + +_cmdrTeam \ No newline at end of file diff --git a/Common/Functions/Common_GetCommanderVotes.sqf b/Common/Functions/Common_GetCommanderVotes.sqf new file mode 100644 index 0000000..054f363 --- /dev/null +++ b/Common/Functions/Common_GetCommanderVotes.sqf @@ -0,0 +1,19 @@ +Private["_count","_side","_teams","_total","_vote","_votes"]; + +_side = _this Select 0; + +_teams = (Format["WFBE_%1TEAMS",str _side] Call GetNamespace); +_total = Count _teams + 1; + +_votes = []; +for [{_count = 0},{_count < _total},{_count = _count + 1}] do {_votes = _votes + [0]}; + +//Count votes. +for [{_count = 1},{_count < _total},{_count = _count + 1}] do { + if (isPlayer (leader (_teams Select (_count - 1)))) then { + _vote = (Call Compile Format ["%1Team%2Vote",Str _side,_count]) + 1; + _votes Set[_vote,(_votes Select _vote) + 1]; + }; +}; + +_votes diff --git a/Common/Functions/Common_GetConfigInfo.sqf b/Common/Functions/Common_GetConfigInfo.sqf new file mode 100644 index 0000000..ce83cad --- /dev/null +++ b/Common/Functions/Common_GetConfigInfo.sqf @@ -0,0 +1,8 @@ +Private ['_element','_from','_object']; +_object = _this select 0; +_element = _this select 1; +_from = if (count _this > 2) then {_this select 2} else {'CfgVehicles'}; + +if (typeName _object == 'OBJECT') then {_object = typeOf(_object)}; + +getText (configFile >> _from >> _object >> _element) \ No newline at end of file diff --git a/Common/Functions/Common_GetConfigVehicleCrewSlot.sqf b/Common/Functions/Common_GetConfigVehicleCrewSlot.sqf new file mode 100644 index 0000000..6039ff7 --- /dev/null +++ b/Common/Functions/Common_GetConfigVehicleCrewSlot.sqf @@ -0,0 +1,21 @@ +/* Adapted from BIS turret's function. */ +private ['_entry','_turrestcount','_turrets']; +_entry = configFile >> 'CfgVehicles' >> _this >> 'Turrets'; + +vhasCommander = false; +vhasGunner = false; +_turrets = [_entry] Call Compile preprocessFile "Common\Functions\Common_GetConfigVehicleTurretsReturn.sqf"; + +tmp_overall = []; + +if (count _turrets > 0) then { + [_turrets, []] Call Compile preprocessFile "Common\Functions\Common_GetConfigVehicleTurrets.sqf"; +}; + +_turrestcount = count(tmp_overall); +if (vhasGunner) then {_turrestcount = _turrestcount - 1}; +if (vhasCommander) then {_turrestcount = _turrestcount - 1}; + +// diag_log format ["%1 %2",_entry,tmp_overall]; + +[[vhasCommander,vhasGunner,count(tmp_overall)+1,_turrestcount], tmp_overall] \ No newline at end of file diff --git a/Common/Functions/Common_GetConfigVehicleTurrets.sqf b/Common/Functions/Common_GetConfigVehicleTurrets.sqf new file mode 100644 index 0000000..f060f7a --- /dev/null +++ b/Common/Functions/Common_GetConfigVehicleTurrets.sqf @@ -0,0 +1,16 @@ +private ["_turrets", "_i", "_path"]; +_turrets = _this select 0; +_path = _this select 1; +_i = 0; + +while {_i < (count _turrets)} do { + private ["_turretIndex", "_thisTurret"]; + _turretIndex = _turrets select _i; + _thisTurret = _path + [_turretIndex]; + + tmp_overall = tmp_overall + [_thisTurret]; + + [([_turrets select (_i + 1), _thisTurret] Call Compile preprocessFile "Common\Functions\Common_GetConfigVehicleTurrets.sqf")]; + + _i = _i + 2; +}; \ No newline at end of file diff --git a/Common/Functions/Common_GetConfigVehicleTurretsReturn.sqf b/Common/Functions/Common_GetConfigVehicleTurretsReturn.sqf new file mode 100644 index 0000000..c0901d5 --- /dev/null +++ b/Common/Functions/Common_GetConfigVehicleTurretsReturn.sqf @@ -0,0 +1,54 @@ +if ((count _this) < 1) exitWith {debugLog "Log: [returnVehicleTurrets] Function requires at least 1 parameter!"; []}; + +private ["_entry"]; +_entry = _this select 0; + +//Validate parameters +if ((typeName _entry) != (typeName configFile)) exitWith {debugLog "Log: [returnVehicleTurrets] Entry (0) must be a Config!"; []}; + +private ["_turrets", "_turretIndex"]; +_turrets = []; +_turretIndex = 0; + +//Explore all turrets and sub-turrets recursively. +for "_i" from 0 to ((count _entry) - 1) do +{ + private ["_subEntry"]; + _subEntry = _entry select _i; + + if (isClass _subEntry) then + { + private ["_hasGunner","_isset","_pcom","_pgun"]; + _hasGunner = [_subEntry, "hasGunner"] Call BIS_fnc_returnConfigEntry; + + _pgun = [_subEntry, "primaryGunner"] Call BIS_fnc_returnConfigEntry; + _pcom = [_subEntry, "primaryObserver"] Call BIS_fnc_returnConfigEntry; + + _isset = false; + if (_pgun == 1 && !vhasGunner) then {vhasGunner = true;_isset = true}; + if (_pcom == 1 && !vhasCommander && !_isset) then {vhasCommander = true}; + + //Make sure the entry was found. + if !(isNil "_hasGunner") then + { + if (_hasGunner == 1) then + { + _turrets = _turrets + [_turretIndex]; + + //Include sub-turrets, if present. + if (isClass (_subEntry >> "Turrets")) then + { + _turrets = _turrets + [[_subEntry >> "Turrets"] Call Compile preprocessFile "Common\Functions\Common_GetConfigVehicleTurretsReturn.sqf"]; + } + else + { + _turrets = _turrets + [[]]; + }; + }; + }; + + _turretIndex = _turretIndex + 1; + }; +}; + +_turrets \ No newline at end of file diff --git a/Common/Functions/Common_GetFactories.sqf b/Common/Functions/Common_GetFactories.sqf new file mode 100644 index 0000000..39c7ffc --- /dev/null +++ b/Common/Functions/Common_GetFactories.sqf @@ -0,0 +1,10 @@ +Private ["_buildings","_kind","_list","_side","_type"]; +_side = _this select 0; +_kind = _this select 1; +_buildings = _this select 2; + +_list = []; +_type = (Format["WFBE_%1STRUCTURENAMES",str _side] Call GetNamespace) select _kind; +{if (typeOf _x == _type && alive _x) then {_list = _list + [_x]}} forEach _buildings; + +_list \ No newline at end of file diff --git a/Common/Functions/Common_GetFriendlyCamps.sqf b/Common/Functions/Common_GetFriendlyCamps.sqf new file mode 100644 index 0000000..cebe329 --- /dev/null +++ b/Common/Functions/Common_GetFriendlyCamps.sqf @@ -0,0 +1,14 @@ +private ["_camps","_friendlyCamps","_side","_sideID","_town"]; + +_town = _this Select 0; +_side = _this Select 1; + +_sideID = _side Call GetSideID; +_camps = _town getVariable "camps"; +_friendlyCamps = []; + +{ + if ((_x getVariable "sideID") == _sideID) then {_friendlyCamps = _friendlyCamps + [_x]}; +} forEach _camps; + +_friendlyCamps \ No newline at end of file diff --git a/Common/Functions/Common_GetGroupFromConfig.sqf b/Common/Functions/Common_GetGroupFromConfig.sqf new file mode 100644 index 0000000..5427057 --- /dev/null +++ b/Common/Functions/Common_GetGroupFromConfig.sqf @@ -0,0 +1,23 @@ +Private ['_config','_faction','_group','_kind','_side','_type']; +_side = _this select 0; +_faction = _this select 1; +_kind = _this select 2; +_type = _this select 3; + +_config = configFile >> "CfgGroups" >> _side >> _faction >> _kind >> _type; +_group = []; + +if (isClass _config) then { + for "_j" from 0 to ((count _config) - 1) do { + private ["_mclass"]; + _mclass = _config select _j; + + if (isClass (_mclass)) then { + _group = _group + [getText(_mclass >> "vehicle")]; + }; + }; +} else { + diag_log Format ["[WFBE (ERROR)][frameno:%1 | ticktime:%2] Common_GetGroupFromConfig: Entry (configFile >> 'CfgGroups' >> '%3' >> '%4' >> '%5' >> '%6') is not a valid group config.",diag_frameno,diag_tickTime,_side,_faction,_kind,_type]; +}; + +_group \ No newline at end of file diff --git a/Common/Functions/Common_GetHostilesInArea.sqf b/Common/Functions/Common_GetHostilesInArea.sqf new file mode 100644 index 0000000..eef2647 --- /dev/null +++ b/Common/Functions/Common_GetHostilesInArea.sqf @@ -0,0 +1,18 @@ +Private ['_hostiles','_object','_objects','_safeFromSide','_within']; +_object = _this select 0; +_safeFromSide = _this select 1; +_within = if (count _this > 2) then {_this select 2} else {50}; + +_objects = _object nearEntities[[eastSoldierBaseClass,westSoldierBaseClass,resistanceSoldierBaseClass,"Car","Motorcycle","Tank","Air"],_within]; +_hostiles = 0; + +if (typeName _safeFromSide == 'ARRAY') then { + { + _hostiles = _hostiles + (_x countSide _objects); + } forEach _safeFromSide; +}; +if (typeName _safeFromSide == 'SIDE') then { + _hostiles = _hostiles + (_safeFromSide countSide _objects); +}; + +_hostiles \ No newline at end of file diff --git a/Common/Functions/Common_GetLiveUnits.sqf b/Common/Functions/Common_GetLiveUnits.sqf new file mode 100644 index 0000000..5909c82 --- /dev/null +++ b/Common/Functions/Common_GetLiveUnits.sqf @@ -0,0 +1,8 @@ +Private["_liveUnits","_units"]; + +_units = _this; + +_liveUnits = []; + +{if (alive _x) then {_liveUnits = _liveUnits + [_x]}} forEach _units; +_liveUnits diff --git a/Common/Functions/Common_GetNameSpace.sqf b/Common/Functions/Common_GetNameSpace.sqf new file mode 100644 index 0000000..589da00 --- /dev/null +++ b/Common/Functions/Common_GetNameSpace.sqf @@ -0,0 +1,5 @@ +Private ['_variable']; + +_variable = _this; + +missionNamespace getVariable _variable \ No newline at end of file diff --git a/Common/Functions/Common_GetPositionFrom.sqf b/Common/Functions/Common_GetPositionFrom.sqf new file mode 100644 index 0000000..a695b6b --- /dev/null +++ b/Common/Functions/Common_GetPositionFrom.sqf @@ -0,0 +1,11 @@ +private ["_distance","_direction","_position"]; + +_position = _this Select 0; +if (TypeName _position != "ARRAY") then {_position = Position _position}; + +_distance = _this Select 1; + +_direction = _this Select 2; +if (TypeName _direction != "SCALAR") then {_direction = [_position,_direction] Call GetDirTo}; + +[(_position Select 0)+((sin _direction)*_distance),(_position Select 1)+((cos _direction)*_distance),(_position Select 2)] \ No newline at end of file diff --git a/Common/Functions/Common_GetRandomPosition.sqf b/Common/Functions/Common_GetRandomPosition.sqf new file mode 100644 index 0000000..a5e41ea --- /dev/null +++ b/Common/Functions/Common_GetRandomPosition.sqf @@ -0,0 +1,12 @@ +Private["_position","_radius","_direction","_maxRadius","_minRadius"]; + +_position = _this select 0; +_minRadius = _this select 1; +_maxRadius = _this select 2; +_direction = random 360; + +_radius = (random (_maxRadius - _minRadius)) + _minRadius; +_position = [(_position select 0)+((sin _direction)*_radius),(_position select 1)+((cos _direction)*_radius),(_position select 2)]; +while {surfaceIsWater _position}do {_direction = random 360;_radius = (random (_maxRadius - _minRadius)) + _minRadius;_position = [(_position select 0)+((sin _direction)*_radius),(_position select 1)+((cos _direction)*_radius),(_position select 2)]}; + +_position \ No newline at end of file diff --git a/Common/Functions/Common_GetRespawnCamps.sqf b/Common/Functions/Common_GetRespawnCamps.sqf new file mode 100644 index 0000000..4c8f2ed --- /dev/null +++ b/Common/Functions/Common_GetRespawnCamps.sqf @@ -0,0 +1,14 @@ +Private ['_availableSpawn','_camps','_closestCamp','_deathLoc','_enemySide','_get','_hostiles','_nearestCamps','_respawnCampsMode','_respawnCampsRuleMode','_respawnMinRange','_side','_town','_townSID'],; _deathLoc = _this select 0; +_side = _this select 1; +_availableSpawn = []; +_respawnCampsMode = 'WFBE_RESPAWNCAMPSMODE' Call GetNamespace; +_respawnCampsRuleMode = 'WFBE_RESPAWNCAMPSRULEMODE' Call GetNamespace; +_respawnMinRange = 'WFBE_RESPAWNMINRANGE' Call GetNamespace; + + switch (_respawnCampsMode) do { case 1: { /* Classic Respawn */ _town = [_deathLoc] Call GetClosestLocation; if !(isNull _town) then { if (_town distance _deathLoc < ('WFBE_RESPAWNRANGE' Call GetNamespace)) then { _camps = [_town,_side] Call GetFriendlyCamps; if (count _camps > 0) then { if (_respawnCampsRuleMode > 0) then { _closestCamp = ([_deathLoc,_camps] Call SortByDistance) select 0; _enemySide = if (_side == west) then {[east]} else {[west]}; if (_respawnCampsRuleMode == 2) then {_enemySide = _enemySide + [resistance]}; _hostiles = [_closestCamp,_enemySide,_respawnMinRange] Call GetHostilesInArea; if (_deathLoc distance _closestCamp < _respawnMinRange && _hostiles > 0) then {_camps = _camps - [_closestCamp]}; }; _availableSpawn = _availableSpawn + _camps; }; }; + }; + }; + case 2: { /* Enhanced Respawn - Get the camps around the unit */ _nearestCamps = nearestObjects [_deathLoc, WFCAMP, ('WFBE_RESPAWNRANGE' Call GetNamespace)]; { _get = _x getVariable 'sideID'; if !(isNil '_get') then { if ((_side Call GetSideID) == _get) then { if (_respawnCampsRuleMode > 0) then { if (_deathLoc distance _x < _respawnMinRange) then { _enemySide = if (_side == west) then {[east]} else {[west]}; if (_respawnCampsRuleMode == 2) then {_enemySide = _enemySide + [resistance]}; _hostiles = [_x,_enemySide,_respawnMinRange] Call GetHostilesInArea; if (_hostiles == 0) then {_availableSpawn = _availableSpawn + [_x]}; } else { _availableSpawn = _availableSpawn + [_x]; }; } else { _availableSpawn = _availableSpawn + [_x]; }; }; }; } forEach _nearestCamps; }; case 3: { /* Defender Only Respawn - Get the camps around the unit only if the town is friendly to the unit. */ _nearestCamps = nearestObjects [_deathLoc, WFCAMP, ('WFBE_RESPAWNRANGE' Call GetNamespace)]; { _get = _x getVariable 'sideID'; if !(isNil '_get') then { _town = _x getVariable 'town'; _townSID = _town getVariable 'sideID'; if ((_side Call GetSideID) == _townSID && _get == _townSID) then { + if (_respawnCampsRuleMode > 0) then { if (_deathLoc distance _x < _respawnMinRange) then { _enemySide = if (_side == west) then {[east]} else {[west]}; if (_respawnCampsRuleMode == 2) then {_enemySide = _enemySide + [resistance]}; _hostiles = [_x,_enemySide,_respawnMinRange] Call GetHostilesInArea; if (_hostiles == 0) then {_availableSpawn = _availableSpawn + [_x]}; } else { _availableSpawn = _availableSpawn + [_x]; }; } else { _availableSpawn = _availableSpawn + [_x]; }; }; }; } forEach _nearestCamps; }; }; + +/* Return the available camps */ _availableSpawn \ No newline at end of file diff --git a/Common/Functions/Common_GetSafePlace.sqf b/Common/Functions/Common_GetSafePlace.sqf new file mode 100644 index 0000000..fe0024c --- /dev/null +++ b/Common/Functions/Common_GetSafePlace.sqf @@ -0,0 +1,27 @@ +Private["_count","_currentPosition","_direction","_obstacles","_placed","_position","_radius","_retPos","_vehicles"]; +scopeName "PlaceSafe"; + +_position = _this select 0; +_radius = if (count _this > 1) then {_this select 1} else {35}; +_retPos = []; + +_currentPosition = _position; +_placed = false; +_direction = 0; + +for [{_count = 0},{_count < 30 && !_placed},{_count = _count + 1}] do { + _obstacles = nearestObjects [_currentPosition, ["Building"], 15]; + _vehicles = _currentPosition nearEntities [["Building","Car","Tank","Air"], 7]; + + if (count _obstacles > 0 || count _vehicles > 0 || surfaceIsWater _currentPosition) then { + _currentPosition = [(_position select 0)+((sin _direction)*_radius),(_position select 1)+((cos _direction)*_radius),0]; + _direction = _direction + 36; + if (_count > 15) then {_radius = _radius + 25}; + } else { + _retPos = _currentPosition; + _placed = true; + breakTo "PlaceSafe"; + }; +}; + +_retPos \ No newline at end of file diff --git a/Common/Functions/Common_GetSideFromID.sqf b/Common/Functions/Common_GetSideFromID.sqf new file mode 100644 index 0000000..3d549b7 --- /dev/null +++ b/Common/Functions/Common_GetSideFromID.sqf @@ -0,0 +1,7 @@ +Private["_side"]; + +_side = Resistance; +if (_this == EASTID) then {_side = East}; +if (_this == WESTID) then {_side = West}; + +_side \ No newline at end of file diff --git a/Common/Functions/Common_GetSideHQ.sqf b/Common/Functions/Common_GetSideHQ.sqf new file mode 100644 index 0000000..6c1fab8 --- /dev/null +++ b/Common/Functions/Common_GetSideHQ.sqf @@ -0,0 +1 @@ +Call Compile Format ["%1MHQ",_this] \ No newline at end of file diff --git a/Common/Functions/Common_GetSideHQDeployed.sqf b/Common/Functions/Common_GetSideHQDeployed.sqf new file mode 100644 index 0000000..9b06dbd --- /dev/null +++ b/Common/Functions/Common_GetSideHQDeployed.sqf @@ -0,0 +1 @@ +Call Compile Format ["%1MHQDeployed",_this] \ No newline at end of file diff --git a/Common/Functions/Common_GetSideID.sqf b/Common/Functions/Common_GetSideID.sqf new file mode 100644 index 0000000..a7b2053 --- /dev/null +++ b/Common/Functions/Common_GetSideID.sqf @@ -0,0 +1,7 @@ +Private["_ID"]; + +_ID = RESISTANCEID; +if (_this == east) then {_ID = EASTID}; +if (_this == west) then {_ID = WESTID}; + +_ID \ No newline at end of file diff --git a/Common/Functions/Common_GetSideStructures.sqf b/Common/Functions/Common_GetSideStructures.sqf new file mode 100644 index 0000000..50a503f --- /dev/null +++ b/Common/Functions/Common_GetSideStructures.sqf @@ -0,0 +1 @@ +Call Compile Format ["%1BaseStructures",_this] \ No newline at end of file diff --git a/Common/Functions/Common_GetSideSupply.sqf b/Common/Functions/Common_GetSideSupply.sqf new file mode 100644 index 0000000..a23b240 --- /dev/null +++ b/Common/Functions/Common_GetSideSupply.sqf @@ -0,0 +1 @@ +WF_Logic getVariable Format["%1Supplies",_this] \ No newline at end of file diff --git a/Common/Functions/Common_GetSideTowns.sqf b/Common/Functions/Common_GetSideTowns.sqf new file mode 100644 index 0000000..211ce4c --- /dev/null +++ b/Common/Functions/Common_GetSideTowns.sqf @@ -0,0 +1,10 @@ +Private ['_sideID','_towns']; + +_sideID = (_this) Call GetSideID; +_towns = []; + +{ + if ((_x getVariable 'sideID') == _sideID) then {_towns = _towns + [_x]}; +} forEach towns; + +_towns \ No newline at end of file diff --git a/Common/Functions/Common_GetSideUpgrades.sqf b/Common/Functions/Common_GetSideUpgrades.sqf new file mode 100644 index 0000000..dab2428 --- /dev/null +++ b/Common/Functions/Common_GetSideUpgrades.sqf @@ -0,0 +1 @@ +Call Compile Format ["%1Upgrades",_this] \ No newline at end of file diff --git a/Common/Functions/Common_GetSleepFPS.sqf b/Common/Functions/Common_GetSleepFPS.sqf new file mode 100644 index 0000000..82b5bc4 --- /dev/null +++ b/Common/Functions/Common_GetSleepFPS.sqf @@ -0,0 +1,11 @@ +Private ["_delay"]; + +_delay = _this; + +if (diag_fps > 15) exitWith {_delay}; +if (diag_fps <= 15 && diag_fps > 10) exitWith {_delay * 0.85}; +if (diag_fps <= 10 && diag_fps > 7) exitWith {_delay * 0.75}; +if (diag_fps <= 7 && diag_fps > 5) exitWith {_delay * 0.70}; +if (diag_fps <= 5) exitWith {_delay * 0.50}; + +_delay \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamArtillery.sqf b/Common/Functions/Common_GetTeamArtillery.sqf new file mode 100644 index 0000000..3bc97d7 --- /dev/null +++ b/Common/Functions/Common_GetTeamArtillery.sqf @@ -0,0 +1,32 @@ +Private["_artillery","_artyTypes","_artyWeapons","_count","_ignoreAmmo","_index","_position","_search","_side","_team","_units","_vehicle","_weapon","_x","_y"]; + +_team = _this select 0; +_ignoreAmmo = _this select 1; +_index = _this select 2; +_side = _this select 3; + +if (_index < 0) exitWith {[]}; + +_units = units _team; +_artyTypes = (Format ["WFBE_%1_ARTILLERY_NAMES",_side] Call GetNamespace) select _index; +_artyWeapons = Format ["WFBE_%1_ARTILLERY_WEAPONS",_side] Call GetNamespace; + +_artillery = []; + +{ + _vehicle = vehicle _x; + + if (typeOf(_vehicle) in _artyTypes) then { + if (!(isNull(gunner _vehicle)) && !(_vehicle in _artillery) && !(isPlayer(gunner _vehicle))) then { + if !(isPlayer(gunner _vehicle)) then { + _weapon = _artyWeapons select _index; + + if (_ignoreAmmo || (_vehicle ammo _weapon > 0)) then { + _artillery = _artillery + [_vehicle]; + }; + }; + }; + }; +} forEach _units; + +_artillery \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamAutonomous.sqf b/Common/Functions/Common_GetTeamAutonomous.sqf new file mode 100644 index 0000000..9c14c75 --- /dev/null +++ b/Common/Functions/Common_GetTeamAutonomous.sqf @@ -0,0 +1,3 @@ +if (isNull _this) exitWith {false}; + +Call Compile Format ["%1Autonomous",_this getVariable 'identification'] \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamFunds.sqf b/Common/Functions/Common_GetTeamFunds.sqf new file mode 100644 index 0000000..a203147 --- /dev/null +++ b/Common/Functions/Common_GetTeamFunds.sqf @@ -0,0 +1,7 @@ +Private ["_funds"]; + +if (isNull _this) exitWith {0}; + +_funds = Call Compile Format ["%1Funds",_this getVariable 'identification']; +if (isNil '_funds') exitWith {0}; +_funds \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamMoveMode.sqf b/Common/Functions/Common_GetTeamMoveMode.sqf new file mode 100644 index 0000000..5860877 --- /dev/null +++ b/Common/Functions/Common_GetTeamMoveMode.sqf @@ -0,0 +1,3 @@ +if (isNull _this) exitWith {"towns"}; + +Call Compile Format ["%1MoveMode",_this getVariable 'identification'] \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamMovePos.sqf b/Common/Functions/Common_GetTeamMovePos.sqf new file mode 100644 index 0000000..c54ea5e --- /dev/null +++ b/Common/Functions/Common_GetTeamMovePos.sqf @@ -0,0 +1,3 @@ +if (isNull _this) exitWith {[0,0,0]}; + +Call Compile Format ["%1MovePos",_this getVariable 'identification'] \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamRespawn.sqf b/Common/Functions/Common_GetTeamRespawn.sqf new file mode 100644 index 0000000..4625e2a --- /dev/null +++ b/Common/Functions/Common_GetTeamRespawn.sqf @@ -0,0 +1,3 @@ +if (isNull _this) exitWith {""}; + +Call Compile Format ["%1Respawn",_this getVariable 'identification'] \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamType.sqf b/Common/Functions/Common_GetTeamType.sqf new file mode 100644 index 0000000..66932c1 --- /dev/null +++ b/Common/Functions/Common_GetTeamType.sqf @@ -0,0 +1,3 @@ +if (isNull _this) exitWith {0}; + +Call Compile Format ["%1Types",_this getVariable 'identification'] \ No newline at end of file diff --git a/Common/Functions/Common_GetTeamVehicles.sqf b/Common/Functions/Common_GetTeamVehicles.sqf new file mode 100644 index 0000000..713fe89 --- /dev/null +++ b/Common/Functions/Common_GetTeamVehicles.sqf @@ -0,0 +1,30 @@ +private ["_canMove","_crew","_ignoreOwnerConflict","_member","_ownerConflict","_range","_team","_teamVehicles","_units","_vehicle"]; + +_team = _this select 0; +_canMove = _this select 1; + +_member = objNull; +_range = 150; +if (count _this > 2) then {_member = _this select 2}; +if (count _this > 3) then {_range = _this select 3}; + +_ignoreOwnerConflict = false; +if (count _this > 4) then {_ignoreOwnerConflict = _this select 4}; + +_teamVehicles = []; +_units = units _team; + + { + _vehicle = vehicle _x; + + if (_x != _vehicle && !(_vehicle in _teamVehicles)) then {_teamVehicles = _teamVehicles + [_vehicle]}; + if (_canMove && !canMove _vehicle) then {_teamVehicles = _teamVehicles - [_vehicle]}; + if (!IsNull _member && _member distance _vehicle > _range) then {_teamVehicles = _teamVehicles - [_vehicle]}; + + _ownerConflict = false; + _crew = crew _vehicle; + {if (_x != leader _team && isPlayer _x) then {_ownerConflict = true}} forEach _crew; + if (!_ignoreOwnerConflict && _ownerConflict) then {_teamVehicles = _teamVehicles - [_vehicle]}; + } forEach _units; + +_teamVehicles \ No newline at end of file diff --git a/Common/Functions/Common_GetTotalCamps.sqf b/Common/Functions/Common_GetTotalCamps.sqf new file mode 100644 index 0000000..407dbf6 --- /dev/null +++ b/Common/Functions/Common_GetTotalCamps.sqf @@ -0,0 +1,7 @@ +Private ['_camps']; + +_camps = _this getVariable "camps"; +if (isNil '_camps') exitWith {1}; +if (count _camps == 0) exitWith {1}; + +count _camps \ No newline at end of file diff --git a/Common/Functions/Common_GetTotalCampsOnSide.sqf b/Common/Functions/Common_GetTotalCampsOnSide.sqf new file mode 100644 index 0000000..10619dc --- /dev/null +++ b/Common/Functions/Common_GetTotalCampsOnSide.sqf @@ -0,0 +1,15 @@ +Private["_camps","_side","_sideID","_total","_town"]; + +_town = _this select 0; +_side = _this select 1; + +_sideID = _side Call GetSideID; + +_camps = _town getVariable "camps"; +if (isNil '_camps') exitWith {1}; +if (count _camps == 0) exitWith {1}; +_total = 0; + +{if ((_x getVariable "sideID") == _sideID) then {_total = _total + 1}} forEach _camps; + +_total \ No newline at end of file diff --git a/Common/Functions/Common_GetTotalSupplyValue.sqf b/Common/Functions/Common_GetTotalSupplyValue.sqf new file mode 100644 index 0000000..2504011 --- /dev/null +++ b/Common/Functions/Common_GetTotalSupplyValue.sqf @@ -0,0 +1,13 @@ +Private["_side","_sideID","_totalSupply"]; + +_side = _this; +_sideID = _side Call GetSideID; +_totalSupply = 0; + +{ + if ((_x getVariable "sideID") == _sideID) then { + _totalSupply = _totalSupply + (_x getVariable "supplyValue"); + }; +} forEach towns; + +_totalSupply \ No newline at end of file diff --git a/Common/Functions/Common_GetTownsHeld.sqf b/Common/Functions/Common_GetTownsHeld.sqf new file mode 100644 index 0000000..e992252 --- /dev/null +++ b/Common/Functions/Common_GetTownsHeld.sqf @@ -0,0 +1,8 @@ +private ["_held","_sideID"]; + +_held = 0; +_sideID = _this Call GetSideID; + +{if ((_x getVariable 'sideID') == _sideID) then {_held = _held + 1}} forEach towns; + +_held \ No newline at end of file diff --git a/Common/Functions/Common_GetTownsIncome.sqf b/Common/Functions/Common_GetTownsIncome.sqf new file mode 100644 index 0000000..df5bf43 --- /dev/null +++ b/Common/Functions/Common_GetTownsIncome.sqf @@ -0,0 +1,18 @@ +Private ["_income","_incomeCoef","_incomeSystem","_side"]; +_side = (_this) Call GetSideID; + +_income = 0; +_incomeSystem = 'WFBE_INCOMESYSTEM' Call GetNamespace; +_incomeCoef = 0; +if (_incomeSystem == 3) then {_incomeCoef = 'WFBE_INC_COEFFICIENT' Call GetNamespace}; + +{ + if ((_x getVariable "sideID") == _side) then { + switch (_incomeSystem) do { + case 3: {_income = _income + ((_x getVariable "supplyValue")*_incomeCoef)}; + default {_income = _income + (_x getVariable "supplyValue")}; + }; + }; +} forEach towns; + +_income \ No newline at end of file diff --git a/Common/Functions/Common_GetTurretsMags.sqf b/Common/Functions/Common_GetTurretsMags.sqf new file mode 100644 index 0000000..f226567 --- /dev/null +++ b/Common/Functions/Common_GetTurretsMags.sqf @@ -0,0 +1,42 @@ +/* Adapted from BIS turret's function. */ +private ['_entry','_turrets','_turretIndex']; +_entry = _this select 0; + +_turrets = []; +_turretIndex = 0; + +//Explore all turrets and sub-turrets recursively. +for '_i' from 0 to ((count _entry) - 1) do +{ + private ['_subEntry']; + _subEntry = _entry select _i; + + if (isClass _subEntry) then + { + private ['_hasGunner']; + _hasGunner = [_subEntry, 'hasGunner'] call BIS_fnc_returnConfigEntry; + + //Make sure the entry was found. + if !(isNil '_hasGunner') then + { + if (_hasGunner == 1) then + { + _turrets = _turrets + [[_turretIndex],getArray(_subEntry >> 'magazines')]; + + //Include sub-turrets, if present. + if (isClass (_subEntry >> 'Turrets')) then + { + _turrets = _turrets + [[_subEntry >> 'Turrets'] call GetTurretsMags]; + } + else + { + _turrets = _turrets + [[]]; + }; + }; + }; + + _turretIndex = _turretIndex + 1; + }; +}; + +_turrets \ No newline at end of file diff --git a/Common/Functions/Common_GetUnitVehicle.sqf b/Common/Functions/Common_GetUnitVehicle.sqf new file mode 100644 index 0000000..f7ba300 --- /dev/null +++ b/Common/Functions/Common_GetUnitVehicle.sqf @@ -0,0 +1,6 @@ +Private['_unit','_return']; +_unit = _this; + +_return = if (_unit != vehicle _unit) then {vehicle _unit} else {_unit}; + +_return \ No newline at end of file diff --git a/Common/Functions/Common_GetUnitsBelowHeight.sqf b/Common/Functions/Common_GetUnitsBelowHeight.sqf new file mode 100644 index 0000000..1232042 --- /dev/null +++ b/Common/Functions/Common_GetUnitsBelowHeight.sqf @@ -0,0 +1,11 @@ +Private["_belowUnits","_height","_min","_units","_z"]; + +_units = _this Select 0; +_height = _this Select 1; +_min = if (count _this > 2) then {_this select 2} else {-10}; + +_belowUnits = []; + +{_z = getPos _x select 2;if (_z < _height && _z >= _min) then {_belowUnits = _belowUnits + [_x]}} ForEach _units; + +_belowUnits \ No newline at end of file diff --git a/Common/Functions/Common_GetVehicleMags.sqf b/Common/Functions/Common_GetVehicleMags.sqf new file mode 100644 index 0000000..bb690a4 --- /dev/null +++ b/Common/Functions/Common_GetVehicleMags.sqf @@ -0,0 +1,4 @@ +private ["_entry"]; +_entry = _this select 0; + +getArray(_entry >> 'magazines') \ No newline at end of file diff --git a/Common/Functions/Common_HandleArtillery.sqf b/Common/Functions/Common_HandleArtillery.sqf new file mode 100644 index 0000000..be8e243 --- /dev/null +++ b/Common/Functions/Common_HandleArtillery.sqf @@ -0,0 +1,104 @@ +/* Handle artillery Fired EH */ +Private ['_ammo','_ammoList','_cannon','_destination','_direction','_dispersion','_distance','_keepShellAlive','_landDestination','_maxRange','_nearLaser','_percent','_projectile','_radius','_shellpos','_side','_smoke','_smokeOnImpact','_velocity','_xcoord','_ycoord']; + +_ammo = _this select 0; +_ammoList = _this select 2; + +//--- Only Catch allowed ammo. +if (_ammo in _ammoList) then { + + //--- Retrieve the parameters. + _projectile = _this select 1; + _destination = _this select 3; + _velocity = _this select 4; + _dispersion = _this select 5; + _cannon = _this select 6; + _distance = _this select 7; + _radius = _this select 8; + _maxRange = _this select 9; + _side = _this select 10; + + //--- Do we have smoke on impact? + _smokeOnImpact = false; + + //--- Randomize Land Area. + _distance = random (_distance / _maxRange * 100) + random _radius; + _direction = random 360; + + //--- Default Position. + _landDestination = [((_destination select 0)+((sin _direction)*_distance))+(random _dispersion)-(random _dispersion),(_destination select 1)+((cos _direction)*_distance)+(random _dispersion)-(random _dispersion),0]; + _keepShellAlive = true; + + //--- SADARM Rounds. + if (_ammo in (Format ["WFBE_%1_ARTILLERY_AMMO_SADARM",_side] Call GetNamespace)) then { + [_projectile,_landDestination,_velocity] Spawn ARTY_HandleSADARM; + //--- SADARM Destroy the original round. + _keepShellAlive = false; + }; + + //--- ILLUM Rounds. + if (_ammo in (Format ["WFBE_%1_ARTILLERY_AMMO_ILLUMN",_side] Call GetNamespace)) then { + [_projectile,_landDestination,_velocity] Spawn ARTY_HandleILLUM; + //--- ILLUM Destroy the original round. + _keepShellAlive = false; + }; + + //--- Some rounds remove the projectile, make sure that it's not removed or anything. + if (_keepShellAlive) then { + //--- LASER Rounds. + if (_ammo in (Format ["WFBE_%1_ARTILLERY_AMMO_LASER",_side] Call GetNamespace)) then { + _nearLaser = _destination nearEntities ['LaserTarget','WFBE_ARTILLERYAMMOLASERRANGE' Call GetNamespace]; + if (count _nearLaser > 0) then { + _nearLaser = getPos (([_destination,_nearLaser] Call SortByDistance) select 0); + _landDestination = [(_nearLaser select 0)+(((random _dispersion)-(random _dispersion))/4),(((_nearLaser select 1)+(random _dispersion)-(random _dispersion))/4),0]; + }; + }; + + //--- Calculate the shell estimated spawn area. + _distance = _landDestination distance _cannon; + _percent = ((500 * 100 / _distance) / 100); + _xcoord = (_landDestination select 0) + _percent * ((_cannon select 0) - (_landDestination select 0)); + _ycoord = (_landDestination select 1) + _percent * ((_cannon select 1) - (_landDestination select 1)); + _shellpos = [_xcoord,_ycoord,1000]; + + //--- Calculate the direction + _xcoord = (_landDestination select 0) - (_cannon select 0); + _ycoord = (_landDestination select 1) - (_cannon select 1); + _direction = -(((_ycoord atan2 _xcoord) + 270) % 360); + if (_direction < 0) then {_direction = _direction + 360}; + + //--- Track the shell (FX)? + _smokeOnImpact = if (_ammo in (Format ["WFBE_%1_ARTILLERY_DEPLOY_SMOKE",_side] Call GetNamespace)) then {true} else {false}; + + //--- Release the shell. + if !(isNull _projectile) then { + _projectile setPos _shellpos; + _projectile setVelocity [(sin _direction*_velocity),(cos _direction*_velocity),((_velocity * 2.03) * -1)]; + + if (WF_A2_Vanilla) then { + //---- MLRS ammo has some weird config problems on vanilla. + if (_ammo == "R_MLRS" || _ammo == "ARTY_R_227mm_HE_Rocket") then { + _projectile setPos _landDestination; + }; + }; + }; + }; + + //--- Release smoke on an impact. + if (_smokeOnImpact) then { + _shellPos = []; + + //--- Wait for the last known position. + while {!isNull _projectile} do { + _shellPos = getPos _projectile; + sleep 0.02; + }; + + //--- If we have it, release it. + if (count _shellPos > 0) then { + _shellPos set [2,0]; + _smoke = "ARTY_SmokeShellWhite" createVehicle _shellPos; + _smoke setPos _shellPos; + }; + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_HandleIncomingMissile.sqf b/Common/Functions/Common_HandleIncomingMissile.sqf new file mode 100644 index 0000000..8318f4c --- /dev/null +++ b/Common/Functions/Common_HandleIncomingMissile.sqf @@ -0,0 +1,22 @@ +Private ["_ammo","_irLock","_missile","_source","_unit"]; +_unit = _this select 0; +_ammo = _this select 1; +_source = _this select 2; + +_missile = nearestObject [_source,_ammo]; +if (isNull _missile) exitWith {}; + +//--- Get the ammo type. +_irLock = getNumber(configFile >> "CfgAmmo" >> _ammo >> "irLock"); + +//--- IR Lock is affected +if (_irLock == 1) then { + _distance = _unit distance _source; + + _limit = 'WFBE_INCOMINGMISSILEMAXRANGE' Call GetNamespace; + + if (_distance > _limit) then { + waitUntil {_missile distance _source > _limit}; + deleteVehicle _missile; + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_IsArtillery.sqf b/Common/Functions/Common_IsArtillery.sqf new file mode 100644 index 0000000..28b97ba --- /dev/null +++ b/Common/Functions/Common_IsArtillery.sqf @@ -0,0 +1,12 @@ +Private ['_artyNames','_i','_retVal','_side','_unit']; +_unit = _this select 0; +_side = _this select 1; + +_retVal = -1; +_artyNames = Format ["WFBE_%1_ARTILLERY_NAMES",_side] Call GetNamespace; + +for [{_i = 0},{_i < count(_artyNames)},{_i = _i + 1}] do { + if (_unit in (_artyNames select _i)) exitWith {_retVal = _i}; +}; + +_retVal \ No newline at end of file diff --git a/Common/Functions/Common_PlaceNear.sqf b/Common/Functions/Common_PlaceNear.sqf new file mode 100644 index 0000000..99f9b75 --- /dev/null +++ b/Common/Functions/Common_PlaceNear.sqf @@ -0,0 +1,34 @@ +Private["_destination","_direction","_faceAway","_maxRadius","_minRadius","_object","_placeSafe","_position","_radius","_randomDirection","_safeRadius"]; + +_object = _this Select 0; +_position = _this Select 1; +_minRadius = _this Select 2; +_maxRadius = _this Select 3; + +_faceAway = true; +if (Count _this > 4) then {_faceAway = _this Select 4}; + +_randomDirection = true; +if (Count _this > 5) then {_randomDirection = _this Select 5}; + +_placeSafe = false; +if (Count _this > 6) then {_placeSafe = _this Select 6}; + +_direction = Random 360; +_radius = (Random (_maxRadius - _minRadius)) + _minRadius; + +if (_placeSafe) then { + _safeRadius = (_maxRadius - _minRadius) / 2; + if (_safeRadius < 5) then {_safeRadius = 5}; + _destination = [(_position Select 0)+((sin _direction)*_radius),(_position Select 1)+((cos _direction)*_radius),(_position Select 2)+0.5]; + [_object,_destination,_safeRadius] Call PlaceSafe; +} else { + _object SetPos [(_position Select 0)+((sin _direction)*_radius),(_position Select 1)+((cos _direction)*_radius),(_position Select 2)+0.5]; +}; + +if (_randomDirection) then {_object SetDir Random 360}; + +if (_faceAway) then { + _destination = GetPos _object; + _object SetDir -((((_destination Select 1) - (_position Select 1)) atan2 ((_destination Select 0) - (_position Select 0))) - 90); +}; \ No newline at end of file diff --git a/Common/Functions/Common_PlaceSafe.sqf b/Common/Functions/Common_PlaceSafe.sqf new file mode 100644 index 0000000..45176c2 --- /dev/null +++ b/Common/Functions/Common_PlaceSafe.sqf @@ -0,0 +1,28 @@ +Private["_count","_currentPosition","_direction","_object","_obstacles","_placed","_position","_radius","_vehicles"]; +scopeName "PlaceSafe"; + +_object = _this select 0; +_position = _this select 1; +_radius = if (count _this > 2) then {_this select 2} else {35}; + +_currentPosition = _position; +_placed = false; +_direction = 0; + +for [{_count = 0},{_count < 30 && !_placed},{_count = _count + 1}] do { + _obstacles = nearestObjects [_currentPosition, ["Building"], 15]; + _vehicles = _currentPosition nearEntities [["Building","Car","Tank","Air"], 7]; + + if (count _obstacles > 0 || count _vehicles > 0 || surfaceIsWater _currentPosition) then { + _currentPosition = [(_position select 0)+((sin _direction)*_radius),(_position select 1)+((cos _direction)*_radius),0]; + _direction = _direction + 36; + if (_count > 15) then {_radius = _radius + 25}; + } else { + _object setPos _currentPosition; + _object setVelocity [0,0,-0.5]; + _placed = true; + breakTo "PlaceSafe"; + }; +}; + +if (!_placed) then {_object setPos _position;_object setVelocity [0,0,-0.5]}; diff --git a/Common/Functions/Common_RearmVehicle.sqf b/Common/Functions/Common_RearmVehicle.sqf new file mode 100644 index 0000000..58ed35c --- /dev/null +++ b/Common/Functions/Common_RearmVehicle.sqf @@ -0,0 +1,39 @@ +Private["_amount","_get","_isAir","_isArtillery","_magazines","_side","_type","_vehicle"]; + +_vehicle = _this select 0; +_side = _this select 1; +_type = typeOf _vehicle; +_isAir = if (_vehicle isKindOf "Air") then {true} else {false}; + +//rearming turrets. +{_vehicle removeMagazine _x} forEach magazines _vehicle; + +_magazines = getArray (configFile >> "CfgVehicles" >> typeOf _vehicle >> "Turrets" >> "MainTurret" >> "Magazines"); +_magazines = _magazines + getArray (configFile >> "CfgVehicles" >> typeOf _vehicle >> "Magazines"); + +{_vehicle addMagazine _x} forEach _magazines; + +/* CM Parameter */ +if (paramCounterMeasures && _isAir) then { + _amount = if (_vehicle isKindOf "Plane") then {'WFBE_COUNTERMEASUREPLANES' Call GetNamespace} else {'WFBE_COUNTERMEASURECHOPPERS' Call GetNamespace}; + _vehicle setVariable ["FlareCount", _amount]; +}; + +_vehicle setVehicleAmmo 1; +reload _vehicle; + +/* Are we dealing with an artillery unit ? */ +_isArtillery = -1; +if (_side == west || _side == east) then {_isArtillery = [_type,_side] Call IsArtillery}; +if (_isArtillery != -1) then {[_vehicle,_isArtillery,_side] Call EquipArtillery}; + +/* Balanced Unit */ +if (_type in ('WFBE_BALANCEDUNITS' Call GetNamespace) && paramBalancing) then {[_vehicle] Call BalanceInit}; + +/* EASA Module */ +if (paramEASA) then { + if (_type in ('WFBE_EASA_Vehicles' Call GetNamespace)) then { + _get = _vehicle getVariable 'WFBE_EASA_Setup'; + if !(isNil '_get') then {[_vehicle,0] Call EASA_Equip}; + }; +}; diff --git a/Common/Functions/Common_RearmVehicleOA.sqf b/Common/Functions/Common_RearmVehicleOA.sqf new file mode 100644 index 0000000..9537b90 --- /dev/null +++ b/Common/Functions/Common_RearmVehicleOA.sqf @@ -0,0 +1,51 @@ +Private['_amount','_config','_get','_isAir','_isArtillery','_magazines','_side','_turrets','_type','_vehicle']; + +_vehicle = _this select 0; +_side = _this select 1; +_type = typeOf _vehicle; +_isAir = if (_vehicle isKindOf "Air") then {true} else {false}; + +/* Clear the vehicle */ +_vehicle setVehicleAmmo 0; + +/* Reload all turrets */ +_turrets = []; +_config = configFile >> 'CfgVehicles' >> typeOf _vehicle >> 'Turrets'; +_turrets = [_config] call GetTurretsMags; +[_vehicle,_turrets] Call SetTurretsMags; +/* Reload the driver (Special) */ +_magazines = [configFile >> 'CfgVehicles' >> typeOf _vehicle] call GetVehicleMags; +{_vehicle addMagazineTurret[_x,[-1]]} forEach _magazines; + +reload _vehicle; + +/* CM Parameter */ +if (paramCounterMeasures && _vehicle isKindOf 'Air') then { + _amount = if (_vehicle isKindOf 'Plane') then {'WFBE_COUNTERMEASUREPLANES' Call GetNamespace} else {'WFBE_COUNTERMEASURECHOPPERS' Call GetNamespace}; + _vehicle setVariable ['FlareCount', _amount]; +}; + +/* Are we dealing with an artillery unit ? */ +_isArtillery = -1; +if (_side == west || _side == east) then {_isArtillery = [_type,_side] Call IsArtillery}; +if (_isArtillery != -1) then {[_vehicle,_isArtillery,_side] Call EquipArtillery}; + +/* Balanced Unit */ +if (_type in ('WFBE_BALANCEDUNITS' Call GetNamespace) && paramBalancing) then {[_vehicle] Call BalanceInit}; + +/* EASA Module */ +if (paramEASA) then { + if (_type in ('WFBE_EASA_Vehicles' Call GetNamespace)) then { + _get = _vehicle getVariable 'WFBE_EASA_Setup'; + if !(isNil '_get') then {[_vehicle,0] Call EASA_Equip}; + }; +}; + +/* Mando Missiles - Reload Flares */ +if (paramMandoMissiles && _isAir) then { + _var = _vehicle getVariable "mando_maxflares"; + if !(isNil "_var") then { + _vehicle setVariable ["mando_flaresleft", _var, true]; + call mando_update_flares; + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_RevealArea.sqf b/Common/Functions/Common_RevealArea.sqf new file mode 100644 index 0000000..3a94c95 --- /dev/null +++ b/Common/Functions/Common_RevealArea.sqf @@ -0,0 +1,11 @@ +Private ["_pos","_range","_reveal","_team","_unit"]; + +_unit = _this select 0; +_range = _this select 1; +_pos = _this select 2; + +{ + _reveal = [_x]; + if (_x != vehicle _x) then {_reveal = _reveal + (crew _x)}; + {_unit reveal _x} forEach _reveal; +} forEach (_pos nearEntities _range); \ No newline at end of file diff --git a/Common/Functions/Common_SetCommanderVotes.sqf b/Common/Functions/Common_SetCommanderVotes.sqf new file mode 100644 index 0000000..48a41c0 --- /dev/null +++ b/Common/Functions/Common_SetCommanderVotes.sqf @@ -0,0 +1,14 @@ +Private["_count","_side","_teams","_total","_value"]; + +_side = _this Select 0; +_value = _this Select 1; + +_teams = (Format["WFBE_%1TEAMS",str _side] Call GetNamespace); +_total = Count _teams + 1; + +//Count votes. +for [{_count = 1},{_count < _total},{_count = _count + 1}] do { + if (isPlayer (leader (_teams Select (_count - 1)))) then { + Call Compile Format["if (%1Team%2Vote != _value) then {%1Team%2Vote = _value;PublicVariable '%1Team%2Vote'};",str _side,_count]; + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_SetNamespace.sqf b/Common/Functions/Common_SetNamespace.sqf new file mode 100644 index 0000000..aaf20f2 --- /dev/null +++ b/Common/Functions/Common_SetNamespace.sqf @@ -0,0 +1,15 @@ +Private ['_get','_override','_variable','_value']; + +_variable = _this select 0; +_value = _this select 1; +_override = if (count _this > 2) then {_this select 2} else {false}; + +//--- BIS Bug, typename doesn't work properly with nil. +if !(_override) then { + _get = _variable Call GetNamespace; + if (isNil '_get') then { + missionNamespace setVariable [_variable,_value]; + }; +} else { + missionNamespace setVariable [_variable,_value]; +}; \ No newline at end of file diff --git a/Common/Functions/Common_SetTeamAutonomous.sqf b/Common/Functions/Common_SetTeamAutonomous.sqf new file mode 100644 index 0000000..e9d2add --- /dev/null +++ b/Common/Functions/Common_SetTeamAutonomous.sqf @@ -0,0 +1,8 @@ +Private['_status','_team']; + +_team = _this select 0; +_status = _this select 1; + +if (isNull _team) exitWith {}; + +Call Compile Format ["%1Autonomous = _status; publicVariable '%1Autonomous';",_team getVariable 'identification']; \ No newline at end of file diff --git a/Common/Functions/Common_SetTeamMoveMode.sqf b/Common/Functions/Common_SetTeamMoveMode.sqf new file mode 100644 index 0000000..e83b940 --- /dev/null +++ b/Common/Functions/Common_SetTeamMoveMode.sqf @@ -0,0 +1,8 @@ +Private['_moveMode','_team']; + +_team = _this select 0; +_moveMode = _this select 1; + +if (isNull _team) exitWith {}; + +Call Compile Format ["%1MoveMode = _moveMode; publicVariable '%1MoveMode';",_team getVariable 'identification']; \ No newline at end of file diff --git a/Common/Functions/Common_SetTeamMovePos.sqf b/Common/Functions/Common_SetTeamMovePos.sqf new file mode 100644 index 0000000..7a45b8f --- /dev/null +++ b/Common/Functions/Common_SetTeamMovePos.sqf @@ -0,0 +1,8 @@ +Private['_movePos','_team']; + +_team = _this select 0; +_movePos = _this select 1; + +if (isNull _team) exitWith {}; + +Call Compile Format ["%1MovePos = _movePos; publicVariable '%1MovePos';",_team getVariable 'identification']; \ No newline at end of file diff --git a/Common/Functions/Common_SetTeamRespawn.sqf b/Common/Functions/Common_SetTeamRespawn.sqf new file mode 100644 index 0000000..606f269 --- /dev/null +++ b/Common/Functions/Common_SetTeamRespawn.sqf @@ -0,0 +1,8 @@ +Private['_respawn','_team']; + +_team = _this select 0; +_respawn = _this select 1; + +if (isNull _team) exitWith {}; + +Call Compile Format ["%1Respawn = _respawn; publicVariable '%1Respawn';",_team getVariable 'identification']; \ No newline at end of file diff --git a/Common/Functions/Common_SetTeamType.sqf b/Common/Functions/Common_SetTeamType.sqf new file mode 100644 index 0000000..6d77a81 --- /dev/null +++ b/Common/Functions/Common_SetTeamType.sqf @@ -0,0 +1,8 @@ +Private['_idtype','_team']; + +_team = _this select 0; +_idtype = _this select 1; + +if (isNull _team) exitWith {}; + +Call Compile Format ["%1Types = _idtype; publicVariable '%1Types';",_team getVariable 'identification']; \ No newline at end of file diff --git a/Common/Functions/Common_SetTurretsMags.sqf b/Common/Functions/Common_SetTurretsMags.sqf new file mode 100644 index 0000000..7881ed9 --- /dev/null +++ b/Common/Functions/Common_SetTurretsMags.sqf @@ -0,0 +1,30 @@ +private ["_content","_cpt","_data","_dataRow","_tConstruct","_turretPath","_vehicle"]; +_vehicle = _this select 0; +_data = _this select 1; +_turretPath = if (count _this > 2) then {_this select 2} else {[]}; +_cpt = count _turretPath; + +for "_i" from 0 to ((count _data) - 1) do { + _dataRow = _data select _i; + + if (count _dataRow > 0) then { + if (typeName _dataRow == 'ARRAY') then { + _content = _dataRow select 0; + //--- root. + if (typeName _content == 'SCALAR') then { + _turretPath set [_cpt,[_content]]; + _tConstruct = []; + {_tConstruct = _tConstruct + _x} forEach _turretPath; + { + _vehicle addMagazineTurret [_x, _tConstruct]; + } forEach (_data select (_i+1)); + }; + //--- go deeper. + if (typeName _content == 'ARRAY') then { + [_vehicle,_dataRow,_turretPath] Call SetTurretsMags; + _turretPath = []; + _cpt = 0; + }; + }; + }; +}; \ No newline at end of file diff --git a/Common/Functions/Common_SortByDistance.sqf b/Common/Functions/Common_SortByDistance.sqf new file mode 100644 index 0000000..a34680e --- /dev/null +++ b/Common/Functions/Common_SortByDistance.sqf @@ -0,0 +1,24 @@ +Private["_count","_count1","_current","_distance","_nearest","_nearestDistance","_object","_objects","_sorted","_total"]; + +_object = _this Select 0; +_objects = +(_this Select 1); + +_sorted = []; + +_total = Count _objects; +for [{_count = 0},{_count < _total},{_count = _count + 1}] do { + _nearest = ObjNull; + _nearestDistance = 100000; + + for [{_count1 = Count _objects - 1},{_count1 >= 0},{_count1 = _count1 - 1}] do { + _current = _objects Select _count1; + _distance = _current Distance _object; + + if (_distance < _nearestDistance) then {_nearest = _current;_nearestDistance = _distance}; + }; + + _sorted = _sorted + [_nearest]; + _objects = _objects - [_nearest]; +}; + +_sorted \ No newline at end of file diff --git a/Common/Functions/Common_SpawnTurrets.sqf b/Common/Functions/Common_SpawnTurrets.sqf new file mode 100644 index 0000000..b9ae10e --- /dev/null +++ b/Common/Functions/Common_SpawnTurrets.sqf @@ -0,0 +1,22 @@ +private ["_turrets", "_path", "_vehicle", "_crew", "_team", "_unit"]; +_turrets = _this select 0; +_path = _this select 1; +_vehicle = _this select 2; +_crew = _this select 3; +_team = _this select 4; +private ["_i"]; +_i = 0; +while {_i < (count _turrets)} do { + private ["_turretIndex", "_thisTurret"]; + _turretIndex = _turrets select _i; + _thisTurret = _path + [_turretIndex]; + + if (isNull (_vehicle turretUnit _thisTurret)) then { + _unit = [_crew,_team,getPos _vehicle,side _team] Call CreateMan; + _unit moveInTurret [_vehicle, _thisTurret]; + }; + + //Spawn units into subturrets. + [_turrets select (_i + 1), _thisTurret, _vehicle, _crew, _team] call SpawnTurrets; + _i = _i + 2; +}; \ No newline at end of file diff --git a/Common/Functions/Common_UnitKilled.sqf b/Common/Functions/Common_UnitKilled.sqf new file mode 100644 index 0000000..dbf11df --- /dev/null +++ b/Common/Functions/Common_UnitKilled.sqf @@ -0,0 +1,196 @@ +Private ["_bounty","_crew","_get","_group","_isAIControlled","_iskilledplayer","_iskillerplayer","_isMan","_killed","_killedname","_killeduid","_killer","_killerID","_killername","_killerTeam","_killerVehName","_killertype","_killeruid","_lost","_objects","_objectType","_side","_sideKiller","_sideVictim","_sta","_uid","_vehicle"]; +_killed = _this select 0; +_killer = _this select 1; +_sideVictim = _this select 2; +_sideKiller = side _killer; + +_group = group _killed; +_killerTeam = group _killer; +_killerVehName = vehicleVarName (leader _killerTeam); +_vehicle = vehicle _killer; +_objectType = typeOf _killed; +_killertype = ""; +_killeruid = ""; +_killername = ""; +_killeduid = ""; +_killedname = ""; +_iskilledplayer = false; + +_isMan = if (_killed isKindOf "Man") then {true} else {false}; + +_iskillerplayer = if (isPlayer _killer) then {true} else {false}; +if (mysql) then { + _killertype = typeOf _killer; + _iskilledplayer = if (isPlayer _killed) then {true} else {false}; + _killeruid = if (_iskillerplayer) then {getPlayerUID(_killer)} else {"0"}; + _killeduid = if (_iskilledplayer) then {getPlayerUID(_killed)} else {"0"}; + _killername = if (_iskillerplayer) then {name _killer} else {"nil"}; + _killedname = if (_iskilledplayer) then {name _killed} else {"nil"}; +}; + +//--- Renegade. +if (_sideKiller == sideEnemy) then { + if (_killer isKindOf westSoldierBaseClass) then {_sideKiller = west}; + if (_killer isKindOf eastSoldierBaseClass) then {_sideKiller = east}; +}; +if (_sideVictim == sideEnemy) then { + if (_killed isKindOf westSoldierBaseClass) then {_sideVictim = west}; + if (_killed isKindOf eastSoldierBaseClass) then {_sideVictim = east}; +}; + +//--- Benny's Garbage Collector. +if (WF_A2_Vanilla) then { + /* Vanilla use the old garbage system */ + if (!(isServer) || local player) then { + _objects = (WF_Logic getVariable "trash") + [_killed]; + WF_Logic setVariable ["trash",_objects,true]; + } else { + trashQueu = trashQueu + [_killed]; + _killed Spawn TrashObject; + }; +} else { + /* OA use the evolved system which no longer require network variables */ + if (isServer) then { + trashQueu = trashQueu + [_killed]; + _killed Spawn TrashObject; + }; +}; + +sleep (random 3); + +if (_isMan && (_sideVictim == west || _sideVictim == east)) then {[str _sideVictim,'Casualties',1] Call UpdateStatistics}; +if (!_isMan && (_sideVictim == west || _sideVictim == east)) then {[str _sideVictim,'VehiclesLost',1] Call UpdateStatistics}; + +_killerID = (leader _killerTeam) Call GetClientID; +_get = _objectType Call GetNamespace; + +_isAIControlled = true; +if (_killerID > 0) then {_isAIControlled = if (isPlayer (leader _killerTeam)) then {false} else {true}}; + +//--- Normal kill. +if (!isNull _killerTeam && !isNil '_get' && (_sideKiller != sideEnemy) && (_sideKiller != _sideVictim) && (_sideKiller != Civilian)) then { + if (_killerID > 0 && !_isAIControlled) then { + /* Bounty */ + if (paramBounty) then { + WFBE_AwardBounty = [_killerVehName,'CLTFNCAWARDBOUNTY',[_objectType, false]]; + publicVariable 'WFBE_AwardBounty'; + if (isHostedServer) then {[_killerVehName,'CLTFNCAWARDBOUNTY',[_objectType, false]] Spawn HandlePVF}; + + //--- Kill Assist. + if (!(_vehicle isKindOf 'Man') && alive _vehicle) then { + _crew = [driver _vehicle, gunner _vehicle, commander _vehicle] - [_killer, player]; + { + if !(isNull _x) then { + if (isPlayer _x && group _x != _killerTeam) then { + WFBE_AwardBounty = [vehicleVarName _x,'CLTFNCAWARDBOUNTY',[_objectType, true]]; + publicVariable 'WFBE_AwardBounty'; + if (isHostedServer) then {[vehicleVarName _x,'CLTFNCAWARDBOUNTY',[_objectType, true]] Spawn HandlePVF}; + }; + }; + } forEach _crew; + }; + }; + + /* AI Score */ + if !(_iskillerplayer) then { + [_objectType,leader _killerTeam] Spawn { + Private ['_player','_point','_type']; + _type = _this select 0; + _player = _this select 1; + + _point = switch (true) do { + case (_type isKindOf "Infantry"): {1}; + case (_type isKindOf "Car"): {2}; + case (_type isKindOf "Ship"): {4}; + case (_type isKindOf "Motorcycle"): {1}; + case (_type isKindOf "Tank"): {4}; + case (_type isKindOf "Helicopter"): {4}; + case (_type isKindOf "Plane"): {6}; + case (_type isKindOf "StaticWeapon"): {2}; + case (_type isKindOf "Building"): {2}; + default {1}; + }; + + sleep random(3); + + if (isServer) then { + ['SRVFNCREQUESTCHANGESCORE',[_player,score _player + _point]] Spawn HandleSPVF; + } else { + WFBE_RequestChangeScore = ['SRVFNCREQUESTCHANGESCORE',[_player,score _player + _point]]; + publicVariable 'WFBE_RequestChangeScore'; + if (isHostedServer) then {['SRVFNCREQUESTCHANGESCORE',[_player,score _player + _point]] Spawn HandleSPVF}; + }; + }; + }; + + /* MySQL */ + if (mysql) then { + _sta = switch (true) do { + case (_objectType isKindOf "Infantry"): {1}; + case (_objectType isKindOf "Car"): {2}; + case (_objectType isKindOf "Ship"): {2}; + case (_objectType isKindOf "Motorcycle"): {1}; + case (_objectType isKindOf "Tank"): {4}; + case (_objectType isKindOf "Helicopter"): {6}; + case (_objectType isKindOf "Plane"): {8}; + case (_objectType isKindOf "StaticWeapon"): {3}; + case (_objectType isKindOf "Building"): {3}; + default {1}; + }; + if (isServer) then { + if (_iskilledplayer) then { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKP?%1?%2?%3?%4?%5",_killeduid,_killedname,_killeruid,_killername,worldName]]]; + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?%5?%6",_killertype,_killeduid,_killedname,"killedby",_sta,worldName]]]; + } else { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?%5?%6",_objectType,_killeruid,_killername,"killed",_sta,worldName]]]; + }; + } else { + if (_iskilledplayer) then { + WF_Logic setVariable ["WF_MYSQL_CLIENT",(WF_Logic getVariable "WF_MYSQL_CLIENT") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKP?%1?%2?%3?%4?%5",_killeduid,_killedname,_killeruid,_killername,worldName]],true]; + WF_Logic setVariable ["WF_MYSQL_CLIENT",(WF_Logic getVariable "WF_MYSQL_CLIENT") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?%5?%6",_killertype,_killeduid,_killedname,"killedby",_sta,worldName]],true]; + } else { + WF_Logic setVariable ["WF_MYSQL_CLIENT",(WF_Logic getVariable "WF_MYSQL_CLIENT") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?%5?%6",_objectType,_killeruid,_killername,"killed",_sta,worldName]],true]; + }; + }; + }; + }; + + if (mysql) then { + if (_isAIControlled) then { + if (isServer) then { + if (mysql && _iskilledplayer) then { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?0?%5",_killertype,_killeduid,_killedname,"killedby",worldName]]]; + }; + } else { + if (mysql && _iskilledplayer) then { + WF_Logic setVariable ["WF_MYSQL_CLIENT",(WF_Logic getVariable "WF_MYSQL_CLIENT") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?0?%5",_killertype,_killeduid,_killedname,"killedby",worldName]],true]; + }; + }; + }; + }; + + /* Playable AI Kill */ + if (paramAI && _killerID > 0 && _isAIControlled) then { + if (isServer) then { + _bounty = (_get select QUERYUNITPRICE) * ('WFBE_BOUNTYMODIFIER' Call GetNamespace); + _bounty = _bounty - (_bounty % 1); + [_killerTeam,_bounty] Call ChangeTeamFunds; + }; + }; +}; + +//--- Teamkill. +if (!isNull _killerTeam && !isNil '_get' && (_sideKiller != sideEnemy) && (_sideKiller == _sideVictim) && (_sideKiller != Civilian) && _isMan) then { + if (_killerID > 0 && !_isAIControlled) then { + WFBE_LocalizeMessage = [_killerVehName,'CLTFNCLOCALIZEMESSAGE',['Teamkill']]; + publicVariable 'WFBE_LocalizeMessage'; + if (isHostedServer) then {[_killerVehName,'CLTFNCLOCALIZEMESSAGE',['Teamkill']] Spawn HandlePVF}; + if (mysql) then { + if (isServer) then { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_Update?%1?%2?teamkill?%3",_killeruid,_killername,worldName]]]; + } else { + WF_Logic setVariable ["WF_MYSQL_CLIENT",(WF_Logic getVariable "WF_MYSQL_CLIENT") + [Format ["MYSQLDATA?WFBE_Update?%1?%2?teamkill?%3",_killeruid,_killername,worldName]],true]; + }; + }; + }; +}; diff --git a/Common/Functions/Common_UpdateStatistics.sqf b/Common/Functions/Common_UpdateStatistics.sqf new file mode 100644 index 0000000..5fd0ef6 --- /dev/null +++ b/Common/Functions/Common_UpdateStatistics.sqf @@ -0,0 +1 @@ +Private ['_side','_val','_var']; _side = _this select 0; _var = _this select 1; _val = _this select 2; WF_Logic setVariable [Format["%1%2",_side,_var],((WF_Logic getVariable Format["%1%2",_side,_var]) + _val),true]; \ No newline at end of file diff --git a/Common/Functions/Common_UseStationaryDefense.sqf b/Common/Functions/Common_UseStationaryDefense.sqf new file mode 100644 index 0000000..6f90f09 --- /dev/null +++ b/Common/Functions/Common_UseStationaryDefense.sqf @@ -0,0 +1,32 @@ +Private["_count","_defense","_defenses","_defenseTypes","_emptyDefenses","_range","_total","_totalDefenses","_unit","_units"]; + +_units = _this select 0; +_range = _this select 1; + +_total = count _units; +if (_total < 1) exitWith {diag_log Format["[WFBE (ERROR)][frameno:%1 | ticktime:%2] Common_UseStationaryDefense.sqf: No units were specified",diag_frameno,diag_tickTime]}; + +_defenseTypes = Format["WFBE_%1DEFENSENAMES",side leader group (_units select 0)] Call GetNamespace; +_defenses = (leader group (_units select 0)) nearEntities[_defenseTypes,_range]; + +_emptyDefenses = []; + +{if (_x EmptyPositions "gunner" > 0) then {_emptyDefenses = _emptyDefenses + [_x]}} forEach _defenses; + +for [{_count = 0},{_count < _total},{_count = _count + 1}] do +{ + _unit = _units select _count; + + _totalDefenses = count _emptyDefenses; + if (_totalDefenses < 1) exitWith {}; + + //If not in a vehicle then check for available defense. + if (alive _unit && _unit == vehicle _unit) then + { + _defense = _emptyDefenses select (_totalDefenses - 1); + + [_unit] allowGetIn true; + _unit assignAsGunner _defense; + _emptyDefenses = _emptyDefenses - [_defense]; + }; +}; \ No newline at end of file -- cgit v1.3.1