cgmsv引擎论坛

 找回密码
 注册/Sign up
搜索
查看: 1161|回复: 7

使用血瓶、料理或其他东西来补充血魔池的lua

[复制链接]

Rank: 1

发表于 2022-11-11 05:39:28 | 显示全部楼层 |阅读模式
修改自muscipular的manapool.lua

想法源自http://bbs.cgmsv.com/thread-1402-1-1.html

9ec46ffe83f750ead2e5eb98f79a6ac1.jpeg



功能如:
30以下免费使用血魔池,但只能充10000封顶
30以上需要使用血瓶兑换血池
30以上需要使用料理兑换魔池


改过的地方能注释都注释了
  1. --修改自muscipular的manapool.lua,wx18602101887
  2. local Module = ModuleBase:createModule('manaPool')
  3. local xue = 15615--可生产出的1000血瓶的编号
  4. local liaoli = 15218--可生产出的鱼翅汤编号
  5. local caijishangxian = 10000--新人免费血魔池充能上限
  6. local caijidengji = 30--新人保护,免费充能等级
  7. local itemList = {
  8.         --想要1瓶血换大量补充,改value即可,蓝同理
  9.   { name = '血池补充2000HP', image = 27243, price = 10, desc = '使用1瓶生命力回复药(2000),来补充血池使用量2000点,等级低于'..caijidengji..'的新人免费使用。', count = 1, maxCount = 999, value = 2000, type = 'lp' },
  10.   --{ name = '血池补充(10000LP)', image = 27243, price = 14500, desc = '使用10瓶生命力回复药(1000),来补充血池使用量10000点', count = 1, maxCount = 999, value = 1000, type = 'lp' },
  11.   --{ name = '血池补充(100000LP)', image = 27243, price = 140000, desc = '使用100瓶生命力回复药(1000),来补充血池使用量100000点', count = 1, maxCount = 999, value = 100000, type = 'lp' },
  12.   --原先muscipular使用的魔池道具图档编号为26206
  13.   { name = '魔池补充2000MP', image = 26745, price = 20, desc = '使用1碗鱼翅汤,来补充魔池使用量2000点,等级低于'..caijidengji..'的新人免费使用。', count = 1, maxCount = 999, value = 2000, type = 'fp' },
  14.   --{ name = '魔池补充(10000FP)', image = 26745, price = 24500, desc = '使用10碗鱼翅汤,来补充魔池使用量10000点', count = 1, maxCount = 999, value = 10000, type = 'fp' },
  15.   --{ name = '魔池补充(100000FP)', image = 26745, price = 240000, desc = '使用100碗鱼翅汤,来补充魔池使用量100000点', count = 1, maxCount = 999, value = 100000, type = 'fp' },
  16. }
  17. --- 加载模块钩子
  18. function Module:onLoad()
  19.   self:logInfo('load')
  20.   local npc = self:NPC_createNormal('血魔池科技', 100602, { map = 1000, x = 227, y = 83, direction = 4, mapType = 0 })
  21.   self:NPC_regTalkedEvent(npc, Func.bind(self.onSellerTalked, self))
  22.   self:NPC_regWindowTalkedEvent(npc, Func.bind(self.onSellerSelected, self));
  23.   self:regCallback('ResetCharaBattleStateEvent', Func.bind(self.onBattleReset, self))
  24. end
  25. function Module:onBattleReset(charIndex)
  26.   if Char.IsDummy(charIndex) then
  27.     return
  28.   end
  29.   local lpPool = tonumber(Field.Get(charIndex, 'LpPool')) or 0;
  30.   local fpPool = tonumber(Field.Get(charIndex, 'FpPool')) or 0;
  31.   if lpPool <= 0 and fpPool <= 0 then
  32.     return
  33.   end
  34.   local lp = Char.GetData(charIndex, CONST.CHAR_血)
  35.   local maxLp = Char.GetData(charIndex, CONST.CHAR_最大血)
  36.   local fp = Char.GetData(charIndex, CONST.CHAR_魔)
  37.   local maxFp = Char.GetData(charIndex, CONST.CHAR_最大魔)
  38.   if lpPool > 0 and lp < maxLp then
  39.     lpPool = lpPool - maxLp + lp;
  40.     if lpPool < 0 then
  41.       maxLp = maxLp + lpPool;
  42.       lpPool = 0;
  43.     end
  44.     --NLG.SystemMessage(charIndex, '[血魔池] 已恢复人物: ' .. (maxLp - lp) .. 'HP, 血池剩余: ' .. lpPool);
  45.         NLG.Say(charIndex,-1,'[血池] 你回复了: ' .. (maxLp - lp) .. 'HP, 剩余: ' .. lpPool,11,2)
  46.   else
  47.     maxLp = lp;
  48.   end
  49.   if fpPool > 0 and fp < maxFp then
  50.     fpPool = fpPool - maxFp + fp;
  51.     if fpPool < 0 then
  52.       maxFp = maxFp + fpPool;
  53.       fpPool = 0;
  54.     end
  55.     --NLG.SystemMessage(charIndex, '[血魔池] 已恢复人物: ' .. (maxFp - fp) .. 'MP, 魔池剩余: ' .. fpPool);
  56.         NLG.Say(charIndex,-1,'[魔池] 你回复了: ' .. (maxFp - fp) .. 'MP, 剩余: ' .. fpPool,8,2)
  57.   else
  58.     maxFp = fp;
  59.   end
  60.   Char.SetData(charIndex, CONST.CHAR_血, maxLp)
  61.   Char.SetData(charIndex, CONST.CHAR_魔, maxFp)
  62.   NLG.UpChar(charIndex);
  63.   local petIndex = Char.GetData(charIndex, CONST.CHAR_战宠);
  64.   if petIndex >= 0 then
  65.     petIndex = Char.GetPet(charIndex, petIndex);
  66.     lp = Char.GetData(petIndex, CONST.CHAR_血)
  67.     maxLp = Char.GetData(petIndex, CONST.CHAR_最大血)
  68.     fp = Char.GetData(petIndex, CONST.CHAR_魔)
  69.     maxFp = Char.GetData(petIndex, CONST.CHAR_最大魔)
  70.     if lpPool > 0 and lp < maxLp then
  71.       lpPool = lpPool - maxLp + lp;
  72.       if lpPool < 0 then
  73.         maxLp = maxLp + lpPool;
  74.         lpPool = 0;
  75.       end
  76.       --NLG.SystemMessage(charIndex, '[血魔池] 已恢复宠物: ' .. (maxLp - lp) .. 'HP, 血池剩余: ' .. lpPool);
  77.           NLG.Say(charIndex,-1,'[血池] 宠物回复了: ' .. (maxLp - lp) .. 'HP, 剩余: ' .. lpPool,11,2)
  78.     else
  79.       maxLp = lp;
  80.     end
  81.     if fpPool > 0 and fp < maxFp then
  82.       fpPool = fpPool - maxFp + fp;
  83.       if fpPool < 0 then
  84.         maxFp = maxFp + fpPool;
  85.         fpPool = 0;
  86.       end
  87.       --NLG.SystemMessage(charIndex, '[血魔池] 已恢复宠物: ' .. (maxFp - fp) .. 'MP, 魔池剩余: ' .. fpPool);
  88.           NLG.Say(charIndex,-1,'[魔池] 宠物回复了: ' .. (maxFp - fp) .. 'MP, 剩余: ' .. fpPool,8,2)
  89.     else
  90.       maxFp = fp;
  91.     end
  92.     Char.SetData(petIndex, CONST.CHAR_血, maxLp)
  93.     Char.SetData(petIndex, CONST.CHAR_魔, maxFp)
  94.     NLG.UpChar(petIndex);
  95.   end
  96.   Field.Set(charIndex, 'LpPool', tostring(lpPool));
  97.   Field.Set(charIndex, 'FpPool', tostring(fpPool));
  98. end
  99. function Module:onSellerTalked(npc, player)
  100.         if NLG.CanTalk(npc, player) then
  101.                 local dengji = Char.GetData(player, %对象_等级%)--获取玩家等级
  102.                         if dengji <= caijidengji then--新人保护,免费使用
  103.                         --NLG.SystemMessage(player, '你是'..caijidengji..'级及以下新人玩家,血魔池免费固定补充为:HP'..caijishangxian..'、MP'..caijishangxian..'。')
  104.                         Field.Set(player, 'LpPool', tonumber(caijishangxian))
  105.                         Field.Set(player, 'FpPool', tonumber(caijishangxian))
  106.                         NLG.ShowWindowTalked(player,npc,%窗口_信息框%,%按钮_确定%,666,'@c\n\n\n你是'..caijidengji..'级及以下新人玩家,血魔池免费固定补充为:HP'..caijishangxian..'、MP'..caijishangxian..'。')
  107.                         NLG.SystemMessage(player, '[血魔池] 补充血池: '..caijishangxian..', 共: '..caijishangxian..'');
  108.                         NLG.SystemMessage(player, '[血魔池] 补充魔池: '..caijishangxian..', 共: '..caijishangxian..'');
  109.                         NLG.SystemMessage(player, '新人,你已经获得强大buff,快去送。');
  110.                         NLG.WalkMove(player,4)--节约cpu
  111.                         NLG.WalkMove(player,4)--降低功耗
  112.                         return
  113.                         end
  114.                 NLG.ShowWindowTalked(player, npc, CONST.窗口_商店买, CONST.BUTTON_是, 0,
  115.                 self:NPC_buildBuyWindowData(101024, '血池黑科技', '充能血魔池', '金钱不足', '背包已满', itemList))
  116.         end
  117. end
  118. function Module:onSellerSelected(npc, player, seqNo, select, data)
  119.   local items = string.split(data, '|');
  120.   local lpPool = tonumber(Field.Get(player, 'LpPool')) or 0;
  121.   local fpPool = tonumber(Field.Get(player, 'FpPool')) or 0;
  122.   local gold = Char.GetData(player, CONST.CHAR_金币)
  123.   local totalGold = 0;
  124.   local totalLp = 0;
  125.   local totalFp = 0;
  126.   local xpsl = 0--获取玩家商店点击血瓶数量
  127.   local llsl = 0--获取玩家商店点击料理数量
  128.   local dengji = Char.GetData(player, %对象_等级%)--获取玩家等级
  129.   local youxp = Char.HaveItem(player,xue)--玩家身上血瓶数量
  130.   local youll = Char.HaveItem(player,liaoli)--玩家身上料理数量
  131.   for i = 1, #items / 2 do
  132.     local c = itemList[items[(i - 1) * 2 + 1] + 1]
  133.     if c then
  134.       local count = (tonumber(items[(i - 1) * 2 + 2]) or 0);
  135.       if c.type == 'lp' then--红
  136.         totalLp = totalLp + c.value * count;
  137.                 xpsl = tonumber(count)
  138.                 print('玩家选择的红数量:'..xpsl..'')
  139.       else--蓝
  140.         totalFp = totalFp + c.value * count;
  141.                 llsl = tonumber(count)
  142.                 print('玩家选择的蓝数量:'..llsl..'')
  143.       end
  144.       totalGold = totalGold + c.price * count;
  145.     end
  146.   end
  147.         if gold < totalGold then
  148.     NLG.SystemMessage(player, '金币不足');
  149.     return
  150.         elseif dengji > caijidengji and xpsl > 0 and llsl > 0 and youxp < xpsl and youll < llsl then
  151.         NLG.SystemMessage(player, '生命力回复药(1000)差 '..xpsl-youxp..' 瓶,鱼翅汤差 '..llsl-youll..' 碗,血魔池补充失败。')
  152.         return
  153.         elseif dengji > caijidengji and xpsl > 0 and youxp < xpsl then
  154.         NLG.SystemMessage(player, '生命力回复药(1000)差 '..xpsl-youxp..' 瓶,血魔池补充失败。')
  155.         return
  156.         elseif dengji > caijidengji and llsl > 0 and youll < llsl then
  157.         NLG.SystemMessage(player, '鱼翅汤差 '..llsl-youll..' 碗,血魔池补充失败。')
  158.         return
  159.         end
  160.   Char.AddGold(player, -totalGold);
  161.   if xpsl > 0 then
  162.   Char.DelItem(player,xue,xpsl)
  163.   end
  164.   if llsl > 0 then
  165.   Char.DelItem(player,liaoli,llsl)
  166.   end
  167.   Field.Set(player, 'LpPool', tostring(lpPool + totalLp));
  168.   Field.Set(player, 'FpPool', tostring(fpPool + totalFp));
  169.   NLG.UpChar(player);
  170.   if totalLp > 0 then
  171.     NLG.SystemMessage(player, '[血魔池] 补充血池: ' .. totalLp .. ', 共: ' .. (lpPool + totalLp));
  172.   end
  173.   if totalFp > 0 then
  174.     NLG.SystemMessage(player, '[血魔池] 补充魔池: ' .. totalFp .. ', 共: ' .. (fpPool + totalFp));
  175.   end
  176. end
  177. --- 卸载模块钩子
  178. function Module:onUnload()
  179.   self:logInfo('unload')
  180. end
  181. return Module;
复制代码






Rank: 1

 楼主| 发表于 2022-11-11 05:46:27 | 显示全部楼层
做好备份,然后直接替换lua/modules/manapool.lua中所有代码

哎呀呀,无法直接贴代码了,论坛安全策略改变了

查收文件吧

manaPool.rar (2.42 KB, 下载次数: 120)

Rank: 1

发表于 2022-11-11 09:42:56 | 显示全部楼层
人在上班中
一看到文章,馬上先偷偷上來跟你說聲感謝
真是太謝謝你了!!

下班回家來試試看!!!!!

Rank: 1

发表于 2022-11-12 01:31:16 | 显示全部楼层
试试看好用不好用。

Rank: 1

发表于 2022-11-12 10:18:46 | 显示全部楼层
大佬厉害,试试看怎么用

Rank: 1

发表于 2022-11-12 14:53:13 | 显示全部楼层
大佬厉害,试试看怎么用

Rank: 1

发表于 2022-11-24 14:28:41 | 显示全部楼层
大佬牛皮 马上去试试

Rank: 1

发表于 2022-11-30 16:50:24 | 显示全部楼层
大佬牛皮 马上去试试
您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

GMT+8, 2024-5-19 09:49 , Processed in 0.181935 second(s), 11 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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