function init()
	gun.name = "Crazy Ivan"
	gun.fireDelay = 1000
	gun.shotrange = 850
	gun.shotspeed = 700
	gun.shotdamage = 1.5
	gun.shotknockback = 8500
	
	gun.burstDelay = 10
	gun.burstNum = 3
	gun.burstDelay = 150
	
	--gun.firecost = 3
	
	gun.enabledoppler = 1--so the arcs don't get messed up
	
	return 0
end


function update()
	return 0
end


function fire()
	--make two shots going out at 45d angles
	for i = 0, 4 do
		gun.addShot("shot4.png", gun.firex, gun.firey, gun.firetheta)
		shot.skipLuaUpdate = 0
		--shot.scale = 1.5
		shot.vars.set("theta", math.random(0,359))
		shot.vars.set("crazymax", math.random(-10,10))
		
		--attach a trail emitter to the shot
		stage.createEmitter("trail", 0, 0)
		e.interval = 10
		e.scale = .8
		e.lifetimer = 250
		e.alpha = .7
		e.setRGB(255,80,0)
		--e.scale = .5
		e.attach(shot)
		e.upload()
	end
	
	--kick the owner back
	gun.owner.add_force(gun.firetheta + 180, 150)--pretty fancy/convoluted tech here, just FYI.
	
	stage.sfx("gun_pew1.wav", gun.firex, gun.firey)

	return 0
end

function shot_update()

	--alter move direction back and forth as lifetimer decays
	--dtheta = math.rad(math.mod((shot.lifetimer / 1000) * 180, 360) + shot.vars.get("thetaoffset"))
	--shot.movrot = shot.movrot - math.sin(dtheta) * 2
	
	--not gonna lie, i don't understand at ALL how this results in the completely chaotic movement of the shots.
	--that's appropriate i feel
	crazymod = (shot.lifetimer / shot.lifetimerMax) * shot.vars.get("crazymax")
	theta = shot.vars.get("theta")
	shot.vars.set("theta", theta + crazymod * .05)
	shot.movrot = shot.movrot - math.sin(math.deg(theta)) * 7-- * crazymod
	shot.speed = shot.speed + crazymod

	return 0
end