From dee52083d359434fc3ac51a871c1b836d092d2ac Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:55:41 +0300 Subject: init --- Server/AI/AI_AddMultiplayerRespawnEH.sqf | 1 + Server/AI/AI_AdvancedRespawn.sqf | 119 + Server/AI/AI_Resistance.sqf | 17 + Server/AI/AI_SquadRespawn.sqf | 104 + Server/AI/AI_TLWPHandler.sqs | 39 + Server/AI/AI_UpdateSupplyTruck.sqf | 24 + Server/AI/AI_Upgrade.sqf | 32 + Server/AI/Orders/AI_MoveTo.sqf | 17 + Server/AI/Orders/AI_Patrol.sqf | 34 + Server/AI/Orders/AI_TownPatrol.sqf | 71 + Server/AI/Orders/AI_WPAdd.sqf | 39 + Server/AI/Orders/AI_WPRemove.sqf | 6 + Server/Config/Config_Allies.sqf | 454 ++++ Server/Config/Config_Civilians.sqf | 139 ++ Server/Config/Config_HugeTown.sqf | 13 + Server/Config/Config_HugeTown2.sqf | 13 + Server/Config/Config_LargeTown.sqf | 13 + Server/Config/Config_LargeTown2.sqf | 13 + Server/Config/Config_MediumTown.sqf | 13 + Server/Config/Config_MediumTown1Tank.sqf | 13 + Server/Config/Config_MediumTown2.sqf | 13 + Server/Config/Config_MediumTown2Tank.sqf | 13 + Server/Config/Config_Occupation.sqf | 925 +++++++ Server/Config/Config_Resistance.sqf | 276 +++ Server/Config/Config_SmallTown.sqf | 13 + Server/Config/Config_SmallTown2.sqf | 13 + Server/Config/Config_Town.sqf | 25 + Server/Construction/Construction_HQSite.sqf | 83 + Server/Construction/Construction_MediumSite.sqf | 135 + Server/Construction/Construction_SmallSite.sqf | 126 + .../Construction_StationaryDefense.sqf | 94 + Server/FSM/aibase.fsm | 677 +++++ Server/FSM/aicommander.fsm | 2025 +++++++++++++++ Server/FSM/aiteam.fsm | 1235 ++++++++++ Server/FSM/allies.fsm | 274 +++ Server/FSM/allies_team.fsm | 184 ++ Server/FSM/basearea.fsm | 141 ++ Server/FSM/basepatrol.fsm | 303 +++ Server/FSM/conquest.fsm | 134 + Server/FSM/emptyvehiclescollector.fsm | 102 + Server/FSM/fasttime.fsm | 101 + Server/FSM/garbagecollector.fsm | 165 ++ Server/FSM/missions.fsm | 233 ++ Server/FSM/queryhandler.fsm | 153 ++ Server/FSM/respatrol.fsm | 336 +++ Server/FSM/resstriker.fsm | 303 +++ Server/FSM/supplytruck.fsm | 287 +++ Server/FSM/townpatrol.fsm | 217 ++ Server/FSM/updatecamp.fsm | 259 ++ Server/FSM/updateresources.fsm | 212 ++ Server/FSM/updateserver.fsm | 424 ++++ Server/FSM/updatetown.fsm | 595 +++++ Server/FSM/updatetownai.fsm | 1377 +++++++++++ Server/FSM/updatetowndefenses.fsm | 631 +++++ Server/FSM/updatetownoccupation.fsm | 730 ++++++ Server/FSM/weather.fsm | 100 + Server/FSM/workers.fsm | 323 +++ Server/Functions/Server_AlliesBuyUnit.sqf | 144 ++ Server/Functions/Server_BuildingDamaged.sqf | 18 + Server/Functions/Server_BuildingHandleDamages.sqf | 22 + Server/Functions/Server_BuildingKilled.sqf | 72 + Server/Functions/Server_BuyUnit.sqf | 163 ++ Server/Functions/Server_CanUpdateTeam.sqf | 19 + Server/Functions/Server_ChangeAICommanderFunds.sqf | 7 + Server/Functions/Server_CreateDefenseTemplate.sqf | 36 + Server/Functions/Server_CreateTeam.sqf | 47 + Server/Functions/Server_GetAICommanderFunds.sqf | 1 + Server/Functions/Server_HQKilled.sqf | 46 + Server/Functions/Server_HandleBuildingDamage.sqf | 3 + Server/Functions/Server_HandleBuildingRepair.sqf | 104 + Server/Functions/Server_HandleDefense.sqf | 40 + Server/Functions/Server_HandleEmptyVehicle.sqf | 36 + Server/Functions/Server_HandleReloadDefense.sqf | 71 + Server/Functions/Server_HandleSPVF.sqf | 16 + Server/Functions/Server_HandleSpecial.sqf | 48 + Server/Functions/Server_MHQRepair.sqf | 38 + Server/Functions/Server_PlaceJoiningUnit.sqf | 18 + Server/Functions/Server_SelectOccupTeam.sqf | 41 + Server/Functions/Server_SelectResTeam.sqf | 144 ++ Server/Functions/Server_SetCampsToSide.sqf | 30 + Server/Functions/Server_SideMessage.sqf | 94 + Server/Functions/Server_TrashObject.sqf | 34 + Server/Functions/Server_UpdateTeam.sqf | 8 + Server/Init/Init_Defenses.sqf | 109 + Server/Init/Init_Server.sqf | 532 ++++ Server/Init/Init_Towns.sqf | 214 ++ Server/Missions/M_BASE_Attack/m_init.sqf | 169 ++ Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf | 128 + Server/Missions/M_TOWN_Attack/m_init.sqf | 160 ++ Server/Missions/M_UAV_RetrieveModule/m_init.sqf | 503 ++++ Server/Module/NEURO/NEURO.sqf | 240 ++ Server/Module/UPSMON/Init_UPSMON.sqf | 576 +++++ Server/Module/UPSMON/UPSMON.sqf | 2575 ++++++++++++++++++++ Server/Module/UPSMON/UPSMON/!R/R_functions.sqf | 343 +++ Server/Module/UPSMON/UPSMON/!R/markerAlpha.sqf | 14 + Server/Module/UPSMON/UPSMON/MON_artillery_add.sqf | 64 + Server/Module/UPSMON/UPSMON/MON_spawn.sqf | 115 + Server/Module/UPSMON/UPSMON/MON_surrended.sqf | 23 + Server/Module/UPSMON/UPSMON/actions/followme.sqf | 93 + .../Module/UPSMON/UPSMON/common/MON_functions.sqf | 2204 +++++++++++++++++ Server/PVFunctions/RequestChangeScore.sqf | 12 + Server/PVFunctions/RequestCommanderVote.sqf | 20 + Server/PVFunctions/RequestDefense.sqf | 11 + Server/PVFunctions/RequestJoin.sqf | 28 + Server/PVFunctions/RequestMHQRepair.sqf | 1 + Server/PVFunctions/RequestSpecial.sqf | 1 + Server/PVFunctions/RequestStructure.sqf | 12 + Server/PVFunctions/RequestTeamUpdate.sqf | 26 + Server/PVFunctions/RequestUpgrade.sqf | 1 + Server/PVFunctions/RequestVehicleLock.sqf | 10 + Server/PVFunctions/RequestWorker.sqf | 19 + Server/Server_PlayerConnected.sqf | 109 + Server/Server_PlayerDisconnected.sqf | 87 + Server/Server_VoteForCommander.sqf | 38 + Server/Support/Support_ParaAmmo.sqf | 107 + Server/Support/Support_ParaVehicles.sqf | 89 + Server/Support/Support_Paratroopers.sqf | 79 + Server/Support/Support_UAV.sqf | 20 + 118 files changed, 24443 insertions(+) create mode 100644 Server/AI/AI_AddMultiplayerRespawnEH.sqf create mode 100644 Server/AI/AI_AdvancedRespawn.sqf create mode 100644 Server/AI/AI_Resistance.sqf create mode 100644 Server/AI/AI_SquadRespawn.sqf create mode 100644 Server/AI/AI_TLWPHandler.sqs create mode 100644 Server/AI/AI_UpdateSupplyTruck.sqf create mode 100644 Server/AI/AI_Upgrade.sqf create mode 100644 Server/AI/Orders/AI_MoveTo.sqf create mode 100644 Server/AI/Orders/AI_Patrol.sqf create mode 100644 Server/AI/Orders/AI_TownPatrol.sqf create mode 100644 Server/AI/Orders/AI_WPAdd.sqf create mode 100644 Server/AI/Orders/AI_WPRemove.sqf create mode 100644 Server/Config/Config_Allies.sqf create mode 100644 Server/Config/Config_Civilians.sqf create mode 100644 Server/Config/Config_HugeTown.sqf create mode 100644 Server/Config/Config_HugeTown2.sqf create mode 100644 Server/Config/Config_LargeTown.sqf create mode 100644 Server/Config/Config_LargeTown2.sqf create mode 100644 Server/Config/Config_MediumTown.sqf create mode 100644 Server/Config/Config_MediumTown1Tank.sqf create mode 100644 Server/Config/Config_MediumTown2.sqf create mode 100644 Server/Config/Config_MediumTown2Tank.sqf create mode 100644 Server/Config/Config_Occupation.sqf create mode 100644 Server/Config/Config_Resistance.sqf create mode 100644 Server/Config/Config_SmallTown.sqf create mode 100644 Server/Config/Config_SmallTown2.sqf create mode 100644 Server/Config/Config_Town.sqf create mode 100644 Server/Construction/Construction_HQSite.sqf create mode 100644 Server/Construction/Construction_MediumSite.sqf create mode 100644 Server/Construction/Construction_SmallSite.sqf create mode 100644 Server/Construction/Construction_StationaryDefense.sqf create mode 100644 Server/FSM/aibase.fsm create mode 100644 Server/FSM/aicommander.fsm create mode 100644 Server/FSM/aiteam.fsm create mode 100644 Server/FSM/allies.fsm create mode 100644 Server/FSM/allies_team.fsm create mode 100644 Server/FSM/basearea.fsm create mode 100644 Server/FSM/basepatrol.fsm create mode 100644 Server/FSM/conquest.fsm create mode 100644 Server/FSM/emptyvehiclescollector.fsm create mode 100644 Server/FSM/fasttime.fsm create mode 100644 Server/FSM/garbagecollector.fsm create mode 100644 Server/FSM/missions.fsm create mode 100644 Server/FSM/queryhandler.fsm create mode 100644 Server/FSM/respatrol.fsm create mode 100644 Server/FSM/resstriker.fsm create mode 100644 Server/FSM/supplytruck.fsm create mode 100644 Server/FSM/townpatrol.fsm create mode 100644 Server/FSM/updatecamp.fsm create mode 100644 Server/FSM/updateresources.fsm create mode 100644 Server/FSM/updateserver.fsm create mode 100644 Server/FSM/updatetown.fsm create mode 100644 Server/FSM/updatetownai.fsm create mode 100644 Server/FSM/updatetowndefenses.fsm create mode 100644 Server/FSM/updatetownoccupation.fsm create mode 100644 Server/FSM/weather.fsm create mode 100644 Server/FSM/workers.fsm create mode 100644 Server/Functions/Server_AlliesBuyUnit.sqf create mode 100644 Server/Functions/Server_BuildingDamaged.sqf create mode 100644 Server/Functions/Server_BuildingHandleDamages.sqf create mode 100644 Server/Functions/Server_BuildingKilled.sqf create mode 100644 Server/Functions/Server_BuyUnit.sqf create mode 100644 Server/Functions/Server_CanUpdateTeam.sqf create mode 100644 Server/Functions/Server_ChangeAICommanderFunds.sqf create mode 100644 Server/Functions/Server_CreateDefenseTemplate.sqf create mode 100644 Server/Functions/Server_CreateTeam.sqf create mode 100644 Server/Functions/Server_GetAICommanderFunds.sqf create mode 100644 Server/Functions/Server_HQKilled.sqf create mode 100644 Server/Functions/Server_HandleBuildingDamage.sqf create mode 100644 Server/Functions/Server_HandleBuildingRepair.sqf create mode 100644 Server/Functions/Server_HandleDefense.sqf create mode 100644 Server/Functions/Server_HandleEmptyVehicle.sqf create mode 100644 Server/Functions/Server_HandleReloadDefense.sqf create mode 100644 Server/Functions/Server_HandleSPVF.sqf create mode 100644 Server/Functions/Server_HandleSpecial.sqf create mode 100644 Server/Functions/Server_MHQRepair.sqf create mode 100644 Server/Functions/Server_PlaceJoiningUnit.sqf create mode 100644 Server/Functions/Server_SelectOccupTeam.sqf create mode 100644 Server/Functions/Server_SelectResTeam.sqf create mode 100644 Server/Functions/Server_SetCampsToSide.sqf create mode 100644 Server/Functions/Server_SideMessage.sqf create mode 100644 Server/Functions/Server_TrashObject.sqf create mode 100644 Server/Functions/Server_UpdateTeam.sqf create mode 100644 Server/Init/Init_Defenses.sqf create mode 100644 Server/Init/Init_Server.sqf create mode 100644 Server/Init/Init_Towns.sqf create mode 100644 Server/Missions/M_BASE_Attack/m_init.sqf create mode 100644 Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf create mode 100644 Server/Missions/M_TOWN_Attack/m_init.sqf create mode 100644 Server/Missions/M_UAV_RetrieveModule/m_init.sqf create mode 100644 Server/Module/NEURO/NEURO.sqf create mode 100644 Server/Module/UPSMON/Init_UPSMON.sqf create mode 100644 Server/Module/UPSMON/UPSMON.sqf create mode 100644 Server/Module/UPSMON/UPSMON/!R/R_functions.sqf create mode 100644 Server/Module/UPSMON/UPSMON/!R/markerAlpha.sqf create mode 100644 Server/Module/UPSMON/UPSMON/MON_artillery_add.sqf create mode 100644 Server/Module/UPSMON/UPSMON/MON_spawn.sqf create mode 100644 Server/Module/UPSMON/UPSMON/MON_surrended.sqf create mode 100644 Server/Module/UPSMON/UPSMON/actions/followme.sqf create mode 100644 Server/Module/UPSMON/UPSMON/common/MON_functions.sqf create mode 100644 Server/PVFunctions/RequestChangeScore.sqf create mode 100644 Server/PVFunctions/RequestCommanderVote.sqf create mode 100644 Server/PVFunctions/RequestDefense.sqf create mode 100644 Server/PVFunctions/RequestJoin.sqf create mode 100644 Server/PVFunctions/RequestMHQRepair.sqf create mode 100644 Server/PVFunctions/RequestSpecial.sqf create mode 100644 Server/PVFunctions/RequestStructure.sqf create mode 100644 Server/PVFunctions/RequestTeamUpdate.sqf create mode 100644 Server/PVFunctions/RequestUpgrade.sqf create mode 100644 Server/PVFunctions/RequestVehicleLock.sqf create mode 100644 Server/PVFunctions/RequestWorker.sqf create mode 100644 Server/Server_PlayerConnected.sqf create mode 100644 Server/Server_PlayerDisconnected.sqf create mode 100644 Server/Server_VoteForCommander.sqf create mode 100644 Server/Support/Support_ParaAmmo.sqf create mode 100644 Server/Support/Support_ParaVehicles.sqf create mode 100644 Server/Support/Support_Paratroopers.sqf create mode 100644 Server/Support/Support_UAV.sqf (limited to 'Server') diff --git a/Server/AI/AI_AddMultiplayerRespawnEH.sqf b/Server/AI/AI_AddMultiplayerRespawnEH.sqf new file mode 100644 index 0000000..1308fb4 --- /dev/null +++ b/Server/AI/AI_AddMultiplayerRespawnEH.sqf @@ -0,0 +1 @@ +(leader _this) addMPEventHandler ['MPRespawn',{if (isServer && !(isPlayer (_this select 0))) then {_this Spawn AIAdvancedRespawn}}]; \ No newline at end of file diff --git a/Server/AI/AI_AdvancedRespawn.sqf b/Server/AI/AI_AdvancedRespawn.sqf new file mode 100644 index 0000000..a05caac --- /dev/null +++ b/Server/AI/AI_AdvancedRespawn.sqf @@ -0,0 +1,119 @@ +/* Enhanced Respawn Management via Multiplayer Event Handler - Experimental */ +Private ['_autonomous','_availableSpawn','_buildings','_checks','_closestRespawn','_corpse','_deathLoc','_hq','_i','_isForcedRespawn','_mobileRespawns','_moveMode','_pos','_ran','_range','_rcm','_rd','_respawn','_respawnLoc','_respawnedUnit','_side','_sideText','_skip','_team','_update','_upgrades']; + +_respawnedUnit = _this select 0; +_corpse = _this select 1; + +_deathLoc = getPos _corpse; +_rd = 'WFBE_RESPAWNDELAY' Call GetNamespace; +_rcm = 'WFBE_RESPAWNCAMPSMODE' Call GetNamespace; + +_side = side _respawnedUnit; +//--- Ensure that the side is not civilian. +if (_side == civilian) then { + if (_respawnedUnit isKindOf westSoldierBaseClass) then {_side = west}; + if (_respawnedUnit isKindOf eastSoldierBaseClass) then {_side = east}; +}; +_sideText = str _side; +_team = group _respawnedUnit; +_respawn = (_team) Call GetTeamRespawn; +_respawnLoc = objNull; + +diag_log format ["[WFBE (INFORMATION)][frameno:%7 | ticktime:%8] AI_AdvancedRespawn: AI Team Leader '%1' (Team '%2', Rank '%3', Type '%4', Side '%5') has respawned after dieing at %6",_respawnedUnit,_team,rank _respawnedUnit,typeOf _respawnedUnit,_side,_deathLoc,diag_frameno,diag_tickTime]; + +//--- Remove previous EH. +_respawnedUnit removeAllEventHandlers "Killed"; +Call Compile Format ["_respawnedUnit addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; + +//--- Place the leader on a 'safe' position. +_respawnedUnit setPos getMarkerPos Format["%1TempRespawnMarker",_sideText]; + +_availableSpawn = []; +_isForcedRespawn = false; + +//--- Ensure that the ai is not forced to respawn. +if (typeName _respawn == 'STRING') then {if (_respawn == "forceRespawn") then {_isForcedRespawn = true}}; + +//--- Towns. +if (_rcm > 0 && !_isForcedRespawn) then { + _availableSpawn = _availableSpawn + ([_deathLoc, _side] Call GetRespawnCamps); +}; + +_upgrades = (_sideText) Call GetSideUpgrades; + +//--- Mobile Respawn. +if (paramMobileRespawn && !_isForcedRespawn) then { + _mobileRespawns = Format ["WFBE_%1AMBULANCES",_sideText] Call GetNamespace; + _range = (Format["WFBE_RESPAWNMOBILERANGE%1",(_upgrades select 7)] Call GetNamespace); + _checks = _deathLoc nearEntities[_mobileRespawns,_range]; + if (count _checks > 0) then { + {if (alive _x) then {_availableSpawn = _availableSpawn + [_x]}} forEach _checks; + }; +}; + +//--- Wait. +_i = _rd; +_skip = false; +while {_i > 0} do { + if (isPlayer(_respawnedUnit) || !(alive _respawnedUnit)) exitWith {_skip = true}; + + _i = _i - 1; + sleep 1; +}; + +//--- Make sure that the AI didn't die or that a player hasn't replaced him before going any further. +if !(_skip) then { + //--- Equip the AI. + _ran = 1 + round(random(2)); + [_respawnedUnit,Format ["WFBE_%1LEADERWEAPONS%2%3",_sideText,_upgrades select 13,_ran] Call GetNamespace, Format ["WFBE_%1LEADERAMMO%2%3",_sideText,_upgrades select 13,_ran] Call GetNamespace] Call EquipLoadout; + _hq = (_sideText) Call GetSideHQ; + _buildings = (_sideText) Call GetSideStructures; + + //--- Check whether AI has a spawn set or not. + _update = false; + switch (typeName _respawn) do { + case "STRING": { + //--- Not defined. + _update = true; + if (_isForcedRespawn) then {[_team,""] Call SetTeamRespawn}; + }; + case "OBJECT": { + //--- Defined. + _respawnLoc = _respawn; + if (!alive _respawn || isNull _respawn) then { + [_team, ""] Call SetTeamRespawn; + _update = true; + }; + }; + }; + + //--- Default respawn. + if (_update) then { + _respawnLoc = _hq; + if (count _buildings > 0) then { + _closestRespawn = [_hq,_buildings] Call SortByDistance; + _respawnLoc = _closestRespawn select 0; + }; + }; + + //--- Alternative spawn location. + if (count _availableSpawn > 0) then { + _respawnLoc = _availableSpawn select (round(random((count _availableSpawn)-1))); + }; + + diag_log format ["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_AdvancedRespawn: AI Team Leader %1 is respawning at: %2 (%3)",_respawnedUnit,typeOf _respawnLoc,_respawnLoc,diag_frameno,diag_tickTime]; + + _pos = [getPos _respawnLoc,20,30] Call GetRandomPosition; + _pos set [2,0]; + _respawnedUnit setPos _pos; + + //--- Assign fresh order if the AI is not on autonomous mode. + _autonomous = (_team) Call GetTeamAutonomous; + if !(_autonomous) then { + _moveMode = (_team) Call GetTeamMoveMode; + if (_moveMode == "towns") then {[_team,"resetTowns"] Call SetTeamMoveMode}; + if (_moveMode == "move") then {[_team,"resetMove"] Call SetTeamMoveMode}; + if (_moveMode == "patrol") then {[_team,"resetPatrol"] Call SetTeamMoveMode}; + if (_moveMode == "defense") then {[_team,"resetDefense"] Call SetTeamMoveMode}; + }; +}; \ No newline at end of file diff --git a/Server/AI/AI_Resistance.sqf b/Server/AI/AI_Resistance.sqf new file mode 100644 index 0000000..2fe1ce2 --- /dev/null +++ b/Server/AI/AI_Resistance.sqf @@ -0,0 +1,17 @@ +Private ["_action","_position","_range","_team"]; +_team = _this select 0; +_position = _this select 1; +_range = _this select 2; +_action = _this select 3; + +switch (_action) do { + case "Patrol": {[_team,_position,_range] Call BIS_fnc_taskPatrol}; + case "Defend": { + _team setFormation "STAG COLUMN"; + _team setBehaviour "AWARE"; + _team setSpeedMode "NORMAL"; + + [_team, true, [[_position, 'SAD', 40, 30, "", []]]] Call AIWPAdd; + }; + case "CPatrol": {[_team,_position,_range] Spawn AIPatrol}; +}; \ No newline at end of file diff --git a/Server/AI/AI_SquadRespawn.sqf b/Server/AI/AI_SquadRespawn.sqf new file mode 100644 index 0000000..08a32a2 --- /dev/null +++ b/Server/AI/AI_SquadRespawn.sqf @@ -0,0 +1,104 @@ +Private ["_availableSpawn","_autonomous","_buildings","_checks","_closestRespawn","_deathLoc","_enemySide","_hq","_isForcedRespawn","_leader","_mobileRespawns","_moveMode","_pos","_ran","_range","_rcm'","_rd","_respawn","_respawnLoc","_side","_sideText","_team","_update","_upgrades"]; +_side = _this select 0; +_team = _this select 1; +_sideText = str _side; +_deathLoc = objNull; +_respawnLoc = objNull; + +_rd = 'WFBE_RESPAWNDELAY' Call GetNamespace; +_rcm = 'WFBE_RESPAWNCAMPSMODE' Call GetNamespace; + +sleep (random 0.5); + +while {!gameOver} do { + if (isPlayer leader _team) exitWith {}; + [str _side,'UnitsCreated',1] Call UpdateStatistics; + waitUntil {!alive leader _team || isPlayer leader _team}; + _deathLoc = getPos (leader _team); + diag_log format ["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_SquadRespawn: AI Team Leader '%1' (Team '%2') is dead at %3",leader _team,_team,_deathLoc,diag_frameno,diag_tickTime]; + if (isPlayer leader _team) exitWith {}; + waitUntil {alive leader _team || isPlayer leader _team}; + if (isPlayer leader _team) exitWith {}; + + _respawn = (_team) Call GetTeamRespawn; + + //--- Place the AI. + _leader = leader _team; + _leader removeAllEventHandlers "Killed"; + Call Compile Format ["_leader addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; + _leader setPos getMarkerPos Format["%1TempRespawnMarker",_sideText]; + + _availableSpawn = []; + _isForcedRespawn = false; + if (typeName _respawn == 'STRING') then {if (_respawn == "forceRespawn") then {_isForcedRespawn = true}}; + + //--- Towns. + if (_rcm > 0 && !_isForcedRespawn) then { + _availableSpawn = _availableSpawn + ([_deathLoc, _side] Call GetRespawnCamps); + }; + + _upgrades = (_sideText) Call GetSideUpgrades; + + //--- Mobile Respawn. + if (paramMobileRespawn && !_isForcedRespawn) then { + _mobileRespawns = Format ["WFBE_%1AMBULANCES",_sideText] Call GetNamespace; + _range = (Format["WFBE_RESPAWNMOBILERANGE%1",(_upgrades select 7)] Call GetNamespace); + _checks = _deathLoc nearEntities[_mobileRespawns,_range]; + if (count _checks > 0) then { + {if (alive _x) then {_availableSpawn = _availableSpawn + [_x]}} forEach _checks; + }; + }; + + sleep _rd; + + //--- Equip the AI. + _ran = 1 + round(random(2)); + [_leader,Format ["WFBE_%1LEADERWEAPONS%2%3",_sideText,_upgrades select 13,_ran] Call GetNamespace, Format ["WFBE_%1LEADERAMMO%2%3",_sideText,_upgrades select 13,_ran] Call GetNamespace] Call EquipLoadout; + _hq = (_sideText) Call GetSideHQ; + _buildings = (_sideText) Call GetSideStructures; + + //--- Check whether AI has a spawn set or not. + _update = false; + switch (typeName _respawn) do { + case "STRING": { + _update = true; + if (_isForcedRespawn) then {[_team,""] Call SetTeamRespawn}; + }; //--- Not defined. + case "OBJECT": { + _respawnLoc = _respawn; + if (!alive _respawn || isNull _respawn) then { + [_team, ""] Call SetTeamRespawn; + _update = true; + }; //--- Defined. + }; + }; + + //--- Default respawn. + if (_update) then { + _respawnLoc = _hq; + if (count _buildings > 0) then { + _closestRespawn = [_hq,_buildings] Call SortByDistance; + _respawnLoc = _closestRespawn select 0; + }; + }; + + //--- Alternative spawn location. + if (count _availableSpawn > 0) then { + _respawnLoc = _availableSpawn select (round(random((count _availableSpawn)-1))); + }; + + diag_log format ["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_SquadRespawn: AI Team Leader %1 is respawning at: %2 (%3)",leader _team,typeOf _respawnLoc,_respawnLoc,diag_frameno,diag_tickTime]; + _pos = [getPos _respawnLoc,20,30] Call GetRandomPosition; + _pos set [2,0]; + _leader setPos _pos; + + //--- Assign fresh order (tbc). + _autonomous = (_team) Call GetTeamAutonomous; + if !(_autonomous) then { + _moveMode = (_team) Call GetTeamMoveMode; + if (_moveMode == "towns") then {[_team,"resetTowns"] Call SetTeamMoveMode}; + if (_moveMode == "move") then {[_team,"resetMove"] Call SetTeamMoveMode}; + if (_moveMode == "patrol") then {[_team,"resetPatrol"] Call SetTeamMoveMode}; + if (_moveMode == "defense") then {[_team,"resetDefense"] Call SetTeamMoveMode}; + }; +}; \ No newline at end of file diff --git a/Server/AI/AI_TLWPHandler.sqs b/Server/AI/AI_TLWPHandler.sqs new file mode 100644 index 0000000..c94a6a8 --- /dev/null +++ b/Server/AI/AI_TLWPHandler.sqs @@ -0,0 +1,39 @@ +Private ["_group","_i","_timeSince","_unit","_units","_waitForMembers","_wpPos"] +_group = _this select 0 +_wpPos = _this select 1 + +_timeSince = 0 + +if (vehicle (leader _group) isKindOf "Air") then {Goto "Exit";} + +#Main + ~5 + + _timeSince = _timeSince + 5 + + ;Check for the group's status. + _units = ((units _group) Call GetLiveUnits) - [leader _group] + + ;Exit if the leader is the only member. + if (count _units < 2) then {Goto "Exit";} + + _i = 0 + _waitForMembers = false + + ;Iterate through all members. + #Loop + _unit = _units select _i + + if (_unit distance (leader _group) > 150 && !(_unit isKindOf 'Air')) then {_waitForMembers = true; if (_timeSince > 240) then {[vehicle _unit,getPos (leader _group),75] Call PlaceSafe;};} + + _i = _i + 1 + + if (_i == count _units) then {if (_waitForMembers) then {Goto "Main";} else {Goto "Exit";}}; + + Goto "Loop" + + Goto "Main" + +#Exit + + Exit \ No newline at end of file diff --git a/Server/AI/AI_UpdateSupplyTruck.sqf b/Server/AI/AI_UpdateSupplyTruck.sqf new file mode 100644 index 0000000..9083ed7 --- /dev/null +++ b/Server/AI/AI_UpdateSupplyTruck.sqf @@ -0,0 +1,24 @@ +Private ["_AITrucks","_destinations","_driver","_full","_hq","_isDeployed","_maist","_side","_sideText","_team","_type","_vehicle"]; +_side = _this select 0; +_sideText = str _side; +_maist = 'WFBE_MAXAISUPPLYTRUCKS' Call GetNamespace; + +sleep ((Random 200) / 100); +sleep ((Random 200) / 100); + +waitUntil {townInit}; + +while {!gameOver} do { + sleep 60; + _AITrucks = Format ["WFBE_%1_AISupplyTrucks",_sideText] Call GetNamespace; + _full = false; + if (count _AITrucks >= _maist) then {_full = true}; + if (!_full) then { + _isDeployed = (_sideText) Call GetSideHQDeployed; + _hq = (_sideText) Call GetSideHQ; + if ((_isDeployed)&&(alive _hq)&&(!isNull _hq)) then { + diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] AI_UpdateSupplyTruck: A %1 Supply truck has been created",_side,diag_frameno,diag_tickTime]; + [_side] ExecFSM "Server\FSM\supplytruck.fsm"; + }; + }; +}; diff --git a/Server/AI/AI_Upgrade.sqf b/Server/AI/AI_Upgrade.sqf new file mode 100644 index 0000000..dabac71 --- /dev/null +++ b/Server/AI/AI_Upgrade.sqf @@ -0,0 +1,32 @@ +Private ["_index","_index2","_name","_side","_sideText","_time","_upgrades","_upgrades_old"]; +_time = _this select 0; +_index = _this select 1; +_index2 = _this select 2; +_name = _this select 3; +_side = _this select 4; +_sideText = Str _side; + +Call Compile Format ["WFBE_%1_Upgrading = true; publicVariable 'WFBE_%1_Upgrading';",_sideText]; + +_upgrades_old = (_sideText) Call GetSideUpgrades; + +sleep _time; + +_upgrades = (_sideText) Call GetSideUpgrades; + +//--- Failover due to faulty pv. +for '_i' from 0 to count _upgrades_old do { + if ((_upgrades_old select _i) != (_upgrades select _i)) then {_upgrades set [_i, (_upgrades_old select _i)]}; +}; + +_upgrades set [_index2,_index + 1]; +Call Compile Format ["%1Upgrades = _upgrades; publicVariable '%1Upgrades';",_sideText]; + +WFBE_LocalizeMessage = [_side,'CLTFNCLOCALIZEMESSAGE',['UpgradeComplete',_index2,(_index + 1)]]; +publicVariable 'WFBE_LocalizeMessage'; +if (isHostedServer) then {[_side,'CLTFNCLOCALIZEMESSAGE',['UpgradeComplete',_index2,(_index + 1)]] Spawn HandlePVF}; +[Format["WFBE_%1_Upgrading",_sideText],false,true] Call SetNamespace; + +["NewIntelAvailable","",_side,""] Spawn SideMessage; + +Call Compile Format ["WFBE_%1_Upgrading = false; publicVariable 'WFBE_%1_Upgrading';",_sideText]; diff --git a/Server/AI/Orders/AI_MoveTo.sqf b/Server/AI/Orders/AI_MoveTo.sqf new file mode 100644 index 0000000..e372393 --- /dev/null +++ b/Server/AI/Orders/AI_MoveTo.sqf @@ -0,0 +1,17 @@ +private ["_destination","_mission","_radius","_team","_update"]; +_team = _this select 0; +_destination = _this select 1; +_mission = _this select 2; +_radius = if (count _this > 3) then {_this select 3} else {30}; + +_update = true; +if (side _team == west || side _team == east) then { + _update = (_team) Call CanUpdateTeam; +}; + +//--- Override. +if (_update) then {_team Call UpdateTeam}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_MoveTo: The %1 %2 Team is moving to %3",side _team,_team,_destination,diag_frameno,diag_tickTime]; + +[_team,true,[[_destination, _mission, _radius, 20, "", []]]] Call AIWPAdd; \ No newline at end of file diff --git a/Server/AI/Orders/AI_Patrol.sqf b/Server/AI/Orders/AI_Patrol.sqf new file mode 100644 index 0000000..8cff904 --- /dev/null +++ b/Server/AI/Orders/AI_Patrol.sqf @@ -0,0 +1,34 @@ +Private ["_destination","_maxWaypoints","_pos","_radius","_rand1","_rand2","_team","_type","_update","_wps","_z"]; +_team = _this select 0; +_destination = _this select 1; +_radius = if (count _this > 2) then {_this select 2} else {30}; +if (typeName _destination == 'OBJECT') then {_destination = getPos _destination}; + +_update = true; +if (side _team == west || side _team == east) then { + _update = (_team) Call CanUpdateTeam; +}; + +//--- Override. +if (_update) then {_team Call UpdateTeam}; + +_maxWaypoints = 8; +_wps = []; +for [{_z=0},{_z<=_maxWaypoints},{_z=_z+1}] do { + _rand1 = (random _radius) - (random _radius); + _rand2 = (random _radius) - (random _radius); + _pos = [(_destination select 0)+_rand1,(_destination select 1)+_rand2,0]; + _tries = 100; + while {surfaceIsWater _pos && _tries > 0} do { + _tries = _tries - 1; + _rand1 = (random _radius) - (random _radius); + _rand2 = (random _radius) - (random _radius); + _pos = [(_destination select 0)+_rand1,(_destination select 1)+_rand2,0]; + }; + _type = if (_z != _maxWaypoints) then {'MOVE'} else {'CYCLE'}; + _wps = _wps + [[_pos,_type,35,40,"",[]]]; +}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_Patrol: The %1 %2 Team is patrolling at %3",side _team,_team,_destination,diag_frameno,diag_tickTime]; + +[_team, true, _wps] Call AIWPAdd; \ No newline at end of file diff --git a/Server/AI/Orders/AI_TownPatrol.sqf b/Server/AI/Orders/AI_TownPatrol.sqf new file mode 100644 index 0000000..15122d3 --- /dev/null +++ b/Server/AI/Orders/AI_TownPatrol.sqf @@ -0,0 +1,71 @@ +/* + Author: Benny + Name: AI_TownPatrol.sqf + Parameters: + 0 - Team + 1 - Town + 2 - (Radius) + Description: + This file is called upon a resistance / occupation patrol, AI will randomly patrol in towns, including the camps and the depots. +*/ + +Private ['_camps','_insert','_insertObject','_insertStep','_maxWaypoints','_pos','_radius','_rand1','_rand2','_team','_town','_townPos','_type','_update','_usable','_wpcompletionRadius','_wpradius','_wps','_z']; +_team = _this select 0; +_town = _this select 1; +_radius = if (count _this > 2) then {_this select 2} else {30}; +if (typeName _town != 'OBJECT') exitWith {diag_log Format ["[WFBE (ERROR)] AI_TownPatrol: Object expected, %1 given",_town]}; +if (isNull _team) exitWith {diag_log Format ["[WFBE (ERROR)] AI_TownPatrol: Null Groups cannot be used (Town: %1)",_town]}; +_townPos = getPos _town; + +_camps = _town getVariable 'camps'; + +_usable = [_town] + _camps; +_maxWaypoints = ('WFBE_TOWNPATROLHOPS' Call GetNamespace) + count(_usable); +_wps = []; + +//--- Randomize the behaviours. +if (random 100 > 50) then {_team setFormation "DIAMOND"} else {_team setFormation "STAG COLUMN"}; +if (random 100 > 50) then {_team setCombatMode "YELLOW"} else {_team setCombatMode "RED"}; +if (random 100 > 50) then {_team setBehaviour "AWARE"} else {_team setBehaviour "COMBAT"}; +if (random 100 > 50) then {_team setSpeedMode "NORMAL"} else {_team setSpeedMode "LIMITED"}; + +//--- Dyn insert. +_insertStep = if (count(_usable) != 0) then {floor(_maxWaypoints / count(_usable))} else {-1}; +_insert = _insertStep; +_insertObject = objNull; +_wpradius = -1; +_wpcompletionRadius = -1; + +for [{_z=0},{_z<=_maxWaypoints},{_z=_z+1}] do { + if (_z == _insert && count _usable > 0) then { + _insert = _insert + _insertStep; + _insertObject = _usable select (round(random((count _usable)-1))); + _usable = _usable - [_insertObject]; + }; + + if (isNull _insertObject) then { + _rand1 = random _radius; + _rand2 = random _radius; + _pos = [(_townPos select 0)+_rand1,(_townPos select 1)+_rand2,0]; + _tries = 100; + while {surfaceIsWater _pos && _tries > 0} do { + _tries = _tries - 1; + _rand1 = random _radius; + _rand2 = random _radius; + _pos = [(_townPos select 0)+_rand1,(_townPos select 1)+_rand2,0]; + }; + _wpradius = 32; + _wpcompletionRadius = 44; + } else { + _pos = getPos _insertObject; + _wpradius = 35; + _wpcompletionRadius = 68; + }; + + _type = if (_z != _maxWaypoints) then {'MOVE'} else {'CYCLE'}; + _wps = _wps + [[_pos,_type,_wpradius,_wpcompletionRadius, "", []]]; +}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_TownPatrol: The %1 %2 Team is patrolling the %3 town",side _team,_team,_town,diag_frameno,diag_tickTime]; + +[_team, true, _wps] Call AIWPAdd; \ No newline at end of file diff --git a/Server/AI/Orders/AI_WPAdd.sqf b/Server/AI/Orders/AI_WPAdd.sqf new file mode 100644 index 0000000..ad04518 --- /dev/null +++ b/Server/AI/Orders/AI_WPAdd.sqf @@ -0,0 +1,39 @@ +/* + Author: Benny + Name: AI_WPAdd.sqf + Parameters: + 0 - Team + 1 - Clear (Remove WPs) + 2 - Waypoints (given in an Array) + Description: + This file is used to give a detailed WP system. + Exemple: + [_team, true, [[getPos _camp, 'MOVE', 10, 20, "", []],[[1560,2560,0], 'SAD', 50, 70, "", ["canComplete", "this sidechat 'lets roll'"]]...]] Call AddWP; +*/ + +Private ['_clear','_completionRadius','_position','_radius','_scripted','_statements','_team','_type','_waypoint','_waypoints','_WPCount']; +_team = _this select 0; +_clear = _this select 1; +_waypoints = _this select 2; + +if (_clear) then {_team Call AIWPRemove}; + +{ + _position = _x select 0; + _type = _x select 1; + _radius = _x select 2; + _completionRadius = _x select 3; + _scripted = _x select 4; + _statements = _x select 5; + if (typeName _position == 'OBJECT') then {_position = getPos _position}; + + _WPCount = count (waypoints _team); + + _team addWaypoint [_position,_radius]; + [_team, _WPCount] setWaypointType _type; + [_team, _WPCount] setWaypointCompletionRadius _completionRadius; + if (_type == 'SCRIPTED') then {[_team, _WPCount] setWaypointScript _scripted}; + if (count _statements > 0) then {[_team, _WPCount] setWaypointStatements [_statements select 0, _statements select 1]}; + + if (_WPCount == 0) then {_team setCurrentWaypoint [_team, _WPCount]}; +} forEach _waypoints; \ No newline at end of file diff --git a/Server/AI/Orders/AI_WPRemove.sqf b/Server/AI/Orders/AI_WPRemove.sqf new file mode 100644 index 0000000..a02a1e2 --- /dev/null +++ b/Server/AI/Orders/AI_WPRemove.sqf @@ -0,0 +1,6 @@ +Private ['_team','_z']; +_team = _this; + +for [{_z = (count (waypoints _team))-1},{_z > -1},{_z = _z - 1}] do { + deleteWaypoint [_team, _z]; +}; \ No newline at end of file diff --git a/Server/Config/Config_Allies.sqf b/Server/Config/Config_Allies.sqf new file mode 100644 index 0000000..f0e500e --- /dev/null +++ b/Server/Config/Config_Allies.sqf @@ -0,0 +1,454 @@ +Private ['_alliesTeamCost','_alliesTeamTemplates','_alliesTeamTemplateRequires','_alliesTeamTypes','_d','_f','_get','_p','_u']; +/* ALLIES TEAM TEMPLATES */ +/* CDF*/ +_alliesTeamTemplates = []; +_alliesTeamTemplateRequires = []; +_alliesTeamTypes = []; //--- 0 Inf, 2 Light, 3 Armor, 4 Air +_alliesTeamCost = []; + +_d = ["Infantry - Infantry Squad"]; +_u = ["CDF_Soldier_TL"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_GL"]; +_u = _u + ["CDF_Soldier"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_GL"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier"]; +_u = _u + ["CDF_Soldier_Medic"]; +_f = [true,false,false,false]; +_p = 0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [0]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Infantry - Rifle Squad"]; +_u = ["CDF_Soldier_TL"]; +_u = _u + ["CDF_Soldier_AR"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_Marksman"]; +_u = _u + ["CDF_Soldier_Marksman"]; +_f = [true,false,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [0]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Infantry - Rifle Squad"]; +_u = ["CDF_Soldier_TL"]; +_u = _u + ["CDF_Soldier_AR"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_Marksman"]; +_u = _u + ["CDF_Soldier_Marksman"]; +_f = [true,false,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [0]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Infantry - Weapon Squad"]; +_u = ["CDF_Soldier_Officer"]; +_u = _u + ["CDF_Soldier_AR"]; +_u = _u + ["CDF_Soldier_Engineer"]; +_u = _u + ["CDF_Soldier_Light"]; +_u = _u + ["CDF_Soldier_Strela"]; +_u = _u + ["CDF_Soldier_Strela"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_Sniper"]; +_u = _u + ["CDF_Soldier_Spotter"]; +_f = [true,false,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [0]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - Infantry Squad"]; +_u = ["CDF_Soldier_TL"]; +_u = _u + ["Ural_CDF"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_GL"]; +_u = _u + ["CDF_Soldier"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier"]; +_u = _u + ["CDF_Soldier_Medic"]; +_f = [true,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - Infantry Section"]; +_u = ["UAZ_AGS30_CDF"]; +_u = _u + ["UAZ_AGS30_CDF"]; +_u = _u + ["UAZ_MG_CDF"]; +_f = [false,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - AA Patrol"]; +_u = ["Ural_ZU23_CDF"]; +_u = _u + ["Ural_ZU23_CDF"]; +_f = [false,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - BRDM"]; +_u = ["BRDM2_CDF"]; +_u = _u + ["BRDM2_ATGM_CDF"]; +_f = [false,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Mechanized - Rifle Squad"]; +_u = ["CDF_Soldier_TL"]; +_u = _u + ["BMP2_CDF"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_Marksman"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier"]; +_f = [true,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Mechanized - BMP2"]; +_u = ["BMP2_CDF"]; +_u = _u + ["BMP2_CDF"]; +_u = _u + ["BMP2_CDF"]; +_f = [false,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Armored - T72"]; +_u = ["T72_CDF"]; +_u = _u + ["T72_CDF"]; +_u = _u + ["T72_CDF"]; +_f = [false,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Armored - Mix"]; +_u = ["T72_CDF"]; +_u = _u + ["ZSU_CDF"]; +_u = _u + ["BMP2_CDF"]; +_f = [false,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Air - Hinds"]; +_u = ["Mi24_D"]; +_u = _u + ["Mi24_D"]; +_f = [false,false,false,true]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [3]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Airborn Infantry - Hind"]; +_u = ["CDF_Soldier_TL"]; +_u = _u + ["Mi24_D"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_Strela"]; +_u = _u + ["CDF_Soldier_Strela"]; +_f = [true,false,false,true]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [3]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Airborn Infantry - Mi17"]; +_u = ["CDF_Soldier_TL"]; +_u = _u + ["Mi17_CDF"]; +_u = _u + ["CDF_Soldier_MG"]; +_u = _u + ["CDF_Soldier_AR"]; +_u = _u + ["CDF_Soldier_Marksman"]; +_u = _u + ["CDF_Soldier_RPG"]; +_u = _u + ["CDF_Soldier_Strela"]; +_u = _u + ["CDF_Soldier_Medic"]; +_f = [true,false,false,true]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [3]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +['WFBE_WESTALLIESTEAMTEMPLATES',_alliesTeamTemplates,true] Call SetNamespace; +['WFBE_WESTALLIESTEAMTEMPLATEREQUIRES',_alliesTeamTemplateRequires,true] Call SetNamespace; +['WFBE_WESTALLIESTEAMTYPES',_alliesTeamTypes,true] Call SetNamespace; +['WFBE_WESTALLIESTEAMCOST',_alliesTeamCost,true] Call SetNamespace; + +/* Insurgent*/ +_alliesTeamTemplates = []; +_alliesTeamTemplateRequires = []; +_alliesTeamTypes = []; //--- 0 Inf, 2 Light, 3 Armor, 4 Air +_alliesTeamCost = []; + +_d = ["Infantry - Group"]; +_u = ["Ins_Soldier_CO"]; +_u = _u + ["Ins_Soldier_AR"]; +_u = _u + ["Ins_Soldier_GL"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_2"]; +_u = _u + ["Ins_Soldier_AR"]; +_u = _u + ["Ins_Soldier_1"]; +_u = _u + ["Ins_Soldier_Medic"]; +_f = [true,false,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [0]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Infantry - Weapons Group"]; +_u = ["Ins_Soldier_CO"]; +_u = _u + ["Ins_Soldier_MG"]; +_u = _u + ["Ins_Soldier_MG"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_AR"]; +_u = _u + ["Ins_Soldier_AR"]; +_u = _u + ["Ins_Soldier_2"]; +_f = [true,false,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [0]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Infantry - Weapon Squad"]; +_u = ["Ins_Soldier_CO"]; +_u = _u + ["Ins_Soldier_AR"]; +_u = _u + ["Ins_Soldier_Sapper"]; +_u = _u + ["Ins_Soldier_2"]; +_u = _u + ["Ins_Soldier_AA"]; +_u = _u + ["Ins_Soldier_AA"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_Sniper"]; +_u = _u + ["Ins_Soldier_Sab"]; +_f = [true,false,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [0]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - Infantry Squad"]; +_u = ["Ins_Soldier_CO"]; +_u = _u + ["Ural_INS"]; +_u = _u + ["Ins_Soldier_MG"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_GL"]; +_u = _u + ["Ins_Soldier_1"]; +_u = _u + ["Ins_Soldier_MG"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_1"]; +_u = _u + ["Ins_Soldier_Medic"]; +_f = [true,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - Infantry Section"]; +_u = ["UAZ_AGS30_INS"]; +_u = _u + ["UAZ_SPG9_INS"]; +_u = _u + ["UAZ_MG_INS"]; +_f = [false,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - AA Patrol"]; +_u = ["Ural_ZU23_INS"]; +_u = _u + ["Ural_ZU23_INS"]; +_f = [false,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Motorized - BRDM"]; +_u = ["BRDM2_INS"]; +_u = _u + ["BRDM2_ATGM_INS"]; +_f = [false,true,false,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [1]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Mechanized - Rifle Squad"]; +_u = ["Ins_Soldier_CO"]; +_u = _u + ["BMP2_INS"]; +_u = _u + ["Ins_Soldier_MG"]; +_u = _u + ["Ins_Soldier_MG"]; +_u = _u + ["Ins_Soldier_Sniper"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_1"]; +_f = [true,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Mechanized - BMP2"]; +_u = ["BMP2_INS"]; +_u = _u + ["BMP2_INS"]; +_u = _u + ["BMP2_INS"]; +_f = [false,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Armored - T72"]; +_u = ["T72_INS"]; +_u = _u + ["T72_INS"]; +_u = _u + ["T72_INS"]; +_f = [false,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Armored - Mix"]; +_u = ["T72_INS"]; +_u = _u + ["ZSU_INS"]; +_u = _u + ["BMP2_INS"]; +_f = [false,false,true,false]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [2]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Air - Sukhoi 25"]; +_u = ["Su25_Ins"]; +_u = _u + ["Su25_Ins"]; +_f = [false,false,false,true]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [3]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +_d = ["Airborn Infantry - Mi17"]; +_u = ["Ins_Soldier_CO"]; +_u = _u + ["Mi17_Ins"]; +_u = _u + ["Ins_Soldier_MG"]; +_u = _u + ["Ins_Soldier_AR"]; +_u = _u + ["Ins_Soldier_Sab"]; +_u = _u + ["Ins_Soldier_AT"]; +_u = _u + ["Ins_Soldier_AA"]; +_u = _u + ["Ins_Soldier_Medic"]; +_f = [true,false,false,true]; +_p =0; +{_get = _x Call GetNamespace;if (!isNil '_get') then {_p = _p + (_get select QUERYUNITPRICE)}} forEach _u; + +_alliesTeamTemplates = _alliesTeamTemplates + [_u]; +_alliesTeamTemplateRequires = _alliesTeamTemplateRequires + [_f]; +_alliesTeamTypes = _alliesTeamTypes + [3]; +_alliesTeamCost = _alliesTeamCost + [_p]; + +['WFBE_EASTALLIESTEAMTEMPLATES',_alliesTeamTemplates,true] Call SetNamespace; +['WFBE_EASTALLIESTEAMTEMPLATEREQUIRES',_alliesTeamTemplateRequires,true] Call SetNamespace; +['WFBE_EASTALLIESTEAMTYPES',_alliesTeamTypes,true] Call SetNamespace; +['WFBE_EASTALLIESTEAMCOST',_alliesTeamCost,true] Call SetNamespace; \ No newline at end of file diff --git a/Server/Config/Config_Civilians.sqf b/Server/Config/Config_Civilians.sqf new file mode 100644 index 0000000..48a62a8 --- /dev/null +++ b/Server/Config/Config_Civilians.sqf @@ -0,0 +1,139 @@ +/* + 3 levels of civilians, villagers, citizen and large citizen (keep them). + keep the same _n name +*/ + + +Private ['_civType','_n','_u']; +_civType = ('WFBE_CIVILIANFACTIONS' Call GetNamespace) select ('WFBE_CIVILIANFACTION' Call GetNamespace); + +if (_civType == 'Chernarus Civilians') then { + _n = ["Villagers1"]; + _u = ["Villager1"]; + _u = _u + ["Woodlander1"]; + _u = _u + ["Worker1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Villagers2"]; + _u = ["Villager4"]; + _u = _u + ["Woodlander2"]; + _u = _u + ["Farmwife1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Villagers3"]; + _u = ["Villager2"]; + _u = _u + ["WorkWoman3"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Villagers4"]; + _u = ["Villager2"]; + _u = _u + ["WorkWoman3"]; + _u = _u + ["Worker3"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen1"]; + _u = ["Citizen2"]; + _u = _u + ["Profiteer3"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen2"]; + _u = ["Rocker2"]; + _u = _u + ["Citizen4"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen3"]; + _u = ["WorkWoman5"]; + _u = _u + ["Citizen3"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen4"]; + _u = ["Damsel2"]; + _u = _u + ["Madam5"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen1"]; + _u = ["SchoolTeacher"]; + _u = _u + ["Functionary1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen2"]; + _u = ["Assistant"]; + _u = _u + ["Secretary3"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen3"]; + _u = ["Worker3"]; + _u = _u + ["Hooker1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen4"]; + _u = ["Citizen3"]; + _u = _u + ["Villager2"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; +}; + +if (_civType == 'Takistan Civilians') then { + _n = ["Villagers1"]; + _u = ["TK_CIV_Takistani02_EP1"]; + _u = _u + ["TK_CIV_Takistani03_EP1"]; + _u = _u + ["TK_CIV_Takistani06_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Villagers2"]; + _u = ["TK_CIV_Worker01_EP1"]; + _u = _u + ["TK_CIV_Woman02_EP1"]; + _u = _u + ["TK_CIV_Takistani06_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Villagers3"]; + _u = ["TK_CIV_Takistani05_EP1"]; + _u = _u + ["TK_CIV_Takistani01_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Villagers4"]; + _u = ["TK_CIV_Woman01_EP1"]; + _u = _u + ["TK_CIV_Takistani04_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen1"]; + _u = ["TK_CIV_Worker02_EP1"]; + _u = _u + ["CIV_EuroMan01_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen2"]; + _u = ["CIV_EuroMan01_EP1"]; + _u = _u + ["CIV_EuroMan02_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen3"]; + _u = ["TK_CIV_Takistani06_EP1"]; + _u = _u + ["TK_CIV_Takistani03_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Citizen4"]; + _u = ["TK_CIV_Takistani04_EP1"]; + _u = _u + ["TK_CIV_Takistani05_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen1"]; + _u = ["TK_CIV_Woman03_EP1"]; + _u = _u + ["TK_CIV_Woman03_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen2"]; + _u = ["TK_CIV_Takistani01_EP1"]; + _u = _u + ["TK_CIV_Takistani05_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen3"]; + _u = ["TK_CIV_Takistani02_EP1"]; + _u = _u + ["TK_CIV_Woman01_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeCitizen4"]; + _u = ["TK_CIV_Takistani03_EP1"]; + _u = _u + ["TK_CIV_Takistani02_EP1"]; + [Format["WFBE_CIV%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; +}; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Config_Civilians: Intialization - [Done]",diag_frameno,diag_tickTime]; \ No newline at end of file diff --git a/Server/Config/Config_HugeTown.sqf b/Server/Config/Config_HugeTown.sqf new file mode 100644 index 0000000..4badb39 --- /dev/null +++ b/Server/Config/Config_HugeTown.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['huge1'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 55; + +[_town,_townName,30,120,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_HugeTown2.sqf b/Server/Config/Config_HugeTown2.sqf new file mode 100644 index 0000000..13e39c0 --- /dev/null +++ b/Server/Config/Config_HugeTown2.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['huge2'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 60; + +[_town,_townName,30,120,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_LargeTown.sqf b/Server/Config/Config_LargeTown.sqf new file mode 100644 index 0000000..5a06682 --- /dev/null +++ b/Server/Config/Config_LargeTown.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['large1'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 65; + +[_town,_townName,20,80,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_LargeTown2.sqf b/Server/Config/Config_LargeTown2.sqf new file mode 100644 index 0000000..c9df7bc --- /dev/null +++ b/Server/Config/Config_LargeTown2.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['large2'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 60; + +[_town,_townName,20,80,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_MediumTown.sqf b/Server/Config/Config_MediumTown.sqf new file mode 100644 index 0000000..5d20450 --- /dev/null +++ b/Server/Config/Config_MediumTown.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['medium1'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 65; + +[_town,_townName,10,50,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_MediumTown1Tank.sqf b/Server/Config/Config_MediumTown1Tank.sqf new file mode 100644 index 0000000..582995a --- /dev/null +++ b/Server/Config/Config_MediumTown1Tank.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['medium4'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 65; + +[_town,_townName,10,60,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_MediumTown2.sqf b/Server/Config/Config_MediumTown2.sqf new file mode 100644 index 0000000..373f491 --- /dev/null +++ b/Server/Config/Config_MediumTown2.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['medium2'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 75; + +[_town,_townName,10,50,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_MediumTown2Tank.sqf b/Server/Config/Config_MediumTown2Tank.sqf new file mode 100644 index 0000000..8301036 --- /dev/null +++ b/Server/Config/Config_MediumTown2Tank.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['medium3'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 70; + +[_town,_townName,10,60,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_Occupation.sqf b/Server/Config/Config_Occupation.sqf new file mode 100644 index 0000000..35bdb8b --- /dev/null +++ b/Server/Config/Config_Occupation.sqf @@ -0,0 +1,925 @@ + +private ["_n","_u"]; +if (WF_A2_Vanilla) then { + //--- West. + _n = ["SmallTeam1"]; + _u = ["USMC_Soldier_SL"]; + _u = _u + ["USMC_Soldier_TL"]; + _u = _u + ["USMC_Soldier_AR"]; + _u = _u + ["USMC_Soldier"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam2"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["USMC_Soldier_AR"]; + _u = _u + ["USMC_Soldier_LAT"]; + _u = _u + ["USMC_Soldier_Medic"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam3"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["USMC_Soldier_MG"]; + _u = _u + ["USMC_Soldier_AR"]; + _u = _u + ["USMC_Soldier_LAT"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam1"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["HMMWV_Avenger"]; + _u = _u + ["HMMWV_Armored"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam2"]; + _u = ["USMC_Soldier_SL"]; + _u = _u + ["HMMWV_TOW"]; + _u = _u + ["LAV25"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam3"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["HMMWV_Avenger"]; + _u = _u + ["HMMWV_MK19"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam1"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["USMC_Soldier_AR"]; + _u = _u + ["USMC_Soldier_Medic"]; + _u = _u + ["USMC_Soldier_AA"]; + _u = _u + ["USMC_Soldier_AA"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam2"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["USMC_Soldier_AA"]; + _u = _u + ["USMC_Soldier_AA"]; + _u = _u + ["USMC_Soldier_LAT"]; + _u = _u + ["USMC_Soldier_AT"]; + _u = _u + ["USMC_Soldier_AR"]; + _u = _u + ["USMC_Soldier_MG"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam3"]; + _u = ["USMC_SoldierS_Sniper"]; + _u = _u + ["USMC_SoldierS_Spotter"]; + _u = _u + ["USMC_SoldierS_Spotter"]; + _u = _u + ["USMC_SoldierS"]; + _u = _u + ["USMC_SoldierS"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam1"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["HMMWV_Avenger"]; + _u = _u + ["AAV"]; + _u = _u + ["LAV25"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam2"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["M1A1"]; + _u = _u + ["M1A1"]; + _u = _u + ["HMMWV_Ambulance"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam3"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["AAV"]; + _u = _u + ["HMMWV_M2"]; + _u = _u + ["M1A1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam1"]; + _u = ["USMC_Soldier_HAT"]; + _u = _u + ["USMC_Soldier_AT"]; + _u = _u + ["USMC_Soldier_HAT"]; + _u = _u + ["USMC_Soldier_HAT"]; + _u = _u + ["USMC_Soldier_HAT"]; + _u = _u + ["USMC_Soldier"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam2"]; + _u = ["FR_TL"]; + _u = _u + ["FR_AR"]; + _u = _u + ["FR_GL"]; + _u = _u + ["FR_Marksman"]; + _u = _u + ["FR_R"]; + _u = _u + ["FR_Corpsman"]; + _u = _u + ["FR_Sapper"]; + _u = _u + ["FR_AC"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam3"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["USMC_Soldier_AA"]; + _u = _u + ["USMC_Soldier_AA"]; + _u = _u + ["USMC_Soldier_Medic"]; + _u = _u + ["USMC_Soldier_GL"]; + _u = _u + ["USMC_SoldierS_Sniper"]; + _u = _u + ["USMC_Soldier_AT"]; + _u = _u + ["USMC_Soldier_MG"]; + _u = _u + ["USMC_Soldier_AR"]; + _u = _u + ["USMC_Soldier_LAT"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam1"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["M1A2_TUSK_MG"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam2"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["MLRS"]; + _u = _u + ["M1A2_TUSK_MG"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam3"]; + _u = ["USMC_Soldier_TL"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["M1A2_TUSK_MG"]; + _u = _u + ["AAV"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + //--- East. + _n = ["SmallTeam1"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_MG"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam2"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_LAT"]; + _u = _u + ["RU_Soldier_Marksman"]; + _u = _u + ["RU_Soldier_AR"]; + _u = _u + ["RU_Soldier_GL"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam3"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["RU_Soldier_MG"]; + _u = _u + ["RU_Soldier_GL"]; + _u = _u + ["RU_Soldier_AT"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam1"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["UAZ_AGS30_RU"]; + _u = _u + ["GAZ_Vodnik"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam2"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["GAZ_Vodnik"]; + _u = _u + ["GAZ_Vodnik_HMG"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam3"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["UAZ_AGS30_RU"]; + _u = _u + ["GAZ_Vodnik_HMG"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam1"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_AA"]; + _u = _u + ["RU_Soldier_LAT"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam2"]; + _u = ["RUS_Commander"]; + _u = _u + ["RUS_Soldier1"]; + _u = _u + ["RUS_Soldier2"]; + _u = _u + ["RUS_Soldier_GL"]; + _u = _u + ["RUS_Soldier_Marksman"]; + _u = _u + ["RUS_Soldier3"]; + _u = _u + ["RUS_Soldier_TL"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam3"]; + _u = ["MVD_Soldier_TL"]; + _u = _u + ["MVD_Soldier_MG"]; + _u = _u + ["MVD_Soldier_AT"]; + _u = _u + ["MVD_Soldier_GL"]; + _u = _u + ["MVD_Soldier_Sniper"]; + _u = _u + ["MVD_Soldier_Marksman"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam1"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["GAZ_Vodnik"]; + _u = _u + ["BMP3"]; + _u = _u + ["BTR90"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam2"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["T72_RU"]; + _u = _u + ["T72_RU"]; + _u = _u + ["GAZ_Vodnik_MedEvac"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam3"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["BMP3"]; + _u = _u + ["GAZ_Vodnik_HMG"]; + _u = _u + ["T72_RU"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam1"]; + _u = ["RU_Soldier_HAT"]; + _u = _u + ["RU_Soldier_HAT"]; + _u = _u + ["RU_Soldier_HAT"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam2"]; + _u = ["RUS_Commander"]; + _u = _u + ["RUS_Soldier1"]; + _u = _u + ["RUS_Soldier2"]; + _u = _u + ["RUS_Soldier_GL"]; + _u = _u + ["RUS_Soldier_Marksman"]; + _u = _u + ["RUS_Soldier3"]; + _u = _u + ["RUS_Soldier_TL"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam3"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_MG"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier_LAT"]; + _u = _u + ["RU_Soldier_Marksman"]; + _u = _u + ["RU_Soldier_AR"]; + _u = _u + ["RU_Soldier_GL"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam1"]; + _u = ["RU_Soldier_TL"]; + if (WF_ACE) then + { + _u = _u + ["ACE_T90"]; + + _u = _u + ["ACE_T90"]; + + _u = _u + ["ACE_T90"]; + } + else + { + _u = _u + ["T90"]; + _u = _u + ["T90"]; + _u = _u + ["T90"]; + }; + _u = _u + ["T72_RU"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam2"]; + _u = ["RU_Soldier_TL"]; + if (WF_ACE) then + { + _u = _u + ["ACE_T90"]; + } + else + { + _u = _u + ["T90"]; + }; + _u = _u + ["GRAD_RU"]; + _u = _u + ["T72_RU"]; + _u = _u + ["2S6M_Tunguska"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam3"]; + _u = ["RU_Soldier_TL"]; + + if (WF_ACE) then + { + _u = _u + ["ACE_T90"]; + + _u = _u + ["ACE_T90"]; + } + else + { + _u = _u + ["T90"]; + + _u = _u + ["T90"]; + }; + + _u = _u + ["2S6M_Tunguska"]; + _u = _u + ["T72_RU"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; +}; + +if (WF_A2_Arrowhead) then { + //--- West. + _n = ["SmallTeam1"]; + _u = ["US_Soldier_SL_EP1"]; + _u = _u + ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + _u = _u + ["US_Soldier_Medic_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_MG_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["HMMWV_Avenger_DES_EP1"]; + _u = _u + ["HMMWV_M1151_M2_DES_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam2"]; + _u = ["US_Soldier_SL_EP1"]; + _u = _u + ["HMMWV_TOW_DES_EP1"]; + _u = _u + ["M1126_ICV_mk19_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["HMMWV_Avenger_DES_EP1"]; + _u = _u + ["HMMWV_M998_crows_MK19_DES_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_Medic_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + _u = _u + ["US_Soldier_AT_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_MG_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam3"]; + _u = ["US_Soldier_Sniper_EP1"]; + _u = _u + ["US_Soldier_Marksman_EP1"]; + _u = _u + ["US_Soldier_Marksman_EP1"]; + _u = _u + ["US_Soldier_SniperH_EP1"]; + _u = _u + ["US_Soldier_SniperH_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["HMMWV_Avenger_DES_EP1"]; + _u = _u + ["M2A3_EP1"]; + _u = _u + ["M1126_ICV_M2_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["M1A1_US_DES_EP1"]; + _u = _u + ["M1A1_US_DES_EP1"]; + _u = _u + ["HMMWV_Ambulance_DES_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["M1126_ICV_M2_EP1"]; + _u = _u + ["HMMWV_M998_crows_M2_DES_EP1"]; + _u = _u + ["M1A1_US_DES_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam1"]; + _u = ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_AT_EP1"]; + _u = _u + ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam2"]; + _u = ["US_Delta_Force_EP1"]; + _u = _u + ["US_Delta_Force_AR_EP1"]; + _u = _u + ["US_Delta_Force_SD_EP1"]; + _u = _u + ["US_Delta_Force_Assault_EP1"]; + _u = _u + ["US_Delta_Force_Marksman_EP1"]; + _u = _u + ["US_Delta_Force_M14_EP1"]; + _u = _u + ["US_Delta_Force_MG_EP1"]; + _u = _u + ["US_Delta_Force_Medic_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_Medic_EP1"]; + _u = _u + ["US_Soldier_GL_EP1"]; + _u = _u + ["US_Soldier_Sniper_EP1"]; + _u = _u + ["US_Soldier_AT_EP1"]; + _u = _u + ["US_Soldier_MG_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["MLRS_DES_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["M1A2_US_TUSK_MG_EP1"]; + _u = _u + ["M6_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + //--- East. + _n = ["SmallTeam1"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["TK_Soldier_MG_EP1"]; + _u = _u + ["TK_Soldier_AT_EP1"]; + _u = _u + ["TK_Soldier_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam2"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["TK_Soldier_LAT_EP1"]; + _u = _u + ["TK_Soldier_Spotter_EP1"]; + _u = _u + ["TK_Soldier_AR_EP1"]; + _u = _u + ["TK_Soldier_GL_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam3"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["TK_Soldier_MG_EP1"]; + _u = _u + ["TK_Soldier_GL_EP1"]; + _u = _u + ["TK_Soldier_AT_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam1"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["LandRover_MG_TK_EP1"]; + _u = _u + ["BTR60_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam2"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["BTR60_TK_EP1"]; + _u = _u + ["BRDM2_TK_EP1"]; + _u = _u + ["BRDM2_ATGM_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam3"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["UAZ_AGS30_TK_EP1"]; + _u = _u + ["BRDM2_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam1"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["TK_Soldier_AA_EP1"]; + _u = _u + ["TK_Soldier_LAT_EP1"]; + _u = _u + ["TK_Soldier_AT_EP1"]; + _u = _u + ["TK_Soldier_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam2"]; + _u = ["TK_Special_Forces_TL_EP1"]; + _u = _u + ["TK_Soldier_Medic_EP1"]; + _u = _u + ["TK_Soldier_HAT_EP1"]; + _u = _u + ["TK_Soldier_HAT_EP1"]; + _u = _u + ["TK_Special_Forces_EP1"]; + _u = _u + ["TK_Special_Forces_EP1"]; + _u = _u + ["TK_Special_Forces_MG_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam3"]; + _u = ["TK_Special_Forces_TL_EP1"]; + _u = _u + ["TK_Soldier_Medic_EP1"]; + _u = _u + ["TK_Soldier_SniperH_EP1"]; + _u = _u + ["TK_Soldier_Sniper_Night_EP1"]; + _u = _u + ["TK_Soldier_Night_1_EP1"]; + _u = _u + ["TK_Soldier_Night_2_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam1"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["BMP2_TK_EP1"]; + _u = _u + ["BMP2_TK_EP1"]; + _u = _u + ["BTR60_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam2"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["M113Ambul_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam3"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["BMP2_TK_EP1"]; + _u = _u + ["Ural_ZU23_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam1"]; + _u = ["TK_Soldier_HAT_EP1"]; + _u = _u + ["TK_Soldier_HAT_EP1"]; + _u = _u + ["TK_Soldier_HAT_EP1"]; + _u = _u + ["TK_Soldier_AT_EP1"]; + _u = _u + ["TK_Soldier_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam2"]; + _u = ["TK_Special_Forces_TL_EP1"]; + _u = _u + ["TK_Special_Forces_EP1"]; + _u = _u + ["TK_Special_Forces_EP1"]; + _u = _u + ["TK_Special_Forces_EP1"]; + _u = _u + ["TK_Special_Forces_MG_EP1"]; + _u = _u + ["TK_Special_Forces_MG_EP1"]; + _u = _u + ["TK_Special_Forces_MG_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam3"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["TK_Soldier_MG_EP1"]; + _u = _u + ["TK_Soldier_AT_EP1"]; + _u = _u + ["TK_Soldier_LAT_EP1"]; + _u = _u + ["TK_Soldier_Spotter_EP1"]; + _u = _u + ["TK_Soldier_AR_EP1"]; + _u = _u + ["TK_Soldier_GL_EP1"]; + _u = _u + ["TK_Soldier_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam1"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["T55_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam2"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["T55_TK_EP1"]; + _u = _u + ["T55_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["ZSU_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam3"]; + _u = ["TK_Soldier_SL_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + _u = _u + ["ZSU_TK_EP1"]; + _u = _u + ["T72_TK_EP1"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; +}; + +if (WF_A2_CombinedOps) then { + //--- West. + _n = ["SmallTeam1"]; + _u = ["US_Soldier_SL_EP1"]; + _u = _u + ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + _u = _u + ["US_Soldier_Medic_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_MG_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"HMMWV_Avenger"} else {"HMMWV_Avenger_DES_EP1"}]; + _u = _u + [if (WF_Camo) then {"HMMWV_M2"} else {"HMMWV_M1151_M2_DES_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam2"]; + _u = ["US_Soldier_SL_EP1"]; + _u = _u + [if (WF_Camo) then {"LAV25"} else {"M1126_ICV_mk19_EP1"}]; + _u = _u + [if (WF_Camo) then {"HMMWV_TOW"} else {"HMMWV_TOW_DES_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"HMMWV_Avenger"} else {"HMMWV_Avenger_DES_EP1"}]; + _u = _u + [if (WF_Camo) then {"HMMWV_MK19"} else {"HMMWV_M998_crows_MK19_DES_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_Medic_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + _u = _u + ["US_Soldier_AT_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_MG_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam3"]; + _u = ["US_Soldier_Sniper_EP1"]; + _u = _u + ["US_Soldier_Marksman_EP1"]; + _u = _u + ["US_Soldier_Marksman_EP1"]; + _u = _u + ["US_Soldier_SniperH_EP1"]; + _u = _u + ["US_Soldier_SniperH_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"HMMWV_Avenger"} else {"HMMWV_Avenger_DES_EP1"}]; + _u = _u + ["M2A3_EP1"]; + _u = _u + [if (WF_Camo) then {"AAV"} else {"M1126_ICV_M2_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"M1A1"} else {"M1A1_US_DES_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A1"} else {"M1A1_US_DES_EP1"}]; + _u = _u + [if (WF_Camo) then {"HMMWV_Ambulance"} else {"HMMWV_Ambulance_DES_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"AAV"} else {"M1126_ICV_M2_EP1"}]; + _u = _u + [if (WF_Camo) then {"HMMWV_Armored"} else {"HMMWV_M998_crows_M2_DES_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A1"} else {"M1A1_US_DES_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam1"]; + _u = ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_AT_EP1"]; + _u = _u + ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_HAT_EP1"]; + _u = _u + ["US_Soldier_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam2"]; + _u = ["US_Delta_Force_EP1"]; + _u = _u + ["US_Delta_Force_AR_EP1"]; + _u = _u + ["US_Delta_Force_SD_EP1"]; + _u = _u + ["US_Delta_Force_Assault_EP1"]; + _u = _u + ["US_Delta_Force_Marksman_EP1"]; + _u = _u + ["US_Delta_Force_M14_EP1"]; + _u = _u + ["US_Delta_Force_MG_EP1"]; + _u = _u + ["US_Delta_Force_Medic_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_AA_EP1"]; + _u = _u + ["US_Soldier_Medic_EP1"]; + _u = _u + ["US_Soldier_GL_EP1"]; + _u = _u + ["US_Soldier_Sniper_EP1"]; + _u = _u + ["US_Soldier_AT_EP1"]; + _u = _u + ["US_Soldier_MG_EP1"]; + _u = _u + ["US_Soldier_AR_EP1"]; + _u = _u + ["US_Soldier_LAT_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam1"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam2"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + [if (WF_Camo) then {"MLRS"} else {"MLRS_DES_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam3"]; + _u = ["US_Soldier_TL_EP1"]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + [if (WF_Camo) then {"M1A2_TUSK_MG"} else {"M1A2_US_TUSK_MG_EP1"}]; + _u = _u + ["M6_EP1"]; + [Format["WFBE_WEST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + //--- East. + _n = ["SmallTeam1"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_MG"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam2"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_LAT"]; + _u = _u + ["RU_Soldier_Marksman"]; + _u = _u + ["RU_Soldier_AR"]; + _u = _u + ["RU_Soldier_GL"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallTeam3"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["RU_Soldier_MG"]; + _u = _u + ["RU_Soldier_GL"]; + _u = _u + ["RU_Soldier_AT"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam1"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["UAZ_AGS30_RU"]; + _u = _u + ["GAZ_Vodnik"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam2"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["GAZ_Vodnik"]; + _u = _u + ["GAZ_Vodnik_HMG"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SmallVehTeam3"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["UAZ_AGS30_RU"]; + _u = _u + ["GAZ_Vodnik_HMG"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam1"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_AA"]; + _u = _u + ["RU_Soldier_LAT"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam2"]; + _u = ["RUS_Commander"]; + _u = _u + ["RUS_Soldier1"]; + _u = _u + ["RUS_Soldier2"]; + _u = _u + ["RUS_Soldier_GL"]; + _u = _u + ["RUS_Soldier_Marksman"]; + _u = _u + ["RUS_Soldier3"]; + _u = _u + ["RUS_Soldier_TL"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumTeam3"]; + _u = ["MVD_Soldier_TL"]; + _u = _u + ["MVD_Soldier_MG"]; + _u = _u + ["MVD_Soldier_AT"]; + _u = _u + ["MVD_Soldier_GL"]; + _u = _u + ["MVD_Soldier_Sniper"]; + _u = _u + ["MVD_Soldier_Marksman"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam1"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["GAZ_Vodnik"]; + _u = _u + ["BMP3"]; + _u = _u + ["BTR90"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam2"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["T72_RU"]; + _u = _u + ["T72_RU"]; + _u = _u + ["GAZ_Vodnik_MedEvac"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MediumVehTeam3"]; + _u = ["RU_Soldier_TL"]; + _u = _u + ["BMP3"]; + _u = _u + ["GAZ_Vodnik_HMG"]; + _u = _u + ["T72_RU"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam1"]; + _u = ["RU_Soldier_HAT"]; + _u = _u + ["RU_Soldier_HAT"]; + _u = _u + ["RU_Soldier_HAT"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam2"]; + _u = ["RUS_Commander"]; + _u = _u + ["RUS_Soldier1"]; + _u = _u + ["RUS_Soldier2"]; + _u = _u + ["RUS_Soldier_GL"]; + _u = _u + ["RUS_Soldier_Marksman"]; + _u = _u + ["RUS_Soldier3"]; + _u = _u + ["RUS_Soldier_TL"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeTeam3"]; + _u = ["RU_Soldier_SL"]; + _u = _u + ["RU_Soldier_MG"]; + _u = _u + ["RU_Soldier_AT"]; + _u = _u + ["RU_Soldier_LAT"]; + _u = _u + ["RU_Soldier_Marksman"]; + _u = _u + ["RU_Soldier_AR"]; + _u = _u + ["RU_Soldier_GL"]; + _u = _u + ["RU_Soldier"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam1"]; + _u = ["RU_Soldier_TL"]; + + if (WF_ACE) then + { + _u = _u + ["ACE_T90"]; + _u = _u + ["ACE_T90"]; + _u = _u + ["ACE_T90"]; + } + else + { + _u = _u + ["T90"]; + _u = _u + ["T90"]; + _u = _u + ["T90"]; + }; + + _u = _u + ["T72_RU"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam2"]; + _u = ["RU_Soldier_TL"]; + if (WF_ACE) then + { + _u = _u + ["ACE_T90"]; + } + else + { + _u = _u + ["T90"]; + }; + _u = _u + ["GRAD_RU"]; + _u = _u + ["T72_RU"]; + _u = _u + ["2S6M_Tunguska"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LargeVehTeam3"]; + _u = ["RU_Soldier_TL"]; + if (WF_ACE) then + { + _u = _u + ["ACE_T90"]; + _u = _u + ["ACE_T90"]; + } + else + { + _u = _u + ["T90"]; + _u = _u + ["T90"]; + }; + _u = _u + ["2S6M_Tunguska"]; + _u = _u + ["T72_RU"]; + [Format["WFBE_EAST%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; +}; + +diag_log "[WFBE (INIT)] Config_Occupation: Intialization - [Done]"; \ No newline at end of file diff --git a/Server/Config/Config_Resistance.sqf b/Server/Config/Config_Resistance.sqf new file mode 100644 index 0000000..7dcc61b --- /dev/null +++ b/Server/Config/Config_Resistance.sqf @@ -0,0 +1,276 @@ +private ["_resType","_n","_u"]; +_resType = 'WFBE_RESISTANCEFACTION' Call GetNamespace; +if (isNil '_resType') then {_resType = -1}; + +if (WF_A2_Vanilla || _resType == 0) then { + _n = ["Group"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_AR"]; + _u = _u + ["GUE_Soldier_1"]; + _u = _u + ["GUE_Soldier_3"]; + _u = _u + ["GUE_Soldier_2"]; + _u = _u + ["GUE_Soldier_Medic"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["GroupAssault"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_AR"]; + _u = _u + ["GUE_Soldier_MG"]; + _u = _u + ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_2"]; + _u = _u + ["GUE_Soldier_Medic"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["GroupWeapons"]; + _u = ["GUE_Soldier_2"]; + _u = _u + ["GUE_Soldier_MG"]; + _u = _u + ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_Sab"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Patrol1"]; + _u = ["GUE_Soldier_2"]; + _u = _u + ["GUE_Soldier_MG"]; + _u = _u + ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_GL"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Patrol2"]; + _u = ["GUE_Soldier_1"]; + _u = _u + ["GUE_Soldier_AR"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_2"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["ATTeam"]; + _u = ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_AR"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["AATeam"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["GUE_Soldier_AA"]; + _u = _u + ["GUE_Soldier_AA"]; + _u = _u + ["GUE_Soldier_AR"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SniperTeam"]; + _u = ["GUE_Soldier_Sniper"]; + _u = _u + ["GUE_Soldier_Scout"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Militia"]; + _u = ["GUE_Worker2"]; + _u = _u + ["GUE_Woodlander3"]; + _u = _u + ["GUE_Villager3"]; + _u = _u + ["GUE_Woodlander2"]; + _u = _u + ["GUE_Woodlander1"]; + _u = _u + ["GUE_Villager4"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Technical"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["Offroad_DSHKM_Gue"]; + _u = _u + ["Offroad_SPG9_Gue"]; + _u = _u + ["Pickup_PK_GUE"]; + _u = _u + ["GUE_Soldier_MG"]; + _u = _u + ["GUE_Soldier_3"]; + _u = _u + ["GUE_Soldier_Sniper"]; + _u = _u + ["GUE_Soldier_AR"]; + _u = _u + ["GUE_Soldier_Medic"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MotorizedGroup"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["V3S_GUE"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_1"]; + _u = _u + ["GUE_Soldier_AR"]; + _u = _u + ["GUE_Soldier_MG"]; + _u = _u + ["GUE_Soldier_AT"]; + _u = _u + ["GUE_Soldier_Medic"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MotorizedAATeam"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["Ural_ZU23_Gue"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_AA"]; + _u = _u + ["GUE_Soldier_1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MechanizedPatrol"]; + _u = ["GUE_Soldier_AR"]; + _u = _u + ["BRDM2_GUE"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MechanizedGroup"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["BMP2_GUE"]; + _u = _u + ["GUE_Soldier_MG"]; + _u = _u + ["GUE_Soldier_GL"]; + _u = _u + ["GUE_Soldier_3"]; + _u = _u + ["GUE_Soldier_AR"]; + _u = _u + ["GUE_Soldier_Sniper"]; + _u = _u + ["GUE_Soldier_AT"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LightArmor"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["BMP2_GUE"]; + _u = _u + ["BMP2_GUE"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["HeavyArmor"]; + _u = ["GUE_Soldier_CO"]; + _u = _u + ["T72_GUE"]; + _u = _u + ["T72_GUE"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; +}; + +if (WF_A2_Arrowhead || _resType == 1) then { + _n = ["Group"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + _u = _u + ["TK_GUE_Soldier_EP1"]; + _u = _u + ["TK_GUE_Soldier_5_EP1"]; + _u = _u + ["TK_GUE_Soldier_5_EP1"]; + _u = _u + ["TK_GUE_Bonesetter_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["GroupAssault"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_AT_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + _u = _u + ["TK_GUE_Soldier_MG_EP1"]; + _u = _u + ["TK_GUE_Soldier_HAT_EP1"]; + _u = _u + ["TK_GUE_Soldier_5_EP1"]; + _u = _u + ["TK_GUE_Bonesetter_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["GroupWeapons"]; + _u = ["TK_GUE_Soldier_5_EP1"]; + _u = _u + ["TK_GUE_Soldier_MG_EP1"]; + _u = _u + ["TK_GUE_Soldier_AT_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_AT_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Patrol1"]; + _u = ["TK_GUE_Soldier_5_EP1"]; + _u = _u + ["TK_GUE_Soldier_MG_EP1"]; + _u = _u + ["TK_GUE_Soldier_AT_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Patrol2"]; + _u = ["TK_GUE_Soldier_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_HAT_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["ATTeam"]; + _u = ["TK_GUE_Soldier_AT_EP1"]; + _u = _u + ["TK_GUE_Soldier_AT_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["AATeam"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["TK_GUE_Soldier_AA_EP1"]; + _u = _u + ["TK_GUE_Soldier_AA_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["SniperTeam"]; + _u = ["TK_GUE_Soldier_Sniper_EP1"]; + _u = _u + ["TK_GUE_Soldier_2_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Militia"]; + _u = ["TK_GUE_Soldier_2_EP1"]; + _u = _u + ["TK_GUE_Soldier_3_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_5_EP1"]; + _u = _u + ["TK_GUE_Bonesetter_EP1"]; + _u = _u + ["TK_GUE_Soldier_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["Technical"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["Offroad_DSHKM_TK_GUE_EP1"]; + _u = _u + ["Offroad_SPG9_TK_GUE_EP1"]; + _u = _u + ["Pickup_PK_TK_GUE_EP1"]; + _u = _u + ["TK_GUE_Soldier_MG_EP1"]; + _u = _u + ["TK_GUE_Soldier_5_EP1"]; + _u = _u + ["TK_GUE_Soldier_Sniper_EP1"]; + _u = _u + ["TK_GUE_Soldier_HAT_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + _u = _u + ["TK_GUE_Bonesetter_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MotorizedGroup"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["V3S_TK_GUE_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_AT_EP1"]; + _u = _u + ["TK_GUE_Soldier_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + _u = _u + ["TK_GUE_Soldier_MG_EP1"]; + _u = _u + ["TK_GUE_Soldier_HAT_EP1"]; + _u = _u + ["TK_GUE_Bonesetter_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MotorizedAATeam"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["Ural_ZU23_TK_GUE_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_AA_EP1"]; + _u = _u + ["TK_GUE_Soldier_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MechanizedPatrol"]; + _u = ["TK_GUE_Soldier_AR_EP1"]; + _u = _u + ["BTR40_MG_TK_GUE_EP1"]; + _u = _u + ["BRDM2_TK_GUE_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["MechanizedGroup"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["T34_TK_GUE_EP1"]; + _u = _u + ["BTR40_MG_TK_GUE_EP1"]; + _u = _u + ["TK_GUE_Soldier_MG_EP1"]; + _u = _u + ["TK_GUE_Soldier_4_EP1"]; + _u = _u + ["TK_GUE_Soldier_HAT_EP1"]; + _u = _u + ["TK_GUE_Soldier_AR_EP1"]; + _u = _u + ["TK_GUE_Soldier_Sniper_EP1"]; + _u = _u + ["TK_GUE_Soldier_AT_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["LightArmor"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["T34_TK_GUE_EP1"]; + _u = _u + ["T34_TK_GUE_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; + + _n = _n + ["HeavyArmor"]; + _u = ["TK_GUE_Warlord_EP1"]; + _u = _u + ["T55_TK_GUE_EP1"]; + _u = _u + ["T55_TK_GUE_EP1"]; + [Format["WFBE_RES%1UNITS",_n select (count _n - 1)],_u,true] Call SetNamespace; +}; + +diag_log "[WFBE (INIT)] Config_Resistance: Intialization - [Done]"; \ No newline at end of file diff --git a/Server/Config/Config_SmallTown.sqf b/Server/Config/Config_SmallTown.sqf new file mode 100644 index 0000000..4aadeb3 --- /dev/null +++ b/Server/Config/Config_SmallTown.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['light1'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 70; + +[_town,_townName,10,50,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_SmallTown2.sqf b/Server/Config/Config_SmallTown2.sqf new file mode 100644 index 0000000..481545d --- /dev/null +++ b/Server/Config/Config_SmallTown2.sqf @@ -0,0 +1,13 @@ +Private ['_probability','_range','_teams','_town','_townName']; + +_town = _this Select 0; +_townName = _this Select 1; + +_range = 600; +if (Count _this > 3) then {_range = _this Select 3}; + +_teams = ['light2'] Call Compile preprocessFile "Server\Functions\Server_SelectResTeam.sqf"; + +_probability = 78; + +[_town,_townName,10,50,_range,_teams,_probability] ExecVM "Common\Init\Init_Location.sqf"; \ No newline at end of file diff --git a/Server/Config/Config_Town.sqf b/Server/Config/Config_Town.sqf new file mode 100644 index 0000000..35f5724 --- /dev/null +++ b/Server/Config/Config_Town.sqf @@ -0,0 +1,25 @@ +Private ['_configScripts','_location','_locationName','_params','_range','_script','_total']; + +_location = _this Select 0; +_locationName = _this Select 1; +_configScripts = _this Select 2; + +if (isNull _location) exitWith {}; + +waitUntil {townModeSet}; +if ((str _location) in TownTemplate) exitWith { + diag_log Format ["[WFBE (INIT)][frameno:%3 | ticktime:%4] Config_Town: Removing town %1 (%2) since the town is removed in the towns templates.",_location,_locationName,diag_frameno,diag_tickTime]; + if (isServer) then {deleteVehicle _location}; +}; + +_range = 600; +if (Count _this > 4) then {_range = _this Select 4}; + +_total = Count _configScripts; +_script = _configScripts Select (Random (_total - 1)); +_params = [_location,_locationName]; +if (Count _this > 4) then {_params = _params + [_range]}; + +waitUntil{initJIP && commonInitComplete}; + +_params ExecVM Format["Server\Config\Config_%1.sqf",_script]; \ No newline at end of file diff --git a/Server/Construction/Construction_HQSite.sqf b/Server/Construction/Construction_HQSite.sqf new file mode 100644 index 0000000..3e4bef6 --- /dev/null +++ b/Server/Construction/Construction_HQSite.sqf @@ -0,0 +1,83 @@ +Private ["_areas","_deployed","_direction","_grp","_HQ","_HQName","_logic","_MHQ","_near","_position","_side","_sideText","_site","_text","_type","_update","_varTH"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_sideText = _side; + +/* Handle the LAG. */ +_varTH = format['WF_CHQInUse_%1',_sideText]; +waitUntil {!(WF_Logic getVariable _varTH)}; +WF_Logic setVariable [_varTH,true]; + +_HQ = (_sideText) Call GetSideHQ; +_deployed = (_sideText) Call GetSideHQDeployed; + +if (!_deployed) then { + _HQ setPos [1,1,1]; + + _site = _type CreateVehicle _position; + _site SetDir _direction; + _site SetPos _position; + + Call Compile Format ["%1MHQ = _site; %1MHQDeployed = true; publicVariable '%1MHQ'; publicVariable '%1MHQDeployed';",_sideText]; + + _site setVehicleInit Format["[this,true,%1] ExecVM 'Client\Init\Init_BaseStructure.sqf'",_side]; + processInitCommands; + + ["Constructed",_type,_side] Spawn SideMessage; + Call Compile Format ["_site addEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",_side,typeOf _site]; + _site addEventHandler ["hit",{_this Spawn BuildingDamaged}]; + if (paramHandleFF) then {Call Compile Format ["_site addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]}; + + //--- base area limits. + if (paramBaseArea) then { + _update = true; + _areas = WF_Logic getVariable Format['%1Area',_sideText]; + _near = [_position,_areas] Call SortByDistance; + if (count _near > 0) then { + if ((_near select 0) distance _position < (('WFBE_BASEAREARANGE' Call GetNamespace) + ('WFBE_MHQBUILDINGRANGE' Call GetNamespace))) then {_update = false}; + }; + if (_update) then { + _grp = createGroup sideLogic; + _logic = _grp createUnit ["Logic",[0,0,0],[],0,"NONE"]; + _logic setPos _position; + WF_Logic setVariable [Format['%1Area',_sideText],_areas + [_logic],true]; + }; + }; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_HQSite: The %1 MHQ (%2) was deployed",_sideText,_type,diag_frameno,diag_tickTime]; + + deleteVehicle _HQ; +} else { + _position = getPos _HQ; + _direction = getDir _HQ; + _HQName = Format["WFBE_%1MHQNAME",_sideText] Call GetNamespace; + + _HQ SetPos [1,1,1]; + + _MHQ = _HQName createVehicle _position; + + Call Compile Format ["%1MHQ = _MHQ; %1MHQDeployed = false; publicVariable '%1MHQ'; publicVariable '%1MHQDeployed';",_sideText]; + + _MHQ setDir _direction; + _MHQ setVelocity [0,0,-1]; + _MHQ setVariable ["WFBE_Taxi_Prohib", true]; + + ["Constructed",_HQName,_side] Spawn SideMessage; + Call Compile Format ["_MHQ AddEventHandler [""killed"",{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",_side,typeOf _MHQ]; + if (paramHandleFF) then {Call Compile Format ["_MHQ addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]}; + + _text = ""; + if (('WFBE_INCOMINGMISSILEMAXRANGE' Call GetNamespace) != 0) then {_text = "this addEventHandler ['IncomingMissile', {_this Spawn HandleIncomingMissile}];"}; + + _MHQ setVehicleInit Format["['Headquarters','ColorGreen',[1,1],'','HQUndeployed',this,0.2,false,'','',false,%1] ExecVM 'Common\Common_MarkerUpdate.sqf';%2",_side,_text]; + processInitCommands; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_HQSite: The %1 MHQ (%2) was mobilized",_sideText,_HQName,diag_frameno,diag_tickTime]; + + deleteVehicle _HQ; +}; + +/* Handle the LAG. */ +WF_Logic setVariable [_varTH,false]; \ No newline at end of file diff --git a/Server/Construction/Construction_MediumSite.sqf b/Server/Construction/Construction_MediumSite.sqf new file mode 100644 index 0000000..c153784 --- /dev/null +++ b/Server/Construction/Construction_MediumSite.sqf @@ -0,0 +1,135 @@ +//***************************************************************************************** +//Description: Creates a small construction site. +//***************************************************************************************** +Private ["_construct","_constructed","_direction","_group","_index","_nearLogic","_objects","_position","_rlType","_side","_site","_siteName","_startTime","_structures","_structuresNames","_time","_timeNextUpdate","_type"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_index = _this select 4; + +_time = ((Format ["WFBE_%1STRUCTURETIMES",str _side] Call GetNamespace) select _index) / 2; + +_siteName = Format["WFBE_%1CONSTRUCTIONSITE",str _side] Call GetNamespace; + +_structures = Format ['WFBE_%1STRUCTURES',str _side] Call GetNamespace; +_structuresNames = Format ['WFBE_%1STRUCTURENAMES',str _side] Call GetNamespace; +_rlType = _structures select (_structuresNames find _type); + +_startTime = time; +_timeNextUpdate = _startTime + _time; + +_objects = []; +if (WF_A2_Arrowhead) then {_objects = [[_siteName,[0,0,0.00242043],359.958,1,0],["Paleta2",[0.430908,-5.60693,-0.30535],359.945,1,0],["Paleta1",[-2.62598,-6.0437,0.000275612],359.951,1,0],["Land_Barrel_sand",[-10.1826,0.356689,7.62939e-005],0.00146227,1,0],["Land_Barrel_sand",[-10.7854,-1.97974,0.000187874],359.987,1,0],["Paleta1",[-9.7251,5.53955,0.000106812],359.976,1,0],["Land_Barrel_sand",[-11.053,-4.12183,0.00019455],359.987,1,0],["Land_Barrel_sand",[-12.3416,-1.57056,7.43866e-005],0.00146227,1,0],["Barrels",[-12.5134,0.682861,0.000136375],0.00146227,1,0],["RoadBarrier_long",[1.63794,-12.8806,-0.000716209],359.92,1,0],["Land_Barrel_sand",[-11.5149,-6.25757,0.00084877],359.938,1,0],["Land_Barrel_sand",[-12.7363,-3.63184,0.000207901],359.938,1,0],["Barrel4",[14.1938,0.500732,0.000412941],359.98,1,0],["Land_Barrel_sand",[-13.0708,-5.9082,0.000863075],359.938,1,0],["Barrel5",[14.7661,-1.11182,0.000411987],359.98,1,0],["Barrel1",[14.7314,2.21338,0.000409126],359.98,1,0],["Paleta2",[12.0034,9.8418,-0.305568],0.0412118,1,0],["RoadCone",[-12.2202,-13.7024,0.000279427],359.984,1,0],["RoadCone",[-12.1877,15.0469,0.000328064],359.969,1,0],["RoadCone",[14.5701,-13.311,0.000322342],359.995,1,0],["RoadCone",[14.6084,14.6824,0.000889778],359.994,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [[_siteName,[0,0,0.00242043],359.958,1,0],["Paleta2",[0.430908,-5.60693,-0.30535],359.945,1,0],["Paleta1",[-2.62598,-6.0437,0.000275612],359.951,1,0],["Land_Ind_BoardsPack1",[-0.82251,-9.15479,0.00291061],49.9467,1,0],["Land_Barrel_sand",[-10.1826,0.356689,7.62939e-005],0.00146227,1,0],["Land_Barrel_sand",[-10.7854,-1.97974,0.000187874],359.987,1,0],["Paleta1",[-9.7251,5.53955,0.000106812],359.976,1,0],["Land_Ind_Timbers",[1.88354,11.1238,-0.487763],95.0061,1,0],["Land_Barrel_sand",[-11.053,-4.12183,0.00019455],359.987,1,0],["Land_Ind_BoardsPack1",[-6.6582,-10.0774,0.0021534],324.956,1,0],["Land_Ind_BoardsPack1",[9.50244,-7.4668,0.00151634],270,1,0],["Land_Ind_Timbers",[12.0264,4.19629,-0.534346],359.98,1,0],["Land_Barrel_sand",[-12.3416,-1.57056,7.43866e-005],0.00146227,1,0],["Barrels",[-12.5134,0.682861,0.000136375],0.00146227,1,0],["RoadBarrier_long",[1.63794,-12.8806,-0.000716209],359.92,1,0],["Land_Barrel_sand",[-11.5149,-6.25757,0.00084877],359.938,1,0],["Land_Barrel_sand",[-12.7363,-3.63184,0.000207901],359.938,1,0],["Land_Ind_BoardsPack1",[-4.74194,-12.4204,0.00105476],49.9807,1,0],["Barrel4",[14.1938,0.500732,0.000412941],359.98,1,0],["Land_Barrel_sand",[-13.0708,-5.9082,0.000863075],359.938,1,0],["Barrel5",[14.7661,-1.11182,0.000411987],359.98,1,0],["Land_Ind_BoardsPack1",[9.42847,-11.5142,0.00151634],359.964,1,0],["Barrel1",[14.7314,2.21338,0.000409126],359.98,1,0],["Paleta2",[12.0034,9.8418,-0.305568],0.0412118,1,0],["RoadCone",[-12.2202,-13.7024,0.000279427],359.984,1,0],["RoadCone",[-12.1877,15.0469,0.000328064],359.969,1,0],["RoadCone",[14.5701,-13.311,0.000322342],359.995,1,0],["RoadCone",[14.6084,14.6824,0.000889778],359.994,1,0]]}; +_construct = Compile PreprocessFile "ca\modules\dyno\data\scripts\objectMapper.sqf"; +_constructed = ([_position,_direction,_objects] Call _construct); + +//--- Create the logic. +(createGroup sideLogic) createUnit ["LocationLogicStart",_position,[],0,"NONE"]; + +_nearLogic = objNull; +if !(paramUseWorkers) then { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + waitUntil {time >= _timeNextUpdate}; + _timeNextUpdate = _startTime + _time * 2; +} else { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + //--- Instanciate the logic. + _nearLogic setVariable ["WFBE_B_Completion", 0]; + _nearLogic setVariable ["WFBE_B_CompletionRatio", 0.6]; + _nearLogic setVariable ["WFBE_B_Direction", _direction]; + _nearLogic setVariable ["WFBE_B_Position", _position]; + _nearLogic setVariable ["WFBE_B_Repair", false]; + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + //--- Add the logic to the list. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) + [_nearLogic],true] Call SetNamespace; + + //--- Awaits for 33% of completion. + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 33.33) exitWith {}; + }; +}; + +if (WF_A2_Arrowhead) then {_objects = [[_siteName,[2.52539,-0.0065918,-0.000685692],359.928,1,0],["Land_WoodenRamp",[-2.27954,-0.582764,0.377601],270,1,0],["Land_WoodenRamp",[0.94751,-4.2085,0.388518],179.986,1,0],[_siteName,[2.60547,6.20386,-0.000685692],359.928,1,0],["Land_Dirthump01_EP1",[-8.63159,8.021,-0.00167847],29.985,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [[_siteName,[2.52539,-0.0065918,-0.000685692],359.928,1,0],["Land_WoodenRamp",[-2.27954,-0.582764,0.377601],270,1,0],["Land_WoodenRamp",[0.94751,-4.2085,0.388518],179.986,1,0],[_siteName,[2.60547,6.20386,-0.000685692],359.928,1,0],["Land_Dirthump01",[-8.63159,8.021,-0.00167847],29.985,1,0]]}; +_constructed = _constructed + ([_position,_direction,_objects] Call _construct); + +if !(paramUseWorkers) then { + waitUntil {time >= _timeNextUpdate}; + _timeNextUpdate = _startTime + _time * 3; +} else { + //--- Awaits for 66% + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 66.66) exitWith {}; + }; +}; + +if (WF_A2_Arrowhead) then {_objects = [["Land_Misc_Scaffolding",[5.67456,2.39307,0.0763969],179.92,1,0],["Land_Dirthump02_EP1",[-8.63159,8.021,0.000141144],29.9958,1,0],["Barrels",[11.4519,12.5623,0.00311279],359.877,1,0],["RoadCone",[-12.1465,-13.7354,0.000406265],359.958,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [["Land_Misc_Scaffolding",[5.67456,2.39307,0.0763969],179.92,1,0],["Land_Ind_Timbers",[10.0811,4.63477,-0.127748],359.961,1,0],["Land_Dirthump02",[-8.63159,8.021,0.000141144],29.9958,1,0],["Land_Ind_BoardsPack1",[13.3027,-7.63159,0.00639725],359.838,1,0],["Land_Ind_BoardsPack1",[-9.70117,-12.4263,0.00152397],324.976,1,0],["Land_Ind_BoardsPack1",[-7.78491,-14.7693,0.00152779],49.9774,1,0],["Barrels",[11.4519,12.5623,0.00311279],359.877,1,0],["Land_Ind_BoardsPack1",[13.4668,-11.5061,0.00515175],359.942,1,0],["RoadCone",[-12.1465,-13.7354,0.000406265],359.958,1,0]]}; +_constructed = _constructed + ([_position,_direction,_objects] Call _construct); + +if !(paramUseWorkers) then { + waitUntil {time >= _timeNextUpdate}; + + if !(isNull _nearLogic) then { + _group = group _nearLogic; + deleteVehicle _nearLogic; + deleteGroup _group; + }; +} else { + //--- Awaits for 100% + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 100) exitWith {}; + }; + + //--- Remove the logic from the list since it's built. Add it back if destroyed. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_nearLogic],true] Call SetNamespace; +}; + +{if !(isNull _x) then {deleteVehicle _x}} forEach _constructed; + +_site = _type createVehicle _position; +_site setDir _direction; +_site setPos _position; + +["Constructed",_type,_side] Spawn SideMessage; + +if (!IsNull _site) then { + Call Compile Format ["%1BaseStructures = %1BaseStructures + [_site]; publicVariable '%1BaseStructures';",str _side]; + + _site setVehicleInit Format["[this,false,%1] ExecVM 'Client\Init\Init_BaseStructure.sqf'",_side]; + processInitCommands; + + _site addEventHandler ["hit",{_this Spawn BuildingDamaged}]; + if (paramHandleFF) then { + Call Compile Format ["_site addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]; + } else { + _site addEventHandler ['handleDamage',{[_this select 0, _this select 2] Call HandleBuildingDamage}]; + }; + Call Compile Format ["_site AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn BuildingKilled}];",_side,_type]; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_MediumSite: A %1 %2 has been constructed",str _side,_type,diag_frameno,diag_tickTime]; +}; \ No newline at end of file diff --git a/Server/Construction/Construction_SmallSite.sqf b/Server/Construction/Construction_SmallSite.sqf new file mode 100644 index 0000000..30e77c5 --- /dev/null +++ b/Server/Construction/Construction_SmallSite.sqf @@ -0,0 +1,126 @@ +//***************************************************************************************** +//Description: Creates a small construction site. +//***************************************************************************************** +Private ["_construct","_constructed","_direction","_group","_index","_nearLogic","_objects","_position","_rlType","_side","_site","_siteName","_startTime","_structures","_structuresNames","_time","_timeNextUpdate","_type"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_index = _this select 4; + +_time = ((Format ["WFBE_%1STRUCTURETIMES",str _side] Call GetNamespace) select _index) / 2; + +_siteName = Format["WFBE_%1CONSTRUCTIONSITE",str _side] Call GetNamespace; + +_structures = Format ['WFBE_%1STRUCTURES',str _side] Call GetNamespace; +_structuresNames = Format ['WFBE_%1STRUCTURENAMES',str _side] Call GetNamespace; +_rlType = _structures select (_structuresNames find _type); + +_startTime = time; +_timeNextUpdate = _startTime + _time; + +_objects = []; +if (WF_A2_Arrowhead) then {_objects = [[_siteName,[0,0,-0.000230789],359.997,1,0],["Paleta2",[0.416992,-5.62012,-0.305746],0.0130822,1,0],["Land_Barrel_sand",[-5.59448,3.26929,6.29425e-005],359.997,1,0],["Paleta1",[-2.62976,-6.04736,5.53131e-005],0.0130822,1,0],["Barrel4",[6.63696,0.694336,0.000753403],359.991,1,0],["Land_Barrel_sand",[-6.73267,2.06372,6.10352e-005],359.997,1,0],["Barrel5",[7.19604,2.8855,0.00028801],0.0135841,1,0],["Barrel1",[6.08984,5.5415,0.00028801],0.0135841,1,0],["Land_Barrel_sand",[-7.13452,4.40747,6.29425e-005],359.997,1,0],["RoadBarrier_long",[0.221924,-8.58496,0.00206566],0.0130822,1,0],["Land_Barrel_sand",[-8.27271,2.80054,6.10352e-005],359.997,1,0],["Barrels",[-7.91895,-4.09668,0.00037384],0.0128253,1,0],["RoadCone",[-10.4381,-8.94336,0.000131607],0.0119093,1,0],["RoadCone",[11.1655,-8.79932,0.00034523],359.991,1,0],["RoadCone",[-10.5692,12.6655,0.000509262],359.948,1,0],["RoadCone",[11.0276,12.3904,0.000509262],359.948,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [[_siteName,[0,0,-0.000230789],359.997,1,0],["Paleta2",[0.416992,-5.62012,-0.305746],0.0130822,1,0],["Land_Barrel_sand",[-5.59448,3.26929,6.29425e-005],359.997,1,0],["Paleta1",[-2.62976,-6.04736,5.53131e-005],0.0130822,1,0],["Barrel4",[6.63696,0.694336,0.000753403],359.991,1,0],["Land_Ind_BoardsPack2",[6.41797,-2.52051,0.000915527],270,1,0],["Land_Barrel_sand",[-6.73267,2.06372,6.10352e-005],359.997,1,0],["Barrel5",[7.19604,2.8855,0.00028801],0.0135841,1,0],["Barrel1",[6.08984,5.5415,0.00028801],0.0135841,1,0],["Land_Barrel_sand",[-7.13452,4.40747,6.29425e-005],359.997,1,0],["RoadBarrier_long",[0.221924,-8.58496,0.00206566],0.0130822,1,0],["Land_Barrel_sand",[-8.27271,2.80054,6.10352e-005],359.997,1,0],["Barrels",[-7.91895,-4.09668,0.00037384],0.0128253,1,0],["Land_Ind_BoardsPack1",[6.40332,-7.16162,0.000520706],0.0130822,1,0],["Land_Ind_BoardsPack1",[-6.18384,-8.09961,0.000535965],50.0093,1,0],["RoadCone",[-10.4381,-8.94336,0.000131607],0.0119093,1,0],["RoadCone",[11.1655,-8.79932,0.00034523],359.991,1,0],["RoadCone",[-10.5692,12.6655,0.000509262],359.948,1,0],["RoadCone",[11.0276,12.3904,0.000509262],359.948,1,0]]}; +_construct = Compile PreprocessFile "ca\modules\dyno\data\scripts\objectMapper.sqf"; +_constructed = ([_position,_direction,_objects] Call _construct); + +//--- Create the logic. +(createGroup sideLogic) createUnit ["LocationLogicStart",_position,[],0,"NONE"]; + +_nearLogic = objNull; +if !(paramUseWorkers) then { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + waitUntil {time >= _timeNextUpdate}; + _timeNextUpdate = _startTime + _time * 2; +} else { + //--- Grab the logic. + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Position the logic. + _nearLogic setPos _position; + + //--- Instanciate the logic. + _nearLogic setVariable ["WFBE_B_Completion", 0]; + _nearLogic setVariable ["WFBE_B_CompletionRatio", 1.1]; + _nearLogic setVariable ["WFBE_B_Direction", _direction]; + _nearLogic setVariable ["WFBE_B_Position", _position]; + _nearLogic setVariable ["WFBE_B_Repair", false]; + _nearLogic setVariable ["WFBE_B_Type", _rlType]; + + //--- Add the logic to the list. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) + [_nearLogic],true] Call SetNamespace; + + //--- Awaits for 50% of completion. + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 50) exitWith {}; + }; +}; + +if (WF_A2_Arrowhead) then {_objects = [["Land_WoodenRamp",[-2.45703,-0.593262,0.357508],270,1,0],["Land_WoodenRamp",[-2.5083,1.3811,0.357508],270,1,0],[_siteName,[4.6333,0.338135,0.00393867],90,1,0],["Land_Dirthump02_EP1",[-0.587891,8.57935,0.00207901],359.967,1,0],["Land_Dirthump01_EP1",[-3.97363,-8.49219,-4.57764e-005],29.9804,1,0],["Land_WoodenRamp",[8.8335,-0.125977,0.403545],90,1,0]]}; +if (WF_A2_Vanilla || WF_A2_CombinedOps) then {_objects = [["Land_WoodenRamp",[-2.45703,-0.593262,0.357508],270,1,0],["Land_WoodenRamp",[-2.5083,1.3811,0.357508],270,1,0],[_siteName,[4.6333,0.338135,0.00393867],90,1,0],["Land_Dirthump02",[-0.587891,8.57935,0.00207901],359.967,1,0],["Land_Dirthump01",[-3.97363,-8.49219,-4.57764e-005],29.9804,1,0],["Land_WoodenRamp",[8.8335,-0.125977,0.403545],90,1,0]]}; +_constructed = _constructed + ([_position,_direction,_objects] Call _construct); + +if !(paramUseWorkers) then { + waitUntil {time >= _timeNextUpdate}; + + if !(isNull _nearLogic) then { + _group = group _nearLogic; + deleteVehicle _nearLogic; + deleteGroup _group; + }; +} else { + //--- Awaits for 100% + while {true} do { + sleep 1; + if ((_nearLogic getVariable "WFBE_B_Completion") >= 100) exitWith {}; + }; + + //--- Remove the logic from the list since it's built. Add it back if destroyed. + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_nearLogic],true] Call SetNamespace; +}; + +{if !(isNull _x) then {DeleteVehicle _x}} ForEach _constructed; + +_site = _type CreateVehicle _position; +_site SetDir _direction; +_site SetPos _position; + +["Constructed",_type,_side] Spawn SideMessage; + +if (!IsNull _site) then { + Call Compile Format ["%1BaseStructures = %1BaseStructures + [_site]; publicVariable '%1BaseStructures';",str _side]; + + _site SetVehicleInit Format["[this,false,%1] ExecVM 'Client\Init\Init_BaseStructure.sqf'",_side]; + ProcessInitCommands; + + _site addEventHandler ["hit",{_this Spawn BuildingDamaged}]; + if (paramHandleFF) then { + Call Compile Format ["_site addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]; + } else { + _site addEventHandler ['handleDamage',{[_this select 0, _this select 2] Call HandleBuildingDamage}]; + }; + Call Compile Format ["_site AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn BuildingKilled}];",_side,_type]; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_SmallSite: A %1 %2 has been constructed",str _side,_type,diag_frameno,diag_tickTime]; +}; + +//--- Base Patrols. +if ((_type == WESTBAR || _type == EASTBAR) && paramBasePatrols) then { + [_site, _side] ExecFSM 'Server\FSM\basepatrol.fsm'; + diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Construction_SmallSite: A %1 Base Patrol Module has been launched",str _side,diag_frameno,diag_tickTime]; +} \ No newline at end of file diff --git a/Server/Construction/Construction_StationaryDefense.sqf b/Server/Construction/Construction_StationaryDefense.sqf new file mode 100644 index 0000000..1c62e25 --- /dev/null +++ b/Server/Construction/Construction_StationaryDefense.sqf @@ -0,0 +1,94 @@ +/* Description: Creates Defenses. */ +Private ["_buildings","_defense","_direction","_isAIQuery","_isArtillery","_manned","_position","_side","_type"]; +_type = _this select 0; +_side = _this select 1; +_position = _this select 2; +_direction = _this select 3; +_manned = _this select 4; +_isAIQuery = _this select 5; +_manRange = if (count _this > 6) then {_this select 6} else {'WFBE_DEFENSEMANRANGE' Call GetNamespace}; + +_defense = _type createVehicle _position; +_defense setDir _direction; +_defense setPos _position; + +diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_StationaryDefense: A %1 %2 was created",str _side,_type,diag_frameno,diag_tickTime]; + +//--- If it's a minefield, we exit the script while spawning it. +if (_type == 'Sign_Danger') exitWith { + Private ["_c","_h","_mine","_mineType","_toWorld"]; + _mineType = if (_side == east) then {'MineMineE'} else {'MineMine'}; + _h = -4; + _c = 0; + for [{_z=0}, {_z<9}, {_z=_z+1}] do{ + _array = [((_defense worldToModel (getPos _defense)) select 0) - 16 +_c,((_defense worldToModel (getPos _defense)) select 1) + _h]; + _toWorld = _defense modelToWorld _array; + _toWorld set[2,0]; + _mine = createMine [_mineType, _toWorld,[], 0]; + _c = _c + 4; + }; + + _h = 0; + _c = 2; + for [{_z=0}, {_z<8}, {_z=_z+1}] do{ + _array = [((_defense worldToModel (getPos _defense)) select 0) - 16 +_c,((_defense worldToModel (getPos _defense)) select 1) + _h]; + _toWorld = _defense modelToWorld _array; + _toWorld set[2,0]; + _mine = createMine [_mineType, _toWorld,[], 0]; + _c = _c + 4; + }; + + _h = 4; + _c = 0; + for [{_z=0}, {_z<9}, {_z=_z+1}] do{ + _array = [((_defense worldToModel (getPos _defense)) select 0) - 16 +_c,((_defense worldToModel (getPos _defense)) select 1) + _h]; + _toWorld = _defense modelToWorld _array; + _toWorld set[2,0]; + _mine = createMine [_mineType, _toWorld,[], 0]; + _c = _c + 4; + }; + deleteVehicle _defense; +}; + +if (_type == 'Concrete_Wall_EP1') then { + _defense addEventHandler ['handleDamage',{getDammage (_this select 0)+(_this select 2)/160}]; +}; + +Call Compile Format ["_defense addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; + +if (_defense EmptyPositions "gunner" > 0 && ((('WFBE_AIDEFENSE' Call GetNamespace) > 0) || _isAIQuery)) then { + Private ["_alives","_check","_closest","_team"]; + _team = if (_side == WEST) then {WF_DefenseWestGrp} else {WF_DefenseEastGrp}; + emptyQueu = emptyQueu + [_defense]; + [_defense, _side] Spawn HandleReloadDefense; + _defense Spawn HandleEmptyVehicle; + if (_manned) then { + _alives = (units _team) Call GetLiveUnits; + if (count _alives < ('WFBE_AIDEFENSE' Call GetNamespace) || _isAIQuery) then { + _buildings = (str _side) Call GetSideStructures; + _closest = ['BARRACKSTYPE',_buildings,_manRange,_side,_defense] Call BuildingInRange; + + //--- Manning Defenses. + if !(isNull _closest) then { + [_defense,_side,_team,_closest] Spawn HandleDefense; + }; + }; + }; +}; + +if (paramArtyUI) then { + Private ["_isAC","_isVeh"]; + _isVeh = getNumber(configFile >> "CfgVehicles" >> typeOf(_defense) >> "ARTY_IsArtyVehicle"); + _isAC = getNumber(configFile >> "CfgVehicles" >> typeOf(_defense) >> "artilleryScanner"); + if (_isVeh == 1 || _isAC == 1) then { + _defense setVehicleInit "[this] ExecVM 'Common\Common_InitArtillery.sqf'"; + processInitCommands; + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Construction_StationaryDefense: Artillery UI has been set over the %1 %2",str _side,_type,diag_frameno,diag_tickTime]; + }; +}; + +/* Are we dealing with an artillery unit ? */ +_isArtillery = [_type,_side] Call IsArtillery; +if (_isArtillery != -1) then {[_defense,_isArtillery,_side] Call EquipArtillery}; + +_defense \ No newline at end of file diff --git a/Server/FSM/aibase.fsm b/Server/FSM/aibase.fsm new file mode 100644 index 0000000..8bf9094 --- /dev/null +++ b/Server/FSM/aibase.fsm @@ -0,0 +1,677 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"AI_BASE_Init",0,250,-15.348785,-34.504990,74.651321,15.495049,0.000000,"AI BASE" \n "Init"}; +item1[] = {"AI_BASE_End",1,250,121.421707,50.708939,211.421722,100.708939,0.000000,"AI BASE" \n "End"}; +item2[] = {"AI_Base_Running",4,218,122.273567,-35.331635,212.273392,14.668474,0.000000,"AI Base" \n "Running"}; +item3[] = {"AI_Base_Not_Runn",4,218,-15.582159,46.154228,74.417801,96.154228,0.000000,"AI Base" \n "Not Running"}; +item4[] = {"Advanced__Init",2,4346,-16.452499,124.902863,73.547501,174.902863,0.000000,"Advanced " \n "Init"}; +item5[] = {"Loop",8,218,-16.586647,206.297379,73.413300,256.297363,0.000000,"Loop"}; +item6[] = {"Global_Checks",2,250,-16.758400,279.866577,73.241608,329.866577,0.000000,"Global Checks"}; +item7[] = {"Player_Commander",4,218,121.742462,280.140930,211.742416,330.140930,10.000000,"Player" \n "Commander?"}; +item8[] = {"Teams_Type",4,218,-164.034988,280.176239,-74.035011,330.176270,1.000000,"Teams Type"}; +item9[] = {"Update_Teams",2,250,-163.247650,207.771179,-73.247955,257.771149,0.000000,"Update Teams"}; +item10[] = {"Upgrades",4,218,-215.547272,312.433167,-125.547333,362.433167,0.000000,"Upgrades"}; +item11[] = {"Upgrades",2,250,-267.724365,207.955505,-177.724365,257.955505,0.000000,"Upgrades"}; +item12[] = {"",7,210,-169.994583,128.282928,-161.994583,136.282974,0.000000,""}; +link0[] = {0,2}; +link1[] = {0,3}; +link2[] = {2,1}; +link3[] = {3,4}; +link4[] = {4,5}; +link5[] = {5,6}; +link6[] = {6,5}; +link7[] = {6,7}; +link8[] = {6,8}; +link9[] = {6,10}; +link10[] = {7,1}; +link11[] = {8,9}; +link12[] = {9,12}; +link13[] = {10,11}; +link14[] = {11,12}; +link15[] = {12,5}; +globals[] = {0.000000,0,0,0,0,640,480,1,21,6316128,1,-428.130035,157.950897,480.503235,-35.746780,705,621,1}; +window[] = {0,-1,-1,-1,-1,866,125,1470,125,1,723}; +*//*%FSM*/ +class FSM +{ + fsmName = "aibase"; + class States + { + /*%FSM*/ + class AI_BASE_Init + { + name = "AI_BASE_Init"; + init = /*%FSM*/"_side = _this select 0;" \n + "_sideText = Str _side;" \n + "" \n + "_aibase = Format [""WFBE_%1_AIBase"",_sideText] Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class AI_Base_Not_Runn + { + priority = 0.000000; + to="Advanced__Init"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_aibase"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class AI_Base_Running + { + priority = 0.000000; + to="AI_BASE_End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_aibase"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class AI_BASE_End + { + name = "AI_BASE_End"; + init = /*%FSM*/"[Format[""WFBE_%1_AIBase"",_sideText],false,true] Call SetNamespace;" \n + "" \n + "if (!isNull _driver && alive _driver) then {" \n + " _group = group _driver;" \n + " deleteVehicle _vehicle;" \n + " deleteVehicle _driver;" \n + " deleteGroup _group;" \n + "};" \n + "if (!isNull _HQDriver && alive _HQDriver) then {" \n + " _group = group _HQDriver;" \n + " unassignVehicle _HQDriver;" \n + " _HQDriver action [""EJECT"",_hq];" \n + " deleteVehicle _HQDriver;" \n + " deleteGroup _group;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Advanced__Init + { + name = "Advanced__Init"; + init = /*%FSM*/"[Format[""WFBE_%1_AIBase"",_sideText],true,true] Call SetNamespace;" \n + "" \n + "_hq = (_sideText) Call GetSideHQ;" \n + "_isDeployed = (_sideText) Call GetSideHQDeployed;" \n + "" \n + "_types = Format[""WFBE_%1STRUCTURES"",_sideText] Call GetNamespace;" \n + "_names = Format[""WFBE_%1STRUCTURENAMES"",_sideText] Call GetNamespace;" \n + "_costs = Format[""WFBE_%1STRUCTURECOSTS"",_sideText] Call GetNamespace;" \n + "_scripts = Format[""WFBE_%1STRUCTURESCRIPTS"",_sideText] Call GetNamespace;" \n + "" \n + "_structureState = [false,false,false,false,false,false];" \n + "_structureTimer = 0;" \n + "_structureTotal = count _structureState;" \n + "_structureTypes = [""BARRACKS"",""LIGHT"",""COMMANDCENTER"",""HEAVY"",""AIRCRAFT"",""SERVICEPOINT""];" \n + "_structureRelPos = [[75,75],[-75,75],[75,0],[75,-75],[-75,-75],[-75,0]];" \n + "_structurePos = [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]];" \n + "" \n + "_repairTruck = Format['WFBE_%1REPAIRTRUCK',_sideText] Call GetNamespace;" \n + "_crew = Format [""WFBE_%1SOLDIER"",_sideText] Call GetNamespace;" \n + "_HQMoving = false;" \n + "_repairAlive = false;" \n + "_deployed = false;" \n + "_vehicle = objNull;" \n + "_HQDriver = objNull;" \n + "_driver = objNull;" \n + "_destination = objNull;" \n + "_lastMove = time;" \n + "_buildingLocations = [eastStartingLocation,westStartingLocation];" \n + "_lastTeamAssignements = -3000;" \n + "_lastUpgradeCheck = -120;" \n + "_type = 0;" \n + "_teams = (Format[""WFBE_%1TEAMS"",_sideText] Call GetNamespace);" \n + "_sideMHQRepair = Format [""%1MHQRepair"",_sideText];" \n + "_sideSupply = Format [""%1Supplies"",_sideText];" \n + "_repairPrice = 'WFBE_MHQREPAIRPRICE' Call GetNamespace;" \n + "_vc = 'WFBE_VICTORYCONDITION' Call GetNamespace;" \n + "_ul = 'WFBE_UPGRADELABELS' Call GetNamespace;" \n + "_upgrlev = 'WFBE_UPGRADELEVELS' Call GetNamespace;" \n + "_upgrcond = 'WFBE_UPGRADECONDITION' Call GetNamespace;" \n + "_upgrord = 'WFBE_UPGRADEAIORDER' Call GetNamespace;" \n + "_hqt = Format[""WFBE_%1HEADQUARTERSTYPE"",_sideText] Call GetNamespace;" \n + "" \n + "_totalSupply = 0;" \n + "{_totalSupply = _totalSupply + (_x getVariable 'maxSupplyValue')} forEach towns;" \n + "" \n + "_buildings = (_sideText) Call GetSideStructures;" \n + "" \n + "{" \n + " if (_x distance _hq < 500) then {" \n + " _type = typeOf _x;" \n + " if (_type in [WESTBAR,EASTBAR]) then {_structureState set [0,true]};//--- Barracks." \n + " if (_type in [WESTLVF,EASTLVF]) then {_structureState set [1,true]};//--- Light." \n + " if (_type in [WESTCC,EASTCC]) then {_structureState set [2,true]};//--- Command Center." \n + " if (_type in [WESTHEAVY,EASTHEAVY]) then {_structureState set [3,true]};//--- Heavy." \n + " if (_type in [WESTAIR,EASTAIR]) then {_structureState set [4,true]};//--- Aircraft." \n + " if (_type in [WESTSP,EASTSP]) then {_structureState set [5,true]};//--- Service Point." \n + " };" \n + "} forEach _buildings;" \n + "" \n + "_HQIsAlive = if (alive _hq) then {true} else {false};" \n + "_canBeDeploy = true;" \n + "if (isMultiplayer && _HQIsAlive) then {" \n + " _tbpr = 'WFBE_TOWNBUILDPROTECTIONRANGE' Call GetNamespace;" \n + " _isPlayerOnSide = false;" \n + " " \n + " {" \n + " if (!isNull _x) then {" \n + " if (side _x == _side && isPlayer _x) then {_isPlayerOnSide = true};" \n + " };" \n + " } forEach playableUnits;" \n + " " \n + " if (_isPlayerOnSide) then {" \n + " {" \n + " if (_x distance _hq < _tbpr) then {_canBeDeploy = false};" \n + " } forEach towns;" \n + " };" \n + "};" \n + "" \n + "if (!_isDeployed && _HQIsAlive && _canBeDeploy) then {" \n + " _pos = getPos _hq;" \n + " _pos set [2,0];" \n + " _pos = [_pos,(('WFBE_AREAHQUNDEPLOYED' Call GetNamespace) select 0)+20] Call GetSafePlace;" \n + " if (count _pos < 1) then {_pos = [_pos,(('WFBE_AREAHQUNDEPLOYED' Call GetNamespace) select 0)+50] Call GetSafePlace};" \n + " if (count _pos < 1) then {_pos = Call Compile Format [""%1StartingLocation"",_sideText]};" \n + " _dir = getDir _hq;" \n + " _HQType = _names select _hqt;" \n + " _supply = WF_Logic getVariable Format [""%1Supplies"",_sideText];" \n + " if (_supply >= (_costs select _hqt)) then {" \n + " [_HQType,_side,_pos,_dir] ExecVM 'Server\Construction\Construction_HQSite.sqf';" \n + " _supply = _supply - (_costs select _hqt);" \n + " WF_Logic setVariable [Format [""%1Supplies"",_sideText],_supply,true];" \n + " };" \n + "};" \n + "" \n + "_CommanderUpgrade = {" \n + " Private [""_index"",""_index2"",""_name"",""_side"",""_sideText"",""_time""];" \n + " _time = _this select 0;" \n + " _index = _this select 1;" \n + " _index2 = _this select 2;" \n + " _name = _this select 3;" \n + " _side = _this select 4;" \n + " _sideText = Str _side;" \n + " " \n + " sleep _time;" \n + " " \n + " _upgrades = (_sideText) Call GetSideUpgrades;" \n + " _upgrades Set [_index2,_index + 1];" \n + " Call Compile Format [""%1Upgrades = _upgrades; publicVariable '%1Upgrades';"",_sideText];" \n + " " \n + " WFBE_LocalizeMessage = [_side,'CLTFNCLOCALIZEMESSAGE',['UpgradeComplete',_index2,(_index + 1)]];" \n + " publicVariable 'WFBE_LocalizeMessage';" \n + " if (!isMultiplayer || (isServer && local player)) then {[_side,'CLTFNCLOCALIZEMESSAGE',['UpgradeComplete',_index2,(_index + 1)]] Spawn HandlePVF};" \n + " [Format[""WFBE_%1_Upgrading"",_sideText],false,true] Call SetNamespace;" \n + "" \n + " [""NewIntelAvailable"","""",_side,""""] Spawn SideMessage" \n + "};" \n + "" \n + "_lastCheck = 0;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global_Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Global_Checks + { + name = "Global_Checks"; + init = /*%FSM*/"//--- EXPERIMENTAL ENHANCED AI COMMANDER HANDLING --- Benny - 08/09/2009." \n + "_commander = (_side) Call GetCommanderTeam;" \n + "" \n + "_lastCheck = time;" \n + "_hq = (_sideText) Call GetSideHQ;" \n + "" \n + "_HQIsAlive = if !(alive _hq) then {false} else {true};" \n + "if (_structureTimer > 20) then {" \n + " _structureTimer = 0;" \n + " //--- Base Buildings handling." \n + " for [{_count = 0},{_count < _structureTotal},{_count = _count + 1}] do {" \n + " _currentBuilding = _structureTypes select _count;" \n + " if !(_structureState select _count) then {" \n + " _supply = WF_Logic getVariable _sideSupply;" \n + " _index = Format[""WFBE_%1%2TYPE"",_sideText,_currentBuilding] Call GetNamespace;" \n + " if ((_supply > (_costs select _index)) && _HQIsAlive) then {" \n + " _limit = (Format['WFBE_BUILDINGMAX%1',_currentBuilding]) Call GetNamespace;" \n + " _structureType = _names select _index;" \n + " _buildings = (_sideText) Call GetSideStructures;" \n + " _pursue = true;" \n + " " \n + " //--- Limit control." \n + " _current = {(typeOf _x) == _structureType} count _buildings;" \n + " if (_current >= _limit) then {_pursue = false};" \n + " " \n + " //--- AI Can build." \n + " if (_pursue) then {" \n + " _x = getPos _hq select 0;" \n + " _y = getPos _hq select 1;" \n + " _pos = [];" \n + " _pos set [0,((_structureRelPos select _count) select 0) + _x];" \n + " _pos set [1,((_structureRelPos select _count) select 1) + _y];" \n + " _newPos = [0,0,0];" \n + " _roads = [];" \n + " /* Retrieve the AI Spawn area */" \n + " _distance = (Format[""WFBE_%1STRUCTUREDISTANCES"",_sideText] Call GetNamespace) select _index;" \n + " _direction = (Format[""WFBE_%1STRUCTUREDIRECTIONS"",_sideText] Call GetNamespace) select _index;" \n + " " \n + " _continue = true;" \n + " _attempts = 0;" \n + " _max = 100;" \n + " while {_continue} do {" \n + " _newPos = [_pos,30,_max,10,0,50,0] Call BIS_fnc_findSafePos;" \n + " _aiSpawnPos = [_newPos,_distance,_direction] Call GetPositionFrom;" \n + " _aiSpawnPos set [2,0];" \n + " _roads = _newPos nearRoads 30;" \n + " _roads2 = _aiSpawnPos nearRoads 30;" \n + " " \n + " _isFlat = _aiSpawnPos isFlatEmpty [" \n + " 5, //--- Minimal distance from another object" \n + " 0, //--- If 0, just check position. If >0, select new one" \n + " 0.6, //--- Max gradient" \n + " 5, //--- Gradient area" \n + " 0, //--- 0 for restricted water, 2 for required water," \n + " false, //--- True if some water can be in 25m radius" \n + " objNull //--- Ignored object" \n + " ];" \n + " " \n + " _isTooClose = false;" \n + " {if (_x distance _newPos < 70) then {_isTooClose = true}} forEach _structurePos;" \n + " if (count _roads == 0 && count _roads2 == 0 && !_isTooClose && count _isFlat != 0) then {_continue = false};" \n + " _attempts = _attempts + 1;" \n + " if (_attempts > 100 && _max == 100) then {_max = _max + 150};" \n + " };" \n + " _structurePos set [_count, _newPos];" \n + " _dir = 0;" \n + " _script = _scripts select _index;" \n + " [_structureType,_side,_newPos,_dir,_index] ExecVM (Format[""Server\Construction\Construction_%1.sqf"",_script]);" \n + " _supply = _supply - (_costs select _index);" \n + " WF_Logic setVariable [_sideSupply,_supply,true];" \n + " _structureState set [_count,true];" \n + " };" \n + " };" \n + " };" \n + " };" \n + " " \n + " //--- Base is completed. Proceed to next one." \n + " _completed = true;" \n + " {if (!_x) then {_completed = false}} forEach _structureState;" \n + " if (_completed && !_HQMoving && time - _lastMove > ('WFBE_AICOMMANDERMOVEINTERVAL' Call GetNamespace)) then {_HQMoving = true};" \n + " " \n + " //--- HQ Moving part (it has to be alive)." \n + " if (_HQMoving && _HQIsAlive || _deployed) then {" \n + " _isDeployed = (_sideText) Call GetSideHQDeployed;" \n + " if (_isDeployed) then {" \n + " _pos = getPos _hq;" \n + " _dir = getDir _hq;" \n + " _HQType = _names select _hqt;" \n + " _supply = WF_Logic getVariable _sideSupply;" \n + " if (_supply >= (_costs select _hqt)) then {" \n + " [_HQType,_side,_pos,_dir] ExecVM ""Server\Construction\Construction_HQSite.sqf"";" \n + " _supply = _supply - (_costs select _hqt);" \n + " WF_Logic setVariable [_sideSupply,_supply,true];" \n + " _deployed = true;" \n + " };" \n + " };" \n + " " \n + " if (_deployed) then {" \n + " _deployed = false;" \n + " if (typeOf _hq != (Format [""WFBE_%1MHQNAME"",_sideText] Call GetNamespace)) then {_deployed = true};" \n + " if (!_deployed) then {" \n + " _hq = (_sideText) Call GetSideHQ;" \n + " _destination = objNull;" \n + " _destinations = startingLocations - _buildingLocations;" \n + " _sorted = [_hq,_destinations] Call SortByDistance;" \n + " _destination = _sorted select 0;" \n + " if (!isNull (driver _hq)) then {(driver _hq) setDammage 1};" \n + " _group = createGroup _side;" \n + " _HQDriver = [_crew,_group,getPos _hq,_side] Call CreateMan;" \n + " [_HQDriver] AllowGetIn true;" \n + " _HQDriver MoveInDriver _hq;" \n + " _HQDriver AssignAsDriver _hq;" \n + " [_HQDriver] OrderGetIn true;" \n + " _HQDriver doMove ([GetPos _destination,10,20] Call GetRandomPosition);" \n + " _lastMove = time;" \n + " };" \n + " };" \n + " " \n + " if (_hq distance _destination < 30 && !isNull _destination) then {" \n + " _HQMoving = false;" \n + " _buildingLocations = _buildingLocations + [_destination];" \n + " _destination = objNull;" \n + " if (!isNull _HQDriver && alive _HQDriver) then {" \n + " _group = group _HQDriver;" \n + " unassignVehicle _HQDriver;" \n + " _HQDriver action [""EJECT"",_hq];" \n + " deleteVehicle _HQDriver;" \n + " deleteGroup _group;" \n + " };" \n + " _isDeployed = (_sideText) Call GetSideHQDeployed;" \n + " if (!_isDeployed) then {" \n + " _pos = getPos _hq;" \n + " _dir = getDir _hq;" \n + " _HQType = _names select _hqt;" \n + " _supply = WF_Logic getVariable _sideSupply;" \n + " if (_supply >= (_costs select _hqt)) then {" \n + " [_HQType,_side,_pos,_dir] ExecVM ""Server\Construction\Construction_HQSite.sqf"";" \n + " _supply = _supply - (_costs select _hqt);" \n + " WF_Logic setVariable [_sideSupply,_supply,true];" \n + " };" \n + " _buildings = (_sideText) Call GetSideStructures;" \n + " _structureState = [false,false,false,false,false,false];" \n + " {" \n + " _type = typeOf _x;" \n + " if (_type in [WESTBAR,EASTBAR] && (_x distance _hq < 500)) then {_structureState set [0,true]} else {_structureState set [0,false]};//--- Barracks." \n + " if (_type in [WESTLVF,EASTLVF] && (_x distance _hq < 500)) then {_structureState set [1,true]} else {_structureState set [1,false]};//--- Light." \n + " if (_type in [WESTCC,EASTCC] && (_x distance _hq < 500)) then {_structureState set [2,true]} else {_structureState set [2,false]};//--- Command Center." \n + " if (_type in [WESTHEAVY,EASTHEAVY] && (_x distance _hq < 500)) then {_structureState set [3,true]} else {_structureState set [3,false]};//--- Heavy." \n + " if (_type in [WESTAIR,EASTAIR] && (_x distance _hq < 500)) then {_structureState set [4,true]} else {_structureState set [4,false]};//--- Aircraft." \n + " if (_type in [WESTSP,EASTSP] && (_x distance _hq < 500)) then {_structureState set [5,true]} else {_structureState set [5,false]};//--- Service Point." \n + " } forEach _buildings;" \n + " };" \n + " };" \n + " };" \n + " " \n + " //--- HQ Repair Part." \n + " if (!_HQIsAlive && _vc != 1) then {" \n + " //--- Closest Light." \n + " _buildings = (_sideText) Call GetSideStructures;" \n + " _checks = [_side,Format [""WFBE_%1LIGHTTYPE"",_sideText] Call GetNamespace,_buildings] Call GetFactories;" \n + " _light = objNull;" \n + " if (count _checks > 0) then {" \n + " _sorted = [_hq,_checks] Call SortByDistance;" \n + " _light = _sorted select 0;" \n + " };" \n + "" \n + " //--- Repair truck died." \n + " if (!(alive _vehicle) || isNull _vehicle || !alive _driver || isNull _driver) then {_repairAlive = false};" \n + " " \n + " //--- Light is Alive, we can build a repair truck." \n + " if (!_repairAlive && !isNull _light) then {" \n + " _type = TypeOf _light;" \n + " _index = _names find _type;" \n + " _distance = (Format[""WFBE_%1STRUCTUREDISTANCES"",str _side] Call GetNamespace) select _index;" \n + " _direction = (Format[""WFBE_%1STRUCTUREDIRECTIONS"",str _side] Call GetNamespace) select _index;" \n + " _position = [GetPos _light,_distance,GetDir _light + _direction] Call GetPositionFrom;" \n + " " \n + " _vehicle = [_repairTruck,_position,_side,true] Call CreateVehi;" \n + " _group = createGroup _side;" \n + " _driver = [_crew,_group,_position,_side] Call CreateMan;" \n + " [_driver] AllowGetIn true;" \n + " _driver MoveInDriver _vehicle;" \n + " _repairAlive = true;" \n + "" \n + " [_sideText,'VehiclesCreated',1] Call UpdateStatistics;" \n + " [_sideText,'UnitsCreated',1] Call UpdateStatistics;" \n + " _driver doMove ([GetPos _hq,10,20] Call GetRandomPosition);" \n + " };" \n + " " \n + " //--- Repair truck is in repair range." \n + " if (_driver distance _hq < 50 && _repairAlive) then {" \n + " if (isEngineOn _vehicle) then {_vehicle engineOn false};" \n + " _supply = WF_Logic getVariable _sideSupply;" \n + " if (_supply >= _repairPrice) then {" \n + " _isBeingFixed = WF_Logic getVariable _sideMHQRepair;" \n + " if (!_isBeingFixed) then {" \n + " _supply = _supply - _repairPrice;" \n + " WF_Logic setVariable [_sideSupply,_supply,true];" \n + " WF_Logic setVariable [_sideMHQRepair,true,true];" \n + " [_side] Spawn MHQRepair;" \n + " _HQMoving = true;" \n + " _deployed = true;" \n + " };" \n + " if (!isNull _driver && alive _driver) then {" \n + " _group = group _driver;" \n + " unassignVehicle _driver;" \n + " _driver action [""EJECT"",_hq];" \n + " deleteVehicle _vehicle;" \n + " deleteVehicle _driver;" \n + " deleteGroup _group;" \n + " };" \n + " };" \n + " };" \n + " };" \n + "};" \n + "_structureTimer = _structureTimer + 10;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Player_Commander + { + priority = 10.000000; + to="AI_BASE_End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!isNull _commander"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Teams_Type + { + priority = 1.000000; + to="Update_Teams"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastTeamAssignements > 300 && isNull _commander"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Upgrades + { + priority = 0.000000; + to="Upgrades"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpgradeCheck > 120 && isNull _commander"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global_Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Teams + { + name = "Update_Teams"; + init = /*%FSM*/"_lastTeamAssignements = time;" \n + "_templates = Format [""WFBE_%1AITEAMTEMPLATES"",_sideText] Call GetNamespace;" \n + "_teamTypes = Format [""WFBE_%1AITEAMTYPES"",_sideText] Call GetNamespace;" \n + "_currentConfig = [];" \n + "_totalFunds = 0;" \n + "" \n + "{" \n + " if !(isNil '_x') then {" \n + " _teamIndex = (_x) Call GetTeamType;" \n + " _totalFunds = _totalFunds + ((_x) Call GetTeamFunds);" \n + " if (_teamIndex == -1) then {_teamIndex = 0};" \n + " _currentConfig = _currentConfig + [_teamTypes select _teamIndex];" \n + " };" \n + "} forEach _teams;" \n + "" \n + "_avgIncome = _totalFunds / maxPlayers;" \n + "_infantryTypes = {_x == 0} count _currentConfig;" \n + "_lightTypes = {_x == 1} count _currentConfig;" \n + "_heavyTypes = {_x == 2} count _currentConfig;" \n + "_airTypes = {_x == 3} count _currentConfig;" \n + "" \n + "_income = _side Call GetTotalSupplyValue;" \n + "" \n + "_infPercent = 0;" \n + "_lightPercent = 0;" \n + "_heavyPercent = 0;" \n + "_airPercent = 0;" \n + "if (_income < (_totalSupply - (_totalSupply/1.2)) || _avgIncome < 2000) then {_infPercent = 70; _lightPercent = 30};" \n + "if ((_income >= (_totalSupply - (_totalSupply/1.2)) && _income < (_totalSupply - (_totalSupply/1.6))) || _avgIncome > 2000) then {_infPercent = 60; _lightPercent = 30; _heavyPercent = 10};" \n + "if ((_income >= (_totalSupply - (_totalSupply/1.6)) && _income < (_totalSupply - (_totalSupply/2))) || _avgIncome > 4000) then {_infPercent = 50; _lightPercent = 30; _heavyPercent = 20};" \n + "if ((_income >= (_totalSupply - (_totalSupply/2)) && _income < (_totalSupply - (_totalSupply/3))) || _avgIncome > 12000) then {_infPercent = 40; _lightPercent = 30; _heavyPercent = 30};" \n + "if ((_income >= (_totalSupply - (_totalSupply/3)) && _income < (_totalSupply - (_totalSupply/4))) || _avgIncome > 18000) then {_infPercent = 30; _lightPercent = 20; _heavyPercent = 40; _airPercent = 10};" \n + "if (_income >= (_totalSupply - (_totalSupply/4)) || _avgIncome > 24000) then {_infPercent = 20; _lightPercent = 20; _heavyPercent = 50; _airPercent = 10};" \n + "" \n + "_infAssign = round(maxPlayers * (_infPercent / 100));" \n + "_lightAssign = round(maxPlayers * (_lightPercent / 100));" \n + "_heavyAssign = round(maxPlayers * (_heavyPercent / 100));" \n + "_airAssign = round(maxPlayers * (_airPercent / 100));" \n + "" \n + "_infTemplates = [];" \n + "_lightTemplates = [];" \n + "_heavyTemplates = [];" \n + "_airTemplates = [];" \n + "" \n + "_i = 0;" \n + "{" \n + " switch (_x) do {" \n + " case 0: {_infTemplates = _infTemplates + [_i]};" \n + " case 1: {_lightTemplates = _lightTemplates + [_i]};" \n + " case 2: {_heavyTemplates = _heavyTemplates + [_i]};" \n + " case 3: {_airTemplates = _airTemplates + [_i]};" \n + " };" \n + " _i = _i + 1;" \n + "} forEach _teamTypes;" \n + "" \n + "{" \n + " if !(isNil '_x') then {" \n + " _skip = false;" \n + " if (_infAssign > 0) then {" \n + " _type = _infTemplates select (round(random((count _infTemplates)-1)));" \n + " _infAssign = _infAssign - 1;" \n + " _skip = true;" \n + " };" \n + " if (_lightAssign > 0 && !_skip) then {" \n + " _type = _lightTemplates select (round(random((count _lightTemplates)-1)));" \n + " _lightAssign = _lightAssign - 1;" \n + " _skip = true;" \n + " };" \n + " if (_heavyAssign > 0 && !_skip) then {" \n + " _type = _heavyTemplates select (round(random((count _heavyTemplates)-1)));" \n + " _heavyAssign = _heavyAssign - 1;" \n + " _skip = true;" \n + " };" \n + " if (_airAssign > 0 && !_skip) then {" \n + " _type = _airTemplates select (round(random((count _airTemplates)-1)));" \n + " _airAssign = _airAssign - 1;" \n + " _skip = true;" \n + " };" \n + " [_x,_type] Call SetTeamType;" \n + " };" \n + "} forEach _teams;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global_Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Upgrades + { + name = "Upgrades"; + init = /*%FSM*/"_lastUpgradeCheck = time;" \n + "" \n + "//--- Command center is needed for upgrades. AI won't upgrade if he's moving around. Don't bother with money atm, only supply." \n + "_isDeployed = (_sideText) Call GetSideHQDeployed;" \n + "_buildings = (_sideText) Call GetSideStructures;" \n + "_checks = [_side,Format [""WFBE_%1COMMANDCENTERTYPE"",_sideText] Call GetNamespace,_buildings] Call GetFactories;" \n + "if (_isDeployed && (count _checks > 0) && !(Format[""WFBE_%1_Upgrading"",_sideText] Call GetNamespace)) then {" \n + " _upgrades = (_sideText) Call GetSideUpgrades;" \n + " _supply = WF_Logic getVariable _sideSupply;" \n + " _break = false;" \n + "" \n + " _upgrade = -1;" \n + " _index = -1;" \n + " _supplyLevel = -1;" \n + " " \n + " for [{_x = 0},{_x < (count _upgrord) && !_break},{_x = _x + 1}] do {" \n + " _index = _upgrord select _x;" \n + " _canUpgrade = _upgrcond select _index;" \n + " //--- Can we use that upgrade?." \n + " if (_canUpgrade) then {" \n + " _upgradeLevels = _upgrlev select _index;" \n + " _currentLevel = _upgrades select _index;" \n + " //--- Have we reached the max?." \n + " if (_currentLevel < _upgradeLevels) then {" \n + " _supplyLevel = ((Format [""WFBE_UPGRADEPRICESLEVEL%1"",(_currentLevel + 1)] Call GetNamespace) select _index) select 0;" \n + " //--- Do we have enough ksupply to upgrade?. Otherwise, just skip the upgrade until AI has enough supply." \n + " if (_supply > _supplyLevel) then {" \n + " _upgrade = _currentLevel;" \n + " _break = true;" \n + " } else {" \n + " _break = true;" \n + " };" \n + " };" \n + " };" \n + " };" \n + " " \n + " if (_upgrade != -1) then {" \n + " [Format[""WFBE_%1_Upgrading"",_sideText],true,true] Call SetNamespace;" \n + " _supply = _supply - _supplyLevel;" \n + " WF_Logic setVariable [_sideSupply,_supply,true];" \n + " _time = (Format [""WFBE_UPGRADETIMESLEVEL%1"",_upgrade+1] Call GetNamespace) select _index;" \n + " _name = _ul select _index;" \n + " [_time,_upgrade,_index,_name,_side] Spawn _CommanderUpgrade;" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global_Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="AI_BASE_Init"; + finalStates[] = + { + "AI_BASE_End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/aicommander.fsm b/Server/FSM/aicommander.fsm new file mode 100644 index 0000000..6deb87f --- /dev/null +++ b/Server/FSM/aicommander.fsm @@ -0,0 +1,2025 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,29.117783,-243.242416,119.117828,-193.242630,0.000000,"Init"}; +item1[] = {"End",1,250,-216.387955,-52.508366,-126.387947,-2.508394,0.000000,"End"}; +item2[] = {"Commander_Check",2,250,-82.090652,-139.314026,7.909359,-89.314034,0.000000,"Commander" \n "Check"}; +item3[] = {"AI",4,218,43.444695,-138.881104,133.444702,-88.881126,0.000000,"AI"}; +item4[] = {"Gameover",4,218,-216.387955,-139.464890,-126.387947,-89.464890,0.000000,"Gameover"}; +item5[] = {"_",8,218,-51.736092,-228.307785,-21.083296,-207.387909,0.000000,""}; +item6[] = {"Check_HQ",2,250,167.429672,-138.824554,257.429688,-88.824554,0.000000,"Check HQ"}; +item7[] = {"Alive",4,218,167.029816,-63.614120,257.029968,-13.613998,0.000000,"Alive"}; +item8[] = {"Dead",4,218,167.829926,-230.037415,257.830078,-180.037399,0.000000,"Dead"}; +item9[] = {"Check_HQ_Status",2,250,298.248291,-63.614052,388.248230,-13.614052,0.000000,"Check HQ" \n "Status"}; +item10[] = {"Mobilized",4,218,433.250854,-64.045685,523.250732,-14.045616,0.000000,"Mobilized"}; +item11[] = {"Deployed",4,218,298.503387,29.438709,388.503357,79.438721,0.000000,"Deployed"}; +item12[] = {"Check_Repair",2,250,296.539734,-230.131653,386.539734,-180.131622,0.000000,"Check" \n "Repair"}; +item13[] = {"Repair_Moving",4,218,429.166107,-228.948074,519.166382,-178.948105,0.000000,"Repair" \n "Moving"}; +item14[] = {"Repair_Null",4,218,429.329987,-153.716705,519.330261,-103.716690,0.000000,"Repair" \n "Null"}; +item15[] = {"Check_Status",2,250,563.136597,-243.488693,653.136597,-193.488678,0.000000,"Check" \n "Status"}; +item16[] = {"Check_Light",2,250,562.396851,-183.315887,652.396851,-133.315872,0.000000,"Check" \n "Light"}; +item17[] = {"Alive",4,218,715.106934,-184.222443,805.106934,-134.222443,0.000000,"Alive"}; +item18[] = {"Dead",4,218,715.106995,-243.430771,805.106995,-193.430771,0.000000,"Dead"}; +item19[] = {"Create_Repair",2,250,858.268066,-185.584671,948.268066,-135.584671,0.000000,"Create" \n "Repair"}; +item20[] = {"Skip",2,250,859.370850,-245.140686,949.370911,-195.140793,0.000000,"Skip"}; +item21[] = {"",7,210,1028.113892,-194.407562,1036.114014,-186.407562,0.000000,""}; +item22[] = {"",7,210,1027.204102,-330.018250,1035.203979,-322.018250,0.000000,""}; +item23[] = {"",7,210,-41.498245,-331.121155,-33.498249,-323.121155,0.000000,""}; +item24[] = {"Check_Status_1",2,250,567.105652,-64.265991,657.105652,-14.265972,0.000000,"Check" \n "Status"}; +item25[] = {"Moving",4,218,709.035706,-103.210243,799.035706,-53.210236,0.000000,"Moving"}; +item26[] = {"Empty",4,218,703.864319,-36.693626,793.864319,13.306374,0.000000,"Empty"}; +item27[] = {"Spawn___Lead",2,250,853.857727,-35.590744,943.857727,14.409276,0.000000,"Spawn & Lead"}; +item28[] = {"Check_Position",2,250,852.754883,-103.970093,942.754883,-53.970085,0.000000,"Check" \n "Position"}; +item29[] = {"",7,210,1028.114868,-51.031216,1036.114990,-43.031216,0.000000,""}; +item30[] = {"Check_Move",2,250,439.100250,29.323673,529.100098,79.323669,0.000000,"Check" \n "Move"}; +item31[] = {"Move",4,218,579.575684,29.323677,669.576050,79.323685,0.000000,"Move"}; +item32[] = {"Proceed",4,218,436.745636,114.689537,526.745728,164.689575,0.000000,"Proceed"}; +item33[] = {"Move",2,250,712.286255,29.029057,802.286255,79.029053,0.000000,"Move"}; +item34[] = {"",7,210,1028.016968,50.640667,1036.016846,58.640675,0.000000,""}; +item35[] = {"Check_Base",2,250,292.344421,114.037247,382.344421,164.037247,0.000000,"Check" \n "Base"}; +item36[] = {"Update",4,218,138.614502,145.674393,228.614502,195.674393,0.000000,"Update"}; +item37[] = {"Skip",4,218,138.614502,78.700897,228.614502,128.700897,0.000000,"Skip"}; +item38[] = {"Skip_1",2,250,-24.498369,79.781113,65.501648,129.781113,0.000000,"Skip"}; +item39[] = {"Update_Base",2,250,-24.498356,146.754593,65.501656,196.754593,0.000000,"Update" \n "Base"}; +item40[] = {"_",8,218,-113.658813,123.267853,-83.006012,144.187729,0.000000,""}; +item41[] = {"Check_Defenses",2,250,-263.351929,109.838028,-173.352142,159.838013,0.000000,"Check Defenses"}; +item42[] = {"Update",4,218,-400.730560,148.182983,-310.730560,198.182983,0.000000,"Update"}; +item43[] = {"Skip",4,218,-400.730560,81.209473,-310.730560,131.209488,0.000000,"Skip"}; +item44[] = {"Skip_2",2,250,-563.843628,82.289688,-473.843506,132.289688,0.000000,"Skip"}; +item45[] = {"Update_Defenses",2,250,-563.843628,149.263184,-473.843384,199.263184,0.000000,"Update" \n "Defenses"}; +item46[] = {"_",8,218,-653.004028,125.776443,-622.351196,146.696320,0.000000,""}; +item47[] = {"Check_Upgrades",2,250,-683.420288,273.342194,-593.420410,323.342194,0.000000,"Check Upgrades"}; +item48[] = {"Update",4,218,-508.776093,300.503662,-418.775909,350.503662,0.000000,"Update"}; +item49[] = {"Skip",4,218,-508.776093,233.530121,-418.775909,283.530151,0.000000,"Skip"}; +item50[] = {"Skip_3",2,250,-329.947998,234.610321,-239.947815,284.610352,0.000000,"Skip"}; +item51[] = {"Update_Upgrades",2,250,-329.947998,301.583862,-239.947693,351.583862,0.000000,"Update" \n "Upgrades"}; +item52[] = {"_",8,218,-167.467773,275.580872,-136.814941,296.500732,0.000000,""}; +item53[] = {"Check_Types",2,250,-197.088531,386.316132,-107.088661,436.316132,0.000000,"Check Types"}; +item54[] = {"Update",4,218,-22.444336,413.477600,67.555847,463.477600,0.000000,"Update"}; +item55[] = {"Skip",4,218,-22.444336,346.504059,67.555847,396.504089,0.000000,"Skip"}; +item56[] = {"Skip_4",2,250,156.383759,347.584259,246.383911,397.584290,0.000000,"Skip"}; +item57[] = {"Update_Types",2,4346,156.383759,414.557800,246.384033,464.557800,0.000000,"Update" \n "Types"}; +item58[] = {"_",8,218,318.863953,388.554810,349.516785,409.474670,0.000000,""}; +item59[] = {"Check_Move_1",2,250,-135.812561,688.819275,-45.812672,738.819336,0.000000,"Check Move"}; +item60[] = {"Check_Workers",2,250,289.874207,510.880676,379.874207,560.880615,0.000000,"Check" \n "Workers"}; +item61[] = {"Workers",4,218,145.521439,513.043701,235.521378,563.043640,0.000000,"Workers"}; +item62[] = {"Time",4,218,140.350052,579.560242,230.349976,629.560242,0.000000,"Time"}; +item63[] = {"Nothing",2,250,-6.216207,579.195068,83.783813,629.194946,0.000000,"Nothing"}; +item64[] = {"Update_Workers",2,250,-7.319051,510.815735,82.681030,560.815674,0.000000,"Update" \n "Workers"}; +item65[] = {"Update",4,218,28.554688,721.853210,118.554871,771.853149,0.000000,"Update"}; +item66[] = {"Skip",4,218,28.554688,654.879639,118.554871,704.879700,0.000000,"Skip"}; +item67[] = {"Skip_5",2,250,207.382751,655.959839,297.382874,705.959900,0.000000,"Skip"}; +item68[] = {"Update_Move",2,250,206.000549,721.551208,296.000916,771.551147,0.000000,"Update" \n "Move"}; +item69[] = {"",7,210,1026.111328,696.930481,1034.111206,704.930481,0.000000,""}; +item70[] = {"_",8,218,-105.421837,566.197021,-74.769012,587.116821,0.000000,""}; +item71[] = {"Being_Fixed",4,218,429.542877,-297.545441,519.542847,-247.545441,0.000000,"Being Fixed"}; +item72[] = {"Skip_6",2,250,562.756470,-305.701782,652.756470,-255.701782,0.000000,"Skip"}; +item73[] = {"",7,210,760.996826,-287.467224,768.996826,-279.467224,0.000000,""}; +item74[] = {"",7,210,364.846039,698.257568,372.846039,706.257568,0.000000,""}; +link0[] = {0,5}; +link1[] = {2,3}; +link2[] = {2,4}; +link3[] = {3,6}; +link4[] = {4,1}; +link5[] = {5,2}; +link6[] = {6,7}; +link7[] = {6,8}; +link8[] = {7,9}; +link9[] = {8,12}; +link10[] = {9,10}; +link11[] = {9,11}; +link12[] = {10,24}; +link13[] = {11,30}; +link14[] = {12,13}; +link15[] = {12,14}; +link16[] = {12,71}; +link17[] = {13,15}; +link18[] = {14,16}; +link19[] = {15,73}; +link20[] = {16,17}; +link21[] = {16,18}; +link22[] = {17,19}; +link23[] = {18,20}; +link24[] = {19,21}; +link25[] = {20,21}; +link26[] = {21,22}; +link27[] = {22,23}; +link28[] = {23,5}; +link29[] = {24,25}; +link30[] = {24,26}; +link31[] = {25,28}; +link32[] = {26,27}; +link33[] = {27,29}; +link34[] = {28,29}; +link35[] = {29,21}; +link36[] = {30,31}; +link37[] = {30,32}; +link38[] = {31,33}; +link39[] = {32,35}; +link40[] = {33,34}; +link41[] = {34,29}; +link42[] = {35,36}; +link43[] = {35,37}; +link44[] = {36,39}; +link45[] = {37,38}; +link46[] = {38,40}; +link47[] = {39,40}; +link48[] = {40,41}; +link49[] = {41,42}; +link50[] = {41,43}; +link51[] = {42,45}; +link52[] = {43,44}; +link53[] = {44,46}; +link54[] = {45,46}; +link55[] = {46,47}; +link56[] = {47,48}; +link57[] = {47,49}; +link58[] = {48,51}; +link59[] = {49,50}; +link60[] = {50,52}; +link61[] = {51,52}; +link62[] = {52,53}; +link63[] = {53,54}; +link64[] = {53,55}; +link65[] = {54,57}; +link66[] = {55,56}; +link67[] = {56,58}; +link68[] = {57,58}; +link69[] = {58,60}; +link70[] = {59,65}; +link71[] = {59,66}; +link72[] = {60,61}; +link73[] = {60,62}; +link74[] = {61,64}; +link75[] = {62,63}; +link76[] = {63,70}; +link77[] = {64,70}; +link78[] = {65,68}; +link79[] = {66,67}; +link80[] = {67,74}; +link81[] = {68,74}; +link82[] = {69,34}; +link83[] = {70,59}; +link84[] = {71,72}; +link85[] = {72,73}; +link86[] = {73,22}; +link87[] = {74,69}; +globals[] = {0.000000,0,0,0,0,640,480,1,103,6316128,1,-734.083008,803.701538,900.392273,-375.968842,900,777,1}; +window[] = {0,-1,-1,-1,-1,1037,110,1562,145,1,918}; +*//*%FSM*/ +class FSM +{ + fsmName = "aicommander"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_side = _this select 0;" \n + "_sideText = Str _side;" \n + "_sideID = (_side) Call GetSideID;" \n + "" \n + "_hq = (_side) Call GetSideHQ;" \n + "" \n + "_lastHQMoveOrder = 0;" \n + "_lastHQMovePos = getPos _hq;" \n + "" \n + "_lastRepairMoveOrder = 0;" \n + "_lastRepairMosPos = [0,0,0];" \n + "" \n + "_lastUpdate = -500;" \n + "_lastUpdateBase = -500;" \n + "_lastUpdateDefenses = -500;" \n + "_lastUpdateMove = -500;" \n + "_lastUpdateTypes = -500;" \n + "_lastUpdateUpgrades = -500;" \n + "_lastUpdateWorkers = -500;" \n + "" \n + "//--- Init the base types." \n + "_types = Format[""WFBE_%1STRUCTURES"",_sideText] Call GetNamespace;" \n + "_names = Format[""WFBE_%1STRUCTURENAMES"",_sideText] Call GetNamespace;" \n + "_costs = Format[""WFBE_%1STRUCTURECOSTS"",_sideText] Call GetNamespace;" \n + "_scripts = Format[""WFBE_%1STRUCTURESCRIPTS"",_sideText] Call GetNamespace;" \n + "" \n + "_eastStructuresNames = ""WFBE_EASTSTRUCTURENAMES"" Call GetNamespace;" \n + "_westStructuresNames = ""WFBE_WESTSTRUCTURENAMES"" Call GetNamespace;" \n + "" \n + "_hqCanMove = false;" \n + "_hqDeployAt = ([_hq, startingLocations] Call SortByDistance) select 0;" \n + "_hqDeployRange = 'WFBE_HQDEPLOYRANGE' Call GetNamespace;" \n + "_hqType = Format[""WFBE_%1HEADQUARTERSTYPE"",_sideText] Call GetNamespace;" \n + "" \n + "_upgradesLabels = 'WFBE_UPGRADELABELS' Call GetNamespace;" \n + "_upgradesLevels = 'WFBE_UPGRADELEVELS' Call GetNamespace;" \n + "_upgradesConditions = 'WFBE_UPGRADECONDITION' Call GetNamespace;" \n + "_upgradesOrders = 'WFBE_UPGRADEAIORDER' Call GetNamespace;" \n + "" \n + "_baseAiInterval = 'WFBE_AICOMMANDERMOVEINTERVAL' Call GetNamespace;" \n + "_baseAiIntervalLast = time;" \n + "_baseAlive = [];" \n + "_baseDefenses = [];" \n + "_baseDefensesTemplate = [[Format[""WFBE_%1DEFENSES_MG"",_sideText] Call GetNamespace,[150,150],0,""MG""],[Format[""WFBE_%1DEFENSES_MG"",_sideText] Call GetNamespace,[-150,150],0,""MG""],[Format[""WFBE_%1DEFENSES_MG"",_sideText] Call GetNamespace,[-150,-150],180,""MG""],[Format[""WFBE_%1DEFENSES_MG"",_sideText] Call GetNamespace,[150,-150],180,""MG""],[Format[""WFBE_%1DEFENSES_AAPOD"",_sideText] Call GetNamespace,[0,135],0,""AAPOD""],[Format[""WFBE_%1DEFENSES_AAPOD"",_sideText] Call GetNamespace,[110,-145],90,""AAPOD""],[Format[""WFBE_%1DEFENSES_AAPOD"",_sideText] Call GetNamespace,[-110,-145],270,""AAPOD""],[Format[""WFBE_%1DEFENSES_MASH"",_sideText] Call GetNamespace,[0,-80],180,""MASH""],[Format[""WFBE_%1DEFENSES_ATPOD"",_sideText] Call GetNamespace,[0,-130],0,""""],[Format[""WFBE_%1DEFENSES_ATPOD"",_sideText] Call GetNamespace,[-100,130],315,""""],[Format[""WFBE_%1DEFENSES_ATPOD"",_sideText] Call GetNamespace,[100,130],45,""""],[Format[""WFBE_%1DEFENSES_CANNON"",_sideText] Call GetNamespace,[120,120],0,""""],[Format[""WFBE_%1DEFENSES_CANNON"",_sideText] Call GetNamespace,[-120,-120],180,""""]];" \n + "_baseDirections = Format[""WFBE_%1STRUCTUREDIRECTIONS"",_sideText] Call GetNamespace;" \n + "_baseDistances = Format[""WFBE_%1STRUCTUREDISTANCES"",_sideText] Call GetNamespace;" \n + "_baseInProgress = [];" \n + "_baseOrder = [""Barracks"",""Light"",""CommandCenter"",""Heavy"",""Aircraft"",""ServicePoint""];" \n + "_baseStructureRelPos = [[50,50],[-50,50],[50,0],[50,-50],[-50,-50],[-50,0]];" \n + "_baseTimerCheck = [];" \n + "_baseWalls = [];" \n + "" \n + "_currentContent = 0;" \n + "_crew = Format [""WFBE_%1SOLDIER"",_sideText] Call GetNamespace;" \n + "_driver = objNull;" \n + "_overallDefenses = [];" \n + "_repairPrice = 'WFBE_MHQREPAIRPRICE' Call GetNamespace;" \n + "_repairTruck = objNull;" \n + "_victoryCondition = 'WFBE_VICTORYCONDITION' Call GetNamespace;" \n + "" \n + "_teams = (Format[""WFBE_%1TEAMS"",_sideText] Call GetNamespace);" \n + "_templates = Format [""WFBE_%1AITEAMTEMPLATES"",_sideText] Call GetNamespace;" \n + "_teamTypes = Format [""WFBE_%1AITEAMTYPES"",_sideText] Call GetNamespace;" \n + "_teamUpgrades = Format [""WFBE_%1AITEAMUPGRADES"",_sideText] Call GetNamespace;" \n + "_totalSupply = 0;" \n + "{_totalSupply = _totalSupply + (_x getVariable 'maxSupplyValue')} forEach towns;" \n + "" \n + "_workerPrice = if (paramUseWorkers) then {'WFBE_WORKERS_PRICE' Call GetNamespace} else {0};" \n + "" \n + "_overallDefenses = missionNamespace getVariable Format [""WFBE_Defenses_%1_Global"",_sideText];" \n + "_currentContent = 0;" \n + "_totalContent = 0;" \n + "if !(isNil ""_overallDefenses"") then {_totalContent = count _overallDefenses} else {_overallDefenses = []};" \n + "" \n + "_baseDefenses = [];" \n + "_defenses = missionNamespace getVariable Format [""WFBE_Defenses_%1"",_sideText];" \n + "for '_i' from 0 to count(_baseDefensesTemplate)-1 do {_baseDefenses set [_i,["""",[]]]};" \n + "if (isNil '_defenses') then {" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1"",_sideText],_baseDefenses];" \n + "} else {" \n + " //--- Check the distance;" \n + " _currentContent = -1;" \n + " for '_i' from 0 to _totalContent-1 do { " \n + " _defenses = _overallDefenses select _i;" \n + " {" \n + " if (count(_x select 1) > 0) then {" \n + " if (alive (_x select 0)) then {" \n + " if ((_x select 0) distance _hq < 750) then {" \n + " _baseDefenses = _defenses;" \n + " _currentContent = _i;" \n + " };" \n + " };" \n + " };" \n + " if (_currentContent != -1) exitWith {};" \n + " } forEach _defenses;" \n + " if (_currentContent != -1) exitWith {};" \n + " };" \n + "};" \n + "" \n + "if (_currentContent == -1) then {_currentContent = count _overallDefenses};" \n + "" \n + "_baseAiIntervalLast = time;" \n + "_baseAlive = [false,false,false,false,false,false];" \n + "_baseInProgress = [false,false,false,false,false,false];" \n + "_baseTimerCheck = [0,0,0,0,0,0];" \n + "_baseWalls = [[],[],[],[],[],[]];" \n + "" \n + "_isStartingFSM = true;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Commander_Check + { + name = "Commander_Check"; + init = /*%FSM*/"_commander = (_side) Call GetCommanderTeam;" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver || !isNull _commander"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class AI + { + priority = 0.000000; + to="Check_HQ"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && isNull _commander"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_HQ + { + name = "Check_HQ"; + init = /*%FSM*/"_hq = (_sideText) Call GetSideHQ;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Dead + { + priority = 0.000000; + to="Check_Repair"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!(alive _hq) && _victoryCondition != 1"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Alive + { + priority = 0.000000; + to="Check_HQ_Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"alive _hq"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_HQ_Status + { + name = "Check_HQ_Status"; + init = /*%FSM*/"_hqDeployed = (_sideText) Call GetSideHQDeployed;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Deployed + { + priority = 0.000000; + to="Check_Move"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_hqDeployed"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Mobilized + { + priority = 0.000000; + to="Check_Status_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_hqDeployed"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Repair + { + name = "Check_Repair"; + init = /*%FSM*/"_isBeingRepaired = WF_Logic getVariable Format [""%1MHQRepair"",_sideText];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Repair_Null + { + priority = 0.000000; + to="Check_Light"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!alive _repairTruck && !_isBeingRepaired"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Being_Fixed + { + priority = 0.000000; + to="Skip_6"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_isBeingRepaired"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Repair_Moving + { + priority = 0.000000; + to="Check_Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"alive _repairTruck && !_isBeingRepaired"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Status + { + name = "Check_Status"; + init = /*%FSM*/"if (!(alive _driver) || !canMove(_repairTruck)) then {" \n + " {_x setDammage 1} forEach [_driver, _repairTruck];" \n + "} else {" \n + " if (_lastRepairMosPos distance (getPos _repairTruck) < 20) then {" \n + " _lastRepairMoveOrder = _lastRepairMoveOrder + 5;" \n + " } else {" \n + " _lastRepairMoveOrder = 0;" \n + " };" \n + "" \n + " if (_lastRepairMoveOrder > 40) then {" \n + " _lastRepairMoveOrder = 0;" \n + " [_hq, getPos _repairTruck, 50] Call PlaceSafe;" \n + " (driver _hq) doMove ([getPos _hq,10,20] Call GetRandomPosition);" \n + " };" \n + "" \n + " _lastRepairMosPos = getPos _repairTruck;" \n + "};" \n + "" \n + "//--- Repair if possible." \n + "if (_repairTruck distance _hq < 75) then {" \n + " if (isEngineOn _repairTruck) then {_repairTruck engineOn false};" \n + " _currency = if !(paramMoneyOnly) then {(_side) Call GetSideSupply} else {(_side) Call GetAICommanderFunds};" \n + " if (_currency >= _repairPrice) then {" \n + " if !(paramMoneyOnly) then {" \n + " [_side,-_repairPrice] Call ChangeSideSupply;" \n + " } else {" \n + " [_side,-_repairPrice] Call ChangeAICommanderFunds;" \n + " };" \n + " " \n + " WF_Logic setVariable [Format [""%1MHQRepair"",_sideText],true,true];" \n + " [_side] Spawn MHQRepair;" \n + "" \n + " if (alive _driver) then {_group = group _driver; deleteVehicle _driver; deleteGroup _group};" \n + " deleteVehicle _repairTruck;" \n + "" \n + " //--- Determine a suitable moving location close by." \n + " _sortedLocation = [_hq, startingLocations] Call SortByDistance;" \n + "" \n + " _hqDeployAt = objNull;" \n + " {" \n + " if (count (nearestObjects [_x, _names, 400]) > 0 && _x distance _hq < 2000) exitWith {_hqDeployAt = _x};" \n + " } forEach _sortedLocation;" \n + "" \n + " if (isNull _hqDeployAt) then {_hqDeployAt = getPos _hq};" \n + " _isStartingFSM = false;" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Light + { + name = "Check_Light"; + init = /*%FSM*/"_buildings = (_sideText) Call GetSideStructures;" \n + "_checks = [_side,Format [""WFBE_%1LIGHTTYPE"",_sideText] Call GetNamespace,_buildings] Call GetFactories;" \n + "_light = objNull;" \n + "" \n + "if (count _checks > 0) then {" \n + " _sorted = [_hq,_checks] Call SortByDistance;" \n + " _light = _sorted select 0;" \n + "};" \n + "" \n + "if (alive _driver) then {_group = group _driver; deleteVehicle _driver; deleteGroup _group};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Dead + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!(alive _light)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Alive + { + priority = 0.000000; + to="Create_Repair"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"alive _light"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Create_Repair + { + name = "Create_Repair"; + init = /*%FSM*/"_type = typeOf _light;" \n + "_index = _names find _type;" \n + "_distance = (Format[""WFBE_%1STRUCTUREDISTANCES"",_sideText] Call GetNamespace) select _index;" \n + "_direction = (Format[""WFBE_%1STRUCTUREDIRECTIONS"",_sideText] Call GetNamespace) select _index;" \n + "_position = [getPos _light,_distance,getDir _light + _direction] Call GetPositionFrom;" \n + "" \n + "_repairTruck = [Format[""WFBE_%1REPAIRTRUCK"",_sideText] Call GetNamespace,_position,_side,true] Call CreateVehi;" \n + "_group = createGroup _side;" \n + "_driver = [_crew,_group,_position,_side] Call CreateMan;" \n + "[_driver] allowGetIn true;" \n + "_driver moveInDriver _repairTruck;" \n + "_repairAlive = true;" \n + "" \n + "[_sideText,'VehiclesCreated',1] Call UpdateStatistics;" \n + "[_sideText,'UnitsCreated',1] Call UpdateStatistics;" \n + "_driver doMove ([GetPos _hq,10,20] Call GetRandomPosition);"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + name = "Skip"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Status_1 + { + name = "Check_Status_1"; + init = /*%FSM*/"_inRange = if (_hq distance _hqDeployAt < 200) then {true} else {false};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Empty + { + priority = 0.000000; + to="Spawn___Lead"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_isStartingFSM || !_inRange"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Moving + { + priority = 0.000000; + to="Check_Position"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_isStartingFSM || _inRange"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Spawn___Lead + { + name = "Spawn___Lead"; + init = /*%FSM*/"if !(alive(driver _hq)) then {" \n + " _HQDriver = [_crew,(createGroup _side),getPos _hq,_side] Call CreateMan;" \n + " [_HQDriver] allowGetIn true;" \n + " _HQDriver moveInDriver _hq;" \n + " _HQDriver assignAsDriver _hq;" \n + " [_HQDriver] orderGetIn true;" \n + " _HQDriver doMove ([GetPos _hqDeployAt,10,20] Call GetRandomPosition);" \n + "};" \n + "" \n + "if (alive(driver _hq)) then {" \n + "" \n + " if (_lastHQMovePos distance (getPos _hq) < 20 && !surfaceIsWater(getPos _hq)) then {" \n + " _lastHQMoveOrder = _lastHQMoveOrder + 5;" \n + " } else {" \n + " _lastHQMoveOrder = 0;" \n + " };" \n + "" \n + " if (_lastHQMoveOrder > 40) then {" \n + " _lastHQMoveOrder = 0;" \n + " [_hq, getPos _hq, 50] Call PlaceSafe;" \n + " (driver _hq) doMove ([GetPos _hqDeployAt,10,20] Call GetRandomPosition);" \n + " };" \n + "" \n + " _lastHQMovePos = getPos _hq;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Position + { + name = "Check_Position"; + init = /*%FSM*/"_canBeDeploy = true;" \n + "" \n + "//--- On multiplayer, ensure that there is no exploits." \n + "if (isMultiplayer) then {" \n + " _tbpr = 'WFBE_TOWNBUILDPROTECTIONRANGE' Call GetNamespace;" \n + " _isPlayerOnSide = false;" \n + " " \n + " {if (!isNull _x) then {if (side _x == _side && isPlayer _x) exitWith {_isPlayerOnSide = true}}} forEach playableUnits;" \n + " " \n + " if (_isPlayerOnSide) then {" \n + " {if (_x distance _hq < _tbpr) exitWith {_canBeDeploy = false}} forEach towns;" \n + " };" \n + "};" \n + "" \n + "//--- HQ Can be deployed." \n + "if (_canBeDeploy) then {" \n + " if (alive(driver _hq)) then {(driver _hq) setDammage 1};" \n + "" \n + " _pos = getPos _hq;" \n + " _pos set [2,0];" \n + " _pos = [_pos,(('WFBE_AREAHQUNDEPLOYED' Call GetNamespace) select 0)+20] Call GetSafePlace;" \n + " if (count _pos < 1) then {_pos = [_pos,(('WFBE_AREAHQUNDEPLOYED' Call GetNamespace) select 0)+50] Call GetSafePlace};" \n + " if (count _pos < 1) then {_pos = Call Compile Format [""%1StartingLocation"",_sideText]};" \n + " _dir = getDir _hq;" \n + " _currency = if !(paramMoneyOnly) then {(_side) Call GetSideSupply} else {(_side) Call GetAICommanderFunds};" \n + "" \n + " //--- Ensure that we have the supply required to deploy the HQ." \n + " if (_currency >= (_costs select _hqType)) then {" \n + " [(_names select _hqType),_side,_pos,_dir] ExecVM 'Server\Construction\Construction_HQSite.sqf';" \n + "" \n + " if !(paramMoneyOnly) then {" \n + " [_side, -(_costs select _hqType)] Call ChangeSideSupply;" \n + " } else {" \n + " [_side, -(_costs select _hqType)] Call ChangeAICommanderFunds;" \n + " };" \n + " " \n + " if (_isStartingFSM) then {_isStartingFSM = false};" \n + " };" \n + "" \n + " //--- Reset local variable." \n + " _overallDefenses = missionNamespace getVariable Format [""WFBE_Defenses_%1_Global"",_sideText];" \n + " _currentContent = 0;" \n + " _totalContent = 0;" \n + " if !(isNil ""_overallDefenses"") then {_totalContent = count _overallDefenses} else {_overallDefenses = []};" \n + "" \n + " _baseDefenses = [];" \n + " _defenses = missionNamespace getVariable Format [""WFBE_Defenses_%1"",_sideText];" \n + " for '_i' from 0 to count(_baseDefensesTemplate)-1 do {_baseDefenses set [_i,["""",[]]]};" \n + " if (isNil '_defenses') then {" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1"",_sideText],_baseDefenses];" \n + " } else {" \n + " //--- Check the distance;" \n + " _currentContent = -1;" \n + " for '_i' from 0 to _totalContent-1 do { " \n + " _defenses = _overallDefenses select _i;" \n + " {" \n + " if (count(_x select 1) > 0) then {" \n + " if (alive (_x select 0)) then {" \n + " if ((_x select 0) distance _hq < 750) then {" \n + " _baseDefenses = _defenses;" \n + " _currentContent = _i;" \n + " };" \n + " };" \n + " };" \n + " if (_currentContent != -1) exitWith {};" \n + " } forEach _defenses;" \n + " if (_currentContent != -1) exitWith {};" \n + " };" \n + " };" \n + "" \n + " if (_currentContent == -1) then {_currentContent = count _overallDefenses};" \n + "" \n + " _baseAiIntervalLast = time;" \n + " _baseAlive = [false,false,false,false,false,false];" \n + " _baseInProgress = [false,false,false,false,false,false];" \n + " _baseTimerCheck = [time,time,time,time,time,time];" \n + " _baseWalls = [[],[],[],[],[],[]];" \n + "};" \n + ""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Move + { + name = "Check_Move"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Proceed + { + priority = 0.000000; + to="Check_Base"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_hqCanMove"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Move + { + priority = 0.000000; + to="Move"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_hqCanMove"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Move + { + name = "Move"; + init = /*%FSM*/"_hqCanMove = false;" \n + "" \n + "[(_names select _hqType),_side,getPos _hq,getDir _hq] ExecVM 'Server\Construction\Construction_HQSite.sqf';"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Base + { + name = "Check_Base"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Skip_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdateBase <= 45"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + priority = 0.000000; + to="Update_Base"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdateBase > 45"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_1 + { + name = "Skip_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Defenses"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Base + { + name = "Update_Base"; + init = /*%FSM*/"_lastUpdateBase = time;" \n + "" \n + "_buildings = (_sideText) Call GetSideStructures;" \n + "" \n + "//--- Get the buildings close of the HQ by type (repair if downed)." \n + "_barracks = ['BARRACKSTYPE',_buildings,750,_side,_hq] Call BuildingInRange;" \n + "_light = ['LIGHTTYPE',_buildings,750,_side,_hq] Call BuildingInRange;" \n + "_heavy = ['HEAVYTYPE',_buildings,750,_side,_hq] Call BuildingInRange;" \n + "_air = ['AIRCRAFTTYPE',_buildings,750,_side,_hq] Call BuildingInRange;" \n + "_servicePoint = ['SERVICEPOINTTYPE',_buildings,750,_side,_hq] Call BuildingInRange;" \n + "_commandCenter = ['COMMANDCENTERTYPE',_buildings,750,_side,_hq] Call BuildingInRange;" \n + "" \n + "//--- Get the building in progress." \n + "_contentInProgress = [objNull,objNull,objNull,objNull,objNull,objNull];" \n + "_nearLogics = _hq nearEntities [[""LocationLogicStart""],550];" \n + "{" \n + " _get = _x getVariable 'WFBE_B_Type';" \n + " " \n + " if !(isNil '_get') then {" \n + " switch (_get) do {" \n + " case ""Barracks"": {_contentInProgress set [0, _x]};" \n + " case ""Light"": {_contentInProgress set [1, _x]};" \n + " case ""CommandCenter"": {_contentInProgress set [2, _x]};" \n + " case ""Heavy"": {_contentInProgress set [3, _x]};" \n + " case ""Aircraft"": {_contentInProgress set [4, _x]};" \n + " case ""ServicePoint"": {_contentInProgress set [5, _x]};" \n + " };" \n + " };" \n + "} forEach _nearLogics;" \n + "" \n + "//--- Is there a CC at least." \n + "_check = [_side, Format [""WFBE_%1COMMANDCENTERTYPE"",_sideText] Call GetNamespace,_buildings] Call GetFactories;" \n + "_ccAvailable = if (count _check == 0) then {false} else {true};" \n + "" \n + "_content = [_barracks,_light,_commandCenter,_heavy,_air,_servicePoint];" \n + "_baseStructurePos = [];" \n + "{_baseStructurePos = _baseStructurePos + [getPos _x]} forEach _content;" \n + "" \n + "//--- Check for construction etc." \n + "for '_i' from 0 to count(_content)-1 do {" \n + " _currency = if !(paramMoneyOnly) then {(_side) Call GetSideSupply} else {(_side) Call GetAICommanderFunds};" \n + "" \n + " _currentStructure = _content select _i;" \n + " _isInProgress = _baseInProgress select _i;" \n + " _isAlive = _baseAlive select _i;" \n + " _timer = _baseTimerCheck select _i;" \n + " _isLogicInProgress = _contentInProgress select _i;" \n + "" \n + " //--- Bad Catch?" \n + " if (_isInProgress && !_isAlive && _timer > 400) then {" \n + " _baseInProgress set [_i, false];" \n + " };" \n + "" \n + " //--- Alive?" \n + " if (alive _currentStructure) then {if !(_isAlive) then {_baseAlive set [_i , true]}};" \n + "" \n + " //--- Destroyed?" \n + " if (_isInProgress && _isAlive && !(alive _currentStructure)) then {" \n + " _baseAlive set [_i , false];" \n + " _baseInProgress set [_i, false];" \n + " };" \n + "" \n + " //--- Not in progress, we can build it." \n + " if (!_isInProgress && isNull(_currentStructure) && isNull(_isLogicInProgress)) then {" \n + " _currentType = _baseOrder select _i;" \n + " _type = _types find _currentType;" \n + "" \n + " //--- Check the supply." \n + " _cost = _costs select _type;" \n + " if (_cost <= _currency) then {" \n + "" \n + " //--- check about the building limit." \n + " _buildLimit = false;" \n + " _current = Call Compile Format ['%1BuildingsCurrent',_sideText];" \n + " _limit = (Format['WFBE_BUILDINGMAX%1',_currentType]) Call GetNamespace;" \n + " if (isNil '_limit') then {_limit = 4}; //--- Default." \n + " if ((_current select (_type-1)) >= _limit) then {_buildLimit = true};" \n + "" \n + " //--- Can build." \n + " if !(_buildLimit) then {" \n + " _pos = getPos _hq;" \n + " _x = _pos select 0;" \n + " _y = _pos select 1;" \n + " _pos = [];" \n + " _pos set [0,((_baseStructureRelPos select _i) select 0) + _x];" \n + " _pos set [1,((_baseStructureRelPos select _i) select 1) + _y];" \n + " _newPos = [0,0,0];" \n + " _roads = [];" \n + "" \n + " _attempts = 0;" \n + " _max = 100;" \n + " while {true} do {" \n + " _newPos = [_pos,30,_max,10,0,50,0] Call BIS_fnc_findSafePos;" \n + " _aiSpawnPos = [_newPos,_baseDistances select _i,_baseDirections select _i] Call GetPositionFrom;" \n + " _aiSpawnPos set [2,0];" \n + " _roads = _newPos nearRoads 30;" \n + " _roads2 = _aiSpawnPos nearRoads 30;" \n + " " \n + " _isFlat = _aiSpawnPos isFlatEmpty [" \n + " 5, //--- Minimal distance from another object" \n + " 0, //--- If 0, just check position. If >0, select new one" \n + " 0.6, //--- Max gradient" \n + " 5, //--- Gradient area" \n + " 0, //--- 0 for restricted water, 2 for required water," \n + " false, //--- True if some water can be in 25m radius" \n + " objNull //--- Ignored object" \n + " ];" \n + " " \n + " _isTooClose = false;" \n + " {if (_x distance _newPos < 70) exitWith {_isTooClose = true}} forEach _baseStructurePos;" \n + " if (count _roads == 0 && count _roads2 == 0 && !_isTooClose && count _isFlat != 0) exitWith {};" \n + " _attempts = _attempts + 1;" \n + " if (_attempts > 100 && _max == 100) then {_max = _max + 150};" \n + " };" \n + " _baseStructurePos set [_i, _newPos];" \n + " [(_names select _type),_side,_newPos,0,_type] ExecVM (Format[""Server\Construction\Construction_%1.sqf"",(_scripts select _type)]);" \n + " if !(paramMoneyOnly) then {" \n + " [_side, -_cost] Call ChangeSideSupply;" \n + " } else {" \n + " [_side, -_cost] Call ChangeAICommanderFunds;" \n + " };" \n + " _baseInProgress set [_i, true];" \n + " _baseTimerCheck set [_i, time];" \n + " " \n + " _current set [_type - 1, (_current select (_type-1)) + 1];" \n + " Call Compile Format ['%1BuildingsCurrent = _current',_sideText];" \n + " publicVariable Format ['%1BuildingsCurrent',_sideText]; " \n + " };" \n + " };" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Defenses"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Defenses + { + name = "Check_Defenses"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Skip_2"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"isNull _barracks || time - _lastUpdateDefenses <= 80"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + priority = 0.000000; + to="Update_Defenses"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!isNull _barracks && time - _lastUpdateDefenses > 80"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_2 + { + name = "Skip_2"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Upgrades"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Defenses + { + name = "Update_Defenses"; + init = /*%FSM*/"_lastUpdateDefenses = time;" \n + "" \n + "//--- Buildings checks" \n + "for '_i' from 0 to count(_content)-1 do {" \n + " _building = _content select _i;" \n + " _type = _baseOrder select _i;" \n + " _buildingWall = _baseWalls select _i;" \n + "" \n + " if (alive _building) then {" \n + " if (count _buildingWall == 0) then {" \n + " //--- Persistent check (Walls), only executed if the array is empty." \n + " _defenses = _building getVariable 'WFBE_Walls';" \n + " if !(isNil ""_defenses"") then {_baseWalls set [_i,_defenses]};" \n + " " \n + " _defenses = [_building,Format [""WFBE_NEURODEF_%1_WALLS"",_type] Call GetNamespace,(_baseWalls select _i)] Call CreateDefenseTemplate;" \n + " _baseWalls set [_i ,_defenses];" \n + " _building setVariable ['WFBE_Walls', _defenses];" \n + " } else {" \n + " {" \n + " if !(alive _x) exitWith {" \n + " _defenses = [_building,Format [""WFBE_NEURODEF_%1_WALLS"",_type] Call GetNamespace,(_baseWalls select _i)] Call CreateDefenseTemplate;" \n + " _baseWalls set [_i ,_defenses];" \n + " _building setVariable ['WFBE_Walls', _defenses];" \n + " };" \n + " } forEach (_baseWalls select _i);" \n + " };" \n + " } else {" \n + " if (count(_buildingWall) > 0) then {" \n + " {deleteVehicle _x} forEach (_baseWalls select _i);" \n + " _baseWalls set [_i, []];" \n + " };" \n + " };" \n + "} forEach _content;" \n + "" \n + "//--- Defenses Check." \n + "for '_i' from 0 to count(_baseDefenses)-1 do {" \n + " _defense = (_baseDefenses select _i) select 0;" \n + "" \n + " //--- If object, it exist or existed." \n + " if (typename _defense == ""OBJECT"") then {" \n + " _template = (_baseDefenses select _i) select 1;" \n + " " \n + " if (alive _defense) then {" \n + " {" \n + " if !(alive _x) exitWith {" \n + " _template = _baseDefensesTemplate select _i;" \n + " _defenses = [_defense,Format [""WFBE_NEURODEF_%1"",_template select 3] Call GetNamespace] Call CreateDefenseTemplate;" \n + " _baseDefenses set [_i, [_defense,_defenses]];" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1"",_sideText],_baseDefenses];" \n + " _overallDefenses set [_currentContent, _baseDefenses];" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1_Global"",_sideText], _overallDefenses];" \n + " };" \n + " } forEach _template;" \n + "" \n + " //--- Keep the defense able to fire." \n + " if !(isNull(gunner _defense)) then {" \n + " if !(someAmmo _defense) then {[_defense,_side] Call RearmVehicle};" \n + " };" \n + " } else {" \n + " if (count(_template) > 0) then {" \n + " {deleteVehicle _x} forEach _template;" \n + " _baseDefenses set [_i, ["""",[]]];" \n + " _defense = (_baseDefenses select _i) select 0;" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1"",_sideText],_baseDefenses];" \n + " _overallDefenses set [_currentContent, _baseDefenses];" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1_Global"",_sideText], _overallDefenses];" \n + " };" \n + " };" \n + " };" \n + "" \n + " //--- If string, it don't exist." \n + " if (typename _defense == ""STRING"") then {" \n + " _aiComFunds = (_side) Call GetAICommanderFunds;" \n + " _template = _baseDefensesTemplate select _i;" \n + " _pool = _template select 0;" \n + " _picked = _pool select round(random((count _pool)-1));" \n + "" \n + " //--- Grab the defense price." \n + " _details = _picked Call GetNamespace;" \n + " _price = if !(isNil '_details') then {_details select QUERYUNITPRICE} else {400};" \n + "" \n + " if (_aiComFunds >= _price) then {" \n + " [_side, -_price] Call ChangeAICommanderFunds;" \n + " " \n + " _pos = getPos _hq;" \n + " _x = _pos select 0;" \n + " _y = _pos select 1;" \n + " _pos = [];" \n + " _pos set [0,((_template select 1) select 0) + _x];" \n + " _pos set [1,((_template select 1) select 1) + _y];" \n + " _newPos = [0,0,0];" \n + " _roads = [];" \n + "" \n + " _attempts = 0;" \n + " _max = 100;" \n + " while {true} do {" \n + " _newPos = [_pos,30,_max,10,0,50,0] Call BIS_fnc_findSafePos;" \n + " _roads = _newPos nearRoads 24;" \n + "" \n + " _isTooClose = false;" \n + " {if (_x distance _newPos < 30) exitWith {_isTooClose = true}} forEach _content;" \n + " if (count _roads == 0 && !_isTooClose && count(_newPos nearEntities 15) == 0) exitWith {};" \n + " _attempts = _attempts + 1;" \n + " if (_attempts > 100 && _max == 100) then {_max = _max + 150};" \n + " };" \n + "" \n + " _created = [_picked,_side,_newPos,_template select 2,true,true,('WFBE_DEFENSEMANRANGE' Call GetNamespace)*3] Call ConstructDefense;" \n + "" \n + " //--- Extra?" \n + " _defenses = [];" \n + " _extra = _template select 3;" \n + " if (_extra != """") then {" \n + " _defenses = [_created,Format [""WFBE_NEURODEF_%1"",_extra] Call GetNamespace] Call CreateDefenseTemplate;" \n + " };" \n + "" \n + " _baseDefenses set [_i, [_created,_defenses]];" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1"",_sideText],_baseDefenses];" \n + " _overallDefenses set [_currentContent, _baseDefenses];" \n + " missionNamespace setVariable [Format [""WFBE_Defenses_%1_Global"",_sideText], _overallDefenses];" \n + " };" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Upgrades"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Upgrades + { + name = "Check_Upgrades"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Skip_3"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_ccAvailable || time - _lastUpdateUpgrades <= 60"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + priority = 0.000000; + to="Update_Upgrades"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_ccAvailable && time - _lastUpdateUpgrades > 60"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_3 + { + name = "Skip_3"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Types"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Upgrades + { + name = "Update_Upgrades"; + init = /*%FSM*/"_lastUpdateUpgrades = time;" \n + "" \n + "if !(Call Compile Format [""WFBE_%1_Upgrading"",_sideText]) then {" \n + " _upgrades = (_sideText) Call GetSideUpgrades;" \n + " _currency = if !(paramMoneyOnly) then {(_side) Call GetSideSupply} else {(_side) Call GetAICommanderFunds};" \n + " _break = false;" \n + "" \n + " _upgrade = -1;" \n + " _index = -1;" \n + " _supplyLevel = -1;" \n + " " \n + " for [{_x = 0},{_x < (count _upgradesOrders) && !_break},{_x = _x + 1}] do {" \n + " _index = _upgradesOrders select _x;" \n + " _canUpgrade = _upgradesConditions select _index;" \n + "" \n + " //--- Can we use that upgrade?." \n + " if (_canUpgrade) then {" \n + " _upgradeLevels = _upgradesLevels select _index;" \n + " _currentLevel = _upgrades select _index;" \n + " //--- Have we reached the max?." \n + " if (_currentLevel < _upgradeLevels) then {" \n + " _currencyID = if !(paramMoneyOnly) then {0} else {1};" \n + " _supplyLevel = ((Format [""WFBE_UPGRADEPRICESLEVEL%1"",(_currentLevel + 1)] Call GetNamespace) select _index) select _currencyID;" \n + " //--- Do we have enough currency to upgrade?. Otherwise, just skip the upgrade until AI has enough currency." \n + " if (_currency > _supplyLevel) then {" \n + " _upgrade = _currentLevel;" \n + " _break = true;" \n + " } else {" \n + " _break = true;" \n + " };" \n + " };" \n + " };" \n + " };" \n + " " \n + " if (_upgrade != -1) then {" \n + " if !(paramMoneyOnly) then {" \n + " [_side,-_supplyLevel] Call ChangeSideSupply;" \n + " } else {" \n + " [_side,-_supplyLevel] Call ChangeAICommanderFunds;" \n + " };" \n + " " \n + " _time = (Format [""WFBE_UPGRADETIMESLEVEL%1"",_upgrade+1] Call GetNamespace) select _index;" \n + " _name = _upgradesLabels select _index;" \n + " [_time,_upgrade,_index,_name,_side] Spawn AIUpgrade;" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Types"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Types + { + name = "Check_Types"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Skip_4"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdateTypes <= 120"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + priority = 0.000000; + to="Update_Types"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdateTypes > 120"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_4 + { + name = "Skip_4"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Workers"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Types + { + name = "Update_Types"; + init = /*%FSM*/"_lastUpdateTypes = time;" \n + "" \n + "_totalFunds = 0;" \n + "" \n + "{" \n + " if !(isNil '_x') then {_totalFunds = _totalFunds + ((_x) Call GetTeamFunds)};" \n + "} forEach _teams;" \n + "" \n + "_avgIncome = _totalFunds / maxPlayers;" \n + "" \n + "_income = _side Call GetTotalSupplyValue;" \n + "" \n + "_type = 0;" \n + "" \n + "_infPercent = 0;" \n + "_lightPercent = 0;" \n + "_heavyPercent = 0;" \n + "_airPercent = 0;" \n + "if (_income < (_totalSupply - (_totalSupply/1.2)) || _avgIncome < 2000) then {_infPercent = 70; _lightPercent = 30};" \n + "if ((_income >= (_totalSupply - (_totalSupply/1.2)) && _income < (_totalSupply - (_totalSupply/1.6))) || _avgIncome > 2000) then {_infPercent = 60; _lightPercent = 30; _heavyPercent = 10};" \n + "if ((_income >= (_totalSupply - (_totalSupply/1.6)) && _income < (_totalSupply - (_totalSupply/2))) || _avgIncome > 4000) then {_infPercent = 50; _lightPercent = 30; _heavyPercent = 20};" \n + "if ((_income >= (_totalSupply - (_totalSupply/2)) && _income < (_totalSupply - (_totalSupply/3))) || _avgIncome > 12000) then {_infPercent = 40; _lightPercent = 25; _heavyPercent = 30; _airPercent = 5};" \n + "if ((_income >= (_totalSupply - (_totalSupply/3)) && _income < (_totalSupply - (_totalSupply/4))) || _avgIncome > 18000) then {_infPercent = 30; _lightPercent = 20; _heavyPercent = 40; _airPercent = 10};" \n + "if (_income >= (_totalSupply - (_totalSupply/4)) || _avgIncome > 24000) then {_infPercent = 20; _lightPercent = 20; _heavyPercent = 45; _airPercent = 15};" \n + "" \n + "_infAssign = round(maxPlayers * (_infPercent / 100));" \n + "_lightAssign = round(maxPlayers * (_lightPercent / 100));" \n + "_heavyAssign = round(maxPlayers * (_heavyPercent / 100));" \n + "_airAssign = round(maxPlayers * (_airPercent / 100));" \n + "" \n + "_infTemplates = [];" \n + "_lightTemplates = [];" \n + "_heavyTemplates = [];" \n + "_airTemplates = [];" \n + "" \n + "_i = 0;" \n + "" \n + "/* Experimental - Start */" \n + "_upgrades = (_sideText) Call GetSideUpgrades;" \n + "" \n + "//--- Retrieve the available types." \n + "{" \n + " _upgradesTemplate = _teamUpgrades select _i;" \n + " switch (_x) do {" \n + " //--- Infantry." \n + " case 0: {" \n + " _canAdd = true;" \n + " for '_k' from 0 to 3 do {" \n + " if ((_upgrades select _k) < (_upgradesTemplate select _k)) exitWith {_canAdd = false};" \n + " };" \n + " if (_canAdd) then {_infTemplates = _infTemplates + [_i]};" \n + " };" \n + " //--- Light." \n + " case 1: {" \n + " _canAdd = true;" \n + " for '_k' from 0 to 3 do {" \n + " if ((_upgrades select _k) < (_upgradesTemplate select _k)) exitWith {_canAdd = false};" \n + " };" \n + " if (_canAdd) then {_lightTemplates = _lightTemplates + [_i]};" \n + " };" \n + " //--- Heavy." \n + " case 2: {" \n + " _canAdd = true;" \n + " for '_k' from 0 to 3 do {" \n + " if ((_upgrades select _k) < (_upgradesTemplate select _k)) exitWith {_canAdd = false};" \n + " };" \n + " if (_canAdd) then {_heavyTemplates = _heavyTemplates + [_i]};" \n + " };" \n + " //--- Air." \n + " case 3: {" \n + " _canAdd = true;" \n + " for '_k' from 0 to 3 do {" \n + " if ((_upgrades select _k) < (_upgradesTemplate select _k)) exitWith {_canAdd = false};" \n + " };" \n + " if (_canAdd) then {_airTemplates = _airTemplates + [_i]};" \n + " };" \n + " };" \n + " _i = _i + 1;" \n + "} forEach _teamTypes;" \n + "" \n + "//--- How many types are available." \n + "_templates_infavailable = count _infTemplates;" \n + "_templates_ligavailable = count _lightTemplates;" \n + "_templates_heaavailable = count _heavyTemplates;" \n + "_templates_airavailable = count _airTemplates;" \n + "" \n + "//--- Assign if possible." \n + "if (_templates_infavailable > 0 || _templates_ligavailable > 0 || _templates_heaavailable > 0 || _templates_airavailable > 0) then {" \n + " //--- Reallocate if necessary - Infantry." \n + " if (_templates_infavailable == 0 && _infAssign > 0) then {" \n + " _dividedEnd = _infAssign;" \n + " _ressourceDivision = [_dividedEnd / 2, (_dividedEnd/2) - ((_dividedEnd/2) / 4), (_dividedEnd/2)/4];" \n + " " \n + " _infAssign = 0;" \n + " _i = 0;" \n + " " \n + " if (_templates_ligavailable != 0) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_heaavailable == 0) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_heaavailable != 0) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_ligavailable == 0 && _i < 3) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0 && _i < 3) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_airavailable != 0) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_ligavailable == 0 && _i < 3) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_heaavailable == 0 && _i < 3) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " };" \n + " };" \n + " };" \n + "" \n + " //--- Reallocate if necessary - Light." \n + " if (_templates_ligavailable == 0 && _lightAssign > 0) then {" \n + " _dividedEnd = _lightAssign;" \n + " _ressourceDivision = [_dividedEnd / 2, (_dividedEnd/2) - ((_dividedEnd/2) / 4), (_dividedEnd/2)/4];" \n + " " \n + " _lightAssign = 0;" \n + " _i = 0;" \n + " " \n + " if (_templates_infavailable != 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_heaavailable == 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_heaavailable != 0) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_infavailable == 0 && _i < 3) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0 && _i < 3) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_airavailable != 0) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_infavailable == 0 && _i < 3) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_heaavailable == 0 && _i < 3) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " };" \n + " };" \n + " };" \n + " " \n + " //--- Reallocate if necessary - Heavy." \n + " if (_templates_heaavailable == 0 && _heavyAssign > 0) then {" \n + " _dividedEnd = _heavyAssign;" \n + " _ressourceDivision = [_dividedEnd / 2, (_dividedEnd/2) - ((_dividedEnd/2) / 4), (_dividedEnd/2)/4];" \n + " " \n + " _heavyAssign = 0;" \n + " _i = 0;" \n + " " \n + " if (_templates_infavailable != 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_ligavailable == 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_ligavailable != 0) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_infavailable == 0 && _i < 3) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0 && _i < 3) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_airavailable != 0) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_infavailable == 0 && _i < 3) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_ligavailable == 0 && _i < 3) then {" \n + " _airAssign = _airAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " };" \n + " };" \n + " };" \n + " " \n + " //--- Reallocate if necessary - Air." \n + " if (_templates_airavailable == 0 && _airAssign > 0) then {" \n + " _dividedEnd = _airAssign;" \n + " _ressourceDivision = [_dividedEnd / 2, (_dividedEnd/2) - ((_dividedEnd/2) / 4), (_dividedEnd/2)/4];" \n + " " \n + " _airAssign = 0;" \n + " _i = 0;" \n + " " \n + " if (_templates_infavailable != 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_ligavailable == 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0) then {" \n + " _infAssign = _infAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_ligavailable != 0) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_infavailable == 0 && _i < 3) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_airavailable == 0 && _i < 3) then {" \n + " _lightAssign = _lightAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " " \n + " if (_i < 3) then {" \n + " if (_templates_heaavailable != 0) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " " \n + " if (_templates_infavailable == 0 && _i < 3) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " " \n + " if (_templates_ligavailable == 0 && _i < 3) then {" \n + " _heavyAssign = _heavyAssign + (_ressourceDivision select _i);" \n + " _i = _i + 1;" \n + " };" \n + " };" \n + " };" \n + " };" \n + " };" \n + " " \n + " {" \n + " if !(isNil '_x') then {" \n + " _skip = false;" \n + " if (_infAssign > 0) then {" \n + " _type = _infTemplates select (round(random((count _infTemplates)-1)));" \n + " _infAssign = _infAssign - 1;" \n + " _skip = true;" \n + " };" \n + " if (_lightAssign > 0 && !_skip) then {" \n + " _type = _lightTemplates select (round(random((count _lightTemplates)-1)));" \n + " _lightAssign = _lightAssign - 1;" \n + " _skip = true;" \n + " };" \n + " if (_heavyAssign > 0 && !_skip) then {" \n + " _type = _heavyTemplates select (round(random((count _heavyTemplates)-1)));" \n + " _heavyAssign = _heavyAssign - 1;" \n + " _skip = true;" \n + " };" \n + " if (_airAssign > 0 && !_skip) then {" \n + " _type = _airTemplates select (round(random((count _airTemplates)-1)));" \n + " _airAssign = _airAssign - 1;" \n + " _skip = true;" \n + " };" \n + " [_x,_type] Call SetTeamType;" \n + " };" \n + " } forEach _teams;" \n + "};" \n + "/* Experimental - End */"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Workers"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Move_1 + { + name = "Check_Move_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Skip_5"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdateMove <= 120"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + priority = 0.000000; + to="Update_Move"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdateMove > 120"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Workers + { + name = "Check_Workers"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Time + { + priority = 0.000000; + to="Nothing"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!paramUseWorkers || time - _lastUpdateWorkers <= 20"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Workers + { + priority = 0.000000; + to="Update_Workers"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"paramUseWorkers && time - _lastUpdateWorkers > 20"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Nothing + { + name = "Nothing"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Move_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Workers + { + name = "Update_Workers"; + init = /*%FSM*/"_lastUpdateWorkers = time;" \n + "" \n + "_workers = Call Compile Format [""WF_%1Workers"",_sideText];" \n + "_aliveWorkers = (_workers) Call GetLiveUnits;" \n + "" \n + "//--- enough workers or?." \n + "if (count _aliveWorkers < ('WFBE_WORKERS_MAX' Call GetNamespace)) then {" \n + " _aiComFunds = (_side) Call GetAICommanderFunds;" \n + "" \n + " if (_aiComFunds >= _workerPrice) then {" \n + " [_side, -_workerPrice] Call ChangeAICommanderFunds;" \n + " " \n + " //--- Which index." \n + " _index = 0;" \n + " for '_i' from 0 to count(_workers)-1 do {" \n + " if (isNull (_workers select _i)) exitWith {_index = _i};" \n + " };" \n + " " \n + " if (_index == 0 && count(_workers) > 0) then {_index = count _workers};" \n + " " \n + " [_side, _hq, _index] Call SRVFNCRequestWorker;" \n + " };" \n + "} else {" \n + " //--- Max reached, enough in base to build else dispose." \n + " {" \n + " if (_x distance _hq > 600 && alive _x) then {_x setDammage 1};" \n + " } forEach _workers;" \n + "};" \n + ""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_Move_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_5 + { + name = "Skip_5"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Move + { + name = "Update_Move"; + init = /*%FSM*/"_lastUpdateMove = time;" \n + "" \n + "if (time - _baseAiIntervalLast > _baseAiInterval) then {" \n + " _hqCanMove = true;" \n + "" \n + " //--- Build limit Check" \n + " _buildLimit = false;" \n + " _current = Call Compile Format ['%1BuildingsCurrent',_sideText];" \n + " _limit = 'WFBE_BUILDINGMAXBARRACKS' Call GetNamespace;" \n + " if (isNil '_limit') then {_limit = 4}; //--- Default." \n + " if ((_current select 0) >= _limit) exitWith {_hqCanMove = false};" \n + "" \n + " //--- check the nearby buildings." \n + " {" \n + " if !(alive _x) exitWith {_hqCanMove = false}; " \n + " } forEach _content;" \n + "" \n + " if (_hqCanMove) then {" \n + " //--- Check Defenses." \n + " for '_i' from 0 to count(_baseDefenses)-1 do {" \n + " _defense = (_baseDefenses select _i) select 0;" \n + " if (typeName _defense == ""STRING"") exitWith {_hqCanMove = false};" \n + " };" \n + "" \n + " if (_hqCanMove) then {" \n + " //--- Attempt to get a destination." \n + " _sortedLocation = [_hq, startingLocations] Call SortByDistance;" \n + "" \n + " _hqDeployAt = objNull;" \n + " {" \n + " if (count (nearestObjects [_x, (_westStructuresNames + _eastStructuresNames), 400]) == 0 && _x distance _hq > 700) exitWith {_hqDeployAt = _x};" \n + " } forEach _sortedLocation;" \n + " " \n + " if !(isNull _hqDeployAt) then {" \n + " //--- Location Picked." \n + " _hostileTowns = 0;" \n + " _distance = _hq distance _hqDeployAt;" \n + " {if (_x distance _hq < _distance && ((_x getVariable 'sideID') != _sideID)) then {_hostileTowns = _hostileTowns + 1}} forEach towns;" \n + " " \n + " if (_hostileTowns != 0) then {_hqCanMove = false};" \n + " } else {" \n + " _hqCanMove = false;" \n + " };" \n + " };" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_6 + { + name = "Skip_6"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Commander_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 10"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/aiteam.fsm b/Server/FSM/aiteam.fsm new file mode 100644 index 0000000..62ac00d --- /dev/null +++ b/Server/FSM/aiteam.fsm @@ -0,0 +1,1235 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-81.542984,-257.577942,8.457038,-207.578140,0.000000,"Init"}; +item1[] = {"AI",4,218,-82.819679,-169.595276,7.180347,-119.595261,0.000000,"AI"}; +item2[] = {"Player",4,218,49.705437,-259.537231,139.705353,-209.537186,1.000000,"Player"}; +item3[] = {"End",1,250,321.430817,-171.897736,411.430847,-121.897774,0.000000,"End"}; +item4[] = {"_",-1,250,78.086945,-213.540482,78.086945,-208.131866,0.000000,""}; +item5[] = {"Advanced_Init",2,250,-85.897964,-82.487251,4.102041,-32.487217,0.000000,"Advanced Init"}; +item6[] = {"Loop",4,218,-83.198402,0.114880,6.801598,50.114880,0.000000,"Loop"}; +item7[] = {"",7,210,86.608803,29.398537,94.608841,37.398552,0.000000,""}; +item8[] = {"_",8,218,62.498558,99.618889,94.074371,122.354271,0.000000,""}; +item9[] = {"Towns",4,218,424.040314,260.865143,514.040283,310.865143,1.000000,"Towns"}; +item10[] = {"Check",2,250,-83.027481,86.339714,6.972525,136.339722,0.000000,"Check"}; +item11[] = {"Handle_AI_Mode",2,250,34.021767,145.371872,124.021767,195.371826,0.000000,"Handle" \n "AI Mode"}; +item12[] = {"Handle_Towns",2,4346,645.149963,260.576935,735.150269,310.576996,0.000000,"Handle Towns"}; +item13[] = {"Auto_Move",4,218,156.132660,127.149292,246.132660,177.149307,1.000000,"Auto Move"}; +item14[] = {"Ind_Move",4,218,151.292526,60.816727,241.292587,110.816818,0.000000,"Ind Move"}; +item15[] = {"Handle_Movement",2,250,259.692505,65.755508,349.692505,115.755600,0.000000,"Handle" \n "Movement"}; +item16[] = {"",7,210,783.690674,11.963443,791.690674,19.963448,0.000000,""}; +item17[] = {"Independant",2,250,258.015839,-8.785803,348.015778,41.214260,0.000000,"Independant"}; +item18[] = {"_",8,218,848.837219,4.163350,882.557495,26.575237,0.000000,""}; +item19[] = {"Handle_Buildings",2,250,945.165405,-11.593051,1035.166992,38.406914,0.000000,"Handle Buildings"}; +item20[] = {"Not_Ready",4,218,1100.195435,17.938362,1190.195313,67.938385,0.000000,"Not Ready"}; +item21[] = {"Ready",4,218,1103.682739,-48.457657,1193.682617,1.542370,1.000000,"Ready"}; +item22[] = {"Update_Building",2,250,1231.852661,-47.771744,1321.852783,2.228256,0.000000,"Update Building"}; +item23[] = {"_",8,218,1364.159546,-1.876722,1397.271606,20.541275,0.000000,""}; +item24[] = {"Nil",2,250,1230.162842,18.195518,1320.162720,68.195541,0.000000,"Nil"}; +item25[] = {"Handle_NEURO",2,250,936.365967,410.514252,1026.365967,460.514252,0.000000,"Handle NEURO"}; +item26[] = {"Not_Ready",4,218,786.411011,385.692657,876.411011,435.692657,0.000000,"Not Ready"}; +item27[] = {"Ready",4,218,787.582764,448.519836,877.582764,498.519836,0.000000,"Ready"}; +item28[] = {"Update_NEURO",2,250,666.334106,448.291901,756.334106,498.291901,0.000000,"Update NEURO"}; +item29[] = {"Nil_1",2,250,667.132202,384.425903,757.132202,434.425903,0.000000,"Nil"}; +item30[] = {"_",8,218,594.121155,430.249359,623.907043,450.620209,0.000000,""}; +item31[] = {"Handle_Purchases",2,250,301.274597,414.618500,391.274658,464.618500,0.000000,"Handle" \n "Purchases"}; +item32[] = {"Skip",4,218,181.354340,379.690796,271.354309,429.690796,0.000000,"Skip"}; +item33[] = {"Purchase",4,218,180.375580,442.118439,270.375549,492.118439,0.000000,"Purchase"}; +item34[] = {"Nil_2",2,250,52.676552,379.745789,142.676575,429.745789,0.000000,"Nil"}; +item35[] = {"Handle_Env",2,250,53.368782,440.550720,143.368713,490.550720,0.000000,"Handle Env"}; +item36[] = {"_",8,218,-40.001137,393.311249,-9.106947,416.546387,0.000000,""}; +item37[] = {"Done",2,250,-201.887054,5.574802,-111.887016,55.574814,0.000000,"Done"}; +item38[] = {"Continue",4,218,111.227577,532.703003,201.227600,582.703003,0.000000,"Continue"}; +item39[] = {"Skip",4,218,12.053749,531.477417,102.053658,581.477417,0.000000,"Skip"}; +item40[] = {"",7,210,-160.345612,430.631622,-152.345581,438.631622,0.000000,""}; +item41[] = {"Handle_Purchase",2,250,72.976715,609.960266,162.976746,659.960266,0.000000,"Handle" \n "Purchase"}; +item42[] = {"_",8,218,-166.701218,623.231323,-139.133789,643.141235,0.000000,""}; +item43[] = {"Handle_Move",2,250,600.383606,198.903793,690.383606,248.903793,0.000000,"Handle Move"}; +item44[] = {"Move",4,218,423.396515,198.786560,513.396484,248.786560,0.000000,"Move"}; +item45[] = {"Patrol",4,218,425.609192,137.120514,515.609192,187.120529,0.000000,"Patrol"}; +item46[] = {"Handle_Patrol",2,250,577.069885,137.120560,667.069885,187.120560,0.000000,"Handle Patrol"}; +item47[] = {"Defense",4,218,424.527344,75.454391,514.527283,125.454391,0.000000,"Defense"}; +item48[] = {"Handle_Defense",2,250,557.596313,76.536301,647.596313,126.536301,0.000000,"Handle Defense"}; +item49[] = {"Handle_Injured",2,250,1335.737915,79.091011,1425.737915,129.090988,0.000000,"Handle Injured"}; +item50[] = {"Not_Ready",4,218,1282.343750,173.416992,1372.343750,223.417023,0.000000,"Not Ready"}; +item51[] = {"Ready",4,218,1390.460693,173.416977,1480.460693,223.416962,0.000000,"Ready"}; +item52[] = {"Update_Injured",2,250,1392.124146,264.900574,1482.124146,314.900574,0.000000,"Update Injured"}; +item53[] = {"Nil_3",2,250,1282.343750,263.237244,1372.343750,313.237244,0.000000,"Nil"}; +item54[] = {"_",8,218,1358.857300,424.581024,1397.293823,447.967590,0.000000,""}; +item55[] = {"Check_1",2,250,180.789749,-259.549835,270.789703,-209.549866,0.000000,"Check"}; +item56[] = {"Gameover",4,218,320.254791,-258.390808,410.254761,-208.390778,1.000000,"Gameover"}; +item57[] = {"Idle",4,218,180.499100,-361.358368,270.498993,-311.358368,0.000000,"Idle"}; +item58[] = {"Check_2",2,250,44.078018,-361.358368,134.078003,-311.358368,0.000000,"Check"}; +item59[] = {"Player",4,218,42.931602,-458.802002,132.931793,-408.802002,0.000000,"Player"}; +item60[] = {"AI",4,218,-192.079422,-362.504791,-102.079514,-312.504791,0.000000,"AI"}; +item61[] = {"",7,210,-151.955643,-61.002697,-143.955643,-53.002697,0.000000,""}; +item62[] = {"Wait",2,250,288.260162,-459.948456,378.260162,-409.948456,0.000000,"Wait"}; +item63[] = {"_",8,218,318.144775,-352.061035,349.720581,-329.325653,0.000000,""}; +version=1; +class LayoutItems +{ + class Item4 + { + class ItemInfo + { + FontFace="Arial"; + FontHeight=10; + lStyle=1; + }; + }; +}; +link0[] = {0,1}; +link1[] = {0,2}; +link2[] = {1,5}; +link3[] = {2,55}; +link4[] = {5,6}; +link5[] = {6,10}; +link6[] = {7,2}; +link7[] = {8,11}; +link8[] = {9,12}; +link9[] = {10,7}; +link10[] = {10,8}; +link11[] = {11,13}; +link12[] = {11,14}; +link13[] = {12,16}; +link14[] = {13,15}; +link15[] = {14,17}; +link16[] = {15,9}; +link17[] = {15,44}; +link18[] = {15,45}; +link19[] = {15,47}; +link20[] = {16,18}; +link21[] = {17,16}; +link22[] = {18,19}; +link23[] = {19,20}; +link24[] = {19,21}; +link25[] = {20,24}; +link26[] = {21,22}; +link27[] = {22,23}; +link28[] = {23,49}; +link29[] = {24,23}; +link30[] = {25,26}; +link31[] = {25,27}; +link32[] = {26,29}; +link33[] = {27,28}; +link34[] = {28,30}; +link35[] = {29,30}; +link36[] = {30,31}; +link37[] = {31,32}; +link38[] = {31,33}; +link39[] = {32,34}; +link40[] = {33,35}; +link41[] = {34,36}; +link42[] = {35,38}; +link43[] = {35,39}; +link44[] = {36,40}; +link45[] = {37,6}; +link46[] = {38,41}; +link47[] = {39,40}; +link48[] = {40,37}; +link49[] = {41,42}; +link50[] = {42,40}; +link51[] = {43,16}; +link52[] = {44,43}; +link53[] = {45,46}; +link54[] = {46,16}; +link55[] = {47,48}; +link56[] = {48,16}; +link57[] = {49,50}; +link58[] = {49,51}; +link59[] = {50,53}; +link60[] = {51,52}; +link61[] = {52,54}; +link62[] = {53,54}; +link63[] = {54,25}; +link64[] = {55,56}; +link65[] = {55,57}; +link66[] = {56,3}; +link67[] = {57,58}; +link68[] = {58,59}; +link69[] = {58,60}; +link70[] = {59,62}; +link71[] = {60,61}; +link72[] = {61,5}; +link73[] = {62,63}; +link74[] = {63,55}; +globals[] = {0.000000,0,0,0,0,640,480,1,102,6316128,1,-236.814148,967.257141,522.169556,-528.625977,707,617,1}; +window[] = {0,-1,-1,-32000,-32000,912,175,1588,175,1,725}; +*//*%FSM*/ +class FSM +{ + fsmName = "aiteam"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_team = _this select 0;" \n + "_stored = str _team;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Player + { + priority = 1.000000; + to="Check_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"isPlayer (leader _team) || isNull _team || isNil ""_team"" || gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class AI + { + priority = 0.000000; + to="Advanced_Init"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!(isPlayer (leader _team))"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/"diag_log Format[""[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] aiteam.fsm: Team %1 is null or nil, exiting FSM."",_stored,diag_frameno,diag_tickTime];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Advanced_Init + { + name = "Advanced_Init"; + init = /*%FSM*/"diag_log Format[""[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] aiteam.fsm: Team %1 is ai controlled."",_team,diag_frameno,diag_tickTime];" \n + "" \n + "_side = side _team;" \n + "_sideText = str _side;" \n + "_sideID = (_side) Call GetSideID;" \n + "" \n + "_ccInRange = false;" \n + "_ccr = 'WFBE_COMMANDCENTERRANGE' Call GetNamespace;" \n + "_defenseTime = -120;" \n + "_dr = 'WFBE_DEFENSEMANRANGE' Call GetNamespace;" \n + "_lastBuyType = -1;" \n + "_lastCheckBuilding = -200;" \n + "_lastCheckInjured = -200;" \n + "_lastCheckVehicles = -200;" \n + "_lastCheck = -100;" \n + "_lastCoord = [0,0,0];" \n + "_mbu = 'WFBE_MAXGROUPSIZEAI' Call GetNamespace;" \n + "_minCheckArray = [800,1600,3200,6400];" \n + "_moveAtRunning = false;" \n + "_moveAtLast = objNull;" \n + "_moveAt = objNull;" \n + "_pur = 'WFBE_PURCHASEUNITSRANGE' Call GetNamespace;" \n + "_pr = 'WFBE_PATROLRANGE' Call GetNamespace;" \n + "_templates = Format [""WFBE_%1AITEAMTEMPLATES"",_sideText] Call GetNamespace;" \n + "_templatesRequire = Format [""WFBE_%1AITEAMTEMPLATEREQUIRES"",_sideText] Call GetNamespace;" \n + "_templatesUpgrade = Format [""WFBE_%1AITEAMUPGRADES"",_sideText] Call GetNamespace;" \n + "_town_cvar = """";" \n + "if (('WFBE_TOWNCONQUESTMODE' Call GetNamespace) > 0) then {_town_cvar = if (_side == west) then {""wfbe_cancap_w""} else {""wfbe_cancap_e""}};" \n + "_upgradeLevel = -1;" \n + "_nextPurchase = time + 60 + (random 120);" \n + "" \n + "_buyType = (_team) Call GetTeamType;" \n + "if (_buyType == -1) then {" \n + " _index = round(random(count(_templates) - 1));" \n + " _teamType = _templates select _index;" \n + " _teamRequire = _templatesRequire select _index;" \n + " [_team,_index] Call SetTeamType;" \n + "};" \n + "" \n + "if (isMultiplayer && WF_A2_Vanilla) then {[_side,_team] Spawn AISquadRespawn};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 14;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check + { + name = "Check"; + init = /*%FSM*/"_lastCheck = time + random(1);"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Player + { + priority = 1.000000; + to="Check_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"isPlayer (leader _team) || isNull _team || isNil ""_team"" || gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_AI_Mode"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_AI_Mode + { + name = "Handle_AI_Mode"; + init = /*%FSM*/"_commandMode = _team Call GetTeamAutonomous;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Auto_Move + { + priority = 1.000000; + to="Handle_Movement"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_commandMode"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Ind_Move + { + priority = 0.000000; + to="Independant"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_commandMode"/*%FSM*/; + action=/*%FSM*/"_commandMode"/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Towns + { + name = "Handle_Towns"; + init = /*%FSM*/"if (_moveMode == 'resetTowns') then {" \n + " _moveAtLast = _moveAt;" \n + " _moveAt = objNull;" \n + " _moveAtRunning = false;" \n + " [_team,'towns'] Call SetTeamMoveMode;" \n + "};" \n + "" \n + "if !(isNull _moveAt) then {" \n + " _tsideID = _moveAt getVariable 'sideID';" \n + " if ((leader _team) distance _moveAt < 40 || _tsideID == _sideID) then {" \n + " if (_tsideID == _sideID) then {" \n + " _moveAtLast = _moveAt;" \n + " _moveAt = objNull;" \n + " _moveAtRunning = false;" \n + " };" \n + " };" \n + "};" \n + "" \n + "if (isNull _moveAt) then {" \n + " _moveAt = [leader _team, _side, _town_cvar] Call GetClosestLocationBySide;" \n + "};" \n + "" \n + "if (!isNull _moveAtLast && !isNull _moveAt) then {" \n + " _tlsideID = _moveAtLast getVariable 'sideID';" \n + " if (_tlsideID != _sideID && ((leader _team) distance _moveAt > (leader _team) distance _moveAtLast)) then {" \n + " _moveAtLast = _moveAt;" \n + " _moveAt = objNull;" \n + " _moveAtRunning = false;" \n + " };" \n + "};" \n + "" \n + "if (!isNull _moveAt && !_moveAtRunning) then {" \n + " /* Use a smart system to attack a town, AI Commander deal with the teams sync if needed. */" \n + " _wporigin = getPos (leader _team);" \n + " _wpdest = getPos _moveAt;" \n + " " \n + " _update = (_team) Call CanUpdateTeam;" \n + " if (_update) then {_team Call UpdateTeam};" \n + " " \n + " _cleanWP = true;" \n + " " \n + " if (_wporigin distance _wpdest > 550) then {" \n + " _percent = 1 - (550 / (_wporigin distance _wpdest));" \n + "" \n + " _x = (_wporigin select 0) + _percent * ((_wpdest select 0) - (_wporigin select 0));" \n + " _y = (_wporigin select 1) + _percent * ((_wpdest select 1) - (_wporigin select 1));" \n + " " \n + " /* Create the first move order to the town's border */" \n + " _wppos = [[_x,_y,0], 0, 75] Call GetRandomPosition;" \n + " [_team,true,[[_wppos, 'MOVE', 40, 20, """", [""true"", ""nullReturn = (this) Spawn NEURO_BE_HandleArrivalCargo""]]]] Call AIWPAdd;" \n + " _cleanWP = false;" \n + " };" \n + " " \n + " [_team,_cleanWP,[[_moveAt, 'SCRIPTED', 35, 20, 'Server\AI\AI_TLWPHandler.sqs',[]]]] Call AIWPAdd;" \n + " [_team,false,[[_moveAt, 'SAD', 35, 20, """", []]]] Call AIWPAdd;" \n + " [_team,_moveAt] Call SetTeamMovePos;" \n + " " \n + " _moveAtRunning = true;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Buildings"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Movement + { + name = "Handle_Movement"; + init = /*%FSM*/"_moveMode = _team Call GetTeamMoveMode;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Towns + { + priority = 1.000000; + to="Handle_Towns"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_moveMode == 'towns' || _moveMode == 'resetTowns'"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Patrol + { + priority = 0.000000; + to="Handle_Patrol"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_moveMode == 'patrol' || _moveMode == 'resetPatrol'"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Defense + { + priority = 0.000000; + to="Handle_Defense"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_moveMode == 'defense' || _moveMode == 'resetDefense'"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Move + { + priority = 0.000000; + to="Handle_Move"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_moveMode == 'move' || _moveMode == 'resetMove'"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Independant + { + name = "Independant"; + init = /*%FSM*/"_moveAt = objNull;" \n + "_moveAtLast = objNull;" \n + "_moveAtRunning = false;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Buildings"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Buildings + { + name = "Handle_Buildings"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Ready + { + priority = 1.000000; + to="Update_Building"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheckBuilding >= 29"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Not_Ready + { + priority = 0.000000; + to="Nil"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheckBuilding < 29"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Building + { + name = "Update_Building"; + init = /*%FSM*/"_lastCheckBuilding = time;" \n + "" \n + "_purchaseRange = if (_ccInRange) then {_ccr} else {_pur};" \n + "_buildings = (_sideText) Call GetSideStructures;" \n + "" \n + "_check = ['BARRACKSTYPE',_buildings,_purchaseRange,_side,leader _team] Call BuildingInRange;" \n + "_barrack = _check;" \n + "_barracksInRange = if (isNull _check) then {false} else {true};" \n + "" \n + "_check = ['LIGHTTYPE',_buildings,_purchaseRange,_side,leader _team] Call BuildingInRange;" \n + "_light = _check;" \n + "_lightInRange = if (isNull _check) then {false} else {true};" \n + "" \n + "_check = ['HEAVYTYPE',_buildings,_purchaseRange,_side,leader _team] Call BuildingInRange;" \n + "_heavy = _check;" \n + "_heavyInRange = if (isNull _check) then {false} else {true};" \n + "" \n + "_check = ['AIRCRAFTTYPE',_buildings,_purchaseRange,_side,leader _team] Call BuildingInRange;" \n + "_air = _check;" \n + "_airInRange = if (isNull _check) then {false} else {true};" \n + "" \n + "_check = ['COMMANDCENTERTYPE',_buildings,_ccr,_side,leader _team] Call BuildingInRange;" \n + "_ccInRange = if (isNull _check) then {false} else {true};" \n + "" \n + "_buildingArray = [_barrack,_light,_heavy,_air];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Injured"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Nil + { + name = "Nil"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Injured"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_NEURO + { + name = "Handle_NEURO"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Ready + { + priority = 0.000000; + to="Update_NEURO"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"(time - _lastCheckVehicles >= 30) && !paramUPSMON"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Not_Ready + { + priority = 0.000000; + to="Nil_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"(time - _lastCheckVehicles < 30) || paramUPSMON"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_NEURO + { + name = "Update_NEURO"; + init = /*%FSM*/"_lastCheckVehicles = time;" \n + "" \n + "_vehicles = [_team, false] Call GetTeamVehicles;" \n + "" \n + "//--- Update the Path." \n + "(_team) Call NEURO_BE_UpdateTeamDestination;" \n + "" \n + "//--- Update NEURO transportation." \n + "_canAssign = true;" \n + "" \n + "//--- NEURO Security, AI don't need to get in when they are taking a town." \n + "if (_moveMode == 'towns') then {" \n + " if (leader _team distance _moveAt < 700) then {_canAssign = false};" \n + "};" \n + "" \n + "if (_canAssign) then {[_team, getPos leader _team] Call NEURO_BE_AssignToVehicle};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Purchases"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Nil_1 + { + name = "Nil_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Purchases"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Purchases + { + name = "Handle_Purchases"; + init = /*%FSM*/"_size = Count ((units _team) Call GetLiveUnits);" \n + "_globalQueu = _team getVariable ""queue"";" \n + "if (isNil ""_globalQueu"") then {_globalQueu = []};" \n + "_cpt = count _globalQueu;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Purchase + { + priority = 0.000000; + to="Handle_Env"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"(_cpt + _size) <= _mbu && alive (leader _team) && time > _nextPurchase"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Nil_2"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"(_cpt + _size) > _mbu || time <= _nextPurchase"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Nil_2 + { + name = "Nil_2"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Done"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Env + { + name = "Handle_Env"; + init = /*%FSM*/"_buyType = (_team) Call GetTeamType;" \n + "" \n + "_teamType = _templates select _buyType;" \n + "_teamRequire = _templatesRequire select _buyType;" \n + "_teamUpgrade = _templatesUpgrade select _buyType;" \n + "" \n + "_upgrades = (_sideText) Call GetSideUpgrades;" \n + "" \n + "_barrackUpLevel = _upgrades select 0;" \n + "_lightUpLevel = _upgrades select 1;" \n + "_heavyUpLevel = _upgrades select 2;" \n + "_airUpLevel = _upgrades select 3;" \n + "" \n + "_upArray = [_barrackUpLevel,_lightUpLevel,_heavyUpLevel,_airUpLevel];" \n + "_funds = _team Call GetTeamFunds;" \n + "" \n + "_canBuy = true;" \n + "for '_i' from 0 to 3 do {" \n + " if ((_upArray select _i) < (_teamUpgrade select _i)) then {" \n + " _canBuy = false;" \n + " } else {" \n + " if (_teamRequire select _i) then {" \n + " if (_funds < (_minCheckArray select _i)) then {" \n + " _canBuy = false;" \n + " };" \n + " };" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Done"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_canBuy"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Continue + { + priority = 0.000000; + to="Handle_Purchase"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_canBuy"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Done + { + name = "Done"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 14;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Purchase + { + name = "Handle_Purchase"; + init = /*%FSM*/"_nextPurchase = time + 60 + (random 120);" \n + "" \n + "_buyType = (_team) Call GetTeamType;" \n + "if (_lastBuyType != _buyType) then {" \n + " if (_buyType != -1) then {" \n + " _teamType = _templates select _buyType;" \n + " _teamRequire = _templatesRequire select _buyType;" \n + " };" \n + " _lastBuyType = _buyType;" \n + "};" \n + "" \n + "//--- Final types." \n + "_types = +_teamType;" \n + "" \n + "//--- Prevent class stacking, use an existing type compare system." \n + "_units = (units _team) Call GetLiveUnits;" \n + "_units = _units + ([_team, true] Call GetTeamVehicles);" \n + "_typesU = [];" \n + "{_typesU = _typesU + [typeOf _x]} forEach _units;" \n + "" \n + "_difference = round(_mbu / count _types);" \n + "_maxAllowed = [];" \n + "" \n + "for '_i' from 0 to count(_types)-1 do {" \n + " _type = _types select _i;" \n + " //--- IMPORTANT TODO: Do the godamn ratio for each vehicle over the count of teamtypes. 4 = 20% each" \n + " _maxAllowed set [_i, _difference - ({_x == _type} count _typesU)];" \n + "};" \n + "" \n + "for '_i' from 0 to count(_maxAllowed) do {" \n + " if ((_maxAllowed select _i) <= 0) then {" \n + " _maxAllowed set [_i, -1];" \n + " _types set [_i, -1];" \n + " };" \n + "};" \n + "" \n + "//--- We remove the unecessary types." \n + "_types = _types - [-1];" \n + "_maxAllowed = _maxAllowed - [-1];" \n + "" \n + "if (count _types > 0) then {" \n + " //--- Use CIPHER module to order the array with priority." \n + " _types = ([_maxAllowed, true, _types] Call CIPHER_SortArray) select 1;" \n + "};" \n + "" \n + "//--- Define the needs." \n + "_needs = [];" \n + "if (_teamRequire select 0) then {_needs = _needs + [_barracksInRange]};" \n + "if (_teamRequire select 1) then {_needs = _needs + [_lightInRange]};" \n + "if (_teamRequire select 2) then {_needs = _needs + [_heavyInRange]};" \n + "if (_teamRequire select 3) then {_needs = _needs + [_airInRange]};" \n + "_canBuy = true;" \n + "{if (!_x) then {_canBuy = false}} forEach _needs;" \n + "" \n + "//--- Team purchases." \n + "if (_canBuy) then {" \n + " _upgrades = (_sideText) Call GetSideUpgrades;" \n + " {" \n + " _buyFrom = objNull;" \n + " _kindDetail = _x Call GetNamespace;" \n + " if !(isNil '_kindDetail') then {" \n + " _crews = _kindDetail select QUERYUNITCREW;" \n + " _price = _kindDetail select QUERYUNITPRICE;" \n + " _upgradeRequired = _kindDetail select QUERYUNITUPGRADE;" \n + " _unitType = _kindDetail select QUERYUNITFACTORY;" \n + " switch (_unitType) do {" \n + " case 0: {" \n + " _buyFrom = _barrack;" \n + " _upgradeLevel = 0;" \n + " };" \n + " case 1: {" \n + " _buyFrom = _light;" \n + " _upgradeLevel = 1;" \n + " };" \n + " case 2: {" \n + " _buyFrom = _heavy;" \n + " _upgradeLevel = 2;" \n + " };" \n + " case 3: {" \n + " _buyFrom = _air;" \n + " _upgradeLevel = 2;" \n + " };" \n + " };" \n + " if !(isNull _buyFrom) then {" \n + " _upgradeStatus = _upgrades select _upgradeLevel;" \n + " _globalQueu = +(_team getVariable ""queue"");" \n + " if (isNil ""_globalQueu"") then {_globalQueu = []};" \n + " if ((count _globalQueu) + _size < _mbu && _funds > _price && _upgradeStatus >= _upgradeRequired) then {" \n + " _vehiSlots = [true,false,false,false];" \n + " _IDS = []; " \n + " if !(_x isKindOf ""Man"") then {" \n + " if (typeName _crews == ""ARRAY"") then {" \n + " if (_crews select 0) then {_vehiSlots set [2, true]};" \n + " if (_crews select 1) then {_vehiSlots set [1, true]};" \n + " if ((_crews select 3) > 0) then {_vehiSlots set [3, true]};" \n + " " \n + " {" \n + " _ran = round(2000 + random(10) + random (100) + random(1000));" \n + " _globalQueu set [count _globalQueu, _ran];" \n + " _IDS set [count _IDS, _ran];" \n + " } forEach _vehiSlots;" \n + " } else {" \n + " if (_crews < 3 && _crews != 1) then {" \n + " _ran2 = round(2000 + random(10) + random (100) + random(1000));" \n + " _globalQueu = _globalQueu + [_ran2];" \n + " _vehiSlots = [true,true,false];" \n + " _IDS = _IDS + [_ran2];" \n + " };" \n + " if (_crews > 2) then {" \n + " _ran2 = round(2000 + random(10) + random (100) + random(1000));" \n + " _ran3 = round(2000 + random(10) + random (100) + random(1000));" \n + " _globalQueu = _globalQueu + [_ran2,_ran3];" \n + " _vehiSlots = [true,true,true];" \n + " _IDS = _IDS + [_ran2,_ran3];" \n + " };" \n + " };" \n + " } else {" \n + " _ran = round(2000 + random(10) + random (100) + random(1000));" \n + " _IDS = [_ran];" \n + " _globalQueu = _globalQueu + [_ran];" \n + " };" \n + " [_IDS,_buyFrom,_x,_side,_team,_vehiSlots] Spawn AIBuyUnit;" \n + " [_team,-_price] Call ChangeTeamFunds;" \n + " _team setVariable [""queue"", _globalQueu];" \n + " };" \n + " };" \n + " } else {" \n + " diag_log Format[""[WFBE (ERROR)][frameno:%2 | ticktime:%3] aiteam.fsm: Element %1 is not defined within the core system."",_x,diag_frameno,diag_tickTime];" \n + " };" \n + " } forEach _types;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Done"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Move + { + name = "Handle_Move"; + init = /*%FSM*/"if (_moveMode == 'resetMove') then {" \n + " _lastCoord = [0,0,0];" \n + " [_team,'move'] Call SetTeamMoveMode;" \n + "};" \n + "" \n + "_coord = (_team) Call GetTeamMovePos;" \n + "if ((_coord select 0 != _lastCoord select 0)&&(_coord select 1 != _lastCoord select 1)) then {" \n + " _lastCoord = _coord;" \n + " _update = (_team) Call CanUpdateTeam;" \n + " if (_update) then {_team Call UpdateTeam};" \n + " [_team,true,[[_coord, 'MOVE', 40, 20, """", []]]] Call AIWPAdd;" \n + "" \n + " _moveAtLast = _moveAt;" \n + " _moveAt = objNull;" \n + " _moveAtRunning = false;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Buildings"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Patrol + { + name = "Handle_Patrol"; + init = /*%FSM*/"if (_moveMode == 'resetPatrol') then {" \n + " _lastCoord = [0,0,0];" \n + " [_team,'patrol'] Call SetTeamMoveMode;" \n + "};" \n + "" \n + "_coord = (_team) Call GetTeamMovePos;" \n + "if ((_coord select 0 != _lastCoord select 0)&&(_coord select 1 != _lastCoord select 1)) then {" \n + " _lastCoord = _coord;" \n + " [_team,_coord,_pr] Call AIPatrol;" \n + "" \n + " _moveAtLast = _moveAt;" \n + " _moveAt = objNull;" \n + " _moveAtRunning = false;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Buildings"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Defense + { + name = "Handle_Defense"; + init = /*%FSM*/"if (_moveMode == 'resetDefense') then {" \n + " _lastCoord = [0,0,0];" \n + " [_team,'defense'] Call SetTeamMoveMode;" \n + "};" \n + "" \n + "_coord = (_team) Call GetTeamMovePos;" \n + "if ((_coord select 0 != _lastCoord select 0)&&(_coord select 1 != _lastCoord select 1)) then {" \n + " _lastCoord = _coord;" \n + " [_team,_coord,_pr] Call AIPatrol;" \n + "" \n + " _moveAtLast = _moveAt;" \n + " _moveAt = objNull;" \n + " _moveAtRunning = false;" \n + "};" \n + "" \n + "if (time - _defenseTime > 60) then {" \n + " _defenseTime = time;" \n + " [units _team,_dr] Call UseStationaryDefense;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_Buildings"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Handle_Injured + { + name = "Handle_Injured"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Ready + { + priority = 0.000000; + to="Update_Injured"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheckInjured >= 119"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Not_Ready + { + priority = 0.000000; + to="Nil_3"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheckInjured < 119"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Injured + { + name = "Update_Injured"; + init = /*%FSM*/"_lastCheckInjured = time;" \n + "" \n + "_alives = (units _team) Call GetLiveUnits;" \n + "" \n + "{" \n + " if (vehicle _x == _x) then {" \n + " if !(canStand _x) then {" \n + " _x playMove ""amovppnemstpsraswrfldnon_healed"";" \n + " _x setDammage 0;" \n + " };" \n + " };" \n + "} forEach _alives;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_NEURO"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Nil_3 + { + name = "Nil_3"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Handle_NEURO"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_1 + { + name = "Check_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 1.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver || isNil ""_team"" || isNull _team"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Idle + { + priority = 0.000000; + to="Check_2"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && !isNull _team"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_2 + { + name = "Check_2"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class AI + { + priority = 0.000000; + to="Advanced_Init"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!isPlayer (leader _team)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Player + { + priority = 0.000000; + to="Wait"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"isPlayer (leader _team)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Wait + { + name = "Wait"; + init = /*%FSM*/"_wait = time + 20;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _wait"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/allies.fsm b/Server/FSM/allies.fsm new file mode 100644 index 0000000..e2248b4 --- /dev/null +++ b/Server/FSM/allies.fsm @@ -0,0 +1,274 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Allies_Init",0,250,-44.418510,-87.799530,45.581596,-37.799454,0.000000,"Allies" \n "Init"}; +item1[] = {"loop",4,218,-43.082561,-10.971841,46.917431,39.028156,0.000000,"loop"}; +item2[] = {"Check",2,4346,-190.853607,-12.100532,-100.853592,37.899467,0.000000,"Check"}; +item3[] = {"done",4,218,-314.399872,-10.889294,-224.399902,39.110706,0.000000,"done"}; +item4[] = {"end",1,250,-315.611145,69.052460,-225.611130,119.052437,0.000000,"end"}; +link0[] = {0,1}; +link1[] = {1,2}; +link2[] = {2,1}; +link3[] = {2,3}; +link4[] = {3,4}; +globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-472.927826,92.799797,435.032471,-147.570496,704,720,1}; +window[] = {0,-1,-1,-1,-1,945,231,1576,105,1,722}; +*//*%FSM*/ +class FSM +{ + fsmName = "allies"; + class States + { + /*%FSM*/ + class Allies_Init + { + name = "Allies_Init"; + init = /*%FSM*/"_side = _this select 0;" \n + "_sideText = str _side;" \n + "_timeStart = time;" \n + "" \n + "_startingLocation = Call Compile Format [""%1StartingLocation"",_sideText];" \n + "_nearest = [_startingLocation,(startingLocations - [_startingLocation])] Call SortByDistance;" \n + "_allysLoc = _nearest select 0;" \n + "" \n + "_types = if (_side == west) then {[""CDF_WarfareBBarracks"",""CDF_WarfareBLightFactory"",""CDF_WarfareBUAVterminal"",""CDF_WarfareBHeavyFactory"",""CDF_WarfareBAircraftFactory"",""CDF_WarfareBVehicleServicePoint""]} else {[""Ins_WarfareBBarracks"",""Ins_WarfareBLightFactory"",""Ins_WarfareBUAVterminal"",""Ins_WarfareBHeavyFactory"",""Ins_WarfareBAircraftFactory"",""Ins_WarfareBVehicleServicePoint""]};" \n + "_structureRelPos = [[75,75],[-75,75],[75,0],[75,-75],[-75,-75],[-75,0]];" \n + "_structurePos = [[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]];" \n + "_structureLabel = [""B"",""L"",""C"",""H"",""A"",""S""];" \n + "_alives = [];" \n + "" \n + "_checkNeeds = {" \n + " Private [""_building"",""_canBuy"",""_needs"",""_require""];" \n + " _require = _this select 0;" \n + " _building = _this select 1;" \n + " _needs = [];" \n + " if (_require select 0) then {_needs = _needs + [alive (_building select 0)]};" \n + " if (_require select 1) then {_needs = _needs + [alive (_building select 1)]};" \n + " if (_require select 2) then {_needs = _needs + [alive (_building select 2)]};" \n + " if (_require select 3) then {_needs = _needs + [alive (_building select 3)]};" \n + " _canBuy = true;" \n + " {if (!_x) then {_canBuy = false}} forEach _needs;" \n + " _canBuy" \n + "};" \n + "" \n + "for [{_count = 0},{_count < (count _types)},{_count = _count + 1}] do {" \n + " _type = _types select _count;" \n + " _x = getPos _allysLoc select 0;" \n + " _y = getPos _allysLoc select 1;" \n + " _pos = [];" \n + " _pos set [0,((_structureRelPos select _count) select 0) + _x];" \n + " _pos set [1,((_structureRelPos select _count) select 1) + _y];" \n + " _newPos = [0,0,0];" \n + " _roads = [];" \n + " _continue = true;" \n + " while {_continue} do {" \n + " _newPos = [_pos,30,100,10,0,50,0] Call BIS_fnc_findSafePos;" \n + " _roads = _newPos nearRoads 60;" \n + " _isTooClose = false;" \n + " {if (_x distance _newPos < 70) then {_isTooClose = true}} forEach _structurePos;" \n + " if (count _roads == 0 || _isTooClose) then {_continue = false};" \n + " };" \n + " _structurePos set [_count, _newPos];" \n + " _building = _type createVehicle (_structurePos select _count);" \n + " _building setVehicleInit Format[""[this,false,%1,'%2'] ExecVM 'Client\Init\Init_BaseStructure.sqf'"",_side,_structureLabel select _count];" \n + " processInitCommands;" \n + " if (_count in [0,1,3,4]) then {_alives = _alives + [_building]};" \n + "};" \n + "" \n + "_barrack = _alives select 0;" \n + "_light = _alives select 1;" \n + "_heavy = _alives select 2;" \n + "_air = _alives select 3;" \n + "" \n + "_alliesTemplates = Format[""WFBE_%1ALLIESTEAMTEMPLATES"",_sideText] Call GetNamespace;" \n + "_alliesTemplatesRequire = Format[""WFBE_%1ALLIESTEAMTEMPLATEREQUIRES"",_sideText] Call GetNamespace;" \n + "_alliesTemplatesTypes = Format[""WFBE_%1ALLIESTEAMTYPES"",_sideText] Call GetNamespace;" \n + "_alliesTemplatesCost = Format[""WFBE_%1ALLIESTEAMCOST"",_sideText] Call GetNamespace;" \n + "" \n + "_barracksTemplate = [];" \n + "_lightTemplate = [];" \n + "_heavyTemplate = [];" \n + "_airTemplate = [];" \n + "_o = 0;" \n + "{" \n + " if (_alliesTemplatesTypes select _o == 0) then {_barracksTemplate = _barracksTemplate + [_o]};" \n + " if (_alliesTemplatesTypes select _o == 1) then {_lightTemplate = _lightTemplate + [_o]};" \n + " if (_alliesTemplatesTypes select _o == 2) then {_heavyTemplate = _heavyTemplate + [_o]};" \n + " if (_alliesTemplatesTypes select _o == 3) then {_airTemplate = _airTemplate + [_o]};" \n + " _o = _o + 1;" \n + "} forEach _alliesTemplates;" \n + "" \n + "WF_Logic setVariable [Format[""%1TeamInfA"",_sideText],false];" \n + "WF_Logic setVariable [Format[""%1TeamInfB"",_sideText],false];" \n + "WF_Logic setVariable [Format[""%1TeamVehA"",_sideText],false];" \n + "WF_Logic setVariable [Format[""%1TeamHVehA"",_sideText],false];" \n + "WF_Logic setVariable [Format[""%1TeamAVehA"",_sideText],false];" \n + "" \n + "_minInfFunds = 2000;" \n + "_minLightFunds = 5000;" \n + "_minHeavyFunds = 8000;" \n + "_minAirFunds = 40000;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class loop + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _timeStart > 60"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check + { + name = "Check"; + init = /*%FSM*/"_timeStart = time;" \n + "" \n + "_funds = Call Compile Format [""%1AlliesFunds"",_sideText];" \n + "" \n + "_teamInfAAlive = WF_Logic getVariable Format[""%1TeamInfA"",_sideText];" \n + "_teamInfBAlive = WF_Logic getVariable Format[""%1TeamInfB"",_sideText];" \n + "_teamVehAAlive = WF_Logic getVariable Format[""%1TeamVehA"",_sideText];" \n + "_teamHVehAAlive = WF_Logic getVariable Format[""%1TeamHVehA"",_sideText];" \n + "_teamAVehAAlive = WF_Logic getVariable Format[""%1TeamAVehA"",_sideText];" \n + "" \n + "if (!_teamInfAAlive) then {" \n + " if (_funds > _minInfFunds) then {" \n + " _ranTemp = _barracksTemplate select round(random((count _barracksTemplate)-1));" \n + " _templateToUse = _alliesTemplates select _ranTemp;" \n + " _templateRequire = _alliesTemplatesRequire select _ranTemp;" \n + " _templateCost = _alliesTemplatesCost select _ranTemp;" \n + " " \n + " _canBuy = [_templateRequire,_alives] Call _checkNeeds;" \n + " " \n + " if (_funds > _templateCost && _canBuy) then {" \n + " Call Compile Format [""%1AlliesFunds = %1AlliesFunds - _templateCost"",_sideText];" \n + " _funds = Call Compile Format [""%1AlliesFunds"",_sideText];" \n + " [_side,_templateToUse,_templateRequire,_alives,Format[""%1TeamInfA"",_sideText]] ExecFSM ""Server\FSM\allies_team.fsm"";" \n + " WF_Logic setVariable [Format[""%1TeamInfA"",_sideText],true];" \n + " };" \n + " };" \n + "};" \n + "" \n + "if (!_teamInfBAlive) then {" \n + " if (_funds > _minInfFunds) then {" \n + " _ranTemp = _barracksTemplate select round(random((count _barracksTemplate)-1));" \n + " _templateToUse = _alliesTemplates select _ranTemp;" \n + " _templateRequire = _alliesTemplatesRequire select _ranTemp;" \n + " _templateCost = _alliesTemplatesCost select _ranTemp;" \n + " " \n + " _canBuy = [_templateRequire,_alives] Call _checkNeeds;" \n + " " \n + " if (_funds > _templateCost && _canBuy) then {" \n + " Call Compile Format [""%1AlliesFunds = %1AlliesFunds - _templateCost"",_sideText];" \n + " _funds = Call Compile Format [""%1AlliesFunds"",_sideText];" \n + " [_side,_templateToUse,_templateRequire,_alives,Format[""%1TeamInfB"",_sideText]] ExecFSM ""Server\FSM\allies_team.fsm"";" \n + " WF_Logic setVariable [Format[""%1TeamInfB"",_sideText],true];" \n + " };" \n + " };" \n + "};" \n + "" \n + "if (!_teamVehAAlive) then {" \n + " if (_funds > _minLightFunds) then {" \n + " _ranTemp = _lightTemplate select round(random((count _lightTemplate)-1));" \n + " _templateToUse = _alliesTemplates select _ranTemp;" \n + " _templateRequire = _alliesTemplatesRequire select _ranTemp;" \n + " _templateCost = _alliesTemplatesCost select _ranTemp;" \n + " " \n + " _canBuy = [_templateRequire,_alives] Call _checkNeeds;" \n + " " \n + " if (_funds > _templateCost && _canBuy) then {" \n + " Call Compile Format [""%1AlliesFunds = %1AlliesFunds - _templateCost"",_sideText];" \n + " _funds = Call Compile Format [""%1AlliesFunds"",_sideText];" \n + " [_side,_templateToUse,_templateRequire,_alives,Format[""%1TeamVehA"",_sideText]] ExecFSM ""Server\FSM\allies_team.fsm"";" \n + " WF_Logic setVariable [Format[""%1TeamVehA"",_sideText],true];" \n + " };" \n + " };" \n + "};" \n + "" \n + "if (!_teamHVehAAlive) then {" \n + " if (_funds > _minHeavyFunds) then {" \n + " _ranTemp = _heavyTemplate select round(random((count _heavyTemplate)-1));" \n + " _templateToUse = _alliesTemplates select _ranTemp;" \n + " _templateRequire = _alliesTemplatesRequire select _ranTemp;" \n + " _templateCost = _alliesTemplatesCost select _ranTemp;" \n + " " \n + " _canBuy = [_templateRequire,_alives] Call _checkNeeds;" \n + "" \n + " if (_funds > _templateCost && _canBuy) then {" \n + " Call Compile Format [""%1AlliesFunds = %1AlliesFunds - _templateCost"",_sideText];" \n + " _funds = Call Compile Format [""%1AlliesFunds"",_sideText];" \n + " [_side,_templateToUse,_templateRequire,_alives,Format[""%1TeamHVehA"",_sideText]] ExecFSM ""Server\FSM\allies_team.fsm"";" \n + " WF_Logic setVariable [Format[""%1TeamHVehA"",_sideText],true];" \n + " };" \n + " };" \n + "};" \n + "" \n + "if (!_teamAVehAAlive) then {" \n + " if (_funds > _minAirFunds) then {" \n + " _ranTemp = _airTemplate select round(random((count _airTemplate)-1));" \n + " _templateToUse = _alliesTemplates select _ranTemp;" \n + " _templateRequire = _alliesTemplatesRequire select _ranTemp;" \n + " _templateCost = _alliesTemplatesCost select _ranTemp;" \n + " " \n + " _canBuy = [_templateRequire,_alives] Call _checkNeeds;" \n + " " \n + " if (_funds > _templateCost && _canBuy) then {" \n + " Call Compile Format [""%1AlliesFunds = %1AlliesFunds - _templateCost"",_sideText];" \n + " _funds = Call Compile Format [""%1AlliesFunds"",_sideText];" \n + " [_side,_templateToUse,_templateRequire,_alives,Format[""%1TeamAVehA"",_sideText]] ExecFSM ""Server\FSM\allies_team.fsm"";" \n + " WF_Logic setVariable [Format[""%1TeamAVehA"",_sideText],true];" \n + " };" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class done + { + priority = 0.000000; + to="end"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver || ({alive _x} count _alives) == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class loop + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _timeStart > 60"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class end + { + name = "end"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + }; + initState="Allies_Init"; + finalStates[] = + { + "end" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/allies_team.fsm b/Server/FSM/allies_team.fsm new file mode 100644 index 0000000..43d5a2b --- /dev/null +++ b/Server/FSM/allies_team.fsm @@ -0,0 +1,184 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Allies_Init",0,4346,-44.418510,-87.799530,45.581596,-37.799454,0.000000,"Allies" \n "Init"}; +item1[] = {"loop",4,218,-43.082561,-10.971841,46.917431,39.028156,0.000000,"loop"}; +item2[] = {"Check",2,250,-190.853607,-12.100532,-100.853592,37.899467,0.000000,"Check"}; +item3[] = {"done",4,218,-314.399872,-10.889294,-224.399902,39.110706,0.000000,"done"}; +item4[] = {"end",1,250,-315.611145,69.052460,-225.611130,119.052437,0.000000,"end"}; +link0[] = {0,1}; +link1[] = {1,2}; +link2[] = {2,1}; +link3[] = {2,3}; +link4[] = {3,4}; +globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-440.874512,60.746586,402.023224,-114.561028,704,695,1}; +window[] = {0,-1,-1,-1,-1,915,75,1420,75,1,722}; +*//*%FSM*/ +class FSM +{ + fsmName = "allies_team"; + class States + { + /*%FSM*/ + class Allies_Init + { + name = "Allies_Init"; + init = /*%FSM*/"_side = _this select 0;" \n + "_template = _this select 1;" \n + "_templateRequire = _this select 2;" \n + "_buildings = _this select 3;" \n + "_status = _this select 4;" \n + "" \n + "_barrack = _buildings select 0;" \n + "_light = _buildings select 1;" \n + "_heavy = _buildings select 2;" \n + "_air = _buildings select 3;" \n + "" \n + "_destination = objNull;" \n + "_lastDestination = objNull;" \n + "_orderComplete = true;" \n + "_timeStart = time;" \n + "_end = false;" \n + "" \n + "_team = createGroup _side;" \n + "" \n + "{" \n + " _buyFrom = objNull;" \n + " _kind = (Format[""WFBE_%1ALLIESBARRACKSUNITS"",str _side] Call GetNamespace) find _x;" \n + " _kindDetail = _x Call GetNamespace;" \n + " _crews = _kindDetail select QUERYUNITCREW;" \n + " _unitType = _kindDetail select QUERYUNITFACTORY;" \n + " switch (_unitType) do {" \n + " case 0: {" \n + " _buyFrom = _barrack;" \n + " };" \n + " case 1: {" \n + " _buyFrom = _light;" \n + " };" \n + " case 2: {" \n + " _buyFrom = _heavy;" \n + " };" \n + " case 3: {" \n + " _buyFrom = _air;" \n + " };" \n + " };" \n + " if !(isNull _buyFrom) then {" \n + " _vehiSlots = [true,false,false,false];" \n + " _IDS = []; " \n + " if !(_x isKindOf ""Man"") then {" \n + " if (typeName _crews == ""ARRAY"") then {" \n + " if (_crews select 0) then {_vehiSlots set [2, true]};" \n + " if (_crews select 1) then {_vehiSlots set [1, true]};" \n + " if ((_crews select 3) > 0) then {_vehiSlots set [3, true]};" \n + " " \n + " {" \n + " _ran = 2000 + random(10) + random (100) + random(1000);" \n + " _IDS set [count _IDS, _ran];" \n + " } forEach _vehiSlots;" \n + " } else {" \n + " if (_crews < 3 && _crews != 1) then {" \n + " _ran2 = 2000 + random(10) + random (100) + random(1000);" \n + " _vehiSlots = [true,true,false];" \n + " _IDS = _IDS + [_ran2];" \n + " };" \n + " if (_crews > 2) then {" \n + " _ran2 = 2000 + random(10) + random (100) + random(1000);" \n + " _ran3 = 2000 + random(10) + random (100) + random(1000);" \n + " _vehiSlots = [true,true,true];" \n + " _IDS = _IDS + [_ran2] + [_ran3];" \n + " };" \n + " };" \n + " };" \n + " [_IDS,_buyFrom,_x,_side,_team,_vehiSlots] Spawn AlliesBuyUnit;" \n + " };" \n + "} forEach _template;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class loop + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_end && time - _timeStart > 120 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check + { + name = "Check"; + init = /*%FSM*/"_timeStart = time;" \n + "" \n + "_alives = (units _team) Call GetLiveUnits;" \n + "_end = if (count _alives > 0) then {false} else {true};" \n + "" \n + "if ((leader _team) distance _destination < 30) then {" \n + " _locationSide = (_destination getVariable ""sideID"") Call GetSideFromID;" \n + " if (_locationSide == _side) then {_orderComplete = true;_lastDestination = _destination};" \n + "};" \n + "if (((_destination getVariable ""sideID"") Call GetSideFromID) == _side) then {_orderComplete = true;_lastDestination = _destination};" \n + "if (!isNull(_lastDestination)) then {if (((_lastDestination getVariable ""sideID"") Call GetSideFromID) != _side) then {_orderComplete = true}};" \n + "" \n + "if (_orderComplete) then {" \n + " _destinations = [];" \n + " {" \n + " _locationSide = (_x getVariable ""sideID"") Call GetSideFromID;" \n + " if (_locationSide != _side) then {_destinations = _destinations + [_x]};" \n + " } forEach towns;" \n + " if (count _destinations > 0) then {" \n + " _orderComplete = false;" \n + " _loc = [leader _team,_destinations] Call SortByDistance;" \n + " _destination = _loc select 0;" \n + " [_team,_destination,""move""] Call AIMoveTo;" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class done + { + priority = 0.000000; + to="end"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver || _end"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class loop + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_end && time - _timeStart > 120 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class end + { + name = "end"; + init = /*%FSM*/"WF_Logic setVariable [_status,false];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + }; + initState="Allies_Init"; + finalStates[] = + { + "end" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/basearea.fsm b/Server/FSM/basearea.fsm new file mode 100644 index 0000000..177e28d --- /dev/null +++ b/Server/FSM/basearea.fsm @@ -0,0 +1,141 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-81.542984,-257.577942,8.457038,-207.578140,0.000000,"Init"}; +item1[] = {"End",1,250,-216.387955,-52.508366,-126.387947,-2.508394,0.000000,"End"}; +item2[] = {"Update_Areas",2,4346,-82.090652,-139.314026,7.909359,-89.314034,0.000000,"Update Areas"}; +item3[] = {"Loop",4,218,53.846153,-139.681244,143.846161,-89.681236,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-216.387955,-139.464890,-126.387947,-89.464890,0.000000,"Gameover"}; +item5[] = {"_",8,218,-51.736092,-184.192123,-21.083296,-163.272247,0.000000,""}; +link0[] = {0,5}; +link1[] = {2,3}; +link2[] = {2,4}; +link3[] = {3,2}; +link4[] = {4,1}; +link5[] = {5,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,8,6316128,1,-450.330200,450.329834,163.072220,-391.043060,721,617,1}; +window[] = {0,-1,-1,-1,-1,792,265,1678,55,1,739}; +*//*%FSM*/ +class FSM +{ + fsmName = "basearea"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_brr = 'WFBE_BASEAREARANGE' Call GetNamespace;" \n + "_mbr = 'WFBE_MHQBUILDINGRANGE' Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Update_Areas"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Areas + { + name = "Update_Areas"; + init = /*%FSM*/"_lastUpdate = time;" \n + "_areaWest = WF_Logic getVariable 'WestArea';" \n + "_areaEast = WF_Logic getVariable 'EastArea';" \n + "" \n + "_buildingsWest = WestBaseStructures + [WestMHQ];" \n + "_buildingsEast = EastBaseStructures + [EastMHQ];" \n + "" \n + "_newWest = _areaWest;" \n + "_newEast = _areaEast;" \n + "" \n + "{" \n + " _logic = _x;" \n + " _structures = [_logic,_buildingsWest] Call SortByDistance;" \n + " _update = false;" \n + " if (count _structures > 0) then {" \n + " if ((_structures select 0) distance _logic > (_brr + _mbr)) then {_update = true};" \n + " if (_update) then {" \n + " _newWest = _newWest - [_logic] - [objNull];" \n + " _grp = group _logic;" \n + " deleteVehicle _logic;" \n + " deleteGroup _grp;" \n + " };" \n + " };" \n + "} forEach _areaWest;" \n + "" \n + "if (count _newWest != count _areaWest) then {" \n + " WF_Logic setVariable ['WestArea',_newWest,true];" \n + "};" \n + "" \n + "{" \n + " _logic = _x;" \n + " _structures = [_logic,_buildingsEast] Call SortByDistance;" \n + " _update = false;" \n + " if (count _structures > 0) then {" \n + " if ((_structures select 0) distance _logic > (_brr + _mbr)) then {_update = true};" \n + " if (_update) then {" \n + " _newEast = _newEast - [_logic] - [objNull];" \n + " _grp = group _logic;" \n + " deleteVehicle _logic;" \n + " deleteGroup _grp;" \n + " };" \n + " };" \n + "} forEach _areaEast;" \n + "" \n + "if (count _newEast != count _areaEast) then {" \n + " WF_Logic setVariable ['EastArea',_newEast,true];" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Areas"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 30"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/basepatrol.fsm b/Server/FSM/basepatrol.fsm new file mode 100644 index 0000000..b5ac244 --- /dev/null +++ b/Server/FSM/basepatrol.fsm @@ -0,0 +1,303 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init_Patrol",0,250,-55.645832,-232.443039,34.354168,-182.443039,0.000000,"Init Patrol"}; +item1[] = {"_",8,218,-27.486687,-147.637543,6.009465,-118.394058,0.000000,""}; +item2[] = {"Building_Status",2,250,-55.764599,-83.906609,34.235420,-33.906616,0.000000,"Building" \n "Status"}; +item3[] = {"Alive",4,218,-57.270676,3.753643,32.729324,53.753662,1.000000,"Alive"}; +item4[] = {"Dead",4,218,75.014023,-81.237984,165.014221,-31.238003,0.000000,"Dead"}; +item5[] = {"Worth__defending",2,250,201.740265,-81.387749,291.740295,-31.387749,0.000000,"Worth" \n " defending?"}; +item6[] = {"Yes",4,218,200.643723,38.075150,290.643738,88.075134,1.000000,"Yes"}; +item7[] = {"No",4,218,328.454315,-81.330719,418.454376,-31.330761,0.000000,"No"}; +item8[] = {"Exit_Patrol",1,250,453.130798,-80.331696,543.130859,-30.331718,0.000000,"Exit Patrol"}; +item9[] = {"Status",2,250,206.126862,235.996475,296.126648,285.996338,0.000000,"Status"}; +item10[] = {"Wait",4,218,-234.715958,235.996490,-144.715927,285.996399,1.000000,"Wait"}; +item11[] = {"Game_Over",4,218,454.348022,235.593781,544.348022,285.593781,0.000000,"Game Over"}; +item12[] = {"Teams_Status",2,250,-55.966236,80.275879,34.033779,130.275909,0.000000,"Teams Status"}; +item13[] = {"Skip",4,218,137.039566,80.103676,227.039597,130.103638,0.000000,"Skip"}; +item14[] = {"Spawning",4,218,-54.869621,155.942947,35.130379,205.942947,1.000000,"Spawning"}; +item15[] = {"Spawn",2,4346,71.483360,157.670105,161.483368,207.670105,0.000000,"Spawn"}; +item16[] = {"_",8,218,101.881767,227.152191,135.427612,252.182098,0.000000,""}; +link0[] = {0,1}; +link1[] = {1,2}; +link2[] = {2,3}; +link3[] = {2,4}; +link4[] = {3,12}; +link5[] = {4,5}; +link6[] = {5,6}; +link7[] = {5,7}; +link8[] = {6,9}; +link9[] = {7,8}; +link10[] = {9,10}; +link11[] = {9,11}; +link12[] = {10,2}; +link13[] = {11,8}; +link14[] = {12,13}; +link15[] = {12,14}; +link16[] = {13,9}; +link17[] = {14,15}; +link18[] = {15,16}; +link19[] = {16,9}; +globals[] = {0.000000,0,0,0,0,640,480,1,61,6316128,1,-265.668091,546.403687,327.217163,-287.807800,640,520,1}; +window[] = {0,-1,-1,-1,-1,838,154,1453,203,1,658}; +*//*%FSM*/ +class FSM +{ + fsmName = "basepatrol"; + class States + { + /*%FSM*/ + class Init_Patrol + { + name = "Init_Patrol"; + init = /*%FSM*/"_building = _this select 0;" \n + "_side = _this select 1;" \n + "" \n + "_posBuilding = getPos _building;" \n + "" \n + "_lastCheck = 0;" \n + "_teams = [];" \n + "_maxTeams = 'WFBE_TOWNOCCUPATIONDIFFICULTY' Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Building_Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Building_Status + { + name = "Building_Status"; + init = /*%FSM*/"_aliveTeams = _teams;" \n + "{" \n + " _alives = (units _x) Call GetLiveUnits;" \n + " if (count _alives < 1 || isNull _x) then {" \n + " _aliveTeams = _aliveTeams - [_x] - [objNull];" \n + " };" \n + "} forEach _teams;" \n + "_teams = _aliveTeams;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Alive + { + priority = 1.000000; + to="Teams_Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"alive _building"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Dead + { + priority = 0.000000; + to="Worth__defending"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"isNull _building || !(alive _building)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Worth__defending + { + name = "Worth__defending"; + init = /*%FSM*/"_buildings = (str _side) Call GetSideStructures;" \n + "_sorted = [_posBuilding, _buildings] Call SortByDistance;" \n + "" \n + "_nearby = false;" \n + "if (count _sorted > 0) then {" \n + " if ((_sorted select 0) distance _posBuilding < 400) then {_nearby = true};" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Yes + { + priority = 1.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_nearby"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class No + { + priority = 0.000000; + to="Exit_Patrol"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_nearby"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Exit_Patrol + { + name = "Exit_Patrol"; + init = /*%FSM*/"{" \n + " _group = _x;" \n + " {" \n + " deleteVehicle _x;" \n + " } forEach (units _x);" \n + "" \n + " deleteGroup _group;" \n + "} forEach _teams;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Status + { + name = "Status"; + init = /*%FSM*/"_lastCheck = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 1.000000; + to="Building_Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 300 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Game_Over + { + priority = 0.000000; + to="Exit_Patrol"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Teams_Status + { + name = "Teams_Status"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Spawning + { + priority = 1.000000; + to="Spawn"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"count _teams < _maxTeams"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"count _teams >= _maxTeams"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Spawn + { + name = "Spawn"; + init = /*%FSM*/"_group = createGroup _side;" \n + "" \n + "_currentUpgrades = (str _side) Call GetSideUpgrades;" \n + "_currentLevel = _currentUpgrades select 13;" \n + "" \n + "if (count _teams > 1) then {" \n + " _currentLevel = round(random(_currentLevel));" \n + "};" \n + "" \n + "[_building,_side,_group,(Format['WFBE_%1BASEPATROLS_%2',_side,_currentLevel]) Call GetNamespace] Spawn {" \n + " Private ['_direction','_distance','_group','_index','_position','_side','_site','_type','_units'];" \n + " _site = _this select 0;" \n + " _side = _this select 1;" \n + " _group = _this select 2;" \n + " _units = _this select 3;" \n + " " \n + " _type = typeOf _site;" \n + " _index = (Format[""WFBE_%1STRUCTURENAMES"",str _side] Call GetNamespace) find _type;" \n + " _distance = (Format[""WFBE_%1STRUCTUREDISTANCES"",str _side] Call GetNamespace) select _index;" \n + " _direction = (Format[""WFBE_%1STRUCTUREDIRECTIONS"",str _side] Call GetNamespace) select _index;" \n + " _position = [getPos _site,_distance,getDir _site + _direction] Call GetPositionFrom;" \n + " " \n + " _created = 0;" \n + " " \n + " {" \n + " if (alive _site) then {" \n + " if (_x isKindOf 'Man') then {" \n + " sleep 7;" \n + " _soldier = [_x,_group,_position,_side] Call CreateMan;" \n + " _created = _created + 1;" \n + " };" \n + " };" \n + " } forEach _units;" \n + " " \n + " if (_created > 0) then {" \n + " _built = WF_Logic getVariable Format [""%1UnitsCreated"",str _side];" \n + " _built = _built + 1;" \n + " WF_Logic setVariable [Format[""%1UnitsCreated"",str _side],_built,true];" \n + " [str _side,'UnitsCreated',_built] Call UpdateStatistics;" \n + " [_group,_site,'WFBE_PATROLRANGE' Call GetNamespace] Spawn AIPatrol;" \n + " };" \n + "};" \n + "" \n + "_teams = _teams + [_group];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init_Patrol"; + finalStates[] = + { + "Exit_Patrol" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/conquest.fsm b/Server/FSM/conquest.fsm new file mode 100644 index 0000000..6072425 --- /dev/null +++ b/Server/FSM/conquest.fsm @@ -0,0 +1,134 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,4346,53.240814,-221.988968,143.240845,-171.989166,0.000000,"Init"}; +item1[] = {"End",1,250,-216.387955,-52.508366,-126.387947,-2.508394,0.000000,"End"}; +item2[] = {"Update_Conquest",2,250,-82.090652,-139.314026,7.909359,-89.314034,0.000000,"Update" \n "Conquest"}; +item3[] = {"Loop",4,218,53.846153,-139.681244,143.846161,-89.681236,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-216.387955,-139.464890,-126.387947,-89.464890,0.000000,"Gameover"}; +link0[] = {0,3}; +link1[] = {2,3}; +link2[] = {2,4}; +link3[] = {3,2}; +link4[] = {4,1}; +globals[] = {0.000000,0,0,0,0,640,480,1,8,6316128,1,-348.696411,348.696136,79.849762,-328.514618,921,592,1}; +window[] = {0,-1,-1,-1,-1,837,100,1513,100,1,939}; +*//*%FSM*/ +class FSM +{ + fsmName = "conquest"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_ntime = 0;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Conquest"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _ntime"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Conquest + { + name = "Update_Conquest"; + init = /*%FSM*/"_wt = [];" \n + "_et = [];" \n + "" \n + "{" \n + " _sideID = _x getVariable 'sideID';" \n + " if (_sideID == WestID) then {_wt = _wt + [_x]};" \n + " if (_sideID == EastID) then {_et = _et + [_x]};" \n + "} forEach towns;" \n + "" \n + "{" \n + " Private [""_hq"",""_set"",""_side"",""_sideID"",""_sideTowns"",""_sideVar""];" \n + " _sideTowns = _x select 0;" \n + " _sideVar = _x select 1;" \n + " _side = _x select 2;" \n + " _sideID = _x select 3;" \n + " _set = [];" \n + " " \n + " if (count _sideTowns > 0) then {" \n + " {" \n + " _neighbors = _x getVariable ""neighbors"";" \n + " if !(isNil ""_neighbors"") then {" \n + " {" \n + " if ((_x getVariable ""sideID"") != _sideID) then {" \n + " _x setVariable [_sideVar, true];" \n + " if !(_x in _set) then {_set = _set + [_x]};" \n + " };" \n + " } forEach _neighbors;" \n + " };" \n + " } forEach _sideTowns;" \n + " } else {" \n + " _hq = (_side) Call GetSideHQ;" \n + " _nearest = ([_hq, towns] Call SortByDistance) select 0;" \n + " if !(_nearest getVariable _sideVar) then {_nearest setVariable [_sideVar, true]};" \n + " _set = [_nearest];" \n + " };" \n + "" \n + " _set = towns - _set;" \n + " {" \n + " if (_x getVariable _sideVar) then {_x setVariable [_sideVar, false]};" \n + " } forEach _set;" \n + "} forEach [[_wt, ""wfbe_cancap_w"", west, WESTID], [_et, ""wfbe_cancap_e"", east, EASTID]];" \n + "" \n + "_ntime = time + 10;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Conquest"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _ntime"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/emptyvehiclescollector.fsm b/Server/FSM/emptyvehiclescollector.fsm new file mode 100644 index 0000000..40c2936 --- /dev/null +++ b/Server/FSM/emptyvehiclescollector.fsm @@ -0,0 +1,102 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,69.011497,-125.277687,159.011566,-75.277672,0.000000,"Init"}; +item1[] = {"Update_Empty_Veh",2,4346,67.881363,24.571560,157.881256,74.571510,0.000000,"Update" \n "Empty" \n "Vehicles"}; +item2[] = {"End",1,250,-62.454956,96.990730,27.545134,146.990707,0.000000,"End"}; +item3[] = {"Loop",4,218,68.212364,-51.053558,158.212402,-1.053517,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-62.855103,24.549839,27.144907,74.549820,0.000000,"Gameover"}; +link0[] = {0,3}; +link1[] = {1,3}; +link2[] = {1,4}; +link3[] = {3,1}; +link4[] = {4,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,19,6316128,1,-421.780701,421.779755,226.237854,-325.234192,748,514,1}; +window[] = {0,-1,-1,-1,-1,837,154,1414,203,1,766}; +*//*%FSM*/ +class FSM +{ + fsmName = "emptyvehiclescollector"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Empty_Veh"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 1 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Empty_Veh + { + name = "Update_Empty_Veh"; + init = /*%FSM*/"_vehicles = WF_Logic getVariable ""emptyVehicles"";" \n + "{" \n + " if !(_x in emptyQueu) then {" \n + " _vehicles2 = WF_Logic getVariable ""emptyVehicles"";" \n + " emptyQueu = emptyQueu + [_x];" \n + " _x Spawn HandleEmptyVehicle;" \n + " _reloaded = _vehicles2 - [_x] - [objNull];" \n + " WF_Logic setVariable [""emptyVehicles"",_reloaded,true];" \n + " };" \n + "} forEach _vehicles;" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Empty_Veh"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 1 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/fasttime.fsm b/Server/FSM/fasttime.fsm new file mode 100644 index 0000000..a8a4796 --- /dev/null +++ b/Server/FSM/fasttime.fsm @@ -0,0 +1,101 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,4346,-81.542984,-257.577942,8.457038,-207.578140,0.000000,"Init"}; +item1[] = {"End",1,250,-216.387955,-52.508366,-126.387947,-2.508394,0.000000,"End"}; +item2[] = {"Update_Time",2,250,-82.090652,-139.314026,7.909359,-89.314034,0.000000,"Update Time"}; +item3[] = {"Loop",4,218,53.846153,-139.681244,143.846161,-89.681236,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-216.387955,-139.464890,-126.387947,-89.464890,0.000000,"Gameover"}; +item5[] = {"_",8,218,-51.736092,-184.192123,-21.083296,-163.272247,0.000000,""}; +link0[] = {0,5}; +link1[] = {2,3}; +link2[] = {2,4}; +link3[] = {3,2}; +link4[] = {4,1}; +link5[] = {5,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,8,6316128,1,-348.696411,348.696136,79.849762,-328.514618,1011,622,1}; +window[] = {0,-1,-1,-1,-1,795,22,1435,58,1,1029}; +*//*%FSM*/ +class FSM +{ + fsmName = "fasttime"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_currentTime = DayTime;" \n + "_lastUpdate = time;" \n + "_ftr = ('WFBE_FASTTIMERATES' Call GetNamespace) select ('WFBE_FASTTIMERATE' Call GetNamespace);" \n + "WF_Logic setVariable [""currentTime"",_currentTime,true];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Update_Time"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Time + { + name = "Update_Time"; + init = /*%FSM*/"skipTime _ftr;" \n + "_currentTime = dayTime;" \n + "WF_Logic setVariable [""currentTime"",_currentTime,true];" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Time"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 1"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/garbagecollector.fsm b/Server/FSM/garbagecollector.fsm new file mode 100644 index 0000000..596beca --- /dev/null +++ b/Server/FSM/garbagecollector.fsm @@ -0,0 +1,165 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,27.096645,-357.382507,117.096680,-307.382507,0.000000,"Init"}; +item1[] = {"Loop",4,218,349.567535,-189.804108,439.567596,-139.804062,0.000000,"Loop"}; +item2[] = {"End",1,250,35.343773,-97.642059,125.343819,-47.642326,0.000000,"End"}; +item3[] = {"Arrowhead_Garbag",2,4346,201.635025,-189.872375,291.634949,-139.872375,0.000000,"Arrowhead" \n "Garbage"}; +item4[] = {"Loop",4,218,-301.789124,-191.088837,-211.789047,-141.088791,0.000000,"Loop"}; +item5[] = {"Vanilla",4,218,-28.368071,-262.232788,61.631752,-212.232986,0.000000,"Vanilla"}; +item6[] = {"Arrowhead",4,218,94.700302,-263.344727,184.700043,-213.344574,0.000000,"Arrowhead"}; +item7[] = {"Vanilla_Garbage",2,250,-153.091797,-191.262604,-63.091869,-141.262650,0.000000,"Vanilla" \n "Garbage"}; +item8[] = {"Gameover",4,218,34.943623,-190.869827,124.943687,-140.869797,0.000000,"Gameover"}; +link0[] = {0,5}; +link1[] = {0,6}; +link2[] = {1,3}; +link3[] = {3,1}; +link4[] = {3,8}; +link5[] = {4,7}; +link6[] = {5,7}; +link7[] = {6,3}; +link8[] = {7,4}; +link9[] = {7,8}; +link10[] = {8,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,38,6316128,1,-314.217926,456.388641,91.977463,-442.708069,748,514,1}; +window[] = {0,-1,-1,-1,-1,659,25,1285,25,1,766}; +*//*%FSM*/ +class FSM +{ + fsmName = "garbagecollector"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Arrowhead + { + priority = 0.000000; + to="Arrowhead_Garbag"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!WF_A2_Vanilla"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Vanilla + { + priority = 0.000000; + to="Vanilla_Garbage"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"WF_A2_Vanilla"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Arrowhead_Garbag + { + name = "Arrowhead_Garbag"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "/* Units Removal */" \n + "" \n + "_whq = (west) Call GetSideHQ;" \n + "_ehq = (East) Call GetSideHQ;" \n + "" \n + "{" \n + " if (!(_x in trashQueu) && !(_x in ignoreQueu) && !(_x in playableUnits) && (_x != _whq) && (_x != _ehq)) then {" \n + " _x Spawn TrashObject;" \n + " };" \n + "} forEach allDead;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Arrowhead_Garbag"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 30 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Vanilla_Garbage + { + name = "Vanilla_Garbage"; + init = /*%FSM*/"_objects = WF_Logic getVariable ""trash"";" \n + "{" \n + " if !(_x in trashQueu) then {" \n + " _objects2 = WF_Logic getVariable ""trash"";" \n + " trashQueu = trashQueu + [_x];" \n + " _x Spawn TrashObject;" \n + " _renewed = _objects2 - [_x] - [objNull];" \n + " WF_Logic setVariable [""trash"",_renewed,true];" \n + " };" \n + "} forEach _objects;" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Vanilla_Garbage"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 0.5 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/missions.fsm b/Server/FSM/missions.fsm new file mode 100644 index 0000000..ecc3b98 --- /dev/null +++ b/Server/FSM/missions.fsm @@ -0,0 +1,233 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,4346,-74.017166,-296.043274,15.982856,-246.043442,0.000000,"Init"}; +item1[] = {"End",1,250,-198.827713,-59.197983,-108.827713,-9.198011,0.000000,"End"}; +item2[] = {"Update_Time",2,250,-73.728622,-145.167450,16.271379,-95.167450,0.000000,"Update Time"}; +item3[] = {"Loop",4,218,-74.092773,-224.973862,15.907227,-174.973846,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-197.991501,-144.482101,-107.991493,-94.482101,0.000000,"Gameover"}; +item5[] = {"Create",4,218,-73.431000,-64.188675,16.568987,-14.188683,1.000000,"Create"}; +item6[] = {"Assign_a_Mission",2,250,72.904373,-65.024872,162.904373,-15.024889,0.000000,"Assign a" \n "Mission"}; +item7[] = {"Skip",2,250,186.627869,-224.739502,276.627808,-174.739502,0.000000,"Skip"}; +item8[] = {"_",8,218,215.894943,-49.973213,248.197006,-28.404099,0.000000,""}; +link0[] = {0,3}; +link1[] = {2,3}; +link2[] = {2,4}; +link3[] = {2,5}; +link4[] = {3,2}; +link5[] = {4,1}; +link6[] = {5,6}; +link7[] = {6,8}; +link8[] = {7,3}; +link9[] = {8,7}; +globals[] = {0.000000,0,0,0,0,640,480,1,14,6316128,1,-348.696289,348.696289,188.145477,-327.791229,834,617,1}; +window[] = {0,-1,-1,-1,-1,762,25,1438,25,1,852}; +*//*%FSM*/ +class FSM +{ + fsmName = "missions"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_maxmissionswest = 'WFBE_MISSIONSMAXIMUM_WEST' Call GetNamespace;" \n + "_maxmissionseast = 'WFBE_MISSIONSMAXIMUM_EAST' Call GetNamespace;" \n + "_randomizer = 'WFBE_MISSIONSRANDOMIZER' Call GetNamespace;" \n + "_timeout = 'WFBE_MISSIONSTIMEOUT' Call GetNamespace;" \n + "_canReuseAfter = 'WFBE_MISSIONSREUSABILITY' Call GetNamespace;" \n + "_totalMissions = count('WFBE_M_CONTENT' Call GetNamespace) - 1;" \n + "" \n + "_lastUpdate = 0;" \n + "_lastMissionAssignedTime = -6000;" \n + "_lastMissionsIndex = [];" \n + "['_WFBE_M_RUNNINGMISSIONS_WEST',0,true] Call SetNamespace;" \n + "['_WFBE_M_RUNNINGMISSIONS_EAST',0,true] Call SetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Time"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 30"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Time + { + name = "Update_Time"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "_runningMissionsWest = '_WFBE_M_RUNNINGMISSIONS_WEST' Call GetNamespace;" \n + "_runningMissionsEast = '_WFBE_M_RUNNINGMISSIONS_EAST' Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Create + { + priority = 1.000000; + to="Assign_a_Mission"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastMissionAssignedTime >= _timeout && (_runningMissionsWest < _maxmissionswest || _runningMissionsEast < _maxmissionseast)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Time"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 30"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Assign_a_Mission + { + name = "Assign_a_Mission"; + init = /*%FSM*/"//--- Retrieve an updated version of the missions array." \n + "_missions = 'WFBE_M_CONTENT' Call GetNamespace;" \n + "_missionAssigned = false;" \n + "" \n + "//--- Retrieve a 'free' mission." \n + "_i = -1;" \n + "while {_i < 0} do {" \n + " _r = round (random _totalMissions);" \n + " if !(_r in _lastMissionsIndex) then {_i = _r};" \n + "};" \n + "" \n + "//--- Retrieve the current mission content." \n + "_mission = (_missions select _i);" \n + "" \n + "//--- Can we run it?" \n + "_go = false;" \n + "if ((_mission select 5) == civilian) then {if (_runningMissionsWest < _maxmissionswest && _runningMissionsEast < _maxmissionseast) then {_go = true}};" \n + "if ((_mission select 5) == west) then {if (_runningMissionsWest < _maxmissionswest) then {_go = true}};" \n + "if ((_mission select 5) == east) then {if (_runningMissionsEast < _maxmissionseast) then {_go = true}};" \n + "" \n + "if (_go) then {" \n + " _islandHeader = (_mission select 0) select 0;" \n + " //--- All" \n + " if (_islandHeader == '*') then {" \n + " _go = true;" \n + " } else {" \n + " if (_islandHeader == '!') then {" \n + " //--- If island not in." \n + " if !(worldName in (_mission select 0)) then {_go = true};" \n + " } else {" \n + " //--- If island in." \n + " if (worldName in (_mission select 0)) then {_go = true};" \n + " };" \n + " };" \n + "};" \n + "" \n + "//--- Go?" \n + "if (_go) then {" \n + " //--- Check for the mission condition (Compile it)." \n + " if (Call Compile (_mission select 4)) then {" \n + " [_mission select 2,_mission select 3,_mission select 5] ExecVM (_mission select 1);" \n + "" \n + " //--- Randomize the next mission delay." \n + " _lastMissionAssignedTime = (time)+random(_randomizer)-random(_randomizer);" \n + "" \n + " //--- Select the mission type (both, west ,east)" \n + " switch (_mission select 5) do {" \n + " case civilian: {['_WFBE_M_RUNNINGMISSIONS_WEST',_runningMissionsWest + 1, true] Call SetNamespace;['_WFBE_M_RUNNINGMISSIONS_EAST',_runningMissionsEast + 1, true] Call SetNamespace};" \n + " case west: {['_WFBE_M_RUNNINGMISSIONS_WEST',_runningMissionsWest + 1, true] Call SetNamespace};" \n + " case east: {['_WFBE_M_RUNNINGMISSIONS_EAST',_runningMissionsEast + 1, true] Call SetNamespace};" \n + " };" \n + " " \n + " //--- Increment Mission index (it will apply to the getter, no need to set again)." \n + " _mission set [3,(_mission select 3) + 1];" \n + "" \n + " //--- Push (i.e limit 4, [1,2,3,4] add 5 >> [5,1,2,3])." \n + " for [{_z = (count _lastMissionsIndex)},{_z > 0},{_z = _z - 1}] do {" \n + " _lastMissionsIndex set [_z, (_lastMissionsIndex select (_z - 1))];" \n + " };" \n + " " \n + " //--- Resize if we're above the limit." \n + " _lastMissionsIndex set [0, _i];" \n + " if (count _lastMissionsIndex >= _canReuseAfter) then {" \n + " _lastMissionsIndex resize (_canReuseAfter - 1);" \n + " };" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + name = "Skip"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Time"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 30"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/queryhandler.fsm b/Server/FSM/queryhandler.fsm new file mode 100644 index 0000000..2f5f130 --- /dev/null +++ b/Server/FSM/queryhandler.fsm @@ -0,0 +1,153 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,67.883751,-127.533096,157.883820,-77.533165,0.000000,"Init"}; +item1[] = {"Update_Query",2,250,67.881363,24.571560,157.881256,74.571510,0.000000,"Update" \n "Query"}; +item2[] = {"End",1,250,-189.891251,153.378479,-99.891129,203.378586,0.000000,"End"}; +item3[] = {"Loop",4,218,68.212364,-51.053558,158.212402,-1.053517,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-62.855103,24.549839,27.144907,74.549820,0.000000,"Gameover"}; +item5[] = {"End_Check",2,4346,-191.718842,24.369755,-101.718727,74.369736,0.000000,"End Check"}; +item6[] = {"_",8,218,-162.287018,100.867683,-128.674744,124.929321,0.000000,""}; +link0[] = {0,3}; +link1[] = {1,3}; +link2[] = {1,4}; +link3[] = {3,1}; +link4[] = {4,5}; +link5[] = {5,6}; +link6[] = {6,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,21,6316128,1,-421.780701,421.779755,226.237854,-325.234192,748,514,1}; +window[] = {0,-1,-1,-1,-1,772,203,1463,138,1,766}; +*//*%FSM*/ +class FSM +{ + fsmName = "queryhandler"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "_mysql_query = [];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Query"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 0.3 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Query + { + name = "Update_Query"; + init = /*%FSM*/"_cobjects = WF_Logic getVariable ""WF_MYSQL_CLIENT"";" \n + "_sobjects = WF_Logic getVariable ""WF_MYSQL_SERVER"";" \n + "" \n + "_query = """";" \n + "" \n + "if (count _cobjects > 0) then {" \n + " _query = _cobjects select 0;" \n + " _cobjects set [0,""nil""];" \n + " _cobjects = _cobjects - [""nil""];" \n + " WF_Logic setVariable [""WF_MYSQL_CLIENT"",_cobjects,true];" \n + "};" \n + "" \n + "if (count _sobjects > 0 && _query == """") then {" \n + " _query = _sobjects select 0;" \n + " _sobjects set [0,""nil""];" \n + " _sobjects = _sobjects - [""nil""];" \n + " WF_Logic setVariable [""WF_MYSQL_SERVER"",_sobjects];" \n + "};" \n + "" \n + "if (_query != """") then {copyToClipboard _query};" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End_Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Query"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 0.3 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class End_Check + { + name = "End_Check"; + init = /*%FSM*/"[] Spawn {" \n + " {" \n + " if (isPlayer (leader _x)) then {" \n + " sleep 0.3;" \n + " " \n + " _get = Format[""WFBE_JIP_USER%1"",getPlayerUID (leader _x)] Call GetNamespace;" \n + " if !(isNil '_get') then {" \n + " _field = if (side (leader _x) == (WF_Logic getVariable ""WF_Winner"")) then {""win""} else {""loss""};" \n + " _strTr = if (side(leader _x) == west) then {'west'} else {'east'};" \n + " copyToClipboard Format [""MYSQLDATAďż˝WFBE_EndGameďż˝%1ďż˝%2ďż˝%3ďż˝%4ďż˝%5ďż˝%6"",getPlayerUID (leader _x), name (leader _x), time - (_get select 5), _strTr, worldName, _field];" \n + " };" \n + " };" \n + " } forEach (('WFBE_EASTTEAMS' Call GetNamespace)+('WFBE_WESTTEAMS' Call GetNamespace));" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/respatrol.fsm b/Server/FSM/respatrol.fsm new file mode 100644 index 0000000..4d1d9b3 --- /dev/null +++ b/Server/FSM/respatrol.fsm @@ -0,0 +1,336 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init_Patrol",0,250,-37.336731,-245.259415,52.663269,-195.259415,0.000000,"Init Patrol"}; +item1[] = {"Wait",4,218,-34.704277,-60.518974,55.295708,-10.518976,0.000000,"Wait"}; +item2[] = {"Activity",2,250,-38.403221,10.450424,51.596794,60.450424,0.000000,"Activity"}; +item3[] = {"is_Active",4,218,101.439552,11.111540,191.439560,61.111511,1.000000,"is Active"}; +item4[] = {"Actions",2,250,100.520218,-64.953995,190.520096,-14.954021,0.000000,"Actions"}; +item5[] = {"Spawn",4,218,-316.513123,35.015533,-226.513107,85.015488,10.000000,"Spawn"}; +item6[] = {"Create",2,250,-316.368622,-205.743271,-226.368637,-155.743256,0.000000,"Create"}; +item7[] = {"Gameover",4,218,-99.764572,74.877029,-9.764542,124.877037,0.000000,"Gameover"}; +item8[] = {"End",1,250,-101.050774,175.913666,-11.050694,225.913651,0.000000,"End"}; +item9[] = {"Wait",4,218,-38.930679,109.403816,51.069321,159.403778,0.000000,"Wait"}; +item10[] = {"Respawn_units",2,250,207.845749,108.995827,297.845764,158.995819,0.000000,"Respawn units"}; +item11[] = {"_",8,218,231.577728,-112.425110,275.102661,-89.123550,0.000000,""}; +item12[] = {"_",8,218,-14.641279,-176.291138,27.894829,-149.034271,0.000000,""}; +item13[] = {"Advanced_Init",2,250,-39.362053,-125.860779,50.637978,-75.860779,0.000000,"Advanced Init"}; +item14[] = {"Town_Enemy",4,218,-253.437073,0.921768,-163.437073,50.921768,0.000000,"Town Enemy"}; +item15[] = {"Idle",2,250,-251.141953,-120.718803,-161.141937,-70.718803,0.000000,"Idle"}; +link0[] = {0,12}; +link1[] = {1,2}; +link2[] = {2,3}; +link3[] = {2,5}; +link4[] = {2,7}; +link5[] = {2,9}; +link6[] = {2,14}; +link7[] = {3,4}; +link8[] = {4,1}; +link9[] = {5,6}; +link10[] = {6,1}; +link11[] = {7,8}; +link12[] = {9,10}; +link13[] = {10,11}; +link14[] = {11,13}; +link15[] = {12,13}; +link16[] = {13,1}; +link17[] = {14,15}; +link18[] = {15,1}; +globals[] = {0.000000,0,0,0,0,640,480,1,40,6316128,1,-340.674133,424.132904,299.011444,-280.217407,680,520,1}; +window[] = {0,-1,-1,-1,-1,838,154,1453,203,1,698}; +*//*%FSM*/ +class FSM +{ + fsmName = "respatrol"; + class States + { + /*%FSM*/ + class Init_Patrol + { + name = "Init_Patrol"; + init = /*%FSM*/"_location = _this select 0;" \n + "_startSV = _location getVariable ""startingSupplyValue"";" \n + "" \n + "_rpi = 'WFBE_RESPATROLINTERVAL' Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Advanced_Init"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Activity + { + name = "Activity"; + init = /*%FSM*/"_lastUpdate = time;" \n + "_sideID = _location getVariable ""sideID"";" \n + "_isActive = _location getVariable ""activePatrol"";" \n + "_SV =_location getVariable ""supplyValue"";" \n + "" \n + "_alives = if (!isNil ""_team"") then {Count ((Units _team) Call GetLiveUnits)} else {0};" \n + "" \n + "if (time - _travelTime > 1200) then {_lastMission = """"};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Spawn + { + priority = 10.000000; + to="Create"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && !_isActive && _sideID == RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class is_Active + { + priority = 1.000000; + to="Actions"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && _isActive && _alives > 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Respawn_units"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_alives <= 0 && _isActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Town_Enemy + { + priority = 0.000000; + to="Idle"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && !_isActive && _sideID != RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Actions + { + name = "Actions"; + init = /*%FSM*/"if (_SV != _startSV || _sideID != RESISTANCEID) then {" \n + " _curMission = ""Defend"";" \n + "} else {" \n + " _curMission = ""Patrol"";" \n + "};" \n + "" \n + "_nsid = _nearest getVariable ""sideID"";" \n + "" \n + "if (_curMission != _lastMission || ((leader _team) distance _nearest < 60 && _nsid == RESISTANCEID)) then {" \n + " _lastMission = _curMission;" \n + " _travelTime = time;" \n + " switch (_curMission) do {" \n + " case ""Patrol"": {" \n + " _nearTowns = ([leader _team,towns] Call SortByDistance) - [_lastDestination];" \n + " _nearest = _nearTowns select 0;" \n + " if (count towns > 3) then {" \n + " _nearest = _nearTowns select (round(random 2));" \n + " } else {" \n + " if (count towns > 2) then {" \n + " _nearest = _nearTowns select (round(random 1));" \n + " } else {" \n + " _nearest = _nearTowns select 0;" \n + " };" \n + " };" \n + " [_team,getPos _nearest,""move""] Call AIMoveTo;" \n + " _lastDestination = _nearest" \n + " };" \n + " case ""Defend"": {" \n + " [_team,getPos _location,""move""] Call AIMoveTo;" \n + " };" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > (30+random 1)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Create + { + name = "Create"; + init = /*%FSM*/"_team = createGroup resistance;" \n + "_unit = objNull;" \n + "_vehicles = [];" \n + "_position = [getPos _location,100,300] Call GetRandomPosition;" \n + "" \n + "{" \n + " if (_x isKindOf ""Man"") then {" \n + " _unit = [_x,_team,_position,resistance] Call CreateMan;" \n + " } else {" \n + " _type = if (_x isKindOf 'Man') then {'WFBE_GUERSOLDIER' Call GetNamespace} else {if (_x isKindOf 'Air') then {'WFBE_GUERPILOT' Call GetNamespace} else {'WFBE_GUERCREW' Call GetNamespace}};" \n + " _vehicle = [_x,_position,resistance,paramResVehLock] Call CreateVehi;" \n + " _vehicles = _vehicles + [_vehicle];" \n + " _unit = [_type,_team,_position,resistance] Call CreateMan;" \n + " _unit moveInDriver _vehicle;" \n + " if (_vehicle emptyPositions ""gunner"" > 0) then {_unit = [_type,_team,_position,resistance] Call CreateMan;_unit moveInGunner _vehicle};" \n + " if (_vehicle emptyPositions ""commander"" > 0) then {_unit = [_type,_team,_position,resistance] Call CreateMan;_unit moveInCommander _vehicle};" \n + " };" \n + "} forEach _types;" \n + "" \n + "{_team addVehicle _x} forEach _vehicles;" \n + "" \n + "if (count _vehicles > 0) then {" \n + " {" \n + " emptyQueu = emptyQueu + [_x];" \n + " _x Spawn HandleEmptyVehicle;" \n + " } forEach _vehicles;" \n + "};" \n + "" \n + "_location setVariable [""activePatrol"",true];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > (30+random 1)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Respawn_units + { + name = "Respawn_units"; + init = /*%FSM*/"_idleStart = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Advanced_Init"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _idleStart > 5"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Advanced_Init + { + name = "Advanced_Init"; + init = /*%FSM*/"_lastUpdate = 0;" \n + "_lastDestination = _location;" \n + "_curMission = """";" \n + "_lastMission = """";" \n + "_team = nil;" \n + "_nearest = _location;" \n + "_travelTime = time;" \n + "" \n + "//--- Select a team sample depending of the SV." \n + "_types = -1;" \n + "if (_startSV <= 10) then {_types = Format [""WFBE_RESPATROLTYPE1%1"",round(random 2)] Call GetNamespace};" \n + "if (_startSV > 10 && _startSV <= 20) then {_types = Format [""WFBE_RESPATROLTYPE2%1"",round(random 2)] Call GetNamespace};" \n + "if (_startSV > 20 && _startSV <= 30) then {_types = Format [""WFBE_RESPATROLTYPE3%1"",round(random 2)] Call GetNamespace};" \n + "if (typeName _types != 'ARRAY') then {_types = 'WFBE_RESPATROLTYPE10' Call GetNamespace};" \n + "" \n + "_location setVariable [""activePatrol"",false];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > (30+random 1)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Idle + { + name = "Idle"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > (30+random 1)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init_Patrol"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/resstriker.fsm b/Server/FSM/resstriker.fsm new file mode 100644 index 0000000..5f29b20 --- /dev/null +++ b/Server/FSM/resstriker.fsm @@ -0,0 +1,303 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init_Patrol",0,250,-37.336731,-245.259415,52.663269,-195.259415,0.000000,"Init Patrol"}; +item1[] = {"Wait",4,218,-35.585495,-60.933670,54.414505,-10.933670,0.000000,"Wait"}; +item2[] = {"Activity",2,250,-38.403221,10.450424,51.596794,60.450424,0.000000,"Activity"}; +item3[] = {"is_Active",4,218,101.439552,11.111540,191.439560,61.111511,1.000000,"is Active"}; +item4[] = {"Actions",2,250,100.520218,-64.953995,190.520096,-14.954021,0.000000,"Actions"}; +item5[] = {"Spawn",4,218,-316.513123,35.015533,-226.513107,85.015488,10.000000,"Spawn"}; +item6[] = {"Create",2,250,-316.368622,-205.743271,-226.368637,-155.743256,0.000000,"Create"}; +item7[] = {"Gameover",4,218,-99.764572,74.877029,-9.764542,124.877037,0.000000,"Gameover"}; +item8[] = {"End",1,250,-101.050774,175.913666,-11.050694,225.913651,0.000000,"End"}; +item9[] = {"Wait",4,218,-38.930679,109.403816,51.069321,159.403778,0.000000,"Wait"}; +item10[] = {"Respawn_units",2,250,207.845749,108.995827,297.845764,158.995819,0.000000,"Respawn units"}; +item11[] = {"_",8,218,231.577728,-112.425110,275.102661,-89.123550,0.000000,""}; +item12[] = {"_",8,218,-14.641279,-176.291138,27.894829,-149.034271,0.000000,""}; +item13[] = {"Advanced_Init",2,250,-39.362053,-125.860779,50.637978,-75.860779,0.000000,"Advanced Init"}; +item14[] = {"Town_Enemy",4,218,-253.437073,0.921768,-163.437073,50.921768,0.000000,"Town Enemy"}; +item15[] = {"Idle",2,250,-251.141953,-120.718803,-161.141937,-70.718803,0.000000,"Idle"}; +link0[] = {0,12}; +link1[] = {1,2}; +link2[] = {2,3}; +link3[] = {2,5}; +link4[] = {2,7}; +link5[] = {2,9}; +link6[] = {2,14}; +link7[] = {3,4}; +link8[] = {4,1}; +link9[] = {5,6}; +link10[] = {6,1}; +link11[] = {7,8}; +link12[] = {9,10}; +link13[] = {10,11}; +link14[] = {11,13}; +link15[] = {12,13}; +link16[] = {13,1}; +link17[] = {14,15}; +link18[] = {15,1}; +globals[] = {0.000000,0,0,0,0,640,480,1,40,6316128,1,-414.643646,338.593170,226.689758,-316.083740,680,490,1}; +window[] = {0,-1,-1,-1,-1,710,75,1374,75,1,698}; +*//*%FSM*/ +class FSM +{ + fsmName = "resstriker"; + class States + { + /*%FSM*/ + class Init_Patrol + { + name = "Init_Patrol"; + init = /*%FSM*/"_location = _this select 0;" \n + "_target = objNull;" \n + "" \n + "_rsi = 'WFBE_RESSTRIKERINTERVAL' Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Advanced_Init"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Activity + { + name = "Activity"; + init = /*%FSM*/"_lastUpdate = time + 40 + random 2;" \n + "_sideID = _location getVariable ""sideID"";" \n + "_isActive = _location getVariable ""activeStriker"";" \n + "" \n + "_alives = if (!isNil ""_team"") then {Count ((Units _team) Call GetLiveUnits)} else {0};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Spawn + { + priority = 10.000000; + to="Create"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && !_isActive && _sideID == RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class is_Active + { + priority = 1.000000; + to="Actions"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && _isActive && _alives > 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Respawn_units"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_alives <= 0 && _isActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Town_Enemy + { + priority = 0.000000; + to="Idle"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && !_isActive && _sideID != RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Actions + { + name = "Actions"; + init = /*%FSM*/"_update = false;" \n + "if (time - _travelTime > 2400 || !alive _target) then {_update = true};" \n + "" \n + "if (_update) then {" \n + " _buildings = (WestBaseStructures) + (EastBaseStructures) + [EastMHQ,WestMHQ];" \n + " _near = [_location, _buildings] Call SortByDistance;" \n + " _target = _near select 0;" \n + " [_team, true, [[_target, 'SAD', 100, 60, """", []]]] Call AIWPAdd;" \n + " _travelTime = time;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _lastUpdate"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Create + { + name = "Create"; + init = /*%FSM*/"_team = createGroup resistance;" \n + "_unit = objNull;" \n + "_vehicles = [];" \n + "_position = [getPos _location,100,300] Call GetRandomPosition;" \n + "" \n + "//--- Select a team." \n + "_types = Format [""WFBE_RESSTRIKERTYPE1%1"",round(random 3)] Call GetNamespace;" \n + "" \n + "{" \n + " if (_x isKindOf ""Man"") then {" \n + " _unit = [_x,_team,_position,resistance] Call CreateMan;" \n + " } else {" \n + " _type = if (_x isKindOf 'Man') then {'WFBE_GUERSOLDIER' Call GetNamespace} else {if (_x isKindOf 'Air') then {'WFBE_GUERPILOT' Call GetNamespace} else {'WFBE_GUERCREW' Call GetNamespace}};" \n + " _vehicle = [_x,_position,resistance,paramResVehLock] Call CreateVehi;" \n + " _vehicles = _vehicles + [_vehicle];" \n + " _unit = [_type,_team,_position,resistance] Call CreateMan;" \n + " _unit moveInDriver _vehicle;" \n + " if (_vehicle emptyPositions ""gunner"" > 0) then {_unit = [_type,_team,_position,resistance] Call CreateMan;_unit moveInGunner _vehicle};" \n + " if (_vehicle emptyPositions ""commander"" > 0) then {_unit = [_type,_team,_position,resistance] Call CreateMan;_unit moveInCommander _vehicle};" \n + " };" \n + "} forEach _types;" \n + "" \n + "{_team addVehicle _x} forEach _vehicles;" \n + "" \n + "if (count _vehicles > 0) then {" \n + " {" \n + " emptyQueu = emptyQueu + [_x];" \n + " _x Spawn HandleEmptyVehicle;" \n + " } forEach _vehicles;" \n + "};" \n + "" \n + "_location setVariable [""activeStriker"",true];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _lastUpdate"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Respawn_units + { + name = "Respawn_units"; + init = /*%FSM*/"_idleStart = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Advanced_Init"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _idleStart > _rsi"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Advanced_Init + { + name = "Advanced_Init"; + init = /*%FSM*/"_lastUpdate = -60;" \n + "_team = nil;" \n + "_travelTime = time;" \n + "" \n + "_location setVariable [""activeStriker"",false];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _lastUpdate"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Idle + { + name = "Idle"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Activity"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _lastUpdate"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init_Patrol"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/supplytruck.fsm b/Server/FSM/supplytruck.fsm new file mode 100644 index 0000000..74e591d --- /dev/null +++ b/Server/FSM/supplytruck.fsm @@ -0,0 +1,287 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Truck_Init",0,250,-171.242203,-13.536451,-81.242249,36.463646,0.000000,"Truck Init"}; +item1[] = {"Truck_End",1,250,-303.115265,388.653168,-213.115280,438.653076,0.000000,"Truck End"}; +item2[] = {"Truck_is__dead_",4,218,-302.663574,272.303101,-212.663345,322.302917,1.000000,"Truck is " \n "dead?"}; +item3[] = {"Global__Checks",3,250,-170.493988,177.490768,-80.494026,227.490891,0.000000,"Global" \n " Checks"}; +item4[] = {"Loop",8,218,-171.007660,71.851631,-81.007713,121.851631,0.000000,"Loop"}; +item5[] = {"Can__Move_",4,218,-300.051117,178.466248,-210.051086,228.466232,0.000000,"Can " \n "Move?"}; +item6[] = {"Check__Locations",2,250,-299.279907,73.958237,-209.971802,123.266243,0.000000,"Check" \n " Locations"}; +item7[] = {"Deliver_",4,218,-170.476105,272.373291,-80.476044,322.373322,0.000000,"Deliver?"}; +item8[] = {"Delivery",2,250,-170.157013,387.966614,-80.156998,437.966614,0.000000,"Delivery"}; +item9[] = {"",7,210,49.830540,409.317871,57.830544,417.317871,0.000000,""}; +item10[] = {"",7,210,49.565125,92.576248,57.565128,100.576248,0.000000,""}; +item11[] = {"Destination_",4,218,-53.444309,177.966080,36.555691,227.966080,0.000000,"Destination?"}; +item12[] = {"Reload",2,250,-46.849068,102.598534,43.150940,152.598419,0.000000,"Reload"}; +link0[] = {0,4}; +link1[] = {2,1}; +link2[] = {3,2}; +link3[] = {3,5}; +link4[] = {3,7}; +link5[] = {3,11}; +link6[] = {4,3}; +link7[] = {5,6}; +link8[] = {6,4}; +link9[] = {7,8}; +link10[] = {8,9}; +link11[] = {9,10}; +link12[] = {10,4}; +link13[] = {11,12}; +link14[] = {12,4}; +globals[] = {0.000000,0,0,0,0,640,480,1,23,6316128,1,-459.421387,124.502724,528.344360,-109.468002,726,906,1}; +window[] = {2,-1,-1,-1,-1,921,175,1135,175,3,744}; +*//*%FSM*/ +class FSM +{ + fsmName = "supplytruck"; + class States + { + /*%FSM*/ + class Truck_Init + { + name = "Truck_Init"; + init = /*%FSM*/"_side = _this select 0;" \n + "_sideText = str _side;" \n + "" \n + "_type = Format ['WFBE_%1SUPPLYTRUCK',_sideText] Call GetNamespace;" \n + "_crew = Format [""WFBE_%1SOLDIER"",_sideText] Call GetNamespace;" \n + "_hq = (_sideText) Call GetSideHQ;" \n + "_vehicle = [_type,(GetPos _hq),_side,true] Call CreateVehi;" \n + "_team = CreateGroup _side;" \n + "_driver = [_crew,_team,(getpos _vehicle),_side] Call CreateMan;" \n + "[_driver] AllowGetIn true;" \n + "_driver MoveInDriver _vehicle;" \n + "[Format[""WFBE_%1_AISupplyTrucks"",_sideText],(Format[""WFBE_%1_AISupplyTrucks"",_sideText] Call GetNamespace) + [_vehicle],true] Call SetNamespace;" \n + "[_vehicle,GetPos _hq,30,50,true,false,true] Call PlaceNear;" \n + "" \n + "[_sideText,'VehiclesCreated',1] Call UpdateStatistics;" \n + "[_sideText,'UnitsCreated',1] Call UpdateStatistics;" \n + "" \n + "_spt = Format[""WFBE_%1SERVICEPOINTTYPE"",_sideText] Call GetNamespace;" \n + "" \n + "_SV = 1000;" \n + "_currentSV = 0;" \n + "_maxSV = 0;" \n + "_timer = 0;" \n + "_closest = objNull;" \n + "_sp = _hq;" \n + "_lastDestination = _hq;" \n + "_isDelivering = false;" \n + "_lastCheck = time;" \n + "_lastDelivery = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global__Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 15"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Truck_End + { + name = "Truck_End"; + init = /*%FSM*/"if (alive _driver) then {_driver setDammage 1};" \n + "(_vehicle) spawn { sleep 120;if (alive _this) then {_this setDammage 1}};" \n + "[Format[""WFBE_%1_AISupplyTrucks"",_sideText],(Format[""WFBE_%1_AISupplyTrucks"",_sideText] Call GetNamespace) - [_vehicle],true] Call SetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Global__Checks + { + name = "Global__Checks"; + init = /*%FSM*/"if (fuel _vehicle < 0.4) then {_vehicle setFuel 1};" \n + "_destinations = [];" \n + "{" \n + " _locationSide = (_x getVariable ""sideID"") Call GetSideFromID;" \n + " if (_locationSide == _side) then {_destinations = _destinations + [_x]};" \n + "} forEach towns;" \n + "" \n + "_hq = (_sideText) Call GetSideHQ;" \n + "if (_vehicle Distance _hq < 70 || _vehicle Distance _sp < 70) then {_SV = 1000;_lastDelivery = time};" \n + "" \n + "_timer = _timer + 15;" \n + "if (_timer > 30) then {_isDelivering = false;_timer = 0};" \n + "if (time - _lastDelivery > 600) then {_vehicle setDammage 1};" \n + "_lastCheck = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Truck_is__dead_ + { + priority = 1.000000; + to="Truck_End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!(alive _driver)||!(alive _vehicle)|| isNull _driver || isNull _vehicle || !canMove _vehicle"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Deliver_ + { + priority = 0.000000; + to="Delivery"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_vehicle distance _closest < 60;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Destination_ + { + priority = 0.000000; + to="Reload"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"count _destinations < 1"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Can__Move_ + { + priority = 0.000000; + to="Check__Locations"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"count _destinations > 0 && !_isDelivering"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check__Locations + { + name = "Check__Locations"; + init = /*%FSM*/"_loc = [leader _team,_destinations] Call SortByDistance;" \n + "_closest = _loc select 0;" \n + "_possibleLoc = objNull;" \n + "_skip = false;" \n + "_isDelivering = true;" \n + "{" \n + " _currentSV = _x getVariable ""supplyValue"";" \n + " _maxSV = _x getVariable ""maxSupplyValue"";" \n + " if (_currentSV < _maxSV && !_skip && _x !=_lastDestination) then {_closest = _x;_skip = true};" \n + "} forEach _loc;" \n + "" \n + "_currentSV = _closest getVariable ""supplyValue"";" \n + "if (_SV <= _currentSV) then {" \n + " _skip = false;" \n + " {" \n + " _currentSV = _x getVariable ""supplyValue"";" \n + " if (_currentSV > _SV && !_skip && _x distance _vehicle < _hq distance _vehicle && _lastDestination != _x) then {_possibleLoc = _x;_skip = true};" \n + " } forEach _loc;" \n + " if (isNull _possibleLoc) then {_possibleLoc = _hq};" \n + "};" \n + "" \n + "if (!isNull _possibleLoc) then {" \n + " _closest = _possibleLoc;" \n + " if (_possibleLoc == _hq) then {" \n + " _buildings = (str _side) Call GetSideStructures;" \n + " _checks = [_side,_spt,_buildings] Call GetFactories;" \n + " if (count _checks > 0) then {" \n + " _sorted = [_vehicle,_checks] Call SortByDistance;" \n + " _nearest = _sorted select 0;" \n + " _deployed = (str _side) Call GetSideHQDeployed;" \n + " if (_nearest distance _vehicle < _vehicle distance _hq || !_deployed || getDammage _hq >= 1) then {_closest = _nearest;_sp = _nearest};" \n + " };" \n + " };" \n + "};" \n + "" \n + "driver _vehicle doMove ([GetPos _closest,10,20] Call GetRandomPosition);"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global__Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 15"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Delivery + { + name = "Delivery"; + init = /*%FSM*/"_isDelivering = false;" \n + "_lastDestination = _closest;" \n + "if (_closest in towns) then {" \n + " _currentSV = _closest getVariable ""supplyValue"";" \n + " _maxSV = _closest getVariable ""maxSupplyValue"";" \n + " _sideDeliver = (_closest getVariable ""sideID"") Call GetSideFromID;" \n + " _upgrades = (_sideText) Call GetSideUpgrades;" \n + " _increaseOf = (Format[""WFBE_MAXSUPPLYTRUCKSSV%1"",_upgrades select 6] Call GetNamespace);" \n + " _requireChange = false;" \n + " if (_SV > _currentSV && _sideDeliver == _side) then {_currentSV = _currentSV + _increaseOf;_requireChange = true};" \n + " if (_currentSV > _maxSV) then {_currentSV = _maxSV;_requireChange = true};" \n + " if (_requireChange) then {_closest setVariable [""supplyValue"",_currentSV,true]};" \n + " _SV = _currentSV;" \n + "};" \n + "" \n + "_lastDelivery = time;" \n + "_closest = objNull;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global__Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 15"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Reload + { + name = "Reload"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Global__Checks"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastCheck > 15"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Truck_Init"; + finalStates[] = + { + "Truck_End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/townpatrol.fsm b/Server/FSM/townpatrol.fsm new file mode 100644 index 0000000..20b07da --- /dev/null +++ b/Server/FSM/townpatrol.fsm @@ -0,0 +1,217 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,4346,-27.775419,-111.166977,62.224556,-61.166962,0.000000,"Init"}; +item1[] = {"_",-1,250,-11.537962,23.713089,-8.193480,23.713089,0.000000,""}; +item2[] = {"_",8,218,-1.511484,-17.446537,36.912697,11.742107,0.000000,""}; +item3[] = {"Check",2,250,-28.138243,43.531616,61.861732,93.531563,0.000000,"Check"}; +item4[] = {"Team_is_Dead",4,218,96.689819,42.858948,186.689758,92.858955,1.000000,"Team is Dead"}; +item5[] = {"End",1,250,97.392929,120.390938,187.392944,170.390991,0.000000,"End"}; +item6[] = {"",7,210,203.696777,214.089935,211.696777,222.089935,0.000000,""}; +item7[] = {"Update",4,218,-27.899580,120.367233,62.100410,170.367279,0.000000,"Update"}; +item8[] = {"Change",2,250,-27.260115,192.051666,62.739876,242.051483,0.000000,"Change"}; +item9[] = {"",7,210,203.564392,-7.076275,211.564392,0.923725,0.000000,""}; +item10[] = {"Idle",4,218,-147.923401,44.465637,-57.923424,94.465645,0.000000,"Idle"}; +item11[] = {"Idle",2,250,-147.793304,-27.947792,-57.793274,22.052193,0.000000,"Idle"}; +version=1; +class LayoutItems +{ + class Item1 + { + class ItemInfo + { + FontFace="Arial"; + FontHeight=10; + lStyle=1; + }; + }; +}; +link0[] = {0,2}; +link1[] = {2,3}; +link2[] = {3,4}; +link3[] = {3,7}; +link4[] = {3,10}; +link5[] = {4,5}; +link6[] = {6,9}; +link7[] = {7,8}; +link8[] = {8,6}; +link9[] = {9,2}; +link10[] = {10,11}; +link11[] = {11,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,33,6316128,1,-256.373871,339.914581,308.677979,-157.313736,659,515,1}; +window[] = {0,-1,-1,-1,-1,939,274,1534,304,1,677}; +*//*%FSM*/ +class FSM +{ + fsmName = "townpatrol"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_location = _this select 0;" \n + "_team = _this select 1;" \n + "_sideID = _this select 2;" \n + "_focus = _this select 3;" \n + "_isReinforcement = _this select 4;" \n + "_name = vehicleVarName _location;" \n + "" \n + "_lastUpdate = - 60;" \n + "" \n + "_lastSV = _location getVariable 'supplyValue';" \n + "_startSV = _location getVariable 'startingSupplyValue';" \n + "_mode = ""patrol"";" \n + "_lastMode = ""nil"";" \n + "" \n + "_tudd = 'WFBE_TOWNUNITSDEFENSEDISTANCE' Call GetNamespace;" \n + "_tupd = 'WFBE_TOWNUNITSPATROLDISTANCE' Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 30;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check + { + name = "Check"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "_aliveTeam = if (count ((units _team) Call GetLiveUnits) == 0) then {false} else {true};" \n + "" \n + "_currentSV = _location getVariable 'supplyValue';" \n + "if (_currentSV < _lastSV || _currentSV < _startSV || _sideID != (_location getVariable 'sideID')) then {" \n + " _mode = ""defense"";" \n + "} else {" \n + " _mode = ""patrol"";" \n + "};" \n + "" \n + "_lastSV = _currentSV;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Team_is_Dead + { + priority = 1.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver || !_aliveTeam || isNull _team"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Idle + { + priority = 0.000000; + to="Idle"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_aliveTeam && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + priority = 0.000000; + to="Change"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_aliveTeam && _mode != _lastMode && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/"if (_isReinforcement) then {" \n + " if (_sideID == RESISTANCEID) then {" \n + " _reinf = _location getVariable ""reinforcements"";" \n + " _reinf = _reinf - 1;" \n + " _location setVariable [""reinforcements"",_reinf];" \n + " } else {" \n + " _reinf = _location getVariable ""reinforcements_occ"";" \n + " _reinf = _reinf - 1;" \n + " _location setVariable [""reinforcements_occ"",_reinf];" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Change + { + name = "Change"; + init = /*%FSM*/"_lastMode = _mode;" \n + "" \n + "if (_mode == ""patrol"") then {" \n + " if (isNull _focus) then {" \n + " [_team,_location,_tupd] Spawn AITownPatrol;" \n + " } else {" \n + " [_team,_focus,_tupd/4] Spawn AIPatrol;" \n + " };" \n + "} else {" \n + " [_team,getPos _location,_tudd,""Defend""] Spawn AITownResitance;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 30;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Idle + { + name = "Idle"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 30;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/updatecamp.fsm b/Server/FSM/updatecamp.fsm new file mode 100644 index 0000000..9a6d79e --- /dev/null +++ b/Server/FSM/updatecamp.fsm @@ -0,0 +1,259 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-63.253571,-299.618378,26.746418,-249.618469,0.000000,"Init"}; +item1[] = {"End",1,250,-182.368073,-113.480629,-92.368042,-63.480659,0.000000,"End"}; +item2[] = {"Gameover",4,218,-182.650177,-187.482422,-92.650192,-137.482452,0.000000,"Gameover"}; +item3[] = {"_",8,218,-34.448154,-230.434799,-2.642141,-207.859543,0.000000,""}; +item4[] = {"Camp_Core",2,250,-63.405182,-187.376434,26.594841,-137.376434,0.000000,"Camp Core"}; +item5[] = {"Camp_Advanced",2,4346,-64.617218,-39.786873,25.382790,10.213146,0.000000,"Camp" \n "Advanced"}; +item6[] = {"Empty",4,218,57.329758,-187.310150,147.329803,-137.310150,0.000000,"Empty"}; +item7[] = {"Not_Empty",4,218,-63.807266,-111.064079,26.192720,-61.064079,0.000000,"Not Empty"}; +item8[] = {"Capture",4,218,-182.872635,-39.579437,-92.872635,10.420566,0.000000,"Capture"}; +item9[] = {"Skip",4,218,57.688011,-38.769463,147.687988,11.230536,0.000000,"Skip"}; +item10[] = {"",7,210,215.273621,-222.741318,223.273621,-214.741318,0.000000,""}; +item11[] = {"_",2,250,174.323486,-38.769455,264.323486,11.230541,0.000000,""}; +item12[] = {"Capture",2,250,-301.937958,-38.769463,-211.937988,11.230541,0.000000,"Capture"}; +item13[] = {"",7,210,-260.177917,-222.741318,-252.177872,-214.741318,0.000000,""}; +link0[] = {0,3}; +link1[] = {2,1}; +link2[] = {3,4}; +link3[] = {4,2}; +link4[] = {4,6}; +link5[] = {4,7}; +link6[] = {5,8}; +link7[] = {5,9}; +link8[] = {6,11}; +link9[] = {7,5}; +link10[] = {8,12}; +link11[] = {9,11}; +link12[] = {10,3}; +link13[] = {11,10}; +link14[] = {12,13}; +link15[] = {13,3}; +globals[] = {0.000000,0,0,0,0,640,480,1,29,6316128,1,-374.429932,315.755920,137.483551,-318.334381,885,911,1}; +window[] = {2,-1,-1,-1,-1,802,50,1435,50,3,903}; +*//*%FSM*/ +class FSM +{ + fsmName = "updatecamp"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = -5;" \n + "" \n + "_camp = _this Select 0;" \n + "_town = _this Select 1;" \n + "_flag = _this Select 2;" \n + "" \n + "_delay = 3;" \n + "_timeToCapture = 0;" \n + "_townName = str _town;" \n + "_campName = Str _camp;" \n + "" \n + "_townSideID = _town getVariable ""sideID"";" \n + "_supply = _town getVariable ""supplyValue"";" \n + "_tcmode = 'WFBE_TOWNCONQUESTMODE' Call GetNamespace;" \n + "_lastSupply = _supply;" \n + "" \n + "_awaits = _delay;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Camp_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Camp_Core + { + name = "Camp_Core"; + init = /*%FSM*/"_lastUpdate = time + random(0.2);" \n + "" \n + "_objects = _camp NearEntities[""Man"",5];" \n + "_livingUnits = _objects Call GetLiveUnits;" \n + "_west = West CountSide _livingUnits;" \n + "_east = East CountSide _livingUnits;" \n + "" \n + "_awaits = (_delay) Call GetSleepFPS;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Empty + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_east == 0 && _west == 0 && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Not_Empty + { + priority = 0.000000; + to="Camp_Advanced"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"(_east != 0 || _west != 0) && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Camp_Advanced + { + name = "Camp_Advanced"; + init = /*%FSM*/"_skip = false;" \n + "_capture = false;" \n + "" \n + "_sideID = _camp getVariable ""sideID"";" \n + "_supply = _town getVariable ""supplyValue"";" \n + "_timeToCapture = _camp getVariable ""supplyValue"";" \n + "_townSideID = _town getVariable ""sideID"";" \n + "" \n + "if (_tcmode > 0) then {" \n + " if (_west > 0 && !(_town getVariable ""wfbe_cancap_w"") && (_townSideID != WESTID)) then {_west = 0;_skip = true};" \n + " if (_east > 0 && !(_town getVariable ""wfbe_cancap_e"") && (_townSideID != EASTID)) then {_east = 0; _skip = true};" \n + "};" \n + "" \n + "_force = (_east + _west) * _delay;" \n + "if (_sideID == EASTID && _east > 0) then {_timeToCapture = _timeToCapture + _east};" \n + "if (_sideID == EASTID && _west > 0) then {_timeToCapture = _timeToCapture - _west};" \n + "if (_sideID == WESTID && _west > 0) then {_timeToCapture = _timeToCapture + _west};" \n + "if (_sideID == WESTID && _east > 0) then {_timeToCapture = _timeToCapture - _east};" \n + "if (_sideID != EASTID && _sideID != WESTID) then {_timeToCapture = _timeToCapture - _force};" \n + "if (_timeToCapture > _supply) then {_timeToCapture = _supply};" \n + "if (_timeToCapture <= 0) then {_skip = true;_capture = true};" \n + "if (!_skip) then {" \n + " if (_timeToCapture == _lastSupply && _force == 0 && _sideID == _townSideID) then {_timeToCapture = _supply};" \n + " _lastSupply = _supply;" \n + " if (_timeToCapture == (_camp getVariable ""supplyValue"")) then {_skip = true};" \n + " if (!_skip) then {_camp setVariable [""supplyValue"",_timeToCapture,true]};" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_capture"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Capture + { + priority = 0.000000; + to="Capture"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_capture"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class _ + { + name = "_"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Camp_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Capture + { + name = "Capture"; + init = /*%FSM*/"_captureSideID = WESTID;" \n + "if (_sideID == WESTID || (_sideID == RESISTANCEID && _east > 0)) then {_captureSideID = EASTID};" \n + "_side = _sideID Call GetSideFromID;" \n + "if (_sideID == WESTID || _sideID == EASTID) then {[""LostAt"",""Strongpoint"",_side,_town] Spawn SideMessage};" \n + "_camp setVariable [""sideID"",_captureSideID,true];" \n + "WFBE_CampCaptured = [nil,'CLTFNCCAMPCAPTURED',[_town,_captureSideID,_camp]];" \n + "publicVariable 'WFBE_CampCaptured';" \n + "if (isHostedServer) then {[nil,'CLTFNCCAMPCAPTURED',[_town,_captureSideID,_camp]] Spawn HandlePVF};" \n + "_side = _captureSideID Call GetSideFromID;" \n + "if (_captureSideID != RESISTANCEID) then {[""CapturedNear"",""Strongpoint"",_side,_town] Spawn SideMessage};" \n + "_texture = Format[""WFBE_%1FLAG"",str _side] Call GetNamespace;" \n + "_flag setFlagTexture _texture;" \n + "if (_townSideID == _captureSideID) then {_timeToCapture = _supply};" \n + "if (_townSideID != _captureSideID) then {_timeToCapture = _town getVariable ""startingSupplyValue""};" \n + "_sideID = _captureSideID;" \n + "_camp setVariable [""supplyValue"",_timeToCapture,true];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Camp_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/updateresources.fsm b/Server/FSM/updateresources.fsm new file mode 100644 index 0000000..1cc127d --- /dev/null +++ b/Server/FSM/updateresources.fsm @@ -0,0 +1,212 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,66.287125,-127.850632,156.287064,-77.850792,0.000000,"Init"}; +item1[] = {"Update_Resources",2,4346,-66.836029,-56.267544,23.163887,-6.267582,0.000000,"Update" \n "Resources"}; +item2[] = {"End",1,250,-218.006683,15.304325,-128.006653,65.304314,0.000000,"End"}; +item3[] = {"Loop",4,218,65.605347,-56.267605,155.605377,-6.267574,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-216.668854,-56.267559,-126.668869,-6.267574,0.000000,"Gameover"}; +link0[] = {0,3}; +link1[] = {1,3}; +link2[] = {1,4}; +link3[] = {3,1}; +link4[] = {4,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,15,6316128,1,-288.082031,288.081207,332.960358,-262.037384,673,695,1}; +window[] = {0,-1,-1,-1,-1,855,87,1570,45,1,691}; +*//*%FSM*/ +class FSM +{ + fsmName = "updateresources"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = time;" \n + "_is = 'WFBE_INCOMESYSTEM' Call GetNamespace;" \n + "_ii = 'WFBE_INCOMEINTERVAL' Call GetNamespace;" \n + "_allies = 'WFBE_ALLIES' Call GetNamespace;" \n + "" \n + "_wTeams = ('WFBE_WESTTEAMS' Call GetNamespace);" \n + "_eTeams = ('WFBE_EASTTEAMS' Call GetNamespace);" \n + "_awaits = _ii;" \n + "" \n + "_incomeCoef = 0;" \n + "_divisor = 0;" \n + "_com_income_w = 0;" \n + "_com_income_e = 0;" \n + "_ply_income_w = 0;" \n + "_ply_income_e = 0;" \n + "if (_is == 3) then {_incomeCoef = 'WFBE_INC_COEFFICIENT' Call GetNamespace;_divisor = 'WFBE_INC_DIVIDE_COM' Call GetNamespace;};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Resources"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Resources + { + name = "Update_Resources"; + init = /*%FSM*/"_eastIncome = 0;" \n + "_westIncome = 0;" \n + "_eastSupply = 0;" \n + "_westSupply = 0;" \n + "" \n + "//--- Income Getter." \n + "{" \n + " _side = (_x getVariable ""sideID"") Call GetSideFromID;" \n + " if (_side == East) then {" \n + " switch (_is) do {" \n + " case 3: {_eastIncome = _eastIncome + ((_x getVariable ""supplyValue"")*_incomeCoef)};" \n + " default {_eastIncome = _eastIncome + (_x getVariable ""supplyValue"")};" \n + " };" \n + " _eastSupply = _eastSupply + (_x getVariable ""supplyValue"");" \n + " };" \n + " if (_side == West) then {" \n + " switch (_is) do {" \n + " case 3: {_westIncome = _westIncome + ((_x getVariable ""supplyValue"")*_incomeCoef)};" \n + " default {_westIncome = _westIncome + (_x getVariable ""supplyValue"")};" \n + " };" \n + " _westSupply = _westSupply + (_x getVariable ""supplyValue"");" \n + " };" \n + "} forEach towns;" \n + "" \n + "//--- Half Income." \n + "if (_is == 2) then {" \n + " _eastIncome = round(_eastIncome / 2);" \n + " _westIncome = round(_westIncome / 2);" \n + "};" \n + "" \n + "//--- Commander System" \n + "switch (_is) do {" \n + " case 3: {" \n + " _ply_income_w = round(_westIncome * (((100 - WestCommanderPercent)/100)/maxPlayers));" \n + " _ply_income_e = round(_eastIncome * (((100 - EastCommanderPercent)/100)/maxPlayers));" \n + " _com_income_w = round((_westIncome * (WestCommanderPercent/100)) / _divisor)+_ply_income_w;" \n + " _com_income_e = round((_eastIncome * (EastCommanderPercent/100)) / _divisor)+_ply_income_e;" \n + " };" \n + " case 4: {" \n + " _ply_income_w = round(_westIncome * (100 - WestCommanderPercent)/100);" \n + " _ply_income_e = round(_eastIncome * (100 - EastCommanderPercent)/100);" \n + " _com_income_w = round((_westIncome - _ply_income_w)*maxPlayers) + _ply_income_w;" \n + " _com_income_e = round((_eastIncome - _ply_income_e)*maxPlayers) + _ply_income_e;" \n + " };" \n + "};" \n + "" \n + "//---- East Income, only updates if necessary." \n + "if (_eastIncome > 0) then {" \n + " if !(paramMoneyOnly) then {[east, _eastSupply] Call ChangeSideSupply};" \n + " " \n + " _comTeam = (east) Call GetCommanderTeam;" \n + " if (isNull _comTeam) then {_comTeam = grpNull};" \n + "" \n + " {" \n + " if !(isNil '_x') then {" \n + " //--- AI." \n + " _income = 0;" \n + " switch (_is) do {" \n + " case 3: {_income = if (_comTeam != _x) then {_ply_income_e} else {_com_income_e}};" \n + " case 4: {_income = if (_comTeam != _x) then {_ply_income_e} else {_com_income_e}};" \n + " default {if !(isPlayer (leader _x)) then {_income = _eastIncome}};" \n + " };" \n + " " \n + " if (_income != 0) then {[_x,_income] Call ChangeTeamFunds};" \n + " };" \n + " } forEach _eTeams;" \n + "" \n + " if (isNull((east) Call GetCommanderTeam) && paramAIcom) then {" \n + " [east, _eastIncome] Call ChangeAICommanderFunds;" \n + " };" \n + "};" \n + "" \n + "//---- West Income, only updates if necessary." \n + "if (_westIncome > 0) then {" \n + " if !(paramMoneyOnly) then {[west, _westSupply] Call ChangeSideSupply};" \n + " " \n + " _comTeam = (west) Call GetCommanderTeam;" \n + " if (isNull _comTeam) then {_comTeam = grpNull};" \n + "" \n + " {" \n + " if !(isNil '_x') then {" \n + " //--- AI." \n + " _income = 0;" \n + " switch (_is) do {" \n + " case 3: {_income = if (_comTeam != _x) then {_ply_income_w} else {_com_income_w}};" \n + " case 4: {_income = if (_comTeam != _x) then {_ply_income_w} else {_com_income_w}};" \n + " default {if !(isPlayer (leader _x)) then {_income = _westIncome}};" \n + " };" \n + " " \n + " if (_income != 0) then {[_x,_income] Call ChangeTeamFunds};" \n + " };" \n + " } forEach _wTeams;" \n + "" \n + " if (isNull((west) Call GetCommanderTeam) && paramAIcom) then {" \n + " [west, _westIncome] Call ChangeAICommanderFunds;" \n + " };" \n + "};" \n + "" \n + "//--- Allies." \n + "if (_allies > 0) then {" \n + " westAlliesFunds = westAlliesFunds + _westIncome;" \n + " eastAlliesFunds = eastAlliesFunds + _eastIncome;" \n + "};" \n + "" \n + "_awaits = (_ii) Call GetSleepFPS;" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Resources"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/updateserver.fsm b/Server/FSM/updateserver.fsm new file mode 100644 index 0000000..1a7cd75 --- /dev/null +++ b/Server/FSM/updateserver.fsm @@ -0,0 +1,424 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,68.844200,-235.317032,158.844086,-185.317093,0.000000,"Init"}; +item1[] = {"Loop",4,218,69.950378,-54.529591,159.950424,-4.529562,0.000000,"Loop"}; +item2[] = {"End",1,250,71.371758,179.546143,161.371826,229.546112,0.000000,"End"}; +item3[] = {"Loop",4,218,-30.854136,-55.398598,59.145935,-5.398569,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,71.840584,101.891243,161.840546,151.891220,0.000000,"Gameover"}; +item5[] = {"_",8,218,96.687485,-169.297226,128.493500,-146.721985,0.000000,""}; +item6[] = {"Wait",2,250,67.782181,-122.639091,157.782181,-72.639091,0.000000,"Wait"}; +item7[] = {"Annihilation",2,250,-30.415300,33.022167,59.584702,83.022156,0.000000,"Annihilation"}; +item8[] = {"Assassination",2,250,70.389214,33.891174,160.389175,83.891144,0.000000,"Assassination"}; +item9[] = {"Loop",4,218,171.623901,-54.529591,261.623230,-4.529560,0.000000,"Loop"}; +item10[] = {"Supremacy",2,250,172.062729,33.891171,262.062012,83.891174,0.000000,"Supremacy"}; +item11[] = {"_",2,250,-61.980644,102.236549,28.019346,152.236542,0.000000,""}; +item12[] = {"_",4,218,-61.980686,179.758133,28.019318,229.758133,0.000000,""}; +item13[] = {"Town",2,250,275.342438,33.587734,365.342438,83.587723,0.000000,"Town"}; +item14[] = {"Loop",4,4314,275.618805,-53.185108,365.618805,-3.185127,0.000000,"Loop"}; +link0[] = {0,5}; +link1[] = {1,8}; +link2[] = {3,7}; +link3[] = {4,11}; +link4[] = {5,6}; +link5[] = {6,1}; +link6[] = {6,3}; +link7[] = {6,9}; +link8[] = {6,14}; +link9[] = {7,3}; +link10[] = {7,4}; +link11[] = {8,1}; +link12[] = {8,4}; +link13[] = {9,10}; +link14[] = {10,4}; +link15[] = {10,9}; +link16[] = {11,12}; +link17[] = {12,2}; +link18[] = {13,4}; +link19[] = {13,14}; +link20[] = {14,13}; +globals[] = {0.000000,0,0,0,0,640,480,1,24,6316128,1,-124.082573,468.916992,194.838867,-216.614029,595,514,1}; +window[] = {0,-1,-1,-1,-1,834,200,1460,200,1,613}; +*//*%FSM*/ +class FSM +{ + fsmName = "updateserver"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = time;" \n + "_winTime = time;" \n + "" \n + "_vc = 'WFBE_VICTORYCONDITION' Call GetNamespace;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Wait"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/"diag_log Format[""[WFBE (OUTRO)][frameno:%1 | ticktime:%2] updateserver.fsm: Mission end - [Done]"",diag_frameno,diag_tickTime];" \n + "failMission ""END1"";"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Wait + { + name = "Wait"; + init = /*%FSM*/"_total = totalTowns;" \n + "_westTowns = 0;" \n + "_eastTowns = 0;" \n + "{_sideID = _x getVariable ""sideID"";if (_sideID == WESTID) then {_westTowns = _westTowns + 1};if (_sideID == EASTID) then {_eastTowns = _eastTowns + 1}} ForEach towns;" \n + ""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Annihilation"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop_1 + { + priority = 0.000000; + to="Supremacy"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 2"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop_2 + { + priority = 0.000000; + to="Town"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 3"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop_3 + { + priority = 0.000000; + to="Assassination"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 1"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Annihilation + { + name = "Annihilation"; + init = /*%FSM*/"_westMHQ = WestMHQ;" \n + "_eastMHQ = EastMHQ;" \n + "_westBuildings = WestBaseStructures;" \n + "_eastBuildings = EastBaseStructures;" \n + "" \n + "_westMHQAlive = true;" \n + "_eastMHQAlive = true;" \n + "if (isNull _westMHQ || getDammage _westMHQ >= 1) then {_westMHQAlive = false};" \n + "if (isNull _eastMHQ || getDammage _eastMHQ >= 1) then {_eastMHQAlive = false};" \n + "" \n + "//--- East Win." \n + "if ((count _westBuildings == 0)&&(!_westMHQAlive) && !gameOver) then {" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",east];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "//--- West Win." \n + "if ((count _eastBuildings == 0)&&(!_eastMHQAlive) && !gameOver) then {" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[WESTID,_westBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[WESTID,_westBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",west];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Annihilation"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Assassination + { + name = "Assassination"; + init = /*%FSM*/"_westMHQ = WestMHQ;" \n + "_eastMHQ = EastMHQ;" \n + "_westBuildings = WestBaseStructures;" \n + "_eastBuildings = EastBaseStructures;" \n + "" \n + "_westMHQAlive = true;" \n + "_eastMHQAlive = true;" \n + "if (isNull _westMHQ || getDammage _westMHQ >= 1) then {_westMHQAlive = false};" \n + "if (isNull _eastMHQ || getDammage _eastMHQ >= 1) then {_eastMHQAlive = false};" \n + "" \n + "_westTowns = 0;" \n + "_eastTowns = 0;" \n + "{_sideID = _x getVariable ""sideID"";if (_sideID == WESTID) then {_westTowns = _westTowns + 1};if (_sideID == EASTID) then {_eastTowns = _eastTowns + 1}} ForEach towns;" \n + "" \n + "//--- East Win." \n + "if (!_westMHQAlive || (_eastTowns == _total) && !gameOver) then {" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",east];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "//--- West Win." \n + "if (!_eastMHQAlive || (_westTowns == _total) && !gameOver) then {" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[WESTID,_westBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[WESTID,_westBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",west];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Assassination"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 1"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Supremacy + { + name = "Supremacy"; + init = /*%FSM*/"_westMHQ = WestMHQ;" \n + "_eastMHQ = EastMHQ;" \n + "_westBuildings = WestBaseStructures;" \n + "_eastBuildings = EastBaseStructures;" \n + "" \n + "_westMHQAlive = true;" \n + "_eastMHQAlive = true;" \n + "if (isNull _westMHQ || getDammage _westMHQ >= 1) then {_westMHQAlive = false};" \n + "if (isNull _eastMHQ || getDammage _eastMHQ >= 1) then {_eastMHQAlive = false};" \n + "" \n + "_westTowns = 0;" \n + "_eastTowns = 0;" \n + "{_sideID = _x getVariable ""sideID"";if (_sideID == WESTID) then {_westTowns = _westTowns + 1};if (_sideID == EASTID) then {_eastTowns = _eastTowns + 1}} ForEach towns;" \n + "" \n + "_westFactories = 0;" \n + "_eastFactories = 0;" \n + "{" \n + " _tmp = count([west,Format [""WFBE_WEST%1TYPE"",_x] Call GetNamespace,_westBuildings] Call GetFactories);" \n + " _westFactories = _westFactories + _tmp;" \n + " _tmp = count([east,Format [""WFBE_EAST%1TYPE"",_x] Call GetNamespace,_eastBuildings] Call GetFactories);" \n + " _eastFactories = _eastFactories + _tmp;" \n + "} forEach [""BARRACKS"",""LIGHT"",""HEAVY"",""AIRCRAFT""];" \n + "" \n + "//--- East Win." \n + "if (!_westMHQAlive && _westFactories == 0 || (_eastTowns == _total) && !gameOver) then {" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",east];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "//--- West Win." \n + "if (!_eastMHQAlive && _eastFactories == 0 || (_westTowns == _total) && !gameOver) then {" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[WESTID,_westBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[WESTID,_westBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",west];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Supremacy"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 2"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class _ + { + name = "_"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _winTime > 20"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Town + { + name = "Town"; + init = /*%FSM*/"_westTowns = 0;" \n + "_eastTowns = 0;" \n + "{_sideID = _x getVariable ""sideID"";if (_sideID == WESTID) then {_westTowns = _westTowns + 1};if (_sideID == EASTID) then {_eastTowns = _eastTowns + 1}} ForEach towns;" \n + "" \n + "//--- East Win." \n + "if (_eastTowns == _total && !gameOver) then {" \n + " _eastBuildings = EastBaseStructures;" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[EASTID,_eastBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",east];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "//--- West Win." \n + "if (_westTowns == _total && !gameOver) then {" \n + " _westBuildings = WestBaseStructures;" \n + " WFBE_EndGame = [nil,'CLTFNCENDGAME',[WESTID,_westBuildings]];" \n + " publicVariable 'WFBE_EndGame';" \n + " if (isHostedServer) then {[nil,'CLTFNCENDGAME',[WESTID,_westBuildings]] Spawn HandlePVF};" \n + " WF_Logic setVariable [""WF_Winner"",west];" \n + " gameOver = true;" \n + " _winTime = time;" \n + "};" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Town"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 20 && !gameOver && _vc == 3"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ diff --git a/Server/FSM/updatetown.fsm b/Server/FSM/updatetown.fsm new file mode 100644 index 0000000..d494788 --- /dev/null +++ b/Server/FSM/updatetown.fsm @@ -0,0 +1,595 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-63.537106,-304.001923,26.462904,-254.002228,0.000000,"Init"}; +item1[] = {"End",1,250,-182.368073,-113.480629,-92.368042,-63.480659,0.000000,"End"}; +item2[] = {"Gameover",4,218,-182.650177,-187.482422,-92.650192,-137.482452,0.000000,"Gameover"}; +item3[] = {"_",8,218,-34.448154,-230.434799,-2.642141,-207.859543,0.000000,""}; +item4[] = {"Town_Core",2,250,-63.405182,-187.376434,26.594841,-137.376434,0.000000,"Town Core"}; +item5[] = {"Time_Supply",4,218,53.706718,-187.309784,143.706726,-137.309799,0.000000,"Time" \n "Supply"}; +item6[] = {"Empty",4,218,-182.574295,-36.908699,-92.574234,13.091309,0.000000,"Empty"}; +item7[] = {"Not_Empty",4,218,-64.729942,42.105545,25.270105,92.105507,0.000000,"Not Empty"}; +item8[] = {"Normal_Supply",4,218,-63.477135,-114.415787,26.522726,-64.415848,0.000000,"Normal" \n "Supply"}; +item9[] = {"Check",2,250,-64.187141,-36.072510,25.812870,13.927521,0.000000,"Check"}; +item10[] = {"Time_Supply",2,250,54.842167,-111.734596,144.842194,-61.734596,0.000000,"Time Supply"}; +item11[] = {"_",8,218,84.156120,-22.145014,115.962143,0.430260,0.000000,""}; +item12[] = {"_",2,250,-300.613251,-37.831039,-210.613235,12.168960,0.000000,""}; +item13[] = {"",7,210,-260.014130,-223.295425,-252.014069,-215.295425,0.000000,""}; +item14[] = {"Town_Advanced",2,4346,-67.838142,416.225128,22.161905,466.225098,0.000000,"Town Advanced"}; +item15[] = {"Captured",4,218,48.796371,416.225128,138.796494,466.225098,0.000000,"Captured"}; +item16[] = {"Skip",4,218,-302.480042,416.225128,-212.479980,466.225159,0.000000,"Skip"}; +item17[] = {"Captured",2,250,169.032181,416.024658,259.032227,466.024719,0.000000,"Captured"}; +item18[] = {"",7,210,210.899033,-223.047119,218.899048,-215.047119,0.000000,""}; +item19[] = {"Pick_Capture_Mod",2,250,-64.359787,111.495216,25.640230,161.495224,0.000000,"Pick Capture" \n "Mode"}; +item20[] = {"Threshold",4,218,-66.673355,182.056427,23.326881,232.056427,0.000000,"Threshold"}; +item21[] = {"Classic",4,218,-182.347382,110.338463,-92.347397,160.338455,0.000000,"Classic"}; +item22[] = {"Set_Classic",2,250,-182.257019,253.936035,-92.256966,303.936127,0.000000,"Set Classic"}; +item23[] = {"Set_Threshold",2,250,-66.763634,253.774261,23.236481,303.774231,0.000000,"Set Threshold"}; +item24[] = {"_",8,218,-37.573990,342.842560,-4.796462,363.201202,0.000000,""}; +item25[] = {"All_Camps",4,218,58.254791,111.494164,148.254791,161.494156,0.000000,"All Camps"}; +item26[] = {"Set_All_Camps",2,250,58.345169,254.115845,148.345154,304.115936,0.000000,"Set All Camps"}; +link0[] = {0,3}; +link1[] = {2,1}; +link2[] = {3,4}; +link3[] = {4,2}; +link4[] = {4,5}; +link5[] = {4,8}; +link6[] = {5,10}; +link7[] = {6,12}; +link8[] = {7,19}; +link9[] = {8,9}; +link10[] = {9,6}; +link11[] = {9,7}; +link12[] = {10,11}; +link13[] = {11,9}; +link14[] = {12,13}; +link15[] = {13,3}; +link16[] = {14,15}; +link17[] = {14,16}; +link18[] = {15,17}; +link19[] = {16,12}; +link20[] = {17,18}; +link21[] = {18,3}; +link22[] = {19,20}; +link23[] = {19,21}; +link24[] = {19,25}; +link25[] = {20,23}; +link26[] = {21,22}; +link27[] = {22,24}; +link28[] = {23,24}; +link29[] = {24,14}; +link30[] = {25,26}; +link31[] = {26,24}; +globals[] = {0.000000,0,0,0,0,640,480,1,62,6316128,1,-329.233032,316.761841,541.239014,-274.360809,518,624,1}; +window[] = {0,-1,-1,-1,-1,944,175,1435,175,1,536}; +*//*%FSM*/ +class FSM +{ + fsmName = "updatetown"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = -10;" \n + "" \n + "_location = _this select 0;" \n + "_detectionRange = _this select 1;" \n + "_name = Str _location;" \n + "" \n + "_startingSupplyValue = _location getVariable ""startingSupplyValue"";" \n + "_maxSupplyValue = _location getVariable ""maxSupplyValue"";" \n + "_timeAttacked = time - 60;" \n + "_activeEnemies = 0;" \n + "_force = 0;" \n + "_lastUp = 0;" \n + "_mccr = 'WFBE_MAXCAMPCAPTURERATE' Call GetNamespace;" \n + "_ss = 'WFBE_SUPPLYSYSTEM' Call GetNamespace;" \n + "_ssi = 'WFBE_SUPPLYSYSTEMINCREASETIME' Call GetNamespace;" \n + "_tcr = 'WFBE_TOWNCAPTURERANGE' Call GetNamespace;" \n + "_tcrate = 'WFBE_TOWNCAPTURERATE' Call GetNamespace;" \n + "_tcmode = 'WFBE_TOWNCONQUESTMODE' Call GetNamespace;" \n + "" \n + "_delay = 5;" \n + "_awaits = _delay;" \n + "" \n + "_tcm = 'WFBE_TOWNCAPTUREMODE' Call GetNamespace;" \n + "if (_tcm == 1) then {_tcr = 'WFBE_TOWNCAPTURERANGETHRESHOLD' Call GetNamespace };//--- Threshold Mode." \n + "" \n + "_timeSupply = if (_ss == 1) then {true} else {false};" \n + "" \n + "_defenses = _location NearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_detectionRange];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Town_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Town_Core + { + name = "Town_Core"; + init = /*%FSM*/"_lastUpdate = time + random (0.2);" \n + "" \n + "_sideID = _location getVariable ""sideID"";" \n + "_objects = _location nearEntities[[eastSoldierBaseClass,westSoldierBaseClass,resistanceSoldierBaseClass,""Car"",""Motorcycle"",""Tank"",""Air""],_tcr];" \n + "" \n + "_awaits = (_delay) Call GetSleepFPS;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Time_Supply + { + priority = 0.000000; + to="Time_Supply"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_timeSupply && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Normal_Supply + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_timeSupply && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check + { + name = "Check"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Not_Empty + { + priority = 0.000000; + to="Pick_Capture_Mod"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"count _objects > 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Empty + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"count _objects == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Time_Supply + { + name = "Time_Supply"; + init = /*%FSM*/"_objects = _location NearEntities[[eastSoldierBaseClass,westSoldierBaseClass,resistanceSoldierBaseClass,""Car"",""Motorcycle"",""Tank"",""Air""],(_tcr*2)];" \n + "_objects = (_objects Call GetLiveUnits) unitsBelowHeight 200;" \n + "_side = _sideID Call GetSideFromID;" \n + "_activeEnemies = (East countSide _objects) + (Resistance countSide _objects);" \n + "if (_side == East) then {_activeEnemies = (West countSide _objects) + (Resistance countSide _objects)};" \n + "if (_sideID != RESISTANCEID && _activeEnemies == 0) then {" \n + " _lastUp = _lastUp + 5;" \n + " if (_lastUp >= _ssi) then {" \n + " _lastUp = 0;" \n + " _upgrades = (str _side) Call GetSideUpgrades;" \n + " _increaseOf = (Format[""WFBE_SUPPLYSYSTEMINCREASE%1"",_upgrades select 6] Call GetNamespace);" \n + " _supplyValue = _location getVariable ""supplyValue"";" \n + " _supplyValue = _supplyValue + _increaseOf;" \n + " if (_supplyValue > _maxSupplyValue) then {_supplyValue = _maxSupplyValue};" \n + " _location setVariable [""supplyValue"",_supplyValue,true];" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Check"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class _ + { + name = "_"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Town_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Town_Advanced + { + name = "Town_Advanced"; + init = /*%FSM*/"if !(_skip) then {" \n + " if (_tcmode > 0) then {" \n + " if (_west > 0 && !(_location getVariable ""wfbe_cancap_w"")) then {_west = 0};" \n + " if (_east > 0 && !(_location getVariable ""wfbe_cancap_e"")) then {_east = 0};" \n + " };" \n + "" \n + " _rate = _tcrate;" \n + " if (_east > 0) then {_rate = _tcrate * ([_location,East] Call GetTotalCampsOnSide) / (_location Call GetTotalCamps) * _mccr};" \n + " if (_west > 0) then {_rate = _tcrate * ([_location,West] Call GetTotalCampsOnSide) / (_location Call GetTotalCamps) * _mccr};" \n + " if (_rate < 1) then {_rate = 1};" \n + " if (_sideID == EASTID && (_west > 0 || _resistance > 0) && time - _timeAttacked > 60) then {_timeAttacked = time;[""IsUnderAttack"",_location,East,_name] Spawn SideMessage};" \n + " if (_sideID == WESTID && (_east > 0 || _resistance > 0) && time - _timeAttacked > 60) then {_timeAttacked = time;[""IsUnderAttack"",_location,West,_name] Spawn SideMessage};" \n + " _supplyValue = _location getVariable ""supplyValue"";" \n + " _supplyValue = round(_supplyValue - (_resistance + _east + _west) * _rate);" \n + " _location setVariable [""supplyValue"",_supplyValue,true];" \n + " if (_supplyValue < 1) then {_captured = true};" \n + "};" \n + "" \n + "if (_protected) then {" \n + " _supplyValue = _location getVariable ""supplyValue"";" \n + " if (_supplyValue < _startingSupplyValue) then {" \n + " _supplyValue = _supplyValue + _force * _tcrate;" \n + " if (_supplyValue > _startingSupplyValue) then {_supplyValue = _startingSupplyValue};" \n + " _location setVariable [""supplyValue"",_supplyValue,true];" \n + " };" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_captured"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Captured + { + priority = 0.000000; + to="Captured"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_captured"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Captured + { + name = "Captured"; + init = /*%FSM*/"_location setVariable [""supplyValue"",_startingSupplyValue,true];" \n + "_side = ""R"";" \n + "if (_west > 0) then {_side = ""W""};" \n + "if (_east > 0) then {_side = ""E""};" \n + "" \n + "switch (_side) do {" \n + " case 'R': {" \n + " if (_sideID == WESTID) then {" \n + " WFBE_TownCaptured = [nil,'CLTFNCTOWNCAPTURED',[_location,RESISTANCEID,WESTID]];" \n + " publicVariable 'WFBE_TownCaptured';" \n + " if (isHostedServer) then {[nil,'CLTFNCTOWNCAPTURED',[_location,RESISTANCEID,WESTID]] Spawn HandlePVF};" \n + " [""Lost"",_location,West] Spawn SideMessage;" \n + " };" \n + " if (_sideID == EASTID) then {" \n + " WFBE_TownCaptured = [nil,'CLTFNCTOWNCAPTURED',[_location,RESISTANCEID,EASTID]];" \n + " publicVariable 'WFBE_TownCaptured';" \n + " if (isHostedServer) then {[nil,'CLTFNCTOWNCAPTURED',[_location,RESISTANCEID,EASTID]] Spawn HandlePVF};" \n + " [""Lost"",_location,East] Spawn SideMessage;" \n + " };" \n + " _location setVariable [""sideID"",RESISTANCEID,true];" \n + " };" \n + " case 'E': {" \n + " if (_sideID == WESTID) then {" \n + " WFBE_TownCapturedPublic = [nil,'CLTFNCTOWNCAPTUREDPUBLIC',[_location,EASTID]];" \n + " publicVariable 'WFBE_TownCapturedPublic';" \n + " if (isHostedServer) then {[nil,'CLTFNCTOWNCAPTUREDPUBLIC',[_location,EASTID]] Spawn HandlePVF};" \n + " [""Lost"",_location,West] Spawn SideMessage;" \n + " };" \n + " if (_sideID == RESISTANCEID) then {" \n + " WFBE_TownCaptured = [nil,'CLTFNCTOWNCAPTURED',[_location,EASTID,EASTID]];" \n + " publicVariable 'WFBE_TownCaptured';" \n + " if (isHostedServer) then {[nil,'CLTFNCTOWNCAPTURED',[_location,EASTID,EASTID]] Spawn HandlePVF};" \n + " };" \n + " if (paramKeepCamps) then {[_location,East,_sideID Call GetSideFromID] Spawn SetCampsToSide};" \n + " _location setVariable [""sideID"",EASTID,true];" \n + " [""Captured"",_location,East] Spawn SideMessage;" \n + " };" \n + " case 'W': {" \n + " if (_sideID == EASTID) then {" \n + " WFBE_TownCapturedPublic = [nil,'CLTFNCTOWNCAPTUREDPUBLIC',[_location,WESTID]];" \n + " publicVariable 'WFBE_TownCapturedPublic';" \n + " if (isHostedServer) then {[nil,'CLTFNCTOWNCAPTUREDPUBLIC',[_location,WESTID]] Spawn HandlePVF};" \n + " [""Lost"",_location,East] Spawn SideMessage;" \n + " };" \n + " if (_sideID == RESISTANCEID) then {" \n + " WFBE_TownCaptured = [nil,'CLTFNCTOWNCAPTURED',[_location,WESTID,WESTID]];" \n + " publicVariable 'WFBE_TownCaptured';" \n + " if (isHostedServer) then {[nil,'CLTFNCTOWNCAPTURED',[_location,WESTID,WESTID]] Spawn HandlePVF};" \n + " };" \n + " if (paramKeepCamps) then {[_location,West,_sideID Call GetSideFromID] Spawn SetCampsToSide};" \n + " _location setVariable [""sideID"",WESTID,true];" \n + " [""Captured"",_location,West] Spawn SideMessage;" \n + " };" \n + "};" \n + "" \n + "{" \n + " if (!isPlayer(Gunner _x)) then {" \n + " _unit = (gunner _x);" \n + " if !(isNull _unit) then {_unit setPos (getpos _x);deleteVehicle _unit};" \n + " deleteVehicle _x;" \n + " };" \n + "} forEach _defenses;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Town_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > _awaits"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Pick_Capture_Mod + { + name = "Pick_Capture_Mod"; + init = /*%FSM*/"_livingUnits = (_objects Call GetLiveUnits) unitsBelowHeight 200;" \n + "_west = West CountSide _livingUnits;" \n + "_east = East CountSide _livingUnits;" \n + "_resistance = Resistance CountSide _livingUnits;" \n + "_skip = false;" \n + "_protected = false;" \n + "_captured = false;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Classic + { + priority = 0.000000; + to="Set_Classic"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_tcm == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class All_Camps + { + priority = 0.000000; + to="Set_All_Camps"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_tcm == 2"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Threshold + { + priority = 0.000000; + to="Set_Threshold"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_tcm == 1"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Set_Classic + { + name = "Set_Classic"; + init = /*%FSM*/"if (_sideID == RESISTANCEID && _resistance > 0) then {_force = _resistance;_protected = true;_skip = true};" \n + "if (_sideID == EASTID && _east > 0) then {_force = _east;_protected = true;_skip = true};" \n + "if (_sideID == WESTID && _west > 0) then {_force = _west;_protected = true;_skip = true};" \n + "" \n + "if (_east > 0 && _west > 0) then {_skip = true};" \n + "if (_west > 0 && _resistance > 0) then {_skip = true};" \n + "if (_resistance > 0 && _east > 0) then {_skip = true};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Town_Advanced"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Set_Threshold + { + name = "Set_Threshold"; + init = /*%FSM*/"_resistanceDominion = if (_resistance > _east && _resistance > _west) then {true} else {false};" \n + "_westDominion = if (_west > _east && _west > _resistance) then {true} else {false};" \n + "_eastDominion = if (_east > _west && _east > _resistance) then {true} else {false};" \n + "" \n + "if (_sideID == RESISTANCEID && _resistanceDominion) then {_force = _resistance;_protected = true;_skip = true};" \n + "if (_sideID == EASTID && _eastDominion) then {_force = _east;_protected = true;_skip = true};" \n + "if (_sideID == WESTID && _westDominion) then {_force = _west;_protected = true;_skip = true};" \n + "" \n + "if (_resistanceDominion) then {" \n + " _resistance = if (_east > _west) then {_resistance - _east} else {_resistance - _west};" \n + " _force = _resistance;" \n + " _east = 0; " \n + " _west = 0;" \n + "};" \n + "if (_westDominion) then {" \n + " _west = if (_east > _resistance) then {_west - _east} else {_west - _resistance};" \n + " _force = _west;" \n + " _east = 0;" \n + " _resistance = 0;" \n + "};" \n + "if (_eastDominion) then {" \n + " _east = if (_west > _resistance) then {_east - _west} else {_east - _resistance};" \n + " _force = _east;" \n + " _west = 0;" \n + " _resistance = 0;" \n + "};" \n + "" \n + "if (!_resistanceDominion && !_westDominion && !_eastDominion) then {_west = 0; _east = 0; _resistance = 0};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Town_Advanced"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Set_All_Camps + { + name = "Set_All_Camps"; + init = /*%FSM*/"_resistanceDominion = if (_resistance > _east && _resistance > _west) then {true} else {false};" \n + "_westDominion = if (_west > _east && _west > _resistance) then {true} else {false};" \n + "_eastDominion = if (_east > _west && _east > _resistance) then {true} else {false};" \n + "" \n + "if (_sideID == RESISTANCEID && _resistanceDominion) then {_force = _resistance;_protected = true;_skip = true};" \n + "if (_sideID == EASTID && _eastDominion) then {_force = _east;_protected = true;_skip = true};" \n + "if (_sideID == WESTID && _westDominion) then {_force = _west;_protected = true;_skip = true};" \n + "" \n + "if (_resistanceDominion) then {" \n + " _resistance = if (_east > _west) then {_resistance - _east} else {_resistance - _west};" \n + " _force = _resistance;" \n + " _east = 0; " \n + " _west = 0;" \n + "};" \n + "if (_westDominion) then {" \n + " _west = if (_east > _resistance) then {_west - _east} else {_west - _resistance};" \n + " _force = _west;" \n + " _east = 0;" \n + " _resistance = 0;" \n + "};" \n + "if (_eastDominion) then {" \n + " _east = if (_west > _resistance) then {_east - _west} else {_east - _resistance};" \n + " _force = _east;" \n + " _west = 0;" \n + " _resistance = 0;" \n + "};" \n + "" \n + "if (!_resistanceDominion && !_westDominion && !_eastDominion) then {_west = 0; _east = 0; _resistance = 0};" \n + "" \n + "_totalCamps = _location Call GetTotalCamps;" \n + "" \n + "if (_west > 0) then {" \n + " if (_totalCamps != ([_location,west] Call GetTotalCampsOnSide)) then {_skip = true};" \n + "};" \n + "if (_east > 0) then {" \n + " if (_totalCamps != ([_location,east] Call GetTotalCampsOnSide)) then {_skip = true};" \n + "};" \n + "//--- Resistance don't need all camps!" \n + "/*" \n + "if (_resistance > 0) then {" \n + " if (_totalCamps != ([_location,resistance] Call GetTotalCampsOnSide)) then {_skip = true};" \n + "};" \n + "*/"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Town_Advanced"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/updatetownai.fsm b/Server/FSM/updatetownai.fsm new file mode 100644 index 0000000..4c0baa5 --- /dev/null +++ b/Server/FSM/updatetownai.fsm @@ -0,0 +1,1377 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-81.542984,-257.577942,8.457038,-207.578140,0.000000,"Init"}; +item1[] = {"Loop",4,218,-81.400459,-164.956757,8.599551,-114.956772,0.000000,"Loop"}; +item2[] = {"Root",2,250,-81.695038,-84.595222,8.304958,-34.595226,0.000000,"Root"}; +item3[] = {"East____West",4,218,54.026054,-85.166306,144.026276,-35.166328,2.000000,"East || West"}; +item4[] = {"Resistance",4,218,-211.512375,-85.535400,-121.512367,-35.535374,1.000000,"Resistance"}; +item5[] = {"Enemies",2,250,-294.367432,85.381798,-204.367416,135.381744,0.000000,"Enemies"}; +item6[] = {"Enemies_1",2,250,121.220261,78.907684,211.220276,128.907654,0.000000,"Enemies"}; +item7[] = {"Clear",4,218,-437.596313,86.397621,-347.596313,136.397583,0.000000,"Clear"}; +item8[] = {"Hostile",4,218,-295.383301,171.725250,-205.383255,221.725250,0.000000,"Hostile"}; +item9[] = {"Hostile",4,218,121.220253,168.298737,211.220245,218.298767,0.000000,"Hostile"}; +item10[] = {"Clear",4,218,251.104004,79.940926,341.103973,129.940887,0.000000,"Clear"}; +item11[] = {"Update",2,250,-83.093033,145.655670,6.906990,195.655670,0.000000,"Update"}; +item12[] = {"East____West",4,218,51.054230,211.066879,141.054169,261.066833,2.000000,"East || West"}; +item13[] = {"Resistance",4,218,-225.570770,211.066833,-135.570770,261.066833,1.000000,"Resistance"}; +item14[] = {"Active",2,250,50.993599,303.105865,140.993622,353.105865,0.000000,"Active"}; +item15[] = {"Active_1",2,250,-226.321884,302.090027,-136.321869,352.090027,0.000000,"Active"}; +item16[] = {"Yes",4,218,-226.428909,389.984589,-136.428909,439.984589,0.000000,"Yes"}; +item17[] = {"No",4,218,-361.424255,303.105835,-271.424255,353.105835,0.000000,"No"}; +item18[] = {"Yes",4,218,50.993557,388.433655,140.993561,438.433655,0.000000,"Yes"}; +item19[] = {"No",4,218,180.001099,304.121643,270.001099,354.121643,0.000000,"No"}; +item20[] = {"Reinforcement",2,250,-228.026566,480.105957,-138.026550,530.105957,0.000000,"Reinforcement"}; +item21[] = {"Reinforcement_1",2,250,52.438057,477.071014,142.438080,527.070984,0.000000,"Reinforcement"}; +item22[] = {"Disabled",4,218,189.443558,474.997864,279.443420,524.997864,0.000000,"Disabled"}; +item23[] = {"Enabled",4,218,52.594284,569.904968,142.594299,619.904968,0.000000,"Enabled"}; +item24[] = {"Enabled",4,218,-227.136414,572.915527,-137.136414,622.915527,0.000000,"Enabled"}; +item25[] = {"Disabled",4,218,-356.889191,481.315216,-266.889191,531.315186,0.000000,"Disabled"}; +item26[] = {"Create_Teams",2,250,-504.760498,301.661316,-414.760498,351.661316,0.000000,"Create Teams"}; +item27[] = {"Filter_Out",2,250,312.391754,304.012329,402.391754,354.012329,0.000000,"Filter Out"}; +item28[] = {"Reinforce",2,250,-227.312881,661.195923,-137.312851,711.195923,0.000000,"Reinforce"}; +item29[] = {"Reinforce_1",2,4346,53.078735,665.977051,143.078766,715.977051,0.000000,"Reinforce"}; +item30[] = {"_",8,218,-61.027760,723.917419,-18.699284,749.470459,0.000000,""}; +item31[] = {"Resistance_Clean",2,250,-84.636703,800.070679,5.363308,850.070679,0.000000,"Resistance" \n "Clean" \n "Update"}; +item32[] = {"Activity",4,218,52.897964,800.575867,142.897949,850.575867,0.000000,"Activity"}; +item33[] = {"Skip",4,218,-84.158691,894.561279,5.841303,944.561279,1.000000,"Skip"}; +item34[] = {"Check_Time",2,250,197.415848,801.073425,287.415894,851.073425,0.000000,"Check Time"}; +item35[] = {"Occupation_Clean",2,250,-84.477402,988.013367,5.522614,1038.013428,0.000000,"Occupation" \n "Clean" \n "Update"}; +item36[] = {"_",8,218,516.491821,999.625427,558.820740,1025.178345,0.000000,""}; +item37[] = {"Activity",4,218,-227.812027,987.478455,-137.812027,1037.478271,0.000000,"Activity"}; +item38[] = {"Skip",4,218,-85.511490,1086.126953,4.488537,1136.126953,0.000000,"Skip"}; +item39[] = {"Check_Time_1",2,250,-362.144073,988.819214,-272.144043,1038.819214,0.000000,"Check Time"}; +item40[] = {"Skip",2,250,-356.665619,712.646545,-266.665619,762.646545,0.000000,"Skip"}; +item41[] = {"Skip_1",2,250,188.821106,711.607605,278.821106,761.607605,0.000000,"Skip"}; +item42[] = {"_",2,250,-720.830017,1086.698120,-630.829895,1136.698120,0.000000,""}; +item43[] = {"_",8,218,-614.807983,900.023926,-572.479492,925.577576,0.000000,""}; +item44[] = {"",7,210,-681.073242,-142.960266,-673.073242,-134.960266,0.000000,""}; +item45[] = {"Ground",4,218,313.725525,398.264923,403.725525,448.264923,0.000000,"Ground"}; +item46[] = {"",7,210,548.178650,101.751083,556.178650,109.751068,0.000000,""}; +item47[] = {"",7,210,557.477966,730.003906,565.478027,738.003906,0.000000,""}; +item48[] = {"",7,210,-641.013123,25.217754,-633.013123,33.217751,0.000000,""}; +item49[] = {"",7,210,-641.013062,733.310120,-633.013000,741.310120,0.000000,""}; +item50[] = {"Air",4,218,450.295349,303.113800,540.295410,353.113800,0.000000,"Air"}; +item51[] = {"Create_Teams_1",2,250,312.606049,503.490906,402.606079,553.490906,0.000000,"Create" \n "Teams"}; +item52[] = {"Create_AA_Teams",2,250,451.414673,503.490906,541.414734,553.490906,0.000000,"Create" \n "AA Teams"}; +item53[] = {"_",8,218,404.726166,577.962646,447.054626,603.515686,0.000000,""}; +item54[] = {"Civilians",4,218,-627.123352,300.957153,-537.123352,350.957153,0.000000,"Civilians"}; +item55[] = {"No_Civilians",4,218,-503.680084,396.450958,-413.680084,446.450958,0.000000,"No Civilians"}; +item56[] = {"Create_Civilians",2,250,-624.794250,497.767517,-534.794250,547.767517,0.000000,"Create Civilians"}; +item57[] = {"Skip_2",2,250,-503.680115,494.273926,-413.680084,544.273926,0.000000,"Skip"}; +item58[] = {"_",8,218,-546.874634,573.304443,-504.546204,598.857483,0.000000,""}; +item59[] = {"Gameover",4,218,-81.332367,-8.259530,8.667633,41.740471,0.000000,"Gameover"}; +item60[] = {"End",1,250,-79.733475,64.343887,10.266556,114.343887,0.000000,"End"}; +item61[] = {"Ready",4,218,345.695007,799.360779,435.695007,849.360779,0.000000,"Ready"}; +item62[] = {"Wait",4,218,198.982651,893.935669,288.982666,943.935669,0.000000,"Wait"}; +item63[] = {"Remove_Resistanc",2,250,493.620056,800.573181,583.620056,850.573181,0.000000,"Remove" \n "Resistance"}; +item64[] = {"Ready",4,218,-360.421417,889.169373,-270.421417,939.169373,0.000000,"Ready"}; +item65[] = {"Wait",4,218,-509.167969,988.333862,-419.167999,1038.333740,0.000000,"Wait"}; +item66[] = {"Remove_Occupatio",2,250,-510.321045,888.016357,-420.321045,938.016357,0.000000,"Remove" \n "Occupation"}; +item67[] = {"Occupation_Etat",2,250,177.150528,-86.332535,267.150513,-36.332535,0.000000,"Occupation" \n "Etat"}; +item68[] = {"No_Occupation",4,218,177.150635,-164.860199,267.150513,-114.860199,0.000000,"No" \n "Occupation"}; +item69[] = {"Idle",2,250,49.026558,-165.893478,139.026489,-115.893478,0.000000,"Idle"}; +item70[] = {"Occupation",4,218,121.354660,-3.671861,211.354614,46.328136,0.000000,"Occupation"}; +item71[] = {"Resistance_Etat",2,250,-349.607574,-84.825172,-259.607574,-34.825172,0.000000,"Resistance" \n "Etat"}; +item72[] = {"Resistance",4,218,-295.487061,-1.640314,-205.487045,48.359688,0.000000,"Resistance"}; +item73[] = {"No_Resistance",4,218,-495.933289,-84.825500,-405.933289,-34.825500,0.000000,"No" \n "Resistance"}; +item74[] = {"Idle_1",2,250,-637.440308,-84.593369,-547.440308,-34.593380,0.000000,"Idle"}; +link0[] = {0,1}; +link1[] = {1,2}; +link2[] = {2,3}; +link3[] = {2,4}; +link4[] = {2,59}; +link5[] = {3,67}; +link6[] = {4,71}; +link7[] = {5,7}; +link8[] = {5,8}; +link9[] = {6,9}; +link10[] = {6,10}; +link11[] = {7,48}; +link12[] = {8,11}; +link13[] = {9,11}; +link14[] = {10,46}; +link15[] = {11,12}; +link16[] = {11,13}; +link17[] = {12,14}; +link18[] = {13,15}; +link19[] = {14,18}; +link20[] = {14,19}; +link21[] = {15,16}; +link22[] = {15,17}; +link23[] = {16,20}; +link24[] = {17,26}; +link25[] = {18,21}; +link26[] = {19,27}; +link27[] = {20,24}; +link28[] = {20,25}; +link29[] = {21,22}; +link30[] = {21,23}; +link31[] = {22,41}; +link32[] = {23,29}; +link33[] = {24,28}; +link34[] = {25,40}; +link35[] = {26,54}; +link36[] = {26,55}; +link37[] = {27,45}; +link38[] = {27,50}; +link39[] = {28,30}; +link40[] = {29,30}; +link41[] = {30,31}; +link42[] = {31,32}; +link43[] = {31,33}; +link44[] = {32,34}; +link45[] = {33,35}; +link46[] = {34,61}; +link47[] = {34,62}; +link48[] = {35,37}; +link49[] = {35,38}; +link50[] = {36,35}; +link51[] = {37,39}; +link52[] = {38,42}; +link53[] = {39,64}; +link54[] = {39,65}; +link55[] = {40,30}; +link56[] = {41,30}; +link57[] = {42,44}; +link58[] = {43,42}; +link59[] = {44,1}; +link60[] = {45,51}; +link61[] = {46,47}; +link62[] = {47,41}; +link63[] = {48,49}; +link64[] = {49,40}; +link65[] = {50,52}; +link66[] = {51,53}; +link67[] = {52,53}; +link68[] = {53,41}; +link69[] = {54,56}; +link70[] = {55,57}; +link71[] = {56,58}; +link72[] = {57,58}; +link73[] = {58,40}; +link74[] = {59,60}; +link75[] = {61,63}; +link76[] = {62,35}; +link77[] = {63,36}; +link78[] = {64,66}; +link79[] = {65,42}; +link80[] = {66,43}; +link81[] = {67,68}; +link82[] = {67,70}; +link83[] = {68,69}; +link84[] = {69,1}; +link85[] = {70,6}; +link86[] = {71,72}; +link87[] = {71,73}; +link88[] = {72,5}; +link89[] = {73,74}; +link90[] = {74,44}; +globals[] = {0.000000,0,0,0,0,640,480,1,90,6316128,1,-779.566345,598.192566,1098.315674,-269.875427,720,715,1}; +window[] = {0,-1,-1,-1,-1,954,343,1756,94,1,738}; +*//*%FSM*/ +class FSM +{ + fsmName = "updatetownai"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_location = _this select 0;" \n + "_resistance_teamtypes = _this select 1;" \n + "_probability = _this select 2;" \n + "" \n + "_location_patroldistance = 'WFBE_TOWNUNITSPATROLDISTANCE' Call GetNamespace;" \n + "_location_range = _location getVariable 'range';" \n + "_location_rangepatrol = _location_range * ('WFBE_DETECTIONTOPATROLRANGERATIO' Call GetNamespace);" \n + "_location_rangespawn = 'WFBE_TOWNUNITSPAWNRANGE' Call GetNamespace;" \n + "" \n + "_location setVariable [""reinforcements"",0];" \n + "_location setVariable [""reinforcements_occ"",0];" \n + "" \n + "_camps = _location getVariable 'camps';" \n + "_defensiveTeam = objNull;" \n + "_position = [];" \n + "_totalCamps = count _camps;" \n + "" \n + "_lastUpdate = 10;" \n + "" \n + "_occupation_aaactive = false;" \n + "_occupation_active = false;" \n + "_occupation_difficulty = 'WFBE_TOWNOCCUPATIONDIFFICULTY' Call GetNamespace;" \n + "_occupation_inactive = 0;" \n + "_occupation_inactivetime = 'WFBE_OCCUPATIONINACTIVETIME' Call GetNamespace;" \n + "_occupation_manable = 'WFBE_OCCUPATIONMAXDEFENSES' Call GetNamespace;" \n + "_occupation_lastreinforcement = 0;" \n + "_occupation_reinforcementdelay = 'WFBE_OCCUPATIONREINFORCEMENTDELAY' Call GetNamespace;" \n + "_occupation_reinforcementteamsmax = if ((_location getVariable ""maxSupplyValue"")< 60) then {1 + ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace)} else {2 + ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace)};" \n + "" \n + "_occupation_teams = [];" \n + "_occupation_vehicles = [];" \n + "" \n + "_occupation_aasvfloor1 = 'WFBE_OCCUPATIONAATEAM1' Call GetNamespace;" \n + "_occupation_aasvfloor2 = 'WFBE_OCCUPATIONAATEAM2' Call GetNamespace;" \n + "" \n + "_resistance_active = false;" \n + "_resistance_defenses = _location nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_location_range];" \n + "_resistance_inactive = 0;" \n + "_resistance_inactivetime = 'WFBE_RESISTANCEINACTIVETIME' Call GetNamespace;" \n + "_resistance_lastreinforcement = 0;" \n + "_resistance_reinforcementdelay = 'WFBE_RESISTANCEREINFORCEMENTDELAY' Call GetNamespace;" \n + "_resistance_reinforcementteamsmax = if ((_location getVariable ""maxSupplyValue"")< 60) then {1 + ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace)} else {2 + ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace)};" \n + "" \n + "_civilians_enabled = if (('WFBE_CIVILIANFACTION' Call GetNamespace) > 0) then {true} else {false};" \n + "_civilians_teamstype = """";" \n + "_civilians_coef = 1;" \n + "if (_civilians_enabled) then {" \n + " if ((_location getVariable 'maxSupplyValue') <= 50) then {_civilians_teamstype = ""Villagers""};" \n + " if ((_location getVariable 'maxSupplyValue') > 50 && (_location getVariable ""maxSupplyValue"") < 120) then {_civilians_teamstype = ""Citizen"";_civilians_coef = 2};" \n + " if ((_location getVariable 'maxSupplyValue') >= 120) then {_civilians_teamstype = ""LargeCitizen"";_civilians_coef = 3};" \n + "};" \n + "" \n + "{_x addEventHandler [""Killed"",{[_this select 0,_this select 1,resistance] Spawn UnitKilled}]} forEach _resistance_defenses;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Root"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 5;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Root + { + name = "Root"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "_sideID = _location getVariable 'sideID';" \n + "_side = _sideID Call GetSideFromID;" \n + "" \n + "_objects = _location nearEntities[[resistanceSoldierBaseClass,eastSoldierBaseClass,westSoldierBaseClass,""Car"",""Motorcycle"",""Tank"",""Air""],_location_range];" \n + "_objects = _objects unitsBelowHeight 200;" \n + "_resistanceEnemies = (West countSide _objects) + (East countSide _objects);" \n + "_occupationEnemies = if (_side == east) then {(west countSide _objects) + (resistance countSide _objects)} else {(east countSide _objects) + (resistance countSide _objects)};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class East____West + { + priority = 2.000000; + to="Occupation_Etat"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_sideID != RESISTANCEID && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Resistance + { + priority = 1.000000; + to="Resistance_Etat"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_sideID == RESISTANCEID && !gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Enemies + { + name = "Enemies"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Hostile + { + priority = 0.000000; + to="Update"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_resistanceEnemies > 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Clear + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_resistanceEnemies == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Enemies_1 + { + name = "Enemies_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Clear + { + priority = 0.000000; + to="Skip_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_occupationEnemies == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Hostile + { + priority = 0.000000; + to="Update"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_occupationEnemies > 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + name = "Update"; + init = /*%FSM*/"if (_resistanceEnemies > 0) then {_resistance_inactive = time};" \n + "if (_occupationEnemies > 0) then {_occupation_inactive = time};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class East____West + { + priority = 2.000000; + to="Active"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_sideID != RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Resistance + { + priority = 1.000000; + to="Active_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_sideID == RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Active + { + name = "Active"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class No + { + priority = 0.000000; + to="Filter_Out"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_occupation_active"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Yes + { + priority = 0.000000; + to="Reinforcement_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_occupation_active"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Active_1 + { + name = "Active_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class No + { + priority = 0.000000; + to="Create_Teams"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_resistance_active"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Yes + { + priority = 0.000000; + to="Reinforcement"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_resistance_active"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Reinforcement + { + name = "Reinforcement"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Disabled + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!paramResReinf || (_location getVariable ""reinforcements"") >= _resistance_reinforcementteamsmax || time - _resistance_lastreinforcement <= _resistance_reinforcementdelay"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Enabled + { + priority = 0.000000; + to="Reinforce"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"paramResReinf && (_location getVariable ""reinforcements"") < _resistance_reinforcementteamsmax && time - _resistance_lastreinforcement > _resistance_reinforcementdelay"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Reinforcement_1 + { + name = "Reinforcement_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Enabled + { + priority = 0.000000; + to="Reinforce_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"paramOccReinf && (_location getVariable ""reinforcements_occ"") < _occupation_reinforcementteamsmax && time - _occupation_lastreinforcement > _occupation_reinforcementdelay"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Disabled + { + priority = 0.000000; + to="Skip_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!paramOccReinf || (_location getVariable ""reinforcements_occ"") >= _occupation_reinforcementteamsmax || time - _occupation_lastreinforcement <= _occupation_reinforcementdelay"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Create_Teams + { + name = "Create_Teams"; + init = /*%FSM*/"if (count _resistance_defenses > 0) then {" \n + " //--- Update the defenses." \n + " for '_i' from 0 to count(_resistance_defenses)-1 do {" \n + " if !(alive (_resistance_defenses select _i)) then {_resistance_defenses = _resistance_defenses - [_resistance_defenses select _i]};" \n + " };" \n + "" \n + " //--- Man the defenses that can be manned." \n + " {" \n + " if (_x emptyPositions ""gunner"" > 0) then {" \n + " if (isNull WF_ResistanceDefenseTeam) then {WF_ResistanceDefenseTeam = createGroup resistance};" \n + " _unit = ['WFBE_GUERSOLDIER' Call GetNamespace,WF_ResistanceDefenseTeam,(getPos _x),resistance] Call CreateMan;" \n + " _unit assignAsGunner _x;" \n + " [_unit] orderGetIn true;" \n + " _unit moveInGunner _x;" \n + " [WF_ResistanceDefenseTeam, 350, _unit] Call RevealArea;" \n + " };" \n + " } forEach _resistance_defenses;" \n + "};" \n + "" \n + "_resistance_active = true;" \n + "_resistance_teams = [];" \n + "_resistance_vehicles = [];" \n + "_ci = 0;" \n + "" \n + "//--- Create the teams." \n + "{ " \n + " _camp = objNull;" \n + " if (_ci < _totalCamps) then {" \n + " _position = ([getPos (_camps select _ci),8,40] Call GetRandomPosition);" \n + " _camp = _camps select _ci;" \n + " _ci = _ci + 1;" \n + " } else {" \n + " _position = ([getPos _location, _location_rangespawn, _location_rangepatrol] Call GetRandomPosition);" \n + " };" \n + " " \n + " _team = createGroup resistance;" \n + " _position = [_position, 50] Call GetSafePlace;" \n + " " \n + " _retVal = [Format[""WFBE_RES%1UNITS"",_x] Call GetNamespace, _position, resistance, paramResVehLock, _team, _probability] Call CreateTeamTemplate;" \n + " _vehicles = _retVal select 1;" \n + " " \n + " emptyQueu = emptyQueu + _vehicles;" \n + " {_x Spawn HandleEmptyVehicle} forEach _vehicles;" \n + " " \n + " _resistance_vehicles = _resistance_vehicles + _vehicles;" \n + " _resistance_teams = _resistance_teams + [_team];" \n + " " \n + " [_team, 350, _position] Call RevealArea;" \n + " [_location,_team,RESISTANCEID,_camp,false] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + " if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + "} forEach _resistance_teamtypes;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class No_Civilians + { + priority = 0.000000; + to="Skip_2"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_civilians_enabled"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Civilians + { + priority = 0.000000; + to="Create_Civilians"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_civilians_enabled"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Filter_Out + { + name = "Filter_Out"; + init = /*%FSM*/"_isAirOnly = false;" \n + "if !(_occupation_aaactive) then {" \n + " _objects = _location nearEntities[[""Air""],_location_range*1.5];" \n + " _objects = [_objects Call GetLiveUnits,200,25] Call GetUnitsBelowHeight;" \n + "" \n + " _airEnemies = if (_side == East) then {(West countSide _objects) + (Resistance countSide _objects)} else {(East countSide _objects) + (Resistance countSide _objects)};" \n + " _isAirOnly = if (_airEnemies == _occupationEnemies) then {true} else {false};" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Air + { + priority = 0.000000; + to="Create_AA_Teams"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_isAirOnly"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Ground + { + priority = 0.000000; + to="Create_Teams_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_isAirOnly"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Reinforce + { + name = "Reinforce"; + init = /*%FSM*/"_resistance_lastreinforcement = time;" \n + "" \n + "//--- Create the team." \n + "_position = ([getPos _location, _location_rangespawn, _location_rangepatrol] Call GetRandomPosition);" \n + "_near = _position nearEntities 75;" \n + "_ctx = (east countSide _near) + (west countSide _near);" \n + "_i = 0;" \n + "while {_ctx > 0 && _i < 400} do {" \n + " _position = ([getPos _location, _location_rangespawn + 200, _location_rangepatrol] Call GetRandomPosition);" \n + " _near = _position nearEntities 75;" \n + " _ctx = (east countSide _near) + (west countSide _near);" \n + " _i = _i + 1;" \n + "};" \n + "" \n + "_team = createGroup resistance;" \n + "_position = [_position, 50] Call GetSafePlace;" \n + "" \n + "_retVal = [Format[""WFBE_RES%1UNITS"",_resistance_teamtypes select round (random ((count _resistance_teamtypes)-1))] Call GetNamespace, _position, resistance, paramResVehLock, _team, _probability] Call CreateTeamTemplate;" \n + "_vehicles = _retVal select 1;" \n + "" \n + "emptyQueu = emptyQueu + _vehicles;" \n + "{_x Spawn HandleEmptyVehicle} forEach _vehicles;" \n + "" \n + "_resistance_vehicles = _resistance_vehicles + _vehicles;" \n + "_resistance_teams = _resistance_teams + [_team];" \n + "" \n + "[_team, 350, _position] Call RevealArea;" \n + "[_location,_team,RESISTANCEID,objNull,true] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + "if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + "" \n + "_existing = _location getVariable ""reinforcements"";" \n + "_location setVariable [""reinforcements"",_existing + 1];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Resistance_Clean"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Reinforce_1 + { + name = "Reinforce_1"; + init = /*%FSM*/"_occupation_lastreinforcement = time;" \n + "" \n + "//--- Create the team." \n + "_position = ([getPos _location, _location_rangespawn, _location_rangepatrol] Call GetRandomPosition);" \n + "_near = _position nearEntities 75;" \n + "_ctx = (east countSide _near) + (west countSide _near);" \n + "_i = 0;" \n + "while {_ctx > 0 && _i < 400} do {" \n + " _position = ([getPos _location, _location_rangespawn + 200, _location_rangepatrol] Call GetRandomPosition);" \n + " _near = _position nearEntities 75;" \n + " _ctx = (east countSide _near) + (west countSide _near);" \n + " _i = _i + 1;" \n + "};" \n + "" \n + "_team = createGroup _side;" \n + "_position = [_position, 50] Call GetSafePlace;" \n + "" \n + "_occupation_teamtypes = [_location getVariable 'supplyValue'] Call SelectOccupTeam;" \n + "" \n + "_retVal = [Format[""WFBE_%1%2UNITS"",str _side, _occupation_teamtypes select round (random ((count _occupation_teamtypes)-1))] Call GetNamespace, _position, _side, true, _team, _probability] Call CreateTeamTemplate;" \n + "_vehicles = _retVal select 1;" \n + "" \n + "_built = count(_retVal select 0);" \n + "_builtveh = count _vehicles;" \n + "" \n + "emptyQueu = emptyQueu + _vehicles;" \n + "{_x Spawn HandleEmptyVehicle; _x setVariable [""WFBE_Taxi_Prohib"", true]} forEach _vehicles;" \n + "" \n + "_occupation_vehicles = _occupation_vehicles + _vehicles;" \n + "_occupation_teams = _occupation_teams + [_team];" \n + "" \n + "[_team, 350, _position] Call RevealArea;" \n + "[_location,_team,_sideID,objNull,true] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + "if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + "" \n + "if (_built > 0) then {[str _side,'UnitsCreated',_built] Call UpdateStatistics};" \n + "if (_builtveh > 0) then {[str _side,'VehiclesCreated',_builtveh] Call UpdateStatistics};" \n + "" \n + "_existing = _location getVariable ""reinforcements_occ"";" \n + "_location setVariable [""reinforcements_occ"",_existing + 1];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Resistance_Clean"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Resistance_Clean + { + name = "Resistance_Clean"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 1.000000; + to="Occupation_Clean"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_resistance_active"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Activity + { + priority = 0.000000; + to="Check_Time"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_resistance_active"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Time + { + name = "Check_Time"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="Occupation_Clean"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _resistance_inactive <= _resistance_inactivetime"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Ready + { + priority = 0.000000; + to="Remove_Resistanc"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _resistance_inactive > _resistance_inactivetime"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Occupation_Clean + { + name = "Occupation_Clean"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_occupation_active && !_occupation_aaactive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Activity + { + priority = 0.000000; + to="Check_Time_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_occupation_active || _occupation_aaactive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Check_Time_1 + { + name = "Check_Time_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Wait + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _occupation_inactive <= _occupation_inactivetime"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Ready + { + priority = 0.000000; + to="Remove_Occupatio"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _occupation_inactive > _occupation_inactivetime"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + name = "Skip"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Resistance_Clean"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_1 + { + name = "Skip_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Resistance_Clean"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class _ + { + name = "_"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Root"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 5;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Create_Teams_1 + { + name = "Create_Teams_1"; + init = /*%FSM*/"[""HostilesDetectedNear"",_location,_side] Spawn SideMessage;" \n + "" \n + "_occupation_defenses = _location nearEntities [(Format ['WFBE_%1DEFENSENAMES',str _side] Call GetNamespace),_location_patroldistance*1.4];" \n + "if (count _occupation_defenses > 0) then {" \n + " //--- Update the defenses." \n + " for '_i' from 0 to count(_occupation_defenses)-1 do {" \n + " if ((_occupation_defenses select _i) emptyPositions 'gunner' == 0) then {_occupation_defenses = _occupation_defenses - [_occupation_defenses select _i]};" \n + " };" \n + "" \n + " //--- Limit the defenses if we're above the limit." \n + " if (count _occupation_defenses > _occupation_manable) then {_occupation_defenses resize (_occupation_manable - 1)};" \n + "" \n + " _defensiveTeam = Call Compile Format [""WF_Defense%1Grp"",str _side];" \n + " if (isNull _defensiveTeam) then {Call Compile Format [""WF_Defense%1Grp = createGroup %1"",str _side];_defensiveTeam = Call Compile Format [""WF_Defense%1Grp"",str _side];};" \n + "" \n + " //--- Man the defenses." \n + " {" \n + " _unit = [Format [""WFBE_%1SOLDIER"",str _side] Call GetNamespace,_defensiveTeam,[(getPos _x select 0)+5,getPos _x select 1,0],_side] Call CreateMan;" \n + " _unit assignAsGunner _x;" \n + " [_unit] orderGetIn true;" \n + " _unit moveInGunner _x;" \n + " [_defensiveTeam, 350, _unit] Call RevealArea;" \n + " } forEach _occupation_defenses;" \n + "};" \n + "" \n + "_occupation_active = true;" \n + "_occupation_teamtypes = [_location getVariable 'supplyValue'] Call SelectOccupTeam;" \n + "_ci = 0;" \n + "_built = 0;" \n + "_builtveh = 0;" \n + "" \n + "//--- Create the teams." \n + "{ " \n + " _camp = objNull;" \n + " if (_ci < _totalCamps) then {" \n + " _position = ([getPos (_camps select _ci),8,40] Call GetRandomPosition);" \n + " _camp = _camps select _ci;" \n + " _ci = _ci + 1;" \n + " } else {" \n + " _position = ([getPos _location, _location_rangespawn, _location_rangepatrol] Call GetRandomPosition);" \n + " };" \n + " " \n + " _team = createGroup _side;" \n + " _position = [_position, 50] Call GetSafePlace;" \n + " " \n + " _retVal = [Format[""WFBE_%1%2UNITS"",str _side,_x] Call GetNamespace, _position, _side, true, _team, _probability] Call CreateTeamTemplate;" \n + " _vehicles = _retVal select 1;" \n + " " \n + " _built = _built + (count(_retVal select 0));" \n + " _builtveh = _builtveh + (count _vehicles);" \n + " " \n + " emptyQueu = emptyQueu + _vehicles;" \n + " {_x Spawn HandleEmptyVehicle; _x setVariable [""WFBE_Taxi_Prohib"", true]} forEach _vehicles;" \n + " " \n + " _occupation_vehicles = _occupation_vehicles + _vehicles;" \n + " _occupation_teams = _occupation_teams + [_team];" \n + " " \n + " [_team, 350, _position] Call RevealArea;" \n + " [_location,_team,_sideID,_camp,false] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + " if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + "} forEach _occupation_teamtypes;" \n + "" \n + "if (_built > 0) then {[str _side,'UnitsCreated',_built] Call UpdateStatistics};" \n + "if (_builtveh > 0) then {[str _side,'VehiclesCreated',_builtveh] Call UpdateStatistics};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Skip_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Create_AA_Teams + { + name = "Create_AA_Teams"; + init = /*%FSM*/"[""HostilesDetectedNear"",_location,_side] Spawn SideMessage;" \n + "_occupation_aaactive = true;" \n + "" \n + "_currentSV = _location getVariable ""supplyValue"";" \n + "_type = 'Small';" \n + "if (_currentSV < _occupation_aasvfloor1) then {_type = 'Small'};" \n + "if (_currentSV >= _occupation_aasvfloor1 && _currentSV < _occupation_aasvfloor2) then {_type = 'Medium'};" \n + "if (_currentSV > _occupation_aasvfloor2) then {_type = 'Large'};" \n + "" \n + "_grps = 1 + floor(_occupation_difficulty/2);" \n + "if (_type == 'Small') then {_grps = _grps + 1};" \n + "" \n + "_built = 0;" \n + "_builtveh = 0;" \n + "" \n + "//--- Create the teams." \n + "for '_i' from 0 to _grps do {" \n + " _position = ([getPos _location, _location_rangespawn, _location_rangepatrol] Call GetRandomPosition);" \n + " " \n + " _effectiveType = _type;" \n + " if (_i > 2) then {" \n + " if (_type == 'Medium' && random 100 > 75) then {_effectiveType = ['Small','Medium'] select round(random 1)};" \n + " if (_type == 'Large' && random 100 > 70) then {_effectiveType = ['Small','Medium','Large'] select round(random 2)};" \n + " };" \n + " " \n + " _team = createGroup _side;" \n + " _position = [_position, 50] Call GetSafePlace;" \n + " " \n + " _retVal = [Format [""WFBE_%1%2AATEAMUNITS"",_side,_effectiveType] Call GetNamespace, _position, _side, true, _team, _probability] Call CreateTeamTemplate;" \n + " _vehicles = _retVal select 1;" \n + " " \n + " _built = _built + (count(_retVal select 0));" \n + " _builtveh = _builtveh + (count _vehicles);" \n + " " \n + " emptyQueu = emptyQueu + _vehicles;" \n + " {_x Spawn HandleEmptyVehicle; _x setVariable [""WFBE_Taxi_Prohib"", true]} forEach _vehicles;" \n + " " \n + " _occupation_vehicles = _occupation_vehicles + _vehicles;" \n + " _occupation_teams = _occupation_teams + [_team];" \n + " " \n + " [_location,_team,_sideID,objNull,false] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + " " \n + " //--- AA Team are well informed about air units." \n + " {_team reveal _x} forEach _objects;" \n + "" \n + " //--- Use UPSMON AI if enabled." \n + " if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""reinforcement""] Spawn UPSMON};" \n + "};" \n + "" \n + "if (_built > 0) then {[str _side,'UnitsCreated',_built] Call UpdateStatistics};" \n + "if (_builtveh > 0) then {[str _side,'VehiclesCreated',_builtveh] Call UpdateStatistics};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Skip_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Create_Civilians + { + name = "Create_Civilians"; + init = /*%FSM*/"_civilians_teams = [];" \n + "" \n + "//--- Create the teams." \n + "for '_i' from 0 to _civilians_coef do {" \n + " _position = ([getPos _location, _location_rangespawn, _location_rangepatrol] Call GetRandomPosition);" \n + " " \n + " _team = createGroup civilian;" \n + " _position = [_position, 50] Call GetSafePlace;" \n + " " \n + " _unitTypes = Format[""WFBE_CIV%1%2UNITS"",_civilians_teamstype,(1+round(random 3))] Call GetNamespace;" \n + " " \n + " {" \n + " _unit = _team createUnit [_x,_position,[],0.4,""FORM""];" \n + " _unit addEventHandler ['Killed',{[_this select 0,_this select 1] Spawn CivilianKilled}];" \n + " } forEach _unitTypes;" \n + "" \n + " _civilians_teams = _civilians_teams + [_team];" \n + " " \n + " [_team,_location,(_location_patroldistance/2)] Spawn AITownPatrol;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip_2 + { + name = "Skip_2"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Remove_Resistanc + { + name = "Remove_Resistanc"; + init = /*%FSM*/"_resistance_active = false;" \n + "" \n + "//--- Teams Units." \n + "{" \n + " if !(isNil '_x') then {" \n + " if !(isNull _x) then {" \n + " {deleteVehicle _x} forEach units _x;" \n + " deleteGroup _x;" \n + " };" \n + " };" \n + "} forEach _resistance_teams;" \n + "" \n + "//--- Teams vehicles." \n + "{" \n + " if (!isPlayer _x && side _x == resistance) then {deleteVehicle _x};" \n + "} forEach _resistance_vehicles;" \n + "" \n + "if (paramResReinf) then {_location setVariable [""reinforcements_alive"",0]};" \n + "" \n + "if (_civilians_enabled) then {" \n + " {" \n + " if !(isNil '_x') then {" \n + " if !(isNull _x) then {" \n + " {deleteVehicle _x} forEach units _x;" \n + " deleteGroup _x;" \n + " };" \n + " };" \n + " } forEach _civilians_teams;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Occupation_Clean"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Remove_Occupatio + { + name = "Remove_Occupatio"; + init = /*%FSM*/"_occupation_active = false;" \n + "_occupation_aaactive = false;" \n + "" \n + "//--- Teams Units." \n + "{" \n + " if !(isNil '_x') then {" \n + " if !(isNull _x) then {" \n + " {deleteVehicle _x} forEach units _x;" \n + " deleteGroup _x;" \n + " };" \n + " };" \n + "} forEach _occupation_teams;" \n + "" \n + "//--- Teams vehicles." \n + "{" \n + " if !(isPlayer _x) then {deleteVehicle _x};" \n + "} forEach _occupation_vehicles;" \n + "" \n + "if (paramOccReinf) then {_location setVariable [""reinforcements_occ"",0]};" \n + "" \n + "{" \n + " if (!isNull(Gunner _x) && !isPlayer(Gunner _x)) then {" \n + " _unit = (gunner _x);" \n + " if (group _unit == _defensiveTeam) then {" \n + " _unit setPos (getpos _x);" \n + " deleteVehicle _unit;" \n + " };" \n + " };" \n + "} forEach _occupation_defenses;" \n + "_occupation_defenses = [];" \n + "_defensiveTeam = objNull;" \n + "" \n + "_occupation_teams = [];" \n + "_occupation_vehicles = [];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Occupation_Etat + { + name = "Occupation_Etat"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Occupation + { + priority = 0.000000; + to="Enemies_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"paramOccup"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class No_Occupation + { + priority = 0.000000; + to="Idle"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!paramOccup"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Idle + { + name = "Idle"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Root"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 5;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Resistance_Etat + { + name = "Resistance_Etat"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class No_Resistance + { + priority = 0.000000; + to="Idle_1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!paramRes"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Resistance + { + priority = 0.000000; + to="Enemies"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"paramRes"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Idle_1 + { + name = "Idle_1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Root"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _lastUpdate > 5;"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/updatetowndefenses.fsm b/Server/FSM/updatetowndefenses.fsm new file mode 100644 index 0000000..b99616f --- /dev/null +++ b/Server/FSM/updatetowndefenses.fsm @@ -0,0 +1,631 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-63.339870,-329.544403,26.660130,-279.544769,0.000000,"Init"}; +item1[] = {"End",1,250,-182.368073,-113.480629,-92.368042,-63.480659,0.000000,"End"}; +item2[] = {"Gameover",4,218,-182.650177,-187.482422,-92.650192,-137.482452,0.000000,"Gameover"}; +item3[] = {"_",8,218,-35.668163,-247.514877,-3.862146,-224.939621,0.000000,""}; +item4[] = {"Defense_Core",2,250,-63.405182,-187.376434,26.594841,-137.376434,0.000000,"Defense Core"}; +item5[] = {"Resistance",4,218,-63.096802,-113.322952,26.903198,-63.322945,0.000000,"Resistance"}; +item6[] = {"Skip",4,218,51.723022,-187.995987,141.723053,-137.995987,0.000000,"Skip"}; +item7[] = {"_",8,218,392.190338,-190.067062,423.996338,-167.491791,0.000000,""}; +item8[] = {"Advanced_Defense",2,250,-63.899727,-37.846992,26.100292,12.153011,0.000000,"Advanced" \n "Defense"}; +item9[] = {"Skip",4,218,52.047401,-37.929413,142.047272,12.070588,0.000000,"Skip"}; +item10[] = {"Enemies",4,218,-63.950096,42.576328,26.049911,92.576347,0.000000,"Enemies"}; +item11[] = {"Active",4,218,49.450504,118.698433,139.450470,168.698425,0.000000,"Active"}; +item12[] = {"Update",2,250,-63.949944,119.619461,26.049990,169.619431,0.000000,"Update"}; +item13[] = {"_",2,250,357.586823,-300.604431,447.586670,-250.604416,0.000000,""}; +item14[] = {"Inactive",4,218,-63.968323,202.808212,26.031679,252.808212,0.000000,"Inactive"}; +item15[] = {"Spawn_Res",2,4346,505.445801,202.593475,595.445435,252.593460,0.000000,"Spawn Res"}; +item16[] = {"__1",2,250,173.981140,117.028183,263.981445,167.028183,0.000000,""}; +item17[] = {"Reinf_",4,218,321.587677,117.539032,411.587677,167.539017,0.000000,"Reinf?"}; +item18[] = {"no_Reinf",4,218,173.933121,40.630589,263.933228,90.630539,1.000000,"no Reinf"}; +item19[] = {"Reinforce",2,250,321.791260,38.423203,411.791290,88.423172,0.000000,"Reinforce"}; +item20[] = {"Passive",4,218,212.037048,-299.501312,302.036926,-249.501312,0.000000,"Passive"}; +item21[] = {"Active",4,218,358.437775,-380.021667,448.437714,-330.021667,0.000000,"Active"}; +item22[] = {"__2",2,250,96.136414,-339.761383,186.136520,-289.761505,0.000000,""}; +item23[] = {"__3",2,250,358.437653,-452.002045,448.437714,-402.002045,0.000000,""}; +item24[] = {"Time___1",4,218,215.696960,-494.702240,305.696960,-444.702209,0.000000,"Time >"}; +item25[] = {"Time__",4,218,210.816925,-367.821625,300.816895,-317.821625,0.000000,"Time <"}; +item26[] = {"Delete",2,250,90.036407,-493.482239,180.036377,-443.482239,0.000000,"Delete"}; +item27[] = {"Civilians",4,218,438.384674,124.400330,528.384521,174.400330,0.000000,"Civilians"}; +item28[] = {"No_Civilians",4,218,569.764099,125.541168,659.764099,175.541046,0.000000,"No Civilians"}; +item29[] = {"Spawn_Civilians",2,250,438.011932,38.918774,528.011597,88.918900,0.000000,"Spawn Civilians"}; +link0[] = {0,3}; +link1[] = {2,1}; +link2[] = {3,4}; +link3[] = {4,2}; +link4[] = {4,5}; +link5[] = {4,6}; +link6[] = {5,8}; +link7[] = {6,13}; +link8[] = {7,13}; +link9[] = {8,9}; +link10[] = {8,10}; +link11[] = {9,13}; +link12[] = {10,12}; +link13[] = {11,16}; +link14[] = {12,11}; +link15[] = {12,14}; +link16[] = {13,20}; +link17[] = {13,21}; +link18[] = {14,15}; +link19[] = {15,27}; +link20[] = {15,28}; +link21[] = {16,17}; +link22[] = {16,18}; +link23[] = {17,19}; +link24[] = {18,13}; +link25[] = {19,7}; +link26[] = {20,22}; +link27[] = {21,23}; +link28[] = {22,3}; +link29[] = {23,24}; +link30[] = {23,25}; +link31[] = {24,26}; +link32[] = {25,22}; +link33[] = {26,3}; +link34[] = {27,29}; +link35[] = {28,13}; +link36[] = {29,7}; +globals[] = {0.000000,0,0,0,0,640,480,1,84,6316128,1,-95.598221,725.231018,310.641174,-552.086548,862,906,1}; +window[] = {2,-1,-1,-1,-1,912,148,1473,71,3,880}; +*//*%FSM*/ +class FSM +{ + fsmName = "updatetowndefenses"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "_location = _this select 0;" \n + "_resistanceTeamTypes = _this select 1;" \n + "_probability = _this select 2;" \n + "_detectionRange = _this select 3;" \n + "_maxSV = _this select 4;" \n + "_name = str _location;" \n + "" \n + "_camps = _location getVariable 'camps';" \n + "_totalCamps = count _camps;" \n + "" \n + "_patrolRange = _detectionRange * ('WFBE_DETECTIONTOPATROLRANGERATIO' Call GetNamespace);" \n + "_resistanceActive = false;" \n + "_emptyDefenses = [];" \n + "_teams = [];" \n + "_vehicles = [];" \n + "_position = [];" \n + "_timeInactive = 0;" \n + "_lastReinf = -500;" \n + "_rit = 'WFBE_RESISTANCEINACTIVETIME' Call GetNamespace;" \n + "_tupd = 'WFBE_TOWNUNITSPATROLDISTANCE' Call GetNamespace;" \n + "_tusr = 'WFBE_TOWNUNITSPAWNRANGE' Call GetNamespace;" \n + "_useCivilians = if (('WFBE_CIVILIANFACTION' Call GetNamespace) > 0) then {true} else {false};" \n + "" \n + "_maxReinforcementTeams = if ((_location getVariable ""supplyValue"")< 60) then {1 + ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace)} else {2 + ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace)};" \n + "_location setVariable [""reinforcements"",0];" \n + "" \n + "_civTeams = """";" \n + "_cTeams = [];" \n + "_coef = 1;" \n + "if (_useCivilians) then {" \n + " if (_maxSV <= 50) then {_civTeams = ""Villagers""};" \n + " if (_maxSV > 50 && _maxSV < 120) then {_civTeams = ""Citizen"";_coef = 2};" \n + " if (_maxSV >= 120) then {_civTeams = ""LargeCitizen"";_coef = 3};" \n + "};" \n + "" \n + "_defenses = _location nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_detectionRange];" \n + "{_x addEventHandler [""Killed"",{[_this select 0,_this select 1,resistance] Spawn UnitKilled}]} forEach _defenses;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Defense_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Defense_Core + { + name = "Defense_Core"; + init = /*%FSM*/"_lastUpdate = time + random(0.2);" \n + "" \n + "_sideID = _location getVariable ""sideID"";"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Resistance + { + priority = 0.000000; + to="Advanced_Defense"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 10 && _sideID == RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 10 && _sideID != RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Advanced_Defense + { + name = "Advanced_Defense"; + init = /*%FSM*/"_objects = _location nearEntities[[eastSoldierBaseClass,westSoldierBaseClass,""Car"",""Motorcycle"",""Tank"",""Air""],_detectionRange];" \n + "_objects = [_objects Call GetLiveUnits,200] Call GetUnitsBelowHeight;" \n + "_enemies = (West countSide _objects) + (East countSide _objects);"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Enemies + { + priority = 0.000000; + to="Update"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_enemies > 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_enemies <= 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + name = "Update"; + init = /*%FSM*/"_timeInactive = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Inactive + { + priority = 0.000000; + to="Spawn_Res"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_resistanceActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Active + { + priority = 0.000000; + to="__1"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_resistanceActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class _ + { + name = "_"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Active + { + priority = 0.000000; + to="__3"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_resistanceActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Passive + { + priority = 0.000000; + to="__2"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_resistanceActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Spawn_Res + { + name = "Spawn_Res"; + init = /*%FSM*/"_teamCount = 0;" \n + "_totalTeams = count _resistanceTeamTypes;" \n + "_emptyDefenses = [];" \n + "" \n + "{if ((_x EmptyPositions ""gunner"" > 0)&&(alive _x)) then {_emptyDefenses = _emptyDefenses + [_x]}} forEach _defenses;" \n + "{" \n + " if (isNull WF_ResistanceDefenseTeam) then {WF_ResistanceDefenseTeam = createGroup resistance};" \n + " _unit = ['WFBE_GUERSOLDIER' Call GetNamespace,WF_ResistanceDefenseTeam,(getPos _x),resistance] Call CreateMan;" \n + " [_unit] allowGetIn true;" \n + " _unit assignAsGunner _x;" \n + " [_unit] orderGetIn true;" \n + " _unit moveInGunner _x;" \n + " [WF_ResistanceDefenseTeam, 350, _unit] Call RevealArea;" \n + "} forEach _emptyDefenses;" \n + "" \n + "_ci = 0;" \n + "while {_teamCount < _totalTeams} do {" \n + " _resistanceActive = true;" \n + " _unitTypes = Format[""WFBE_RES%1UNITS"",_resistanceTeamTypes select _teamCount] Call GetNamespace;" \n + " _leaderName = _unitTypes select 0;" \n + " _camp = objNull;" \n + " if (_ci < _totalCamps) then {" \n + " _position = ([getPos (_camps select _ci),8,40] Call GetRandomPosition);" \n + " _camp = _camps select _ci;" \n + " } else {" \n + " _position = ([getPos _location,_tusr,_patrolRange] Call GetRandomPosition);" \n + " };" \n + " _team = createGroup Resistance;" \n + " _leader = [_leaderName,_team,_position,resistance] Call CreateMan;" \n + " [_leader,_position,50] Call PlaceSafe;" \n + " _position = getPos _leader;" \n + " _teams = _teams + [_team];" \n + " _count = 1;" \n + " _total = count _unitTypes;" \n + " while {_count < _total} do {" \n + " _unitName = _unitTypes select _count;" \n + " if (random(100) < _probability) then {" \n + " if (_unitName isKindOf ""Man"") then {" \n + " _unit = [_unitName,_team,_position,resistance] Call CreateMan;" \n + " } else {" \n + " _vehicle = [_unitName,_position,resistance,paramResVehLock] Call CreateVehi;" \n + " _vehicles = _vehicles + [_vehicle];" \n + " emptyQueu = emptyQueu + [_vehicle];" \n + " _vehicle Spawn HandleEmptyVehicle;" \n + " _continue = true;" \n + " if (vehicle _leader == _leader) then {_leader moveInDriver _vehicle;_continue = false};" \n + " _type = if (_vehicle isKindOf 'Man') then {'WFBE_GUERSOLDIER' Call GetNamespace} else {if (_vehicle isKindOf 'Air') then {'WFBE_GUERPILOT' Call GetNamespace} else {'WFBE_GUERCREW' Call GetNamespace}};" \n + " if (_continue) then {_driver = [_type,_team,_position,resistance] Call CreateMan;_driver moveInDriver _vehicle};" \n + " if (_vehicle emptyPositions ""gunner"" > 0) then {_gunner = [_type,_team,_position,resistance] Call CreateMan;_gunner moveInGunner _vehicle};" \n + " if (_vehicle emptyPositions ""commander"" > 0) then {_commander = [_type,_team,_position,resistance] Call CreateMan;_commander moveInCommander _vehicle};" \n + " };" \n + " };" \n + " _count = _count + 1;" \n + " };" \n + " [_team, 350, _position] Call RevealArea;" \n + " [_location,_team,RESISTANCEID,_camp,false] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + " if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + " _teamCount = _teamCount + 1;" \n + " _ci = _ci + 1;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class No_Civilians + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_useCivilians"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Civilians + { + priority = 0.000000; + to="Spawn_Civilians"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_useCivilians"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class __1 + { + name = "__1"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class no_Reinf + { + priority = 1.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!paramResReinf || (_location getVariable ""reinforcements"") >= _maxReinforcementTeams || time - _lastReinf <= 300"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Reinf_ + { + priority = 0.000000; + to="Reinforce"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"paramResReinf && (_location getVariable ""reinforcements"") < _maxReinforcementTeams && time - _lastReinf > 300"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Reinforce + { + name = "Reinforce"; + init = /*%FSM*/"_lastReinf = time;" \n + "_unitTypes = Format[""WFBE_RES%1UNITS"",_resistanceTeamTypes select round (random ((count _resistanceTeamTypes)-1))] Call GetNamespace;" \n + "_leaderName = _unitTypes select 0;" \n + "_position = ([getPos _location,_tusr + 150,_patrolRange] Call GetRandomPosition);" \n + "_near = _position nearEntities 75;" \n + "_ctx = (east countSide _near) + (west countSide _near);" \n + "_i = 0;" \n + "while {_ctx > 0 && _i < 400} do {" \n + " _position = ([getPos _location,_tusr + 150,_patrolRange] Call GetRandomPosition);" \n + " _near = _position nearEntities 75;" \n + " _ctx = (east countSide _near) + (west countSide _near);" \n + " _i = _i + 1;" \n + "};" \n + "_team = createGroup Resistance;" \n + "_leader = [_leaderName,_team,_position,resistance] Call CreateMan;" \n + "[_leader,_position,50] Call PlaceSafe;" \n + "_position = getPos _leader;" \n + "_teams = _teams + [_team];" \n + "_count = 1;" \n + "_total = count _unitTypes;" \n + "while {_count < _total} do {" \n + " _unitName = _unitTypes select _count;" \n + " if (random(100) < _probability) then {" \n + " if (_unitName isKindOf ""Man"") then {" \n + " _unit = [_unitName,_team,_position,resistance] Call CreateMan;" \n + " } else {" \n + " _vehicle = [_unitName,_position,resistance,paramResVehLock] Call CreateVehi;" \n + " _vehicles = _vehicles + [_vehicle];" \n + " _continue = true;" \n + " emptyQueu = emptyQueu + [_vehicle];" \n + " _vehicle Spawn HandleEmptyVehicle;" \n + " if (vehicle _leader == _leader) then {_leader moveInDriver _vehicle;_continue = false};" \n + " _type = if (_vehicle isKindOf 'Man') then {'WFBE_GUERSOLDIER' Call GetNamespace} else {if (_vehicle isKindOf 'Air') then {'WFBE_GUERPILOT' Call GetNamespace} else {'WFBE_GUERCREW' Call GetNamespace}};" \n + " if (_continue) then {_driver = [_type,_team,_position,resistance] Call CreateMan;_driver moveInDriver _vehicle};" \n + " if (_vehicle emptyPositions ""gunner"" > 0) then {_gunner = [_type,_team,_position,resistance] Call CreateMan;_gunner moveInGunner _vehicle};" \n + " if (_vehicle emptyPositions ""commander"" > 0) then {_commander = [_type,_team,_position,resistance] Call CreateMan;_commander moveInCommander _vehicle};" \n + " };" \n + " };" \n + " _count = _count + 1;" \n + "};" \n + "" \n + "if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + "" \n + "[_location,_team,RESISTANCEID,objNull,true] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + "" \n + "_existing = _location getVariable ""reinforcements"";" \n + "_location setVariable [""reinforcements"",_existing + 1];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class __2 + { + name = "__2"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Defense_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class __3 + { + name = "__3"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Time__ + { + priority = 0.000000; + to="__2"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _timeInactive <= _rit"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Time___1 + { + priority = 0.000000; + to="Delete"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _timeInactive > _rit"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Delete + { + name = "Delete"; + init = /*%FSM*/"_resistanceActive = false;" \n + "_count = 0;" \n + "_total = Count _teams;" \n + "" \n + "while {_count < _total} do {" \n + " _team = _teams Select _count;" \n + " if !(isNil '_team') then {" \n + " if !(isNull _team) then {" \n + " {deleteVehicle _x} forEach units _team;" \n + " deleteGroup _team;" \n + " };" \n + " };" \n + " _count = _count + 1;" \n + "};" \n + "" \n + "{if (side _x != west && side _x != east) then {deleteVehicle _x}} forEach _vehicles;" \n + "{if (!isNull(Gunner _x) && !isPlayer(Gunner _x)) then {_unit = (gunner _x);_unit setPos (getpos _x);deleteVehicle _unit}} forEach _defenses;" \n + "_vehicles = [];" \n + "_teams = [];" \n + "" \n + "if (paramResReinf) then {_location setVariable [""reinforcements_alive"",0]};" \n + "" \n + "if (_useCivilians) then {" \n + " _count = 0;" \n + " _total = count _cTeams;" \n + " while {_count < _total} do {" \n + " _team = _cTeams select _count;" \n + " {deleteVehicle _x} forEach units _team;" \n + " deleteGroup _team;" \n + " _count = _count + 1;" \n + " };" \n + " _cTeams = [];" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Defense_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Spawn_Civilians + { + name = "Spawn_Civilians"; + init = /*%FSM*/"_teamCount = 0;" \n + "while {_teamCount < _coef} do {" \n + " _unitTypes = Format[""WFBE_CIV%1%2UNITS"",_civTeams,(1+round(random 3))] Call GetNamespace;" \n + " _leaderName = _unitTypes select 0;" \n + " _position = ([getPos _location,_tusr,_patrolRange] Call GetRandomPosition);" \n + " _team = createGroup Civilian;" \n + " _leader = _team createUnit [_leaderName,_position,[],0.4,""FORM""];" \n + " _leader addEventHandler ['Killed',{[_this select 0,_this select 1] Spawn CivilianKilled}];" \n + " [_leader,_position,50] Call PlaceSafe;" \n + " _position = getPos _leader;" \n + " _cTeams = _cTeams + [_team];" \n + " _count = 1;" \n + " _total = count _unitTypes;" \n + "" \n + " while {_count < _total} do {" \n + " _unitName = _unitTypes select _count;" \n + " _unit = _team createUnit [_unitName,_position,[],0.4,""FORM""];" \n + " _unit addEventHandler ['Killed',{[_this select 0,_this select 1] Spawn CivilianKilled}];" \n + " _count = _count + 1;" \n + " };" \n + "" \n + " _teamCount = _teamCount + 1;" \n + " [_team,_location,(_tupd/2)] Spawn AITownPatrol;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="_"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/updatetownoccupation.fsm b/Server/FSM/updatetownoccupation.fsm new file mode 100644 index 0000000..b9d92b2 --- /dev/null +++ b/Server/FSM/updatetownoccupation.fsm @@ -0,0 +1,730 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-185.449844,-271.783020,-95.449898,-221.783386,0.000000,"Init"}; +item1[] = {"End",1,250,-182.368073,-113.480629,-92.368042,-63.480659,0.000000,"End"}; +item2[] = {"Gameover",4,218,-182.650177,-187.482422,-92.650192,-137.482452,0.000000,"Gameover"}; +item3[] = {"_",8,218,-33.398170,-257.734375,-1.592157,-235.159103,0.000000,""}; +item4[] = {"Defense_Core",2,250,-63.405182,-187.376434,26.594841,-137.376434,0.000000,"Defense Core"}; +item5[] = {"Occupied",4,218,-63.096802,-113.322952,26.903198,-63.322945,0.000000,"Occupied"}; +item6[] = {"Resistance",4,218,51.723022,-187.995987,141.723053,-137.995987,0.000000,"Resistance"}; +item7[] = {"_",8,218,455.074921,-99.775017,486.880951,-77.199760,0.000000,""}; +item8[] = {"Advanced_Defense",2,250,-63.899727,-37.846992,26.100292,12.153011,0.000000,"Advanced" \n "Defense"}; +item9[] = {"Clear",4,218,52.047401,-37.929413,142.047272,12.070588,0.000000,"Clear"}; +item10[] = {"Enemies",4,218,-63.950096,42.576328,26.049911,92.576347,0.000000,"Enemies"}; +item11[] = {"Active",4,218,57.932362,119.758667,147.932343,169.758682,0.000000,"Active"}; +item12[] = {"Update",2,250,-63.949944,119.619461,26.049990,169.619431,0.000000,"Update"}; +item13[] = {"Status",2,250,246.226044,-113.680588,336.225677,-63.680626,0.000000,"Status"}; +item14[] = {"Inactive",4,218,-65.445023,202.808212,24.554951,252.808258,0.000000,"Inactive"}; +item15[] = {"Spawn",2,4346,332.534119,203.132462,422.533905,253.132477,0.000000,"Spawn"}; +item16[] = {"Action",2,250,186.626160,119.316673,276.626404,169.316635,0.000000,"Action"}; +item17[] = {"no_Reinf_occ",4,218,187.878845,30.874571,277.878967,80.874619,0.000000,"no Reinf" \n "occ"}; +item18[] = {"Reinf_occ",4,218,319.613403,120.090843,409.613129,170.090881,0.000000,"Reinf" \n "occ"}; +item19[] = {"Reinforce",2,250,319.318024,32.180855,409.318024,82.180870,0.000000,"Reinforce"}; +item20[] = {"Passive",4,218,205.209961,-219.674011,295.209961,-169.674026,0.000000,"Passive"}; +item21[] = {"Active",4,218,304.639740,-218.685745,394.639740,-168.685760,0.000000,"Active"}; +item22[] = {"Skip",2,250,55.112442,-272.279236,145.112457,-222.279205,0.000000,"Skip"}; +item23[] = {"Delay_Status",2,250,307.081726,-300.316772,397.081757,-250.316772,0.000000,"Delay Status"}; +item24[] = {"Timeout",4,218,306.751160,-390.142151,396.751343,-340.142151,0.000000,"Timeout"}; +item25[] = {"Ticking",4,218,180.878448,-300.777557,270.878479,-250.777557,0.000000,"Ticking"}; +item26[] = {"Delete",2,250,54.588959,-390.142120,144.588943,-340.142120,0.000000,"Delete"}; +item27[] = {"",7,210,92.196381,-92.931099,100.196358,-84.931099,0.000000,""}; +item28[] = {"Filter",2,250,74.266075,203.384094,164.266052,253.383881,0.000000,"Filter"}; +item29[] = {"Air",4,218,74.266052,289.476624,164.265518,339.476501,0.000000,"Air"}; +item30[] = {"Normal",4,218,199.817520,203.384094,289.817749,253.384003,0.000000,"Normal"}; +item31[] = {"Spawn_AA",2,250,423.418945,290.672302,513.419067,340.672119,0.000000,"Spawn AA"}; +item32[] = {"",7,210,464.831757,224.797241,472.831757,232.797226,0.000000,""}; +link0[] = {0,3}; +link1[] = {2,1}; +link2[] = {3,4}; +link3[] = {4,2}; +link4[] = {4,5}; +link5[] = {4,6}; +link6[] = {5,8}; +link7[] = {6,27}; +link8[] = {7,13}; +link9[] = {8,9}; +link10[] = {8,10}; +link11[] = {9,27}; +link12[] = {10,12}; +link13[] = {11,16}; +link14[] = {12,11}; +link15[] = {12,14}; +link16[] = {13,20}; +link17[] = {13,21}; +link18[] = {14,28}; +link19[] = {15,32}; +link20[] = {16,17}; +link21[] = {16,18}; +link22[] = {17,27}; +link23[] = {18,19}; +link24[] = {19,7}; +link25[] = {20,22}; +link26[] = {21,23}; +link27[] = {22,3}; +link28[] = {23,24}; +link29[] = {23,25}; +link30[] = {24,26}; +link31[] = {25,22}; +link32[] = {26,3}; +link33[] = {27,13}; +link34[] = {28,29}; +link35[] = {28,30}; +link36[] = {29,31}; +link37[] = {30,15}; +link38[] = {31,32}; +link39[] = {32,7}; +globals[] = {0.000000,0,0,0,0,640,480,1,90,6316128,1,-249.754089,662.279846,374.132294,-401.634460,763,649,1}; +window[] = {0,-1,-1,-1,-1,840,148,1600,71,1,781}; +*//*%FSM*/ +class FSM +{ + fsmName = "updatetownoccupation"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "_location = _this select 0;" \n + "_probability = _this select 1;" \n + "_detectionRange = _this select 2;" \n + "_name = Str _location;" \n + "" \n + "_isAirOnly = false;" \n + "_patrolRange = _detectionRange * ('WFBE_DETECTIONTOPATROLRANGERATIO' Call GetNamespace);" \n + "_occupationActive = false;" \n + "_occupationAAActive = false;" \n + "_updateVehi = false;" \n + "_teams = [];" \n + "_vehicles = [];" \n + "_position = [];" \n + "_timeInactive = 0;" \n + "_lastReinf = -500;" \n + "_tit = 'WFBE_TOWNOCCUPATIONINACTIVETIME' Call GetNamespace;" \n + "_tupd = 'WFBE_TOWNUNITSPATROLDISTANCE' Call GetNamespace;" \n + "_tusr = 'WFBE_TOWNUNITSPAWNRANGE' Call GetNamespace;" \n + "_defensiveTeam = objNull;" \n + "" \n + "_camps = _location getVariable 'camps';" \n + "_totalCamps = count _camps;" \n + "" \n + "_maxReinforcementTeams = 1 + ('WFBE_TOWNOCCUPATIONDIFFICULTY' Call GetNamespace);" \n + "_location setVariable [""reinforcements_occ"",0];" \n + "" \n + "_defenses = [];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Defense_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Defense_Core + { + name = "Defense_Core"; + init = /*%FSM*/"_lastUpdate = time + random(0.2);" \n + "" \n + "_sideID = _location getVariable ""sideID"";"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Occupied + { + priority = 0.000000; + to="Advanced_Defense"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 10 && (_sideID == EASTID || _sideID == WESTID)"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Resistance + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 10 && _sideID == RESISTANCEID"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Advanced_Defense + { + name = "Advanced_Defense"; + init = /*%FSM*/"_objects = _location NearEntities[[eastSoldierBaseClass,westSoldierBaseClass,resistanceSoldierBaseClass,""Car"",""Motorcycle"",""Tank"",""Air""],_detectionRange];" \n + "_objects = [_objects Call GetLiveUnits,200,-10] Call GetUnitsBelowHeight;" \n + "_side = _sideID Call GetSideFromID;" \n + "_enemies = if (_side == East) then {(West countSide _objects) + (Resistance countSide _objects)} else {(East countSide _objects) + (Resistance countSide _objects)};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Enemies + { + priority = 0.000000; + to="Update"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_enemies > 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Clear + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_enemies == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update + { + name = "Update"; + init = /*%FSM*/"_timeInactive = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Inactive + { + priority = 0.000000; + to="Filter"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_occupationActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Active + { + priority = 0.000000; + to="Action"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_occupationActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Status + { + name = "Status"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Active + { + priority = 0.000000; + to="Delay_Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_occupationActive || _occupationAAActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Passive + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_occupationActive && !_occupationAAActive"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Spawn + { + name = "Spawn"; + init = /*%FSM*/"[""HostilesDetectedNear"",_location,_side] Spawn SideMessage;" \n + "" \n + "_teamCount = 0;" \n + "_vehiBuilt = 0;" \n + "_built = 0;" \n + "_currentSV = _location getVariable ""supplyValue"";" \n + "_probaOccupation = 75;" \n + "_occupationsTeamTypes = [_currentSV] Call SelectOccupTeam;" \n + "_totalTeams = count _occupationsTeamTypes;" \n + "" \n + "_ci = 0;" \n + "while {_teamCount < _totalTeams} do {" \n + " _occupationActive = true;" \n + " _unitTypes = Format[""WFBE_%1%2UNITS"",str _side,_occupationsTeamTypes select _teamCount] Call GetNamespace;" \n + " _leaderName = _unitTypes select 0;" \n + " _camp = objNull;" \n + " if (_ci < _totalCamps) then {" \n + " _position = ([getPos (_camps select _ci),8,40] Call GetRandomPosition);" \n + " _camp = _camps select _ci;" \n + " } else {" \n + " _position = ([getPos _location,_tusr,_patrolRange] Call GetRandomPosition);" \n + " };" \n + " _team = createGroup _side;" \n + " _leader = [_leaderName,_team,_position,_side] Call CreateMan;" \n + " [_leader,_position,50] Call PlaceSafe;" \n + " _position = getPos _leader;" \n + " _teams = _teams + [_team];" \n + " _count = 1;" \n + " _total = count _unitTypes;" \n + " _built = _built + 1;" \n + " while {_count < _total} do {" \n + " _unitName = _unitTypes select _count;" \n + " if (random(100) < _probaOccupation) then {" \n + " if (_unitName isKindOf ""Man"") then {" \n + " _unit = [_unitName,_team,_position,_side] Call CreateMan;" \n + " _built = _built + 1;" \n + " } else {" \n + " _vehicle = [_unitName,_position,_side,true] Call CreateVehi;" \n + " _vehicles = _vehicles + [_vehicle];" \n + " emptyQueu = emptyQueu + [_vehicle];" \n + " _vehicle Spawn HandleEmptyVehicle;" \n + " _vehiBuilt = _vehiBuilt + 1;" \n + " _continue = true;" \n + " if (vehicle _leader == _leader) then {_leader MoveInDriver _vehicle;_continue = false};" \n + " _type = Format [""WFBE_%1SOLDIER"",str _side] Call GetNamespace;" \n + " if (typeOf _vehicle == ""Tank"") then {_type = Format [""WFBE_%1CREW"",str _side] Call GetNamespace};" \n + " if (_continue) then {_driver = [_type,_team,_position,_side] Call CreateMan;_driver moveInDriver _vehicle;_built = _built + 1;};" \n + " if (_vehicle emptyPositions ""gunner"" > 0) then {_gunner = [_type,_team,_position,_side] Call CreateMan;_gunner moveInGunner _vehicle;_built = _built + 1;};" \n + " if (_vehicle emptyPositions ""commander"" > 0) then {_commander = [_type,_team,_position,_side] Call CreateMan;_commander moveInCommander _vehicle;_built = _built + 1;};" \n + " };" \n + " };" \n + " _count = _count + 1;" \n + " };" \n + "" \n + " [_team, 350, _position] Call RevealArea;" \n + " [_location,_team,_sideID,_camp,false] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + "" \n + " if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + " _teamCount = _teamCount + 1;" \n + " _ci = _ci + 1;" \n + "};" \n + "" \n + "_temp = _location nearEntities [(Format ['WFBE_%1DEFENSENAMES',str _side] Call GetNamespace),_tupd*1.4];" \n + "_defensiveTeam = Call Compile Format [""WF_Defense%1Grp"",str _side];" \n + "if (isNull _defensiveTeam) then {Call Compile Format [""WF_Defense%1Grp = createGroup %1"",str _side]};" \n + "_count = 0;" \n + "{" \n + " if (_x emptyPositions 'gunner' > 0 && alive _x) then {" \n + " _defenses = _defenses + [_x];" \n + " _unit = [Format [""WFBE_%1SOLDIER"",str _side] Call GetNamespace,_defensiveTeam,[(getPos _x select 0)+5,getPos _x select 1,0],_side] Call CreateMan;" \n + " [_unit] allowGetIn true;" \n + " _unit assignAsGunner _x;" \n + " [_unit] orderGetIn true;" \n + " _unit moveInGunner _x;" \n + " [_defensiveTeam, 350, _unit] Call RevealArea;" \n + " _count = _count + 1;" \n + " };" \n + "" \n + " if (_count > 25) exitWith {};" \n + "} forEach _temp;" \n + "" \n + "[str _side,'UnitsCreated',_built] Call UpdateStatistics;" \n + "if (_vehiBuilt > 0) then {[str _side,'VehiclesCreated',_vehiBuilt] Call UpdateStatistics};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Action + { + name = "Action"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Reinf_occ + { + priority = 0.000000; + to="Reinforce"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"paramOccReinf && (_location getVariable ""reinforcements_occ"") < _maxReinforcementTeams && time - _lastReinf > 300"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class no_Reinf_occ + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!paramOccReinf || (_location getVariable ""reinforcements_occ"") >= _maxReinforcementTeams || time - _lastReinf <= 300"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Reinforce + { + name = "Reinforce"; + init = /*%FSM*/"_lastReinf = time;" \n + "_currentSV = _location getVariable ""supplyValue"";" \n + "_probaOccupation = 75;" \n + "_occupationsTeamTypes = [_currentSV] Call SelectOccupTeam;" \n + "" \n + "_unitTypes = Format[""WFBE_%1%2UNITS"",str _side,_occupationsTeamTypes select round(random((count _occupationsTeamTypes)-1))] Call GetNamespace;" \n + "_leaderName = _unitTypes select 0;" \n + "_position = ([getPos _location,_tusr + 150,_patrolRange] Call GetRandomPosition);" \n + "_near = _position nearEntities 75;" \n + "_ctx = (east countSide _near) + (west countSide _near);" \n + "_i = 0;" \n + "while {_ctx > 0 && _i < 400} do {" \n + " _position = ([getPos _location,_tusr + 150,_patrolRange] Call GetRandomPosition);" \n + " _near = _position nearEntities 75;" \n + " _ctx = (east countSide _near) + (west countSide _near);" \n + " _i = _i + 1;" \n + "};" \n + "_team = createGroup _side;" \n + "_leader = [_leaderName,_team,_position,_side] Call CreateMan;" \n + "[_leader,_position,50] Call PlaceSafe;" \n + "_position = getPos _leader;" \n + "_teams = _teams + [_team];" \n + "_count = 1;" \n + "_total = count _unitTypes;" \n + "_built = 1;" \n + "_vehiBuilt = 0;" \n + "while {_count < _total} do {" \n + " _unitName = _unitTypes select _count;" \n + " if (random(100) < _probaOccupation) then {" \n + " if (_unitName isKindOf ""Man"") then {" \n + " _unit = [_unitName,_team,_position,_side] Call CreateMan;" \n + " _built = _built + 1;" \n + " } else {" \n + " _vehicle = [_unitName,_position,_side,true] Call CreateVehi;" \n + " _vehicles = _vehicles + [_vehicle];" \n + " emptyQueu = emptyQueu + [_vehicle];" \n + " _vehicle Spawn HandleEmptyVehicle;" \n + " _vehiBuilt = _vehiBuilt + 1;" \n + " _continue = true;" \n + " if (vehicle _leader == _leader) then {_leader MoveInDriver _vehicle;_continue = false};" \n + " _type = Format [""WFBE_%1SOLDIER"",str _side] Call GetNamespace;" \n + " if (typeOf _vehicle == ""Tank"") then {_type = Format [""WFBE_%1CREW"",str _side] Call GetNamespace};" \n + " if (_continue) then {_driver = [_type,_team,_position,_side] Call CreateMan;_driver moveInDriver _vehicle;_built = _built + 1;};" \n + " if (_vehicle emptyPositions ""gunner"" > 0) then {_gunner = [_type,_team,_position,_side] Call CreateMan;_gunner moveInGunner _vehicle;_built = _built + 1;};" \n + " if (_vehicle emptyPositions ""commander"" > 0) then {_commander = [_type,_team,_position,_side] Call CreateMan;_commander moveInCommander _vehicle;_built = _built + 1;};" \n + " };" \n + " };" \n + " _count = _count + 1;" \n + "};" \n + "" \n + "if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""fortify"",""reinforcement""] Spawn UPSMON};" \n + "" \n + "[_location,_team,_sideID,objNull,true] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + "" \n + "[str _side,'UnitsCreated',_built] Call UpdateStatistics;" \n + "if (_vehiBuilt > 0) then {[str _side,'VehiclesCreated',_vehiBuilt] Call UpdateStatistics};" \n + "" \n + "_existing = _location getVariable ""reinforcements_occ"";" \n + "_location setVariable [""reinforcements_occ"",_existing + 1];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Skip + { + name = "Skip"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Defense_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Delay_Status + { + name = "Delay_Status"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Ticking + { + priority = 0.000000; + to="Skip"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _timeInactive <= _tit"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Timeout + { + priority = 0.000000; + to="Delete"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time - _timeInactive > _tit"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Delete + { + name = "Delete"; + init = /*%FSM*/"_occupationActive = false;" \n + "_occupationAAActive = false;" \n + "" \n + "_count = 0;" \n + "_total = count _teams;" \n + "while {_count < _total} do {" \n + " _team = _teams select _count;" \n + " if !(isNil '_team') then {" \n + " if !(isNull _team) then {" \n + " {deleteVehicle _x} forEach units _team;" \n + " deleteGroup _team;" \n + " };" \n + " };" \n + " _count = _count + 1;" \n + "};" \n + "" \n + "{" \n + " _del = true;" \n + " if (count(crew _x) > 0) then {" \n + " if (isPlayer(leader (crew _x select 0))) then {_del = false};" \n + " };" \n + " if (_del) then {deleteVehicle _x};" \n + "} forEach _vehicles;" \n + "" \n + "_vehicles = [];" \n + "_teams = [];" \n + "" \n + "if (paramOccReinf) then {_location setVariable [""reinforcements_occ"",0]};" \n + "" \n + "{" \n + " if (!isNull(Gunner _x) && !isPlayer(Gunner _x)) then {" \n + " _unit = (gunner _x);" \n + " if (group _unit == _defensiveTeam) then {" \n + " _unit setPos (getpos _x);" \n + " deleteVehicle _unit;" \n + " };" \n + " };" \n + "} forEach _defenses;" \n + "_defenses = [];" \n + "_defensiveTeam = objNull;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Defense_Core"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Filter + { + name = "Filter"; + init = /*%FSM*/"if !(_occupationAAActive) then {" \n + " _objects = _location NearEntities[[""Air""],_detectionRange];" \n + " _objects = [_objects Call GetLiveUnits,200,25] Call GetUnitsBelowHeight;" \n + "" \n + " _airEnemies = if (_side == East) then {(West countSide _objects) + (Resistance countSide _objects)} else {(East countSide _objects) + (Resistance countSide _objects)};" \n + " _isAirOnly = if (_airEnemies == _enemies) then {true} else {false};" \n + "} else {" \n + " _isAirOnly = false;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Normal + { + priority = 0.000000; + to="Spawn"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!_isAirOnly"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Air + { + priority = 0.000000; + to="Spawn_AA"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_isAirOnly"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Spawn_AA + { + name = "Spawn_AA"; + init = /*%FSM*/"[""HostilesDetectedNear"",_location,_side] Spawn SideMessage;" \n + "_occupationAAActive = true;" \n + "" \n + "_currentSV = _location getVariable ""supplyValue"";" \n + "" \n + "_sv1 = 'WFBE_OCCUPATIONAATEAM1' Call GetNamespace;" \n + "_sv2 = 'WFBE_OCCUPATIONAATEAM2' Call GetNamespace;" \n + "" \n + "//--- Set the team type to spawn." \n + "_type = 'Small';" \n + "if (_currentSV < _sv1) then {_type = 'Small'};" \n + "if (_currentSV >= _sv1 && _currentSV < _sv2) then {_type = 'Medium'};" \n + "if (_currentSV > _sv2) then {_type = 'Large'};" \n + "" \n + "_grps = 1 + floor(('WFBE_TOWNOCCUPATIONDIFFICULTY' Call GetNamespace)/2);" \n + "if (_type == 'Small') then {_grps = _grps + 1};" \n + "" \n + "_i = 0;" \n + "_infantry = 0;" \n + "_aaVehicles = [];" \n + "while {_i < _grps} do {" \n + " _position = ([getPos _location,_tusr/2,_patrolRange] Call GetRandomPosition);" \n + " _safePos = [_position,50] Call GetSafePlace;" \n + " " \n + " _effectiveType = _type;" \n + " if (_grps > 2) then {" \n + " if (_type == 'Medium' && random 100 > 75) then {_effectiveType = ['Small','Medium'] select round(random 1)};" \n + " if (_type == 'Large' && random 100 > 70) then {_effectiveType = ['Small','Medium','Large'] select round(random 2)};" \n + " };" \n + " " \n + " _teamType = Format [""WFBE_%1%2AATEAMUNITS"",_side,_effectiveType] Call GetNamespace;" \n + " " \n + " _retVal = [_teamType,_safePos,_side,false] Call CreateTeamTemplate;" \n + " _aaVehicles = _retVal select 1;" \n + " _team = _retVal select 2;" \n + " " \n + " {emptyQueu = emptyQueu + [_x];_x Spawn HandleEmptyVehicle} forEach _aaVehicles;" \n + " " \n + " _teams = _teams + [_team];" \n + " _vehicles = _vehicles + _aaVehicles;" \n + " _infantry = _infantry + (count (_retVal select 0)) + (count(_retVal select 3));" \n + " " \n + " [_location,_team,_sideID,objNull,false] ExecFSM ""Server\FSM\townpatrol.fsm"";" \n + " " \n + " //--- AA Team are well informed about air units." \n + " {_team reveal _x} forEach _objects;" \n + "" \n + " //--- Use UPSMON AI if enabled." \n + " if (paramUPSMON) then {[(leader _team),Format ['UPSMON_TOWN_%1',str _location],""move"",""nofollow"",""reinforcement""] Spawn UPSMON};" \n + " " \n + " _i = _i + 1;" \n + "};" \n + "" \n + "if (_infantry > 0) then {[str _side,'UnitsCreated',_infantry] Call UpdateStatistics};" \n + "if (count _aaVehicles > 0) then {[str _side,'VehiclesCreated',count _aaVehicles] Call UpdateStatistics};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Status"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/weather.fsm b/Server/FSM/weather.fsm new file mode 100644 index 0000000..8795dea --- /dev/null +++ b/Server/FSM/weather.fsm @@ -0,0 +1,100 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-81.542984,-257.577942,8.457038,-207.578140,0.000000,"Init"}; +item1[] = {"End",1,250,-216.387955,-52.508366,-126.387947,-2.508394,0.000000,"End"}; +item2[] = {"Update_Weather",2,4346,-82.090652,-139.314026,7.909359,-89.314034,0.000000,"Update Weather"}; +item3[] = {"Loop",4,218,53.846153,-139.681244,143.846161,-89.681236,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-216.387955,-139.464890,-126.387947,-89.464890,0.000000,"Gameover"}; +item5[] = {"_",8,218,-51.736092,-184.192123,-21.083296,-163.272247,0.000000,""}; +link0[] = {0,5}; +link1[] = {2,3}; +link2[] = {2,4}; +link3[] = {3,2}; +link4[] = {4,1}; +link5[] = {5,2}; +globals[] = {0.000000,0,0,0,0,640,480,1,8,6316128,1,-348.696411,348.696136,79.849762,-328.514618,921,617,1}; +window[] = {0,-1,-1,-1,-1,762,25,1438,25,1,939}; +*//*%FSM*/ +class FSM +{ + fsmName = "weather"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"WF_Logic setVariable [""overCast"",random(1),true];" \n + "_wt = 'WFBE_WEATHERTRANSITION' Call GetNamespace;" \n + "_delay = ((_wt * 2) + 100);" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Update_Weather"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/""/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Weather + { + name = "Update_Weather"; + init = /*%FSM*/"_overCast = random(1);" \n + "if (isDedicated) then {_wt setOvercast _overCast};" \n + "WF_Logic setVariable [""overCast"",_overCast,true];" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Weather"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > _delay"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End" + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/FSM/workers.fsm b/Server/FSM/workers.fsm new file mode 100644 index 0000000..98cd7d8 --- /dev/null +++ b/Server/FSM/workers.fsm @@ -0,0 +1,323 @@ +/*%FSM*/ +/*%FSM*/ +/* +item0[] = {"Init",0,250,-81.542984,-257.577942,8.457038,-207.578140,0.000000,"Init"}; +item1[] = {"End",1,250,-341.327942,-139.587799,-251.327972,-89.587807,0.000000,"End"}; +item2[] = {"Update_Worker",2,250,-82.090652,-139.314026,7.909359,-89.314034,0.000000,"Update Worker"}; +item3[] = {"Loop",4,218,53.846153,-139.681244,143.846161,-89.681236,0.000000,"Loop"}; +item4[] = {"Gameover",4,218,-216.387955,-139.464890,-126.387947,-89.464890,0.000000,"Gameover"}; +item5[] = {"_",8,218,-51.736092,-184.192123,-21.083296,-163.272247,0.000000,""}; +item6[] = {"No_Job",4,218,-18.119097,-70.317200,71.880913,-20.317196,0.000000,"No Job"}; +item7[] = {"Job",4,218,-129.429321,-69.559975,-39.429314,-19.559986,0.000000,"Job"}; +item8[] = {"Update_Job",2,4346,-129.807770,17.519415,-39.807682,67.519424,0.000000,"Update Job"}; +item9[] = {"Idle_or_Assign",2,250,-17.740370,16.005005,72.259621,66.005020,0.000000,"Idle or Assign"}; +item10[] = {"",7,210,23.149067,111.413750,31.149073,119.413750,0.000000,""}; +item11[] = {"",7,210,94.437599,110.454597,102.437599,118.454597,0.000000,""}; +item12[] = {"Build",4,218,-259.291138,17.519421,-169.291153,67.519417,0.000000,"Build"}; +item13[] = {"Maintenance",4,218,-259.231995,82.296516,-169.232025,132.296509,0.000000,"Maintenance"}; +item14[] = {"Update_Build",2,250,-375.901794,18.161104,-285.901794,68.161102,0.000000,"Update Build"}; +item15[] = {"Update_Maintenan",2,250,-375.085449,82.180977,-285.085449,132.181000,0.000000,"Update" \n "Maintenance"}; +item16[] = {"",7,210,-405.433075,39.363052,-397.433075,47.363045,0.000000,""}; +item17[] = {"",7,210,-404.876038,105.391983,-396.876038,113.391983,0.000000,""}; +item18[] = {"",7,210,-406.079773,223.920914,-398.079773,231.920914,0.000000,""}; +item19[] = {"",7,210,23.259628,223.163696,31.259632,231.163696,0.000000,""}; +link0[] = {0,5}; +link1[] = {2,4}; +link2[] = {2,6}; +link3[] = {2,7}; +link4[] = {3,2}; +link5[] = {4,1}; +link6[] = {5,2}; +link7[] = {6,9}; +link8[] = {7,8}; +link9[] = {8,12}; +link10[] = {8,13}; +link11[] = {9,10}; +link12[] = {10,11}; +link13[] = {11,3}; +link14[] = {12,14}; +link15[] = {13,15}; +link16[] = {14,16}; +link17[] = {15,17}; +link18[] = {16,17}; +link19[] = {17,18}; +link20[] = {18,19}; +link21[] = {19,10}; +globals[] = {0.000000,0,0,0,0,640,480,1,28,6316128,1,-573.943970,177.921814,238.376556,-265.316376,921,617,1}; +window[] = {0,-1,-1,-1,-1,837,100,1513,100,1,939}; +*//*%FSM*/ +class FSM +{ + fsmName = "workers"; + class States + { + /*%FSM*/ + class Init + { + name = "Init"; + init = /*%FSM*/"_worker = _this select 0;" \n + "_side = _this select 1;" \n + "_index = _this select 2;" \n + "" \n + "_assignedConstruction = objNull;" \n + "_action = """";" \n + "_pos = getPos _worker;" \n + "_idleFor = 0;" \n + "_lastMoveOrdered = -40;" \n + "" \n + "_speed = 'WFBE_WORKERS_RATIO' Call GetNamespace;" \n + "_distance = 'WFBE_WORKERS_BUILDDISTANCE' Call GetNamespace;" \n + "_maxDistance = 'WFBE_WORKERS_MAXRANGE' Call GetNamespace;" \n + "_repairs = 'WFBE_WORKERS_REPAIR' Call GetNamespace;" \n + "" \n + "_animations = [""AinvPknlMstpSlayWrflDnon_AmovPknlMstpSnonWnonDnon"", ""AinvPknlMstpSlayWrflDnon_AmovPknlMstpSnonWnonDnon"", ""AinvPknlMstpSlayWrflDnon_AmovPercMstpSrasWrflDnon"", ""AinvPknlMstpSlayWrflDnon_medic""];" \n + "" \n + "_lastUpdate = time;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class _ + { + priority = 0.000000; + to="Update_Worker"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class End + { + name = "End"; + init = /*%FSM*/"_workers = Call Compile Format [""WF_%1Workers"",str _side];" \n + "_workers set [_index, objNull];" \n + "Call Compile Format [""WF_%1Workers = _workers; publicVariable 'WF_%1Workers';"",str _side];"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Worker + { + name = "Update_Worker"; + init = /*%FSM*/"_lastUpdate = time;" \n + "" \n + "_temp = (Format [""WFBE_WORKERS_%1LOGIC"",str _side]) Call GetNamespace;" \n + "" \n + "//--- Range calculation." \n + "_buildList = [];" \n + "{if (_x distance _worker < _maxDistance) then {_buildList = _buildList + [_x]}} forEach _temp;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class No_Job + { + priority = 0.000000; + to="Idle_or_Assign"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"alive _worker && isNull _assignedConstruction|| count _buildList == 0"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Job + { + priority = 0.000000; + to="Update_Job"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"alive _worker && !isNull _assignedConstruction && count _buildList > 0 || _action == ""Maintenance"""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Gameover + { + priority = 0.000000; + to="End"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"gameOver || !alive _worker"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Job + { + name = "Update_Job"; + init = /*%FSM*/"if (_pos distance (getPos _worker) < 5 && _worker distance _assignedConstruction > _distance) then {" \n + " _idleFor = _idleFor + 5;" \n + "} else {" \n + " _idleFor = 0;" \n + "};" \n + "" \n + "if (_idleFor > 30) then {" \n + " _idleFor = 0;" \n + " [_worker, getPos _worker, 40] Call PlaceSafe;" \n + "};" \n + "" \n + "if (behaviour _worker != ""CARELESS"") then {_worker setBehaviour ""CARELESS""};" \n + "" \n + "_pos = getPos _worker;"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Maintenance + { + priority = 0.000000; + to="Update_Maintenan"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_action == ""Maintenance"""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + /*%FSM*/ + class Build + { + priority = 0.000000; + to="Update_Build"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"_action == ""Build"" || _action == ""Repair"""/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Idle_or_Assign + { + name = "Idle_or_Assign"; + init = /*%FSM*/"if (count _buildList > 0) then {" \n + " _temp = [_worker, _buildList] Call SortByDistance;" \n + " {" \n + " if !(isNull _assignedConstruction) exitWith {}; " \n + "" \n + " _get = _x getVariable ""WFBE_B_Completion"";" \n + " " \n + " if !(isNil '_get') then {" \n + " if (_get <= 100) then {" \n + " _action = if (_x getVariable ""WFBE_B_Repair"") then {""Repair""} else {""Build""};" \n + " _assignedConstruction = _x;" \n + " };" \n + " };" \n + " } forEach _temp;" \n + "};" \n + "" \n + "//--- Maintenance?" \n + "if (count _buildList == 0) then {" \n + " _structures = (_side) Call GetSideStructures;" \n + "" \n + " _structures = [_worker, _structures] Call SortByDistance;" \n + "" \n + " {" \n + " if (getDammage _x > 0 && alive _x) exitWith {_assignedConstruction = _x;_action = ""Maintenance"";}" \n + " } forEach _structures;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Worker"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 4"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Build + { + name = "Update_Build"; + init = /*%FSM*/"if (_assignedConstruction in _buildList) then {" \n + " _completion = _assignedConstruction getVariable ""WFBE_B_Completion"";" \n + " _ratio = _assignedConstruction getVariable ""WFBE_B_CompletionRatio"";" \n + "" \n + " if (_completion < 100) then {" \n + " if (_worker distance _assignedConstruction > _distance) then {" \n + " if (time - _lastMoveOrdered > 40) then {_worker commandMove (getPos _assignedConstruction);_lastMoveOrdered = time};" \n + " } else {" \n + " _worker playMove (_animations select round(random((count _animations)-1)));" \n + " _ratio = (_speed * _ratio) + _completion;" \n + " if (_ratio > 100) then {_ratio = 100};" \n + " _assignedConstruction setVariable [""WFBE_B_Completion"", _ratio];" \n + " };" \n + " } else {" \n + " _action = """";" \n + " _assignedConstruction = objNull;" \n + " };" \n + "} else {" \n + " _action = """";" \n + " _assignedConstruction = objNull;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Worker"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 4"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + /*%FSM*/ + class Update_Maintenan + { + name = "Update_Maintenan"; + init = /*%FSM*/"if (alive _assignedConstruction && getDammage _assignedConstruction > 0) then {" \n + " if (_worker distance _assignedConstruction > _distance) then {" \n + " if (time - _lastMoveOrdered > 30) then {_worker commandMove (getPos _assignedConstruction);_lastMoveOrdered = time};" \n + " } else {" \n + " _worker playMove (_animations select round(random((count _animations)-1)));" \n + " _damages = (getDammage _assignedConstruction) - _repairs;" \n + " if (_damages < 0) then {_damages = 0};" \n + " _assignedConstruction setDammage _damages;" \n + " };" \n + "} else {" \n + " _action = """";" \n + " _assignedConstruction = objNull;" \n + "};"/*%FSM*/; + precondition = /*%FSM*/""/*%FSM*/; + class Links + { + /*%FSM*/ + class Loop + { + priority = 0.000000; + to="Update_Worker"; + precondition = /*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"!gameOver && time - _lastUpdate > 4"/*%FSM*/; + action=/*%FSM*/""/*%FSM*/; + }; + /*%FSM*/ + }; + }; + /*%FSM*/ + }; + initState="Init"; + finalStates[] = + { + "End", + }; +}; +/*%FSM*/ \ No newline at end of file diff --git a/Server/Functions/Server_AlliesBuyUnit.sqf b/Server/Functions/Server_AlliesBuyUnit.sqf new file mode 100644 index 0000000..8a40f0e --- /dev/null +++ b/Server/Functions/Server_AlliesBuyUnit.sqf @@ -0,0 +1,144 @@ +Private ["_building","_built","_config","_crew","_direction","_dir","_distance","_factoryPosition","_factoryType","_id","_index","_isVehicle","_longest","_position","_queu","_queu2","_ret","_side","_sideText","_soldier","_team","_turrets","_type","_unitType","_vehicle","_waitTime"]; +_id = _this select 0; +_building = _this select 1; +_unitType = _this select 2; +_side = _this select 3; +_team = _this select 4; +_isVehicle = _this select 5; + +_sideText = str _side; + +if ((!alive _building)||(isNull _building)) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_AlliesBuyUnit.sqf: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime];}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_AlliesBuyUnit: AI Team %1 has purchased a '%2'",_team,_unitType,diag_frameno,diag_tickTime]; + +_queu = _building getVariable "queu"; +if (isNil "_queu") then {_queu = []}; +_queu = _queu + [_id select 0]; +_building setVariable ["queu",_queu]; + +_type = typeOf _building; +if (_type == "CDF_WarfareBBarracks" || _type == "Ins_WarfareBBarracks") then {_type = Call Compile Format ["%1BAR",str _side]}; +if (_type == "CDF_WarfareBLightFactory" || _type == "Ins_WarfareBLightFactory") then {_type = Call Compile Format ["%1LVF",str _side]}; +if (_type == "CDF_WarfareBHeavyFactory" || _type == "Ins_WarfareBHeavyFactory") then {_type = Call Compile Format ["%1HEAVY",str _side]}; +if (_type == "CDF_WarfareBAircraftFactory" || _type == "Ins_WarfareBAircraftFactory") then {_type = Call Compile Format ["%1AIR",str _side]}; + +_index = (Format ["WFBE_%1STRUCTURENAMES",_sideText] Call GetNamespace) find _type; +_distance = (Format ["WFBE_%1STRUCTUREDISTANCES",_sideText] Call GetNamespace) select _index; +_direction = (Format ["WFBE_%1STRUCTUREDIRECTIONS",_sideText] Call GetNamespace) select _index; +_factoryType = (Format ["WFBE_%1STRUCTURES",_sideText] Call GetNamespace) select _index; + +_waitTime = (_unitType Call GetNamespace) select QUERYUNITTIME; +_position = [getPos _building,_distance,getDir _building + _direction] Call GetPositionFrom; +_longest = Format ["WFBE_LONGEST%1BUILDTIME",_factoryType] Call GetNamespace; + +_ret = 0; +_queu2 = [0]; + +if (count _queu > 0) then { + _queu2 = _building getVariable "queu"; +}; + +while {_id select 0 != _queu select 0} do { + sleep 4; + _ret = _ret + 4; + _queu = _building getVariable "queu"; + + if (!(alive _building)||(isNull _building)) exitWith { + _queu = _building getVariable "queu"; + _queu = _queu - [_queu select 0]; + _building setVariable ["queu",_queu]; + diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit.sqf: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime]; + }; + + if (_queu select 0 == _queu2 select 0) then { + if (_ret > _longest) then { + if (count _queu > 0) then { + _queu = _building getVariable "queu"; + _queu = _queu - [_queu select 0]; + _building setVariable ["queu",_queu]; + }; + }; + }; + if (count _queu != count _queu2) then { + _ret = 0; + _queu2 = _building getVariable "queu"; + }; +}; + +sleep _waitTime; + +_queu = _building getVariable "queu"; +_queu = _queu - [_id select 0]; +_building setVariable ["queu",_queu]; + +if ((!alive _building)||(isNull _building)) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_AlliesBuyUnit.sqf: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime];}; + +if (_unitType isKindOf "Man") then { + _soldier = [_unitType,_team,_position,_side] Call CreateMan; + [_sideText,'UnitsCreated',1] Call UpdateStatistics; + + //--- Infantry can use the team vehicles as cargo. + _vehicle = [_team,true] Call GetTeamVehicles; + {_team addVehicle _x} forEach _vehicle; +} else { + _crew = Format["WFBE_%1ALLIESSOLDIER",_sideText] Call GetNamespace; + if (_unitType isKindOf "Tank") then {_crew = Format ["WFBE_%1ALLIESCREW",_sideText] Call GetNamespace}; + if (_unitType isKindOf "Air") then {_crew = Format ["WFBE_%1ALLIESPILOT",_sideText] Call GetNamespace}; + _vehicle = [_unitType,_position,_side,true] Call CreateVehi; + _factoryPosition = getPos _building; + _dir = -((((_position select 1) - (_factoryPosition select 1)) atan2 ((_position select 0) - (_factoryPosition select 0))) - 90); + _vehicle setDir _dir; + _vehicle setVelocity [0,0,-1]; + //--- AI Can fly...? (*roll eyes at the harriers*). + if (_vehicle isKindOf "Plane") then { + _vehicle setPos [_position select 0,_position select 1,1500]; + _vehicle setVelocity [(sin _direction) * 250,(cos _direction) * 250,0]; + }; + + /* Clear the vehicle */ + clearWeaponCargo _vehicle; + clearMagazineCargo _vehicle; + + emptyQueu = emptyQueu + [_vehicle]; + _vehicle Spawn HandleEmptyVehicle; + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + [_soldier] orderGetIn true; + _soldier assignAsDriver _vehicle; + _soldier moveInDriver _vehicle; + + [_sideText,'VehiclesCreated',1] Call UpdateStatistics; + _built = 1; + if (_isVehicle select 1) then { + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + [_soldier] orderGetIn true; + _soldier assignAsGunner _vehicle; + _soldier moveInGunner _vehicle; + _built = _built + 1; + }; + if (_isVehicle select 2) then { + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + [_soldier] orderGetIn true; + _soldier assignAsCommander _vehicle; + _soldier moveInCommander _vehicle; + _built = _built + 1; + }; + if (_isVehicle select 3) then { + Private ["_get","_turrets"]; + _get = _unitType Call GetNamespace; + _turrets = _get select QUERYUNITTURRETS; + + { + if (isNull (_vehicle turretUnit _x)) then { + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + _soldier moveInTurret [_vehicle, _x]; + _built = _built + 1; + }; + } forEach _turrets; + }; + [_sideText,'UnitsCreated',_built] Call UpdateStatistics; +}; \ No newline at end of file diff --git a/Server/Functions/Server_BuildingDamaged.sqf b/Server/Functions/Server_BuildingDamaged.sqf new file mode 100644 index 0000000..034a8ef --- /dev/null +++ b/Server/Functions/Server_BuildingDamaged.sqf @@ -0,0 +1,18 @@ +Private["_currentDammages","_damage","_damagedBy","_side","_structure","_timeAttacked"]; + +_structure = _this Select 0; +_damagedBy = _this Select 1; +_damage = _this Select 2; +_currentDammages = getDammage _structure; + +_side = east; +if ((typeOf _structure) in ('WFBE_WESTSTRUCTURENAMES' Call GetNamespace)) then {_side = west}; + +_timeAttacked = Format["WFBE_%1_TimeUnderAttack",str _side] Call GetNamespace; + +if (_side != Side _damagedBy) then { + if (time - _timeAttacked > 30 && _damage > 0.05 && ((_currentDammages + _damage) < 1)) then { + [Format["WFBE_%1_TimeUnderAttack",str _side],time,true] Call SetNamespace; + ["IsUnderAttack",TypeOf _structure ,_side] Spawn SideMessage; + }; +}; \ No newline at end of file diff --git a/Server/Functions/Server_BuildingHandleDamages.sqf b/Server/Functions/Server_BuildingHandleDamages.sqf new file mode 100644 index 0000000..f5b5913 --- /dev/null +++ b/Server/Functions/Server_BuildingHandleDamages.sqf @@ -0,0 +1,22 @@ +Private ['_building','_dammages','_origin','_side','_sideBuilding','_side']; + +_building = _this select 0; +_dammages = _this select 1; +_origin = _this select 2; +_sideBuilding = _this select 3; + +_side = civilian; +if (side _origin == sideEnemy) then { + if (_origin isKindOf westSoldierBaseClass) then {_side = west}; + if (_origin isKindOf eastSoldierBaseClass) then {_side = east}; +} else { + _side = side _origin; +}; + +if (_sideBuilding == _side) then { + _dammages = false; +} else { + _dammages = [_building, _dammages] Call HandleBuildingDamage; +}; + +_dammages \ No newline at end of file diff --git a/Server/Functions/Server_BuildingKilled.sqf b/Server/Functions/Server_BuildingKilled.sqf new file mode 100644 index 0000000..77b3f2c --- /dev/null +++ b/Server/Functions/Server_BuildingKilled.sqf @@ -0,0 +1,72 @@ +Private ['_current','_find','_killer','_structure','_structures','_side','_tked','_type','_uid']; +_structure = _this select 0; +_killer = _this select 1; +_side = _this select 2; +_type = _this select 3; + +diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuildingKilled: A %1 %2 Structure has been destroyed (By: %5)",str _side,_type,diag_frameno,diag_tickTime,_killer]; + +//--- Building Teamkill. +if ((side _killer == _side)&&(isPlayer(_killer))) then { + _uid = getPlayerUID _killer; + if !(paramShowUID) then {_uid = "xxxxxxx"}; + _tked = [_type, 'displayName'] Call GetConfigInfo; + WFBE_LocalizeMessage = [_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]]; + publicVariable 'WFBE_LocalizeMessage'; + if (isHostedServer) then {[_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]] Spawn HandlePVF}; + if (mysql) then { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_Update?%1?%2?teamkillstr?%3",_uid,name _killer,worldName]]]; + }; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuildingKilled: Player %1 (%2) has teamkilled a friendly building.",name _killer,_uid,diag_frameno,diag_tickTime]; +}; + +if (mysql) then { + if ((side _killer != _side)&&(isPlayer(_killer))) then { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?3?%5",_type,getPlayerUID _killer,name _killer,"killed",worldName]]]; + }; +}; + +//--- Decrement building limit. +_find = (Format ['WFBE_%1STRUCTURENAMES',_side] Call GetNamespace) find _type; +if (_find != -1) then { + _current = Call Compile Format ['%1BuildingsCurrent',_side]; + _current set [_find - 1, (_current select (_find-1)) - 1]; + Call Compile Format ['%1BuildingsCurrent = _current',_side]; + publicVariable Format ['%1BuildingsCurrent',_side]; +}; + +Call Compile Format ["%1BaseStructures = %1BaseStructures - [_structure] - [objNull]; publicVariable '%1BaseStructures';",str _side]; + +["Destroyed",_type,_side] Spawn SideMessage; + +//--- Can be fixed with workers. +if (paramUseWorkers) then { + Private ["_nearLogic","_position","_sold"]; + + _sold = _structure getVariable "sold"; + + if (isNil '_sold') then { + //--- Grab the logic. + _position = getPos _structure; + _nearLogic = _position nearEntities [["LocationLogicStart"],15]; + if (count _nearLogic > 0) then {_nearLogic = ([_position, _nearLogic] Call SortByDistance) select 0} else {_nearLogic = objNull}; + + if (isNull _nearLogic) exitWith {}; + + //--- Completed at 25% on destruction, dropping until it reach 0 (delete). + _nearLogic setVariable ["WFBE_B_Completion", 25]; + //--- The ratio gets lower after each destruction. + _nearLogic setVariable ["WFBE_B_CompletionRatio", (_nearLogic getVariable "WFBE_B_CompletionRatio")*0.8]; + //--- Can be repaired. + _nearLogic setVariable ["WFBE_B_Repair", true]; + + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) + [_nearLogic],true] Call SetNamespace; + + [_nearLogic, typeOf _structure, _side, _find - 1] Spawn HandleBuildingRepair; + }; +}; + +sleep 10; + +deleteVehicle _structure; diff --git a/Server/Functions/Server_BuyUnit.sqf b/Server/Functions/Server_BuyUnit.sqf new file mode 100644 index 0000000..e028685 --- /dev/null +++ b/Server/Functions/Server_BuyUnit.sqf @@ -0,0 +1,163 @@ +Private ["_building","_built","_config","_crew","_direction","_dir","_distance","_factoryType","_factoryPosition","_gbq","_id","_index","_isVehicle","_longest","_position","_queu","_queu2","_ret","_side","_sideText","_soldier","_team","_turrets","_type","_unitType","_vehicle","_waitTime"]; +_id = _this select 0; +_building = _this select 1; +_unitType = _this select 2; +_side = _this select 3; +_team = _this select 4; +_isVehicle = _this select 5; + +_sideText = str _side; + +if (!(alive _building)||(isPlayer (leader _team))) exitWith { + _gbq = (_team getVariable "queue") - _id; + _team setVariable ["queue",_gbq]; + if !(alive _building) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime]}; + if (isPlayer (leader _team)) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuyUnit: Canceled unit '%1', Player %2 has replaced the AI Team leader.",_unitType, name (leader _team),diag_frameno,diag_tickTime]}; +}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_BuyUnit: %1 Team '%2' has purchased a %3",_side,_team,_unitType,diag_frameno,diag_tickTime]; + +_queu = _building getVariable "queu"; +if (isNil "_queu") then {_queu = []}; +_queu = _queu + [_id select 0]; +_building setVariable ["queu",_queu,true]; + +_type = typeOf _building; +_index = (Format ["WFBE_%1STRUCTURENAMES",_sideText] Call GetNamespace) find _type; +_distance = (Format ["WFBE_%1STRUCTUREDISTANCES",_sideText] Call GetNamespace) select _index; +_direction = (Format ["WFBE_%1STRUCTUREDIRECTIONS",_sideText] Call GetNamespace) select _index; +_factoryType = (Format ["WFBE_%1STRUCTURES",_sideText] Call GetNamespace) select _index; +_waitTime = (_unitType Call GetNamespace) select QUERYUNITTIME; +_position = [getPos _building,_distance,getDir _building + _direction] Call GetPositionFrom; +_longest = Format ["WFBE_LONGEST%1BUILDTIME",_factoryType] Call GetNamespace; + +_ret = 0; +_queu2 = [0]; + +if (count _queu > 0) then { + _queu2 = _building getVariable "queu"; +}; + +while {_id select 0 != _queu select 0} do { + sleep 4; + _ret = _ret + 4; + _queu = _building getVariable "queu"; + + if (!(alive _building)||(isNull _building)||(isPlayer (leader _team))) exitWith { + _gbq = (_team getVariable "queue") - _id; + _team setVariable ["queue",_gbq]; + _queu = _building getVariable "queu"; + _queu = _queu - [_queu select 0]; + _building setVariable ["queu",_queu,true]; + if !(alive _building) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime]}; + if (isPlayer (leader _team)) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuyUnit: Canceled unit '%1', Player %2 has replaced the AI Team leader.",_unitType, name (leader _team),diag_frameno,diag_tickTime]}; + }; + + if (_queu select 0 == _queu2 select 0) then { + if (_ret > _longest) then { + if (count _queu > 0) then { + _queu = _building getVariable "queu"; + _queu = _queu - [_queu select 0]; + _building setVariable ["queu",_queu,true]; + }; + }; + }; + if (count _queu != count _queu2) then { + _ret = 0; + _queu2 = _building getVariable "queu"; + }; +}; + +sleep _waitTime; + +_queu = _building getVariable "queu"; +_queu = _queu - [_id select 0]; +_building setVariable ["queu",_queu,true]; + +if (!(alive _building)||(isPlayer (leader _team))) exitWith { + _gbq = (_team getVariable "queue") - _id; + _team setVariable ["queue",_gbq]; + if !(alive _building) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_BuyUnit: Canceled unit '%1', the factory is destroyed.",_unitType,diag_frameno,diag_tickTime]}; + if (isPlayer (leader _team)) then {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_BuyUnit: Canceled unit '%1', Player %2 has replaced the AI Team leader.",_unitType, name (leader _team),diag_frameno,diag_tickTime]}; +}; + +if (_unitType isKindOf "Man") then { + _soldier = [_unitType,_team,_position,_side] Call CreateMan; + [_sideText,'UnitsCreated',1] Call UpdateStatistics; +} else { + _crew = Format ["WFBE_%1SOLDIER",_sideText] Call GetNamespace; + if (_unitType isKindOf "Tank") then {_crew = Format ["WFBE_%1CREW",_sideText] Call GetNamespace}; + if (_unitType isKindOf "Air") then {_crew = Format ["WFBE_%1PILOT",_sideText] Call GetNamespace}; + _vehicle = [_unitType,_position,_side,true] Call CreateVehi; + _factoryPosition = getPos _building; + _dir = -((((_position select 1) - (_factoryPosition select 1)) atan2 ((_position select 0) - (_factoryPosition select 0))) - 90); + _vehicle setDir _dir; + _vehicle setVelocity [0,0,-1]; + //--- AI Can fly. + if (_vehicle isKindOf "Air") then { + _vehicle flyInHeight 120; + if (_vehicle isKindOf "Plane") then { + _vehicle setPos [_position select 0,_position select 1,1500]; + _vehicle setVelocity [sin _dir * 250,cos _dir * 250,0]; + }; + }; + + emptyQueu = emptyQueu + [_vehicle]; + _vehicle Spawn HandleEmptyVehicle; + if (_vehicle distance (leader _team) < 200) then {(units _team) allowGetIn true;_team addVehicle _vehicle}; + + /* Clear the vehicle */ + clearWeaponCargo _vehicle; + clearMagazineCargo _vehicle; + + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + [_soldier] orderGetIn true; + if (_unitType in ('WFBE_BALANCEDUNITS' Call GetNamespace) && paramBalancing) then {[_vehicle] Spawn BalanceInit}; + _soldier assignAsDriver _vehicle; + _soldier moveInDriver _vehicle; + [_sideText,'VehiclesCreated',1] Call UpdateStatistics; + _built = 1; + if (_isVehicle select 1) then { + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + [_soldier] orderGetIn true; + _soldier assignAsGunner _vehicle; + _soldier moveInGunner _vehicle; + _built = _built + 1; + }; + if (_isVehicle select 2) then { + if (vehicle leader _team == leader _team && leader _team distance _vehicle < 200 && alive leader _team) then { + [leader _team] allowGetIn true; + [leader _team] orderGetIn true; + (leader _team) assignAsCommander _vehicle; + (leader _team) moveInCommander _vehicle; + } else { + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + [_soldier] orderGetIn true; + _soldier assignAsCommander _vehicle; + _soldier moveInCommander _vehicle; + }; + _built = _built + 1; + }; + + if (_isVehicle select 3) then { + Private ["_get","_turrets"]; + _get = _unitType Call GetNamespace; + _turrets = _get select QUERYUNITTURRETS; + + { + if (isNull (_vehicle turretUnit _x)) then { + _soldier = [_crew,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + _soldier moveInTurret [_vehicle, _x]; + _built = _built + 1; + }; + } forEach _turrets; + }; + [_sideText,'UnitsCreated',_built] Call UpdateStatistics; +}; + +_gbq = (_team getVariable "queue") - _id; +_team setVariable ["queue",_gbq]; \ No newline at end of file diff --git a/Server/Functions/Server_CanUpdateTeam.sqf b/Server/Functions/Server_CanUpdateTeam.sqf new file mode 100644 index 0000000..e4863b7 --- /dev/null +++ b/Server/Functions/Server_CanUpdateTeam.sqf @@ -0,0 +1,19 @@ +/* + Author: Benny + Name: Server_CanUpdateTeam.sqf + Parameters: + 0 - Group + Description: + This function detect whether a human commander is in command or not and if a team is in the 'main' teams. +*/ + +Private ['_canUpdate','_commander','_team']; +_team = _this; + +_canUpdate = true; +if (((leader _team) Call GetClientID) != 0) then { + _commander = (side _team) Call GetCommanderTeam; + if !(isNull _commander) then {_canUpdate = false}; +}; + +_canUpdate \ No newline at end of file diff --git a/Server/Functions/Server_ChangeAICommanderFunds.sqf b/Server/Functions/Server_ChangeAICommanderFunds.sqf new file mode 100644 index 0000000..447fd09 --- /dev/null +++ b/Server/Functions/Server_ChangeAICommanderFunds.sqf @@ -0,0 +1,7 @@ +Private ["_amount","_funds","_side"]; +_side = _this select 0; +_amount = _this select 1; + +_funds = (_side) Call GetAICommanderFunds; + +[Format ["WFBE_%1_AICommanderFunds",_side], _funds + _amount, true] Call SetNamespace; \ No newline at end of file diff --git a/Server/Functions/Server_CreateDefenseTemplate.sqf b/Server/Functions/Server_CreateDefenseTemplate.sqf new file mode 100644 index 0000000..ae00769 --- /dev/null +++ b/Server/Functions/Server_CreateDefenseTemplate.sqf @@ -0,0 +1,36 @@ +Private ["_created","_current","_dir","_i","_object","_origin","_relDir","_relPos","_skip","_template","_toplace","_toWorld"]; +_origin = _this select 0; +_template = _this select 1; +_existingTemplate = if (count _this > 2) then {_this select 2} else {[]}; + +_dir = getDir _origin; +_created = []; +_toplace = objNull; + +for '_i' from 0 to count(_template)-1 do { + _current = _template select _i; + _object = _current select 0; + _relPos = _current select 1; + _relDir = _current select 2; + + _skip = false; + if (_i < count(_existingTemplate)) then { + if (alive(_existingTemplate select _i)) then {_skip = true}; + }; + + if !(_skip) then { + _toplace = _object createVehicle [0,0,0]; + + _toWorld = _origin modelToWorld _relPos; + _toWorld set [2,0]; + + _toplace setDir (_dir - _relDir); + _toplace setPos _toWorld; + } else { + _toplace = _existingTemplate select _i; + }; + + _created = _created + [_toplace]; +}; + +_created \ No newline at end of file diff --git a/Server/Functions/Server_CreateTeam.sqf b/Server/Functions/Server_CreateTeam.sqf new file mode 100644 index 0000000..83f9151 --- /dev/null +++ b/Server/Functions/Server_CreateTeam.sqf @@ -0,0 +1,47 @@ +Private ['_canCreate','_commander','_crews','_ctype','_driver','_firstDone','_gunner','_list','_lockVehicles','_position','_probability','_side','_team','_type','_unit','_units','_vehicle','_vehicles']; + +_list = _this select 0; +_position = _this select 1; +_side = _this select 2; +_lockVehicles = _this select 3; +_team = _this select 4; +_probability = if (count _this > 5) then {_this select 5} else {-1}; +_units = []; +_vehicles = []; +_crews = []; +_firstDone = false; + +//--- Create a group if none are given as a parameter. +if (isNull _team) then {_team = createGroup _side}; + +_ctype = switch (_side) do {case West: {'WEST'}; case East: {'EAST'}; case Resistance: {'GUER'}; case Civilian: {'CIV'}}; + +//--- Create. +{ + _canCreate = true; + if (_probability != -1) then { + if (random 100 > _probability && _firstDone) then {_canCreate = false}; + _firstDone = true; + }; + + if (_canCreate) then { + if (_x isKindOf 'Man') then { + _unit = [_x,_team,_position,_side] Call CreateMan; + _units = _units + [_unit]; + } else { + _vehicle = [_x,_position,_side,_lockVehicles] Call CreateVehi; + _type = if (_vehicle isKindOf 'Man') then {Format ['WFBE_%1SOLDIER',_ctype] Call GetNamespace} else {if (_vehicle isKindOf 'Air') then {Format ['WFBE_%1PILOT',_ctype] Call GetNamespace} else {Format ['WFBE_%1CREW',_ctype] Call GetNamespace}}; + if (_vehicle emptyPositions 'driver' > 0) then {_driver = [_type,_team,_position,_side] Call CreateMan;_driver moveInDriver _vehicle;_crews = _crews + [_driver]}; + if (_vehicle emptyPositions 'gunner' > 0) then {_gunner = [_type,_team,_position,_side] Call CreateMan;_gunner moveInGunner _vehicle;_crews = _crews + [_gunner]}; + if (_vehicle emptyPositions 'commander' > 0) then {_commander = [_type,_team,_position,_side] Call CreateMan;_commander moveInCommander _vehicle;_crews = _crews + [_commander]}; + _vehicles = _vehicles + [_vehicle]; + }; + }; +} forEach _list; + +//--- Add vehicles. +{ + _team addVehicle _x; +} forEach _vehicles; + +[_units,_vehicles,_team,_crews] \ No newline at end of file diff --git a/Server/Functions/Server_GetAICommanderFunds.sqf b/Server/Functions/Server_GetAICommanderFunds.sqf new file mode 100644 index 0000000..841814d --- /dev/null +++ b/Server/Functions/Server_GetAICommanderFunds.sqf @@ -0,0 +1 @@ +Format ["WFBE_%1_AICommanderFunds",_this] Call GetNamespace \ No newline at end of file diff --git a/Server/Functions/Server_HQKilled.sqf b/Server/Functions/Server_HQKilled.sqf new file mode 100644 index 0000000..b24be73 --- /dev/null +++ b/Server/Functions/Server_HQKilled.sqf @@ -0,0 +1,46 @@ +Private ["_deployed","_dir","_hq","_HQName","_killer","_kname","_kuid","_MHQ","_pos","_side","_tked","_type","_uid"]; +_hq = _this select 0; +_killer = _this select 1; +_side = _this select 2; +_type = _this select 3; + +_pos = getPos _hq; +_dir = getDir _hq; +_kuid = if (isPlayer _killer) then {getPlayerUID _killer} else {'0'}; +_kname = name _killer; + +_deployed = (str _side) Call GetSideHQDeployed; + +diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_HQKilled: The %1 MHQ has been destroyed",str _side,diag_frameno,diag_tickTime]; + +//--- Building Teamkill. +if ((side _killer == _side)&&(isPlayer(_killer))) then { + _uid = if !(paramShowUID) then {_uid = 'xxxxxxx'} else {_kuid}; + _tked = [_type, 'displayName'] Call GetConfigInfo; + WFBE_LocalizeMessage = [_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]]; + publicVariable 'WFBE_LocalizeMessage'; + if (isHostedServer) then {[_side,'CLTFNCLOCALIZEMESSAGE',['BuildingTeamkill',name _killer,_uid,_tked]] Spawn HandlePVF}; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_HQKilled: Player %1 (%2) has teamkilled the MHQ.",name _killer,_uid,diag_frameno,diag_tickTime]; +}; + +sleep random(2); +if (_deployed) then { + _HQName = Format["WFBE_%1MHQNAME",_side] Call GetNamespace; + _MHQ = _HQName createVehicle _pos; + _MHQ setDir _dir; + _MHQ setDammage 1; + + Call Compile Format ["%1MHQ = _MHQ; %1MHQDeployed = false; publicVariable '%1MHQ'; publicVariable '%1MHQDeployed';",str _side]; +}; + +if (mysql) then { + if ((side _killer != _side)&&(isPlayer(_killer))) then { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_Update?%1?%2?killedhq?%3",getPlayerUID _killer,name _killer,worldName]]]; + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_InsertOrUpdate_PKAI?%1?%2?%3?%4?%5?%6",_type,_kuid,_kname,"killed",4,worldName]]]; + }; +}; + +if (_type == WESTHQ) then {_type = 'WFBE_WESTMHQNAME' Call GetNamespace}; +if (_type == EASTHQ) then {_type = 'WFBE_EASTMHQNAME' Call GetNamespace}; +['Destroyed',_type,_side] Spawn SideMessage; diff --git a/Server/Functions/Server_HandleBuildingDamage.sqf b/Server/Functions/Server_HandleBuildingDamage.sqf new file mode 100644 index 0000000..31da5c2 --- /dev/null +++ b/Server/Functions/Server_HandleBuildingDamage.sqf @@ -0,0 +1,3 @@ +Private ["_difference"]; +_difference = ((_this select 1) - (getDammage (_this select 0)))/('WFBE_BUILDINGDAMAGEREDUCTION' Call GetNamespace); +((getDammage (_this select 0))+_difference) \ No newline at end of file diff --git a/Server/Functions/Server_HandleBuildingRepair.sqf b/Server/Functions/Server_HandleBuildingRepair.sqf new file mode 100644 index 0000000..04e082c --- /dev/null +++ b/Server/Functions/Server_HandleBuildingRepair.sqf @@ -0,0 +1,104 @@ +Private ["_bindex","_degradation","_direction","_etat","_group","_lastCompletionCheck","_logic","_position","_ruins","_ruinsType","_side","_type"]; + +_logic = _this select 0; +_type = _this select 1; +_side = _this select 2; +_bindex = _this select 3; + +_lastCompletionCheck = 0; +_degradation = 'WFBE_WORKERS_DEGRADATION' Call GetNamespace; + +_ruinsType = "WFBE_WORKERS_RUINS" Call GetNamespace; +_position = _logic getVariable "WFBE_B_Position"; +_direction = _logic getVariable "WFBE_B_Direction"; + +//--- Create ruins wherever the building get destroyed. +_ruins = _ruinsType createVehicle _position; +_ruins setDir _direction; +_ruins setPos _position; + +while {true} do { + _etat = _logic getVariable 'WFBE_B_Completion'; + + //--- Completed. + if (_etat >= 100) exitWith { + Private ["_buildingsCosts","_buildingsNames","_buildingsType","_current","_index","_limit","_site"]; + _buildingsType = Format["WFBE_%1STRUCTURES",str _side] Call GetNamespace; + _buildingsType = _buildingsType - [_buildingsType select 0]; + _buildingsNames = Format["WFBE_%1STRUCTURENAMES",str _side] Call GetNamespace; + _buildingsNames = _buildingsNames - [_buildingsNames select 0]; + _buildingsCosts = Format["WFBE_%1STRUCTURECOSTS",str _side] Call GetNamespace; + + //--- Place if limits allows us to do so. + _index = _buildingsNames find _type; + + if (_index != -1) then { + _current = Call Compile Format ['%1BuildingsCurrent',str _side]; + _limit = (Format['WFBE_BUILDINGMAX%1',(_buildingsType select _index)]) Call GetNamespace; + if (isNil '_limit') then {_limit = 4}; //--- Default. + + //--- We can build, the limist hasn't been reached yet. + if ((_current select _index) < _limit) then { + _site = _type createVehicle _position; + _site setDir _direction; + _site setPos _position; + + ["Constructed",_type,_side] Spawn SideMessage; + + //--- Site is created, we add the rest. + if !(isNull _site) then { + _current set [_bindex, (_current select _bindex) + 1]; + Call Compile Format ['%1BuildingsCurrent = _current',_side]; + publicVariable Format ['%1BuildingsCurrent',_side]; + + Call Compile Format ["%1BaseStructures = %1BaseStructures + [_site]; publicVariable '%1BaseStructures';",str _side]; + + _site setVehicleInit Format["[this,false,%1] ExecVM 'Client\Init\Init_BaseStructure.sqf'",_side]; + processInitCommands; + + _site addEventHandler ["hit",{_this Spawn BuildingDamaged}]; + if (paramHandleFF) then { + Call Compile Format ["_site addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, %1] Call BuildingHandleDamages}]",_side]; + } else { + _site addEventHandler ['handleDamage',{getDammage (_this select 0)+((_this select 2)/('WFBE_BUILDINGDAMAGEREDUCTION' Call GetNamespace))}]; + }; + Call Compile Format ["_site AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn BuildingKilled}];",_side,_type]; + + if !(paramMoneyOnly) then { + [_side, -round((_buildingsCosts select _index)/2)] Call ChangeSideSupply; + }; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_HandleBuildingRepair: A %1 %2 has been repaired",str _side,_type,diag_frameno,diag_tickTime]; + }; + + _logic setVariable ["WFBE_B_Repair",false]; + }; + }; + + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_logic],true] Call SetNamespace; + }; + + sleep 5; + + //--- Has the etat changed? + if ((_logic getVariable 'WFBE_B_Completion') == _etat) then {_lastCompletionCheck = _lastCompletionCheck + 5} else {_lastCompletionCheck = 0}; + + //--- Degradation if nothing happened. + if (_lastCompletionCheck > 30) then { + _etat = (_logic getVariable "WFBE_B_Completion") - _degradation; + if (_etat < 0) then {_etat = 0}; + _logic setVariable ["WFBE_B_Completion",_etat]; + _lastCompletionCheck = 0; + }; + + //--- If the etat reach 0, the building is lost. + if (_etat <= 0) exitWith { + [Format ["WFBE_WORKERS_%1LOGIC",str _side],((Format ["WFBE_WORKERS_%1LOGIC",str _side]) Call GetNamespace) - [_logic],true] Call SetNamespace; + + _group = group _logic; + deleteVehicle _logic; + deleteGroup _group; + }; +}; + +deleteVehicle _ruins; \ No newline at end of file diff --git a/Server/Functions/Server_HandleDefense.sqf b/Server/Functions/Server_HandleDefense.sqf new file mode 100644 index 0000000..8182271 --- /dev/null +++ b/Server/Functions/Server_HandleDefense.sqf @@ -0,0 +1,40 @@ +Private ["_buildings","_closest","_defense","_direction","_distance","_index","_position","_side","_soldier","_team","_type","_unit"]; +_defense = _this select 0; +_side = _this select 1; +_team = _this select 2; +_closest = _this select 3; + +while {alive _defense} do { + if (isNull(gunner _defense) || !alive gunner _defense) then { + + sleep 7; + + if (alive _closest && !(isNull _closest )) then { + _type = typeOf _closest; + _index = (Format["WFBE_%1STRUCTURENAMES",str _side] Call GetNamespace) find _type; + _distance = (Format["WFBE_%1STRUCTUREDISTANCES",str _side] Call GetNamespace) select _index; + _direction = (Format["WFBE_%1STRUCTUREDIRECTIONS",str _side] Call GetNamespace) select _index; + _position = [getPos _closest,_distance,getDir (_closest) + _direction] Call GetPositionFrom; + + _type = Format ["WFBE_%1SOLDIER",str _side] Call GetNamespace; + _soldier = [_type,_team,_position,_side] Call CreateMan; + [_soldier] allowGetIn true; + _soldier assignAsGunner _defense; + [_soldier] orderGetIn true; + + [str _side,'UnitsCreated',1] Call UpdateStatistics; + + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_HandleDefense: A Soldier has been dispatched to the %1 defense %2",str _side,_type,diag_frameno,diag_tickTime]; + + //--- Calculate the average time in function of the distance and the speed. + sleep ((((_soldier distance _defense)/(14*1000))*3600)+20); + + if ((vehicle _soldier != _defense)&& alive _soldier &&(!isNull _soldier)) then { + if ((_defense EmptyPositions "gunner" > 0) && alive _defense && (!isNull _defense)) then {_soldier MoveInGunner _defense} else {deleteVehicle _soldier}; + }; + } else { + diag_log Format["[WFBE (INFORMATION)][frameno:%1 | ticktime:%2] Server_HandleDefense.sqf: Canceled auto manning, the barracks is destroyed.",diag_frameno,diag_tickTime]; + }; + }; + sleep 420; +}; \ No newline at end of file diff --git a/Server/Functions/Server_HandleEmptyVehicle.sqf b/Server/Functions/Server_HandleEmptyVehicle.sqf new file mode 100644 index 0000000..29307a8 --- /dev/null +++ b/Server/Functions/Server_HandleEmptyVehicle.sqf @@ -0,0 +1,36 @@ +Private ['_abtimer','_exit','_skip','_timer','_trash','_vehicle']; + +_vehicle = _this; + +_exit = false; +_timer = 0; +_abtimer = ('WFBE_ABANDONVEHICLETIMER' Call GetNamespace); + +while {!_exit} do { + sleep 20; + _skip = false; + if (!(alive _vehicle) && !(isNull _vehicle)) then { + _skip = true; + _exit = true; + if !(_vehicle in trashQueu) then { + trashQueu = trashQueu + [_vehicle]; + _vehicle Spawn TrashObject; + }; + }; + if (!(isNull _vehicle) && !_skip) then { + if (({alive _x} count (crew _vehicle)) > 0) then {_timer = 0}; + if (_timer > _abtimer) then { + _exit = true; + if (someAmmo _vehicle) then {_vehicle setVehicleAmmo 0}; + _vehicle setDammage 1; + sleep 2; + if !(_vehicle in trashQueu) then { + trashQueu = trashQueu + [_vehicle]; + (_vehicle) Spawn TrashObject; + }; + }; + _timer = _timer + 20; + } else {_exit = true}; +}; + +emptyQueu = emptyQueu - [_vehicle]; \ No newline at end of file diff --git a/Server/Functions/Server_HandleReloadDefense.sqf b/Server/Functions/Server_HandleReloadDefense.sqf new file mode 100644 index 0000000..61eeee2 --- /dev/null +++ b/Server/Functions/Server_HandleReloadDefense.sqf @@ -0,0 +1,71 @@ +private ["_defense", "_side", "_sideID", "_turret", "_closestTown", "_reload", "_buildings", "_mhq", "_magazine"]; + +_defense = _this select 0; +_side = _this select 1; +_sideID = _side Call GetSideID; + +if(!isArray(configFile >> "CfgVehicles" >> (typeOf _defense) >> "Turrets" >> "MainTurret" >> "weapons")) exitWith { }; + +_turret = getArray(configFile >> "CfgVehicles" >> (typeOf _defense) >> "Turrets" >> "MainTurret" >> "weapons") select 0; +_closestTown = [_defense] Call GetClosestLocation; + +if(isNull _closestTown || _closestTown distance _defense > 400) then +{ + _closestTown = ObjNull; +}; + +// 0: no auto reloading +if(paramDefenseReloading == 0) exitWith { }; + +while { alive _defense } do +{ + sleep 10; + if((_defense ammo _turret) == 0) then + { + _reload = false; + + // 3: Reload everywhere + if(paramDefenseReloading == 3) then + { + _reload = true; + }; + + // 2: Reload near towns or base/HQ + if(!_reload && paramDefenseReloading == 2) then + { + _reload = false; + if(!isNull _closestTown && (_closestTown getVariable "sideID") == _sideID) then + { + _reload = true; + }; + }; + + // 1: Reload near base/HQ + if(!_reload && (paramDefenseReloading == 1 || paramDefenseReloading == 2)) then + { + _buildings = (str _side) Call GetSideStructures; + _mhq = call compile format ["%1MHQ", str _side]; + + if(!isNil "_mhq") then + { + _buildings = _buildings + [ _mhq ]; + }; + + { + if(_defense distance _x < 200) exitWith + { + _reload = true; + } + } forEach(_buildings); + }; + + if(_reload) then + { + _magazine = (_defense magazinesTurret [0]) select 0; + if(!isNil "_magazine") then + { + ["ACE_sys_crewserved_remadd", [_defense, _magazine, 1]] call CBA_fnc_globalEvent; + }; + }; + }; +}; \ No newline at end of file diff --git a/Server/Functions/Server_HandleSPVF.sqf b/Server/Functions/Server_HandleSPVF.sqf new file mode 100644 index 0000000..3b955bf --- /dev/null +++ b/Server/Functions/Server_HandleSPVF.sqf @@ -0,0 +1,16 @@ +/* + description: + - New network system handler. + note: + - addPublicVariableEventHandler is triggered everywhere BUT on the caller. + usage: + - [server PVF to run, parameters] +*/ + +Private ["_parameters","_publicVar","_script"]; +_publicVar = _this; + +_script = _publicVar select 0; +_parameters = if (count _publicVar > 1) then {_publicVar select 1} else {[]}; + +_parameters Spawn (Call Compile _script); \ No newline at end of file diff --git a/Server/Functions/Server_HandleSpecial.sqf b/Server/Functions/Server_HandleSpecial.sqf new file mode 100644 index 0000000..fc3fec8 --- /dev/null +++ b/Server/Functions/Server_HandleSpecial.sqf @@ -0,0 +1,48 @@ +Private['_args','_base','_dropPosX','_dropPosY','_dropPosZ','_droppos1','_droppos2','_playerTeam','_side','_st','_target']; + +_args = _this; +_side = _args select 1; + +switch (_args select 0) do { + case "Paratroops": { + _args spawn KAT_Paratroopers; + }; + + case "ParaVehi": { + _args spawn KAT_ParaVehicles; + }; + + case "ParaAmmo": { + _args spawn KAT_ParaAmmo; + }; + + case "RespawnST": { + _st = Format ["WFBE_%1_AISupplyTrucks",Str _side] Call GetNamespace; + {if (!isNull (driver _x)) then {driver _x setDammage 1};_x setDammage 1} forEach _st; + diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_HandleSpecial: The %1 supply trucks have been respawned.",str _side,diag_frameno,diag_tickTime]; + }; + + case "uav": { + _args spawn KAT_UAV; + }; + + case "upgrade": {["NewIntelAvailable","",_side,""] Spawn SideMessage}; + + case "ICBM": { + _base = (_args select 2); + _target = (_args select 3); + _playerTeam = (_args select 4); + diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_HandleSpecial: The %1 %2 Team (Leader: %3) has called an ICBM Nuke.",str _side,_playerTeam,name (leader _playerTeam),diag_frameno,diag_tickTime]; + if (isNull _target || !alive _target) exitWith {}; + _dropPosX = getPos _base select 0; + _dropPosY = getPos _base select 1; + _dropPosZ = getPos _base select 2; + _droppos1 = [_dropPosX + 4, _dropPosY + 4, _dropPosZ]; + _droppos2 = [_dropPosX + 8, _dropPosY + 8, _dropPosZ]; + waitUntil {!alive _target || isNull _target}; + det1 = "BO_GBU12_LGB" createVehicle [(getpos _target select 0),(getpos _target select 1), 0]; + det2 = createVehicle ["BO_GBU12_LGB",_droppos1,[], 0, "None"]; + det3 = createVehicle ["BO_GBU12_LGB",_droppos2,[], 0, "None"]; + [_base] Spawn NukeDammage; + }; +}; \ No newline at end of file diff --git a/Server/Functions/Server_MHQRepair.sqf b/Server/Functions/Server_MHQRepair.sqf new file mode 100644 index 0000000..ae8b533 --- /dev/null +++ b/Server/Functions/Server_MHQRepair.sqf @@ -0,0 +1,38 @@ +Private ["_commanderTeam","_direction","_hq","_HQName","_MHQ","_position","_side","_sideText","_text"]; +_side = _this select 0; +_sideText = str _side; + +_hq = (_sideText) Call GetSideHQ; +_position = getPos _hq; +_direction = getDir _hq; + +_commanderTeam = (_side) Call GetCommanderTeam; +if !(isNull _commanderTeam) then { + WFBE_SetHQStatus = [vehicleVarName (leader _commanderTeam),'CLTFNCSETHQSTATUS',false]; + publicVariable 'WFBE_SetHQStatus'; + if (isHostedServer) then {[vehicleVarName (leader _commanderTeam),'CLTFNCSETHQSTATUS',false] Spawn HandlePVF}; +}; + +sleep 15; + +_HQName = Format["WFBE_%1MHQNAME",_sideText] Call GetNamespace; +_MHQ = _HQName createVehicle _position; + +Call Compile Format ["%1MHQ = _MHQ; publicVariable '%1MHQ';",_sideText]; + +_MHQ setDir _direction; +_MHQ setVelocity [0,0,-1]; + +Call Compile Format ["_MHQ AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",_side,typeOf _MHQ]; + +_text = ""; +if (('WFBE_INCOMINGMISSILEMAXRANGE' Call GetNamespace) != 0) then {_text = "this addEventHandler ['IncomingMissile', {_this Spawn HandleIncomingMissile}];"}; +_MHQ setVehicleInit Format["['Headquarters','ColorGreen',[1,1],'','HQUndeployed',this,0.2,false,'','',false,%1] ExecVM 'Common\Common_MarkerUpdate.sqf';%2",_side,_text]; +processInitCommands; + +deleteVehicle _hq; + +Call Compile Format ["%1MHQDeployed = false; publicVariable '%1MHQDeployed';",_sideText]; +WF_Logic setVariable [Format ["%1MHQRepair",_sideText],false,true]; + +diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_MHQRepair: The %1 MHQ was repaired.",_sideText,diag_frameno,diag_tickTime]; \ No newline at end of file diff --git a/Server/Functions/Server_PlaceJoiningUnit.sqf b/Server/Functions/Server_PlaceJoiningUnit.sqf new file mode 100644 index 0000000..99deb63 --- /dev/null +++ b/Server/Functions/Server_PlaceJoiningUnit.sqf @@ -0,0 +1,18 @@ +Private ["_buildings","_hq","_placeAt","_side","_unit"]; + +_unit = _this select 0; +_side = _this select 1; + +waitUntil {!isNil Format["%1StartingLocation",str _side]}; + +_buildings = (str _side) Call GetSideStructures; +_hq = (str _side) Call GetSideHQ; + +_placeAt = objNull; +if (count _buildings > 0) then { + _placeAt = ([_hq, _buildings] Call SortByDistance) select 0; +} else { + _placeAt = _hq; +}; + +_unit setPos ([getPos _placeAt,20,30] Call GetRandomPosition); \ No newline at end of file diff --git a/Server/Functions/Server_SelectOccupTeam.sqf b/Server/Functions/Server_SelectOccupTeam.sqf new file mode 100644 index 0000000..a28bf3c --- /dev/null +++ b/Server/Functions/Server_SelectOccupTeam.sqf @@ -0,0 +1,41 @@ +private ["_difficulty","_probaOccupation","_oc1","_oc2","_oc3","_oc4","_oc5","_oc6","_ran1","_ran2","_supplyValue","_teams","_type","_x"]; +_supplyValue = _this select 0; +_type = []; +_teams = []; + +_oc1 = 'WFBE_OCCUPATIONTEAM1' Call GetNamespace; +_oc2 = 'WFBE_OCCUPATIONTEAM2' Call GetNamespace; +_oc3 = 'WFBE_OCCUPATIONTEAM3' Call GetNamespace; +_oc4 = 'WFBE_OCCUPATIONTEAM4' Call GetNamespace; +_oc5 = 'WFBE_OCCUPATIONTEAM5' Call GetNamespace; +_oc6 = 'WFBE_OCCUPATIONTEAM6' Call GetNamespace; + +_probaOccupation = 75; +if ((_supplyValue >= _oc1)&&(_supplyValue < _oc2)) then {_type = ["SmallTeam"];_probaOccupation = 95}; +if ((_supplyValue >= _oc2)&&(_supplyValue < _oc3)) then {_type = ["SmallTeam","SmallVehTeam"];_probaOccupation = 85}; +if ((_supplyValue >= _oc3)&&(_supplyValue < _oc4)) then {_type = ["SmallTeam","MediumTeam","MediumVehTeam"];_probaOccupation = 75}; +if ((_supplyValue >= _oc4)&&(_supplyValue < _oc5)) then {_type = ["SmallTeam","MediumTeam","LargeTeam","MediumVehTeam"];_probaOccupation = 65}; +if ((_supplyValue >= _oc5)&&(_supplyValue < _oc6)) then {_type = ["SmallTeam","MediumTeam","LargeTeam","MediumVehTeam","LargeVehTeam"];_probaOccupation = 60}; +if (_supplyValue >= _oc6) then {_type = ["SmallTeam","MediumTeam","LargeTeam","SmallVehTeam","MediumVehTeam","LargeVehTeam"];_probaOccupation = 55}; + +_difficulty = 'WFBE_TOWNOCCUPATIONDIFFICULTY' Call GetNamespace; +if (_difficulty == 5) then { + if (diag_fps >= 35) then {_difficulty = 4}; + if (diag_fps >= 25 && diag_fps < 30) then {_difficulty = 3}; + if (diag_fps >= 15 && diag_fps < 25) then {_difficulty = 2}; + if (diag_fps < 15) then {_difficulty = 1}; +} else { + _probaOccupation = _probaOccupation - (_difficulty * 5); + if (_probaOccupation < 10) then {_probaOccupation = 10}; +}; + +for [{_z = 0},{_z <= _difficulty},{_z = _z + 1}] do { + _ran1 = random 100; + if (_ran1 < _probaOccupation) then { + {_ran2 = round(1 + random 2);_teams = _teams + [Format ["%1%2",_x,_ran2]]} forEach _type; + }; +}; + +if (count _teams < 1) then {_teams = ["SmallTeam1"]}; + +_teams \ No newline at end of file diff --git a/Server/Functions/Server_SelectResTeam.sqf b/Server/Functions/Server_SelectResTeam.sqf new file mode 100644 index 0000000..63e1218 --- /dev/null +++ b/Server/Functions/Server_SelectResTeam.sqf @@ -0,0 +1,144 @@ +Private ['_difficulty','_factor','_infAssign','_minInfSpawnRatio','_minVehSpawnRatio','_poolInf','_poolVeh','_ratioInfantry','_ranArr','_ratioVehicle','_teams','_try','_vehAssign']; + +_difficulty = _this select 0; + +_ratioVehicle = 0; +_ratioInfantry = 0; + +_teams = []; +_poolInf = []; +_poolVeh = []; + +_vehAssign = 0; +_infAssign = 0; +_minInfSpawnRatio = 0; +_minVehSpawnRatio = 0; +_try = 0; + +switch (_difficulty) do { + case 'light1': { + _ratioVehicle = 10; + _ratioInfantry = 90; + _try = 3; + _minInfSpawnRatio = 15; + _minVehSpawnRatio = 35; + + _poolInf = ['Group','Patrol1','Patrol2','Militia']; + _poolVeh = ['MotorizedGroup']; + }; + case 'light2': { + _ratioVehicle = 20; + _ratioInfantry = 80; + _try = 4; + _minInfSpawnRatio = 20; + _minVehSpawnRatio = 40; + + _poolInf = ['Group','GroupWeapons','ATTeam','Patrol2','Militia']; + _poolVeh = ['Technical']; + }; + case 'medium1': { + _ratioVehicle = 20; + _ratioInfantry = 80; + _try = 5; + _minInfSpawnRatio = 18; + _minVehSpawnRatio = 35; + + _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','SniperTeam']; + _poolVeh = ['Technical']; + }; + case 'medium2': { + _ratioVehicle = 40; + _ratioInfantry = 60; + _try = 5; + _minInfSpawnRatio = 22; + _minVehSpawnRatio = 39; + + _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam']; + _poolVeh = ['MechanizedGroup','MechanizedPatrol','LightArmor','Technical','MotorizedGroup']; + }; + case 'medium3': { + _ratioVehicle = 30; + _ratioInfantry = 70; + _try = 5; + _minInfSpawnRatio = 26; + _minVehSpawnRatio = 32; + + _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault']; + _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','Technical','MotorizedGroup']; + }; + case 'medium4': { + _ratioVehicle = 35; + _ratioInfantry = 65; + _try = 5; + _minInfSpawnRatio = 28; + _minVehSpawnRatio = 32; + + _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam']; + _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','Technical','HeavyArmor']; + }; + case 'large1': { + _ratioVehicle = 30; + _ratioInfantry = 70; + _try = 5; + _minInfSpawnRatio = 25; + _minVehSpawnRatio = 35; + + _poolInf = ['GroupWeapons','ATTeam','GroupAssault','SniperTeam']; + _poolVeh = ['MechanizedGroup','MechanizedPatrol','LightArmor','LightArmor','HeavyArmor','Technical']; + }; + case 'large2': { + _ratioVehicle = 45; + _ratioInfantry = 55; + _try = 6; + _minInfSpawnRatio = 25; + _minVehSpawnRatio = 32; + + _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam','SniperTeam']; + _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','HeavyArmor','HeavyArmor','Technical']; + }; + case 'huge1': { + _ratioVehicle = 50; + _ratioInfantry = 50; + _try = 6; + _minInfSpawnRatio = 30; + _minVehSpawnRatio = 35; + + _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam','SniperTeam']; + _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','LightArmor','HeavyArmor','HeavyArmor','Technical']; + }; + case 'huge2': { + _ratioVehicle = 50; + _ratioInfantry = 50; + _try = 7; + _minInfSpawnRatio = 35; + _minVehSpawnRatio = 35; + + _poolInf = ['Group','GroupWeapons','ATTeam','GroupAssault','AATeam','SniperTeam']; + _poolVeh = ['MechanizedGroup','MechanizedPatrol','MotorizedAATeam','LightArmor','LightArmor','HeavyArmor','HeavyArmor','Technical']; + }; +}; + +_try = _try * ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace); +_vehAssign = round(_try * (_ratioVehicle / 100)); +_infAssign = round(_try * (_ratioInfantry / 100)); + +for [{_z = 0},{_z < _try},{_z = _z + 1}] do { + if (_vehAssign > 0) then { + _vehAssign = _vehAssign - 1; + if (random 100 > _minVehSpawnRatio) then { + _ranArr = round(random((count _poolVeh)-1)); + _teams = _teams + [_poolVeh select _ranArr]; + }; + }; + if (_infAssign > 0) then { + _infAssign = _infAssign - 1; + if (random 100 > _minInfSpawnRatio) then { + _ranArr = round(random((count _poolInf)-1)); + _teams = _teams + [_poolInf select _ranArr]; + }; + }; +}; + +if (count _teams < 1) then {_teams = ['Group']}; + +_teams \ No newline at end of file diff --git a/Server/Functions/Server_SetCampsToSide.sqf b/Server/Functions/Server_SetCampsToSide.sqf new file mode 100644 index 0000000..36df4d6 --- /dev/null +++ b/Server/Functions/Server_SetCampsToSide.sqf @@ -0,0 +1,30 @@ +Private["_camp","_camps","_count","_notifyAllSides","_objects","_previousSide","_side","_sideID","_startingSV","_texture","_town"]; + +_town = _this Select 0; +_side = _this Select 1; +_previousSide = _this Select 2; + +_sideID = _side Call GetSideID; +_camps = _town getVariable "camps"; +_startingSV = _town getVariable "supplyValue"; + +for [{_count = Count _camps - 1},{_count >= 0},{_count = _count - 1}] do { + _camp = _camps Select _count; + _camp setVariable ["sideID",_sideID,true]; + _camp setVariable ["supplyValue",_startingSV,true]; + + _texture = Format["WFBE_%1FLAG",str _side] Call GetNamespace; + + _objects = _camp nearEntities[[WFFLAG],20]; + if (count _objects > 0) then {(_objects Select 0) setFlagTexture _texture}; +}; + +sleep 0.5; + +_notifyAllSides = (_previousSide == East || _previousSide == West); + +WFBE_AllCampsCaptured = [nil,'CLTFNCALLCAMPSCAPTURED',[_town,_sideID,_notifyAllSides]]; +publicVariable 'WFBE_AllCampsCaptured'; +if (isHostedServer) then {[nil,'CLTFNCALLCAMPSCAPTURED',[_town,_sideID,_notifyAllSides]] Spawn HandlePVF}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_SetCampsToSide: '%1' Camps have been set to %2",_town,str _side,diag_frameno,diag_tickTime]; diff --git a/Server/Functions/Server_SideMessage.sqf b/Server/Functions/Server_SideMessage.sqf new file mode 100644 index 0000000..b2bdad0 --- /dev/null +++ b/Server/Functions/Server_SideMessage.sqf @@ -0,0 +1,94 @@ +Private ["_canSpeak","_extra","_localizedString","_locRaw","_receiver","_rlName","_side","_speaker","_special","_specialb","_topicSide","_value"]; +_special = _this select 0; +_specialb = _this select 1; +_side = _this select 2; +_extra = ""; +if (count _this > 3) then {_extra = _this select 3}; + +_speaker = BIS_WF_HQEAST; _receiver = BIS_WF_HQEAST2; _topicSide = BIS_WF_HQEAST_TI; +if (_side == west) then {_speaker = BIS_WF_HQWEST;_receiver = BIS_WF_HQWEST2; _topicSide = BIS_WF_HQWEST_TI}; + +//--- Radio: Base building / attacks / destruction. +if (_special in ["Destroyed","IsUnderAttack","Constructed"]) then { + _localizedString = localize "strwfbarracks"; + _value = "Barracks"; + switch (typeName _specialb) do { + case "OBJECT": { + _localizedString = _specialb getVariable "name"; + _value = _extra; + }; + case "STRING": { + if (_specialb == ('WFBE_WESTMHQNAME' Call GetNamespace) || _specialb == ('WFBE_EASTMHQNAME' Call GetNamespace)) then {_localizedString = localize "STRHeadquarters";_value = "Headquarters";if (_special == "Constructed") then {_special = "Mobilized"}}; + if (_specialb == WESTHQ || _specialb == EASTHQ) then {_localizedString = localize "STRHeadquarters";_value = "Headquarters";if (_special == "Constructed") then {_special = "Deployed"}}; + if (_specialb == WESTLVF || _specialb == EASTLVF) then {_localizedString = localize "STRLightVehicleSupply";_value = "LightVehicleSupply"}; + if (_specialb == WESTCC || _specialb == EASTCC) then { + _localizedString = localize "STR_WF_CommandCenter"; + _value = "UAVTerminal"; + if (WF_A2_Arrowhead || (WF_A2_CombinedOps && _side == west)) then {_value = "CommandPost"}; + }; + if (_specialb == WESTHEAVY || _specialb == EASTHEAVY) then {_localizedString = localize "STRHeavyVehicleSupply";_value = "HeavyVehicleSupply"}; + if (_specialb == WESTAIR || _specialb == EASTAIR) then {_localizedString = localize "STRHelipad";_value = "Helipad"}; + if (_specialb == WESTSP || _specialb == EASTSP) then {_localizedString = localize "STRServicePoint";_value = "ServicePoint"}; + if (_specialb == WESTAAR || _specialb == EASTAAR) then {_localizedString = localize "STRAntiAirRadar";_value = "AntiAirRadar"}; + }; + }; + _speaker kbTell [_receiver, _topicSide, _special,["1","",_localizedString,[_value]],true]; +}; + +//--- Radio: Town Capture/Loss. +if (_special in ["Lost","Captured","HostilesDetectedNear"]) then { + _locRaw = str _specialb; + _rlName = _specialb getVariable "name"; + _canSpeak = if (_side == east && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false}; + if !(_canSpeak) then {_canSpeak = if (_side == west && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}}; + if !(_canSpeak) then {_canSpeak = if (WF_A2_Vanilla && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false}}; + if !(_canSpeak) then {_canSpeak = if (WF_A2_Arrowhead && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}}; + + if !(_canSpeak) then {_locRaw = "Town"} else { + switch (_locRaw) do { + case "Vyshnoye": {_locRaw = "Vyshnoe"}; + case "Shahbaz": {_locRaw = "Town"}; + case "Qeslaq": {_locRaw = "Town"}; + }; + }; + _speaker kbTell [_receiver, _topicSide, _special,["1","",_rlName,[_locRaw]],true]; +}; + +//--- Radio: Voting for a new commander. +if (_special in ["VotingForNewCommander","NewIntelAvailable"]) then {_speaker kbTell [_receiver, _topicSide, _special,true]}; + +//--- Radio: Camp Capture/Loss. +if (_special in ["CapturedNear","LostAt"]) then { + _locRaw = str _extra; + _rlName = _extra getVariable "name"; + _canSpeak = if (_side == east && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false}; + if !(_canSpeak) then {_canSpeak = if (_side == west && WF_A2_CombinedOps && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}}; + if !(_canSpeak) then {_canSpeak = if (WF_A2_Vanilla && worldName in ('WFBE_WORLDWHITELISTVA' Call GetNamespace)) then {true} else {false}}; + if !(_canSpeak) then {_canSpeak = if (WF_A2_Arrowhead && worldName in ('WFBE_WORLDWHITELISTOA' Call GetNamespace)) then {true} else {false}}; + + if !(_canSpeak) then {_locRaw = "Town"} else { + switch (_locRaw) do { + case "Vyshnoye": {_locRaw = "Vyshnoe"}; + case "Shahbaz": {_locRaw = "Town"}; + case "Qeslaq": {_locRaw = "Town"}; + }; + }; + _speaker kbTell [_receiver, _topicSide, _special,["1","",_specialb,[_specialb]],["2","",_rlName,[_locRaw]],true]; +}; + +if (paramSecondaryMissions) then { + //--- Radio: Mission. + if (_special in ['MMissionFailed','NewMissionAvailable']) then { + _speaker kbTell [_receiver, _topicSide, _special,true]; + }; + + //--- Radio: Mission Complete. + if (_special == 'MMissionComplete') then { + _speaker kbTell [_receiver, _topicSide, _special,["1","",_specialb,[_extra]],true]; + }; + + //--- Radio: Extraction Team. + if (_special in ['ExtractionTeam','ExtractionTeamCancel']) then { + _speaker kbTell [_receiver, _topicSide, _special,["1","",_specialb,[_specialb]],true]; + }; +}; \ No newline at end of file diff --git a/Server/Functions/Server_TrashObject.sqf b/Server/Functions/Server_TrashObject.sqf new file mode 100644 index 0000000..bb983f1 --- /dev/null +++ b/Server/Functions/Server_TrashObject.sqf @@ -0,0 +1,34 @@ +/* + Author: Benny + Name: Server_TrashObject.sqf + Parameters: + 0 - Object + Description: + This function will remove an object after the defined amount of time. +*/ + +private ["_alive","_group","_isMan","_object","_get"]; +_object = _this; + +if !(isNull _object) then { + _group = []; + _isMan = if (_object isKindOf "Man") then {true} else {false}; + + if (_isMan) then {_group = group _object}; + + sleep ('WFBE_UNITREMOVEDLAY' Call GetNamespace); + trashQueu = trashQueu - [_object]; + + if (_isMan) then {hideBody _object; sleep 6}; + + deleteVehicle _object; + + if (_isMan) then { + if !(isNull _group) then { + _get = _group getVariable 'queue'; + if (isNil '_get') then { + if (count (units _group) <= 0) then {deleteGroup _group;}; + }; + }; + }; +}; \ No newline at end of file diff --git a/Server/Functions/Server_UpdateTeam.sqf b/Server/Functions/Server_UpdateTeam.sqf new file mode 100644 index 0000000..274c420 --- /dev/null +++ b/Server/Functions/Server_UpdateTeam.sqf @@ -0,0 +1,8 @@ +Private ['_formations','_team']; +_team = _this; + +_formations = ['FILE','DIAMOND','STAG COLUMN','WEDGE']; +_team setFormation (_formations select round(random(count _formations -1))); +_team setBehaviour "AWARE"; +_team setSpeedMode "NORMAL"; +_team setCombatMode "YELLOW"; \ No newline at end of file diff --git a/Server/Init/Init_Defenses.sqf b/Server/Init/Init_Defenses.sqf new file mode 100644 index 0000000..3b45b4e --- /dev/null +++ b/Server/Init/Init_Defenses.sqf @@ -0,0 +1,109 @@ +/* Structures */ +['WFBE_NEURODEF_BARRACKS_WALLS',[ + ['Land_HBarrier_large',[8,0,0],90], + ['Land_HBarrier_large',[8,10,0],90], + ['Land_HBarrier_large',[8,-7.5,0],90], + ['Land_HBarrier_large',[5,-11,0],180], + ['Land_HBarrier_large',[0.5,-11,0],180], + ['Land_HBarrier_large',[-6,-11,0],180], + ['Land_HBarrier_large',[-9.5,-7.5,0],90], + ['Land_HBarrier_large',[-9.5,2.5,0],90], + ['Land_HBarrier_large',[5,13,0],180], + ['Land_HBarrier_large',[0.5,13,0],180], + ['Land_HBarrier_large',[-6,13,0],180], + ['Land_HBarrier_large',[-9.5,9.5,0],90] +],true] Call SetNamespace; + +['WFBE_NEURODEF_LIGHT_WALLS',[ + ['Land_HBarrier_large',[10,-1,0],90], + ['Land_HBarrier_large',[10,9,0],-90], + ['Land_HBarrier_large',[10,-8.5,0],90], + ['Land_HBarrier_large',[7,-12,0],180], + ['Land_HBarrier_large',[0,-12,0],180], + ['Land_HBarrier_large',[-7,-12,0],180], + ['Land_HBarrier_large',[7,12,0],180], + ['Land_HBarrier_large',[0,12,0],180], + ['Land_HBarrier_large',[-7,12,0],180], + ['Land_HBarrier_large',[-11,-9,0],90], + ['Land_HBarrier_large',[-11,-1.5,0],90], + ['Land_HBarrier_large',[-11,6,0],90], + ['Land_HBarrier_large',[-11,9,0],90] +],true] Call SetNamespace; + +['WFBE_NEURODEF_COMMANDCENTER_WALLS',[ + ['Land_HBarrier_large',[4,-3.5,0],90], + ['Land_HBarrier_large',[4,4,0],90], + ['Land_HBarrier_large',[1,7.5,0],180], + ['Land_HBarrier_large',[-2.5,7.5,0],180], + ['Land_HBarrier_large',[-5.5,4,0],90], + ['Land_HBarrier_large',[-5.5,-3.5,0],90], + ['Land_HBarrier5',[4,-6.5,0],180] +],true] Call SetNamespace; + +['WFBE_NEURODEF_SERVICEPOINT_WALLS',[ + ['Land_HBarrier_large',[4,-3.5,0],90], + ['Land_HBarrier_large',[4,4,0],90], + ['Land_HBarrier_large',[1,7.5,0],180], + ['Land_HBarrier_large',[-2.5,7.5,0],180], + ['Land_HBarrier_large',[-5.5,4,0],90], + ['Land_HBarrier_large',[-5.5,-3.5,0],90], + ['Land_HBarrier5',[4,-6.5,0],180] +],true] Call SetNamespace; + +['WFBE_NEURODEF_HEAVY_WALLS',[ + ['Land_HBarrier_large',[14,-1,0],90], + ['Land_HBarrier_large',[14,9,0],-90], + ['Land_HBarrier_large',[14,-8.5,0],90], + ['Land_HBarrier_large',[14,-11,0],90], + ['Land_HBarrier_large',[11,-14.5,0],180], + ['Land_HBarrier_large',[4.5,-14.5,0],180], + ['Land_HBarrier_large',[-3,-14.5,0],180], + ['Land_HBarrier_large',[-10.5,-14.5,0],180], + ['Land_HBarrier_large',[-14,-11,0],90], + ['Land_HBarrier_large',[-14,-3.5,0],90], + ['Land_HBarrier_large',[-14,4,0],90], + ['Land_HBarrier_large',[-14,9.5,0],90], + ['Land_HBarrier_large',[11,13,0],180], + ['Land_HBarrier_large',[3.5,13,0],180], + ['Land_HBarrier_large',[-4,13,0],180], + ['Land_HBarrier_large',[-11,13,0],-180] +],true] Call SetNamespace; + +['WFBE_NEURODEF_AIRCRAFT_WALLS',[ + ['Land_HBarrier_large',[10,-1,0],90], + ['Land_HBarrier_large',[10,9,0],-90], + ['Land_HBarrier_large',[10,-8.5,0],90], + ['Land_HBarrier_large',[7,-12,0],180], + ['Land_HBarrier_large',[0,-12,0],180], + ['Land_HBarrier_large',[-7,-12,0],180], + ['Land_HBarrier_large',[7,12,0],180], + ['Land_HBarrier_large',[0,12,0],180], + ['Land_HBarrier_large',[-7,12,0],180], + ['Land_HBarrier_large',[-11,-9,0],90], + ['Land_HBarrier_large',[-11,-1.5,0],90], + ['Land_HBarrier_large',[-11,6,0],90], + ['Land_HBarrier_large',[-11,9,0],90] +],true] Call SetNamespace; + +['WFBE_NEURODEF_MG',[ + [if (WF_A2_Vanilla) then {'Land_fortified_nest_small'} else {'Land_fortified_nest_small_EP1'},[0.25,0,0],180], + ['Land_fort_bagfence_corner',[-1,-3,0],0] +],true] Call SetNamespace; + +['WFBE_NEURODEF_AAPOD',[ + ['Land_fort_bagfence_round',[0,2,0],0], + ['Land_fort_bagfence_long',[-2.8,-1.7,0],90], + ['Land_fort_bagfence_long',[2.8,-1.7,0],90], + ['Land_fort_bagfence_long',[1.4,-5.5,0],0], + ['Land_fort_bagfence_corner',[-1.8,-5,0],0] +],true] Call SetNamespace; + +['WFBE_NEURODEF_MASH',[ + ['Land_fort_bagfence_corner',[-3,3,0],270], + ['Land_fort_bagfence_long',[-3.5,-0.2,0],90], + ['Land_fort_bagfence_corner',[-2.5,-3.5,0],0], + ['Land_fort_bagfence_long',[0.5,-4,0],0], + ['Land_fort_bagfence_corner',[3.5,-3,0],90], + ['Land_fort_bagfence_long',[4,-0.2,0],90], + ['Land_fort_bagfence_corner',[3,3.5,0],180] +],true] Call SetNamespace; \ No newline at end of file diff --git a/Server/Init/Init_Server.sqf b/Server/Init/Init_Server.sqf new file mode 100644 index 0000000..7fa2a3d --- /dev/null +++ b/Server/Init/Init_Server.sqf @@ -0,0 +1,532 @@ +if (!isServer || time > 30) exitWith {diag_log Format["[WFBE (WARNING)][frameno:%1 | ticktime:%2] Init_Server: The server initialization cannot be called more than once.",diag_frameno,diag_tickTime]}; + +Private ['_BIS_WF_HQEASTgrp','_BIS_WF_HQEASTgrp2','_BIS_WF_HQWESTgrp','_BIS_WF_HQWESTgrp2','_WF_GroupLogic','_WF_GroupLogic2','_WF_GroupLogic3','_WF_GroupLogic4','_alice','_allies','_attempts','_eastLocation','_i','_locationLogics','_nearLogics','_oc','_ran','_ssd','_starterVehicle','_total','_type','_upArray','_vehicle','_weat','_westLocation']; + +diag_log Format["[WFBE (INIT)][frameno:%2 | ticktime:%3] Init_Server: Init Start at %1",time,diag_frameno,diag_tickTime]; + +//--- Allow resistance group to be spawned without a placeholder. +createCenter resistance; +resistance setFriend [west,0]; +resistance setFriend [east,0]; + +if (paramAI) then { + AIBuyUnit = Compile preprocessFile "Server\Functions\Server_BuyUnit.sqf"; + if (WF_A2_Vanilla) then {AISquadRespawn = Compile preprocessFile "Server\AI\AI_SquadRespawn.sqf"}; +}; +if !(WF_A2_Vanilla) then {AIAdvancedRespawn = Compile preprocessFile "Server\AI\AI_AdvancedRespawn.sqf"}; +AIMoveTo = Compile preprocessFile "Server\AI\Orders\AI_MoveTo.sqf"; +AIPatrol = Compile preprocessFile "Server\AI\Orders\AI_Patrol.sqf"; +AITownPatrol = Compile preprocessFile "Server\AI\Orders\AI_TownPatrol.sqf"; +AITownResitance = Compile preprocessFile "Server\AI\AI_Resistance.sqf"; +AIUpgrade = Compile preprocessFile "Server\AI\AI_Upgrade.sqf"; +AIWPAdd = Compile preprocessFile "Server\AI\Orders\AI_WPAdd.sqf"; +AIWPRemove = Compile preprocessFile "Server\AI\Orders\AI_WPRemove.sqf"; +BuildingDamaged = Compile preprocessFile "Server\Functions\Server_BuildingDamaged.sqf"; +if (paramHandleFF) then {BuildingHandleDamages = Compile preprocessFile "Server\Functions\Server_BuildingHandleDamages.sqf"}; +BuildingKilled = Compile preprocessFile "Server\Functions\Server_BuildingKilled.sqf"; +CanUpdateTeam = Compile preprocessFile "Server\Functions\Server_CanUpdateTeam.sqf"; +ChangeAICommanderFunds = Compile preprocessFile "Server\Functions\Server_ChangeAICommanderFunds.sqf"; +ConstructDefense = Compile preprocessFile "Server\Construction\Construction_StationaryDefense.sqf"; +CreateTeamTemplate = Compile preprocessFile "Server\Functions\Server_CreateTeam.sqf"; +CreateDefenseTemplate = Compile preprocessFile "Server\Functions\Server_CreateDefenseTemplate.sqf"; +if (paramUseWorkers) then {HandleBuildingRepair = Compile preprocessFile "Server\Functions\Server_HandleBuildingRepair.sqf"}; +GetAICommanderFunds = Compile preprocessFile "Server\Functions\Server_GetAICommanderFunds.sqf"; +HandleBuildingDamage = Compile preprocessFile "Server\Functions\Server_HandleBuildingDamage.sqf"; +HandleDefense = Compile preprocessFile "Server\Functions\Server_HandleDefense.sqf"; +HandleReloadDefense = Compile preprocessFile "Server\Functions\Server_HandleReloadDefense.sqf"; +HandleEmptyVehicle = Compile preprocessFile "Server\Functions\Server_HandleEmptyVehicle.sqf"; +HandleSPVF = Compile preprocessFile "Server\Functions\Server_HandleSPVF.sqf"; +HandleSpecial = Compile preprocessFile "Server\Functions\Server_HandleSpecial.sqf"; +HQKilled = Compile preprocessFile "Server\Functions\Server_HQKilled.sqf"; +MHQRepair = Compile preprocessFile "Server\Functions\Server_MHQRepair.sqf"; +SelectOccupTeam = Compile preprocessFile "Server\Functions\Server_SelectOccupTeam.sqf"; +SetCampsToSide = Compile preprocessFile "Server\Functions\Server_SetCampsToSide.sqf"; +SideMessage = Compile preprocessFile "Server\Functions\Server_SideMessage.sqf"; +SVoteForCommander = Compile preprocessFile "Server\Server_VoteForCommander.sqf"; +TrashObject = Compile preprocessFile "Server\Functions\Server_TrashObject.sqf"; +UpdateTeam = Compile preprocessFile "Server\Functions\Server_UpdateTeam.sqf"; +UpdateSupplyTruck = Compile preprocessFile "Server\AI\AI_UpdateSupplyTruck.sqf"; + +//--- Support Functions. +KAT_ParaAmmo = Compile preProcessfile "Server\Support\Support_ParaAmmo.sqf"; +KAT_Paratroopers = Compile preProcessfile "Server\Support\Support_Paratroopers.sqf"; +KAT_ParaVehicles = Compile preProcessfile "Server\Support\Support_ParaVehicles.sqf"; +KAT_UAV = Compile preProcessfile "Server\Support\Support_UAV.sqf"; + +//--- Call in NEURO System (Taxi Advanced Script). +[] Call Compile preprocessFile "Server\Module\NEURO\NEURO.sqf"; + +//--- NEURO: Special Condition. +missionNamespace setVariable["NEURO_TAXI_CONDITION", "isNil {_x getVariable 'WFBE_Taxi_Prohib'} && local _x"]; + +//--- Server Init is now complete. +serverInitComplete = true; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Functions - [Done]",diag_frameno,diag_tickTime]; + +//--- Run the MySQL Module if defined. +if (mysql) then { + WF_Logic setVariable ["WF_MYSQL_CLIENT",[],true]; + WF_Logic setVariable ["WF_MYSQL_SERVER",[Format ["MYSQLDATA?WFBE_Insert_Island?%1?%2",worldName,getText (configFile >> "CfgWorlds" >> worldName >> "description")]]]; + [] ExecFSM "Server\FSM\queryhandler.fsm"; + + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: MySQL Module - [Done]",diag_frameno,diag_tickTime]; +}; + +//--- JIP Handler, handle the joining and leaving players. +onPlayerConnected "[_uid,_name] ExecVM 'Server\Server_PlayerConnected.sqf'"; +onPlayerDisconnected "[_uid,_name] ExecVM 'Server\Server_PlayerDisconnected.sqf'"; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: JIP - [Done]",diag_frameno,diag_tickTime]; + +startingLocations = []; +_total = 0; + +//--- Getting all locations. +while {!isNil Format["StartingLocation%1",_total]} do { + startingLocations = startingLocations + [Call Compile Format["StartingLocation%1",_total]]; + _total = _total + 1; +}; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Starting Locations - [Done]",diag_frameno,diag_tickTime]; + +//--- Waiting for the common part to be executed. +waitUntil {commonInitComplete && townInit}; + +[] Call Compile preprocessFile 'Server\Init\Init_Defenses.sqf'; + +//--- Fast Time. +if (('WFBE_FASTTIMERATE' Call GetNamespace) > 0) then { + [] ExecFSM "Server\FSM\fasttime.fsm"; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Fast Time Module - [Done]",diag_frameno,diag_tickTime]; +}; + +//--- Weather. +_weat = 'WFBE_WEATHER' Call GetNamespace; +if (_weat == 3) then { + [] ExecFSM "Server\FSM\weather.fsm"; +} else { + if (isDedicated) then { + _oc = 0.05; + switch (_weat) do { + case 0: {_oc = 0}; + case 1: {_oc = 0.5}; + case 2: {_oc = 1}; + }; + 60 setOvercast _oc; + }; +}; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Weather Module - [Done]",diag_frameno,diag_tickTime]; + +//--- Static defenses in town main group, they exchange information about enemies. +WF_ResistanceDefenseTeam = createGroup resistance; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Common and Towns - [Done]",diag_frameno,diag_tickTime]; + +//--- Select whether the spawn restriction is enabled or not. +_locationLogics = []; +if (paramSpawnRestriction) then { + { + _nearLogics = _x nearEntities[["LocationLogic"],2000]; + if (count _nearLogics > 0) then {{if !(_x in _locationLogics) then {_locationLogics = _locationLogics + [_x]}} forEach _nearLogics}; + } forEach towns; + if (count _locationLogics < 3) then {{if !(_x in _locationLogics) then {_locationLogics = _locationLogics + [_x]}} forEach [StartingLocation0,StartingLocation1]}; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Spawn Restriction - [Done]",diag_frameno,diag_tickTime]; +} else { + _locationLogics = startingLocations; +}; + +_total = count _locationLogics; + +//--- Getting locations that have a distance above the SIDESTARTINGDISTANCE variable. +_westLocation = StartingLocation0; +_eastLocation = StartingLocation0; +switch ('WFBE_STARTINGLOCATIONMODE' Call GetNamespace) do { + case 0: {_westLocation = StartingLocation0; _eastLocation = StartingLocation1};//--- West North, East South. + case 1: {_westLocation = StartingLocation1; _eastLocation = StartingLocation0};//--- West South, East North. + case 2: { + //--- Random. Attempt to get a location above the given range. + _attempts = 0; + _ssd = 'WFBE_SIDESTARTINGDISTANCE' Call GetNamespace; + + //--- Random range?. + if (_ssd == -1) then {_ssd = floor(random(9500))}; + + while {_eastLocation distance _westLocation < _ssd && _attempts <= 500} do { + _eastLocation = _locationLogics select (random (_total - 1)); + _westLocation = _locationLogics select (random (_total - 1)); + _attempts = _attempts + 1; + }; + + //--- Couldn't find a starting location in range. + if (_attempts >= 500) then { + if (paramSpawnRestriction) then { + _westLocation = _locationLogics select 0; + _eastLocation = _locationLogics select ((count _locationLogics)-1); + } else { + _westLocation = StartingLocation0; + _eastLocation = StartingLocation1; + }; + }; + }; +}; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Starting Location Mode (%3) - [Done]",diag_frameno,diag_tickTime,('WFBE_STARTINGLOCATIONMODE' Call GetNamespace)]; + +//--- Moving each non-owner objects to the location. +EastMHQ setPos getPos _eastLocation; +WestMHQ setPos getPos _westLocation; + +//--- NEURO Protection. +EastMHQ setVariable ["WFBE_Taxi_Prohib", true]; +WestMHQ setVariable ["WFBE_Taxi_Prohib", true]; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: HQ Placement - [Done]",diag_frameno,diag_tickTime]; + +//--- Friendly Fire handler. +if (paramHandleFF) then { + EastMHQ addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, east] Call BuildingHandleDamages}]; + WestMHQ addEventHandler ['handleDamage',{[_this select 0,_this select 2,_this select 3, west] Call BuildingHandleDamages}]; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Friendly Fire Handling - [Done]",diag_frameno,diag_tickTime]; +}; + +eastStartingLocation = _eastLocation; +westStartingLocation = _westLocation; + +publicVariable "eastStartingLocation"; +publicVariable "westStartingLocation"; + +//--- Adding a killed EH to both MHQ. +Call Compile Format ["EastMHQ AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",east,typeOf EastMHQ]; +Call Compile Format ["WestMHQ AddEventHandler ['killed',{[_this select 0,_this select 1,%1,'%2'] Spawn HQKilled}];",west,typeOf WestMHQ]; + +//--- Radio System - Server. +_WF_GroupLogic = createGroup sideLogic; +_WF_GroupLogic2 = createGroup sideLogic; +_WF_GroupLogic3 = createGroup sideLogic; +_WF_GroupLogic4 = createGroup sideLogic; + +_BIS_WF_HQEASTgrp = createGroup east; +_BIS_WF_HQWESTgrp = createGroup west; +_BIS_WF_HQEASTgrp2 = createGroup east; +_BIS_WF_HQWESTgrp2 = createGroup west; + +BIS_WF_HQEAST = _WF_GroupLogic createUnit ["Logic",[0,0,0],[],0,"NONE"]; [BIS_WF_HQEAST] joinSilent _BIS_WF_HQEASTgrp; +BIS_WF_HQWEST = _WF_GroupLogic2 createUnit ["Logic",[0,0,0],[],0,"NONE"]; [BIS_WF_HQWEST] joinSilent _BIS_WF_HQWESTgrp; +BIS_WF_HQEAST2 = _WF_GroupLogic3 createUnit ["Logic",[0,0,0],[],0,"NONE"]; [BIS_WF_HQEAST2] joinSilent _BIS_WF_HQEASTgrp2; +BIS_WF_HQWEST2 = _WF_GroupLogic4 createUnit ["Logic",[0,0,0],[],0,"NONE"]; [BIS_WF_HQWEST2] joinSilent _BIS_WF_HQWESTgrp2; + +BIS_WF_HQEAST_TI = ('WFBE_EASTANNOUNCERS' Call GetNamespace) select round(random((count ('WFBE_EASTANNOUNCERS' Call GetNamespace))-1)); +BIS_WF_HQWEST_TI = ('WFBE_WESTANNOUNCERS' Call GetNamespace) select round(random((count ('WFBE_WESTANNOUNCERS' Call GetNamespace))-1)); + +BIS_WF_HQEAST setIdentity BIS_WF_HQEAST_TI; +BIS_WF_HQEAST setRank 'COLONEL'; +BIS_WF_HQEAST setGroupId ["HQ"]; +BIS_WF_HQEAST kbAddTopic [BIS_WF_HQEAST_TI,"Client\kb\hq.bikb","Client\kb\hq.fsm",{call compile preprocessFileLineNumbers "Client\kb\hq.sqf"}]; + +BIS_WF_HQWEST setIdentity BIS_WF_HQWEST_TI; +BIS_WF_HQWEST setRank 'COLONEL'; +BIS_WF_HQWEST setGroupId ["HQ"]; +BIS_WF_HQWEST kbAddTopic [BIS_WF_HQWEST_TI,"Client\kb\hq.bikb","Client\kb\hq.fsm",{call compile preprocessFileLineNumbers "Client\kb\hq.sqf"}]; + +publicVariable 'BIS_WF_HQEAST'; +publicVariable 'BIS_WF_HQEAST_TI'; +publicVariable 'BIS_WF_HQWEST'; +publicVariable 'BIS_WF_HQWEST_TI'; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Registered Radio Announcers (West: %3 East: %4) - [Done]",diag_frameno,diag_tickTime,BIS_WF_HQWEST_TI,BIS_WF_HQEAST_TI]; + +['WFBE_West_TimeUnderAttack',0,true] Call SetNamespace; +['WFBE_East_TimeUnderAttack',0,true] Call SetNamespace; + +['WFBE_West_LastCommander',objNull,true] Call SetNamespace; +['WFBE_East_LastCommander',objNull,true] Call SetNamespace; + +['WFBE_West_AIBase',false,true] Call SetNamespace; +['WFBE_East_AIBase',false,true] Call SetNamespace; + +['WFBE_West_AISupplyTrucks',[],true] Call SetNamespace; +['WFBE_East_AISupplyTrucks',[],true] Call SetNamespace; + +['WFBE_West_AICommanderFunds',round(('WFBE_WESTSTARTINGMONEY' Call GetNamespace)*1.5),true] Call SetNamespace; +['WFBE_East_AICommanderFunds',round(('WFBE_EASTSTARTINGMONEY' Call GetNamespace)*1.5),true] Call SetNamespace; + +//--- MHQ Tracking. +_text = ""; +if (('WFBE_INCOMINGMISSILEMAXRANGE' Call GetNamespace) != 0) then {_text = "this addEventHandler ['IncomingMissile', {_this Spawn HandleIncomingMissile}];"}; +EastMHQ setVehicleInit Format["['Headquarters','ColorGreen',[1,1],'','HQUndeployed',this,0.2,false,'','',false,East] ExecVM 'Common\Common_MarkerUpdate.sqf';%1",_text]; +processInitCommands; +WestMHQ setVehicleInit Format["['Headquarters','ColorGreen',[1,1],'','HQUndeployed',this,0.2,false,'','',false,West] ExecVM 'Common\Common_MarkerUpdate.sqf';%1",_text]; +processInitCommands; + +//--- Statistics variables. +WF_Logic setVariable ["eastUnitsCreated",0,true]; +WF_Logic setVariable ["eastCasualties",0,true]; +WF_Logic setVariable ["eastVehiclesCreated",0,true]; +WF_Logic setVariable ["eastVehiclesLost",0,true]; +WF_Logic setVariable ["westUnitsCreated",0,true]; +WF_Logic setVariable ["westCasualties",0,true]; +WF_Logic setVariable ["westVehiclesCreated",0,true]; +WF_Logic setVariable ["westVehiclesLost",0,true]; + +WF_Logic setVariable ["WF_CHQInUse_West",false]; +WF_Logic setVariable ["WF_CHQInUse_East",false]; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Stats Variable - [Done]",diag_frameno,diag_tickTime]; + +//--- Structures (en: it's possible to add location in the array, just make sure that they match the defined type in config_structures). +EastBaseStructures = []; +WestBaseStructures = []; +publicVariable "EastBaseStructures"; +publicVariable "WestBaseStructures"; + +emptyQueu = []; +trashQueu = []; +ignoreQueu = []; + +//--- Starting Vehicles East. +{ + _vehicle = [_x,(getPos EastMHQ),east,false] Call CreateVehi; + [_vehicle,getPos EastMHQ,45,60,true,false,true] Call PlaceNear; + clearWeaponCargo _vehicle; + clearMagazineCargo _vehicle; + emptyQueu = emptyQueu + [_vehicle]; + _vehicle Spawn HandleEmptyVehicle; +} forEach ('WFBE_EASTSTARTINGVEHICLES' Call GetNamespace); +//--- Starting Vehicles West. +{ + _vehicle = [_x,(getPos WestMHQ),west,false] Call CreateVehi; + [_vehicle,getPos WestMHQ,45,60,true,false,true] Call PlaceNear; + clearWeaponCargo _vehicle; + clearMagazineCargo _vehicle; + emptyQueu = emptyQueu + [_vehicle]; + _vehicle Spawn HandleEmptyVehicle; +} forEach ('WFBE_WESTSTARTINGVEHICLES' Call GetNamespace); + +if (paramAI) then { + //--- Loadout replacement & positioning & variables. + _i = 1; + { + if !(isNil "_x") then { + if (!isPlayer (leader _x) && alive (leader _x)) then { + _ran = 1 + round(random(2)); + (leader _x) setPos ([getPos _eastLocation,20,30] Call GetRandomPosition); + [(leader _x),Format ["WFBE_EASTLEADERWEAPONS0%1",_ran] Call GetNamespace,Format ["WFBE_EASTLEADERAMMO0%1",_ran] Call GetNamespace] Call EquipLoadout; + }; + _x setVariable ["queue",[]]; + Call Compile Format ["EastSlot%1Funds = %2; publicVariable 'EastSlot%1Funds';",_i,'WFBE_EASTSTARTINGMONEY' Call GetNamespace]; + [_x, false] Call SetTeamAutonomous; + [_x, ""] Call SetTeamRespawn; + [_x, -1] Call SetTeamType; + [_x, "towns"] Call SetTeamMoveMode; + [_x, [0,0,0]] Call SetTeamMovePos; + if (('WFBE_ISIS' Call GetNamespace) != 0) then {(leader _x) addEventHandler['handleDamage',{_this Call ISIS_Wound}]}; + if !(WF_A2_Vanilla) then {(_x) Call Compile preprocessFile 'Server\AI\AI_AddMultiplayerRespawnEH.sqf'}; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: East AI Team (%3) Full Init - [Done]",diag_frameno,diag_tickTime,_x]; + }; + _i = _i + 1; + } forEach ('WFBE_EASTTEAMS' Call GetNamespace); + _i = 1; + { + if !(isNil "_x") then { + if (!isPlayer (leader _x) && alive (leader _x)) then { + _ran = 1 + round(random(2)); + (leader _x) setPos ([getPos _westLocation,20,30] Call GetRandomPosition); + [(leader _x),Format ["WFBE_WESTLEADERWEAPONS0%1",_ran] Call GetNamespace,Format ["WFBE_WESTLEADERAMMO0%1",_ran] Call GetNamespace] Call EquipLoadout; + }; + _x setVariable ["queue",[]]; + Call Compile Format ["WestSlot%1Funds = %2; publicVariable 'WestSlot%1Funds';",_i,'WFBE_WESTSTARTINGMONEY' Call GetNamespace]; + [_x, false] Call SetTeamAutonomous; + [_x, ""] Call SetTeamRespawn; + [_x, -1] Call SetTeamType; + [_x, "towns"] Call SetTeamMoveMode; + [_x, [0,0,0]] Call SetTeamMovePos; + if (('WFBE_ISIS' Call GetNamespace) != 0) then {(leader _x) addEventHandler['handleDamage',{_this Call ISIS_Wound}]}; + if !(WF_A2_Vanilla) then {(_x) Call Compile preprocessFile 'Server\AI\AI_AddMultiplayerRespawnEH.sqf'}; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: West AI Team (%3) Full Init - [Done]",diag_frameno,diag_tickTime,_x]; + }; + _i = _i + 1; + } forEach ('WFBE_WESTTEAMS' Call GetNamespace); + + //--- AI Supply Trucks. + if (('WFBE_SUPPLYSYSTEM' Call GetNamespace) == 0) then { + [east] Spawn UpdateSupplyTruck; + [west] Spawn UpdateSupplyTruck; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Truck Supply System - [Done]",diag_frameno,diag_tickTime]; + }; + + //--- AI Teams (Don't pause the server initialization process). + [] Spawn { + waitUntil{townInit}; + {if (!isNil "_x") then {[_x] ExecFSM "Server\FSM\aiteam.fsm"}} forEach ('WFBE_EASTTEAMS' Call GetNamespace); + {if (!isNil "_x") then {[_x] ExecFSM "Server\FSM\aiteam.fsm"}} forEach ('WFBE_WESTTEAMS' Call GetNamespace); + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: AI Teams FSM - [Done]",diag_frameno,diag_tickTime]; + }; +} else { + _i = 1; + { + if !(isNil "_x") then { + Call Compile Format ["EastSlot%1Funds = %2; publicVariable 'EastSlot%1Funds';",_i,'WFBE_EASTSTARTINGMONEY' Call GetNamespace]; + _x setVariable ["identification", Format["EastSlot%1",_i]]; + [_x, false] Call SetTeamAutonomous; + [_x, ""] Call SetTeamRespawn; + [_x, -1] Call SetTeamType; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: East AI Team (%3) Partial Init - [Done]",diag_frameno,diag_tickTime,_x]; + }; + _i = _i + 1; + } forEach ('WFBE_EASTTEAMS' Call GetNamespace); + _i = 1; + { + if !(isNil "_x") then { + Call Compile Format ["WestSlot%1Funds = %2; publicVariable 'WestSlot%1Funds';",_i,'WFBE_WESTSTARTINGMONEY' Call GetNamespace]; + _x setVariable ["identification", Format["WestSlot%1",_i]]; + [_x, false] Call SetTeamAutonomous; + [_x, ""] Call SetTeamRespawn; + [_x, -1] Call SetTeamType; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: West AI Team (%3) Partial Init - [Done]",diag_frameno,diag_tickTime,_x]; + }; + _i = _i + 1; + } forEach ('WFBE_WESTTEAMS' Call GetNamespace); +}; + +//--- Town starting mode. +if (('WFBE_TOWNSTARTINGMODE' Call GetNamespace) != 0 || ('WFBE_RESPATROL' Call GetNamespace) > 0 || ('WFBE_RESSTRIKER' Call GetNamespace) > 0) then {[] Call Compile preprocessFile "Server\Init\Init_Towns.sqf"}; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Starting Vehicles - [Done]",diag_frameno,diag_tickTime]; + +//--- Pre-initialization of the Garbage Collector & Empty vehicle collector. +if (WF_A2_Vanilla) then {WF_Logic setVariable ["trash",[],true]}; +WF_Logic setVariable ["emptyVehicles",[],true]; + +//--- Civilians Module. +if (('WFBE_CIVILIANFACTION' Call GetNamespace) > 0) then { + //--- Create a group center. + createCenter civilian; + //--- Civilian Kill function. + CivilianKilled = Compile preprocessFile "Common\Functions\Common_CivilianKilled.sqf"; + //--- Execute the config file. + [] Call Compile preprocessFile "Server\Config\Config_Civilians.sqf"; +}; + +//--- Don't pause the server init script. +[] Spawn { + waitUntil {townInit}; + [] ExecFSM "Server\FSM\updateserver.fsm"; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server (Delayed): Server Module - [Done]",diag_frameno,diag_tickTime]; + [] ExecFSM "Server\FSM\updateresources.fsm"; + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server (Delayed): Ressources Module - [Done]",diag_frameno,diag_tickTime]; + + if (('WFBE_TOWNCONQUESTMODE' Call GetNamespace) > 0) then {[] ExecFSM "Server\FSM\conquest.fsm"}; +}; +[] ExecFSM "Server\FSM\garbagecollector.fsm"; +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Garbage Collector Module - [Done]",diag_frameno,diag_tickTime]; +[] ExecFSM "Server\FSM\emptyvehiclescollector.fsm"; +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Empty Vehicles Collector Module - [Done]",diag_frameno,diag_tickTime]; + +//--- Network System Part 2. +EastMHQDeployed = false; publicVariable 'EastMHQDeployed'; +WestMHQDeployed = false; publicVariable 'WestMHQDeployed'; + +WFBE_East_Upgrading = false; publicVariable 'WFBE_East_Upgrading'; +WFBE_West_Upgrading = false; publicVariable 'WFBE_West_Upgrading'; + +if !(paramMoneyOnly) then { + WF_Logic setVariable ["EastSupplies",EastSupplies,true]; + WF_Logic setVariable ["WestSupplies",WestSupplies,true]; +}; + +WF_Logic setVariable ["EastCommanderVoteTime",60,true]; +WF_Logic setVariable ["WestCommanderVoteTime",60,true]; + +WF_Logic setVariable ["EastCommanderTeam",EastCommanderTeam,true]; +WF_Logic setVariable ["WestCommanderTeam",WestCommanderTeam,true]; + +WF_Logic setVariable ["EastMHQRepair",false,true]; +WF_Logic setVariable ["WestMHQRepair",false,true]; + +//--- Upgrades. +_upArray = if (paramUpgradesEast) then {[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} else {'WFBE_UPGRADELEVELS' Call GetNamespace}; +EASTUpgrades = _upArray; +PublicVariable 'EASTUpgrades'; +_upArray = if (paramUpgradesWest) then {[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} else {'WFBE_UPGRADELEVELS' Call GetNamespace}; +WESTUpgrades = _upArray; +PublicVariable 'WESTUpgrades'; + +//--- Building Limits. +WestBuildingsCurrent = []; +EastBuildingsCurrent = []; +for '_i' from 0 to ((count ('WFBE_WESTSTRUCTURES' Call GetNamespace))-2) do {WestBuildingsCurrent set [_i, 0]}; +for '_i' from 0 to ((count ('WFBE_EASTSTRUCTURES' Call GetNamespace))-2) do {EastBuildingsCurrent set [_i, 0]}; +PublicVariable 'WestBuildingsCurrent'; +PublicVariable 'EastBuildingsCurrent'; + +if (paramRespawnMASH) then { + WF_Logic setVariable ["EastMASH",objNull,true]; + WF_Logic setVariable ["WestMASH",objNull,true]; +}; + +//--- Base Area (grouped base) +if (paramBaseArea) then { + WF_Logic setVariable ["EastArea",[],true]; + WF_Logic setVariable ["WestArea",[],true]; + + [] ExecFSM "Server\FSM\basearea.fsm"; +}; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Network Variables - [Done]",diag_frameno,diag_tickTime]; + +//--- Allies base. +_allies = 'WFBE_ALLIES' Call GetNamespace; +if (_allies > 0 && (WF_A2_Vanilla || WF_A2_CombinedOps)) then { + AlliesBuyUnit = Compile preprocessFile "Server\Functions\Server_AlliesBuyUnit.sqf"; + [] Call Compile preprocessFile "Server\Config\Config_Allies.sqf"; + if (_allies in [1,3]) then {[west] ExecFSM "Server\FSM\allies.fsm"}; + if (_allies in [2,3]) then {[east] ExecFSM "Server\FSM\allies.fsm"}; + + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Allies Module - [Done]",diag_frameno,diag_tickTime]; +}; + +//--- Use Workers? +if (paramUseWorkers) then { + WF_WestWorkers = []; + publicVariable "WF_WestWorkers"; + WF_EastWorkers = []; + publicVariable "WF_EastWorkers"; + + ["WFBE_WORKERS_WESTLOGIC",[],true] Call SetNamespace; + ["WFBE_WORKERS_EASTLOGIC",[],true] Call SetNamespace; +}; + +//--- Create base / town defenses group. +WF_DefenseWestGrp = createGroup west; +WF_DefenseEastGrp = createGroup east; + +//--- ALICE Module. +if (paramAlice) then { + _type = if (WF_A2_Vanilla) then {'AliceManager'} else {'Alice2Manager'}; + (createGroup sideLogic) createUnit [_type,[0,0,0],[],0,"NONE"]; + + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: ALICE Module - [Done]",diag_frameno,diag_tickTime]; +}; + +//--- Mission Module +if (paramSecondaryMissions) then { + ExecFSM 'Server\FSM\missions.fsm'; + + diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Server: Missions Init - [Done]",diag_frameno,diag_tickTime]; +}; + +//--- UPSMON AI +if (paramUPSMON) then { + Call Compile preprocessFileLineNumbers "Server\Module\UPSMON\Init_UPSMON.sqf"; +}; + +diag_log Format["[WFBE (INIT)][frameno:%2 | ticktime:%3] Init_Server: Init End at %1",time,diag_frameno,diag_tickTime]; + +//--- Waiting until that the game is launched. +waitUntil {time > 0}; + +//--- Launch votes. +[East] Spawn SVoteForCommander; +[West] Spawn SVoteForCommander; \ No newline at end of file diff --git a/Server/Init/Init_Towns.sqf b/Server/Init/Init_Towns.sqf new file mode 100644 index 0000000..98e6995 --- /dev/null +++ b/Server/Init/Init_Towns.sqf @@ -0,0 +1,214 @@ +private ['_half','_wStart','_eStart','_nearTownsW','_nearTownsE','_near','_x','_camps','_total','_limit','_defenses','_require', +'_initied','_towns','_town','_boundaries','_minus','_total','_z']; + +waitUntil {townInit}; + +//--- Special Towns mode. +switch ('WFBE_TOWNSTARTINGMODE' Call GetNamespace) do { + //--- 50-50. + case 1: { + _half = round ((count towns) / 2 ); + _wStart = westStartingLocation; + _eStart = eastStartingLocation; + + _nearTownsW = []; + _nearTownsE = []; + + _near = [_wStart,towns] Call SortByDistance; + if (count _near > 0) then { + for [{_z = 0},{_z < _half},{_z = _z + 1}] do {_nearTownsW = _nearTownsW + [_near select _z]}; + }; + + _nearTownsE = (towns - _nearTownsW); + + { + _x setVariable ['sideID',WESTID,true]; + _camps = _x getVariable "camps"; + {_x setVariable ['sideID',WESTID,true]} forEach _camps; + } forEach _nearTownsW; + { + _x setVariable ['sideID',EASTID,true]; + _camps = _x getVariable "camps"; + {_x setVariable ['sideID',EASTID,true]} forEach _camps; + } forEach _nearTownsE; + }; + + //--- Nearby Towns. + case 2: { + _total = count towns; + _wStart = westStartingLocation; + _eStart = eastStartingLocation; + _limit = floor(_total / 6); + _nearTownsW = []; + _nearTownsE = []; + + _near = [_wStart,towns] Call SortByDistance; + if (count _near > 0) then { + for [{_z = 0},{_z < _limit},{_z = _z + 1}] do {_nearTownsW = _nearTownsW + [_near select _z]}; + }; + + _near = [_eStart,(towns - _nearTownsW)] Call SortByDistance; + if (count _near > 0) then { + for [{_z = 0},{_z < _limit},{_z = _z + 1}] do {_nearTownsE = _nearTownsE + [_near select _z]}; + }; + + { + _x setVariable ['sideID',WESTID,true]; + _camps = _x getVariable "camps"; + {_x setVariable ['sideID',WESTID,true]} forEach _camps; + _defenses = _x nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_x getVariable "range"]; + {deleteVehicle _x} forEach _defenses; + } forEach _nearTownsW; + { + _x setVariable ['sideID',EASTID,true]; + _camps = _x getVariable "camps"; + {_x setVariable ['sideID',EASTID,true]} forEach _camps; + _defenses = _x nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_x getVariable "range"]; + {deleteVehicle _x} forEach _defenses; + } forEach _nearTownsE; + }; + + //--- Random Towns (25% East, 25% West, 50% Res). + case 3: { + _total = count towns; + _half = round(count towns)/4; + _minus = round(count towns)/2; + _boundaries = 'WFBE_BOUNDARIESXY' Call GetNamespace; + _nearTownsW = []; + _resTowns = []; + _towns = +towns; + + //--- Use boundaries to determinate the center if possible. + if !(isNil '_boundaries') then { + Private ["_dis1","_dis2","_e","_posF1","_posF2","_posx","_posy","_searchArea","_size"]; + //--- Attempt to set the center of the island resistance. + _searchArea = [(_boundaries / 2)-0.1,(_boundaries / 2)+0.1,0]; + _posx = _searchArea select 0; + _posy = _searchArea select 0; + _size = _boundaries/5; + _e = sqrt((_size)^2 - (_size)^2); + _posF1 = [_posx + (sin (90) * _e),_posy + (cos (90) * _e)]; + _posF2 = [_posx - (sin (90) * _e),_posy - (cos (90) * _e)]; + _total = 2 * _size; + + //--- Determinate resistance towns. + { + _position = getPos _x; + + _dis1 = _position distance _posF1; + _dis2 = _position distance _posF2; + if (_dis1+_dis2 < _total) then { + _resTowns = _resTowns + [_x]; + }; + + if (count _resTowns >= _minus) exitWith {}; + } forEach towns; + + //--- Update Towns. + _towns = _towns - _resTowns; + _e = count _towns; + + //--- Check if we couldn't reach 50% Res. + if (count _resTowns < _minus) then { + for '_z' from 0 to _e-1 do { + _town = _towns select round(random((count _towns)-1)); + _towns = _towns - [_town]; + + _resTowns = _resTowns + [_town]; + + if (count _resTowns >= _minus) exitWith {}; + }; + }; + + //--- Update Towns Again. + _towns = _towns - _resTowns; + _e = count _towns; + + //--- Assign west or east towns. + for '_z' from 0 to totalTowns-_minus-1 do { + _town = _towns select round(random((count _towns)-1)); + _towns = _towns - [_town]; + if (count _nearTownsW < _half) then { + _nearTownsW = _nearTownsW + [_town]; + _town setVariable ['sideID',WESTID,true]; + _camps = _town getVariable "camps"; + {_x setVariable ['sideID',WESTID,true]} forEach _camps; + _defenses = _town nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_town getVariable "range"]; + {deleteVehicle _x} forEach _defenses; + } else { + _town setVariable ['sideID',EASTID,true]; + _camps = _town getVariable "camps"; + {_x setVariable ['sideID',EASTID,true]} forEach _camps; + _defenses = _town nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_town getVariable "range"]; + {deleteVehicle _x} forEach _defenses; + }; + }; + } else { + //--- No boundaries defined, we use a random system. + for '_z' from 0 to _minus-1 do { + _town = _towns select round(random((count _towns)-1)); + _towns = _towns - [_town]; + if (count _nearTownsW < _half) then { + _nearTownsW = _nearTownsW + [_town]; + _town setVariable ['sideID',WESTID,true]; + _camps = _town getVariable "camps"; + {_x setVariable ['sideID',WESTID,true]} forEach _camps; + _defenses = _town nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_town getVariable "range"]; + {deleteVehicle _x} forEach _defenses; + } else { + _town setVariable ['sideID',EASTID,true]; + _camps = _town getVariable "camps"; + {_x setVariable ['sideID',EASTID,true]} forEach _camps; + _defenses = _town nearEntities['WFBE_RESISTANCEDEFENSENAMES' Call GetNamespace,_town getVariable "range"]; + {deleteVehicle _x} forEach _defenses; + }; + }; + }; + + + }; +}; + +//--- Resistance Patrols. +if (('WFBE_TOWNSTARTINGMODE' Call GetNamespace) != 1 && ('WFBE_RESPATROL' Call GetNamespace > 0)) then { + _require = if (('WFBE_RESPATROL' Call GetNamespace) > count towns) then {count towns} else {'WFBE_RESPATROL' Call GetNamespace}; + _initied = 0; + _towns = towns; + + //--- Don't bother with the randomizer if the amount set in RESPATROLMAX is >= count towns. + while {_initied < _require} do { + if (_require == count towns) then { + [_towns select _initied] ExecFSM "Server\FSM\respatrol.fsm"; + _initied = _initied + 1; + } else { + if (random 2 > 1) then { + _town = [_towns select (round(random((count _towns)-1)))] ExecFSM "Server\FSM\respatrol.fsm"; + _towns = _towns - [_town]; + _initied = _initied + 1; + }; + }; + }; +}; + +//--- Resistance Strikers. +if (('WFBE_TOWNSTARTINGMODE' Call GetNamespace) != 1 && ('WFBE_RESSTRIKER' Call GetNamespace) > 0) then { + _require = if (('WFBE_RESSTRIKER' Call GetNamespace) > count towns) then {count towns} else {'WFBE_RESSTRIKER' Call GetNamespace}; + _initied = 0; + _towns = towns; + + //--- Don't bother with the randomizer if the amount set in RESSTRIKERMAX is >= count towns. + while {_initied < _require} do { + if (_require == count towns) then { + [_towns select _initied] ExecFSM "Server\FSM\resstriker.fsm"; + _initied = _initied + 1; + } else { + if (random 2 > 1) then { + _town = [_towns select (round(random((count _towns)-1)))] ExecFSM "Server\FSM\resstriker.fsm"; + _towns = _towns - [_town]; + _initied = _initied + 1; + }; + }; + }; +}; + +diag_log Format["[WFBE (INIT)][frameno:%1 | ticktime:%2] Init_Towns (Server): Towns starting mode initialization - [Done]",diag_frameno,diag_tickTime]; \ No newline at end of file diff --git a/Server/Missions/M_BASE_Attack/m_init.sqf b/Server/Missions/M_BASE_Attack/m_init.sqf new file mode 100644 index 0000000..d16b977 --- /dev/null +++ b/Server/Missions/M_BASE_Attack/m_init.sqf @@ -0,0 +1,169 @@ +/* Base Attack Script (Hybrid) */ +Private ['_attackAfter','_attempts','_boundariesxy','_cpt','_group','_groups','_grps','_hq','_i','_inRange','_isHQDeployed','_jipHandler','_marker','_markerSize','_near','_pos','_position','_retVal','_runFor','_size','_spawnLocations','_structures','_target','_teamType','_uniqueIndex','_uniqueLabel','_vehicles']; + +_uniqueLabel = _this select 0; +_uniqueIndex = _this select 1; +_runFor = _this select 2; + +//--- Make sure that at least one building is available. +_structures = (_runFor) Call GetSideStructures; +if (count _structures == 0) exitWith{ + [Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; +}; + +/* Radio the designated team that a new mission is available */ +['NewMissionAvailable','',_runFor] Spawn SideMessage; + +//--- Grab the HQ. +_isHQDeployed = (_runFor) Call GetSideHQDeployed; +if (_isHQDeployed) then { + _hq = (_runFor) Call GetSideHQ; + if (alive _hq) then {_structures = _structures + [_hq]}; +}; + +//--- Pick a target. +_target = _structures select floor(random (count _structures)); + +//--- Progressive difficulty. +_grps = 2 + ('WFBE_TOWNRESISTANCEDIFFICULTY' Call GetNamespace); + +//--- Create the groups. +_groups = []; +for [{_i = 0},{_i < _grps},{_i = _i + 1}] do { + _groups = _groups + [createGroup resistance]; +}; + +_markerSize = 700; +_size = _markerSize; + +//--- Plan the attack delay. +_attackAfter = (300)+(random 100)-(random 100); + +//--- Warn the client. +WFBE_M_BASE_Attack = [_runFor,'CLTFNCM_BASE_ATTACK',[_size/2,_uniqueLabel,_uniqueIndex,_target,_groups]]; +publicVariable 'WFBE_M_BASE_Attack'; +if (isHostedServer || local player) then {[_runFor,'CLTFNCM_BASE_ATTACK',[_size/2,_uniqueLabel,_uniqueIndex,_target,_groups]] Spawn HandlePVF}; +_jipHandler = [_runFor,_size,_uniqueLabel,_uniqueIndex,_target,_groups] Spawn { + Private ['_groups','_oldPlayerList','_runFor','_size','_target','_uniqueLabel','_uniqueIndex','_update']; + _runFor = _this select 0; + _size = (_this select 1)/2; + _uniqueLabel = _this select 2; + _uniqueIndex = _this select 3; + _target = _this select 4; + _groups = _this select 5; + + while {true} do { + _oldPlayerList = playableUnits; + sleep 15; + _update = false; + { + if !(_x in _oldPlayerList) then {_update = true}; + } forEach playableUnits; + + if (_update) then { + WFBE_M_BASE_Attack = [_runFor,'CLTFNCM_BASE_ATTACK',[_size,_uniqueLabel,_uniqueIndex,_target,_groups]]; + publicVariable 'WFBE_M_BASE_Attack'; + if (isHostedServer || local player) then {[_runFor,'CLTFNCM_BASE_ATTACK',[_size,_uniqueLabel,_uniqueIndex,_target,_groups]] Spawn HandlePVF}; + }; + }; +}; + +sleep _attackAfter; + +//--- Targert died? +if !(alive _target) then { + //--- Pick another target if possible, else send them to the HQ (DoA). + _structures = (_runFor) Call GetSideStructures; + if (count _structures == 0) then { + _hq = (_runFor) Call GetSideHQ; + _target = _hq; + } else { + _target = _structures select floor(random (count _structures)); + }; +}; + +//--- UPSMON Area Definition. +_marker = ""; +if (paramUPSMON) then { + _marker = Format['UPSMON_%1%2',_uniqueLabel,_uniqueIndex]; + createMarkerLocal [_marker, getPos _target]; + _marker setMarkerColorLocal "ColorBlue"; + _marker setMarkerShapeLocal "RECTANGLE"; + _marker setMarkerBrushLocal "BORDER"; + _marker setMarkerSizeLocal [300,300]; + _marker setMarkerAlphaLocal 0; +}; + +_spawnLocations = []; +_attempts = 0; +while {count _spawnLocations < 8} do { + sleep 0.05; + _position = ([getPos _target,(_markerSize * 0.75),(_markerSize)] Call GetRandomPosition); + _pos = [_position, 50] Call GetSafePlace; + + _inRange = true; + if (paramBoundaries) then { + _boundariesxy = 'WFBE_BOUNDARIESXY' Call GetNamespace; + if (((_pos select 0) < (_markerSize / 2) || (_pos select 0) > (_boundariesxy - (_markerSize / 2))) || ((_pos select 1) < (_markerSize / 2) || (_pos select 1) > (_boundariesxy - (_markerSize / 2)))) then { + _inRange = false; + }; + }; + + _near = _pos nearEntities [['Man','Car','Motorcycle','Ship','Air','Tank','StaticCannon'],_markerSize/8]; + + if (east countSide _near == 0 && west countSide _near == 0 && _inRange) then {_spawnLocations = _spawnLocations + [_pos];_size = 650}; + _attempts = _attempts + 1; + + if (_attempts > 50) then { + _attempts = 0; + _size = _size + (_markerSize/5); + }; +}; + +_i = 0; +_vehicles = []; +while {_i < _grps} do { + _teamType = Format ["WFBE_RESPATROLTYPE%1%2",1 + round(random 2),round(random 2)] Call GetNamespace; + _group = _groups select _i; + _pos = _spawnLocations select floor(random(count _spawnLocations)); + + _retVal = [_teamType,_pos,resistance,paramResVehLock,_group] Call CreateTeamTemplate; + _vehicles = _vehicles + (_retVal select 1); + + _group setFormation (['COLUMN','ECH RIGHT','LINE','FILE','DIAMOND'] select floor(random 5)); + + _group setBehaviour 'COMBAT'; + _group setCombatMode 'RED'; + _group move (getPos _target); + + //--- If UPS is enabled, the ai will do a bit more than sitting in base. + if (paramUPSMON) then {[(leader _group),_marker,"move","nofollow","reinforcement"] Spawn UPSMON}; + + _i = _i + 1; +}; + +//--- Wait until everyone's dead. +waitUntil { + sleep 1; + + _cpt = 0; + { + if !(isNil '_x') then { + _cpt = _cpt + (count ((units _x) Call GetLiveUnits)); + }; + } forEach _groups; + + _cpt == 0 +}; + +//--- Kill the spawned thread if it still runs. +if !(scriptDone _jipHandler) then {terminate _jipHandler}; + +//--- Wait for the client to end up his sync. +sleep 35; + +//--- Free the mission. +[Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; + +//--- Delete UPSMON Marker if necessary. +if (paramUPSMON) then {deleteMarkerLocal _marker}; \ No newline at end of file diff --git a/Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf b/Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf new file mode 100644 index 0000000..d874c2e --- /dev/null +++ b/Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf @@ -0,0 +1,128 @@ +/* Players Attack Script (Hybrid) */ +Private ["_boundaries","_chopper","_group","_jipHandler","_list","_pilot","_players","_ran","_ranDir","_runFor","_ranPos","_target","_targets","_turrets","_uniqueIndex","_uniqueLabel","_vehicle"]; + +_uniqueLabel = _this select 0; +_uniqueIndex = _this select 1; +_runFor = _this select 2; + +//--- Retrieve the players on a side. +_players = []; +_list = Format ["WFBE_%1TEAMS",_runFor] Call GetNamespace; +{ + if !(isNil '_x') then { + if (side _x == _runFor) then { + if (isPlayer(leader _x) && alive(leader _x)) then {_players = _players + [leader _x]}; + }; + }; +} forEach _list; + +//--- Ensure that the team already has a town. +if (count _players == 0) exitWith { + [Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; +}; + +//--- Radio the designated team that a new mission is available. +['NewMissionAvailable','',_runFor] Spawn SideMessage; + +//--- Define the chopper spawn position. +_boundaries = "WFBE_BOUNDARIESXY" Call GetNamespace; + +_ranPos = []; +_ranDir = []; + +_bd = 'WFBE_BOUNDARIESXY' Call GetNamespace; +if !(isNil '_bd') then { + _ranPos = [ + [0+random(200),0+random(200),400+random(200)], + [0+random(200),_bd-random(200),400+random(200)], + [_bd-random(200),_bd-random(200),400+random(200)], + [_bd-random(200),0+random(200),400+random(200)] + ]; + _ranDir = [45,145,225,315]; +} else { + _ranPos = [[0+random(200),0+random(200),400+random(200)],[10000+random(200),0+random(200),400+random(200)]]; + _ranDir = [45,315]; +}; + +_ran = round(random((count _ranPos)-1)); + +//--- This script use PMC units. +_chopper = "Ka60_PMC"; +_group = createGroup resistance; +_vehicle = createVehicle [_chopper,(_ranPos select _ran), [], (_ranDir select _ran), "FLY"]; +_vehicle addEventHandler ['Killed',{[_this select 0,_this select 1,resistance] Spawn UnitKilled}]; + +//--- Man the chopper. +_pilot = ["Soldier_Pilot_PMC",_group,[0,0,0],resistance] Call CreateMan; +_pilot moveInDriver _vehicle; +_pilot = ["Soldier_Pilot_PMC",_group,[0,0,0],resistance] Call CreateMan; +_pilot moveInGunner _vehicle; + +//--- Man the extra turrets. +_config = configFile >> "CfgVehicles" >> _chopper >> "Turrets"; +_turrets = [_config] call BIS_fnc_returnVehicleTurrets; +if (count _turrets > 0) then {[_turrets, [], _vehicle, "Soldier_Pilot_PMC", _group] call SpawnTurrets}; + +//--- Warn the client. +WFBE_M_PLAYERS_Attack_Air = [_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_vehicle,_uniqueLabel,_uniqueIndex]]; +publicVariable 'WFBE_M_PLAYERS_Attack_Air'; +if (isHostedServer || local player) then {[_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_vehicle,_uniqueLabel,_uniqueIndex]] Spawn HandlePVF}; +_jipHandler = [_vehicle,_uniqueLabel,_uniqueIndex] Spawn { + Private ['_chopper','_oldPlayerList','_runFor','_uniqueLabel','_uniqueIndex','_update']; + _chopper = _this select 0; + _uniqueLabel = _this select 1; + _uniqueIndex = _this select 1; + + while {true} do { + _oldPlayerList = playableUnits; + sleep 15; + _update = false; + { + if !(_x in _oldPlayerList) then {_update = true}; + } forEach playableUnits; + + if (_update) then { + WFBE_M_PLAYERS_Attack_Air = [_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_chopper,_uniqueLabel,_uniqueIndex]]; + publicVariable 'WFBE_M_PLAYERS_Attack_Air'; + if (isHostedServer || local player) then {[_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_chopper,_uniqueLabel,_uniqueIndex]] Spawn HandlePVF}; + }; + }; +}; + +//--- Move the chopper toward the target. +while {true} do { + sleep 20; + + _players = []; + { + if !(isNil '_x') then { + if (side _x == _runFor) then { + if (isPlayer(leader _x) && alive(leader _x)) then {_players = _players + [leader _x]}; + }; + }; + } forEach _list; + + if (count _players == 0 || !alive _vehicle || !alive(driver _vehicle) || !canMove _vehicle) exitWith {}; + + _targets = [_vehicle, _players] Call SortByDistance; + _target = _targets select 0; + { + if (vehicle _x == _x && !((vehicle _x) isKindOf "Air")) exitWith {_target = _x}; + } forEach _targets; + + if !(someAmmo _vehicle) then {[_vehicle,resistance] Call RearmVehicle}; + + _vehicle doMove (getPos _target); + {_group reveal _x} forEach (vehicle _target nearEntities 200); +}; + +if (alive _vehicle || count _players == 0) then {_vehicle setDammage 1}; +{if (alive _x || count _players == 0) then {_x setDammage 1}} forEach (units _group); + +//--- Kill the spawned thread if it still runs. +if !(scriptDone _jipHandler) then {terminate _jipHandler}; + +//--- Wait for the client to end up his sync. +sleep 35; + +[Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; \ No newline at end of file diff --git a/Server/Missions/M_TOWN_Attack/m_init.sqf b/Server/Missions/M_TOWN_Attack/m_init.sqf new file mode 100644 index 0000000..b687535 --- /dev/null +++ b/Server/Missions/M_TOWN_Attack/m_init.sqf @@ -0,0 +1,160 @@ +/* Town Attack Script (Hybrid) */ +Private ['_attackAfter','_attempts','_boundariesxy','_cpt','_group','_groups','_grps','_i','_inRange','_jipHandler','_markerSize','_near','_pos','_position','_resTypes','_retVal','_runFor','_sideID','_size','_spawnLocations','_sup','_teamType','_town','_towns','_uniqueIndex','_uniqueLabel','_vehicles']; + +_uniqueLabel = _this select 0; +_uniqueIndex = _this select 1; +_runFor = _this select 2; + +//--- Retrieve towns. +_towns = []; +_sideID = (_runFor) Call GetSideID; +{ + if (_x getVariable 'sideID' == _sideID) then {_towns = _towns + [_x]}; +} forEach towns; + +//--- Ensure that the team already has a town. +if (count _towns == 0) exitWith { + [Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; +}; + +/* Radio the designated team that a new mission is available */ +['NewMissionAvailable','',_runFor] Spawn SideMessage; + +//--- Pick a town. +_town = _towns select round(random((count _towns)-1)); + +_markerSize = 500; +_size = _markerSize; + +//--- Get the groups depending on the SV. +_sup = _town getVariable 'supplyValue'; +_grps = 1; +if (_sup < 30) then {_grps = 2}; +if (_sup >= 30 && _sup < 50) then {_grps = 3}; +if (_sup >= 50 && _sup < 80) then {_grps = 4}; +if (_sup >= 80 && _sup < 100) then {_grps = 5}; +if (_sup >= 100 && _sup < 120) then {_grps = 6}; +if (_sup >= 120) then {_grps = 7}; + +//--- Create the groups. +_groups = []; +for [{_i = 0},{_i < _grps},{_i = _i + 1}] do { + _groups = _groups + [createGroup resistance]; +}; + +//--- Plan the attack delay. +_attackAfter = (200)+(random 100)-(random 100); + +//--- Warn the client. +WFBE_M_TOWN_Attack = [_runFor,'CLTFNCM_TOWN_ATTACK',[_size/2,_uniqueLabel,_uniqueIndex,_town,_groups]]; +publicVariable 'WFBE_M_TOWN_Attack'; +if (isHostedServer || local player) then {[_runFor,'CLTFNCM_TOWN_ATTACK',[_size/2,_uniqueLabel,_uniqueIndex,_town,_groups]] Spawn HandlePVF}; +_jipHandler = [_runFor,_size,_uniqueLabel,_uniqueIndex,_town,_groups] Spawn { + Private ['_groups','_oldPlayerList','_runFor','_size','_town','_uniqueLabel','_uniqueIndex','_update']; + _runFor = _this select 0; + _size = (_this select 1)/2; + _uniqueLabel = _this select 2; + _uniqueIndex = _this select 3; + _town = _this select 4; + _groups = _this select 5; + + while {true} do { + _oldPlayerList = playableUnits; + sleep 15; + _update = false; + { + if !(_x in _oldPlayerList) then {_update = true}; + } forEach playableUnits; + + if (_update) then { + WFBE_M_TOWN_Attack = [_runFor,'CLTFNCM_TOWN_ATTACK',[_size,_uniqueLabel,_uniqueIndex,_town,_groups]]; + publicVariable 'WFBE_M_TOWN_Attack'; + if (isHostedServer || local player) then {[_runFor,'CLTFNCM_TOWN_ATTACK',[_size,_uniqueLabel,_uniqueIndex,_town,_groups]] Spawn HandlePVF}; + }; + }; +}; + +//--- Wait... +sleep _attackAfter; + +_spawnLocations = []; +_attempts = 0; +while {count _spawnLocations < 8} do { + sleep 0.05; + _position = ([getPos _town,(_markerSize * 0.75),(_markerSize)] Call GetRandomPosition); + _pos = [_position, 50] Call GetSafePlace; + + _inRange = true; + if (paramBoundaries) then { + _boundariesxy = 'WFBE_BOUNDARIESXY' Call GetNamespace; + if (((_pos select 0) < (_markerSize / 2) || (_pos select 0) > (_boundariesxy - (_markerSize / 2))) || ((_pos select 1) < (_markerSize / 2) || (_pos select 1) > (_boundariesxy - (_markerSize / 2)))) then { + _inRange = false; + }; + }; + + _near = _pos nearEntities [['Man','Car','Motorcycle','Ship','Air','Tank','StaticCannon'],_markerSize/8]; + + if (east countSide _near == 0 && west countSide _near == 0 && _inRange) then {_spawnLocations = _spawnLocations + [_pos];_size = 650}; + _attempts = _attempts + 1; + + if (_attempts > 50) then { + _attempts = 0; + _size = _size + (_markerSize/5); + }; +}; + +_resTypes = _town getVariable 'resistanceTypes'; +_sideID = _town getVariable 'sideID'; + +_i = 0; +_vehicles = []; +while {_i < _grps} do { + _teamType = Format ["WFBE_RES%1UNITS",_resTypes select floor(random(count _resTypes))] Call GetNamespace; + _group = _groups select _i; + _pos = _spawnLocations select floor(random(count _spawnLocations)); + + _retVal = [_teamType,_pos,resistance,paramResVehLock,_group] Call CreateTeamTemplate; + _vehicles = _vehicles + [_retVal select 1]; + + _group setFormation (['COLUMN','ECH RIGHT','LINE','FILE','DIAMOND'] select floor(random 5)); + + if (_sideID == RESISTANCEID) then { + //--- Town is held by the resistance. + _group setBehaviour 'AWARE'; + _group setCombatMode 'YELLOW'; + [_group,_town,150] Spawn AITownPatrol; + } else { + _group setBehaviour 'COMBAT'; + _group setCombatMode 'RED'; + _group move (getPos _town); + //--- Town is held by the occupation. + }; + + //--- Enhance the experience with UPSMON. + if (paramUPSMON) then {[(leader _group),Format ['UPSMON_TOWN_%1',str _town],"move","nofollow","reinforcement"] Spawn UPSMON}; + + _i = _i + 1; +}; + +//--- Wait until everyone's dead. +waitUntil { + sleep 1; + + _cpt = 0; + { + if !(isNil '_x') then { + _cpt = _cpt + (count ((units _x) Call GetLiveUnits)); + }; + } forEach _groups; + + _cpt == 0 +}; + +//--- Kill the spawned thread if it still runs. +if !(scriptDone _jipHandler) then {terminate _jipHandler}; + +//--- Wait for the client to end up his sync. +sleep 35; + +//--- Free the mission. +[Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; \ No newline at end of file diff --git a/Server/Missions/M_UAV_RetrieveModule/m_init.sqf b/Server/Missions/M_UAV_RetrieveModule/m_init.sqf new file mode 100644 index 0000000..b9d8388 --- /dev/null +++ b/Server/Missions/M_UAV_RetrieveModule/m_init.sqf @@ -0,0 +1,503 @@ +/* UAV Retrieve Module Script */ +Private ['_attempts','_boundariesxy','_completeList','_completeListTr','_crashed','_craters','_defensePos','_east','_eastUAV','_ecomplete','_end','_espos','_eteam','_eteamname','_eteamrunning','_jipHandler','_list','_markerSize','_near','_nearUav','_pos','_ran','_randomPos','_resistance','_returned','_safeRadius','_size','_spawnUnits','_team','_uav','_uavModel','_uniqueIndex','_uniqueLabel','_unit','_units','_vehicles','_waitFor','_wcomplete','_west','_westUAV','_winner','_wspos','_wteam','_wteamname','_wteamrunning']; + +_uniqueLabel = _this select 0; +_uniqueIndex = _this select 1; + +_randomPos = []; + +//--- Marker size. +_markerSize = 750; + +//--- Is boundaries enabled? +_boundariesxy = 'WFBE_BOUNDARIESXY' Call GetNamespace; +if !(isNil '_boundariesxy') then { + //--- Use the boundaries to get a position, limit it to a possible location (not outside of the map). + _boundariesxy = _boundariesxy - (_markerSize*2); + if (_boundariesxy <= 0) then {_boundariesxy = ('WFBE_BOUNDARIESXY' Call GetNamespace)}; + + _safeRadius = 750; + _attempts = 0; + + //--- Get a safe 'clear' position for a crash site. + while {_attempts != -1} do { + sleep 0.005; + + _attempts = _attempts + 1; + + _randomPos = [_markerSize + (random _boundariesxy),_markerSize + (random _boundariesxy),0]; + + //--- Water-free & building free + if (count (_randomPos isFlatEmpty [20/8,0,0.6,20,0,false,objNull]) > 0) then { + //--- We don't want any 'living' units around. + if (count(_randomPos nearEntities [['Man','Car','Motorcycle','Ship','Air','Tank','StaticWeapon'],_safeRadius/2]) == 0) exitWith {_attempts = -1}; + + //--- Result may vary. + if (_attempts > 250 && _safeRadius > 10) then { + _attempts = 0; + _safeRadius = _safeRadius - 100; + if (_safeRadius < 10) then {_safeRadius = 10}; + }; + }; + }; +} else { + //--- Get a random location around a town. + _pos = getPos (towns select round(random((count towns) -1))); + + _safeRadius = 500; + _attempts = 0; + + //--- Get a safe 'clear' position for a crash site. + while {_attempts != -1} do { + sleep 0.01; + + _attempts = _attempts + 1; + + _randomPos = [(_pos select 0) + random(_safeRadius)-random(_safeRadius),(_pos select 1) + random(_safeRadius)-random(_safeRadius),0]; + + //--- Water-free & building free + if (count (_randomPos isFlatEmpty [20/8,0,0.6,20,0,false,objNull]) > 0) then { + //--- We don't want any 'living' units around. + if (count(_randomPos nearEntities [['Man','Car','Motorcycle','Ship','Air','Tank','StaticWeapon'],_safeRadius/2]) == 0) exitWith {_attempts = -1}; + + //--- Result may vary. + if (_attempts > 50) then { + _attempts = 0; + _safeRadius = _safeRadius + 200; + if (_safeRadius > 1500) then {attempts = -1;_randomPos = []}; + }; + }; + }; +}; + +//--- No suitable position found? exit. +if (count _randomPos == 0) exitWith { + diag_log Format["[WFBE (INFORMATION)][frameno:%1 | ticktime:%2] M_UAV_RetrieveModule: Unable to determine a spawn location.",diag_frameno,diag_tickTime]; + ['_WFBE_M_RUNNINGMISSIONS_WEST',('_WFBE_M_RUNNINGMISSIONS_WEST' Call GetNamespace) - 1, true] Call SetNamespace; + ['_WFBE_M_RUNNINGMISSIONS_EAST',('_WFBE_M_RUNNINGMISSIONS_EAST' Call GetNamespace) - 1, true] Call SetNamespace; +}; + +//--- Define the context. +_eastUAV = 'WFBE_EASTUAV' Call GetNamespace; +_westUAV = 'WFBE_WESTUAV' Call GetNamespace; + +//--- No suitable UAV models? exit. +if (_eastUAV == '' && _westUAV == '') exitWith { + diag_log Format["[WFBE (INFORMATION)][frameno:%1 | ticktime:%2] M_UAV_RetrieveModule: No suitable UAV Models defined for WFBE_EASTUAV & WFBE_WESTUAV.",diag_frameno,diag_tickTime]; + ['_WFBE_M_RUNNINGMISSIONS_WEST',('_WFBE_M_RUNNINGMISSIONS_WEST' Call GetNamespace) - 1, true] Call SetNamespace; + ['_WFBE_M_RUNNINGMISSIONS_EAST',('_WFBE_M_RUNNINGMISSIONS_EAST' Call GetNamespace) - 1, true] Call SetNamespace; +}; + +/* Radio both side for a new mission available */ +['NewMissionAvailable','',West] Spawn SideMessage; +['NewMissionAvailable','',East] Spawn SideMessage; + +//--- Determine which one to use. +_crashed = civilian; +if (_eastUAV != '') then { + //--- West UAV tend to fall more often ;) + _crashed = if (random 100 > 25) then {west} else {east}; +} else { + _crashed = west; +}; + +//--- Place and destroy the uav. +_uavModel = if (_crashed == west) then {_westUAV} else {_eastUAV}; +_uav = _uavModel createVehicle (_randomPos); +_uav setDammage 1; + +//--- Garbage protection. +if !(WF_A2_Vanilla) then {ignoreQueu = ignoreQueu + [_uav]}; +_uav setVariable ['keepAlive',true,true]; //--- Salvager protection. + +//--- Determine if the uav is held by resistance forces or not. +_spawnUnits = 0 Spawn {}; +_team = objNull; +_units = []; +_vehicles = []; +if (random 100 > 35) then { + //--- Pick a resistance patrol template (Only the light & medium one). + _list = Format["WFBE_RESPATROLTYPE%1%2",ceil(random 3),round(random 2)] Call GetNamespace; + + //--- Get the team spawn position. + _defensePos = [[(_randomPos select 0)+random(150)-random(150),(_randomPos select 1)+random(150)-random(150)], 250] Call GetSafePlace; + + //--- Create the team. + _returned = [_list,_defensePos,resistance,paramResVehLock,objNull] Call CreateTeamTemplate; + _units = _returned select 0; + _vehicles = _returned select 1; + _team = _returned select 2; + + //--- Start the hunt/guard script. + _spawnUnits = [_units,_vehicles,_randomPos,_markerSize] Spawn { + Private ['_area','_guard','_objects','_target','_targets','_units','_vehicles']; + _units = _this select 0; + _vehicles = _this select 1; + _guard = _this select 2; + _area = _this select 3; + + while {({alive _x} count _units) > 0} do { + sleep 20; + + _targets = _guard nearEntities [['Man','Car','Motorcycle','Ship','Air','Tank','StaticWeapon'],_area]; + _objects = _targets; + { + if !(_x isKindOf 'Man') then {if (count (crew _x) == 0) then {_objects = _objects - [_x]}}; + if (side _x == resistance || side _x == civilian) then {_objects = _objects - [_x]}; + } forEach _targets; + + _targets = [_guard,_objects] Call SortByDistance; + + if (count _targets > 0) then { + _target = _targets select 0; + (_units) commandMove [(getPos _target select 0)-random(60)+random(60), (getPos _target select 1)-random(60)+random(60), 0]; + }; + }; + }; +}; + +//--- Send to client, task, size, etc. +WFBE_M_UAV_RetrieveModule = [nil,'CLTFNCM_UAV_RETRIEVEMODULE',[_markerSize,_uniqueLabel,_uniqueIndex,_uav]]; +publicVariable 'WFBE_M_UAV_RetrieveModule'; +if (isHostedServer || local player) then {[nil,'CLTFNCM_UAV_RETRIEVEMODULE',[_markerSize,_uniqueLabel,_uniqueIndex,_uav]] Spawn HandlePVF}; +_jipHandler = [_markerSize,_uniqueLabel,_uniqueIndex,_uav] Spawn { + Private ['_oldPlayerList','_update']; + while {true} do { + _oldPlayerList = playableUnits; + sleep 15; + _update = false; + { + if !(_x in _oldPlayerList) exitWith {_update = true}; + } forEach playableUnits; + + if (_update) then { + WFBE_M_UAV_RetrieveModule = [nil,'CLTFNCM_UAV_RETRIEVEMODULE',_this]; + publicVariable 'WFBE_M_UAV_RetrieveModule'; + if (isHostedServer || local player) then {[nil,'CLTFNCM_UAV_RETRIEVEMODULE',_this] Spawn HandlePVF}; + }; + }; +}; + +//--- Choose the module extraction team. +_wteam = []; +_eteam = []; +//--- Vanilla. +if (WF_A2_Vanilla) then { + _wteam = ['FR_Miles','FR_OHara','FR_Rodriguez','FR_Sykes']; + _eteam = ['RUS_Soldier_TL','RUS_Soldier_GL','RUS_Soldier2','RUS_Soldier2']; +} else { + //--- Combined Ops. + if (WF_A2_CombinedOps) then { + if (WF_Camo) then { + if (random 100 > 50) then { + _wteam = ['FR_Miles','FR_OHara','FR_Rodriguez','FR_Sykes']; + } else { + if (paramDLCBAF) then { + _wteam = ['BAF_Soldier_SL_W','BAF_Soldier_W','BAF_Soldier_W','BAF_Soldier_Medic_W']; + } else { + _wteam = ['CZ_Special_Forces_TL_DES_EP1','CZ_Special_Forces_DES_EP1','CZ_Special_Forces_DES_EP1','CZ_Special_Forces_GL_DES_EP1']; + }; + }; + _eteam = ['RUS_Soldier_TL','RUS_Soldier_GL','RUS_Soldier2','RUS_Soldier2']; + } else { + if (random 100 > 50) then { + if (paramDLCBAF && random 100 > 50) then { + _wteam = ['BAF_Soldier_SL_DDPM','BAF_Soldier_DDPM','BAF_Soldier_DDPM','BAF_Soldier_Medic_DDPM']; + } else { + _wteam = ['CZ_Special_Forces_TL_DES_EP1','CZ_Special_Forces_DES_EP1','CZ_Special_Forces_DES_EP1','CZ_Special_Forces_GL_DES_EP1']; + }; + _eteam = ['RUS_Soldier_TL','RUS_Soldier_GL','RUS_Soldier2','RUS_Soldier2']; + } else { + if (random 100 > 50) then { + _wteam = ['GER_Soldier_TL_EP1','GER_Soldier_EP1','GER_Soldier_EP1','GER_Soldier_Medic_EP1']; + } else { + _wteam = ['US_Delta_Force_TL_EP1','US_Delta_Force_EP1','US_Delta_Force_EP1','US_Delta_Force_Medic_EP1']; + }; + _eteam = ['TK_Special_Forces_TL_EP1','TK_Special_Forces_EP1','TK_Special_Forces_EP1','TK_Special_Forces_MG_EP1']; + }; + }; + } else { + //--- Arowwhead. + if (random 100 > 50) then { + if (paramDLCBAF && random 100 > 50) then { + _wteam = ['BAF_Soldier_SL_DDPM','BAF_Soldier_DDPM','BAF_Soldier_DDPM','BAF_Soldier_Medic_DDPM']; + } else { + _wteam = ['GER_Soldier_TL_EP1','GER_Soldier_EP1','GER_Soldier_EP1','GER_Soldier_Medic_EP1']; + }; + _eteam = ['RUS_Soldier_TL','RUS_Soldier_GL','RUS_Soldier2','RUS_Soldier2']; + } else { + if (random 100 > 50) then { + _wteam = ['CZ_Special_Forces_TL_DES_EP1','CZ_Special_Forces_DES_EP1','CZ_Special_Forces_DES_EP1','CZ_Special_Forces_GL_DES_EP1']; + } else { + _wteam = ['US_Delta_Force_TL_EP1','US_Delta_Force_EP1','US_Delta_Force_EP1','US_Delta_Force_Medic_EP1']; + }; + _eteam = ['TK_Special_Forces_TL_EP1','TK_Special_Forces_EP1','TK_Special_Forces_EP1','TK_Special_Forces_MG_EP1']; + }; + }; +}; + +//--- Handle the 'Middle part'. +_end = false; +_wteamrunning = objNull; +_eteamrunning = objNull; +_wteamname = ""; +_eteamname = ""; +_waitFor = 0; +_wspos = []; +_espos = []; +_wcomplete = false; +_ecomplete = false; +_completeList = ['WellDoneOut','GoodJobOut']; +_completeListTr = ['Well done, out.','Good job, out.']; +while {!_end} do { + sleep 5; + + if (isNull _uav) exitWith {}; + + //--- Todo, player radio HQ for extraction team. + _nearUav = _uav nearEntities 50; + + _west = west countSide _nearUav; + _east = east countSide _nearUav; + _resistance = resistance countSide _nearUav; + + //--- Team checkups (west). + if !(isNull _wteamrunning) then { + if (count ((units _wteamrunning) Call GetLiveUnits) == 0) then { + if (_waitFor <= 0) then { + ['ExtractionTeamCancel',_wteamname,West] Spawn SideMessage; + _wteamrunning = objNull; + _waitFor = 60; + }; + } else { + if (_waitFor < -200) then { + _waitFor = -1; + (units _wteamrunning) commandMove (getPos _uav); + }; + if (((leader _wteamrunning) distance _uav) < 50 && !_ecomplete && !_wcomplete) then { + _waitFor = 70; + _wcomplete = true; + + _uav setVariable ['side', West, true]; + + _wteamrunning setCombatMode "RED"; + _wteamrunning setBehaviour "COMBAT"; + }; + }; + }; + + //--- Team checkups (east). + if !(isNull _eteamrunning) then { + if (count ((units _eteamrunning) Call GetLiveUnits) == 0) then { + if (_waitFor <= 0) then { + ['ExtractionTeamCancel',_wteamname,East] Spawn SideMessage; + _eteamrunning = objNull; + _waitFor = 60; + }; + } else { + if (_waitFor < -200) then { + _waitFor = -1; + (units _eteamrunning) commandMove (getPos _uav); + }; + if (((leader _eteamrunning) distance _uav) < 50 && !_wcomplete && !_ecomplete) then { + _waitFor = 70; + _ecomplete = true; + + _uav setVariable ['side', East, true]; + + _eteamrunning setCombatMode "RED"; + _eteamrunning setBehaviour "COMBAT"; + }; + }; + + }; + + if (_resistance == 0 && _waitFor <= 0) then { + if (_west > 0 && isNull(_wteamrunning)) then { + //--- Warn the side that the extraction team is coming. + _wteamname = ['Reaper','Fatman','Anvil'] select (round(random 2)); + ['ExtractionTeam',_wteamname,West] Spawn SideMessage; + + //--- Get a spawn position for the team. + _pos = []; + _attempts = 0; + _size = _markerSize; + while {true} do { + sleep 0.05; + _pos = [_randomPos, _size] Call GetSafePlace; + + _near = _pos nearEntities [['Man','Car','Motorcycle','Ship','Air','Tank','StaticWeapon'],_markerSize/5]; + + if (east countSide _near == 0 && resistance countSide _near == 0) exitWith {}; + _attempts = _attempts + 1; + + if (_attempts > 20) then { + _attempts = 0; + _size = _size + (_markerSize/5); + }; + }; + _wspos = _pos; + _wteamrunning = createGroup west; + + { + _unit = [_x,_wteamrunning,_pos,west] Call CreateMan; + } forEach _wteam; + + (units _wteamrunning) commandMove (getPos _uav); + }; + if (_east > 0 && isNull(_eteamrunning)) then { + //--- Warn the side that the extraction team is coming. + _eteamname = ['Frostbite','Sabre','Hammer'] select (round(random 2)); + ['ExtractionTeam',_eteamname,East] Spawn SideMessage; + + //--- Get a spawn position for the team. + _pos = []; + _size = _markerSize; + while {true} do { + sleep 0.05; + _pos = [_randomPos, _size] Call GetSafePlace; + + _near = _pos nearEntities [['Man','Car','Motorcycle','Ship','Air','Tank','StaticWeapon'],_markerSize/5]; + + if (west countSide _near == 0 && resistance countSide _near == 0) exitWith {}; + _attempts = _attempts + 1; + + if (_attempts > 20) then { + _attempts = 0; + _size = _size + (_markerSize/5); + }; + }; + _espos = _pos; + _eteamrunning = createGroup east; + + { + _unit = [_x,_eteamrunning,_pos,east] Call CreateMan; + } forEach _eteam; + + (units _eteamrunning) commandMove (getPos _uav); + }; + }; + + //--- Mission ends (west). + if (_wcomplete && _waitFor <= 0) then { + //--- if the team is dead, then we're not done yet. + if (count ((units _wteamrunning) Call GetLiveUnits) > 0) then { + _end = true; + _ran = round(random (count(_completeList)-1)); + ['MMissionComplete',_completeListTr select _ran,West,_completeList select _ran] Spawn SideMessage; + ['MMissionFailed','',East] Spawn SideMessage; + + _wteamrunning setCombatMode "YELLOW"; + _wteamrunning setBehaviour "AWARE"; + (units _wteamrunning) commandMove _wspos; + } else { + _wcomplete = false; + }; + }; + //--- Missions ends (east) + if (_ecomplete && _waitFor <= 0) then { + //--- if the team is dead, then we're not done yet. + if (count ((units _eteamrunning) Call GetLiveUnits) > 0) then { + _end = true; + _ran = round(random (count(_completeList)-1)); + ['MMissionComplete',_completeListTr select _ran,East,_completeList select _ran] Spawn SideMessage; + ['MMissionFailed','',West] Spawn SideMessage; + + _eteamrunning setCombatMode "YELLOW"; + _eteamrunning setBehaviour "AWARE"; + (units _eteamrunning) commandMove _espos; + } else { + _ecomplete = false; + }; + }; + + _waitFor = _waitFor - 5; +}; + +//--- Extraction teams removal (West). +if ({alive _x} count (units _wteamrunning) > 0) then { + //--- West. + [_wteamrunning,_wspos] Spawn { + Private ['_startPos','_team']; + _team = _this select 0; + _startPos = _this select 1; + + //--- Relative Infantry wait time. + sleep (((((leader _team) distance _startPos)/(14*1000))*3600)); + + //--- Remove vehicles. + {if !(_x in trashQueu) then {deleteVehicle _x}} forEach (units _team); + + //--- Group hasn't been removed yet. + if !(isNull _team) then {deleteGroup _team}; + }; +}; + +//--- Extraction teams removal (East). +if ({alive _x} count (units _eteamrunning) > 0) then { + //--- East. + [_eteamrunning,_espos] Spawn { + Private ['_startPos','_team']; + _team = _this select 0; + _startPos = _this select 1; + + //--- Relative Infantry wait time. + sleep (((((leader _team) distance _startPos)/(14*1000))*3600)); + + //--- Remove vehicles. + {if !(_x in trashQueu) then {deleteVehicle _x}} forEach (units _team); + + //--- Group hasn't been removed yet. + if !(isNull _team) then {deleteGroup _team}; + }; +}; + +//--- Kill the spawned thread if it still runs. +if !(scriptDone _jipHandler) then {terminate _jipHandler}; +if !(scriptDone _spawnUnits) then {terminate _spawnUnits}; + +//--- Tell the patrolling units (if there's any, to go away and dissapear). +if (({alive _x} count _units) > 0) then { + //--- Clean up. + [_units, _vehicles, _team, [[(_randomPos select 0)+random(_markerSize)-random(_markerSize),(_randomPos select 1)+random(_markerSize)-random(_markerSize)], 250] Call GetSafePlace] Spawn { + Private ['_pos','_team','_units','_vehicles']; + _units = _this select 0; + _vehicles = _this select 1; + _team = _this select 2; + _pos = _this select 3; + + //--- Move. + (_units) commandMove _pos; + + //--- Relative Infantry wait time. + sleep (((((leader _team) distance _pos)/(14*1000))*3600)); + + //--- Remove vehicles. + {if !(_x in trashQueu) then {if (isPlayer (driver _x)) then {emptyQueu = emptyQueu + [_x]} else {deleteVehicle _x}}} forEach _vehicles; + {if !(_x in trashQueu) then {deleteVehicle _x}} forEach _units; + + //--- Group hasn't been removed yet. + if !(isNull _grp) then {deleteGroup _grp}; + }; +}; + +//--- Lift the ignore rule on the uav (garbage protection). +if !(WF_A2_Vanilla) then {ignoreQueu = ignoreQueu - [_uav]}; + +//--- Remove crates if we've generated any. +_craters = nearestObjects [_randomPos, ['CraterLong'], 250]; +{deleteVehicle _x} forEach _craters; +if !(isNull _uav) then {deleteVehicle _uav}; + +//--- Give the 'winning' side an award. +_winner = if (_ecomplete) then {east} else {west}; +WFBE_LocalizeMessage = [_winner,'CLTFNCLOCALIZEMESSAGE',['SecondaryAward','$',1000]]; +publicVariable 'WFBE_LocalizeMessage'; +if (isHostedServer) then {[_winner,'CLTFNCLOCALIZEMESSAGE',['SecondaryAward','$',1000]] Spawn HandlePVF}; + +//--- Wait for the client to end up his sync. +sleep 35; + +//--- Free the mission. +['_WFBE_M_RUNNINGMISSIONS_WEST',('_WFBE_M_RUNNINGMISSIONS_WEST' Call GetNamespace) - 1, true] Call SetNamespace; +['_WFBE_M_RUNNINGMISSIONS_EAST',('_WFBE_M_RUNNINGMISSIONS_EAST' Call GetNamespace) - 1, true] Call SetNamespace; \ No newline at end of file diff --git a/Server/Module/NEURO/NEURO.sqf b/Server/Module/NEURO/NEURO.sqf new file mode 100644 index 0000000..53f7ad2 --- /dev/null +++ b/Server/Module/NEURO/NEURO.sqf @@ -0,0 +1,240 @@ +/* + * Neuro Taxi System by Benny. + * Use the missionNamspace to set a condition for boarding the vehicle (NEURO_TAXI_CONDITION), _x define the vehicle. + * i.e: missionNamespace setVariable["NEURO_TAXI_CONDITION", "isNil {_x getVariable 'WFBE_Taxi_Prohib'}"]; + */ + +NEURO_BE_ClearVehiclePositions = { + { + if (!alive _x || _x distance _this > 900) then {unassignVehicle _x}; + } forEach (assignedCargo _this); + + { + if !(isNull _x) then {if (!alive _x || _x distance _this > 900) then {unassignVehicle _x}}; + } forEach [assignedDriver _this, assignedGunner _this, assignedCommander _this]; +}; + +NEURO_BE_GetVehicleEmptiness = { + Private ["_cargo","_commander","_driver","_gunner","_hasCommander","_hasDriver","_hasGunner","_isFull","_isEmpty","_vehicleCargo"]; + //--- Update the ETAT. + (_this) Call NEURO_BE_ClearVehiclePositions; + + _driver = _this emptyPositions "driver"; + _gunner = _this emptyPositions "gunner"; + _commander = _this emptyPositions "commander"; + _cargo = _this emptyPositions "cargo"; + + _hasDriver = false; + _hasGunner = false; + _hasCommander = false; + _vehicleCargo = count (assignedCargo _this); + if !(isNull(assignedDriver _this)) then {_driver = 0;_hasDriver = true;}; + if !(isNull(assignedGunner _this)) then {_gunner = 0;_hasGunner = true;}; + if !(isNull(assignedCommander _this)) then {_commander = 0;_hasCommander = true;}; + + _cargo = abs (_cargo - _vehicleCargo); + + _isFull = if (_driver == 0 && _gunner == 0 && _commander == 0 && _cargo == 0) then {true} else {false}; + _isEmpty = if (!_hasDriver && !_hasGunner && !_hasCommander) then {true} else {false}; + + [_driver,_gunner,_commander,_cargo,_isFull,_isEmpty] +}; + +NEURO_BE_GetNonAssignedUnits = { + Private ["_list"]; + _list = []; + + { + if (isNull(assignedVehicle _x)) then {_list = _list + [_x]}; + } forEach _this; + + _list +}; + +NEURO_BE_GetSuitableVehicles = { + Private ["_list","_nearest","_process","_side"]; + _nearest = _this select 0; + _side = _this select 1; + + _list = []; + { + if (canMove _x && fuel _x > 0.2 && (side _x) in [civilian, _side]) then { + _process = true; + if !(isNull(driver _x)) then {if (!local(driver _x) || (side driver _x) != _side) then {_process = false}}; + if (!(isNull(assignedDriver _x)) && _process) then {if (!local(assignedDriver _x) || (side assignedDriver _x) != _side) then {_process = false}}; + + if (_process) then { + if (Call Compile (missionNamespace getVariable 'NEURO_TAXI_CONDITION')) then { + _list = _list + [_x]; + }; + }; + + }; + } forEach _nearest; + + _list +}; + +NEURO_BE_GetGroupWPDestination = { + Private ["_destination"]; + _destination = [0,0,0]; + + if (isNull _this) exitWith {_destination}; + + if (count waypoints _this > 0) then { + _destination = waypointPosition [_this, currentWaypoint _this]; + }; + + _destination +}; + +NEURO_BE_GetVehicleZOffset = { + (getPos _this) select 2 +}; + +NEURO_BE_HandleArrivalCargo = { + Private ["_vehicle"]; + _vehicle = vehicle _this; + + //--- Paradrop or unload. + if ((_vehicle) Call NEURO_BE_GetVehicleZOffset > 25) then { + { + if !(surfaceIsWater(getPos _vehicle)) then { + if (alive _x && _vehicle == vehicle _x && local _x) then { + unassignVehicle _x; + [_x] orderGetIn false; + _x action ["EJECT", _vehicle]; + sleep 1.2; + }; + } else { + unassignVehicle _x; + [_x] orderGetIn false; + }; + } forEach (assignedCargo _vehicle); + } else { + { + if (alive _x && _vehicle == vehicle _x && local _x) then { + unassignVehicle _x; + [_x] orderGetIn false; + sleep 0.4; + }; + } forEach (assignedCargo _vehicle); + }; +}; + +NEURO_BE_UpdateTeamDestination = { + Private ["_assignedVehicle","_destinationDriver","_forceOut","_group","_groupDestination"]; + _group = _this; + _forceOut = []; + + _groupDestination = (_group) Call NEURO_BE_GetGroupWPDestination; + + { + _assignedVehicle = assignedVehicle _x; + + if !(isNull _assignedVehicle) then { + if (isNull(driver _assignedVehicle) && isNull(assignedDriver _assignedVehicle) || isPlayer(_assignedVehicle)) then { + _forceOut = _forceOut + [_x]; + } else { + _destinationDriver = (group (driver _assignedVehicle)) Call NEURO_BE_GetGroupWPDestination; + if (_groupDestination distance _destinationDriver > 600) then { + if (_x in (assignedCargo _assignedVehicle)) then {_forceOut = _forceOut + [_x]}; + }; + }; + }; + } forEach (units _group); + + if (count _forceOut > 0) then { + {unassignVehicle _x} forEach _forceOut; + _forceOut orderGetIn false; + }; +}; + +NEURO_BE_AssignToVehicle = { + Private ["_assignedUnits","_cargoEmptiness","_emptiness","_group","_isEmpty","_isFull","_isPlayerVehicle","_near","_position","_process","_range","_unit","_units","_vehicle"]; + _group = _this select 0; + _position = _this select 1; + _range = 500; + + _groupUnits = units _group; + _units = (_groupUnits) Call NEURO_BE_GetNonAssignedUnits; + if (count _units == 0) exitWith {}; + + _near = _position nearEntities [["Motorcycle","Car","Tank","Helicopter"], _range]; + _near = [_near, side _group] Call NEURO_BE_GetSuitableVehicles; + if (count _near == 0) exitWith {}; + + _assignedUnits = []; + + { + _vehicle = _x; + _emptiness = (_vehicle) Call NEURO_BE_GetVehicleEmptiness; + _cargoEmptiness = _emptiness select 3; + + _isFull = if (_emptiness select 4) then {true} else {false}; + _isEmpty = if (_emptiness select 5) then {true} else {false}; + _isPlayerVehicle = if (isPlayer(_vehicle)) then {true} else {false}; + + //--- Vehicle is not full. + if (!_isFull && !_isPlayerVehicle) then { + //--- Driver, Gunner, Commander. + if (_isEmpty || (effectiveCommander _vehicle) in _groupUnits) then { + //--- Driver + if ((_emptiness select 0) > 0) then { + (_units select 0) assignAsDriver _vehicle; + _assignedUnits = _assignedUnits + [_units select 0]; + _units = _units - [_units select 0]; + }; + + //--- Gunner. + if ((_emptiness select 1) > 0 && count _units > 0) then { + (_units select 0) assignAsGunner _vehicle; + _assignedUnits = _assignedUnits + [_units select 0]; + _units = _units - [_units select 0]; + }; + + //--- Commander. + if ((_emptiness select 2) > 0 && count _units > 0) then { + (_units select 0) assignAsCommander _vehicle; + _assignedUnits = _assignedUnits + [_units select 0]; + _units = _units - [_units select 0]; + }; + }; + + //--- Cargo. + if (_cargoEmptiness > 0 && count _units > 0) then { + _count = count _units; + + //--- Make sure that the vehicle is going around the squad's destination. + _process = true; + if !(isNull(driver _vehicle)) then { + _driverMoveTo = (group driver _vehicle) Call NEURO_BE_GetGroupWPDestination; + _distance = _driverMoveTo distance ((_group) Call NEURO_BE_GetGroupWPDestination); + + if (_distance > 600 || (_driverMoveTo select 0 == 0 && _driverMoveTo select 1 == 0)) then {_process = false}; + }; + + //--- All condition are met, the ai may be able to board the vehicle. + if (_process) then { + for '_i' from 0 to _count-1 do { + _unit = _units select _i; + + if (_unit distance _vehicle < 500) then { + _unit assignAsCargo _vehicle; + _assignedUnits = _assignedUnits + [_unit]; + _cargoEmptiness = _cargoEmptiness - 1; + }; + + if (_cargoEmptiness <= 0) exitWith {}; + }; + }; + }; + + _units = _units - _assignedUnits; + }; + + if (count _units == 0) exitWith {}; + } forEach _near; + + if (count _assignedUnits > 0) then {_assignedUnits orderGetIn true}; +}; \ No newline at end of file diff --git a/Server/Module/UPSMON/Init_UPSMON.sqf b/Server/Module/UPSMON/Init_UPSMON.sqf new file mode 100644 index 0000000..b1929a8 --- /dev/null +++ b/Server/Module/UPSMON/Init_UPSMON.sqf @@ -0,0 +1,576 @@ +// ========================================================================================================= +// UPSMON - Urban Patrol Script Mon +// Version: 5.1.0 +// Author: Monsada (chs.monsada@gmail.com) +// +// Wiki: http://dev-heaven.net/projects/upsmon/wiki +// Forum: http://forums.bistudio.com/showthread.php?t=91696 +// Share your missions with upsmon: http://dev-heaven.net/projects/upsmon/boards/86 +// --------------------------------------------------------------------------------------------------------- +// Based on Urban Patrol Script +// Version: 2.0.3 +// Author: Kronzky (www.kronzky.info / kronzky@gmail.com) +// --------------------------------------------------------------------------------------------------------- +// Some little fixes: !Rafalsky (v5.0.8 - 5.0.9) +// --------------------------------------------------------------------------------------------------------- + +//Adding eventhandlers + "KRON_UPS_EAST_SURRENDED" addPublicVariableEventHandler { if (_this select 1) then { nul=[east] execvm "Server\Module\UPSMON\UPSMON\MON_surrended.sqf";};}; + "KRON_UPS_WEST_SURRENDED" addPublicVariableEventHandler { if (_this select 1) then { nul=[west] execvm "Server\Module\UPSMON\UPSMON\MON_surrended.sqf";};}; + "KRON_UPS_GUER_SURRENDED" addPublicVariableEventHandler { if (_this select 1) then { nul=[resistance] execvm "Server\Module\UPSMON\UPSMON\MON_surrended.sqf";};}; + "MON_LOCAL_EXEC" addPublicVariableEventHandler { if (local ((_this select 1)select 0)) then { + call ( compile format[(_this select 1)select 1,(_this select 1)select 0] ); + }; + }; + + +if (!isServer) exitWith {}; + +//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// These Variables should be checked and set as required, to make the mission runs properly. +//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +// ACE Wounds System for AI (set TRUE to On, set FALSE to Off) ! +ace_sys_wounds_noai = false; // set it as required + +//1=Enable or 0=disable debug. In debug could see a mark positioning de leader and another mark of the destination of movement, very useful for editing mission +KRON_UPS_Debug = 0; + +//1=Enable or 0=disable. In game display global chat info about who just killed a civilian. +//numbers of Civilians killed by players could be read from array 'KILLED_CIV_COUNTER' -> [Total,by West,by East,by Res] +R_WHO_IS_CIV_KILLER_INFO = 1; + + +// if you are spotted by AI group, how close the other AI group have to be to You , to be informed about your present position. over this, will lose target +KRON_UPS_sharedist = 600; + +// If enabled IA communication between them with radio defined sharedist distance, 0/2 +// (must be set to 2 in order to use reinforcement !R) +KRON_UPS_comradio = 2; + +//Sides that are enemies of resistance +KRON_UPS_Res_enemy = [east]; + +// Distance from destination for searching vehicles. (Search area is about 200m), +// If your destination point is further than KRON_UPS_searchVehicledist, AI will try to find a vehicle to go there. +KRON_UPS_searchVehicledist = 600; // 700, 900 + +//Enables or disables AI to use static weapons +KRON_UPS_useStatics = true; + +//Enables or disables AI to put mines if armoured enemies near +KRON_UPS_useMines = true; + +//------------------------------------------------------------------------------------------------------------------------------ +// These Variables can be changed if needed but it is not necessary. +//------------------------------------------------------------------------------------------------------------------------------ + +//% of chanse to use smoke by team members when someone wounded or killed in the group in %(default 13 & 35). +// set both to 0 -> to switch off this function +R_USE_SMOKE_wounded = 13; +R_USE_SMOKE_killed = 35; + +//Height that heli will fly this input will be randomised in a 10% +KRON_UPS_flyInHeight = 80; + +//Percentage of units to surrender. +KRON_UPS_EAST_SURRENDER = 0; // 10 +KRON_UPS_WEST_SURRENDER = 0; // 10 +KRON_UPS_GUER_SURRENDER = 0; // 10 + +// knowsAbout 1.03 , 1.49 to add this enemy to "target list" (1-4) the higher number the less detect ability (original in 5.0.7 was 0.5) +// it does not mean the AI will not shoot at you. This mean what must be knowsAbout you to AI start asking by radio for help other groups in KRON_UPS_sharedist from you +R_knowsAboutEnemy = 1.49; + +// units will react (change the beahaviour) when dead bodies found +R_deadBodiesReact = false; // true OR flase + +// --------------------------------------------------------------------------------------------------------------------- +// Better do not change these variables if you aren't sure !R +// --------------------------------------------------------------------------------------------------------------------- + +//Efective distance for doing perfect ambush (max distance is this x2) +KRON_UPS_ambushdist = 70; + +//Max distance to target for doing para-drop, will be randomised between 0 and 100% of this value. +KRON_UPS_paradropdist = 250; + +//Frequency for doing calculations for each squad. +KRON_UPS_Cycle = 10; //org 20 + +//Time that lider wait until doing another movement, this time reduced dynamically under fire, and on new targets +KRON_UPS_react = 60; + +//Min time to wait for doing another reaction +KRON_UPS_minreact = 20; // org 30 + +//Max waiting is the maximum time patrol groups will wait when arrived to target for doing another target. +KRON_UPS_maxwaiting = 30; + +// how long AI units should be in alert mode after initially spotting an enemy +KRON_UPS_alerttime = 90; + +// how far opfors should move away if they're under attack +KRON_UPS_safedist = 250; //org 300 + +// how close unit has to be to target to generate a new one target or to enter stealth mode +KRON_UPS_closeenough = 300; //org 300 + +//Enable it to send reinforcements, better done it in a trigger inside your mission. +KRON_UPS_reinforcement = false; + +//Artillery support, better control if set in trigger +KRON_UPS_ARTILLERY_EAST_FIRE = false; //set to true for doing east to fire +KRON_UPS_ARTILLERY_WEST_FIRE = false; //set to true for doing west to fire +KRON_UPS_ARTILLERY_GUER_FIRE = false; //set to true for doing resistance to fire + +//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Do not touch these variables !!!! !R +//--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + R_GOTHIT_ARRAY =[0]; + AcePresent = isClass(configFile/"CfgPatches"/"ace_main"); + UPSMON_Version = "UPSMON 5.1.0 beta1"; + KILLED_CIV_COUNTER = [0,0,0,0,0]; + KRON_UPS_flankAngle = 45; //Angulo de flanqueo + KRON_UPS_INIT = 0; //Variable que indica que ha sido inicializado + KRON_UPS_EAST_SURRENDED = false; + KRON_UPS_WEST_SURRENDED = false; + KRON_UPS_GUER_SURRENDED = false; + KRON_AllWest=[]; //All west AI + KRON_AllEast=[]; //All east AI + KRON_AllRes=[]; //All resistance AI + KRON_UPS_East_enemies = []; + KRON_UPS_West_enemies = []; + KRON_UPS_Guer_enemies = []; + KRON_UPS_East_friends = []; + KRON_UPS_West_friends = []; + KRON_UPS_Guer_friends = []; + KRON_targets0 =[];//objetivos west + KRON_targets1 =[];//objetivos east + KRON_targets2 =[];//resistence + KRON_targetsPos =[];//Posiciones de destino actuales. + KRON_NPCs = []; //Lideres de los grupos actuales + KRON_UPS_Instances=0; + KRON_UPS_Total=0; + KRON_UPS_Exited=0; + KRON_UPS_East_Total = 0; + KRON_UPS_West_Total = 0; + KRON_UPS_Guer_Total = 0; + KRON_UPS_ARTILLERY_UNITS = []; + KRON_UPS_ARTILLERY_WEST_TARGET = objnull; + KRON_UPS_ARTILLERY_EAST_TARGET = objnull; + KRON_UPS_ARTILLERY_GUER_TARGET = objnull; + KRON_UPS_TEMPLATES = []; + KRON_UPS_MG_WEAPONS = ["MG36","M249","M240","MK_48","PK","PKm","Pecheneg","M249 Para","M249 Para M145","M240G M145","M60"]; + + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + // ***************************************** SERVER INITIALIZATION ***************************************** + if (isNil("KRON_UPS_INIT") || KRON_UPS_INIT == 0) then { + + //Init library function, Required Version: 5.0 of mon_functions + call compile preprocessFileLineNumbers "Server\Module\UPSMON\UPSMON\common\MON_functions.sqf"; + + //init !R functions + call compile preprocessFileLineNumbers "Server\Module\UPSMON\UPSMON\!R\R_functions.sqf"; + + if (isNil "RE") then {[] execVM "\ca\Modules\MP\data\scripts\MPframework.sqf"}; + + //scripts initialization + UPSMON = compile preprocessFile "Server\Module\UPSMON\UPSMON.sqf"; + UPSMON_surrended = compile preprocessFile "Server\Module\UPSMON\UPSMON\MON_surrended.sqf"; + + // declaración de variables privadas + private["_obj","_trg","_l","_pos"]; + + // global functions + KRON_randomPos = {private["_cx","_cy","_rx","_ry","_cd","_sd","_ad","_tx","_ty","_xout","_yout"];_cx=_this select 0; _cy=_this select 1; _rx=_this select 2; _ry=_this select 3; _cd=_this select 4; _sd=_this select 5; _ad=_this select 6; _tx=random (_rx*2)-_rx; _ty=random (_ry*2)-_ry; _xout=if (_ad!=0) then {_cx+ (_cd*_tx - _sd*_ty)} else {_cx+_tx}; _yout=if (_ad!=0) then {_cy+ (_sd*_tx + _cd*_ty)} else {_cy+_ty}; [_xout,_yout]}; + KRON_PosInfo = {private["_pos","_lst","_bld","_bldpos"];_pos=_this select 0; _lst=_pos nearObjects ["House",12]; if (count _lst==0) then {_bld=0;_bldpos=0} else {_bld=_lst select 0; _bldpos=[_bld] call KRON_BldPos}; [_bld,_bldpos]}; + KRON_PosInfo3 = {private["_pos","_lst","_bld","_bldpos"];_pos=_this select 0; _lst= nearestObjects [_pos, [], 3]; + if (count _lst==0) then {_bld=objnull;_bldpos=0} else {_bld = nearestbuilding (_lst select 0); + _bldpos=[_bld] call KRON_BldPos2}; [_bld,_bldpos]}; + KRON_BldPos = {private ["_bld","_bldpos","_posZ","_maxZ"];_bld=_this select 0;_maxZ=0;_bi=0;_bldpos=0;while {_bi>=0} do {if (((_bld BuildingPos _bi) select 0)==0) then {_bi=-99} else {_bz=((_bld BuildingPos _bi) select 2); if (((_bz)>4) && ((_bz>_maxZ) || ((_bz==_maxZ) && (random 1>.8)))) then {_maxZ=_bz; _bldpos=_bi}};_bi=_bi+1};_bldpos}; + KRON_BldPos2 = {private ["_bld","_bldpos"]; + _bld=_this select 0; _bldpos = 1; + while {format ["%1", _bld buildingPos _bldpos] != "[0,0,0]"} do {_bldpos = _bldpos + 1;}; + _bldpos = _bldpos - 1; _bldpos;}; + + + KRON_getDirPos = {private["_a","_b","_from","_to","_return"]; _from = _this select 0; _to = _this select 1; _return = 0; _a = ((_to select 0) - (_from select 0)); _b = ((_to select 1) - (_from select 1)); if (_a != 0 || _b != 0) then {_return = _a atan2 _b}; if ( _return < 0 ) then { _return = _return + 360 }; _return}; + KRON_distancePosSqr = {round(((((_this select 0) select 0)-((_this select 1) select 0))^2 + (((_this select 0) select 1)-((_this select 1) select 1))^2)^0.5)}; + KRON_relPos = {private["_p","_d","_a","_x","_y","_xout","_yout"];_p=_this select 0; _x=_p select 0; _y=_p select 1; _d=_this select 1; _a=_this select 2; _xout=_x + sin(_a)*_d; _yout=_y + cos(_a)*_d;[_xout,_yout,0]}; + KRON_rotpoint = {private["_cp","_a","_tx","_ty","_cd","_sd","_cx","_cy","_xout","_yout"];_cp=_this select 0; _cx=_cp select 0; _cy=_cp select 1; _a=_this select 1; _cd=cos(_a*-1); _sd=sin(_a*-1); _tx=_this select 2; _ty=_this select 3; _xout=if (_a!=0) then {_cx+ (_cd*_tx - _sd*_ty)} else {_cx+_tx}; _yout=if (_a!=0) then {_cy+ (_sd*_tx + _cd*_ty)} else {_cy+_ty}; [_xout,_yout,0]}; + KRON_stayInside = { + private["_np","_nx","_ny","_cp","_cx","_cy","_rx","_ry","_d","_tp","_tx","_ty","_fx","_fy"]; + _np=_this select 0; _nx=_np select 0; _ny=_np select 1; + _cp=_this select 1; _cx=_cp select 0; _cy=_cp select 1; + _rx=_this select 2; _ry=_this select 3; _d=_this select 4; + _tp = [_cp,_d,(_nx-_cx),(_ny-_cy)] call KRON_rotpoint; + _tx = _tp select 0; _fx=_tx; + _ty = _tp select 1; _fy=_ty; + if (_tx<(_cx-_rx)) then {_fx=_cx-_rx}; + if (_tx>(_cx+_rx)) then {_fx=_cx+_rx}; + if (_ty<(_cy-_ry)) then {_fy=_cy-_ry}; + if (_ty>(_cy+_ry)) then {_fy=_cy+_ry}; + if ((_fx!=_tx) || (_fy!=_ty)) then {_np = [_cp,_d*-1,(_fx-_cx),(_fy-_cy)] call KRON_rotpoint}; + _np; + }; + // Misc + KRON_UPSgetArg = {private["_cmd","_arg","_list","_a","_v"]; _cmd=_this select 0; _arg=_this select 1; _list=_this select 2; _a=-1; {_a=_a+1; _v=format["%1",_list select _a]; if (_v==_cmd) then {_arg=(_list select _a+1)}} foreach _list; _arg}; + KRON_UPSsetArg = {private["_cmd","_arg","_list","_a","_v"]; + _cmd=_this select 0; + _arg=_this select 1; + _list=_this select 2; + _a=-1; + { + _a=_a+1; + _v= format ["%1", _list select _a]; + if (_v==_cmd) then { + _a=_a+1; + _list set [_a,_arg]; + }; + } foreach _list; + _list}; + KRON_deleteDead = {private["_u","_s"];_u=_this select 0; _s= _this select 1; _u removeAllEventHandlers "killed"; sleep _s; deletevehicle _u}; + + + + + + // *********************************************************************************************************** + // MAIN UPSMON SERVER FUNCTION + // *********************************************************************************************************** + MON_MAIN_server = { + + private["_obj","_trg","_l","_pos","_countWestSur","_countEastSur","_countResSur","_WestSur","_EastSur","_ResSur","_target","_targets","_targets0","_targets1","_targets2","_npc","_cycle" + ,"_arti","_side","_range","_rounds","_area","_maxcadence","_mincadence","_bullet","_fire","_knownpos","_sharedenemy","_enemyside","_timeout"]; + _cycle = 10; //Time to do a call to commander + _arti = objnull; + _side = ""; + _range = 0; + _rounds = 0; + _area = 0; + _maxcadence = 0; + _mincadence = 0; + _bullet = ""; + _fire = false; + _target = objnull; + _knownpos =[0,0,0]; + _enemyside = []; + + _WestSur = KRON_UPS_WEST_SURRENDED; + _EastSur = KRON_UPS_EAST_SURRENDED; + _ResSur = KRON_UPS_GUER_SURRENDED; + + + //Main loop + while {true} do + { + _countWestSur = round ( KRON_UPS_West_Total * KRON_UPS_WEST_SURRENDER / 100); + _countEastSur = round ( KRON_UPS_East_Total * KRON_UPS_EAST_SURRENDER / 100); + _countResSur = round ( KRON_UPS_Guer_Total * KRON_UPS_GUER_SURRENDER / 100); + + //Checks for WEST surrender + if (KRON_UPS_WEST_SURRENDER > 0 && !KRON_UPS_WEST_SURRENDED ) then { + { + if (!alive _x || !canmove _x) then {KRON_AllWest = KRON_AllWest-[_x]}; + }foreach KRON_AllWest; + + if ( count KRON_AllWest <= _countWestSur ) then { + KRON_UPS_WEST_SURRENDED = true; + publicvariable "KRON_AllWest"; + publicvariable "KRON_UPS_WEST_SURRENDED"; + }; + }; + + //Checks for EAST surrender + if (KRON_UPS_EAST_SURRENDER > 0 && !KRON_UPS_EAST_SURRENDED ) then { + { + if (!alive _x || !canmove _x) then {KRON_AllEast = KRON_AllEast-[_x]}; + }foreach KRON_AllEast; + + if ( count KRON_AllEast <= _countEastSur ) then { + KRON_UPS_EAST_SURRENDED = true; + publicvariable "KRON_AllEast"; + publicvariable "KRON_UPS_EAST_SURRENDED"; + }; + }; + + //Checks for RESISTANCE surrender + if (KRON_UPS_GUER_SURRENDER > 0 && !KRON_UPS_GUER_SURRENDED ) then { + { + if (!alive _x || !canmove _x) then {KRON_AllRes = KRON_AllRes-[_x]}; + }foreach KRON_AllRes; + + if ( count KRON_AllRes <= _countResSur ) then { + KRON_UPS_GUER_SURRENDED = true; + publicvariable "KRON_AllRes"; + publicvariable "KRON_UPS_GUER_SURRENDED"; + }; + }; + + //Exec surrended script + if (KRON_UPS_WEST_SURRENDED && !_WestSur ) then { + _WestSur = true; + [west] spawn UPSMON_surrended; + }; + if (KRON_UPS_EAST_SURRENDED && !_EastSur ) then { + _EastSur = true; + [east] spawn UPSMON_surrended; + }; + if (KRON_UPS_GUER_SURRENDED && !_ResSur ) then { + _ResSur = true; + [Resistance] spawn UPSMON_surrended; + }; + sleep 0.5; + + _sharedenemy = 0; + _targets0 = []; + _targets1 = []; + _targets2 = []; + { + if (!isnull _x && alive _x && !captive _x ) then { + _npc = _x; + _targets = []; + + switch (side _npc) do { + //West targets + case west: { + _sharedenemy = 0; + _enemyside = [east]; + }; + //East targets + case east: { + _sharedenemy = 1; + _enemyside = [west]; + }; + //Resistance targets + case resistance: { + _sharedenemy = 2; + _enemyside = KRON_UPS_Res_enemy; + }; + }; + + if (side _npc in KRON_UPS_Res_enemy) then { + _enemyside = _enemyside + [resistance]; + }; + + //Gets known targets on each leader for comunicating enemy position + //Has better performance with targetsquery + //_targets = _npc nearTargets KRON_UPS_sharedist; + _targets = _npc targetsQuery ["","","","",""]; + + { + //_target = _x select 4; //Neartargets + _target = _x select 1; //Targetsquery + if ( side _target in _enemyside ) then { + // if (KRON_UPS_Debug>0) then {player globalchat format["%1: knows about %2, enemies=%3",_npc getVariable ("UPSMON_grpid"),_npc knowsabout _target, _npc countEnemy _targets ]}; + + if (!isnull _target && alive _target && canmove _target && !captive _target && _npc knowsabout _target > R_knowsAboutEnemy + && ( _target iskindof "Land" || _target iskindof "Air" || _target iskindof "Ship" ) + && !( _target iskindof "Animal") + && ( _target emptyPositions "Gunner" == 0 && _target emptyPositions "Driver" == 0 + || (!isnull (gunner _target) && canmove (gunner _target)) + || (!isnull (driver _target) && canmove (driver _target))) + ) then { + //Saves last known position + //_knownpos = _x select 0; //Neartargets + _knownpos = _x select 4;//Targetsquery + _target setvariable ["UPSMON_lastknownpos", _knownpos, false]; + // _npc setVariable ["R_knowsAboutTarget", true, false]; // !R + + call (compile format ["_targets%1 = _targets%1 - [_target]",_sharedenemy]); + call (compile format ["_targets%1 = _targets%1 + [_target]",_sharedenemy]); + }; + }; + sleep 0.01; + } foreach _targets; + }; + sleep 0.01; + }foreach KRON_NPCs; + + //Share targets + KRON_targets0 = _targets0; + KRON_targets1 = _targets1; + KRON_targets2 = _targets2; + + //Target debug console + if (KRON_UPS_Debug>0) then {hintsilent parseText format["%1
--------------------------
West(A=%2 C=%3 T=%4)
East(A=%5 C=%6 T=%7)
Res(A=%8 C=%9 T=%10)
" + ,UPSMON_Version + ,KRON_UPS_West_Total, count KRON_AllWest, count KRON_targets0 + ,KRON_UPS_East_Total, count KRON_AllEast, count KRON_targets1 + ,KRON_UPS_Guer_Total, count KRON_AllRes, count KRON_targets2 ]}; + sleep 0.5; + + //Artillery module control + { + _arti = _x select 0; + _rounds = _x select 1; + _range = _x select 2; + _area = _x select 3; + _maxcadence = _x select 4; + _mincadence = _x select 5; + _bullet = _x select 6; + _salvobreak = _x select 7; + + if (isnil{_arti getVariable ("timeout")}) then { + _arti setVariable ["timeout", time, false]; + sleep 0.1; + }; + + _timeout = _arti getVariable ("timeout"); + + if (!isnull (gunner _arti) && canmove (gunner _arti) && (time >= _timeout)) then { + _side = side gunner _arti; + _fire = call (compile format ["KRON_UPS_ARTILLERY_%1_FIRE",_side]); + + + + //If fire enabled gets a known target pos for doing fire if no friendly squads near. + if (_fire) then { + _target = call (compile format ["KRON_UPS_ARTILLERY_%1_TARGET",_side]); + if (isnil "_target" ) then {_target = objnull;}; + + switch (_side) do { + //West targets + case west: { + _targets = KRON_targets0; + }; + //East targets + case east: { + _targets = KRON_targets1; + }; + //Resistance targets + case resistance: { + _targets = KRON_targets2; + }; + }; + + //Check if has a target + if (!(_target in _targets ) || isnull _target || !alive _target) then { + _target = objnull; + { + _auxtarget = _x; + _targetPos = _auxtarget getvariable ("UPSMON_lastknownpos"); + if (!isnil "_targetPos") then { + //If target in range check no friendly squad near + if (alive _auxtarget && !(_auxtarget iskindof "Air") && (round([position _arti,_targetPos] call KRON_distancePosSqr)) <= _range) then { + _target = _auxtarget; + //Must check if no friendly squad near fire position + { + if (!isnull _x && _side == side _x) then { + if ((round([position _x,_targetPos] call KRON_distancePosSqr)) < (KRON_UPS_safedist * 0.7)) exitwith {_target = objnull;}; + }; + } foreach KRON_NPCs; + }; + }; + + //If target found exit + if (!isnull _target) exitwith {}; + } foreach _targets; + }; + + //If target fires artillery + if (!isnull _target) then { + //Fix current target + call (compile format ["KRON_UPS_ARTILLERY_%1_TARGET = _target",_side]); + _targetPos = _target getvariable ("UPSMON_lastknownpos"); + if (!isnil "_targetPos") then { + + _arti removeAllEventHandlers "fired"; sleep 0.01; + // chatch the bullet in the air and delete it + _arti addeventhandler["fired", {deletevehicle (nearestobject[_this select 0, _this select 4])}]; + [_arti,_targetPos,_rounds,_area,_maxcadence,_mincadence,_bullet,_salvobreak] spawn MON_artillery_dofire; + }; + }; + }; + }; + sleep 0.5; + } foreach KRON_UPS_ARTILLERY_UNITS; + + + // if (KRON_UPS_Debug>0) then {player globalchat format["Init_upsmon artillery=%1",count KRON_UPS_ARTILLERY_UNITS]}; + sleep _cycle; + }; + }; + }; + + +// *********************************************************************************************************** +// INITIALIZATION OF UPSMON +// *********************************************************************************************************** + + _l = allunits + vehicles; + { + if ((_x iskindof "AllVehicles") && (side _x != civilian)) then { + _s = side _x; + switch (_s) do { + case west: + { KRON_AllWest=KRON_AllWest+[_x]; }; + case east: + { KRON_AllEast=KRON_AllEast+[_x]; }; + case resistance: + { KRON_AllRes=KRON_AllRes+[_x]; }; + }; + }; + } forEach _l; + _l = nil; + + if (isNil("KRON_UPS_Debug")) then {KRON_UPS_Debug=0}; + + KRON_UPS_East_enemies = KRON_AllWest; + KRON_UPS_West_enemies = KRON_AllEast; + + if (east in KRON_UPS_Res_enemy ) then { + KRON_UPS_East_enemies = KRON_UPS_East_enemies+KRON_AllRes; + KRON_UPS_Guer_enemies = KRON_AllEast; + } else { + KRON_UPS_East_friends = KRON_UPS_East_friends+KRON_AllRes; + KRON_UPS_Guer_friends = KRON_AllEast; + }; + + if (west in KRON_UPS_Res_enemy ) then { + KRON_UPS_West_enemies = KRON_UPS_West_enemies+KRON_AllRes; + KRON_UPS_Guer_enemies = KRON_UPS_Guer_enemies+KRON_AllWest; + } else { + KRON_UPS_West_friends = KRON_UPS_West_friends+KRON_AllRes; + KRON_UPS_Guer_friends = KRON_UPS_Guer_friends+KRON_AllWest; + }; + + KRON_UPS_West_Total = count KRON_AllWest; + KRON_UPS_East_Total = count KRON_AllEast; + KRON_UPS_Guer_Total = count KRON_AllRes; + + //Initialization done + KRON_UPS_INIT=1; + + + //killciv EH + _l = allunits; + { + if (side _x == civilian) then { + + + _x AddEventHandler ["firedNear", {nul = _this spawn R_SN_EHFIREDNEAR}]; + sleep 0.01; + + + _x AddEventHandler ["killed", {nul = _this spawn R_SN_EHKILLEDCIV}]; + sleep 0.01; + }; + } forEach _l; + _l = nil; + + + + +// --------------------------------------------------------------------------------------------------------- +processInitCommands; + +//Executes de main process of server +[] SPAWN MON_MAIN_server; + +diag_log "--------------------------------"; +diag_log (format["UPSMON started"]); +if(true) exitWith {}; \ No newline at end of file diff --git a/Server/Module/UPSMON/UPSMON.sqf b/Server/Module/UPSMON/UPSMON.sqf new file mode 100644 index 0000000..af4860b --- /dev/null +++ b/Server/Module/UPSMON/UPSMON.sqf @@ -0,0 +1,2575 @@ +// ========================================================================================================= +// UPSMON - Urban Patrol Script +// version 5.1.0 beta 1 +// +// Author: Monsada (chs.monsada@gmail.com) +// Comunidad Hispana de Simulación: +// +// Wiki: http://dev-heaven.net/projects/upsmon/wiki +// Forum: http://forums.bistudio.com/showthread.php?t=91696 +// Share your missions with upsmon: http://dev-heaven.net/projects/upsmon/boards/86 +// --------------------------------------------------------------------------------------------------------- +// Based on Urban Patrol Script v2.0.3 +// Author: Kronzky (www.kronzky.info / kronzky@gmail.com) +// --------------------------------------------------------------------------------------------------------- +// Some little fixes: !Rafalsky (v5.0.8 - 5.1.0) +// Code improvements: shay_gman(Artillery), Nordin("noveh") +// --------------------------------------------------------------------------------------------------------- + +// Required parameters: +// unit = Unit to patrol area (1st argument) +// markername = Name of marker that covers the active area. (2nd argument) +// +// Patrol squad samples: (put in the leader's init field) +// nul=[this,"area0"] execVM "scripts\upsmon.sqf"; +// +// Defensive squad samples: +// nul=[this,"area0","nomove"] execVM "scripts\upsmon.sqf"; +// +// Reinforcement +// nul=[this,"area0","reinforcement:",1] execVM "scripts\UPSMON.sqf"; +// (in trigger call: KRON_UPS_reinforcement1 = true; +// (call pos marker mkr1): KRON_UPS_reinforcement1_pos = getMarkerPos "mkr1"; +// +// +// Optional parameters: _ +// random = Place unit at random start position. +// randomdn = Only use random positions on ground level. +// randomup = Only use random positions at top building positions. +// min:n/max:n = Create a random number (between min and max) of 'clones'. ("min:",2,"max:",5) +// init:string = Custom init string for created clones. +// nomove = Unit will stay or hide in the near buildings until enemy is spotted. +// nofollow = Unit will only follow an enemy within the marker area.(When fight sometimes can go outside) +// onroad = Unit will get target destination only on the roads +// nosmoke = Units will not use smoke when s/o wounded or die. +// delete:n = Delete dead units after 'n' seconds. +// nowait = Do not wait at patrol end points. +// noslow = Keep default behaviour of unit (don't change to "safe" and "limited"). +// noai = Don't use enhanced AI for evasive and flanking maneuvers. +// trigger = Display a message when no more units are left in sector. +// empty:n = Consider area empty, even if 'n' units are left. +// reinforcement = Makes squad as reinforcement, when alarm KRON_UPS_reinforcement==true this squad will go where enemy were. +// reinforcement:x = Makes squad as reinforcement id, when alarm KRON_UPS_reinforcementx==true this squad will go where enemy were. +// fortify = makes leader order to take positions on nearly buildings at distance 200 meters, squad fortified moves less than "nomove" +// aware,combat,stealth,careless defines default behaviour of squad +// noveh = the group will not search for transport vehicles (unless in fight and only combat vehicles) +// nowp = No waypoints will be created for this squad UNTIL ENEMY DETECTED, this squad will comunicate enemies but will not be moved by UPSMON until enemy detected, after that upsmon takes control of squad +// nowp2 = No waypoints will be created for this squad UNTIL ENEMY DETECTED and damaged, this squad will comunicate enemies but will not be moved by UPSMON until enemy detected and damaged, after that upsmon takes control of squad +// nowp3 = No waypoints will be created for this squad in any way, this squad will comunicate enemies but will not be moved by UPSMON. +// ambush = Ambush squad will not move until in combat, will lay mines if enabled and wait for incoming enemies stealth and ambush when near or discovered. +// ambush2 = Ambush squad will not move until in combat, will NOT LAY MINES and wait for incoming enemies stealth and ambush when near or discovered. +// ambush:n = Creates an anbush and wait maximun the especified time n in seconds. you can put 0 seconds for putting mines and go away if combined with "move" for example +// ambush2:n = Same as ambush:n but without laying mines. +// respawn = allow squad to respawn when all members are dead and no targets near +// respawn:x = allows to define the number of times squad may respawn. +// showmarker = Display the area marker. +// track = Display a position and destination marker for each unit. + +// spawned = use only with squads created in runtime, this feature will add squad to UPSMON correctly. +// aware,combat,stealth,careless defines default behaviour of squad + +// numbers of Civilians killed by players could be read from the array 'KILLED_CIV_COUNTER' -> [Total, by West, by East, by Res, The Killer] + + +if (!isServer) exitWith {}; + + +if (isNil("KRON_UPS_INIT")) then { + KRON_UPS_INIT=0; +}; + +waitUntil {KRON_UPS_INIT==1}; + +// convert argument list to uppercase + _UCthis = []; + for [{_i=0},{_i0) then {player sidechat format["%1: New instance %2 %3 %4",_grpidx,_npc getVariable ("UPSMON_grpid")]}; + + + + + + + +// == get the name of area marker ============================================== + _areamarker = _this select 1; + if (isNil ("_areamarker")) exitWith { + hint "UPS: Area marker not defined.\n(Typo, or name not enclosed in quotation marks?)"; + }; + + // remember center position of area marker + _centerpos = getMarkerPos _areamarker; + _centerX = abs(_centerpos select 0); + _centerY = abs(_centerpos select 1); + _centerpos = [_centerX,_centerY]; + + // show/hide area marker + _showmarker = if ("SHOWMARKER" in _UCthis) then {"SHOWMARKER"} else {"HIDEMARKER"}; + if (_showmarker=="HIDEMARKER") then { + //_areamarker setMarkerCondition "false"; // VBS2 + _areamarker setMarkerPos [-abs(_centerX),-abs(_centerY)]; + }; + +// is anybody alive in the group? + _exit = true; + if (typename _npc=="OBJECT") then { + if (!isnull group _npc) then { + _npc = [_npc,units (group _npc)] call MON_getleader; + }else{ + _vehicles = [_npc,2] call MON_nearestSoldiers; + if (count _vehicles>0) then { + _npc = [_vehicles select 0,units (_vehicles select 0)] call MON_getleader; + }; + }; + } else { + if (count _obj>0) then { + _npc = [_obj,count _obj] call MON_getleader; + }; + }; + + + // set the leader in the vehilce + if (!(_npc iskindof "Man")) then { + if (!isnull(commander _npc) ) then { + _npc = commander _npc; + }else{ + if (!isnull(driver _npc) ) then { + _npc = driver _npc; + }else{ + _npc = gunner _npc; + }; + }; + group _npc selectLeader _npc; + }; + +// =============================================== + if (alive _npc) then {_exit = false;}; + if (KRON_UPS_Debug>0 && _exit) then {player sidechat format["%1 There is no alive members %1 %2 %3",_grpidx,typename _npc,typeof _npc, count units _npc]}; + + + // exit if something went wrong during initialization (or if unit is on roof) + if (_exit) exitWith { + if (KRON_UPS_DEBUG>0) then {hint "Initialization aborted"}; + }; + + + +// remember the original group members, so we can later find a new leader, in case he dies + _members = units _npc; + KRON_UPS_Total = KRON_UPS_Total + (count _members); + +//Fills member soldier types + _vehicles = []; + { + if (vehicle _x != _x ) then { + _vehicles = _vehicles - [vehicle _x]; + _vehicles = _vehicles + [vehicle _x]; + }; + _membertypes = _membertypes + [typeof _x]; + } foreach _members; + +//Fills member vehicle types + { + _vehicletypes = _vehicletypes + [typeof _x]; + } foreach _vehicles; + +// what type of "vehicle" is _npc ? + _isman = "Man" countType [ vehicle _npc]>0; + _iscar = "LandVehicle" countType [vehicle _npc]>0; + _isboat = "Ship" countType [vehicle _npc]>0; + _isplane = "Air" countType [vehicle _npc]>0; + +// we just have to brute-force it for now, and declare *everyone* an enemy who isn't a civilian + _isSoldier = _side != civilian; + + _friends=[]; + _enemies=[]; + _sharedenemy=0; + + if (_isSoldier) then { + switch (_side) do { + case west: + { _sharedenemy=0; + _friendside = [west]; + _enemyside = [east]; + }; + case east: + { _sharedenemy=1; + _friendside = [east]; + _enemyside = [west]; + }; + case resistance: + { + _sharedenemy=2; + _enemyside = KRON_UPS_Res_enemy; + + if (!(east in _enemyside)) then { + _friendside = [east]; + }; + if (!(west in _enemyside)) then { + _friendside = [west]; + }; + }; + }; + }; + + if (_side in KRON_UPS_Res_enemy) then { + _enemyside = _enemyside + [resistance]; + }else { + _friendside = _friendside + [resistance]; + }; + sleep .05; + +//Sets min units alive for surrender + _surrender = call (compile format ["KRON_UPS_%1_SURRENDER",_side]); + + + + // Tanks friendlys are contabiliced +{ + if ( side _x in _friendside && ( _x iskindof "Tank" || _x iskindof "Wheeled_APC" )) then { + _friendlytanks = _friendlytanks + [_x]; + }; +}foreach vehicles; + +// global unit variable to externally influence script +//call compile format ["KRON_UPS_%1=1",_npcname]; + +// X/Y range of target area +_areasize = getMarkerSize _areamarker; +_rangeX = _areasize select 0; +_rangeY = _areasize select 1; +_area = abs((_rangeX * _rangeY) ^ 0.5); +// marker orientation (needed as negative value!) +_areadir = (markerDir _areamarker) * -1; + + +// store some trig calculations +_cosdir=cos(_areadir); +_sindir=sin(_areadir); + +// minimum distance of new target position +_mindist=(_rangeX^2+_rangeY^2)/3; +if (_rangeX==0) exitWith { + hint format["UPS: Cannot patrol Sector: %1\nArea Marker doesn't exist",_areamarker]; +}; + +// remember the original mode & speed +_orgMode = behaviour _npc; +_orgSpeed = speedmode _npc; + +// set first target to current position (so we'll generate a new one right away) +_currPos = getpos _npc; +_orgPos = _currPos; +_orgDir = getDir _npc; +_orgWatch=[_currPos,50,_orgDir] call KRON_relPos; +_lastpos = _currPos; + +_avoidPos = [0,0]; +_flankPos = [0,0]; +_attackPos = [0,0]; +_newattackPos = [0,0]; +_fixedtargetpos = [0,0]; +_frontPos = [0,0]; +_dirf1 = 0;_dirf2=0;_flankPos2=[0,0]; +_dist = 10000; +_lastdist = 0; +_lastmove1 = 0; +_lastmove2 = 0; +_maxmove=0; +_moved=0; + +_damm=0; +_dammchg=0; +_lastdamm = 0; +_timeontarget = 0; + +_fightmode = "walk"; +_fm=0; +_gothit = false; +_pursue = false; +_hitPos=[0,0,0]; +_react = 0; +_lastknown = 0; +_opfknowval = 0; + +_sin0=1; +_sin90=1; _cos90=0; +_sin270=-1; _cos270=0; +_targetX =0; _targetY=0; +_relTX=0;_relTY=0; +_relUX=0;_relUY=0; +_supressed = false; +_flankdist=0; +_nBuilding=nil; +_nBuildingt =nil; +_speedmode="Limited"; +_distnbuid = 0; +_distnbuidt = 0; +_objsflankPos1 = []; +_cntobjs1 = 0; +_objsflankPos2 = []; +_cntobjs2 = 0; +_targettext =""; +_dir1 =0;_dir2=0;_dir3=0;_dd=0; +_timeontarget=0; +_reinforcement =""; +_reinforcementsent = false; +_target = objnull; +_newtarget=objnull; +_flankdir=0; //1 tendencia a flankpos1, 2 tendencia a flankpos2 +_prov=0; +_targets=[]; +_planta=0; //Indice de plantas en edificios +_newflankAngle = 0; +_closeenough = KRON_UPS_closeenough; +_gunner = objnull; +_driver = objnull; +_fortify = false; +_buildingdist= 60;//Distance to search buildings near +_Behaviour = "SAFE"; +_grp = grpnull; +_grp = group _npc; +_template = 0; +_nowpType = 1; +_ambushtype = 1; +_rstuckControl = 0; +_makenewtarget=true; + + + +// set target tolerance high for choppers & planes +if (_isplane) then {_closeenough = KRON_UPS_closeenough * 2}; + +// ***************************************** optional arguments ***************************************** + +// wait at patrol end points +_pause = if ("NOWAIT" in _UCthis) then {"NOWAIT"} else {"WAIT"}; +// don't move until an enemy is spotted +_nomove = if ("NOMOVE" in _UCthis) then {"NOMOVE"} else {"MOVE"}; + +//fortify group in near places + _fortify= if ("FORTIFY" in _UCthis) then {true} else {false}; + _fortifyorig = _fortify; + if (_fortify) then { + _nomove="NOMOVE"; + _minreact = KRON_UPS_minreact * 3; + _buildingdist = _buildingdist * 2; + _makenewtarget = false; + _wait = 3000; + }; + +// create _targerpoint on the roads only (by this group) + _onroad = if ("ONROAD" in _UCthis) then {true} else {false}; +// do not use smoke (by this group) + _nosmoke = if ("NOSMOKE" in _UCthis) then {true} else {false}; +// do not search for vehicles (unless in fight and combat vehicles) +_noveh = if ("NOVEH" in _UCthis) then {true} else {false}; + + + +// don't make waypoints + _nowp = if ("NOWP" in _UCthis) then {true} else {false}; + _nowp = if ("NOWP2" in _UCthis) then {true} else {_nowp}; + _nowp = if ("NOWP3" in _UCthis) then {true} else {_nowp}; + _nowpType = if ("NOWP2" in _UCthis) then {2} else {_nowpType}; + _nowpType = if ("NOWP3" in _UCthis) then {3} else {_nowpType}; + +//Ambush squad will no move until in combat or so close enemy + _ambush= if ("AMBUSH" in _UCthis) then {true} else {false}; + _ambush= if ("AMBUSH:" in _UCthis) then {true} else {_ambush}; + _ambush= if ("AMBUSH2" in _UCthis) then {true} else {_ambush}; + _ambushwait = ["AMBUSH:",_ambushwait,_UCthis] call KRON_UPSgetArg; + _ambushwait = ["AMBUSH2:",_ambushwait,_UCthis] call KRON_UPSgetArg; + _ambushType = if ("AMBUSH2" in _UCthis) then {2} else {_ambushType}; + _ambushType = if ("AMBUSH2:" in _UCthis) then {2} else {_ambushType}; + +// respawn + _respawn = if ("RESPAWN" in _UCthis) then {true} else {false}; + _respawn = if ("RESPAWN:" in _UCthis) then {true} else {_respawn}; + _respawnmax = ["RESPAWN:",_respawnmax,_UCthis] call KRON_UPSgetArg; + if (!_respawn) then {_respawnmax = 0}; + +// any init strings? + _initstr = ["INIT:","",_UCthis] call KRON_UPSgetArg; + +// don't follow outside of marker area + _nofollow = if ("NOFOLLOW" in _UCthis) then {"NOFOLLOW"} else {"FOLLOW"}; +// share enemy info + _shareinfo = if ("NOSHARE" in _UCthis) then {"NOSHARE"} else {"SHARE"}; +// "area cleared" trigger activator + _areatrigger = if ("TRIGGER" in _UCthis) then {"TRIGGER"} else {if ("NOTRIGGER" in _UCthis) then {"NOTRIGGER"} else {"SILENTTRIGGER"}}; + + // suppress fight behaviour + if ("NOAI" in _UCthis) then {_isSoldier=false}; + + // adjust cycle delay + _cycle = ["CYCLE:",KRON_UPS_Cycle,_UCthis] call KRON_UPSgetArg; + _currcycle=_cycle; + + //spawned for squads created in runtime + _spawned= if ("SPAWNED" in _UCthis) then {true} else {false}; + if (_spawned) then { + if (KRON_UPS_Debug>0) then {player sidechat format["%1: squad has been spawned, respawns %2",_grpidx,_respawnmax]}; + switch (side _npc) do { + case west: + { KRON_AllWest=KRON_AllWest + units _npc; + }; + case east: + { KRON_AllEast=KRON_AllEast + units _npc; }; + case resistance: + { + KRON_AllRes=KRON_AllRes + units _npc; + if (east in KRON_UPS_Res_enemy ) then { + KRON_UPS_East_enemies = KRON_UPS_East_enemies+units _npc; + } else { + KRON_UPS_East_friends = KRON_UPS_East_friends+units _npc; + }; + if (west in KRON_UPS_Res_enemy ) then { + KRON_UPS_West_enemies = KRON_UPS_West_enemies+units _npc; + } else { + KRON_UPS_West_friends = KRON_UPS_West_friends+units _npc; + }; + }; + }; + call (compile format ["KRON_UPS_%1_Total = KRON_UPS_%1_Total + count (units _npc)",side _npc]); + + _vehicletypes = ["VEHTYPE:",_vehicletypes,_UCthis] call KRON_UPSgetArg; + + }; + +// set drop units at random positions + _initpos = "ORIGINAL"; + if ("RANDOM" in _UCthis) then {_initpos = "RANDOM"}; + if ("RANDOMUP" in _UCthis) then {_initpos = "RANDOMUP"}; + if ("RANDOMDN" in _UCthis) then {_initpos = "RANDOMDN"}; + // don't position groups or vehicles on rooftops + if ((_initpos!="ORIGINAL") && ((!_isman) || (count _members)>1)) then {_initpos="RANDOMDN"}; + + // set behaviour modes (or not) + _orgMode = "SAFE"; + if ("CARELESS" in _UCthis) then {_orgMode = "CARELESS"}; + if ("AWARE" in _UCthis) then {_orgMode = "AWARE"}; + if ("COMBAT" in _UCthis) then {_orgMode = "COMBAT"}; + if ("STEALTH" in _UCthis) then {_orgMode = "STEALTH"}; + +// set original beahviour + if (!_isSoldier) then { + _Behaviour = "CARELESS"; + } else { + _Behaviour = _orgMode; + }; + _npc setbehaviour _Behaviour; + + +// set initial speed + _noslow = if ("NOSLOW" in _UCthis) then {"NOSLOW"} else {"SLOW"}; + if (_noslow!="NOSLOW") then { + _orgSpeed = "limited"; + } else { + _orgSpeed = "FULL"; + }; + _speedmode = _orgSpeed; + _npc setspeedmode _speedmode; + +// set If enemy detected reinforcements will be sent REIN1 + _reinforcement= if ("REINFORCEMENT" in _UCthis) then {"REINFORCEMENT"} else {"NOREINFORCEMENT"}; //rein_yes + _rfid = ["REINFORCEMENT:",0,_UCthis] call KRON_UPSgetArg; // rein_# + + if (_rfid>0) then { + _reinforcement="REINFORCEMENT"; + //if (KRON_UPS_Debug>0) then {hintsilent format["%1: reinforcement group %2",_grpidx,_rfid,_rfidcalled,_reinforcement]}; + }; + +//set Is a template for spawn module? + _template = ["TEMPLATE:",_template,_UCthis] call KRON_UPSgetArg; + //Fills template array for spawn + if (_template > 0 && !_spawned) then { + KRON_UPS_TEMPLATES = KRON_UPS_TEMPLATES + ( [[_template]+[_side]+[_membertypes]+[_vehicletypes]] ); + //if (KRON_UPS_Debug>0) then {diag_log format["%1 Adding TEMPLATE %2 _spawned %3",_grpidx,_template,_spawned]}; + //if (KRON_UPS_Debug>0) then {player globalchat format["KRON_UPS_TEMPLATES %1",count KRON_UPS_TEMPLATES]}; + }; + +// make start position random + if (_initpos!="ORIGINAL") then { + // find a random position (try a max of 20 positions) + _try=0; + _bld=0; + _bldpos=0; + while {_try<20} do { + _currPos=[_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; + _posinfo=[_currPos] call KRON_PosInfo3; + // _posinfo: [0,0]=no house near, [obj,-1]=house near, but no roof positions, [obj,pos]=house near, with roof pos + _bld=_posinfo select 0; + _bldpos=_posinfo select 1; + if (_isplane || _isboat || !(surfaceiswater _currPos)) then { + if (((_initpos=="RANDOM") || (_initpos=="RANDOMUP")) && (_bldpos>0)) then {_try=99}; + if (((_initpos=="RANDOM") || (_initpos=="RANDOMDN")) && (_bldpos==0)) then {_try=99}; + }; + _try=_try+1; + sleep .01; + }; + if (_bldpos==0) then { + + { //man + if (vehicle _x == _x) then { + _x setpos _currPos; + }; + } foreach units _npc; + + sleep .5; + { // vehicles + _targetpos = _currPos findEmptyPosition [10, 100]; + sleep .4; + if (count _targetpos <= 0) then {_targetpos = _currpos}; + _x setPos _targetpos; + } foreach _vehicles; + + } else { + // put the unit on top of a building + _npc setPos (_bld buildingPos _bldpos); + _currPos = getPos _npc; + _nowp=true; // don't move if on roof + }; + }; + +// track unit ====================================================================================== + _track = if (("TRACK" in _UCthis) || (KRON_UPS_Debug>0)) then {"TRACK"} else {"NOTRACK"}; + _trackername = ""; + _destname = ""; + if (_track=="TRACK") then { + _track = "TRACK"; + _trackername=format["trk_%1",_grpidx]; + _markerobj = createMarker[_trackername,[0,0]]; + _markerobj setMarkerShape "ICON"; + _markertype = if (isClass(configFile >> "cfgMarkers" >> "WTF_Dot")) then {"WTF_DOT"} else {"DOT"}; + _trackername setMarkerType _markertype; + _markercolor = switch (side _npc) do { + case west: {"ColorGreen"}; + case east: {"ColorRed"}; + case resistance: {"ColorBlue"}; + default {"ColorBlack"}; + }; + _trackername setMarkerColor _markercolor; + _trackername setMarkerText format["%1",_grpidx]; + _trackername setmarkerpos _currPos; + + _destname=format["dest_%1",_grpidx]; + _markerobj = createMarker[_destname,[0,0]]; + _markerobj setMarkerShape "ICON"; + _markertype = if (isClass(configFile >> "cfgMarkers" >> "WTF_Flag")) then {"WTF_FLAG"} else {"FLAG"}; + _destname setMarkerType _markertype; + _destname setMarkerColor _markercolor; + _destname setMarkerText format["%1",_grpidx]; + _destname setMarkerSize [.5,.5]; + }; + + +// delete dead units ============================================================================== + _deletedead = ["DELETE:",0,_UCthis] call KRON_UPSgetArg; + if (_deletedead>0) then { + { + _x addEventHandler['killed',format["[_this select 0,%1] spawn KRON_deleteDead",_deletedead]]; + sleep 0.01; + }forEach _members; + }; + +// how many group clones? ========================================================================= +// TBD: add to global side arrays? + _mincopies = ["MIN:",0,_UCthis] call KRON_UPSgetArg; + _maxcopies = ["MAX:",0,_UCthis] call KRON_UPSgetArg; + if (_mincopies>_maxcopies) then {_maxcopies = _mincopies}; + if (_maxcopies>140) exitWith {hint "Cannot create more than 140 groups!"}; + if (_maxcopies>0) then { + _copies = _mincopies + random (_maxcopies-_mincopies); + + // create the clones + for "_grpcnt" from 1 to _copies do { + // copy groups + if (isNil ("KRON_grpindex")) then {KRON_grpindex = 0}; + KRON_grpindex = KRON_grpindex+1; + // copy group leader + _unittype = typeof _npc; + // make the clones civilians + // use random Civilian models for single unit groups + if ((_unittype=="Civilian") && (count _members==1)) then {_rnd=1+round(random 20); if (_rnd>1) then {_unittype=format["Civilian%1",_rnd]}}; + + _grp=createGroup side _npc; + _lead = _grp createUnit [_unittype, getpos _npc, [], 0, "form"]; + _lead setVehicleVarName format["l%1",KRON_grpindex]; + call compile format["l%1=_lead",KRON_grpindex]; + _lead setBehaviour _orgMode; + _lead setSpeedmode _orgSpeed; + _lead setSkill skill _npc; + _lead setVehicleInit _initstr; + [_lead] join _grp; + _grp selectLeader _lead; + // copy team members (skip the leader) + _i=0; + { + _i=_i+1; + if (_i>1) then { + _newunit = _grp createUnit [typeof _x, getpos _x, [],0,"form"]; + _newunit setBehaviour _orgMode; + _newunit setSpeedMode _orgSpeed; + _newunit setSkill skill _x; + _newunit setVehicleInit _initstr; + [_newunit] join _grp; + }; + } foreach _members; + + nul=[_lead,_areamarker,_pause,_noslow,_nomove,_nofollow,_initpos,_track,_showmarker,_shareinfo,"DELETE:",_dead] execVM "scripts\upsmon.sqf"; + //sleep .05; + }; + processInitCommands; + sleep .05; + }; + + +// units that can be left for area to be "cleared" ============================================================================================= + _zoneempty = ["EMPTY:",0,_UCthis] call KRON_UPSgetArg; + +// create area trigger ========================================================================================================================= + if (_areatrigger!="NOTRIGGER") then { + _trgside = switch (side _npc) do { case west: {"WEST"}; case east: {"EAST"}; case resistance: {"GUER"}; case civilian: {"CIV"};}; + //_trgside = switch (side _npc) do { case west: {"EAST"}; case east: {"WEST"}; case resistance: {"ANY"}; case civilian: {"ANY"};}; + _trgname="KRON_Trig_"+_trgside+"_"+_areamarker; + _flgname="KRON_Cleared_"+_areamarker; + // has the trigger been created already? + KRON_TRGFlag=-1; + call compile format["%1=false",_flgname]; + call compile format["KRON_TRGFlag=%1",_trgname]; + if (isNil ("KRON_TRGFlag")) then { + // trigger doesn't exist yet, so create one (make it a bit bigger than the marker, to catch path finding 'excursions' and flanking moves) + call compile format["%1=createTrigger['EmptyDetector',_centerpos]",_trgname]; + call compile format["%1 setTriggerArea[_rangeX*1.5,_rangeY*1.5,markerDir _areamarker,true]",_trgname]; + call compile format["%1 setTriggerActivation[_trgside,'PRESENT',true]",_trgname]; + call compile format["%1 setEffectCondition 'true'",_trgname]; + call compile format["%1 setTriggerTimeout [5,7,10,true]",_trgname]; + if (_areatrigger!="SILENTTRIGGER") then { + call compile format["%1 setTriggerStatements['count thislist<=%6', 'titletext [''SECTOR <%2> LIMPIO'',''PLAIN''];''%2'' setmarkerpos [-%4,-%5];%3=true;', 'titletext [''SECTOR <%2> HA SIDO REOCUPADO'',''PLAIN''];''%2'' setmarkerpos [%4,%5];%3=false;']", _trgname,_areamarker,_flgname,_centerX,_centerY,_zoneempty]; + + } else { + call compile format["%1 setTriggerStatements['count thislist<=%3', '%2=true;', '%2=false;']", _trgname,_flgname,_zoneempty]; + }; + }; + sleep .05; + }; + +//If a soldier has a useful building takes about ====================================================================================================================== + if ( _nomove=="NOMOVE" ) then { + sleep 10; + _unitsIn = [_grpid,_npc,150] call MON_GetIn_NearestStatic; + if ( count _unitsIn > 0 ) then { sleep 10}; + [_npc, _buildingdist,false,_wait,true] spawn MON_moveNearestBuildings; + }; + +// init done + _newpos = false; + _targetPos = [0,0,0];//_currPos; + _targettext ="_currPos"; + _swimming = false; + _waiting = if (_nomove=="NOMOVE") then {9999} else {0}; + _sharedist = if (_nomove=="NOMOVE") then {KRON_UPS_sharedist} else {KRON_UPS_sharedist*1.5}; + + +//Gets position of waypoint if no targetpos + if (format ["%1", _targetPos] == "[0,0,0]") then { + _index = (count waypoints _grp) - 1; + _wp = [_grp,_index]; + _targetPos = waypointPosition _wp; + if (([_currpos,_targetPos] call KRON_distancePosSqr)<= 20) then {_targetPos = [0,0,0];}; + }; + +// *********************************************************************************************************** +// ************************************************ MAIN LOOP ************************************************ +// *********************************************************************************************************** +_loop=true; + +scopeName "main"; +while {_loop} do { + + +//if (KRON_UPS_Debug>0) then {player sidechat format["%1: _cycle=%2 _currcycle=%3 _react=%4 _waiting=%5",_grpidx,_cycle,_currcycle,_react,_waiting]}; + _timeontarget=_timeontarget+_currcycle; + _react=_react+_currcycle; + _waiting = _waiting - _currcycle; + _lastreact = _lastreact + _currcycle; + _newpos = false; + + + + _sokilled = false; + _sowounded = false; + + + // CHECK IF did anybody in the group got hit or die? + if ((R_GOTHIT_ARRAY select _grpId) != 0) then + { + _gothit = true; + + if ((R_GOTHIT_ARRAY select _grpId) == 1) then + { + _sowounded = true; + } + else + { + _sokilled = true; + }; + sleep 0.01; + R_GOTHIT_ARRAY set [_grpId, 0]; + }; + + + + + + // nobody left alive, exit routine + if (count _members==0) then { + _exit=true; + } else { + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + }; + + //exits from loop + if (_exit) exitwith {}; + + + //Checks if surrender is enabled + if ( _surrender > 0 ) then { + _surrended = call (compile format ["KRON_UPS_%1_SURRENDED",_side]); + }; + + //If surrended exits from script + if (_surrended) exitwith { + { + [_x] spawn MON_surrender; + }foreach _members; + + if (KRON_UPS_Debug>0) then {_npc globalchat format["%1: %2 SURRENDED",_grpidx,_side]}; + }; + + //Assign the current leader of the group in the array of group leaders + KRON_NPCs set [_grpid,_npc]; + + // current position + _currPos = getpos _npc; _currX = _currPos select 0; _currY = _currPos select 1; + if (_track=="TRACK" || KRON_UPS_Debug>0) then { _trackername setmarkerpos _currPos; }; + + + // if the AI is a civilian we don't have to bother checking for enemy encounters + if ( _isSoldier && !_exit) then { + _pursue=false; + //_Behaviour = Behaviour _npc; + + //Variables to see if the leader is in a vehicle + _incar = "LandVehicle" countType [vehicle (_npc)]>0; + _inheli = "Air" countType [vehicle (_npc)]>0; + _inboat = "Ship" countType [vehicle (_npc)]>0; + + + //If the group is strengthened and the enemies have been detected are sent to target + if (_rfid > 0 ) then { + _rfidcalled = call (compile format ["KRON_UPS_reinforcement%1",_rfid]); // will be TRUE when variable in triger will be true. + if (isnil "_rfidcalled") then {_rfidcalled=false}; + _fixedtargetPos = call (compile format ["KRON_UPS_reinforcement%1_pos",_rfid]); // will be position os setfix target of sending reinforcement + if (isnil "_fixedtargetPos") then { + _fixedtargetPos=[0,0]; + }else{ + _fixedtargetPos = [abs(_fixedtargetPos select 0),abs(_fixedtargetPos select 1)]; + _target = objnull; + }; + }; + sleep .01; + + //Reinforcement control + if (_reinforcement=="REINFORCEMENT") then { + // (global call OR id call) AND !send yet + if ( (KRON_UPS_reinforcement || _rfidcalled) && (!_reinforcementsent)) then { + _reinforcementsent=true; + _fortify = false; + _minreact = KRON_UPS_minreact; + _buildingdist = 60; + _react = _react + 100; + _waiting = -1; + if (format ["%1",_fixedtargetPos] != "[0,0]") then {_nowp = false}; + if (KRON_UPS_Debug>0) then {player sidechat format["%1 called for reinforcement %2",_grpidx,_fixedtargetPos]}; + } else { + // !(global or id call) AND send + if ( !(KRON_UPS_reinforcement || _rfidcalled) && (_reinforcementsent)) then { + _fixedtargetPos = [0,0]; + _attackPos = [0,0]; + _fortify = _fortifyorig; + _reinforcementsent=false; + if (_rfid > 0 ) then { + call (compile format ["KRON_UPS_reinforcement%1_pos = [0,0]",_rfid]); + call (compile format ["KRON_UPS_reinforcement%1 = false",_rfid]); + }; + if (KRON_UPS_Debug>0) then {player sidechat format["%1 reinforcement canceled",_grpidx]}; + }; + }; + }; + + //Gets targets from radio + _targets = call (compile format ["KRON_targets%1",_sharedenemy]); + + // if (KRON_UPS_Debug>0) then {player globalchat format["targets from global upsmon: %1",_targets]}; + //Reveal targets found by members to leader + { + //_NearestEnemy = assignedTarget _x; + //if (KRON_UPS_Debug>0) then {player globalchat format["Nearest Enemy %1, know about %2",_NearestEnemy,_x knowsabout _NearestEnemy]}; + _NearestEnemy = _x findnearestenemy _x; + if (_x knowsabout _NearestEnemy > R_knowsAboutEnemy && (_npc knowsabout _NearestEnemy <= R_knowsAboutEnemy || count _targets <= 0 )) then { + + if (_npc knowsabout _NearestEnemy <= R_knowsAboutEnemy ) then { + _npc reveal _NearestEnemy; + if (KRON_UPS_Debug>0) then {player globalchat format["%1: %2 reveals target %3 to leader",_grpidx,typeof _x, typeof _NearestEnemy]}; + }; + + //If no targets adds this + if (count _targets <= 0) then { + //_target = _NearestEnemy; + _targets = _targets + [_NearestEnemy]; + _NearestEnemy setvariable ["UPSMON_lastknownpos", position _NearestEnemy, false]; + //if (KRON_UPS_Debug>0) then {player globalchat format["%1: %3 added to targets",_grpidx,typeof _x, typeof _target]}; + }; + }; + } foreach units _npc; + + + //if no target but _npc knows enemy then this is _target + if (isNull (_target)) then { + { + if ((_npc knowsabout _x > R_knowsAboutEnemy) && (alive _x) && (canmove _x)) then { + _target =_x; + if (!isNull (_target)) exitWith{}; + }; + } foreach _targets; + }; + + + + + //Resets distance to target + _dist = 10000; + + //Gets current known position of target and distance + if ( !isNull (_target) && alive _target ) then { + _newattackPos = _target getvariable ("UPSMON_lastknownpos"); + + if ( !isnil "_newattackPos" ) then { + _attackPos=_newattackPos; + //Gets distance to target known pos + _dist = ([_currpos,_attackPos] call KRON_distancePosSqr); + }; + }; + + + //Initialization for geting new targets + //If the current target is dead or no prior knowledge is cleaned + if (isNull (_target) || !alive _target || !canmove _target ) then { + _lastknown = 0; + _opfknowval = 0; + _target = objnull; + }; + + _newtarget = _target; + + + if ((_shareinfo=="SHARE")) then { + + //Requests for radio the enemy's position, if it is within the range of acts + if ((KRON_UPS_comradio == 2)) then + { + _targetsnear = false; + + //I we have a close target alive do not search another + if (!alive _target || !canmove _target || _dist > _closeenough) then { + { + if ( !isnull _x && canmove _x && alive _x ) then { + + _newattackPos = _x getvariable ("UPSMON_lastknownpos"); + + if ( !isnil "_newattackPos" ) then { + _dist3 = ([_currpos,_newattackPos] call KRON_distancePosSqr); + + //Sets if near targets to begin warning + IF ( _dist3 <= (_closeenough + KRON_UPS_safedist)) then { _targetsnear = true }; + + //Sets new target + if ( ( isnull (_newtarget) || captive _newtarget|| !alive _newtarget|| !canmove _newtarget || _dist3 < _dist ) + && ( _dist3 <= _sharedist || _reinforcementsent ) + && ( !(_x iskindof "Air") || (_x iskindof "Air" && _isplane )) + && ( !(_x iskindof "Ship") || (_x iskindof "Ship" && _isboat )) + && ( _x emptyPositions "Gunner" == 0 && _x emptyPositions "Driver" == 0 + || (!isnull (gunner _x) && canmove (gunner _x)) + || (!isnull (driver _x) && canmove (driver _x))) + ) then { + _newtarget = _x; + _opfknowval = _npc knowsabout _x; + _dist = _dist3; + if (_dist < _closeenough) exitWith {}; + }; + }; + }; + } foreach _targets; + sleep 0.5; + }; + }; + + //If you change the target changed direction flanking initialize + if ( !isNull (_newtarget) && alive _newtarget && canmove _newtarget && (_newtarget != _target || isNull (_target)) ) then { + _timeontarget = 0; + _targetdead = false; + _flankdir= if (random 100 <= 10) then {0} else {_flankdir}; + _target = _newtarget; + }; + }; + + // use smoke when hit or s/o killed + if !_nosmoke then { + { + //when hit + if (_sowounded && random 100 < R_USE_SMOKE_wounded) then { + nul = [_x,_target] spawn MON_throw_grenade; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1: We got wounded smoking!",_grpidx]}; + }; + + //when die + if (_sokilled && random 100 < R_USE_SMOKE_killed) then { + nul = [_x,_target] spawn MON_throw_grenade; + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: We got killed one, smoking!",_grpidx]}; + }; + sleep 0.1; + } foreach _members; + }; + + + + //Gets current known position of target and distance + if ( !isNull (_target) && alive _target ) then { + //Enemy detected + if (_fightmode != "fight" ) then { + _fightmode = "fight"; + _npc setCombatMode "RED"; // !R + _react = KRON_UPS_react; + if (KRON_UPS_Debug>0) then {player sidechat format["%1: Enemy detected %2",_grpidx, typeof _target]}; + + if (_nowpType == 1) then { + nul = [_npc] call R_FN_deleteObsoleteWaypoints; + _nowp = false; + }; + }; + + _newattackPos = _target getvariable ("UPSMON_lastknownpos"); + + if ( !isnil "_newattackPos" ) then { + _attackPos=_newattackPos; + //Gets distance to target known pos + _dist = ([_currpos,_attackPos] call KRON_distancePosSqr); + //Looks at target known pos + _members lookat _attackPos; + }; + }; + + //If the enemy has moved away from the radio coverage is not a reinforcement sent we will have lost track + if ( _fightmode != "walk" && !isnull(_target) && _dist < 15 && _npc knowsabout _target < R_knowsAboutEnemy ) then { + //If squad is near last position and no target clear position of target + if (KRON_UPS_Debug>0) then {player sidechat format["%1: Target lost",_grpidx]}; + _fightmode="walk"; + _speedmode = _orgSpeed; + _target = objnull; + _Behaviour = _orgMode; + _waiting = -1; + _unitpos = "AUTO"; + _pursue=false; + _targetdead = true; + _makenewtarget = true; //Go back to the original position + }; + + //If knowledge of the target increases accelerate the reaction + if (_opfknowval>_lastknown ) then { + _react = _react + 20; + }; + + // if spotted an enemy or got shot, so start pursuit, if in combat and exceed time to react or movecompleted + if (!_ambushed && (_fightmode != "walk") && ((_react >= KRON_UPS_react && _lastreact >=_minreact) || moveToCompleted _npc )) then { + _pursue=true; + }; + + + //Ambush ========================================================================================================== + if (_ambush && !_ambushed) then { + _ambushed = true; + _nowp = true; + _currcycle = 2; + _grp setFormation "LINE"; + _npc setBehaviour "STEALTH"; + _npc setSpeedMode "FULL"; + + + /* + sleep 12; + { + [_x,"DOWN"] spawn MON_setUnitPos; + sleep 2; + _x stop true; + player sidechat format["%1 %2",_x,_npc]; + + } foreach units _npc; + */ + + //Puts a mine if near road + if ( _ambushType == 1 ) then { + if (KRON_UPS_Debug>0) then {player sidechat format["%1: Puting mine for ambush",_grpidx]}; + _npc setBehaviour "careless"; + _dir1 = getDir _npc; + _mineposition = [position _npc,_dir1, (KRON_UPS_ambushdist / 1.2)] call MON_GetPos2D; + _roads = _mineposition nearroads 25; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1: Roads #:%2",_grpidx, (count _roads)]}; + + while {_Mines > 0} do + { + _i = 0; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1 Current Roads #:%2 _Mines:%3",_grpidx, (count _roads),_Mines]}; + if (count _roads > 0) then { + _rnd = floor (random (count _roads)); + _mineposition = position (_roads select _rnd); + _roads = _roads - [_roads select _rnd]; + if ([_npc,_mineposition] call MON_CreateMine) then {_Mines = _Mines -1; _i = 1;}; + } else { + _mineposition = [position _npc,(_dir1-30) mod 360, (KRON_UPS_ambushdist / 1.2 ) + random 10] call MON_GetPos2D; + if ([_npc,_mineposition] call MON_CreateMine) then {_Mines = _Mines -1; _i = 1;}; + }; + sleep 0.1; + if (_i != 1) then {_Mines = _Mines -1;} //in case no mine was set + }; + + _npc setBehaviour "carelesscareless"; + sleep 30; + { + if (!stopped _x) then { + _x domove position _npc; + waituntil {moveToCompleted _x || moveToFailed _x || !alive _x || !canmove _x || _x distance _npc <= 5}; + }; + } foreach units _npc; + }; + + + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + + _grp setFormation "LINE"; + _npc setBehaviour "AWARE"; + sleep 10; + + sleep 0.1; + _unitpos ="DOWN"; + { + [_x,_unitpos] spawn MON_setUnitPos; + sleep 0.5; + _x stop true; + } foreach units _npc; + _npc setBehaviour "STEALTH"; + _pursue = false; + + }; // end of ambush mine + + + + + + //Ambushr enemy is nearly aproach + //_ambushdist = 50; + // if (_npc knowsabout _NearestEnemy <= R_knowsAboutEnemy ) + + if (_ambush) then { + _prov = ((_ambushdist*2 - (_npc distance _NearestEnemy))*3) - 40; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1:%6 _ambushdist=%5 last=%2 dist=%3 prov=%4",_grpidx,_lastdist,_npc distance _NearestEnemy,_prov,_ambushdist,typeof _NearestEnemy]}; + + if (_gothit || _reinforcementsent || time > _ambushwait + || ( "Air" countType [_NearestEnemy]<=0 + && ( _npc distance _NearestEnemy <= _ambushdist + random 10 + || (!isNull (_NearestEnemy) && (( random 100 <= _prov && _npc distance _NearestEnemy > _lastdist) + || _npc distance _NearestEnemy > _ambushdist*3 && _lastdist < _ambushdist*3 && _lastdist > 0)) + )) + ) then { + sleep ((random 1) + 1); // let the enemy then get in the area + if (KRON_UPS_Debug>0) then {player sidechat format["%1: ATTACK !",_grpidx]}; + _nowp = false; + _ambush = false; + _ambushed = false; + _currcycle = _cycle; + { + _x stop false; + _x setUnitPos "Auto"; + } foreach _members; + _npc setBehaviour "STEALTH"; + _npc setCombatMode "RED"; + + //No engage yet + _pursue = false; + }; + + //Sets distance to target + _lastdist = _npc distance _NearestEnemy; + }; // end of ambush + + + + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: _nowp=%2 in vehicle=%3 _inheli=%4 _npc=%5",_grpidx,_nowp,vehicle (_npc) ,_inheli,typeof _npc ]}; + + //If in vehicle take driver if not controlled by user + if (alive _npc && !_nowp) then { + if (!_isman || (vehicle (_npc) != _npc && !_inboat && !(vehicle (_npc) iskindof "StaticWeapon"))) then { + + //If new target is close enough getout vehicle (not heli) + _unitsin = []; + + if (!_inheli) then { + if (_fightmode == "walk") then { + _GetOutDist = _area / 20; + }else{ + _GetOutDist = _closeenough * ((random .4) + 0.6); + }; + + + + + //If near target or stuck getout of vehicle and lock or gothit exits inmediately + if (_gothit || _dist <= _closeenough * 1.5 || (_lastcurrpos select 0 == _currpos select 0 && _lastcurrpos select 1 == _currpos select 1 && moveToFailed (vehicle (_npc))) || moveTocompleted (vehicle (_npc))) then + { + _GetOutDist = 10000; + }; + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: vehicle=%2 _npc=%3",_grpidx,vehicle (_npc) ,typeof _npc ]}; + + _unitsin = [_npc] call R_FN_allUnitsInCargo; // return units in cargo in all vehs used by the group + + private ["_handle1"]; + _handle1 = [_npc,_targetpos,_GetOutDist] spawn R_SN_GetOutDist; // getout if as close as _GetOutDist to the target + _timeout = time + 10; + waitUntil {scriptDone _handle1 || time > _timeout}; + + } else { + _GetOutDist = 0; + }; + + + + // if there was getout of the cargo + if (count _unitsin > 0) then { + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: Geting out of vehicle, dist=%2 atdist=%3 _area=%4",_grpidx,([_currpos,_targetpos] call KRON_distancePosSqr),_GetOutDist,_area]}; + _timeout = time + 7; + { + waituntil {vehicle _x == _x || !canmove _x || !alive _x || time > _timeout || movetofailed _x }; + } foreach _unitsin; + + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + if (_fightmode == "fight" || _gothit) then { + _npc setBehaviour "COMBAT"; // AWARE + _groupOne = group _npc; + _groupOne setFormation "DIAMOND"; + nul = [_npc,30] spawn MON_move; + }; + + sleep 0.2; + // select leader outside of vehicle + { + if (alive _x && canmove _x) exitwith {group _x selectLeader _x; _npc = _x}; + } foreach _unitsin; + + + + if (_fightmode == "fight") then { + _pursue = true; + }else + { + _pursue = false; + _makenewtarget=true; + }; + }; + }; + }; + + + //If under attack or increasing knowledge speeds up the response and regain control of the AI + if (_gothit) then { + _react = if (!_supressed) then {_react + 30}; + if (_fightmode != "walk") then { + if (_nowpType != 3) then { + nul = [_npc] call R_FN_deleteObsoleteWaypoints; + _nowp = false; + }; + }; + }; + + //If there is no objective order is canceled persecution + if ((isNull (_target) || !alive _target )) then { + _pursue=false; + + if (_gothit && !_fortify && !_nowp) then { + if ((_fightmode == "walk")) then + { + //It could be a sniper, better be alert and move in case + _Behaviour = "COMBAT"; + _speedmode = "FULL"; + _unitpos = "AUTO"; + _gothit = false; + _makenewtarget = true; + _waiting = -1; + if ((random 100 < 20) && !_nosmoke) then { + nul= [_npc,_target] spawn MON_throw_grenade; + }; + if (KRON_UPS_Debug>0) then {player sidechat format["%1: Have been damaged moving",_grpidx,_makenewtarget]}; + } else { + if ((_react >= KRON_UPS_react && _lastreact >=_minreact && count _targets <= 0) || _sowounded) then { + //We shoot and we have no target, we move from position + if (KRON_UPS_Debug>0) then {player sidechat format["%1: Under fire by unkown target, moving to newpos",_grpidx]}; + //Covers the group with a smoke grenade + if (!_supressed && (random 100 < 80) && !_nosmoke) then { + nul= [_npc,_target] spawn MON_throw_grenade; + }; + _gothit = false; + _makenewtarget = true; + _waiting = -1; + _pause="NOWAIT"; + _speedmode = "FULL"; + _unitpos = "middle"; + _Behaviour = "AWARE"; + } else { + if (_lastreact >=_minreact && !_targetdead) then + { + _targetdead = true; + _pursue = true; + //We have run out of targets continue to search + if (KRON_UPS_Debug>0) then {player sidechat format["%1: Target defeated, searching",_grpidx]}; + }; + }; + }; + }; + }; + + + + + + + //If no fixed target check if current target is available + if (format ["%1",_fixedtargetPos] != "[0,0]") then { + //If fixed target check if close enough or near enemy and gothit + if (([_currpos,_fixedtargetpos] call KRON_distancePosSqr) <= _closeenough || (_dist <= _closeenough && _gothit)) then { + _fixedtargetPos = [0,0]; + } else { + _pursue = false; + _attackPos=_fixedtargetPos; + if (_react >= KRON_UPS_react && _lastreact >=_minreact) then { + _makenewtarget = true; + _unitpos = "AUTO"; + _speed = "FULL"; + }; + }; + }; + + + + + + //If captive or surrended do not pursue + if ( isnil "_attackPos") then {_pursue = false;}; + if ( captive _target || format ["%1", _attackPos] == "[0,0]") then {_pursue = false;}; + + //If no waypoint do not move + if (_nowp) then { + _makenewtarget = false; + _pursue = false; + }; + + if (_inheli) then { + _landing = _heli getVariable "UPSMON_landing"; + if (isnil ("_landing")) then {_landing=false;}; + if (_landing) then { + _pursue = false; + }; + }; + sleep 0.5; + +// ********************************************************************************************************************** +// PURSUE: CHASE BEGINS THE LENS +// ********************************************************************************************************************** + + if (_pursue) then { + + + // if (KRON_UPS_Debug>0) then {player sidechat format["%1: is in pursure",_grpidx]}; + + _pursue = false; + _newpos = true; + _react = 0; + _lastreact = 0; + _timeontarget = 0; + _makenewtarget = false; + _fm = 1; + //Cancel supress effect when reaction time + _supressed = false; + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + // get position of spotted unit in player group, and watch that spot + _targetPos = _attackPos; + _targetX = _targetPos select 0; _targetY = _targetPos select 1; + _currPos = getpos _npc; + + // also go into "combat mode" + _pause="NOWAIT"; + _waiting=0; + + // angle from unit to target + _dir1 = [_currPos,_targetPos] call KRON_getDirPos; + // angle from target to unit (reverse direction) + _dir2 = (_dir1+180) mod 360; + + //Establecemos una distancia de flanqueo + _flankdist = ((random 0.5)+0.7)*KRON_UPS_safedist; + + //La distancia de flanqueo no puede ser superior a la distancia del objetivo o nos pordría pillar por la espalda + _flankdist = if ((_flankdist*1.40) >= _dist) then {_dist*.65} else {_flankdist}; + + if (_inheli) then {_flankdist = _flankdist / 2;}; + + // avoidance position (right or left of unit) + _avoidPos = [_currPos,_dir2, KRON_UPS_safedist] call MON_GetPos2D; + + //Calculamos posición de avance frontal + _frontPos = [_targetPos,_dir2, _flankdist] call MON_GetPos2D; + + + //Adaptamos el ángulo de flanqueo a la distancia + _newflankAngle = ((random(KRON_UPS_flankAngle)+1) * 2 * (_flankdist / KRON_UPS_safedist )) + (KRON_UPS_flankAngle/1.4) ; + if (_newflankAngle > KRON_UPS_flankAngle) then {_newflankAngle = KRON_UPS_flankAngle}; + + //Calculamos posición de flanqueo 1 45ş + _dirf1 = (_dir2+_newflankAngle) mod 360; + _flankPos = [_targetPos,_dirf1, _flankdist] call MON_GetPos2D; + + + //Calculamos posición de flanqueo 2 -45ş + _dirf2 = (_dir2-_newflankAngle+360) mod 360; + _flankPos2 = [_targetPos,_dirf2, _flankdist] call MON_GetPos2D; + + if (KRON_UPS_Debug>0) then { + "flank1" setmarkerpos _flankPos; "flank2" setmarkerpos _flankPos2; "target" setmarkerpos _attackPos; + }; + + + //Decidir por el mejor punto de flanqueo + //Contamos las posiciones de destino de otros grupos más alejadas + _fldest = 0; + _fldest2 = 0; + _fldestfront = 0; + _i = 0; + + { + if (_i != _grpid && format ["%1", _x] != "[0,0]") then { + _dist1 = [_x,_flankPos] call KRON_distancePosSqr; + _dist2 = [_x,_flankPos2] call KRON_distancePosSqr; + _dist3 = [_x,_frontPos] call KRON_distancePosSqr; + if (_dist1 <= _flankdist/1.5 || _dist2 <= _flankdist/1.5 || _dist3 <= _flankdist/1.5) then { + if (_dist1 < _dist2 && _dist1 < _dist3) then {_fldest = _fldest + 1;}; + if (_dist2 < _dist1 && _dist2 < _dist3) then {_fldest2 = _fldest2 + 1;}; + if (_dist3 < _dist1 && _dist3 < _dist2) then {_fldestfront = _fldestfront + 1;}; + }; + }; + _i = _i + 1; + + sleep 0.01; + } foreach KRON_targetsPos; + + + //We have the positions of other groups more distant + _i = 0; + { + if (_i != _grpid && !isnull(_x)) then { + _dist1 = [getpos(_x),_flankPos] call KRON_distancePosSqr; + _dist2 = [getpos(_x),_flankPos2] call KRON_distancePosSqr; + _dist3 = [getpos(_x),_frontPos] call KRON_distancePosSqr; + if (_dist1 <= _flankdist/1.5 || _dist2 <= _flankdist/1.5 || _dist3 <= _flankdist/1.5) then { + if (_dist1 < _dist2 && _dist1 < _dist3) then {_fldest = _fldest + 1;}; + if (_dist2 < _dist1 && _dist2 < _dist3) then {_fldest2 = _fldest2 + 1;}; + if (_dist3 < _dist1 && _dist3 < _dist2) then {_fldestfront = _fldestfront + 1;}; + }; + }; + _i = _i + 1; + sleep 0.01; + } foreach KRON_NPCs; + + + + //La preferencia es la elección inicial de dirección + switch (_flankdir) do { + case 1: + {_prov = 125}; + case 2: + {_prov = -25}; + default + {_prov = 50}; + }; + + + //Si es positivo significa que hay más destinos existentes lejanos a la posicion de flanqueo1, tomamos primariamente este + if (_fldest<_fldest2) then {_prov = _prov + 50;}; + if (_fldest2<_fldest) then {_prov = _prov - 50;}; + + //Si la provablilidad es negativa indica que tomará el flank2 por lo tanto la provabilidad de coger 1 es 0 + if (_prov<0) then {_prov = 0;}; + + + //Evaluamos la dirección en base a la provablilidad calculada + if ((random 100) <= _prov) then { + _flankdir =1; + _flankPos = _flankPos; _targettext = "_flankPos"; + } else { + _flankdir =2; + _flankPos = _flankPos2; _targettext = "_flankPos2"; + }; + + + //Posición de ataque por defecto el flanco + _targetPos = _flankPos; + _targettext = "_flankPos"; + + + if ((surfaceIsWater _flankPos && !(_isplane || _isboat)) ) then { + _targetPos = _attackPos;_targettext ="_attackPos"; + _flankdir =0; + } else { + if (_fldestfront < _fldest && _fldestfront < _fldest2) then { + _targetPos = _frontPos;_targettext ="_frontPos"; + }; + }; + + + //Establish the type of waypoint + //DESTROY has worse behavior with and sometimes do not move + _wptype = "MOVE"; + + //Set speed and combat mode + _rnd = random 100; + if (_dist <= _closeenough) then { + //If we are so close we prioritize discretion fire + if ( _dist <= _closeenough/2 ) then { + //Close combat modeo + _speedmode = "LIMITED"; + _wpformation = "LINE"; + _unitpos = "AUTO"; //"Middle" + _react = _react + KRON_UPS_react / 2; + _minreact = KRON_UPS_minreact / 2; + if ((_nomove == "NOMOVE" && _rnd < 25) && !_reinforcementsent) then { + //Defensive combat + _Behaviour = "STEALTH"; + _wptype = "HOLD"; + } else { + if (_rnd < 80) then { + _Behaviour = "COMBAT"; // (combat / stealth) + } else { + _Behaviour = "AWARE"; + }; + _wptype = "MOVE"; + _npc setCombatMode "RED"; + } + } else { + //If the troop has the role of not moving tend to keep the position + _speedmode = "NORMAL"; + _wpformation = "VEE"; //or VEE + _unitpos = "AUTO";// "Middle" + _minreact = KRON_UPS_minreact / 1.5; + if ((_nomove == "NOMOVE" && _rnd < 50) && !_reinforcementsent) then { + //Combate defensivo + _Behaviour = "COMBAT"; + _wptype = "HOLD"; + } else { + if (_rnd < 70) then { + _Behaviour = "AWARE"; + } else { + _Behaviour = "COMBAT"; + }; + _wptype = "MOVE"; + _npc setCombatMode "YELLOW"; + }; + }; + } else { + if (( _dist <= (_closeenough + KRON_UPS_safedist))) then { + _speedmode = "FULL"; + _wpformation = "WEDGE"; + _unitpos = if (_rnd < 90) then {"Middle"} else {"AUTO"}; + _minreact = KRON_UPS_minreact; + if ((_nomove=="NOMOVE" && _rnd < 75) && !_reinforcementsent) then { + //Combate defensivo + _Behaviour = "COMBAT"; //AWARE + _wptype = "HOLD"; + } else { + //Movimiento con precaución (más rápido) + _Behaviour = "AWARE"; + _wptype = "MOVE"; + }; + } else { + //In May distance of radio patrol act.. + if (( _dist < KRON_UPS_sharedist )) then { + //Platoon from the target must move fast and to the point + _Behaviour = "AWARE"; + _speedmode = "FULL"; + _unitpos = if (_rnd < 60) then {"Middle"} else {"AUTO"}; + _minreact = KRON_UPS_minreact * 2; + if ((_nomove=="NOMOVE" && _rnd < 95) && !_reinforcementsent) then { + _wptype = "HOLD"; + _wpformation = "WEDGE"; + } else { + _wptype = "MOVE"; + _wpformation = "WEDGE"; + }; + } else { + //Platoon very far from the goal if not move nomove role + _Behaviour = "SAFE"; + _speedmode = "FULL"; + _unitpos = "AUTO"; + _minreact = KRON_UPS_minreact * 3; + + if (((_nomove=="NOMOVE") || (_nomove=="MOVE" && _rnd < 70)) && !_reinforcementsent) then { + _wptype = "HOLD"; + _wpformation = "WEDGE"; + }else{ + _wptype = "MOVE"; + _wpformation = "FILE"; //COLUMN + }; + }; + }; + }; + + + + //Always keep the brackets fortified position + if ( _fortify && random 100 < 99) then {_wptype = "HOLD"}; + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + //If leader is in vehicle will move in anyway + if (vehicle _npc != _npc || !_isman) then { + _wptype = "MOVE"; + _Behaviour = "AWARE"; + if ( _inheli ) then { + _speedmode = "FULL"; + _unitpos = "AUTO"; + _targetPos = _AttackPos; + }; + }; + + + + + + //Establecemos el target + KRON_targetsPos set [_grpid,_targetPos]; + sleep 0.01; + + //If use statics are enabled leader searches for static weapons near. + // Tanks enemies are contabiliced + if ( KRON_UPS_useMines && _Mines > 0 ) then { + _enemytanksnear = false; + { + if ( ("Tank" countType [_x] > 0 || "Wheeled_APC" countType [_x] >0 + || "Tank" countType [vehicle _x] > 0 || "Wheeled_APC" countType [vehicle _x] >0 ) + && alive _x && canMove _x && _npc distance _x <= _closeenough + KRON_UPS_safedist ) + exitwith { _enemytanksnear = true; _enemytanknear = _x;}; + } foreach _targets; + + + + //If use mines are enabled and enemy armors near and no friendly armor put mine. + if ( _enemytanksnear && !isnull _enemytanknear && alive _enemytanknear ) then { + _friendlytanksnear = false; + { + if (!( alive _x && canMove _x)) then {_friendlytanks = _friendlytanks - [_x]}; + if (alive _x && canMove _x && _npc distance _x <= _closeenough + KRON_UPS_safedist ) exitwith { _friendlytanksnear = true;}; + }foreach _friendlytanks; + + if (!_friendlytanksnear && random(100)<30 ) then { + _dir1 = [_currPos,position _enemytanknear] call KRON_getDirPos; + _mineposition = [position _npc,_dir1, 25] call MON_GetPos2D; + _roads = _mineposition nearroads 50; + if (count _roads > 0) then {_mineposition = position (_roads select 0);}; + if ([_npc,_mineposition] call MON_CreateMine) then { + _Mines = _Mines -1; + if (KRON_UPS_Debug>0) then {player sidechat format["%1: %3 puting mine for %2",_grpidx,typeof _enemytanknear, side _npc]}; + }; + }; + }; + }; + + + + + + //Si es unidad de refuerzo siempre acosará al enemigo + if (_reinforcementsent) then { + _wptype="MOVE"; + _newpos=true; + _makenewtarget = false; + }; + + if (_nofollow=="NOFOLLOW" && _wptype != "HOLD") then { + _targetPos = [_targetPos,_centerpos,_rangeX,_rangeY,_areadir] call KRON_stayInside; + _targetdist = [_currPos,_targetPos] call KRON_distancePosSqr; + if ( _targetdist <= 1 ) then { + _wptype="HOLD"; + }; + }; + + if (_wptype == "HOLD") then { + _targetPos = _currPos; _targettext ="_currPos"; + }; + + //Is updated with the latest value, changing the target + _lastknown = _opfknowval; + + //If for whatever reason cancels the new position should make clear the parameters that go into pursuit + if (!_newpos) then { + //If the unit has decided to maintain position but is being attacked is being suppressed, should have the opportunity to react + _newpos = _gothit; + + if (!_newpos) then { + _targetPos=_lastpos; + if (KRON_UPS_Debug>0) then {player sidechat format["%1 Mantaining orders %2",_grpidx,_nomove]}; + }; + }; + if (KRON_UPS_Debug>=1) then { + "avoid" setmarkerpos _avoidPos; "flank" setmarkerpos _flankPos; _destname setMarkerPos _targetPos; + }; + }; //END PURSUE + sleep 0.1; + }; //((_isSoldier) && ((count _enemies)>0) + + +// ********************************************************************************************************************** +// NO NEWS +// ********************************************************************************************************************** + if !(_newpos) then { + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + // calculate new distance + // if we're waiting at a waypoint, no calculating necessary + _currpos = getpos _npc; + + + + //Sets behaviour of squad if nearly changes of target + if (_targetsnear) then{ + if (( toUpper(_Behaviour) IN _safemode) && _isSoldier) then { + _Behaviour = "AWARE"; + _npc setBehaviour _Behaviour; + }; + }; + + + + //If in safe mode if find dead bodies change behaviour + if ((toUpper(_Behaviour) IN _safemode) && _deadBodiesReact)then { + _unitsin = [_npc,_buildingdist] call MON_deadbodies; + if (count _unitsin > 0) then { + if !_isSoldier then { + _npc setSpeedMode "FULL"; + } else { + if ( random 100 < 75) then { + _Behaviour = "AWARE"; + } else { + _Behaviour = "COMBAT"; + }; + _react = _react + 30; + _npc setBehaviour _Behaviour; + if (KRON_UPS_Debug>0) then {player sidechat format["%1 dead bodies found! set %2",_grpidx,_Behaviour, count _targets]}; + }; + }; + }; + + + //Stuck control + if (!_nowp && alive _npc && canmove _npc && _wptype == "MOVE" && _timeontarget >= 60 && _lastcurrpos select 0 == _currpos select 0 && _lastcurrpos select 1 == _currpos select 1) then { + [_npc] call MON_cancelstop; + _makenewtarget = true; + if (KRON_UPS_Debug>0) then {player sidechat format["%1 stucked, moving",_grpidx]}; + }; + + _lastpos = _targetPos; + _lastcurrpos = _currpos; //sets last currpos for avoiding stuk + + if (_waiting<0) then { + //Gets distance to targetpos + _targetdist = [_currPos,_targetPos] call KRON_distancePosSqr; + + //It assesses whether it has exceeded the maximum waiting time and the objective is already shot to return to the starting position. + if (_fightmode!="walk") then { + if (_timeontarget > KRON_UPS_alerttime && count _targets <= 0 && ( isNull (_target) || !alive (_target) || captive _target)) then { + _pursue = false; + _gothit = false; + _targetdead = true; + _fightmode = "walk"; + _speedmode = _orgSpeed; + _targetPos = _currPos; + _reinforcementsent = false; + _target = objnull; + _fixedtargetPos = [0,0]; + _Behaviour = _orgMode; + _waiting = -1; + _unitpos = "AUTO"; + _wpformation = "WEDGE"; + + KRON_UPS_reinforcement = false; //there is no threat + if (_rfid > 0 ) then { + call (compile format ["KRON_UPS_reinforcement%1 = false;",_rfid]); + }; + + {[_x,"AUTO"] spawn MON_setUnitPos;} foreach units _npc; + _npc setBehaviour _orgMode; + + if (KRON_UPS_Debug>0) then {player sidechat format["%1 Without objectives, leaving combat mode",_grpidx]}; + }; + }; + + + //if (KRON_UPS_Debug>0) then {player globalchat format["%1 _targetdist %2 atdist=%3 dist=%4",_grpidx, _targetdist, _area/8,_dist]}; + // if not in combat and we're either close enough, seem to be stuck, or are getting damaged, so find a new target + if (!_nowp && (!_gothit) && (!_swimming) && (_fightmode == "walk") && (( _targetdist <= (_area/4) || moveToFailed _npc) && (_timeontarget > KRON_UPS_maxwaiting))) then { + _makenewtarget=true; + _unitpos = "AUTO"; + _Behaviour = _orgMode; + }; + + // make new target + if (_makenewtarget) then + { + _gothit = false; + _react = 0; + _lastreact = 0; + _makenewtarget = false; + _timeontarget = 0; + _wptype = "MOVE"; + + if (format ["%1",_fixedtargetPos] !="[0,0]") then { + _targetPos = _fixedtargetPos; _targettext ="Reinforcement"; + } else { + + if ((_nomove=="NOMOVE") && (_timeontarget>KRON_UPS_alerttime)) then { + if (KRON_UPS_Debug>0) then {player sidechat format["nomove: %1",_nomove]}; + if (([_currPos,_orgPos] call KRON_distancePosSqr)<_closeenough) then { + _newpos = false; + _wptype = "HOLD"; + _waiting = 9999; + if (_fortify) then { + _minreact = KRON_UPS_minreact * 3; + _buildingdist = _buildingdist * 2; + _wait = 3000; + }; + } else { + _targetPos=_orgPos; _targettext ="_orgPos"; + }; + } else { + + //rStuckControl !R + _rcurrPos = getpos _npc; + if (_rlastPos select 0 == _rcurrPos select 0 && _rlastPos select 1 == _rcurrPos select 1) then { + + if (KRON_UPS_Debug>0) then {player sidechat format["%1 !RstuckControl try to move",_grpidx]}; + if (vehicle _npc != _npc) then { + _rstuckControl = _rstuckControl + 1; + if (_rstuckControl > 1) then { + _jumpers = crew (vehicle _npc); + { + _x spawn MON_doGetOut; + sleep 0.5; + } forEach _jumpers; + + } else { + nul = [vehicle _npc] spawn MON_domove; + } + + } else { + nul = [_npc,25] spawn MON_domove; + }; + + } else { + _rstuckControl = 0; + }; + _rlastPos = _rcurrPos; + + + + // re-read marker position/size + _centerpos = getMarkerPos _areamarker; _centerX = abs(_centerpos select 0); _centerY = abs(_centerpos select 1); + _centerpos = [_centerX,_centerY]; + _areasize = getMarkerSize _areamarker; _rangeX = _areasize select 0; _rangeY = _areasize select 1; + _areadir = (markerDir _areamarker) * -1; + + // find a new target that's not too close to the current position + _targetPos=_currPos; _targettext ="newTarget"; + _tries=0; + + while {((([_currPos,_targetPos] call KRON_distancePosSqr) < _mindist)) && (_tries<50)} do { + _tries=_tries+1; + // generate new target position + _targetPos = [_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; + + _loop2=FALSE; + // boat or plane + // if (KRON_UPS_Debug>0) then {player sidechat format["%1, type: %2",_npc, typeOf _npc]}; sleep 4; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1 isplane",_isplane]}; sleep 4; + if (_isplane || _isboat) then { + // boat + if (_isboat) then { + _tries2=0; + while {(!_loop2) && (_tries2 <50)} do { + _tries2=_tries2+1; + _targetPosTemp = [_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; + if (surfaceIsWater _targetPosTemp) then { + _targetPos = _targetPosTemp; + _loop2 = TRUE; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1 Boat just got new targetPos",_grpidx]}; + }; + sleep 0.05; + }; + + // plane + } else { + _targetPos = [_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1 Plane just got new targetPos",_grpidx]}; + }; + + // man or car + } else { + // "_onroad" + if _onroad then { + _tries2=0; + while {(!_loop2) && (_tries2 <100)} do { + _tries2=_tries2+1; + + _targetPosTemp = [_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; + _roads = (_targetPosTemp nearRoads 50); + if ((count _roads) > 0) then { + _targetPosTemp = getpos (_roads select 0); + _targetPos = _targetPosTemp; + _loop2 = TRUE; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1 Onroad just got new targetPos",_grpidx]}; + }; + sleep 0.05; + }; + // any place on ground + } else { + + _tries2=0; + while {(!_loop2) && (_tries2 <100)} do { + _tries2=_tries2+1; + _targetPosTemp = [_centerX,_centerY,_rangeX,_rangeY,_cosdir,_sindir,_areadir] call KRON_randomPos; + if (!surfaceIsWater _targetPosTemp) then { + _targetPos = _targetPosTemp; + _loop2 = TRUE; + //if (KRON_UPS_Debug>0) then {player sidechat format["%1 Man just got new TP %2, %3",_grpidx,_targetPos,_tries2]}; + }; + sleep 0.05; + }; + + }; + }; + }; + }; + }; + sleep 0.05; + + + // distance to target position + _avoidPos = [0,0]; _flankPos = [0,0]; _attackPos = [0,0]; _frontPos = [0,0]; + _fm=0; + _newpos=true; + }; + }; + }; + + // if in water, get right back out of it again + if (surfaceIsWater _currPos) then { + if (_isman && !_swimming) then { + _drydist=999; + // look around, to find a dry spot + for [{_a=0}, {_a<=270}, {_a=_a+90}] do { + _dp=[_currPos,30,_a] call KRON_relPos; + if !(surfaceIsWater _dp) then {_targetPos=_dp}; + }; + _newpos=true; + _swimming=true; + }; + } else { + _swimming=false; + }; + + sleep 0.5; + + +// ********************************************************************************************************************** +// NEWPOS: SE EJECUTA LA ORDEN DE MOVIMIENTO +// ********************************************************************************************************************** +// if (KRON_UPS_Debug>0) then {player sidechat format["%1 rea=%2 wai=%3 tim=%4 tg=%5 %6",_grpidx,_react,_waiting,_timeontarget,typeof _target,alive _target]}; + if ((_waiting<=0) && _newpos) then { + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + _currPos = getpos _npc; + _newpos = false; + _waiting = -1; + _swimming=false; + _GetIn_NearestVehicles = false; + + //Gets distance to targetpos + _targetdist = [_currPos,_targetPos] call KRON_distancePosSqr; + + //If gothit and not in vehicle + if (_gothit && _npc == vehicle (_npc) && alive _npc ) then { + + //Unidad suprimida + if ((random 100) <50) then { + //if (KRON_UPS_Debug>0) then {player sidechat format["%1 supressed by fire",_grpidx]}; + + //The unit is deleted, delete the current waypoint + _supressed = true; + _targetPos = _currPos; _targettext ="SUPRESSED"; + _wptype = "HOLD"; + + //Prone + { + //Motion vanishes + if ( _x iskindof "Man" && canmove _x && alive _x) then { + if ((random 100)<40 || (primaryWeapon _x ) in KRON_UPS_MG_WEAPONS) then {[_x,"DOWN",20] spawn MON_setUnitPosTime; + }else{ [_x,"Middle"] spawn MON_setUnitPos;}; + }; + sleep 0.01; + } foreach units _npc; + + //All Retreat!! + if ((random 100)<=60 && morale _npc < 0) then { + _targetPos = _avoidPos;_targettext = "_avoidPos"; + _wptype = "MOVE"; + _flankdir = 0; + if (!_newpos && KRON_UPS_Debug>0) then {player sidechat format["%1 All Retreat!!!",_grpidx]}; + }; + }; + + if ((random 100) < 15 && _targettext == "_avoidPos" && !_nosmoke) then { + [_npc,_target] call MON_throw_grenade; + }; + sleep 0.5; + }; + + + + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + //If you have not been removed progress continue + if (alive _npc) then { + _currPos = getpos _npc; + + if ( _wptype == "MOVE") then { + + //Try to avoid stucked soldiers out of vehicles + if ( _npc == vehicle _npc) then { + { + if (alive _x && canmove _x) then { + //[_x] spawn MON_cancelstop; + [_x] dofollow _npc; + }; + } foreach _members; + }; + sleep 0.05; + + //Search for vehicle + if ((!_gothit && _targetdist >= ( KRON_UPS_searchVehicledist )) && _isSoldier && !_noveh) then { + + if ( vehicle _npc == _npc && _dist > _closeenough ) then { + + _unitsIn = [_grpid,_npc] call MON_GetIn_NearestVehicles; + + if ( count _unitsIn > 0) then { + _GetIn_NearestVehicles = true; + _speedmode = "FULL"; + _unitpos = "AUTO"; + _npc setbehaviour "SAFE"; + _npc setspeedmode "FULL"; + _timeout = time + 60; + + _vehicle = objnull; + _vehicles = []; + { + waituntil {vehicle _x != _x || !canmove _x || !canstand _x || !alive _x || time > _timeout || movetofailed _x}; + + if ( vehicle _x != _x && (isnull _vehicle || _vehicle != vehicle _x)) then { + _vehicle = vehicle _x ; + _vehicles = _vehicles + [_vehicle] + }; + }foreach _unitsIn; + sleep 1; + + { + _vehicle = _x; + _cargo = _vehicle getvariable ("UPSMON_cargo"); + if ( isNil("_cargo")) then {_cargo = [];}; + _cargo ordergetin true; + + //Wait for other groups to getin + { + waituntil {vehicle _x != _x || !canmove _x || !canstand _x || !alive _x || time > _timeout || movetofailed _x}; + } foreach _cargo; + + //Starts gunner control + nul = [_vehicle] spawn MON_Gunnercontrol; + sleep 0.1; + // nul = [_x,30] spawn MON_domove; //!R just little kick to make sure it moves + } foreach _vehicles; + + //Cheks if leader has dead until wait + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc) exitwith {_exit=true;}; + + + if ( "Air" countType [vehicle (_npc)]>0) then { + _rnd = (random 2) * 0.1; + _flyInHeight = round(KRON_UPS_flyInHeight * (0.9 + _rnd)); + vehicle _npc flyInHeight _flyInHeight; + + //If you just enter the helicopter landing site is defined + if (_GetIn_NearestVehicles) then { + _GetOutDist = round(((KRON_UPS_paradropdist ) * (random 100) / 100 ) + 150); + + [vehicle _npc, _TargetPos, _GetOutDist, 90] spawn MON_doParadrop; // org _flyInHeight + sleep 1; + //Execute control stuck for helys + [vehicle _npc] spawn MON_HeliStuckcontrol; + if (KRON_UPS_Debug>0 ) then {player sidechat format["%1: flyingheiht=%2 paradrop at dist=%3",_grpidx, _flyInHeight, _GetOutDist,_rnd]}; + }; + }; + }; + }; + }; + }; + sleep 0.05; + + + //Get in combat vehicles + if (!_gothit && !_GetIn_NearestVehicles && _fightmode != "walk" && _isSoldier) then { + _dist2 = _dist / 4; + if ( _dist2 <= 100 ) then { + _unitsIn = []; + _unitsIn = [_grpid,_npc,_dist2,false] call MON_GetIn_NearestCombat; + _timeout = time + (_dist2/2); + + if ( count _unitsIn > 0) then { + if (KRON_UPS_Debug>0 ) then {player sidechat format["%1: Geting in combat vehicle targetdist=%2",_grpidx,_npc distance _target]}; + _npc setbehaviour "SAFE"; + _npc setspeedmode "FULL"; + + { + waituntil {vehicle _x != _x || !canmove _x || !canstand _x || !alive _x || time > _timeout || movetofailed _x}; + }foreach _unitsIn; + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + //Return to combat mode + _npc setbehaviour _Behaviour; + _timeout = time + 150; + { + waituntil {vehicle _x != _x || !canmove _x || !alive _x || time > _timeout || movetofailed _x}; + }foreach _unitsIn; + + { + if ( vehicle _x iskindof "Air") then { + //moving hely for avoiding stuck + if (driver vehicle _x == _x) then { + _vehicle = vehicle (_x); + nul = [_vehicle,1000] spawn MON_domove; + //Execute control stuck for helys + [_vehicle] spawn MON_HeliStuckcontrol; + if (KRON_UPS_Debug>0 ) then {player sidechat format["%1: Geting in combat vehicle after",_grpidx,_npc distance _target]}; + }; + }; + + if (driver vehicle _x == _x) then { + //Starts gunner control + nul = [vehicle _x] spawn MON_Gunnercontrol; + }; + sleep 0.01; + }foreach _unitsIn; + }; + + }; + }; + + + + sleep 0.05; + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + //If use statics are enabled leader searches for static weapons near. + if ((KRON_UPS_useStatics && (vehicle _npc == _npc) && !_GetIn_NearestVehicles && _isSoldier ) && ((_wptype == "HOLD" && (random 100) < 80) || (_wptype != "HOLD" && (random 100) < 60))) then { + + _unitsIn = [_grpid,_npc,_buildingdist] call MON_GetIn_NearestStatic; + + if ( count _unitsIn > 0) then { + _npc setbehaviour "SAFE"; + _npc setspeedmode "FULL"; + _timeout = time + 60; + + { + waituntil {vehicle _x != _x || !canmove _x || !alive _x || time > _timeout || movetofailed _x}; + }foreach _unitsIn; + + }; + sleep 0.05; + }; + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + //Buildings usage. + if (!_GetIn_NearestVehicles) then { + if ( _wptype == "HOLD" && vehicle _npc == _npc && ( _fortify ||(random 100) < 60) ) then { + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: Moving to nearest buildings",_grpidx]}; + [_npc,_buildingdist,false,_wait] spawn MON_moveNearestBuildings; + } else { + //If we are close enough patrol in buildings for searching enemies + if ((( _wptype != "HOLD" && vehicle _npc == _npc && (random 100) < 90 ) + && _npc == vehicle _npc && _dist <= ( _closeenough ))) then { + [_npc,_buildingdist,true] spawn MON_moveNearestBuildings; + }; + }; + sleep 0.05; + }; + + // did the leader die? + _npc = [_npc,_members] call MON_getleader; + if (!alive _npc || !canmove _npc || isplayer _npc ) exitwith {_exit=true;}; + + if (isnull _grp || _grp != group _npc) then { + _grp = group _npc; + }; + + + _index = currentWaypoint _grp; + + //If the waypoing is different than it has or is different from what we set hold + IF (_wptype != "HOLD" || _lastwptype != _wptype) then { + //Has not completed or are waypoints + //_index = 1 Waypoint by default, not use. + if ( _index == 1 || _index > count waypoints _grp && !isnull _grp) then { + _wp = _grp addWaypoint [_targetPos, 0]; + _index = _wp select 1; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1: created wp %2 index %3",_grpidx,_wp, _index]}; + } else { + _wp = [_grp,_index]; + // if (KRON_UPS_Debug>0) then {player globalchat format["%1: not created wp %2 index %3 %4",_grpidx,_wp, _index,_targetPos]}; + }; + }; + + // _wp = [_grp,_index]; + + + + // if iscar the run fast if targetpost is far. + if ((!_gothit && _targetdist >= (_closeenough * 1.5)) && (vehicle _npc != _npc)) then { + _speedmode = "FULL"; + } else { + // _speedmode = _orgSpeed; + }; + + + + //We define the parameters of the new waypoint + _wp setWaypointType _wptype; + _wp setWaypointPosition [_targetPos, 0]; + _wp setWaypointFormation _wpformation; + _wp setWaypointSpeed _speedmode; + _lastwptype = _wptype; + + + //If you have more than 1 waypoints delete the obsolete + { + if ( _x select 1 < _index ) then { + deleteWaypoint _x; + }; + sleep 0.05; + } foreach waypoints _grp; + + + //if (KRON_UPS_Debug>0) then {diag_log format["%1: waypoints %2 %3 %4 %5",_grpidx,count waypoints _grp, _grp, group _npc, group (leader _npc)]}; + + //Sets behaviour + if (toupper(behaviour _npc) != toupper (_Behaviour)) then { + _npc setBehaviour _Behaviour; + }; + + //Refresh position vector + KRON_targetsPos set [_grpid,_targetPos]; + + //Although there are predefined type of movement to a small percentage will vary on an individual level + + + { + if ((random 100)<95 && _x == vehicle _x && _x iskindof "Man" && !((primaryWeapon _x ) in KRON_UPS_MG_WEAPONS)) then { + nul = [_x,_unitpos] spawn MON_setUnitPos; + }else{ + nul = [_x,"AUTO"] spawn MON_setUnitPos; + }; + } foreach units _npc; + + + //If closeenough will leave some soldiers doing supress fire + if (_gothit || _dist <= _closeenough) then { + { + if (!canStand _x || ((primaryWeapon _x ) in KRON_UPS_MG_WEAPONS) || (vehicle _x == _x && _x iskindof "Man" && (random 100) < 50) ) then { + _x suppressFor 15; + }; + } foreach units _npc; + }; + }; + + + _gothit = false; + + + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: %2 %3 %4 %5 %6 %7 %8 %9 %10",_grpidx, _wptype, _targettext,_dist, _speedmode, _unitpos, _Behaviour, _wpformation,_fightmode,count waypoints _grp];}; + }; + + if (_track=="TRACK") then { + switch (_fm) do { + case 1: + {_destname setmarkerSize [.4,.4]}; + case 2: + {_destname setmarkerSize [.6,.6]}; + default + {_destname setmarkerSize [.5,.5]}; + }; + _destname setMarkerPos _targetPos; + + }; + + //If in hely calculations must done faster + if (_isplane || _inheli) then { + _currcycle = _cycle/2; + _flyInHeight = KRON_UPS_flyInHeight; + vehicle _npc flyInHeight _flyInHeight; + + }; + + if ((_exit) || (isNil("_npc"))) then { + _loop=false; + } else { + // slowly increase the cycle duration after an incident + sleep _currcycle; + }; + +}; //while {_loop} + + + if (KRON_UPS_Debug>0) then {hint format["%1 exiting mainloop",_grpidx]}; + + //Limpiamos variables globales de este grupo + KRON_targetsPos set [_grpid,[0,0]]; + KRON_NPCs set [_grpid,objnull]; + KRON_UPS_Exited=KRON_UPS_Exited+1; + + if (_track=="TRACK") then { + //_trackername setMarkerType "Dot"; + _trackername setMarkerType "Empty"; + _destname setMarkerType "Empty"; + }; + + //Gets dist from orinal pos + if (!isnull _target) then { + _dist = ([_orgpos,position _target] call KRON_distancePosSqr); + }; + // if (KRON_UPS_Debug>0) then {player sidechat format["%1 _dist=%2 _closeenough=%3",_grpidx,_dist,_closeenough]}; + + //does respawn of group ===================================================================================================== + if (_respawn && _respawnmax > 0 && !_surrended && _dist > _closeenough) then { + if (KRON_UPS_Debug>0) then {player sidechat format["%1 doing respawn",_grpidx]}; + + // copy group leader + _unittype = _membertypes select 0; + + // make the clones civilians + // use random Civilian models for single unit groups + if ((_unittype=="Civilian") && (count _members==1)) then {_rnd=1+round(random 20); if (_rnd>1) then {_unittype=format["Civilian%1",_rnd]}}; + + _grp=createGroup _side; + _lead = _grp createUnit [_unittype, _orgpos, [], 0, "form"]; + _lead setVehicleInit _initstr; + [_lead] join _grp; + _grp selectLeader _lead; + + // copy team members (skip the leader) + _i=0; + { + _i=_i+1; + if (_i>1) then { + _newunit = _grp createUnit [_x, _orgpos, [],0,"form"]; + _newunit setVehicleInit _initstr; + [_newunit] join _grp; + sleep 0.1; + }; + } foreach _membertypes; + + + if ( _lead == vehicle _lead) then { + { + if (alive _x && canmove _x) then { + [_x] dofollow _lead; + }; + sleep 0.1; + } foreach units _lead; + }; + + { + _targetpos = _orgpos findEmptyPosition [10, 200]; + sleep .4; + if (count _targetpos <= 0) then {_targetpos = _orgpos}; + //if (KRON_UPS_Debug>0) then {player globalchat format["%1 create vehicle _newpos %2 ",_x,_targetpos]}; + _newunit = _x createvehicle (_targetpos); + } foreach _vehicletypes; + + + //if (KRON_UPS_Debug>0) then {player globalchat format["%1 _vehicletypes: %2",_grpidx, _vehicletypes]}; + + //Set new parameters + if (!_spawned) then { + + _UCthis = _UCthis + ["SPAWNED"]; + + if ((count _vehicletypes) > 0) then { + _UCthis = _UCthis + ["VEHTYPE:"] + ["dummyveh"]; + }; + }; + + + _UCthis set [0,_lead]; + _respawnmax = _respawnmax - 1; + _UCthis = ["RESPAWN:",_respawnmax,_UCthis] call KRON_UPSsetArg; + sleep 0.1; + _UCthis = ["VEHTYPE:",_vehicletypes,_UCthis] call KRON_UPSsetArg; + + + // if (KRON_UPS_Debug>0) then {player globalchat format["%1 _UCthis: %2",_grpidx,_UCthis]}; + //Exec UPSMON script + _UCthis SPAWN UPSMON; + sleep 0.1; + processInitCommands; + }; + + _friends=nil; + _enemies=nil; + _enemytanks = nil; + _friendlytanks = nil; + _roads = nil; + _targets = nil; + _members = nil; + _membertypes = nil; + _UCthis = nil; + + if (!alive _npc) then { + deleteGroup _grp; + }; \ No newline at end of file diff --git a/Server/Module/UPSMON/UPSMON/!R/R_functions.sqf b/Server/Module/UPSMON/UPSMON/!R/R_functions.sqf new file mode 100644 index 0000000..396892f --- /dev/null +++ b/Server/Module/UPSMON/UPSMON/!R/R_functions.sqf @@ -0,0 +1,343 @@ +/* + autor: !R + + 5.1.0 +*/ + + + +// get new position [x,y,x] from pos in distance and angle. +// [_pos, _distance, _angle] call R_relPos3D; +// [newX,newY,Z] +R_relPos3D = + { + private["_p","_d","_a","_x","_y","_z","_xout","_yout"]; + _p=_this select 0; + _x=_p select 0; + _y=_p select 1; + _z=_p select 2; + _d=_this select 1; + _a=_this select 2; + _xout=_x + sin(_a) * _d; + _yout=_y + cos(_a) * _d; + [_xout,_yout,_z] + }; + + +// [_unit] spawn R_ThrowSmoke; +R_ThrowSmoke = + { + private ["_unit","_shell", + "_moves","_unitPos","_pos","_flare","_direction"]; + + /* + _stanThrow = ["AwopPercMstpSgthWrflDnon_Start1", "AwopPercMstpSgthWrflDnon_Throw1","AwopPercMstpSgthWrflDnon_End1"]; + _kneeThrow = ["AwopPknlMstpSgthWrflDnon_Start", "AwopPknlMstpSgthWrflDnon_Throw" ,"AwopPknlMstpSgthWrflDnon_End"]; + _proneThrow= ["AwopPpneMstpSgthWrflDnon_Start", "AwopPpneMstpSgthWrflDnon_Throw" ,"AwopPpneMstpSgthWrflDnon_End"]; + */ + + _moves = ["AwopPercMstpSgthWrflDnon_Start1","AwopPknlMstpSgthWrflDnon_Start","AwopPpneMstpSgthWrflDnon_Start"]; + + _unit = _this select 0; + _shell = "SmokeShell"; + _unitPos = unitPos _unit; + + //Animation + switch (_unitPos) do { + + case "Auto": + { + _unit playMove (_moves select 1); + }; + + case "Up": + { + _unit playMove (_moves select 0); + }; + + case "Middle": + { + _unit playMove (_moves select 1); + }; + + case "Down": + { + _unit playMove (_moves select 2); + }; + }; + + sleep 4; + _direction = direction _unit; + + // use such bypass as setvelocity does not work in MP + _pos = position _unit; + _pos = [(_pos select 0),(_pos select 1),(_pos select 2)+1.5]; + _pos = [_pos, 18, _direction] call R_relPos3D; + + if (alive _unit && canmove _unit) then { + _flare = _shell createVehicle _pos; + }; + + // setvelocity does not work in MP http://dev-heaven.net/issues/17949 + /* + _vector = [18,direction _unit,0] call C B A_fnc_polar2vect; + + _pos=position _unit; + _pos=[(_pos select 0),(_pos select 1),(_pos select 2)+2]; + _flare = _shell createVehicle _pos; + _flare setPos _pos; + _flare setvelocity _vector; + + */ + }; + + + + // [_unit] call R_FN_deleteObsoleteWaypoints; + // leave only the last way point + R_FN_deleteObsoleteWaypoints = + { + private ["_unit","_grp"]; + + _unit = _this select 0; + _grp = group _unit; + while {(count (waypoints _grp)) > 1} do + { + deleteWaypoint ((waypoints _grp) select 0); + }; + }; + + + + // array = [_npc] call R_FN_vehiclesUsedByGroup; + // return array of vehicles used by group + R_FN_vehiclesUsedByGroup = + { + private ["_npc","_vehicles"]; + + _npc = _this select 0; + _vehicles = []; + + if (!alive _npc) exitwith {}; + + { + if (( vehicle _x != _x || !(_x iskindof "Man")) && !((vehicle _x) in _vehicles)) then { + _vehicles = _vehicles + [vehicle _x]; + }; + } foreach units _npc; + + _vehicles + }; + + + // array = [_vehicle] call R_FN_unitsInCargo; + // array of units in cargo of the vehicle (in vehicle and assigned as cargo) + R_FN_unitsInCargo = + { + private ["_vehicle","_x","_unitsInCargo"]; + + _vehicle = _this select 0; + _unitsInCargo = []; + { + if( (assignedVehicleRole _x) select 0 == "Cargo") then + { + _unitsInCargo = _unitsInCargo + [_x]; + }; + } forEach crew _vehicle; + + _unitsInCargo + }; + + + + + + // array = [_npc] call R_FN_allUnitsInCargo; + // array of all units in cargo of the group (not driver, commander or gunner) + R_FN_allUnitsInCargo = + { + private ["_npc","_vehicles","_unitsInCargo","_allUnitsInCargo"]; + + _npc = _this select 0; + if (!alive _npc) exitwith {}; + + _allUnitsInCargo =[]; + + _vehicles = [_npc] call R_FN_vehiclesUsedByGroup; + + { + _unitsInCargo = [_x] call R_FN_unitsInCargo; + _allUnitsInCargo = _allUnitsInCargo + _unitsInCargo; + + } foreach _vehicles; + + _allUnitsInCargo + }; + + + // old MON_GetOutDist + // <- _npc + // <- _targetPos: position for exiting(if no waypoint used) + // <- _atdist: minimal dist to the _targetpos do getout + // -> nothing + // nul = [_npc,_targetpos,_atdist] spawn R_SN_GetOutDist; + R_SN_GetOutDist = { + private["_vehicle","_npc","_target","_atdist","_getout","_dogetout","_driver","_commander","_targetpos","_dist","_vehpos","_vehicles"]; + + _npc = _this select 0; + _targetpos = _this select 1; + _atdist = _this select 2; // minimal dist to the target to do getOut + + _dogetout = []; // units to do getout + _vehicles = []; // vehs used by the group + + if (!alive _npc) exitwith{}; + + _vehicle = vehicle _npc; + _vehpos = getpos _vehicle; + + _dist = round([_vehpos,_targetpos] call KRON_distancePosSqr); // dist to the target + + // if (KRON_UPS_Debug>0) then {player sidechat format["%1: Getoutdist dist=%2 atdist=%3 ",typeof _vehicle,_dist, _atdist]}; + + // if _npc is in vehicle + if ( _vehicle != _npc || !(_npc iskindof "Man")) then { + + if ( (_dist) <= _atdist ) then { + _vehicles = [_npc] call R_FN_vehiclesUsedByGroup; // vehicles use by the group + { + _dogetout = [_x] call R_FN_unitsInCargo; // units cargo in the vehicle + _driver = driver _x; + + if ( count _dogetout > 0 ) then { + //Stop the veh for 5.5 sek + nul = [_vehicle,5] spawn MON_doStop; + + sleep 0.8; // give time to actualy stop + + { + _x spawn MON_GetOut; + sleep 0.3; + } foreach _dogetout; + + //We removed the id to the vehicle so it can be reused + _x setVariable ["UPSMON_grpid", 0, false]; + _x setVariable ["UPSMON_cargo", [], false]; + + [_npc,_x, _driver] spawn MON_checkleaveVehicle; // if every one outside, make sure driver can walk + sleep 0.01; + }; + } foreach _vehicles; + }; + }; + }; + + // #define GOTHIT(X) ([X] call R_FN_GOTHIT) + // nul = [_grpId] call R_FN_GOTHIT; + R_FN_GOTHIT = + { + _grpId = _this select 0; + if ((R_GOTHIT_ARRAY select _grpId) != 0) then + { + true + } + else + { + false + } + }; + + // use in gothit proces + // nul = [_unit, _shooter] spawn R_SN_EHHIT; + R_SN_EHHIT = + { + private ["_unit","_shooter","_grpId"]; + _unit = _this select 0; + _shooter = _this select 1; + _grpId = _unit getVariable ("UPSMON_grpid"); + + if ((side _unit != side _shooter) && (R_GOTHIT_ARRAY select _grpId) == 0) then + { + R_GOTHIT_ARRAY set [_grpId, 1]; + // if (KRON_UPS_Debug > 0) then {player globalchat format["UNIT: %1, SHOOTER :%2 %3",_unit,_shooter,side _shooter]}; + }; + }; + + + // use in gothit proces + // nul = [_unit, _shooter] spawn R_SN_EHKILLED; + R_SN_EHKILLED = + { + private ["_unit","_shooter","_grpId"]; + + _unit = _this select 0; + _shooter = _this select 1; + _grpId = _unit getVariable ("UPSMON_grpid"); + + if ((side _unit != side _shooter) && (R_GOTHIT_ARRAY select _grpId) == 0) then + { + R_GOTHIT_ARRAY set [_grpId, 2]; + // if (KRON_UPS_Debug > 0) then {player globalchat format["UNIT: %1, SHOOTER :%2 %3",_unit,_shooter,side _shooter]}; + }; + }; + + + // logic is needed to display rGlobalChat + private ["_center","_group"]; + _center = createCenter sideLogic; _group = createGroup _center; + R_Logic_civkill = _group createUnit ["LOGIC", [2,2,1], [], 0, "NONE"]; + _group = nil; + _center = nil; + + + // used in gothit proces + // nul = [_unit, _shooter] spawn R_SN_EHKILLEDCIV; + R_SN_EHKILLEDCIV = + { + private ["_killer","_side"]; + _killer = _this select 1; + + //only if player killed a civilian + if (isPlayer _killer) then { + + KILLED_CIV_COUNTER set [0,(KILLED_CIV_COUNTER select 0) + 1]; + + // if (KRON_UPS_Debug > 0) then {player globalchat format["KILLER: %1, %2", side _killer,KILLED_CIV_COUNTER ]}; + switch (side _killer) do + { + case west: + { + KILLED_CIV_COUNTER set [1,(KILLED_CIV_COUNTER select 1) + 1]; + }; + + case east: + { + KILLED_CIV_COUNTER set [2,(KILLED_CIV_COUNTER select 2) + 1]; + }; + + case resistance: + { + KILLED_CIV_COUNTER set [3,(KILLED_CIV_COUNTER select 3) + 1]; + }; + }; + KILLED_CIV_COUNTER set [4,_killer]; + + //if (KRON_UPS_Debug > 0) then {player globalchat format["KILLER: %1", side _killer ]}; + if (KRON_UPS_Debug > 0) then {player globalchat format["KILLED_CIV_COUNTER: %1",KILLED_CIV_COUNTER]}; + if (R_WHO_IS_CIV_KILLER_INFO > 0) then { + [R_Logic_civkill, nil , rglobalChat, format ["A CIVILIAN WAS KILLED BY %1",_killer]] call RE; + }; + }; + }; + + + //firedNear + R_SN_EHFIREDNEAR = + { + private ["_civ"]; + _civ = leader (_this select 0); + _civ setspeedmode "FULL"; + }; + + + \ No newline at end of file diff --git a/Server/Module/UPSMON/UPSMON/!R/markerAlpha.sqf b/Server/Module/UPSMON/UPSMON/!R/markerAlpha.sqf new file mode 100644 index 0000000..7b0ea31 --- /dev/null +++ b/Server/Module/UPSMON/UPSMON/!R/markerAlpha.sqf @@ -0,0 +1,14 @@ +/* ============================================= + !R + Hide area markers. + + create Game Logic Object + put in initialization field: + + nul = call compile preprocessFile "scripts\UPSMON\!R\markerAlpha.sqf"; + + all markers area must be named area0, area1...area13 + +================================================= */ + +{ _x setmarkeralpha 0; } foreach ["area0", "area1", "area2","area3","area4","area5","area6","area7","area8","area9","area10","area11","area12","area13"]; \ No newline at end of file diff --git a/Server/Module/UPSMON/UPSMON/MON_artillery_add.sqf b/Server/Module/UPSMON/UPSMON/MON_artillery_add.sqf new file mode 100644 index 0000000..ecaec71 --- /dev/null +++ b/Server/Module/UPSMON/UPSMON/MON_artillery_add.sqf @@ -0,0 +1,64 @@ +/* ===================================================================================================== + MON_spawn.sqf + Author: Monsada (chs.monsada@gmail.com) + Comunidad Hispana de Simulación: + http://www.simulacion-esp.com + ===================================================================================================== + Parámeters: [_artillery,(_range,_rounds,_area,_cadence,_mincadence)] execvm "scripts\UPSMON\MON_artillery_add.sqf"; + <- _artillery object to attach artillery script, must be an object with gunner. + <- ( _rounds ) rounds to fire each time, default 1 + <- ( _range ) range of artillery, default 800 + <- ( _area ) Dispersion area, 150m by default + <- ( _maxcadence ) Cadence of fire, is random between min, default 10s + <- ( _mincadence ) Minimum cadence, default 5s + <- ( _bullet ) Class of bullet to fire, default ARTY_Sh_81_HE + ===================================================================================================== + 1. Place a static weapon on map. + 2. Exec module in int of static weapon + + nul=[this] execVM "scripts\UPSMON\MON_artillery_add.sqf"; + + 1. Be sure static weapon has a gunner or place a "fortify" squad near, this will make squad to take static weapon. + 2. Create a trigger in your mission for setting when to fire. Set side artillery variable to true: + + KRON_UPS_ARTILLERY_EAST_FIRE = true; + + This sample will do east artilleries to fire on known enemies position, when you want to stop fire set to false. + + For more info: + http://dev-heaven.net/projects/upsmon/wiki/Artillery_module + =====================================================================================================*/ +if (!isserver) exitWith {}; + +//Waits until UPSMON is init +waitUntil {!isNil("KRON_UPS_INIT")}; +waitUntil {KRON_UPS_INIT==1}; + +private ["_artillery","_smoke1","_i","_area","_position","_maxcadence","_mincadence","_sleep","_rounds","_dummypos","_salvobreak"]; +_range = 800; +_area = 150; +_maxcadence = 10; +_mincadence = 5; +_sleep = 0; +_rounds = 1; +_bullet = "ARTY_Sh_81_HE"; +_vector =[]; +_salvobreak = 10; + +_artillery = _this select 0; +//if (KRON_UPS_Debug>0) then {player globalchat format["MON_artillery_add before %1 %2 %3",isnull _artillery,alive _artillery]}; +if (isnull _artillery || !alive _artillery) exitwith{}; +if ((count _this) > 1) then {_rounds = _this select 1;}; +if ((count _this) > 2) then {_range = _this select 2;}; +if ((count _this) > 3) then {_area = _this select 3;}; +if ((count _this) > 4) then {_maxcadence = _this select 4;}; +if ((count _this) > 5) then {_mincadence = _this select 5;}; +if ((count _this) > 6) then {_bullet = _this select 6;}; +if ((count _this) > 7) then {_salvobreak = _this select 7;}; +//Add artillery to array of artilleries +_vector = [_artillery,_rounds,_range,_area,_maxcadence,_mincadence,_bullet,_salvobreak]; +if (isnil "KRON_UPS_ARTILLERY_UNITS" ) then {KRON_UPS_ARTILLERY_UNITS = []}; +KRON_UPS_ARTILLERY_UNITS = KRON_UPS_ARTILLERY_UNITS + [_vector]; + +_dummypos = [getpos _artillery, 50, getdir _artillery] call R_relPos3D; +(gunner _artillery) lookAt [_dummypos select 0, _dummypos select 1,(_dummypos select 2)+100]; diff --git a/Server/Module/UPSMON/UPSMON/MON_spawn.sqf b/Server/Module/UPSMON/UPSMON/MON_spawn.sqf new file mode 100644 index 0000000..e952752 --- /dev/null +++ b/Server/Module/UPSMON/UPSMON/MON_spawn.sqf @@ -0,0 +1,115 @@ +/* ===================================================================================================== + MON_spawn.sqf + Author: Monsada (chs.monsada@gmail.com) + Comunidad Hispana de Simulación: + http://www.simulacion-esp.com + ===================================================================================================== + Parámeters: [Param1,Param2,Param3,[Param4]] EXECVM "SCRIPTS\UPSMON\MON_SPAWN.SQF"; + <- Param1 Id of the template to copy. + <- Param2 Position to create new squad. + <- Param3 Nş of squads to create + <- Param4 Array of parameters of UPSMON, first must be name of marc to patrol + ===================================================================================================== + Function that allows to spawn UPSMON squads. + + 1- create a squad in editor. Exec UPSMON and set TEMPLATE id, this will save members of squad, not equipement. + nul = [this,"town","TEMPLATE:",1] execVM "scripts\upsmon.sqf"; + 2- Exec MON_spawn on trigger or where you want telling the copy of the template to create + and the position. + nul = [1,[0,0,0],3,[mark, upsmon optional params]] EXECVM "SCRIPTS\UPSMON\MON_SPAWN.SQF"; + =====================================================================================================*/ +if (!isserver) exitWith {}; + +//Waits until UPSMON is init +waitUntil {!isNil("KRON_UPS_INIT")}; +waitUntil {KRON_UPS_INIT==1}; +private ["_template","_position","_params","_copies","_membertypes","_unittype","_side","_UCthis","_initstr","_grp","_lead","_newunit","_i","_newpos","_vehicle","_initlstr"]; + +//Parameter reading +_template = _this select 0; +_position = _this select 1; +_copies = _this select 2; +_params = _this select 3; + +//Initialization +_membertypes = []; +_side = ""; +_UCthis = []; +_initstr = ""; +_initlstr = ""; +_grp = grpnull; +_lead = objnull; +_newunit = objnull; +_newpos=[]; +_vehicle=[]; + +//Gets parameters of UPSMON +for [{_i=0},{_i0) then {player globalchat format["Spawning %3 copies of template %1",_template,_position,_copies,count KRON_UPS_TEMPLATES]}; +//if (KRON_UPS_Debug>0) then {diag_log format["Spawning %3 copies of template %1 on %2 templates %4",_template,_position,_copies,count KRON_UPS_TEMPLATES]}; + +//Search if any template +{ + if ((_x select 0) == _template) then { + _side = _x select 1; + _membertypes = _x select 2; + _vehicletypes = _x select 3; + //Gets leader type + _unittype= _membertypes select 0; + + //if (KRON_UPS_Debug>0) then {player globalchat format["template %1:%2 ",_template,_membertypes]}; + + for [{_i=1},{_i<=_copies},{_i=_i+1}] do { + + // make the clones civilians + // use random Civilian models for single unit groups + if ((_unittype=="Civilian") && (count _members==1)) then {_rnd=1+round(random 20); if (_rnd>1) then {_unittype=format["Civilian%1",_rnd]}}; + + _grp=createGroup _side; + + _lead = _grp createUnit [_unittype, _position, [], 0, "form"]; + _lead setVehicleInit _initlstr; + [_lead] join _grp; + _grp selectLeader _lead; + sleep 1; + + // copy team members (skip the leader) + _c=0; + { + _c=_c+1; + if (_c>1) then { + _newpos = _position findEmptyPosition [10, 200]; + sleep .4; + if (count _newpos <= 0) then {_newpos = _position}; + _newunit = _grp createUnit [_x, _newpos, [],0,"form"]; + _newunit setVehicleInit _initstr; + [_newunit] join _grp; + }; + } foreach _membertypes; + + + { + _newpos = _position findEmptyPosition [10, 200]; + sleep .4; + if (count _newpos <= 0) then {_newpos = _position}; + _newunit = _x createvehicle (_newpos); + } foreach _vehicletypes; + + //Set new parameters + _params = [_lead] + _UCthis; + + //Exec UPSMON script + _params SPAWN UPSMON; + + processInitCommands; + }; + }; +}foreach KRON_UPS_TEMPLATES; + +if (true) exitwith{}; diff --git a/Server/Module/UPSMON/UPSMON/MON_surrended.sqf b/Server/Module/UPSMON/UPSMON/MON_surrended.sqf new file mode 100644 index 0000000..15c4ee7 --- /dev/null +++ b/Server/Module/UPSMON/UPSMON/MON_surrended.sqf @@ -0,0 +1,23 @@ +// ========================================================================================================= +// Script for adding the action of follow player. +// Version: 1.0 +// Author: Monsada (smirall@hotmail.com) +// --------------------------------------------------------------------------------------------------------- +private ["_side","_soldiers"]; +_side = _this select 0; + +_soldiers = switch (_side) do { + case west: {KRON_AllWest}; + case east: {KRON_AllEast}; + case resistance: {KRON_AllRes}; +}; + +{ + if ( leader _x == _x ) then { + _x addaction ["Order your men to follow me", "scripts\UPSMON\actions\followme.sqf", [], 1, false]; + } else { + _x addaction ["Follow me", "scripts\UPSMON\actions\followme.sqf", [], 1, false]; + }; +}foreach _soldiers; + +if (true) exitWith {}; diff --git a/Server/Module/UPSMON/UPSMON/actions/followme.sqf b/Server/Module/UPSMON/UPSMON/actions/followme.sqf new file mode 100644 index 0000000..1d325c5 --- /dev/null +++ b/Server/Module/UPSMON/UPSMON/actions/followme.sqf @@ -0,0 +1,93 @@ +// ========================================================================================================= +// Script for action follow me when surrended, adds the soldier to player squad in a random choice. +// Version: 1.0 +// Author: Monsada (smirall@hotmail.com) +// --------------------------------------------------------------------------------------------------------- +private ["_obj","_caller","_id","_objtype","_rnd","_join","_direction"]; +_npc = _this select 0; +_caller = _this select 1; +_id = _this select 2; + +_rnd = 0; +_join=true; +_npc switchmove ""; + +_direction = ((getpos _caller select 0) - (getpos _npc select 0)) atan2 ((getpos _caller select 1) - (getpos _npc select 1)); + +//If positive values are needed then use: +if(_direction < 0) then {_direction = _direction + 360}; +_npc setdir _direction; +_npc dowatch _caller; +_npc setSpeedMode "LIMITED"; +_npc domove position _caller; + + +sleep 0.5; + +_rnd = random 100; +_npc setmimic "Sad"; + +if (_rnd <= 30 ) then { + _npc globalchat "Ok"; +}; + +if (_rnd > 30 && _rnd <= 50) then { + _npc globalchat "Yes"; +}; + + +if (_rnd > 50 && _rnd <= 100) then { + _join=false; + _rnd = random 100; + + if (_rnd < 20) then { + _npc setmimic "angry"; + _npc switchmove "CtsPercMstpSnonWnonDnon_idle31rejpaniVnose"; + _npc globalchat "Kiss my ass"; + }; + + if (_rnd > 20 && _rnd <= 40) then { + _npc setmimic "Agresive"; + _npc switchmove "CtsPercMstpSnonWnonDnon_idle33rejpaniVzadku"; + sleep 3; + _npc globalchat "Que te den"; + }; + + if (_rnd > 40 && _rnd <= 60) then { + _npc setmimic "Agresive"; + _npc switchmove "CtsPercMstpSnonWnonDnon_idle33rejpaniVzadku"; + sleep 1; + _npc globalchat "Fuck you"; + }; + + if (_rnd > 60 && _rnd <= 80) then { + _npc setmimic "Agresive"; + _npc switchmove "CtsPercMstpSnonWnonDnon_idle32podrbaniNanose"; + sleep 0.5; + _npc globalchat "Follow your mother"; + }; + + if (_rnd > 80 && _rnd <= 100) then { + _npc setmimic "angry"; + sleep 0.1; + _npc switchmove "CtsPercMstpSnonWnonDnon_idle32podrbaniNanose"; + _npc globalchat "Fuck you"; + }; +}; + +if (_join) then { + // remove the action once it is activated + _npc stop false; + if (_npc == leader _npc) then { + _npc globalchat "All follow that man"; + { + _x switchmove ""; + [_x] joinSilent _caller; + }foreach units _npc; + } else { + _npc removeAction _id; + [_npc] joinSilent _caller; + }; +}; + +if (true) exitWith {}; diff --git a/Server/Module/UPSMON/UPSMON/common/MON_functions.sqf b/Server/Module/UPSMON/UPSMON/common/MON_functions.sqf new file mode 100644 index 0000000..8adf336 --- /dev/null +++ b/Server/Module/UPSMON/UPSMON/common/MON_functions.sqf @@ -0,0 +1,2204 @@ +// ========================================================================================================= +// Biblioteca de funciones comunes +// Version: 5.1.0 +// Author: Monsada (smirall@hotmail.com) +// http://www.simulacion-esp.com/ +// Comunidad Hispana de Simulación +// ========================================================================================================= + +MON_bugged_vehicles = ["BIS_alice_emptydoor","ACE_Grenade_Geometry"]; + +// in Vanilia extra bugged vehicle +if !(AcePresent) then { + MON_bugged_vehicles = MON_bugged_vehicles + ["HMMWV_M998A2_SOV_DES_EP1"]; +}; + +// --------------------------------------------------------------------------------------------------------- +//Función que permite posicionar objetos a la altura definida +//param1: objeto +//param2: altura +MON_subir = { +if (!isserver) exitwith{}; +private ["_object","_altura","_pos","_x","_y","_z","_bld","_bldpos"]; + +_object = _this select 0; +_altura = _this select 1; + +_x = 0; +_y = 0; +_z = 0; +_pos =0; +_bld = objnull; +_bldpos =0; + +_pos = getposasl _object; + +_x = _pos select 0; +_y = ( _pos select 1 ); +_z = ( _pos select 2 ) + _altura; +_object setposasl [_x,_y ,_z]; +}; +//Retorna la dirección entre dos posiciones +MON_getDirPos = {private["_a","_b","_from","_to","_return"]; _from = _this select 0; _to = _this select 1; _return = 0; _a = ((_to select 0) - (_from select 0)); _b = ((_to select 1) - (_from select 1)); if (_a != 0 || _b != 0) then {_return = _a atan2 _b}; if ( _return < 0 ) then { _return = _return + 360 }; _return}; +// --------------------------------------------------------------------------------------------------------- +//Función de borra unidades que han sido matadas +//param1: objeto a borrar cuando muera +//param2: tiempo a esperar antes de borrar el objeto +MON_deleteDead = {private["_u","_s"];_u=_this select 0; _s= _this select 1; _u removeAllEventHandlers "killed"; sleep _s; deletevehicle _u}; +MON_deleteDeadDist = {private["_u","_s","_dist","_OCercanos","_cicle","_deleted","_isplayer"]; + _i = 0; + _cicle = 10; + _deleted = false; + _isplayer = false; + _u = _this select 0; _s = _this select 1; _dist = _this select 2; + _u removeAllEventHandlers "killed"; + sleep _s; + + while {!_deleted} do { + _isplayer = false; + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_u, ["Man"] , _dist]; + + //Validamos si alguno de los soldados cerca es un jugador y está vivo + {if (isplayer _x && alive _x) exitwith {_isplayer = true;}}foreach _OCercanos; + + if (!_isplayer) then { + deletevehicle _u; + _deleted = true; + }; + sleep _cicle; + }; +}; +// --------------------------------------------------------------------------------------------------------- +//Función tomada de UPS, busca el comando en la lista y devuelve el siguiente elemento +//param1: comando a buscar +//param2: valor por defecto del comando +//param3: array con los comandos +//Retorna valor del comando encontrado o valor por defecto +MON_getArg = {private["_cmd","_arg","_list","_a","_v"]; _cmd=_this select 0; _arg=_this select 1; _list=_this select 2; _a=-1; {_a=_a+1; _v=format["%1",_list select _a]; +if (_v==_cmd) then {_arg=(_list select _a+1)}} foreach _list; _arg}; + +// --------------------------------------------------------------------------------------------------------- +//Función que devuelve una posición en 3D a partir de otra, una dirección y una distancia +//param1: posición +//param2: dirección +//param3: distancia +//Retorna vector de posicion en 3D [0,0,0] +MON_GetPos = +{ + private ["_pos","_dir","_dist","_cosU","_cosT","_relTX","_sinU","_sinT","_relTY","_newPos","_newPosX","_newPosY", "_targetZ" ]; + _pos = _this select 0; + _dir = _this select 1; + _dist = _this select 2; + + _targetX = _pos select 0; _targetY = _pos select 1; _targetZ = _pos select 2; + + //Calculamos posición + _cosU = [_dir] call MON_GetCOS; _sinU = [_dir] call MON_GetSIN; + _cosT = abs cos(_dir); _sinT = abs sin(_dir); + _relTX = _sinT * _dist * _cosU; _relTY = _cosT * _dist * _sinU; + _newPosX = _targetX + _relTX; _newPosY = _targetY + _relTY; + _newPos = [_newPosX,_newPosY,_targetZ]; + _newPos; +}; + +// --------------------------------------------------------------------------------------------------------- +//Función que devuelve una posición en 2D a partir de otra, una dirección y una distancia +//param1: posición +//param2: dirección +//param3: distancia +//Retorna vector de posicion en 2D [0,0] +MON_GetPos2D = +{ + private ["_pos","_dir","_dist","_cosU","_cosT","_relTX","_sinU","_sinT","_relTY","_newPos","_newPosX","_newPosY" ]; + _pos = _this select 0; + _dir = _this select 1; + _dist = _this select 2; + + _targetX = _pos select 0; _targetY = _pos select 1; + + //Calculamos posición + _cosU = [_dir] call MON_GetCOS; _sinU = [_dir] call MON_GetSIN; + _cosT = abs cos(_dir); _sinT = abs sin(_dir); + _relTX = _sinT * _dist * _cosU; _relTY = _cosT * _dist * _sinU; + _newPosX = _targetX + _relTX; _newPosY = _targetY + _relTY; + _newPos = [_newPosX,_newPosY]; + _newPos; +}; + +// --------------------------------------------------------------------------------------------------------- +//Función que devuelve las posiciones que se pueden ocupar dentro de un edificio +//param1: objeto location +//Retorna numero de posiciones que tiene el edificio +MON_BldPos = {private ["_bld","_bldpos"]; + _bld=_this; _bldpos = 1; + while {format ["%1", _bld buildingPos _bldpos] != "[0,0,0]"} do {_bldpos = _bldpos + 1;}; + _bldpos = _bldpos - 1; _bldpos;}; + +// --------------------------------------------------------------------------------------------------------- +//Función que devuelve la casa que hay más cerca del objeto param1 y las posiciones que se pueden ocupar dentro de ella. +//param1: objeto +//Retorna vector con [objeto location, posiciones que tiene] +MON_PosInfo = { + private["_obj","_bld","_bldpos"]; + _obj=_this; + _bld = nearestbuilding _obj; + _bldpos= _bld call MON_BldPos; + [_bld,_bldpos]; + }; + +// --------------------------------------------------------------------------------------------------------- +//Función que devuelve el valor negativo o positivo del seno en base a un angulo +MON_GetSIN = { + private["_dir","_sin","_cos"]; + _dir=_this select 0; + if (_dir<90) then + { + _sin=1; + } else + { + if (_dir<180) then + { + _sin=-1; + } else + { + if (_dir<270) then + { + _sin=-1; + } + else + { + _sin=1; + }; + }; + }; + _sin +}; + +// --------------------------------------------------------------------------------------------------------- +//Función que devuelve el valor negativo o positivo del coseno en base a un angulo +MON_GetCOS = { + private["_dir","_cos"]; + _dir=_this select 0; + if (_dir<90) then + { + _cos=1; + } else + { + if (_dir<180) then + { + _cos=1; + } else + { + if (_dir<270) then + { + _cos=-1; + } + else + { + _cos=-1; + }; + }; + }; + _cos +}; + +//Función que busca vehiculos cercanos y hace entrar a las unidades del lider +//Parámeters: [_grpid,_npc] +// <- _grpid: id of group to assign to vehicle +// <- _npc: lider +// -> _getin: true if any getin +MON_GetIn_NearestVehicles = { + private["_vehicles","_npc","_units","_unitsIn","_grpid","_getin"]; + _grpid = _this select 0; + _npc = _this select 1; + + _vehicles=[[]]; + _air=[[]]; + _units = []; + _unitsIn = []; + _getin=false; + + if (leader _npc == _npc) then { + _units = units _npc; + } else + { + _units = _units + [_npc]; + }; + + { + if ( (_x!= vehicle _x && !((vehicle _x) iskindof "StaticWeapon" )) || !(_x iskindof "Man") || !alive _x || !canmove _x || !canstand _x) then {_units = _units-[_x];}; + }foreach _units; + + _unitsIn = _units; + + //First catch combat vehicles + if ( (count _units) > 0) then { + _air = [_npc,200] call MON_NearestsAirTransports; + {if (_npc knowsabout (_x select 0) <= 0.5) then{ _air = _air - [_x]};}foreach _air; + _units = [_grpid, _units, _air, false] call MON_selectvehicles; + }; + sleep 0.05; + if ( (count _units) > 1) then { + _vehicles = [_npc,200,true] call MON_NearestsLandCombat; + {if (_npc knowsabout(_x select 0) <= 0.5) then{ _vehicles = _vehicles - [_x]};}foreach _vehicles; + _units = [_grpid, _units, _vehicles, false] call MON_selectvehicles; + }; + sleep 0.05; + if ( (count _units) > 0) then { + _vehicles = [_npc,200] call MON_NearestsLandTransports; + {if (_npc knowsabout (_x select 0) <= 0.5) then{ _vehicles = _vehicles - [_x]};}foreach _vehicles; + _units = [_grpid, _units, _vehicles, false] call MON_selectvehicles; + }; + sleep 0.05; + if ( (count _units) > 0 && (count _vehicles) > 0) then { + sleep 1; + _vehicles = _vehicles + _air; + _units = [_grpid, _units, _vehicles, true] call MON_selectvehicles; + }; + sleep 0.05; + _unitsIn = _unitsIn - _units; + + _unitsIn; + //sleep 0.05; +}; + +//Función que busca vehiculos cercanos y hace entrar a las unidades del lider +//Parámeters: [_grpid,_npc] +// <- _grpid: id of group to assign to vehicle +// <- _npc: lider +// -> _getin: true if any getin +MON_GetIn_NearestCombat = { + private["_vehicles","_npc","_units","_unitsIn","_grpid","_getin","_dist","_all"]; + _grpid = _this select 0; + _npc = _this select 1; + _dist = _this select 2; + _all = _this select 3; + + _vehicles=[[]]; + _units = []; + _unitsIn = []; + _getin=false; + + if (leader _npc == _npc) then { + _units = units _npc; + } else + { + _units = _units + [_npc]; + }; + + { + if ( (_x!= vehicle _x && !((vehicle _x) iskindof "StaticWeapon" )) || !(_x iskindof "Man") || !alive _x || !canmove _x || !canstand _x) then {_units = _units-[_x];}; + }foreach _units; + + //If suficient units leader will not get in + if (!all) then { + if (count _units > 2 ) then {_units = _units - [leader _npc]}; + }; + + _unitsIn = _units; + + //We need 2 units available if not any leave vehicle to another squad + if ( (count _units) > 1) then { + _vehicles = [_npc,_dist,_all] call MON_NearestsAirCombat; + {if (_npc knowsabout (_x select 0) <= 0.5) then{ _vehicles = _vehicles - [_x]};}foreach _vehicles; + _units = [_grpid, _units, _vehicles, false] call MON_selectvehicles; + }; + sleep 0.05; + + if ( (count _units) > 1) then { + _vehicles = [_npc,_dist,_all] call MON_NearestsLandCombat; + {if (_npc knowsabout(_x select 0) <= 0.5) then{ _vehicles = _vehicles - [_x]};}foreach _vehicles; + _units = [_grpid, _units, _vehicles, false] call MON_selectvehicles; + }; + + _unitsIn = _unitsIn - _units; + + _unitsIn; +}; + +//Función que busca vehiculos cercanos y hace entrar a las unidades del lider +//Parámeters: [_grpid,_npc] +// <- _grpid: id of group to assign to vehicle +// <- _npc: lider +// -> _getin: true if any getin +MON_GetIn_NearestBoat = { + private["_vehicles","_npc","_units","_unitsIn","_grpid","_getin","_dist"]; + _grpid = _this select 0; + _npc = _this select 1; + _dist = _this select 2; + + _vehicles=[[]]; + _units = []; + _unitsIn = []; + _getin=false; + + if (leader _npc == _npc) then { + _units = units _npc; + } else + { + _units = _units + [_npc]; + }; + + { + if ( (_x!= vehicle _x && !((vehicle _x) iskindof "StaticWeapon" )) || !(_x iskindof "Man") || !alive _x || !canmove _x || !canstand _x) then {_units = _units-[_x];}; + }foreach _units; + + _unitsIn = _units; + + //We need 2 units available if not any leave vehicle to another squad + if ( (count _units) > 0) then { + _vehicles = [_npc,_dist] call MON_Nearestsboats; + {if (_npc knowsabout (_x select 0) <= 0.5) then{ _vehicles = _vehicles - [_x]};}foreach _vehicles; + _units = [_grpid, _units, _vehicles, false] call MON_selectvehicles; + }; + + if ( (count _units) > 1 && (count _vehicles) > 0) then { + sleep 1; + _units = [_grpid, _units, _vehicles, true] call MON_selectvehicles; + }; + + _unitsIn = _unitsIn - _units; + _unitsIn; +}; + +//Función que busca staticos cercanos y hace entrar a las unidades del lider +//Parámeters: [_grpid,_npc] +// <- _grpid: id of group to assign to vehicle +// <- _npc: lider +// -> _getin: true if any getin +MON_GetIn_NearestStatic = { + private["_vehicles","_npc","_units","_unitsIn","_grpid","_getin","_count"]; + _grpid = _this select 0; + _npc = _this select 1; + _count = 0; + _distance = 100; + if ((count _this) > 2) then {_distance = _this select 2;}; + + _vehicles=[]; + _units = []; + _unitsIn = []; + _getin=false; + + //Buscamos staticos cerca + _vehicles = [_npc,_distance] call MON_NearestsStaticWeapons; + + if ( count _vehicles == 0) exitwith {_unitsIn;}; + + if (leader _npc == _npc) then { + _units = (units _npc) - [_npc]; + } else + { + _units = _units + [_npc]; + }; + + //Solo tomamos las unidades vivas y que no estén en vehiculo + { + if ( (_x iskindof "Man") && _x == vehicle _x && alive _x && canmove _x && canstand _x) then { + _unitsIn = _unitsIn + [_x]; + }; + }foreach _units; + + //Intentamos tomar solo las que estén disponibles + _units = []; + { + if (unitready _x) then { + _units = _units + [_x]; + }; + }foreach _unitsin; + + //Si hay unidades disponibles las usamos + if (count _units > 0) then { + _unitsIn = _units; + }; + + //if (KRON_UPS_Debug>0 ) then {player sidechat format["%1: Found %2 estatic weapons %3 men available",_grpid,count _vehicles, count _unitsIn]}; + + _units = _unitsIn; + if ( count _unitsIn > 0) then { + _units = [_grpid, _units, _vehicles, true] call MON_selectvehicles; + }; + + _unitsIn = _unitsIn - _units; + + _unitsIn; +}; + +//Function to assign units to vehicles +//Parámeters: [_grpid,_unitsin,_vehicle] +// <- _grpid: id of group to assign to vehicle +// <- _units: array of units to getin +// <- _vehicles: array of vehicles to use +// -> _untis: array of units getin + MON_selectvehicles = { + private["_vehicles","_emptypositions","_units","_unitsIn","_i","_grpid","_vehgrpid","_unit","_wp","_any","_index","_cargo"]; + _grpid = _this select 0; + _units = _this select 1; + _vehicles = _this select 2; + _any = _this select 3; //meter en cualquier vehiculo + + _wp = []; + _vehicle = []; + _unitsIn = []; + _emptypositions = 0; + _i = 0; + _vehgrpid = 0; + _unit = objnull; + _index = 0; + _cargo = []; + + { + if ((count _units) == 0 ) exitwith {}; + + _vehicle = _x select 0 ; + _emptypositions = _x select 1; + _unitsIn = []; + _i = 0; + _vehgrpid = _vehicle getvariable ("UPSMON_grpid"); + _cargo = _vehicle getvariable ("UPSMON_cargo"); + if ( isNil("_vehgrpid") ) then {_vehgrpid = 0;}; + if ( isNil("_cargo") ) then {_cargo = [];}; + + //Asignamos el vehiculo a a la escuadra si contiene las posiciones justas + if (_vehgrpid == 0) then { + _vehicle setVariable ["UPSMON_grpid", _grpid, false]; + _vehicle setVariable ["UPSMON_cargo", _unitsIn, false]; + _vehgrpid = _grpid; + }; + + { + if (!alive _x || !canmove _x) then {_cargo = _cargo - [_x]; }; + }foreach _cargo; + + _emptypositions = _emptypositions - (count _cargo - count ( crew _vehicle) ); + + + //if (KRON_UPS_Debug>0) then {player sidechat format["%1 %2 positions=%3 cargo=%4 crew=%5",_grpid, typeof _vehicle, _emptypositions, count _cargo,count (crew _vehicle)]}; + //ahora buscamos en cualquier vehiculo + if ( _vehgrpid == _grpid || (_emptypositions > 0 && _any)) then { + + while {_i < _emptypositions && _i < count _units} do + { + _unit = _units select _i; + _unitsIn = _unitsIn + [_unit]; + _i = _i + 1; + }; + _units = _units - _unitsIn; + + if ( (count _unitsIn) > 0) then { + //Metemos las unidades en el vehiculo + [_grpid,_unitsIn,_vehicle] spawn MON_UnitsGetIn; + if (KRON_UPS_Debug>0 ) then {player sidechat format["%1: Get in %2 %3 units of %4 available",_grpid,typeof _vehicle,count _unitsIn,_emptypositions]}; + //if (KRON_UPS_Debug>0 ) then {diag_log format["%1: Moving %3 units into %2 with %4 positions",_grpid,typeof _vehicle,count _unitsIn,_emptypositions]}; + }; + }; + _index = _index + 1; + sleep 0.05; + } foreach _vehicles; + + _units; + }; + + +//Funcion que mete la tropa en el vehiculo +//Parámeters: [_grpid,_unitsin,_vehicle] +// <- _grpid: id of group to assign to vehicle +// <- _unitsin: array of units to getin +// <- _vehicle +MON_UnitsGetIn = { + private["_grpid","_vehicle","_npc","_driver","_gunner", "_unitsin", "_units" , "_Commandercount","_Drivercount","_Gunnercount","_cargo", + "_Cargocount","_emptypositions","_commander","_vehgrpid","_cargo"]; + + _grpid = _this select 0; + _unitsin = _this select 1; + _vehicle = _this select 2; + + _units = _unitsin; + _driver = objnull; + _gunner = objnull; + _commander = objnull; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + _cargo = []; + + _Cargocount = (_vehicle) emptyPositions "Cargo"; + _Gunnercount = (_vehicle) emptyPositions "Gunner"; + _Commandercount = (_vehicle) emptyPositions "Commander"; + _Drivercount = (_vehicle) emptyPositions "Driver"; + + //Obtenemos el identificador del vehiculo + _vehgrpid = _vehicle getvariable ("UPSMON_grpid"); + _cargo = _vehicle getvariable ("UPSMON_cargo"); + if ( isNil("_vehgrpid") ) then {_vehgrpid = 0;}; + if ( isNil("_cargo") ) then {_cargo = [];}; + + _cargo = _cargo - _unitsin; //Para evitar duplicados + _cargo = _cargo + _unitsin; //Ańadimos a la carga + _vehicle setVariable ["UPSMON_cargo", _cargo, false]; + + //Hablitamos a la IA para entrar en el vehiculo + { + [_x,0] call MON_dostop; + + if ("StaticWeapon" countType [vehicle (_x)]>0) then + { + _x spawn MON_doGetOut; + }; + + unassignVehicle _x; + _x spawn MON_Allowgetin; + }foreach _units; + + //Assigned to the leader as commander or cargo + { + if ( _vehgrpid == _grpid && _x == leader _x && _Commandercount > 0 ) exitwith + { + _Commandercount = 0; + _commander = _x; + _commander assignAsCommander _vehicle; + _units = _units - [_x]; + [_x] orderGetIn true; + }; + + if ( _x == leader _x && _Cargocount > 0 ) exitwith + { + _x assignAsCargo _vehicle; + _units = _units - [_x]; + _Cargocount = _Cargocount - 1; + [_x] orderGetIn true; + }; + }foreach _units; + //if (KRON_UPS_Debug>0 ) then {player sidechat format["%1: _vehgrpid %2 ,_Gunnercount %3, %4",_grpid,_vehgrpid,_Gunnercount,count _units]}; + + //Si el vehiculo pertenece al grupo asignamos posiciones de piloto, sinó solo de carga + if ( _vehgrpid == _grpid ) then { + + //Asignamos el conductor + if ( _Drivercount > 0 && count (_units) > 0 ) then { + _driver = _units select (count _units - 1); + [_driver,_vehicle,0] spawn MON_assignasdriver; + _units = _units - [_driver]; + }; + + //Asignamos el artillero + if ( _Gunnercount > 0 && count (_units) > 0 ) then { + _gunner = [_vehicle,_units] call MON_getNearestSoldier; + [_gunner,_vehicle] spawn MON_assignasgunner; + _units = _units - [_gunner]; + }; + }; + + //if (KRON_UPS_Debug>0 ) then {player sidechat format["%1: _vehgrpid=%2 units=%4",_grpid,_vehgrpid,_cargocount,count _units]}; + //Movemos el resto como carga + if ( _Cargocount > 0 && count (_units) > 0 ) then { + { + _x assignAsCargo _vehicle; + [_x] orderGetIn true; + sleep 0.05; + } forEach _units; + }; + + { + [_x] spawn MON_avoidDissembark; + } forEach _unitsin - [_driver] - [_gunner] -[_commander]; + +}; + +MON_getNearestSoldier = { + private["_units","_obj","_near"]; + + _obj = _this select 0; + _units = _this select 1; + + _near = objnull; + + { + if (isnull _near) then { + _near = _x; + } else { + if ( _x distance _obj < _near distance _obj ) then {_near = _x;}; + }; + }foreach _units; + _near; +}; + +MON_avoidDissembark = { + private["_npc","_vehicle","_timeout"]; + + _npc = _this select 0; + _vehicle = vehicle _npc ; + + _timeout = 120; + _timeout = time + _timeout; + + while {_npc == vehicle _npc && alive _npc && canmove _npc && time < _timeout} do { + sleep 1; + }; + + if (!alive _npc || !canmove _npc || time >= _timeout || driver vehicle _npc == _npc) exitwith{}; + _npc stop true; + + while {_npc != vehicle _npc && alive _npc && canmove _npc} do {sleep 1;}; + _npc stop false; + sleep 0.5; + + if (!alive _npc || !canmove _npc) exitwith{}; +}; + + +//Función que devuelve un vehiculo de transporte cercano +//Parámeters: [_npc] +// <- _npc: object for position search +// -> _vehicle: vehicle +MON_NearestLandTransport = { + private["_vehicle","_npc","_transportSoldier","_OCercanos","_driver", "_Commandercount","_Drivercount","_Gunnercount","_Cargocount"]; + + _npc = _this; + + _OCercanos = []; + _transportSoldier = 0; + _vehicle = objnull; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Car","TANK","Truck","Motorcycle"] , 150]; + + { + _Cargocount = (_x) emptyPositions "Cargo"; + _Gunnercount = (_x) emptyPositions "Gunner"; + _Commandercount = (_x) emptyPositions "Commander"; + _Drivercount = (_x) emptyPositions "Driver"; + + _transportSoldier = _Cargocount + _Gunnercount + _Commandercount + _Drivercount; + + if (!locked _x && canMove _x && _transportSoldier >= count (units _npc) && !(typeof _x in MON_bugged_vehicles) + && (_drivercount > 0 || side _npc == side _x )) exitwith {_vehicle = _x;}; + }foreach _OCercanos; + + _vehicle; +}; + +//Función que devuelve un array con los vehiculos terrestres más cercanos +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_NearestsLandTransports = { + private["_vehicles","_npc","_emptypositions","_OCercanos","_driver", "_Commandercount","_Drivercount","_Gunnercount","_Cargocount","_distance"]; + + _npc = _this select 0; + _distance = _this select 1; + + _OCercanos = []; + _emptypositions = 0; + _vehicles = []; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Car","TANK","Truck","Motorcycle"] , _distance]; + + { + _Cargocount = (_x) emptyPositions "Cargo"; + _Gunnercount = (_x) emptyPositions "Gunner"; + _Commandercount = (_x) emptyPositions "Commander"; + _Drivercount = (_x) emptyPositions "Driver"; + + _emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount; + + if (!locked _x && _emptypositions > 0 && canMove _x && !(typeof _x in MON_bugged_vehicles) + && (_drivercount > 0 || side _npc == side _x )) then { _vehicles = _vehicles + [[_x,_emptypositions]];}; + }foreach _OCercanos; + + _vehicles; +}; + +//Función que devuelve un array con los vehiculos terrestres más cercanos +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_NearestsLandCombat = { + private["_vehicles","_npc","_emptypositions","_OCercanos","_driver", "_Commandercount","_Drivercount","_Gunnercount","_Cargocount","_distance","_all"]; + + _npc = _this select 0; + _distance = _this select 1; + _all = _this select 2; + + _OCercanos = []; + _emptypositions = 0; + _vehicles = []; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Car","TANK","Truck","Motorcycle"] , _distance]; + + { + if (_all) then { + _Cargocount = (_x) emptyPositions "Cargo"; + }; + _Gunnercount = (_x) emptyPositions "Gunner"; + _Drivercount = (_x) emptyPositions "Driver"; + _Commandercount = (_x) emptyPositions "Commander"; + + _emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount; + + if (!locked _x && _Gunnercount > 0 && canMove _x && !(typeof _x in MON_bugged_vehicles) + && (_drivercount > 0 || side _npc == side _x )) then { _vehicles = _vehicles + [[_x,_emptypositions]];}; + }foreach _OCercanos; + + _vehicles; +}; + +//Función que devuelve un array con los vehiculos aereos más cercanos +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_NearestsAirTransports = { + private["_vehicles","_npc","_emptypositions","_OCercanos","_driver", "_Commandercount","_Drivercount","_Gunnercount","_Cargocount","_distance"]; + + _npc = _this select 0; + _distance = _this select 1; + + _OCercanos = []; + _emptypositions = 0; + _vehicles = []; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Helicopter"] , _distance]; + + { + _Cargocount = (_x) emptyPositions "Cargo"; + _Gunnercount = (_x) emptyPositions "Gunner"; + _Commandercount = (_x) emptyPositions "Commander"; + _Drivercount = (_x) emptyPositions "Driver"; + + _emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount; + + if (!locked _x && _emptypositions > 0 && canMove _x && !(typeof _x in MON_bugged_vehicles) + && (_drivercount > 0 || side _npc == side _x )) then { _vehicles = _vehicles + [[_x,_emptypositions]];}; + }foreach _OCercanos; + + _vehicles; +}; + +//Function that returns an array with the closest air vehicles +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_NearestsAirCombat = { + private["_vehicles","_npc","_emptypositions","_OCercanos","_driver", "_Commandercount","_Drivercount","_Gunnercount","_Cargocount","_distance","_all"]; + + _npc = _this select 0; + _distance = _this select 1; + _all = _this select 2; + + _OCercanos = []; + _emptypositions = 0; + _vehicles = []; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + + + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Helicopter"] , _distance]; + + { + if (_all) then { + _Cargocount = (_x) emptyPositions "Cargo"; + }; + + // _Gunnercount = [_x] call RAF_numberOfTurrets; + _Gunnercount = (_x) emptyPositions "Gunner"; + _Drivercount = (_x) emptyPositions "Driver"; + _Commandercount = (_x) emptyPositions "Commander"; + + _emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount; + + if (!locked _x && _Gunnercount > 0 && canMove _x && !(typeof _x in MON_bugged_vehicles) + && (_drivercount > 0 || side _npc == side _x )) then { _vehicles = _vehicles + [[_x,_emptypositions]];}; + }foreach _OCercanos; + _vehicles //return +}; + +//Función que devuelve un array con los vehiculos staticos más cercanos +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_NearestsStaticWeapons = { + private["_vehicles","_npc","_emptypositions","_OCercanos","_driver", "_Commandercount","_Drivercount","_Gunnercount","_Cargocount","_distance"]; + + _npc = _this select 0; + _distance = _this select 1; + + _OCercanos = []; + _emptypositions = 0; + _vehicles = []; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["StaticWeapon"] , _distance]; + + { + _Gunnercount = (_x) emptyPositions "Gunner"; + _emptypositions = _Gunnercount; + if (!locked _x && alive _x && _emptypositions > 0 && !(typeof _x in MON_bugged_vehicles) ) then { _vehicles = _vehicles + [[_x,_emptypositions]];}; + }foreach _OCercanos; + + _vehicles //return + }; + +//Función que devuelve un array con los vehiculos marinos más cercanos +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_Nearestsboats = { + private["_vehicles","_npc","_emptypositions","_OCercanos","_driver", "_Commandercount","_Drivercount","_Gunnercount","_Cargocount","_distance"]; + + _npc = _this select 0; + _distance = _this select 1; + + _OCercanos = []; + _emptypositions = 0; + _vehicles = []; + _Cargocount = 0; + _Gunnercount = 0; + _Commandercount = 0; + _Drivercount = 0; + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Ship"] , _distance]; + + { + _Cargocount = (_x) emptyPositions "Cargo"; + _Gunnercount = (_x) emptyPositions "Gunner"; + _Commandercount = (_x) emptyPositions "Commander"; + _Drivercount = (_x) emptyPositions "Driver"; + + _emptypositions = _Cargocount + _Gunnercount + _Commandercount + _Drivercount; + + if (!locked _x && _emptypositions > 0 && canMove _x && (_drivercount > 0 || side _npc == side _x )) then { _vehicles = _vehicles + [[_x,_emptypositions]];}; + }foreach _OCercanos; + + _vehicles //return + }; + +//Function to delay the taking of the steering wheel and the vehicle will not have time to rise and +MON_assignasdriver = { + private["_vehicle","_driver","_wait"]; + _driver = _this select 0; + _vehicle = _this select 1; + _wait = _this select 2; + + [_driver,_wait] spawn MON_dostop; + sleep _wait; + + unassignVehicle _driver; + _driver assignasdriver _vehicle; + [_driver] orderGetIn true; + + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: assigning to driver of %2 ",_driver, typeof _vehicle]}; +}; + +MON_assignasgunner = { + private["_vehicle","_gunner","_dist"]; + _gunner = _this select 0; + _vehicle = _this select 1; + _dist=0; + + _gunner assignasgunner _vehicle; + [_gunner] orderGetIn true; + + waituntil { _gunner != vehicle _gunner || !alive _gunner || !canmove _gunner ||!alive _vehicle || !canfire _vehicle}; + + if ( alive _gunner && alive _vehicle && canmove _gunner && canfire _vehicle) then { + _dist = _gunner distance _vehicle; + if (_dist < 3) then { + _gunner moveInTurret [_vehicle, [0]] ; + }; + }; +}; + + +//Allow getin +MON_Allowgetin = { + //Hablitamos a la IA para entrar en el vehiculo + [_this] allowGetIn true; +}; + + +//If every on is outside, make sure driver can move + MON_checkleaveVehicle={ + _npc = _this select 0; + _vehicle = _this select 1; + _driver = _this select 2; + _in = false; + + //Take time to go all units + sleep 5; + { + if (_x != vehicle _x) then {_in = true}; + }foreach units _npc; + + + // if no one is inside + if (!_in) then { + _driver enableAI "MOVE"; + sleep 1; + _driver stop false; + sleep 1; + _driver leaveVehicle _vehicle; + sleep 1; + }; + }; + + +//Function for order a unit to exit if no gunner +//Parámeters: [_npc] +// <- _npc: +MON_GetOut = { + private["_vehicle","_npc","_getout" ,"_gunner"]; + + _npc = _this; + _vehicle = vehicle (_npc); + _gunner = objnull; + _gunner = gunner _vehicle; + + sleep 0.05; + if (!alive _npc) exitwith{}; + + //If no leave the vehicle gunner + if ( isnull _gunner || !alive _gunner || !canmove _gunner || (_gunner != _npc && driver _vehicle != _npc && commander _vehicle != _npc) ) then { + [_npc] allowGetIn false; + _npc spawn MON_doGetOut; + unassignVehicle _npc; + + //sleep 0.2; + }; + }; + +//Function for order a unit to exit +//Parámeters: [_npc] +// <- _npc: +MON_doGetOut = { + private["_vehicle","_npc","_getout" ,"_gunner","_groupOne","_timeout","_dir"]; + + _npc = _this; + _vehicle = vehicle (_npc); + + sleep 0.05; + if (_vehicle == _npc) exitwith{}; + + //Wait until vehicle is stopped + waituntil {!alive _npc || !canmove _npc || !alive _vehicle || ( (abs(velocity _vehicle select 0)) <= 0.1 && (abs(velocity _vehicle select 1)) <= 0.1 ) + || ( _vehicle iskindof "Air" && ((position _vehicle) select 2) <= 1)}; + + if (!alive _npc || !canmove _npc) exitwith{}; + unassignVehicle _npc; + _npc action ["getOut", _vehicle]; + doGetOut _npc; + [_npc] allowGetIn false; + nul = [_npc] spawn MON_cancelstop; + + waituntil {!alive _npc || !canmove _npc || vehicle _npc == _npc}; + if (!alive _npc || !canmove _npc) exitwith{}; + + if (leader _npc != _npc) then { + //Moves out with dispersion of 45ş + _dir = getDir _npc; + _dir = _dir + 45 - (random 90); + nul = [_npc,25,_dir] spawn MON_domove; + //if (KRON_UPS_Debug>0 ) then { player globalchat format["%1 Moving away from %2 %2ş",_npc, typeof _vehicle,_dir];}; + }; +}; + +//Function for exiting of heli +//Parámeters: [_heli,_targetPos,_atdist] +// <- _heli: +// <- _targetPos: position for exiting(if no waypoint used) +// <- _atdist: distance for doing paradrop or landing +MON_doParadrop = { + if (KRON_UPS_Debug>0 ) then { player globalchat format["Mon_doParadrop started"];}; + private["_heli","_npc","_getout" ,"_gunner","_targetpos","_helipos","_dist","_index","_grp","_wp","_targetPosWp","_targetP","_units","_crew","_timeout","_jumpers"]; + _heli = _this select 0; + _targetPos = [0,0]; + _atdist = 250; + _flyingheigh = KRON_UPS_flyInHeight; + _landonBeh = ["CARELESS","SAFE"]; + _timeout=0; + + //Gets optional parameters + if ((count _this) > 1) then {_targetPos = _this select 1;}; + if ((count _this) > 2) then {_atdist = _this select 2;}; + if ((count _this) > 3) then {_flyingheigh = _this select 3;}; + + _helipos = [0,0]; + _targetposWp = [0,0]; + _gunner = objnull; + _gunner = gunner _heli; + _dist = 1000000; + _index = 0; + _grp = GRPNULL; + _wp = []; + _units =[]; + _crew =[]; + + waituntil {count crew _heli > 0 || !alive _heli || !canmove _heli}; + _grp = group ((crew _heli) select 0); + _npc = leader ((crew _heli) select 0); + _units = units _npc; + + while { (_dist >= _atdist || _dist < 10) && alive _heli && canmove _heli && count crew _heli > 0} do { + _heli flyInHeight _flyingheigh; + + + /* + //Take last waypoint + _index = (count waypoints _grp) - 1; + _wp = [_grp,_index]; + _targetPosWp = waypointPosition _wp; + if (format ["%1", _targetPosWp] == "[0,0,0]") then {_targetPosWp = _targetPos}; + */ + + _targetPosWp = _targetPos; + + _helipos = position _heli; + _dist = round([_helipos,_targetPosWp] call KRON_distancePosSqr); + //if (KRON_UPS_Debug>0 ) then {player globalchat format["Goiing to drop zone _dist=%1, _atdist=%2", _dist, _atdist ];}; + sleep 1; + }; + + if (!alive _heli || count crew _heli == 0) exitwith{}; + _crew = crew _heli; + + //Jump + if (((position _heli) select 2) >= 90 && !surfaceIsWater position _heli && (!(toupper (behaviour _npc) IN _landonBeh) || (random 100) < 20)) then { + //moving hely for avoiding stuck + if (KRON_UPS_Debug>0 ) then {_heli globalchat format["doing paradrop high %1 dist=%2",(position _heli) select 2,_dist,_atdist];}; + + _jumpers = [_heli] call R_FN_unitsInCargo; + + //Do paradrop + { + if( (assignedVehicleRole _x) select 0 == "Cargo")then + { + unassignVehicle _x; + _x action ["EJECT", _heli] ; + _x stop false; + [_x] allowGetIn false; + [_x] spawn MON_ACE_Watersurvival; + + }; + sleep 0.5; + } forEach crew _heli; + [_heli,700] spawn MON_domove; + + //Clear Hely vars + _heli setVariable ["UPSMON_grpid", 0, false]; + _heli setVariable ["UPSMON_cargo", [], false]; + + // set orginal fly hight + // _flyingheigh = KRON_UPS_flyInHeight; + // _heli flyInHeight _flyingheigh; + + //Waits until all units are down + _timeout = time + 60; + { + waituntil {(_x == vehicle _x ) || !alive _x || !canmove _x || isnull _x || time > _timeout}; + //Fix bug of ACE that sometimes AI gets in stand animation + //_x switchMove "AmovPercMsprSlowWrflDf_AmovPpneMstpSrasWrflDnon_2"; + } foreach _jumpers; + + + if ( _npc == vehicle _npc) then { + { + if (alive _x && canmove _x) then { + [_x] dofollow _npc; + }; + } foreach units _npc; + }; + + + + //if (KRON_UPS_Debug>0) then {player globalchat format["%1 after paradrop",_npc]}; + + if (alive _npc && canmove _npc) then { + _npc move _targetPosWp; + }else{ + {if (alive _x && canmove _x) exitwith { _x move _targetPosWp;}}foreach _crew; + }; + + //If only pilot land heli + if (count crew _heli <=1) then { + [_heli] spawn MON_landHely; + }; + } else { + //land + + if ( ((position _heli) select 2) >= 60 && !surfaceIsWater _helipos && ((random 100)<20 || !canmove _heli || (toupper (behaviour _npc) IN _landonBeh))) then { + [_heli] spawn MON_landHely; + + } + else { + If (alive _heli && canmove _heli && count crew _heli > 0) then { + if (KRON_UPS_Debug>0 ) then {_heli globalchat format["%1 failed paradrop, trying another time",typeof _heli];}; + //Try another time + _heli flyInHeight _flyingheigh; + sleep 3; + [_heli, _targetPos, _atdist*1.5,_flyingheigh] spawn MON_doParadrop; + }; + }; + }; +}; + +//Lands hely +MON_landHely = { + private["_heli","_npc","_crew","_NearestEnemy","_timeout","_landing","_targetpos","_jumpers"]; + _heli = _this select 0; + _crew =[]; + _targetpos=[0,0]; + _timeout = 0; + _landing = false; + + sleep 0.05; + if (!alive _heli || !canmove _heli ) exitwith{}; + _crew = crew _heli; + _npc = leader (_crew select 0); + + //Checks hely is already landing + _landing = _heli getVariable "UPSMON_landing"; + if (isnil ("_landing")) then {_landing=false; _heli setVariable ["UPSMON_landing", false, false];}; + if (_landing) exitwith {}; + + //Orders to land heli + _heli land "LAND"; + if (KRON_UPS_Debug>0 ) then {player globalchat format["%1 is landing",typeof _heli];}; + + //Puts a mark for knowing hely is landing + _heli setVariable ["UPSMON_landing", true, false]; + + //Waits for land position + waituntil {!alive _heli || toUpper(landResult _heli) != "NOTREADY" }; + if (alive _heli && (toUpper(landResult _heli) == "NOTFOUND")) exitwith { + if (KRON_UPS_Debug>0 ) then { player globalchat format["%1 no landing zone, doing paradrop",typeof _heli];}; + _heli setVariable ["UPSMON_landing", false, false]; + [_heli] spawn MON_doparadrop; + }; + + //1rt try-Waits until velocity and heigh are good for getting out + _timeout = 60 + time; + waituntil {!alive _heli || time > _timeout || ((abs(velocity _heli select 2)) <= 1 && ((position _heli) select 2) <= 0.7)}; + + //2nd try-Waits until velocity and heigh are good for getting out + if (((position _heli) select 2) > 2 && ((position _heli) select 2) < 30 && !surfaceiswater position _heli) then { + _heli land "LAND"; + _timeout = 30 + time; + waituntil {!alive _heli || time > _timeout || ((position _heli) select 2) > 30 || ( (abs(velocity _heli select 2)) <= 1 && ((position _heli) select 2) <= 0.7)}; + + //Failed landing doing paradrop + if ( ((position _heli) select 2) > 30) exitwith { + if (KRON_UPS_Debug>0 ) then { player globalchat format["%1 landing timeout, doing paradrop",typeof _heli];}; + _heli setVariable ["UPSMON_landing", false, false]; + sleep 5; + [_heli] spawn MON_doparadrop; + }; + }; + + //Chechs if alive before continuing + if (!alive _heli) exitwith{}; + + + //If there is pilot and gunner, get out only cargo + if ((!isnull gunner _heli) && (!isnull driver _heli)) then { + _jumpers = [_heli] call R_FN_unitsInCargo; + } else { + _jumpers = crew _heli; + }; + + + //dogetout each of _jumpers + { + _x spawn MON_doGetOut; + sleep 0.5; + } forEach _jumpers; + + _timeout = 20 + time; + + //Waits until all getout of heli + { + waituntil {vehicle _x == _x || !canmove _x || !alive _x || movetofailed _x || time > _timeout }; + } forEach _jumpers; + + sleep 1; + _heli land "NONE"; + sleep 1; + [_heli,700] spawn MON_domove; + + + + + // If leader alive sets combat mode + if (alive _npc && canmove _npc) then { + //Gets nearest known enemy for putting in combat mode + _NearestEnemy = _npc findNearestEnemy _npc; + if (!isnull _NearestEnemy ) then { + _npc setBehaviour "AWARE"; + _groupOne = group _npc; + _groupOne setFormation "DIAMOND"; + }; + + //Moves to current target Position + _grpid = _npc getvariable "UPSMON_grpid"; + if !(isnil "_grpid") then { + _targetpos =(KRON_targetsPos select _grpid); + _npc move _targetpos; + if (KRON_UPS_Debug>0 ) then { player globalchat format["%1 landed, moving to %2 %3",_grpid,_targetpos,count KRON_targetsPos];}; + }; + }; + + //Quitamos el id al vehiculo para que pueda ser reutilizado + _heli setVariable ["UPSMON_grpid", 0, false]; + _heli setVariable ["UPSMON_cargo", [], false]; + _heli setVariable ["UPSMON_landing", false, false]; +}; + +//Controls that heli not stoped flying +MON_HeliStuckcontrol = { + private["_heli","_landing","_stuckcontrol","_dir1","_targetPos","_lastpos"]; + _heli = _this select 0; + + _landing = false; + _stuckcontrol = false; + _targetPos=[0,0,0]; + _dir1 = 0; + + sleep 0.05; + if ( !alive _heli || !canmove _heli ) exitwith{}; + + //Checks stuckcontrol not active + _stuckcontrol = _heli getVariable "UPSMON_stuckcontrol"; + if (isnil ("_stuckcontrol")) then {_stuckcontrol=false}; + if (_stuckcontrol) exitwith {}; + + _heli setVariable ["UPSMON_stuckcontrol", true, false]; + //if (KRON_UPS_Debug>0 ) then {player globalchat format["%1 stuck control begins",typeof _heli];}; + + //Stuck loop control + while {(alive _heli) && (count crew _heli) > 0 } do { + sleep 5; + if ((abs(velocity _heli select 0)) <= 5 && (abs(velocity _heli select 1)) <= 5 && (abs(velocity _heli select 2)) <= 5 && ((position _heli) select 2) >= 30) then { + + _landing = _heli getVariable "UPSMON_landing"; + if (isnil ("_landing")) then {_landing=false;}; + + if (!_landing) then { + //moving hely for avoiding stuck + [_heli,800] spawn MON_domove; + if (KRON_UPS_Debug>0 ) then {player GLOBALCHAT format["%1 stucked at %2m height, moving",typeof _heli,(position _heli) select 2];}; + sleep 25; + }; + }; + }; + //if (KRON_UPS_Debug>0 ) then {player globalchat format["%1 exits from stuck control",typeof _heli];}; + _heli setVariable ["UPSMON_stuckcontrol", false, false]; +}; + +//Function that checks is gunner is alive, if not moves a cargo +MON_Gunnercontrol = { + private["_vehicle","_gunnercontrol","_hasgunner","_crew","_crew2"]; + _vehicle = _this select 0; + + _targetPos=[0,0,0]; + _dir1 = 0; + _gunnercontrol = false; + _hasgunner = (_vehicle) emptyPositions "Gunner" > 0 || !isnull gunner _vehicle; + _crew = []; + _crew2 = []; //Without driver and gunner + + sleep 0.05; + if ( !alive _vehicle || !canmove _vehicle ) exitwith{}; + + //Checks stuckcontrol not active + _gunnercontrol = _vehicle getVariable "UPSMON_gunnercontrol"; + if (isnil ("_gunnercontrol")) then {_gunnercontrol=false}; + if (_gunnercontrol) exitwith {}; + + _vehicle setVariable ["UPSMON_gunnercontrol", true, false]; + + _crew = crew _vehicle; + //gunner and driver loop control + while { alive _vehicle && canmove _vehicle && count _crew > 0} do { + _crew = crew _vehicle; + { + if (!canmove _x || !alive _x) then {_crew = _crew -[_x];}; + }foreach _crew; + + //Driver control + if ((isnull (driver _vehicle) || !alive (driver _vehicle) || !canmove (driver _vehicle)) && count _crew > 0) then { + _crew2 = _crew - [gunner _vehicle]; + if (count _crew2 > 0) then { + (_crew2 select (count _crew2 - 1)) spawn MON_movetodriver; + }; + }; + + //Gunner control + if ( _hasgunner && (isnull (gunner _vehicle) || !alive (gunner _vehicle) || !canmove (gunner _vehicle)) && count _crew > 1) then { + _crew2 = _crew - [driver _vehicle]; + if (count _crew2 > 0) then { + (_crew2 select (count _crew2 - 1)) spawn MON_movetogunner; + }else{ + (_crew select 0) spawn MON_movetogunner; + }; + }; + sleep 20; + //if (KRON_UPS_Debug>0 ) then {player globalchat format["%1 crew=%2",typeof _vehicle, count _crew];}; + }; + //if (KRON_UPS_Debug>0 ) then {player globalchat format["%1 exits from gunner control",typeof _vehicle];}; + _vehicle setVariable ["UPSMON_gunnercontrol", false, false]; +}; + + +//Mueve a todo el grupo adelante +MON_move = { + private["_npc","_dir1","_targetPos","_dist"]; + _npc = _this select 0; + _dist = _this select 1; + + sleep 0.05; + if (!alive _npc || !canmove _npc ) exitwith{}; + + _dir1 = getDir _npc; + _targetPos = [position _npc,_dir1, _dist] call MON_GetPos2D; + _npc move _targetPos; +}; + +//Mueve al soldado adelante +MON_domove = { + private["_npc","_dir1","_targetPos","_dist"]; + _npc = _this select 0; + _dist = _this select 1; + if ((count _this) > 2) then {_dir1 = _this select 2;} else{_dir1 = getDir _npc;}; + + sleep 0.05; + if (!alive _npc || !canmove _npc ) exitwith{}; + + _targetPos = [position _npc,_dir1, _dist] call MON_GetPos2D; + //If position water and not boat not go + if (surfaceIsWater _targetPos && !(_npc iskindof "boat" || _npc iskindof "air") ) exitwith {}; + _npc domove _targetPos; +}; + +//Función que detiene al soldado y lo hace esperar x segundos +MON_doStop = { + private["_sleep","_npc"]; + + _npc = _this select 0; + _sleep = _this select 1; + + sleep 0.05; + if (!alive _npc || !canmove _npc ) exitwith{}; + if ( _sleep == 0 ) then {_sleep = 0.1}; + + //Restauramos valores por defecto de movimiento + //_npc disableAI "MOVE"; + dostop _npc ; + sleep _sleep; + [_npc] spawn MON_cancelstop; +}; + +//Función que detiene al soldado y lo hace esperar x segundos +MON_cancelstop = { + private["_npc"]; + _npc = _this select 0; + _npc stop false; +}; + +//Make grenade dodge animation +MON_evadeGrenade = { + if (!alive _this || (vehicle _this) != _this || !canmove _this) exitwith{}; + + _this playmovenow "AmovPercMstpSlowWrflDnon_ActsPpneMstpSlowWrflDr_GrenadeEscape"; + sleep 8; + if (!alive _this || (vehicle _this) != _this || !canmove _this) exitwith{}; + _this switchmove "AmovPpneMstpSrasWrflDnon_AmovPpneMevaSlowWrflDr"; //croqueta + _this playmovenow "AmovPpneMstpSrasWrflDnon"; //prone +}; + +//Realiza la animación de la croqueta +MON_animCroqueta = { + if (!alive _this || (vehicle _this) != _this || !canmove _this || !(_this iskindof "Man")) exitwith{}; + + if ((random 1)<=.50) then { + _this switchmove "AmovPpneMstpSrasWrflDnon_AmovPpneMevaSlowWrflDl"; //croqueta + } else { + _this switchmove "AmovPpneMstpSrasWrflDnon_AmovPpneMevaSlowWrflDr"; //croqueta + }; +}; + +//Throw a grenade +MON_throw_grenade = { + private["_target","_npc"]; + _npc = _this select 0; + _target = _this select 1; + sleep random 1.5; + if (!alive _npc || (vehicle _npc) != _npc || !canmove _npc) exitwith{}; + [_npc,_target] spawn MON_dowatch; + sleep 0.1; + + // R_Functions + [_npc] spawn R_ThrowSmoke; + + + /* + + _npc addMagazine "SmokeShell"; + _npc selectWeapon "throw"; + sleep .1; + _npc fire ["SmokeShellMuzzle","SmokeShellMuzzle","SmokeShell"]; + */ +}; + +//Establece el tipo de posición +MON_setUnitPos = { + private["_pos","_npc"]; + _npc = _this select 0; + _pos = _this select 1; + + sleep 0.5; + if (!alive _npc || !canmove _npc || _npc != vehicle _npc || !(_npc iskindof "Man")) exitwith{}; + _npc setUnitPos _pos; + sleep 1; +}; +//Establece el tipo de posición +MON_setUnitPosTime = { + private["_pos","_npc"]; + _npc = _this select 0; + _pos = _this select 1; + _time = _this select 2; + + if (!alive _npc || !canmove _npc) exitwith{}; + _npc setUnitPos _pos; + sleep _time; + _npc setUnitPos "AUTO"; + sleep 1; +}; + +// Función para mirar en una dirección +MON_dowatch = { + private["_target","_npc"]; + _npc = _this select 0; + _target = _this select 1; + + if (!alive _npc) exitwith{}; + _npc dowatch _target; + sleep 1; +}; + +//Función que mueve al soldado a la posición de conductor +//Parámeters: [_npc,_vehicle] +// <- _npc: unit to move to driver pos +// <- _vehicle +MON_movetoDriver = { + private["_vehicle","_npc"]; + _npc = _this ; + _vehicle = vehicle _npc; + + //Si está muerto + if (vehicle _npc == _npc || !alive _npc || !canmove _npc || !(_npc iskindof "Man")) exitwith{}; + + if (isnull(driver _vehicle) || !alive(driver _vehicle) || !canmove(driver _vehicle)) then { + //if (KRON_UPS_Debug>0) then {player sidechat format["%1: Moving to driver of %2 ",_npc,typeof _vehicle]}; + _npc action ["getOut", _vehicle]; + doGetOut _npc; + WaitUntil {vehicle _npc==_npc || !alive _npc || !canmove _npc}; + //Si está muerto + if (!alive _npc || !canmove _npc) exitwith{}; + unassignVehicle _npc; + _npc assignasdriver _vehicle; + _npc moveindriver _vehicle; + }; +}; + +//Función que mueve al soldado a la posición de conductor +//Parámeters: [_npc,_vehicle] +// <- _npc: unit to move to driver pos +// <- _vehicle +MON_movetogunner = { + private["_vehicle","_npc"]; + _npc = _this ; + _vehicle = vehicle _npc; + + sleep 0.05; + //Si está muerto + if (vehicle _npc == _npc || !alive _npc || !canmove _npc || !(_npc iskindof "Man")) exitwith{}; + + if (isnull(gunner _vehicle) || !alive(gunner _vehicle) || !canmove(gunner _vehicle)) then { + if (KRON_UPS_Debug>0) then {player sidechat format["%1: Moving to gunner of %2 ",_npc,typeof _vehicle]}; + _npc action ["getOut", _vehicle]; + doGetOut _npc; + WaitUntil {vehicle _npc==_npc || !alive _npc || !canmove _npc}; + //Si está muerto + if (!alive _npc || !canmove _npc) exitwith{}; + unassignVehicle _npc; + _npc assignasgunner _vehicle; + _npc moveingunner _vehicle; + }; +}; + +//Función que retorna array de arrays con edificios y sus plantas +//Parámeters: [_object,(_distance,_minfloors)] +// <- _object: soldier to get near buildings +// <- _distance: distance to search buildings (optional, 25 by default) +// <- _minfloors: min floors of building (optional) if not especified min floors is 2 +// -> [_bld,_bldpos] +MON_GetNearestBuildings = { + private ["_object","_altura","_pos","_bld","_bldpos","_posinfo","_minfloors","_OCercanos","_distance","_blds"]; + _distance = 25; + _minfloors = 2; + _altura = 0; + _blds = []; + + _object = _this select 0; + if ((count _this) > 1) then {_distance = _this select 1;}; + if ((count _this) > 2) then {_minfloors = _this select 2;}; + + _pos =0; + _bld = objnull; + _bldpos =0; + _posinfo=[]; + + //La altura mínima es 2 porque hay muchos edificios q devuelven 2 de altura pero no se puede entrar en ellos. + if ( minfloors == 0 ) then { + minfloors = 2; + }; + + // _posinfo: [0,0]=no house near, [obj,0]=house near, but no roof positions, [obj,pos]=house near, with roof pos + //_posinfo= _object call MON_PosInfo; + _OCercanos = nearestObjects [_object, ["house","building"] , _distance]; + + { + _bldpos = _x call MON_BldPos; + if ( _bldpos >= _minfloors && damage _x <= 0 ) then { _blds = _blds + [[_x,_bldpos]];}; + //player sidechat format["%1 cerca de edificio con %2 plantas %5",typeof _object,_bldpos]; + }foreach _OCercanos; + + _blds; +}; + +//Function to move al units of squad to near buildings +//Parámeters: [_npc,(_patrol,_minfloors)] +// <- _npc: lider +// <- _distance: distance to search buildings (optional, 25 by default) +// <- _patrol: wheter must patrol or not +MON_moveNearestBuildings = { + private ["_npc","_altura","_pos","_bld","_bldpos","_posinfo","_blds","_distance","_cntobjs1","_bldunitin","_blddist","_patrol","_wait","_all"]; + _distance = 30; + _altura = 0; + _patrol = false; + _wait=60; + _all = false; + + _npc = _this select 0; + if ((count _this) > 1) then {_distance = _this select 1;}; + if ((count _this) > 2) then {_patrol = _this select 2;}; + if ((count _this) > 3) then {_wait = _this select 3;}; + if ((count _this) > 4) then {_all = _this select 4;}; + + + _pos =0; + _bld = objnull; + _bldpos =0; + _cntobjs1=0; + _bldunitsin=[]; + _units=[]; + _blds=[]; + + //If all soldiers move leader too + if (_all) then { + _units = (units _npc); + }else{ + _units = (units _npc) - [_npc]; + }; + + sleep 0.05; + { + if (_x iskindof "Man" && unitReady _x && _x == vehicle _x && canmove _x && alive _x && canstand _x) then {_bldunitsin = _bldunitsin + [_x]} + }foreach _units; + + if (count _bldunitsin == 0) exitwith {}; + + //Obtenemos los edificios cercanos al lider + _blds = [_npc,_distance] call MON_GetNearestBuildings; + + if (count _blds==0) exitwith {}; + + //Movemos a la unidades a los edificios cercanos. + [_bldunitsin, _blds, _patrol,_wait,_all] spawn MON_moveBuildings; + +}; + + +//Function to move al units of squad to near buildings +//Parámeters: [_npc,(_patrol,_minfloors)] +// <- _units: array of units +// <- _blds: array of buildingsinfo [_bld,pos] +// <- _patrol: wheter must patrol or not +// -> _bldunitsin: array of units moved to builidings +MON_moveBuildings = { + private ["_npc","_altura","_pos","_bld","_bldpos","_posinfo","_blds","_cntobjs1","_bldunitin","_blddist","_i","_patrol","_wait","_all","_minpos","_blds2"]; + _patrol = false; + _wait = 60; + _minpos = 2; + _all = false; + + _units = _this select 0; + _blds = _this select 1; + if ((count _this) > 2) then {_patrol = _this select 2;}; + if ((count _this) > 3) then {_wait = _this select 3;}; + if ((count _this) > 4) then {_all = _this select 4;}; + if ((count _this) > 5) then {_minpos = _this select 5;}; + + _altura = 0; + _pos =0; + _bld = objnull; + _bldpos =0; + _cntobjs1=0; + _bldunitsin=[]; + _movein=[]; + _blds2 =[]; + + //if (KRON_UPS_Debug>0) then {player globalchat format["MON_moveBuildings _units=%1 _blds=%2",count _units, count _blds]; }; + //if (KRON_UPS_Debug>0) then {diag_log format["MON_moveBuildings _units=%1 _blds=%2",count _units, count _blds];}; + + { + _bld = _x select 0; + _bldpos = _x select 1; + + if ( _bldpos >= _minpos ) then { + _cntobjs1 = 1; + _movein = []; + _i = 0; + + if (_patrol) then { + if (_bldpos >= 8) then { _cntobjs1 = 2 }; + } else { + if (_bldpos >= 8) then { _cntobjs1 = round(random 3) + 1;}; + }; + + //Buscamos una unidad cercana para recorrerlo + { + if (_x iskindof "Man" && unitReady _x && canmove _x && alive _x && vehicle _x == _x && _i < _cntobjs1) then{ + _movein = _movein + [_x]; + _i = _i + 1; + }; + } foreach _units; + + //if (KRON_UPS_Debug>0) then {player globalchat format["_units=%3 _bldunitsin %4 _movein=%1",_movein, typeof _bld, count _units, count _bldunitsin];} + //if (KRON_UPS_Debug>0) then {diag_log format["_units=%3 _bldunitsin %4 _movein=%1 %2 %5",_movein, typeof _bld, count _units, count _bldunitsin,_x];}; + + if (count _movein > 0) then { + _bldunitsin = _bldunitsin + _movein; + _units = _units - _bldunitsin; + if (_patrol) then { + { + [_x,_bld,_bldpos] spawn MON_patrolBuilding; + }foreach _movein; + } else { + { + _altura = floor(random(_bldpos)); + if (_altura<2) then {_altura = _minpos}; + [_x,_bld,_altura,_wait] spawn MON_movetoBuilding; + }foreach _movein; + }; + }; + }; + + if (count _units == 0) exitwith {}; + }foreach _blds; + + //If need to enter all units in building and rest try with a superior lvl + if ( _all && count _units > 0 ) then { + _blds2 = []; + _minpos = _minpos + 3; + { + if ( (_x select 1) >= _minpos) then { + _blds2 = _blds2 + [_x]; + }; + }foreach _blds; + + //if (KRON_UPS_Debug>0) then {player globalchat format["MON_moveBuildings exit _units=%1 _blds=%2",count _units, count _blds2]; }; + //if (KRON_UPS_Debug>0) then {diag_log format["MON_moveBuildings exit _units=%1 _blds=%2",count _units, count _blds2];}; + + if (count _blds2 > 0 ) then { + [_units, _blds2, _patrol,_wait,_all,_minpos] call MON_moveBuildings; + }; + _bldunitsin = _bldunitsin + _units; + }; + _bldunitsin; +}; + +//Function to move a unit to a position in a building +//Parámeters: [_npc,(_patrol,_minfloors)] +// <- _npc: soldier +// <- _bld: building +// <- _altura: building +// <- _wait: time to wait in position +MON_movetoBuilding = { + + private ["_npc","_altura","_bld","_wait","_dist","_retry","_soldiers"]; + _wait = 60; + _timeout = 120; + _dist = 0; + _retry = false; + + _npc = _this select 0; + _bld = _this select 1; + _altura = _this select 2; + if ((count _this) > 3) then {_wait = _this select 3;}; + + //Si está en un vehiculo ignoramos la orden + if (vehicle _npc != _npc || !alive _npc || !canmove _npc) exitwith{}; + + //Si ya está en un edificio ignoramos la orden + _inbuilding = _npc getvariable ("UPSMON_inbuilding"); + if ( isNil("_inbuilding") ) then {_inbuilding = false;}; + if (_inbuilding) exitwith{}; + + _npc domove (_bld buildingPos _altura); + _npc setVariable ["UPSMON_inbuilding", _inbuilding, false]; + _npc setvariable ["UPSMON_buildingpos", nil, false]; + _timeout = time + _timeout; + + //if (KRON_UPS_Debug>0) then {player globalchat format["%4|_bld=%1 | %2 | %3",typeof _bld, _npc, typeof _npc ,_altura];}; + //if (KRON_UPS_Debug>0) then {diag_log format["%4|_bld=%1 | %2 | %3",typeof _bld, _npc, typeof _npc ,_altura];}; + + waitUntil {moveToCompleted _npc || moveToFailed _npc || !alive _npc || !canmove _npc || _timeout < time}; + + if (moveToCompleted _npc && alive _npc && canmove _npc) then { + _dist = [position _npc,_bld buildingPos _altura] call KRON_distancePosSqr; + + _soldiers = [_npc,1] call MON_nearestSoldiers; + + //If more soldiers in same floor see to keep or goout. + if (count _soldiers > 0) then { + { + if (!isnil{_x getvariable ("UPSMON_buildingpos")}) exitwith {_retry = true}; + }foreach _soldiers; + }; + + if (!_retry && _dist <= 2) then { + _npc setvariable ["UPSMON_buildingpos", _altura, false]; + sleep 0.1; + [_npc,_wait] spawn MON_dostop; + }; + }; + + if (!alive _npc || !canmove _npc) exitwith{}; + _npc setVariable ["UPSMON_inbuilding", false, false]; + + + //Down one position. + if (_retry ) then { + _altura = _altura + 1; + _bldpos = _bld call MON_BldPos; + + if (_altura <= _bldpos) then { + [_npc,_bld,_altura] spawn MON_movetoBuilding; + }; + }; +}; + + +//Función para mover a una unidad al edificio más cercano +//Parámeters: [_npc,_bld,(_BldPos)] +// <- _npc: soldier to move +// <- _bld:building to patrol +// <- _BldPos: positions of builiding (optional) +MON_patrolBuilding = { + private ["_npc","_bld","_bldpos","_posinfo","_minfloors","_OCercanos","_distance","_timeout","_pos","_inbuilding","_rnd","_NearestEnemy","_patrolto","_time"]; + _bldpos = 0; + _pos = 0; + _timeout = 0; + _i = 1; + _inbuilding = false; + _rnd = 0; + _patrolto = 0; + _NearestEnemy = objnull; + _time = 0; + + _npc = _this select 0; + _bld = _this select 1; + if ((count _this) > 2) then {_bldpos = _this select 2;} else {_bldpos = _x call MON_BldPos;}; + + if (_i > _bldpos) then {_i = _bldpos}; + _patrolto = round ( 10 + random (_bldpos) ); + + if (_patrolto > _bldpos) then {_patrolto = _bldpos}; + + //Si ya está muerto o no se puede mover se ignora + if (!(_npc iskindof "Man") || !alive _npc || !canmove _npc) exitwith{}; + + //Si ya está en un edificio ignoramos la orden + _inbuilding = _npc getvariable ("UPSMON_inbuilding"); + if ( isNil("_inbuilding") ) then {_inbuilding = false;}; + + //Asignamos el vehiculo a a la escuadra si contiene las posiciones justas + if (!_inbuilding) then { + _inbuilding = true; + _npc setVariable ["UPSMON_inbuilding", _inbuilding, false]; + [_npc,"Middle"] spawn MON_setUnitPos; + _timeout = time + 60; + + //player sidechat format["%1 patrol building %2 from %3 to %4",typeof _npc, typeof _bld,_i, _patrolto]; + + while { _i <= _patrolto && alive _npc && canmove _npc} do{ + + _npc domove (_bld buildingPos _i); + + + _time = time + 30; + waitUntil {moveToCompleted _npc or moveToFailed _npc or !alive _npc or _time < time}; + + if (moveToCompleted _npc) then { + _timeout = time + 60; + _i = _i + 1; + } else { + if (moveToFailed _npc || !canmove _npc || !alive _npc || _timeout < time) then { + //player sidechat format["%1 Cancelando patrulla en %2",_npc, typeof _bld]; + _i = _patrolto + 1; + }; + }; + sleep 0.05; + }; + + //Si está en un vehiculo ignoramos la orden + if (!alive _npc || !canmove _npc) exitwith{}; + + //Volvemos con el lider + _npc domove (position leader _npc); + + //Marcamos que ya hemos finalizado + sleep 60; //Damos tiempo para salir del edificio + _npc setVariable ["UPSMON_inbuilding", false, false]; + }; +}; + +//Function to put a mine +//Parámeters: [_npc,(_position)] +// <- _npc: leader +// <- _position:location for mine (optional) +MON_CreateMine = { + private ["_npc","_rnd","_soldier","_mine","_dir","_position"]; + _soldier = _this select 0; + if ((count _this) > 1) then {_position = _this select 1;} else {_position = [0,0];}; + + _mine = objnull; + _rnd = 0; + _dir = 0; + _npc = leader _soldier; + + if (_soldier == _npc ) then { + _rnd = round (random ( count ((units _npc)))); + _soldier = (units _npc) select _rnd; + }; + + //leader only control not work + //Si está en un vehiculo ignoramos la orden + if (!(_soldier iskindof "Man" ) || _soldier == _npc || _soldier!=vehicle _soldier || !alive _soldier || !canmove _soldier) exitwith {false}; + + //Animación para montar el arma + if ((count _this) > 1) then { + [_soldier,_position] spawn MON_doCreateMine; + }else{ + [_soldier] spawn MON_doCreateMine; + }; + true; +}; + +MON_doCreateMine = { + private ["_npc","_rnd","_soldier","_mine","_dir","_position"]; + _position = [0,0]; + + _soldier = _this select 0; + if ((count _this) > 1) then {_position = _this select 1;}; + + //If not is Man or dead exit + if (!(_x iskindof "Man" ) || _soldier!=vehicle _soldier || !alive _soldier || !canmove _soldier) exitwith {false}; + + _soldier stop false; + [_soldier,"AUTO"] spawn MON_setUnitPos; + + if ((count _this) > 1) then { + _soldier domove _position; + waituntil {unitReady _soldier || moveToCompleted _soldier || moveToFailed _soldier || !alive _soldier || !canmove _soldier}; + }; + + if (moveToFailed _soldier || !alive _soldier || _soldier != vehicle _soldier || !canmove _soldier) exitwith {false}; + + //Crouche + _soldier playMovenow "ainvpknlmstpslaywrfldnon_1"; + sleep 1; + + if (!alive _soldier || !canmove _soldier) exitwith{}; + _dir = getdir _soldier; + _position = [position _soldier,_dir, 0.5] call MON_GetPos2D; + _mine = createMine ["MineMine", _position , [], 0]; + + //Prepare mine + _soldier playMoveNow "AinvPknlMstpSlayWrflDnon_medic"; + sleep 5; + + //Return to formation + _soldier domove position ( leader _soldier ); +}; + +//Function to surrender AI soldier +//Parámeters: [_npc] +// <- _npc: soldier to surrender +MON_surrender = { + private ["_npc","_vehicle"]; + _npc = _this select 0; + + if (!alive _npc || !canmove _npc) exitwith {}; + + _npc addrating -1000; + _npc setcaptive true; + sleep 0.5; + + _vehicle = vehicle _npc; + + if ( _npc != _vehicle || !(_npc iskindof "Man" )) then { + _vehicle setcaptive true; + + if ( "Air" countType [_vehicle]>0) then { + + //Si acaba de entrar en el heli se define punto de aterrizaje + if (_npc == driver _vehicle ) then { + [_vehicle] call MON_landHely; + }; + } else { + _npc spawn MON_doGetOut; + }; + + //Esperamos a que esté parado + waituntil {_npc == vehicle _npc || !alive _npc}; + }; + + if (!alive _npc || !canmove _npc) exitwith {}; + _npc setcaptive true; + _npc stop true; + + [_npc,"UP"] call MON_setUnitPos; + removeAllWeapons _npc; + sleep 1; + _npc playMoveNow "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon"; + +}; + +//Returns leader if was dead +MON_getleader = { + private ["_npc","_members"]; + _npc = _this select 0; + _members = _this select 1; + + sleep 0.05; + if (!alive _npc ) then { + //takes commder a soldier not in vehicle + { + if (alive _x && canmove _x && _x == vehicle _x && !isplayer _x) exitwith { + _npc = _x; + }; + } foreach _members; + + //if no soldier out of vehicle takes any + if (!alive _npc ) then { + { + if (alive _x && canmove _x) exitwith {_npc = _x;}; + } foreach _members; + }; + + //If not alive or already leader or is player exits + if (isPlayer _npc || !alive _npc || !canmove _npc ) then + { + { + if (alive _x && !isPlayer _x) exitwith {_npc = [_npc, _members] call MON_getleader;}; + }foreach _members; + }; + + if (leader _npc == _npc) exitwith {_npc}; + + //Set new _npc as leader + group _npc selectLeader _npc; + }; + _npc // return +}; + +MON_ACE_Watersurvival = { + private ["_lb","_pos","_ejector","_in","_grpid","_rnd"]; + _in =[]; + _rnd = 0; + _ejector = _this select 0; + //if (KRON_UPS_Debug>0) then {player globalchat format["MON_ACE_Watersurvival %1",typeof _ejector]}; + + waitUntil { !canmove _ejector || !alive _ejector || isnull (_ejector) || ((getPos vehicle _ejector) select 2 < 1) }; + if ( !surfaceIsWater (getpos _ejector) || !canmove _ejector || !alive _ejector || isnull (_ejector) ) exitWith {}; + + //Miramos de entrar en un barco cercano + _grpid = _ejector getvariable "UPSMON_grpid"; + if (isnil "_grpid") then {_grpid = 0}; + _in = [_grpid,_ejector,30] call MON_GetIn_NearestBoat; + + //If no boat near creates a zodiac + if (count _in <= 0) then { + if (!(isNil "ace_main")) then { + _lb = "ACE_Lifeboat_US" createVehicle getposASL _ejector; + }else{ + _lb = "Zodiac" createVehicle getposASL _ejector; + }; + _pos = getposASL _ejector; + _pos set [0, ((_pos select 0) + 2)]; + _pos set [1, ((_pos select 1) + 2)]; + //_pos set [2, 0]; + _lb setPos _pos; + + //Moves in boat + if !(isPlayer _ejector) then { + [_ejector,_lb,0] call MON_assignasdriver; + }; + }; + + //Wait until reached eart + waitUntil { !canmove _ejector || !alive _ejector || isnull (_ejector) || !surfaceIsWater (position _ejector) }; + if (KRON_UPS_Debug>0) then {player globalchat format["Exit from boat%1",typeof _lb]}; + _ejector spawn MON_dogetout; +}; + +//=============================================================Changed by Shay_gman======================================================================================== +//Function to do artillery +//Parámeters: [_position,(_rounds,_area,_cadence,_mincadence)] +// <- _arti: +// <- _position: center of fire create artillery +// <- _rounds: rounds of fire +// <- _area: Dispersion area +// <- _maxcadence: Cadence of fire, is random between min +// <- _mincadence: Minimum cadence +// <- _bullet: class of bullet to fire, default ARTY_Sh_81_HE + +MON_artillery_dofire = { + if (!isserver) exitWith {}; + private ["_smoke1","_i","_area","_position","_maxcadence","_mincadence","_sleep","_rounds","_arti","_timeout","_salvo_break"]; + _area = 150; + _maxcadence = 10; + _mincadence = 5; + _sleep = 0; + _rounds = 5; + _bullet = "ARTY_Sh_81_HE"; + _position =[]; + _salvo_break = 10; + + _arti = _this select 0; + _position = _this select 1; + if ((count _this) > 2) then {_rounds = _this select 2;}; + if ((count _this) > 3) then {_area = _this select 3;}; + if ((count _this) > 4) then {_maxcadence = _this select 4;}; + if ((count _this) > 5) then {_mincadence = _this select 5;}; + if ((count _this) > 6) then {_bullet = _this select 6;}; + if ((count _this) > 7) then {_salvo_break = _this select 7;}; + + // set reload time for 1000 make do not fire untill this salvo finish + _timeout = time + 1000; + _arti setVariable ["timeout", _timeout, false]; + + _area2 = _area * 2; + if (KRON_UPS_Debug>0) then { player globalchat format["artillery doing fire on %1",_position] }; + for [{_i=0}, {_i<_rounds}, {_i=_i+1}] do + { + _arti fire (weapons _arti select 0); + _sleep = random _maxcadence; + if (_sleep < _mincadence) then {_sleep = _mincadence}; + sleep _sleep; + _smoke1 = _bullet createVehicle [(_position select 0)+ random _area2 - _area, (_position select 1)+ random _area2 - _area, (_position select 2)+ 100]; + _arti setVehicleAmmo 1; + }; + + // set reload time for next salvo + _timeout = time + _salvo_break; + _arti setVariable ["timeout", _timeout, false]; + }; + +//Función que devuelve un array con los vehiculos terrestres más cercanos +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_deadbodies = { + private["_vehicles","_npc","_bodies","_OCercanos","_distance","_side"]; + + _npc = _this select 0; + _distance = _this select 1; + //_side = _this select 2; + + _OCercanos = []; + _bodies = []; + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Man"] , _distance]; + + { + if (_npc knowsabout _x >0.5 && (!canmove _x || !alive _x)) then { _bodies = _bodies + [_x];}; + }foreach _OCercanos; + + _bodies; + }; + +//Función que devuelve un array con los vehiculos terrestres más cercanos +//Parámeters: [_npc,_distance] +// <- _npc: object for position search +// <- _distance: max distance from npc +// -> _vehicles: array of vehicles +MON_nearestSoldiers = { + private["_vehicles","_npc","_soldiers","_OCercanos","_distance","_side"]; + + _npc = _this select 0; + _distance = _this select 1; + + if (isnull _npc) exitwith {}; + + _OCercanos = []; + _soldiers = []; + + //Buscamos objetos cercanos + _OCercanos = nearestObjects [_npc, ["Man"] , _distance]; + _OCercanos = _OCercanos - [_npc]; + + { + if ( alive _x && canmove _x ) then { _soldiers = _soldiers + [_x];}; + }foreach _OCercanos; + + _soldiers; +}; \ No newline at end of file diff --git a/Server/PVFunctions/RequestChangeScore.sqf b/Server/PVFunctions/RequestChangeScore.sqf new file mode 100644 index 0000000..2d7bec8 --- /dev/null +++ b/Server/PVFunctions/RequestChangeScore.sqf @@ -0,0 +1,12 @@ +Private["_oldScore","_newScore","_playerChanged"]; + +_playerChanged = _this select 0; +_newScore = _this select 1; + +_oldScore = score _playerChanged; +_playerChanged addScore -_oldScore; +_playerChanged addScore _newScore; + +WFBE_ChangeScore = [nil,'CLTFNCCHANGESCORE',[_playerChanged,_newScore]]; +publicVariable 'WFBE_ChangeScore'; +if (isHostedServer) then {[nil,'CLTFNCCHANGESCORE',[_playerChanged,_newScore]] Spawn HandlePVF}; diff --git a/Server/PVFunctions/RequestCommanderVote.sqf b/Server/PVFunctions/RequestCommanderVote.sqf new file mode 100644 index 0000000..cff13d4 --- /dev/null +++ b/Server/PVFunctions/RequestCommanderVote.sqf @@ -0,0 +1,20 @@ +Private["_commanderTeam","_side","_team"]; + +_side = _this; + +if ((WF_Logic getVariable Format["%1CommanderVoteTime",str _side]) <= 0) then { + _team = -1; + _commanderTeam = (_side) Call GetCommanderTeam; + + if (!IsNull _commanderTeam) then { + _team = (Format["WFBE_%1TEAMS",str _side] Call GetNamespace) find _commanderTeam; + }; + + [_side,_team] Call SetCommanderVotes; + [_side] Spawn SVoteForCommander; + ["VotingForNewCommander","",_side,""] Spawn SideMessage; + + WFBE_VoteForCommander = [_side,'CLTFNCVOTEFORCOMMANDER']; + publicVariable 'WFBE_VoteForCommander'; + if (isHostedServer) then {[_side,'CLTFNCVOTEFORCOMMANDER'] Spawn HandlePVF}; +}; diff --git a/Server/PVFunctions/RequestDefense.sqf b/Server/PVFunctions/RequestDefense.sqf new file mode 100644 index 0000000..70d6a5d --- /dev/null +++ b/Server/PVFunctions/RequestDefense.sqf @@ -0,0 +1,11 @@ +private ["_defenseType","_dir","_index","_manned","_pos","_side"]; +_side = _this select 0; +_defenseType = _this select 1; +_pos = _this select 2; +_dir = _this select 3; +_manned = _this select 4; + +_index = (Format["WFBE_%1DEFENSENAMES",str _side] Call GetNamespace) find _defenseType; +if (_index != -1) then { + [_defenseType,_side,_pos,_dir,_manned,false] Call ConstructDefense; +}; \ No newline at end of file diff --git a/Server/PVFunctions/RequestJoin.sqf b/Server/PVFunctions/RequestJoin.sqf new file mode 100644 index 0000000..010dff6 --- /dev/null +++ b/Server/PVFunctions/RequestJoin.sqf @@ -0,0 +1,28 @@ +Private["_canJoin","_get","_name","_side","_sideOrigin","_uid","_varname"]; + +_uid = _this select 0; +_side = _this select 1; +_name = _this select 2; +_varname = _this select 3; + +_canJoin = true; + +_get = Format["WFBE_JIP_USER%1",_uid] Call GetNamespace; + +if !(isNil '_get') then { + _sideOrigin = _get select 3; + + if (_sideOrigin != _side) then { + if !(paramShowUID) then {_uid = "xxxxxxx"}; + + WFBE_LocalizeMessage = [nil,'CLTFNCLOCALIZEMESSAGE',['Teamswap',_name,_uid,_sideOrigin,_side]]; + publicVariable 'WFBE_LocalizeMessage'; + + _canJoin = false; + + diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] RequestJoin: Player %1 <%2> (%3) has been sent back to the lobby for teamswapping.",_name,_varname,_get select 0,diag_frameno,diag_tickTime]; + }; +}; + +WFBE_CanJoin = [_varname,'CLTFNCCANJOIN',[_varname,_canJoin]]; +publicVariable 'WFBE_CanJoin'; \ No newline at end of file diff --git a/Server/PVFunctions/RequestMHQRepair.sqf b/Server/PVFunctions/RequestMHQRepair.sqf new file mode 100644 index 0000000..087a7a1 --- /dev/null +++ b/Server/PVFunctions/RequestMHQRepair.sqf @@ -0,0 +1 @@ +[_this] Spawn MHQRepair; \ No newline at end of file diff --git a/Server/PVFunctions/RequestSpecial.sqf b/Server/PVFunctions/RequestSpecial.sqf new file mode 100644 index 0000000..3455c98 --- /dev/null +++ b/Server/PVFunctions/RequestSpecial.sqf @@ -0,0 +1 @@ +_this Spawn HandleSpecial; \ No newline at end of file diff --git a/Server/PVFunctions/RequestStructure.sqf b/Server/PVFunctions/RequestStructure.sqf new file mode 100644 index 0000000..ad6b610 --- /dev/null +++ b/Server/PVFunctions/RequestStructure.sqf @@ -0,0 +1,12 @@ +Private ['_dir','_index','_pos','_script','_side','_structure','_structureType']; + +_side = _this select 0; +_structureType = _this select 1; +_pos = _this select 2; +_dir = _this select 3; + +_index = (Format ["WFBE_%1STRUCTURENAMES",str _side] Call GetNamespace) find _structureType; +if (_index != -1) then { + _script = (Format ["WFBE_%1STRUCTURESCRIPTS",str _side] Call GetNamespace) select _index; + [_structureType,_side,_pos,_dir,_index] ExecVM (Format["Server\Construction\Construction_%1.sqf",_script]); +}; \ No newline at end of file diff --git a/Server/PVFunctions/RequestTeamUpdate.sqf b/Server/PVFunctions/RequestTeamUpdate.sqf new file mode 100644 index 0000000..892c182 --- /dev/null +++ b/Server/PVFunctions/RequestTeamUpdate.sqf @@ -0,0 +1,26 @@ +private ["_args","_team"]; + +_args = _this; +_team = _args select 0; + +//--- One team. +if (typeName _team == "ARRAY") then { + { + _x setBehaviour (_args select 1); + _x setCombatMode (_args select 2); + _x setFormation (_args select 3); + _x setSpeedMode (_args select 4); + diag_log Format["[WFBE (INFORMATION)][frameno:%6 | ticktime:%7] RequestTeamUpdate: The %1 Team properties has been updated (Behavior: %2 | Combat Mode: %3 | Formation: %4 | Speed Mode: %5)",_x,(_args select 1),(_args select 2),(_args select 3),(_args select 4),diag_frameno,diag_tickTime]; + } forEach _team; +}; + +//--- The whole team. +if (typeName _team == "SIDE") then { + { + _x setBehaviour (_args select 1); + _x setCombatMode (_args select 2); + _x setFormation (_args select 3); + _x setSpeedMode (_args select 4); + } forEach (Format["WFBE_%1TEAMS",str _team] Call GetNamespace); + diag_log Format["[WFBE (INFORMATION)][frameno:%6 | ticktime:%7] RequestTeamUpdate: The %1 Teams properties have been updated (Behavior: %2 | Combat Mode: %3 | Formation: %4 | Speed Mode: %5)",_team,(_args select 1),(_args select 2),(_args select 3),(_args select 4),diag_frameno,diag_tickTime]; +}; \ No newline at end of file diff --git a/Server/PVFunctions/RequestUpgrade.sqf b/Server/PVFunctions/RequestUpgrade.sqf new file mode 100644 index 0000000..f811ca5 --- /dev/null +++ b/Server/PVFunctions/RequestUpgrade.sqf @@ -0,0 +1 @@ +_this Spawn AIUpgrade; \ No newline at end of file diff --git a/Server/PVFunctions/RequestVehicleLock.sqf b/Server/PVFunctions/RequestVehicleLock.sqf new file mode 100644 index 0000000..299ca0e --- /dev/null +++ b/Server/PVFunctions/RequestVehicleLock.sqf @@ -0,0 +1,10 @@ +private ["_locked","_vehicle"]; + +_vehicle = _this select 0; +_locked = _this select 1; + +_vehicle lock _locked; + +WFBE_SetVehicleLock = [nil,'CLTFNCSETVEHICLELOCK',[_vehicle,_locked]]; +publicVariable 'WFBE_SetVehicleLock'; +if (isHostedServer) then {[nil,'CLTFNCSETVEHICLELOCK',[_vehicle,_locked]] Spawn HandlePVF}; diff --git a/Server/PVFunctions/RequestWorker.sqf b/Server/PVFunctions/RequestWorker.sqf new file mode 100644 index 0000000..3c891dc --- /dev/null +++ b/Server/PVFunctions/RequestWorker.sqf @@ -0,0 +1,19 @@ +Private["_group","_index","_model","_models","_position","_side","_unit"]; + +_side = _this select 0; +_position = _this select 1; +_index = _this select 2; + +_models = Format ["WFBE_WORKERS_MODELS_%1",str _side] Call GetNamespace; +_model = _models select (round(random((count _models)-1))); +_group = createGroup _side; +_position = [getPos _position, 30] Call GetSafePlace; +_unit = [_model,_group,_position,_side] Call CreateMan; + +_group setSpeedMode "LIMITED"; + +_workers = Call Compile Format ["WF_%1Workers",str _side]; +_workers set [_index, _unit]; +Call Compile Format ["WF_%1Workers = _workers; publicVariable 'WF_%1Workers';",str _side]; + +[_unit,_side,_index] ExecFSM "Server\FSM\workers.fsm"; \ No newline at end of file diff --git a/Server/Server_PlayerConnected.sqf b/Server/Server_PlayerConnected.sqf new file mode 100644 index 0000000..b8856a4 --- /dev/null +++ b/Server/Server_PlayerConnected.sqf @@ -0,0 +1,109 @@ +/* + Author: Benny + Name: Server_PlayerConnected.sqf + Parameters: + 0 - User ID + 1 - User Name + Description: + This file is called upon a player connection, the player's information are stored or retrieved before being updated. +*/ +Private ['_attempts','_funds','_get','_name','_sideJoined','_sideOrigin','_slotIndex','_team','_uid','_units']; +_uid = _this select 0; +_name = _this select 1; + +diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_PlayerConnected: Player %1 (%2) has joined the game",_name,_uid,diag_frameno,diag_tickTime]; + +sleep (0.1+random(0.1)); + +//--- Don't bother with the server. +if (_name == '__SERVER__' || _uid == '') exitWith {}; + +//--- Attempt to get the player's team. +_attempts = 0; +_team = objNull; +while {_attempts < 12 && isNull _team} do { + sleep 1; + {if ((getPlayerUID (leader _x)) == _uid) then {_team = _x}} forEach ('WFBE_EASTTEAMS' Call GetNamespace); + {if ((getPlayerUID (leader _x)) == _uid) then {_team = _x}} forEach ('WFBE_WESTTEAMS' Call GetNamespace); + _attempts = _attempts + 1; +}; + +//--- Not found, exit. +if (isNull _team) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_PlayerConnected: Player %1 (%2) is not defined within the west and east teams.",_name,_uid,diag_frameno,diag_tickTime]}; + +_sideJoined = civilian; + +//--- Nasty hack, a leader side can be enemy so we do a class check. +if ((leader _team) isKindOf westSoldierBaseClass) then {_sideJoined = west}; +if ((leader _team) isKindOf eastSoldierBaseClass) then {_sideJoined = east}; + +//--- Type not found. +if (_sideJoined == civilian) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_PlayerConnected: Player %1 (%2) side couldn't be found.",_name,_uid,diag_frameno,diag_tickTime]}; + +//--- Retrieve the player's team. +_slotIndex = (Format["WFBE_%1TEAMS",str _sideJoined] Call GetNamespace) find _team; +if (_slotIndex == -1) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_PlayerConnected: Player %1 (%2) team's wasn't found.",_name,_uid,diag_frameno,diag_tickTime]}; + +//--- MySQL Update. +if (mysql) then { + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_Insert_Players?%1?%2",_uid,_name]]]; +}; + +//--- Grab the player info (if they exist). +_get = Format["WFBE_JIP_USER%1",_uid] Call GetNamespace; + +//--- Force the unit out if it's in a vehicle. +if !(isNull(assignedVehicle (leader _team))) then { + unassignVehicle (leader _team); + [leader _team] orderGetIn false; + [leader _team] allowGetIn false; +}; + +//--- Do we keep the AI over JIP?. +if !(paramKeepAI) then { + diag_log Format ["[WFBE (INFORMATION)][frameno:%7 | ticktime:%8] Server_PlayerConnected: Removing units (Team: %1, Team Side: %2, Team Leader: %3) for Player %4 (%5) DEBUG:%6.",_team,side _team,name (leader _team),_name,_uid,_get,diag_frameno,diag_tickTime]; + _units = units _team; + _units = _units - [(leader _team)]; + _units = _units + ([_team,false] Call GetTeamVehicles); + {deleteVehicle _x} forEach _units; +}; + +//--- 'Sanitize' the player. +_team Call AIWPRemove; +(leader _team) setDammage 0; + +//--- ISIS. +if (('WFBE_ISIS' Call GetNamespace) != 0) then {(leader _team) removeAllEventHandlers "handleDamage"}; + +//--- Player didn't d/c. +if (isNil '_get') exitWith { + /* + UID | Slot Index | Cash | Side | Current Side | (mysql) time | Vehicle Var Name + This new method allows the server to execute the code faster, it will also prevent any possible 'wrong indexing' with the array (JIP Scripts are ExecVM'ed + by the engine), note that this method also sanitize the values, preventing them from being modified by anything else than the server. + */ + [Format["WFBE_JIP_USER%1",_uid],[_uid,_slotIndex,0,_sideJoined,_sideJoined,if (mysql) then {round(time)} else {0},vehicleVarName (leader _team)],true] Call SetNamespace; + + Call Compile Format ["%1Funds = %2; publicVariable '%1Funds';",_team getVariable 'identification',Format ["WFBE_%1STARTINGMONEY",str _sideJoined] Call GetNamespace]; +}; + +//--- Player d/c before, update info. +_get set [1,_slotIndex]; +_get set [4,_sideJoined]; +if (mysql) then {_get set [5,round(time)]}; +_get set [6,vehicleVarName (leader _team)]; + +//--- Player d/c before, grab the info. +_funds = _get select 2; +_sideOrigin = _get select 3; + +//--- Update. +[Format["WFBE_JIP_USER%1",_uid],_get,true] Call SetNamespace; + +//--- Did the player teamswap?. +if (_sideOrigin != _sideJoined) then { + _funds = Format ["WFBE_%1STARTINGMONEY",str _sideJoined] Call GetNamespace; +}; + +//--- Set the cash. +Call Compile Format ["%1Funds = _funds; publicVariable '%1Funds';",_team getVariable 'identification']; \ No newline at end of file diff --git a/Server/Server_PlayerDisconnected.sqf b/Server/Server_PlayerDisconnected.sqf new file mode 100644 index 0000000..8242514 --- /dev/null +++ b/Server/Server_PlayerDisconnected.sqf @@ -0,0 +1,87 @@ +/* + Author: Benny + Name: Server_PlayerDisconnected.sqf + Parameters: + 0 - User ID + 1 - User Name + Description: + This file is called upon a player disconnection, the player's information are updated. +*/ +Private ['_buildings','_closestRespawn','_cmdrTeam','_funds','_get','_hq','_name','_respawnLoc','_side','_sideText','_slotIndex','_team','_units','_uid']; +_uid = _this select 0; +_name = _this select 1; + +diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_PlayerDisconnected: Player %1 (%2) has left the game",_name,_uid,diag_frameno,diag_tickTime]; + +//--- Grab the player info (if they exist). +_get = Format["WFBE_JIP_USER%1",_uid] Call GetNamespace; +if (isNil '_get') exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_PlayerDisconnected: Player %1 (%2) don't have any information stored.",_name,_uid,diag_frameno,diag_tickTime]}; + +//--- Check this mess. +_side = _get select 4; +_sideText = str _side; +_slotIndex = _get select 1; +_team = Call Compile Format ["group %1",_get select 6]; +if (isNull _team) exitWith {diag_log Format ["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_PlayerDisconnected: Player %1 (%2) team is null.",_name,_uid,diag_frameno,diag_tickTime]}; + +//--- MySQL Update. +if (mysql && !gameOver) then { + Private ['_strTrans']; + _strTrans = if (_side == west) then {'west'} else {'east'}; + WF_Logic setVariable ["WF_MYSQL_SERVER",(WF_Logic getVariable "WF_MYSQL_SERVER") + [Format ["MYSQLDATA?WFBE_Disconnect_Player?%1?%2?%3?%4?%5",_uid,_name,round(time - (_get select 5)),_strTrans,worldName]]]; +}; + +//--- Force the unit out if it has a vehicle. +if !(isNull(assignedVehicle (leader _team))) then { + unassignVehicle (leader _team); + [leader _team] orderGetIn false; + [leader _team] allowGetIn false; +}; + +//--- Is unit driving the HQ? +_hq = (_sideText) Call GetSideHQ; +if (vehicle(leader _team) == _hq) then {(leader _team) action ["EJECT", _hq]}; + +//--- Keep AI over JIP? +if !(paramKeepAI) then { + diag_log Format ["[WFBE (INFORMATION)][frameno:%7 | ticktime:%8] Server_PlayerDisconnected: Removing units (Team: %1, Team Side: %2, Team Leader: %3) for Player %4 (%5) DEBUG:%6.",_team,side _team,leader _team,_name,_uid,_get,diag_frameno,diag_tickTime]; + _units = units _team; + _units = _units - [leader _team]; + _units = _units + ([_team,false] Call GetTeamVehicles) - [_hq]; + {deleteVehicle _x} forEach _units; +}; + +//--- Save the Client Cash. +_funds = _team Call GetTeamFunds; +_get set [2,_funds]; + +//--- SetPos the AI. +_buildings = (_sideText) Call GetSideStructures; +_respawnLoc = _hq; +if (count _buildings > 0) then { + _closestRespawn = [leader _team,_buildings] Call SortByDistance; + _respawnLoc = _closestRespawn select 0; +}; +(leader _team) setPos ([getPos _respawnLoc,20,30] Call GetRandomPosition); + +//--- ISIS. +if (('WFBE_ISIS' Call GetNamespace) != 0) then {(leader _team) addEventHandler['handleDamage',{_this Call ISIS_Wound}]}; + +//--- Update. +[Format["WFBE_JIP_USER%1",_uid],_get,true] Call SetNamespace; + +//--- Player was commander?. +_cmdrTeam = (_side) Call GetCommanderTeam; +if !(isNull (_cmdrTeam)) then { + if (_team == _cmdrTeam) then { + WF_Logic setVariable [Format ["%1CommanderTeam",_sideText],objNull,true]; + WFBE_LocalizeMessage = [_side,'CLTFNCLOCALIZEMESSAGE',['CommanderDisconnected']]; + publicVariable 'WFBE_LocalizeMessage'; + + //--- High Command (Remove). + if (paramHighCommand && count (hcAllGroups (leader _team)) > 0) then {HCRemoveAllGroups (leader _team)}; + + //--- AI Can move freely now & respawn at the default location. + {[_x,false] Call SetTeamAutonomous;[_x, ""] Call SetTeamRespawn;} forEach (Format["WFBE_%1TEAMS",_sideText] Call GetNamespace); + }; +}; \ No newline at end of file diff --git a/Server/Server_VoteForCommander.sqf b/Server/Server_VoteForCommander.sqf new file mode 100644 index 0000000..6a4d2a4 --- /dev/null +++ b/Server/Server_VoteForCommander.sqf @@ -0,0 +1,38 @@ +Private ['_aibase','_commanderTeam','_comVoteTime','_delay','_side','_sideText']; +_side = _this select 0; +_sideText = _side; + +_comVoteTime = 'WFBE_VOTETIME' Call GetNamespace; +WF_Logic setVariable [Format["%1CommanderVoteTime",_sideText],_comVoteTime,true]; + +while {_comVoteTime > 0} do { + sleep 1; + _comVoteTime = _comVoteTime - 1; + WF_Logic setVariable [Format["%1CommanderVoteTime",_sideText],_comVoteTime,true]; +}; + +WF_Logic setVariable [Format["%1CommanderVoteTime",_sideText],_comVoteTime,true]; + +_commanderTeam = [_side] Call GetCommanderFromVotes; +if (!IsNull _commanderTeam) then {WF_Logic setVariable [Format ["%1CommanderTeam",_sideText],_commanderTeam,true]} else {WF_Logic setVariable [Format ["%1CommanderTeam",_sideText],objNull,true]}; + +_delay = 0; +if (_side == East) then {_delay = 1}; + +sleep _delay; + +WFBE_CommanderVote = [_side,'CLTFNCCOMMANDERVOTE',_commanderTeam]; +publicVariable 'WFBE_CommanderVote'; +if (isHostedServer) then {[_side,'CLTFNCCOMMANDERVOTE',_commanderTeam] Spawn HandlePVF}; + +[Format["WFBE_%1_LastCommander",_sideText],_commanderTeam,true] Call SetNamespace; + +_aibase = Format["WFBE_%1_AIBase",_sideText] Call GetNamespace; +// if (isNull _commanderTeam && paramAIcom && !_aibase) then {[_side] ExecFSM "Server\FSM\aibase.fsm"}; +if (isNull _commanderTeam && paramAIcom && !_aibase) then {[_side] ExecFSM "Server\FSM\aicommander.fsm"}; + +if (isNull _commanderTeam) then { + diag_log Format["[WFBE (INFORMATION)][frameno:%2 | ticktime:%3] Server_VoteForCommander: %1 Commander = AI Commander.",_sideText,diag_frameno,diag_tickTime]; +} else { + diag_log Format["[WFBE (INFORMATION)][frameno:%3 | ticktime:%4] Server_VoteForCommander: %1 Commander = %2.",_sideText,name (leader _commanderTeam),diag_frameno,diag_tickTime]; +}; \ No newline at end of file diff --git a/Server/Support/Support_ParaAmmo.sqf b/Server/Support/Support_ParaAmmo.sqf new file mode 100644 index 0000000..2176b72 --- /dev/null +++ b/Server/Support/Support_ParaAmmo.sqf @@ -0,0 +1,107 @@ +Private['_args','_bd','_cargo','_grp','_pilot','_playerTeam','_positionCoord','_ran','_ranDir','_ranPos','_side','_timeStart','_vehicle','_vehicleCoord']; + +_args = _this; +_side = _args select 1; + +_playerTeam = (_args select 3); +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_HandleSpecial: The %1 %2 Team (Leader: %3) has called an Ammunition Paradroping",str _side,_playerTeam,name (leader _playerTeam),diag_frameno,diag_tickTime]; +_ranPos = []; +_ranDir = []; + +_bd = 'WFBE_BOUNDARIESXY' Call GetNamespace; +if !(isNil '_bd') then { + _ranPos = [ + [0+random(200),0+random(200),400+random(200)], + [0+random(200),_bd-random(200),400+random(200)], + [_bd-random(200),_bd-random(200),400+random(200)], + [_bd-random(200),0+random(200),400+random(200)] + ]; + _ranDir = [45,145,225,315]; +} else { + _ranPos = [[0+random(200),0+random(200),400+random(200)],[15000+random(200),0+random(200),400+random(200)]]; + _ranDir = [45,315]; +}; + +_timeStart = time; +_ran = round(random((count _ranPos)-1)); +_grp = createGroup _side; +_vehicle = createVehicle [Format ["WFBE_%1PARAVEHI",str _side] Call GetNamespace,(_ranPos select _ran), [], (_ranDir select _ran), "FLY"]; +_pilot = [Format ["WFBE_%1PILOT",str _side] Call GetNamespace,_grp,[100,12000,0],_side] Call CreateMan; +[str _side,'VehiclesCreated',1] Call UpdateStatistics; +[str _side,'UnitsCreated',1] Call UpdateStatistics; +_pilot moveInDriver _vehicle; +_grp setBehaviour 'CARELESS'; +_grp setCombatMode 'STEALTH'; +_pilot disableAI 'AUTOTARGET'; +_pilot disableAI 'TARGET'; +[_grp,(_args select 2),"MOVE",10] Call AIMoveTo; +Call Compile Format ["_vehicle addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; +_vehicle setVehicleInit Format["[this,%1] ExecVM 'Common\Common_InitUnit.sqf';",_side]; +processInitCommands; +_vehicle flyInHeight (200 + random(20)); +_cargo = (crew _vehicle) - [driver _vehicle, gunner _vehicle, commander _vehicle]; + +while {true} do { + sleep 1; + if (!alive _pilot || !alive _vehicle || isNull _vehicle || isNull _pilot) exitWith {}; + if (!(isPlayer (leader _playerTeam)) || time - _timeStart > 500) exitWith {{_x setDammage 1} forEach (_cargo+[_pilot,_vehicle]);deleteGroup _grp}; + _vehicleCoord = [getPos _pilot select 0,getpos _pilot select 1]; + _positionCoord = [(_args select 2) select 0,(_args select 2) select 1]; + if (_vehicleCoord distance _positionCoord < 100) exitWith {}; +}; + +[_vehicle,_side] Spawn { + Private ['_ammo','_ammos','_chopper','_chute','_side']; + _chopper = _this select 0; + _side = _this select 1; + + _ammos = Format["WFBE_%1PARAAMMO",_side] Call GetNamespace; + if (typeName _ammos != 'ARRAY') exitWith {diag_log Format["[WFBE (INFORMATION)] Server_HandleSpecial: Expected array, given %1 for ammunitions.",typeName _ammos]}; + + { + _ammo = _x createVehicle [0,0,0]; + + [_chopper,_ammo,_side] Spawn { + Private ['_ammo','_chopper','_chute','_pos','_side','_type']; + _chopper = _this select 0; + _ammo = _this select 1; + _side = _this select 2; + + _chute = (Format['WFBE_%1PARACHUTE',str _side] Call GetNamespace) createVehicle [0,0,20]; + _chute setPos [getPos _chopper select 0, getPos _chopper select 1, (getPos _chopper select 2) - 11]; + _chute setDir (getDir _chopper); + + _ammo setPos getPos _chute; + _ammo attachTo [_chute,[0,0,0]]; + waitUntil {getPos _ammo select 2 < 3}; + detach _ammo; + + _type = typeOf _ammo; + _pos = getPos _ammo; + deleteVehicle _ammo; + _ammo = _type createVehicle _pos; + + Call Compile Format ["_ammo addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; + + sleep 5; + + deleteVehicle _chute; + }; + + sleep 0.8; + } forEach _ammos; +}; + +[_grp,(_ranPos select _ran),"MOVE",10] Call AIMoveTo; + +while {true} do { + sleep 1; + if (!alive _pilot || !alive _vehicle || isNull _vehicle || isNull _pilot) exitWith {}; + _vehicleCoord = [getPos _pilot select 0,getpos _pilot select 1]; + _positionCoord = [(_ranPos select _ran) select 0,(_ranPos select _ran) select 1]; + if (_vehicleCoord distance _positionCoord < 200) exitWith {}; +}; + +deleteVehicle _pilot; +deleteVehicle _vehicle; +deleteGroup _grp; \ No newline at end of file diff --git a/Server/Support/Support_ParaVehicles.sqf b/Server/Support/Support_ParaVehicles.sqf new file mode 100644 index 0000000..837d97e --- /dev/null +++ b/Server/Support/Support_ParaVehicles.sqf @@ -0,0 +1,89 @@ +Private['_args','_bd','_cargo','_cargoVehicle','_grp','_pilot','_playerTeam','_positionCoord','_ran','_ranDir','_ranPos','_side','_timeStart','_vehicle','_vehicleCoord']; + +_args = _this; +_side = _args select 1; + +_playerTeam = (_args select 3); +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_HandleSpecial: The %1 %2 Team (Leader: %3) has called a Vehicle Paradroping",str _side,_playerTeam,name (leader _playerTeam),diag_frameno,diag_tickTime]; +_ranPos = []; +_ranDir = []; + +_bd = 'WFBE_BOUNDARIESXY' Call GetNamespace; +if !(isNil '_bd') then { + _ranPos = [ + [0+random(200),0+random(200),400+random(200)], + [0+random(200),_bd-random(200),400+random(200)], + [_bd-random(200),_bd-random(200),400+random(200)], + [_bd-random(200),0+random(200),400+random(200)] + ]; + _ranDir = [45,145,225,315]; +} else { + _ranPos = [[0+random(200),0+random(200),400+random(200)],[15000+random(200),0+random(200),400+random(200)]]; + _ranDir = [45,315]; +}; + +_timeStart = time; +_ran = round(random((count _ranPos)-1)); +_grp = createGroup _side; +_vehicle = createVehicle [Format ["WFBE_%1PARAVEHI",str _side] Call GetNamespace,(_ranPos select _ran), [], (_ranDir select _ran), "FLY"]; +[str _side,'VehiclesCreated',1] Call UpdateStatistics; +[str _side,'UnitsCreated',1] Call UpdateStatistics; +_pilot = [Format ["WFBE_%1PILOT",str _side] Call GetNamespace,_grp,[100,12000,0],_side] Call CreateMan; +_pilot moveInDriver _vehicle; +_pilot doMove (_args select 2); +_grp setBehaviour 'CARELESS'; +_grp setCombatMode 'STEALTH'; +_pilot disableAI 'AUTOTARGET'; +_pilot disableAI 'TARGET'; +[_grp,(_args select 2),"MOVE",10] Call AIMoveTo; +Call Compile Format ["_vehicle addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; +_vehicle setVehicleInit Format["[this,%1] ExecVM 'Common\Common_InitUnit.sqf';",_side]; +processInitCommands; +_vehicle flyInHeight (300 + random(75)); +_cargo = (crew _vehicle) - [driver _vehicle, gunner _vehicle, commander _vehicle]; +_cargoVehicle = [Format ["WFBE_%1PARAVEHICARGO",str _side] Call GetNamespace,[0,0,50],_side,false] Call CreateVehi; +_cargoVehicle attachTo [_vehicle,[0,0,-3]]; + +emptyQueu = emptyQueu + [_cargoVehicle]; +_cargoVehicle Spawn HandleEmptyVehicle; + +while {true} do { + sleep 1; + if (!alive _pilot || !alive _vehicle || isNull _vehicle || isNull _pilot || !alive _cargoVehicle) exitWith {}; + if (!(isPlayer (leader _playerTeam)) || time - _timeStart > 500) exitWith {{_x setDammage 1} forEach (_cargo+[_pilot,_vehicle,_cargoVehicle]);deleteGroup _grp}; + _vehicleCoord = [getPos _pilot select 0,getpos _pilot select 1]; + _positionCoord = [(_args select 2) select 0,(_args select 2) select 1]; + if (_vehicleCoord distance _positionCoord < 100) exitWith {}; +}; + +detach _cargoVehicle; + +[_cargoVehicle,_side] Spawn { + Private ['_chute','_side','_vehicle']; + _vehicle = _this select 0; + _side = _this select 1; + sleep 2; + if (!alive _vehicle) exitWith {}; + _chute = (Format['WFBE_%1PARACHUTE',str _side] Call GetNamespace) createVehicle [0,0,20]; + _chute setPos [getPos _vehicle select 0, getPos _vehicle select 1, (getPos _vehicle select 2) - 11]; + _chute setDir (getDir _vehicle); + _vehicle attachTo [_chute,[0,0,0]]; + waitUntil {getPos _vehicle select 2 < 10 || !alive _vehicle}; + detach _vehicle; + sleep 10; + deleteVehicle _chute; +}; + +[_grp,(_ranPos select _ran),"MOVE",10] Call AIMoveTo; + +while {true} do { + sleep 1; + if (!alive _pilot || !alive _vehicle || isNull _vehicle || isNull _pilot) exitWith {}; + _vehicleCoord = [getPos _pilot select 0,getpos _pilot select 1]; + _positionCoord = [(_ranPos select _ran) select 0,(_ranPos select _ran) select 1]; + if (_vehicleCoord distance _positionCoord < 200) exitWith {}; +}; + +deleteVehicle _pilot; +deleteVehicle _vehicle; +deleteGroup _grp; \ No newline at end of file diff --git a/Server/Support/Support_Paratroopers.sqf b/Server/Support/Support_Paratroopers.sqf new file mode 100644 index 0000000..684e233 --- /dev/null +++ b/Server/Support/Support_Paratroopers.sqf @@ -0,0 +1,79 @@ +Private['_args','_bd','_built','_cargo','_currentLevel','_currentUpgrades','_delay','_grp','_pilot','_playerTeam','_positionCoord','_ran','_ranDir','_ranPos','_side','_timeStart','_unit','_units','_vehicle','_vehicleCoord']; + +_args = _this; +_side = _args select 1; + +_playerTeam = (_args select 3); +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_HandleSpecial: The %1 %2 Team (Leader: %3) has called a Paratroops Reinforcement",str _side,_playerTeam,name (leader _playerTeam),diag_frameno,diag_tickTime]; +_ranPos = []; +_ranDir = []; + +_bd = 'WFBE_BOUNDARIESXY' Call GetNamespace; +if !(isNil '_bd') then { + _ranPos = [ + [0+random(200),0+random(200),400+random(200)], + [0+random(200),_bd-random(200),400+random(200)], + [_bd-random(200),_bd-random(200),400+random(200)], + [_bd-random(200),0+random(200),400+random(200)] + ]; + _ranDir = [45,145,225,315]; +} else { + _ranPos = [[0+random(200),0+random(200),400+random(200)],[15000+random(200),0+random(200),400+random(200)]]; + _ranDir = [45,315]; +}; + +_timeStart = time; +_ran = round(random((count _ranPos)-1)); +_grp = createGroup _side; +_vehicle = createVehicle [Format ["WFBE_%1PARACARGO",str _side] Call GetNamespace,(_ranPos select _ran), [], (_ranDir select _ran), "FLY"]; +[str _side,'VehiclesCreated',1] Call UpdateStatistics; +_pilot = [Format ["WFBE_%1PILOT",str _side] Call GetNamespace,_grp,[100,12000,0],_side] Call CreateMan; +_pilot moveInDriver _vehicle; +_pilot doMove (_args select 2); +_grp setBehaviour 'CARELESS'; +_grp setCombatMode 'STEALTH'; +_pilot disableAI 'AUTOTARGET'; +_pilot disableAI 'TARGET'; +_built = 1; +[_grp,(_args select 2),"MOVE",10] Call AIMoveTo; +Call Compile Format ["_vehicle addEventHandler ['Killed',{[_this select 0,_this select 1,%1] Spawn UnitKilled}]",_side]; +_vehicle setVehicleInit Format["[this,%1] ExecVM 'Common\Common_InitUnit.sqf';",_side]; +processInitCommands; +_vehicle flyInHeight (300 + random(75)); +_currentUpgrades = (str _side) Call GetSideUpgrades; +_currentLevel = _currentUpgrades select 4; +_units = Format ["WFBE_%1PARACHUTELEVEL%2",Str _side,_currentLevel] Call GetNamespace; +{ + _unit = [_x,_grp,[100,12000,0],_side] Call CreateMan; + _unit moveInCargo _vehicle; + _built = _built + 1; +} forEach _units; + +[str _side,'UnitsCreated',_built] Call UpdateStatistics; +_cargo = (crew _vehicle) - [driver _vehicle, gunner _vehicle, commander _vehicle]; + +while {true} do { + sleep 1; + if (!alive _pilot || !alive _vehicle || isNull _vehicle || isNull _pilot) exitWith {}; + if (!(isPlayer (leader _playerTeam)) || time - _timeStart > 500) exitWith {{_x setDammage 1} forEach (_cargo+[_pilot,_vehicle]);deleteGroup _grp}; + _vehicleCoord = [getPos _pilot select 0,getpos _pilot select 1]; + _positionCoord = [(_args select 2) select 0,(_args select 2) select 1]; + if (_vehicleCoord distance _positionCoord < 200) exitWith {}; +}; + +_delay = 1; +if (_side == WEST) then {_delay = 0.3}; +{_x action ["EJECT",_vehicle];sleep _delay;[_x] join (leader _playerTeam)} forEach _cargo; +[_grp,(_ranPos select _ran),"MOVE",10] Call AIMoveTo; + +while {true} do { + sleep 1; + if (!alive _pilot || !alive _vehicle || isNull _vehicle || isNull _pilot) exitWith {}; + _vehicleCoord = [getPos _pilot select 0,getpos _pilot select 1]; + _positionCoord = [(_ranPos select _ran) select 0,(_ranPos select _ran) select 1]; + if (_vehicleCoord distance _positionCoord < 200) exitWith {}; +}; + +deleteVehicle _pilot; +deleteVehicle _vehicle; +deleteGroup _grp; \ No newline at end of file diff --git a/Server/Support/Support_UAV.sqf b/Server/Support/Support_UAV.sqf new file mode 100644 index 0000000..aded9a0 --- /dev/null +++ b/Server/Support/Support_UAV.sqf @@ -0,0 +1,20 @@ +Private["_args","_driver","_gunner","_playerTeam","_side","_uav"]; + +_args = _this; +_side = _args select 1; + +_uav = (_args select 2); +_driver = driver _uav; +_gunner = gunner _uav; +_playerTeam = (_args select 3); + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] Server_HandleSpecial: The %1 %2 Team (Leader: %3) has called an UAV",str _side,_playerTeam,name (leader _playerTeam),diag_frameno,diag_tickTime]; + +while {true} do { + sleep 5; + if (!(isPlayer (leader _playerTeam)) || !alive _uav) exitWith {}; +}; + +if (!isNull _driver) then {if (alive _driver) then {_driver setDammage 1};if (!(_driver in trashQueu)) then {trashQueu = trashQueu + [_driver];_driver Spawn TrashObject}}; +if (!isNull _gunner) then {if (alive _gunner) then {_gunner setDammage 1};if (!(_gunner in trashQueu)) then { trashQueu = trashQueu + [_gunner];_gunner Spawn TrashObject}}; +if (!isNull _uav) then {if (alive _uav) then {_uav setDammage 1};if (!(_uav in trashQueu)) then { trashQueu = trashQueu + [_uav];_uav Spawn TrashObject}}; \ No newline at end of file -- cgit v1.3.1