function init()
	gun.name = "Photon_Arc"
	gun.fireDelay = 2400
	gun.shotrange = 800
	gun.shotspeed = 350--overridden
	gun.shotdamage = 3
	gun.shotknockback = 9000
	gun.burstDelay = 500
	
	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
		--make two shots going out at 90d angles
		for i = 0, 1 do
			gun.addShot("shot4.png", gun.firex, gun.firey, gun.firetheta - 90 + 180*i)
			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()
		end
		
		stage.GFP("firing arc")
			
		gun.sfx("gun_photon.wav", gun.firex, gun.firey)
	end

	return 0
end

function shot_update()
	shot.speed = 350

	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 * .03)
	end

	return 0
end