本帖最后由 ahsin 于 2021-11-10 17:59 编辑
代码加了注释,方便各位小伙伴看懂
根据cgmsv21.2a自带的 lua/module/newbiebless.lua修改
1、40级以下新人,免费战后满血满魔
2、41开始,需要身上携带指定道具,才能自动满血满魔,道具编号为711152
3、经验祝福系统未改动
4、战斗后自动理包功能,通过角色人物的交易开关识别,如果【易】点亮了,将自动丢指定道具
5、代码中找到laji、laji2、laji3,参考自动丢垃圾范围写法
Delegate.RegDelBattleOverEvent("NewbieBless_BattleOver");
local zdbj = 711152--战斗补给包
--战斗结束全局事件
function NewbieBless_BattleOver(_battle)
for i=0,9 do
local player = Battle.GetPlayer(_battle,i);
local petindex = Char.GetData(player,%对象_战宠%)
local petindex2 = Char.GetPet(player,petindex)
--if player > -1 and Char.GetData(player,%对象_等级%) <= 40 and Char.GetData(player,%对象_血%) < Char.GetData(player,%对象_最大血%) then
if player > -1 and Char.GetData(player,%对象_等级%) <= 40 then
Char.SetData(player,%对象_血%,Char.GetData(player,%对象_最大血%));
Char.SetData(player,%对象_魔%,Char.GetData(player,%对象_最大魔%));
Char.SetData(petindex2,%对象_血%,Char.GetData(petindex2,%对象_最大血%));
Char.SetData(petindex2,%对象_魔%,Char.GetData(petindex2,%对象_最大魔%));
NLG.UpChar(petindex);
NLG.UpChar(petindex2);
NLG.UpChar(player);
NLG.SystemMessage(player,"[新手庇护]"..Char.GetData(player,%对象_名字%).."40级及以下玩家,血魔免费自动全满.");
end
if(player > -1 and Char.GetData(player,%对象_战死%)==0 and Char.GetData(player,%对象_获得经验%)>1 and Battle.GetGainMode(_battle)==%战奖_普通% and Battle.GetType(_battle)==%战斗_普通%) then
local battlePrize = math.random(1,100);
if(battlePrize >=80 and battlePrize<=82 )then
Char.SetData(player,%对象_获得经验%,Char.GetData(player,%对象_获得经验%)*103/100);
NLG.UpChar(player);
NLG.SystemMessage(player,"[战神庇护]"..Char.GetData(player,%对象_名字%).."受到了战神的祝福,本场战斗经验值增加3%.");
elseif(battlePrize >=97 and battlePrize<=99 )then
Char.SetData(player,%对象_获得经验%,Char.GetData(player,%对象_获得经验%)*106/100);
NLG.UpChar(player);
NLG.SystemMessage(player,"[战神庇护]"..Char.GetData(player,%对象_名字%).."受到了战神的祝福,本场战斗经验值增加6%.");
elseif(battlePrize >=1 and battlePrize<=2 )then
local battlePrizeGold = math.random(50,500);
Char.AddGold(player,battlePrizeGold);
NLG.SystemMessage(player,"[财神庇护]"..Char.GetData(player,%对象_名字%).."受到了财神的祝福,战斗获得"..battlePrizeGold.."金钱奖励.");
elseif(battlePrize >=9 and battlePrize<=12 )then
Char.SetData(player,%对象_获得经验%,Char.GetData(player,%对象_获得经验%)*97/100);
NLG.UpChar(player);
NLG.SystemMessage(player,"[衰神诅咒]"..Char.GetData(player,%对象_名字%).."受到了衰神的诅咒,本场战斗所得经验降低3%.");
end
end
--230236979魔力自动战斗补给开始
if Char.HaveItem(player,zdbj) >= 1 and Char.GetData(player,%对象_等级%) > 40 then
if Char.HaveItem(player,zdbj) == 1 then--最后1个自动补给道具提醒
Char.DelItem(player,zdbj,1)
Char.SetData(player,%对象_血%,Char.GetData(player,%对象_最大血%));
Char.SetData(player,%对象_魔%,Char.GetData(player,%对象_最大魔%));
Char.SetData(petindex2,%对象_血%,Char.GetData(petindex2,%对象_最大血%));
Char.SetData(petindex2,%对象_魔%,Char.GetData(petindex2,%对象_最大魔%));
NLG.UpChar(petindex);
NLG.UpChar(petindex2);
NLG.UpChar(player);
--NLG.SystemMessage(player,"[自动补给]您的血魔已经回复,感谢购买。");
--NLG.SystemMessage(player,"你的战备奶包用光啦!下次战斗记得不要死哦。");
NLG.Say(player,-1,"你的战备奶包用光啦!下次战斗记得不要死哦。",6,3)
else
Char.DelItem(player,zdbj,1)
Char.SetData(player,%对象_血%,Char.GetData(player,%对象_最大血%));
Char.SetData(player,%对象_魔%,Char.GetData(player,%对象_最大魔%));
Char.SetData(petindex2,%对象_血%,Char.GetData(petindex2,%对象_最大血%));
Char.SetData(petindex2,%对象_魔%,Char.GetData(petindex2,%对象_最大魔%));
NLG.UpChar(petindex);
NLG.UpChar(petindex2);
NLG.UpChar(player);
--NLG.SystemMessage(player,"[自动补给]您的血魔已经回复,感谢购买。");
NLG.Say(player,-1,"自动回复完成,战备奶包还剩 "..Char.HaveItem(player,zdbj).." 个。",5,3)
end
end
if Char.GetData(player,%对象_交易开关%) == 1 then--自动丢垃圾+理包
for laji = 14801,15055 do--3.0图鉴
Char.DelItem(player,laji,99)
end
for laji2 = 606600,606691 do--7.0图鉴
Char.DelItem(player,laji2,99)
end
for laji3 = 18310,18313 do--水晶碎片
Char.DelItem(player,laji3,99)
end
Char.DelItem(player,18194,99)--红头盔
Char.DelItem(player,18195,99)--绿头盔
NLG.SortItem(player);
NLG.Say(player,-1,"检测到你开启了交易,战斗后包包自动清理完毕。",1,3)
--NLG.SystemMessage(player,"检测到你开启了交易,战斗后包包自动清理完毕。");
end
end
return 1;
end
复制代码