上图吧;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
在这里检测的条件 可以是 U变量 也可以是临时类型变量 譬如<$N(tsxxx)> 我这里设置的这个变量主要是我自己好判断所以字符串以ts开头数值型以tn开头
如何设置,我相信大家都能够想得到吧,这里就不多过介绍设置了
下面是代码(主要是开阔思路,代码不完善外需要后期优化)
--两个全局缓存变量,这个变量玩家不大退会一直存在
local MonClist = {}
local MonNtxt = ""
--init所绑定的入口函数
function bao1(MonActor,TagActor,sItemName)
return BurstItem(MonActor,TagActor,sItemName);
end
--条件处理
function BurstItem(MonActor,TagActor,sItemName)
local MonName = MonActor:getCharName();
local TagName = TagActor:getCharName();
local ClTxt = ""
local Clist = {}
local Clist_z = {}
--实装环境中不要重置怪物名称缓存;
MonNtxt = ""
--这里进行一个数据缓存,之所以使用字符串拼接检测而不是直接检索缓存表,我个人认用字符串检测更节省资源;
if ini_zfcss(MonNtxt,MonName.."|") == 0 then
MonNtxt = MonNtxt..MonName.."|"
ClTxt = readFile(".\\Envir\\MonItems\\ItemCondition\\"..MonName..".txt")
Clist = strSplit(ClTxt,"\n")
MonClist[MonName] = Clist
end
if ini_zfcss(MonNtxt,MonName.."|") ~= 0 then
for ai,av in pairs(MonClist[MonName]) do
if ini_zfcss(av,sItemName) ~= 0 then
Clist_z = strSplit(av," ")
if #Clist_z == 4 then
--特定变量满足时执行;
if in_array(Clist_z[3],{">","<","="}) then
if not sy_utes(TagActor,Clist_z[2],Clist_z[3],Clist_z[4]) then
TagActor:sendMsg(2,"物品:"..Clist_z[1].." 将要爆出时检测到条件不满足!", -1, -1)
return false
end
end
end
end
end
end
--print("["..MonName.."]被["..TagName.."]击杀,爆出物品:"..sItemName..Conditionlist[1]);
return true;--返回结果(true为可爆出 false为不可爆出)
end
--条件判断辅助
--玩家U变量与临时变量检测(参数3为判断符号时则进行判断)
function sy_utes(play,str1,str2,str3)
local strn = 0
local strs = 0
local strt = ""
if string.find(str1,"u") then
str1 = string.gsub(str1,"u","")
strn = play:getVal_U(str1)
if str2 ~= "" then
strs = tonumber(str3)
if str2 == ">" then
if strn > strs then
return true
end
return false
end
if str2 == "<" then
if strn < strs then
return true
end
return false
end
if str2 == "=" then
if strn == strs then
return true
end
return false
end
end
return strn
end
if string.find(str1,"ts") then
strt = play:getVal_S_Ex(str1)
if str2 == ">" then
return false
end
if str2 == "<" then
return false
end
if str2 == "=" then
if strt == str3 then
return true
end
return false
end
return strs
end
if string.find(str1,"tn") then
strn = play:getVal_S_Ex(str1)
if str2 ~= "" then
strs = tonumber(str3)
if str2 == ">" then
if strn > strs then
return true
end
return false
end
if str2 == "<" then
if strn < strs then
return true
end
return false
end
if str2 == "=" then
if strn == strs then
return true
end
return false
end
end
return strn
end
end
--字符串检测
function ini_zfcss(str,str1)
if string.find(str,str1) ~= nil then
return string.find(str,str1)
else
return 0
end
end
贴上一个视频效果:
https://www.bilibili.com/video/BV1Rt4y1m765/
补充内容 (2020-4-4 06:03):
视频地址不知道怎么回事是错的,看下面这个
https://www.bilibili.com/video/BV1Rt4y1m765
补充内容 (2020-4-4 06:05):
直接点击地址显示错误 只能手动复制打开
补充内容 (2020-4-4 12:42):
视频连接点这个(上面的都显示错误)
https://www.bilibili.com/video/BV1Rt4y1m765/?v=22
补充内容 (2020-4-4 12:42):
视频连接点这个(上面的都显示错误)
https://www.bilibili.com/video/BV1Rt4y1m765/?v=22
补充内容 (2020-4-4 12:42):
视频连接点这个(上面的都显示错误)
https://www.bilibili.com/video/BV1Rt4y1m765/?v=22
补充内容 (2020-4-4 12:52):
视频连接错误可以点下面的(因为跳转的时候论坛会在后面加一些参数导致错误)
https://www.bilibili.com/video/BV1Rt4y1m765?v=2 |