From dee52083d359434fc3ac51a871c1b836d092d2ac Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:55:41 +0300 Subject: init --- 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 ++++++ 26 files changed, 11521 insertions(+) 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 (limited to 'Server/FSM') 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 -- cgit v1.3.1