dofile("scripts/entities/entityinclude.lua")

nauty = 0

function spawnEgg(me)
	node = getNodeByName("COLLECTIBLENAUTILUSPRIMELOCATION")
	createEntity("CollectibleNautilusPrime", "", node_x(node), node_y(node))
end

function init(me)
	if isFlag(FLAG_MINIBOSS_NAUTILUSPRIME, 0) then
		nauty = createEntity("NautilusPrime", "", node_x(me), node_y(me))
	else
		spawnEgg(me)
	end
end

function update(me, dt)
	if nauty ~= 0 then
		if entity_isState(nauty, STATE_DEAD) then
			setFlag(FLAG_MINIBOSS_NAUTILUSPRIME, 1)
			spawnEgg(me)
			nauty = 0
		end
	end
end
