改了个WOW插件-法师自动补全施法材料

Wayne posted @ Sun, 08 Apr 2012 09:15:20 +0000 in Experience , 6163 readers

开始重操旧业玩起了WOW,只不过这次玩的是法师。法师有三种施法材料:魔粉,传送符文,传送门符文。用光了会被人质疑为不够专业。材料在包裹里20个一组占一个格子,所以一次买的时候最好买齐20个,省的老是回来补。手动买其实也没啥不方便的,不过能自动还是自动吧,懒人自然有懒想法。

这个功能倒是很常见的功能了,从古到今,带这功能的各种插件和宏都流传了不少。不过我这不是没装嘛。特地去为了这点事情而找个东西,实在太费劲了,不如自己直接添上。我在已经装了的一个叫AutoRepair的插件上开始修改。AutoRepair,顾名思义就是自动修理装备用的,修理装备会需要打开商店界面,用到MERCHANT_SHOW这个事件,这样就省得我自己去注册了。

AutoRepair插件分三个文件,一个AutoRepair.toc,一个AutoRepair.xml,一个AutoRepair.lua。  toc结尾的文件可以无视,xml文件则如下:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\..\FrameXML\UI.xsd">
<Script file="AutoRepair.lua"/> 
<Frame name="frmautorepair">
  <Scripts>
   <OnEvent>
    arEvent();
   </OnEvent>
   <OnLoad>
    arInit();
   </OnLoad>
  </Scripts>
 </Frame>
</Ui>

很简单明了,arInit() 里面注册了事件,arEvent()则是事件处理。那么很明显,我需要在arEvent()里面加点东西。

AutoRepair.lua的arEvent():

function arevent(self, event)
	if armode==nil then
		armode=0;
	end

	if (event=="MERCHANT_SHOW" and CanMerchantRepair()==1) then
		repairAllCost, canRepair = GetRepairAllCost();
		if (canRepair==1) then
			if(armode<=1) then
				if( repairAllCost<=GetMoney() ) then
					RepairAllItems(0);
					DEFAULT_CHAT_FRAME:AddMessage("Your items have been repaired for "..GetCoinText(repairAllCost,", ")..".",255,255,0);
				else
					DEFAULT_CHAT_FRAME:AddMessage("You don't have enough money for repair!",255,0,0);
				end
			end

			if(armode==2 or armode==3)then
				RepairAllItems(1);
			end

			if(armode==2) then
				if( repairAllCost<=GetMoney() ) then
					RepairAllItems(0);
					DEFAULT_CHAT_FRAME:AddMessage("Your items have been repaired for "..GetCoinText(repairAllCost,", ")..".",255,255,0);
				else
					DEFAULT_CHAT_FRAME:AddMessage("You don't have enough money for repair!",255,0,0);
				end
			end		
		end
	end

	if (event=="VARIABLES_LOADED") then
		arStatus();
	end

end

它把事件处理放在了一个 if 中,只不过后面又跟了个判断是否可以修理的CanMerchantRepair(),这样的话我还是不要直接塞进它的 if 里面,而是跟在最后面比较好。在第二个事件 VARIABLE_LOADED 处理了之后,加上:

	if (event =="MERCHANT_SHOW" ) then
		local itemid = 17020;  --魔粉
		fillItem(itemid);
		
		itemid = 17031;  --传送符文 
		fillItem(itemid);

		itemid = 17032; -- 传送门符文
		fillItem(itemid);
	end

itemid 是物品编号,这个是从在线数据库查的,肯定准。这里加了一个函数fillItem, 内容如下:

function fillItem(itemid)
	local item_name = GetItemInfo(itemid);
	local item_count = GetItemCount(itemid);
	
	for i=0,GetMerchantNumItems() do
		if GetMerchantItemInfo(i) == item_name then
			BuyMerchantItem(i,20-item_count);
			DEFAULT_CHAT_FRAME:AddMessage("Buy "..item_name.." "..(20-item_count));
		end
	end
end

主要是调用了几个API,查API可以到wowwiki上找,很全很好用。

添加完后,保存关闭,进游戏,找到材料商人,状况良好:

 

 

 

 

instagram löschen li said:
Wed, 19 Jul 2023 14:04:49 +0000

Aus persönlichen Gründen werden einige Benutzer ihre Instagram-Konten löschen. Bevor Sie ihr Konto löschen, sollten Sie genau prüfen, ob Sie es wirklich wollen oder nicht. Weil es so einfach ist, sich anzumelden und Ihr Konto jederzeit zu kündigen. instagram löschen link Sobald Sie mit dem Löschen fortfahren, gibt es keine Möglichkeit, das Konto wiederherzustellen, und Sie verlieren alle Ihre Timeline-Posts, Reels, Follower, Kommentare und Favoriten.

GSSTB 4th Class Boo said:
Tue, 22 Aug 2023 12:02:37 +0000

Gujarat Board Primary School Academic Year Close in Every Year Month of April, Gujarat Board Elementary School new Academic Year Open in Every Year Month of Jun, Every Year Gujarat State Wise Class More Than 50 Laks of Students Attended, Every Year Primary School Education Department Government of Gujarat Distribution in Textbook in Gujarati / English / Hindi Medium.The Printed Gujarat Class GSSTB 4th Class Book 2024 Textbook 2024 are Distributed Through Cooperative Institutions All over Gujarat. Vendors are Linked to the Distribution of Textbooks with Distributors in each District. Gujarat Board Class Book 2024 are easily Accessible to All Students of This System, This will assist in improving the Quality of Teaching by Understanding the Type of Difficulties Faced by Students.

seo service london said:
Mon, 06 Nov 2023 12:22:39 +0000

I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post. Excellent read, Positive site, where did u come up with the information on this posting?I

pavzi.com said:
Fri, 05 Jan 2024 11:45:33 +0000

Board Model Papers 2024 Download with Suggestions for 10th Class Textbooks 2024 Pdf Download and SSLC New Syllabus Sample Question Paper 2024 and different types of model papers boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course Languages & Subjects Important Question for the above link.

seo service london said:
Tue, 16 Jan 2024 11:15:39 +0000

Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blo


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter