'== included in the AI scripts file =='

'can go through gates
s.controller.vars.init("gateworthy", 1)

'always on p1's side
s.faction = 1

'add a caution effect
If s.controller.vars.get("caution") = 0 Then s.controller.vars.set("caution", 1)

'slightly randomize the range of the tractor beam to spread them out a little
If s.controller.vars.get("init") = 0
	For Local g:GunBeam = EachIn s.gunGroup[0]
		g.shotrange:+ (g.shotrange * (Rnd() - .5))/2
		s.controller.vars.set("signature", Abs(g.shotdamage))
	Next
	s.controller.vars.set("init", 1)
EndIf

Local towRange# = rangeGroup(s, 0)

If s.controller.target = Null
	'slow down
	If s.speed > 5 Then s.speed = s.speed - 5 Else s.speed = 0

	'look for savior
	If s.controller.hasTimerTicked("targetCheck", 1000)		  '1 = friendly
		'make a list of things to ignore, AKA self
		Local ignoreList:TList = New TList
		ignoreList.addLast(s)
		
		'find a friendly (non-other cryopod) tower
		Repeat
			s.controller.target = closestShip(s.x, s.y, s.faction, 1, towRange, ignoreList)
			If s.controller.target <> Null Then ignoreList.addLast(s.controller.target)
		Until s.controller.target = Null Or s.controller.target.behavior = "player"
		' Or (s.controller.target.behavior <> "cryopod" And Not s.controller.target.ord)'(not other cryopods or ordinance)
	EndIf

Else
	'are we still in range of them?
	Local dist# = approxDist(s.x-s.controller.target.x,s.y-s.controller.target.y)
	
	If dist <= towRange
		'tractor beam to them
		AI.fireWeapons(s, 0, s.controller.target.x, s.controller.target.y)
	Else
		s.controller.target = Null
	EndIf
	
EndIf

'we don't have any thrusters so this doesn't do anything besides trick the gate into letting us through
's.afterburn = 1
	
	
	

