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

改进版佣兵

[复制链接]

发表于 2021-12-18 16:11:40 | 显示全部楼层 |阅读模式
基于http://bbs.cgmsv.com/thread-1083-1-1.html的帖子,做的改进在此之前也在用muscipluar究极大佬的框架http://bbs.cgmsv.com/thread-1036-1-1.html只能太尼玛牛逼了来形容

修改内容有:


补充内容 (2021-12-24 22:33):
全套lua在20楼
yb.lua代码有更新,在34楼

注意:
使用20楼一套lua的伙伴,module/ng.lua中有一键获得gm权限的隐藏命令,打开ng.lua搜索sex,然后修改关键字哦

补充内容 (2022-1-21 01:54):


==============
截止46楼,本帖不再更新代码,已经有各种大佬的变种修改版本了

补充内容 (2022-1-21 02:36):
↑↑↑↑46楼哦

补充内容 (2022-2-11 19:22):
请多关注muscipluar大神的更新
单变超
Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_P_MAGIC, 41, 2739);--超陨
暨10改成41
推荐研究大神的const.lua
side0=右侧队伍

 楼主| 发表于 2021-12-18 16:24:28 | 显示全部楼层

改进版佣兵

本帖最后由 ahsin 于 2021-12-18 16:26 编辑

刚才手抖按了ctrl发帖了。。。然后编辑完帖子又说超过5分钟不能改了,哈哈哈,只能跟帖了
基于http://bbs.cgmsv.com/thread-1083-1-1.html的帖子,做的改进
在此之前也在用muscipluar究极大佬的框架http://bbs.cgmsv.com/thread-1036-1-1.html只能太尼玛牛逼了来形容

修改内容有:
1、保留老lua,使用module,不用modules。主要原因是老lua要拦截talk,所以在新框架里会收不到talk msg,技术有限,只能挪出来用
2、限制每职的佣兵只能召唤1位
3、命令调整/aig /aij /aiq /aif /aim /aigd(弓、剑、骑、斧、魔、格)4、添加/killai,开除佣兵
5、玩家下线后,佣兵一起kill,不再堵地图上
6、佣兵能力根据玩家bp的80~100%来生成,不再固定,后期不辣鸡
7、注意,我把佣兵造型改了,如果你的服没对应图档,建议改一个图档编号

步骤一、
不要覆盖init.lua,把大佬框架的init.lua添加进老init.lua即可,其他都不冲突,全部丢进lua文件夹

步骤二、
autoBattle.lua放在modules里,修改了如下(注意autoBattle.lua里的佣兵名字要和yb.lua里的一样,否则不战斗)
  1. local Module = ModuleBase:createModule('autoBattle')
  2. --local disCacheCom = {}
  3. --disCacheCom[0] = 1;
  4. --disCacheCom[1] = 1;
  5. --disCacheCom[2] = 1;
  6. --disCacheCom[3] = 1;
  7. --disCacheCom[5] = 1;
  8. --disCacheCom[6] = 1;
  9. --disCacheCom[7] = 1;
  10. --disCacheCom[8] = 1;
  11. --disCacheCom[9] = 1;
  12. --disCacheCom[0xe] = 1;
  13. --disCacheCom[0x1a] = 1;
  14. --disCacheCom[0x9CB] = 1;
  15. --disCacheCom[0x9CC] = 1;
  16. --disCacheCom[0xDAC] = 1;
  17. --local charData = {};
  18. local battleData = {};
  19. function Module:onLoad()
  20.   self:logInfo('load')
  21.   --self:regCallback('TalkEvent', Func.bind(Module.handleChat, self))
  22.   --self:regCallback('LogoutEvent', Func.bind(Module.cleanUp, self))
  23.   --self:regCallback('BattleActionEvent', Func.bind(Module.battleActionEventCallBack, self))
  24.   self:regCallback('BattleOverEvent', Func.bind(Module.battleOverEventCallback, self))
  25.   self:regCallback('BeforeBattleTurnEvent', Func.bind(Module.handleBattleAutoCommand, self))
  26. end
  27. function Module:battleOverEventCallback(battleIndex)
  28.   battleData[battleIndex] = nil;
  29. end
  30. function Module:handleBattleAutoCommand(battleIndex)
  31.   local turn = Battle.GetTurn(battleIndex)
  32.   if battleData[battleIndex] == turn then
  33.     return
  34.   end
  35.   battleData[battleIndex] = turn;
  36.   local hasAutoBattle = false;
  37.   self:logDebug('handleBattleAutoCommand', battleIndex)
  38.   self:logDebug('turn', turn);
  39.   local hasPlayer = false;
  40.   for i = 0, 9 do
  41.     local charIndex = Battle.GetPlayer(battleIndex, i);
  42.     if charIndex >= 0 then
  43.       --if Char.GetData(charIndex, CONST.CHAR_类型) == CONST.对象类型_人 then
  44.       if Char.IsDummy(charIndex) then
  45.         local petIndex = Battle.GetPlayer(battleIndex, math.fmod(i + 5, 10));
  46.         self:logDebug('auto battle', charIndex, petIndex);
  47.         hasAutoBattle = true;
  48.         if Battle.IsWaitingCommand(charIndex) and Char.GetData(charIndex,%对象_名字%) == "恶魔猎手"  then
  49.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_P_RANDOMSHOT, 10, 9509);
  50.         end
  51.                 if Battle.IsWaitingCommand(charIndex) and Char.GetData(charIndex,%对象_名字%) == "剑圣"  then
  52.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_FIRSTATTACK, 10, 26209);
  53.         end
  54.                 if Battle.IsWaitingCommand(charIndex) and Char.GetData(charIndex,%对象_名字%) == "法国榔头"  then
  55.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_P_PARAMETER, 10, 309);
  56.         end
  57.                 if Battle.IsWaitingCommand(charIndex) and Char.GetData(charIndex,%对象_名字%) == "Archer"  then
  58.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_P_PARAMETER, 10, 109);
  59.         end
  60.                 if Battle.IsWaitingCommand(charIndex) and Char.GetData(charIndex,%对象_名字%) == "加盐纯净水"  then
  61.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_P_SPIRACLESHOT, 10, 409);
  62.         end
  63.                 if Battle.IsWaitingCommand(charIndex) and Char.GetData(charIndex,%对象_名字%) == "马猴烧酒"  then
  64.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_P_MAGIC, 10, 2209);
  65.         end
  66.         if petIndex >= 0 then
  67.           Battle.ActionSelect(petIndex, CONST.BATTLE_COM.BATTLE_COM_ATTACK, 10, -1);
  68.         else
  69.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_ATTACK, 10, -1);
  70.         end
  71.       else
  72.         hasPlayer = true;
  73.       end
  74.       --local data = charData[charIndex]
  75.       --if type(data) == 'table' and Char.GetData(charIndex, CONST.CHAR_BattleMode) == 2 then
  76.       --  hasAutoBattle = true;
  77.       --  Char.SetData(charIndex, CONST.CHAR_BattleMode, 3);
  78.       --  Char.SetData(charIndex, CONST.CHAR_BattleCom1, data.comA1 or 0);
  79.       --  Char.SetData(charIndex, CONST.CHAR_BattleCom2, data.comA2 or -1);
  80.       --  Char.SetData(charIndex, CONST.CHAR_BattleCom3, data.comA3 or -1);
  81.       --  Char.SetData(charIndex, CONST.CHAR_Battle2Com1, data.comB1 or 0);
  82.       --  Char.SetData(charIndex, CONST.CHAR_Battle2Com2, data.comB2 or -1);
  83.       --  Char.SetData(charIndex, CONST.CHAR_Battle2Com3, data.comB3 or -1);
  84.       --end
  85.       --end
  86.     end
  87.   end
  88.   self:logDebug(hasAutoBattle, hasPlayer, not hasPlayer)
  89.   if not hasPlayer and hasAutoBattle then
  90.     for i = 0, 9 do
  91.       local charIndex = Battle.GetPlayer(battleIndex, i);
  92.       if charIndex >= 0 and Char.GetData(charIndex, CONST.CHAR_类型) == CONST.对象类型_人 then
  93.         local petIndex = Battle.GetPlayer(battleIndex, math.fmod(i + 5, 10));
  94.         self:logDebug('auto battle', charIndex, petIndex);
  95.         hasAutoBattle = true;
  96.         if Battle.IsWaitingCommand(charIndex) then
  97.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_ESCAPE, -1, -1);
  98.         end
  99.         if petIndex >= 0 then
  100.           Battle.ActionSelect(petIndex, CONST.BATTLE_COM.BATTLE_COM_ATTACK, -1, -1);
  101.         else
  102.           Battle.ActionSelect(charIndex, CONST.BATTLE_COM.BATTLE_COM_ESCAPE, -1, -1);
  103.         end
  104.       end
  105.     end
  106.   end
  107.   return hasAutoBattle;
  108. end
  109. --function Module:handleChat(charIndex, msg, color, range, size)
  110. --  if msg == '/battle auto' then
  111. --    charData[charIndex] = true;
  112. --    NLG.SystemMessage(charIndex, '开启自动战斗');
  113. --    return 0;
  114. --  elseif msg == '/battle off' then
  115. --    charData[charIndex] = nil;
  116. --    NLG.SystemMessage(charIndex, '关闭自动战斗');
  117. --    return 0;
  118. --  end
  119. --  return 1
  120. --end
  121. --function Module:cleanUp(charIndex)
  122. --  if charData[charIndex] then
  123. --    charData[charIndex] = nil;
  124. --  end
  125. --  return 0;
  126. --end
  127. --function Module:battleActionEventCallBack(charIndex, battleIndex, com1, com2, com3, actionNum)
  128. --  if charData[charIndex] then
  129. --    local data = { }
  130. --    charData[charIndex] = data;
  131. --    local flag = 'A';
  132. --    data['comA1'] = 0;
  133. --    data['comA2'] = -1;
  134. --    data['comA3'] = -1;
  135. --    data['comB1'] = 0;
  136. --    data['comB2'] = -1;
  137. --    data['comB3'] = -1;
  138. --    if disCacheCom[com1] then
  139. --      charData[charIndex] = true;
  140. --      return
  141. --    end
  142. --    if actionNum == 2 then
  143. --      flag = 'B';
  144. --    end
  145. --    data['com' .. flag .. '1'] = com1;
  146. --    data['com' .. flag .. '2'] = com2;
  147. --    data['com' .. flag .. '3'] = com3;
  148. --  end
  149. --end
  150. function Module:onUnload()
  151.   self:logInfo('unload');
  152.   --self.hook.uninstall();
  153. end
  154. return Module;
复制代码

步骤三、
yb.lua放到module文件夹里,注意modules文件夹里哦
  1. ---模块类
  2. local ybModule = ModuleBase:createModule('yb')
  3. local allyb = 0
  4. -- 普通玩家命令
  5. --local commandsNormal = {}
  6. wanjia = {}--玩家表
  7. for bbb = 0,800 do
  8.         wanjia[bbb] = {}
  9.         wanjia[bbb][1] = 0
  10.         wanjia[bbb][2] = 0
  11.         wanjia[bbb][3] = 0
  12.         wanjia[bbb][4] = 0
  13.         wanjia[bbb][5] = 0
  14.         wanjia[bbb][6] = 0
  15. end
  16. Delegate.RegDelTalkEvent("yb_TalkEvent");--说话触发
  17. Delegate.RegDelAllOutEvent("yboffline");--玩家下线触发
  18. function yboffline(player)--玩家下线清空自己召唤的ai
  19. if wanjia[player][1] > 0 then
  20.         Char.DelDummy(wanjia[player][1])
  21. end
  22. if wanjia[player][2] > 0 then
  23.         Char.DelDummy(wanjia[player][2])
  24. end
  25. if wanjia[player][3] > 0 then
  26.         Char.DelDummy(wanjia[player][3])
  27. end
  28. if wanjia[player][4] > 0 then
  29.         Char.DelDummy(wanjia[player][4])
  30. end
  31. if wanjia[player][5] > 0 then
  32.         Char.DelDummy(wanjia[player][5])
  33. end
  34. if wanjia[player][6] > 0 then
  35.         Char.DelDummy(wanjia[player][6])
  36. end
  37. end
  38. --[[
  39. function ybteam(player,player2,status)--组队事件
  40.         t1 = Char.IsDummy(player)
  41.         t2 = Char.PartyNum(player)
  42.         ni2 = tonumber(player)
  43.         if t2 < 1 then--检测到离队
  44.                 Char.DelDummy(wanjia[ni2][1])
  45.                 Char.DelDummy(wanjia[ni2][2])
  46.                 Char.DelDummy(wanjia[ni2][3])
  47.                 Char.DelDummy(wanjia[ni2][4])
  48.                 wanjia[ni2][1] = 0
  49.                 wanjia[ni2][2] = 0
  50.                 wanjia[ni2][3] = 0
  51.                 wanjia[ni2][4] = 0
  52.         end
  53.         --print(Char.PartyNum(player))
  54. end
  55. ]]
  56. --function commandsNormal.yb01(player, args)
  57. function yb_TalkEvent(player,msg,color,range,size)
  58. suiji = math.random(80,100)--生成80~100的随机数--然后ai参考人物生成浮动bp
  59. rlv = Char.GetData(player,%对象_等级%)
  60. rlv = rlv /100 * suiji
  61. rx = Char.GetData(player,%对象_体力%)
  62. rx = rx / 100 * suiji
  63. rm = Char.GetData(player,%对象_魔法%)
  64. rm = rm / 100 * suiji
  65. rg = Char.GetData(player,%对象_力量%)
  66. rg = rg / 100 * suiji
  67. --print(rg)
  68. rf = Char.GetData(player,%对象_强度%)
  69. rf = rf / 100 * suiji
  70. rs = Char.GetData(player,%对象_速度%)
  71. rs = rs / 100 * suiji
  72. --print(rm)
  73. if msg == "/killai" or msg == "、killai" then--干掉ai的命令
  74. if wanjia[player][1] > 0 then
  75.         Char.DelDummy(wanjia[player][1])
  76.         wanjia[player][1] = 0
  77. end
  78. if wanjia[player][2] > 0 then
  79.         Char.DelDummy(wanjia[player][2])
  80.         wanjia[player][2] = 0
  81. end
  82. if wanjia[player][3] > 0 then
  83.         Char.DelDummy(wanjia[player][3])
  84.         wanjia[player][3] = 0
  85. end
  86. if wanjia[player][4] > 0 then
  87.         Char.DelDummy(wanjia[player][4])
  88.         wanjia[player][4] = 0
  89. end
  90. if wanjia[player][5] > 0 then
  91.         Char.DelDummy(wanjia[player][5])
  92.         wanjia[player][5] = 0
  93. end
  94. if wanjia[player][6] > 0 then
  95.         Char.DelDummy(wanjia[player][6])
  96.         wanjia[player][6] = 0
  97. end
  98. NLG.SystemMessage(player, '已开除所有佣兵。' )
  99. end
  100. if msg == "/aig" or msg == "、aig" then
  101.         if Char.GetData(player,%对象_战宠%) == -1 then
  102.         NLG.SystemMessage(player, '不带宠,无法召唤佣兵。' )
  103.         elseif allyb > 750 then
  104.         NLG.SystemMessage(player, '当前线路人口爆满,无法添加佣兵了。' )
  105.         else
  106.         if wanjia[player][1] == 0 then
  107.         local charIndex1 = Char.CreateDummy()--生成ai佣兵
  108.         allyb = charIndex1
  109.         print("编号:"..charIndex1.."")
  110.         wanjia[player][1] = charIndex1
  111.         
  112.         Char.SetData(charIndex1, CONST.CHAR_X, Char.GetData(player, CONST.CHAR_X));
  113.         Char.SetData(charIndex1, CONST.CHAR_Y, Char.GetData(player, CONST.CHAR_Y));
  114.         Char.SetData(charIndex1, CONST.CHAR_地图, Char.GetData(player, CONST.CHAR_地图));
  115.         Char.SetData(charIndex1, CONST.CHAR_名字, '恶魔猎手');
  116.         Char.SetData(charIndex1, CONST.CHAR_地图类型, Char.GetData(player, CONST.CHAR_地图类型));
  117.         Char.SetData(charIndex1, CONST.CHAR_形象, 100269);
  118.         Char.SetData(charIndex1, CONST.CHAR_原形, 105791);
  119.         Char.SetData(charIndex1, CONST.CHAR_原始图档, 100269);
  120.         print('charIndex1', charIndex1)
  121.         --print(player)
  122.         Char.SetData(charIndex1, CONST.CHAR_体力, rx);
  123.         Char.SetData(charIndex1, CONST.CHAR_力量, rg);
  124.         Char.SetData(charIndex1, CONST.CHAR_强度, rf);
  125.         Char.SetData(charIndex1, CONST.CHAR_速度, rs);
  126.         Char.SetData(charIndex1, CONST.CHAR_魔法, rm);
  127.         Char.SetData(charIndex1, CONST.CHAR_风属性, 100);
  128.         Char.SetData(charIndex1, CONST.CHAR_闪躲, 30);
  129.         Char.SetData(charIndex1, CONST.CHAR_魅力, 100);
  130.         Char.SetData(charIndex1, CONST.CHAR_等级, rlv);
  131.         Char.SetData(charIndex1, CONST.CHAR_种族, 0);
  132.         NLG.UpChar(charIndex1);
  133.         Char.SetData(charIndex1, CONST.CHAR_血, Char.GetData(charIndex1, CONST.CHAR_最大血));
  134.         Char.SetData(charIndex1, CONST.CHAR_魔, Char.GetData(charIndex1, CONST.CHAR_最大魔));
  135.         Char.GiveItem(charIndex1, 2100, 1, false);
  136.         Char.MoveItem(charIndex1, 8, CONST.EQUIP_左手, -1);
  137.         Char.SetData(charIndex1, CONST.CHAR_职业, 44);
  138.         Char.SetData(charIndex1, CONST.CHAR_职类ID, 40);
  139.         Char.SetData(charIndex1, CONST.CHAR_职阶, 3);
  140.         Char.AddSkill(charIndex1, 95);
  141.         --Char.GivePet(charIndex1, 3004);
  142.         --Char.SetPetDepartureState(charIndex1, 0, CONST.PET_STATE_战斗);
  143.         --Char.SetData(charIndex1, CONST.CHAR_战宠, 0);
  144.         --local petIndex = Char.GetPet(charIndex1, 0);
  145.         --Char.SetData(petIndex, CONST.PET_DepartureBattleStatus, CONST.PET_STATE_战斗);
  146.         NLG.SystemMessage(player, '召唤佣兵: 弓箭手' )
  147.         Char.JoinParty(charIndex1, player);
  148.         else
  149.         NLG.SystemMessage(player, '只能召唤1位弓箭手。' )
  150.         end
  151.         end
  152. elseif msg == "/aij" or msg == "、aij" then
  153.         if Char.GetData(player,%对象_战宠%) == -1 then
  154.         NLG.SystemMessage(player, '不带宠,无法召唤佣兵。' )
  155.         elseif allyb > 750 then
  156.         NLG.SystemMessage(player, '当前线路人口爆满,无法添加佣兵了。' )
  157.         else
  158.         if wanjia[player][2] == 0 then
  159.         local charIndex1 = Char.CreateDummy()--生成ai佣兵
  160.         allyb = charIndex1
  161.         print("编号:"..charIndex1.."")
  162.         wanjia[player][2] = charIndex1
  163. Char.SetData(charIndex1, CONST.CHAR_X, Char.GetData(player, CONST.CHAR_X));
  164. Char.SetData(charIndex1, CONST.CHAR_Y, Char.GetData(player, CONST.CHAR_Y));
  165. Char.SetData(charIndex1, CONST.CHAR_地图, Char.GetData(player, CONST.CHAR_地图));
  166. Char.SetData(charIndex1, CONST.CHAR_名字, '剑圣');
  167. Char.SetData(charIndex1, CONST.CHAR_地图类型, Char.GetData(player, CONST.CHAR_地图类型));
  168. Char.SetData(charIndex1, CONST.CHAR_形象, 100528);
  169. Char.SetData(charIndex1, CONST.CHAR_原形, 101127);
  170. Char.SetData(charIndex1, CONST.CHAR_原始图档, 100528);
  171. print('charIndex1', charIndex1)
  172. Char.SetData(charIndex1, CONST.CHAR_体力, rx);
  173. Char.SetData(charIndex1, CONST.CHAR_力量, rg);
  174. Char.SetData(charIndex1, CONST.CHAR_强度, rf);
  175. Char.SetData(charIndex1, CONST.CHAR_速度, rs);
  176. Char.SetData(charIndex1, CONST.CHAR_魔法, rm);
  177. Char.SetData(charIndex1, CONST.CHAR_地属性, 100);
  178. Char.SetData(charIndex1, CONST.CHAR_命中, 30);
  179. Char.SetData(charIndex1, CONST.CHAR_魅力, 100);
  180. Char.SetData(charIndex1, CONST.CHAR_等级, rlv);
  181. Char.SetData(charIndex1, CONST.CHAR_种族, 0);
  182. NLG.UpChar(charIndex1);
  183. Char.SetData(charIndex1, CONST.CHAR_血, Char.GetData(charIndex1, CONST.CHAR_最大血));
  184. Char.SetData(charIndex1, CONST.CHAR_魔, Char.GetData(charIndex1, CONST.CHAR_最大魔));
  185. --Char.GiveItem(charIndex1, 900048, 1, false);
  186. --Char.MoveItem(charIndex1, 8, CONST.EQUIP_左手, -1);
  187. Char.SetData(charIndex1, CONST.CHAR_职业, 14);
  188. Char.SetData(charIndex1, CONST.CHAR_职类ID, 10);
  189. Char.SetData(charIndex1, CONST.CHAR_职阶, 3);
  190. Char.AddSkill(charIndex1, 1006);
  191. --Char.GivePet(charIndex1, 3004);
  192. --Char.SetPetDepartureState(charIndex1, 0, CONST.PET_STATE_战斗);
  193. --Char.SetData(charIndex1, CONST.CHAR_战宠, 0);
  194. --local petIndex = Char.GetPet(charIndex1, 0);
  195. --Char.SetData(petIndex, CONST.PET_DepartureBattleStatus, CONST.PET_STATE_战斗);
  196. NLG.SystemMessage(player, '召唤佣兵: 剑士' )
  197. Char.JoinParty(charIndex1, player);
  198. else
  199.         NLG.SystemMessage(player, '只能召唤1位剑士。' )
  200.         end
  201.         end
  202. elseif msg == "/aif" or msg == "、aif" then
  203.         if Char.GetData(player,%对象_战宠%) == -1 then
  204.         NLG.SystemMessage(player, '不带宠,无法召唤佣兵。' )
  205.         elseif allyb > 750 then
  206.         NLG.SystemMessage(player, '当前线路人口爆满,无法添加佣兵了。' )
  207.         else
  208.         if wanjia[player][3] == 0 then
  209.         local charIndex1 = Char.CreateDummy()--生成ai佣兵
  210.         allyb = charIndex1
  211.         print("编号:"..charIndex1.."")
  212.         wanjia[player][3] = charIndex1
  213. Char.SetData(charIndex1, CONST.CHAR_X, Char.GetData(player, CONST.CHAR_X));
  214. Char.SetData(charIndex1, CONST.CHAR_Y, Char.GetData(player, CONST.CHAR_Y));
  215. Char.SetData(charIndex1, CONST.CHAR_地图, Char.GetData(player, CONST.CHAR_地图));
  216. Char.SetData(charIndex1, CONST.CHAR_名字, '法国榔头');
  217. Char.SetData(charIndex1, CONST.CHAR_地图类型, Char.GetData(player, CONST.CHAR_地图类型));
  218. Char.SetData(charIndex1, CONST.CHAR_形象, 100125);
  219. Char.SetData(charIndex1, CONST.CHAR_原形, 105997);
  220. Char.SetData(charIndex1, CONST.CHAR_原始图档, 100125);
  221. print('charIndex1', charIndex1)
  222. Char.SetData(charIndex1, CONST.CHAR_体力, rx);
  223. Char.SetData(charIndex1, CONST.CHAR_力量, rg);
  224. Char.SetData(charIndex1, CONST.CHAR_强度, rf);
  225. Char.SetData(charIndex1, CONST.CHAR_速度, rs);
  226. Char.SetData(charIndex1, CONST.CHAR_魔法, rm);
  227. Char.SetData(charIndex1, CONST.CHAR_火属性, 100);
  228. Char.SetData(charIndex1, CONST.CHAR_必杀, 30);
  229. Char.SetData(charIndex1, CONST.CHAR_魅力, 100);
  230. Char.SetData(charIndex1, CONST.CHAR_等级, rlv);
  231. Char.SetData(charIndex1, CONST.CHAR_种族, 0);
  232. NLG.UpChar(charIndex1);
  233. Char.SetData(charIndex1, CONST.CHAR_血, Char.GetData(charIndex1, CONST.CHAR_最大血));
  234. Char.SetData(charIndex1, CONST.CHAR_魔, Char.GetData(charIndex1, CONST.CHAR_最大魔));
  235. --Char.GiveItem(charIndex1, 900049, 1, false);
  236. --Char.MoveItem(charIndex1, 8, CONST.EQUIP_左手, -1);
  237. Char.SetData(charIndex1, CONST.CHAR_职业, 24);
  238. Char.SetData(charIndex1, CONST.CHAR_职类ID, 20);
  239. Char.SetData(charIndex1, CONST.CHAR_职阶, 3);
  240. Char.AddSkill(charIndex1, 3);
  241. --Char.GivePet(charIndex1, 3004);
  242. --Char.SetPetDepartureState(charIndex1, 0, CONST.PET_STATE_战斗);
  243. --Char.SetData(charIndex1, CONST.CHAR_战宠, 0);
  244. --local petIndex = Char.GetPet(charIndex1, 0);
  245. --Char.SetData(petIndex, CONST.PET_DepartureBattleStatus, CONST.PET_STATE_战斗);
  246. NLG.SystemMessage(player, '召唤佣兵: 战斧' )
  247. Char.JoinParty(charIndex1, player);
  248. else
  249.         NLG.SystemMessage(player, '只能召唤1位战斧。' )
  250.         end
  251.         end
  252. elseif msg == "/aiq" or msg == "、aiq" then
  253.         if Char.GetData(player,%对象_战宠%) == -1 then
  254.         NLG.SystemMessage(player, '不带宠,无法召唤佣兵。' )
  255.         elseif allyb > 750 then
  256.         NLG.SystemMessage(player, '当前线路人口爆满,无法添加佣兵了。' )
  257.         else
  258.         if wanjia[player][4] == 0 then
  259.         local charIndex1 = Char.CreateDummy()--生成ai佣兵
  260.         allyb = charIndex1
  261.         print("编号:"..charIndex1.."")
  262.         wanjia[player][4] = charIndex1
  263. Char.SetData(charIndex1, CONST.CHAR_X, Char.GetData(player, CONST.CHAR_X));
  264. Char.SetData(charIndex1, CONST.CHAR_Y, Char.GetData(player, CONST.CHAR_Y));
  265. Char.SetData(charIndex1, CONST.CHAR_地图, Char.GetData(player, CONST.CHAR_地图));
  266. Char.SetData(charIndex1, CONST.CHAR_名字, 'Archer');
  267. Char.SetData(charIndex1, CONST.CHAR_地图类型, Char.GetData(player, CONST.CHAR_地图类型));
  268. Char.SetData(charIndex1, CONST.CHAR_形象, 100073);
  269. Char.SetData(charIndex1, CONST.CHAR_原形, 101142);
  270. Char.SetData(charIndex1, CONST.CHAR_原始图档, 100073);
  271. print('charIndex1', charIndex1)
  272. Char.SetData(charIndex1, CONST.CHAR_体力, rx);
  273. Char.SetData(charIndex1, CONST.CHAR_力量, rg);
  274. Char.SetData(charIndex1, CONST.CHAR_强度, rf);
  275. Char.SetData(charIndex1, CONST.CHAR_速度, rs);
  276. Char.SetData(charIndex1, CONST.CHAR_魔法, rm);
  277. Char.SetData(charIndex1, CONST.CHAR_水属性, 100);
  278. Char.SetData(charIndex1, CONST.CHAR_反击, 30);
  279. Char.SetData(charIndex1, CONST.CHAR_魅力, 100);
  280. Char.SetData(charIndex1, CONST.CHAR_等级, rlv);
  281. Char.SetData(charIndex1, CONST.CHAR_种族, 0);
  282. NLG.UpChar(charIndex1);
  283. Char.SetData(charIndex1, CONST.CHAR_血, Char.GetData(charIndex1, CONST.CHAR_最大血));
  284. Char.SetData(charIndex1, CONST.CHAR_魔, Char.GetData(charIndex1, CONST.CHAR_最大魔));
  285. --Char.GiveItem(charIndex1, 2100, 1, false);
  286. --Char.MoveItem(charIndex1, 8, CONST.EQUIP_左手, -1);
  287. Char.SetData(charIndex1, CONST.CHAR_职业, 34);
  288. Char.SetData(charIndex1, CONST.CHAR_职类ID, 30);
  289. Char.SetData(charIndex1, CONST.CHAR_职阶, 3);
  290. Char.AddSkill(charIndex1, 1);
  291. --Char.GivePet(charIndex1, 3004);
  292. --Char.SetPetDepartureState(charIndex1, 0, CONST.PET_STATE_战斗);
  293. --Char.SetData(charIndex1, CONST.CHAR_战宠, 0);
  294. --local petIndex = Char.GetPet(charIndex1, 0);
  295. --Char.SetData(petIndex, CONST.PET_DepartureBattleStatus, CONST.PET_STATE_战斗);
  296. NLG.SystemMessage(player, '召唤佣兵: 骑士' )
  297. Char.JoinParty(charIndex1, player);
  298. else
  299.         NLG.SystemMessage(player, '只能召唤1位骑士。' )
  300.         end
  301.         end
  302. elseif msg == "/aigd" or msg == "、aigd" then
  303.         if Char.GetData(player,%对象_战宠%) == -1 then
  304.         NLG.SystemMessage(player, '不带宠,无法召唤佣兵。' )
  305.         elseif allyb > 750 then
  306.         NLG.SystemMessage(player, '当前线路人口爆满,无法添加佣兵了。' )
  307.         else
  308.         if wanjia[player][5] == 0 then
  309.         local charIndex1 = Char.CreateDummy()--生成ai佣兵
  310.         allyb = charIndex1
  311.         print("编号:"..charIndex1.."")
  312.         wanjia[player][5] = charIndex1
  313. Char.SetData(charIndex1, CONST.CHAR_X, Char.GetData(player, CONST.CHAR_X));
  314. Char.SetData(charIndex1, CONST.CHAR_Y, Char.GetData(player, CONST.CHAR_Y));
  315. Char.SetData(charIndex1, CONST.CHAR_地图, Char.GetData(player, CONST.CHAR_地图));
  316. Char.SetData(charIndex1, CONST.CHAR_名字, '加盐纯净水');
  317. Char.SetData(charIndex1, CONST.CHAR_地图类型, Char.GetData(player, CONST.CHAR_地图类型));
  318. Char.SetData(charIndex1, CONST.CHAR_形象, 100108);
  319. Char.SetData(charIndex1, CONST.CHAR_原形, 119500);
  320. Char.SetData(charIndex1, CONST.CHAR_原始图档, 100108);
  321. print('charIndex1', charIndex1)
  322. Char.SetData(charIndex1, CONST.CHAR_体力, rx);
  323. Char.SetData(charIndex1, CONST.CHAR_力量, rg);
  324. Char.SetData(charIndex1, CONST.CHAR_强度, rf);
  325. Char.SetData(charIndex1, CONST.CHAR_速度, rs);
  326. Char.SetData(charIndex1, CONST.CHAR_魔法, rm);
  327. Char.SetData(charIndex1, CONST.CHAR_地属性, 100);
  328. Char.SetData(charIndex1, CONST.CHAR_命中, 30);
  329. Char.SetData(charIndex1, CONST.CHAR_魅力, 100);
  330. Char.SetData(charIndex1, CONST.CHAR_等级, rlv);
  331. Char.SetData(charIndex1, CONST.CHAR_种族, 0);
  332. NLG.UpChar(charIndex1);
  333. Char.SetData(charIndex1, CONST.CHAR_血, Char.GetData(charIndex1, CONST.CHAR_最大血));
  334. Char.SetData(charIndex1, CONST.CHAR_魔, Char.GetData(charIndex1, CONST.CHAR_最大魔));
  335. --Char.GiveItem(charIndex1, 2100, 1, false);
  336. --Char.MoveItem(charIndex1, 8, CONST.EQUIP_左手, -1);
  337. Char.SetData(charIndex1, CONST.CHAR_职业, 144);
  338. Char.SetData(charIndex1, CONST.CHAR_职类ID, 140);
  339. Char.SetData(charIndex1, CONST.CHAR_职阶, 3);
  340. Char.AddSkill(charIndex1, 4);
  341. --Char.GivePet(charIndex1, 3004);
  342. --Char.SetPetDepartureState(charIndex1, 0, CONST.PET_STATE_战斗);
  343. --Char.SetData(charIndex1, CONST.CHAR_战宠, 0);
  344. --local petIndex = Char.GetPet(charIndex1, 0);
  345. --Char.SetData(petIndex, CONST.PET_DepartureBattleStatus, CONST.PET_STATE_战斗);
  346. NLG.SystemMessage(player, '召唤佣兵: 格斗' )
  347. Char.JoinParty(charIndex1, player);
  348. else
  349.         NLG.SystemMessage(player, '只能召唤1位格斗。' )
  350.         end
  351.         end
  352. elseif msg == "/aim" or msg == "、aim" then
  353.         if Char.GetData(player,%对象_战宠%) == -1 then
  354.         NLG.SystemMessage(player, '不带宠,无法召唤佣兵。' )
  355.         elseif allyb > 750 then
  356.         NLG.SystemMessage(player, '当前线路人口爆满,无法添加佣兵了。' )
  357.         else
  358.         if wanjia[player][6] == 0 then
  359.         local charIndex1 = Char.CreateDummy()--生成ai佣兵
  360.         allyb = charIndex1
  361.         print("编号:"..charIndex1.."")
  362.         wanjia[player][6] = charIndex1
  363. Char.SetData(charIndex1, CONST.CHAR_X, Char.GetData(player, CONST.CHAR_X));
  364. Char.SetData(charIndex1, CONST.CHAR_Y, Char.GetData(player, CONST.CHAR_Y));
  365. Char.SetData(charIndex1, CONST.CHAR_地图, Char.GetData(player, CONST.CHAR_地图));
  366. Char.SetData(charIndex1, CONST.CHAR_名字, '马猴烧酒');
  367. Char.SetData(charIndex1, CONST.CHAR_地图类型, Char.GetData(player, CONST.CHAR_地图类型));
  368. Char.SetData(charIndex1, CONST.CHAR_形象, 100322);
  369. Char.SetData(charIndex1, CONST.CHAR_原形, 104968);
  370. Char.SetData(charIndex1, CONST.CHAR_原始图档, 100322);
  371. print('charIndex1', charIndex1)
  372. Char.SetData(charIndex1, CONST.CHAR_体力, rx/2);
  373. Char.SetData(charIndex1, CONST.CHAR_力量, 0);
  374. Char.SetData(charIndex1, CONST.CHAR_强度, rf);
  375. Char.SetData(charIndex1, CONST.CHAR_速度, rs);
  376. Char.SetData(charIndex1, CONST.CHAR_魔法, rm*10);
  377. Char.SetData(charIndex1, CONST.CHAR_风属性, 100);
  378. Char.SetData(charIndex1, CONST.CHAR_闪躲, 30);
  379. Char.SetData(charIndex1, CONST.CHAR_魅力, 100);
  380. Char.SetData(charIndex1, CONST.CHAR_等级, rlv);
  381. Char.SetData(charIndex1, CONST.CHAR_种族, 0);
  382. NLG.UpChar(charIndex1);
  383. Char.SetData(charIndex1, CONST.CHAR_血, Char.GetData(charIndex1, CONST.CHAR_最大血));
  384. Char.SetData(charIndex1, CONST.CHAR_魔, Char.GetData(charIndex1, CONST.CHAR_最大魔));
  385. --Char.GiveItem(charIndex1, 2100, 1, false);
  386. --Char.MoveItem(charIndex1, 8, CONST.EQUIP_左手, -1);
  387. Char.SetData(charIndex1, CONST.CHAR_职业, 74);
  388. Char.SetData(charIndex1, CONST.CHAR_职类ID, 70);
  389. Char.SetData(charIndex1, CONST.CHAR_职阶, 3);
  390. Char.AddSkill(charIndex1, 22);
  391. --Char.GivePet(charIndex1, 3004);
  392. --Char.SetPetDepartureState(charIndex1, 0, CONST.PET_STATE_战斗);
  393. --Char.SetData(charIndex1, CONST.CHAR_战宠, 0);
  394. --local petIndex = Char.GetPet(charIndex1, 0);
  395. --Char.SetData(petIndex, CONST.PET_DepartureBattleStatus, CONST.PET_STATE_战斗);
  396. NLG.SystemMessage(player, '召唤佣兵: 法师')
  397. Char.JoinParty(charIndex1, player);
  398. else
  399.         NLG.SystemMessage(player, '只能召唤1位法师。' )
  400.         end
  401.         end
  402. end
  403. end
  404. --[[
  405. function ybModule:handleTalkEvent(player, msg)
  406. local command = msg:match('^/([%w]+)')
  407.   if commandsNormal[command] then
  408.   local arg = msg:match('^/[%w]+ +(.+)$')
  409.     arg = arg and string.split(arg, ' ') or {}
  410.     commandsNormal[command](player, arg);
  411.     return
  412.   end
  413.   return 1;
  414. end
  415. ]]
  416. --- 加载模块钩子
  417. function ybModule:onLoad()
  418.   self:logInfo('load')
  419.   self:regCallback('TalkEvent', Func.bind(self.handleTalkEvent, self))
  420. end
  421. --- 卸载模块钩子
  422. function ybModule:onUnload()
  423.   self:logInfo('unload')
  424. end
  425. return ybModule;
复制代码





补充内容 (2021-12-24 22:34):
一套lua在20楼
最新yb.lua代码在34楼

 楼主| 发表于 2021-12-18 16:32:03 | 显示全部楼层
又过了5分钟,不能修改了,哈哈哈


上文中,yb.lua放到module文件夹里,注意不是modules文件夹里哦

发表于 2021-12-19 00:54:36 | 显示全部楼层
大佬接受小弟一拜,终于可以单开玩魔力了

发表于 2021-12-19 01:45:57 | 显示全部楼层
請問不管是之前的打/yb01 跟這裡的打/aig都只是對話框跑出字而已什麼都沒有
我都有把兩個iua放進該資料夾裡

发表于 2021-12-19 01:48:25 | 显示全部楼层
佣兵可以召唤出来没问题了,就是说不了话,打GM命令也没有作用

 楼主| 发表于 2021-12-19 11:56:37 来自手机 | 显示全部楼层
csummer 发表于 2021-12-19 01:45
請問不管是之前的打/yb01 跟這裡的打/aig都只是對話框跑出字而已什麼都沒有
我都有把兩個iua放進該資料夾裡 ...

检查一下lua/system/allevent里有没有all_talk.lua
然后lua/config.lua需要添加yb.lua
然后lua/muduleconfig.lua需要添加autobattle.lua(好像已经有了,检查一下吧)

 楼主| 发表于 2021-12-19 12:01:21 | 显示全部楼层
