搜索
查看: 4310|回复: 18

今天下午研究了一下物品爆出条件的这个东西

[复制链接]
发表于 2020-4-4 04:10:41 | 显示全部楼层 |阅读模式
上图吧;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

在这里检测的条件 可以是 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

评分

参与人数 2金钱 +10 热心值 +2 收起 理由
1580 + 10 + 1 很给力!
怪怪 + 1 很给力!

查看全部评分

发表于 2020-4-4 06:53:54 | 显示全部楼层
虽然看不懂,还是得顶一下
发表于 2020-4-4 07:01:00 | 显示全部楼层
好东西,必须点赞

喊一遍口号:地振高冈 一派西山千古秀; 门朝大海,三河合水万年流。
发表于 2020-4-4 07:28:43 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2020-4-4 08:21:20 | 显示全部楼层
视频应该被删除了,看上去挺高大上的!等我细细品!
发表于 2020-4-4 12:22:56 | 显示全部楼层
厉害      
发表于 2020-4-4 16:05:25 | 显示全部楼层
真厉害
发表于 2020-4-4 16:10:44 | 显示全部楼层
真的秀,厉害了
发表于 2020-4-4 17:06:32 | 显示全部楼层
非常厉害
发表于 2020-4-4 20:38:35 | 显示全部楼层

好东西,必须点赞

喊一遍口号:地振高冈 一派西山千古秀; 门朝大海,三河合水万年流
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|HGEM2论坛

GMT+8, 2024-9-21 10:42 , Processed in 0.542313 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表