--------------------------------------------------------
--5Σûнӳɹ
-----------------------------------------------
function ܳ(ID)
	local ܳ = 0;
	while Ƿ("",ID) == 0 and ܳ < 5 do		
		(ID);
		ʱ(1000)		
		ܳ = ܳ+1;				
		("ܳ:" ..ܳ);
	end;
	if Ƿ("",ID) == 1 or (ܳ > 4 or Ƿ("",ID) == 0) then			
		ֵ = 1;
	end;
	return ֵ;
end
-----------------------------------------------
--һɫ
function Զܳ縱()
	if ͼID() == 11102 or ͼID() == 11401  then 							--
		("============Զܳ縱==============================");
		----------------------------------------------------------------------------
		ýű("\\ܼӵ滻.txt");
		----------------------------------------------------------------------------
		ֽƷ(3);
		if Ʒ("ʷʫҩˮ") < 60 and װ() < 600  then
			if ͼID() == 11102 then
				ʼܴ();
				(14215.00,8324.00,4262.41,600,60,1);
				(20142.16,13417.78,4910.00,600,60,1);
				ܴ();
				if 귶Χ(20142.16,13417.78) < 100 then
					Ʒ("Magick Scholar Ethan",3, 200 - Ʒ("ʷʫҩˮ"));  	
				end;
			elseif ͼID() == 11401 then
				Ѱ·(-12820.00,3075.00,489.64);
				if 귶Χ(-12820.00,3075.00) < 100 then
					Ʒ("Sandra",3, 200 - Ʒ("ʥҩˮ"));  	
				end;			
			end;
		elseif װ() < 1302 and װ() >= 600 and (Ʒ("ʥҩˮ") +Ʒ("ʷʫҩˮ")) < 60 then
			if ͼID() == 11102 then
				ʼܴ();
				(14215.00,8324.00,4262.41,600,60,1);
				(20142.16,13417.78,4910.00,600,60,1);
				ܴ();
				if 귶Χ(20142.16,13417.78) < 100 then
					Ʒ("Magick Scholar Ethan",6, 100 - Ʒ("ʥҩˮ"));  	
				end;
			elseif ͼID() == 11401 then
				Ѱ·(-12820.00,3075.00,489.64);
				if 귶Χ(-12820.00,3075.00) < 100 then
					Ʒ("Sandra",6, 100 - Ʒ("ʥҩˮ"));  	
				end;			
			end;
		elseif (Ʒ("ǹҩˮ") +Ʒ("ףҩˮ")+Ʒ("ʥҩˮ") +Ʒ("ʷʫҩˮ")) < 30 and װ() >= 1302  then	
			if ͼID() == 11102 then
				ʼܴ();
				(14215.00,8324.00,4262.41,600,60,1);
				(20142.16,13417.78,4910.00,600,60,1);
				ܴ();
				if 귶Χ(20142.16,13417.78) < 100 then
					Ʒ("Magick Scholar Ethan",9, 100 - Ʒ("ףҩˮ"));  	
				end;
			elseif ͼID() == 11401 then
				Ѱ·(-12820.00,3075.00,489.64);
				if 귶Χ(-12820.00,3075.00) < 100 then
					Ʒ("Sandra",9, 100 - Ʒ("ףҩˮ"));  	
				end;			
			end;
		elseif Ʒ(" : Ƭ") < 40 then				--Awakening: Chaos Shard
			if ͼID() == 11102 then
				ʼܴ();
				(19519.00,11881.00,4764.15,600,60,1);
				ܴ();
				if 귶Χ(19519.00,11881.00) < 100 then
					Ʒ("˹",1, 100 - Ʒ(" : Ƭ"));  	--
					Ʒ("Marrain",1, 100 - Ʒ(" : Ƭ"));  	--
				end;
			elseif ͼID() == 11401 then
				Ѱ·(-12717.00,3558.00,488.00);
				if 귶Χ(-12717.00,3558.00) < 100 then
					Ʒ("Blith",5, 100 - Ʒ(" : Ƭ"));  	--
				end;			
			end;
		elseif װ־(0) < 8000 or װ־(1) < 1000 or װ־(2) < 1000 or װ־(3) < 1000 or װ־(4) < 1000 then
			if ͼID() == 11102 then
				ʼܴ();
				(19484.00,14576.00,4911.00,600,60,1);
				ܴ();
				if 귶Χ(19484.00,14576.00)<100 then
					ȫ("");
					ȫ("Winry");
				end;
			elseif ͼID() == 11401 then
				Ѱ·(-17407.00,5076.00,488.00);
				if 귶Χ(-17407.00,5076.00)<100 then
					ȫ("Akena");
				end;			
			end;
		else
			if Զƥ丱 == 1 then
				if װ() < 600 then
					볡();					--
				elseif װ() < 1100 then
					볡(9);				--Լ
				elseif װ() >= 1100 then
					볡(17)				--Ῠ
				end;				
			elseif Զƥ丱 ==  0 then
				볡();
			elseif Զƥ丱 > 1 and Զƥ丱 < 20 then
				볡(Զƥ丱);
				ʱ(3000);
			end;
		end;		
	else
		ýű("\\θܳ.txt");
	end;
