使用ABLUA语句实现身上拥有物品的条件 - 神奇石器时代技术研究交流
神奇石器技术研究交流网 - 业务联系QQ:420004208

使用ABLUA语句实现身上拥有物品的条件

  • 内容
  • 相关

标题可能看着不是很明白,我细说下,就是加个当身上拥有某个物品的时候才可以执行下列域名,比如当身上拥有指定物品则进行开战,或者给其他道具,或者传送等操作。

以这篇例子做参照:http://sa60.com/post-131.html

这里我们要用的接口是char库的Finditem,这个接口返回的数值是道具的索引,如果未找到该道具则返回-1

为了方便看重要的注释,之前的注释去掉先。


function Talked(meindex, talkerindex , szMes, color )
	if npc.isFaceToFace(meindex, talkerindex, 1) == 1 then
		token = "欢迎挑战神奇大魔王。"
		      .."\n点击确定你我将和你战斗。"
		lssproto.windows(talkerindex, "对话框", "确定|取消", 1, char.getWorkInt( meindex, "对象"), token)
	end 
end

function WindowTalked ( meindex, talkerindex, seqno, select, data)
	if npc.isFaceToFace(meindex, talkerindex, 1) == 1 then
		if seqno == 1 then
			if select == 1 then
				--定义个itemindex的变量,char.Finditem来搜索对话者身上的2400道具来返回索引
				itemindex = char.Finditem(talkerindex, 2400)
				--大于-1就说明在对话者的身上搜索到了2400的物品
				if itemindex > -1 then
				    enemytable = {1690, -1, -1, -1, -1, -1, -1, -1, -1, -1}
				    battleindex = battle.CreateVsEnemy(talkerindex, meindex, enemytable)
				else
				    --如果数值是小于0即-1,则利用窗口对话告知你没有指定道具。
				    lssproto.windows(talkerindex, "对话框", "取消", -1, char.getWorkInt(meindex, "对象"), "你没有指定道具。")
				end
			end
		end
	end 
end

function Create(name, metamo, floor, x, y, dir)
	npcindex = npc.CreateNpc(name, metamo, floor, x, y, dir)
	char.setFunctionPointer(npcindex, "对话事件", "Talked", "")
	char.setFunctionPointer(npcindex, "窗口事件", "WindowTalked", "")
end

function main()
	Create("黑暗精灵王", 100444, 2000, 82, 84, 6)
end
这样就实现了身上有指定道具才能执行其他操作的功能。

版权声明:若无特殊注明,本文皆为《sa60》原创,转载请保留文章出处。

本文链接:使用ABLUA语句实现身上拥有物品的条件 - http://sa60.com/post-229.html

本文标签:

使用ABLUA语句实现身上拥有物品的条件