Code:
function vendorItemsLimited(_items) {
var _pbags = client.dataModel.model.ent.main.inventory.playerbags;
var _delay = 400;
var _sellCount = 0;
var _classType = unsafeWindow.client.dataModel.model.ent.main.classtype;
var _bagCount = unsafeWindow.client.dataModel.model.ent.main.inventory.playerbags.length;
var _bagUsed = 0;
var _bagUnused = 0;
var _tmpBag = [];
var _profitems = [];
// Pattern for items to leave out of auto vendoring (safeguard)
var _excludeItems =/(Gemfood|Gem_Upgrade_Resource|Artifact|Hoard|Coffer|Fuse|Ward|Preservation|Armor_Enhancement|Weapon_Enhancement|T[5-9]_Enchantment|T[5-9]_Runestones|T10_Enchantment|T10_Runestones|4c_Personal|Item_Potion_Companion_Xp|Gateway_Rewardpack|Consumable_Id_Scroll|Dungeon_Delve_Key)/; // edited by RottenMind 17.01.2015
if (settings["autovendor_profresults"]) {
/** Profession leveling result item cleanup logic for T1-4 crafted results
* Created by RM on 14.1.2015.
* List contains crafted_items, based "Mustex/Bunta NW robot 1.05.0.1L crafting list, can be used making list for items what are "Auto_Vendored".
* Items on list must be checked and tested.
*/
/*#1, Tier3, end list, sell allways all, "TierX" is here "TX" !!*/
/*_profitems[0] = {
pattern : /^Crafted_(Jewelcrafting_Waist_Offense_3|Jewelcrafting_Neck_Defense_3|Jewelcrafting_Waist_Defense_3|Med_Armorsmithing_T3_Chain_Armor_Set_1|Med_Armorsmithing_T3_Chain_Pants2|Med_Armorsmithing_T3_Chain_Shirt2|Med_Armorsmithing_T3_Chain_Helm_Set_1|Med_Armorsmithing_T3_Chain_Pants|Med_Armorsmithing_T3_Chain_Boots_Set_1|Hvy_Armorsmithing_T3_Plate_Armor_Set_1|Hvy_Armorsmithing_T3_Plate_Pants2|Hvy_Armorsmithing_T3_Plate_Shirt2|Hvy_Armorsmithing_T3_Plate_Helm_Set_1|Hvy_Armorsmithing_T3_Plate_Boots_Set_1|Leatherworking_T3_Leather_Armor_Set_1|Leatherworking_T3_Leather_Pants2|Leatherworking_T3_Leather_Shirt2|Leatherworking_T3_Leather_Helm_Set_1|Leatherworking_T3_Leather_Boots_Set_1|Tailoring_T3_Cloth_Armor_Set_3|Tailoring_T3_Cloth_Armor_Set_2|Tailoring_T3_Cloth_Armor_Set_1|Tailoring_T3_Cloth_Pants2_Set2|Tailoring_T3_Cloth_Shirt2|Tailoring_T3_Cloth_Helm_Set_1|Artificing_T3_Pactblade_Temptation_5|Artificing_T3_Icon_Virtuous_5|Weaponsmithing_T3_Dagger_4)$/,
limit : 0,
count : 0
};*/ // moved to selljunk filter, RottenMind
/*#2, Tier2 - tier3 mixed, upgrade, sell if inventory full, "TierX" is here "TX" */
_profitems[1] = {
pattern : /^Crafted_(Jewelcrafting_Neck_Misc_2|Jewelcrafting_Waist_Misc_2|Med_Armorsmithing_T3_Chain_Pants|Med_Armorsmithing_T3_Chain_Shirt|Hvy_Armorsmithing_T3_Plate_Pants|Hvy_Armorsmithing_T3_Plate_Shirt|Leatherworking_T3_Leather_Pants|Leatherworking_T3_Leather_Shirt|Tailoring_T3_Cloth_Shirt|Tailoring_T3_Cloth_Pants||Artificing_T3_Pactblade_Temptation_4|Artificing_T3_Icon_Virtuous_4|Weaponsmithing_T2_Dagger_3|Weaponsmithing_T2_Dagger_3)$/,
limit : 0,
count : 0
};
/*#3, Tier2, upgrade, sell if inventory full, "TierX" is here "TX" */
_profitems[2] = {
pattern : /^Crafted_(Jewelcrafting_Neck_Offense_2|Jewelcrafting_Waist_Offense_2|Med_Armorsmithing_T2_Chain_Armor_Set_1|Med_Armorsmithing_T2_Chain_Pants_2|Med_Armorsmithing_T2_Chain_Boots_Set_1|Med_Armorsmithing_T2_Chain_Shirt_2|Med_Armorsmithing_T2_Chain_Pants_1|Med_Armorsmithing_T2_Chain_Shirt|Hvy_Armorsmithing_T2_Plate_Armor_Set_1|Hvy_Armorsmithing_T2_Plate_Pants_2|Hvy_Armorsmithing_T2_Plate_Boots_Set_1|Hvy_Armorsmithing_T2_Plate_Shirt_2|Hvy_Armorsmithing_T2_Plate_Pants_1|Hvy_Armorsmithing_T2_Shield_Set_1|Hvy_Armorsmithing_T2_Plate_Shirt|Leatherworking_T2_Leather_Shirt|Leatherworking_T2_Leather_Boots_Set_1|Leatherworking_T2_Leather_Shirt_2|Leatherworking_T2_Leather_Pants_1|Leatherworking_T2_Leather_Armor_Set_1|Leatherworking_T2_Leather_Pants_2|Tailoring_T2_Cloth_Armor_Set_1|Tailoring_T2_Cloth_Pants_2|Tailoring_T2_Cloth_Boots_Set_1|Tailoring_T2_Cloth_Shirt_2|Tailoring_T2_Cloth_Pants_1|Artificing_T2_Pactblade_Temptation_3|Artificing_T1_Icon_Virtuous_2|Weaponsmithing_T2_Dagger_2)$/,
limit : 0,
count : 0
};
/*#4, Tier1, upgrade, sell if inventory full, "TierX" is here "TX" */
_profitems[3] = {
pattern : /^Crafted_(Jewelcrafting_Neck_Misc_1|Jewelcrafting_Waist_Misc_1|Med_Armorsmithing_T1_Chain_Armor_Set_1|Med_Armorsmithing_T1_Chain_Boots_Set_1|Hvy_Armorsmithing_Plate_Armor_1|Hvy_Armorsmithing_T1_Plate_Armor_Set_1|Hvy_Armorsmithing_T1_Plate_Boots_Set_1|Leatherworking_T1_Leather_Boots_Set_1|Leatherworking_T1_Leather_Boots_Set_1|Leatherworking_T1_Leather_Armor_Set_1|Tailoring_T1_Cloth_Armor_1|Tailoring_T1_Cloth_Pants_1|Tailoring_T1_Cloth_Boots_Set_1|Artificing_T1_Pactblade_Convergence_2|Artificing_T1_Icon_Virtuous_2|Weaponsmithing_T1_Dagger_1)$/,
limit : 0,
count : 0
};
/*#5, Tier0, upgrade, sell if inventory full, taskilist "Tier1" is here "empty" or "_" must replace (_T1_|_)*/
_profitems[4] = {
pattern : /^Crafted_(Jewelcrafting_Waist_Offense_1|Jewelcrafting_Neck_Offense_1|Med_Armorsmithing_Chain_Boots_1|Med_Armorsmithing_Chain_Shirt_1|Med_Armorsmithing_Chain_Armor_1|Med_Armorsmithing_Chain_Pants_1|Hvy_Armorsmithing_Plate_Boots_1|Hvy_Armorsmithing_Plate_Shirt_1|Hvy_Armorsmithing_Shield_1|Leatherworking_Tier0_Intro_1|Leatherworking_Leather_Boots_1|Leatherworking_Leather_Shirt_1|Leatherworking_Leather_Armor_1|Leatherworking_Leather_Pants_1|Tailoring_Cloth_Boots_1|Tailoring_Cloth_Shirt_1|Artificing_T1_Pactblade_Convergence_1|Artificing_Icon_Virtuous_1|Artificing_Symbol_Virtuous_1|Weaponsmithing_Dagger_1)$/,
limit : 0,
count : 0
};
}
$.each(_pbags, function (bi, bag) {
bag.slots.forEach(function (slot) {
// Match unused slots
if (slot === null || !slot || slot === undefined) {
_bagUnused++;
}
// Match items to exclude from auto vendoring, dont add to _tmpBag: Exclude pattern list - bound - Epic Quality - Blue Quality
else if ( _excludeItems.test(slot.name) || slot.bound || slot.rarity == "Special" || slot.rarity == "Gold") {
_bagUsed++;
}
// Match everything else
else {
if (settings["autovendor_profresults"]) {
for (i = 1; i < _profitems.length; i++) {
if (_profitems[i].pattern.test(slot.name))
_profitems[i].count++;
}
}
_tmpBag[_tmpBag.length] = slot;
_bagUsed++;
}
});
});
if (settings["autovendor_profresults"]) {
_tmpBag.forEach(function (slot) {
for (i = 1; i < _profitems.length; i++) { // edited by RottenMind
if (slot && _profitems[i].pattern.test(slot.name) && !slot.bound && _profitems[i].count > 3 && Inventory_bagspace() <= 7 ) { // edited by RottenMind
var vendor = {
vendor : "Nw_Gateway_Professions_Merchant"
};
vendor.id = slot.uid;
vendor.count = 1;
console.log('Selling', vendor.count, slot.name, 'to vendor.');
window.setTimeout(function () {
client.sendCommand('GatewayVendor_SellItemToVendor', vendor);
}, _delay);
_profitems[i].count--;
break;
}
}
});
}
_tmpBag.forEach(function (slot) {
for (i = 1; i < _items.length; i++) { // edited by RottenMind
var _Limit = (parseInt(_items[i].limit) > 99) ? 99 : _items[i].limit;
if (slot && _items[i].pattern.test(slot.name) && !slot.bound) {
// Node Kits vendor logic for restricted bag space
if (settings["autovendor_kits"]) {
if ( _bagCount < 2 || _bagUnused < 6 ||
(slot.name == "Item_Consumable_Skill_Dungeoneering" && (_classType == "Player_Guardian" || _classType == "Player_Greatweapon")) ||
(slot.name == "Item_Consumable_Skill_Arcana" && (_classType == "Player_Controller" || _classType == "Player_Scourge")) ||
(slot.name == "Item_Consumable_Skill_Religion" && _classType == "Player_Devoted") ||
(slot.name == "Item_Consumable_Skill_Thievery" && _classType == "Player_Trickster") ||
(slot.name == "Item_Consumable_Skill_Nature" && _classType == "Player_Archer")
) {
_Limit = 0;
}
}
// Sell Items
if (slot.count > _Limit) {
_sellCount++;
var vendor = {
vendor: "Nw_Gateway_Professions_Merchant"
};
vendor.id = slot.uid;
vendor.count = slot.count - _Limit;
console.log('Selling', vendor.count, slot.name, 'to vendor.');
window.setTimeout(function () {
client.sendCommand('GatewayVendor_SellItemToVendor', vendor);
}, _delay);
_delay = _delay + 400;
break;
}
}
}
});
return _sellCount;
}