Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**************************************************************************************************************************************************************************************************************/
- // Battle INF item handler
- // Author: Thommas
- // version 3.3
- /**************************************************************************************************************************************************************************************************************/
- //User settings
- var die = 0; //Items of this rarity and lower will be crafted together mindlessly and then sold 0 to disable
- var beCareful = 0; //Items of this rarity will be crafted together with items of the same rarity and name/subclass 0 to disable
- var itsDangerousAlone = 0; //Items of this rarity will be crafted together with items of the same rarity and name/subclass 0 to disable
- var sellDezeNuts = 0; //Items of this rarity and lower will be sold if no other action is assigned to them 0 to disable
- var timeOut = 5; //Notification timeout. 5 is default
- var getOld = 0; //If 3, will attempt to age ALL items, inventory AND equipment. If 2, will attempt to age items equipped. If 1 will attempt to age ALL items in inventory. 0 to disable
- //Settings be done
- /**************************************************************************************************************************************************************************************************************/
- //Functions start here
- //New item related functions
- //Grind new item with item in inventory. Both must be of equal or lower rarity than defined by variable die
- var grind = function(item)
- {
- //Cycles through items in inventory
- for (var i = 0; i < ScriptAPI.$user.inventory.items.length; i++)
- {
- //If current item matches requirements
- if ((ScriptAPI.$user.inventory.items[i] != item) && (ScriptAPI.$user.inventory.items[i].rarity <= die) && !ScriptAPI.$user.inventory.items[i].lock)
- {
- //Then items will be grinded and notification
- API.notifications.create("♺ " + ScriptAPI.$user.inventory.items[i].name + " ☆" + ScriptAPI.$user.inventory.items[i].rarity + " ↔ " + item.name + " ☆" + item.rarity + ".", timeOut);
- ScriptAPI.$craftingService.craftItems(ScriptAPI.$user.inventory.items[i], item);
- ScriptAPI.$userService.sellItem(ScriptAPI.$user.inventory.items[i]);
- //Item has been processed. Script needs not run other new item related functions. By returning true, var done = true
- return true;
- }
- }
- }
- //Merge new item with item in inventory. Both must be of the same rarity and have the same name. E.g. Sword, or Armor
- var merge = function(item)
- {
- //Cycles through items in inventory
- for (var i = 0; i < ScriptAPI.$user.inventory.items.length; i++) //Cycles through items in inventory
- {
- //If current item matches requirements
- if ((ScriptAPI.$user.inventory.items[i] != item) && (ScriptAPI.$user.inventory.items[i].rarity == item.rarity) && (ScriptAPI.$user.inventory.items[i].name == item.name) && (ScriptAPI.$user.inventory.items[i].plus + item.plus < (5*item.rarity+5)) && !ScriptAPI.$user.inventory.items[i].lock)
- {
- //Then items will be merged and notification. Note that time stampt is not required. Script is triggered by item drop, as such the new item will always be newer than the item selected in the inventory
- API.notifications.create("✦ " + ScriptAPI.$user.inventory.items[i].name + "☆" + ScriptAPI.$user.inventory.items[i].rarity + "+" + ScriptAPI.$user.inventory.items[i].plus + " ↔ " + item.name + " ☆" + item.rarity + ".", timeOut);
- ScriptAPI.$craftingService.craftItems(ScriptAPI.$user.inventory.items[i], item);
- //Item has been processed. Script needs not run other new item related functions. By returning true, var done = true
- return true;
- }
- }
- }
- //Sells item
- var sell = function(item)
- {
- //Sells item and notification
- API.notifications.create("☄ " + item.name + " ☆" + item.rarity + ".", timeOut);
- ScriptAPI.$userService.sellItem(item);
- //Item has ben processed. Script needs not run other new item related functions. By returning true, var done = true
- return true;
- }
- //Triggered when no other new item related function was run
- var keep = function(item)
- {
- //Notification
- API.notifications.create("❤ " + item.name + " ☆" + item.rarity + ".", timeOut);
- //With this, new item has been processed. This is the new item related function which runs last, returns true, new item handling is done
- return true;
- }
- //New item related functions end
- //Function which ages items
- var ageing = function(setting)
- {
- //Determining what to do
- //If setting 1 or 3, age ALL items in inventory
- if (setting == 1 || setting == 3)
- {
- //Cycle through items in inventory
- for (var i = 0; i < ScriptAPI.$user.inventory.items.length; i++)
- {
- //Ageing up item
- ScriptAPI.$craftingService.ageUpItem(ScriptAPI.$user.inventory.items[i]);
- }
- }
- //If setting 2 or 3, age items currently equipped
- if (setting == 2 || setting == 3)
- {
- //Cycle through items currently equipped
- for (var i = 0; i < ScriptAPI.$user.character.equipment.length; i++)
- {
- //Ageing up item
- ScriptAPI.$craftingService.ageUpItem(ScriptAPI.$user.character.equipment[i]);
- }
- }
- }
- //No more functions
- //Function triggers start here
- //Loops equal amount of items received, as such script can handle any amount of items
- for (var i = 0; i < items.length; i++)
- {
- //var newItemDone equals true when new item has been processed. No other new item related function will be run then
- var newItemDone = false;
- //Check if item meets requirements for grinding
- if (items[i].rarity <= die) {
- newItemDone = grind(items[i]); }
- //Checks if item meets requirements for merging
- if (!newItemDone && ((items[i].rarity == beCareful) || (items[i].rarity == itsDangerousAlone))) {
- newItemDone = merge(items[i]); }
- //Checks if item meets requirements for selling
- if (!newItemDone && (items[i].rarity <= sellDezeNuts)) {
- newItemDone = sell(items[i]); }
- //If no function has been run, item will be kept
- if (!newItemDone) {
- newItemDone = keep(items[i]); }
- }
- //Triggers item ageing function
- if (getOld > 0) {
- ageing(getOld); }
- //No more function triggers
- /*
- *****************************************************************Changelog*****************************************************************
- Version 3.3
- Fixed attempt to merge/grind locked items
- Version 3.2
- Added automagic item ageing
- Adjusted comments
- Note: Automagic ageing appears to be quite resource intensive. I myself experience a small stutter whenever it cycles through 80+ items.
- Version 3.1:
- Added changelog
- Added notification timeout variable
- *****************************************************************Changelog*****************************************************************
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement