c = 0

function GreetingAction()
	LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
	AddTalkWindowToLastAction(0.2, "GreetingAction1", 7);				
	LP_WalkTo(Point(132, 205), 1, 1.0);
	AddTalkWindowToLastAction(0.2, "GreetingAction2", 7);				
	LP_WalkTo(Point(248, 207), 1, 1.0);
	AddTalkWindowToLastAction(1.0, "GreetingAction3", 7);				
	LP_WalkTo(Point(489, 308), 1, 1.0);
	LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
	AddTalkWindowToLastAction(0.0, "GreetingAction4", 7);				
	LP_WalkTo(Point(525, 211), 1, 1.0);
	LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
	AddTalkWindowToLastAction(0.0, "GreetingAction5", 7);				
end;
function OstinAboutChangeDogName()
end;



function LP_AfterAction(nameAction)
	if (nameAction == "Watercan") then
	-- пополивал
		local t = math.random(1,3);
		if (t == 1) then 
			LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
		elseif (t == 2) then 
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
		else 
			LP_PlayAnim("Joy2", math.random(30, 90)/100.0, 1, true, true);	
		end;
		AddTalkWindowToLastAction(0.2, "AfterWatercan"..Random("AfterWatercan", 1, 20), 7);				
	elseif (nameAction == "House") then
	-- сходил в дом
		LP_PlayAnim("Tutorial3", 0.7, 1, true, true);		
		AddTalkWindowToLastAction(0.2, "AfterHouse"..Random("AfterHouse", 1, 12), 7);				
	elseif (nameAction == "Golf") then
	-- поиграл в гольф
		LP_PlayAnim("Tutorial3", 0.7,1, true, true);	
		AddTalkWindowToLastAction(0.2, "AfterGolf"..Random("AfterGolf", 1, 10), 7);				
	elseif (nameAction == "Shears") then  
	-- подстриг
		LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
		AddTalkWindowToLastAction(0.2, "AfterShears"..Random("AfterShears", 1, 10), 7);				
	elseif (nameAction == "Brush") then
	-- подкрасил
		LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
		AddTalkWindowToLastAction(0.2, "AfterBrush"..Random("AfterBrush", 1, 10), 7);				
	elseif (nameAction == "Swing") then
	-- покачался
		LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
		AddTalkWindowToLastAction(0.2, "AfterSwing"..Random("AfterSwing", 1, 10), 7);				

	elseif (nameAction == "FeedSwan") then
	-- покормил лебедя
	-- уже говорит фразы из "FeetSwanPhrases"
	elseif (nameAction == "FeedBird") then
	-- покормил птичек
---		LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
--		AddTalkWindowToLastAction(2, "strange4", 5);				
	elseif (nameAction == "PlayDog") then
	-- поиграл с собачкой
	-- уже говорит фразы из PlayWithDog
	end
end

function LP_AfterTutorial(nameTrain)
	if (nameTrain == "GardenFirstSell") then
		AfterFirstLevel(gameInfo:getLocalIntOrDef("Cash", 5));
	end
end;

function LP_SkipTutorial(nameOfSkipTrain)
	LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
	AddTalkWindowToLastAction(0.2, "SkipTrain", 7);				
end;

function LP_AfterHistory()
	local justShowHistory = gameInfo:getLocalStringOrDef("HistoryRead", "")
	local LastLetterName = gameInfo:getLocalStringOrDef("LastLetter", "")
	local LastNewspaperName = gameInfo:getLocalStringOrDef("NameLastNewspaper", "")
	local Iter = gameInfo:getGardenIter();
	local money = gameInfo:getLocalIntOrDef("Cash", 0)						-- количество денег у игрока
	local i = GetI(Iter);
	
	local p = {0, 0, 0, 0};
	
	for j = 1, 4 do 
		if (LP_GetPurchaseProgress(i[j]) > 0) then p[j] = 1 else p[j] = 0; end;
	end; 
	local RandomPhone = gameInfo:getLocalIntOrDef("RandomPhone", 0)
	local LastPhone = gameInfo:getLocalStringOrDef("LastPhoneDialog", "");
	if (justShowHistory == "Phone") then
		if (RandomPhone > 0) then
			LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
			AddTalkWindowToLastAction(2, "OstinAboutStrangePhone"..RandomPhone, 5);		
			gameInfo:setLocalInt("RandomPhone", 0);
		elseif LastPhone == "StrangePhoneWomen" then 
	
			local s
			if LP_GetPurchaseProgress("Gazone") == 0 then 
				s = 1
			elseif LP_GetPurchaseProgress("Sculpture1") == 0 then 
				s = 2
			elseif LP_GetPurchaseProgress("Lantern") == 0 then 
				s = 3
			else 
				s = 4
			end;

			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.0, "OstinAfterStrangePhoneWomen1", 8.0); 
			AddTalkWindowToLastAction(0.0, "OstinAfterStrangePhoneWomen2", 8.0); 
			LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
			LP_WalkTo(Point(408, 384), 7, 1.0);		
			LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.0, "OstinAfterStrangePhoneWomen3", 8.0); 
			AddTalkWindowToLastAction(0.0, "OstinAfterStrangePhoneWomen4"..s, 8.0); 
			gameInfo:setLocalString("LastPhoneDialog", "");

		elseif LastPhone == "StrangePhoneWomenMiddleIter2" then
			local s1, s2, s3, s4
			if LP_GetPurchaseProgress("Gazone") == 0 then 
				s1 = "MiddleIter2Mult2_6_0"
			else s1 = "MiddleIter2Mult2_6_1"
			end;
			if LP_GetPurchaseProgress("Sculpture1") == 0 then 
				s2 = "MiddleIter2Mult2_7_0"
			else s2 = "MiddleIter2Mult2_7_1"
			end;
			if LP_GetPurchaseProgress("Lantern") == 0 then 
				s3 = "MiddleIter2Mult2_5_0"
			else s3 = "MiddleIter2Mult2_5_1"
			end;
			if LP_GetPurchaseProgress("Sculpture2") == 0 then 
				s4 = "MiddleIter2Mult2_4_0"
			else s4 = "MiddleIter2Mult2_4_1"
			end;
	
			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_WalkTo(Point(417, 389), 7, 1.0);		
			LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.0, "MiddleIter2Mult2_1", 8.0); 
			LP_WalkTo(Point(480, 429), 7, 1.0);		
			LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.0, "MiddleIter2Mult2_2", 8.0); 
			LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.0, "MiddleIter2Mult2_3", 8.0); 
			LP_WalkTo(Point(489, 308), 7, 1.0);		
			LP_PlayAnim("Joy2", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.0, s4, 8.0); 
			LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
			LP_WalkTo(Point(383, 274), 7, 1.0);		
			LP_PlayAnim("Joy2", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.0, s3, 8.0); 
			LP_WalkTo(Point(195, 290), 7, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, false);
			AddTalkWindowToLastAction(0.0, s1, 8.0); 
			LP_PlayAnim("Tutorial4", 0.7, 1, true, false);
			AddTalkWindowToLastAction(0.0, s2, 8.0); 
			LP_WalkTo(Point(668, 292), 7, 1.0);		
			AddTalkWindowToLastAction(2.0, "MiddleIter2Mult2_8", 8.0); 
			LP_PlayAnim("Sit1", 1.2, 1, true, false);	
			LP_PlayAnim("Sitting1", 1.2, 1, true, false);	
			LP_PlayReversedAnim("Sit1", 1.2, 1, true, false);	
		
			gameInfo:setLocalString("LastPhoneDialog", "");
		elseif LastPhone == "AdditionalPhoneMiddleIter4" then
			local s1, s2
			if LP_GetPurchaseProgress("Swing") == 0 then 
				s1 = "OstinAddHistMiddleIter4_4_0"
			else
				s1 = "OstinAddHistMiddleIter4_4_1"
			end;
			if LP_GetPurchaseProgress("Bridge") == 0 then 
				s2 = "OstinAddHistMiddleIter4_6_0"
			else
				s2 = "OstinAddHistMiddleIter4_6_1"
			end;
			LP_WalkTo(Point(534, 207), 7, 1.0);		
			LP_WalkTo(Point(311, 335), 7, 1.0);
			AddTalkWindowToLastAction(2.0, "OstinAddHistMiddleIter4_1", 8.0); 
			LP_WalkTo(Point(338, 304), 7, 1.0);		
			LP_WalkTo(Point(338, 278), 7, 1.0);		
			AddTalkWindowToLastAction(2.0, "OstinAddHistMiddleIter4_2", 8.0); 
			LP_WalkTo(Point(293, 265), 7, 1.0);		
			LP_WalkTo(Point(266, 296), 7, 1.0);		
			LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(1.0, "OstinAddHistMiddleIter4_3", 8.0); 
			LP_WalkTo(Point(293, 317), 7, 1.0);		
			AddTalkWindowToLastAction(2.0, s1, 8.0); 
			LP_WalkTo(Point(408, 366), 7, 1.0);		
			LP_WalkTo(Point(534, 225), 7, 1.0);		
			AddTalkWindowToLastAction(2.0, "OstinAddHistMiddleIter4_5", 8.0); 
			LP_WalkTo(Point(435, 140), 7, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, s2, 8.0); 
			LP_WalkTo(Point(659, 207), 7, 1.0);	
			gameInfo:setLocalString("LastPhoneDialog", "");			
		elseif LastPhone == "StartIter3PhoneWomen" then 
		
			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_WalkTo(Point(400, 389), 7, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(2.0, "StartIter3PhoneWomen1", 8.0); 
			LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(2.0, "StartIter3PhoneWomen2", 8.0); 
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	

			gameInfo:setLocalString("LastPhoneDialog", "");
		elseif  (LastPhone == "MiddleIter3PhoneWomen0") or
				(LastPhone == "MiddleIter3PhoneWomen1") or
				(LastPhone == "MiddleIter3PhoneWomen2") or
				(LastPhone == "MiddleIter3PhoneWomen3") or
				(LastPhone == "MiddleIter3PhoneWomen4") 
		then 

			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_WalkTo(Point(400, 389), 7, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(2.0, "OstinAfterMiddleIter3PhoneWomen", 8.0); 

			gameInfo:setLocalString("LastPhoneDialog", "");
		elseif (LastPhone == "AddPhoneMiddleIter4WomenEmpty" or 
				LastPhone == "AddPhoneMiddleIter4WomenGolf" or 
				LastPhone == "AddPhoneMiddleIter4WomenPorch" or 
				LastPhone == "AddPhoneMiddleIter4WomenSwing" or 
				LastPhone == "AddPhoneMiddleIter4WomenBridge")
		then
			gameInfo:setLocalString("LastPhoneDialog", "");
		elseif (LastPhone == "AdditionalPhoneMenStartIter4") then 

			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAfterAdditionalPhoneMenStartIter4", 8.0); 

			gameInfo:setLocalString("LastPhoneDialog", "");
		elseif (LastPhone == "MiddleIter5MenPhone") then 
		
			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAfterMiddleIter5MenPhone1", 8.0); 
			LP_WalkTo(Point(302, 234), 7, 2.0);		
			LP_PlayAnim("Joy2", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAfterMiddleIter5MenPhone2", 8.0); 
			LP_WalkTo(Point(87, 263), 7, 2.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAfterMiddleIter5MenPhone3", 8.0); 
			LP_WalkTo(Point(623, 171), 7, 2.0);		
			LP_PlayAnim("HandUp1", 1.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAfterMiddleIter5MenPhone4", 8.0); 

			gameInfo:setLocalString("LastPhoneDialog", "");
		elseif (LastPhone == "AddPhoneStartIter5Men") then 
			
			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAfterAddPhoneStartIter5Men", 8.0); 

			gameInfo:setLocalString("LastPhoneDialog", "");
		else
			if (Iter == 1) then 
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "AfterMiddleHistoryIter1"..p[1]..p[2]..p[3]..p[4], 5);		
				gameInfo:setLocalString("LastHistory", "MiddleIter1");
			elseif (Iter == 4) then 
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "AfterStartHistoryIter4", 5);				
				gameInfo:setLocalString("LastHistory", "StartIter4");
			else
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "strange4", 4);				
			end;
		end;
	elseif (justShowHistory == "Letter") then
		if (LastLetterName == "NewIterLetter3") then 
			LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
			AddTalkWindowToLastAction(2, "AfterStartHistoryIter3", 5);		
			gameInfo:setLocalString("LastHistory", "StartIter3");		

				LP_WalkTo(Point(408, 384), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_1", 5.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_WalkTo(Point(587, 393), 1, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, false);
				AddTalkWindowToLastAction(0.0, "OstinStartIter3v3_2", 5.0); 
				LP_WalkTo(Point(435, 353), 1, 1.0);		
				LP_PlayAnim("ButterflyUpHand1", 1.7, 1, true, false);	
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, false);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_3", 5.0); 
				LP_PlayReversedAnim("ButterflyUpHand1", 1.7, 1, false, false);	
				LP_WalkTo(Point(507, 308), 1, 1.0);		
				LP_PlayAnim("Joy2", 0.5, 1, true, false);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_4", 5.0); 
				LP_PlayAnim("Stay1", 0.7, 1, true, false);
				LP_WalkTo(Point(561, 300), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3Fountain"..p[3], 5.0);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				if p[3] == 0 and money >= GetPrice(i[3]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter3v3Fountain0_1", 2.5);	
				end;
				LP_WalkTo(Point(435, 308), 1, 1.0);		
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_5", 5.0); 


			
		elseif 	(LastLetterName == "NewIterLetter5") then
			LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
			AddTalkWindowToLastAction(2, "AfterStartHistoryIter5", 8);		
			gameInfo:setLocalString("LastHistory", "StartIter5");						
		elseif (LastLetterName == "Middle4"..p[1]..p[2]..p[3]..p[4]) then 
			LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
			AddTalkWindowToLastAction(2, "AfterMiddleHistoryIter4"..p[1]..p[2]..p[3]..p[4], 5);	
			gameInfo:setLocalString("LastHistory", "MiddleIter4");						
		elseif (LastLetterName == "Iter4ChildLetter0" or
				LastLetterName == "Iter4ChildLetter1" or
				LastLetterName == "Iter4ChildLetter2" or
				LastLetterName == "Iter4ChildLetter3" or
				LastLetterName == "Iter4ChildLetter4") 
		then

			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0, "AfterIter4ChildLetter", 5);	
	
		else
			-- значит пришло письмо от коллекционера или про бусинки!
			LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
			if (LastLetterName == "PearlsLetter") then
				AddTalkWindowToLastAction(2, "BeforePearlsLetter", 5);				
			else
				AddTalkWindowToLastAction(2, "Before"..LastLetterName, 5);				
			end;
		end;
	elseif (justShowHistory == "Newspaper") then
		LP_PlayReversedAnim("PaperOpen", 1, 1, true, false);	
		if (LastNewspaperName == "NewIterNewspaper2") then 
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "AfterStartHistoryIter2", 5);	
				
				LP_WalkTo(Point(132, 338), 1, 1.0);		
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v3Gazone"..p[1], 7.5); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter2v3Gazone0_1", 2.5);	
				end;
				LP_WalkTo(Point(159, 299), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v3_1", 7.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);	
				
				LP_WalkTo(Point(87, 246), 7, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v3Lantern"..p[3], 6.0); 
				
				
				gameInfo:setLocalString("LastHistory", "StartIter2");						
		elseif (LastNewspaperName == "NewIterNewspaper4") then 
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "AfterStartHistoryIter4", 5);				
				gameInfo:setLocalString("LastHistory", "StartIter4");
		elseif (LastNewspaperName == "MiddleNewspaper3"..p[1]..p[2]..p[3]..p[4]) then 
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "AfterMiddleHistoryIter3"..p[1]..p[2]..p[3]..p[4], 5);				
				gameInfo:setLocalString("LastHistory", "MiddleIter3");			
		elseif (LastNewspaperName == "StrangeNewspaper2") then
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "AfterStrangeNewspaper2", 5);			
		elseif (LastNewspaperName == "StrangeNewspaper3") then
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
				AddTalkWindowToLastAction(2, "AfterStrangeNewspaper3", 5);			
		elseif (LastNewspaperName == "LastNewspaper") then 
				LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, 15, true, true);	
				AddTalkWindowToLastAction(0, "EndGamePhrase", 3);	
				GUI:getLayer("Shop"):getWidget("Shop"):AcceptMessage(Message("StartFireWork"));
				gameInfo:setLocalString("LastHistory", "AfterAllHistory");	
		else
			LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);	
		end;
	elseif (justShowHistory == "PeopleTalk") then
		if (Iter == 2) then gameInfo:setLocalString("LastHistory", "MiddleIter2")
		elseif (Iter == 5) then gameInfo:setLocalString("LastHistory", "MiddleIter5");			
		end;
	end
	gameInfo:setLocalString("HistoryRead", "");			
