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()

