function init()
	gun.name = "Photon"
	gun.fireDelay = 2400
	gun.shotrange = 800
	gun.shotspeed = 200--overridden
	gun.shotdamage = 5
	gun.shotknockback = 9000
	gun.burstDelay = 500
	
	gun.fixed = 4--forward
	
	return 0
end


function update()
	return 0
end


function fire()
	--get a target
	gun.target = stage.getClosestShip(gun.firex, gun.firey, gun.owner.faction, -1, 800)

	--fire a homing shot at that target
	if gun.hasTarget() == 1 then
		gun.addShot("shot4.png", gun.firex, gun.firey, gun.firetheta)
		shot.speed = shot.speed + math.random(0, 100)
		shot.target = gun.target
		shot.skipLuaUpdate = 0
		shot.scale = 1.5

		--attach a trail emitter to the shot
		stage.createEmitter("shottrail", 0, 0)
		e.scale = .5
		e.attach(shot)
		e.upload()

		gun.sfx("gun_photon.wav", gun.firex, gun.firey)
	end

	return 0
end

function shot_update()
	shot.speed = 260

	if shot.hasTarget() == 1 and shot.target.cloaked == 0 then
		--angle self towards the target
		--shot.movrot = math.deg(math.atan2(shot.target.y - shot.y, shot.target.x - shot.x))
		theta = math.deg(math.atan2(shot.target.y - shot.y, shot.target.x - shot.x))
		facing = shot.movrot
		
		--figure out the direction we need to go; convert the two absolute angles to a relative one
		if theta < 180 then theta = theta + 360 end
		if facing < 180 then facing = facing + 360 end
		dir = theta - facing
		if dir > 180 then dir = dir - 360 end
		if dir < -180 then dir = dir + 360 end
		
		--turn towards the target
		shot.movrot = shot.movrot + (dir * (shot.speed / 4000))
	end

	return 0
end