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

修改祝福系统newbiebless.lua,变成战后回血魔、理包、丢垃圾

[复制链接]

发表于 2021-11-10 17:55:41 | 显示全部楼层 |阅读模式
本帖最后由 ahsin 于 2021-11-10 17:59 编辑

代码加了注释,方便各位小伙伴看懂

根据cgmsv21.2a自带的 lua/module/newbiebless.lua修改

1、40级以下新人,免费战后满血满魔
2、41开始,需要身上携带指定道具,才能自动满血满魔,道具编号为711152
3、经验祝福系统未改动
4、战斗后自动理包功能,通过角色人物的交易开关识别,如果【易】点亮了,将自动丢指定道具
5、代码中找到laji、laji2、laji3,参考自动丢垃圾范围写法


  1. Delegate.RegDelBattleOverEvent("NewbieBless_BattleOver");
  2. local zdbj = 711152--战斗补给包
  3. --战斗结束全局事件
  4. function NewbieBless_BattleOver(_battle)
  5.         for i=0,9 do
  6.                 local player = Battle.GetPlayer(_battle,i);
  7.                 local petindex = Char.GetData(player,%对象_战宠%)
  8.                 local petindex2 = Char.GetPet(player,petindex)
  9.                 --if player > -1 and Char.GetData(player,%对象_等级%) <= 40 and Char.GetData(player,%对象_血%) < Char.GetData(player,%对象_最大血%) then
  10.                 if player > -1 and Char.GetData(player,%对象_等级%) <= 40 then
  11.                         Char.SetData(player,%对象_血%,Char.GetData(player,%对象_最大血%));
  12.                         Char.SetData(player,%对象_魔%,Char.GetData(player,%对象_最大魔%));
  13.                         Char.SetData(petindex2,%对象_血%,Char.GetData(petindex2,%对象_最大血%));
  14.                         Char.SetData(petindex2,%对象_魔%,Char.GetData(petindex2,%对象_最大魔%));
  15.                         NLG.UpChar(petindex);
  16.                         NLG.UpChar(petindex2);
  17.                         NLG.UpChar(player);
  18.                         NLG.SystemMessage(player,"[新手庇护]"..Char.GetData(player,%对象_名字%).."40级及以下玩家,血魔免费自动全满.");
  19.                 end
  20.                 if(player > -1 and Char.GetData(player,%对象_战死%)==0 and Char.GetData(player,%对象_获得经验%)>1 and Battle.GetGainMode(_battle)==%战奖_普通% and Battle.GetType(_battle)==%战斗_普通%) then
  21.                         local battlePrize = math.random(1,100);
  22.                         if(battlePrize >=80 and battlePrize<=82 )then
  23.                                 Char.SetData(player,%对象_获得经验%,Char.GetData(player,%对象_获得经验%)*103/100);
  24.                                 NLG.UpChar(player);
  25.                                 NLG.SystemMessage(player,"[战神庇护]"..Char.GetData(player,%对象_名字%).."受到了战神的祝福,本场战斗经验值增加3%.");
  26.                         elseif(battlePrize >=97 and battlePrize<=99 )then
  27.                                 Char.SetData(player,%对象_获得经验%,Char.GetData(player,%对象_获得经验%)*106/100);
  28.                                 NLG.UpChar(player);
  29.                                 NLG.SystemMessage(player,"[战神庇护]"..Char.GetData(player,%对象_名字%).."受到了战神的祝福,本场战斗经验值增加6%.");
  30.                         elseif(battlePrize >=1 and battlePrize<=2 )then
  31.                                 local battlePrizeGold = math.random(50,500);
  32.                                 Char.AddGold(player,battlePrizeGold);
  33.                                 NLG.SystemMessage(player,"[财神庇护]"..Char.GetData(player,%对象_名字%).."受到了财神的祝福,战斗获得"..battlePrizeGold.."金钱奖励.");
  34.                         elseif(battlePrize >=9 and battlePrize<=12 )then
  35.                                 Char.SetData(player,%对象_获得经验%,Char.GetData(player,%对象_获得经验%)*97/100);
  36.                                 NLG.UpChar(player);
  37.                                 NLG.SystemMessage(player,"[衰神诅咒]"..Char.GetData(player,%对象_名字%).."受到了衰神的诅咒,本场战斗所得经验降低3%.");
  38.                         end
  39.                 end
  40.                 --230236979魔力自动战斗补给开始
  41.                 if Char.HaveItem(player,zdbj) >= 1 and Char.GetData(player,%对象_等级%) > 40 then
  42.                         if Char.HaveItem(player,zdbj) == 1 then--最后1个自动补给道具提醒
  43.                                 Char.DelItem(player,zdbj,1)
  44.                                 Char.SetData(player,%对象_血%,Char.GetData(player,%对象_最大血%));
  45.                                 Char.SetData(player,%对象_魔%,Char.GetData(player,%对象_最大魔%));
  46.                                 Char.SetData(petindex2,%对象_血%,Char.GetData(petindex2,%对象_最大血%));
  47.                                 Char.SetData(petindex2,%对象_魔%,Char.GetData(petindex2,%对象_最大魔%));
  48.                                 NLG.UpChar(petindex);
  49.                                 NLG.UpChar(petindex2);
  50.                                 NLG.UpChar(player);
  51.                                 --NLG.SystemMessage(player,"[自动补给]您的血魔已经回复,感谢购买。");
  52.                                 --NLG.SystemMessage(player,"你的战备奶包用光啦!下次战斗记得不要死哦。");
  53.                                 NLG.Say(player,-1,"你的战备奶包用光啦!下次战斗记得不要死哦。",6,3)
  54.                         else
  55.                                 Char.DelItem(player,zdbj,1)
  56.                                 Char.SetData(player,%对象_血%,Char.GetData(player,%对象_最大血%));
  57.                                 Char.SetData(player,%对象_魔%,Char.GetData(player,%对象_最大魔%));
  58.                                 Char.SetData(petindex2,%对象_血%,Char.GetData(petindex2,%对象_最大血%));
  59.                                 Char.SetData(petindex2,%对象_魔%,Char.GetData(petindex2,%对象_最大魔%));
  60.                                 NLG.UpChar(petindex);
  61.                                 NLG.UpChar(petindex2);
  62.                                 NLG.UpChar(player);
  63.                                 --NLG.SystemMessage(player,"[自动补给]您的血魔已经回复,感谢购买。");
  64.                                 NLG.Say(player,-1,"自动回复完成,战备奶包还剩 "..Char.HaveItem(player,zdbj).." 个。",5,3)
  65.                         end                        
  66.                 end
  67.                 if Char.GetData(player,%对象_交易开关%) == 1 then--自动丢垃圾+理包
  68.                         for laji = 14801,15055 do--3.0图鉴
  69.                                 Char.DelItem(player,laji,99)
  70.                         end
  71.                         for laji2 = 606600,606691 do--7.0图鉴
  72.                                 Char.DelItem(player,laji2,99)
  73.                         end
  74.                         for laji3 = 18310,18313 do--水晶碎片
  75.                         Char.DelItem(player,laji3,99)
  76.                         end
  77.                         Char.DelItem(player,18194,99)--红头盔
  78.                         Char.DelItem(player,18195,99)--绿头盔
  79.                         NLG.SortItem(player);
  80.                         NLG.Say(player,-1,"检测到你开启了交易,战斗后包包自动清理完毕。",1,3)
  81.                         --NLG.SystemMessage(player,"检测到你开启了交易,战斗后包包自动清理完毕。");
  82.                 end
  83.         end
  84.         return 1;
  85. end
复制代码


您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

GMT+8, 2026-6-5 09:14 , Processed in 0.029646 second(s), 2 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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