|
本帖最后由 loveqiao361 于 2019-1-10 09:35 编辑
首先要分析清楚Cubing中的逻辑,特别是与town中动作的关联。我的方法是添加Cubing的Recipe以达到目的,再在town中增加回收药剂的需求检测进行购买,购买后更新Cubing的需求情况。这里列出3种回收:单件暗金,单件套装,两件套装。
Cubing在人物config中主要是以物品classid的形式进行设置。
由于Cubing.init()这个function,用户也可以通过写对应classid的字符串达到config中设置的目的。
首先添全局变量Recipe中的属性,也就是作者思路中的Recipe.Index:
- Recycle: {
- Unique: 56,
- Set: 57,
- SetDouble: 58
- }
复制代码 然后在Cubing.buildRecipe这个function下加入我们的Recipe,这里以溶解药剂(classid = 517)为例:
- case Recipe.Recycle.Unique:
- this.recipes.push({Ingredients: [Config.Recipes[i][1], 517], Index: Recipe.Recycle.Unique});
- break;
-
- case Recipe.Recycle.Set:
- this.recipes.push({Ingredients: [Config.Recipes[i][1], 517], Index: Recipe.Recycle.Set});
- break;
- case Recipe.Recycle.SetDouble:
- this.recipes.push({Ingredients: [Config.Recipes[i][1], Config.Recipes[i][2], 517], Index: Recipe.Recycle.SetDouble});
- break;
复制代码
重头戏:Cubing.validItem()和Cubing.buildLists()
先说说Cubing.buildLists() 这里加的不多,主要是给两件套装的回收增加回收药剂通过validItem的条件。
将:- this.recipes[i].Enabled = true;
复制代码
上方的if判断条件改变,如下:
- // Enable recipes for gem/jewel pickup
- if ((this.recipes[i].Index !== Recipe.Rune && this.recipes[i].Index <= Recipe.Recycle.Set)
- || (this.recipes[i].Index === Recipe.Rune && j >= 1) ||
- (this.recipes[i].Index === Recipe.Recycle.SetDouble && j >= 1)
- ) { // Enable rune recipe after 2 bases are found
- this.recipes[i].Enabled = true;
- }
复制代码
这样就完成了,然后看validItem()
根据作者的方式,在根据Index作判断之前加上:
- if (unit.itemType === 81 || unit.classid === 517) {
- if (recipe.Enabled){
- return true;
- }
- return false;
- }
复制代码
然后根据Index来做判断,首先是单件暗金,不符合nip需求采取回收,由于单件暗金戒指与项链比较特殊,这里分别给了一个例子,乌鸦之霜和大君之怒:- if (recipe.Index === Recipe.Recycle.Unique) {
- if (unit.quality === 7 && NTIP.CheckItem(unit) === 0){
- switch(unit.classid){//Judge whether it can be recycled
- case 522: //Unique ring
- //Raven Fros
- return unit.getStat(2) >= 15 && unit.getStat(19) >= 15;
-
- case 520: //amulet
- //Highlord's Wrah
- return unit.getStat(41) == 35 && unit.getStat(93) == 2;
- }
- return true;
- }
- return false;
- }
复制代码 单件套装与单件暗金同理:
- if (recipe.Index === Recipe.Recycle.Set) {
- if (unit.quality === 5 && NTIP.CheckItem(unit) === 0){
- return true;
- }
- return false;
- }
复制代码
然后是两件套装,由于Cubing的特性,只会一组一组做,所以这里采取不同的方式,达到nip需求才采取回收,这样就会留下所有两件套装中的物品。
如需留下高品质物品,则在函数下写出筛选函数,这里给一个NEC绿头的例子:
- if (recipe.Index === Recipe.Recycle.SetDouble) {
- if (unit.quality === 5 && NTIP.CheckItem(unit) === 1){
- switch(unit.classid){//Judge whether it is good to keep
- case 465: //Set BoneVisage(NEC HELM)
- //Best:[defense] == 257
- return unit.getStat(31) < 257 && NTIP.CheckItem(unit) === 1;
- }
- return true;
- }
- return false;
- }
复制代码
这里要注意,如需做筛选留下高品质物品,nip中需写出至少一个stat的最低要求保证鉴定,这样才能进行筛选。我的做法是加了一条[defense] >= 最低防御。
这样Cubing基本就完成了,先来看Town。
首先在Town.doChores的this.identify()后加上:
于是在Town对象中建立函数:
- buyRecyclePotion: function(){
- if(Cubing.checkRecycle() > 0){
- var i, npc, thawing;
-
- if (me.act === 3) {
- this.goToTown(Pather.accessToAct(4) ? 4 : 2);
- }
- if (!this.initNPC("Key", "buyRecyclePotion")) {
- return false;
- }
- npc = getInteractedNPC();
- if (!npc || !npc.itemcount) {
- return false;
- }
- thawing = npc.getItem(517);
-
- for(i=0; i<Cubing.checkRecycle(); i+=1){
- if (thawing && Storage.Inventory.CanFit(thawing)) {
- try {
- thawing.buy();
- } catch (e1) {
- print(e1);
- // Couldn't buy the tome, don't spam the scrolls
- return false;
- }
- } else {
- break;
- }
- }
- Cubing.update();
- }
- return true;
- },
复制代码 如果你好奇为什么init中的Task是"Key",建议你去看一下游戏中卖溶解药剂的NPC……
最后在Cubing中建立获取溶解药剂的数量需求函数即可:
- checkRecycle:function (){
- var i, sum = 0;
- for (i = 0; i < this.neededIngredients.length; i += 1) {
- if(this.neededIngredients[i].classid === 517){
- sum = sum+1;
- }
- }
-
- return sum;
- },
复制代码
人物设置部分不用多说,给一个unique shako的例子:- //暗金军帽
- Config.Recipes.push([Recipe.Recycle.Unique, "Shako"]);
复制代码
done.
|
|