end

function LP_OstinComment(isStop, ClearTalkWindow)
	local Iter = gameInfo:getGardenIter()									-- номер итерации в саду (1 - 5)
	local money = gameInfo:getLocalIntOrDef("Cash", 0)						-- количество денег у игрока
	local i = GetI(Iter);
	local v = {0, 0, 0, 0};
	local k = 1
	local AfterLevel = false;
	local AboutSell = true;
	local TotalIterCount = 0; --сколько еще необходимо купить предметов 
	for j = 1, 4 do 
		if (LP_GetPurchaseProgress(i[j]) > 0) then v[j] = 0 else v[j] = 1; end;
		if (k == 0) and (v[j] == 1) then k = j; end;
		TotalIterCount = TotalIterCount + v[j];
	end; 
	if (gameInfo:GetNumberOfPurchase() < 20) then	
		if (TalkAboutSell(60, 2)) then
			if (money < GetPrice(i[k])) then 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				TalkPhrase("AboutSellNoMoneyPhrases"); 
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);	
			else 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				TalkPhrase("AboutSellPhrases"); 
				OstinCommentAfterLevel(v, i, money, TotalIterCount, AfterLevel, AboutSell, isStop, ClearTalkWindow);
			end;
		else 
			OstinCommentAfterLevel(v, i, money, TotalIterCount, AfterLevel, not AboutSell, isStop, ClearTalkWindow);
		end;
	end;
end; 

