--[[ Ѩ:[Ĺ][][][Ӱ][][][][][ʳ][][鼫][]
ؼ:
̫	3 1Ч
	ȫ
	1 3˺ (1ϼ ˺3ɼCD)
	1 2˺ 1Ч
˻	3˺ 1Ч
˽	1Ϣ 1dot 1 1˺
	2Ϣ 1Ѫ 1
ƾ	2Ϣ 1 1ܻѪ
--]]

--رԶ
setglobal("Զ", false)

--ѡ
addopt("", false)
addopt("ֶ", false)

--
local v = {}
v["Ϣ"] = true

--ѭ
function Main()
	--ʼ
	v[""] = qidian()
	v["ǳCD"] = scdtime("ǳ")
	v["CD"] = scdtime("")
	v["CD"] = scdtime("")
	v["CD"] = scdtime("򽣹")
	v["˻CD"] = scdtime("˻ĹԪ")
	v["˽CD"] = scdtime("˽һ")
	v["ʱ"] = tbufftime("", id())
	v["в"] = tbuffsn("", id())
	v["ʱ"] = bufftime("")
	v["ʱ"] = bufftime("")
	v["Ų"] = buffsn("")

	local tSpeedXY, tSpeedZ = speed(tid())
	v["Ŀ꾲ֹ"] = rela("ж") and tSpeedXY <= 0 and tSpeedZ <= 0
	v[""] = npc("ϵ:Լ", ":", "<15")
	v["ǳ"] = npc("ϵ:Լ", ":ǳ", "<13")
	v[""] = npc("ϵ:Լ", ":", "<13")
	_, v[""] = npc("ϵ:Լ", ":̫|ǳ|", "<13")

	--ûս
	if nofight() and nobuff("") then
		CastX("")
	end

	--
	if fight() and life() < 0.5 and gettimer("") > 0.3 and nobuff("") and gettimer("תǬ") > 0.3 and buffstate("Ч") < 40 then
		if CastX("") then return end
		if CastX("תǬ") then return end
	end

	--ûս 3
	if nofight() and v["Ŀ꾲ֹ"] then
		_, v["Ŀ"] = tnpc("ϵ:Լ", ":̫|ǳ|", "<13")
		if v["Ŀ"] < 3 then
			CastX("ǳ")
		end
	end
	
	--
	if getopt("") and dungeon() and nofight() then return end

	--˽ ִ
	if rela("ж") and dis() < 6 and v[""] >= 3 and v["Ų"] < 3 then
		if v[""] == 0 and v["ǳCD"] < cdinterval(16) then
			CastX("˽һ")
		end
	end

	--3
	if v[""] < 3 and v[""] + v["Ų"] < 3 then
		CastX("")
		CastX("̫")
	end

	--
	if v["ʱ"] < 0 or v["ʱ"] > 12 then
		CastX("")
	end

	--ǳ
	v["ǳ"], v["ǳʱ"] = qc("ǳ", id(), id())
	if v["ǳ"] > -1 or v["ǳʱ"] < 1 then
		CastX("ǳ")
	end

	--, 󶨾Ӱ
	if not getopt("ֶ") or keydown(1) then	--ûֶѡ, ߰¿ݼ1(ǰ1, ڿݼԼõĿݼ1Ӧİ)
		if nobuff("") and rela("ж") and dis() < 6 and face() < 90 and bufftime("Ӱ") > 0.5 and cdtime("Ӱ") <= 0 then
			if v["ʱ"] > 10 and v["Ų"] >= 3 then
				if CastX("") then
					CastX("ƾ")
				end
			end
		end
	end

	--Ӱ
	CastX("Ӱ")

	--򽣹
	if rela("ж") and dis() < 8 and tnpc("ϵ:Լ", ":", "ɫ<10") ~= 0 then
		CastX("򽣹")
	end
	
	--޽
	if v["ʱ"] > 0 and qidian() >= 6 then
		if v["ʱ"] < 12 then
			CastX("޽")
		end
	end

	--˽
	if rela("ж") and dis() < 6 and v["ǳ"] ~= 0 and v[""] ~= 0 then
		if v[""] == 0 and v["ǳCD"] < cdinterval(16) then
			CastX("˽һ")
		end
	end

	--޽
	if v["ʱ"] > 0 and qidian() >= 6 then
		CastX("޽")
	end

	--
	if v[""] == 0 then
		CastX("")
	end

	--
	if fight() and mana() < 0.4 then
		if CastX("", true) then
			stopmove()
		end
	end

	--˻ĹԪ
	CastX("˻ĹԪ")

	--ûϢ
	if fight() and rela("ж") and dis() < 6 and cdleft(16) <= 0 and castleft() <= 0 and gettimer("") > 0.3 and gettimer("ǳ") > 0.3 and gettimer("̫") > 0.3 and gettimer("") > 0.3 and state("վ|·|ܲ|Ծ") then
		PrintInfo("----------û, ")
	end
end

--Ϣ
function PrintInfo(s)
	if not v["Ϣ"] then return end
	local szinfo = ":"..v[""]..", :"..v["в"]..", "..v["ʱ"]..", :"..v["ʱ"]..", :"..v["Ų"]..", "..v["ʱ"]..", CD:"..v["CD"]..", ǳCD:"..v["ǳCD"]..", ˽CD:"..v["˽CD"]..", CD:"..v["CD"]..", ǳCD:"..v["ǳCD"]..", CD:"..v["CD"]
	if s then
		szinfo = s..szinfo
	end
	print(szinfo)
end

--ʹüܲϢ
function CastX(szSkill, bSelf)
	if cast(szSkill, bSelf) then
		settimer(szSkill)
		PrintInfo()
		return true
	end
	return false
end

--ս״̬ı
function OnFight(bFight)
	if bFight then
		print("--------------------ս")
	else
		print("--------------------뿪ս")
	end
end
