--Respawning Practice Targets at Tbilisi
PracticeT55 = SPAWN:New("PracticeT55"):InitLimit(10,500):SpawnScheduled(10,0)
PracticeATZ = SPAWN:New("PracticeATZ"):InitLimit(10,500):SpawnScheduled(10,0)
PracticeBMP = SPAWN:New("PracticeBMP"):InitLimit(10,500):SpawnScheduled(10,0)
PracticeT55_2 = SPAWN:New("PracticeT55_2"):InitLimit(14,500):SpawnScheduled(10,0)
PracticeT55_3 = SPAWN:New("PracticeT55_3"):InitLimit(10,500):SpawnScheduled(10,0)
PracticeZU23 = SPAWN:New("PracticeZU23"):InitLimit(10,500):SpawnScheduled(10,0)
Red_target_1 = SPAWN:New("Red target 1"):InitLimit(2,1000):SpawnScheduled(120,0):InitCleanUp(60):InitRepeatOnLanding()
Red_Target_2 = SPAWN:New("Red Target 2"):InitLimit(1,1000):SpawnScheduled(600,0):InitCleanUp(60):InitRepeatOnLanding()

--Respawning Tankers
Navy_Kanteen = SPAWN:New("Navy Kanteen"):InitLimit(1,500):SpawnScheduled(5,0):InitRepeatOnLanding():InitCleanUp(60)
Kanteen = SPAWN:New("Kanteen"):InitLimit(1,500):SpawnScheduled(5,0):InitRepeatOnLanding():InitCleanUp(60)
Floating_Canteen = SPAWN:New("Floating Canteen"):InitLimit(1,500):SpawnScheduled(5,0):InitRepeatOnLanding():InitCleanUp(60)
Sky_Eye = SPAWN:New("Sky Eye"):InitLimit(1,500):SpawnScheduled(5,0):InitRepeatOnLanding():InitCleanUp(60)

--Respawning Blue Defense Planes
Spooky = SPAWN:New("Spooky"):InitLimit(4,500):SpawnScheduled(60,0):InitRepeatOnLanding():InitCleanUp(60)

--Respawning Blue Offensive Planes
Freedom_Eagles = SPAWN:New("Freedom Eagles"):InitLimit(4,500):SpawnScheduled(1200,0):InitRepeatOnLanding()
Self_Defense_Kats = SPAWN:New("Self defense Kats"):InitLimit(4,500):SpawnScheduled(900,0):InitRepeatOnLanding():InitCleanUp(60)
Spotting_Yak = SPAWN:New("Spotting Yak"):InitLimit(1,500):SpawnScheduled(120,0):InitRepeatOnLanding():InitCleanUp(60)
Spotting_Yak_2 = SPAWN:New("Spotting Yak 2"):InitLimit(1,500):SpawnScheduled(60,0):InitRepeatOnLanding():InitCleanUp(60)
Spooky_2 = SPAWN:New("Spooky 2"):InitLimit(4,500):SpawnScheduled(600,0):InitRepeatOnLanding():InitCleanUp(60)
Spookys = SPAWN:New("Spookys"):InitLimit(2,500):SpawnScheduled(600,0):InitRepeatOnLanding():InitCleanUp(60)

--Respawning Blue AA Defenses
Gudauta_AA_1 = SPAWN:New("Gudauta AA 1"):InitLimit(5,500):SpawnScheduled(5,0)
Gudauta_AA_2 = SPAWN:New("Gudauta AA 2"):InitLimit(5,500):SpawnScheduled(5,0)
Adler_AA_1 = SPAWN:New("Adler AA 1"):InitLimit(5,500):SpawnScheduled(5,0)
Adler_AA_2 = SPAWN:New("Adler AA 2"):InitLimit(27,500):SpawnScheduled(5,0)
FARP_AA_1 = SPAWN:New("FARP AA 1"):InitLimit(5,500):SpawnScheduled(5,0)
FARP_AA_2 = SPAWN:New("FARP AA 2"):InitLimit(5,500):SpawnScheduled(5,0)

--Respawning Blue Ground Forces
FARP_Ground_Force = SPAWN:New("FARP Ground Force"):InitLimit(10,500):SpawnScheduled(5,0)


