Index
Tutorials

AI Orbital

Description

This is a companion cpack to Autopilot AI - allowing a limited use of the Orbital rockets. This has 2 modes: it will use Rain on the deepest creeper, and also - less often, will target the deepest creeper to hit with Singularity, and fire Conversion just as it's finished. The AI will need to have the Rocket factory built and working, or an alternative means of incrementing the orbital count.

# --AIOrbital-- 3/31/2021 3:30:25 PM
#Damper 1 - not implemented
#Singularity 1 -  ~900 update counts
#Rain 2 - ~900 update counts
#Conversion 5 - instant
 
#The following need to be at least 1500 otherwise they'll cause multiple rains and orbitals to fire at the same location at the same time
#Defaults are 4000 rain, 6000 orbital
$raincooldown:4000 
$orbitalbombcooldown:6000
 
$$ignoreunits:"605a5a9f-03b7-430c-bcea-31c4d7067324"
 
:FindBestTarget
#First, find all ignoreunits
GetUnitsByType(<-ignoreunits 0) ->ignoreunitslist
if(GetListCount(<-ignoreunitslist)  gt0)
           do (GetListCount(<-ignoreunitslist) 0)
trace2(GetUnitCell(<-ignoreunitslist[I]))
                      ApplyToDamageMap(<-ignoreunitslist[I] GetUnitCell(<-ignoreunitslist[I] ) 3 500 false)
           loop
endif
GetMaxCreeperCellWithDamage  ->*orbitalZ ->*orbitalX
if(GetListCount(<-ignoreunitslist)  gt0)
           do (GetListCount(<-ignoreunitslist) 0)
                      ApplyToDamageMap(<-ignoreunitslist[I] GetUnitCell(<-ignoreunitslist[I] ) 3 -500 false)
           loop
endif
ClearList(<-ignoreunitslist)
 
:Frame
GetOrbitalCount <-*orbitals + ->*orbitals
SetOrbitalCount(0)
#trace(<-*orbitals)
 
#Singularity plus Conversion
if ((<-*orbitals gt (6))  and (<-*orbitalbomb eq0) and (<-*rainstorm neq (1))) #Fire Singularity
           @FindBestTarget
           CreateUnitOnTerrain("singularity" <-*orbitalX <-*orbitalZ 0)
           <-*orbitals 1 - ->*orbitals
           1 ->*orbitalbomb
            GetGameUpdateCount ->*orbitalbombcount
#trace("singularity fired")
endif
if((<-*orbitalbomb eq (1)) and (GetGameUpdateCount gt(<-*orbitalbombcount 900 +))) #Singularity finished, fire Conversion
           CreateUnitOnTerrain("conversion" <-*orbitalX <-*orbitalZ 0)
           <-*orbitals 5 - ->*orbitals
           2 ->*orbitalbomb
#trace("singularity done, now conversion")
endif
if((<-*orbitalbomb eq (2)) and (GetGameUpdateCount gt(<-*orbitalbombcount 1200 +)))
           3 ->*orbitalbomb
#trace("rain can fire")
endif
if((<-*orbitalbomb eq (3)) and (GetGameUpdateCount gt(<-*orbitalbombcount <-orbitalbombcooldown +))) #give Rain a chance to fire after this
           0 ->*orbitalbomb
#trace("conversion off cooldown")
endif
 
#Rain
if ((<-*orbitals gt (2))  and (<-*orbitalbomb neq (1)) and (<-*orbitalbomb neq (2)) and (<-*rainstorm eq0)) 
#If we're not in the middle of, or recovering from a Conversion Bomb
           @FindBestTarget
           CreateUnitOnTerrain("rain" <-*orbitalX <-*orbitalZ 0)
           <-*orbitals 2 - ->*orbitals
           1 ->*rainstorm
            GetGameUpdateCount ->*rainstormcount
#trace("rain fired")
endif
if((<-*rainstorm eq (1)) and (GetGameUpdateCount gt(<-*rainstormcount 1200 +))) #Rain has finished
           2 ->*rainstorm
#trace("singularity can fire")
endif
if((<-*rainstorm eq (2)) and (GetGameUpdateCount gt(<-*rainstormcount <-raincooldown +))) #Cooldown time
           0 ->*rainstorm
#trace("rain off cooldown")
endif
 
:Once
RegisterForMSG("MSG_FrameAdvance" "Frame")
0 ->*orbitalX
0 ->*orbitalZ
0 ->*orbitals
0 ->*orbitalbomb
0 ->*rainstorm