function OnWarpEnter()
	PlaySound("Sounds/SFX/A_Wind2.ogg",-1)
	--SetMarker("Pi Ramses\\Temple U\\Warp_0005.wp",0,0)
	--SetMarker("Pi Ramses\\Temple U\\Warp_0004.wp",0,0)
	SetMarker("Pi Ramses\\Temple U\\Warp_0046.wp",0,0)
	--
	if MAYA_BETRAYED then
		if BrickMakerTurned_piM_006 then
			SetMarker("Pi Ramses\\Temple U\\Warp_0004.wp",0,0)
		end
	else
		SetMarker("Pi Ramses\\Temple U\\Warp_0004.wp",0,0)
	end
	--
	BrickMakerLastAnim = false
	if MAYA_BETRAYED and FirstKahemTalk_piU_010 then
		AnimationSetToStart("G2U1",true)
		if not BrickMakerTurned_piM_006 then
			StartAnimationPart("O3U1",0,30,-1,true) 
			SetMarker("O3U1",4,0)
		else
			StartAnimationPart("O3U1",150,180,-1,true)
			SetMarker("Pi Ramses\\Temple U\\Warp_0004.wp",0,0)
		end
	end
	if MAYA_BEATED then
		AnimationSetToStart("G2U1",false)
	end
end

function OnAnimationFinished(objectName)
	if objectName=="O3U1" then
		BrickMakerTurned_piM_006 = true
		BrickMakerLastAnim = false
		StartAnimationPart("O3U1",240,270,-1,true)
		DrawText("OUVB1338","OUVB1338.ogg")
		DrawText("OUVB1339","OUVB1339.ogg")
		DrawText("OUVB1340","OUVB1340.ogg")
		DrawText("OUVB1341","OUVB1341.ogg")
	end
end

function AskSeparation()
	if brickMakerTest == "start" then
		PushAnswer("MAIA1311")
		PushAnswer("MAIA1312")
	elseif brickMakerTest=="step1" then
		PushAnswer("MAIA1314") --ok
		PushAnswer("MAIA1315")
		PushAnswer("MAIA1316")
	elseif brickMakerTest=="step2" then
		PushAnswer("MAIA1318")
		PushAnswer("MAIA1319") --ok
		PushAnswer("MAIA1316")
	elseif brickMakerTest=="step3" then
		PushAnswer("MAIA1321") --ok
		PushAnswer("MAIA1322")
		PushAnswer("MAIA1316")
	elseif brickMakerTest=="step4" then
		PushAnswer("MAIA1324")--ok
		PushAnswer("MAIA1325")
		PushAnswer("MAIA1316")
	elseif brickMakerTest=="step5" then
		PushAnswer("MAIA1327")--ok
		PushAnswer("MAIA1328")
		PushAnswer("MAIA1316")
	end
 end

function OnAnswered(textid)
	if textid=="MAIA1311" then
		DrawText("MAIA1311","MAIA1311.ogg")
		DrawText("OUVB1313","OUVB1313.ogg")
	elseif textid=="MAIA1312" then
		DrawText("MAIA1312","MAIA1312.ogg")
	elseif textid=="MAIA1314" then
		DrawText("MAIA1314","MAIA1314.ogg")
		DrawText("OUVB1317","OUVB1317.ogg")
	elseif textid=="MAIA1315" then
		DrawText("MAIA1315","MAIA1315.ogg")
		DrawText("OUVB1330","OUVB1330.ogg")
		brickMakerTest="start"
	elseif textid=="MAIA1316" then
		DrawText("MAIA1316","MAIA1316.ogg")
	elseif textid=="MAIA1318" then
		DrawText("MAIA1318","MAIA1318.ogg")
		DrawText("OUVB1331","OUVB1331.ogg")
		SetMarker("O3U1",4,0)
		brickMakerTest="start"
	elseif textid=="MAIA1319" then
		DrawText("MAIA1319","MAIA1319.ogg")
		DrawText("OUVB1320","OUVB1320.ogg")
	elseif textid=="MAIA1321" then
		DrawText("MAIA1321","MAIA1321.ogg")
		DrawText("OUVB1323","OUVB1323.ogg")
	elseif textid=="MAIA1322" then
		DrawText("MAIA1322","MAIA1322.ogg")
		DrawText("OUVB1332","OUVB1332.ogg")
	elseif textid=="MAIA1324" then
		DrawText("MAIA1324","MAIA1324.ogg")
		DrawText("OUVB1326","OUVB1326.ogg")
	elseif textid=="MAIA1325" then
		DrawText("MAIA1325","MAIA1325.ogg")
		DrawText("OUVB1333","OUVB1333.ogg")
		brickMakerTest="start"
		SetMarker("O3U1",4,0)
	elseif textid=="MAIA1327" then
		DrawText("MAIA1327","MAIA1327.ogg")
		DrawText("OUVB1335","OUVB1335.ogg")
		DrawText("MAIA1336","MAIA1336.ogg")
		DrawText("OUVB1337","OUVB1337.ogg")
		brickMakerTest="over"
	elseif textid=="MAIA1328" then
		DrawText("MAIA1328","MAIA1328.ogg")
		DrawText("OUVB1334","OUVB1334.ogg")
		brickMakerTest="start"
		SetMarker("O3U1",4,0)
	end
