ShowMessage("领取离火 $Rev: 214 $")

--[[
[author]
descript="每天可领取1次"
]]--
script_name="离火炼炉"


function _SMain(...)

	local g_ScriptID = 890174
	local nJJS = DataPool:UserBag_CountItemByName("精金石碎片")
	local nLH = DataPool:UserBag_CountItemByName("离火")

	local spaceNum = PlayerPackage:GetEmptySlot(1)
	if spaceNum < 2 then
   		ShowMessage("领取离火：背包材料栏空位不足，脚本结束！")
  		return
	end

	if Player:GetData("LEVEL") < 80 then
 		ShowMessage("领取离火：角色等级低于80，脚本结束！")
   		return
	end

	while true do 

		if GetQuestTimesInfo("离火炼炉") == 0 then
			ShowMessage("今日已经领取完离火!")
			return
		end

		MoveToNPC(363, 243, 1, "慕白")
		System:Sleep(1000)
		QuestFrameOptionClicked(script_name , CMP_PART_MATCH)
		System:Sleep(1000)

		local index = Get_XParam_INT(g_ScriptID, 1) 
		local yinhuo = Get_XParam_INT(g_ScriptID, 2) 
		local lianshi = Get_XParam_INT(g_ScriptID, 3)

		DbgPrintf("bag %d , param %d,%d,%d" , tonumber(spaceNum) ,tonumber(index) , tonumber(yinhuo) , tonumber(lianshi))
		
	
		while UI:IsWindowShow("TheFireStove") do 
		
			index = Get_XParam_INT(g_ScriptID, 1) 
			yinhuo = Get_XParam_INT(g_ScriptID, 2) 
			lianshi = Get_XParam_INT(g_ScriptID, 3)	  

			if lianshi <= 0 then
				UI:WindowHide("Quest")
				local New_nJJS = DataPool:UserBag_CountItemByName("精金石碎片")
				local New_nLH = DataPool:UserBag_CountItemByName("离火")
				ShowMessage("成功领取[%d]个精金石碎片和[%d]个离火，结束脚本", (New_nJJS - nJJS), (New_nLH - nLH))
				return
			end
		
			if yinhuo > 0 and index == 1 then
				DoLuaString("" , "TheFireStove_FireButton_OnClick()")
				System:Sleep(500)
				continue
			end
		
			if UI:IsWindowShow("TheFireStove_MessageBox") then
				DoLuaString("" , "TheFireStove_MessageBox_OK_Clicked()")
				System:Sleep(1000)
	 		end	
			   
			DoLuaString("" , "TheFireStove_StoneButton_OnClick()")
			System:Sleep(500)  

			if FindDebugMessage("您的背包材料栏剩余空间不足") == true then
   				ShowMessage("领取离火：背包材料栏空位不足，脚本结束！")
  				return
			end
		end
	end
end

_SMain()




