搜索
查看: 3591|回复: 13

发几个lua写的buff (之前一个帖子发错板块了)

[复制链接]
发表于 2020-5-23 01:15:21 | 显示全部楼层 |阅读模式
效果如下:
斩首=直接斩杀血量低于5%/10%/20%的怪物
禁锢=攻击时有概率让对手禁锢1/2/5秒
蛛网=攻击时有概率让对方被蛛网笼罩1/2/5秒
剧毒=攻击时有概率让对方中毒3/8/20秒
灵活=受到攻击伤害时,有5%/10%/20%的概率吸收99%的伤害!


下面贴代码:
  1. --使用技能回调
  2. function tiancai_DoSpellSkill(Actor,TagActor,MagicID)
  3.         local actorname = Actor:getCharName()
  4.         local TagActorName = TagActor:getCharName()
  5.         local Olook = TagActor:getRace()
  6.         local Ulook = Actor:getRace()
  7.         local Ueee = 0
  8.         local u
  9.         local uh
  10.         local buff = "高级剧毒|高级蛛网|中级禁锢|高级斩首" <span style="color: rgb(102, 102, 102); font-family: Monaco, Consolas, &quot;Lucida Console&quot;, &quot;Courier New&quot;, serif; font-size: 12px;">--实装中这里的buff列表肯定从玩家变量中获取,我这里写死是假设该玩家有这些buff</span>
  11.         --如若触发本体是宝宝的话,那么将操作对象转换为本体
  12.         if Ulook == 66 then
  13.         u = s.obj.getPlayer(Actor:getMasterName())
  14.         uh = s.obj.getHero(u:getCharName())
  15.         end
  16.        
  17.         --统一操作对象
  18.         if Ulook == 0 then
  19.         u = Actor
  20.         uh = s.obj.getHero(u:getCharName())
  21.         end
  22.        
  23.         --剧毒buff
  24.         if ini_zfcss(buff,"剧毒") then
  25.                 if ini_zfcss(buff,"高级剧毒") > 0 then
  26.                         if math.random(1,100) < 10 then
  27.                                 TagActor:setActorStatus(4,20)
  28.                                 u:sendMsg(2,"剧毒buff生效,对手中毒20秒", -1, -1)
  29.                         end
  30.                 end
  31.                 if ini_zfcss(buff,"中级剧毒") > 0 then
  32.                         if math.random(1,100) < 10 then
  33.                                 TagActor:setActorStatus(4,10)
  34.                                 u:sendMsg(2,"剧毒buff生效,对手中毒10秒", -1, -1)
  35.                         end
  36.                 end
  37.                 if ini_zfcss(buff,"初级剧毒") > 0 then
  38.                         if math.random(1,100) < 10 then
  39.                                 TagActor:setActorStatus(4,5)
  40.                                 u:sendMsg(2,"剧毒buff生效,对手中毒5秒", -1, -1)
  41.                         end
  42.                 end
  43.         end
  44.         --蛛网buff
  45.         if ini_zfcss(buff,"蛛网") then
  46.                 if ini_zfcss(buff,"高级蛛网") > 0 then
  47.                         if math.random(1,100) < 10 then
  48.                                 TagActor:setActorStatus(3,5)
  49.                                 u:sendMsg(2,"蛛网buff生效,对手减速5秒", -1, -1)
  50.                         end
  51.                 end
  52.                 if ini_zfcss(buff,"中级蛛网") > 0 then
  53.                         if math.random(1,100) < 10 then
  54.                                 TagActor:setActorStatus(3,2)
  55.                                 u:sendMsg(2,"蛛网buff生效,对手减速2秒", -1, -1)
  56.                         end
  57.                 end
  58.                 if ini_zfcss(buff,"初级蛛网") > 0 then
  59.                         if math.random(1,100) < 10 then
  60.                                 TagActor:setActorStatus(3,1)
  61.                                 u:sendMsg(2,"蛛网buff生效,对手减速1秒", -1, -1)
  62.                         end
  63.                 end
  64.         end
  65.         --禁锢buff
  66.         if ini_zfcss(buff,"禁锢") then
  67.                 if ini_zfcss(buff,"高级禁锢") > 0 then
  68.                         if math.random(1,100) < 10 then
  69.                                 TagActor:setActorStatus(1,5)
  70.                                 u:sendMsg(2,"禁锢buff生效,对手定身5秒", -1, -1)
  71.                         end
  72.                 end
  73.                 if ini_zfcss(buff,"中级禁锢") > 0 then
  74.                         if math.random(1,100) < 10 then
  75.                                 TagActor:setActorStatus(1,2)
  76.                                 u:sendMsg(2,"禁锢buff生效,对手定身2秒", -1, -1)
  77.                         end
  78.                 end
  79.                 if ini_zfcss(buff,"初级禁锢") > 0 then
  80.                         if math.random(1,100) < 10 then
  81.                                 TagActor:setActorStatus(1,1)
  82.                                 u:sendMsg(2,"禁锢buff生效,对手定身1秒", -1, -1)
  83.                         end
  84.                 end
  85.         end
  86.         --斩首buff
  87.         if not in_array(Olook,{0,66}) then
  88.                 if ini_zfcss(buff,"斩首") > 0 then
  89.                         local omaxhp = TagActor:getMaxHp()
  90.                         local ohp = TagActor:getHp()
  91.                         local ohpf = math.round(ohp / omaxhp * 100)
  92.                         print("怪物剩余百分百血量:"..ohpf.." 他的血量"..omaxhp.."-"..ohp)
  93.                         if ini_zfcss(buff,"高级斩首") > 0 then
  94.                                 if ohpf < 20 then
  95.                                         TagActor:setHp(0)
  96.                                         u:sendMsg(2,"高级斩首buff生效,直接斩杀"..TagActorName..ohp.."血量!", -1, -1)
  97.                                 end
  98.                         end
  99.                         if ini_zfcss(buff,"中级斩首") > 0 then
  100.                                 if ohpf < 10 then
  101.                                         TagActor:setHp(0)
  102.                                         u:sendMsg(2,"中级斩首buff生效,直接斩杀"..TagActorName..ohp.."血量!", -1, -1)
  103.                                 end
  104.                         end
  105.                         if ini_zfcss(buff,"初级斩首") > 0 then
  106.                                 if ohpf < 5 then
  107.                                         TagActor:setHp(0)
  108.                                         u:sendMsg(2,"初级斩首buff生效,直接斩杀"..TagActorName..ohp.."血量!", -1, -1)
  109.                                 end
  110.                         end
  111.                 end
  112.         end
  113.        
  114. end

  115. --角色受到伤害时触发(返回指定伤害数值)
  116. function tiancai_shoushang(actor,nPoint)
  117.         local actorname = actor:getCharName()
  118.         local Ulook = actor:getRace()
  119.         local u
  120.         local uh
  121.         local buff = "高级剧毒|高级蛛网|中级禁锢|高级灵活"
  122.         local upo = math.round(nPoint / 100)
  123.         local upox = 0
  124.         --如若触发本体是宝宝的话,那么将操作对象转换为本体
  125.         if Ulook == 66 then
  126.         u = s.obj.getPlayer(actor:getMasterName())
  127.         uh = s.obj.getHero(u:getCharName())
  128.         end
  129.        
  130.         --统一操作对象
  131.         if Ulook == 0 then
  132.         u = actor
  133.         uh = s.obj.getHero(u:getCharName())
  134.         end
  135.        
  136.         --人物或者宝宝才能执行
  137.         if in_array(Ulook,{0,66}) then
  138.                         if ini_zfcss(buff,"灵活") > 999 then
  139.                                 if ini_zfcss(buff,"高级灵活") > 0 then
  140.                                         if math.random(1,100) < 20 then
  141.                                                 upox = upo * 99
  142.                                                 u:sendMsg(2,"高级灵活buff生效,本次吸收99%("..upox..")点伤害", -1, -1)
  143.                                         end
  144.                                 end
  145.                                 if ini_zfcss(buff,"中级灵活") > 0 then
  146.                                         if math.random(1,100) < 10 then
  147.                                                 upox = upo * 99
  148.                                                 u:sendMsg(2,"中级灵活buff生效,本次吸收99%("..upox..")点伤害", -1, -1)
  149.                                         end
  150.                                 end
  151.                                 if ini_zfcss(buff,"初级灵活") > 0 then
  152.                                         if math.random(1,100) < 5 then
  153.                                                 upox = upo * 99
  154.                                                 u:sendMsg(2,"初级灵活buff生效,本次吸收99%("..upox..")点伤害", -1, -1)
  155.                                         end
  156.                                 end
  157.                         end
  158.         end
  159.         nPoint = nPoint - upox
  160.         print("扣血回调:"..nPoint)
  161.         return nPoint
  162. end

  163. --数组检测
  164. function in_array(b,list)
  165.         if not list then
  166.                 return false   
  167.         end
  168.         if list then
  169.                 for _, v in pairs(list) do
  170.                         if v == b then
  171.                                 return true
  172.                         end
  173.                 end
  174.                 return false
  175.         end
  176. end
  177. --字符串检测
  178. function ini_zfcss(str,str1)
  179.         if string.find(str,str1) ~= nil then
  180.                 return string.find(str,str1)
  181.         else
  182.                 return 0
  183.         end
  184. end
