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

boss = 0

function spawnItem(me)
	debugLog("Spawning collectible dumbo egg")
	node = getNodeByName("DUMBOEGGLOC")
	if node == 0 then
		debugLog("COULD NOT FIND NODE!")
	end
	createEntity("CollectibleDumboEgg", "", node_x(node), node_y(node))
end

function init(me)
	debugLog("INITTTT")
	if isFlag(FLAG_MINIBOSS_OCTOMUN, 0) then
		boss = getEntity("Octomun")
	else
		ent = getEntity("Octomun")
		entity_delete(ent)
		spawnItem(me)
	end
end

function update(me, dt)
	if boss ~= 0 then
		if entity_isState(boss, STATE_DEAD) then
			setFlag(FLAG_MINIBOSS_OCTOMUN, 1)
			spawnItem(me)
			boss = 0
		end
	end
end