--Respawning Red Planes
Red_Water_Defenders = SPAWN:New("Red Water Defenders"):InitLimit(4,500):SpawnScheduled(2400,0):InitCleanUp(60):InitRepeatOnLanding()
Red_SU27 = SPAWN:New("Red SU-27"):InitLimit(4,500):SpawnScheduled(1200,0):InitCleanUp(60):InitRepeatOnLanding()
Red_Mig21 = SPAWN:New("Red Mig 21"):InitLimit(4,500):SpawnScheduled(1000,0):InitCleanUp(60):InitRepeatOnLanding()
Red_KA50 = SPAWN:New("Red KA-50"):InitLimit(4,500):SpawnScheduled(300,0):InitCleanUp(60):InitRepeatOnLanding()
Red_SU33 = SPAWN:New("Red Su-33"):InitLimit(4,500):SpawnScheduled(2400,0):InitCleanUp(60):InitRepeatOnLanding()
Okanieba = SPAWN:New("okanieba"):InitLimit(1,500):SpawnScheduled(600,0):InitCleanUp(60):InitRepeatOnLanding()
Red_Mig29 = SPAWN:New("Red Mig-29"):InitLimit(4,500):SpawnScheduled(18000,0):InitCleanUp(60):InitRepeatOnLanding()
Red_Mig31 = SPAWN:New("Red Mig-31"):InitLimit(4,500):SpawnScheduled(6000,0):InitCleanUp(60):InitRepeatOnLanding()
Red_Mig23 = SPAWN:New("Red Mig-23"):InitLimit(4,500):SpawnScheduled(900,0):InitCleanUp(60):InitRepeatOnLanding()
Red_Mig19 = SPAWN:New("Red Mig-19"):InitLimit(4,500):SpawnScheduled(600,0):InitCleanUp(60):InitRepeatOnLanding()
Su25_harassers = SPAWN:New("Su25 harassers"):InitLimit(4,500):SpawnScheduled(1800,0):InitCleanUp(60):InitRepeatOnLanding()


--Respawning Red Ground Forces
Bridge_Defense_1 = SPAWN:New("Bridge defense 1"):InitLimit(10,500):SpawnScheduled(7200,0)
Tupase_Ship_1 = SPAWN:New("tupase attack ship 1"):InitLimit(1,500):SpawnScheduled(21600,0)
Tupase_Ship_2 = SPAWN:New("tupase attack ship 2"):InitLimit(1,500):SpawnScheduled(21600,0)
Tupase_Ship_3 = SPAWN:New("tupase attack ship 3"):InitLimit(1,500):SpawnScheduled(21600,0)
Tupase_SA_15 = SPAWN:New("Tupase SA 15"):InitLimit(10,500):SpawnScheduled(7200,0)
Tupase_ZU23 = SPAWN:New("Tupase ZU"):InitLimit(10,500):SpawnScheduled(600,0)
Tupase_INF = SPAWN:New("Tupase Infantry"):InitLimit(42,500):SpawnScheduled(600,0)
Tupase_RPG = SPAWN:New("Tupase RPG"):InitLimit(24,500):SpawnScheduled(600,0)
Tupase_Patrol = SPAWN:New("Tupase Patrol"):InitLimit(5,500):SpawnScheduled(1200,0)
Maykop_SA8 = SPAWN:New("Maykop SA8"):InitLimit(5,500):SpawnScheduled(14400,0)
Maykop_ZU23 = SPAWN:New("Maykop ZU23"):InitLimit(15,500):SpawnScheduled(600,0)
Maykop_BTR = SPAWN:New("Maykop BTR"):InitLimit(2,500):SpawnScheduled(600,0)
Novor_Convoy = SPAWN:New("Novor Convoy"):InitLimit(10,500):SpawnScheduled(300,0)
Novor_ZU23 = SPAWN:New("Novor ZU23"):InitLimit(18,500):SpawnScheduled(600,0)
Novor_SA15 = SPAWN:New("Novor SA15"):InitLimit(5,500):SpawnScheduled(1200,0)
Novor_Fleet_1 = SPAWN:New("Novor Fleet 1"):InitLimit(8,500):SpawnScheduled(7200,0)
Novor_Fleet_2 = SPAWN:New("Novor Fleet 2"):InitLimit(10,500):SpawnScheduled(7200,0)
Novor_Cargo_Ship = SPAWN:New("Novor Cargo Ship"):InitLimit(1,500):SpawnScheduled(300,0)
Novor_Sub = SPAWN:New("Novor Sub"):InitLimit(1,500):SpawnScheduled(14400,0)
Novor_Cargo_Ship_2 = SPAWN:New("Novor Cargo Ship 2"):InitLimit(1,500):SpawnScheduled(300,0)

--Sochi Ground Combat Forces Spawning
Adler_Ground_Force_1 = SPAWN:New("Adler Ground Force 1"):InitLimit(15,500):SpawnScheduled(600,0)
Adler_Ground_Force_2 = SPAWN:New("Adler Ground Force 2"):InitLimit(15,500):SpawnScheduled(600,0): SpawnScheduleStop()
Red_Sochi_Attacker_North = SPAWN:New("Red Sochi North Attackers"):InitLimit(21,500):SpawnScheduled(600,0):SpawnScheduleStop()
Red_Sochi_Attacker_South = SPAWN:New("Red Sochi South Attackers"):InitLimit(18,500):SpawnScheduled(600,0):SpawnScheduleStop()


--Setting up Captureable Zones
US_CC = COMMANDCENTER:New( GROUP:FindByName( "BLUEHQ" ), "USA HQ" )

SochiZoneN = ZONE:New("Sochi North")
SochiZoneS = ZONE:New("Sochi South")

SochiZoneNorth = ZONE_CAPTURE_COALITION:New(SochiZoneN,coalition.side.RED,Unit.Category.GROUND_UNIT)
SochiZoneNorth:__Guard(1)
SochiZoneNorth:Smoke( SMOKECOLOR.Red )
SochiZoneNorth:Start(1,10)

SochiZoneSouth = ZONE_CAPTURE_COALITION:New(SochiZoneS,coalition.side.RED,Unit.Category.GROUND_UNIT)
SochiZoneSouth:__Guard(1)
SochiZoneSouth:Smoke( SMOKECOLOR.Red )
SochiZoneSouth:Start(1,10)


--Capture Zone Events

--- @param Functional.SochiZoneNorth#ZONE_CAPTURE_COALITION self
function SochiZoneNorth:OnEnterCaptured( From, Event, To )
  if From ~= To then
    local Coalition = self:GetCoalition()
    self:E( { Coalition = Coalition } )
    if Coalition == coalition.side.BLUE then
      SochiZoneNorth:Smoke( SMOKECOLOR.Blue )
      US_CC:MessageTypeToCoalition( string.format( "%s is under protection of the USA! Red groundforces inbound from the North-West!", ZoneCaptureCoalition:GetZoneName() ), MESSAGE.Type.Information )
	  Red_Sochi_Attacker_North:SpawnScheduleStart()
	  Red_Sochi_Attacker_South:SpawnScheduleStop()
	  Adler_Ground_Force_2:SpawnScheduleStop()
    else
      SochiZoneNorth:Smoke( SMOKECOLOR.Red )
      US_CC:MessageTypeToCoalition( string.format( "%s is under protection of Russia! Provide CAS for our groundforces attempting to capture it!", ZoneCaptureCoalition:GetZoneName() ), MESSAGE.Type.Information )
	  Red_Sochi_Attacker_North:SpawnScheduleStop()
	  Adler_Ground_Force_2:SpawnScheduleStart()
    end
  end
end

--- @param Functional.SochiZoneSouth#ZONE_CAPTURE_COALITION self
function SochiZoneSouth:OnEnterCaptured( From, Event, To )
  if From ~= To then
    local Coalition = self:GetCoalition()
    self:E( { Coalition = Coalition } )
    if Coalition == coalition.side.BLUE then
      SochiZoneSouth:Smoke( SMOKECOLOR.Blue )
      US_CC:MessageTypeToCoalition( string.format( "%s is under protection of the USA! Red groundforces inbound from the North!", ZoneCaptureCoalition:GetZoneName() ), MESSAGE.Type.Information )
	  Red_Sochi_Attacker_South:SpawnScheduleStart()
	  Adler_Ground_Force_1:SpawnScheduleStop()
	  Adler_Ground_Force_2:SpawnScheduleStart()
    else
      SochiZoneSouth:Smoke( SMOKECOLOR.Red )
      US_CC:MessageTypeToCoalition( string.format( "%s is under protection of Russia! Provide CAS for our groundforces sttempting to capture it!", ZoneCaptureCoalition:GetZoneName() ), MESSAGE.Type.Information )
	  Red_Sochi_Attacker_South:SpawnScheduleStop()
	  Adler_Ground_Force_1:SpawnScheduleStart()
	  Adler_Ground_Force_2:SpawnScheduleStop()
    end
  end
end


