Zynava Posted October 25, 2021 Share Posted October 25, 2021 (edited) Do you like my free scripts? Please show your support and Buy Me a Coffee! ☕ Hi, first script here. 🙂 Originally written by Edwardino, but with a few improvements. See the top comments "CHANGES" in the code for main features. HOW TO USE: Have the equal desired amount of Cosmic Runes in your inventory & the equal amount of the items you need enchanting in your bank before starting the script. * Change these lines to match the object being enchanted & the enchanted item: public String itemToBeEnchanted = "Emerald amulet"; public String enchantedItem = "Amulet of defence"; * Change this method to establish which enchantment level you're working with: public void CAST_ENCHANT() { Time.sleep(500, 100, () -> myMagicBook().cast(Spell.Modern.LEVEL_2_ENCHANT)); // Example: Spell.Modern.LEVEL_3_ENCHANMENT for Lv-3 Enchant } CODE: import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.ItemWidget; import com.epicbot.api.shared.methods.*; import com.epicbot.api.shared.model.Spell; import com.epicbot.api.shared.script.LoopScript; import com.epicbot.api.shared.script.ScriptManifest; import com.epicbot.api.shared.util.time.Time; @ScriptManifest(name = "Improved Enchanter by Zynava", gameType = GameType.OS) public class ImprovedEnchanter extends LoopScript { /** * * THIS BOT IS BUILT FOR ENCHANTING LV-1 - LV-4 * However... While it doesn't track the other runes for higher level enchantments, it will still work if you have them. * * CREDITS: * Original script author -> Edwardino * Improvement author -> Zynava * * CHANGES: * - Improved readability of code * - Easy-to-alter items being enchanted via script * * See 'itemToBeEnchanted', 'enchantedItem' & 'CAST_ENCHANT()' below * - Grouped relevant methods together, labeled. * - Added sleep methods to reduce the amount of buggy clicks **/ // CHANGE THESE TO WHATEVER YOU'RE WORKING WITH public String itemToBeEnchanted = "Emerald amulet"; public String enchantedItem = "Amulet of defence"; public String COSMIC_RUNES = "Cosmic rune"; public void CAST_ENCHANT() { Time.sleep(500, 100, () -> myMagicBook().cast(Spell.Modern.LEVEL_2_ENCHANT)); } // BEGIN METHODS FOR NESTED REFERENCES public IClientAPI myClient() {return getAPIContext().client();} public IBankAPI myBank() {return getAPIContext().bank();} public IInventoryAPI myInventory() {return getAPIContext().inventory();} public IMagicAPI myMagicBook() {return getAPIContext().magic();} public IGameAPI myGame() {return getAPIContext().game();} public IScriptAPI myScript() {return getAPIContext().script();} // END METHODS FOR NESTED REFERENCES /********************************************************** *********************BANKING METHODS********************** **********************************************************/ // Do I need to bank? (Checks for necessary supplies in inventory) public boolean botNeedsToBank() { boolean doesHaveSupplies = !myInventory().contains(COSMIC_RUNES) || !myInventory().contains(itemToBeEnchanted); return doesHaveSupplies; } // Do I need to OPEN the bank? public boolean needsToOpenBank() { return !myBank().isOpen(); } // Open the bank public void openBank() { System.out.println("Opening bank."); myBank().open(); } // Close the bank public void closeBank() { System.out.println("Closing bank."); myBank().close(); } // Do I need to deposit? public boolean shouldDeposit() { return myInventory().getCount(enchantedItem) > 0; } // Deposit all items except runes public void depositEnchantedItems() { System.out.println("Depositing enchanted items."); myBank().depositAll(enchantedItem); } // Can withdraw more of the item I'm enchanting? public boolean shouldWithdraw() { return myInventory().getCount(itemToBeEnchanted) == 0 && myBank().getCount(itemToBeEnchanted) > 0; } // Withdraw items public void withdrawItems() { System.out.println("Withdrawing items to be enchanted."); myBank().withdraw(27, itemToBeEnchanted); } /********************************************************** *********************ENCHANTING METHODS******************* **********************************************************/ // Should I begin enchanting? public boolean shouldEnchant() { boolean hasSupplies = myInventory().contains(itemToBeEnchanted) && myInventory().contains(COSMIC_RUNES); return hasSupplies; } // Begin enchanting public void enchantItem() { System.out.println("Enchanting..."); CAST_ENCHANT(); ItemWidget item = myInventory().getItem(itemToBeEnchanted); if(item != null) { item.interact(); Time.sleep(1000); } } @Override public boolean onStart(String... strings) { System.out.print("Starting Improved Enchanter script..."); return true; } @Override protected int loop() { if(!myClient().isLoggedIn()) { System.out.println("Please wait until you are logged in."); } // First checks supplies & if bank needs to be opened if(botNeedsToBank() && needsToOpenBank()) { openBank(); } // If bank is open: // Deposits and/or Withdraws as needed // Closes bank after // If there's no more to withdraw // Close bank, logout, end script if(myBank().isOpen()) { if(shouldDeposit()) { depositEnchantedItems(); } if(shouldWithdraw()) { withdrawItems(); closeBank(); Time.sleep(1000); } else { closeBank(); myGame().logout(); Time.sleep(800); myScript().stop("Script stopping..."); } } // Enchants if there's items needing to be enchanted if(shouldEnchant()) { enchantItem(); } return 200; } } Edited November 8, 2021 by Zynava Needed to edit title to express that it's Open Source. 2 Quote Link to comment Share on other sites More sharing options...
Sellout Posted October 25, 2021 Share Posted October 25, 2021 Nice one ❤️ Quote Link to comment Share on other sites More sharing options...
Zynava Posted October 25, 2021 Author Share Posted October 25, 2021 1 hour ago, Sellout said: Nice one ❤️ Thanks man! I had a lot of fun with this one. More to come... Quote Link to comment Share on other sites More sharing options...
Sellout Posted October 27, 2021 Share Posted October 27, 2021 Can't wait to see more 😄 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.