Saligiaer 发表于 2021-12-19 01:48
佣兵可以召唤出来没问题了,就是说不了话,打GM命令也没有作用

看看lua/system/allevent/all_talk.lua
备份一下,换成
  1. --说话全局事件
  2. function All_TalkEvent(player,msg,color,range,size)
  3.     local talkret = 1;
  4.         for _,Func in pairs(tbl_delegate_TalkEvent) do       
  5.             local f =loadstring("return "..Func.."("..player..",""..msg.."","..color..","..range..","..size..")");       
  6.                 if(f~=nil)then
  7.                         if(f() == 0) then
  8.                                 talkret = 0;
  9.                         end
  10.                 end
  11.     end
  12.         return talkret;
  13. end
复制代码

发表于 2021-12-19 14:46:34 | 显示全部楼层
现在已经弄好了,有个BUG就是用了最新0.1.17增强lua,佣兵自动战斗会报错,换回0.1.16就正常了

发表于 2021-12-19 16:27:31 | 显示全部楼层
ahsin 发表于 2021-12-19 11:56
检查一下lua/system/allevent里有没有all_talk.lua
然后lua/config.lua需要添加yb.lua
然后lua/mudulecon ...

123

123
這樣的嗎?還是不ˋ行
您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

GMT+8, 2026-6-5 09:08 , Processed in 0.084910 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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