From dee52083d359434fc3ac51a871c1b836d092d2ac Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:55:41 +0300 Subject: init --- Client/Functions/Client_BuildUnit.sqf | 240 +++++++++++++++++++++ Client/Functions/Client_ChangePlayerFunds.sqf | 1 + Client/Functions/Client_CommandChatMessage.sqf | 1 + Client/Functions/Client_CommanderUpgrade.sqf | 34 +++ Client/Functions/Client_DebugHint.sqf | 8 + Client/Functions/Client_DisplayInventory.sqf | 98 +++++++++ Client/Functions/Client_EquipDefaultLoadout.sqf | 17 ++ Client/Functions/Client_FX.sqf | 50 +++++ Client/Functions/Client_GetIncome.sqf | 33 +++ Client/Functions/Client_GetMarkerColoration.sqf | 1 + Client/Functions/Client_GetPlayerFunds.sqf | 1 + Client/Functions/Client_GetRespawnAvailable.sqf | 58 +++++ .../Functions/Client_GetStructureMarkerLabel.sqf | 16 ++ Client/Functions/Client_GetTime.sqf | 1 + Client/Functions/Client_GroupChatMessage.sqf | 1 + Client/Functions/Client_HandleHQAction.sqf | 12 ++ Client/Functions/Client_HandleOnMap.sqf | 17 ++ Client/Functions/Client_HandlePVF.sqf | 30 +++ Client/Functions/Client_InitTownsAndCamps.sqf | 40 ++++ Client/Functions/Client_IsOnMap.sqf | 17 ++ Client/Functions/Client_MarkerAnim.sqf | 45 ++++ Client/Functions/Client_OnRespawnHandler.sqf | 78 +++++++ Client/Functions/Client_PreRespawnHandler.sqf | 15 ++ Client/Functions/Client_ReplaceArray.sqf | 12 ++ Client/Functions/Client_ReplaceInventoryAmmo.sqf | 65 ++++++ Client/Functions/Client_RequestFireMission.sqf | 25 +++ Client/Functions/Client_RespawnBag.sqf | 33 +++ Client/Functions/Client_ReturnArraySortAsc.sqf | 30 +++ Client/Functions/Client_SetControlFadeAnim.sqf | 28 +++ Client/Functions/Client_SetControlFadeAnimStop.sqf | 9 + Client/Functions/Client_SetGroupsID.sqf | 13 ++ Client/Functions/Client_SupportHeal.sqf | 99 +++++++++ Client/Functions/Client_SupportRearm.sqf | 78 +++++++ Client/Functions/Client_SupportRefuel.sqf | 78 +++++++ Client/Functions/Client_SupportRepair.sqf | 78 +++++++ Client/Functions/Client_TaskSystem.sqf | 69 ++++++ Client/Functions/Client_TitleTextMessage.sqf | 7 + Client/Functions/Client_UIAddItem.sqf | 11 + Client/Functions/Client_UIAddMagazine.sqf | 35 +++ Client/Functions/Client_UIChangeComboBuyUnits.sqf | 15 ++ Client/Functions/Client_UIFillListBuyUnits.sqf | 35 +++ Client/Functions/Client_UIFillListTeamOrders.sqf | 42 ++++ Client/Functions/Client_UIFindLBValue.sqf | 12 ++ Client/Functions/Client_UIGearFillList.sqf | 40 ++++ Client/Functions/Client_UIGearFillTemplateList.sqf | 31 +++ 45 files changed, 1659 insertions(+) create mode 100644 Client/Functions/Client_BuildUnit.sqf create mode 100644 Client/Functions/Client_ChangePlayerFunds.sqf create mode 100644 Client/Functions/Client_CommandChatMessage.sqf create mode 100644 Client/Functions/Client_CommanderUpgrade.sqf create mode 100644 Client/Functions/Client_DebugHint.sqf create mode 100644 Client/Functions/Client_DisplayInventory.sqf create mode 100644 Client/Functions/Client_EquipDefaultLoadout.sqf create mode 100644 Client/Functions/Client_FX.sqf create mode 100644 Client/Functions/Client_GetIncome.sqf create mode 100644 Client/Functions/Client_GetMarkerColoration.sqf create mode 100644 Client/Functions/Client_GetPlayerFunds.sqf create mode 100644 Client/Functions/Client_GetRespawnAvailable.sqf create mode 100644 Client/Functions/Client_GetStructureMarkerLabel.sqf create mode 100644 Client/Functions/Client_GetTime.sqf create mode 100644 Client/Functions/Client_GroupChatMessage.sqf create mode 100644 Client/Functions/Client_HandleHQAction.sqf create mode 100644 Client/Functions/Client_HandleOnMap.sqf create mode 100644 Client/Functions/Client_HandlePVF.sqf create mode 100644 Client/Functions/Client_InitTownsAndCamps.sqf create mode 100644 Client/Functions/Client_IsOnMap.sqf create mode 100644 Client/Functions/Client_MarkerAnim.sqf create mode 100644 Client/Functions/Client_OnRespawnHandler.sqf create mode 100644 Client/Functions/Client_PreRespawnHandler.sqf create mode 100644 Client/Functions/Client_ReplaceArray.sqf create mode 100644 Client/Functions/Client_ReplaceInventoryAmmo.sqf create mode 100644 Client/Functions/Client_RequestFireMission.sqf create mode 100644 Client/Functions/Client_RespawnBag.sqf create mode 100644 Client/Functions/Client_ReturnArraySortAsc.sqf create mode 100644 Client/Functions/Client_SetControlFadeAnim.sqf create mode 100644 Client/Functions/Client_SetControlFadeAnimStop.sqf create mode 100644 Client/Functions/Client_SetGroupsID.sqf create mode 100644 Client/Functions/Client_SupportHeal.sqf create mode 100644 Client/Functions/Client_SupportRearm.sqf create mode 100644 Client/Functions/Client_SupportRefuel.sqf create mode 100644 Client/Functions/Client_SupportRepair.sqf create mode 100644 Client/Functions/Client_TaskSystem.sqf create mode 100644 Client/Functions/Client_TitleTextMessage.sqf create mode 100644 Client/Functions/Client_UIAddItem.sqf create mode 100644 Client/Functions/Client_UIAddMagazine.sqf create mode 100644 Client/Functions/Client_UIChangeComboBuyUnits.sqf create mode 100644 Client/Functions/Client_UIFillListBuyUnits.sqf create mode 100644 Client/Functions/Client_UIFillListTeamOrders.sqf create mode 100644 Client/Functions/Client_UIFindLBValue.sqf create mode 100644 Client/Functions/Client_UIGearFillList.sqf create mode 100644 Client/Functions/Client_UIGearFillTemplateList.sqf (limited to 'Client/Functions') diff --git a/Client/Functions/Client_BuildUnit.sqf b/Client/Functions/Client_BuildUnit.sqf new file mode 100644 index 0000000..ae71a20 --- /dev/null +++ b/Client/Functions/Client_BuildUnit.sqf @@ -0,0 +1,240 @@ +Private ["_building","_cpt","_commander","_created","_crew","_currentUnit","_description","_direction","_distance","_driver","_extracrew","_factory","_factoryPosition","_factoryType","_group","_gunner","_index","_init","_isArtillery","_isMan","_locked","_longest","_position","_queu","_queu2","_ret","_show","_soldier","_waitTime","_txt","_type","_upgrades","_unique","_unit","_vehi","_vehicle","_vehicles"]; +_building = _this select 0; +_unit = _this select 1; +_vehi = _this select 2; +_factory = _this select 3; +_cpt = _this select 4; + +_isMan = if (_unit isKindOf "Man") then {true} else {false}; + +unitQueu = unitQueu + _cpt; + +_distance = 0; +_direction = 0; +_longest = 0; +_position = 0; +_waitTime = 0; +_factoryType = ""; +_description = ""; + +_currentUnit = _unit Call GetNamespace; +_waitTime = _currentUnit select QUERYUNITTIME; +_description = _currentUnit select QUERYUNITLABEL; + +_type = typeOf _building; +_index = (Format ["WFBE_%1STRUCTURENAMES",sideJoinedText] Call GetNamespace) find _type; +if (_index != -1) then { + _distance = (Format ["WFBE_%1STRUCTUREDISTANCES",sideJoinedText] Call GetNamespace) select _index; + _direction = (Format ["WFBE_%1STRUCTUREDIRECTIONS",sideJoinedText] Call GetNamespace) select _index; + _factoryType = (Format ["WFBE_%1STRUCTURES",sideJoinedText] Call GetNamespace) select _index; + _position = [getPos _building,_distance,getDir _building + _direction] Call GetPositionFrom; + _longest = Format ["WFBE_LONGEST%1BUILDTIME",_factoryType] Call GetNamespace; +} else { + if (_type in WFDEPOT) then { + _distance = depotDistance; + _direction = depotDirection; + _factoryType = "Depot"; + }; + if (_type in WFHANGAR) then { + _distance = airportDistance; + _direction = airportDirection; + _factoryType = "Airport"; + }; + _position = [getPos _building,_distance,getDir _building + _direction] Call GetPositionFrom; + _longest = Format ["WFBE_LONGEST%1BUILDTIME",_factoryType] Call GetNamespace; +}; + +_unique = varQueu; +varQueu = (random 10)+(random 100)+(random 1000); +_queu = _building getVariable "queu"; +if (isNil "_queu") then {_queu = []}; +_queu = _queu + [_unique]; +_building setVariable ["queu",_queu,true]; + +_ret = 0; +_queu2 = [0]; + +if (count _queu > 0) then {_queu2 = _building getVariable "queu"}; + +_show = false; +while {_unique != _queu select 0 && alive _building && !isNull _building} do { + sleep 4; + _show = true; + _ret = _ret + 4; + _queu = _building getVariable "queu"; + + 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"; + }; +}; + +if (_show) then {hint(parseText(Format [localize "STR_WF_INFO_BuyEffective",_description]))}; + +sleep _waitTime; + +_queu = _building getVariable "queu"; +_queu = _queu - [_unique]; +_building setVariable ["queu",_queu,true]; + +_group = group player; +if !(alive _building) exitWith { + unitQueu = unitQueu - _cpt; + [Format["WFBE_C_QUEUE_%1",_factory],(Format["WFBE_C_QUEUE_%1",_factory] Call GetNamespace)-1,true] Call SetNamespace; +}; + +_created = objNull; +if (_isMan) then { + _soldier = [_unit,_group,_position,sideJoined] Call CreateMan; + _created = _soldier; + [sideJoinedText,'UnitsCreated',1] Call UpdateStatistics; +} else { + _driver = _vehi select 0; + _gunner = _vehi select 1; + _commander = _vehi select 2; + _extracrew = _vehi select 3; + _locked = _vehi select 4; + _vehicle = [_unit,_position,sideJoined,_locked] Call CreateVehi; + _created = _vehicle; + clientTeam reveal _vehicle; + _factoryPosition = getPos _building; + _vehicle setDir -((((_position select 1) - (_factoryPosition select 1)) atan2 ((_position select 0) - (_factoryPosition select 0))) - 90); + _vehicle setVelocity [0,0,-1]; + _vehicles = (WF_Logic getVariable "emptyVehicles") + [_vehicle]; + WF_Logic setVariable ["emptyVehicles",_vehicles,true]; + + if (isHostedServer) then {_vehicle setVariable ["WFBE_Taxi_Prohib", true]}; + + //--- Clear the vehicle. + clearWeaponCargo _vehicle; + clearMagazineCargo _vehicle; + + /* Section: Init */ + + //--- Units that can lift vehicles. + if (_unit in Zeta_Lifter) then { + _upgrades = (sideJoinedText) Call GetSideUpgrades; + if (_upgrades select 8 > 0) then {_vehicle addAction [localize "STR_WF_Lift","Client\Module\ZetaCargo\Zeta_Hook.sqf"]}; + }; + + //--- Lock / Unlock. + _vehicle addAction [localize "STR_WF_Unlock","Client\Action\Action_ToggleLock.sqf", [], 95, false, true, '', 'alive _target && locked _target']; + _vehicle addAction [localize "STR_WF_Lock","Client\Action\Action_ToggleLock.sqf", [], 94, false, true, '', 'alive _target && !(locked _target)']; + + //--- Repair Truck. + if (_unit in (Format['WFBE_%1REPAIRTRUCKS',sideJoinedText] Call GetNamespace)) then { + if (('WFBE_VICTORYCONDITION' Call GetNamespace) != 1) then { + _vehicle setVehicleInit Format ["this addAction [localize 'STR_WF_BuildMenu_Repair','Client\Action\Action_BuildRepair.sqf', [], 99, false, true, '', 'side player == side _target && alive _target && player distance _target <= %1'];this addAction [localize 'STR_WF_Repair_MHQ','Client\Action\Action_RepairMHQ.sqf', [], 98, false, true, '', 'alive _target']",'WFBE_REPAIRTRUCKRANGE' Call GetNamespace]; + } else { + _vehicle setVehicleInit Format ["this addAction [localize 'STR_WF_BuildMenu_Repair','Client\Action\Action_BuildRepair.sqf', [], 99, false, true, '', 'side player == side _target && alive _target && player distance _target <= %1']",'WFBE_REPAIRTRUCKRANGE' Call GetNamespace]; + }; + processInitCommands; + }; + + //--- Supply Truck. + if (_unit in (Format['WFBE_%1SUPPLYTRUCKS',sideJoinedText] Call GetNamespace)) then {[_vehicle,sideJoined] ExecFSM 'Client\FSM\updatesupply.fsm'}; + + //--- Salvage Truck. + if (_unit in (Format['WFBE_%1SALVAGETRUCK',sideJoinedText] Call GetNamespace)) then {[_vehicle] ExecFSM 'Client\FSM\updatesalvage.fsm'}; + + //--- Deal with ship units. + if (_unit isKindOf "Ship") then {_vehicle addAction [localize "STR_WF_Push","Client\Action\Action_Push.sqf", [], 93, false, true, "", "driver _target == _this && alive _target && speed _target < 30"]}; + + //--- Deal with Air units. + if (_unit isKindOf "Air") then { + _init = ""; + + //--- Add HALO + Cargo Eject to the vehicle if it can transport soldiers. + if !(_isMan) then { + if ((getNumber (configFile >> 'CfgVehicles' >> _unit >> 'transportSoldier')) > 0) then { + _init = _init + Format["this AddAction ['HALO','Client\Action\Action_HALO.sqf', [], 97, false, true, '', 'getPos _target select 2 >= %1 && alive _target'];this addAction [localize 'STR_WF_Cargo_Eject','Client\Action\Action_EjectCargo.sqf', [], 99, false, true, '', 'driver _target == _this && alive _target'];",('WFBE_HALOJUMPHEIGHT' Call GetNamespace)]; + }; + }; + + //--- Countermeasures parameter (Vanilla). + if (paramCounterMeasures) then { + _upgrades = (sideJoinedText) Call GetSideUpgrades; + if (_upgrades select 9 > 0) then {_init = _init + "nullReturn = [this] ExecVM 'Client\Module\CM\CM_Init.sqf';this addEventHandler ['incomingMissile',{_this Spawn CM_Countermeasures}];"}; + }; + + //--- AAR Tracking. + if (paramAARadar) then {_init = _init + Format["nullReturn = [this,%1] ExecVM 'Common\Common_AARadarMarkerUpdate.sqf';",sideJoined]}; + + //--- Planes have a Taxi Reverse feature. + if (_unit isKindOf "Plane") then {_vehicle addAction [localize "STR_WF_TaxiReverse","Client\Action\Action_TaxiReverse.sqf", [], 92, false, true, "", "driver _target == _this && alive _target && speed _target < 4 && speed _target > -4 && getPos _target select 2 < 4"]}; + + //--- Process the init. + if (_init != "") then {_vehicle setVehicleInit _init; processInitCommands}; + }; + + //--- Units Balancing. + if (_unit in ('WFBE_BALANCEDUNITS' Call GetNamespace) && paramBalancing) then {[_vehicle] Spawn BalanceInit}; + + //--- Are we dealing with an artillery unit. + _isArtillery = [_unit,sideJoinedText] Call IsArtillery; + if (_isArtillery != -1) then {[_vehicle,_isArtillery,sideJoinedText] Call EquipArtillery}; + + /* Section: Creation */ + + [sideJoinedText,'VehiclesCreated',1] Call UpdateStatistics; + _built = 0; + _group addVehicle _vehicle; + + //--- Empty Vehicle. + if (!_driver && !_gunner && !_commander) exitWith {}; + + //--- Crew Management. + _crew = Format ["WFBE_%1SOLDIER",sideJoinedText] Call GetNamespace; + if (_unit isKindOf "Tank") then {_crew = Format ["WFBE_%1CREW",sideJoinedText] Call GetNamespace}; + if (_unit isKindOf "Air") then {_crew = Format ["WFBE_%1PILOT",sideJoinedText] Call GetNamespace}; + + //--- Driver. + if (_driver) then { + _soldier = [_crew,_group,_position,sideJoined] Call CreateMan; + [_soldier] allowGetIn true; + _soldier moveInDriver _vehicle; + }; + + //--- Gunner. + if (_gunner) then { + _soldier = [_crew,_group,_position,sideJoined] Call CreateMan; + [_soldier] allowGetIn true; + _soldier moveInGunner _vehicle; + }; + + //--- Commander. + if (_commander) then { + _soldier = [_crew,_group,_position,sideJoined] Call CreateMan; + [_soldier] allowGetIn true; + _soldier moveInCommander _vehicle; + }; + + //--- Extra vehicle turrets. + if (_extracrew) then { + Private ["_turrets"]; + _turrets = _currentUnit select QUERYUNITTURRETS; + + { + if (isNull (_vehicle turretUnit _x)) then { + _soldier = [_crew,_group,_position,sideJoined] Call CreateMan; + [_soldier] allowGetIn true; + _soldier moveInTurret [_vehicle, _x]; + }; + } forEach _turrets; + }; + [sideJoinedText,'UnitsCreated',_cpt] Call UpdateStatistics; +}; + +unitQueu = unitQueu - _cpt; + +[Format["WFBE_C_QUEUE_%1",_factory],(Format["WFBE_C_QUEUE_%1",_factory] Call GetNamespace)-1,true] Call SetNamespace; +hint parseText(Format [localize "STR_WF_INFO_Build_Complete",_description]); \ No newline at end of file diff --git a/Client/Functions/Client_ChangePlayerFunds.sqf b/Client/Functions/Client_ChangePlayerFunds.sqf new file mode 100644 index 0000000..6732640 --- /dev/null +++ b/Client/Functions/Client_ChangePlayerFunds.sqf @@ -0,0 +1 @@ +[clientTeam, _this] Call ChangeTeamFunds; \ No newline at end of file diff --git a/Client/Functions/Client_CommandChatMessage.sqf b/Client/Functions/Client_CommandChatMessage.sqf new file mode 100644 index 0000000..38de886 --- /dev/null +++ b/Client/Functions/Client_CommandChatMessage.sqf @@ -0,0 +1 @@ +player commandChat _this; \ No newline at end of file diff --git a/Client/Functions/Client_CommanderUpgrade.sqf b/Client/Functions/Client_CommanderUpgrade.sqf new file mode 100644 index 0000000..366fa31 --- /dev/null +++ b/Client/Functions/Client_CommanderUpgrade.sqf @@ -0,0 +1,34 @@ +private ["_i","_index","_index2","_name","_time","_upgrades"]; +_time = _this select 0; +_index = _this select 1; +_index2 = _this select 2; +_name = _this select 3; +isUpgrading = true; + +hint Format [localize "STR_WF_Upgrade_Start",_name]; + +WFBE_RequestChangeScore = ['SRVFNCREQUESTCHANGESCORE',[player,score player + ('WFBE_COMMANDERUPGRADESCORE' Call GetNamespace)]]; +publicVariable 'WFBE_RequestChangeScore'; +if (!isMultiplayer || (isServer && local player)) then {['SRVFNCREQUESTCHANGESCORE',[player,score player + ('WFBE_COMMANDERUPGRADESCORE' Call GetNamespace)]] Spawn HandleSPVF}; + +_i = _time; +while {_i > 0} do { + _i = _i - 1; + upgradingTime = _i; + sleep 1; +}; +_upgrades = (sideJoinedText) Call GetSideUpgrades; +_upgrades Set [_index,_index2 + 1]; +Call Compile Format ["%1Upgrades = _upgrades; publicVariable '%1Upgrades';",sideJoinedText]; +upgradingTime = -1; +isUpgrading = false; +hint Format [localize "STR_WF_Upgrade_Complete",_name,_index2 + 1]; +WFBE_LocalizeMessage = [sideJoined,'CLTFNCLOCALIZEMESSAGE',['UpgradeComplete',_index,(_index2 + 1)]]; +publicVariable 'WFBE_LocalizeMessage'; +if (!isMultiplayer || (isServer && local player) || local player) then {[sideJoined,'CLTFNCLOCALIZEMESSAGE',['UpgradeComplete',_index,(_index2 + 1)]] Spawn HandlePVF}; + +sleep 0.3; + +WFBE_RequestSpecial = ['SRVFNCREQUESTSPECIAL',['upgrade',sideJoined]]; +publicVariable 'WFBE_RequestSpecial'; +if (!isMultiplayer || (isServer && local player)) then {['SRVFNCREQUESTSPECIAL',['upgrade',sideJoined]] Spawn HandleSPVF}; diff --git a/Client/Functions/Client_DebugHint.sqf b/Client/Functions/Client_DebugHint.sqf new file mode 100644 index 0000000..5c6af51 --- /dev/null +++ b/Client/Functions/Client_DebugHint.sqf @@ -0,0 +1,8 @@ +Private ["_string"]; + +_string = _this; +if (isMultiplayer) then { + hint _string; +} else { + hintC _string; +}; \ No newline at end of file diff --git a/Client/Functions/Client_DisplayInventory.sqf b/Client/Functions/Client_DisplayInventory.sqf new file mode 100644 index 0000000..7765609 --- /dev/null +++ b/Client/Functions/Client_DisplayInventory.sqf @@ -0,0 +1,98 @@ +Private ['_cost','_count','_get','_inventoryGUI','_inventorySlots','_items','_loadout','_misca','_miscInvGUI','_miscItemSlots','_primary','_secondary','_sidearm','_sidearmInvGUI','_sidearmInventorySlots','_slot','_sorted']; +_loadout = _this select 0; +_items = _this select 1; + +_inventoryGUI = 3503; +_sidearmInvGUI = 3515; +_miscInvGUI = 3523; + +for [{_count = 0},{_count < 12},{_count = _count + 1}] do {CtrlSetText[_inventoryGUI + _count,"\Ca\UI\Data\ui_gear_mag_gs.paa"]}; +for [{_count = 0},{_count < 8},{_count = _count + 1}] do {CtrlSetText[_sidearmInvGUI + _count,"\Ca\UI\Data\ui_gear_mag_gs.paa"]}; +for [{_count = 0},{_count < 12},{_count = _count + 1}] do {CtrlSetText[_miscInvGUI + _count,"\Ca\UI\Data\ui_gear_eq_gs.paa"]}; + +_cost = 0; +_slot = 0; +_inventorySlots = []; +_sidearmInventorySlots = []; +_miscItemSlots = []; + +_primary = []; +_secondary = []; +_sidearm = []; +_misca = []; + +{ + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + switch (_get select QUERYGEARTYPE) do { + case 'primary': {_primary = _primary + [_x]}; + case 'secondary': {_secondary = _secondary + [_x]}; + case 'sidearm': {_sidearm = _sidearm + [_x]}; + case 'CfgMagazines': {_misca = _misca + [_x]}; + case 'CfgWeapons': {_misca = _misca + [_x]}; + }; + }; + +} forEach _loadout; + +_sorted = _primary + _secondary + _misca; +_sidearm = _sidearm + _misca; + +{ + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + if (!(_get select QUERYGEARHANDGUNPOOL)) then { + ctrlSetText[_inventoryGUI + _slot,(_get select QUERYGEARPICTURE)]; + _cost = _cost + (_get select QUERYGEARCOST); + _slot = _slot + 1; + _inventorySlots = _inventorySlots + [_x]; + for [{_count = (_get Select QUERYGEARSPACE) - 1},{_count > 0},{_count = _count - 1}] do { + ctrlSetText[_inventoryGUI + _slot,""]; + _slot = _slot + 1; + _inventorySlots = _inventorySlots + [""]; + }; + }; + }; +} forEach _sorted; + +_slot = 0; + +{ + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + if (_get select QUERYGEARHANDGUNPOOL) then { + ctrlSetText[_sidearmInvGUI + _slot,(_get select QUERYGEARPICTURE)]; + _cost = _cost + (_get select QUERYGEARCOST); + _slot = _slot + 1; + _sidearmInventorySlots = _sidearmInventorySlots + [_x]; + for [{_count = (_get Select QUERYGEARSPACE) - 1},{_count > 0},{_count = _count - 1}] do { + ctrlSetText[_sidearmInvGUI + _slot,""]; + _slot = _slot + 1; + _sidearmInventorySlots = _sidearmInventorySlots + [""]; + }; + }; + }; +} forEach _sidearm; + +_slot = 0; + +{ + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + CtrlSetText[_miscInvGUI + _slot,(_get select QUERYGEARPICTURE)]; + _slot = _slot + 1; + _miscItemSlots = _miscItemSlots + [_x]; + _cost = _cost + (_get select QUERYGEARCOST); + for [{_count = (_get Select QUERYGEARSPACE) - 1},{_count > 0},{_count = _count - 1}] do { + ctrlSetText[_miscInvGUI + _slot,""]; + _slot = _slot + 1; + _miscItemSlots = _miscItemSlots + [""]; + }; + }; +} forEach _items; + +[_inventorySlots,_sidearmInventorySlots,_miscItemSlots,_cost] \ No newline at end of file diff --git a/Client/Functions/Client_EquipDefaultLoadout.sqf b/Client/Functions/Client_EquipDefaultLoadout.sqf new file mode 100644 index 0000000..29c2f45 --- /dev/null +++ b/Client/Functions/Client_EquipDefaultLoadout.sqf @@ -0,0 +1,17 @@ +private ["_unit", "_defaultWeap", "_defaultAmmo"]; + +_unit = _this; + +_defaultWeap = Format ["WFBE_%1DEFAULTWEAPONS",sideJoinedText] Call GetNamespace; +_defaultAmmo = Format ["WFBE_%1DEFAULTAMMO",sideJoinedText] Call GetNamespace; + +if (paramAceWounds) then +{ + _defaultAmmo = _defaultAmmo + [ 'ACE_Bandage', 'ACE_Bandage', 'ACE_Morphine', 'ACE_Morphine' ]; + if(getNumber(configFile >> "CfgVehicles" >> (typeOf _unit) >> "attendant") == 1) then + { + _defaultAmmo = _defaultAmmo + [ 'ACE_Epinephrine', 'ACE_Epinephrine', 'ACE_Medkit', 'ACE_Medkit' ]; + }; +}; + +[_unit,_defaultWeap,_defaultAmmo] Call EquipLoadout; \ No newline at end of file diff --git a/Client/Functions/Client_FX.sqf b/Client/Functions/Client_FX.sqf new file mode 100644 index 0000000..7fc9d21 --- /dev/null +++ b/Client/Functions/Client_FX.sqf @@ -0,0 +1,50 @@ +Private ["_index"]; +_index = _this select 0; + +switch (_index) do { + case 0: { + // None. + "colorCorrections" ppEffectEnable false; + "chromAberration" ppEffectEnable false; + "radialBlur" ppEffectEnable false; + "filmGrain" ppEffectEnable false; + }; + case 1: { + // High contrast postprocess added. + "colorCorrections" ppEffectAdjust [1, 0.9, -0.002, [0.0, 0.0, 0.0, 0.0], [1.0, 0.6, 0.4, 0.6], [0.199, 0.587, 0.114, 0.0]]; + "colorCorrections" ppEffectCommit 1; + "colorCorrections" ppEffectEnable true; + }; + case 2: { + // Blue color corrections added (movie night style). + "colorCorrections" ppEffectAdjust [1, 1, 0, [0.0, 0.0, 0.0, 0.0], [0.6, 0.6, 1.8, 0.7], [0.199, 0.587, 0.114, 0.0]]; + "colorCorrections" ppEffectCommit 1; + "colorCorrections" ppEffectEnable true; + }; + case 3: { + // Color corrections. + "colorCorrections" ppEffectAdjust [1, 0.8, -0.002, [0.0, 0.0, 0.0, 0.0], [0.6, 0.7, 0.8, 0.65], [0.199, 0.587, 0.114, 0.0]]; + "colorCorrections" ppEffectCommit 1; + "colorCorrections" ppEffectEnable true; + }; + case 4: { + // Color corrections. + "colorCorrections" ppEffectAdjust [1, 1, -0.0045, [0.0, 0.0, 0.0, 0.0], [1, 0.6, 0.4, 0.4], [0.199, 0.587, 0.114, 0.0]]; + "colorCorrections" ppEffectCommit 1; + "colorCorrections" ppEffectEnable true; + // Light film grain. + "filmGrain" ppEffectEnable true; + "filmGrain" ppEffectAdjust [0.02, 1, 1, 0.1, 1, false]; + "filmGrain" ppEffectCommit 1; + }; + case 5: { + // Color corrections. + "colorCorrections" ppEffectAdjust [1, 1, -0.002, [0.1, 0.05, 0.0, 0.02], [1.2, 1.0, 0.8, 0.666], [0.5, 0.5, 0.5, 0.0]]; + "colorCorrections" ppEffectCommit 1; + "colorCorrections" ppEffectEnable true; + // Light film grain. + "filmGrain" ppEffectEnable true; + "filmGrain" ppEffectAdjust [0.02, 1, 1, 0.1, 1, false]; + "filmGrain" ppEffectCommit 1; + }; +}; \ No newline at end of file diff --git a/Client/Functions/Client_GetIncome.sqf b/Client/Functions/Client_GetIncome.sqf new file mode 100644 index 0000000..c3e2529 --- /dev/null +++ b/Client/Functions/Client_GetIncome.sqf @@ -0,0 +1,33 @@ +Private["_commanderTeam","_income","_incomeSystem","_side"]; + +_side = _this; +_incomeSystem = 'WFBE_INCOMESYSTEM' Call GetNamespace; +_income = (_side) Call GetTownsIncome; + +switch (_incomeSystem) do { + case 2: {_income = round(_income /2)}; + case 3: { + Private["_ply"]; + _commanderTeam = (_side) Call GetCommanderTeam; + if (isNull _commanderTeam) then {_commanderTeam = grpNull}; + _ply = round(_income * (((100 - (Call Compile Format ["%1CommanderPercent",_side]))/100)/maxPlayers)); + if (_commanderTeam == group player) then { + _income = round((_income * ((Call Compile Format ["%1CommanderPercent",_side])/100)) / ('WFBE_INC_DIVIDE_COM' Call GetNamespace)) + _ply; + } else { + _income = _ply; + }; + }; + case 4: { + Private["_ply"]; + _commanderTeam = (_side) Call GetCommanderTeam; + if (isNull _commanderTeam) then {_commanderTeam = grpNull}; + _ply = round(_income * (100 - (Call Compile Format ["%1CommanderPercent",_side])) / 100); + if (_commanderTeam == group player) then { + _income = _ply + round((_income - _ply)*maxPlayers); + } else { + _income = _ply; + }; + }; +}; + +_income \ No newline at end of file diff --git a/Client/Functions/Client_GetMarkerColoration.sqf b/Client/Functions/Client_GetMarkerColoration.sqf new file mode 100644 index 0000000..33920a6 --- /dev/null +++ b/Client/Functions/Client_GetMarkerColoration.sqf @@ -0,0 +1 @@ +Private ["_color","_colorationMode","_colorFor"]; _colorFor = _this; _colorationMode = 'WFBE_MAPCOLORATION' Call GetNamespace; _color = ""; switch (_colorFor) do { case "Friendly": { switch (_colorationMode) do { case 0: {_color = "ColorGreen"}; case 1: {_color = if (sideJoined == west) then {"ColorBlue"} else {"ColorRed"}}; }; }; case "Enemy": { switch (_colorationMode) do { case 0: {_color = "ColorRed"}; case 1: {_color = if (sideJoined == west) then {"ColorRed"} else {"ColorBlue"}}; }; }; case "Resistance": { switch (_colorationMode) do { case 0: {_color = "ColorBlue"}; case 1: {_color = "ColorGreen"}; }; }; case "Leader": { switch (_colorationMode) do { case 0: {_color = "ColorBlue"}; case 1: {_color = "ColorBlue"}; }; }; }; _color \ No newline at end of file diff --git a/Client/Functions/Client_GetPlayerFunds.sqf b/Client/Functions/Client_GetPlayerFunds.sqf new file mode 100644 index 0000000..6c8989d --- /dev/null +++ b/Client/Functions/Client_GetPlayerFunds.sqf @@ -0,0 +1 @@ +(clientTeam) Call GetTeamFunds \ No newline at end of file diff --git a/Client/Functions/Client_GetRespawnAvailable.sqf b/Client/Functions/Client_GetRespawnAvailable.sqf new file mode 100644 index 0000000..4155ee8 --- /dev/null +++ b/Client/Functions/Client_GetRespawnAvailable.sqf @@ -0,0 +1,58 @@ +Private ["_availableSpawn","_buildings","_checks","_deathLoc","_farps","_hq","_mobileRespawns","_range","_side","_sideText","_upgrades"]; + +_side = _this select 0; +_deathLoc = _this select 1; +_sideText = str _side; + +//--- Base. +_hq = (_sideText) Call GetSideHQ; +_availableSpawn = [_hq]; +_buildings = (_sideText) Call GetSideStructures; +_checks = [_side,Format ["WFBE_%1BARRACKSTYPE",_sideText] Call GetNamespace,_buildings] Call GetFactories; +if (count _checks > 0) then {_availableSpawn = _availableSpawn + _checks}; +_checks = [_side,Format ["WFBE_%1LIGHTTYPE",_sideText] Call GetNamespace,_buildings] Call GetFactories; +if (count _checks > 0) then {_availableSpawn = _availableSpawn + _checks}; +_checks = [_side,Format ["WFBE_%1COMMANDCENTERTYPE",_sideText] Call GetNamespace,_buildings] Call GetFactories; +if (count _checks > 0) then {_availableSpawn = _availableSpawn + _checks}; +_checks = [_side,Format ["WFBE_%1HEAVYTYPE",_sideText] Call GetNamespace,_buildings] Call GetFactories; +if (count _checks > 0) then {_availableSpawn = _availableSpawn + _checks}; +_checks = [_side,Format ["WFBE_%1AIRCRAFTTYPE",_sideText] Call GetNamespace,_buildings] Call GetFactories; +if (count _checks > 0) then {_availableSpawn = _availableSpawn + _checks}; +_checks = [_side,Format ["WFBE_%1SERVICEPOINTTYPE",_sideText] Call GetNamespace,_buildings] Call GetFactories; +if (count _checks > 0) then {_availableSpawn = _availableSpawn + _checks}; + +//--- HQ is dead, but we can spawn at other buildings. +if (!alive _hq && count _availableSpawn > 1) then {_availableSpawn = _availableSpawn - [_hq]}; + +//--- Mobile respawn. +if (paramMobileRespawn) then { + _mobileRespawns = Format ["WFBE_%1AMBULANCES",_sideText] Call GetNamespace; + _upgrades = (_sideText) Call GetSideUpgrades; + _range = (Format["WFBE_RESPAWNMOBILERANGE%1",(_upgrades select 7)] Call GetNamespace); + _checks = _deathLoc nearEntities[_mobileRespawns,_range]; + if (count _checks > 0) then { + { + if (_x emptyPositions "cargo" > 0) then { + _availableSpawn = _availableSpawn + [_x]; + }; + } forEach _checks; + }; +}; + +//--- MASH. +if (paramRespawnMASH) then { + _farps = Format ["WFBE_%1FARP",_sideText] Call GetNamespace; + _upgrades = (_sideText) Call GetSideUpgrades; + _range = (Format["WFBE_RESPAWNMOBILERANGE%1",(_upgrades select 7)] Call GetNamespace); + _checks = nearestObjects [_deathLoc, [_farps], _range]; + if (count _checks > 0) then { + {if (alive _x) then {_availableSpawn = _availableSpawn + [_x]}} forEach _checks; + }; +}; + +//--- Camps. +if (('WFBE_RESPAWNCAMPSMODE' Call GetNamespace) > 0) then { + _availableSpawn = _availableSpawn + ([_deathLoc, _side] Call GetRespawnCamps); +}; + +_availableSpawn \ No newline at end of file diff --git a/Client/Functions/Client_GetStructureMarkerLabel.sqf b/Client/Functions/Client_GetStructureMarkerLabel.sqf new file mode 100644 index 0000000..50e14bb --- /dev/null +++ b/Client/Functions/Client_GetStructureMarkerLabel.sqf @@ -0,0 +1,16 @@ +Private["_class","_label","_structure"]; + +_structure = _this Select 0; + +_label = ""; +_class = TypeOf _structure; + +if (_class == EASTBAR || _class == WESTBAR) then {_label = "B"}; +if (_class == EASTLVF || _class == WESTLVF) then {_label = "L"}; +if (_class == EASTCC || _class == WESTCC) then {_label = "C"}; +if (_class == EASTHEAVY || _class == WESTHEAVY) then {_label = "H"}; +if (_class == EASTAIR || _class == WESTAIR) then {_label = "A"}; +if (_class == EASTSP || _class == WESTSP) then {_label = "S"}; +if (_class == EASTAAR || _class == WESTAAR) then {_label = "AAR"}; + +_label \ No newline at end of file diff --git a/Client/Functions/Client_GetTime.sqf b/Client/Functions/Client_GetTime.sqf new file mode 100644 index 0000000..995efdc --- /dev/null +++ b/Client/Functions/Client_GetTime.sqf @@ -0,0 +1 @@ +Private ["_days","_hours","_minutes","_seconds","_uptime"]; _days = 0; _hours = 0; _minutes = 0; _seconds = 0; _uptime = time; _days = floor(_uptime / 86400); _hours = floor((_uptime - (_days * 86400)) / 3600); _minutes = floor((_uptime - (_hours * 3600) - (_days * 86400)) / 60); _seconds = floor(_uptime - (_minutes * 60) - (_hours * 3600) -(_days * 86400)); [_days,_hours,_minutes,_seconds] \ No newline at end of file diff --git a/Client/Functions/Client_GroupChatMessage.sqf b/Client/Functions/Client_GroupChatMessage.sqf new file mode 100644 index 0000000..f13fb76 --- /dev/null +++ b/Client/Functions/Client_GroupChatMessage.sqf @@ -0,0 +1 @@ +player groupChat _this \ No newline at end of file diff --git a/Client/Functions/Client_HandleHQAction.sqf b/Client/Functions/Client_HandleHQAction.sqf new file mode 100644 index 0000000..b8e4e60 --- /dev/null +++ b/Client/Functions/Client_HandleHQAction.sqf @@ -0,0 +1,12 @@ +Private ['_hq']; +_hq = _this; + +if (isNull _hq) exitWith {}; + +/* Lag Handler */ +while {!isNull _hq} do { + canBuildWHQ = false; + sleep 0.21; +}; + +canBuildWHQ = true; \ No newline at end of file diff --git a/Client/Functions/Client_HandleOnMap.sqf b/Client/Functions/Client_HandleOnMap.sqf new file mode 100644 index 0000000..c98f961 --- /dev/null +++ b/Client/Functions/Client_HandleOnMap.sqf @@ -0,0 +1,17 @@ +Private ['_isOnMap','_timeToKill']; + +_timeToKill = 'WFBE_OFFMAPMAXTIME' Call GetNamespace; +paramBoundariesRunning = true; + +while {true} do { + sleep 1; + _isOnMap = Call BoundariesIsOnMap; + if !(_isOnMap) then { + hint parseText(Format[localize 'STR_WF_INFO_OffmapWarning',_timeToKill]); + _timeToKill = _timeToKill - 1; + }; + if (_timeToKill < 0 || _isOnMap || !(alive player)) exitWith { + if !(_isOnMap && alive player) then {(vehicle player) setDamage 1}; + paramBoundariesRunning = false; + }; +}; \ No newline at end of file diff --git a/Client/Functions/Client_HandlePVF.sqf b/Client/Functions/Client_HandlePVF.sqf new file mode 100644 index 0000000..3d61118 --- /dev/null +++ b/Client/Functions/Client_HandlePVF.sqf @@ -0,0 +1,30 @@ +/* + description: + - New network system handler. + destination: + - Nil: Everyone + - String: vehicleVarName of the unit to trigger on. + - Side: A side + note: + - addPublicVariableEventHandler is triggered everywhere BUT on the caller. + usage: + - [destination,client PVF to run,parameters] +*/ + +Private ["_destination","_exit","_parameters","_publicVar","_script"]; +_publicVar = _this; +_exit = true; + +_destination = _publicVar select 0; +if (isNil '_destination') then {_destination = 0;_exit = false}; +if (typeName(_destination) == 'SIDE') then {if (sideJoined == _destination) then {_exit = false}}; +if (typeName(_destination) == 'STRING') then { + if (vehicleVarName player == _destination) then {_exit = false}; +}; + +if (_exit) exitWith {}; + +_script = _publicVar select 1; +_parameters = if (count _this > 2) then {_publicVar select 2} else {[]}; + +_parameters Spawn (Call Compile _script); \ No newline at end of file diff --git a/Client/Functions/Client_InitTownsAndCamps.sqf b/Client/Functions/Client_InitTownsAndCamps.sqf new file mode 100644 index 0000000..cdddcbc --- /dev/null +++ b/Client/Functions/Client_InitTownsAndCamps.sqf @@ -0,0 +1,40 @@ +Private ["_camp","_campSideID","_camps","_count","_count1","_marker","_town","_townSideID"]; + +for [{_count = totalTowns - 1},{_count >= 0},{_count = _count - 1}] do { + _town = towns select _count; + _townSideID = _town getVariable "sideID"; + + if (sideID == _townSideID) then { + _marker = Format["%1Depot",str _town]; + _marker setMarkerColorLocal ("Friendly" Call GetMarkerColoration); + }; + + while {true} do { + sleep .005; + _camps = _town getVariable "camps"; + if !(isNil "_camps") exitWith {}; + }; + _camps = _town getVariable "camps"; + + for [{_count1 = count _camps - 1},{_count1 >= 0},{_count1 = _count1 - 1}] do { + _camp = _camps select _count1; + if !(isNull _camp) then { + _marker = Format["%1Camp%2",str _town,_camps find _camp]; + + while {true} do { + sleep .005; + _campSideID = _camp getVariable "sideID"; + if !(isNil "_campSideID") exitWith {}; + }; + _campSideID = _camp getVariable "sideID"; + + if (sideID == _campSideID) then { + _marker setMarkerColorLocal ("Friendly" Call GetMarkerColoration); + } else{ + if (_townSideID == sideID) then { + _marker setMarkerColorLocal ("Enemy" Call GetMarkerColoration); + }; + }; + }; + }; +}; \ No newline at end of file diff --git a/Client/Functions/Client_IsOnMap.sqf b/Client/Functions/Client_IsOnMap.sqf new file mode 100644 index 0000000..db72724 --- /dev/null +++ b/Client/Functions/Client_IsOnMap.sqf @@ -0,0 +1,17 @@ +Private ['_adis','_bdis','_borderdis','_boundary','_difx','_dify','_dir','_position','_positiondis','_sqrradH','_sqrradHR']; + +_boundary = 'WFBE_BOUNDARIESXY' Call GetNamespace; +_sqrradH = _boundary / 2; +_sqrradHR = [_sqrradH,_sqrradH]; +_position = [getPos player select 0, getPos player select 1]; + +_difx = (_position select 0) - _sqrradH; +_dify = (_position select 1) - _sqrradH; +_dir = atan (_difx / _dify); +if (_dify < 0) then {_dir = _dir + 180}; +_adis = abs (_sqrradH / cos (90 - _dir)); +_bdis = abs (_sqrradH / cos _dir); +_borderdis = _adis min _bdis; +_positiondis = _position distance _sqrradHR; + +if (_positiondis < _borderdis) then {true} else {false} \ No newline at end of file diff --git a/Client/Functions/Client_MarkerAnim.sqf b/Client/Functions/Client_MarkerAnim.sqf new file mode 100644 index 0000000..beb85b2 --- /dev/null +++ b/Client/Functions/Client_MarkerAnim.sqf @@ -0,0 +1,45 @@ +Private ["_additionalErase","_direction","_expand","_markerColor","_markerMax","_markerMin","_markerName","_markerPosition","_markerSize","_markerType"]; +_markerName = _this select 0; +_markerPosition = _this select 1; +_markerType = _this select 2; +_markerSize = _this select 3; +_markerColor = _this select 4; +_markerMin = _this select 5; +_markerMax = _this select 6; +_additionalErase = ""; +if (count _this > 7) then {_additionalErase = _this select 7}; + +deleteMarkerLocal _markerName; +CreateMarkerLocal [_markerName,_markerPosition]; +_markerName setMarkerTypeLocal _markerType; +_markerName setMarkerColorLocal _markerColor; +_markerName setMarkerSizeLocal [_markerSize,_markerSize]; + +_difference = (_markerMax - _markerMin)/10; +_direction = 0; +_expand = true; +activeAnimMarker = true; + +if (_additionalErase != "") then { + Private ["_pr"]; + _pr = 'WFBE_PATROLRANGE' Call GetNamespace; + createMarkerLocal [_additionalErase,_markerPosition]; + _additionalErase setMarkerShapeLocal "Ellipse"; + _additionalErase setMarkerColorLocal _markerColor; + _additionalErase setMarkerSizeLocal [_pr,_pr]; +}; + +while {activeAnimMarker} do { + sleep 0.03; + + _direction = (_direction + 1) % 360; + _markerName setMarkerDirLocal _direction; + _markerName setMarkerSizeLocal [_markerSize,_markerSize]; + + if (_markerSize > _markerMax) then {_expand = false}; + if (_markerSize < _markerMin) then {_expand = true}; + if (_expand) then {_markerSize = _markerSize + _difference} else {_markerSize = _markerSize - _difference}; +}; + +deleteMarkerLocal _markerName; +if (_additionalErase != "") then {deleteMarkerLocal _additionalErase}; \ No newline at end of file diff --git a/Client/Functions/Client_OnRespawnHandler.sqf b/Client/Functions/Client_OnRespawnHandler.sqf new file mode 100644 index 0000000..fe6c57d --- /dev/null +++ b/Client/Functions/Client_OnRespawnHandler.sqf @@ -0,0 +1,78 @@ +Private ["_buildings","_charge","_funds","_loadDefault","_listbp","_mode","_price","_safeArray","_skip","_spawn","_spawnInside","_temp","_unit","_weaps"]; + +_unit = _this select 0; +_spawn = _this select 1; +_loadDefault = true; + +//--- Respawn. +_spawnInside = false; +if ((typeOf _spawn) in (Format ["WFBE_%1AMBULANCES",sideJoinedText] Call GetNamespace) && alive _spawn) then { + if (_spawn emptyPositions "cargo" > 0 && !(locked _spawn)) then {_unit moveInCargo _spawn;_spawnInside = true}; +}; + +if !(_spawnInside) then {_unit setPos ([getPos _spawn,10,20] Call GetRandomPosition)}; + +//--- Loadout. +if (!isNil "respawnWeapons" && !WFBE_RespawnDefaultGear) then { + _mode = 'WFBE_RESPAWNPENALTY' Call GetNamespace; + + if (_mode in [0,2,3,4,5]) then { + //--- Calculate the price/funds. + if (_mode != 0) then { + _price = 0; + + //--- Get the mode pricing. + switch (_mode) do { + case 2: {_price = respawnGearCost}; + case 3: {_price = round(respawnGearCost/2)}; + case 4: {_price = round(respawnGearCost/4)}; + case 5: {_price = respawnGearCost}; + }; + + //--- Are we charging only on mobile respawn? + _charge = true; + if (_mode == 5) then { + _buildings = (sideJoinedText) Call GetSideStructures; + if (_spawn in _buildings || _spawn == ((sideJoinedText) Call GetSideHQ)) then {_charge = false}; + }; + + if (_charge) then { + //--- Charge if possible. + _funds = Call GetPlayerFunds; + if (_funds < _price) then { + // Just take it down to zero. + _price = _funds; + }; + -(_price) Call ChangePlayerFunds; + (Format[localize 'STR_WF_CHAT_Gear_RespawnCharge',_price]) Call GroupChatMessage; + }; + }; + + //--- Use the respawn loadout. + if(WF_ACE) then + { + [player, respawnWeapons, respawnAmmo] Call EquipLoadout; + player setVariable ["ACE_weapononback", respawnWeaponOnBack]; + _safeArray = respawnAceRuckContents select 1; + player setVariable ["ACE_RuckMagContents", +_safeArray]; + _safeArray = respawnAceRuckContents select 0; + player setVariable ["ACE_RuckWepContents", +_safeArray]; + } + else + { + _temp = +(respawnWeapons); + _listbp = 'WFBE_BACKPACKS' Call GetNamespace; + {if (_x in _listbp) then {_temp = _temp - [_x]}} forEach respawnWeapons; + _weaps = _temp; + + [_unit,_weaps,respawnAmmo] Call EquipLoadout; + if !(WF_A2_Vanilla) then {Call RespawningBag}; + }; + _loadDefault = false; + }; +}; + +//--- Load the default loadout. +if (_loadDefault) then { + player Call EquipDefaultLoadout; +}; \ No newline at end of file diff --git a/Client/Functions/Client_PreRespawnHandler.sqf b/Client/Functions/Client_PreRespawnHandler.sqf new file mode 100644 index 0000000..189fe60 --- /dev/null +++ b/Client/Functions/Client_PreRespawnHandler.sqf @@ -0,0 +1,15 @@ +Private ["_hq","_unit"]; + +_unit = _this; + +(_unit) Call WFBE_SK_FNC_Apply; +[] ExecFSM "Client\FSM\updateactions.fsm"; + +Options = _unit addAction ["" + (localize "STR_WF_Options") + "","Client\Action\Action_Menu.sqf", "", 1, false, true, "", "_target == player"]; + +if (!isNull commanderTeam) then { + _hq = (sideJoinedText) Call GetSideHQ; + if (commanderTeam == group _unit) then {HQAction = _unit addAction [localize "STR_WF_BuildMenu","Client\Action\Action_Build.sqf", [_hq], 100, false, true, "", "hqInRange && canBuildWHQ && (_target == player)"]}; +}; + +[sideJoinedText,'UnitsCreated',1] Call UpdateStatistics; \ No newline at end of file diff --git a/Client/Functions/Client_ReplaceArray.sqf b/Client/Functions/Client_ReplaceArray.sqf new file mode 100644 index 0000000..b05136c --- /dev/null +++ b/Client/Functions/Client_ReplaceArray.sqf @@ -0,0 +1,12 @@ +Private ['_array','_indexExcluded','_newArray','_z']; +_array = _this select 0; +_indexExcluded = _this select 1; + +_newArray = []; +for [{_z = 0},{_z < count(_array)},{_z = _z + 1}] do { + if (_z != _indexExcluded) then { + _newArray = _newArray + [_array select _z]; + }; +}; + +_newArray \ No newline at end of file diff --git a/Client/Functions/Client_ReplaceInventoryAmmo.sqf b/Client/Functions/Client_ReplaceInventoryAmmo.sqf new file mode 100644 index 0000000..810e4e2 --- /dev/null +++ b/Client/Functions/Client_ReplaceInventoryAmmo.sqf @@ -0,0 +1,65 @@ +Private ['_freeSpace','_futureSpace','_get','_limit','_magazines','_newMag','_newMagIsSide','_newMagSpace','_oldMags','_presentMags','_replacement','_rlIndex','_size','_spaceToReduce','_totalToReplace','_z']; +_newMag = _this select 0; +_oldMags = _this select 1; +_magazines = _this select 2; + +_presentMags = []; +_replacement = []; +_size = 0; +_spaceToReduce = 0; + +{ + Private['_cmag','_ct']; + _cmag = _x; + _ct = {_x == _cmag} count _oldMags; + + if (_ct > 0) then { + _get = _cmag Call GetNamespace; + _presentMags = _presentMags + [_cmag]; + _spaceToReduce = _spaceToReduce + (_get select QUERYGEARSPACE); + }; +} forEach _magazines; + +if (_newMag == "") exitWith {_magazines - _presentMags}; + +_get = _newMag Call GetNamespace; +_newMagSpace = _get select QUERYGEARSPACE; +_newMagIsSide = _get select QUERYGEARHANDGUNPOOL; +_limit = if (_newMagIsSide) then {8} else {12}; + +if (_newMagIsSide) then { + { + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + if (_get select QUERYGEARHANDGUNPOOL) then { + _size = _size + (_get select QUERYGEARSPACE); + }; + }; + } forEach _magazines; +} else { + { + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + if !(_get select QUERYGEARHANDGUNPOOL) then { + _size = _size + (_get select QUERYGEARSPACE); + }; + }; + } forEach _magazines; +}; + +_totalToReplace = count _presentMags; +_freeSpace = _size - _spaceToReduce; + +_futureSpace = _totalToReplace * _newMagSpace; +while {(_futureSpace + _freeSpace) > _limit} do { + _totalToReplace = _totalToReplace - 1; + _futureSpace = _totalToReplace * _newMagSpace; +}; + +for [{_z = 0},{_z < _totalToReplace},{_z = _z + 1}] do {_replacement = _replacement + [_newMag]}; + +_magazines = (_magazines - _presentMags) + _replacement; + +_magazines \ No newline at end of file diff --git a/Client/Functions/Client_RequestFireMission.sqf b/Client/Functions/Client_RequestFireMission.sqf new file mode 100644 index 0000000..8657fa7 --- /dev/null +++ b/Client/Functions/Client_RequestFireMission.sqf @@ -0,0 +1,25 @@ +Private ["_count","_destination","_index","_type","_units"]; + +_destination = _this select 0; +_index = _this select 1; +_type = 0; + +scopeName "FireMission"; + +_units = [group player,false,_index,sideJoinedText] Call GetTeamArtillery; + +if (count _units < 1) exitWith {}; +_type = ((Format ['WFBE_%1_ARTILLERY_NAMES',sideJoinedText] Call GetNamespace) select _index) find (typeOf (_units select 0)); + +if (_type < 0) exitWith {_type}; + +_units = [group player,false,_index,sideJoinedText] Call GetTeamArtillery; +if (Count _units < 1) then {breakTo "FireMission"}; + +for [{_count = count _units - 1},{_count >= 0},{_count = _count - 1}] do { + [_units select _count,_destination,Side player,artyRange,_index] Spawn FireArtillery; +}; + +//Keep weapons reloaded. +_units = [Group player,true,_index,sideJoinedText] Call GetTeamArtillery; +{if (!someAmmo _x) then {[_x,sideJoinedText] Call RearmVehicle}} forEach _units; \ No newline at end of file diff --git a/Client/Functions/Client_RespawnBag.sqf b/Client/Functions/Client_RespawnBag.sqf new file mode 100644 index 0000000..dd20527 --- /dev/null +++ b/Client/Functions/Client_RespawnBag.sqf @@ -0,0 +1,33 @@ +private ["_add"]; + +if !(isNil 'respawnBag') then { + _add = false; + /* Player did purchase a backpack and have one by default */ + if !(isNull (unitBackPack player)) then { + /* If the backpack type is different from the current one, then we remove it */ + if (typeOf (unitBackPack player) != respawnBag) then { + removeBackpack player; + _add = true; + }; + } else { + _add = true; + }; + + /* We give a new backpack to the player */ + if (_add) then {player addBackpack respawnBag}; + + /* We clear the new backpack content */ + clearMagazineCargo (unitBackpack player); + + /* We add the player's backpack content inside the new one */ + if (count (respawnBagContent select 0) > 0) then { + for '_u' from 0 to count(respawnBagContent select 0)-1 do { + (unitBackpack player) addMagazineCargo [(respawnBagContent select 0) select _u, (respawnBagContent select 1) select _u]; + }; + }; +} else { + /* Player did not purchase a backpack but have one by default */ + if !(isNull (unitBackPack player)) then { + removeBackpack player; + }; +}; \ No newline at end of file diff --git a/Client/Functions/Client_ReturnArraySortAsc.sqf b/Client/Functions/Client_ReturnArraySortAsc.sqf new file mode 100644 index 0000000..82b1bcb --- /dev/null +++ b/Client/Functions/Client_ReturnArraySortAsc.sqf @@ -0,0 +1,30 @@ +/* Only use string ! */ +Private['_ammo','_asciAr','_copy','_i','_index','_k','_list','_lowest','_unit','_weapon','_weapons']; + +_list = _this; +_temp = []; + +_asciAr = []; +/* Get the ascii value */ +{ + _asciAr = _asciAr + [(toArray(_x)) select 0]; +} forEach _list; +_copy = +_asciAr; + +_lowest = 100000; +_index = -1; +for [{_i = 0},{_i < count _asciAr},{_i = _i + 1}] do { + /* Get Lowest */ + for [{_k = 0},{_k < count _copy},{_k = _k + 1}] do { + if (_lowest > (_copy select _k) && (_copy select _k) != -1) then { + _lowest = _copy select _k; + _index = _k; + }; + }; + + _temp = _temp + [_index]; + _copy set [_index, -1]; + _lowest = 100000; +}; + +_temp \ No newline at end of file diff --git a/Client/Functions/Client_SetControlFadeAnim.sqf b/Client/Functions/Client_SetControlFadeAnim.sqf new file mode 100644 index 0000000..941de91 --- /dev/null +++ b/Client/Functions/Client_SetControlFadeAnim.sqf @@ -0,0 +1,28 @@ +Private ["_color","_control","_duration","_text","_textcontent"]; +_control = _this select 0; +_text = _this select 1; +_duration = _this select 2; +_color = _this select 3; + +//--- Animate. +_textcontent = parsetext (Format["%2",_color,_text]); +with uinamespace do { + (currentBEDialog displayCtrl _control) ctrlSetStructuredText _textcontent; + (currentBEDialog displayCtrl _control) ctrlShow true; +}; + +_i = 0; +while {_i < _duration} do { + with uinamespace do { + (currentBEDialog displayCtrl _control) ctrlSetFade (_i % 2); + (currentBEDialog displayCtrl _control) ctrlCommit 1; + }; + + _i = _i + 1; + sleep 1; +}; + +with uinamespace do { + (currentBEDialog displayCtrl _control) ctrlSetStructuredText parseText (""); + (currentBEDialog displayCtrl _control) ctrlShow false; +}; \ No newline at end of file diff --git a/Client/Functions/Client_SetControlFadeAnimStop.sqf b/Client/Functions/Client_SetControlFadeAnimStop.sqf new file mode 100644 index 0000000..6f39abe --- /dev/null +++ b/Client/Functions/Client_SetControlFadeAnimStop.sqf @@ -0,0 +1,9 @@ +Private ["_control","_duration","_text","_textcontent"]; +_control = _this select 0; + +with uinamespace do { + if !(ctrlShown (currentBEDialog displayCtrl _control)) exitWith {}; + + (currentBEDialog displayCtrl _control) ctrlSetStructuredText parseText (""); + (currentBEDialog displayCtrl _control) ctrlShow false; +}; \ No newline at end of file diff --git a/Client/Functions/Client_SetGroupsID.sqf b/Client/Functions/Client_SetGroupsID.sqf new file mode 100644 index 0000000..6c6ab62 --- /dev/null +++ b/Client/Functions/Client_SetGroupsID.sqf @@ -0,0 +1,13 @@ +Private ["_m","_milalpha","_u"]; + +_milalpha = ["Alpha","Bravo","Charlie","Delta","Echo","Foxtrot","Golf","Hotel","India","Juliet","Kilo","Lima","Mike", +"November","Oscar","Papa","Quebec","Romeo","Sierra","Tango","Uniform","Victor","Whiskey","X-Ray","Yankee","Zulu", +"Razor","Fatman","StarForce","Frostbite","Battlemage","Manhattan","Firefly","Swordsman","Sabre","Hammer","Reaper", +"Anvil","Fortune"]; + +_u = 0; +_m = count _milalpha; +{ + if !(isNil '_x' && _u < _m) then {_x setGroupID [_milalpha select _u]}; + _u = _u + 1; +} forEach clientTeams \ No newline at end of file diff --git a/Client/Functions/Client_SupportHeal.sqf b/Client/Functions/Client_SupportHeal.sqf new file mode 100644 index 0000000..4680487 --- /dev/null +++ b/Client/Functions/Client_SupportHeal.sqf @@ -0,0 +1,99 @@ +Private ['_airCoef','_artCoef','_cts','_distanceMin','_heaCoef','_healTime','_i','_ligCoef','_name','_nearIsDP','_nearIsRT','_nearIsSP','_repairRange','_spType','_supportRange','_supports','_typeRepair','_veh']; +_veh = _this select 0; +_supports = _this select 1; +_typeRepair = _this select 2; +_spType = _this select 3; +_supportRange = 'WFBE_SUPPORTRANGE' Call GetNamespace; +_repairRange = 'WFBE_REPAIRTRUCKRANGE' Call GetNamespace; + +//--- Retrieve Informations. +_name = [typeOf _veh, 'displayName'] Call GetConfigInfo; +_healTime = 'WFBE_SUPPORTHEALTIME' Call GetNamespace; + +//--- SP? +_nearIsSP = false; +_nearIsDP = false; +_nearIsRT = false; +{ + if ((typeOf _x) == _spType) then {_nearIsSP = true}; + if ((typeOf _x) in WFDEPOT) then {_nearIsDP = true}; + if ((typeOf _x) in _typeRepair) then {_nearIsRT = true}; +} forEach _supports; + +//--- Coefficient Vary depending on the support type. +_airCoef = 1; +_artCoef = 1; +_heaCoef = 1; +_ligCoef = 1; +if (_nearIsRT) then { + _airCoef = 2.8; + _artCoef = 2.4; + _heaCoef = 2.2; + _ligCoef = 2.0; +}; +if (_nearIsDP) then { + _airCoef = 2.3; + _artCoef = 2.1; + _heaCoef = 1.9; + _ligCoef = 1.7; +}; +if (_nearIsSP) then { + _airCoef = 1.8; + _artCoef = 1.6; + _heaCoef = 1.4; + _ligCoef = 1.2; +}; + +//--- Class Malus. +if (_veh isKindOf 'Air') then {_healTime = round(_healTime * (_airCoef + getDammage _veh))}; +if (_veh isKindOf 'StaticWeapon') then {_healTime = round(_healTime * (_artCoef + getDammage _veh))}; +if (_veh isKindOf 'Tank') then {_healTime = round(_healTime * (_heaCoef + getDammage _veh))}; +if (_veh isKindOf 'Car' || _veh isKindOf 'Motorcycle') then {_healTime = round(_healTime * (_ligCoef + getDammage _veh))}; + +//--- Inform the player. +hint parseText(Format[localize "STR_WF_INFO_Healing",_name,_healTime]); + +//--- Make sure that we still have something as a support. +_cts = 0; +_i = 0; +while {true} do { + sleep 1; + + //--- Check the distance & alive. + _cts = 0; + { + _distanceMin = if ((typeOf _x) in _typeRepair) then {_repairRange} else {_supportRange}; + if ((alive _x) && ((_veh distance _x) < _distanceMin)) then {_cts = _cts + 1}; + } forEach _supports; + + _i = _i + 1; + + if (_cts == 0 || !(alive _veh) || (getPos _veh) select 2 > 2) exitWith {hint parseText(Format[localize "STR_WF_INFO_Heal_Failed",_name])}; + if (_i >= _healTime) exitWith {hint parseText(Format[localize "STR_WF_INFO_Heal_Success",_name])}; +}; + +//--- Heal the damages? +if (_cts != 0) then { + if (_veh isKindOf "Man") then { + _veh setDammage 0; + if (paramAceWounds) then + { + _veh call ace_sys_wounds_fnc_RemoveBleed; + _veh call ace_sys_wounds_fnc_RemovePain; + _vel call ace_sys_wounds_fnc_RemoveUncon; + }; + } else { + _crews = crew _veh; + if (count _crews > 0) then { + { + _x setDammage 0; + if (paramAceWounds) then + { + _x call ace_sys_wounds_fnc_RemoveBleed; + _x call ace_sys_wounds_fnc_RemovePain; + _x call ace_sys_wounds_fnc_RemoveUncon; + }; + } forEach _crews + }; + }; +}; \ No newline at end of file diff --git a/Client/Functions/Client_SupportRearm.sqf b/Client/Functions/Client_SupportRearm.sqf new file mode 100644 index 0000000..ac2697e --- /dev/null +++ b/Client/Functions/Client_SupportRearm.sqf @@ -0,0 +1,78 @@ +Private ['_airCoef','_artCoef','_cts','_distanceMin','_heaCoef','_i','_ligCoef','_name','_nearIsDP','_nearIsRT','_nearIsSP','_repairRange','_rearmTime','_spType','_supportRange','_supports','_typeRepair','_veh']; +_veh = _this select 0; +_supports = _this select 1; +_typeRepair = _this select 2; +_spType = _this select 3; +_supportRange = 'WFBE_SUPPORTRANGE' Call GetNamespace; +_repairRange = 'WFBE_REPAIRTRUCKRANGE' Call GetNamespace; + +//--- Retrieve Informations. +_name = [typeOf _veh, 'displayName'] Call GetConfigInfo; +_rearmTime = 'WFBE_SUPPORTREARMTIME' Call GetNamespace; + +//--- SP? +_nearIsSP = false; +_nearIsDP = false; +_nearIsRT = false; +{ + if ((typeOf _x) == _spType) then {_nearIsSP = true}; + if ((typeOf _x) in WFDEPOT) then {_nearIsDP = true}; + if ((typeOf _x) in _typeRepair) then {_nearIsRT = true}; +} forEach _supports; + +//--- Coefficient Vary depending on the support type. +_airCoef = 1; +_artCoef = 1; +_heaCoef = 1; +_ligCoef = 1; +if (_nearIsRT) then { + _airCoef = 3.4; + _artCoef = 3; + _heaCoef = 2.8; + _ligCoef = 2.6; +}; +if (_nearIsDP) then { + _airCoef = 2.5; + _artCoef = 2.4; + _heaCoef = 2.2; + _ligCoef = 2; +}; +if (_nearIsSP) then { + _airCoef = 1.9; + _artCoef = 1.7; + _heaCoef = 1.5; + _ligCoef = 1.2; +}; + +//--- Class Malus. +if (_veh isKindOf 'Air') then {_rearmTime = round(_rearmTime * _airCoef)}; +if (_veh isKindOf 'StaticWeapon') then {_rearmTime = round(_rearmTime * _artCoef)}; +if (_veh isKindOf 'Tank') then {_rearmTime = round(_rearmTime * _heaCoef)}; +if (_veh isKindOf 'Car' || _veh isKindOf 'Motorcycle') then {_rearmTime = round(_rearmTime * _ligCoef)}; + +//--- Inform the player. +hint parseText(Format[localize "STR_WF_INFO_Rearming",_name,_rearmTime]); + +//--- Make sure that we still have something as a support. +_cts = 0; +_i = 0; +while {true} do { + sleep 1; + + //--- Check the distance & alive. + _cts = 0; + { + _distanceMin = if ((typeOf _x) in _typeRepair) then {_repairRange} else {_supportRange}; + if ((alive _x) && ((_veh distance _x) < _distanceMin)) then {_cts = _cts + 1}; + } forEach _supports; + + _i = _i + 1; + + if (_cts == 0 || !(alive _veh) || (getPos _veh) select 2 > 2) exitWith {hint parseText(Format[localize "STR_WF_INFO_Rearm_Failed",_name])}; + if (_i >= _rearmTime) exitWith {hint parseText(Format[localize "STR_WF_INFO_Rearm_Success",_name])}; +}; + +//--- Rearm? +if (_cts != 0) then { + [_veh,sideJoined] Spawn RearmVehicle; +}; \ No newline at end of file diff --git a/Client/Functions/Client_SupportRefuel.sqf b/Client/Functions/Client_SupportRefuel.sqf new file mode 100644 index 0000000..25cef76 --- /dev/null +++ b/Client/Functions/Client_SupportRefuel.sqf @@ -0,0 +1,78 @@ +Private ['_airCoef','_artCoef','_cts','_distanceMin','_heaCoef','_i','_ligCoef','_name','_nearIsDP','_nearIsRT','_nearIsSP','_repairRange','_refTime','_spType','_supportRange','_supports','_typeRepair','_veh']; +_veh = _this select 0; +_supports = _this select 1; +_typeRepair = _this select 2; +_spType = _this select 3; +_supportRange = 'WFBE_SUPPORTRANGE' Call GetNamespace; +_repairRange = 'WFBE_REPAIRTRUCKRANGE' Call GetNamespace; + +//--- Retrieve Informations. +_name = [typeOf _veh, 'displayName'] Call GetConfigInfo; +_refTime = 'WFBE_SUPPORTREFUELTIME' Call GetNamespace; + +//--- SP? +_nearIsSP = false; +_nearIsDP = false; +_nearIsRT = false; +{ + if ((typeOf _x) == _spType) then {_nearIsSP = true}; + if ((typeOf _x) in WFDEPOT) then {_nearIsDP = true}; + if ((typeOf _x) in _typeRepair) then {_nearIsRT = true}; +} forEach _supports; + +//--- Coefficient Vary depending on the support type. +_airCoef = 1; +_artCoef = 1; +_heaCoef = 1; +_ligCoef = 1; +if (_nearIsRT) then { + _airCoef = 2.8; + _artCoef = 2.4; + _heaCoef = 2.2; + _ligCoef = 2.0; +}; +if (_nearIsDP) then { + _airCoef = 2.3; + _artCoef = 2.1; + _heaCoef = 1.9; + _ligCoef = 1.7; +}; +if (_nearIsSP) then { + _airCoef = 1.8; + _artCoef = 1.6; + _heaCoef = 1.4; + _ligCoef = 1.2; +}; + +//--- Class Malus. +if (_veh isKindOf 'Air') then {_refTime = round(_refTime * (_airCoef + (1 - fuel _veh)))}; +if (_veh isKindOf 'StaticWeapon') then {_refTime = round(_refTime * (_artCoef + (1 - fuel _veh)))}; +if (_veh isKindOf 'Tank') then {_refTime = round(_refTime * (_heaCoef + (1 - fuel _veh)))}; +if (_veh isKindOf 'Car' || _veh isKindOf 'Motorcycle') then {_refTime = round(_refTime * (_ligCoef + (1 - fuel _veh)))}; + +//--- Inform the player. +hint parseText(Format[localize "STR_WF_INFO_Refueling",_name,_refTime]); + +//--- Make sure that we still have something as a support. +_cts = 0; +_i = 0; +while {true} do { + sleep 1; + + //--- Check the distance & alive. + _cts = 0; + { + _distanceMin = if ((typeOf _x) in _typeRepair) then {_repairRange} else {_supportRange}; + if ((alive _x) && ((_veh distance _x) < _distanceMin)) then {_cts = _cts + 1}; + } forEach _supports; + + _i = _i + 1; + + if (_cts == 0 || !(alive _veh) || (getPos _veh) select 2 > 2) exitWith {hint parseText(Format[localize "STR_WF_INFO_Refueling_Failed",_name])}; + if (_i >= _refTime) exitWith {hint parseText(Format[localize "STR_WF_INFO_Refueling_Success",_name])}; +}; + +//--- Refuel the vehicle? +if (_cts != 0) then { + _veh setFuel 1; +}; \ No newline at end of file diff --git a/Client/Functions/Client_SupportRepair.sqf b/Client/Functions/Client_SupportRepair.sqf new file mode 100644 index 0000000..57169f2 --- /dev/null +++ b/Client/Functions/Client_SupportRepair.sqf @@ -0,0 +1,78 @@ +Private ['_airCoef','_artCoef','_cts','_distanceMin','_heaCoef','_i','_ligCoef','_name','_nearIsDP','_nearIsRT','_nearIsSP','_repairRange','_repTime','_spType','_supportRange','_supports','_typeRepair','_veh']; +_veh = _this select 0; +_supports = _this select 1; +_typeRepair = _this select 2; +_spType = _this select 3; +_supportRange = 'WFBE_SUPPORTRANGE' Call GetNamespace; +_repairRange = 'WFBE_REPAIRTRUCKRANGE' Call GetNamespace; + +//--- Retrieve Informations. +_name = [typeOf _veh, 'displayName'] Call GetConfigInfo; +_repTime = 'WFBE_SUPPORTREPAIRTIME' Call GetNamespace; + +//--- SP? +_nearIsSP = false; +_nearIsDP = false; +_nearIsRT = false; +{ + if ((typeOf _x) == _spType) then {_nearIsSP = true}; + if ((typeOf _x) in WFDEPOT) then {_nearIsDP = true}; + if ((typeOf _x) in _typeRepair) then {_nearIsRT = true}; +} forEach _supports; + +//--- Coefficient Vary depending on the support type. +_airCoef = 1; +_artCoef = 1; +_heaCoef = 1; +_ligCoef = 1; +if (_nearIsRT) then { + _airCoef = 2.4; + _artCoef = 1.8; + _heaCoef = 1.6; + _ligCoef = 1.4; +}; +if (_nearIsDP) then { + _airCoef = 1.9; + _artCoef = 1.5; + _heaCoef = 1.3; + _ligCoef = 1.1; +}; +if (_nearIsSP) then { + _airCoef = 1.4; + _artCoef = 1; + _heaCoef = 0.8; + _ligCoef = 0.6; +}; + +//--- Class Malus. +if (_veh isKindOf 'Air') then {_repTime = round(_repTime * (_airCoef + getDammage _veh))}; +if (_veh isKindOf 'StaticWeapon') then {_repTime = round(_repTime * (_artCoef + getDammage _veh))}; +if (_veh isKindOf 'Tank') then {_repTime = round(_repTime * (_heaCoef + getDammage _veh))}; +if (_veh isKindOf 'Car' || _veh isKindOf 'Motorcycle') then {_repTime = round(_repTime * (_ligCoef + getDammage _veh))}; + +//--- Inform the player. +hint parseText(Format[localize "STR_WF_INFO_Repairing",_name,_repTime]); + +//--- Make sure that we still have something as a support. +_cts = 0; +_i = 0; +while {true} do { + sleep 1; + + //--- Check the distance & alive. + _cts = 0; + { + _distanceMin = if ((typeOf _x) in _typeRepair) then {_repairRange} else {_supportRange}; + if ((alive _x) && ((_veh distance _x) < _distanceMin)) then {_cts = _cts + 1}; + } forEach _supports; + + _i = _i + 1; + + if (_cts == 0 || !(alive _veh) || (getPos _veh) select 2 > 2) exitWith {hint parseText(Format[localize "STR_WF_INFO_Repair_Failed",_name])}; + if (_i >= _repTime) exitWith {hint parseText(Format[localize "STR_WF_INFO_Repair_Success",_name])}; +}; + +//--- Fix the damages? +if (_cts != 0) then { + _veh setDammage 0; +}; \ No newline at end of file diff --git a/Client/Functions/Client_TaskSystem.sqf b/Client/Functions/Client_TaskSystem.sqf new file mode 100644 index 0000000..3072fb2 --- /dev/null +++ b/Client/Functions/Client_TaskSystem.sqf @@ -0,0 +1,69 @@ +Private ["_i","_location","_locations","_next","_sideID","_sorted","_task","_type"]; +_type = _this select 0; +_location = if (count _this > 1) then {_this select 1} else {objNull}; + +switch (_type) do { + //--- Complete Towns set initialization. + case "TownAddComplete": { + //--- Todo: improve the sort by with other digits instead of the first one. + sleep 4; + Private ["_addOrder","_returned","_town","_towns","_townsLabel"]; + _townsLabel = []; + {_townsLabel = _townsLabel + [_x getVariable 'name']} forEach towns; + _towns = ([_townsLabel,true,towns] Call CIPHER_SortArray) select 1; + + for '_i' from 0 to count(_towns)-1 do { + _town = _towns select _i; + waitUntil {_sideID = _town getVariable 'sideID';!isNil '_sideID'}; + _sideID = _town getVariable "sideID"; + _task = player createSimpleTask [Format["TakeTowns_%1",str _town]]; + if (_sideID != sideID) then { + _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"]]; + } else { + _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown_Complete",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_town getVariable "name"]]; + _task setTaskState "Succeeded"; + }; + _task setSimpleTaskDestination (getPos _town); + _town setVariable ['taskLink',_task]; + }; + + ["TownAssignClosest"] Spawn TaskSystem; + }; + + //--- Assign the closest town to the player. + case "TownAssignClosest": { + sleep 4; + _next = [player,sideJoined] Call GetClosestLocationBySide; + if !(isNull _next) then { + ["TownHintNew",_next] Spawn TaskSystem; + _task = (_next getVariable 'taskLink'); + /* Keep the commander order ! */ + if (!isNull comTask) then { + if (taskState comTask == "Succeeded") then {player setCurrentTask _task}; + } else { + player setCurrentTask _task; + }; + }; + }; + + //--- Update a town's value. + case "TownUpdate": { + _task = _location getVariable 'taskLink'; + _sideID = _location getVariable "sideID"; + if !(isNil '_task') then { + if (_sideID == sideID) then { + _task setTaskState "Succeeded"; + _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown_Complete",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]]; + } else { + _task setTaskState "Created"; + _task setSimpleTaskDescription [Format[localize "STR_WF_TaskTown",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"], Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]]; + }; + } + }; + + //--- Hint for a new town task. + case "TownHintNew": {taskHint [format [localize "str_taskNew" + "\n%1",Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]], [1,1,1,1], "taskNew"]}; + + //--- Hint for a completed town task. + case "TownHintDone": {taskHint [format [localize "str_taskAccomplished" + "\n%1",Format [localize "STR_WF_CHAT_TaskTown_Display",_location getVariable "name"]], [1,1,1,1], "taskDone"]}; +}; \ No newline at end of file diff --git a/Client/Functions/Client_TitleTextMessage.sqf b/Client/Functions/Client_TitleTextMessage.sqf new file mode 100644 index 0000000..113e55b --- /dev/null +++ b/Client/Functions/Client_TitleTextMessage.sqf @@ -0,0 +1,7 @@ +Private["_message","_style"]; + +_message = _this Select 0; +_style = "PLAIN"; +if (Count _this > 1) then {_style = _this Select 1}; + +12451 cutText ["\n\n\n\n\n\n\n" + _message,_style]; \ No newline at end of file diff --git a/Client/Functions/Client_UIAddItem.sqf b/Client/Functions/Client_UIAddItem.sqf new file mode 100644 index 0000000..b7e84f6 --- /dev/null +++ b/Client/Functions/Client_UIAddItem.sqf @@ -0,0 +1,11 @@ +Private ['_items','_limit','_mag','_size']; +_items = _this select 0; +_mag = _this select 1; +_size = 0; +_limit = 12; + +{_size = _size + 1} forEach _items; + +if (_size + 1 <= _limit) then {_items = _items + [_mag]}; + +_items \ No newline at end of file diff --git a/Client/Functions/Client_UIAddMagazine.sqf b/Client/Functions/Client_UIAddMagazine.sqf new file mode 100644 index 0000000..509c515 --- /dev/null +++ b/Client/Functions/Client_UIAddMagazine.sqf @@ -0,0 +1,35 @@ +private ["_get","_limit","_newMagSpace","_newMagSideInv","_mag","_magazines","_size"]; +_magazines = _this select 0; +_mag = _this select 1; +_size = 0; +_limit = 12; + +_get = _mag Call GetNamespace; +_newMagSpace = _get select QUERYGEARSPACE; +_newMagSideInv = _get select QUERYGEARHANDGUNPOOL; +_limit = if (_newMagSideInv) then {8} else {12}; + +if (_newMagSideInv) then { + { + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + if (_get select QUERYGEARHANDGUNPOOL) then { + _size = _size + (_get select QUERYGEARSPACE); + }; + }; + } forEach _magazines; +} else { + { + _get = _x Call GetNamespace; + + if !(isNil '_get') then { + if !(_get select QUERYGEARHANDGUNPOOL) then { + _size = _size + (_get select QUERYGEARSPACE); + }; + }; + } forEach _magazines; +}; + +if (_size + _newMagSpace <= _limit) then {_magazines = _magazines + [_mag]}; +_magazines \ No newline at end of file diff --git a/Client/Functions/Client_UIChangeComboBuyUnits.sqf b/Client/Functions/Client_UIChangeComboBuyUnits.sqf new file mode 100644 index 0000000..6867d89 --- /dev/null +++ b/Client/Functions/Client_UIChangeComboBuyUnits.sqf @@ -0,0 +1,15 @@ +Private['_get','_lb','_type']; +_lb = _this select 0; +_type = _this select 1; + +lbClear _lb; +{ + lbAdd [_lb,_x]; +} forEach (Format["WFBE_%1%2FACTIONS",sideJoinedText,_type] Call GetNamespace); + +_get = Format["WFBE_%1%2CURRENTFACTIONSELECTED",sideJoinedText,_type] Call GetNamespace; +if (isNil '_get') then { + lbSetCurSel [_lb,0]; +} else { + lbSetCurSel [_lb,_get]; +}; \ No newline at end of file diff --git a/Client/Functions/Client_UIFillListBuyUnits.sqf b/Client/Functions/Client_UIFillListBuyUnits.sqf new file mode 100644 index 0000000..78e8881 --- /dev/null +++ b/Client/Functions/Client_UIFillListBuyUnits.sqf @@ -0,0 +1,35 @@ +Private ['_addin','_c','_currentUpgrades','_filler','_filter','_i','_listBox','_listNames','_u','_value']; +_listNames = _this select 0; +_filler = _this select 1; +_listBox = _this select 2; +_value = _this select 3; +_u = 0; +_i = 0; + +_currentUpgrades = (sideJoinedText) Call GetSideUpgrades; +_filter = Format["WFBE_%1%2CURRENTFACTIONSELECTED",sideJoinedText,_filler] Call GetNamespace; +if (isNil '_filter') then {_filter = "nil"} else { + if (_filter == 0) then { + _filter = 'nil'; + } else { + _filter = ((Format["WFBE_%1%2FACTIONS",sideJoinedText,_filler] Call GetNamespace) select _filter); + }; +}; + +lnbClear _listBox; +{ + _addin = true; + _c = _x Call GetNamespace; + if (_filter != "nil") then { + if ((_c select QUERYUNITFACTION) != _filter) then {_addin = false}; + }; + if ((_c select QUERYUNITUPGRADE) <= (_currentUpgrades select _value) && _addin) then { + lnbAddRow [_listBox,['$'+str (_c select QUERYUNITPRICE),(_c select QUERYUNITLABEL)]]; + lnbSetData [_listBox,[_i,0],_filler]; + lnbSetValue [_listBox,[_i,0],_u]; + _i = _i + 1; + }; + _u = _u + 1; +} forEach _listNames; + +if (_i > 0) then {lnbSetCurSelRow [_listBox,0]} else {lnbSetCurSelRow [_listBox,-1]}; \ No newline at end of file diff --git a/Client/Functions/Client_UIFillListTeamOrders.sqf b/Client/Functions/Client_UIFillListTeamOrders.sqf new file mode 100644 index 0000000..8d3a0f8 --- /dev/null +++ b/Client/Functions/Client_UIFillListTeamOrders.sqf @@ -0,0 +1,42 @@ +Private ['_color','_extra','_i','_isVehicle','_listBox','_listContent','_pic','_unit']; +_listContent = _this select 0; +_listBox = _this select 1; +_i = 0; +_pic = ""; + +lnbClear _listBox; + +{ + _unit = vehicle _x; + _isVehicle = if (_x != _unit) then {true} else {false}; + + _color = []; + _extra = ""; + if (round(((getDammage _unit)*-100)+100) < 75) then { + _color = [0.875, 0.5, 0, 1]; + _extra = "[Injured] "; + if (round(((getDammage _unit)*-100)+100) < 50) then { + _extra = "[Injured] "; + _color = [0.875, 0, 0, 1]; + if !(alive _x) then {_extra = "[Dead]"}; + }; + }; + if (count _color == 0 && _isVehicle) then { + if !(canMove _unit) then { + _extra = "[Immobilized] "; + _color = [0.875, 0.875, 0, 1]; + }; + }; + + lnbAddRow [_listBox,[str(round(((getDammage _unit)*-100)+100)) + "%",_extra+"("+([typeOf _unit, 'displayName'] Call GetConfigInfo)+") "+name _x]]; + _pic = if (_isVehicle) then {[typeOf _unit, 'picture'] Call GetConfigInfo} else {[typeOf _unit, 'portrait'] Call GetConfigInfo}; + lnbSetPicture [_listBox,[_i,1],_pic]; + + if (count _color > 0) then { + lnbSetColor [_listBox,[_i,0],_color]; + lnbSetColor [_listBox,[_i,1],_color]; + }; + _i = _i + 1; +} forEach _listContent; + +if (_i > 0) then {lnbSetCurSelRow [_listBox,0]} else {lnbSetCurSelRow [_listBox,-1]}; \ No newline at end of file diff --git a/Client/Functions/Client_UIFindLBValue.sqf b/Client/Functions/Client_UIFindLBValue.sqf new file mode 100644 index 0000000..ae06622 --- /dev/null +++ b/Client/Functions/Client_UIFindLBValue.sqf @@ -0,0 +1,12 @@ +Private ['_itemsCount','_listbox','_retVal','_value']; +_listbox = _this select 0; +_value = _this select 1; + +_itemsCount = lbSize _listbox; + +_retVal = -1; +for '_i' from 0 to _itemsCount-1 do { + if (lbValue[_listbox, _i] == _value) exitWith {_retVal = _i}; +}; + +_retVal \ No newline at end of file diff --git a/Client/Functions/Client_UIGearFillList.sqf b/Client/Functions/Client_UIGearFillList.sqf new file mode 100644 index 0000000..2eb0d55 --- /dev/null +++ b/Client/Functions/Client_UIGearFillList.sqf @@ -0,0 +1,40 @@ +Private ['_add','_currentGearUpgr','_filler','_get','_i','_listBox','_listNames','_u']; +_listNames = _this select 0; +_filler = _this select 1; +_listBox = _this select 2; +_u = 0; +_i = 0; +_get = []; + +_currentGearUpgr = ((sideJoinedText) Call GetSideUpgrades) select 13; + +{ + /* Get */ + if (_filler == 'secondary' || _filler == 'all') then { + _get = (_x+'_W') Call GetNamespace; + if (isNil '_get') then { + _get = _x Call GetNamespace; + }; + } else { + _get = _x Call GetNamespace; + }; + + if !(isNil '_get') then { + if ((_get select QUERYGEARUPGRADE) <= _currentGearUpgr) then { + _add = true; + if (paramGearRestriction && !gearInRange) then { + if !(_get select QUERYGEARALLOWED) then {_add = false}; + }; + if (_add) then { + lnbAddRow [_listBox,['$'+str (_get Select QUERYGEARCOST),(_get select QUERYGEARLABEL)]]; + lnbSetPicture [_listBox,[_i,0],_get select QUERYGEARPICTURE]; + lnbSetData [_listBox,[_i,0],_filler]; + lnbSetValue [_listBox,[_i,0],_u]; + _i = _i + 1; + }; + }; + }; + _u = _u + 1; +} forEach _listNames; + +lnbSetCurSelRow [_listBox,0] \ No newline at end of file diff --git a/Client/Functions/Client_UIGearFillTemplateList.sqf b/Client/Functions/Client_UIGearFillTemplateList.sqf new file mode 100644 index 0000000..25dc6cc --- /dev/null +++ b/Client/Functions/Client_UIGearFillTemplateList.sqf @@ -0,0 +1,31 @@ +Private ['_add','_currentUpgrades','_filler','_i','_listBox','_listCosts','_listNames','_listPictures','_listUpgrades','_listAllowed','_u']; +_listCosts = _this select 0; +_listNames = _this select 1; +_listPictures = _this select 2; +_listUpgrades = _this select 3; +_listAllowed = _this select 4; +_filler = _this select 5; +_listBox = _this select 6; +_u = 0; +_i = 0; + +_currentUpgrades = (sideJoinedText) Call GetSideUpgrades; + +{ + if ((_listUpgrades select _u) <= (_currentUpgrades select 13)) then { + _add = true; + if (gearRestriction && !gearInRange) then { + if !(_listAllowed select _u) then {_add = false}; + }; + if (_add) then { + lnbAddRow [_listBox,['$'+str (_listCosts Select _u),_x]]; + lnbSetPicture [_listBox,[_i,0],_listPictures select _u]; + lnbSetData [_listBox,[_i,0],_filler]; + lnbSetValue [_listBox,[_i,0],_u]; + _i = _i + 1; + }; + }; + _u = _u + 1; +} forEach _listNames; + +lnbSetCurSelRow [_listBox,0] \ No newline at end of file -- cgit v1.3.1