战网中国

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 7193|回复: 9

【D2BS】以kolbot为基础的私服自动回收合成的一种思路

[复制链接]

6

主题

51

帖子

454

积分

骑士

Rank: 4

积分
454
发表于 2019-1-9 13:03:37 | 显示全部楼层 |阅读模式
本帖最后由 loveqiao361 于 2019-1-10 09:35 编辑

首先要分析清楚Cubing中的逻辑,特别是与town中动作的关联。我的方法是添加Cubing的Recipe以达到目的,再在town中增加回收药剂的需求检测进行购买,购买后更新Cubing的需求情况。这里列出3种回收:单件暗金,单件套装,两件套装。
Cubing在人物config中主要是以物品classid的形式进行设置。
由于Cubing.init()这个function,用户也可以通过写对应classid的字符串达到config中设置的目的。

首先添全局变量Recipe中的属性,也就是作者思路中的Recipe.Index:


  1.         Recycle: {
  2.                 Unique: 56,
  3.                 Set: 57,
  4.                 SetDouble: 58
  5.         }
复制代码
然后在Cubing.buildRecipe这个function下加入我们的Recipe,这里以溶解药剂(classid = 517)为例:
  1.                         case Recipe.Recycle.Unique:
  2.                                 this.recipes.push({Ingredients: [Config.Recipes[i][1], 517], Index: Recipe.Recycle.Unique});

  3.                                 break;
  4.                                 
  5.                         case Recipe.Recycle.Set:
  6.                                 this.recipes.push({Ingredients: [Config.Recipes[i][1], 517], Index: Recipe.Recycle.Set});

  7.                                 break;

  8.                         case Recipe.Recycle.SetDouble:
  9.                                 this.recipes.push({Ingredients: [Config.Recipes[i][1], Config.Recipes[i][2], 517], Index: Recipe.Recycle.SetDouble});

  10.                                 break;
复制代码

重头戏:Cubing.validItem()和Cubing.buildLists()
先说说Cubing.buildLists() 这里加的不多,主要是给两件套装的回收增加回收药剂通过validItem的条件。

将:
  1. this.recipes[i].Enabled = true;
复制代码

上方的if判断条件改变,如下:
  1.                                                 // Enable recipes for gem/jewel pickup
  2.                                                 if ((this.recipes[i].Index !== Recipe.Rune && this.recipes[i].Index <= Recipe.Recycle.Set)
  3.                                                          || (this.recipes[i].Index === Recipe.Rune && j >= 1) ||
  4.                                                                 (this.recipes[i].Index === Recipe.Recycle.SetDouble && j >= 1)
  5.                                                                 ) { // Enable rune recipe after 2 bases are found
  6.                                                         this.recipes[i].Enabled = true;
  7.                                                 }
复制代码


这样就完成了,然后看validItem()
根据作者的方式,在根据Index作判断之前加上:

  1.                 if (unit.itemType === 81 || unit.classid === 517) {
  2.                                         if (recipe.Enabled){
  3.                                                 return true;
  4.                                         }
  5.                         return false;
  6.                 }
复制代码


然后根据Index来做判断,首先是单件暗金,不符合nip需求采取回收,由于单件暗金戒指与项链比较特殊,这里分别给了一个例子,乌鸦之霜和大君之怒:
  1.                 if (recipe.Index === Recipe.Recycle.Unique) {
  2.                         if (unit.quality === 7 && NTIP.CheckItem(unit) === 0){

  3.                                 switch(unit.classid){//Judge whether it can be recycled
  4.                                         case 522: //Unique ring
  5.                                         //Raven Fros
  6.                                         return unit.getStat(2) >= 15 && unit.getStat(19) >= 15;
  7.                
  8.                                         case 520: //amulet
  9.                                         //Highlord's Wrah
  10.                                         return unit.getStat(41) == 35 && unit.getStat(93) == 2;
  11.                                 }

  12.                         return true;
  13.                         }

  14.                         return false;
  15.                 }
复制代码
单件套装与单件暗金同理:
  1.                 if (recipe.Index === Recipe.Recycle.Set) {
  2.                         if (unit.quality === 5 && NTIP.CheckItem(unit) === 0){
  3.                         return true;
  4.                         }

  5.                         return false;        
  6.                 }
复制代码

然后是两件套装,由于Cubing的特性,只会一组一组做,所以这里采取不同的方式,达到nip需求才采取回收,这样就会留下所有两件套装中的物品。
如需留下高品质物品,则在函数下写出筛选函数,这里给一个NEC绿头的例子:
  1.                 if (recipe.Index === Recipe.Recycle.SetDouble) {
  2.                         if (unit.quality === 5 && NTIP.CheckItem(unit) === 1){
  3.                                 switch(unit.classid){//Judge whether it is good to keep
  4.                                         case 465: //Set BoneVisage(NEC HELM)
  5.                                         //Best:[defense] == 257
  6.                                         return unit.getStat(31) < 257 && NTIP.CheckItem(unit) === 1;
  7.                                 }

  8.                         return true;
  9.                         }

  10.                         return false;        
  11.                 }
复制代码

这里要注意,如需做筛选留下高品质物品,nip中需写出至少一个stat的最低要求保证鉴定,这样才能进行筛选。我的做法是加了一条[defense] >= 最低防御。

这样Cubing基本就完成了,先来看Town。
首先在Town.doChores的this.identify()后加上:
  1. this.buyRecyclePotion();
复制代码

于是在Town对象中建立函数:
  1.         buyRecyclePotion: function(){

  2.                 if(Cubing.checkRecycle() > 0){
  3.                         var i, npc, thawing;
  4.                         
  5.                         if (me.act === 3) {
  6.                                 this.goToTown(Pather.accessToAct(4) ? 4 : 2);
  7.                         }

  8.                         if (!this.initNPC("Key", "buyRecyclePotion")) {
  9.                                 return false;
  10.                         }

  11.                         npc = getInteractedNPC();

  12.                         if (!npc || !npc.itemcount) {
  13.                                 return false;
  14.                         }

  15.                         thawing = npc.getItem(517);
  16.                         
  17.                         for(i=0; i<Cubing.checkRecycle(); i+=1){
  18.                         if (thawing && Storage.Inventory.CanFit(thawing)) {
  19.                                 try {
  20.                                         thawing.buy();
  21.                                 } catch (e1) {
  22.                                         print(e1);
  23.                                         // Couldn't buy the tome, don't spam the scrolls
  24.                                         return false;
  25.                                         }
  26.                         } else {
  27.                                 break;
  28.                                 }
  29.                         }

  30.                         Cubing.update();
  31.                 }

  32.                 return true;
  33.         },
复制代码
如果你好奇为什么init中的Task是"Key",建议你去看一下游戏中卖溶解药剂的NPC……

最后在Cubing中建立获取溶解药剂的数量需求函数即可:
  1.         checkRecycle:function (){
  2.                 var i, sum = 0;

  3.                 for (i = 0; i < this.neededIngredients.length; i += 1) {
  4.                                 if(this.neededIngredients[i].classid === 517){
  5.                                         sum = sum+1;
  6.                                 }
  7.                         }
  8.                
  9.                 return sum;
  10.         },
复制代码

人物设置部分不用多说,给一个unique shako的例子:
  1.         //暗金军帽
  2.         Config.Recipes.push([Recipe.Recycle.Unique, "Shako"]);
复制代码

done.












回复

使用道具 举报

1

主题

14

帖子

58

积分

新手

Rank: 2

积分
58
发表于 2019-5-11 00:24:04 | 显示全部楼层
学习了
回复

使用道具 举报

1

主题

17

帖子

62

积分

新手

Rank: 2

积分
62
发表于 2019-5-12 21:37:30 | 显示全部楼层
找了好久了,就是这个思路
回复 支持 反对

使用道具 举报

1

主题

17

帖子

62

积分

新手

Rank: 2

积分
62
发表于 2019-5-12 21:37:32 | 显示全部楼层
找了好久了,就是这个思路
回复 支持 反对

使用道具 举报

16

主题

227

帖子

982

积分

圣骑士

Rank: 5Rank: 5

积分
982

社区居民

发表于 2019-7-19 09:30:51 | 显示全部楼层
私服BOT 求一个
回复 支持 反对

使用道具 举报

5

主题

35

帖子

224

积分

侠客

Rank: 3Rank: 3

积分
224
发表于 2020-6-8 13:03:27 | 显示全部楼层
请问一下,Cubing.init()这个函数在哪个文件里
回复 支持 反对

使用道具 举报

6

主题

51

帖子

454

积分

骑士

Rank: 4

积分
454
 楼主| 发表于 2021-1-11 12:18:40 | 显示全部楼层
speedwxd 发表于 2020-6-8 13:03
请问一下,Cubing.init()这个函数在哪个文件里

kolbot\libs\common\Cubing.js
回复 支持 反对

使用道具 举报

2

主题

59

帖子

244

积分

侠客

Rank: 3Rank: 3

积分
244
发表于 2021-12-30 08:49:40 来自手机 | 显示全部楼层
标记下,新手有用,这个想法好
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|BattleCN ( 陕ICP备05006600号 )

GMT+8, 2024-3-28 22:41 , Processed in 0.123229 second(s), 22 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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