ShowMessage("幸运快活三任务脚本 $Rev: 192 $")

--[[
[author]
descript="每天可以做1次"
]]--

script_name="幸运快活三"

local g_szMission = "幸运快活三"

local g_NpcInfo = {
	[0] = {szNpcName="柳月虹", fX=230, fY=350}
}

function _SMain(...)

	if GetQuestTimesInfo("幸运快活三") == 0 then
		ShowMessage("今日已经完成幸运抽奖活动!")
		return
	end

	if Player:GetData("LEVEL") < 20 then
		ShowMessage("幸运快活三：玩家等级小于20级。")
		return
	end

	local bDone = false

	while true do

		if UI:IsWindowShow("XingYun") == false then
			if bDone == true then
				QuestFrameSpeak(0, g_NpcInfo[0].szNpcName)
				QuestFrameOptionClicked("领取幸运", CMP_PART_MATCH)
			else
				MoveToNPC(g_NpcInfo[0].fX, g_NpcInfo[0].fY, 1, g_NpcInfo[0].szNpcName)
				QuestFrameOptionClicked(g_szMission, CMP_PART_MATCH)
			end

			System:Sleep(1000)
			if bDone == true and FindDebugMessage("背包空间不足") == true then
				break
			end

			local strType,_,_,_,szText = DataPool:GetNPCEventList_Item(0);

			if strType == "text" then
				if string.find(szText, "没有奖励") then 
					break 
				elseif string.find(szText, "已经参加") then 
					bDone = true 
				elseif string.find(szText, "再等60分钟") then
					break
				end
			end
		else
			DoLuaString("XingYun_Env", string.format("Play_Ani(%d)", 1))
			System:Sleep(1500)
			DoLuaString("XingYun_Env", string.format("Play_Ani(%d)", 2))
			System:Sleep(1500)
			DoLuaString("XingYun_Env", string.format("Play_Ani(%d)", 3))
			System:Sleep(3000)
			DoLuaString("XingYun_Env", "XingYun_Close()")
			bDone = true
			System:Sleep(1000)
		end

		System:Sleep(1000)
	end
end

_SMain()
