ShowMessage("µһ $Rev: 1$")

--[[
[author]
class=2
]]--

function OnDiYiLei()
	
	local strSceneName = ""

	while true do

		strSceneName = GetActiveSceneName()
		
		if string.find(strSceneName, "Ԥ") then

			local nHPPercent = Player:GetData("HP_PERCENT")
			local nMPPercent = Player:GetData("MP_PERCENT")

			if (nHPPercent < 100 or nMPPercent < 100) then 

				MoveToNPC(32, 14, -1, "ָ̨ʹ", false)
				QuestFrameOptionClicked("ɫŭ", CMP_FULL_MATCH)
				QuestFrameOptionClicked("", CMP_FULL_MATCH)
				
				System:Sleep(500)

				MoveToNPC(32, 14, -1, "ָ̨ʹ",false)
				QuestFrameOptionClicked("޻ָѪ", CMP_FULL_MATCH)
				QuestFrameOptionClicked("", CMP_FULL_MATCH)

			else

				local buff_index = Player_GetBuff("ս")
				if buff_index ~= -1 then
					Player_DispelBuffByIndex(buff_index)
				else
					DbgPrintf("ȴ룡")
				end

			end

		elseif strSceneName == "µһ" then

			local nHP = Player:GetData("HP")

			if Player_GetBuff("ս׼") ~= -1 then
			
			else
				if UI:IsWindowShow("NewMatch_ResultShow") == true then
					DbgPrintf("")
					MoveToNPC(107, 110, -1, "ָ", false)
					QuestFrameOptionClicked("뿪", CMP_FULL_MATCH)
					DoLuaString("MessageBox_Self_Env", "MessageBox_Self_OK_Clicked()")
					System:Sleep(3000)
				else
					AI:SetAI("ɱ")
					AI:SetParameter("ʼ")
					AI:SetParameter("", "", 96, 94)
					AI:StartEx(0)
					AI:SetParameter("в" , "ɱ" , 0)
					AI:SetParameter("в" , "ԶPK" , 1)
					AI:SetParameter("в" , "ٻ" , 1)
					AI:StartEx(1)
					while true  do
						local vSceneName = GetActiveSceneName()
						if vSceneName ~= "µһ" then
							break 
						end

						if UI:IsWindowShow("NewMatch_ResultShow") == false then
							break
						end
						
						System:Sleep(1000)
					end
					AI:Stop()

				end

			end

		else
			ShowMessage("롾Ԥҡʼű")
			break

		end

		System:Sleep(200)
	end
end

function _SMain(...)
	OnDiYiLei()
end


_SMain()

