找回密码
 注册/Sign up
搜索
楼主: ahsin

改进版佣兵

[复制链接]

发表于 2021-12-21 00:01:17 | 显示全部楼层
ahsin 发表于 2021-12-20 21:26
我把整个lua文件夹分享了一下,你备份后试试

你是哔哩魔力的那个大佬?服都开了好多年了把!以前还玩过呢

发表于 2021-12-21 03:36:45 | 显示全部楼层
你能用多页背包吗?/bag 我使用不了,直接用新框架直接加载有BUG,不能打字说话了。最新版本的新框架也会出错,只能用老版本的,最新版的应该是说话的函数变动了

发表于 2021-12-21 15:41:26 | 显示全部楼层
ahsin 发表于 2021-12-20 21:26
我把整个lua文件夹分享了一下,你备份后试试

感謝你 可以用了

 楼主| 发表于 2021-12-21 23:55:31 | 显示全部楼层
zaza32167 发表于 2021-12-21 03:36
你能用多页背包吗?/bag 我使用不了,直接用新框架直接加载有BUG,不能打字说话了。最新版本的新框架也会出 ...

没注意,我也是小弟,muscipular是真大佬。新框架使用后,注意一些lua可能不能覆盖,需要合并代码。更深奥的问题,可能你需要直接问muscilular大佬。然后,musicpular的必杀不穿防,只最最重要的api,神一般的存在,做boss再也不需要-防了。

 楼主| 发表于 2021-12-22 02:29:33 | 显示全部楼层
更新yb.lua:
1、新增/aiback,可召回离队的佣兵
2、当玩家登回城后,ai自动跟玩家回城并回到队伍
3、当玩家通过带leavegroup的npc并warp传送到新地图后,ai自动归队

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

补充内容 (2021-12-22 02:41):
4、最多召唤4位ai佣兵,+玩家自己,正好一队

发表于 2021-12-22 12:31:07 来自手机 | 显示全部楼层
装备好像是装备两次才会生效,我没弄出来,移动两次。

发表于 2021-12-22 16:23:49 | 显示全部楼层
佣兵自动战斗会报错,换回0.1.16就正常了???

 楼主| 发表于 2021-12-22 17:50:44 | 显示全部楼层
13776877 发表于 2021-12-22 16:23
佣兵自动战斗会报错,换回0.1.16就正常了???

autobattle和yb里的npc名字要一样

发表于 2021-12-22 19:12:35 | 显示全部楼层
ahsin 发表于 2021-12-22 02:29
更新yb.lua:
1、新增/aiback,可召回离队的佣兵
2、当玩家登回城后,ai自动跟玩家回城并回到队伍

有BUG,登出挂端,删除YB挂断。用的你之前的整套框架

 楼主| 发表于 2021-12-22 23:20:42 | 显示全部楼层
zaza32167 发表于 2021-12-22 19:12
有BUG,登出挂端,删除YB挂断。用的你之前的整套框架

全套测试后,建议筛选几个需要的lua然后使用。仍然要坚持全套的注意lua和道具和地图都是有关联的,道具、地图对不上必然会挂

补充内容 (2021-12-22 23:31):
对了,还有一点,注意我的代码里面

佣兵的形象、名字都被我改了,你可能需要核对一下名字和造型的代码,搜索Char.SetData(charIndex1, CONST.CHAR_原形

补充内容 (2021-12-22 23:32):
如果你的端没有对应的佣兵造型编号,建议改一下
您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

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

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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