StartDialogScene("/DialogScenes/Single/SS2/R1/DialogScene.xdb#xpointer(/DialogScene)")  ----Сцена стартовая

Oddrema = "Oddrema";  
Maeve = "Maeve";  --Miraya

if GetDifficulty() == DIFFICULTY_EASY then
	diff = 0;
	print("easy");
end;

if GetDifficulty() == DIFFICULTY_NORMAL then
	diff =  1;
	print("normal");
end;

if GetDifficulty() == DIFFICULTY_HARD then
	diff = 2;
	DenyAIHeroesFlee(2,1);
	print("hard");
end;

if GetDifficulty() == DIFFICULTY_HEROIC then
	diff = 3;
	DenyAIHeroesFlee(2,1);
	print("heroic");
end;

function map_up()
	DeployReserveHero("Maeve", 83, 73, 0);
	sleep(2);
	ChangeHeroStat("Maeve", 0, 1000 + 4000 * diff);
	RemoveHeroCreatures("Maeve", 14, 9);
	if diff == 3 then
		SetHeroLootable("Maeve", nil);
		GiveArtefact("Maeve", 1);
		GiveArtefact("Maeve", 8);
		GiveArtefact("Maeve", 16);
		GiveArtefact("Maeve", 21);
		GiveArtefact("Maeve", 31);
		GiveArtefact("Maeve", 55);
		GiveArtefact("Maeve", 56);
		AddHeroCreatures(Maeve, 2, 35);
		AddHeroCreatures(Maeve, 4, 20);
		AddHeroCreatures(Maeve, 5, 16);
	end;
	SetRegionBlocked("border", 1, 2);
	SetRegionBlocked("M1", 1, 2);
	SetRegionBlocked("M2", 1, 2);
	SetRegionBlocked("M3", 1, 2);
end;

--------------
function PObjective1() 
	while 1 do	
		if (GetObjectOwner("Falconhill") == 1) and IsHeroAlive("Maeve") == nil then
			print("Falcon dinasty pipez.................................");
			SetObjectiveState('Prim1',OBJECTIVE_COMPLETED);
			return
		end;
	sleep(10);
	end;
end;

function PObjective2()  --loose
	while 1 do
		sleep(10);
		if IsHeroAlive("Oddrema") == nil then
			print("Oddrema.................................");
			SetObjectiveState('Prim2',OBJECTIVE_FAILED);
			Loose();
			break;
		end;
	end;
end;

--------------------------Maeve_ressurect
function Ress ()
	if (GetObjectOwner("Falconhill") ~= 1) and GetObjectiveState('Prim1', 1) ~= OBJECTIVE_COMPLETED and IsHeroAlive("Maeve") == nil then 
		DeployReserveHero("Maeve", 75, 70, 0);
		SetRegionBlocked("border", nil, 2); -----------регион границы разблокан!
		sleep(2);
		MoveHero( "Maeve", 83, 79, 0 );
	end;
end;

--------------------------------Winns

function CheckVictory ()
	while 1 do	
		if GetObjectiveState ('Prim1') == OBJECTIVE_COMPLETED then
			sleep(4);
			StartDialogScene("/DialogScenes/Single/SS2/R3A2/DialogScene.xdb#xpointer(/DialogScene)")  ----Сцена финальная 
			sleep(30);
			Win ();
			Trigger(NEW_DAY_TRIGGER, nil);
			sleep(4);
		end;
		sleep(4);
	end;
end;
----------------------------------///Новые сцены

function CaptureFH()
	while 1 do
		sleep(6);
		if (GetObjectOwner("Falconhill") == 1) and IsHeroAlive("Maeve") == true then 
			StartDialogScene("/DialogScenes/Single/SS2/R3A1/DialogScene.xdb#xpointer(/DialogScene)")  ----Замок взят но аигерой ещё жив 
			break;
		end;
	end;
end;

function Kill_AIfirst()
	while 1 do
		sleep(6);
		if (GetObjectOwner("Falconhill") ~= 1) and IsHeroAlive("Maeve") == nil then 
			StartDialogScene("/DialogScenes/Single/SS2/R2/DialogScene.xdb#xpointer(/DialogScene)")  ----AI убит первый раз 
			break;
		end;
	end;
end;

function Won_scene ()
	if (GetObjectOwner("Falconhill") == 1) and GetObjectiveState('Prim1', 1) == OBJECTIVE_COMPLETED and IsHeroAlive("Maeve") == nil then 
		StartDialogScene("/DialogScenes/Single/SS2/R3A2/DialogScene.xdb#xpointer(/DialogScene)")  ----Сцена финальная 
		sleep(30);
		Win ();
	end;
end;
--------------------------------//Main
startThread(PObjective1);
startThread(PObjective2);
sleep(20);
startThread(CheckVictory);
startThread(map_up);
startThread(CaptureFH);
startThread(Won_scene);
sleep(20);
startThread(Kill_AIfirst); 
Trigger(NEW_DAY_TRIGGER, "Ress")