-- ================================================================================================
-- MENGRIL
-- ================================================================================================

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

running = false

function init(me)
	setupConversationEntity(me, "Mengil")
	entity_initSkeletal(me, "merman", "mengil")
	entity_animate(me, "idle", LOOP_INF)
	entity_scale(me, 0.6, 0.6)
	entity_setActivation(me, AT_CLICK, 80, 256)
	entity_setAffectedBySpells(me, 0)
	if isMapName("TransitPort") then
		entity_animate(me, "sitting", LOOP_INF)
	end

end

function update(me, dt)
	if getStory() < 15 and not running then
		running = true
		naija = getEntity("Naija")
		mengrilNode = getNode("GATE")
		if entity_x(naija) > node_x(mengrilNode) then
			-- the line must be drawn HERE!
			wnd(1)
			txt("Mengril: THOUH SHALT NOT PASS!")
			wnd(0)
			entity_swimToNode(naija, getNode("NAIJABACKOFF"))
			entity_watchForPath(naija)			
		end
		running = false
	end
end

function enterState(me)
end

function exitState(me)
end

function activate(me)
	if getStory() <15 then
		wnd(1)
		txt("Mengril: What? You expect me to have dialogue for the section of the game wherein you're not allowed to leave MainArea?")
		txt("Mengril: Puppy Cocks!")
		wnd(0)
	end
end

function hitSurface(me)
end