end

function OnDialogFinished(dialogName)
	if dialogName=="OUVB1310" then
		brickMakerTest = "start"
		AskSeparation()
	elseif dialogName=="OUVB1313" then
			brickMakerTest = "step1"
			AskSeparation()
	elseif dialogName=="OUVB1317" then
			brickMakerTest="step2"
			AskSeparation()
	elseif dialogName=="OUVB1320" then
			brickMakerTest="step3"
			AskSeparation()
	elseif dialogName=="OUVB1323" then
			brickMakerTest="step4"
			AskSeparation()
	elseif dialogName=="OUVB1326" then
			brickMakerTest="step5"
			AskSeparation()
	elseif dialogName=="OUVB1337" then
			StartAnimationPart("O3U1",90,150,1,true)
			BrickMakerLastAnim = true
	elseif dialogName=="OUVB1341" then
		AddToBag("J_Coffret_serpent_OUVERT")
		SetMarker("Pi Ramses\\Temple U\\Warp_0004.wp",0,0)
		StartAnimationPart("O3U1",150,180,-1,true)
		AnimTestOk = true
	elseif dialogName=="MAIA1312" then
		SetMarker("O3U1",4,0)
	elseif dialogName=="MAIA1316" then
		SetMarker("O3U1",4,0)
	elseif dialogName=="OUVB1329" then
		SetMarker("O3U1",4,0)
	elseif dialogName=="OUVB1330" then
		SetMarker("O3U1",4,0)
	elseif dialogName=="OUVB1331" then
		SetMarker("O3U1",4,0)
	elseif dialogName=="OUVB1332" then
		SetMarker("O3U1",4,0)
	elseif dialogName=="OUVB1333" then
		SetMarker("O3U1",4,0)
	elseif dialogName=="OUVB1334" then
		SetMarker("O3U1",4,0)
	end


	-- make the brickmaker talk if it's his turn to speak
	if dialogName == "MAIA1303" 
	or dialogName == "MAIA1305" 
	or dialogName == "MAIA1308" 
	or dialogName == "MAIA1311" 
	or dialogName == "MAIA1314" 
	or dialogName == "MAIA1315" 
	or dialogName == "MAIA1318" 
	or dialogName == "MAIA1319" 
	or dialogName == "MAIA1321" 
	or dialogName == "MAIA1322" 
	or dialogName == "MAIA1324" 
	or dialogName == "MAIA1325" 
	or dialogName == "MAIA1327" 
	or dialogName == "MAIA1336" 
	or dialogName == "MAIA1328" 
	then
		StartAnimationPart("O3U1",60,90,-1,true)
	end

	-- make him stop talking if it's Maia's turn
	if dialogName == "OUVB1302" 
	or dialogName == "OUVB1304" 
	or dialogName == "OUVB1307" 
	or dialogName == "OUVB1310" 
	or dialogName == "OUVB1313" 
	or dialogName == "OUVB1317" 
	or dialogName == "OUVB1330" 
	or dialogName == "OUVB1331" 
	or dialogName == "OUVB1320" 
	or dialogName == "OUVB1323" 
	or dialogName == "OUVB1332" 
	or dialogName == "OUVB1326" 
	or dialogName == "OUVB1333" 
	or dialogName == "OUVB1335" 
	or dialogName == "OUVB1334"
	then
		StartAnimationPart("O3U1",0,30,-1,true)
	end
end

function OnWarpLeave()
end

function OnWarpObjectHit(objectName)
	if objectName == "O3U1" and not AnimTestOk  then
		if not BrickMakerLastAnim then
			StartAnimationPart("O3U1",60,90,-1,true)
			if not  BrickMakerTalked_piM_017  then
				SetMarker("O3U1",-1,0)
				BrickMakerTalked_piM_017 = true
				TUYA_IN_NAOS = true
				DrawText("OUVB1302","OUVB1302.ogg")
				DrawText("MAIA1303","MAIA1303.ogg")
				DrawText("OUVB1304","OUVB1304.ogg")
				DrawText("MAIA1305","MAIA1305.ogg")
				DrawText("OUVB1306","OUVB1306.ogg")
				DrawText("OUVB1307","OUVB1307.ogg")
				DrawText("MAIA1308","MAIA1308.ogg")
				DrawText("OUVB1309","OUVB1309.ogg")
				DrawText("OUVB1310","OUVB1310.ogg")
				brickMakerTest = "start"
			else
				SetMarker("O3U1",-1,0)
				DrawText("OUVB1310","OUVB1310.ogg")
			end
		end
------------------------------------------------------------
	elseif objectName == "D1T1" then

------------------------------------------------------------
	elseif objectName == "O2T1" then

------------------------------------------------------------
	elseif objectName == "O4t1" then

------------------------------------------------------------
	elseif objectName == "Q4T1" then
	end

        if objectName=="3D\\Pi Ramses\\Temple U\\Warp_0004.wp" then
		if MAYA_BETRAYED then  
			if BrickMakerTurned_piM_006 then
				ChangeWarp(objectName)
			end
		else
			ChangeWarp(objectName)	
		end
	end
	if objectName=="3D\\Pi Ramses\\Temple U\\Warp_0046.wp" then
		ChangeWarp(objectName)
        end
end
