/*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, Bases">*/
/*%FSM<HEAD>*/
/*
item0[] = {"Initialise_Base",0,4346,275.000000,275.000000,375.000000,325.000000,0.000000,"Initialise" \n "Base"};
item1[] = {"Is_friendly",4,218,150.000000,275.000000,250.000000,325.000000,1.000000,"Is" \n "friendly"};
item2[] = {"Is_enemy",4,218,400.000000,275.000000,500.000000,325.000000,0.000000,"Is" \n "enemy"};
item3[] = {"Add_Respawn_Location",2,250,25.000000,275.000000,125.000000,325.000000,0.000000,"Add Respawn" \n "Location &" \n "Vehicles"};
item4[] = {"Spawn_defenders",2,250,525.000000,275.000000,625.000000,325.000000,0.000000,"Spawn" \n "defenders & set" \n "marker"};
item5[] = {"Stop_vehicles_respawning",2,250,400.000000,425.000000,500.000000,475.000000,0.000000,"Stop vehicles" \n "respawning &" \n "remove spawn"};
item6[] = {"Base_being_captu",2,250,650.000000,575.000000,750.000000,625.000000,0.000000,"Base being" \n "captured"};
item7[] = {"Calculate___Spawn",2,250,775.000000,350.000000,875.000000,400.000000,0.000000,"Calculate &" \n "Spawn" \n "Reinforcements"};
item8[] = {"Do_the_checks",8,218,525.000000,350.000000,625.000000,400.000000,0.000000,"Do the checks"};
item9[] = {"Player_within_base",4,218,650.000000,500.000000,750.000000,550.000000,1.000000,"Player" \n "within base" \n "radius"};
item10[] = {"No_enemies_left",4,218,1025.000000,575.000000,1125.000000,625.000000,1.000000,"No" \n "enemies" \n "left"};
item11[] = {"Base_Taken_",2,250,1025.000000,200.000000,1125.000000,250.000000,0.000000,"Base" \n "Taken!"};
item12[] = {"Base_taken",8,218,25.000000,200.000000,125.000000,250.000000,0.000000,"Base" \n "taken"};
item13[] = {"Reinforcements_time",4,218,775.000000,275.000000,875.000000,325.000000,1.000000,"Reinforcements" \n "time?"};
item14[] = {"Players_no_longer",4,218,900.000000,500.000000,1000.000000,550.000000,0.000000,"Players" \n "no longer" \n "within radius"};
item15[] = {"Base_taken",8,218,400.000000,350.000000,500.000000,400.000000,0.000000,"Base" \n "taken"};
item16[] = {"Wait_for_grace_p",4,218,25.000000,350.000000,125.000000,400.000000,0.000000,"Wait for" \n "grace period"};
item17[] = {"Set_time_before",2,250,25.000000,425.000000,125.000000,475.000000,0.000000,"Set time" \n "before next" \n "attack"};
item18[] = {"Wait_for_the_att",4,218,25.000000,500.000000,125.000000,550.000000,1.000000,"Wait" \n "for the" \n "attack"};
item19[] = {"Attack_the_base",2,250,25.000000,575.000000,125.000000,625.000000,0.000000,"Attack the" \n "base!"};
item20[] = {"Enemies_defeated",4,218,150.000000,425.000000,250.000000,475.000000,2.000000,"Enemies" \n "defeated"};
item21[] = {"No_players_remai",4,218,400.000000,500.000000,500.000000,550.000000,1.000000,"No players" \n "remaining"};
item22[] = {"Only_1_base_left",4,218,400.000000,575.000000,500.000000,625.000000,2.000000,"Only 1" \n "base left"};
item23[] = {"Organise_tactical",2,250,25.000000,725.000000,125.000000,775.000000,0.000000,"Organise" \n "tactical" \n "retreat"};
item24[] = {"Ready_to_delete",4,218,-100.000000,575.000000,0.000000,625.000000,1.000000,"Ready" \n "to delete"};
item25[] = {"Clean_up_attacke",2,250,-225.000000,575.000000,-125.000000,625.000000,0.000000,"Clean up" \n "attackers"};
item26[] = {"Wait_for_more_than",4,218,-100.000000,425.000000,0.000000,475.000000,1.000000,"Wait for" \n "more than 1" \n "base"};
item27[] = {"Do_the_checks",4,218,150.000000,575.000000,250.000000,625.000000,0.000000,"Do the checks"};
item28[] = {"Check",2,250,275.000000,500.000000,375.000000,550.000000,0.000000,"Check"};
item29[] = {"Nothing_yet",8,218,150.000000,650.000000,250.000000,700.000000,0.000000,"Nothing yet"};
item30[] = {"Wait___",2,250,275.000000,650.000000,375.000000,700.000000,0.000000,"Wait..."};
item31[] = {"Do_the_checks",4,218,775.000000,425.000000,875.000000,475.000000,0.000000,"Do the checks"};
item32[] = {"Check_1",2,250,775.000000,500.000000,875.000000,550.000000,0.000000,"Check"};
item33[] = {"Ready_to_check",4,218,275.000000,575.000000,375.000000,625.000000,0.000000,"Ready to check"};
item34[] = {"Nothing_yet",8,218,650.000000,425.000000,750.000000,475.000000,0.000000,"Nothing yet"};
item35[] = {"Let_s_go_",8,218,650.000000,650.000000,750.000000,700.000000,0.000000,"Let's go!"};
item36[] = {"Set_timeout___",2,250,775.000000,650.000000,875.000000,700.000000,0.000000,"Set timeout..."};
item37[] = {"Do_the_checks",4,218,900.000000,650.000000,1000.000000,700.000000,0.000000,"Do the checks"};
item38[] = {"Check_2",2,250,900.000000,575.000000,1000.000000,625.000000,0.000000,"Check"};
item39[] = {"Get_ready",8,218,25.000000,800.000000,125.000000,850.000000,0.000000,"Get ready"};
item40[] = {"Set_timeout____1",2,250,-100.000000,800.000000,0.000000,850.000000,0.000000,"Set timeout..."};
item41[] = {"Do_the_checks",4,218,-100.000000,725.000000,0.000000,775.000000,0.000000,"Do the checks"};
item42[] = {"Check_3",2,250,-100.000000,650.000000,0.000000,700.000000,0.000000,"Check"};
item43[] = {"Not_ready_to_del",8,218,-225.000000,725.000000,-125.000000,775.000000,0.000000,"Not ready" \n "to delete"};
item44[] = {"Get_ready",8,218,-350.000000,575.000000,-250.000000,625.000000,0.000000,"Get ready"};
item45[] = {"Set_timeout",2,250,-350.000000,500.000000,-250.000000,550.000000,0.000000,"Set timeout"};
item46[] = {"Do_the_checks",4,218,-350.000000,425.000000,-250.000000,475.000000,0.000000,"Do the checks"};
item47[] = {"Check_4",2,250,-225.000000,425.000000,-125.000000,475.000000,0.000000,"Check"};
item48[] = {"Not_more_than_1",8,218,-225.000000,500.000000,-125.000000,550.000000,0.000000,"Not more" \n "than 1 base"};
item49[] = {"",7,210,446.000000,746.000000,454.000000,754.000000,0.000000,""};
item50[] = {"",7,210,946.000000,371.000000,954.000000,379.000000,0.000000,""};
item51[] = {"Time_up_and_back",4,218,-225.000000,350.000000,-125.000000,400.000000,0.000000,"Time up" \n "and back to one" \n "base?"};
item52[] = {"Set_grace_period",2,250,-225.000000,275.000000,-125.000000,325.000000,0.000000,"Set grace period" \n "timer again!"};
item53[] = {"Wait_for_grace_p",4,218,-100.000000,350.000000,0.000000,400.000000,0.000000,"Wait for" \n "grace period"};
link0[] = {0,1};
link1[] = {0,2};
link2[] = {1,3};
link3[] = {2,4};
link4[] = {3,16};
link5[] = {4,8};
link6[] = {5,15};
link7[] = {6,35};
link8[] = {7,13};
link9[] = {7,31};
link10[] = {8,7};
link11[] = {9,6};
link12[] = {10,11};
link13[] = {11,12};
link14[] = {12,3};
link15[] = {13,7};
link16[] = {14,50};
link17[] = {15,4};
link18[] = {16,17};
link19[] = {17,18};
link20[] = {17,51};
link21[] = {18,19};
link22[] = {19,27};
link23[] = {20,17};
link24[] = {21,5};
link25[] = {22,49};
link26[] = {23,39};
link27[] = {24,25};
link28[] = {25,44};
link29[] = {26,17};
link30[] = {27,28};
link31[] = {28,20};
link32[] = {28,21};
link33[] = {28,22};
link34[] = {28,29};
link35[] = {29,30};
link36[] = {30,33};
link37[] = {31,32};
link38[] = {32,9};
link39[] = {32,34};
link40[] = {33,28};
link41[] = {34,7};
link42[] = {35,36};
link43[] = {36,37};
link44[] = {37,38};
link45[] = {38,10};
link46[] = {38,14};
link47[] = {39,40};
link48[] = {40,41};
link49[] = {41,42};
link50[] = {42,24};
link51[] = {42,43};
link52[] = {43,40};
link53[] = {44,45};
link54[] = {45,46};
link55[] = {46,47};
link56[] = {47,26};
link57[] = {47,48};
link58[] = {48,45};
link59[] = {49,23};
link60[] = {50,7};
link61[] = {51,52};
link62[] = {52,53};
link63[] = {53,17};
globals[] = {25.000000,1,0,0,0,640,480,1,73,6316128,1,-486.994934,819.723877,1115.528809,21.610889,1529,1280,1};
window[] = {2,-1,-1,-1,-1,968,208,1648,208,3,1547};
*//*%FSM</HEAD>*/
class FSM
{
  fsmName = "Bases";
  class States
  {
    /*%FSM<STATE "Initialise_Base">*/
    class Initialise_Base
    {
      name = "Initialise_Base";
      init = /*%FSM<STATEINIT""">*/"_name = """";" \n
       "_isOwned = false;" \n
       "_pos = [];" \n
       "_marker = """";" \n
       "_markerText = """";" \n
       "_iconMarker = """";" \n
       "_radius = 100;" \n
       "_area = [];" \n
       "_groups = 5;" \n
       "_respawnGroups = 0;" \n
       "_respawnTime = 300;" \n
       "_tempVehs = [];" \n
       "_vehicles = [];" \n
       "_spawns = [];" \n
       "" \n
       "{" \n
       "	switch (_x select 0) do" \n
       "	{" \n
       "		case ""name"": { _name = _x select 1; };" \n
       "		case ""isOwned"": { _isOwned = if ((_x select 1) == 1) then { true } else { false }; };" \n
       "		case ""marker"":" \n
       "		{" \n
       "			_pos = getMarkerPos (_x select 1);" \n
       "			_marker = _x select 1;" \n
       "			_markerText = markerText _marker;" \n
       "			_iconMarker = format[""%1_icon"", _marker];" \n
       "			_radius = (getMarkerSize _marker) call BIS_fnc_greatestNum;" \n
       "			" \n
       "			_area = getMarkerSize _marker;" \n
       "			_area = _area + [markerDir _marker];" \n
       "			" \n
       "			_is_rectangle = if (markerShape _marker == ""RECTANGLE"") then { true } else { false };" \n
       "" \n
       "			_area = _area + [_is_rectangle];" \n
       "" \n
       "			_area = [markerPos _marker, _area];" \n
       "" \n
       "			diag_log _area;" \n
       "			" \n
       "		};" \n
       "		case ""groups"": { _groups = _x select 1; };" \n
       "		case ""respawnGroups"": { _respawnGroups = _x select 1; };" \n
       "		case ""respawnTime"": { _respawnTime = _x select 1; };" \n
       "		case ""vehicles"":" \n
       "		{" \n
       "			_tempVehs = _x select 1;" \n
       "			{" \n
       "				_vehicles = _vehicles + [_x];" \n
       "			} forEach _tempVehs;" \n
       "		};" \n
       "	};" \n
       "} forEach _this;" \n
       "" \n
       "//Get special spawn markers" \n
       "_code = format[""%1_spawn_"", _marker];" \n
       "{" \n
       "	if ([_code, _x] call BIS_fnc_inString) then { _spawns = _spawns + [_x]; };" \n
       "} forEach allMapMarkers;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Is_friendly">*/
        class Is_friendly
        {
          priority = 1.000000;
          to="Add_Respawn_Location";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_isOwned"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Is_enemy">*/
        class Is_enemy
        {
          priority = 0.000000;
          to="Spawn_defenders";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isOwned"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Add_Respawn_Location">*/
    class Add_Respawn_Location
    {
      name = "Add_Respawn_Location";
      init = /*%FSM<STATEINIT""">*/"basesOwned = basesOwned + [_marker];" \n
       "" \n
       "[[""base"", ""friendly""], _marker, _pos, _markerText] call AW_fnc_createJIPstateMarker;" \n
       "" \n
       "_respawnID = [west, _marker] call BIS_fnc_addRespawnPosition;" \n
       "" \n
       "_respawningHandles = [];" \n
       "_counter = 1;" \n
       "" \n
       "{" \n
       "	_unit_class = _x select 0;" \n
       "	_unit_marker = _x select 1;" \n
       "" \n
       "	call compile format" \n
       "	[" \n
       "		""" \n
       "			_%1_veh_%2 = [_unit_class, _unit_marker, _marker] execVM """"functions\units\fn_respawnVehicle.sqf"""";" \n
       "			_respawningHandles = _respawningHandles + [_%1_veh_%2];" \n
       "		""," \n
       "		_marker," \n
       "		_counter" \n
       "	];" \n
       "" \n
       "	_counter = _counter + 1;" \n
       "} forEach _vehicles;" \n
       "" \n
       "//Add in spawn markers" \n
       "baseSpawns = baseSpawns + _spawns;" \n
       "" \n
       "_timeout = time + PARAMS_base_gracePeriod;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Wait_for_grace_p">*/
        class Wait_for_grace_p
        {
          priority = 0.000000;
          to="Set_time_before";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(count basesOwned) >= PARAMS_base_basesOwnedBeforeAttacks && time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Spawn_defenders">*/
    class Spawn_defenders
    {
      name = "Spawn_defenders";
      init = /*%FSM<STATEINIT""">*/"[[""base"", ""enemy""], _marker, _pos, _name] call AW_fnc_createJIPstateMarker;" \n
       "" \n
       "_spawnedUnits = [EAST, _groups, _marker] call AW_fnc_spawnEnemy;" \n
       "[_spawnedUnits, [[""patrol"", true, 100]]] call AW_fnc_setBehaviour;" \n
       "" \n
       "_unitGroups = [];" \n
       "" \n
       "{" \n
       "	_type = typeName _x;" \n
       "	switch (_type) do" \n
       "	{" \n
       "		case ""GROUP"": { if (!(_x in _unitGroups)) then { _unitGroups = _unitGroups + [_x]; }; };" \n
       "		case ""OBJECT"": { if (!(group _x in _unitGroups)) then { _unitGroups = _unitGroups + [group _x]; }; };" \n
       "	};" \n
       "} forEach _spawnedUnits;" \n
       "" \n
       "_unitCount = count _unitGroups;" \n
       "" \n
       "_respawnTimeout = (time + _respawnTime);"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Do_the_checks">*/
        class Do_the_checks
        {
          priority = 0.000000;
          to="Calculate___Spawn";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Stop_vehicles_respawning">*/
    class Stop_vehicles_respawning
    {
      name = "Stop_vehicles_respawning";
      init = /*%FSM<STATEINIT""">*/"basesOwned = basesOwned - [_marker];" \n
       "" \n
       "//Respawn handles will kill themselves..." \n
       "" \n
       "{" \n
       "	if ((_x distance _pos) <= _radius && ({alive _x} count (crew _x)) < 1) then" \n
       "	{" \n
       "		_x setDamage 1;" \n
       "	};" \n
       "} forEach vehicles;" \n
       "" \n
       "_respawnID call BIS_fnc_removeRespawnPosition;" \n
       "" \n
       "//Remove base spawn points" \n
       "baseSpawns = baseSpawns - _spawns;" \n
       "" \n
       "[_attackers] spawn" \n
       "{" \n
       "	sleep 15;" \n
       "	(_this select 0) call AW_fnc_collectGarbage;" \n
       "	[] call AW_fnc_collectGarbage;" \n
       "};"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Base_taken">*/
        class Base_taken
        {
          priority = 0.000000;
          to="Spawn_defenders";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Base_being_captu">*/
    class Base_being_captu
    {
      name = "Base_being_captu";
      init = /*%FSM<STATEINIT""">*/"[[""base"", ""attacking""], _marker, _pos, _markerText] call AW_fnc_createJIPstateMarker;" \n
       "[[""type"", ""base_attacking""], [""message"", _markerText], [""global"", true]] call AW_fnc_showNotification;" \n
       "" \n
       "[_spawnedUnits, [[""active_defend"", _marker]]] call AW_fnc_setBehaviour;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Let_s_go_">*/
        class Let_s_go_
        {
          priority = 0.000000;
          to="Set_timeout___";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Calculate___Spawn">*/
    class Calculate___Spawn
    {
      name = "Calculate___Spawn";
      init = /*%FSM<STATEINIT""">*/"_timeout = (time + (5 + random(15)));"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Reinforcements_time">*/
        class Reinforcements_time
        {
          priority = 1.000000;
          to="Calculate___Spawn";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _respawnTimeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"_unitGroups = [];" \n
           "_unitsDefending = [];" \n
           "" \n
           "{" \n
           "	if (!isPlayer _x && alive _x && (_x distance _pos) <= _radius) then" \n
           "	{" \n
           "		_unitsDefending = _unitsDefending + [_x];" \n
           "	};" \n
           "} forEach allUnits;" \n
           "" \n
           "{" \n
           "	_type = typeName _x;" \n
           "	switch (_type) do" \n
           "	{" \n
           "		case ""GROUP"": { if (!(_x in _unitGroups)) then { _unitGroups = _unitGroups + [_x]; }; };" \n
           "		case ""OBJECT"": { if (!(group _x in _unitGroups)) then { _unitGroups = _unitGroups + [group _x]; }; };" \n
           "	};" \n
           "} forEach _unitsDefending;" \n
           "" \n
           "if ((count _unitGroups) < _unitCount) then" \n
           "{" \n
           "	_lacking = (_unitCount - count _unitGroups);" \n
           "	_toSpawn = if (_respawnGroups < _lacking) then { _respawnGroups } else { _lacking };" \n
           "" \n
           "	_respawnedUnits = [EAST, _toSpawn, _marker] call AW_fnc_spawnEnemy;" \n
           "	[_respawnedUnits, [[""patrol"", true, 100]]] call AW_fnc_setBehaviour;" \n
           "" \n
           "	_spawnedUnits = _spawnedUnits + _respawnedUnits;" \n
           "};" \n
           "" \n
           "_respawnTimeout = (time + _respawnTime);"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Do_the_checks">*/
        class Do_the_checks
        {
          priority = 0.000000;
          to="Check_1";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Base_Taken_">*/
    class Base_Taken_
    {
      name = "Base_Taken_";
      init = /*%FSM<STATEINIT""">*/"_isOwned = true;" \n
       "[[""type"", ""base_captured""], [""message"", _markerText], [""global"", true], [""hint"", [""Base"", _marker]]] call AW_fnc_showNotification;" \n
       "" \n
       "[_spawnedUnits, [[""retreat"", _pos, 1000]]] call AW_fnc_setBehaviour;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Base_taken">*/
        class Base_taken
        {
          priority = 0.000000;
          to="Add_Respawn_Location";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Set_time_before">*/
    class Set_time_before
    {
      name = "Set_time_before";
      init = /*%FSM<STATEINIT""">*/"_timeout = if (PARAMS_base_minTimeBeforeAttack > PARAMS_base_maxTimeBeforeAttack) then" \n
       "{" \n
       "	(time + PARAMS_base_maxTimeBeforeAttack + (random (PARAMS_base_minTimeBeforeAttack - PARAMS_base_maxTimeBeforeAttack)))" \n
       "} else {" \n
       "	(time + PARAMS_base_minTimeBeforeAttack + (random (PARAMS_base_maxTimeBeforeAttack - PARAMS_base_minTimeBeforeAttack)))" \n
       "};"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Wait_for_the_att">*/
        class Wait_for_the_att
        {
          priority = 1.000000;
          to="Attack_the_base";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout && (count basesOwned) >= PARAMS_base_basesOwnedBeforeAttacks"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Time_up_and_back">*/
        class Time_up_and_back
        {
          priority = 0.000000;
          to="Set_grace_period";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout && (count basesOwned) < 2"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Attack_the_base">*/
    class Attack_the_base
    {
      name = "Attack_the_base";
      init = /*%FSM<STATEINIT""">*/"_attackers = [EAST, round ((_groups / 2) + random _groups), _pos, [500, 1000]] call AW_fnc_spawnEnemy;" \n
       "[_attackers, [[""attack"", _pos]]] call AW_fnc_setBehaviour;" \n
       "" \n
       "[[""base"", ""under_attack""], _marker, _pos, _markerText] call AW_fnc_createJIPstateMarker;" \n
       "[[""type"", ""base_underattack""], [""message"", _markerText], [""global"", true]] call AW_fnc_showNotification;" \n
       "" \n
       "_timeout = time + (5 + random(15));"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Do_the_checks">*/
        class Do_the_checks
        {
          priority = 0.000000;
          to="Check";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Organise_tactical">*/
    class Organise_tactical
    {
      name = "Organise_tactical";
      init = /*%FSM<STATEINIT""">*/"[_attackers, [[""retreat"", _pos, 1000]]] call AW_fnc_setBehaviour;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Get_ready">*/
        class Get_ready
        {
          priority = 0.000000;
          to="Set_timeout____1";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Clean_up_attacke">*/
    class Clean_up_attacke
    {
      name = "Clean_up_attacke";
      init = /*%FSM<STATEINIT""">*/"_attackers call AW_fnc_collectGarbage;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Get_ready">*/
        class Get_ready
        {
          priority = 0.000000;
          to="Set_timeout";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Check">*/
    class Check
    {
      name = "Check";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Only_1_base_left">*/
        class Only_1_base_left
        {
          priority = 2.000000;
          to="Organise_tactical";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(count basesOwned) < 2"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"[[""type"", ""base_defended""], [""message"", _markerText], [""global"", true]] call AW_fnc_showNotification;" \n
           "[[""base"", ""friendly""], _marker, _pos, _markerText] call AW_fnc_createJIPstateMarker;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Enemies_defeated">*/
        class Enemies_defeated
        {
          priority = 2.000000;
          to="Set_time_before";
          precondition = /*%FSM<CONDPRECONDITION""">*/"private[""_enemiesDead""];" \n
           "" \n
           "_enemiesDead = true;" \n
           "{" \n
           "	if (typeName _x == ""GROUP"") then" \n
           "	{" \n
           "		{" \n
           "			if (alive _x) exitWith { _enemiesDead = false; };" \n
           "		} forEach (units _x);" \n
           "	};" \n
           "" \n
           "	if (!_enemiesDead) exitWith {};" \n
           "} forEach _attackers;"/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_enemiesDead"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"[[""base"", ""friendly""], _marker, _pos, _markerText] call AW_fnc_createJIPstateMarker;" \n
           "[[""type"", ""base_defended""], [""message"", _markerText], [""global"", true]] call AW_fnc_showNotification;" \n
           "_attackers call AW_fnc_collectGarbage;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "No_players_remai">*/
        class No_players_remai
        {
          priority = 1.000000;
          to="Stop_vehicles_respawning";
          precondition = /*%FSM<CONDPRECONDITION""">*/"_friendliesAbsent = true;" \n
           "_baseTaken = false;" \n
           "{" \n
           "	if (alive _x && [_area, _x, false] call BIS_fnc_inTrigger) exitWith { _friendliesAbsent = false; };" \n
           "} forEach playableUnits;" \n
           "" \n
           "if (_friendliesAbsent) then" \n
           "{" \n
           "	_tighterRad = (_radius / 2);" \n
           "	{" \n
           "		if (typeName _x == ""GROUP"") then" \n
           "		{" \n
           "			{" \n
           "				if (alive _x && [_area, _x, false] call BIS_fnc_inTrigger) exitWith { _baseTaken = true; };" \n
           "			} forEach (units _x);" \n
           "		};" \n
           "" \n
           "		if (_baseTaken) exitWith {};" \n
           "	} forEach _attackers;" \n
           "};"/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_baseTaken && (count basesOwned) > 1"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"[[""type"", ""base_lost""], [""message"", _markerText], [""global"", true]] call AW_fnc_showNotification;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Nothing_yet">*/
        class Nothing_yet
        {
          priority = 0.000000;
          to="Wait___";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Wait___">*/
    class Wait___
    {
      name = "Wait___";
      init = /*%FSM<STATEINIT""">*/"_timeout = (time + (5 + random(15)));"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Ready_to_check">*/
        class Ready_to_check
        {
          priority = 0.000000;
          to="Check";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Check_1">*/
    class Check_1
    {
      name = "Check_1";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Player_within_base">*/
        class Player_within_base
        {
          priority = 1.000000;
          to="Base_being_captu";
          precondition = /*%FSM<CONDPRECONDITION""">*/"_beingTaken = false;" \n
           "" \n
           "{" \n
           "	if ([_area, _x, false] call BIS_fnc_inTrigger) exitWith { _beingTaken = true; };" \n
           "} forEach playableUnits;"/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_beingTaken"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Nothing_yet">*/
        class Nothing_yet
        {
          priority = 0.000000;
          to="Calculate___Spawn";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Set_timeout___">*/
    class Set_timeout___
    {
      name = "Set_timeout___";
      init = /*%FSM<STATEINIT""">*/"_timeout = (time + (5 + random(15)));"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Do_the_checks">*/
        class Do_the_checks
        {
          priority = 0.000000;
          to="Check_2";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Check_2">*/
    class Check_2
    {
      name = "Check_2";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "No_enemies_left">*/
        class No_enemies_left
        {
          priority = 1.000000;
          to="Base_Taken_";
          precondition = /*%FSM<CONDPRECONDITION""">*/"_unitGroups = [];" \n
           "_unitsDefending = [];" \n
           "" \n
           "{" \n
           "	if (!isPlayer _x && alive _x && (_x distance _pos) <= _radius) then" \n
           "	{" \n
           "		_unitsDefending = _unitsDefending + [_x];" \n
           "	};" \n
           "} forEach allUnits;" \n
           "" \n
           "{" \n
           "	_type = typeName _x;" \n
           "	switch (_type) do" \n
           "	{" \n
           "		case ""GROUP"": { if (!(_x in _unitGroups)) then { _unitGroups = _unitGroups + [_x]; }; };" \n
           "		case ""OBJECT"": { if (!(group _x in _unitGroups)) then { _unitGroups = _unitGroups + [group _x]; }; };" \n
           "	};" \n
           "} forEach _unitsDefending;"/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(count _unitGroups) < 1"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Players_no_longer">*/
        class Players_no_longer
        {
          priority = 0.000000;
          to="Calculate___Spawn";
          precondition = /*%FSM<CONDPRECONDITION""">*/"_beingTaken = false;" \n
           "" \n
           "{" \n
           "	if ([_area, _x, false] call BIS_fnc_inTrigger) exitWith { _beingTaken = true; };" \n
           "} forEach playableUnits;"/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_beingTaken"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"[[""base"", ""enemy""], _marker, _pos, _markerText] call AW_fnc_createJIPstateMarker;" \n
           "" \n
           "[_spawnedUnits, [[""patrol"", _marker, 100]]] call AW_fnc_setBehaviour;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Set_timeout____1">*/
    class Set_timeout____1
    {
      name = "Set_timeout____1";
      init = /*%FSM<STATEINIT""">*/"_timeout = (time + (5 + random(15)));"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Do_the_checks">*/
        class Do_the_checks
        {
          priority = 0.000000;
          to="Check_3";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Check_3">*/
    class Check_3
    {
      name = "Check_3";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Ready_to_delete">*/
        class Ready_to_delete
        {
          priority = 1.000000;
          to="Clean_up_attacke";
          precondition = /*%FSM<CONDPRECONDITION""">*/"//Define distance needed before deletion" \n
           "_distance = 500;" \n
           "_farAway = true;" \n
           "" \n
           "{" \n
           "	if (!_farAway) exitWith {};" \n
           "	if (typeName _x == ""GROUP"") then" \n
           "	{" \n
           "		_leader = leader _x;" \n
           "		{" \n
           "			if ((_x distance _leader) < _distance) exitWith { _farAway = false; };" \n
           "		} forEach playableUnits;" \n
           "	};" \n
           "} forEach _attackers;"/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_farAway"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Not_ready_to_del">*/
        class Not_ready_to_del
        {
          priority = 0.000000;
          to="Set_timeout____1";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Set_timeout">*/
    class Set_timeout
    {
      name = "Set_timeout";
      init = /*%FSM<STATEINIT""">*/"_timeout = (time + (5 + random(15)));"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Do_the_checks">*/
        class Do_the_checks
        {
          priority = 0.000000;
          to="Check_4";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Check_4">*/
    class Check_4
    {
      name = "Check_4";
      init = /*%FSM<STATEINIT""">*/""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Wait_for_more_than">*/
        class Wait_for_more_than
        {
          priority = 1.000000;
          to="Set_time_before";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(count basesOwned) >= PARAMS_base_basesOwnedBeforeAttacks"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Not_more_than_1">*/
        class Not_more_than_1
        {
          priority = 0.000000;
          to="Set_timeout";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/""/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Set_grace_period">*/
    class Set_grace_period
    {
      name = "Set_grace_period";
      init = /*%FSM<STATEINIT""">*/"//Set timeout again and wait for >1 base to be present before planning another attack" \n
       "" \n
       "_timeout = time;" \n
       "//DEBUG - add grace period parameter to time"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Wait_for_grace_p">*/
        class Wait_for_grace_p
        {
          priority = 0.000000;
          to="Set_time_before";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(count basesOwned) > 1 && time >= _timeout"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
  };
  initState="Initialise_Base";
  finalStates[] =
  {
  };
};
/*%FSM</COMPILE>*/