复制代码
脚本写完没整理,可能会有一些问题,诸如执行完中级的buff后还会继续执行等状况,自己加个判断就好了! 还是同样的话,代码贴出来只是开阔思路,用类似的方法可以让大家写出更优秀的东西,更有效的促进HGE发展的脚步!

评分

参与人数 2金钱 +76 热心值 +2 收起 理由
1580 + 10 + 1 很给力!
法海不懂爱 + 66 + 1 判断buff,加个exit就好了,不用继续判断等.

查看全部评分

发表于 2020-5-23 02:16:03 | 显示全部楼层
666666666666666666666666
发表于 2020-5-23 05:30:11 | 显示全部楼层
这就是大神,感谢无私分享!
发表于 2020-5-23 06:37:12 | 显示全部楼层
大神犀利
发表于 2020-5-23 09:22:11 | 显示全部楼层
小小年纪 竟如此犀利。。。
发表于 2020-5-23 12:28:00 | 显示全部楼层
如此的优秀
发表于 2020-5-23 12:50:47 | 显示全部楼层
发表于 2020-7-3 09:33:19 | 显示全部楼层
来一波完全看不懂的点赞!!!
发表于 2020-7-7 10:30:40 | 显示全部楼层
看不懂,但是觉得很牛逼
发表于 2020-7-20 09:06:15 | 显示全部楼层
虽然看不懂,但是大神无私奉献的精神值得我们学习。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|HGEM2论坛

GMT+8, 2024-9-21 15:30 , Processed in 0.527138 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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