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

[LUA] 初学 弄了个恢复效果常驻试试

[复制链接]

发表于 2025-4-29 19:19:17 | 显示全部楼层 |阅读模式
  1. NL.RegBattleStartEvent(nil,"Bts_Event");
  2. NL.RegBattleActionEvent(nil,"Bta_Event");
  3. function Bta_Event(CharIndex,con1,con2,con3,order)
  4.                         if(VaildChar(CharIndex)==true) then
  5.                                 local Pf1 = Char.GetData(CharIndex,%对象_OtherFlg%);
  6.                                         if(bit_and(Pf1,4194304) >= 1 and order == 1) then
  7.                                                 local Phf1 = Char.GetData(CharIndex,%对象_回复%);
  8.                                                 Battle.SetBattleCharacterStatus(CharIndex, %战属_恢复魔法%,Phf1 * 100);
  9.                                                 Battle.SetBattleCharacterStatus(CharIndex, %战属_恢复回合%,1000);
  10.                                         end
  11.                         end                                                                                                          
  12.         return ;
  13. end
  14. function Bts_Event(BattleIndex)
  15.         return ;
  16. end
  17. function bit_and(a, b)
  18.     local p, c = 1, 0;
  19.     while a + b > 0 do
  20.         local am, bm = a % 2, b % 2;
  21.         if am + bm >= 2 then
  22.             c = c + p;
  23.         end
  24.         a, b, p = math.floor(a / 2), math.floor(b / 2), p * 2;
  25.     end
  26.     return c
  27. end
复制代码

不知道会不会有错误,有大佬指导一下吗?



 楼主| 发表于 2025-5-2 13:58:46 | 显示全部楼层
本帖最后由 richvert 于 2025-5-2 14:18 编辑

稍微补充了点功能
  1. NL.RegBattleStartEvent(nil,"Bts_Event");
  2. NL.RegBattleActionEvent(nil,"Bta_Event");
  3. NL.RegTechOptionEvent(nil,"Bto_Event");
  4. NL.RegDamageCalculateEvent(nil,"Bdc_Event");
  5. --1:双倍伤害 2:受伤害减半 3:元素魔法伤害三倍 4:连击次数+2,伤害+50% 5:状态魔法成功率100% 6:补血魔法效果三倍 7:恢复魔法效果两倍,持续60回合 8:战斗开始状态回复满 9:恢复效果常驻
  6. local CONTANS_SKILL_1=1073741824;
  7. local CONTANS_SKILL_2=536870912;
  8. local CONTANS_SKILL_3=268435456;
  9. local CONTANS_SKILL_4=134217728;
  10. local CONTANS_SKILL_5=67108864;
  11. local CONTANS_SKILL_6=33554432;
  12. local CONTANS_SKILL_7=16777216;
  13. local CONTANS_SKILL_8=8388608;
  14. local CONTANS_SKILL_9=4194304;
  15. function Bdc_Event(CharIndex, DefCharIndex, OriDamage, Damage, BattleIndex, Com1, Com2, Com3, DefCom1, DefCom2, DefCom3, Flg)
  16.         local zdamage = 0;
  17.         local Pf1 = Char.GetData(CharIndex,%对象_OtherFlg%);
  18.         local Pf2 = Char.GetData(DefCharIndex,%对象_OtherFlg%);
  19.         zdamage = Damage;
  20.         if (bit_and(Pf1,CONTANS_SKILL_1) >= 1) then
  21.                 zdamage = Damage * 2;
  22.         end
  23.         if (bit_and(Pf2,CONTANS_SKILL_2) >= 1) then
  24.                 zdamage = Damage * 0.5;
  25.         end
  26.         return zdamage;
  27. end
  28. function Bto_Event(CharIndex, Option, TechID, Val)
  29.         local Pf1 = Char.GetData(CharIndex,%对象_OtherFlg%);
  30.         if (TechID <= 3009 and TechID >= 1900 and bit_and(Pf1,CONTANS_SKILL_3) >= 1) then
  31.                 if Option == "AR:" then
  32.                     return Val*3
  33.                 end
  34.         end
  35.         if (TechID <= 9 and TechID >= 0 and bit_and(Pf1,CONTANS_SKILL_4) >= 1) then
  36.                 if Option == "AN:" then
  37.                     return Val+2
  38.                 end
  39.                 if Option == "AM:" then
  40.                     return Val+2
  41.                 end
  42.                 if Option == "DD:" then
  43.                     return Val+50
  44.                 end
  45.         end
  46.         if (TechID <= 4909 and TechID >= 3200 and bit_and(Pf1,CONTANS_SKILL_5) >= 1) then
  47.                 if Option == "SR:" then
  48.                     return 100
  49.                 end
  50.         end
  51.         if (TechID <= 6309 and TechID >= 6100 and bit_and(Pf1,CONTANS_SKILL_6) >= 1) then
  52.                 if Option == "AR:" then
  53.                     return Val*3
  54.                 end
  55.         end
  56.         if (TechID <= 6609 and TechID >= 6400 and bit_and(Pf1,CONTANS_SKILL_7) >= 1) then
  57.                 if Option == "CH:" then
  58.                     return Val*10
  59.                 end
  60.                 if Option == "RR:" then
  61.                     return Val*2
  62.                 end
  63.         end
  64.   return Val
  65. end
  66. function Bta_Event(CharIndex,con1,con2,con3,order)
  67.         if(VaildChar(CharIndex)==true) then
  68.                 local Pf1 = Char.GetData(CharIndex,%对象_OtherFlg%);
  69.                 if(bit_and(Pf1,CONTANS_SKILL_9) >= 1 and order == 1) then
  70.                         local Phf1 = Char.GetData(CharIndex,%对象_回复%);
  71.                         Battle.SetBattleCharacterStatus(CharIndex, %战属_恢复魔法%,Phf1 * 100);
  72.                         Battle.SetBattleCharacterStatus(CharIndex, %战属_恢复回合%,1000);
  73.                 end
  74.         end                                                                                                         
  75.         return ;
  76. end               
  77. function Bts_Event(BattleIndex)
  78.         for BWhile=0,19 do
  79.                 local CharIndex = Battle.GetPlayer(BattleIndex,BWhile);
  80.                 if(VaildChar(CharIndex)==true) then
  81.                         local Pf1 = Char.GetData(CharIndex,%对象_OtherFlg%);
  82.                         if(bit_and(Pf1,CONTANS_SKILL_8) >= 1) then
  83.                                 local mhp =  Char.GetData(CharIndex,%对象_最大血%);
  84.                                 local mmp =  Char.GetData(CharIndex,%对象_最大魔%);
  85.                                 Char.SetData(CharIndex,%对象_血%,mhp);
  86.                                 Char.SetData(CharIndex,%对象_魔%,mmp);
  87.                         end
  88.                 end
  89.         end
  90.         return 0;
  91. end
  92. function bit_and(a, b)
  93.     local p, c = 1, 0;
  94.     while a + b > 0 do
  95.         local am, bm = a % 2, b % 2;
  96.         if am + bm >= 2 then
  97.             c = c + p;
  98.         end
  99.         a, b, p = math.floor(a / 2), math.floor(b / 2), p * 2;
  100.     end
  101.     return c
  102. end
复制代码




发表于 2025-5-11 19:10:18 | 显示全部楼层
自动回血吗?

 楼主| 发表于 2025-5-13 15:08:37 | 显示全部楼层

对的 但是要先设置标志位才会生效
您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

GMT+8, 2026-6-5 02:30 , Processed in 0.031437 second(s), 2 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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