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

If s.spin = 0 Then s.spin = binsgn(Rand(0,1)) * Rand(1,3) / 3

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

Local explode = False
Local followdist = 350'will look for and follow targets within this range
Local throttle# = .1

'try to avoid collisions: sets gox & goy to point away from nearby ss
'Local ignoreList:TList = New TList
ClearList(s.controller.ignoreProxList)

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

'go towards the target
If target <> Null
	s.controller.ignoreProxList.addLast(target)'don't worry about running into them

	AI.setGoalTo(s, "target")
	Local dx = (s.controller.goalx - s.x)
	Local dy = (s.controller.goaly - s.y)

	'set the movement coords to the target
	s.controller.gox:+ dx*.1
	s.controller.goy:+ dy*.1
	
	'set throttle based on proximity
	throttle = Min(1 - (approxDist(dx, dy) / followdist), 1)
EndIf

AI.setProximityAvoid(s, 70)

If s.controller.gox <> 0 Or s.controller.goy <> 0
	AI.go(s, throttle)
Else
	'slow down
	If s.speed > 1 Then s.speed = s.speed - 2.5*timeMod Else s.speed = 0
EndIf

's.controller.vars.init("shielded", 1)
'If s.controller.vars.get("shielded") >= 1 Then s.addDamageBuffer(7)

'(as ordinance, will explode if it collides with the target)