end;
-----------------------------------------------
Զƥ丱 	= 1;					--0 ֻˢ1 1-Զƥ ֵ-ָ帱 (1-4) Ӱ(5-8)...
-----------------------------------------------
ڲ 		 = 2;						--0 ˢܳԶӸڲ 1-ˢܳҲڲ 2-ڲܳɣ˳
ܳ = 1;						--
----------------------------------------------------------------------------
жϵͼ(0);
(1);
-----------------------------------------------
(0);
(1,1000);
-----------------------------------------------
if ǰְҵ() == 0xCD then
	(3,"˪|A,ܻ|Q,|F,|R,׵|W,|E,ߵĺХ|D,|S,չ|C");
else
	(3,"|W,ն|Q,ն|F,һ|R,ѵն|A,ն|E,ն|D,޽籩|S,չ|C");
end;
-----------------------------------------------
(1);
if װ() < 600 then
	(1,"ʷʫҩˮ",80);
	if Ʒ("ؼҩˮ") > 0 then
		(2,"ؼҩˮ",80);
	elseif Ʒ("ǿҩˮ")>0 then
		(2,"ǿҩˮ",70);
	else	
		(2,"",0);
	end;
elseif װ() < 1302 and װ() >= 600 then
	(1,"ʥҩˮ",80);
	if Ʒ("ʷʫҩˮ") > 0 then
		(2,"ʷʫҩˮ",80);
	elseif Ʒ("ǿҩˮ")>0 then
		(2,"ǿҩˮ",80);
	elseif Ʒ("ףҩˮ")>0 then
		(2,"ףҩˮ",70);			
	else	
		(2,"",0);
	end;	
elseif װ() >= 1302 then
	(1,"ǹҩˮ",70);
	if Ʒ("ʷʫҩˮ")>0 then
		(2,"ʷʫҩˮ",80);		
	elseif Ʒ("ǿҩˮ") > 0 then
		(2,"ǿҩˮ",80);
	elseif Ʒ("ʥҩˮ")>0 then
		(2,"ʥҩˮ",75);	
	elseif Ʒ("ףҩˮ")>0 then
		(2,"ףҩˮ",75);			
	else	
		(2,"",0);
	end;	
end;
(3,"",0);
(4,"",0);
----------------------------------------------------------------------------
--
("======================Զܳ===============================");
if 	ͼID() == 11111 then
	ݵ("Ǻг㳡",0xDBFCE);
elseif ((ܵȼ(0x413C) == 0 and ǰְҵ()==0x66) or (ܵȼ(0x91F0) == 0 and ǰְҵ()==0xCD)  or ͼID() == 10002) then	
	ýű("\\ѧѼ.txt");	
elseif Ƿ("",0x47B761) == 1 then
	дɱ("ȡܳ",0,1);			--һȡ
	дʱ("ÿճ47B761")				--һճʼʱ
	local  = (0,100);
	if (0,-1,1)>=60000 and ͼID() == 11102 then
		if Ʒ() < 20 then
			ֽƷ();
		end;
		ѡ("",0,0x47B761);
		ʱ(2000);
	else		
		Զܳ縱();	
	end;
elseif Ƿ("",0x47B762) == 1 then		--[Chaos Dungeon] Clear Level 1 or above!
	дɱ("ȡܳ",0,1);
	дʱ("ÿճ47B761")
	дʱ("ÿճ47B762")
	local  = (0,100);
	if (0,-1,1)>=60000 and ͼID() == 11102 then
		if Ʒ() < 20 then
			ֽƷ();
		end;
		ѡ("",0,0x47B762);
		ʱ(2000);
	else
		Զܳ縱();
	end;
elseif Ƿ("",0x47B763) == 1 then		--[Chaos Dungeon] Clear Level 1 or above!
	дɱ("ȡܳ",0,1);
	дʱ("ÿճ47B761")
	дʱ("ÿճ47B762")	
	дʱ("ÿճ47B763")	
	local  = (0,100);
	if (0,-1,1)>=60000 and ͼID() == 11102 then
		if Ʒ() < 20 then
			ֽƷ();
		end;	
		ѡ("",0,0x47B763);
		ʱ(2000);
	else
		Զܳ縱();
	end;	
-------------------------------------------------------
--жʺɱ,ȡ󣬻
-------------------------------------------------------	
elseif 	(ͼID() == 11102 or ͼID() == 11401) and ȼ() >= 50 and ɫ() > 1 then	
	ýű("\\ܼӵ滻.txt");
	--
	if Ƿɽ(0x47B761) == 1  then
		(0x47B761);
		ʱ(1000);
	elseif Ƿɽ(0x47B762) == 1 then
		(0x47B762);
		ʱ(1000);
	elseif Ƿɽ(0x47B763) == 1 then		
		(0x47B763);
		ʱ(1000);
	elseif ȡʱ("ÿճ47B761") == 1 and Ƿɽ(0x47B761) == 0  then
		ܳ(0x47B761);	
		if Ƿ("",0x47B761) == 0 then
			дʱ("ÿճ47B761")
			ʱ(2000);
		end;
	elseif ȡʱ("ÿճ47B762") == 1 and Ƿɽ(0x47B762) == 0 then
		ܳ(0x47B762);	
		if Ƿ("",0x47B762) == 0  then	
			дʱ("ÿճ47B762")
		end;
	elseif ȡʱ("ÿճ47B763") == 1  and Ƿɽ(0x47B763) == 0 then	
		("================11111111111========ÿճ47B763=====================" ..ȡʱ("ÿճ47B763",1));
		ܳ(0x47B763);	
		if Ƿ("",0x47B763) == 0 then	
			дʱ("ÿճ47B763")
		end;
