function OnWarpEnter()
	PlaySound("Sounds/SFX/A_Wind2.ogg",-1)	
	SetMarker("Pi Ramses\\Temple U\\Warp_0046.wp",0,0)
	spell="none"

	if Khaem_on_Countryyard then
		----------------------------------------------------
		if not SAVE_04 then
			-- SAVE
			SAVE_04 = true
			SaveGame("4.xml")
		end
		-----------------------------------------------------
		SetMarker("KHU1",4,0)
		StartAnimationPart("KHU1",70,100,-1,true) 
	end
end

function AskSeparation()
	PushAnswer("MAIA1366") --cobra hypnosis
	PushAnswer("MAIA1367") --magical net
	PushAnswer("MAIA1368") --transoformation spell
	PushAnswer("MAIA1369") --suspend training
end

function OnAnswered(textid)
	if textid=="MAIA1366" then
		DrawText("MAIA1366","MAIA1366.ogg")
	elseif textid=="MAIA1367" then
		DrawText("MAIA1367","MAIA1367.ogg")
	elseif textid=="MAIA1368" then
		DrawText("MAIA1368","MAIA1368.ogg")
	elseif textid=="MAIA1369" then
		SetMarker("KHU1",4,0)
	end
end

function OnAnimationFinished(objectName)
	if objectName=="KHU1" then
		if spell=="cobraHypnosisOk" then
			StartAnimationPart("KHU1",130,140,-1,true)
			DrawText("KHAE1373","KHAE1373.ogg")
			DrawText("KHAE1370","KHAE1370.ogg")
		elseif spell=="cobraHypnosisWrong" then
			StartAnimationPart("KHU1",130,140,-1,true)
			DrawText("KHAE1371","KHAE1371.ogg")
			DrawText("KHAE1375","KHAE1375.ogg")
			DrawText("KHAE1370","KHAE1370.ogg")
		elseif spell=="magicalNetOK" then
			StartAnimationPart("KHU1",130,140,-1,true)
			DrawText("KHAE1379","KHAE1379.ogg")
			DrawText("KHAE1370","KHAE1370.ogg")
		elseif spell=="magicalNetWrong" then
			StartAnimationPart("KHU1",130,140,-1,true)
			DrawText("KHAE1371","KHAE1371.ogg")
			DrawText("KHAE1381","KHAE1381.ogg")
			DrawText("KHAE1370","KHAE1370.ogg")
		elseif spell=="lotoTransformationOk" then
			StartAnimationPart("KHU1",130,140,-1,true)
			DrawText("KHAE1384","KHAE1384.ogg")
			DrawText("KHAE1370","KHAE1370.ogg")
		elseif spell=="lotoTransformationWrong" then
			StartAnimationPart("KHU1",130,140,-1,true)
			DrawText("KHAE1371","KHAE1371.ogg")
			DrawText("KHAE1385","KHAE1385.ogg")
			DrawText("KHAE1370","KHAE1370.ogg")
		else
			SetMarker("KHU1",4,0)
			StartAnimationPart("KHU1",70,100,-1,true)
		end
	end
end

function OnDialogFinished(dialogName)
	if dialogName=="KHAE1355" then
			MAYA_BETRAYED = true
			AddToBag("Pluie")
			DrawText("MAIA1356","MAIA1356.ogg")
			DrawText("KHAE1357","KHAE1357.ogg")
			DrawText("MAIA1358","MAIA1358.ogg")
			DrawText("KHAE1359","KHAE1359.ogg")
			DrawText("MAIA1360","MAIA1360.ogg")
			DrawText("KHAE1361","KHAE1361.ogg")
			DrawText("KHAE1362","KHAE1362.ogg")
			DrawText("KHAE1363","KHAE1363.ogg")
	end
	if dialogName=="KHAE1363" then
		StartAnimationPart("KHU1",70,120,-1,true)
		AskSeparation()
	elseif dialogName=="KHAE1370" then
		StartAnimationPart("KHU1",70,100,-1,true)
		AskSeparation()
	elseif dialogName=="MAIA1366" then
		DrawText("KHAE1372","KHAE1372.ogg")
		spell ="cobraHypnosis"
		StartAnimationPart("KHU1",140,215,1,true)
	elseif dialogName=="MAIA1367" then
		DrawText("KHAE1376","KHAE1376.ogg")
		spell ="magicalNet"
		StartAnimationPart("KHU1",215,250,1,true)
	elseif dialogName=="MAIA1368" then
		DrawText("KHAE1382","KHAE1382.ogg")
		spell ="lotoTransformation"
		StartAnimationPart("KHU1",280,315,1,true)
	elseif dialogName=="MAIA1377" then
		spell="cobraHypnosisOk"		
		StartAnimationPart("KHU1",315,330,1,true)
	elseif dialogName=="MAIA1378" then
		spell="magicalNetOK"
		StartAnimationPart("KHU1",315,330,1,true)
	elseif dialogName=="MAIA1383" then
		spell="lotoTransformationOk"		
		StartAnimationPart("KHU1",315,330,1,true)
	elseif dialogName=="MAIA1351" or dialogName=="MAIA1356" or dialogName=="MAIA1358" or dialogName=="MAIA1360" then
		StartAnimationPart("KHU1",130,140,-1,true)
	elseif dialogName=="KHAE1355" or dialogName=="KHAE1357" or dialogName=="KHAE1359" or dialogName=="KHAE1363" then
		StartAnimationPart("KHU1",70,100,-1,true)
	end
end

function OnWarpLeave()
end

function OnWarpObjectHit(objectName)
	if objectName == "KHU1" then
		SetMarker("KHU1",-1,0)
		if not FirstKahemTalk_piU_010 then
			FirstKahemTalk_piU_010 = true
			DrawText("MAIA1351","MAIA1351.ogg")
			DrawText("KHAE1352","KHAE1352.ogg")
			DrawText("KHAE1353","KHAE1353.ogg")
			DrawText("KHAE1354","KHAE1354.ogg")
			DrawText("KHAE1355","KHAE1355.ogg")
		--	DrawText("MAIA1356","MAIA1356.ogg")
			
		elseif spell=="cobraHypnosis" then
				if Selected("Vase_purification") then
					DrawText("MAIA1377","MAIA1377.ogg")
				elseif ObjectInHand() then
					StartAnimationPart("KHU1",332,360,1,true)
					spell="cobraHypnosisWrong"
				else SetMarker("KHU1",4,0)
				end
		elseif spell=="magicalNet" then
				if Selected("J_oriflamme") then
					DrawText("MAIA1378","MAIA1378.ogg")
				elseif ObjectInHand() then
					StartAnimationPart("KHU1",332,360,1,true)
					spell="magicalNetWrong"
				else SetMarker("KHU1",4,0)
				end
		elseif spell=="lotoTransformation" then
				if Selected("J_Oeil") then
					DrawText("MAIA1383","MAIA1383.ogg")
				elseif ObjectInHand() then
					StartAnimationPart("KHU1",332,360,1,true)
					spell="lotoTransformationWrong"
				else SetMarker("KHU1",4,0)
				end
		else
			StartAnimationPart("KHU1",130,140,-1,true)
			DrawText("KHAE1363","KHAE1363.ogg")
		end
------------------------------------------------------------
	elseif objectName == "D3T1" then
	end
	if objectName=="3D\\Pi Ramses\\Temple U\\Warp_0046.wp" then
		ChangeWarp(objectName)
       end
end
