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

'default to chasing the target
s.controller.vars.init("chase", 1)

'start out happy with where we are
If s.controller.goalx = 0 Then s.controller.goalx = s.x
If s.controller.goaly = 0 Then s.controller.goaly = s.y

'try to avoid collisions: sets gox & goy to point away from nearby ss
AI.setProximityAvoid(s)

Local weaponrange = rangeGroup(s, 0) - 25

s.controller.vars.init("holdrad", Rand(250, 350))
Local circledist = Min(weaponrange, s.controller.vars.get("holdrad"))
s.controller.vars.set("holdrad", circledist)

'fly in circles around the goal
AI.holdingPattern(s)

'look for a s.target
AI.getTarget(s, 3000)

If target = Null
	AI.face(s, "go")	
Else
	'set goal to target
	circledist = 1
	AI.setGoalTo(s, "target")
	
	'face the target & go in the direction we decided	
	'AI.face(s, "goal")
	
	'find dist to target
	Local dist# = approxDist(target.x-s.x, target.y-s.y)
	
	'shield self if we're far away
	If dist > weaponrange + 125 Then s.addDamageBuffer(12)
	
	'fire weapons if close
	If dist < weaponrange + 100
		AI.fireAIWeapons(s, 0)'fire at predicted target coords
		AI.face(s, "goal", 55)
	Else
		AI.face(s, "goal", 85)
	EndIf
	
EndIf

AI.go(s, 1)

