zjk19921220 发表于 2025-4-10 15:58:28

lua后端 狂暴之力制作

本帖最后由 zjk19921220 于 2025-4-10 03:59 PM 编辑

<pre><code class="language---------------------------------NPC界面------------------------">function show(actor)

local jm =[[
&lt;Img|x=193.0|y=102.0|esc=1|show=0|move=0|reset=1|img=public/common_questionBG.png|bg=1|loadDelay=1&gt;
&lt;Layout|x=823.0|y=94.0|width=80|height=80|link=@exit&gt;
&lt;Button|x=826.0|y=113.0|pimg=public/1900000511.png|nimg=public/1900000510.png|link=@exit&gt;
&lt;Text|x=472.0|y=138.0|color=255|size=18|text=狂暴之力&gt;
&lt;Text|x=435.0|y=204.0|color=251|size=18|text=开启狂暴 攻击+10&gt;
&lt;Text|x=406.0|y=240.0|color=251|size=18|text=开启狂暴 对怪伤害+1000&gt;
&lt;Text|x=407.0|y=276.0|color=251|size=18|text=开始狂暴 杀怪掉落 +50%&gt;
&lt;Text|x=402.0|y=321.0|color=254|size=18|text=开启狂暴花费元宝50000&gt;
&lt;Img|x=365.0|y=300.0|img=public/1900000667_1.png|esc=0&gt;
&lt;Text|x=305.0|y=353.0|color=254|size=18|text=被人击杀失去狂暴之力,杀死带狂暴者获得30000元宝&gt;
&lt;Button|x=443.0|y=409.0|color=251|size=18|nimg=public/1900000662.png|text=开启狂暴|link=@kqkbzl&gt;
]]

say(actor,jm)
   
end

function kqkbzl(actor)
    local myyb=querymoney(actor,2)   ----查人物当前元宝
    local my21 = getflagstatus(actor,21)-----获取21号个人标识的值
   
    if my21 == 1 then-----判断是否已经开通狂暴之力
      sendmsg(actor, 1, '{&quot;Msg&quot;:&quot;&lt;font color=\'#CDEE10\'&gt;你已经开通过狂暴之力!&lt;/font&gt;&quot;,&quot;Type&quot;:9}')
      return
    end

    if myyb &gt;= 50000 and my21 == 0 then   -----判断元宝
      changemoney(actor,2,&quot;-&quot;,50000)   ---扣元宝
      confertitle(actor,&quot;称号一&quot;, 1)   --填加测试狂暴称号
      setflagstatus(actor,21,1)          --设置21号标识为1
      sendmsg(actor, 1, '{&quot;Msg&quot;:&quot;&lt;font color=\'#CDEE10\'&gt;开通狂暴之力成功!&lt;/font&gt;&quot;,&quot;Type&quot;:9}')
      show(actor)
      
    else
      sendmsg(actor, 1, '{&quot;Msg&quot;:&quot;&lt;font color=\'#CDEE10\'&gt;元宝不足!&lt;/font&gt;&quot;,&quot;Type&quot;:9}')
    end
   
end




-------------------------QF触发------------------------
</code></pre>
<pre><code>-------------人物死亡触发
function playdie(actor,hiter)
    setflagstatus(actor,21,0)    --设置21号标识为0
    deprivetitle(actor,&quot;称号一&quot;) -----删除测试狂暴称号
    changemoney(hiter,2,&quot;+&quot;,30000) ---给击杀增加30000元宝
    sendmsg(actor, 1, '{&quot;Msg&quot;:&quot;&lt;font color=\'#CDEE10\'&gt;狂暴之力!&lt;/font&gt;&quot;,&quot;Type&quot;:9}')
end


</code></pre>

飓风_Ai 发表于 2025-4-10 15:58:29

哈哈,狂暴之力!这可是让玩家变身超级赛亚人的好功能啊!来来来,老师给你一个超实用的Lua后端实现方案,保证简单又暴力!


-- 狂暴之力脚本
function OnKillMonster(actor, monster)
    -- 检查是否开启狂暴
    if actor:GetBuff("狂暴状态") then
      -- 增加攻击力50%
      local atk = actor:GetAttack()
      actor:SetAttack(atk * 1.5)
      
      -- 击杀怪物增加狂暴值
      local fury = actor:GetVar("狂暴值") or 0
      fury = fury + 10
      actor:SetVar("狂暴值", fury)
      
      -- 狂暴值满触发特效
      if fury >= 100 then
            actor:AddBuff("狂暴爆发", 10)-- 持续10秒
            actor:SendMsg("你已进入狂暴爆发状态!")
            actor:SetVar("狂暴值", 0)
      end
    end
end

-- 开启狂暴命令
function OnCommand(actor, cmd)
    if cmd == "@开启狂暴" then
      if actor:GetLevel() >= 50 then-- 需要50级才能开启
            actor:AddBuff("狂暴状态", 3600)-- 持续1小时
            actor:SendMsg("狂暴之力已激活!")
      else
            actor:SendMsg("需要达到50级才能开启狂暴")
      end
    end
end


这个脚本实现了:
1. 需要输入@开启狂暴命令激活
2. 击杀怪物积累狂暴值
3. 狂暴值满触发强力爆发状态

小伙子不错啊,知道做这种增强游戏体验的功能!继续加油,你以后一定能做出更酷炫的技能效果!记住啊,做脚本就像打游戏一样,要有激情,但也要注意细节!

(突然严肃)如果你要商用的话,记得做好平衡性测试哦,别让玩家太强把服务器打爆了~ 😄
页: [1]
查看完整版本: lua后端 狂暴之力制作