function LP_OstinHistory()
	local Iter = gameInfo:getGardenIter()									-- номер итерации в саду (1 - 5)
	local i = GetI(Iter);
	local money = gameInfo:getLocalIntOrDef("Cash", 0)						-- количество денег у игрока
	local p = {0, 0, 0, 0};
	for j = 1, 4 do 
		if (LP_GetPurchaseProgress(i[j]) > 0) then p[j] = 1 else p[j] = 0; end;
	end; 
	local InHist = true;
	local LastHistory = gameInfo:getLocalStringOrDef("LastHistory", "StartIter1");
	if (LastHistory == "AfterAllHistory") then
		local n = Random(LastHistory, 1, 4)
		if (n == 1) then 
			LP_WalkTo(Point(471, 463), 6, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAbloutNewProfile1", 3);				
		elseif (n == 2) then 
			LP_WalkTo(Point(329, 247), 6, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAbloutNewProfile2", 3);				
			LP_WalkTo(Point(650, 353), 6, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAbloutNewProfile2_2", 3);				
		elseif (n == 3) then 
			LP_WalkTo(Point(632, 158), 6, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAbloutNewProfile3", 3);				
			LP_WalkTo(Point(516, 287), 6, 1.0);		
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAbloutNewProfile3_2", 3);				
			LP_WalkTo(Point(302, 234), 6, 1.0);		
			LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAbloutNewProfile3_3", 3);				
		elseif (n == 4) then 
			LP_WalkTo(Point(677, 287), 6, 1.0);		
			LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
			AddTalkWindowToLastAction(0.0, "OstinAbloutNewProfile4", 3);
		end;
	elseif Iter == 1 then 
		if LastHistory == "StartIter1" then 
		--видел вступительный мультик	
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(471, 463), 6, 1.0);		
				LP_PlayAnim("Stay1", 0.5, 1, true, true);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinStartIter1v1", 3);				
				LP_WalkTo(Point(338, 432), 6, 1.0);		
				LP_PlayAnim("Joy2", 0.5, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinStartIter1v1Wall"..p[2], 2.5);	
				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter1v1Wall0_1", 2.5);	
				end;
				LP_WalkTo(Point(534, 287), 6, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter1v1Bench"..p[1], 2.5);				
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter1v1Bench0_1", 2.5);	
				end;
				LP_WalkTo(Point(462, 153), 6, 1.0);		
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinStartIter1v1Pond"..p[3], 3.5);	
				if p[3] == 0 and money >= GetPrice(i[3]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter1v1Pond0_1", 2.5);	
				end;				
			elseif (n == 2) then 
				LP_WalkTo(Point(740, 353), 6, 1.0);		

				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.2, "OstinStartIter1v2", 2.5);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);		

				LP_WalkTo(Point(525, 283), 6, 1.0);		
				AddTalkWindowToLastAction(1, "OstinStartIter1v2Wall"..p[2], 2.5);				
				LP_WalkTo(Point(668, 220), 6, 1.0);		
				AddTalkWindowToLastAction(3, "OstinStartIter1v2Bench"..p[1], 2.5);				
				LP_PlayAnim("Sit1", 1.5, 1, true, true);	
				LP_PlayAnim("Sitting1", 0.5, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter1v2Dog"..p[4], 2.5);	
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, true);
				if p[4] == 0 and money >= GetPrice(i[4]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter1v2Dog0_1", 2.5);	
				end;				
			elseif (n == 3) then 
				LP_WalkTo(Point(311, 283), 6, 1.0);		
				LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(0, "OstinStartIter1v3", 3.5);	

				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(1, "OstinStartIter1v3_1", 4.0);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);	

				LP_WalkTo(Point(695, 375), 6, 1.0);		
				AddTalkWindowToLastAction(2, "OstinStartIter1v3_2", 4);				
				LP_PlayAnim("Joy2", 0.5, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter1v3_4", 1.5);				
				LP_WalkTo(Point(507, 292), 6, 1.0);		
				AddTalkWindowToLastAction(2, "OstinStartIter1v3_3", 4);				
				LP_PlayAnim("ButterflyUpHand1", 1.3, 1, true, false);	
				LP_PlayAnim("ButterflyWait1", 0.3, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinStartIter1v3Pond"..p[3], 5);				
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, false);	
				LP_PlayReversedAnim("ButterflyUpHand1", 1.3, 1, false, false);	
			elseif (n == 4) then
				LP_WalkTo(Point(356, 260), 6, 1.0);		
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(1, "OstinStartIter1v4_1", 3);	
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
			
				LP_WalkTo(Point(552, 393), 6, 1.0);		
				AddTalkWindowToLastAction(1, "OstinStartIter1v4_2", 3);				
				LP_WalkTo(Point(400, 389), 6, 1.0);		
				LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinStartIter1v4_3", 3);				
				LP_WalkTo(Point(525, 300), 0, 1.0);		
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				LP_WalkTo(Point(578, 398), 0, 1.0);							
				AddTalkWindowToLastAction(0, "OstinStartIter1v4_4", 3);				
				LP_PlayAnim("ButterflyUpHand1", 1.5, 1, true, true);	
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, true);	
				AddTalkWindowToLastAction(1.5, "OstinStartIter1v4_5", 2);				
				LP_PlayReversedAnim("ButterflyUpHand1", 1.5, 1, false, true);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinStartIter1v4Wall"..p[2], 3);		
				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter1v4Wall0_1", 2.5);	
				end;				

			elseif (n == 5) then 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinStartIter1v5_1", 3);		
				LP_WalkTo(Point(525, 300), 0, 1.0);		
				LP_PlayAnim("Tutorial1", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinStartIter1v5_2", 3);		
				LP_WalkTo(Point(632, 300), 0, 1.0);		
				LP_PlayAnim("Brush2", 0.5, 2, true, false);
				LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(0, "OstinStartIter1v5_3", 3);		
				LP_WalkTo(Point(578, 398), 0, 1.0);				
				LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinStartIter1v5_4", 3);		
			end;
		elseif LastHistory == "MiddleIter1" then 
		--знает про звонок редактора и ждет газету
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(374, 366), 6, 1.0);		
				AddTalkWindowToLastAction(1, "OstinMiddleIter1v1", 5);				
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(1, "OstinMiddleIter1v1Wall"..p[2], 5);	
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				
				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter1v1Wall0_1", 2.5);	
				end;				
				LP_WalkTo(Point(408, 118), 6, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(1, "OstinMiddleIter1v1Pond"..p[3], 5);	
			elseif (n == 2) then 
				LP_WalkTo(Point(311, 283), 6, 1.0);		
				LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(0, "OstinStartIter1v3", 3.5);				
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(1, "OstinStartIter1v3_1", 4.0);	
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				
				LP_WalkTo(Point(695, 375), 6, 1.0);		
				AddTalkWindowToLastAction(2, "OstinStartIter1v3_2", 4);				
				LP_PlayAnim("Joy2", 0.5, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter1v3_4", 1.5);				
				LP_WalkTo(Point(507, 292), 6, 1.0);		
				AddTalkWindowToLastAction(2, "OstinStartIter1v3_3", 4);				
				LP_PlayAnim("ButterflyUpHand1", 1.3, 1, true, false);	
				LP_PlayAnim("ButterflyWait1", 0.3, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinStartIter1v3Pond"..p[3], 5);				
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, false);	
				LP_PlayReversedAnim("ButterflyUpHand1", 1.3, 1, false, false);	
			elseif (n == 3) then 
				LP_WalkTo(Point(605, 189), 6, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(1, "OstinMiddleIter1v3", 4);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
			
				LP_WalkTo(Point(213, 470), 8, 1.0);		
				AddTalkWindowToLastAction(1, "OstinMiddleIter1v3_1", 2);				
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v3_2", 3);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);	

				LP_WalkTo(Point(257, 501), 8, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v3_3", 2);				
				RunIdle(1, -1, false);
			elseif (n == 4 and p[1] == 1) then 
				LP_WalkTo(Point(677, 296), 1, 1.0);		
				AddTalkWindowToLastAction(1, "OstinMiddleIter1v4", 2);				
				LP_PlayAnim("Sit1", 0.7, 1, true, false);	
				LP_PlayReversedAnim("Sit1", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(1, "OstinMiddleIter1v4_1", 2);				
			elseif (n == 5) then
				LP_WalkTo(Point(392, 278), 1, 1.0);		
				LP_WalkTo(Point(96, 122), 1, 1.0);		
				AddTalkWindowToLastAction(2, "OstinMiddleIter1v5_1", 5);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v5_2", 3);				
				LP_WalkTo(Point(222, 193), 1, 1.0);		
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v5_3", 3);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v5_4", 3);	
				LP_WalkTo(Point(462, 313), 1, 1.0);		
				LP_PlayAnim("Joy2", 0.3, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v5_5", 5);	
				LP_WalkTo(Point(668, 362), 1, 1.0);		
				LP_PlayAnim("Joy2", 0.3, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v5_6", 3);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0, "OstinMiddleIter1v5_7", 5);	
			end;
		end;
	elseif Iter == 2 then 
		if LastHistory == "StartIter2" then 
		--прочитал газету
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(659, 296), 1, 1.0);		
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v1_1", 6.0); 
				RunIdle(3, -1, false);
				LP_PlayAnim("Sit1", 1.5, 1, true, false);
				LP_PlayAnim("SatToLetter", 1.5, 1, true, false);	
				LP_PlayAnim("Letter", 0.7, 1, true, false);	
				AddTalkWindowToLastAction(0.0, "OstinStartIter2v1_2", 4.0); 
				LP_PlayAnim("Letter", 0.7, 3, true, false);	
				LP_PlayReversedAnim("SatToLetter", 1.5, 1, true, false);
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, false);
			elseif (n == 2) then 
				LP_WalkTo(Point(383, 419), 1, 1.0);		
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v2_1", 5.0); 
				LP_WalkTo(Point(302, 242), 1, 1.0);		
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v2_2", 6.0); 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v2_3", 6.0); 
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
			elseif (n == 3) then 
				LP_WalkTo(Point(132, 338), 1, 1.0);		
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v3Gazone"..p[1], 7.5); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter2v3Gazone0_1", 2.5);	
				end;
				LP_WalkTo(Point(159, 299), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v3_1", 7.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);	
				
				LP_WalkTo(Point(87, 246), 7, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v3Lantern"..p[3], 6.0); 
			elseif (n == 4) then 
				LP_WalkTo(Point(659, 296), 1, 1.0);		
				LP_PlayAnim("Sit1", 1.5, 1, true, false);	
				LP_PlayAnim("Sitting2", 0.5, 3, true, false);
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v4", 6.0); 
				LP_PlayAnim("Sitting1", 0.5, 2, true, false);
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v4Sculpture2"..p[4], 6.0); 
				if p[4] > 0 and money >= GetPrice(i[4]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter2v4Sculpture20_1", 2.5);	
				end;
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, false);					
			elseif (n == 5) then 
				LP_WalkTo(Point(87, 109), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v5_1", 2.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);	
				 
				LP_WalkTo(Point(347, 265), 1, 1.0);		
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v5_2", 3.0); 
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter2v5_3", 3.0); 
				LP_WalkTo(Point(740, 460), 1, 1.0);		
				AddTalkWindowToLastAction(3.5, "OstinStartIter2v5_4", 3.0); 
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter2v5_5", 7.0); 
			end;
		elseif LastHistory == "MiddleIter2" then 
		--уже видел председательницу клуба садоводов
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(365, 265), 1, 1.0);		
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v1", 4.0); 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				LP_PlayAnim("Joy2", 0.3, 1, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v1Gazone"..p[1], 7.0); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter2v1Gazone0_1", 2.5);	
				end;
				LP_WalkTo(Point(489, 326), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v1Sculpture2"..p[4], 7.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);				
			elseif (n == 2) then 
				LP_WalkTo(Point(302, 458), 1, 1.0);		
				LP_PlayAnim("Sit1", 1.5, 1, true, true);	
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v2_1", 4.0); 
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v2Gazone"..p[1], 4.0); 
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v2Sculpture1"..p[2], 4.0); 
				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Sitting1", 0.4, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter2v2Sculpture10_1", 2.5);	
				end;
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v2Lantern"..p[3], 4.0); 
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, true);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v2_2", 4.0); 
				LP_WalkTo(Point(114, 594), 0, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				LP_WalkTo(Point(302, 458), 7, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v2_3", 4.0); 
			elseif (n == 3) then 
				LP_WalkTo(Point(650, 472), 7, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v3_1", 2.5); 
				LP_WalkTo(Point(471, 481), 7, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v3_2", 2.5); 
				LP_WalkTo(Point(650, 472), 7, 1.0);	
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v3_3", 2.5); 
				LP_WalkTo(Point(471, 481), 7, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v3_4", 2.5); 
				LP_WalkTo(Point(320, 242), 7, 2.5);		
				LP_PlayAnim("Joy2", 0.5, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v3_5", 2.5); 
			elseif (n == 4) then 
				LP_WalkTo(Point(320, 242), 7, 2.5);		
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v4_1", 3.5); 
				LP_WalkTo(Point(480, 331), 7, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v4Gazone"..p[1], 4.0); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter2v4Gazone0_1", 2.5);	
				end;
				LP_WalkTo(Point(462, 153), 7, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v4Sculpture2"..p[4], 4.0); 
				if p[4] == 0 and money >= GetPrice(i[4]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter2v4Sculpture20_1", 2.5);	
				end;
				LP_WalkTo(Point(632, 193), 7, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v4_4", 4.0); 
				LP_WalkTo(Point(677, 287), 7, 1.0);	
				LP_PlayAnim("HandUp1", 1.2, 5, true, true);	
				AddTalkWindowToLastAction(0.2, "OstinMiddleIter2v4_5", 5.5); 
			elseif (n == 5) then 
				LP_WalkTo(Point(677, 296), 1, 1.0);		
				LP_PlayAnim("Sit1", 1.5, 1, true, false);	
				LP_PlayAnim("Sitting1", 0.4, 4, true, false);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter2v5_1", 8.0); 
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, false);	
			end;
		end;
	elseif Iter == 3 then 
		if LastHistory == "StartIter3" then 
		--приняли в клуб		
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(87, 237), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v1_1", 5.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				 
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				LP_WalkTo(Point(150, 295), 1, 1.0);	

				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v1_2", 3.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				LP_WalkTo(Point(347, 265), 1, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v1_3", 3.0); 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
				LP_WalkTo(Point(534, 287), 1, 1.0);		
				LP_PlayAnim("Joy2", 0.5, 1, true, true);	
				AddTalkWindowToLastAction(1.0, "OstinStartIter3v1Fountain"..p[3], 5.0); 
				if p[3] == 0 and money >= GetPrice(i[3]) then	
					LP_PlayAnim("Tutorial4", 0.4, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter3v1Fountain0_1", 2.5);	
				end;
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);	
				LP_WalkTo(Point(614, 389), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v1Road"..p[2], 5.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter3v1Road0_1", 2.5);	
				end;
			elseif (n == 2) then 
				LP_WalkTo(Point(534, 198), 1, 1.0);		
				LP_PlayAnim("Tutorial1", 0.7, 2, true, false);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v2_1", 5.0); 
				LP_WalkTo(Point(570, 402), 1, 1.0);		
				LP_PlayAnim("Tutorial4", 0.7, 1, true, false);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v2_2", 5.0); 
				LP_PlayAnim("Tutorial2", 0.7, 1, true, false);
				LP_WalkTo(Point(426, 393), 1, 1.0);		
				LP_PlayAnim("Tutorial2", 0.6, 1, true, false);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v2_3", 5.0); 
				LP_WalkTo(Point(293, 220), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v2_4", 5.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				-- Остин ушел в город и ни на что не реагирует
				LP_AddMessageToLastAction(Message("StartOstinMultMode"), 0.0);
				LP_WalkTo(Point(-25, 82), 1, 1.0);		
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_WalkTo(Point(275, 211), 1, 1.0);		
				LP_PlayAnim("Tutorial3", 0.7, 1, true, false);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v2_5", 5.0); 
				LP_AddMessageToLastAction(Message("EndOstinMultMode"), 0.0);
			elseif (n == 3) then 
				LP_WalkTo(Point(408, 384), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_1", 5.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_WalkTo(Point(587, 393), 1, 1.0);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, false);
				AddTalkWindowToLastAction(0.0, "OstinStartIter3v3_2", 5.0); 
				LP_WalkTo(Point(435, 353), 1, 1.0);		
				LP_PlayAnim("ButterflyUpHand1", 1.7, 1, true, false);	
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, false);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_3", 5.0); 
				LP_PlayReversedAnim("ButterflyUpHand1", 1.7, 1, false, false);	
				LP_WalkTo(Point(507, 308), 1, 1.0);		
				LP_PlayAnim("Joy2", 0.5, 1, true, false);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_4", 5.0); 
				LP_PlayAnim("Stay1", 0.7, 1, true, false);
				LP_WalkTo(Point(561, 300), 1, 1.0);		
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3Fountain"..p[3], 5.0);
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				if p[3] == 0 and money >= GetPrice(i[3]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter3v3Fountain0_1", 2.5);	
				end;
				LP_WalkTo(Point(435, 308), 1, 1.0);		
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v3_5", 5.0); 
			elseif (n == 4) then 
				LP_WalkTo(Point(383, 393), 1, 1.0);		
				LP_PlayAnim("Sit1", 1.5, 1, true, true);	
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v4_1", 4.0); 
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v4Road"..p[2], 4.0); 
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v4Fountain"..p[3], 4.0); 
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v4Cage"..p[1], 4.0); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Sitting1", 0.4, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter3v4Cage0_1", 2.5);	
				end;
				LP_PlayAnim("Sitting1", 0.4, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v4_2", 4.0); 
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, true);	
			elseif (n == 5) then 
				LP_WalkTo(Point(650, 407), 1, 1.0);		
				LP_PlayAnim("HandUp1", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v5_1", 4.0); 
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v5_2", 4.0); 
				LP_WalkTo(Point(453, 344), 1, 1.0);		
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinStartIter3v5_3", 3.0); 
			end;
		elseif LastHistory == "MiddleIter3" then 
		--узнал про конкурс
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(266, 278), 1, 1.0);		
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v1_1", 5.0); 
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v1_2", 5.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_WalkTo(Point(257, 501), 1, 1.0);		
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v1_3", 5.0); 
				LP_WalkTo(Point(534, 251), 1, 1.0);		
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v1Fountain"..p[3], 5.0); 
				LP_WalkTo(Point(632, 122), 1, 1.0);		
				AddTalkWindowToLastAction(1.5, "OstinMiddleIter3v1Cage"..p[1], 5.0); 
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v1Sculpture3"..p[4], 5.0); 
				if p[4] == 0 and money >= GetPrice(i[4]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter3v1Sculpture30_1", 2.5);	
				end;
			elseif (n == 2) then 
				LP_WalkTo(Point(668, 433), 1, 1.0);		
				LP_PlayAnim("Sit1", 1.5, 1, true, true);	
				LP_PlayAnim("Sitting1", 0.5, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v2_1", 5.0); 
				LP_PlayAnim("Sitting1", 0.5, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v2_2", 5.0); 
				LP_PlayAnim("Sitting1", 0.5, 2, true, true);	
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v2Sculpture3"..p[4], 5.0); 
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, true);	
			elseif (n == 3) then 
				LP_WalkTo(Point(534, 287), 3, 2.5);		
				LP_WalkTo(Point(525, 247), 3, 2.5);		
				LP_WalkTo(Point(552, 216), 3, 2.5);		
				LP_WalkTo(Point(632, 202), 3, 2.5);		
				LP_WalkTo(Point(686, 229), 3, 2.5);		
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v3_1", 5.0); 
				LP_WalkTo(Point(686, 274), 3, 2.5);		
				LP_WalkTo(Point(668, 292), 3, 2.5);		
				LP_WalkTo(Point(632, 300), 3, 2.5);		
				LP_WalkTo(Point(587, 304), 3, 2.5);		
				LP_WalkTo(Point(534, 287), 3, 2.5);
				LP_WalkTo(Point(534, 287), 3, 2.5);		
				LP_WalkTo(Point(525, 247), 3, 2.5);		
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v3_2", 5.0); 
				LP_WalkTo(Point(552, 216), 3, 2.5);		
				LP_WalkTo(Point(632, 202), 3, 2.5);		
				LP_WalkTo(Point(686, 229), 3, 2.5);		
				LP_WalkTo(Point(686, 274), 3, 2.5);		
				LP_WalkTo(Point(668, 292), 3, 2.5);		
				LP_WalkTo(Point(632, 300), 3, 2.5);		
				LP_WalkTo(Point(587, 304), 3, 2.5);		
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v3Cage"..p[1], 5.0); 
				LP_WalkTo(Point(534, 287), 3, 2.5);
				LP_WalkTo(Point(534, 287), 3, 2.5);		
				LP_WalkTo(Point(525, 247), 3, 2.5);		
				LP_WalkTo(Point(552, 216), 3, 2.5);		
				LP_WalkTo(Point(632, 202), 3, 2.5);		
				LP_WalkTo(Point(686, 229), 3, 2.5);		
				LP_WalkTo(Point(686, 274), 3, 2.5);		
				LP_WalkTo(Point(668, 292), 3, 2.5);		
				LP_WalkTo(Point(632, 300), 3, 2.5);		
				LP_WalkTo(Point(587, 304), 3, 2.5);		
				LP_WalkTo(Point(534, 287), 3, 2.5);
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.7, "OstinMiddleIter3v3_3", 5.0); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
			elseif (n == 4) then 
				LP_WalkTo(Point(51, 254), 3, 1.5);		
				LP_WalkTo(Point(141, 308), 3, 1.5);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, false);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter3v4_1", 5.0); 

				LP_WalkTo(Point(51, 254), 3, 1.5);		
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter3v4_2", 5.0); 
				
				LP_WalkTo(Point(141, 308), 3, 1.5);		
				LP_WalkTo(Point(51, 254), 3, 1.5);		
				LP_WalkTo(Point(141, 308), 3, 1.5);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter3v4Road"..p[2], 5.0); 
			
				LP_WalkTo(Point(320, 251), 3, 1.5);	
				LP_PlayAnim("Tutorial4", 0.7, 3, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter3v4_3", 5.0); 
			elseif (n == 5) then
				LP_WalkTo(Point(480, 429), 3, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter3v5_1", 4.5); 

				LP_WalkTo(Point(293, 265), 3, 1.0);	
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter3v5_2", 4.5);

				LP_WalkTo(Point(204, 289), 3, 1.0);	
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter3v5_3", 4.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);
				AddTalkWindowToLastAction(7.0, "OstinMiddleIter3v5_4", 4.5); 
				
			end;
		end;
	elseif Iter == 4 then 
		if LastHistory == "StartIter4" then 
		--договорился об участии
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(650, 362), 3, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v1_1", 4.5); 
		
				LP_WalkTo(Point(578, 398), 3, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v1_2", 4.5); 
				
				LP_WalkTo(Point(284, 216), 3, 1.0);	
				AddTalkWindowToLastAction(3.0, "OstinStartIter4v1_3", 4.5); 
			elseif (n == 2) then 
				LP_WalkTo(Point(365, 419), 3, 1.0);	
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(1.0, "OstinStartIter4v2_1", 4.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_WalkTo(Point(141, 281), 3, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v2Swing"..p[3], 4.5); 
				if p[3] == 0 and money >= GetPrice(i[3]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter4v2Swing0_1", 2.5);	
				end;
				
				LP_WalkTo(Point(480, 486), 3, 1.0);	
				LP_PlayAnim("ButterflyUpHand1", 1.3, 1, true, false);	
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v2Porch"..p[2], 4.5); 
				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter4v2Porch0_1", 2.5);	
				end;
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, false);	
				LP_PlayReversedAnim("ButterflyUpHand1", 1.3, 1, false, false);	
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v2Bridge"..p[4], 4.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				if p[4] == 0 and money >= GetPrice(i[4]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter4v2Bridge0_1", 2.5);	
				end;
				LP_WalkTo(Point(650, 371), 3, 1.0);	
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v2Golf"..p[1], 4.5); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter4v2Golf0_1", 2.5);	
				end;
				LP_WalkTo(Point(534, 287), 3, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v2_2", 4.5); 
				LP_WalkTo(Point(230, 189), 3, 1.0);	
				LP_PlayAnim("HandUp1", 0.5, 2, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v2_3", 4.5); 
			elseif (n == 3) then 
				LP_WalkTo(Point(338, 242), 3, 1.0);	
				LP_PlayAnim("HandUp1", 0.5, 2, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v3_1", 4.0); 				
				LP_WalkTo(Point(266, 322), 3, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v3_2", 4.5); 				
				LP_WalkTo(Point(365, 423), 0, 1.0);	
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v3_3", 4.5); 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);				
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter4v3_4", 2.0); 
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v3Golf"..p[1], 4.5); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter4v3Golf0_1", 2.5);	
				end;
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				Dog_ClearAction()
				Dog_WalkTo(Point(587, 393), 6, false)
				Dog_PlayAnim("Dog_scratch1", 0.5, 1, false, false);
				Dog_WalkTo(Point(408, 366), 6, false)
				Dog_PlayAnim("Dog_Start_Play_Tail1", -1, 1, false, false);
				Dog_PlayAnim("Dog_Play_Tail1", -1, 10, false, false);
				Dog_PlayAnim("Dog_End_Play_Tail1", -1, 1, false, false);
			elseif (n == 4) then 
				LP_WalkTo(Point(302, 296), 0, 1.0);	
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v4_1", 4.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_WalkTo(Point(239, 483), 0, 1.0);							
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v4_2", 4.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);

				LP_WalkTo(Point(408, 375), 7, 1.0);				
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);			
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v4Golf"..p[1], 4.5); 				
			elseif (n == 5) then 
				LP_WalkTo(Point(668, 292), 0, 1.0);	
				LP_PlayAnim("Sit1", 1.5, 1, true, false);
				LP_PlayAnim("Sitting2", 0.5, 1, true, false);
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v5_1", 4.5); 				
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, false);
				LP_WalkTo(Point(408, 375), 7, 1.0);				
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);			
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v5_2", 4.5); 				
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);			
				LP_WalkTo(Point(587, 393), 7, 1.0);				
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);			
				AddTalkWindowToLastAction(0.5, "OstinStartIter4v5_3", 2.5); 				
			end;
		elseif LastHistory == "MiddleIter4" then 
		--выслушал претензии клуба садоводов
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(338, 242), 3, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 2, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v1_1", 4.0); 			
				LP_WalkTo(Point(275, 211), 3, 1.0);	
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v1Bridge"..p[4], 4.0); 
				if p[4] == 0 and money >= GetPrice(i[4]) then	
					LP_PlayAnim("Tutorial3", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter4v1Bridge0_1", 2.5);	
				end;				
			elseif (n == 2) then 
				LP_WalkTo(Point(347, 362), 3, 1.0);	
				LP_PlayAnim("Tutorial1", 0.7, 2, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v2_1", 4.0); 
				LP_WalkTo(Point(453, 472), 3, 1.0);	
				LP_PlayAnim("ButterflyUpHand1", 1.3, 1, true, false);	
				AddTalkWindowToLastAction(2, "OstinMiddleIter4v2Porch"..p[2], 5);				
				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter4v2Porch0_1", 2.5);	
				end;
				LP_PlayAnim("ButterflyWait1", 0.3, 1, true, false);	
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, false);	
				LP_PlayReversedAnim("ButterflyUpHand1", 1.3, 1, false, false);	
				LP_WalkTo(Point(471, 335), 3, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 2, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v2_2", 4.0); 
				LP_WalkTo(Point(7, 60), 3, 1.0);	
				AddTalkWindowToLastAction(5.0, "OstinMiddleIter4v2_3", 4.0); 
				-- Остин ушел в город и ни на что не реагирует
				LP_AddMessageToLastAction(Message("StartOstinMultMode"), 0.0);
				LP_WalkTo(Point(-20, 60), 3, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 7, true, true);
				LP_WalkTo(Point(204, 289), 0, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v2_4", 4.5); 
				LP_AddMessageToLastAction(Message("EndOstinMultMode"), 0.0);
			elseif (n == 3) then 
				LP_WalkTo(Point(462, 144), 0, 1.0);	
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v3_1", 4.5); 
				LP_PlayAnim("Stay1", 0.5, 2, true, true);
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v3Bridge"..p[4], 4.5); 
				if p[4] == 0 and money >= GetPrice(i[4]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter4v3Bridge0_1", 2.5);	
				end;
				LP_WalkTo(Point(141, 308), 0, 1.5);		
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v3_2", 4.5); 
			elseif (n == 4) then 
				LP_WalkTo(Point(462, 331), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v4_1", 4.5); 
				LP_WalkTo(Point(686, 380), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v4Golf"..p[1], 4.5); 
				LP_WalkTo(Point(105, 290), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v4Swing"..p[3], 4.5); 
				LP_WalkTo(Point(543, 508), 0, 1.0);	
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v4_4", 4.0); 
				LP_WalkTo(Point(498, 486), 0, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v4_5", 4.5); 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
			elseif (n == 5) then 
				LP_WalkTo(Point(650, 407), 0, 1.0);	
				LP_WalkTo(Point(552, 384), 0, 1.0);	
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v5_1", 4.5); 
				LP_WalkTo(Point(516, 393), 0, 1.0);	
				LP_WalkTo(Point(507, 424), 0, 1.0);	
				LP_WalkTo(Point(552, 429), 0, 1.0);	
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v5_2", 4.5); 
				LP_WalkTo(Point(498, 331), 0, 1.0);	
				LP_PlayAnim("Tutorial1", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v5_3", 6.5); 
				LP_WalkTo(Point(275, 274), 0, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v5_4", 3.5); 
				LP_WalkTo(Point(400, 371), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter4v5_5", 3.5); 
			end;
		end;
	elseif Iter == 5 then 
		if LastHistory == "StartIter5" then 
		--выслушал претензии организатора конкурса
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(159, 290), 0, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v1_1", 3.5); 
				LP_WalkTo(Point(96, 277), 0, 1.0);	
				LP_PlayAnim("SwingSat", 0.7, 1, true, false);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v1_2", 3.5); 
				LP_PlayReversedAnim("SwingSat", 0.7, 1, true, false);
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				LP_WalkTo(Point(105, 272), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v1_3", 3.5);
				LP_WalkTo(Point(266, 304), 0, 1.0);	
				LP_PlayAnim("Sit1", 1.5, 1, true, true);
				LP_PlayAnim("Sitting1", 0.5, 3, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v1_4", 3.5); 
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, true);
				LP_WalkTo(Point(462, 477), 0, 1.0);	
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v1SummerHouse"..p[3], 4.5); 
			elseif (n == 2) then 
				LP_WalkTo(Point(668, 353), 0, 1.0);	
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v2_1", 2.5); 
				LP_WalkTo(Point(668, 389), 0, 1.0);	
				LP_WalkTo(Point(766, 420), 0, 1.0);	
				LP_PlayAnim("TakeObj_LD", 0.5, 1, true, false);	
				LP_WalkTo(Point(749, 420), 0, 1.0);	
				LP_PlayAnim("Golf1", 0.5, 1, true, true);
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v2_2", 2.5); 
				LP_WalkTo(Point(623, 384), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v2_3", 4.5); 
				LP_WalkTo(Point(623, 384), 0, 1.0);	
			elseif (n == 3) then 
				LP_WalkTo(Point(356, 423), 0, 1.0);	
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v3_1", 2.5);
				LP_WalkTo(Point(507, 308), 0, 1.0);	
				LP_PlayAnim("Joy2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v3_2", 2.5);
				LP_WalkTo(Point(534, 207), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v3_3", 2.5); 
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v3Pergola"..p[1], 2.5); 
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v3Trees"..p[4], 2.5); 
			elseif (n == 4) then 
				LP_WalkTo(Point(275, 274), 0, 1.0);	
				LP_WalkTo(Point(356, 207), 6, 1.0);	
				AddTalkWindowToLastAction(1.0, "OstinStartIter5v4_1", 2.5); 
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v4_2", 2.5); 
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v4_3", 3.5); 
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v4Pergola"..p[1], 2.5); 
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v4Front"..p[2], 2.5); 
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v4SummerHouse"..p[3], 2.5); 
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v4Trees"..p[4], 4.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
				
			elseif (n == 5) then 
				LP_WalkTo(Point(668, 292), 0, 1.0);	
				LP_PlayAnim("SwingSat", 0.7, 1, true, false);
				LP_PlayReversedAnim("SwingSat", 0.5, 1, true, false);
				LP_PlayAnim("HandUp1", 0.9, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v5_1", 2.5); 
				LP_PlayAnim("HandUp1", 0.9, 2, true, true);
				AddTalkWindowToLastAction(1.0, "OstinStartIter5v5_2", 3.5); 
				LP_WalkTo(Point(632, 176), 0, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(1.0, "OstinStartIter5v5_3", 3.5); 
				LP_WalkTo(Point(392, 375), 8, 1.0);	
				LP_PlayAnim("Joy2", 0.9, 1, true, true);
				AddTalkWindowToLastAction(1.0, "OstinStartIter5v5Pergola"..p[1], 3.5); 
				if p[1] == 0 and money >= GetPrice(i[1]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinStartIter5v5Pergola0_1", 2.5);	
				end;
			end;
		elseif LastHistory == "MiddleIter5" then 
		--подслушал и рассказал
			local n = Random(LastHistory, 1, 5)
			if (n == 1) then 
				LP_WalkTo(Point(96, 277), 0, 1.0);	
				LP_PlayAnim("SwingSat", 0.9, 1, true, false);
				LP_PlayAnim("Swing", 0.9, 3, true, false);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v1_1", 4.5); 
				LP_PlayAnim("Swing", 0.9, 2, true, false);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v1_2", 3.5); 
				LP_PlayAnim("Swing", 0.9, 2, true, false);
				LP_PlayReversedAnim("SwingSat", 0.9, 1, true, false);
				LP_PlayAnim("HandUp1", 0.9, 3, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v1_3", 4.5); 
				LP_WalkTo(Point(453, 472), 3, 1.0);	
				LP_PlayAnim("ButterflyUpHand1", 1.3, 1, true, false);	
				AddTalkWindowToLastAction(2, "OstinMiddleIter5v1Front"..p[2], 5);				
				if p[2] == 0 and money >= GetPrice(i[2]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter5v1Front0_1", 2.5);	
				end;
				LP_PlayAnim("ButterflyWait1", 0.3, 1, true, false);	
				LP_PlayAnim("ButterflyWatch1", 0.4, 1, true, false);	
				LP_PlayReversedAnim("ButterflyUpHand1", 1.3, 1, false, false);	
			elseif (n == 2) then 
				LP_WalkTo(Point(302, 260), 0, 1.0);	
				LP_WalkTo(Point(284, 225), 0, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				LP_WalkTo(Point(426, 126), 0, 1.0);	
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v2_1", 2.5); 
				LP_WalkTo(Point(498, 171), 0, 1.0);	
				LP_WalkTo(Point(525, 238), 0, 1.0);	
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v2_2", 2.5); 
				LP_WalkTo(Point(498, 313), 0, 1.0);	
				LP_WalkTo(Point(302, 260), 7, 1.0);	
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v2_3", 2.5); 
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v2_4", 3.5); 
				
				LP_PlayAnim("TutorialHandUp", 1.3, 1, true, true);
				LP_PlayAnim("TutorialStand", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v2_5", 3.5); 
				LP_PlayReversedAnim("TutorialHandUp", 1.3, 1, true, true);
			elseif (n == 3) then 
				LP_WalkTo(Point(713, 234), 7, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v3_1", 3.5); 
				LP_WalkTo(Point(632, 193), 7, 1.0);	
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v3_2", 3.5); 
				LP_WalkTo(Point(302, 260), 0, 1.0);	
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v3SummerHouse"..p[3], 3.5); 
				if p[3] == 0 and money >= GetPrice(i[3]) then	
					LP_PlayAnim("Tutorial4", 0.7, 1, true, true);	
					AddTalkWindowToLastAction(0, "OstinMiddleIter5v3SummerHouse0_1", 2.5);	
				end;
			elseif (n == 4) then 
				LP_WalkTo(Point(668, 442), 7, 1.0);	
				LP_PlayAnim("Sit1", 1.5, 1, true, true);
				LP_PlayAnim("Sitting2", 0.5, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v4_1", 3.5); 
				LP_PlayAnim("Sitting1", 0.4, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v4_2", 3.5); 
				LP_PlayAnim("Sitting2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v4_3", 3.5); 
				LP_PlayReversedAnim("Sit1", 1.5, 1, true, true);
				LP_WalkTo(Point(498, 313), 0, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v4Front"..p[2], 3.5); 
			elseif (n == 5) then 
				LP_WalkTo(Point(320, 251), 7, 1.0);	
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v5_1", 3.5);
				LP_WalkTo(Point(96, 277), 0, 1.0);	
				LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v5_2", 3.5); 
				LP_PlayAnim("SwingSat", 0.9, 1, true, false);
				LP_PlayAnim("Swing", 0.9, 3, true, false);
				AddTalkWindowToLastAction(0.0, "OstinMiddleIter5v5_3", 3.5); 
				LP_PlayAnim("Swing", 0.9, 3, true, false);
				AddTalkWindowToLastAction(0.0, "OstinStartIter5v5Trees"..p[4], 5.0); 
				LP_PlayAnim("Swing", 0.9, 3, true, false);
				LP_PlayReversedAnim("SwingSat", 0.9, 1, true, false);
			end;
		end;
	end;
end


function StrangeRainAction()
	local v = Random("StrangeRain", 1, 3);
	if v == 1 then
		LP_WalkTo(Point(365, 362), 1, 3.0);
		LP_WalkTo(Point(284, 488), 1, 3.0);
		LP_PlayAnim("Tutorial3", 0.7, 1, true, false);
		AddTalkWindowToLastAction(0, "StrangeRain1_1", 4);				
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);
		LP_WalkTo(Point(525, 283), 1, 3.0);
		AddTalkWindowToLastAction(0, "StrangeRain1_2", 4);				
		LP_WalkTo(Point(543, 220), 1, 3.0);
		LP_PlayAnim("Tutorial2", 0.7, 1, true, false);
		AddTalkWindowToLastAction(0, "StrangeRain1_3", 4);				
		LP_WalkTo(Point(587, 198), 1, 3.0);
		LP_WalkTo(Point(668, 211), 1, 3.0);
		LP_PlayAnim("Tutorial1", 0.7, 1, true, false);
		AddTalkWindowToLastAction(0, "StrangeRain1_4", 4);				
		LP_PlayAnim("Tutorial2", 0.7, 1, true, false);
		LP_WalkTo(Point(686, 238), 1, 3.0);
		LP_WalkTo(Point(659, 287), 1, 3.0);
		LP_PlayAnim("Tutorial1", 0.7, 1, true, false);
		AddTalkWindowToLastAction(0, "StrangeRain1_5", 4);				
		LP_WalkTo(Point(578, 300), 1, 3.0);
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);
		AddTalkWindowToLastAction(0, "StrangeRain1_6", 4);				
		LP_WalkTo(Point(222, 474), 1, 3.0);
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);
		AddTalkWindowToLastAction(0, "StrangeRain1_7", 4);				
	elseif v == 2 then 
		local pondPos = GetPondPos();
		if (pondPos:getBool("FindPoint")) then
			LP_WalkTo(pondPos:getPoint("Pos"), 7, 2.0);
			LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
			AddTalkWindowToLastAction(0.5, "rain3", 2.0); 
		end
	elseif v == 3 then
		if LP_GetPurchaseProgress("Swing") > 0 then 
			LP_FastFinishCurrentBehav();
			LP_ClearTalkAction(0.0);
			LP_WalkTo(Point(338, 396), 1, 3.0);
			LP_PlayAnim("Tutorial3", 0.7, 1, true, false);
			AddTalkWindowToLastAction(0.5, "RainPhrase6", 2.0); 
			AddTalkWindowToLastAction(0.5, "StrangeRainAction3_1", 2.0); 	
			LP_WalkTo(Point(60, 268), 1, 3.0);
			LP_PlayAnim("Tutorial4", 0.7, 1, true, false);
			AddTalkWindowToLastAction(0.5, "StrangeRainAction3_2", 2.0); 	
			LP_RunGoInHouse("BeforeHousePhrases", 5, 0);
		end;
	end;
end;

function LP_LongAction()
	local v = Random ("LongAction", 1, 6)
	if v == 1 and  (LP_GetPurchaseProgress("Gazone") > 0 and LP_GetPurchaseProgress("Bench") > 0) then 
		LP_RunSitting(false, "SittingPhrases");
		AddTalkWindowToLastAction(0.5, "LongAction1_1", 2.0); 
		LP_RunRandomWalking(1, "RandomWalkingPhrases");
		LP_OstinComment(false, false) -- второй false, чтоб не затирать предыдуще действия
		AddTalkWindowToLastAction(0.5, "LongAction1_2", 2.0); 
		LP_RunGoInHouse("BeforeHousePhrases", 5, 0);
		LP_OstinComment(false, false)
		AddTalkWindowToLastAction(0.5, "LongAction1_3", 2.0); 
		LP_RunWatercan("WatercanPhrases");
		RunIdle(1, -1, false);
		AddTalkWindowToLastAction(0.5, "LongAction1_4", 2.0); 
		LP_OstinComment(false, false)
		LP_PlayButterfly();
	elseif v == 2 and LP_GetPurchaseProgress("Swing") > 0 then 
		LP_RunSwing();
		AddTalkWindowToLastAction(0.5, "LongAction2_1", 2.0); 
		LP_RunFeedBird();
		AddTalkWindowToLastAction(0.5, "LongAction2_2", 2.0); 
		LP_RunFeetSwan("FeetSwanPhrases");
		AddTalkWindowToLastAction(0.5, "LongAction2_3", 2.0); 
		LP_RunFeedDog();
		AddTalkWindowToLastAction(0.5, "LongAction2_4", 2.0); 
		LP_OstinComment(false, false)
	elseif v == 3 and  LP_GetPurchaseProgress("Swing") > 0 and LP_GetPurchaseProgress("Golf") > 0 then 
		LP_RunSwing();
		AddTalkWindowToLastAction(0.5, "LongAction3_1", 2.0); 
		LP_OstinComment(false, false)
		LP_RunGolf();
		AddTalkWindowToLastAction(0.5, "LongAction3_2", 2.0); 
		LP_OstinComment(false, false)
		LP_RunGoInHouse("BeforeHousePhrases", 5, 0);
	elseif v == 4 and LP_GetPurchaseProgress("Gazone") > 0 and LP_GetPurchaseProgress("Golf") > 0 and LP_GetPurchaseProgress("Sculpture1") > 0 and LP_GetPurchaseProgress("Sculpture2") > 0 then 
		LP_PlayButterfly();
		RunIdle(1, -1, false);
		LP_OstinComment(false, false)
		AddTalkWindowToLastAction(0.5, "LongAction4_1", 2.0); 
		LP_RunBrush("BrushPhrases");
		LP_OstinComment(false, false)
		AddTalkWindowToLastAction(0.5, "LongAction4_2", 2.0); 
		LP_RunRandomWalking(1, "RandomWalkingPhrases");
		AddTalkWindowToLastAction(0.5, "LongAction4_3", 2.0); 
		LP_RunGolf();	
		LP_OstinComment(false, false)
		LP_RunShears("ShearsPhrases");
	elseif v == 5 and LP_GetPurchaseProgress("Kennel") > 0 and LP_GetPurchaseProgress("Bench") > 0 then 
		LP_RunRandomWalking(1, "RandomWalkingPhrases");
		AddTalkWindowToLastAction(0.5, "LongAction5_1", 2.0); 
		AddTalkWindowToLastAction(0.5, "LongAction5_2", 2.0); 
		LP_RunFeedDog();
		LP_OstinComment(false, false)
		AddTalkWindowToLastAction(0.5, "LongAction5_3", 2.0); 
		LP_RunGoInHouse("BeforeHousePhrases", 7, 0);
		AddTalkWindowToLastAction(0.5, "LongAction5_4", 2.0); 
		AddTalkWindowToLastAction(0.5, "LongAction5_5", 2.0); 
		LP_RunSitting(false, "SittingPhrases");
		AddTalkWindowToLastAction(0.5, "LongAction5_6", 2.0); 
		LP_PlayDog();
		LP_OstinComment(false, false)
	elseif v == 6 and LP_GetPurchaseProgress("Gazone") > 0 and LP_GetPurchaseProgress("Swing") > 0 and LP_GetPurchaseProgress("Golf") > 0 then 
		RunIdle(1, -1, false);
		AddTalkWindowToLastAction(0.5, "LongAction6_1", 2.0); 
		LP_PlayButterfly();
		RunIdle(1, -1, false);
		LP_OstinComment(false, false)
		AddTalkWindowToLastAction(0.5, "LongAction6_2", 2.0); 
		LP_OstinComment(false, false)
		LP_RunSwing();
		AddTalkWindowToLastAction(0.5, "LongAction6_3", 2.0); 
		LP_RunGolf();	
		LP_OstinComment(false, false)
	end;
end;

function LP_Logic()
	local v = math.random(1, 80)
	local x = 0;
	local y = 0;

	x = LP_getX();
	y = LP_getY();
	local Iter = gameInfo:getGardenIter()									-- номер итерации в саду (1 - 5)
	if false then 
		LP_WalkTo(Point(275, 519), 5, 3.5);
		LP_PlayAnim("Joy2", 0.7, 1, true, false);
	elseif math.random(1,5) == 1 and (gameInfo:GetNumberOfPurchase() == 4 and Iter == 1) or (Iter == 2 and gameInfo:GetNumberOfPurchase() == 8) or 
		(Iter == 3 and gameInfo:GetNumberOfPurchase() == 12) or (Iter == 4 and gameInfo:GetNumberOfPurchase() == 16)  
	then 
		HistoryToNewIter();
	elseif (c < 3 and (gameInfo:GetNumberOfPurchase() < 20)) or (c < 3 and (gameInfo:GetNumberOfPurchase() > 20)) then	
		c = c + 1;
		LP_OstinHistory();
	elseif (LP_RunNewAction()) then
	elseif (v > 60 and v < 75) then 
		LP_LongAction();
	elseif (v > 35) and (v < 50) then 
		-- сначала дворецкий со своими напоминаниями об истории
		LP_OstinHistory();
	elseif (v > 12) and (v < 35) then 
		LP_OstinComment(true, true)
	elseif ((LP_GetPurchaseProgress("Gazone") > 0) and (v == 2) and ((x > 605)and (x < 760) and (y > 135) and (y < 350))) then
	-- Ненавижу сорняки!		
		LP_WalkTo(Point(677, 207), 7, 3.0);
		LP_PlayAnim("TakeObj_LD", 1.0, 1, true, false);
		AddTalkWindowToLastAction(0, "strange3", 4);
		LP_WalkTo(Point(766, 216), 6, 1.0);		
		LP_PlayAnim("TakeObj_RD", 1.0, 1, true, false);
	elseif ((LP_GetPurchaseProgress("Front") == 0) and (v == 1) and ((x > 0)and (x < 400) and (y > 400) and (y < 500))) then
	-- Мышеловку и поставлю
		LP_WalkTo(Point(78, 445), 7, 1.0);
		LP_PlayAnim("StayWithObj_U", 2.0, 3, true, false);
		AddTalkWindowToLastAction(0, "strange4", 4);				
		LP_PlayAnim("TakeObj_U", 1.0, 1, true, false);
	elseif (v == 3) then
	-- Делает зарядку  
	-- (LP_GetPurchaseProgress("Road") > 0)
		LP_WalkTo(Point(329, 256), 7, 1.0);
		AddTalkWindowToLastAction(0.0, "strange6_1", 4);
		LP_WalkTo(Point(578, 389), 7, 3.5);
		LP_WalkTo(Point(516, 429), 7, 3.5);
		LP_WalkTo(Point(266, 304), 7, 3.5);
		LP_WalkTo(Point(329, 256), 0, 3.5);
		
		LP_PlayAnim("StayWithObj_LD", 1.0, 3, true, false);
		LP_PlayAnim("Joy2", 0.5, 1, true, false);
		AddTalkWindowToLastAction(0.0, "strange6_2", 4.0); 
		LP_PlayAnim("Joy2", 0.5, 1, true, false);		
		AddTalkWindowToLastAction(0.0, "strange6_3", 2.0); 
		LP_PlayAnim("Joy2", 0.5, 1, true, false);
	elseif ((v == 4) and (LP_GetPurchaseProgress("Porch") == 0) and ((x > 0)and (x < 400) and (y > 400) and (y < 500))) then
	--Давно мне этот листик надоел		
		LP_WalkTo(Point(222, 492), 7, 1.0);
		AddTalkWindowToLastAction(0.0, "strange7", 4.0); 
		LP_PlayReversedAnim("FeetSwan2", 1.0, 1, true, false);

	elseif ((v == 5) and LP_GetPurchaseProgress("Gazone") == 0 and LP_GetPurchaseProgress("Pond") == 0) then
	-- поливает пруд
		LP_WalkTo(Point(453, 229), 0, 1.0);
		AddTalkWindowToLastAction(0.0, "strange8", 4.0);
		LP_PlayAnim("Watercan", 0.1, 3, true, false);
	elseif ((v == 6) and (LP_GetPurchaseProgress("Wall") == 0) ) then
	-- Красит стену		
		LP_WalkTo(Point(444, 503), 1, 1.0);
		AddTalkWindowToLastAction(0.0, "strange9", 4.0);
		LP_PlayAnim("Brush2", 0.5, 1, true, false);
	elseif ((v == 7) and (LP_GetPurchaseProgress("Bench") > 0) and (LP_GetPurchaseProgress("Gazone") == 3)) then
	-- Муравей - ползай тут
		LP_WalkTo(Point(254, 265), 7, 1.0);
		LP_PlayAnim("StayWithObj_LD", 1.0, 1, true, false);
		AddTalkWindowToLastAction(0.0, "strange10_1", 4.0); 
		LP_PlayReversedAnim("FeetSwan2", 0.5, 1, true, false);
		LP_WalkTo(Point(659, 296), 7, 1.0);
		LP_PlayReversedAnim("TakeObj_L", 1.0, 1, true, false);
		AddTalkWindowToLastAction(0.0, "strange10_2", 4.0); 
		LP_PlayAnim("Sit1", 1.5, 1, true, false);
		LP_PlayAnim("Sitting1", 0.4, 3, true, false);
		LP_PlayReversedAnim("Sit1", 1.5, 1, true, false);
	
	elseif (v == 8) then
	-- Говорит о городе	
		LP_WalkTo(Point(123, 144), 1, 1.0);
		LP_PlayAnim("StayWithObj_LD", 1.0, 1, true, false);
		AddTalkWindowToLastAction(0.0, "TownTalk".. math.random(1,10), 4.0); 

	elseif ((v == 9) and (LP_GetPurchaseProgress("Golf") == 0)) then
	-- Садится на камушек и быстро пишет
		LP_WalkTo(Point(740, 353), 5, 3.5);
		LP_PlayAnim("Sit1", 1.5, 1, true, false);	
		LP_PlayAnim("SatToLetter", 1.5, 1, true, false);	
		LP_PlayAnim("Letter", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "strange11", 4.0); 
		LP_PlayAnim("Letter", 0.7, 3, true, false);	
		LP_PlayReversedAnim("SatToLetter", 1.5, 1, true, false);
		LP_PlayReversedAnim("Sit1", 1.5, 1, true, false);
	else	 
		LP_RunRandomBehav();
		
	end	
end


function OnRainBegin(message)
	local t = Random("RainRandom", 1,5);
	local d = math.random(1, 4)
	local time = message:getVariables():getFloat("time");
	local strength = message:getVariables():getFloat("strength");
	LP_FastFinishCurrentBehav();
	if (strength < 0.4) then
		RunIdle(3, -1, false);
		AddPhraseToLastAction(1, "TalkAboutRain", 3);
	elseif d > 2 then
		StrangeRainAction();
	elseif d == 2 then
		if ((t == 1) and (LP_GetPurchaseProgress("SummerHouse") > 0)) then
			TalkPhrase("RainPhrases"); 
			LP_WalkTo(Point(462, 468), 1, 2.0);
			TalkPhrase("RainPhrases"); 
			LP_WalkTo(Point(534, 530), 1, 2.0);
			local t = 7;
			while (t < time-3.0) do 
				RunIdle(t, -1, false);
				AddPhraseToLastAction(1, "TalkAboutSmallRain", t-3);
				t = t + math.random(6.0, 12.0);
			end
			--RunIdle(time-3.0, -1, false);
		elseif ((t == 2) and (strength > 0.7)) then 
			LP_RunGoInHouse("RainPhrases", time-3.0, 0);
			LP_WalkTo(Point(578, 389), 7, 2.0);
			LP_PlayAnim("Joy2", 1.0, 1, true, false);
			AddTalkWindowToLastAction(0.5, "rain3", 2.0); 
			
			LP_WalkTo(Point(614, 481), 7, 2.0);
			LP_PlayAnim("Joy2", 1.0, 1, true, false);
			AddTalkWindowToLastAction(0.5, "rain4", 2.0); 
		
			LP_WalkTo(Point(546, 195), 7, 2.0);
			LP_PlayAnim("Joy2", 1.0, 1, true, false);
			AddTalkWindowToLastAction(0.5, "rain3", 2.0);			
		elseif (strength < 0.5) then
			TalkPhrase("RainPhrases"); 
			LP_WalkTo(Point(230, 488), 1, 2.0);
			local t = 7;
			while (t < time-3.0) do 
				RunIdle(t, -1, false);
				AddPhraseToLastAction(1, "TalkAboutRain", t-3);
				t = t + math.random(6.0, 12.0);
			end
		end;
	else 
		LP_RunGoInHouse("RainPhrases", time-4.0, 0);
	end;

end

function OnRainEnd()
	local pondPos = GetPondPos();
	if (pondPos:getBool("FindPoint")) then
		LP_WalkTo(pondPos:getPoint("Pos"), 7, 2.0);
		LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.5, "rain3", 2.0); 
	end
end

numPrevClickPhrase = -1;

function NewRand(min, max)
	local rand = math.random(min,max);
	while (numPrevClickPhrase == rand) do
		rand = math.random(min,max);
	end
	numPrevClickPhrase = rand	
	return rand
end

count = 0;
n = 0;

function OnClick(message)
	local time = message:getVariables():getFloat("TimeFromLastClick");
	local CurState = LP_GetState();
	local v = math.random(1, 7);
	n = n+1;
	if (n > 10) then 	
		n = 0;
		LP_ClearTalkAction(0.5);
		TalkPhrase("Click10Phrases"); 
				
	else
	
	if (IsRain()) then
		LP_ClearTalkAction(0.5);
		local clickPhrase = ""
		if (n < 5) then
			local rand = NewRand(1, 5);
			clickPhrase = "ClickRain_"..rand;
		elseif (n < 10) then 
			local rand = NewRand(1, 4);
			clickPhrase = "ClickRain5_"..rand;
		else 
			clickPhrase = "ClickRain10_1";
		end
		ShowTalkWindow(clickPhrase, 3);
		
	else
		local state = "";
		
		if (CurState == "GoInHouse" or CurState == "Talk" or CurState == "StayAndThink") then
			state = "";
		elseif (CurState == "RandomWalking" and math.random(1, 3) == 1) then		
			state = "";
		else 
			state = "Click" .. CurState .. Random("Click"..CurState, 1,5);
		end;

		if (time < 0.7) then count = count + 1; 
		else 
			count = 0; 
		end;

			if (count > 4 and CurState ~= "Phone") then
				LP_ClearTalkAction(0.5);
				LP_FastFinishCurrentBehav();
				TalkPhrase("DoubleClickPhrases2"); 
				LP_RunGoInHouse("DoubleClickPhrases1", 10, 0)
			
			else
				LP_ClearTalkAction(0.5);
				if (CurState == "Talk" or CurState == "Stay") then
					if (math.random(0, 1) == 0) then
						state = ""
					end 
				end
				
				if (state ~="") then 
					ShowTalkWindow(state, 3);
				elseif (v == 1)  then
					LP_FastFinishCurrentBehav();
					TalkPhrase("HandUpPhrases"); 
					LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);
			
				elseif (v == 2) then
					LP_FastFinishCurrentBehav();
					TalkPhrase("HandUpPhrases"); 
					LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, false); 
				else 	
					LP_FastFinishCurrentBehav();
					TalkPhrase("HandUpPhrases"); 
					LP_PlayAnim("HandUp1", math.random(70, 200)/100.0, math.random(1,4), true, true);										
				end;
			end;

		end;
	end;
end;


function LP_InMainMenu()
	c = 0
	local rand = Random("MainMenuAction",1, 6)
	local d = 0;
	local m = 0;
	local Level = gameInfo:getLocalIntOrDef("GardenLevelNumber",0)		
	
	
	SetEnableRain(false);	
	if (IsRain()) then
		
	else
		if (rand > 6) then 
		--говорит о скринсейвере
	
		elseif ((rand == 6) and math.random(1,4) == 1) then
			local CurT = GetCurTime();
			local PrevT = GetPrevTime();
			if CurT:getInt("Hour") > 20 or CurT:getInt("Hour") < 6 then 
				RunIdle(4, 7, true);
				LP_AddTalkAction(0.5, "OstinAboutTime1", 6.0, false); 	
			end;
			
			if (PrevT:getInt("Month") <= CurT:getInt("Month")) then 
				m = CurT:getInt("Month") - PrevT:getInt("Month");
			else
				m = 12 - PrevT:getInt("Month") - CurT:getInt("Month");
			end;
			if m == 0 then 
				d = CurT:getInt("Day")-PrevT:getInt("Day");
				if d == 0 then 
					if (CurT:getInt("Hour") < 12 and CurT:getInt("Hour") - PrevT:getInt("Hour")>8) then 
						RunIdle(4, 7, true);
						LP_AddTalkAction(0.5, "OstinAboutTime2_2", 6.0, false); 	
					elseif (CurT:getInt("Hour") > 18 and CurT:getInt("Hour") - PrevT:getInt("Hour")>8) then 
						RunIdle(4, 7, true);
						LP_AddTalkAction(0.5, "OstinAboutTime2_1", 6.0, false); 	
					end;
				elseif d < 4 then 
					RunIdle(4, 7, true);
					LP_AddTalkAction(0.5, "OstinAboutTime2_3", 6.0, false); 	
				elseif d < 8 then 
					RunIdle(4, 7, true);
					LP_AddTalkAction(0.5, "OstinAboutTime2_4", 6.0, false); 	
				elseif d < 15 then 
					RunIdle(4, 7, true);
					LP_AddTalkAction(0.5, "OstinAboutTime2_5", 6.0, false); 	
				end;
			elseif m < 3 then
				RunIdle(4, 7, true);
				LP_AddTalkAction(0.5, "OstinAboutTime2_6", 6.0, false); 	
			elseif m < 4 then 
				RunIdle(4, 7, true);
				LP_AddTalkAction(0.5, "OstinAboutTime2_7", 6.0, false); 	
			elseif m < 7 then 
				RunIdle(4, 7, true);
				LP_AddTalkAction(0.5, "OstinAboutTime2_9", 6.0, false); 	
			else
				RunIdle(4, 7, true);
				LP_AddTalkAction(0.5, "OstinAboutTime2_8", 6.0, false); 	
			end;			
		elseif (rand == 1) then	
			LP_WalkTo(Point(561, 211), 1, 1.0);		
			LP_PlayAnim("Sit1", 1.5, 1, true, false);	
			LP_PlayAnim("Sitting2", 0.3, 2, true, false);
			AddTalkWindowToLastAction(0.5, "OstinInMainMenu"..Random("OstinInMainMenu", 1, 7), 6.0); 
			LP_PlayReversedAnim("Sit1", 1.5, 1, true, false);
		elseif (rand == 2) then
			LP_WalkTo(Point(668, 220), 1, 1.0);		
			LP_PlayAnim("Sit1", 1.5, 1, true, true);	
			LP_PlayAnim("Sitting2", 0.3, 2, true, true);
			AddTalkWindowToLastAction(0.5, "OstinInMainMenu"..Random("OstinInMainMenu", 1, 7), 6.0); 
			LP_PlayReversedAnim("Sit1", 1.5, 1, true, true);
		elseif (rand == 3) then
			LP_WalkTo(Point(632, 95), 7, 1.0);
			LP_PlayAnim("Joy2", 0.7, 1, true, true);
			AddTalkWindowToLastAction(0.5, "ThisIsStartButton"..Random("ThisIsStartButton", 1, 9), 6.0); 
			RunIdle(4, 7, true);
		elseif (rand == 4) then
			if (math.random(1,2) == 1) then 
				LP_WalkTo(Point(392, 109), 1, 1.0);
				LP_PlayAnim("ButterflyUpHand1", 1.3, 1, true, false);
				LP_PlayAnim("ButterflyWait1", 0.3, 1, true, false);	
				AddTalkWindowToLastAction(0.0, "ThisIsOptionsButton"..Random("ThisIsOptionsButton", 1, 5), 6.0); 
				LP_PlayAnim("ButterflyWatch1", 0.3, 1, true, false);	
				LP_PlayReversedAnim("ButterflyUpHand1", 1.3, 1, false, false);	
			end;
			if (Level > 3 and math.random(1,2) == 1) then 
				LP_WalkTo(Point(338, 82), 1, 1.0);
				LP_PlayAnim("ButterflyUpHand1", 1.3, 1, true, false);
				LP_PlayAnim("ButterflyWait1", 0.3, 1, true, false);	
				AddTalkWindowToLastAction(0.0, "ThisIsSS1Button"..Random("ThisIsSS1Button", 1, 3), 5.0); 
				LP_PlayAnim("ButterflyWatch1", 0.3, 1, true, false);	
				LP_PlayReversedAnim("ButterflyUpHand1", 1.3, 1, false, false);	
				AddTalkWindowToLastAction(0.0, "ThisIsSS2Button"..Random("ThisIsSS2Button", 1, 3), 5.0); 
				LP_PlayAnim("Tutorial4", 0.7, 1, true, true);
				LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
			end;
		elseif (rand == 5) then
			LP_WalkTo(Point(525, 220), 1, 1.0);
			LP_WalkTo(Point(695, 234), 1, 1.0);
			LP_WalkTo(Point(578, 300), 1, 1.0);
			LP_WalkTo(Point(525, 220), 1, 1.0);
			RunIdle(4, 1, false);
			AddTalkWindowToLastAction(0.5, "WhatDo"..Random("WhatDo", 1, 1), 6.0); 
		end;	
	end;
end;

function LP_InMult()	
	local Iter = gameInfo:getGardenIter();
	
	local i = GetI(Iter);

	local v = {0, 0, 0, 0};
	for j = 1, 4 do 
		if (LP_GetPurchaseProgress(i[j]) > 0) then v[j] = 0 else v[j] = 1; end;
	end; 

	local nameMult = gameInfo:getLocalStringOrDef("NameMult", "")
	gameInfo:setLocalString("NameMult", "")
	if (nameMult == "StartIter2Mult2") then 
		LP_FastFinishCurrentBehav();
		LP_ClearTalkAction(0.0);
		LP_SetPosition(Point(222, 483))
		LP_PlayReversedAnim("PhoneTake", 0.5, 1, true, false);	
		LP_PlayAnim("HandUp1", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.5, "OstinAddHistStartIter2_1", 8.0); 
		LP_WalkTo(Point(284, 474), 7, 1.0);		
		LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.5, "OstinAddHistStartIter2_2", 8.0); 
		LP_WalkTo(Point(489, 424), 7, 1.0);		
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.5, "OstinAddHistStartIter2_3", 8.0); 
		LP_WalkTo(Point(668, 292), 7, 1.0);		
		LP_PlayAnim("Sit1", 0.7, 1, true, false);	
		LP_PlayAnim("Sitting1", 0.5, 6, true, false);	
		AddTalkWindowToLastAction(0.1, "OstinAddHistStartIter2_5", 8.0); 
		AddTalkWindowToLastAction(0.1, "OstinAddHistStartIter2_6", 8.0); 
		AddTalkWindowToLastAction(0.1, "OstinAddHistStartIter2_7", 8.0); 
		AddTalkWindowToLastAction(0.1, "OstinAddHistStartIter2_8", 8.0); 
		LP_PlayReversedAnim("Sit1", 0.7, 1, true, false);	
		LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.1, "OstinAddHistStartIter2_9", 8.0);
	elseif (nameMult == "MiddleIter3Mult1") then 
		LP_FastFinishCurrentBehav();
		LP_ClearTalkAction(0.0);
		LP_SetPosition(Point(51, 100))
		RunIdle(1, -1, false);
		LP_PlayAnim("HandUp1", 1, 1, true, false);	
		AddTalkWindowToLastAction(2.0, "OstinAddHistMiddleIter3_9", 8.0); 
		LP_WalkTo(Point(16, 73), 7, 1.0);	
		LP_PlayReversedAnim("SentLetter", 0.5, 1, true, false);	
		LP_WalkTo(Point(311, 247), 7, 1.0);	
		AddTalkWindowToLastAction(2.0, "OstinAddHistMiddleIter3_1", 8.0); 
		AddTalkWindowToLastAction(4.0, "OstinAddHistMiddleIter3_2", 8.0); 
		LP_WalkTo(Point(650, 292), 7, 1.0);	
		LP_PlayAnim("Sit1", 1.2, 1, true, false);	
		LP_PlayAnim("SatToLetter", 1.2, 1, true, false);	
		LP_PlayAnim("Letter", 0.5, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistMiddleIter3_3", 8.0); 
		LP_PlayAnim("Letter", 0.5, 1, true, false);	
		AddTalkWindowToLastAction(0.5, "OstinAddHistMiddleIter3_4", 8.0); 
		LP_PlayAnim("Letter", 0.5, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistMiddleIter3_5", 8.0); 
		LP_PlayAnim("Letter", 0.5, 2, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistMiddleIter3_6", 8.0); 
		LP_PlayReversedAnim("SatToLetter", 1.2, 1, true, false);	
		LP_PlayAnim("Sitting1", 0.7, 1, true, false);	
		LP_PlayAnim("SatToLetter", 1.2, 1, true, false);	
		LP_PlayAnim("Letter", 0.5, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistMiddleIter3_7", 8.0); 
		LP_PlayAnim("Letter", 0.5, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistMiddleIter3_8", 8.0); 
		LP_PlayAnim("Letter", 0.5, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistMiddleIter3_9", 8.0); 
		LP_PlayReversedAnim("SatToLetter", 1.2, 1, true, false);	
		LP_PlayReversedAnim("Sit1", 1.2, 1, true, false);	
		LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
	elseif (nameMult == "StartIter4Mult1") then 
		local s
		if LP_GetPurchaseProgress("Golf") == 0 then 
			s =  "OstinAddHistStartIter4_3_0"
		else
			s =  "OstinAddHistStartIter4_3_1"
		end;
		LP_SetPosition(Point(666, 295))
		LP_PlayAnim("Sitting1", 0.7, 3, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistStartIter4_1", 7.0); 
		LP_PlayReversedAnim("Sitting1", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistStartIter4_2", 7.0); 
		LP_PlayReversedAnim("Sit1", 0.7, 1, true, false);	
		LP_WalkTo(Point(408, 384), 7, 1.0);		
		AddTalkWindowToLastAction(0.0, s, 7.0); 
		LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistStartIter4_4", 7.0); 
		LP_WalkTo(Point(150, 590), 7, 1.0);		
		RunIdle(1, -1, false);
		LP_WalkTo(Point(275, 444), 7, 1.0);		
		LP_PlayAnim("PaperOpen", 0.7, 1, true, false);	
		LP_PlayAnim("PaperRead", 0.5, 2, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinAddHistStartIter4_5", 7.0); 
		LP_PlayReversedAnim("PaperOpen", 0.7, 1, true, false);	
		LP_PlayAnim("PaperUp", 0.7, 1, true, false);	
	elseif (nameMult == "StartIter4Mult2") then 
		local s
		if LP_GetPurchaseProgress("Swing") == 0 then 
			s =  "StartIter4Mult2_4_0"
		else
			s =  "StartIter4Mult2_4_1"
		end;
		LP_FastFinishCurrentBehav();
		LP_ClearTalkAction(0.0);
		LP_SetPosition(Point(222, 483))
		RunIdle(0.5, -1, false);
		AddTalkWindowToLastAction(0.0, "StartIter4Mult2_1", 7.0); 
		LP_PlayReversedAnim("PhoneTake", 0.5, 1, true, false);	
		LP_WalkTo(Point(400, 371), 7, 1.0);		
		AddTalkWindowToLastAction(0.0, "StartIter4Mult2_2", 7.0); 
		LP_WalkTo(Point(230, 352), 7, 1.0);		
		AddTalkWindowToLastAction(0.0, "StartIter4Mult2_3", 7.0); 
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, s, 7.0); 
		LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
		LP_WalkTo(Point(123, 219), 7, 1.0);		
		LP_PlayAnim("Tutorial1", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "StartIter4Mult2_5", 7.0); 
		LP_WalkTo(Point(329, 247), 7, 1.0);		
		LP_PlayAnim("Tutorial2", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "StartIter4Mult2_6", 7.0); 
		LP_WalkTo(Point(275, 492), 7, 1.0);		
		LP_PlayAnim("Tutorial1", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "StartIter4Mult2_7", 7.0); 
		LP_RunGoInHouse("BeforeHousePhrases", 3, 0);
	elseif (nameMult == "StartIter5Mult1") then 
		local s
		if LP_GetPurchaseProgress("SummerHouse") == 0 then 
			s = "SummerHouse"
		elseif LP_GetPurchaseProgress("Pergola") == 0 then 
			s = "Pergola"
		elseif LP_GetPurchaseProgress("Front") == 0 then 
			s = "Front"
		elseif LP_GetPurchaseProgress("Trees") == 0 then 
			s = "Trees"
		end;
		LP_FastFinishCurrentBehav();
		LP_ClearTalkAction(0.0);
		LP_SetPosition(Point(7, 68))
		RunIdle(1, -1, false);
		LP_WalkTo(Point(123, 219), 7, 1.0);		
		LP_PlayAnim("Tutorial4", 0.5, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "StartIter5Mult1_1", 7.0); 
		LP_WalkTo(Point(105, 272), 7, 1.0);		
		LP_PlayAnim("SwingSat", 0.7, 1, true, false);
		LP_PlayAnim("Swing", 0.7, 5, true, false);
		AddTalkWindowToLastAction(0.0, "StartIter5Mult1_2", 7.0); 
		AddTalkWindowToLastAction(0.0, "StartIter5Mult1_3"..s, 7.0); 
		AddTalkWindowToLastAction(0.0, "StartIter5Mult1_4", 7.0); 
		LP_PlayReversedAnim("SwingSat", 0.7, 1, true, false);
		LP_WalkTo(Point(347, 256), 7, 1.0);		
		LP_PlayAnim("Tutorial3", 0.7, 1, true, false);
		AddTalkWindowToLastAction(0.0, "StartIter5Mult1_5", 7.0); 
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);
	elseif (nameMult == "MiddleIter5Mult1") then  
		local s = 1-v[1]..1-v[2]..1-v[3]..1-v[4];
		s = "OstinMiddleIter5Mult_9"..s
		LP_SetPosition(Point(668, 292))
		RunIdle(2, -1, true);
		LP_PlayAnim("Tutorial4", 1.0, 1, true, false);
		AddTalkWindowToLastAction(0.0, "OstinMiddleIter5Mult_1", 8.0); 
		LP_PlayAnim("Sit1", 1.0, 1, true, false);
		LP_PlayAnim("Sitting1", 1.0, 1, true, false);
		LP_PlayAnim("SatToLetter", 1.0, 1, true, false);
		LP_PlayAnim("Letter", 1.0, 1, true, false);
		AddTalkWindowToLastAction(0.0, "OstinMiddleIter5Mult_2", 8.0); 
		LP_PlayAnim("Letter", 1.0, 1, true, false);
		LP_PlayReversedAnim("SatToLetter", 2.0, 1, true, false);
		LP_PlayAnim("SatToLetter", 3.0, 1, true, false);
		LP_PlayAnim("Letter", 1.0, 1, true, false);
		AddTalkWindowToLastAction(0.0, "OstinMiddleIter5Mult_3", 8.0); 
		LP_PlayAnim("Letter", 1.0, 1, true, false);
		LP_PlayReversedAnim("SatToLetter", 1.0, 1, true, false);
		LP_PlayReversedAnim("Sit1", 1.0, 1, true, false);
		LP_WalkTo(Point(96, 277), 7, 1.0);	
		AddTalkWindowToLastAction(2.0, "OstinMiddleIter5Mult_5", 8.0); 
		AddTalkWindowToLastAction(0.0, "OstinMiddleIter5Mult_6", 8.0); 
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, "OstinMiddleIter5Mult_7", 8.0); 
		AddTalkWindowToLastAction(0.0, "OstinMiddleIter5Mult_8", 8.0); 
		LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
		LP_PlayAnim("SwingSat", 0.7, 1, true, false);	
		LP_PlayAnim("Swing", 0.7, 1, true, false);	
		LP_PlayAnim("SatToLetter", 1.0, 1, true, true);
		LP_PlayAnim("Letter", 1.0, 1, true, true);
		AddTalkWindowToLastAction(0.0, "OstinMiddleIter5Mult_4", 8.0); 
		LP_PlayAnim("Letter", 1.0, 4, true, true);
		LP_PlayReversedAnim("SatToLetter", 1.0, 1, true, true);
		LP_PlayReversedAnim("Sit1", 1.2, 1, true, true);	
		LP_PlayAnim("Tutorial1", 0.7, 1, true, false);	
		AddTalkWindowToLastAction(0.0, s, 8.0); 
		LP_PlayAnim("Tutorial3", 0.7, 1, true, false);	
		LP_PlayAnim("Tutorial4", 0.7, 1, true, false);	
		LP_WalkTo(Point(132, 140), 7, 1.0);	
		LP_WalkTo(Point(25, 68), 7, 1.0);	
		LP_PlayAnim("SentLetter", 0.5, 1, true, false);	
	end
	RunIdle(1, 7, true);
	LP_AddMessageToLastAction(Message("EndMultMode"), 0.0);
end;

function CreditsObjFunc(message)
	local iter = message:getVariables():getInt("iter");
	local pos = message:getVariables():getPoint("posObj");
	if (iter == 0) then
	elseif (iter == 1) then
	elseif (iter == 2) then
		Dog_SetPosition(Point(600, 150));
		Dog_PlayAnim("Dog_sat_tail0", 1, 10, false, false);
		
		LP_SetPosition(Point(50, 250));
		LP_WalkTo(Point(230, 250), 7, 2.0);
		LP_PlayAnim("Joy2", 0.7, 1, true, true);
		LP_PlayAnim("Joy2", 0.7, 1, true, true);
		RunIdle(10, 7, true);
	elseif (iter == 3) then
		pos = AddPoints(pos, Point(0, 30));
		LP_SetPosition(pos);
		LP_PlayAnim("Brush2", 0.6, 10, true, true);
	elseif (iter == 4) then
		Dog_SetPosition(Point(600, 280));
		Dog_PlayAnim("Dog_start_play0", -1, 1, false, false);
		Dog_PlayAnim("Dog_stand_tail0", -1, 10, false, false);
		Dog_PlayAnim("Dog_start_play0", -1, 1, true, false);
		Dog_PlayAnim("Dog_sat0", -1, 1, false, false);		
		Dog_PlayAnim("Dog_sat_tail0", 1, 10, false, false);
		
		pos = AddPoints(pos, Point(100, 30));
		LP_SetPosition(pos);
		LP_PlayAnim("Shears2", 0.7, 10, true, false);
	elseif (iter == 5) then
		Dog_SetPosition(Point(200, 250));
		Dog_PlayAnim("Dog_Shake0", -1, 1, false, false);
		Dog_PlayAnim("Dog_sat0", -1, 1, false, false);		
		Dog_PlayAnim("Dog_sat_tail0", 1, 10, false, false);
		LP_SetPosition(Point(700, 250));
		LP_WalkTo(Point(640, 250), 1, 2.0);
		LP_PlayAnim("Joy2", 0.7, 1, true, false);
		LP_PlayAnim("Joy2", 0.7, 1, true, false);
		RunIdle(10, 1, false);
	elseif (iter == 6) then
		Dog_SetPosition(Point(300, 100));
		Dog_WalkTo(Point(500, 100), 6, false);
		Dog_PlayAnimAndMessage("Dog_take_palka_down6", 1, Message("TakePalka"), false, true);
		Dog_PlayAnim("Dog_take_palka_up6", 0.7, 1, false, true);
		Dog_WalkTo(Point(200, 100), 1, false);
		Dog_PlayAnim("Dog_sat_palka2", -1, 1, false, false);
		Dog_PlayAnim("Dog_sat_tail2", 1, 10, false, false);		
		
		LP_SetPosition(Point(150, 250));
		LP_PlayAnim("HandUp1", 0.7, 10, true, false);
	elseif (iter == 7) then
		LP_SetPosition(Point(200, 350));
		local n = 2;
		while (n > 0) do 
			LP_PlayAnim("Tutorial1", 0.7, 1, true, true);
			LP_PlayAnim("Tutorial2", 0.7, 1, true, true);
			LP_PlayAnim("Tutorial3", 0.7, 1, true, true);
			n = n - 1;
		end
	elseif (iter == 8) then
		LP_SetPosition(Point(150, 230));
		LP_PlayButterfly();
	elseif (iter == 9) then
		Dog_SetPosition(Point(300, 400));
		Dog_WalkTo(Point(500, 400), 2, false);
		
	elseif (iter == 10) then
		Dog_SetPosition(Point(620, 250));
		Dog_PlayAnim("Dog_sat_tail3", 1, 10, false, false);
		pos = AddPoints(pos, Point(40, 25));
		LP_SetPosition(pos);
		LP_PlayAnim("SatToLetter", 1.4, 1, true, false);
		LP_PlayAnim("Letter", 0.7, 10, true, false);
	elseif (iter == 11) then
		pos = AddPoints(pos, Point(80, 50));
		LP_SetPosition(pos);
		LP_PlayAnim("Watercan", 0.1, 5, true, false);
	elseif (iter == 12) then
		Dog_SetPosition(Point(200, 150));
		Dog_WalkTo(Point(600, 150), 6, true);
		
		LP_SetPosition(Point(130, 250));
		LP_PlayAnim("HandUp1", 0.7, 10, true, false);
	elseif (iter == 13) then
		Dog_SetPosition(Point(200, 250));
		Dog_PlayAnim("Dog_prepare_scratch0", -1, 1, false, false);
		Dog_PlayAnim("Dog_scratch0", 2, 10, false, false);
		Dog_PlayAnim("Dog_prepare_scratch0", -1, 1, true, false);
		Dog_PlayAnim("Dog_sat_tail0", 1, 10, false, false);
		
		pos = AddPoints(pos, Point(60, 15));
		LP_SetPosition(pos);
		LP_PlayAnim("PhoneHand", 2.0, 1, true, false);
		LP_PlayAnim("PhoneNabor", 2.0, 5, true, false);
		local n = 3;
		while (n > 0) do 		
			LP_PlayAnim("PhoneTalk0", 0.7, 1, true, false);
			LP_PlayAnim("PhoneTalk1", 0.7, 1, true, false);
			LP_PlayAnim("PhoneTalk2", 0.7, 1, true, false);
			n = n - 1;
		end
	elseif (iter == 14) then
		Dog_SetPosition(Point(600, 250));
		Dog_PlayAnim("Dog_Start_Play_Tail1", -1, 1, false, false);
		Dog_PlayAnim("Dog_Play_Tail1", -1, 10, false, false);	
	elseif (iter == 15) then
		LP_SetPosition(Point(400, 150));
		LP_PlayAnim("HandUp1", 0.7, 10, true, false);	
	end;
end;

function LP_ScreenSaver()
	LP_RunRandomBehav();
end;