--		
	elseif ͼID() == 11102 or ͼID() == 11401 then
		("========================ÿճ47B761=====================" ..ȡʱ("ÿճ47B761",1));
		("========================ÿճ47B762=====================" ..ȡʱ("ÿճ47B762",1));
		("========================ÿճ47B763=====================" ..ȡʱ("ÿճ47B763",1));
		--ɫ1		
		if ȡʱ("ÿճ47B761",1) == 0 and ȡʱ("ÿճ47B762",1) == 0 and ȡʱ("ÿճ47B763",1) == 0 then
			("============111111111111111=================================");
			--ɫ2
			if ȡʱ("ÿճ47B761",2) == 0 and ȡʱ("ÿճ47B762",2) == 0 and ȡʱ("ÿճ47B763",2) == 0 then				
				--
				if ǰɫ() == 1 then
					½(2);			--ڶɫ
				else
					
					ȡܳ();
					ȡܳ(1);
					ȡܳ(2);
					ȡܳ(3);
					ȡܳ(4);
					if ȡɱ("ȡܳ",1) == 0 then
						("===============ȡܳ==================================")
						ȡܳ();
						ȡܳ(1);
						ȡܳ(2);
						ȡܳ(3);
						ȡܳ(4);
						ʱ(2000);
						if Ʒ("Una's Token") >= 180 then
							дɱ("ȡܳ",1,1);
						else
							ȡܳ();
							ȡܳ(1);
							ȡܳ(2);
							ȡܳ(3);
							ȡܳ(4);
							ʱ(2000);
							дɱ("ȡܳ",1,1);								
						end;
					elseif Ʒ("Una's Token") >= 80 then
						if ͼID() == 11401 then
							Ѱ·(-2389.00,3533.00,737.00);
						else
							ʼܴ();
							(4774.00,9393.00,4228.15,600,60,1);
							ܴ();
						end;
						if 귶Χ(4774.00,9393.00)< 100 or 귶Χ(-2389.00,3533.00)< 100 then
							if Ʒ("Una's Token") >= 500 then
								Сݻ("Halmond",3);
							elseif Ʒ("Una's Token") >= 200 then
								Сݻ("Halmond",2);
							else
								Сݻ("Halmond");
							end;
							ʱ(1000);	
						end;
						
					elseif Ʒ("Hefty Gold Sack") > 0 or Ʒ("Small Safe") > 0 or 
						Ʒ("Large Gold Chest") > 0 or Ʒ("Thin Gold Bar") > 0 or 
						Ʒ("Launch Commemoration Gold Coin") > 0 or Ʒ("Giant Gold Bar") > 0
						or Ʒ("ʢĽ") > 0 then	
						if ͼID() == 11401 then
							Ѱ·(-2389.00,3533.00,737.00);
						else												
							ʼܴ();
							(5212.00,9483.00,4226.00,600,60,1);
							ܴ();
						end;
						if 귶Χ(5212.00,9483.00)<100 or 귶Χ(-2389.00,3533.00)< 100 then
							ʱ(1000);
							();	
							if Ʒ("Hefty Gold Sack") > 0 then
								ʹƷ("Hefty Gold Sack");
							elseif Ʒ("Small Safe") > 0 then
								ʹƷ("Small Safe");
							elseif Ʒ("Large Gold Chest") > 0 then
								ʹƷ("Large Gold Chest");
							elseif Ʒ("Thin Gold Bar") > 0 then	
								ʹƷ("Thin Gold Bar");
							elseif Ʒ("Launch Commemoration Gold Coin") > 0 then	
								ʹƷ("Launch Commemoration Gold Coin");	
							elseif Ʒ("Giant Gold Bar") > 0 then	
								ʹƷ("Giant Gold Bar");								
							elseif Ʒ("ʢĽ") > 0 then	
								ʹƷ("ʢĽ");									
							end;
							ʱ(1000);
							();
							ʱ(1000);
							();		
							ʱ(1000);
							();	
							ʱ(1000);
							();								
						end;
					else
						ʱ(1000);
						();		
						ʱ(1000);
						();	
						ʱ(5000);						
						뿪Ϸ(1);			--д
					end;					
				
				end;	
				--
			else
				--ڶɫ
				if ǰɫ(1) == 1 then
					½(2);
					ʱ(2000);
				end;
			end;			
		else
			--һɫ
			if ǰɫ(2) == 2 then
				½(1);
				ʱ(2000);
			end;			
		end;
		
	end;
else
	("=============θܳ========================");
	ýű("\\θܳ.txt");
end;
