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

'move away from the edges
If Abs(s.x) > 1200 Then s.controller.gox = -50 * Sgn(s.x)
If Abs(s.y) > 1200 Then s.controller.goy = -50 * Sgn(s.y)
If s.controller.gox <> 0 Or s.controller.goy <> 0
	AI.go(s)
Else
	'slow down
	If s.speed > 5 Then s.speed = s.speed - 5*timeMod Else s.speed = 0
EndIf

If s.controller.vars.get("init") = 0
	'slightly randomize the power of the drone's beam to give it a unique signature
	For Local g:GunBeam = EachIn s.gunGroup[1]
		g.shotdamage:- Rnd()
		s.controller.vars.set("signature", Abs(g.shotdamage))
	Next
	
	'make the bomb available from the get-go
	'For Local g:Gun = EachIn s.gunGroup[1]
	'	timerDing(g.timerList, "fireDelay")
	'Next

	s.controller.vars.set("init", 1)
EndIf

'look for the dodongo boss as a target
If target = Null
	If timerTick(s.controller.timerList, "bosssearch", 1000)
		For Local tar:Ship = EachIn shipList
			If tar.behavior = "boss_dodongo"
				s.controller.target = tar.placeholder
				Exit
			EndIf
		Next
		
		'if can't find one, explode
		If target = Null
			vars.set("allalone", vars.get("allalone") + 1)
			Print "can't find bossman"
			If vars.get("allalone") > 5 Then s.armour = 0
		EndIf
	EndIf
Else
	fireShipWeapons(s, 1, target.x, target.y)'fire REPAIR BEAM at the boss
EndIf

'fire bombs out randomly
AI.fireAIWeapons(s, 0, s.x+Rand(-200,200), s.y+Rand(-200,200))

'spin to show bomb status
For Local g:Gun = EachIn s.gunGroup[0]
	Local targetspin = (1-timerTween(g.timerList, "fireDelay")) * 10
	s.spin:+ (targetspin-s.spin)*.1
	'Print g.name + " set spin to " + s.spin + "    "  +timerTime(g.timerList, "fireDelay")
Next


'can't be hurt, either (except by bombs!)
s.addDamageBuffer(29)
