ShowMessage("膜拜 $Rev: 215 $")

--[[
[author]
descript="每天可膜拜1次"
]]--
perday_max=1
script_name="膜拜"


function _SMain()

	while true do

		System:Sleep(500)

		-- 移动到 凤鸣镇 五行尊主·天皇帝君 158 41处
		MoveTo(158, 41, DataBase:GetSceneID("凤鸣镇"))

		-- 选择 膜拜 接任务
		local select_id = INVALID_ID

		local n = EnumObject(true)

		for i=0, n - 1 do
			local idObj, classObj, nameObj, xObj, yObj , sTitle = EnumObject(false, i)
			DbgPrintf("%s %s", tostring(sTitle) , tostring(nameObj))
			if idObj == INVALID_ID then
				continue
			end
		
			if classObj == "NPC" and  sTitle == "#{TWZW_150831_59}" then
				select_id = idObj
				break
			end
		end

		if select_id ~= INVALID_ID then

			QuestFrameSpeak( select_id , "")
			QuestFrameOptionClicked("膜拜", CMP_PART_MATCH)
		
			System:Sleep(2000)
			local isNext,szMsg = GetDebugMessage()
			while isNext == 1 do				
				if string.find(szMsg, "膜拜成功") or string.find(szMsg, "已经膜拜过了") then
--					ShowMessage("膜拜成功！")
					System:UpdateRecord( script_name )
					return
				end
			end
		end

	end
end


_SMain()

